diff --git a/README.md b/README.md index e6287e39d..92f25dd44 100644 --- a/README.md +++ b/README.md @@ -1,134 +1,81 @@ -What is PDC? -============ - -Proactive Data Containers (PDC) is a Novel data abstraction for storing data in an -object-centric manner, where data objects are first-class citizens. - -Visit https://sdm.lbl.gov/pdc for full details and publications discussing the -PDC concepts and designs. The remainder of this README discusses software dependencies -and installation. - - -Required libraries -====== -1 libfabric -```sh - Download libfabric library from https://ofiwg.github.io/libfabric/ - Compile and install following the instructions from https://github.com/ofiwg/libfabric +## Installation for PDC +This instruction is for installing PDC on Linux and Cray machines. Make sure you have GCC version at least 7 and MPI installed before you proceed. +For MPI, the recommended version is MPICH. Follow the procedures in https://www.mpich.org/static/downloads/3.4.1/mpich-3.4.1-installguide.pdf +PDC depends on libfabric and mercury. We are going to install libfabric, mercury, and PDC step by step. +Make sure you record the environmental variables (lines that contains the export commands). They are needed for running PDC and make the libraries again. +# Install libfabric ``` - -2 Mercury -```sh - git clone https://github.com/mercury-hpc/mercury && cd mercury - git submodule update --init - mkdir build - cd build - ccmake .. (where ".." is the relative path to the mercury-X directory) +0. wget https://github.com/ofiwg/libfabric/archive/v1.11.2.tar.gz +1. tar xvzf v1.11.2.tar.gz +2. cd libfabric-1.11.2 +3. mkdir install +4. export LIBFABRIC_DIR=$(pwd)/install +5. ./autogen.sh +6. ./configure --prefix=$LIBFABRIC_DIR CC=gcc CFLAG="-O2" +7. make -j8 +8. make install +9. export LD_LIBRARY_PATH="$LIBFABRIC_DIR/lib:$LD_LIBRARY_PATH" +10. export PATH="$LIBFABRIC_DIR/include:$LIBFABRIC_DIR/lib:$PATH" ``` - -Type 'c' multiple times and choose suitable options. Recommended options are: - - BUILD_SHARED_LIBS ON (or OFF if the library you link - against requires static libraries) - BUILD_TESTING ON - CMAKE_INSTALL_PREFIX /path/to/install/directory - MERCURY_ENABLE_PARALLEL_TESTING OFF (ON requires running on HPC compute nodes) - MERCURY_USE_BOOST_PP OFF - MERCURY_USE_XDR OFF - MERCURY_USE_OPA OFF - NA_USE_BMI OFF - NA_USE_OFI ON - NA_USE_MPI OFF - NA_USE_CCI OFF - NA_USE_SM OFF - - OFI_INCLUDE_DIR LIBFABRIC_PATH/include - OFI_LIBRARY LIBFABRIC_PATH/libbmi.so - - CMAKE_C_FLAGS for both FLAGS, add -dynamic on NERSC machines - CMAKE_CXX_FLAGS if there you see errors: "/usr/bin/ld: attempted - static link of dynamic object `../bin/libmercury_hl.so' " - - -Setting include directory and library paths may require you to toggle to -the advanced mode by typing 't'. Once you are done and do not see any -errors, type 'g' to generate makefiles. Once you exit the CMake -configuration screen and are ready to build the targets, do: - - make - -To test Mercury is successfully built, run - - make test - -Look for Test #1: mercury_rpc_ofi_tcp, Test #2: mercury_bulk_ofi_tcp, etc. - -3 BMI (Optional) -```sh - git clone git://git.mcs.anl.gov/bmi && cd bmi - # If you are building BMI on an OSX platform, then apply the following patch: - # patch -p1 < patches/bmi-osx.patch - ./prepare && ./configure --enable-shared --enable-bmi-only - make && make install +# Install mercury +Make sure the ctest passes. Otherwise PDC will not work. +Step 2 is not required. It is a stable commit I am using when I write this instruction. You may skip it if you believe the current master branch of mercury works. ``` - -4 CCI (Optional) -```sh - git clone https://github.com/CCI/cci && cd cci - ./autogen.pl - ./configure (on Cori add --without-verbs for successful make) - make && make install +0. git clone https://github.com/mercury-hpc/mercury.git +1. cd mercury +2. git checkout e741051fbe6347087171f33119d57c48cb438438 +3. git submodule update --init +4. export MERCURY_DIR=$(pwd)/install +5. mkdir install +6. cd install +7. cmake ../ -DCMAKE_INSTALL_PREFIX=$MERCURY_DIR -DCMAKE_C_COMPILER=gcc -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=ON -DNA_USE_OFI=ON -DNA_USE_SM=OFF +8. make +9. make install +10. ctest +11. export LD_LIBRARY_PATH="$MERCURY_DIR/lib:$LD_LIBRARY_PATH" +12. export PATH="$MERCURY_DIR/include:$MERCURY_DIR/lib:$PATH" ``` - - -Building -==== - git clone git@bitbucket.org:berkeleylab/pdc.git - cd pdc/src - mkdir build - cd build - ccmake .. (where ".." is the relative path to the PDC directory) - -Similar to previous Mercury building process, type 'c' multiple times and choose -suitable options, and toggle to advanced mode by typing 't'. Recommended options are: - - BUILD_SHARED_LIBS ON (or OFF if the library you link - against requires static libraries) - CFLAGS -dynamic (this is required on NERSC machines) - ENABLE_CHECKPOINT ON (or OFF if no metadata checkpoint is needed) - ENABLE_LUSTRE ON - ENABLE_MPI ON (or OFF if only used in serial mode) - ENABLE_MULTITHREAD OFF - ENABLE_TIMING OFF (or ON to enable PDC timer) - - -Once you are done and do not see any errors, type 'g' to generate makefiles. -Once you exit the CMake configuration screen and are ready to build the targets, do: - - make - - -Testing -==== -On NERSC machines (e.g. Cori), do the following: ----- -* Job allocation (e.g. use 4 nodes) -```sh - salloc -C haswell -N 4 -t 01:00:00 -q interactive --gres=craynetwork:2 +# Install PDC +You can replace mpicc to whatever MPI compilers you are using. For example, on Cori, you may need to use cc. +The ctest contains both sequential and MPI tests for our settings. These regression tests should work. ``` -Run PDC create object test ----- -* Set pdc temporary directory for server config file and checkpoint file (optional, if not set, the server and client will create and write/read under ./pdc_tmp) -```sh - export PDC_TMPDIR=/path/to/the/pdc/tmp/dir +0. git clone https://github.com/hpc-io/pdc.git +1. cd pdc +2. git checkout qiao_develop +3. cd src +4. mkdir install +5. cd install +6. export PDC_DIR=$(pwd) +7. cmake ../ -DBUILD_MPI_TESTING=ON -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=ON -DCMAKE_INSTALL_PREFIX=$PDC_DIR -DPDC_ENABLE_MPI=ON -DMERCURY_DIR=$MERCURY_DIR -DCMAKE_C_COMPILER=mpicc +8. make +9. make -j8 +10. ctest ``` -* Run 4 server processes, each on one node in background: -```sh - srun -N 4 -n 4 -c 2 --mem=25600 --cpu_bind=cores --gres=craynetwork:1 ./bin/pdc_server.exe & +# Environmental variables +During installation, we have set some environmental variables. These variables will disappear when you close the current shell. +I recommend adding the following lines to ~/.bashrc. (you can also manually execute them when you login). +The MERCURY_DIR and LIBFABRIC_DIR should be identical to the values you set during your installations of Mercury and Libfabric. +Remember, the install path is the path containing bin and lib directory, instead of the one containing source code. ``` - -* Run 64 client processes that concurrently create 1000 objects in total: -```sh - srun -N 4 -n 64 -c 2 --mem=25600 --cpu_bind=cores --gres=craynetwork:1 ./bin/create_obj_scale -r 1000 +export PDC_DIR="where/you/installed/your/pdc" +export MERCURY_DIR="where/you/installed/your/mercury" +export LIBFABRIC_DIR="where/you/installed/your/libfabric" +export LD_LIBRARY_PATH="$LIBFABRIC_DIR/lib:$MERCURY_DIR/lib:$LD_LIBRARY_PATH" +export PATH="$LIBFABRIC_DIR/include:$LIBFABRIC_DIR/lib:$MERCURY_DIR/include:$MERCURY_DIR/lib:$PATH" +``` +You can also manage the path with Spack, which is a lot more easier to load and unload these libraries. +## Running PDC +The ctest under PDC install folder runs PDC examples using PDC APIs. +PDC needs to run at least two applications. First, you need to start servers. Then, you can run client programs that send I/O request to servers as mercury RPCs. +For example, you can do the following. On Cori, you need to change the mpiexec argument to srun. On Theta, it is aprun. On Summit, it is jsrun. ``` +cd $PDC_DIR/bin +./mpi_test.sh ./pdc_init mpiexec 2 4 +``` +This is test will start 2 processes for PDC servers. The client program ./pdc_init will start 4 processes. Similarly, you can run any of the client examples in ctest. +These source code will provide you some knowledge of how to use PDC. For more reference, you may check the documentation folder in this repository. +# PDC on Cori. +Installation on Cori is not very different from a regular linux machine. Simply replace all gcc/mpicc with the default cc compiler on Cori. Add options -DCMAKE_C_FLAGS="-dynamic" to the cmake line of PDC. Add -DCMAKE_C_FLAGS="-dynamic" -DCMAKE_CXX_FLAGS="-dynamic" at the end of the cmake line for mercury as well. Finally, "-DMPI_RUN_CMD=srun" is needed for ctest command later. Sometimes you may need to unload darshan before installation. + + diff --git a/docs/readme.md b/docs/readme.md new file mode 100644 index 000000000..62672c16b --- /dev/null +++ b/docs/readme.md @@ -0,0 +1,863 @@ +# PDC Documentations + + [PDC user APIs](#pdc-user-apis) + - [PDC general APIs](#pdc-general-apis) + - [PDC container APIs](#pdc-container-apis) + - [PDC object APIs](#pdc-object-apis) + - [PDC region APIs](#pdc-region-apis) + - [PDC property APIs](#pdc-property-apis) + - [PDC query APIs](#pdc-query-apis) + + [PDC data types](#PDC-type-categories) + - [Basic types](#basic-types) + - [Histogram structure](#histogram-structure) + - [Container info](#container-info) + - [Container life time](#container-life-time) + - [Object property](#object-property) + - [Object info](#object-info) + - [Object structure](#object-structure) + - [Region info](#region-info) + - [Access type](#access-type) + - [Query operators](#query-operators) + - [Query structures](#query-structures) + - [Selection structure](#selection-structure) + + [Developers notes](#developer-notes) +# PDC user APIs + ## PDC general APIs + + pdcid_t PDCinit(const char *pdc_name) + - Input: + + pdc_name is the reference for PDC class. Recommended use "pdc" + - Output: + + PDC class ID used for future reference. + - All PDC client applications must call PDCinit before using it. This function will setup connections from clients to servers. A valid PDC server must be running. + - For developers: currently implemented in pdc.c. + + perr_t PDCclose(pdcid_t pdcid) + - Input: + + PDC class ID returned from PDCinit. + - Ouput: + + SUCCEED if no error, otherwise FAIL. + - This is a proper way to end a client-server connection for PDC. A PDCinit must correspond to one PDCclose. + - For developers: currently implemented in pdc.c. + + perr_t PDC_Client_close_all_server() + - Ouput: + + SUCCEED if no error, otherwise FAIL. + - Close all PDC servers that running. + - For developers: see PDC_client_connect.c + ## PDC container APIs + + pdcid_t PDCcont_create(const char *cont_name, pdcid_t cont_prop_id) + - Input: + + cont_name: the name of container. e.g "c1", "c2" + + cont_prop_id: property ID for inheriting a PDC property for container. + - Output: pdc_id for future referencing of this container, returned from PDC servers. + - Create a PDC container for future use. + - For developers: currently implemented in pdc_cont.c. This function will send a name to server and receive an container id. This function will allocate necessary memories and initialize properties for a container. + + pdcid_t PDCcont_create_col(const char *cont_name, pdcid_t cont_prop_id) + - Input: + + cont_name: the name to be assigned to a container. e.g "c1", "c2" + + cont_prop_id: property ID for inheriting a PDC property for container. + - Output: pdc_id for future referencing. + - Exactly the same as PDCcont_create, except all processes must call this function collectively. Create a PDC container for future use collectively. + - For developers: currently implemented in pdc_cont.c. + + pdcid_t PDCcont_open(const char *cont_name, pdcid_t pdc) + - Input: + + cont_name: the name of container used for PDCcont_create. + + pdc: PDC class ID returned from PDCinit. + - Output: + + error code. FAIL OR SUCCESS + - Open a container. Must make sure a container named cont_name is properly created (registered by PDCcont_create at remote servers). + - For developers: currently implemented in pdc_cont.c. This function will make sure the metadata for a container is returned from servers. For collective operations, rank 0 is going to broadcast this metadata ID to the rest of processes. A struct _pdc_cont_info is created locally for future reference. + + perr_t PDCcont_close(pdcid_t id) + - Input: + + container ID, returned from PDCcont_create. + - Output: + + error code, SUCCESS or FAIL. + - Correspond to PDCcont_open. Must be called only once when a container is no longer used in the future. + - For developers: currently implemented in pdc_cont.c. The reference counter of a container is decremented. When the counter reaches zero, the memory of the container can be freed later. + + struct pdc_cont_info *PDCcont_get_info(const char *cont_name) + - Input: + + name of the container + - Output: + + Pointer to a new structure that contains the container information [See container info](#container-info) + - Get container information + - For developers: See pdc_cont.c. Use name to search for pdc_id first by linked list lookup. Make a copy of the metadata to the newly malloced structure. + + perr_t PDCcont_persist(pdcid_t cont_id) + - Input: + + cont_id: container ID, returned from PDCcont_create. + - Output: + + error code, SUCCESS or FAIL. + - Make a PDC container persist. + - For developers, see pdc_cont.c. Set the container life field PDC_PERSIST. + + perr_t PDCprop_set_cont_lifetime(pdcid_t cont_prop, pdc_lifetime_t cont_lifetime) + - Input: + + cont_prop: Container property pdc_id + + cont_lifetime: See [container life time](#container-life-time) + - Output: + + error code, SUCCESS or FAIL. + - Set container life time for a property. + - For developers, see pdc_cont.c. + + pdcid_t PDCcont_get_id(const char *cont_name, pdcid_t pdc_id) + - Input: + + cont_name: Name of the container + + pdc_id: PDC class ID, returned by PDCinit + - Output: + + container ID + - Get container ID by name. This function is similar to open. + - For developers, see pdc_client_connect.c. It will query the servers for container information and create a container structure locally. + + perr_t PDCcont_del(pdcid_t cont_id) + - Input: + + cont_id: container ID, returned from PDCcont_create. + - Output: + + error code, SUCCESS or FAIL. + - Deleta a container + - For developers: see pdc_client_connect.c. Need to send RPCs to servers for metadata update. + + perr_t PDCcont_put_tag(pdcid_t cont_id, char *tag_name, void *tag_value, psize_t value_size) + - Input: + + cont_id: Container ID, returned from PDCcont_create. + + tag_name: Name of the tag + + tag_value: Value to be written under the tag + + value_size: Number of bytes for the tag_value (tag_size may be more informative) + - Output: + + error code, SUCCESS or FAIL. + - Record a tag_value under the name tag_name for the container referenced by cont_id. + - For developers: see pdc_client_connect.c. Need to send RPCs to servers for metadata update. + + perr_t PDCcont_get_tag(pdcid_t cont_id, char *tag_name, void **tag_value, psize_t *value_size) + - Input: + + cont_id: Container ID, returned from PDCcont_create. + + tag_name: Name of the tag + + value_size: Number of bytes for the tag_value (tag_size may be more informative) + - Output: + + tag_value: Pointer to the value to be read under the tag + + error code, SUCCESS or FAIL. + - Retrieve a tag value to the memory space pointed by the tag_value under the name tag_name for the container referenced by cont_id. + - For developers: see pdc_client_connect.c. Need to send RPCs to servers for metadata retrival. + + perr_t PDCcont_del_tag(pdcid_t cont_id, char *tag_name) + - Input: + + cont_id: Container ID, returned from PDCcont_create. + + tag_name: Name of the tag + - Output: + + error code, SUCCESS or FAIL. + - Delete a tag for a container by name + - For developers: see pdc_client_connect.c. Need to send RPCs to servers for metadata update. + + perr_t PDCcont_put_objids(pdcid_t cont_id, int nobj, pdcid_t *obj_ids) + - Input: + + cont_id: Container ID, returned from PDCcont_create. + + nobj: Number of objects to be written + + obj_ids: Pointers to the object IDs + - Output: + + error code, SUCCESS or FAIL. + - Put an array of objects to a container. + - For developers: see pdc_client_connect.c. Need to send RPCs to servers for metadata update. + + perr_t PDCcont_get_objids(pdcid_t cont_id ATTRIBUTE(unused), int *nobj ATTRIBUTE(unused), pdcid_t **obj_ids ATTRIBUTE(unused) ) + TODO: + + perr_t PDCcont_del_objids(pdcid_t cont_id, int nobj, pdcid_t *obj_ids) + - Input: + + cont_id: Container ID, returned from PDCcont_create. + + nobj: Number of objects to be deleted + + obj_ids: Pointers to the object IDs + - Output: + + error code, SUCCESS or FAIL. + - Delete an array of objects to a container. + - For developers: see pdc_client_connect.c. Need to send RPCs to servers for metadata update. + ## PDC object APIs + + pdcid_t PDCobj_create(pdcid_t cont_id, const char *obj_name, pdcid_t obj_prop_id) + - Input: + + cont_id: Container ID, returned from PDCcont_create. + + obj_name: Name of objects to be created + + obj_prop_id: Property ID to be inherited from. + - Output: + + Local object ID + - Create a PDC object. + - For developers: see pdc_obj.c. This process need to send the name of the object to be created to the servers. Then it will receive an object ID. The object structure will inherit attributes from its container and input object properties. + + PDCobj_create_mpi(pdcid_t cont_id, const char *obj_name, pdcid_t obj_prop_id, int rank_id, MPI_Comm comm) + - Input: + + cont_id: Container ID, returned from PDCcont_create. + + obj_name: Name of objects to be created + + rank_id: Which rank ID the object is placed to + + comm: MPI communicator for the rank_id + - Output: + + Local object ID + - Create a PDC object at the rank_id in the communicator comm. This function is a colllective operation. + - For developers: see pdc_mpi.c. If rank_id equals local process rank, then a local object is created. Otherwise we create a global object. The object metadata ID is broadcasted to all processes if a global object is created using MPI_Bcast. + + pdcid_t PDCobj_open(const char *obj_name, pdcid_t pdc) + - Input: + + obj_name: Name of objects to be created + + pdc: PDC class ID, returned from PDCInit + - Output: + + Local object ID + - Open a PDC ID created previously by name. + - For developers: see pdc_obj.c. Need to communicate with servers for metadata of the object. + + perr_t PDCobj_close(pdcid_t obj_id) + - Input: + + obj_id: Local object ID to be closed. + - Output: + + error code, SUCCESS or FAIL. + - Close an object. Must do this after open an object. + - For developers: see pdc_obj.c. Dereference an object by reducing its reference counter. + + struct pdc_obj_info *PDCobj_get_info(pdcid_t obj) + - Input: + + obj_name: Local object ID + - Output: + + object information see [object information](#object-info) + - Get a pointer to a structure that describes the object metadata. + - For developers: see pdc_obj.c. Pull out local object metadata by ID. + + pdcid_t PDCobj_put_data(const char *obj_name, void *data, uint64_t size, pdcid_t cont_id) + - Input: + + obj_name: Name of object + + data: Pointer to data memory + + size: Size of data + + cont_id: Container ID of this object + - Output: + + Local object ID created locally with the input name + - Write data to an object. + - For developers: see pdc_client_connect.c. Nedd to send RPCs to servers for this request. (TODO: change return value to perr_t) + + perr_t PDCobj_get_data(pdcid_t obj_id, void **data, uint64_t *size) + - Input: + + obj_id: Local object ID + + size: Size of data + - Output: + + data: Pointer to data to be filled + + error code, SUCCESS or FAIL. + - Read data from an object. + - For developers: see pdc_client_connect.c. Use PDC_obj_get_info to retrieve name. Then forward name to servers to fulfill requests. + + perr_t PDCobj_del_data(pdcid_t obj_id) + - Input: + + obj_id: Local object ID + - Output: + + error code, SUCCESS or FAIL. + - Delete data from an object. + - For developers: see pdc_client_connect.c. Use PDC_obj_get_info to retrieve name. Then forward name to servers to fulfill requests. + + perr_t PDCobj_put_tag(pdcid_t obj_id, char *tag_name, void *tag_value, psize_t value_size) + - Input: + + obj_id: Local object ID + + tag_name: Name of the tag to be entered + + tag_value: Value of the tag + + value_size: Number of bytes for the tag_value + - Output: + + error code, SUCCESS or FAIL. + - Set the tag value for a tag + - For developers: see pdc_client_connect.c. Need to use PDC_add_kvtag to submit RPCs to the servers for metadata update. + + perr_t PDCobj_get_tag(pdcid_t obj_id, char *tag_name, void **tag_value, psize_t *value_size) + - Input: + + obj_id: Local object ID + + tag_name: Name of the tag to be entered + - Output: + + tag_value: Value of the tag + + value_size: Number of bytes for the tag_value + + error code, SUCCESS or FAIL. + - Get the tag value for a tag + - For developers: see pdc_client_connect.c. Need to use PDC_get_kvtag to submit RPCs to the servers for metadata update. + + perr_t PDCobj_del_tag(pdcid_t obj_id, char *tag_name) + - Input: + + obj_id: Local object ID + + tag_name: Name of the tag to be entered + - Output: + + error code, SUCCESS or FAIL. + - Delete a tag. + - For developers: see pdc_client_connect.c. Need to use PDCtag_delete to submit RPCs to the servers for metadata update. + ## PDC region APIs + + pdcid_t PDCregion_create(psize_t ndims, uint64_t *offset, uint64_t *size) + - Input: + + ndims: Number of dimensions + + offset: Array of offsets + + size: Array of offset length + - Output: + + Region ID + - Create a region with ndims offset/length pairs + - For developers: see pdc_region.c. Need to use PDC_get_kvtag to submit RPCs to the servers for metadata update. + + perr_t PDCregion_close(pdcid_t region_id) + - Input: + + region_id: PDC ID returned from PDCregion_create + - Output: + + None + - Close a PDC region + - For developers: see pdc_region.c. Free offset and size arrays. + + perr_t PDCbuf_obj_map(void *buf, pdc_var_type_t local_type, pdcid_t local_reg, pdcid_t remote_obj, pdcid_t remote_reg) + - Input: + + buf: Memory buffer + + local_type: one of PDC basic types, see [PDC basic types](#basic-types) + + local_reg: Local region ID + + remote_obj: Remote object ID + + remote_reg: Remote region ID + - Output: + + Region ID + - Create a region with ndims offset/length pairs + - For developers: see pdc_region.c. Need to use PDC_get_kvtag to submit RPCs to the servers for metadata update. + + perr_t PDCbuf_obj_unmap(pdcid_t remote_obj_id, pdcid_t remote_reg_id) + - Input: + + remote_obj_id: remote object ID + + remote_reg_id: remote region ID + - Output: + + error code, SUCCESS or FAIL. + - Unmap a region to the user buffer. PDCbuf_obj_map must be called previously. + - For developers: see pdc_region.c. + + perr_t PDCreg_obtain_lock(pdcid_t obj_id, pdcid_t reg_id, pdc_access_t access_type, pdc_lock_mode_t lock_mode) + - Input: + + obj_id: local object ID + + reg_id: local region ID + + access_type: [PDC access type](#access-type) + + lock_mode: PDC_BLOCK or PDC_NOBLOCK + - Output: + + error code, SUCCESS or FAIL. + - Obtain the lock to access a region in an object. + - For developers: see pdc_region.c. + + perr_t PDCreg_release_lock(pdcid_t obj_id, pdcid_t reg_id, pdc_access_t access_type) + - Input: + + obj_id: local object ID + + reg_id: local region ID + + access_type: [PDC access type](#access-type) + - Output: + + error code, SUCCESS or FAIL. + - Release the lock to access a region in an object. + - For developers: see pdc_region.c. +## PDC property APIs + + pdcid_t PDCprop_create(pdc_prop_type_t type, pdcid_t pdcid) + - Input: + + type: one of the followings + ``` + typedef enum { + PDC_CONT_CREATE = 0, + PDC_OBJ_CREATE + } pdc_prop_type_t; + ``` + - pdcid: PDC class ID, returned by PDCInit. + - Output: + + PDC property ID + - Initialize a property structure. + - For developers: see pdc_prop.c. + + perr_t PDCprop_close(pdcid_t id) + - Input: + + id: PDC property ID + - Output: + + error code, SUCCESS or FAIL. + - Close a PDC property after openning. + - For developers: see pdc_prop.c. Decrease reference counter for this property. + + perr_t PDCprop_set_obj_user_id(pdcid_t obj_prop, uint32_t user_id) + - Input: + + obj_prop: PDC property ID (has to be an object) + + user_id: PDC user ID + - Output: + + error code, SUCCESS or FAIL. + - Set the user ID of an object. + - For developers: see pdc_obj.c. Update the user_id field under [object property](#object-property). See developer's note for more details about this structure. + + perr_t PDCprop_set_obj_data_loc(pdcid_t obj_prop, char *loc) + - Input: + + obj_prop: PDC property ID (has to be an object) + + loc: location + - Output: + + error code, SUCCESS or FAIL. + - Set the location of an object. + - For developers: see pdc_obj.c. Update the data_loc field under [object property](#object-property). See developer's note for more details about this structure. + + perr_t PDCprop_set_obj_app_name(pdcid_t obj_prop, char *app_name) + - Input: + + obj_prop: PDC property ID (has to be an object) + + app_name: application name + - Output: + + error code, SUCCESS or FAIL. + - Set the application name of an object. + - For developers: see pdc_obj.c. Update the app_name field under [object property](#object-property). See developer's note for more details about this structure. + + perr_t PDCprop_set_obj_time_step(pdcid_t obj_prop, uint32_t time_step) + - Input: + + obj_prop: PDC property ID (has to be an object) + + time_step: time step + - Output: + + error code, SUCCESS or FAIL. + - Set the time step of an object. + - For developers: see pdc_obj.c. Update the time_step field under [object property](#object-property). See developer's note for more details about this structure. + + perr_t PDCprop_set_obj_tags(pdcid_t obj_prop, char *tags) + - Input: + + obj_prop: PDC property ID (has to be an object) + + tags: tags + - Output: + + error code, SUCCESS or FAIL. + - Set the tags of an object. + - For developers: see pdc_obj.c. Update the tags field under [object property](#object-property). See developer's note for more details about this structure. + + perr_t PDCprop_set_obj_dims(pdcid_t obj_prop, PDC_int_t ndim, uint64_t *dims) + - Input: + + obj_prop: PDC property ID (has to be an object) + + ndim: number of dimensions + + dims: array of dimensions + - Output: + + error code, SUCCESS or FAIL. + - Set the dimensions of an object. + - For developers: see pdc_obj.c. Update the obj_prop_pub->ndim and obj_prop_pub->dims fields under [object property public](#object-property-public). See developer's note for more details about this structure. + + perr_t PDCprop_set_obj_type(pdcid_t obj_prop, pdc_var_type_t type) + - Input: + + obj_prop: PDC property ID (has to be an object) + + type: one of PDC basic types, see [PDC basic types](#basic-types) + - Output: + + error code, SUCCESS or FAIL. + - Set the type of an object. + - For developers: see pdc_obj.c. Update the obj_prop_pub->type field under [object property public](#object-property-public). See developer's note for more details about this structure. + + perr_t PDCprop_set_obj_buf(pdcid_t obj_prop, void *buf) + - Input: + + obj_prop: PDC property ID (has to be an object) + + buf: user memory buffer + - Output: + + error code, SUCCESS or FAIL. + - Set the user memory buffer of an object. + - For developers: see pdc_obj.c. Update the buf field under [object property public](#object-property-public). See developer's note for more details about this structure. + + pdcid_t PDCprop_obj_dup(pdcid_t prop_id) + - Input: + + prop_id: PDC property ID (has to be an object) + - Output: + + a new property ID copied. + - Duplicate an object property + - For developers: see pdc_prop.c. Duplicate the property structure. The ID will be registered with the PDC class. Similar to create and set all the fields. +## PDC query APIs + + pdc_query_t *PDCquery_create(pdcid_t obj_id, pdc_query_op_t op, pdc_var_type_t type, void *value) + - Input: + + obj_id: local PDC object ID + + op: one of the followings, see [PDC query operators](#query-operators) + + type: one of PDC basic types, see [PDC basic types](#basic-types) + + value: constraint value. + - Output: + + a new query structure, see [PDC query structure](#query-structure) + - Create a PDC query. + - For developers, see pdc_query.c. The constraint field of the new query structure is filled with the input arguments. Need to search for the metadata ID using object ID. + + void PDCquery_free(pdc_query_t *query) + - Input: + + query: PDC query from PDCquery_create + - Free a query structure. + - For developers, see pdc_client_server_common.c. + + void PDCquery_free_all(pdc_query_t *root) + - Input: + + root: root of queries to be freed + - Output: + + error code, SUCCESS or FAIL. + - Free all queries from a root. + - For developers, see pdc_client_server_common.c. Recursively free left and right branches. + + pdc_query_t *PDCquery_and(pdc_query_t *q1, pdc_query_t *q2) + - Input: + + q1: First query + + q2: Second query + - Ouput: + + A new query after and operator. + - Perform the and operator on the two PDC queries. + - For developers, see pdc_query.c + + pdc_query_t *PDCquery_or(pdc_query_t *q1, pdc_query_t *q2) + - Input: + + q1: First query + + q2: Second query + - Ouput: + + A new query after or operator. + - Perform the or operator on the two PDC queries. + - For developers, see pdc_query.c + + perr_t PDCquery_sel_region(pdc_query_t *query, struct pdc_region_info *obj_region) + - Input: + + query: Query to select the region + + obj_region: An object region + - Ouput: + + error code, SUCCESS or FAIL. + - Select a region for a PDC query. + - For developers, see pdc_query.c. Set the region pointer of the query structure to the obj_region pointer. + + perr_t PDCquery_get_selection(pdc_query_t *query, pdc_selection_t *sel) + - Input: + + query: Query to get the selection + - Ouput: + + sel: PDC selection defined as the following. This selection describes the query shape, see [PDC selection structure](#selection-structure) + + error code, SUCCESS or FAIL. + - Get the selection information of a PDC query. + - For developers, see pdc_query.c and PDC_send_data_query in pdc_client_connect.c. Copy the selection structure received from servers to the sel pointer. + + perr_t PDCquery_get_nhits(pdc_query_t *query, uint64_t *n) + - Input: + + query: Query to calculate the number of hits + - Ouput: + + n: number of hits + + error code, SUCCESS or FAIL. + - Get the number of hits for a PDC query + - For developers, see pdc_query.c and PDC_send_data_query in pdc_client_connect.c. Copy the selection structure received from servers to the sel pointer. + + perr_t PDCquery_get_data(pdcid_t obj_id, pdc_selection_t *sel, void *obj_data) + - Input: + + obj_id: The object for query + + sel: Selection of the query, query_id is inside it. + - Output: + + obj_data: Pointer to the data memory filled with query data. + - Retrieve data from a PDC query for an object. + - For developers, see pdc_query.c and PDC_Client_get_sel_data in pdc_client_connect.c. + + perr_t PDCquery_get_histogram(pdcid_t obj_id) + - Input: + + obj_id: The object for query + - Output: + + error code, SUCCESS or FAIL. + - Retrieve histogram from a query for a PDC object. + - For developers, see pdc_query.c. This is a local operation that does not really do anything. + + void PDCselection_free(pdc_selection_t *sel) + - Input: + + sel: Pointer to the selection to be freed. + - Output: + + None + - Free a selection structure. + - For developers, see pdc_client_connect.c. Free the coordinates. + + void PDCquery_print(pdc_query_t *query) + - Input: + + query: the query to be printed + - Output: + + None + - Print the details of a PDC query structure. + - For developers, see pdc_client_server_common.c. + + void PDCselection_print(pdc_selection_t *sel) + - Input: + + sel: the PDC selection to be printed + - Output: + + None + - Print the details of a PDC selection structure. + - For developers, see pdc_client_server_common.c. + ## PDC hist APIs + + pdc_histogram_t *PDC_gen_hist(pdc_var_type_t dtype, uint64_t n, void *data) + - Input: + + dtype: One of the PDC basic types see [PDC basic types](#basic-types) + + n: number of values with the basic types. + + data: pointer to the data buffer. + - Output: + + a new [PDC histogram structure](#histogram-structure) + - Generate a PDC histogram from data. This can be used to optimize performance. + - For developers, see pdc_hist_pkg.c + + pdc_histogram_t *PDC_dup_hist(pdc_histogram_t *hist) + - Input: + + hist: [PDC histogram structure](#histogram-structure) + - Output: + + a copied [PDC histogram structure](#histogram-structure) + - Copy a histogram from an existing one + - For developers, see pdc_hist_pkg.c + + pdc_histogram_t *PDC_merge_hist(int n, pdc_histogram_t **hists) + - Input: + + hists: an array of [PDC histogram structure](#histogram-structure) to be merged + - Output + + A merged [PDC histogram structure](#histogram-structure) + - Merge multiple PDC histograms into one + - For developers, see pdc_hist_pkg.c + + void PDC_free_hist(pdc_histogram_t *hist) + - Input: + + hist: the [PDC histogram structure](#histogram-structure) to be freed. + - Output: + + None + - Delete a histogram + - For developers, see pdc_hist_pkg.c, free structure's internal arrays. + + void PDC_print_hist(pdc_histogram_t *hist) + - Input: + + hist: the [PDC histogram structure](#histogram-structure) to be printed. + - Output: + + None: + - Print a PDC histogram's information. The counter for every bin is displayed. + - For developers, see pdc_hist_pkg.c. +# PDC Data types + ## Basic types + ``` + typedef enum { + PDC_UNKNOWN = -1, /* error */ + PDC_INT = 0, /* integer types */ + PDC_FLOAT = 1, /* floating-point types */ + PDC_DOUBLE = 2, /* double types */ + PDC_CHAR = 3, /* character types */ + PDC_COMPOUND = 4, /* compound types */ + PDC_ENUM = 5, /* enumeration types */ + PDC_ARRAY = 6, /* Array types */ + PDC_UINT = 7, /* unsigned integer types */ + PDC_INT64 = 8, /* 64-bit integer types */ + PDC_UINT64 = 9, /* 64-bit unsigned integer types */ + PDC_INT16 = 10, + PDC_INT8 = 11, + NCLASSES = 12 /* this must be last */ + } pdc_var_type_t; + ``` + ## Histogram structure + ``` + typedef struct pdc_histogram_t { + pdc_var_type_t dtype; + int nbin; + double incr; + double *range; + uint64_t *bin; + } pdc_histogram_t; + ``` + ## Container info + ``` + struct pdc_cont_info { + /*Inherited from property*/ + char *name; + /*Registered using PDC_id_register */ + pdcid_t local_id; + /* Need to register at server using function PDC_Client_create_cont_id */ + uint64_t meta_id; + }; + ``` + ## Container life time + ``` + typedef enum { + PDC_PERSIST, + PDC_TRANSIENT + } pdc_lifetime_t; + ``` + ## Object property public + ``` + struct pdc_obj_prop *obj_prop_pub { + /* This ID is the one returned from PDC_id_register . This is a property ID*/ + pdcid_t obj_prop_id; + /* object dimensions */ + size_t ndim; + uint64_t *dims; + pdc_var_type_t type; + }; + ``` + ## Object property + ``` + struct _pdc_obj_prop { + /* Suffix _pub probably means public attributes to be accessed. */ + struct pdc_obj_prop *obj_prop_pub { + /* This ID is the one returned from PDC_id_register . This is a property ID*/ + pdcid_t obj_prop_id; + /* object dimensions */ + size_t ndim; + uint64_t *dims; + pdc_var_type_t type; + }; + /* This ID is returned from PDC_find_id with an input of ID returned from PDC init. + * This is true for both object and container. + * I think it is referencing the global PDC engine through its ID (or name). */ + struct _pdc_class *pdc{ + char *name; + pdcid_t local_id; + }; + /* The following are created with NULL values in the PDC_obj_create function. */ + uint32_t user_id; + char *app_name; + uint32_t time_step; + char *data_loc; + char *tags; + void *buf; + pdc_kvtag_t *kvtag; + + /* The following have been added to support of PDC analysis and transforms. + Will add meanings to them later, they are not critical. */ + size_t type_extent; + uint64_t locus; + uint32_t data_state; + struct _pdc_transform_state transform_prop{ + _pdc_major_type_t storage_order; + pdc_var_type_t dtype; + size_t ndim; + uint64_t dims[4]; + int meta_index; /* transform to this state */ + }; + }; + ``` + ## Object info + ``` + struct pdc_obj_info { + /* Directly coped from user argument at object creation. */ + char *name; + /* 0 for location = PDC_OBJ_LOAL. + * When PDC_OBJ_GLOBAL = 1, use PDC_Client_send_name_recv_id to retrieve ID. */ + pdcid_t meta_id; + /* Registered using PDC_id_register */ + pdcid_t local_id; + /* Set to 0 at creation time. * + int server_id; + /* Object property. Directly copy from user argument at object creation. */ + struct pdc_obj_prop *obj_pt; + }; + ``` + ## Object structure + ``` + struct _pdc_obj_info { + /* Public properties */ + struct pdc_obj_info *obj_info_pub { + /* Directly copied from user argument at object creation. */ + char *name; + /* 0 for location = PDC_OBJ_LOAL. + * When PDC_OBJ_GLOBAL = 1, use PDC_Client_send_name_recv_id to retrieve ID. */ + pdcid_t meta_id; + /* Registered using PDC_id_register */ + pdcid_t local_id; + /* Set to 0 at creation time. * + int server_id; + /* Object property. Directly copy from user argument at object creation. */ + struct pdc_obj_prop *obj_pt; + }; + /* Argument passed to obj create*/ + _pdc_obj_location_t location enum { + /* Either local or global */ + PDC_OBJ_GLOBAL, + PDC_OBJ_LOCAL + } + /* May be used or not used depending on which creation function called. */ + void *metadata; + /* The container pointer this object sits in. Copied*/ + struct _pdc_cont_info *cont; + /* Pointer to object property. Copied*/ + struct _pdc_obj_prop *obj_pt; + /* Linked list for region, initialized with NULL at create time.*/ + struct region_map_list *region_list_head { + pdcid_t orig_reg_id; + pdcid_t des_obj_id; + pdcid_t des_reg_id; + /* Double linked list usage*/ + struct region_map_list *prev; + struct region_map_list *next; + }; + }; + ``` + ## Region info + ``` + struct pdc_region_info { + pdcid_t local_id; + struct _pdc_obj_info *obj; + size_t ndim; + uint64_t *offset; + uint64_t *size; + bool mapping; + int registered_op; + void *buf; + }; + ``` + ## Access type + ``` + typedef enum { PDC_NA=0, PDC_READ=1, PDC_WRITE=2 } + ``` + ## Query operators + ``` + typedef enum { + PDC_OP_NONE = 0, + PDC_GT = 1, + PDC_LT = 2, + PDC_GTE = 3, + PDC_LTE = 4, + PDC_EQ = 5 + } pdc_query_op_t; + ``` + ## Query structures + ``` + typedef struct pdc_query_t { + pdc_query_constraint_t *constraint{ + pdcid_t obj_id; + pdc_query_op_t op; + pdc_var_type_t type; + double value; // Use it as a generic 64bit value + pdc_histogram_t *hist; + + int is_range; + pdc_query_op_t op2; + double value2; + + void *storage_region_list_head; + pdcid_t origin_server; + int n_sent; + int n_recv; + } + struct pdc_query_t *left; + struct pdc_query_t *right; + pdc_query_combine_op_t combine_op; + struct pdc_region_info *region; // used only on client + void *region_constraint; // used only on server + pdc_selection_t *sel; + } pdc_query_t; + ``` + ## Selection structure + ``` + typedef struct pdcquery_selection_t { + pdcid_t query_id; + size_t ndim; + uint64_t nhits; + uint64_t *coords; + uint64_t coords_alloc; + } pdc_selection_t; + ``` +# Developers notes + + This note is for developers. It helps developers to understand the code structure of PDC code as fast as possible. + + PDC internal data structure + - Linkedlist + * Linkedlist is an important data structure for managing PDC IDs. + * Overall. An PDC instance after PDC_Init() has a global variable pdc_id_list_g. See pdc_interface.h + ``` + struct PDC_id_type { + PDC_free_t free_func; /* Free function for object's of this type */ + PDC_type_t type_id; /* Class ID for the type */ + // const PDCID_class_t *cls;/* Pointer to ID class */ + unsigned init_count; /* # of times this type has been initialized */ + unsigned id_count; /* Current number of IDs held */ + pdcid_t nextid; /* ID to use for the next atom */ + PDC_LIST_HEAD(_pdc_id_info) ids; /* Head of list of IDs */ + }; + + struct pdc_id_list { + struct PDC_id_type *PDC_id_type_list_g[PDC_MAX_NUM_TYPES]; + }; + struct pdc_id_list *pdc_id_list_g; + ``` + * pdc_id_list_g is an array that stores the head of linked list for each types. + * The _pdc_id_info is defined as the followng in pdc_id_pkg.h. + ``` + struct _pdc_id_info { + pdcid_t id; /* ID for this info */ + hg_atomic_int32_t count; /* ref. count for this atom */ + void *obj_ptr; /* pointer associated with the atom */ + PDC_LIST_ENTRY(_pdc_id_info) entry; + }; + ``` + * obj_ptr is the pointer to the item the ID refers to. + * See pdc_linkedlist.h for implementations of search, insert, remove etc. operations + - ID + * ID is important for managing different data structures in PDC. + * e.g Creating objects or containers will return IDs for them + - pdcid_t PDC_id_register(PDC_type_t type, void *object) + * This function maintains a linked list. Entries of the linked list is going to be the pointers to the objects. Every time we create an object ID for object using some magics. Then the linked list entry is going to be put to the beginning of the linked list. + * type: One of the followings + ``` + typedef enum { + PDC_BADID = -1, /* invalid Type */ + PDC_CLASS = 1, /* type ID for PDC */ + PDC_CONT_PROP = 2, /* type ID for container property */ + PDC_OBJ_PROP = 3, /* type ID for object property */ + PDC_CONT = 4, /* type ID for container */ + PDC_OBJ = 5, /* type ID for object */ + PDC_REGION = 6, /* type ID for region */ + PDC_NTYPES = 7 /* number of library types, MUST BE LAST! */ + } PDC_type_t; + ``` + * Object: Pointer to the class instance created ( bad naming, not necessarily a PDC object). + - struct _pdc_id_info *PDC_find_id(pdcid_t idid); + * Use ID to get struct _pdc_id_info. For most of the times, we want to locate the object pointer inside the structure. This is linear search in the linked list. + * idid: ID you want to search. + + + PDC core classes. + - Property + * Property in PDC serves as hint and metadata storage purposes. + * Different types of object has different classes (struct) of properties. + * See pdc_prop.c, pdc_prop.h and pdc_prop_pkg.h for details. + - Container + * Container property + ``` + struct _pdc_cont_prop { + /* This class ID is returned from PDC_find_id with an input of ID returned from PDC init. This is true for both object and container. + *I think it is referencing the global PDC engine through its ID (or name). */ + struct _pdc_class *pdc{ + /* PDC class instance name*/ + char *name; + /* PDC class instance ID. For most of the times, we only have 1 PDC class instance. This is like a global variable everywhere.*/ + pdcid_t local_id; + }; + /* This ID is the one returned from PDC_id_register . This is a property ID type. + * Some kind of hashing algorithm is used to generate it at property create time*/ + pdcid_t cont_prop_id; + /* Not very important */ pdc_lifetime_t cont_life; + }; + ``` + * Container structure (pdc_cont_pkg.h and pdc_cont.h) + ``` + struct _pdc_cont_info { + struct pdc_cont_info *cont_info_pub { + /*Inherited from property*/ + char *name; + /*Registered using PDC_id_register */ + pdcid_t local_id; + /* Need to register at server using function PDC_Client_create_cont_id */ + uint64_t meta_id; + }; + /* Pointer to container property. + * This struct is copied at create time.*/ + struct _pdc_cont_prop *cont_pt; + }; + ``` + - Object + * Object property + See [object property](#object-property) + * Object structure (pdc_obj_pkg.h and pdc_obj.h) + See [Object structure](#object-structure) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 83909157d..7438cd6bd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -42,7 +42,9 @@ set(PDC_PACKAGE_VERSION_MAJOR "${PDC_VERSION_MAJOR}.${PDC_VERSION_MINOR}") set(PDC_PACKAGE_VERSION_MINOR "${PDC_VERSION_PATCH}") set(PDC_PACKAGE_STRING "${PDC_PACKAGE_NAME} ${PDC_PACKAGE_VERSION}") set(PDC_PACKAGE_TARNAME "${PDC_PACKAGE}") - +if(NOT MPI_RUN_CMD) + set(MPI_RUN_CMD mpiexec) +endif() #------------------------------------------------------------------------------ # Setup install and output Directories #------------------------------------------------------------------------------ @@ -359,6 +361,7 @@ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/server) # Testing #----------------------------------------------------------------------------- option(BUILD_TESTING "Build testing." OFF) +option(BUILD_MPI_TESTING "Build MPI testing." OFF) if(NOT PDC_EXTERNALLY_CONFIGURED AND BUILD_TESTING) enable_testing() include(CTest) diff --git a/src/api/pdc_client_connect.c b/src/api/pdc_client_connect.c index 35ae7bacc..73c09ff14 100644 --- a/src/api/pdc_client_connect.c +++ b/src/api/pdc_client_connect.c @@ -56,6 +56,8 @@ #include #include #include +#include +#include int is_client_debug_g = 0; pdc_server_selection_t pdc_server_selection_g = PDC_SERVER_DEFAULT; @@ -2255,23 +2257,28 @@ perr_t PDC_Client_buf_map(pdcid_t local_region_id, pdcid_t remote_obj_id, size_t data_size = (size_t *)malloc( sizeof(size_t) ); *data_ptrs = local_data + unit*local_offset[0]; *data_size = unit*local_dims[0]; + //printf("offset size = %d, local dim = %d, unit = %d, data_ptrs[0] = %d, data_ptrs[1] = %d\n", (int)local_offset[0], (int) local_dims[0], (int) unit, ((int*)data_ptrs)[0], ((int*)data_ptrs)[1] ); } else if (ndim == 2) { local_count = local_dims[0]; data_ptrs = (void **)malloc( local_count * sizeof(void *) ); data_size = (size_t *)malloc( local_count * sizeof(size_t) ); data_ptrs[0] = local_data + unit*(local_dims[1]*local_offset[0] + local_offset[1]); + data_size[0] = local_dims[1]; data_size[0] = unit*local_dims[1]; for (i=1; iobj_pt->type_extent; +/* if (region_info->registered_op & PDC_TRANSFORM) { transform_index = -1; PDC_get_transforms(®istry); @@ -2963,7 +2974,7 @@ perr_t PDC_Client_region_release(struct _pdc_obj_info *object_info, struct pdc_r } } } - +*/ // Compute data server and metadata server ids. if (pdc_server_selection_g != PDC_SERVER_DEFAULT) { server_id = object_info->obj_info_pub->server_id; @@ -3251,7 +3262,7 @@ perr_t PDC_Client_data_server_read_check(int server_id, uint32_t client_id, pdc_ HG_Destroy(data_server_read_check_handle); } // end of check io -close: +//close: /* close the shared memory segment as if it was a file */ if (close(shm_fd) == -1) PGOTO_ERROR(FAIL, "==PDC_CLIENT: Close failed!"); @@ -3382,8 +3393,9 @@ perr_t PDC_Client_close_shm(struct pdc_request *req) PGOTO_ERROR(FAIL, "==PDC_CLIENT[%d]: close shm failed", pdc_client_mpi_rank_g); /* remove the shared memory segment from the file system */ - if (shm_unlink(req->shm_addr) == -1) - PGOTO_ERROR(FAIL, "==PDC_CLIENT: Error removing %s", req->shm_addr); + // TODO: fix error + /* if (shm_unlink(req->shm_addr) == -1) */ + /* PGOTO_ERROR(FAIL, "==PDC_CLIENT: Error removing %s", req->shm_addr); */ done: fflush(stdout); @@ -4444,7 +4456,7 @@ perr_t PDC_Client_complete_read_request(int nbuf, struct pdc_request *req) } } -done: +//done: fflush(stdout); FUNC_LEAVE(ret_value); } @@ -5523,7 +5535,7 @@ perr_t PDC_Client_query_name_read_entire_obj_client_agg_cache_iter(int my_nobj, FUNC_LEAVE(ret_value); } -perr_t PDC_add_kvtag(pdcid_t obj_id, pdc_kvtag_t *kvtag) +static perr_t PDC_add_kvtag(pdcid_t obj_id, pdc_kvtag_t *kvtag, int is_cont) { perr_t ret_value = SUCCEED; hg_return_t hg_ret = 0; @@ -5532,12 +5544,23 @@ perr_t PDC_add_kvtag(pdcid_t obj_id, pdc_kvtag_t *kvtag) hg_handle_t metadata_add_kvtag_handle; metadata_add_kvtag_in_t in; struct _pdc_obj_info *obj_prop; + struct _pdc_cont_info *cont_prop; struct _pdc_client_lookup_args lookup_args; FUNC_ENTER(NULL); - obj_prop = PDC_obj_get_info(obj_id); - meta_id = obj_prop->obj_info_pub->meta_id; + if (is_cont == 0) { + obj_prop = PDC_obj_get_info(obj_id); + meta_id = obj_prop->obj_info_pub->meta_id; + in.obj_id = meta_id; + in.hash_value = PDC_get_hash_by_name(obj_prop->obj_info_pub->name); + } + else { + cont_prop = PDC_cont_get_info(obj_id); + meta_id = cont_prop->cont_info_pub->meta_id; + in.obj_id = meta_id; + in.hash_value = PDC_get_hash_by_name(cont_prop->cont_info_pub->name); + } server_id = PDC_get_server_by_obj_id(meta_id, pdc_server_num_g); @@ -5551,8 +5574,6 @@ perr_t PDC_add_kvtag(pdcid_t obj_id, pdc_kvtag_t *kvtag) &metadata_add_kvtag_handle); // Fill input structure - in.obj_id = meta_id; - in.hash_value = PDC_get_hash_by_name(obj_prop->obj_info_pub->name); if (kvtag != NULL && kvtag != NULL && kvtag->size != 0) { in.kvtag.name = kvtag->name; @@ -5597,7 +5618,11 @@ metadata_get_kvtag_rpc_cb(const struct hg_cb_info *callback_info) PGOTO_ERROR(ret_value, "==PDC_CLIENT[%d]: metadata_add_tag_rpc_cb error with HG_Get_output", pdc_client_mpi_rank_g); } client_lookup_args->ret = output.ret; - PDC_kvtag_dup(&(output.kvtag), &client_lookup_args->kvtag); + client_lookup_args->kvtag->name = strdup(output.kvtag.name); + client_lookup_args->kvtag->size = output.kvtag.size; + client_lookup_args->kvtag->value = malloc(output.kvtag.size); + memcpy(client_lookup_args->kvtag->value, output.kvtag.value, output.kvtag.size); + /* PDC_kvtag_dup(&(output.kvtag), &client_lookup_args->kvtag); */ done: fflush(stdout); @@ -5607,7 +5632,7 @@ metadata_get_kvtag_rpc_cb(const struct hg_cb_info *callback_info) FUNC_LEAVE(ret_value); } -perr_t PDC_get_kvtag(pdcid_t obj_id, char *tag_name, pdc_kvtag_t **kvtag) +static perr_t PDC_get_kvtag(pdcid_t obj_id, char *tag_name, pdc_kvtag_t **kvtag, int is_cont) { perr_t ret_value = SUCCEED; hg_return_t hg_ret = 0; @@ -5617,11 +5642,23 @@ perr_t PDC_get_kvtag(pdcid_t obj_id, char *tag_name, pdc_kvtag_t **kvtag) metadata_get_kvtag_in_t in; struct _pdc_get_kvtag_args lookup_args; struct _pdc_obj_info *obj_prop; + struct _pdc_cont_info *cont_prop; FUNC_ENTER(NULL); - obj_prop = PDC_obj_get_info(obj_id); - meta_id = obj_prop->obj_info_pub->meta_id; + if (is_cont == 0) { + obj_prop = PDC_obj_get_info(obj_id); + meta_id = obj_prop->obj_info_pub->meta_id; + in.obj_id = meta_id; + in.hash_value = PDC_get_hash_by_name(obj_prop->obj_info_pub->name); + } + else { + cont_prop = PDC_cont_get_info(obj_id); + meta_id = cont_prop->cont_info_pub->meta_id; + in.obj_id = meta_id; + in.hash_value = PDC_get_hash_by_name(cont_prop->cont_info_pub->name); + } + server_id = PDC_get_server_by_obj_id(meta_id, pdc_server_num_g); debug_server_id_count[server_id]++; @@ -5631,10 +5668,6 @@ perr_t PDC_get_kvtag(pdcid_t obj_id, char *tag_name, pdc_kvtag_t **kvtag) HG_Create(send_context_g, pdc_server_info_g[server_id].addr, metadata_get_kvtag_register_id_g, &metadata_get_kvtag_handle); - // Fill input structure - in.obj_id = meta_id; - in.hash_value = PDC_get_hash_by_name(obj_prop->obj_info_pub->name); - if ( tag_name != NULL && kvtag != NULL) { in.key = tag_name; } @@ -6101,13 +6134,18 @@ perr_t PDCcont_put_tag(pdcid_t cont_id, char *tag_name, void *tag_value, psize_t value_size) { perr_t ret_value = SUCCEED; + pdc_kvtag_t kvtag; FUNC_ENTER(NULL); - ret_value = PDCobj_put_tag(cont_id, tag_name, tag_value, value_size); + kvtag.name = tag_name; + kvtag.value = (void*)tag_value; + kvtag.size = (uint64_t)value_size; + + ret_value = PDC_add_kvtag(cont_id, &kvtag, 1); if (ret_value != SUCCEED) - PGOTO_ERROR(FAIL, "==PDC_CLIENT[%d]: error with PDCobj_put_tag", - pdc_client_mpi_rank_g); + PGOTO_ERROR(FAIL, "==PDC_CLIENT[%d]: Error with PDCcont_put_tag", pdc_client_mpi_rank_g); + done: fflush(stdout); @@ -6118,13 +6156,17 @@ perr_t PDCcont_get_tag(pdcid_t cont_id, char *tag_name, void **tag_value, psize_t *value_size) { perr_t ret_value = SUCCEED; + pdc_kvtag_t *kvtag = NULL; FUNC_ENTER(NULL); - ret_value = PDCobj_get_tag(cont_id, tag_name, tag_value, value_size); + ret_value = PDC_get_kvtag(cont_id, tag_name, &kvtag, 1); if (ret_value != SUCCEED) - PGOTO_ERROR(FAIL, "==PDC_CLIENT[%d]: error with PDCcont_get_tag", - pdc_client_mpi_rank_g); + PGOTO_ERROR(FAIL, "==PDC_CLIENT[%d]: Error with PDC_get_kvtag", pdc_client_mpi_rank_g); + + *tag_value = kvtag->value; + *value_size = kvtag->size; + done: fflush(stdout); @@ -6152,10 +6194,9 @@ pdcid_t PDCobj_put_data(const char *obj_name, void *data, uint64_t size, pdcid_t cont_id) { pdcid_t ret_value = 0; - pdcid_t obj_id, obj_prop; - struct pdc_region_info obj_region; + pdcid_t obj_id, obj_prop, obj_region; perr_t ret; - pdc_metadata_t *meta; + //pdc_metadata_t *meta; struct _pdc_cont_info *info = NULL; struct _pdc_id_info *id_info = NULL; @@ -6165,30 +6206,57 @@ PDCobj_put_data(const char *obj_name, void *data, uint64_t size, pdcid_t cont_id info = (struct _pdc_cont_info *)(id_info->obj_ptr); obj_prop = PDCprop_create(PDC_OBJ_CREATE, info->cont_pt->pdc->local_id); + PDCprop_set_obj_type(obj_prop, PDC_CHAR); PDCprop_set_obj_dims(obj_prop, 1, &size); PDCprop_set_obj_user_id(obj_prop, getuid()); PDCprop_set_obj_time_step(obj_prop, 0); - obj_id = PDCobj_create(cont_id, obj_name, obj_prop); + obj_id = PDC_obj_create(cont_id, obj_name, obj_prop, PDC_OBJ_GLOBAL); if (obj_id <= 0) - PGOTO_ERROR(FAIL, "==PDC_CLIENT[%d]: Error creating object [%s]", + PGOTO_ERROR(0, "==PDC_CLIENT[%d]: Error creating object [%s]", pdc_client_mpi_rank_g, obj_name); - obj_region.ndim = 1; - obj_region.offset = 0; - obj_region.size = &size; + int ndim = 1; + uint64_t offset = 0; + //size = ceil(size/sizeof(int)); + obj_region = PDCregion_create(ndim, &offset, &size); -#ifdef ENABLE_MPI - ret = PDC_Client_query_metadata_name_timestep_agg(obj_name, 0, &meta); -#else - ret = PDC_Client_query_metadata_name_timestep(obj_name, 0, &meta); -#endif + ret = PDCbuf_obj_map(data, PDC_CHAR, obj_region, obj_id, obj_region); + if(ret != SUCCEED) { + PGOTO_ERROR(0, "==PDC_CLIENT[%d]: Error with PDCbuf_obj_map for obj [%s]", + pdc_client_mpi_rank_g, obj_name); + } + + ret = PDCreg_obtain_lock(obj_id, obj_region, PDC_WRITE, PDC_BLOCK); + if (ret != SUCCEED) { + PGOTO_ERROR(0, "==PDC_CLIENT[%d]: Error with PDCreg_obtain_lock for obj [%s]", + pdc_client_mpi_rank_g, obj_name); + } + ret = PDCreg_release_lock(obj_id, obj_region, PDC_WRITE); + if (ret != SUCCEED) { + PGOTO_ERROR(0, "==PDC_CLIENT[%d]: Error with PDCreg_release_lock for obj [%s]", + pdc_client_mpi_rank_g, obj_name); + } - ret = PDC_Client_write(meta, &obj_region, (void *)data); - if (ret != SUCCEED) - PGOTO_ERROR(0, "==PDC_CLIENT[%d]: Error with PDC_Client_write_id for obj [%s]", + ret = PDCbuf_obj_unmap(obj_id, obj_region); + if (ret != SUCCEED) { + PGOTO_ERROR(0, "==PDC_CLIENT[%d]: Error with PDCbuf_obj_unmap for obj [%s]", pdc_client_mpi_rank_g, obj_name); + } + + ret = PDCregion_close(obj_region); + if (ret != SUCCEED) { + PGOTO_ERROR(0, "==PDC_CLIENT[%d]: Error with PDCregion_close for obj [%s]", + pdc_client_mpi_rank_g, obj_name); + } + + ret = PDCprop_close(obj_prop); + if (ret != SUCCEED) { + PGOTO_ERROR(0, "==PDC_CLIENT[%d]: Error with PDCprop_close for obj [%s]", + pdc_client_mpi_rank_g, obj_name); + } + ret_value = obj_id; done: fflush(stdout); FUNC_LEAVE(ret_value); @@ -6263,7 +6331,7 @@ PDCobj_put_tag(pdcid_t obj_id, char *tag_name, void *tag_value, psize_t value_si kvtag.value = (void*)tag_value; kvtag.size = (uint64_t)value_size; - ret_value = PDC_add_kvtag(obj_id, &kvtag); + ret_value = PDC_add_kvtag(obj_id, &kvtag, 0); if (ret_value != SUCCEED) PGOTO_ERROR(FAIL, "==PDC_CLIENT[%d]: Error with PDC_add_kvtag", pdc_client_mpi_rank_g); @@ -6280,7 +6348,7 @@ PDCobj_get_tag(pdcid_t obj_id, char *tag_name, void **tag_value, psize_t *value_ FUNC_ENTER(NULL); - ret_value = PDC_get_kvtag(obj_id, tag_name, &kvtag); + ret_value = PDC_get_kvtag(obj_id, tag_name, &kvtag, 0); if (ret_value != SUCCEED) PGOTO_ERROR(FAIL, "==PDC_CLIENT[%d]: Error with PDC_get_kvtag", pdc_client_mpi_rank_g); @@ -6383,7 +6451,7 @@ PDC_send_data_query(pdc_query_t *query, pdc_query_get_op_t get_op, uint64_t *nhi perr_t ret_value = SUCCEED; hg_return_t hg_ret = 0; uint32_t *target_servers = NULL; - int i, server_id, next_server, prev_server, ntarget = 0; + int i, server_id, next_server = 0, prev_server = 0, ntarget = 0; hg_handle_t handle; pdc_query_xfer_t *query_xfer; struct _pdc_client_lookup_args lookup_args; @@ -6474,7 +6542,7 @@ PDC_recv_coords(const struct hg_cb_info *callback_info) hg_bulk_t local_bulk_handle = callback_info->info.bulk.local_handle; struct bulk_args_t *bulk_args = (struct bulk_args_t *)callback_info->arg; struct _pdc_query_result_list *result_elt; - uint64_t nhits; + uint64_t nhits = 0; uint32_t ndim; int query_id, origin; void *buf; @@ -6629,7 +6697,7 @@ PDC_recv_read_coords_data(const struct hg_cb_info *callback_info) hg_bulk_t local_bulk_handle = callback_info->info.bulk.local_handle; struct bulk_args_t *bulk_args = (struct bulk_args_t *)callback_info->arg; struct _pdc_query_result_list *result_elt; - uint64_t nhits; + uint64_t nhits = 0; int query_id, seq_id; void *buf; pdc_int_ret_t out; diff --git a/src/api/pdc_client_connect.h b/src/api/pdc_client_connect.h index 392ef2346..3a32f3b13 100644 --- a/src/api/pdc_client_connect.h +++ b/src/api/pdc_client_connect.h @@ -821,26 +821,6 @@ perr_t PDC_wait(struct pdc_request *request, unsigned long max_wait_ms, unsigned */ int PDC_get_nproc_per_node(); -/** - * Create a tag with a specific name and value - * - * \param obj_id[IN] Object ID - * \param kvtag [IN] ********* - * - * \return Non-negative on success/Negative on failure - */ -perr_t PDC_add_kvtag(pdcid_t obj_id, pdc_kvtag_t *kvtag); - -/** - * ******* - * - * \param obj_id[IN] Object ID - * \param kvtag [IN] ********* - * - * \return Non-negative on success/Negative on failure - */ -perr_t PDC_get_kvtag(pdcid_t obj_id, char *tag_name, pdc_kvtag_t **kvtag); - /** * ******* * diff --git a/src/api/pdc_client_server_common.c b/src/api/pdc_client_server_common.c index a2ab736f4..5163141c8 100644 --- a/src/api/pdc_client_server_common.c +++ b/src/api/pdc_client_server_common.c @@ -1804,7 +1804,9 @@ analysis_and_region_release_bulk_transfer_cb(const struct hg_cb_info *hg_cb_info */ data_buf = PDC_Server_get_region_buf_ptr(bulk_args->remote_obj_id, bulk_args->remote_region); +#ifdef ENABLE_MPI start_t = MPI_Wtime(); +#endif if (data_buf != NULL) { struct _pdc_region_analysis_ftn_info **registry = NULL; struct _pdc_iterator_cbs_t iter_cbs = {PDCobj_data_getSliceCount, PDCobj_data_getNextBlock}; @@ -1818,11 +1820,11 @@ analysis_and_region_release_bulk_transfer_cb(const struct hg_cb_info *hg_cb_info puts("----------------\n"); } } - +#ifdef ENABLE_MPI end_t = MPI_Wtime(); analysis_t = end_t - start_t; start_t = end_t; - +#endif remote_reg_info = (struct pdc_region_info *)malloc(sizeof(struct pdc_region_info)); if (remote_reg_info == NULL) PGOTO_ERROR(HG_OTHER_ERROR, "remote_reg_info memory allocation failed"); @@ -1856,8 +1858,10 @@ analysis_and_region_release_bulk_transfer_cb(const struct hg_cb_info *hg_cb_info /* Write the analysis results... */ PDC_Server_data_write_out(bulk_args->remote_obj_id, remote_reg_info, data_buf, (size_t)type_extent); +#ifdef ENABLE_MPI end_t = MPI_Wtime(); io_t = end_t - start_t; +#endif PDC_Data_Server_region_release((region_lock_in_t *)&bulk_args->in, &out); local_reg_info = (struct pdc_region_info *)malloc(sizeof(struct pdc_region_info)); if (local_reg_info == NULL) @@ -2096,7 +2100,7 @@ HG_TEST_RPC_CB(region_release, handle) data_server_region_t *target_obj; int error = 0; int dirty_reg = 0; - hg_size_t size; + hg_size_t size, size2; void *data_buf; struct pdc_region_info *server_region; region_list_t *elt, *request_region, *tmp; @@ -2175,7 +2179,55 @@ HG_TEST_RPC_CB(region_release, handle) *data_ptrs_to = data_buf; *data_size_to = (eltt2->remote_region_unit).count_0; } - + if (in.region.ndim == 2) { + remote_count = 1; + data_ptrs_to = (void **)malloc( sizeof(void *) ); + data_size_to = (size_t *)malloc( sizeof(size_t) ); + *data_ptrs_to = data_buf; + *data_size_to = (eltt2->remote_region_unit).count_0 * (eltt2->remote_region_unit).count_1 / in.data_unit; + } + if (in.region.ndim == 3) { + remote_count = 1; + data_ptrs_to = (void **)malloc( sizeof(void *) ); + data_size_to = (size_t *)malloc( sizeof(size_t) ); + *data_ptrs_to = data_buf; + *data_size_to = (eltt2->remote_region_unit).count_0 * (eltt2->remote_region_unit).count_1 / in.data_unit * (eltt2->remote_region_unit).count_2 / in.data_unit ; + } + /* else if (in.region.ndim == 2) { */ + /* dims[1] = (eltt->remote_region_nounit).count_1; */ + /* remote_count = (eltt->remote_region_nounit).count_0; */ + /* data_ptrs_to = (void **)malloc( remote_count * sizeof(void *) ); */ + /* data_size_to = (size_t *)malloc( remote_count * sizeof(size_t) ); */ + /* data_ptrs_to[0] = data_buf + type_size * (dims[1]*(eltt->remote_region_nounit).start_0 + (eltt->remote_region_nounit).start_1); */ + /* data_size_to[0] = (eltt->remote_region_unit).count_1; */ + /* for (k=1; kremote_region_nounit).count_1; */ + /* dims[2] = (eltt->remote_region_nounit).count_2; */ + /* remote_count = (eltt->remote_region_nounit).count_0 * (eltt->remote_region_nounit).count_1; */ + /* data_ptrs_to = (void **)malloc( remote_count * sizeof(void *) ); */ + /* data_size_to = (size_t *)malloc( remote_count * sizeof(size_t) ); */ + /* data_ptrs_to[0] = data_buf + type_size*(dims[2]*dims[1]*(eltt->remote_region_nounit).start_0 + dims[2]*(eltt->remote_region_nounit).start_1 + (eltt->remote_region_nounit).start_2); */ + /* data_size_to[0] = (eltt->remote_region_unit).count_2; */ + /* for (k=0; k<(eltt->remote_region_nounit).count_0-1; k++) { */ + /* for (m=0; m<(eltt->remote_region_nounit).count_1-1; m++) { */ + /* data_ptrs_to[k*(eltt->remote_region_nounit).count_1+m+1] = data_ptrs_to[k*(eltt->remote_region_nounit).count_1+m] + type_size*dims[2]; */ + /* data_size_to[k*(eltt->remote_region_nounit).count_1+m+1] = data_size_to[0]; */ + /* } */ + /* data_ptrs_to[k*(eltt->remote_region_nounit).count_1+(eltt->remote_region_nounit).count_1] = data_ptrs_to[k*(eltt->remote_region_nounit).count_1] + type_size*dims[2]*dims[1]; */ + /* data_size_to[k*(eltt->remote_region_nounit).count_1+(eltt->remote_region_nounit).count_1] = data_size_to[0]; */ + /* } */ + /* k = (eltt->remote_region_nounit).count_0 - 1; */ + /* for (m=0; m<(eltt->remote_region_nounit).count_1-1; m++) { */ + /* data_ptrs_to[k*(eltt->remote_region_nounit).count_1+m+1] = data_ptrs_to[k*(eltt->remote_region_nounit).count_1+m] + type_size*dims[2]; */ + /* data_size_to[k*(eltt->remote_region_nounit).count_1+m+1] = data_size_to[0]; */ + /* } */ + /* } */ + hg_ret = HG_Bulk_create(hg_info->hg_class, remote_count, data_ptrs_to, (hg_size_t *)data_size_to, HG_BULK_READWRITE, &remote_bulk_handle); if (hg_ret != HG_SUCCESS) { error = 1; @@ -2236,8 +2288,10 @@ HG_TEST_RPC_CB(region_release, handle) PDC_Server_data_read_from(obj_map_bulk_args->remote_obj_id, remote_reg_info, data_buf, in.data_unit); size = HG_Bulk_get_size(eltt2->local_bulk_handle); - if (size != HG_Bulk_get_size(remote_bulk_handle)) { + size2 = HG_Bulk_get_size(remote_bulk_handle); + if (size != size2) { error = 1; + printf("==PDC_SERVER: local size %llu, remote %llu\n", size, size2); PGOTO_ERROR(HG_OTHER_ERROR, "===PDC SERVER: HG_TEST_RPC_CB(region_release, handle) local and remote bulk size does not match"); } @@ -2355,18 +2409,22 @@ HG_TEST_RPC_CB(region_release, handle) #endif /* Pull bulk data */ size = HG_Bulk_get_size(eltt->local_bulk_handle); - if (size != HG_Bulk_get_size(remote_bulk_handle)) { + size2 = HG_Bulk_get_size(remote_bulk_handle); + if (size != size2) { error = 1; - PGOTO_ERROR(HG_OTHER_ERROR, "===PDC SERVER: HG_TEST_RPC_CB(region_release, handle) local and remote bulk size does not match"); + printf("==PDC_SERVER: local size %llu, remote %llu\n", size, size2); + /* PGOTO_ERROR(HG_OTHER_ERROR, "===PDC SERVER: HG_TEST_RPC_CB(region_release, handle) local and remote bulk size does not match"); */ } hg_ret = HG_Bulk_transfer(hg_info->context, buf_map_region_release_bulk_transfer_cb, buf_map_bulk_args, HG_BULK_PULL, eltt->local_addr, eltt->local_bulk_handle, 0, remote_bulk_handle, 0, size, HG_OP_ID_IGNORE); if (hg_ret != HG_SUCCESS) { error = 1; PGOTO_ERROR(hg_ret, "===PDC SERVER: HG_TEST_RPC_CB(region_release, handle) buf map Could not read bulk data"); } + break; } } free(tmp); + break; } } #ifdef ENABLE_MULTITHREAD @@ -3679,6 +3737,8 @@ HG_TEST_RPC_CB(bulk_rpc, handle) bulk_args->nbytes = HG_Bulk_get_size(origin_bulk_handle); bulk_args->cnt = cnt; + printf("==PDC_SERVER: bulk_rpc_cb, nbytes %llu\n", bulk_args->nbytes); + /* Create a new block handle to read the data */ HG_Bulk_create(hg_info->hg_class, 1, NULL, (hg_size_t *) &bulk_args->nbytes, HG_BULK_READWRITE, &local_bulk_handle); @@ -5061,6 +5121,8 @@ HG_TEST_RPC_CB(send_shm_bulk_rpc, handle) bulk_args->nbytes = HG_Bulk_get_size(origin_bulk_handle); bulk_args->cnt = cnt; + printf("==PDC_SERVER: send_bulk_rpc_cb, nbytes %llu\n", bulk_args->nbytes); + /* Create a new bulk handle to read the data */ HG_Bulk_create(hg_info->hg_class, 1, NULL, (hg_size_t *) &bulk_args->nbytes, HG_BULK_READWRITE, &local_bulk_handle); @@ -5734,7 +5796,8 @@ int PDC_query_get_nnode(pdc_query_t *query) if (NULL == query) ret_value = 0; - ret_value = 1 + PDC_query_get_nnode(query->left) + PDC_query_get_nnode(query->right); + else + ret_value = 1 + PDC_query_get_nnode(query->left) + PDC_query_get_nnode(query->right); FUNC_LEAVE(ret_value); } diff --git a/src/api/pdc_obj.c b/src/api/pdc_obj.c index e21b87d5d..237465f2a 100644 --- a/src/api/pdc_obj.c +++ b/src/api/pdc_obj.c @@ -133,7 +133,8 @@ pdcid_t PDCobj_create(pdcid_t cont_id, const char *obj_name, pdcid_t obj_prop_id PGOTO_ERROR(0, "cannot allocate ret_value->dims"); for (i=0; iobj_prop_pub->ndim; i++) p->obj_pt->obj_prop_pub->dims[i] = obj_prop->obj_prop_pub->dims[i]; - + + p->obj_pt->obj_prop_pub->type = obj_prop->obj_prop_pub->type; if (obj_prop->app_name) p->obj_pt->app_name = strdup(obj_prop->app_name); if (obj_prop->data_loc) @@ -162,7 +163,7 @@ pdcid_t PDCobj_create(pdcid_t cont_id, const char *obj_name, pdcid_t obj_prop_id for (i=0; iobj_prop_pub->ndim; i++) p->obj_info_pub->obj_pt->dims[i] = obj_prop->obj_prop_pub->dims[i]; -// PDC_Client_attach_metadata_to_local_obj((char *)obj_name, p->meta_id, p->cont->meta_id, p); + //PDC_Client_attach_metadata_to_local_obj((char *)obj_name, p->meta_id, p->cont->meta_id, p); ret_value = p->obj_info_pub->local_id; @@ -224,6 +225,7 @@ pdcid_t PDC_obj_create(pdcid_t cont_id, const char *obj_name, pdcid_t obj_prop_i if (cont_info->cont_pt->pdc->name) p->cont->cont_pt->pdc->name = strdup(cont_info->cont_pt->pdc->name); p->cont->cont_pt->pdc->local_id = cont_info->cont_pt->pdc->local_id; + meta_id = p->cont->cont_info_pub->meta_id; } id_info = PDC_find_id(obj_prop_id); @@ -259,6 +261,13 @@ pdcid_t PDC_obj_create(pdcid_t cont_id, const char *obj_name, pdcid_t obj_prop_i PGOTO_ERROR(0, "cannot allocate ret_value->dims"); for (i=0; iobj_prop_pub->ndim; i++) p->obj_pt->obj_prop_pub->dims[i] = obj_prop->obj_prop_pub->dims[i]; + p->obj_pt->obj_prop_pub->type = obj_prop->obj_prop_pub->type; + if (obj_prop->app_name) + p->obj_pt->app_name = strdup(obj_prop->app_name); + if (obj_prop->data_loc) + p->obj_pt->data_loc = strdup(obj_prop->data_loc); + if (obj_prop->tags) + p->obj_pt->tags = strdup(obj_prop->tags); /* struct pdc_obj_info field */ p->obj_info_pub = PDC_MALLOC(struct pdc_obj_info); @@ -418,7 +427,7 @@ pdcid_t PDCobj_open(const char *obj_name, pdcid_t pdc) PGOTO_ERROR(0, "cannot allocate ret_value->pdc"); // contact metadata server - ret = PDC_Client_query_metadata_name_timestep_agg(obj_name, 0, &out); + ret = PDC_Client_query_metadata_name_timestep(obj_name, 0, &out); if (ret == FAIL) PGOTO_ERROR(0, "query object failed"); @@ -534,7 +543,7 @@ struct pdc_obj_info *PDCobj_iter_get_info(obj_handle *ohandle) { struct pdc_obj_info *ret_value = NULL; struct _pdc_obj_info *info = NULL; - int i; + unsigned i; FUNC_ENTER(NULL); @@ -717,7 +726,6 @@ void **PDCobj_buf_retrieve(pdcid_t obj_id) void **buffer; FUNC_ENTER(NULL); - info = PDC_find_id(obj_id); if (info == NULL) PGOTO_ERROR(NULL, "cannot locate object ID"); @@ -909,15 +917,15 @@ perr_t PDC_free_obj_info(struct _pdc_obj_info *obj) FUNC_LEAVE(ret_value); } -struct pdc_obj_info *PDCobj_get_info(const char *obj_name) +struct pdc_obj_info *PDCobj_get_info(pdcid_t obj_id) { struct pdc_obj_info *ret_value = NULL; struct _pdc_obj_info *tmp = NULL; - pdcid_t obj_id; + /* pdcid_t obj_id; */ FUNC_ENTER(NULL); - obj_id = PDC_find_byname(PDC_OBJ, obj_name); + /* obj_id = PDC_find_byname(PDC_OBJ, obj_name); */ tmp = PDC_obj_get_info(obj_id); diff --git a/src/api/pdc_obj.h b/src/api/pdc_obj.h index 09f027235..dfb451105 100644 --- a/src/api/pdc_obj.h +++ b/src/api/pdc_obj.h @@ -86,7 +86,7 @@ perr_t PDCobj_close(pdcid_t obj_id); * * \return Pointer to pdc_obj_info struct on success/Null on failure */ -struct pdc_obj_info *PDCobj_get_info(const char *obj_name); +struct pdc_obj_info *PDCobj_get_info(pdcid_t obj_id); /** * *********** diff --git a/src/pdc_start b/src/pdc_start index 4d52d69d3..1c5d67b1c 100644 --- a/src/pdc_start +++ b/src/pdc_start @@ -8,7 +8,9 @@ export ENABLE_TIMING=OFF export ENABLE_CHECKPOINT=ON export ENABLE_MULTITHREAD=OFF export BUILD_TESTING=ON +export BUILD_MPI_TESTING=OFF export BUILD_DOCUMENTATION=OFF +export MPI_TEST_CMD=mpiexec export CMAKE_PREFIX_PATH=/Users/kmu/Research/PDC/tools/mercury/share/cmake/mercury export PDC_DATA_LOC=/Users/kmu/Research/PDC/pdc/src/build/gen_data export HG_TRANSPORT=bmi+tcp diff --git a/src/server/pdc_server_metadata.c b/src/server/pdc_server_metadata.c index 734e10767..b2d03e5d6 100644 --- a/src/server/pdc_server_metadata.c +++ b/src/server/pdc_server_metadata.c @@ -2472,6 +2472,7 @@ perr_t PDC_Server_add_kvtag(metadata_add_kvtag_in_t *in, metadata_add_tag_out_t int unlocked; #endif pdc_hash_table_entry_head *lookup_value; + pdc_cont_hash_table_entry_t *cont_lookup_value; FUNC_ENTER(NULL); @@ -2506,10 +2507,18 @@ perr_t PDC_Server_add_kvtag(metadata_add_kvtag_in_t *in, metadata_add_tag_out_t } } // if lookup_value != NULL - else { - printf("==PDC_SERVER[%d]: add tag target %" PRIu64 " not found!\n", pdc_server_rank_g, obj_id); - ret_value = FAIL; - out->ret = -1; + else { // look for containers + cont_lookup_value = hash_table_lookup(container_hash_table_g, &hash_key); + if (cont_lookup_value != NULL) { + PDC_add_kvtag_to_list(&cont_lookup_value->kvtag_list_head, &in->kvtag); + out->ret = 1; + + } + else { + printf("==PDC_SERVER[%d]: add tag target %" PRIu64 " not found!\n", pdc_server_rank_g, obj_id); + ret_value = FAIL; + out->ret = -1; + } } @@ -2577,6 +2586,7 @@ perr_t PDC_Server_get_kvtag(metadata_get_kvtag_in_t *in, metadata_get_kvtag_out_ int unlocked; #endif pdc_hash_table_entry_head *lookup_value; + pdc_cont_hash_table_entry_t *cont_lookup_value; FUNC_ENTER(NULL); @@ -2610,8 +2620,16 @@ perr_t PDC_Server_get_kvtag(metadata_get_kvtag_in_t *in, metadata_get_kvtag_out_ } } else { - ret_value = FAIL; - out->ret = -1; + + cont_lookup_value = hash_table_lookup(container_hash_table_g, &hash_key); + if (cont_lookup_value != NULL) { + PDC_get_kvtag_value_from_list(&cont_lookup_value->kvtag_list_head, in->key, out); + out->ret = 1; + } + else { + ret_value = FAIL; + out->ret = -1; + } } if (ret_value != SUCCEED) { diff --git a/src/server/pdc_server_metadata.h b/src/server/pdc_server_metadata.h index 4c6d54624..bc6f054c7 100644 --- a/src/server/pdc_server_metadata.h +++ b/src/server/pdc_server_metadata.h @@ -78,6 +78,7 @@ typedef struct pdc_cont_hash_table_entry_t { int n_allocated; uint64_t *obj_ids; char tags[TAG_LEN_MAX]; + pdc_kvtag_list_t *kvtag_list_head; } pdc_cont_hash_table_entry_t; /***************************************/ diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index b633f31f6..da8c806e7 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -9,16 +9,33 @@ include_directories( set(PROGRAMS pdc_init create_prop + create_region + create_obj_coll + set_prop + dup_prop + write_obj + write_obj_shared create_cont open_cont cont_life cont_iter + cont_info + cont_getid + cont_tags create_obj open_obj + obj_info obj_iter obj_life obj_dim obj_buf + obj_tags + obj_put_data + open_obj_round_robin + region_obj_map_2D + region_obj_map_3D + obj_round_robin_io + region_obj_map create_obj_scale close_server update_obj @@ -28,9 +45,6 @@ set(PROGRAMS search_obj_scale obj_lock list_all - data_server_read - data_server_write - data_rw_test init_only buf_obj_map buf_obj_map_mpi @@ -39,13 +53,6 @@ set(PROGRAMS bdcats vpicio_v2 bdcats_v2 - data_server_write_vpic - data_server_write_vpic_multits - data_server_read_vpic - data_server_read_vpic_multits - data_server_read_vpic_spatial - data_server_read_vpic_spatial_multits - write_1obj cont_add_del data_server_meta_test kvtag_add_get @@ -77,6 +84,7 @@ endforeach(program) set(SCRIPTS run_test.sh + mpi_test.sh run_multiple_test.sh ) @@ -116,15 +124,85 @@ target_link_libraries(pdcanalysis pdc) add_test(NAME pdc_init WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./pdc_init ) add_test(NAME create_prop WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./create_prop ) +add_test(NAME set_prop WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./set_prop ) +add_test(NAME dup_prop WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./dup_prop ) add_test(NAME create_cont WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./create_cont ) add_test(NAME open_cont WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./open_cont ) add_test(NAME cont_life WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./cont_life ) add_test(NAME cont_iter WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./cont_iter ) +add_test(NAME cont_info WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./cont_info ) +add_test(NAME cont_getid WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./cont_getid ) +add_test(NAME cont_tags WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./cont_tags ) add_test(NAME create_obj WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./create_obj ) add_test(NAME open_obj WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./open_obj ) add_test(NAME obj_iter WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./obj_iter ) add_test(NAME obj_life WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./obj_life ) add_test(NAME obj_dim WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./obj_dim ) add_test(NAME obj_buf WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./obj_buf ) +add_test(NAME obj_tags WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./obj_tags ) +add_test(NAME obj_info WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./obj_info ) +add_test(NAME obj_put_data WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./obj_put_data ) +add_test(NAME create_region WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./create_region ) +add_test(NAME region_obj_map WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./region_obj_map ) +add_test(NAME region_obj_map_2D WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./region_obj_map_2D ) +add_test(NAME region_obj_map_3D WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./region_obj_map_3D ) +add_test(NAME write_obj_int WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./write_obj o 1 int) +add_test(NAME write_obj_float WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./write_obj o 1 float) +add_test(NAME write_obj_double WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./write_obj o 1 double) +add_test(NAME write_obj_char WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./write_obj o 1 char) +add_test(NAME write_obj_uint WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./write_obj o 1 uint) +add_test(NAME write_obj_int64 WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./write_obj o 1 int64) +add_test(NAME write_obj_uint64 WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./write_obj o 1 uint64) +add_test(NAME write_obj_int16 WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./write_obj o 1 int16) +add_test(NAME write_obj_int8 WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./write_obj o 1 int8) +add_test(NAME query_data WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./query_data o 1) add_test(NAME vpicio_bdcats WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_multiple_test.sh ./vpicio ./bdcats ) +add_test(NAME vpicio_query_vpic WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_multiple_test.sh ./vpicio ./query_vpic ) +add_test(NAME vpicio_query_vpic_multi WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_multiple_test.sh ./vpicio ./query_vpic_multi ) +add_test(NAME vpicio_query_vpic_multi_preload WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_multiple_test.sh ./vpicio ./query_vpic_multi_preload ) +add_test(NAME vpicio_query_vpic_multi_nopreload1 WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_multiple_test.sh ./vpicio ./query_vpic_multi_nopreload1 ) +add_test(NAME vpicio_query_vpic_create_data WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_multiple_test.sh ./vpicio ./query_vpic_create_data ) +add_test(NAME vpicio_query_vpic_bin_sds1_nopreload WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_multiple_test.sh ./vpicio ./query_vpic_bin_sds1_nopreload ) +add_test(NAME vpicio_query_vpic_bin_sds1_preload WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_multiple_test.sh ./vpicio ./query_vpic_bin_sds1_preload ) +add_test(NAME vpicio_query_vpic_exyz_preload WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_multiple_test.sh ./vpicio ./query_vpic_exyz_preload ) +add_test(NAME vpicio_query_vpic_exyz_nopreload WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_multiple_test.sh ./vpicio ./query_vpic_exyz_nopreload ) +if(BUILD_MPI_TESTING) + add_test(NAME write_obj_shared_int WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./write_obj_shared ${MPI_RUN_CMD} 2 4 o 1 int) + add_test(NAME write_obj_shared_float WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./write_obj_shared ${MPI_RUN_CMD} 2 4 o 1 float) + add_test(NAME write_obj_shared_double WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./write_obj_shared ${MPI_RUN_CMD} 2 4 o 1 double) + add_test(NAME write_obj_shared_char WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./write_obj_shared ${MPI_RUN_CMD} 2 4 o 1 char) + add_test(NAME write_obj_shared_uint WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./write_obj_shared ${MPI_RUN_CMD} 2 4 o 1 uint) + add_test(NAME write_obj_shared_int64 WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./write_obj_shared ${MPI_RUN_CMD} 2 4 o 1 int64) + add_test(NAME write_obj_shared_uint64 WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./write_obj_shared ${MPI_RUN_CMD} 2 4 o 1 uint64) + add_test(NAME write_obj_shared_int16 WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./write_obj_shared ${MPI_RUN_CMD} 2 4 o 1 int16) + add_test(NAME write_obj_shared_int8 WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./write_obj_shared ${MPI_RUN_CMD} 2 4 o 1 int8) + add_test(NAME create_obj_coll WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./create_obj_coll ${MPI_RUN_CMD} 2 4 ) + add_test(NAME open_obj_round_robin WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./open_obj_round_robin ${MPI_RUN_CMD} 2 4 ) + add_test(NAME region_obj_map_2D_mpi WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./region_obj_map_2D ${MPI_RUN_CMD} 2 4 ) + add_test(NAME region_obj_map_3D_mpi WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./region_obj_map_3D ${MPI_RUN_CMD} 2 4 ) + add_test(NAME obj_round_robin_io WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./obj_round_robin_io ${MPI_RUN_CMD} 2 4 int ) + add_test(NAME pdc_init_mpi WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./pdc_init ${MPI_RUN_CMD} 2 4 ) + add_test(NAME create_prop_mpi WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./create_prop ${MPI_RUN_CMD} 2 4 ) + add_test(NAME set_prop_mpi WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./set_prop ${MPI_RUN_CMD} 2 4 ) + add_test(NAME dup_prop_mpi WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./dup_prop ${MPI_RUN_CMD} 2 4 ) + add_test(NAME create_cont_mpi WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./create_cont ${MPI_RUN_CMD} 2 4 ) + add_test(NAME open_cont_mpi WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./open_cont ${MPI_RUN_CMD} 2 4 ) + add_test(NAME cont_life_mpi WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./cont_life ${MPI_RUN_CMD} 2 4 ) + add_test(NAME cont_iter_mpi WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./cont_iter ${MPI_RUN_CMD} 2 4 ) + add_test(NAME cont_info_mpi WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./cont_info ${MPI_RUN_CMD} 2 4 ) + add_test(NAME cont_getid_mpi WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./cont_getid ${MPI_RUN_CMD} 2 4 ) + add_test(NAME cont_tags_mpi WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./cont_tags ${MPI_RUN_CMD} 2 4 ) + add_test(NAME create_obj_mpi WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./create_obj ${MPI_RUN_CMD} 2 4 ) + add_test(NAME open_obj_mpi WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./open_obj ${MPI_RUN_CMD} 2 4 ) + add_test(NAME obj_iter_mpi WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./obj_iter ${MPI_RUN_CMD} 2 4 ) + add_test(NAME obj_life_mpi WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./obj_life ${MPI_RUN_CMD} 2 4 ) + add_test(NAME obj_dim_mpi WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./obj_dim ${MPI_RUN_CMD} 2 4 ) + add_test(NAME obj_buf_mpi WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./obj_buf ${MPI_RUN_CMD} 2 4 ) + add_test(NAME obj_tags_mpi WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./obj_tags ${MPI_RUN_CMD} 2 4 ) + add_test(NAME obj_info_mpi WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./obj_info ${MPI_RUN_CMD} 2 4 ) + add_test(NAME obj_put_data_mpi WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./obj_put_data ${MPI_RUN_CMD} 2 4 ) + add_test(NAME create_region_mpi WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./create_region ${MPI_RUN_CMD} 2 4 ) + add_test(NAME region_obj_map_mpi WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./region_obj_map ${MPI_RUN_CMD} 2 4 ) + add_test(NAME write_obj_mpi WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./write_obj ${MPI_RUN_CMD} 2 4 o 1 int) +endif() \ No newline at end of file diff --git a/src/tests/cont_getid.c b/src/tests/cont_getid.c new file mode 100644 index 000000000..ed72e1a26 --- /dev/null +++ b/src/tests/cont_getid.c @@ -0,0 +1,101 @@ +/* + * Copyright Notice for + * Proactive Data Containers (PDC) Software Library and Utilities + * ----------------------------------------------------------------------------- + + *** Copyright Notice *** + + * Proactive Data Containers (PDC) Copyright (c) 2017, The Regents of the + * University of California, through Lawrence Berkeley National Laboratory, + * UChicago Argonne, LLC, operator of Argonne National Laboratory, and The HDF + * Group (subject to receipt of any required approvals from the U.S. Dept. of + * Energy). All rights reserved. + + * If you have questions about your rights to use or distribute this software, + * please contact Berkeley Lab's Innovation & Partnerships Office at IPO@lbl.gov. + + * NOTICE. This Software was developed under funding from the U.S. Department of + * Energy and the U.S. Government consequently retains certain rights. As such, the + * U.S. Government has been granted for itself and others acting on its behalf a + * paid-up, nonexclusive, irrevocable, worldwide license in the Software to + * reproduce, distribute copies to the public, prepare derivative works, and + * perform publicly and display publicly, and to permit other to do so. + */ + +#include +#include +#include +#include +#include +#include "pdc.h" + +int main(int argc, char **argv) +{ + int rank = 0, size = 1; + pdcid_t pdc_id, cont_prop, cont_id, cont_id2, cont_id3; + int ret_value = 0; + +#ifdef ENABLE_MPI + MPI_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); +#endif + + // create a pdc + pdc_id = PDCinit("pdc"); + + // create a container property + cont_prop = PDCprop_create(PDC_CONT_CREATE, pdc_id); + if(cont_prop <= 0) { + printf("Fail to create container property @ line %d!\n", __LINE__); + ret_value = 1; + } + // create a container + cont_id = PDCcont_create_col("c1", cont_prop); + if(cont_id <= 0) { + printf("Fail to create container @ line %d!\n", __LINE__); + ret_value = 1; + } +#ifdef ENABLE_MPI + MPI_Barrier(MPI_COMM_WORLD); +#endif + + cont_id2 = PDCcont_open("c1", pdc_id); + if(cont_id2 == 0) { + printf("Fail to open container @ line %d!\n", __LINE__); + ret_value = 1; + } +#ifdef ENABLE_MPI + MPI_Barrier(MPI_COMM_WORLD); +#endif + + cont_id3 = PDCcont_get_id("c1", pdc_id); + if(PDCcont_close(cont_id3) < 0) { + printf("fail to close container cont_id3\n"); + ret_value = 1; + } + // close a container + if(PDCcont_close(cont_id) < 0) { + printf("fail to close container cont_id1\n"); + ret_value = 1; + } + if(PDCcont_close(cont_id2) < 0) { + printf("fail to close container cont_id2\n"); + ret_value = 1; + } + // close a container property + if(PDCprop_close(cont_prop) < 0) { + printf("Fail to close property @ line %d\n", __LINE__); + ret_value = 1; + } + if(PDCclose(pdc_id) < 0) { + printf("fail to close PDC\n"); + ret_value = 1; + } +#ifdef ENABLE_MPI + MPI_Finalize(); +#endif + + return ret_value; +} + diff --git a/src/tests/cont_info.c b/src/tests/cont_info.c new file mode 100644 index 000000000..e09a0b0a8 --- /dev/null +++ b/src/tests/cont_info.c @@ -0,0 +1,94 @@ +/* + * Copyright Notice for + * Proactive Data Containers (PDC) Software Library and Utilities + * ----------------------------------------------------------------------------- + + *** Copyright Notice *** + + * Proactive Data Containers (PDC) Copyright (c) 2017, The Regents of the + * University of California, through Lawrence Berkeley National Laboratory, + * UChicago Argonne, LLC, operator of Argonne National Laboratory, and The HDF + * Group (subject to receipt of any required approvals from the U.S. Dept. of + * Energy). All rights reserved. + + * If you have questions about your rights to use or distribute this software, + * please contact Berkeley Lab's Innovation & Partnerships Office at IPO@lbl.gov. + + * NOTICE. This Software was developed under funding from the U.S. Department of + * Energy and the U.S. Government consequently retains certain rights. As such, the + * U.S. Government has been granted for itself and others acting on its behalf a + * paid-up, nonexclusive, irrevocable, worldwide license in the Software to + * reproduce, distribute copies to the public, prepare derivative works, and + * perform publicly and display publicly, and to permit other to do so. + */ + +#include +#include +#include +#include +#include +#include "pdc.h" + +int main(int argc, char **argv) +{ + int rank = 0, size = 1; + pdcid_t pdc_id, cont_prop, cont_id, cont_id2; + struct pdc_cont_info *cont_info; + +#ifdef ENABLE_MPI + MPI_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); +#endif + + // create a pdc + pdc_id = PDCinit("pdc"); + + // create a container property + cont_prop = PDCprop_create(PDC_CONT_CREATE, pdc_id); + if(cont_prop <= 0) + printf("Fail to create container property @ line %d!\n", __LINE__); + + // create a container + cont_id = PDCcont_create_col("c1", cont_prop); + if(cont_id <= 0) + printf("Fail to create container @ line %d!\n", __LINE__); + +#ifdef ENABLE_MPI + MPI_Barrier(MPI_COMM_WORLD); +#endif + + cont_id2 = PDCcont_open("c1", pdc_id); + if(cont_id2 == 0) + printf("Fail to open container @ line %d!\n", __LINE__); +#ifdef ENABLE_MPI + MPI_Barrier(MPI_COMM_WORLD); +#endif + + cont_info = PDCcont_get_info("c1"); + if (strcmp(cont_info->name, "c1")) { + printf("container get info with wrong name\n"); + return 1; + } + + // close a container + if(PDCcont_close(cont_id) < 0) + printf("fail to close container cont_id1\n"); + + if(PDCcont_close(cont_id2) < 0) + printf("fail to close container cont_id2\n"); + + // close a container property + if(PDCprop_close(cont_prop) < 0) + printf("Fail to close property @ line %d\n", __LINE__); + + if(PDCclose(pdc_id) < 0) + printf("fail to close PDC\n"); + +#ifdef ENABLE_MPI + MPI_Finalize(); +#endif + + return 0; +} + diff --git a/src/tests/cont_iter.c b/src/tests/cont_iter.c index d01f27056..ba3b0ee41 100644 --- a/src/tests/cont_iter.c +++ b/src/tests/cont_iter.c @@ -32,6 +32,7 @@ int main(int argc, char **argv) { pdcid_t pdc, create_prop, cont1, cont2, cont3; cont_handle *ch; int rank = 0, size = 1; + int ret_value = 0; #ifdef ENABLE_MPI MPI_Init(&argc, &argv); @@ -44,32 +45,36 @@ int main(int argc, char **argv) { // create a container property create_prop = PDCprop_create(PDC_CONT_CREATE, pdc); - if(create_prop > 0) + if(create_prop > 0) { printf("Create a container property\n"); - else + } else { printf("Fail to create container property @ line %d!\n", __LINE__); - + ret_value = 1; + } // create a container cont1 = PDCcont_create("c1", create_prop); - if(cont1 > 0) + if(cont1 > 0) { printf("Create a container c1\n"); - else + } else { printf("Fail to create container @ line %d!\n", __LINE__); - + ret_value = 1; + } // create second container cont2 = PDCcont_create("c2", create_prop); - if(cont2 > 0) + if(cont2 > 0) { printf("Create a container c2\n"); - else + } else { printf("Fail to create container @ line %d!\n", __LINE__); - + ret_value = 1; + } // create third container cont3 = PDCcont_create("c3", create_prop); - if(cont3 > 0) + if(cont3 > 0) { printf("Create a container c3\n"); - else + } else { printf("Fail to create container @ line %d!\n", __LINE__); - + ret_value = 1; + } // start container iteration ch = PDCcont_iter_start(pdc); @@ -81,36 +86,41 @@ int main(int argc, char **argv) { } // close cont1 - if(PDCcont_close(cont1) < 0) + if(PDCcont_close(cont1) < 0) { printf("fail to close container c1\n"); - else + ret_value = 1; + } else { printf("successfully close container c1\n"); - + } // close cont2 - if(PDCcont_close(cont2) < 0) + if(PDCcont_close(cont2) < 0) { printf("fail to close container c2\n"); - else + ret_value = 1; + } else { printf("successfully close container c2\n"); - + } // close cont3 - if(PDCcont_close(cont3) < 0) + if(PDCcont_close(cont3) < 0) { printf("fail to close container c3\n"); - else + ret_value = 1; + } else { printf("successfully close container c3\n"); - + } // close a container property - if(PDCprop_close(create_prop) < 0) + if(PDCprop_close(create_prop) < 0) { printf("Fail to close property @ line %d\n", __LINE__); - else + ret_value = 1; + } else { printf("successfully close container property\n"); - + } // close pdc - if(PDCclose(pdc) < 0) - printf("fail to close PDC\n"); - + if(PDCclose(pdc) < 0) { + printf("fail to close PDC\n"); + ret_value = 1; + } #ifdef ENABLE_MPI MPI_Finalize(); #endif - return 0; + return ret_value; } diff --git a/src/tests/cont_life.c b/src/tests/cont_life.c index aed2b272d..ce9cc2d87 100644 --- a/src/tests/cont_life.c +++ b/src/tests/cont_life.c @@ -32,6 +32,7 @@ int main(int argc, char **argv) pdcid_t pdc, create_prop, cont; struct _pdc_cont_prop *prop; int rank = 0, size = 1; + int ret_value = 0; #ifdef ENABLE_MPI MPI_Init(&argc, &argv); @@ -44,21 +45,23 @@ int main(int argc, char **argv) // create a container property create_prop = PDCprop_create(PDC_CONT_CREATE, pdc); - if(create_prop > 0) + if(create_prop > 0) { printf("Create a container property\n"); - else + } else { printf("Fail to create container property @ line %d!\n", __LINE__); - + ret_value = 1; + } // print default container lifetime (persistent) prop = PDCcont_prop_get_info(create_prop); // create a container cont = PDCcont_create("c1", create_prop); - if(cont > 0) + if(cont > 0) { printf("Create a container, c1\n"); - else + } else { printf("Fail to create container @ line %d!\n", __LINE__); - + ret_value = 1; + } // set container lifetime to transient PDCprop_set_cont_lifetime(create_prop, PDC_TRANSIENT); prop = PDCcont_prop_get_info(create_prop); @@ -68,25 +71,28 @@ int main(int argc, char **argv) prop = PDCcont_prop_get_info(create_prop); // close a container - if(PDCcont_close(cont) < 0) + if(PDCcont_close(cont) < 0) { printf("fail to close container c1\n"); - else + ret_value = 1; + } else { printf("successfully close container c1\n"); - + } // close a container property - if(PDCprop_close(create_prop) < 0) + if(PDCprop_close(create_prop) < 0) { printf("Fail to close property @ line %d\n", __LINE__); - else + ret_value = 1; + } else { printf("successfully close container property\n"); - + } // close pdc - if(PDCclose(pdc) < 0) - printf("fail to close PDC\n"); - + if(PDCclose(pdc) < 0) { + printf("fail to close PDC\n"); + ret_value = 1; + } #ifdef ENABLE_MPI MPI_Finalize(); #endif - return 0; + return ret_value; } diff --git a/src/tests/cont_tags.c b/src/tests/cont_tags.c new file mode 100644 index 000000000..300c59988 --- /dev/null +++ b/src/tests/cont_tags.c @@ -0,0 +1,168 @@ +/* + * Copyright Notice for + * Proactive Data Containers (PDC) Software Library and Utilities + * ----------------------------------------------------------------------------- + + *** Copyright Notice *** + + * Proactive Data Containers (PDC) Copyright (c) 2017, The Regents of the + * University of California, through Lawrence Berkeley National Laboratory, + * UChicago Argonne, LLC, operator of Argonne National Laboratory, and The HDF + * Group (subject to receipt of any required approvals from the U.S. Dept. of + * Energy). All rights reserved. + + * If you have questions about your rights to use or distribute this software, + * please contact Berkeley Lab's Innovation & Partnerships Office at IPO@lbl.gov. + + * NOTICE. This Software was developed under funding from the U.S. Department of + * Energy and the U.S. Government consequently retains certain rights. As such, the + * U.S. Government has been granted for itself and others acting on its behalf a + * paid-up, nonexclusive, irrevocable, worldwide license in the Software to + * reproduce, distribute copies to the public, prepare derivative works, and + * perform publicly and display publicly, and to permit other to do so. + */ + +#include +#include +#include +#include "pdc.h" + + +int main(int argc, char **argv) { + pdcid_t pdc, cont_prop, cont, cont2; + perr_t ret; + int ret_value = 0; + + int rank = 0, size = 1; + + char tag_value[128], tag_value2[128], *tag_value_ret; + psize_t value_size; + strcpy(tag_value, "some tag value"); + strcpy(tag_value2, "some tag value 2 is longer than tag 1"); + +#ifdef ENABLE_MPI + MPI_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); +#endif + // create a pdc + pdc = PDCinit("pdc"); + printf("create a new pdc\n"); + + // create a container property + cont_prop = PDCprop_create(PDC_CONT_CREATE, pdc); + if(cont_prop > 0) { + printf("Create a container property\n"); + } else { + printf("Fail to create container property @ line %d!\n", __LINE__); + ret_value = 1; + } + // create a container + cont = PDCcont_create("c1", cont_prop); + if(cont > 0) { + printf("Create a container c1\n"); + } else { + printf("Fail to create container @ line %d!\n", __LINE__); + ret_value = 1; + } + + cont2 = PDCcont_create("c2", cont_prop); + if(cont > 0) { + printf("Create a container c2\n"); + } else { + printf("Fail to create container @ line %d!\n", __LINE__); + ret_value = 1; + } + + ret = PDCcont_put_tag(cont, "some tag", tag_value, strlen(tag_value) + 1); + + if ( ret != SUCCEED ) { + printf("Put tag failed at container 1\n"); + ret_value = 1; + } + ret = PDCcont_put_tag(cont, "some tag 2", tag_value2, strlen(tag_value2) + 1); + if ( ret != SUCCEED ) { + printf("Put tag failed at container 1\n"); + ret_value = 1; + } + + ret = PDCcont_put_tag(cont2, "some tag", tag_value, strlen(tag_value) + 1); + if ( ret != SUCCEED ) { + printf("Put tag failed at container 2\n"); + ret_value = 1; + } + + ret = PDCcont_put_tag(cont2, "some tag 2", tag_value2, strlen(tag_value2) + 1); + if ( ret != SUCCEED ) { + printf("Put tag failed at container 2\n"); + ret_value = 1; + } + + ret = PDCcont_get_tag(cont, "some tag", (void **)&tag_value_ret, &value_size); + if ( ret != SUCCEED ) { + printf("Get tag failed at container 1\n"); + ret_value = 1; + } + if (strcmp(tag_value, tag_value_ret) != 0) { + printf("Wrong tag value at container 1, expected = [%s], get [%s]\n", tag_value, tag_value_ret); + ret_value = 1; + } + + ret = PDCcont_get_tag(cont, "some tag 2", (void **)&tag_value_ret, &value_size); + if ( ret != SUCCEED ) { + printf("Get tag failed at container 1\n"); + ret_value = 1; + } + + if (strcmp(tag_value2, tag_value_ret) != 0) { + printf("Wrong tag value at container 1, expected = [%s], get [%s]\n", tag_value2, tag_value_ret); + ret_value = 1; + } + + ret = PDCcont_get_tag(cont2, "some tag", (void **)&tag_value_ret, &value_size); + if ( ret != SUCCEED ) { + printf("Get tag failed at container 2\n"); + ret_value = 1; + } + + if (strcmp(tag_value, tag_value_ret) != 0) { + printf("Wrong tag value at container 2, expected = [%s], get [%s]\n", tag_value, tag_value_ret); + ret_value = 1; + } + + ret = PDCcont_get_tag(cont2, "some tag 2", (void **)&tag_value_ret, &value_size); + if ( ret != SUCCEED ) { + printf("Get tag failed at container 2\n"); + ret_value = 1; + } + + if (strcmp(tag_value2, tag_value_ret) != 0) { + printf("Wrong tag value at container 2, expected = [%s], get [%s]\n", tag_value2, tag_value_ret); + ret_value = 1; + } + + + // close a container + if(PDCcont_close(cont) < 0) { + printf("fail to close container c1\n"); + ret_value = 1; + } else { + printf("successfully close container c1\n"); + } + // close a container property + if(PDCprop_close(cont_prop) < 0) { + printf("Fail to close property @ line %d\n", __LINE__); + ret_value = 1; + } else { + printf("successfully close container property\n"); + } + // close pdc + if(PDCclose(pdc) < 0) { + printf("fail to close PDC\n"); + ret_value = 1; + } +#ifdef ENABLE_MPI + MPI_Finalize(); +#endif + return ret_value; +} diff --git a/src/tests/create_cont.c b/src/tests/create_cont.c index 6b46817c3..2da7049f6 100644 --- a/src/tests/create_cont.c +++ b/src/tests/create_cont.c @@ -32,6 +32,8 @@ int main(int argc, char **argv) pdcid_t pdc, create_prop, cont; int rank = 0, size = 1; + int ret_value = 0; + #ifdef ENABLE_MPI MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); @@ -44,37 +46,42 @@ int main(int argc, char **argv) // create a container property create_prop = PDCprop_create(PDC_CONT_CREATE, pdc); - if(create_prop > 0) + if(create_prop > 0) { printf("Create a container property\n"); - else + } else { printf("Fail to create container property @ line %d!\n", __LINE__); - + ret_value = 1; + } // create a container cont = PDCcont_create("c1", create_prop); - if(cont > 0) + if(cont > 0) { printf("Create a container c1\n"); - else + } else { printf("Fail to create container @ line %d!\n", __LINE__); - + ret_value = 1; + } // close a container - if(PDCcont_close(cont) < 0) + if(PDCcont_close(cont) < 0) { printf("fail to close container c1\n"); - else + ret_value = 1; + } else { printf("successfully close container c1\n"); - + } // close a container property - if(PDCprop_close(create_prop) < 0) + if(PDCprop_close(create_prop) < 0) { printf("Fail to close property @ line %d\n", __LINE__); - else + ret_value = 1; + } else { printf("successfully close container property\n"); - + } // close pdc - if(PDCclose(pdc) < 0) - printf("fail to close PDC\n"); - + if(PDCclose(pdc) < 0) { + printf("fail to close PDC\n"); + ret_value = 1; + } #ifdef ENABLE_MPI MPI_Finalize(); #endif - return 0; + return ret_value; } diff --git a/src/tests/create_obj.c b/src/tests/create_obj.c index 5081865d7..43df80d7a 100644 --- a/src/tests/create_obj.c +++ b/src/tests/create_obj.c @@ -29,75 +29,100 @@ #include #include "pdc.h" -int main() { +int main(int argc, char **argv) { pdcid_t pdc, cont_prop, cont, obj_prop, obj1, obj2; + int ret_value = 0; + int rank = 0; + char cont_name[128], obj_name1[128], obj_name2[128]; // create a pdc +#ifdef ENABLE_MPI + int size; + MPI_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); +#endif pdc = PDCinit("pdc"); printf("create a new pdc\n"); // create a container property cont_prop = PDCprop_create(PDC_CONT_CREATE, pdc); - if(cont_prop > 0) + if(cont_prop > 0) { printf("Create a container property\n"); - else + } else { printf("Fail to create container property @ line %d!\n", __LINE__); - + ret_value = 1; + } // create a container - cont = PDCcont_create("c1", cont_prop); - if(cont > 0) + sprintf(cont_name, "c%d", rank); + cont = PDCcont_create(cont_name, cont_prop); + if(cont > 0) { printf("Create a container c1\n"); - else + } else { printf("Fail to create container @ line %d!\n", __LINE__); - + ret_value = 1; + } // create an object property obj_prop = PDCprop_create(PDC_OBJ_CREATE, pdc); - if(obj_prop > 0) + if(obj_prop > 0) { printf("Create an object property\n"); - else + } else { printf("Fail to create object property @ line %d!\n", __LINE__); - + ret_value = 1; + } // create first object - obj1 = PDCobj_create(cont, "o1", obj_prop); - if(obj1 > 0) + sprintf(obj_name1, "o1_%d", rank); + obj1 = PDCobj_create(cont, obj_name1, obj_prop); + if(obj1 > 0) { printf("Create an object o1\n"); - else + } else { printf("Fail to create object @ line %d!\n", __LINE__); - + ret_value = 1; + } // create second object - obj2 = PDCobj_create(cont, "o2", obj_prop); - if(obj2 > 0) + sprintf(obj_name2, "o2_%d", rank); + obj2 = PDCobj_create(cont, obj_name2, obj_prop); + if(obj2 > 0) { printf("Create an object o2\n"); - else + } else { printf("Fail to create object @ line %d!\n", __LINE__); - + ret_value = 1; + } // close first object - if(PDCobj_close(obj1) < 0) + if(PDCobj_close(obj1) < 0) { printf("fail to close object o1\n"); - else + ret_value = 1; + } else { printf("successfully close object o1\n"); - + } // close second object - if(PDCobj_close(obj2) < 0) + if(PDCobj_close(obj2) < 0) { printf("fail to close object o2\n"); - else + ret_value = 1; + } else { printf("successfully close object o2\n"); - + } // close a container - if(PDCcont_close(cont) < 0) + if(PDCcont_close(cont) < 0) { printf("fail to close container c1\n"); - else + ret_value = 1; + } else { printf("successfully close container c1\n"); - + } // close a container property - if(PDCprop_close(cont_prop) < 0) + if(PDCprop_close(cont_prop) < 0) { printf("Fail to close property @ line %d\n", __LINE__); - else + ret_value = 1; + } else { printf("successfully close container property\n"); - + } // close pdc - if(PDCclose(pdc) < 0) - printf("fail to close PDC\n"); - - return 0; + if(PDCclose(pdc) < 0) { + printf("fail to close PDC\n"); + ret_value = 1; + } +#ifdef ENABLE_MPI + MPI_Finalize(); +#endif + return ret_value; } diff --git a/src/tests/create_obj_coll.c b/src/tests/create_obj_coll.c new file mode 100644 index 000000000..4adc8656d --- /dev/null +++ b/src/tests/create_obj_coll.c @@ -0,0 +1,175 @@ +/* + * Copyright Notice for + * Proactive Data Containers (PDC) Software Library and Utilities + * ----------------------------------------------------------------------------- + + *** Copyright Notice *** + + * Proactive Data Containers (PDC) Copyright (c) 2017, The Regents of the + * University of California, through Lawrence Berkeley National Laboratory, + * UChicago Argonne, LLC, operator of Argonne National Laboratory, and The HDF + * Group (subject to receipt of any required approvals from the U.S. Dept. of + * Energy). All rights reserved. + + * If you have questions about your rights to use or distribute this software, + * please contact Berkeley Lab's Innovation & Partnerships Office at IPO@lbl.gov. + + * NOTICE. This Software was developed under funding from the U.S. Department of + * Energy and the U.S. Government consequently retains certain rights. As such, the + * U.S. Government has been granted for itself and others acting on its behalf a + * paid-up, nonexclusive, irrevocable, worldwide license in the Software to + * reproduce, distribute copies to the public, prepare derivative works, and + * perform publicly and display publicly, and to permit other to do so. + */ + +#include +#include +#include +#include "pdc.h" + +int main(int argc, char **argv) { + pdcid_t pdc, cont_prop, cont, obj_prop; + pdcid_t obj1, obj2, open11, open12, open21; + int rank = 0, size = 1; + int ret_value = 0; + char cont_name[128], obj_name1[128], obj_name2[128]; + +#ifdef ENABLE_MPI + MPI_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); +#endif + // create a pdc + pdc = PDCinit("pdc"); + printf("create a new pdc\n"); + + // create a container property + cont_prop = PDCprop_create(PDC_CONT_CREATE, pdc); + if(cont_prop > 0) { + printf("Rank %d Create a container property\n", rank); + } else { + printf("Rank %d Fail to create container property @ line %d!\n", rank, __LINE__); + ret_value = 1; + } + // create a container + sprintf(cont_name, "c%d", rank); + cont = PDCcont_create(cont_name, cont_prop); + if(cont > 0) { + printf("Rank %d Create a container c1\n", rank); + } else { + printf("Rank %d Fail to create container @ line %d!\n", rank, __LINE__); + ret_value = 1; + } + // create an object property + obj_prop = PDCprop_create(PDC_OBJ_CREATE, pdc); + if(obj_prop > 0) { + printf("Rank %d Create an object property\n", rank); + } else { + printf("Rank %d Fail to create object property @ line %d!\n", rank, __LINE__); + ret_value = 1; + } + // create first object + sprintf(obj_name1, "o1"); + obj1 = PDCobj_create_mpi(cont, obj_name1, obj_prop, 0, MPI_COMM_WORLD); + if(obj1 > 0) { + printf("Rank %d Create an object o1\n", rank); + } else { + printf("Rank %d Fail to create object @ line %d!\n", rank, __LINE__); + ret_value = 1; + } + printf("checkpoint 1 rank %d\n", rank); + // create second object + sprintf(obj_name2, "o2"); + obj2 = PDCobj_create_mpi(cont, obj_name2, obj_prop, 0, MPI_COMM_WORLD); + if(obj2 > 0) { + printf("Rank %d Create an object o2\n", rank); + } else { + printf("Rank %d Fail to create object @ line %d!\n", rank, __LINE__); + ret_value = 1; + } + printf("checkpoint 2 rank %d\n", rank); + // open first object twice + open11 = PDCobj_open(obj_name1, pdc); + if(open11 == 0) { + printf("Rank %d Fail to open object o1\n", rank); + ret_value = 1; + } else { + printf("Rank %d Open object o1\n", rank); + } + open12 = PDCobj_open(obj_name1, pdc); + if(open12 == 0) { + printf("Rank %d Fail to open object o1\n", rank); + ret_value = 1; + } else { + printf("Rank %d Open object o1\n", rank); + } + // open second object once + open21 = PDCobj_open(obj_name2, pdc); + if(open21 == 0) { + printf("Rank %d Fail to open object o2\n", rank); + ret_value = 1; + } else { + printf("Rank %d Open object o2\n", rank); + } + // close object + if(PDCobj_close(obj1) < 0) { + printf("Rank %d fail to close object o1\n", rank); + ret_value = 1; + } else { + printf("Rank %d successfully close object o1\n", rank); + } + if(PDCobj_close(open11) < 0) { + printf("Rank %d fail to close object open11\n", rank); + ret_value = 1; + } else { + printf("Rank %d successfully close object open11\n", rank); + } + if(PDCobj_close(open12) < 0) { + printf("Rank %d fail to close object open12\n", rank); + ret_value = 1; + } else { + printf("Rank %d successfully close object open12\n", rank); + } + if(PDCobj_close(obj2) < 0) { + printf("Rank %d fail to close object o2\n", rank); + ret_value = 1; + } else { + printf("Rank %d successfully close object o2\n", rank); + } + if(PDCobj_close(open21) < 0) { + printf("Rank %d fail to close object open21\n", rank); + ret_value = 1; + } else { + printf("Rank %d successfully close object open21\n", rank); + } + // close a container + if(PDCcont_close(cont) < 0) { + printf("Rank %d fail to close container c1\n", rank); + ret_value = 1; + } else { + printf("Rank %d successfully close container c1\n", rank); + } + // close a object property + if(PDCprop_close(obj_prop) < 0) { + printf("Rank %d Fail to close property @ line %d\n", rank, __LINE__); + ret_value = 1; + } else { + printf("Rank %d successfully close object property\n", rank); + } + // close a container property + if(PDCprop_close(cont_prop) < 0) { + printf("Rank %d Fail to close property @ line %d\n", rank, __LINE__); + ret_value = 1; + } else { + printf("Rank %d successfully close container property\n", rank); + } + // close pdc + if(PDCclose(pdc) < 0) { + printf("Rank %d fail to close PDC\n", rank); + ret_value = 1; + } +#ifdef ENABLE_MPI + MPI_Finalize(); +#endif + return ret_value; +} diff --git a/src/tests/create_prop.c b/src/tests/create_prop.c index b70eb1dc9..d5a51c4a3 100644 --- a/src/tests/create_prop.c +++ b/src/tests/create_prop.c @@ -31,6 +31,7 @@ int main(int argc, char **argv) { pdcid_t pdc, create_prop1, create_prop2, create_prop; pdc_prop_type_t type = PDC_CONT_CREATE; int rank = 0, size = 1; + int ret_value = 0; #ifdef ENABLE_MPI MPI_Init(&argc, &argv); @@ -45,22 +46,27 @@ int main(int argc, char **argv) { create_prop1 = PDCprop_create(PDC_OBJ_CREATE, pdc); if(create_prop1 <= 0) { printf("Fail to create @ line %d\n", __LINE__); + ret_value = 1; } // create another object property create_prop2 = PDCprop_create(PDC_OBJ_CREATE, pdc); if(create_prop2 <= 0) { printf("Fail to create @ line %d\n", __LINE__); + ret_value = 1; } - if(PDCprop_close(create_prop1)<0) + if(PDCprop_close(create_prop1)<0) { printf("Fail to close property @ line %d\n", __LINE__); - else + ret_value = 1; + } else { printf("successfully close first property\n"); - if(PDCprop_close(create_prop2)<0) + } + if(PDCprop_close(create_prop2)<0) { printf("Fail to close property @ line %d\n", __LINE__); - else + ret_value = 1; + } else { printf("successfully close second property\n"); - + } // create a container property create_prop = PDCprop_create(PDC_CONT_CREATE, pdc); if(create_prop > 0) { @@ -69,21 +75,24 @@ int main(int argc, char **argv) { else if(type == PDC_OBJ_CREATE) printf("Create an object property\n"); } - else + else { printf("Fail to create @ line %d!\n", __LINE__); - + ret_value = 1; + } // close property - if(PDCprop_close(create_prop)<0) - printf("Fail to close property @ line %d\n", __LINE__); - else - printf("successfully close property\n"); - + if(PDCprop_close(create_prop)<0) { + printf("Fail to close property @ line %d\n", __LINE__); + ret_value = 1; + } else { + printf("successfully close property\n"); + } // close a pdc - if(PDCclose(pdc) < 0) - printf("fail to close PDC\n"); - + if(PDCclose(pdc) < 0) { + printf("fail to close PDC\n"); + ret_value = 1; + } #ifdef ENABLE_MPI MPI_Finalize(); #endif - return 0; + return ret_value; } diff --git a/src/tests/create_region.c b/src/tests/create_region.c new file mode 100644 index 000000000..184a4d5a4 --- /dev/null +++ b/src/tests/create_region.c @@ -0,0 +1,75 @@ +/* + * Copyright Notice for + * Proactive Data Containers (PDC) Software Library and Utilities + * ----------------------------------------------------------------------------- + + *** Copyright Notice *** + + * Proactive Data Containers (PDC) Copyright (c) 2017, The Regents of the + * University of California, through Lawrence Berkeley National Laboratory, + * UChicago Argonne, LLC, operator of Argonne National Laboratory, and The HDF + * Group (subject to receipt of any required approvals from the U.S. Dept. of + * Energy). All rights reserved. + + * If you have questions about your rights to use or distribute this software, + * please contact Berkeley Lab's Innovation & Partnerships Office at IPO@lbl.gov. + + * NOTICE. This Software was developed under funding from the U.S. Department of + * Energy and the U.S. Government consequently retains certain rights. As such, the + * U.S. Government has been granted for itself and others acting on its behalf a + * paid-up, nonexclusive, irrevocable, worldwide license in the Software to + * reproduce, distribute copies to the public, prepare derivative works, and + * perform publicly and display publicly, and to permit other to do so. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "pdc.h" + +int main(int argc, char **argv) { + pdcid_t pdc; + int ret_value = 0; + uint64_t offset[3], offset_length[3]; + int rank = 0, size = 1; + offset[0] = 0; + offset[1] = 2; + offset[2] = 5; + offset_length[0] = 2; + offset_length[1] = 3; + offset_length[2] = 5; + +#ifdef ENABLE_MPI + MPI_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); +#endif + + // create a pdc + + pdc = PDCinit("pdc"); + printf("create a new pdc\n"); + + PDCregion_create(3, offset, offset_length); + + PDCregion_create(2, offset, offset_length); + + PDCregion_create(1, offset, offset_length); + + // close pdc + if(PDCclose(pdc) < 0) { + printf("fail to close PDC\n"); + ret_value = 1; + } + +#ifdef ENABLE_MPI + MPI_Finalize(); +#endif + return ret_value; +} diff --git a/src/tests/dup_prop.c b/src/tests/dup_prop.c new file mode 100644 index 000000000..bc1c247c9 --- /dev/null +++ b/src/tests/dup_prop.c @@ -0,0 +1,87 @@ +/* + * Copyright Notice for + * Proactive Data Containers (PDC) Software Library and Utilities + * ----------------------------------------------------------------------------- + + *** Copyright Notice *** + + * Proactive Data Containers (PDC) Copyright (c) 2017, The Regents of the + * University of California, through Lawrence Berkeley National Laboratory, + * UChicago Argonne, LLC, operator of Argonne National Laboratory, and The HDF + * Group (subject to receipt of any required approvals from the U.S. Dept. of + * Energy). All rights reserved. + + * If you have questions about your rights to use or distribute this software, + * please contact Berkeley Lab's Innovation & Partnerships Office at IPO@lbl.gov. + + * NOTICE. This Software was developed under funding from the U.S. Department of + * Energy and the U.S. Government consequently retains certain rights. As such, the + * U.S. Government has been granted for itself and others acting on its behalf a + * paid-up, nonexclusive, irrevocable, worldwide license in the Software to + * reproduce, distribute copies to the public, prepare derivative works, and + * perform publicly and display publicly, and to permit other to do so. + */ + +#include +#include +#include +#include "pdc.h" + +int main(int argc, char **argv) { + pdcid_t pdc, create_prop1, create_prop2, dup_prop; + int rank = 0, size = 1; + int ret_value = 0; + +#ifdef ENABLE_MPI + MPI_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); +#endif + + // create a pdc + pdc = PDCinit("pdc"); + + // create an object property + create_prop1 = PDCprop_create(PDC_OBJ_CREATE, pdc); + if(create_prop1 <= 0) { + printf("Fail to create @ line %d\n", __LINE__); + ret_value = 1; + } + // create another object property + create_prop2 = PDCprop_create(PDC_OBJ_CREATE, pdc); + if(create_prop2 <= 0) { + printf("Fail to create @ line %d\n", __LINE__); + ret_value = 1; + } + + dup_prop = PDCprop_obj_dup(create_prop2); + if(PDCprop_close(dup_prop)<0) { + printf("Fail to close property @ line %d\n", __LINE__); + ret_value = 1; + } else { + printf("successfully close first property\n"); + } + + if(PDCprop_close(create_prop1)<0) { + printf("Fail to close property @ line %d\n", __LINE__); + ret_value = 1; + } else { + printf("successfully close first property\n"); + } + + if(PDCprop_close(create_prop2)<0) { + printf("Fail to close property @ line %d\n", __LINE__); + ret_value = 1; + } else { + printf("successfully close second property\n"); + } + // close a pdc + if(PDCclose(pdc) < 0) { + printf("fail to close PDC\n"); + ret_value = 1; + } +#ifdef ENABLE_MPI + MPI_Finalize(); +#endif + return ret_value; +} diff --git a/src/tests/kvtag_add_get.c b/src/tests/kvtag_add_get.c index 139eddd30..e0ac38419 100644 --- a/src/tests/kvtag_add_get.c +++ b/src/tests/kvtag_add_get.c @@ -37,6 +37,7 @@ int main() { int v2 = 2; double v3 = 3.45; pdc_kvtag_t *value1, *value2, *value3; + psize_t value_size; // create a pdc pdc = PDCinit("pdc"); @@ -95,32 +96,32 @@ int main() { kvtag3.value = (void*)&v3; kvtag3.size = sizeof(double); - if (PDC_add_kvtag(obj1, &kvtag1) < 0) + if (PDCobj_put_tag(obj1, kvtag1.name, kvtag1.value, kvtag1.size) < 0) printf("fail to add a kvtag to o1\n"); else printf("successfully added a kvtag to o1\n"); - if (PDC_add_kvtag(obj2, &kvtag2) < 0) + if (PDCobj_put_tag(obj2, kvtag2.name, kvtag2.value, kvtag2.size) < 0) printf("fail to add a kvtag to o1\n"); else printf("successfully added a kvtag to o1\n"); - if (PDC_add_kvtag(obj2, &kvtag3) < 0) + if (PDCobj_put_tag(obj2, kvtag3.name, kvtag3.value, kvtag3.size) < 0) printf("fail to add a kvtag to o1\n"); else printf("successfully added a kvtag to o1\n"); - if (PDC_get_kvtag(obj1, kvtag1.name, &value1) < 0) + if (PDCobj_get_tag(obj1, kvtag1.name, &value1, &value_size) < 0) printf("fail to get a kvtag from o1\n"); else printf("successfully retrieved a kvtag [%s] = [%s] from o1\n", value1->name, (char*)value1->value); - if (PDC_get_kvtag(obj2, kvtag2.name, &value2) < 0) + if (PDCobj_get_tag(obj2, kvtag2.name, &value2, &value_size) < 0) printf("fail to get a kvtag from o2\n"); else printf("successfully retrieved a kvtag [%s] = [%d] from o2\n", value2->name, *(int*)value2->value); - if (PDC_get_kvtag(obj2, kvtag3.name, &value3) < 0) + if (PDCobj_get_tag(obj2, kvtag3.name, &value3, &value_size) < 0) printf("fail to get a kvtag from o2\n"); else printf("successfully retrieved a kvtag [%s] = [%f] from o2\n", value3->name, *(double*)value3->value); @@ -133,14 +134,14 @@ int main() { v1 = "New Value After Delete"; kvtag1.value = (void*)v1; kvtag1.size = strlen(v1)+1; - if (PDC_add_kvtag(obj1, &kvtag1) < 0) + if (PDCobj_put_tag(obj1, kvtag1.name, kvtag1.value, kvtag1.size) < 0) printf("fail to add a kvtag to o1\n"); else printf("successfully added a kvtag to o1\n"); PDC_free_kvtag(&value1); - if (PDC_get_kvtag(obj1, kvtag1.name, &value1) < 0) + if (PDCobj_get_tag(obj1, kvtag1.name, &value1, &value_size) < 0) printf("fail to get a kvtag from o1\n"); else printf("successfully retrieved a kvtag [%s] = [%s] from o1\n", value1->name, (char*)value1->value); diff --git a/src/tests/kvtag_add_get_scale.c b/src/tests/kvtag_add_get_scale.c index 556c8b2a7..b9971aed1 100644 --- a/src/tests/kvtag_add_get_scale.c +++ b/src/tests/kvtag_add_get_scale.c @@ -73,6 +73,7 @@ int main(int argc, char *argv[]) char tag[128]; pdc_kvtag_t kvtag; pdc_kvtag_t **values; + size_t value_size; #ifdef ENABLE_MPI MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &proc_num); @@ -142,7 +143,7 @@ int main(int argc, char *argv[]) #endif for (i = 0; i < my_add_tag; i++) { v = i+my_add_tag_s; - if (PDC_add_kvtag(obj_ids[i], &kvtag) < 0) + if (PDCobj_put_tag(obj_ids[i], kvtag.name, kvtag.value, kvtag.size) < 0) printf("fail to add a kvtag to o%d\n", i+my_obj_s); } @@ -160,7 +161,7 @@ int main(int argc, char *argv[]) stime = MPI_Wtime(); #endif for (i = 0; i < my_query; i++) { - if (PDC_get_kvtag(obj_ids[i], kvtag.name, &values[i]) < 0) + if (PDCobj_get_tag(obj_ids[i], kvtag.name, &values[i], &value_size) < 0) printf("fail to get a kvtag from o%d\n", i+my_query_s); } @@ -173,24 +174,6 @@ int main(int argc, char *argv[]) fflush(stdout); - // Add old format tags -#ifdef ENABLE_MPI - MPI_Barrier(MPI_COMM_WORLD); - stime = MPI_Wtime(); -#endif - for (i = 0; i < my_add_tag; i++) { - sprintf(tag, "Group=%d", i+my_add_tag_s); - if (PDC_Client_add_tag(obj_ids[i], tag) < 0) - printf("fail to add a tag to o%d\n", i+my_obj_s); - } - -#ifdef ENABLE_MPI - MPI_Barrier(MPI_COMM_WORLD); - total_time = MPI_Wtime() - stime; -#endif - if (my_rank == 0) - printf("Total time to add tags (old format) to %d objects: %.4f\n", n_add_tag, total_time); - for (i = 0; i < my_query; i++) { if (*(int*)(values[i]->value) != i+my_add_tag_s) printf("Error with retrieved tag from o%d\n", i+my_query_s); diff --git a/src/tests/kvtag_get.c b/src/tests/kvtag_get.c index 185b94a19..2e31dc326 100644 --- a/src/tests/kvtag_get.c +++ b/src/tests/kvtag_get.c @@ -33,6 +33,7 @@ int main() { pdcid_t pdc, cont_prop, cont, obj_prop1, obj_prop2, obj1, obj2; pdc_kvtag_t *value1, *value2, *value3; + psize_t value_size; // create a pdc pdc = PDCinit("pdc"); @@ -79,24 +80,24 @@ int main() { else printf("Fail to create object @ line %d!\n", __LINE__); - if (PDC_get_kvtag(obj1, "key1string", &value1) < 0) + if (PDCobj_get_tag(obj1, "key1string", &value1, &value_size) < 0) printf("fail to get a kvtag from o1\n"); else printf("successfully retrieved a kvtag [%s] = [%s] from o1\n", value1->name, (char*)value1->value); - if (PDC_get_kvtag(obj2, "key2int", &value2) < 0) + if (PDCobj_get_tag(obj2, "key2int", &value2, &value_size) < 0) printf("fail to get a kvtag from o2\n"); else printf("successfully retrieved a kvtag [%s] = [%d] from o2\n", value2->name, *(int*)value2->value); - if (PDC_get_kvtag(obj2, "key3double", &value3) < 0) + if (PDCobj_get_tag(obj2, "key3double", &value3, &value_size) < 0) printf("fail to get a kvtag from o2\n"); else printf("successfully retrieved a kvtag [%s] = [%f] from o2\n", value3->name, *(double*)value3->value); PDC_free_kvtag(&value1); - if (PDC_get_kvtag(obj1, "key1string", &value1) < 0) + if (PDCobj_get_tag(obj1, "key1string", &value1, &value_size) < 0) printf("fail to get a kvtag from o1\n"); else printf("successfully retrieved a kvtag [%s] = [%s] from o1\n", value1->name, (char*)value1->value); diff --git a/src/tests/kvtag_query.c b/src/tests/kvtag_query.c index 044d8d567..77fcf8f15 100644 --- a/src/tests/kvtag_query.c +++ b/src/tests/kvtag_query.c @@ -99,22 +99,22 @@ int main() { kvtag3.value = (void*)&v3; kvtag3.size = sizeof(double); - if (PDC_add_kvtag(obj1, &kvtag1) < 0) + if (PDCobj_put_tag(obj1, kvtag1.name, kvtag1.value, kvtag1.size) < 0) printf("fail to add a kvtag to o1\n"); else printf("successfully added a kvtag to o1\n"); - if (PDC_add_kvtag(obj1, &kvtag2) < 0) + if (PDCobj_put_tag(obj1, kvtag2.name, kvtag2.value, kvtag2.size) < 0) printf("fail to add a kvtag to o1\n"); else printf("successfully added a kvtag to o1\n"); - if (PDC_add_kvtag(obj2, &kvtag2) < 0) + if (PDCobj_put_tag(obj2, kvtag2.name, kvtag2.value, kvtag2.size) < 0) printf("fail to add a kvtag to o2\n"); else printf("successfully added a kvtag to o2\n"); - if (PDC_add_kvtag(obj2, &kvtag3) < 0) + if (PDCobj_put_tag(obj2, kvtag3.name, kvtag3.value, kvtag3.size) < 0) printf("fail to add a kvtag to o2\n"); else printf("successfully added a kvtag to o2\n"); diff --git a/src/tests/kvtag_query_scale.c b/src/tests/kvtag_query_scale.c index 43b772dac..9c80f665c 100644 --- a/src/tests/kvtag_query_scale.c +++ b/src/tests/kvtag_query_scale.c @@ -133,7 +133,7 @@ int main(int argc, char *argv[]) v = iter; for (i = 0; i < my_add_tag; i++) { - if (PDC_add_kvtag(obj_ids[i], &kvtag) < 0) + if (PDCobj_put_tag(obj_ids[i], kvtag.name, kvtag.value, kvtag.size) < 0) printf("fail to add a kvtag to o%d\n", i+my_obj_s); } diff --git a/src/tests/mpi_test.sh b/src/tests/mpi_test.sh new file mode 100755 index 000000000..a0890f4cf --- /dev/null +++ b/src/tests/mpi_test.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# This version of the test runner doesn't attempt to run any parallel tests. +# We assume too, that if the library build has enabled MPI, that LD_LIBRARY_PATH is +# defined and points to the MPI libraries used by the linker (e.g. -L 0) + if(cont_prop > 0) { printf("Create a container property\n"); - else + } else { printf("Fail to create container property @ line %d!\n", __LINE__); - + ret_value = 1; + } // create a container - cont = PDCcont_create("c1", cont_prop); - if(cont > 0) + sprintf(cont_name, "c%d", rank); + cont = PDCcont_create(cont_name, cont_prop); + if(cont > 0) { printf("Create a container\n"); - else + } else { printf("Fail to create container @ line %d!\n", __LINE__); - + ret_value = 1; + } // create an object property obj_prop = PDCprop_create(PDC_OBJ_CREATE, pdc); - if(obj_prop > 0) + if(obj_prop > 0) { printf("Create an object property\n"); - else + } else { printf("Fail to create object property @ line %d!\n", __LINE__); - + ret_value = 1; + } + PDCprop_set_obj_buf(obj_prop, myArray); + // create object - obj1 = PDCobj_create(cont, "o1", obj_prop); - if(obj1 > 0) + sprintf(obj_name1, "o1_%d", rank); + obj1 = PDCobj_create(cont, obj_name1, obj_prop); + if(obj1 > 0) { printf("Create an object o1\n"); - else + } else { printf("Fail to create object @ line %d!\n", __LINE__); - + ret_value = 1; + } // set and retrieve the object buffer - PDCprop_set_obj_buf(obj_prop, myArray); + + rbuf = PDCobj_buf_retrieve(obj1); printf("first number to retrieve is: %d\n", *((int *)*rbuf)); - + // close object - if(PDCobj_close(obj1) < 0) + if(PDCobj_close(obj1) < 0) { printf("fail to close object o1\n"); - else + ret_value = 1; + } else { printf("successfully close object o1\n"); - + } // close object property - if(PDCprop_close(obj_prop) < 0) + if(PDCprop_close(obj_prop) < 0) { printf("Fail to close property @ line %d\n", __LINE__); - else + ret_value = 1; + } else { printf("successfully close object property\n"); - + } // close a container - if(PDCcont_close(cont) < 0) + if(PDCcont_close(cont) < 0) { printf("fail to close container c1\n"); - else + ret_value = 1; + } else { printf("successfully close container c1\n"); - + } // close a container property - if(PDCprop_close(cont_prop) < 0) + if(PDCprop_close(cont_prop) < 0) { printf("Fail to close property @ line %d\n", __LINE__); - else + ret_value = 1; + } else { printf("successfully close container property\n"); - + } // close pdc - if(PDCclose(pdc) < 0) - printf("fail to close PDC\n"); - + if(PDCclose(pdc) < 0) { + printf("fail to close PDC\n"); + ret_value = 1; + } #ifdef ENABLE_MPI MPI_Finalize(); #endif - return 0; + return ret_value; } diff --git a/src/tests/obj_dim.c b/src/tests/obj_dim.c index 291e611ab..a2a3a4d7a 100644 --- a/src/tests/obj_dim.c +++ b/src/tests/obj_dim.c @@ -33,7 +33,8 @@ int main(int argc, char **argv) { int rank = 0, size = 1; uint64_t d[3] = {10, 20, 30}; struct pdc_obj_prop *op; - size_t i; + int ret_value = 0; + char cont_name[128], obj_name1[128]; #ifdef ENABLE_MPI MPI_Init(&argc, &argv); @@ -45,67 +46,78 @@ int main(int argc, char **argv) { // create a container property cont_prop = PDCprop_create(PDC_CONT_CREATE, pdc); - if(cont_prop > 0) + if(cont_prop > 0) { printf("Create a container property\n"); - else + } else { printf("Fail to create container property @ line %d!\n", __LINE__); - + ret_value = 1; + } // create a container - cont = PDCcont_create("c1", cont_prop); - if(cont > 0) - printf("Create a container c1\n"); - else + sprintf(cont_name, "c%d", rank); + cont = PDCcont_create(cont_name, cont_prop); + if(cont > 0) { + printf("Create a container c%d\n", rank); + } else { printf("Fail to create container @ line %d!\n", __LINE__); - + ret_value = 1; + } // create an object property obj_prop = PDCprop_create(PDC_OBJ_CREATE,pdc); - if(obj_prop > 0) + if(obj_prop > 0) { printf("Create an object property\n"); - else + } else { printf("Fail to create object property @ line %d!\n", __LINE__); - + ret_value = 1; + } // set object dimension PDCprop_set_obj_dims(obj_prop, 3, d); op = PDCobj_prop_get_info(obj_prop); // create object - obj1 = PDCobj_create(cont, "o1", obj_prop); - if(obj1 > 0) + sprintf(obj_name1, "o1_%d", rank); + obj1 = PDCobj_create(cont, obj_name1, obj_prop); + if(obj1 > 0) { printf("Create an objec o1\n"); - else + } else { printf("Fail to create object @ line %d!\n", __LINE__); - + ret_value = 1; + } // close object - if(PDCobj_close(obj1) < 0) + if(PDCobj_close(obj1) < 0) { printf("fail to close object o1\n"); - else + ret_value = 1; + } else { printf("successfully close object o1\n"); - + } // close object property - if(PDCprop_close(obj_prop) < 0) + if(PDCprop_close(obj_prop) < 0) { printf("Fail to close property @ line %d\n", __LINE__); - else + ret_value = 1; + } else { printf("successfully close object property\n"); - + } // close a container - if(PDCcont_close(cont) < 0) + if(PDCcont_close(cont) < 0) { printf("fail to close container c1\n"); - else + ret_value = 1; + } else { printf("successfully close container c1\n"); - + } // close a container property - if(PDCprop_close(cont_prop) < 0) + if(PDCprop_close(cont_prop) < 0) { printf("Fail to close property @ line %d\n", __LINE__); - else + ret_value = 1; + } else { printf("successfully close container property\n"); - + } // close pdc - if(PDCclose(pdc) < 0) - printf("fail to close PDC\n"); - + if(PDCclose(pdc) < 0) { + printf("fail to close PDC\n"); + ret_value = 1; + } #ifdef ENABLE_MPI MPI_Finalize(); #endif - return 0; + return ret_value; } diff --git a/src/tests/obj_info.c b/src/tests/obj_info.c new file mode 100644 index 000000000..d4518729e --- /dev/null +++ b/src/tests/obj_info.c @@ -0,0 +1,211 @@ +/* + * Copyright Notice for + * Proactive Data Containers (PDC) Software Library and Utilities + * ----------------------------------------------------------------------------- + + *** Copyright Notice *** + + * Proactive Data Containers (PDC) Copyright (c) 2017, The Regents of the + * University of California, through Lawrence Berkeley National Laboratory, + * UChicago Argonne, LLC, operator of Argonne National Laboratory, and The HDF + * Group (subject to receipt of any required approvals from the U.S. Dept. of + * Energy). All rights reserved. + + * If you have questions about your rights to use or distribute this software, + * please contact Berkeley Lab's Innovation & Partnerships Office at IPO@lbl.gov. + + * NOTICE. This Software was developed under funding from the U.S. Department of + * Energy and the U.S. Government consequently retains certain rights. As such, the + * U.S. Government has been granted for itself and others acting on its behalf a + * paid-up, nonexclusive, irrevocable, worldwide license in the Software to + * reproduce, distribute copies to the public, prepare derivative works, and + * perform publicly and display publicly, and to permit other to do so. + */ + +#include +#include +#include +#include "pdc.h" + + +int main(int argc, char **argv) { + pdcid_t pdc, cont_prop, cont, obj_prop; + perr_t ret; + pdcid_t obj1, obj2; + struct pdc_obj_info *obj1_info, *obj2_info; + char cont_name[128], obj_name1[128], obj_name2[128]; + + int rank = 0, size = 1; + int ret_value = 0; + + size_t ndim = 3; + uint64_t dims[3]; + dims[0] = 64; + dims[1] = 3; + dims[2] = 4; + +#ifdef ENABLE_MPI + MPI_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); +#endif + // create a pdc + pdc = PDCinit("pdc"); + printf("create a new pdc\n"); + + // create a container property + cont_prop = PDCprop_create(PDC_CONT_CREATE, pdc); + if(cont_prop > 0) { + printf("Create a container property\n"); + } else { + printf("Fail to create container property @ line %d!\n", __LINE__); + ret_value = 1; + } + // create a container + sprintf(cont_name, "c%d", rank); + cont = PDCcont_create(cont_name, cont_prop); + if(cont > 0) { + printf("Create a container c1\n"); + } else { + printf("Fail to create container @ line %d!\n", __LINE__); + ret_value = 1; + } + // create an object property + obj_prop = PDCprop_create(PDC_OBJ_CREATE, pdc); + if(obj_prop > 0) { + printf("Create an object property\n"); + } else { + printf("Fail to create object property @ line %d!\n", __LINE__); + ret_value = 1; + } + ret = PDCprop_set_obj_dims(obj_prop, ndim, dims); + if ( ret != SUCCEED ) { + printf("Fail to set obj time step @ line %d\n", __LINE__); + ret_value = 1; + } + ret = PDCprop_set_obj_type(obj_prop, PDC_DOUBLE); + if ( ret != SUCCEED ) { + printf("Fail to set obj time step @ line %d\n", __LINE__); + ret_value = 1; + } + + + // create first object + sprintf(obj_name1, "o1_%d", rank); + obj1 = PDCobj_create(cont, obj_name1, obj_prop); + if(obj1 > 0) { + printf("Create an object o1\n"); + } else { + printf("Fail to create object @ line %d!\n", __LINE__); + ret_value = 1; + } + // create second object + sprintf(obj_name2, "o2_%d", rank); + obj2 = PDCobj_create(cont, obj_name2, obj_prop); + if(obj2 > 0) { + printf("Create an object o2\n"); + } else { + printf("Fail to create object @ line %d!\n", __LINE__); + ret_value = 1; + } + obj1_info = PDCobj_get_info(obj1); + obj2_info = PDCobj_get_info(obj2); + if ( strcmp(obj1_info->name, obj_name1) != 0 ) { + printf("Object 1 name is wrong\n"); + ret_value = 1; + } + + if (obj1_info->obj_pt->type != PDC_DOUBLE) { + printf("Type is not properly inherited from object property.\n"); + ret_value = 1; + } + + if (obj1_info->obj_pt->ndim != ndim) { + printf("Number of dimensions is not properly inherited from object property.\n"); + ret_value = 1; + } + if (obj1_info->obj_pt->dims[0] != dims[0]) { + printf("First dimension is not properly inherited from object property.\n"); + ret_value = 1; + } + if (obj1_info->obj_pt->dims[1] != dims[1]) { + printf("Second dimension is not properly inherited from object property.\n"); + ret_value = 1; + } + if (obj1_info->obj_pt->dims[2] != dims[2]) { + printf("Third dimension is not properly inherited from object property.\n"); + ret_value = 1; + } + + if ( strcmp(obj2_info->name, obj_name2) != 0 ) { + printf("Object 2 name is wrong\n"); + ret_value = 1; + } + + if (obj2_info->obj_pt->type != PDC_DOUBLE) { + printf("Type is not properly inherited from object property.\n"); + ret_value = 1; + } + + + if (obj2_info->obj_pt->ndim != ndim) { + printf("Number of dimensions is not properly inherited from object property.\n"); + ret_value = 1; + } + if (obj2_info->obj_pt->dims[0] != dims[0]) { + printf("First dimension is not properly inherited from object property.\n"); + ret_value = 1; + } + if (obj2_info->obj_pt->dims[1] != dims[1]) { + printf("Second dimension is not properly inherited from object property.\n"); + ret_value = 1; + } + if (obj2_info->obj_pt->dims[2] != dims[2]) { + printf("Third dimension is not properly inherited from object property.\n"); + ret_value = 1; + } + + // close object + if(PDCobj_close(obj1) < 0) { + printf("fail to close object o1\n"); + ret_value = 1; + } else { + printf("successfully close object o1\n"); + } + if(PDCobj_close(obj2) < 0) { + printf("fail to close object o2\n"); + ret_value = 1; + } else { + printf("successfully close object o2\n"); + } + // close a container + if(PDCcont_close(cont) < 0) { + printf("fail to close container c1\n"); + ret_value = 1; + } else { + printf("successfully close container c1\n"); + } + // close a object property + if(PDCprop_close(obj_prop) < 0) { + printf("Fail to close property @ line %d\n", __LINE__); + ret_value = 1; + } else { + printf("successfully close object property\n"); + } + // close a container property + if(PDCprop_close(cont_prop) < 0) { + printf("Fail to close property @ line %d\n", __LINE__); + ret_value = 1; + } else { + printf("successfully close container property\n"); + } + // close pdc + if(PDCclose(pdc) < 0) { + printf("fail to close PDC\n"); + ret_value = 1; + } +#ifdef ENABLE_MPI + MPI_Finalize(); +#endif + return ret_value; +} diff --git a/src/tests/obj_iter.c b/src/tests/obj_iter.c index 4198e339b..64b011e34 100644 --- a/src/tests/obj_iter.c +++ b/src/tests/obj_iter.c @@ -34,7 +34,15 @@ int main(int argc, char **argv) int rank = 0, size = 1; obj_handle *oh; struct pdc_obj_info *info; - + int ret_value = 0, ret; + char cont_name[128], obj_name1[128], obj_name2[128], obj_name3[128]; + + size_t ndim = 3; + uint64_t dims[3]; + dims[0] = 64; + dims[1] = 3; + dims[2] = 4; + #ifdef ENABLE_MPI MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); @@ -46,97 +54,147 @@ int main(int argc, char **argv) // create a container property cont_prop = PDCprop_create(PDC_CONT_CREATE, pdc); - if(cont_prop > 0) + if(cont_prop > 0) { printf("Create a container property\n"); - else + } else { printf("Fail to create container property @ line %d!\n", __LINE__); - + ret_value = 1; + } // create a container - cont = PDCcont_create("c1", cont_prop); - if(cont > 0) + sprintf(cont_name, "c%d", rank); + cont = PDCcont_create(cont_name, cont_prop); + if(cont > 0) { printf("Create a container c1\n"); - else + } else { printf("Fail to create container @ line %d!\n", __LINE__); - + ret_value = 1; + } // create an object property obj_prop = PDCprop_create(PDC_OBJ_CREATE, pdc); - if(obj_prop > 0) + if(obj_prop > 0) { printf("Create an object property\n"); - else + } else { printf("Fail to create object property @ line %d!\n", __LINE__); - + ret_value = 1; + } + ret = PDCprop_set_obj_dims(obj_prop, ndim, dims); + if ( ret != SUCCEED ) { + printf("Fail to set obj time step @ line %d\n", __LINE__); + ret_value = 1; + } + ret = PDCprop_set_obj_type(obj_prop, PDC_DOUBLE); + if ( ret != SUCCEED ) { + printf("Fail to set obj time step @ line %d\n", __LINE__); + ret_value = 1; + } + + // create first object - obj1 = PDCobj_create(cont, "o1", obj_prop); - if(obj1 > 0) + sprintf(obj_name1, "o1_%d", rank); + obj1 = PDCobj_create(cont, obj_name1, obj_prop); + if(obj1 > 0) { printf("Create an object o1\n"); - else + } else { printf("Fail to create object @ line %d!\n", __LINE__); - + ret_value = 1; + } // create second object - obj2 = PDCobj_create(cont, "o2", obj_prop); - if(obj2 > 0) + sprintf(obj_name2, "o2_%d", rank); + obj2 = PDCobj_create(cont, obj_name2, obj_prop); + if(obj2 > 0) { printf("Create an object o2\n"); - else + } else { printf("Fail to create object @ line %d!\n", __LINE__); - + ret_value = 1; + } // create third object - obj3 = PDCobj_create(cont, "o3", obj_prop); - if(obj3 > 0) + sprintf(obj_name3, "o3_%d", rank); + obj3 = PDCobj_create(cont, obj_name3, obj_prop); + if(obj3 > 0) { printf("Create an object o3\n"); - else + } else { printf("Fail to create object @ line %d!\n", __LINE__); - + ret_value = 1; + } // start object iteration oh = PDCobj_iter_start(cont); while(!PDCobj_iter_null(oh)) { info = PDCobj_iter_get_info(oh); + if (info->obj_pt->type != PDC_DOUBLE) { + printf("Type is not properly inherited from object property.\n"); + ret_value = 1; + } + if (info->obj_pt->ndim != ndim) { + printf("Number of dimensions is not properly inherited from object property.\n"); + ret_value = 1; + } + if (info->obj_pt->dims[0] != dims[0]) { + printf("First dimension is not properly inherited from object property.\n"); + ret_value = 1; + } + if (info->obj_pt->dims[1] != dims[1]) { + printf("Second dimension is not properly inherited from object property.\n"); + ret_value = 1; + } + if (info->obj_pt->dims[2] != dims[2]) { + printf("Third dimension is not properly inherited from object property.\n"); + ret_value = 1; + } + oh = PDCobj_iter_next(oh, cont); } // close first object - if(PDCobj_close(obj1) < 0) + if(PDCobj_close(obj1) < 0) { printf("fail to close object o1\n"); - else + ret_value = 1; + } else { printf("successfully close object o1\n"); - + } // close second object - if(PDCobj_close(obj2) < 0) + if(PDCobj_close(obj2) < 0) { printf("fail to close object o2\n"); - else + ret_value = 1; + } else { printf("successfully close object o2\n"); - + } // close third object - if(PDCobj_close(obj3) < 0) + if(PDCobj_close(obj3) < 0) { printf("fail to close object o3\n"); - else + ret_value = 1; + } else { printf("successfully close object o3\n"); - + } // close a object property - if(PDCprop_close(obj_prop) < 0) + if(PDCprop_close(obj_prop) < 0) { printf("Fail to close property @ line %d\n", __LINE__); - else + ret_value = 1; + } else { printf("successfully close object property\n"); - + } // close a container - if(PDCcont_close(cont) < 0) + if(PDCcont_close(cont) < 0) { printf("fail to close container c1\n"); - else + ret_value = 1; + } else { printf("successfully close container c1\n"); - + } // close a container property - if(PDCprop_close(cont_prop) < 0) + if(PDCprop_close(cont_prop) < 0) { printf("Fail to close property @ line %d\n", __LINE__); - else + ret_value = 1; + } else { printf("successfully close container property\n"); - + } // close pdc - if(PDCclose(pdc) < 0) - printf("fail to close PDC\n"); - + if(PDCclose(pdc) < 0) { + printf("fail to close PDC\n"); + ret_value = 1; + } #ifdef ENABLE_MPI MPI_Finalize(); #endif - return 0; + return ret_value; } diff --git a/src/tests/obj_life.c b/src/tests/obj_life.c index cbea8dec8..09c8898bf 100644 --- a/src/tests/obj_life.c +++ b/src/tests/obj_life.c @@ -28,7 +28,7 @@ #include "pdc.h" int main(int argc, char **argv) { - pdcid_t pdc, cont_prop, cont, obj_prop, obj1; + pdcid_t pdc, cont_prop, cont, obj1; struct PDC_obj_prop *op; int rank = 0, size = 1; @@ -42,40 +42,39 @@ int main(int argc, char **argv) { // create a container property cont_prop = PDCprop_create(PDC_CONT_CREATE, pdc); - if(cont_prop > 0) + if(cont_prop > 0) { printf("Create a container property\n"); - else + } else { printf("Fail to create container property @ line %d!\n", __LINE__); - + return 1; + } // create a container cont = PDCcont_create("c1", cont_prop); - if(cont > 0) + if(cont > 0) { printf("Create a container c1\n"); - else + } else { printf("Fail to create container @ line %d!\n", __LINE__); - + return 1; + } // close a container - if(PDCcont_close(cont) < 0) + if(PDCcont_close(cont) < 0) { printf("fail to close container c1\n"); - else + return 1; + } else { printf("successfully close container c1\n"); - - // close an object property - if(PDCprop_close(obj_prop) < 0) - printf("Fail to close property @ line %d\n", __LINE__); - else - printf("successfully close object property\n"); - + } // close a container property - if(PDCprop_close(cont_prop) < 0) + if(PDCprop_close(cont_prop) < 0) { printf("Fail to close property @ line %d\n", __LINE__); - else + return 1; + } else { printf("successfully close container property\n"); - + } // close pdc - if(PDCclose(pdc) < 0) - printf("fail to close PDC\n"); - + if(PDCclose(pdc) < 0) { + printf("fail to close PDC\n"); + return 1; + } #ifdef ENABLE_MPI MPI_Finalize(); #endif diff --git a/src/tests/obj_put_data.c b/src/tests/obj_put_data.c new file mode 100644 index 000000000..e2788d5cc --- /dev/null +++ b/src/tests/obj_put_data.c @@ -0,0 +1,124 @@ +/* + * Copyright Notice for + * Proactive Data Containers (PDC) Software Library and Utilities + * ----------------------------------------------------------------------------- + + *** Copyright Notice *** + + * Proactive Data Containers (PDC) Copyright (c) 2017, The Regents of the + * University of California, through Lawrence Berkeley National Laboratory, + * UChicago Argonne, LLC, operator of Argonne National Laboratory, and The HDF + * Group (subject to receipt of any required approvals from the U.S. Dept. of + * Energy). All rights reserved. + + * If you have questions about your rights to use or distribute this software, + * please contact Berkeley Lab's Innovation & Partnerships Office at IPO@lbl.gov. + + * NOTICE. This Software was developed under funding from the U.S. Department of + * Energy and the U.S. Government consequently retains certain rights. As such, the + * U.S. Government has been granted for itself and others acting on its behalf a + * paid-up, nonexclusive, irrevocable, worldwide license in the Software to + * reproduce, distribute copies to the public, prepare derivative works, and + * perform publicly and display publicly, and to permit other to do so. + */ + +#include +#include +#include +#include "pdc.h" + + +int main(int argc, char **argv) { + pdcid_t pdc, cont_prop, cont; + pdcid_t obj1, obj2; + char cont_name[128], obj_name1[128], obj_name2[128]; + + int rank = 0, size = 1; + int ret_value = 0; + + double *data = (double*)malloc(sizeof(double)*128); + memset(data, 1, 128 * sizeof(double)); + +#ifdef ENABLE_MPI + MPI_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); +#endif + // create a pdc + pdc = PDCinit("pdc"); + printf("create a new pdc\n"); + + // create a container property + cont_prop = PDCprop_create(PDC_CONT_CREATE, pdc); + if(cont_prop > 0) { + printf("Create a container property\n"); + } else { + printf("Fail to create container property @ line %d!\n", __LINE__); + ret_value = 1; + } + // create a container + sprintf(cont_name, "c%d", rank); + cont = PDCcont_create(cont_name, cont_prop); + if(cont > 0) { + printf("Rank %d Create a container %s\n", rank, cont_name); + } else { + printf("Fail to create container @ line %d!\n", __LINE__); + ret_value = 1; + } + + sprintf(obj_name1, "o1_%d", rank); + obj1 = PDCobj_put_data(obj_name1, (void*)data, 16*sizeof(double), cont); + if(obj1 > 0) { + printf("Rank %d Put data to %s\n", rank, obj_name1); + } else { + printf("Fail to put data into object @ line %d!\n", __LINE__); + ret_value = 1; + } + + sprintf(obj_name2, "o2_%d", rank); + obj2 = PDCobj_put_data(obj_name2, (void*)data, 128*sizeof(double), cont); + if(obj2 > 0) { + printf("Rank %d Put data to %s\n", rank, obj_name2); + } else { + printf("Fail to put data into object @ line %d!\n", __LINE__); + ret_value = 1; + } + + // close object + if(PDCobj_close(obj1) < 0) { + printf("fail to close object o1\n"); + ret_value = 1; + } else { + printf("successfully close object o1\n"); + } + if(PDCobj_close(obj2) < 0) { + printf("fail to close object o2\n"); + ret_value = 1; + } else { + printf("successfully close object o2\n"); + } + + // close a container + if(PDCcont_close(cont) < 0) { + printf("fail to close container c1\n"); + ret_value = 1; + } else { + printf("successfully close container c1\n"); + } + // close a container property + if(PDCprop_close(cont_prop) < 0) { + printf("Fail to close property @ line %d\n", __LINE__); + ret_value = 1; + } else { + printf("successfully close container property\n"); + } + // close pdc + if(PDCclose(pdc) < 0) { + printf("fail to close PDC\n"); + ret_value = 1; + } +#ifdef ENABLE_MPI + MPI_Finalize(); +#endif + return ret_value; +} diff --git a/src/tests/obj_round_robin_io.c b/src/tests/obj_round_robin_io.c new file mode 100644 index 000000000..0ada33899 --- /dev/null +++ b/src/tests/obj_round_robin_io.c @@ -0,0 +1,394 @@ +/* + * Copyright Notice for + * Proactive Data Containers (PDC) Software Library and Utilities + * ----------------------------------------------------------------------------- + + *** Copyright Notice *** + + * Proactive Data Containers (PDC) Copyright (c) 2017, The Regents of the + * University of California, through Lawrence Berkeley National Laboratory, + * UChicago Argonne, LLC, operator of Argonne National Laboratory, and The HDF + * Group (subject to receipt of any required approvals from the U.S. Dept. of + * Energy). All rights reserved. + + * If you have questions about your rights to use or distribute this software, + * please contact Berkeley Lab's Innovation & Partnerships Office at IPO@lbl.gov. + + * NOTICE. This Software was developed under funding from the U.S. Department of + * Energy and the U.S. Government consequently retains certain rights. As such, the + * U.S. Government has been granted for itself and others acting on its behalf a + * paid-up, nonexclusive, irrevocable, worldwide license in the Software to + * reproduce, distribute copies to the public, prepare derivative works, and + * perform publicly and display publicly, and to permit other to do so. + */ + +#include +#include +#include +#include "pdc.h" + +int main(int argc, char **argv) { + pdcid_t pdc, cont_prop, cont, obj_prop; + pdcid_t obj1, obj2; + int rank = 0, size = 1, i, j, ret, target_rank; + int ret_value = 0; + char cont_name[128], obj_name1[128], obj_name2[128]; + //struct pdc_obj_info *obj1_info, *obj2_info; + + size_t ndim = 3; + uint64_t dims[3]; + + uint64_t *offset; + uint64_t *mysize; + + pdc_var_type_t var_type = PDC_UNKNOWN; + size_t type_size = 1; + + uint64_t my_data_size; + + char *obj_data, *mydata, *data_read; + + pdcid_t local_region, global_region; + +#ifdef ENABLE_MPI + MPI_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); +#endif + + if (!strcmp(argv[1], "float")){ + var_type = PDC_FLOAT; + type_size = sizeof(float); + } else if (!strcmp(argv[1], "int")){ + var_type = PDC_INT; + type_size = sizeof(int); + } else if (!strcmp(argv[1], "double")){ + var_type = PDC_DOUBLE; + type_size = sizeof(double); + } else if (!strcmp(argv[1], "char")){ + var_type = PDC_CHAR; + type_size = sizeof(char); + } else if (!strcmp(argv[1], "uint")){ + var_type = PDC_UINT; + type_size = sizeof(unsigned); + } else if (!strcmp(argv[1], "int64")){ + var_type = PDC_INT64; + type_size = sizeof(int64_t); + } else if (!strcmp(argv[1], "uint64")){ + var_type = PDC_UINT64; + type_size = sizeof(uint64_t); + } else if (!strcmp(argv[1], "int16")){ + var_type = PDC_INT16; + type_size = sizeof(int16_t); + } else if (!strcmp(argv[1], "int8")){ + var_type = PDC_INT8; + type_size = sizeof(int8_t); + } + + dims[0] = rank*2+16; + dims[1] = rank*3+16; + dims[2] = rank*5+16; + my_data_size = 1; + for ( i = 0; i < (int)ndim; ++i ) { + my_data_size *= dims[i]; + } + + mydata = (char*)malloc(my_data_size*type_size); + obj_data = (char*)malloc(my_data_size*type_size); + + offset = (uint64_t*)malloc(sizeof(uint64_t)); + mysize = (uint64_t*)malloc(sizeof(uint64_t)); + offset[0] = 0; + mysize[0] = my_data_size; + + // create a pdc + pdc = PDCinit("pdc"); + printf("create a new pdc\n"); + + // create a container property + cont_prop = PDCprop_create(PDC_CONT_CREATE, pdc); + if(cont_prop > 0) { + printf("Rank %d Create a container property\n", rank); + } else { + printf("Rank %d Fail to create container property @ line %d!\n", rank, __LINE__); + ret_value = 1; + } + // create a container + sprintf(cont_name, "c"); + cont = PDCcont_create_col(cont_name, cont_prop); + //cont = PDCcont_create(cont_name, cont_prop); + if(cont > 0) { + printf("Rank %d Create a container %s\n", rank, cont_name); + } else { + printf("Rank %d Fail to create container @ line %d!\n", rank, __LINE__); + ret_value = 1; + } + // create an object property + obj_prop = PDCprop_create(PDC_OBJ_CREATE, pdc); + if(obj_prop > 0) { + printf("Rank %d Create an object property\n", rank); + } else { + printf("Rank %d Fail to create object property @ line %d!\n", rank, __LINE__); + ret_value = 1; + } + dims[0] = my_data_size; + ret = PDCprop_set_obj_dims(obj_prop, 1, dims); + if ( ret != SUCCEED ) { + printf("Fail to set obj time step @ line %d\n", __LINE__); + ret_value = 1; + } + PDCprop_set_obj_type(obj_prop, var_type); + if ( ret != SUCCEED ) { + printf("Fail to set obj time step @ line %d\n", __LINE__); + ret_value = 1; + } + ret = PDCprop_set_obj_buf(obj_prop, obj_data); + if ( ret != SUCCEED ) { + printf("Fail to set obj data @ line %d\n", __LINE__); + ret_value = 1; + } + + // create first object + sprintf(obj_name1, "o1_%d", rank); + local_region = PDCregion_create(1, offset, mysize); + global_region = PDCregion_create(1, offset, mysize); + + obj1 = PDCobj_create(cont, obj_name1, obj_prop); + if(obj1 > 0) { + printf("Rank %d Create an object %s\n", rank, obj_name1); + } else { + printf("Rank %d Fail to create object @ line %d!\n", rank, __LINE__); + ret_value = 1; + } + for (i = 0; i < (int) my_data_size; i++) { + for ( j = 0; j < (int) type_size; ++j ) { + mydata[i * type_size + j] = (char) (i * type_size + j + rank); + } + } + ret = PDCbuf_obj_map(mydata, var_type, local_region, obj1, global_region); + if(ret != SUCCEED) { + printf("PDCbuf_obj_map failed\n"); + ret_value = 1; + } + ret = PDCreg_obtain_lock(obj1, local_region, PDC_WRITE, PDC_BLOCK); + if (ret != SUCCEED) { + printf("Failed to obtain lock for region\n"); + ret_value = 1; + } + ret = PDCreg_release_lock(obj1, local_region, PDC_WRITE); + if (ret != SUCCEED) { + printf("Failed to release lock for region\n"); + ret_value = 1; + } + ret = PDCbuf_obj_unmap(obj1, global_region); + if(ret != SUCCEED) { + printf("PDCbuf_obj_unmap failed\n"); + ret_value = 1; + } + + + if(PDCregion_close(local_region) < 0) { + printf("fail to close local region\n"); + ret_value = 1; + } + + if(PDCregion_close(global_region) < 0) { + printf("fail to close global region\n"); + ret_value = 1; + } + + // create second object + sprintf(obj_name2, "o2_%d", rank); + obj2 = PDCobj_create(cont, obj_name2, obj_prop); + + local_region = PDCregion_create(1, offset, mysize); + global_region = PDCregion_create(1, offset, mysize); + if(obj2 > 0) { + printf("Rank %d Create an object %s\n", rank, obj_name2); + } else { + printf("Rank %d Fail to create object @ line %d!\n", rank, __LINE__); + ret_value = 1; + } + for (i = 0; i < (int) my_data_size; i++) { + for ( j = 0; j < (int) type_size; ++j ) { + mydata[i * type_size + j] = (char) (i * type_size + j + rank * 5 + 3); + } + } + ret = PDCbuf_obj_map(mydata, var_type, local_region, obj2, global_region); + if(ret != SUCCEED) { + printf("PDCbuf_obj_map failed %d\n", __LINE__); + ret_value = 1; + } + ret = PDCreg_obtain_lock(obj2, local_region, PDC_WRITE, PDC_BLOCK); + if (ret != SUCCEED) { + printf("Failed to obtain lock for region %d\n", __LINE__); + ret_value = 1; + } + ret = PDCreg_release_lock(obj2, local_region, PDC_WRITE); + if (ret != SUCCEED) { + printf("Failed to release lock for region %d\n", __LINE__); + ret_value = 1; + } + ret = PDCbuf_obj_unmap(obj2, global_region); + if(ret != SUCCEED) { + printf("PDCbuf_obj_unmap failed %d\n", __LINE__); + ret_value = 1; + } + + if(PDCregion_close(local_region) < 0) { + printf("fail to close local region %d\n", __LINE__); + ret_value = 1; + } + + if(PDCregion_close(global_region) < 0) { + printf("fail to close global region %d\n", __LINE__); + ret_value = 1; + } + + + // close created objects + if(PDCobj_close(obj1) < 0) { + printf("Rank %d fail to close object o1_%d %d\n", rank, rank, __LINE__); + ret_value = 1; + } else { + printf("Rank %d successfully close object o1_%d\n", rank, rank); + } + if(PDCobj_close(obj2) < 0) { + printf("Rank %d fail to close object o2_%d %d\n", rank, rank, __LINE__); + ret_value = 1; + } else { + printf("Rank %d successfully close object o2_%d\n", rank, rank); + } + // Wait for all processes to finish their object creation + #ifdef ENABLE_MPI + MPI_Barrier(MPI_COMM_WORLD); + #endif + for ( i = 1; i < size; ++i ) { + target_rank = (rank + i) % size; + sprintf(obj_name1, "o1_%d", target_rank); + obj1 = PDCobj_open(obj_name1, pdc); + if(obj1 == 0) { + printf("Rank %d Fail to open object %s %d\n", rank, obj_name1, __LINE__); + ret_value = 1; + } else { + printf("Rank %d Opened object %s\n", rank, obj_name1); + } + sprintf(obj_name2, "o2_%d", target_rank); + obj2 = PDCobj_open(obj_name2, pdc); + if(obj2 == 0) { + printf("Rank %d Fail to open object %s %d\n", rank, obj_name2, __LINE__); + ret_value = 1; + } else { + printf("Rank %d Open object %s\n", rank, obj_name2); + } + + dims[0] = target_rank*2+16; + dims[1] = target_rank*3+16; + dims[2] = target_rank*5+16; + my_data_size = 1; + for ( j = 0; j < (int)ndim; ++j ) { + my_data_size *= dims[j]; + } + offset[0] = 0; + mysize[0] = my_data_size; + local_region = PDCregion_create(1, offset, mysize); + global_region = PDCregion_create(1, offset, mysize); + data_read = (char*)malloc(my_data_size*type_size); + + ret = PDCbuf_obj_map(data_read, var_type, local_region, obj2, global_region); + if(ret != SUCCEED) { + printf("PDCbuf_obj_map for read obj2 failed %d\n",__LINE__); + ret_value = 1; + } + + ret = PDCreg_obtain_lock(obj2, local_region, PDC_READ, PDC_BLOCK); + if(ret != SUCCEED) { + printf("PDCreg_obtain_lock failed %d\n", __LINE__); + ret_value = 1; + } + + ret = PDCreg_release_lock(obj2, local_region, PDC_READ); + if(ret != SUCCEED) { + printf("PDCreg_release_lock failed %d\n", __LINE__); + ret_value = 1; + } + + ret = PDCbuf_obj_unmap(obj2, global_region); + if(ret != SUCCEED) { + printf("PDCbuf_obj_unmap failed %d\n", __LINE__); + ret_value = 1; + } + + for ( j = 0; j < (int) (my_data_size * type_size); ++j ) { + if ( data_read[j] != (char) (j + target_rank * 5 + 3) ) { + printf("----------------------------------rank %d, i = %d, j = %d, wrong value %d!=%d %d\n", rank, i, j, data_read[j], (char)(j + target_rank * 5 + 3), __LINE__); + ret_value = 1; + break; + } + } + + free(data_read); + + if(PDCregion_close(local_region) < 0) { + printf("fail to close local region %d\n", __LINE__); + ret_value = 1; + } + + if(PDCregion_close(global_region) < 0) { + printf("fail to close global region %d\n", __LINE__); + ret_value = 1; + } + + if(PDCobj_close(obj1) < 0) { + printf("Rank %d fail to close object %s %d\n", rank, obj_name1, __LINE__); + ret_value = 1; + } else { + printf("Rank %d successfully close object %s\n", rank, obj_name1); + } + if(PDCobj_close(obj2) < 0) { + printf("Rank %d fail to close object %s %d\n", rank, obj_name2, __LINE__); + ret_value = 1; + } else { + printf("Rank %d successfully close object %s\n", rank, obj_name2); + } + #ifdef ENABLE_MPI + MPI_Barrier(MPI_COMM_WORLD); + #endif + } + + // close a container + if(PDCcont_close(cont) < 0) { + printf("Rank %d fail to close container c %d\n", rank, __LINE__); + ret_value = 1; + } else { + printf("Rank %d successfully close container c\n", rank); + } + // close a object property + if(PDCprop_close(obj_prop) < 0) { + printf("Rank %d Fail to close property @ line %d\n", rank, __LINE__); + ret_value = 1; + } else { + printf("Rank %d successfully close object property\n", rank); + } + // close a container property + if(PDCprop_close(cont_prop) < 0) { + printf("Rank %d Fail to close property @ line %d\n", rank, __LINE__); + ret_value = 1; + } else { + printf("Rank %d successfully close container property\n", rank); + } + // close pdc + if(PDCclose(pdc) < 0) { + printf("Rank %d fail to close PDC %d\n", rank, __LINE__); + ret_value = 1; + } + + free(mydata); + free(obj_data); + free(offset); + free(mysize); +#ifdef ENABLE_MPI + MPI_Finalize(); +#endif + return ret_value; +} diff --git a/src/tests/obj_tags.c b/src/tests/obj_tags.c new file mode 100644 index 000000000..e51f84e00 --- /dev/null +++ b/src/tests/obj_tags.c @@ -0,0 +1,228 @@ +/* + * Copyright Notice for + * Proactive Data Containers (PDC) Software Library and Utilities + * ----------------------------------------------------------------------------- + + *** Copyright Notice *** + + * Proactive Data Containers (PDC) Copyright (c) 2017, The Regents of the + * University of California, through Lawrence Berkeley National Laboratory, + * UChicago Argonne, LLC, operator of Argonne National Laboratory, and The HDF + * Group (subject to receipt of any required approvals from the U.S. Dept. of + * Energy). All rights reserved. + + * If you have questions about your rights to use or distribute this software, + * please contact Berkeley Lab's Innovation & Partnerships Office at IPO@lbl.gov. + + * NOTICE. This Software was developed under funding from the U.S. Department of + * Energy and the U.S. Government consequently retains certain rights. As such, the + * U.S. Government has been granted for itself and others acting on its behalf a + * paid-up, nonexclusive, irrevocable, worldwide license in the Software to + * reproduce, distribute copies to the public, prepare derivative works, and + * perform publicly and display publicly, and to permit other to do so. + */ + +#include +#include +#include +#include "pdc.h" + + +int main(int argc, char **argv) { + pdcid_t pdc, cont_prop, cont, obj_prop; + perr_t ret; + pdcid_t obj1, obj2; + int ret_value = 0; + + int rank = 0, size = 1; + + size_t ndim = 3; + uint64_t dims[3]; + dims[0] = 64; + dims[1] = 3; + dims[2] = 4; + char tag_value[128], tag_value2[128], *tag_value_ret; + char cont_name[128], obj_name1[128], obj_name2[128]; + psize_t value_size; + + strcpy(tag_value, "some tag value"); + strcpy(tag_value2, "some tag value 2 is longer"); + +#ifdef ENABLE_MPI + MPI_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); +#endif + // create a pdc + pdc = PDCinit("pdc"); + printf("create a new pdc\n"); + + // create a container property + cont_prop = PDCprop_create(PDC_CONT_CREATE, pdc); + if(cont_prop > 0) { + printf("Create a container property\n"); + } else { + printf("Fail to create container property @ line %d!\n", __LINE__); + ret_value = 1; + } + // create a container + sprintf(cont_name, "c%d", rank); + cont = PDCcont_create(cont_name, cont_prop); + if(cont > 0) { + printf("Create a container c1\n"); + } else { + printf("Fail to create container @ line %d!\n", __LINE__); + ret_value = 1; + } + // create an object property + obj_prop = PDCprop_create(PDC_OBJ_CREATE, pdc); + if(obj_prop > 0) { + printf("Create an object property\n"); + } else { + printf("Fail to create object property @ line %d!\n", __LINE__); + ret_value = 1; + } + + ret = PDCprop_set_obj_dims(obj_prop, ndim, dims); + if ( ret != SUCCEED ) { + printf("Fail to set obj dim @ line %d\n", __LINE__); + ret_value = 1; + } + ret = PDCprop_set_obj_type(obj_prop, PDC_DOUBLE); + if ( ret != SUCCEED ) { + printf("Fail to set obj type @ line %d\n", __LINE__); + ret_value = 1; + } + + + // create first object + sprintf(obj_name1, "o1_%d", rank); + obj1 = PDCobj_create(cont, obj_name1, obj_prop); + if(obj1 > 0) { + printf("Create an object o1\n"); + } else { + printf("Fail to create object @ line %d!\n", __LINE__); + ret_value = 1; + } + // create second object + sprintf(obj_name2, "o2_%d", rank); + obj2 = PDCobj_create(cont, obj_name2, obj_prop); + if(obj2 > 0) { + printf("Create an object o2\n"); + } else { + printf("Fail to create object @ line %d!\n", __LINE__); + ret_value = 1; + } + + ret = PDCobj_put_tag(obj1, "some tag", tag_value, strlen(tag_value) + 1); + if ( ret != SUCCEED ) { + printf("Put tag failed at object 1\n"); + ret_value = 1; + } + ret = PDCobj_put_tag(obj1, "some tag 2", tag_value2, strlen(tag_value2) + 1); + if ( ret != SUCCEED ) { + printf("Put tag failed at object 1\n"); + ret_value = 1; + } + + ret = PDCobj_put_tag(obj2, "some tag", tag_value, strlen(tag_value) + 1); + if ( ret != SUCCEED ) { + printf("Put tag failed at object 2\n"); + ret_value = 1; + } + + ret = PDCobj_put_tag(obj2, "some tag 2", tag_value2, strlen(tag_value2) + 1); + if ( ret != SUCCEED ) { + printf("Put tag failed at object 2\n"); + ret_value = 1; + } + + ret = PDCobj_get_tag(obj1, "some tag", (void **)&tag_value_ret, &value_size); + if ( ret != SUCCEED ) { + printf("Get tag failed at object 1\n"); + ret_value = 1; + } + + if (strcmp(tag_value, tag_value_ret) != 0) { + printf("Wrong tag value at object 1, expected = %s, get %s\n", tag_value, tag_value_ret); + ret_value = 1; + } + + ret = PDCobj_get_tag(obj1, "some tag 2", (void **)&tag_value_ret, &value_size); + if ( ret != SUCCEED ) { + printf("Get tag failed at object 1\n"); + ret_value = 1; + } + + if (strcmp(tag_value2, tag_value_ret) != 0) { + printf("Wrong tag value 2 at object 1, expected = %s, get %s\n", tag_value2, tag_value_ret); + ret_value = 1; + } + + ret = PDCobj_get_tag(obj2, "some tag", (void **)&tag_value_ret, &value_size); + if ( ret != SUCCEED ) { + printf("Get tag failed at object 2\n"); + ret_value = 1; + } + + if (strcmp(tag_value, tag_value_ret) != 0) { + printf("Wrong tag value at object 2, expected = %s, get %s\n", tag_value, tag_value_ret); + ret_value = 1; + } + + ret = PDCobj_get_tag(obj2, "some tag 2", (void **)&tag_value_ret, &value_size); + if ( ret != SUCCEED ) { + printf("Get tag failed at object 2\n"); + ret_value = 1; + } + + if (strcmp(tag_value2, tag_value_ret) != 0) { + printf("Wrong tag value 2 at object 2, expected = %s, get %s\n", tag_value2, tag_value_ret); + ret_value = 1; + } + + + // close object + if(PDCobj_close(obj1) < 0) { + printf("fail to close object o1\n"); + ret_value = 1; + } else { + printf("successfully close object o1\n"); + } + if(PDCobj_close(obj2) < 0) { + printf("fail to close object o2\n"); + ret_value = 1; + } else { + printf("successfully close object o2\n"); + } + // close a container + if(PDCcont_close(cont) < 0) { + printf("fail to close container c1\n"); + ret_value = 1; + } else { + printf("successfully close container c1\n"); + } + // close a object property + if(PDCprop_close(obj_prop) < 0) { + printf("Fail to close property @ line %d\n", __LINE__); + ret_value = 1; + } else { + printf("successfully close object property\n"); + } + // close a container property + if(PDCprop_close(cont_prop) < 0) { + printf("Fail to close property @ line %d\n", __LINE__); + ret_value = 1; + } else { + printf("successfully close container property\n"); + } + // close pdc + if(PDCclose(pdc) < 0) { + printf("fail to close PDC\n"); + ret_value = 1; + } +#ifdef ENABLE_MPI + MPI_Finalize(); +#endif + return ret_value; +} diff --git a/src/tests/open_cont.c b/src/tests/open_cont.c index 1a572fd18..56db54f7e 100644 --- a/src/tests/open_cont.c +++ b/src/tests/open_cont.c @@ -34,6 +34,8 @@ int main(int argc, char **argv) int rank = 0, size = 1; pdcid_t pdc_id, cont_prop, cont_id, cont_id2; + int ret_value = 0; + #ifdef ENABLE_MPI MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); @@ -45,43 +47,51 @@ int main(int argc, char **argv) // create a container property cont_prop = PDCprop_create(PDC_CONT_CREATE, pdc_id); - if(cont_prop <= 0) + if(cont_prop <= 0) { printf("Fail to create container property @ line %d!\n", __LINE__); - + ret_value = 1; + } // create a container cont_id = PDCcont_create_col("c1", cont_prop); - if(cont_id <= 0) + if(cont_id <= 0) { printf("Fail to create container @ line %d!\n", __LINE__); - + ret_value = 1; + } #ifdef ENABLE_MPI MPI_Barrier(MPI_COMM_WORLD); #endif cont_id2 = PDCcont_open("c1", pdc_id); - if(cont_id2 == 0) + if(cont_id2 == 0) { printf("Fail to open container @ line %d!\n", __LINE__); + ret_value = 1; + } #ifdef ENABLE_MPI MPI_Barrier(MPI_COMM_WORLD); #endif // close a container - if(PDCcont_close(cont_id) < 0) + if(PDCcont_close(cont_id) < 0) { printf("fail to close container cont_id1\n"); - - if(PDCcont_close(cont_id2) < 0) + ret_value = 1; + } + if(PDCcont_close(cont_id2) < 0) { printf("fail to close container cont_id2\n"); - + ret_value = 1; + } // close a container property - if(PDCprop_close(cont_prop) < 0) + if(PDCprop_close(cont_prop) < 0) { printf("Fail to close property @ line %d\n", __LINE__); - - if(PDCclose(pdc_id) < 0) - printf("fail to close PDC\n"); - + ret_value = 1; + } + if(PDCclose(pdc_id) < 0) { + printf("fail to close PDC\n"); + ret_value = 1; + } #ifdef ENABLE_MPI MPI_Finalize(); #endif - return 0; + return ret_value; } diff --git a/src/tests/open_obj.c b/src/tests/open_obj.c index 80c7e9331..849322862 100644 --- a/src/tests/open_obj.c +++ b/src/tests/open_obj.c @@ -31,6 +31,8 @@ int main(int argc, char **argv) { pdcid_t pdc, cont_prop, cont, obj_prop; pdcid_t obj1, obj2, open11, open12, open21; int rank = 0, size = 1; + int ret_value = 0; + char cont_name[128], obj_name1[128], obj_name2[128]; #ifdef ENABLE_MPI MPI_Init(&argc, &argv); @@ -43,109 +45,130 @@ int main(int argc, char **argv) { // create a container property cont_prop = PDCprop_create(PDC_CONT_CREATE, pdc); - if(cont_prop > 0) - printf("Create a container property\n"); - else - printf("Fail to create container property @ line %d!\n", __LINE__); - + if(cont_prop > 0) { + printf("Rank %d Create a container property\n", rank); + } else { + printf("Rank %d Fail to create container property @ line %d!\n", rank, __LINE__); + ret_value = 1; + } // create a container - cont = PDCcont_create("c1", cont_prop); - if(cont > 0) - printf("Create a container c1\n"); - else - printf("Fail to create container @ line %d!\n", __LINE__); - + sprintf(cont_name, "c%d", rank); + cont = PDCcont_create(cont_name, cont_prop); + if(cont > 0) { + printf("Rank %d Create a container c1\n", rank); + } else { + printf("Rank %d Fail to create container @ line %d!\n", rank, __LINE__); + ret_value = 1; + } // create an object property obj_prop = PDCprop_create(PDC_OBJ_CREATE, pdc); - if(obj_prop > 0) - printf("Create an object property\n"); - else - printf("Fail to create object property @ line %d!\n", __LINE__); - + if(obj_prop > 0) { + printf("Rank %d Create an object property\n", rank); + } else { + printf("Rank %d Fail to create object property @ line %d!\n", rank, __LINE__); + ret_value = 1; + } // create first object - obj1 = PDCobj_create(cont, "o1", obj_prop); - if(obj1 > 0) - printf("Create an object o1\n"); - else - printf("Fail to create object @ line %d!\n", __LINE__); - + sprintf(obj_name1, "o1_%d", rank); + obj1 = PDCobj_create(cont, obj_name1, obj_prop); + if(obj1 > 0) { + printf("Rank %d Create an object o1\n", rank); + } else { + printf("Rank %d Fail to create object @ line %d!\n", rank, __LINE__); + ret_value = 1; + } // create second object - obj2 = PDCobj_create(cont, "o2", obj_prop); - if(obj2 > 0) - printf("Create an object o2\n"); - else - printf("Fail to create object @ line %d!\n", __LINE__); - + sprintf(obj_name2, "o2_%d", rank); + obj2 = PDCobj_create(cont, obj_name2, obj_prop); + if(obj2 > 0) { + printf("Rank %d Create an object o2\n", rank); + } else { + printf("Rank %d Fail to create object @ line %d!\n", rank, __LINE__); + ret_value = 1; + } + // open first object twice - open11 = PDCobj_open("o1", pdc); - if(open11 == 0) - printf("Fail to open object o1\n"); - else - printf("Open object o1\n"); - - open12 = PDCobj_open("o1", pdc); - if(open12 == 0) - printf("Fail to open object o1\n"); - else - printf("Open object o1\n"); - + open11 = PDCobj_open(obj_name1, pdc); + if(open11 == 0) { + printf("Rank %d Fail to open object o1\n", rank); + ret_value = 1; + } else { + printf("Rank %d Open object o1\n", rank); + } + open12 = PDCobj_open(obj_name1, pdc); + if(open12 == 0) { + printf("Rank %d Fail to open object o1\n", rank); + ret_value = 1; + } else { + printf("Rank %d Open object o1\n", rank); + } // open second object once - open21 = PDCobj_open("o2", pdc); - if(open21 == 0) - printf("Fail to open object o2\n"); - else - printf("Open object o2\n"); - + open21 = PDCobj_open(obj_name2, pdc); + if(open21 == 0) { + printf("Rank %d Fail to open object o2\n", rank); + ret_value = 1; + } else { + printf("Rank %d Open object o2\n"); + } // close object - if(PDCobj_close(obj1) < 0) - printf("fail to close object o1\n"); - else - printf("successfully close object o1\n"); - - if(PDCobj_close(open11) < 0) - printf("fail to close object open11\n"); - else - printf("successfully close object open11\n"); - - if(PDCobj_close(open12) < 0) - printf("fail to close object open12\n"); - else - printf("successfully close object open12\n"); - - if(PDCobj_close(obj2) < 0) - printf("fail to close object o2\n"); - else - printf("successfully close object o2\n"); - - if(PDCobj_close(open21) < 0) - printf("fail to close object open21\n"); - else - printf("successfully close object open21\n"); - + if(PDCobj_close(obj1) < 0) { + printf("Rank %d fail to close object o1\n", rank); + ret_value = 1; + } else { + printf("Rank %d successfully close object o1\n", rank); + } + if(PDCobj_close(open11) < 0) { + printf("Rank %d fail to close object open11\n", rank); + ret_value = 1; + } else { + printf("Rank %d successfully close object open11\n", rank); + } + if(PDCobj_close(open12) < 0) { + printf("Rank %d fail to close object open12\n", rank); + ret_value = 1; + } else { + printf("Rank %d successfully close object open12\n", rank); + } + if(PDCobj_close(obj2) < 0) { + printf("Rank %d fail to close object o2\n", rank); + ret_value = 1; + } else { + printf("Rank %d successfully close object o2\n", rank); + } + if(PDCobj_close(open21) < 0) { + printf("Rank %d fail to close object open21\n", rank); + ret_value = 1; + } else { + printf("Rank %d successfully close object open21\n", rank); + } // close a container - if(PDCcont_close(cont) < 0) - printf("fail to close container c1\n"); - else - printf("successfully close container c1\n"); - + if(PDCcont_close(cont) < 0) { + printf("Rank %d fail to close container c1\n", rank); + ret_value = 1; + } else { + printf("Rank %d successfully close container c1\n", rank); + } // close a object property - if(PDCprop_close(obj_prop) < 0) - printf("Fail to close property @ line %d\n", __LINE__); - else - printf("successfully close object property\n"); - + if(PDCprop_close(obj_prop) < 0) { + printf("Rank %d Fail to close property @ line %d\n", rank, __LINE__); + ret_value = 1; + } else { + printf("Rank %d successfully close object property\n", rank); + } // close a container property - if(PDCprop_close(cont_prop) < 0) - printf("Fail to close property @ line %d\n", __LINE__); - else - printf("successfully close container property\n"); - + if(PDCprop_close(cont_prop) < 0) { + printf("Rank %d Fail to close property @ line %d\n", rank, __LINE__); + ret_value = 1; + } else { + printf("Rank %d successfully close container property\n", rank); + } // close pdc - if(PDCclose(pdc) < 0) - printf("fail to close PDC\n"); - + if(PDCclose(pdc) < 0) { + printf("Rank %d fail to close PDC\n", rank); + ret_value = 1; + } #ifdef ENABLE_MPI MPI_Finalize(); #endif - return 0; + return ret_value; } diff --git a/src/tests/open_obj_round_robin.c b/src/tests/open_obj_round_robin.c new file mode 100644 index 000000000..907d7ee55 --- /dev/null +++ b/src/tests/open_obj_round_robin.c @@ -0,0 +1,243 @@ +/* + * Copyright Notice for + * Proactive Data Containers (PDC) Software Library and Utilities + * ----------------------------------------------------------------------------- + + *** Copyright Notice *** + + * Proactive Data Containers (PDC) Copyright (c) 2017, The Regents of the + * University of California, through Lawrence Berkeley National Laboratory, + * UChicago Argonne, LLC, operator of Argonne National Laboratory, and The HDF + * Group (subject to receipt of any required approvals from the U.S. Dept. of + * Energy). All rights reserved. + + * If you have questions about your rights to use or distribute this software, + * please contact Berkeley Lab's Innovation & Partnerships Office at IPO@lbl.gov. + + * NOTICE. This Software was developed under funding from the U.S. Department of + * Energy and the U.S. Government consequently retains certain rights. As such, the + * U.S. Government has been granted for itself and others acting on its behalf a + * paid-up, nonexclusive, irrevocable, worldwide license in the Software to + * reproduce, distribute copies to the public, prepare derivative works, and + * perform publicly and display publicly, and to permit other to do so. + */ + +#include +#include +#include +#include "pdc.h" + +int main(int argc, char **argv) { + pdcid_t pdc, cont_prop, cont, obj_prop; + pdcid_t obj1, obj2; + int rank = 0, size = 1, i, ret; + int ret_value = 0; + char cont_name[128], obj_name1[128], obj_name2[128]; + struct pdc_obj_info *obj1_info, *obj2_info; + + size_t ndim = 3; + uint64_t dims[3]; + +#ifdef ENABLE_MPI + MPI_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); +#endif + dims[0] = rank*2+1; + dims[1] = rank*3+2; + dims[2] = rank*5+3; + + // create a pdc + pdc = PDCinit("pdc"); + printf("create a new pdc\n"); + + // create a container property + cont_prop = PDCprop_create(PDC_CONT_CREATE, pdc); + if(cont_prop > 0) { + printf("Rank %d Create a container property\n", rank); + } else { + printf("Rank %d Fail to create container property @ line %d!\n", rank, __LINE__); + ret_value = 1; + } + // create a container + sprintf(cont_name, "c"); + cont = PDCcont_create_col(cont_name, cont_prop); + //cont = PDCcont_create(cont_name, cont_prop); + if(cont > 0) { + printf("Rank %d Create a container %s\n", rank, cont_name); + } else { + printf("Rank %d Fail to create container @ line %d!\n", rank, __LINE__); + ret_value = 1; + } + // create an object property + obj_prop = PDCprop_create(PDC_OBJ_CREATE, pdc); + if(obj_prop > 0) { + printf("Rank %d Create an object property\n", rank); + } else { + printf("Rank %d Fail to create object property @ line %d!\n", rank, __LINE__); + ret_value = 1; + } + ret = PDCprop_set_obj_dims(obj_prop, ndim, dims); + if ( ret != SUCCEED ) { + printf("Fail to set obj time step @ line %d\n", __LINE__); + ret_value = 1; + } + ret = PDCprop_set_obj_type(obj_prop, PDC_DOUBLE); + if ( ret != SUCCEED ) { + printf("Fail to set obj time step @ line %d\n", __LINE__); + ret_value = 1; + } + + // create first object + sprintf(obj_name1, "o1_%d", rank); + obj1 = PDCobj_create(cont, obj_name1, obj_prop); + if(obj1 > 0) { + printf("Rank %d Create an object %s\n", rank, obj_name1); + } else { + printf("Rank %d Fail to create object @ line %d!\n", rank, __LINE__); + ret_value = 1; + } + + // create second object + sprintf(obj_name2, "o2_%d", rank); + obj2 = PDCobj_create(cont, obj_name2, obj_prop); + if(obj2 > 0) { + printf("Rank %d Create an object %s\n", rank, obj_name2); + } else { + printf("Rank %d Fail to create object @ line %d!\n", rank, __LINE__); + ret_value = 1; + } + + // close created objects + if(PDCobj_close(obj1) < 0) { + printf("Rank %d fail to close object o1\n", rank); + ret_value = 1; + } else { + printf("Rank %d successfully close object o1\n", rank); + } + if(PDCobj_close(obj2) < 0) { + printf("Rank %d fail to close object o2\n", rank); + ret_value = 1; + } else { + printf("Rank %d successfully close object o2\n", rank); + } + // Wait for all processes to finish their object creation + #ifdef ENABLE_MPI + MPI_Barrier(MPI_COMM_WORLD); + #endif + for ( i = 1; i < size; ++i ) { + sprintf(obj_name1, "o1_%d", (rank + i) % size); + obj1 = PDCobj_open(obj_name1, pdc); + if(obj1 == 0) { + printf("Rank %d Fail to open object %s\n", rank, obj_name1); + ret_value = 1; + } else { + printf("Rank %d Opened object %s\n", rank, obj_name1); + } + sprintf(obj_name2, "o2_%d", (rank + i) % size); + obj2 = PDCobj_open(obj_name2, pdc); + if(obj2 == 0) { + printf("Rank %d Fail to open object %s\n", rank, obj_name2); + ret_value = 1; + } else { + printf("Rank %d Open object %s\n", rank, obj_name2); + } + obj1_info = PDCobj_get_info(obj1); + obj2_info = PDCobj_get_info(obj2); + if ( strcmp(obj1_info->name, obj_name1) != 0 ) { + printf("Object 1 name is wrong at rank %d\n", rank); + ret_value = 1; + } + + if (obj1_info->obj_pt->type != PDC_DOUBLE) { + printf("Type is not properly inherited from object 1 property at rank %d.\n", rank); + ret_value = 1; + } + + if (obj1_info->obj_pt->ndim != ndim) { + printf("Number of dimensions is not properly inherited from object 1 property at rank %d.\n", rank); + ret_value = 1; + } + if (obj1_info->obj_pt->dims[0] != (unsigned) (i + rank) % size * 2 + 1) { + printf("First dimension is not properly inherited from object 1 property at rank %d.\n", rank); + ret_value = 1; + } + if (obj1_info->obj_pt->dims[1] != (unsigned) (i + rank) % size * 3 + 2) { + printf("Second dimension is not properly inherited from object 1 property at rank %d.\n", rank); + ret_value = 1; + } + if (obj1_info->obj_pt->dims[2] != (unsigned) (i + rank) % size * 5 + 3) { + printf("Third dimension is not properly inherited from object 1 property at rank %d.\n", rank); + ret_value = 1; + } + if ( strcmp(obj2_info->name, obj_name2) != 0 ) { + printf("Object 2 name is wrong\n"); + ret_value = 1; + } + + if (obj2_info->obj_pt->type != PDC_DOUBLE) { + printf("Type is not properly inherited from object property.\n"); + ret_value = 1; + } + + if (obj2_info->obj_pt->ndim != ndim) { + printf("Number of dimensions is not properly inherited from object property at rank %d.\n", rank); + ret_value = 1; + } + if (obj2_info->obj_pt->dims[0] != (unsigned) (i + rank) % size * 2 + 1) { + printf("First dimension is not properly inherited from object property at rank %d.\n", rank); + ret_value = 1; + } + if (obj2_info->obj_pt->dims[1] != (unsigned) (i + rank) % size * 3 + 2) { + printf("Second dimension is not properly inherited from object property at rank %d.\n", rank); + ret_value = 1; + } + if (obj2_info->obj_pt->dims[2] != (unsigned) (i + rank) % size * 5 + 3) { + printf("Third dimension is not properly inherited from object property at rank %d.\n", rank); + ret_value = 1; + } + if(PDCobj_close(obj1) < 0) { + printf("Rank %d fail to close object %s\n", rank, obj_name1); + ret_value = 1; + } else { + printf("Rank %d successfully close object %s\n", rank, obj_name1); + } + if(PDCobj_close(obj2) < 0) { + printf("Rank %d fail to close object %s\n", rank, obj_name2); + ret_value = 1; + } else { + printf("Rank %d successfully close object %s\n", rank, obj_name2); + } + } + + // close a container + if(PDCcont_close(cont) < 0) { + printf("Rank %d fail to close container c1\n", rank); + ret_value = 1; + } else { + printf("Rank %d successfully close container c1\n", rank); + } + // close a object property + if(PDCprop_close(obj_prop) < 0) { + printf("Rank %d Fail to close property @ line %d\n", rank, __LINE__); + ret_value = 1; + } else { + printf("Rank %d successfully close object property\n", rank); + } + // close a container property + if(PDCprop_close(cont_prop) < 0) { + printf("Rank %d Fail to close property @ line %d\n", rank, __LINE__); + ret_value = 1; + } else { + printf("Rank %d successfully close container property\n", rank); + } + // close pdc + if(PDCclose(pdc) < 0) { + printf("Rank %d fail to close PDC\n", rank); + ret_value = 1; + } +#ifdef ENABLE_MPI + MPI_Finalize(); +#endif + return ret_value; +} diff --git a/src/tests/pdc_init.c b/src/tests/pdc_init.c index f0299eca8..e0d822f82 100644 --- a/src/tests/pdc_init.c +++ b/src/tests/pdc_init.c @@ -27,19 +27,28 @@ #include #include "pdc.h" -int main() { +int main(int argc, char **argv) { pdcid_t pdc; - + int rank = 0, size = 1; + int ret_value = 0; + // create a pdc +#ifdef ENABLE_MPI + MPI_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); +#endif + pdc = PDCinit("pdc"); printf("generated new pdc\n"); // close pdc - if(PDCclose(pdc) < 0) + if(PDCclose(pdc) < 0) { printf("fail to close PDC\n"); - + ret_value = 1; + } #ifdef ENABLE_MPI MPI_Finalize(); #endif - return 0; + return ret_value; } diff --git a/src/tests/query_data.c b/src/tests/query_data.c index 8d79478c8..8c0185fb2 100644 --- a/src/tests/query_data.c +++ b/src/tests/query_data.c @@ -10,7 +10,7 @@ #include "pdc_client_server_common.h" void print_usage() { - printf("Usage: srun -n ./data_server_read obj_name size_MB\n"); + printf("Usage: srun -n ./query_data obj_name size_MB\n"); } int main(int argc, char **argv) @@ -31,6 +31,7 @@ int main(int argc, char **argv) int lo1 = 2000, hi1 = 3000; int lo2 = 5000, hi2 = 7000; pdc_query_t *q0, *q1l, *q1h, *q1, *q2l, *q2h, *q2, *q, *q12; + int ret_value = 0; struct timeval ht_total_start; struct timeval ht_total_end; @@ -45,7 +46,10 @@ int main(int argc, char **argv) if (argc < 3) { print_usage(); - return 0; +#ifdef ENABLE_MPI + MPI_Finalize(); +#endif + return 1; } obj_name = argv[1]; @@ -61,19 +65,22 @@ int main(int argc, char **argv) // create a container property cont_prop = PDCprop_create(PDC_CONT_CREATE, pdc); - if(cont_prop <= 0) + if(cont_prop <= 0) { printf("Fail to create container property @ line %d!\n", __LINE__); - + ret_value = 1; + } // create a container cont = PDCcont_create("c1", cont_prop); - if(cont <= 0) + if(cont <= 0) { printf("Fail to create container @ line %d!\n", __LINE__); - + ret_value = 1; + } // create an object property obj_prop = PDCprop_create(PDC_OBJ_CREATE, pdc); - if(obj_prop <= 0) + if(obj_prop <= 0) { printf("Fail to create object property @ line %d!\n", __LINE__); - + ret_value = 1; + } my_data_count = size_MB / size; dims[0] = my_data_count; PDCprop_set_obj_dims(obj_prop, 1, dims); @@ -90,7 +97,7 @@ int main(int argc, char **argv) obj_id = PDCobj_create(cont, obj_name, obj_prop); if (obj_id <= 0) { printf("Error getting an object id of %s from server, exit...\n", "DataServerTestBin"); - exit(-1); + ret_value = 1; } } @@ -102,6 +109,7 @@ int main(int argc, char **argv) PDC_Client_query_metadata_name_timestep( obj_name, 0, &metadata); if (metadata == NULL || metadata->obj_id == 0) { printf("Error with metadata!\n"); + ret_value = 1; } region.ndim = ndim; @@ -135,6 +143,7 @@ int main(int argc, char **argv) // Construct query constraints q0 = PDCquery_create(obj_id, PDC_LT, PDC_INT, &lo0); + PDCquery_sel_region(q0, ®ion); q1l = PDCquery_create(obj_id, PDC_GTE, PDC_INT, &lo1); @@ -149,26 +158,29 @@ int main(int argc, char **argv) q = PDCquery_or(q0, q12); PDCquery_get_selection(q, &sel); + PDCselection_print(&sel); PDCquery_free_all(q); PDCregion_free(®ion); PDCselection_free(&sel); - // close a container - if(PDCcont_close(cont) < 0) + if(PDCcont_close(cont) < 0) { printf("fail to close container c1\n"); - + ret_value = 1; + } // close a container property - if(PDCprop_close(cont_prop) < 0) + if(PDCprop_close(cont_prop) < 0) { printf("Fail to close property @ line %d\n", __LINE__); - - if(PDCclose(pdc) < 0) - printf("fail to close PDC\n"); - + ret_value = 1; + } + if(PDCclose(pdc) < 0) { + printf("fail to close PDC\n"); + ret_value = 1; + } #ifdef ENABLE_MPI MPI_Finalize(); #endif - return 0; + return ret_value; } diff --git a/src/tests/region_obj_map.c b/src/tests/region_obj_map.c new file mode 100644 index 000000000..d3eb89a33 --- /dev/null +++ b/src/tests/region_obj_map.c @@ -0,0 +1,243 @@ +/* + * Copyright Notice for + * Proactive Data Containers (PDC) Software Library and Utilities + * ----------------------------------------------------------------------------- + + *** Copyright Notice *** + + * Proactive Data Containers (PDC) Copyright (c) 2017, The Regents of the + * University of California, through Lawrence Berkeley National Laboratory, + * UChicago Argonne, LLC, operator of Argonne National Laboratory, and The HDF + * Group (subject to receipt of any required approvals from the U.S. Dept. of + * Energy). All rights reserved. + + * If you have questions about your rights to use or distribute this software, + * please contact Berkeley Lab's Innovation & Partnerships Office at IPO@lbl.gov. + + * NOTICE. This Software was developed under funding from the U.S. Department of + * Energy and the U.S. Government consequently retains certain rights. As such, the + * U.S. Government has been granted for itself and others acting on its behalf a + * paid-up, nonexclusive, irrevocable, worldwide license in the Software to + * reproduce, distribute copies to the public, prepare derivative works, and + * perform publicly and display publicly, and to permit other to do so. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "pdc.h" +#include "pdc_client_connect.h" +#include "pdc_client_server_common.h" +#define BUF_LEN 128 + + +int main(int argc, char **argv) { + pdcid_t pdc, cont_prop, cont, obj_prop, reg, reg_global; + perr_t ret; + pdcid_t obj1, obj2; + char cont_name[128], obj_name1[128], obj_name2[128]; + + int rank = 0, size = 1, i; + int ret_value = 0; + + uint64_t offset[3], offset_length[3]; + uint64_t dims[1]; + offset[0] = 0; + offset[1] = 2; + offset[2] = 5; + offset_length[0] = BUF_LEN; + offset_length[1] = 3; + offset_length[2] = 5; + + int *data = (int*)malloc(sizeof(int)*BUF_LEN); + int *data_read = (int*)malloc(sizeof(int)*BUF_LEN); + int *obj_data = (int *)calloc(BUF_LEN, sizeof(int)); + dims[0] = BUF_LEN; + +#ifdef ENABLE_MPI + MPI_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); +#endif + // create a pdc + pdc = PDCinit("pdc"); + printf("create a new pdc\n"); + + // create a container property + cont_prop = PDCprop_create(PDC_CONT_CREATE, pdc); + if(cont_prop > 0) { + printf("Create a container property\n"); + } else { + printf("Fail to create container property @ line %d!\n", __LINE__); + ret_value = 1; + } + // create a container + sprintf(cont_name, "c%d", rank); + cont = PDCcont_create(cont_name, cont_prop); + if(cont > 0) { + printf("Create a container c1\n"); + } else { + printf("Fail to create container @ line %d!\n", __LINE__); + ret_value = 1; + } + // create an object property + obj_prop = PDCprop_create(PDC_OBJ_CREATE, pdc); + if(obj_prop > 0) { + printf("Create an object property\n"); + } else { + printf("Fail to create object property @ line %d!\n", __LINE__); + ret_value = 1; + } + + ret = PDCprop_set_obj_type(obj_prop, PDC_INT); + if ( ret != SUCCEED ) { + printf("Fail to set obj type @ line %d\n", __LINE__); + ret_value = 1; + } + PDCprop_set_obj_buf(obj_prop, obj_data); + PDCprop_set_obj_dims(obj_prop, 1, dims); + PDCprop_set_obj_user_id( obj_prop, getuid()); + PDCprop_set_obj_time_step( obj_prop, 0); + PDCprop_set_obj_app_name(obj_prop, "DataServerTest"); + PDCprop_set_obj_tags( obj_prop, "tag0=1"); + + + // create first object + sprintf(obj_name1, "o1_%d", rank); + obj1 = PDCobj_create(cont, obj_name1, obj_prop); + if(obj1 > 0) { + printf("Create an object o1\n"); + } else { + printf("Fail to create object @ line %d!\n", __LINE__); + ret_value = 1; + } + // create second object + sprintf(obj_name2, "o2_%d", rank); + obj2 = PDCobj_create(cont, obj_name2, obj_prop); + if(obj2 > 0) { + printf("Create an object o2\n"); + } else { + printf("Fail to create object @ line %d!\n", __LINE__); + ret_value = 1; + } + + reg = PDCregion_create(1, offset, offset_length); + reg_global = PDCregion_create(1, offset, offset_length); + + for ( i = 0; i < BUF_LEN; ++i ) { + data[i] = i; + } + ret = PDCbuf_obj_map(data, PDC_INT, reg, obj1, reg_global); + if(ret != SUCCEED) { + printf("PDCbuf_obj_map failed\n"); + ret_value = 1; + } + + for ( i = 0; i < BUF_LEN; ++i ) { + data[i] = -i; + } + + ret = PDCreg_obtain_lock(obj1, reg, PDC_WRITE, PDC_BLOCK); + if(ret != SUCCEED) { + printf("PDCreg_obtain_lock failed\n"); + exit(-1); + } + + ret = PDCreg_release_lock(obj1, reg, PDC_WRITE); + if(ret != SUCCEED) { + printf("PDCreg_release_lock failed\n"); + ret_value = 1; + } + + ret = PDCbuf_obj_unmap(obj1, reg_global); + if(ret != SUCCEED) { + printf("PDCbuf_obj_unmap failed\n"); + ret_value = 1; + } + + reg = PDCregion_create(1, offset, offset_length); + reg_global = PDCregion_create(1, offset, offset_length); + ret = PDCbuf_obj_map(data_read, PDC_INT, reg, obj1, reg_global); + if(ret != SUCCEED) { + printf("PDCbuf_obj_map failed\n"); + ret_value = 1; + } + + ret = PDCreg_obtain_lock(obj1, reg, PDC_READ, PDC_BLOCK); + if(ret != SUCCEED) { + printf("PDCreg_obtain_lock failed\n"); + ret_value = 1; + } + + + + ret = PDCreg_release_lock(obj1, reg, PDC_READ); + if(ret != SUCCEED) { + printf("PDCreg_release_lock failed\n"); + ret_value = 1; + } + + ret = PDCbuf_obj_unmap(obj1, reg_global); + if(ret != SUCCEED) { + printf("PDCbuf_obj_unmap failed\n"); + ret_value = 1; + } + + for ( i = 0; i < BUF_LEN; ++i ) { + if ( data_read[i] != i ) { + printf("wrong value %d!=%d\n", data_read[i], i); + ret_value = 1; + break; + } + } + + + // close object + if(PDCobj_close(obj1) < 0) { + printf("fail to close object o1\n"); + ret_value = 1; + } else { + printf("successfully close object o1\n"); + } + if(PDCobj_close(obj2) < 0) { + printf("fail to close object o2\n"); + ret_value = 1; + } else { + printf("successfully close object o2\n"); + } + // close a container + if(PDCcont_close(cont) < 0) { + printf("fail to close container c1\n"); + ret_value = 1; + } else { + printf("successfully close container c1\n"); + } + // close a object property + if(PDCprop_close(obj_prop) < 0) { + printf("Fail to close property @ line %d\n", __LINE__); + ret_value = 1; + } else { + printf("successfully close object property\n"); + } + // close a container property + if(PDCprop_close(cont_prop) < 0) { + printf("Fail to close property @ line %d\n", __LINE__); + ret_value = 1; + } else { + printf("successfully close container property\n"); + } + // close pdc + if(PDCclose(pdc) < 0) { + printf("fail to close PDC\n"); + ret_value = 1; + } +#ifdef ENABLE_MPI + MPI_Finalize(); +#endif + return ret_value; +} diff --git a/src/tests/region_obj_map_2D.c b/src/tests/region_obj_map_2D.c new file mode 100644 index 000000000..dd21b1f0a --- /dev/null +++ b/src/tests/region_obj_map_2D.c @@ -0,0 +1,248 @@ +/* + * Copyright Notice for + * Proactive Data Containers (PDC) Software Library and Utilities + * ----------------------------------------------------------------------------- + + *** Copyright Notice *** + + * Proactive Data Containers (PDC) Copyright (c) 2017, The Regents of the + * University of California, through Lawrence Berkeley National Laboratory, + * UChicago Argonne, LLC, operator of Argonne National Laboratory, and The HDF + * Group (subject to receipt of any required approvals from the U.S. Dept. of + * Energy). All rights reserved. + + * If you have questions about your rights to use or distribute this software, + * please contact Berkeley Lab's Innovation & Partnerships Office at IPO@lbl.gov. + + * NOTICE. This Software was developed under funding from the U.S. Department of + * Energy and the U.S. Government consequently retains certain rights. As such, the + * U.S. Government has been granted for itself and others acting on its behalf a + * paid-up, nonexclusive, irrevocable, worldwide license in the Software to + * reproduce, distribute copies to the public, prepare derivative works, and + * perform publicly and display publicly, and to permit other to do so. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "pdc.h" +#include "pdc_client_connect.h" +#include "pdc_client_server_common.h" +#define BUF_LEN 128 + + +int main(int argc, char **argv) { + pdcid_t pdc, cont_prop, cont, obj_prop, reg, reg_global; + perr_t ret; + pdcid_t obj1, obj2; + char cont_name[128], obj_name1[128], obj_name2[128]; + + int rank = 0, size = 1, i; + int ret_value = 0; + + uint64_t offset[2], offset_length[2]; + int ndim = 2; + uint64_t dims[2]; + offset[0] = 0; + offset[1] = 0; + offset_length[0] = BUF_LEN/2; + offset_length[1] = 2; + + int *data = (int*)malloc(sizeof(int)*BUF_LEN); + int *data_read = (int*)malloc(sizeof(int)*BUF_LEN); + int *obj_data = (int *)calloc(BUF_LEN, sizeof(int)); + dims[0] = BUF_LEN / 2; + dims[1] = 2; + +#ifdef ENABLE_MPI + MPI_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); +#endif + // create a pdc + pdc = PDCinit("pdc"); + printf("create a new pdc\n"); + + // create a container property + cont_prop = PDCprop_create(PDC_CONT_CREATE, pdc); + if(cont_prop > 0) { + printf("Create a container property\n"); + } else { + printf("Fail to create container property @ line %d!\n", __LINE__); + ret_value = 1; + } + // create a container + sprintf(cont_name, "c%d", rank); + cont = PDCcont_create(cont_name, cont_prop); + if(cont > 0) { + printf("Create a container c1\n"); + } else { + printf("Fail to create container @ line %d!\n", __LINE__); + ret_value = 1; + } + // create an object property + obj_prop = PDCprop_create(PDC_OBJ_CREATE, pdc); + if(obj_prop > 0) { + printf("Create an object property\n"); + } else { + printf("Fail to create object property @ line %d!\n", __LINE__); + ret_value = 1; + } + + ret = PDCprop_set_obj_type(obj_prop, PDC_INT); + if ( ret != SUCCEED ) { + printf("Fail to set obj type @ line %d\n", __LINE__); + ret_value = 1; + } + PDCprop_set_obj_buf(obj_prop, obj_data); + PDCprop_set_obj_dims(obj_prop, ndim, dims); + PDCprop_set_obj_user_id( obj_prop, getuid()); + PDCprop_set_obj_time_step( obj_prop, 0); + PDCprop_set_obj_app_name(obj_prop, "DataServerTest"); + PDCprop_set_obj_tags( obj_prop, "tag0=1"); + + + // create first object + sprintf(obj_name1, "o1_%d", rank); + obj1 = PDCobj_create(cont, obj_name1, obj_prop); + if(obj1 > 0) { + printf("Create an object o1\n"); + } else { + printf("Fail to create object @ line %d!\n", __LINE__); + ret_value = 1; + } + // create second object + sprintf(obj_name2, "o2_%d", rank); + obj2 = PDCobj_create(cont, obj_name2, obj_prop); + if(obj2 > 0) { + printf("Create an object o2\n"); + } else { + printf("Fail to create object @ line %d!\n", __LINE__); + ret_value = 1; + } + + //reg = PDCregion_create(1, offset, offset_length); + //reg_global = PDCregion_create(1, offset, offset_length); + reg = PDCregion_create(ndim, offset, offset_length); + reg_global = PDCregion_create(ndim, offset, offset_length); + + for ( i = 0; i < BUF_LEN; ++i ) { + data[i] = i; + } + ret = PDCbuf_obj_map(data, PDC_INT, reg, obj1, reg_global); + if(ret != SUCCEED) { + printf("PDCbuf_obj_map failed\n"); + ret_value = 1; + } + + for ( i = 0; i < BUF_LEN; ++i ) { + data[i] = i; + } + + ret = PDCreg_obtain_lock(obj1, reg, PDC_WRITE, PDC_BLOCK); + if(ret != SUCCEED) { + printf("PDCreg_obtain_lock failed\n"); + exit(-1); + } + + ret = PDCreg_release_lock(obj1, reg, PDC_WRITE); + if(ret != SUCCEED) { + printf("PDCreg_release_lock failed\n"); + ret_value = 1; + } + + ret = PDCbuf_obj_unmap(obj1, reg_global); + if(ret != SUCCEED) { + printf("PDCbuf_obj_unmap failed\n"); + ret_value = 1; + } + + //reg = PDCregion_create(1, offset, offset_length); + //reg_global = PDCregion_create(1, offset, offset_length); + reg = PDCregion_create(ndim, offset, offset_length); + reg_global = PDCregion_create(ndim, offset, offset_length); + + ret = PDCbuf_obj_map(data_read, PDC_INT, reg, obj1, reg_global); + if(ret != SUCCEED) { + printf("PDCbuf_obj_map failed\n"); + ret_value = 1; + } + + ret = PDCreg_obtain_lock(obj1, reg, PDC_READ, PDC_BLOCK); + if(ret != SUCCEED) { + printf("PDCreg_obtain_lock failed\n"); + ret_value = 1; + } + + + + ret = PDCreg_release_lock(obj1, reg, PDC_READ); + if(ret != SUCCEED) { + printf("PDCreg_release_lock failed\n"); + ret_value = 1; + } + + ret = PDCbuf_obj_unmap(obj1, reg_global); + if(ret != SUCCEED) { + printf("PDCbuf_obj_unmap failed\n"); + ret_value = 1; + } + + for ( i = 0; i < BUF_LEN; ++i ) { + if ( data_read[i] != i ) { + printf("wrong value %d!=%d\n", data_read[i], i); + ret_value = 1; + break; + } + } + + + // close object + if(PDCobj_close(obj1) < 0) { + printf("fail to close object o1\n"); + ret_value = 1; + } else { + printf("successfully close object o1\n"); + } + if(PDCobj_close(obj2) < 0) { + printf("fail to close object o2\n"); + ret_value = 1; + } else { + printf("successfully close object o2\n"); + } + // close a container + if(PDCcont_close(cont) < 0) { + printf("fail to close container c1\n"); + ret_value = 1; + } else { + printf("successfully close container c1\n"); + } + // close a object property + if(PDCprop_close(obj_prop) < 0) { + printf("Fail to close property @ line %d\n", __LINE__); + ret_value = 1; + } else { + printf("successfully close object property\n"); + } + // close a container property + if(PDCprop_close(cont_prop) < 0) { + printf("Fail to close property @ line %d\n", __LINE__); + ret_value = 1; + } else { + printf("successfully close container property\n"); + } + // close pdc + if(PDCclose(pdc) < 0) { + printf("fail to close PDC\n"); + ret_value = 1; + } +#ifdef ENABLE_MPI + MPI_Finalize(); +#endif + return ret_value; +} diff --git a/src/tests/region_obj_map_3D.c b/src/tests/region_obj_map_3D.c new file mode 100644 index 000000000..ef67c1683 --- /dev/null +++ b/src/tests/region_obj_map_3D.c @@ -0,0 +1,250 @@ +/* + * Copyright Notice for + * Proactive Data Containers (PDC) Software Library and Utilities + * ----------------------------------------------------------------------------- + + *** Copyright Notice *** + + * Proactive Data Containers (PDC) Copyright (c) 2017, The Regents of the + * University of California, through Lawrence Berkeley National Laboratory, + * UChicago Argonne, LLC, operator of Argonne National Laboratory, and The HDF + * Group (subject to receipt of any required approvals from the U.S. Dept. of + * Energy). All rights reserved. + + * If you have questions about your rights to use or distribute this software, + * please contact Berkeley Lab's Innovation & Partnerships Office at IPO@lbl.gov. + + * NOTICE. This Software was developed under funding from the U.S. Department of + * Energy and the U.S. Government consequently retains certain rights. As such, the + * U.S. Government has been granted for itself and others acting on its behalf a + * paid-up, nonexclusive, irrevocable, worldwide license in the Software to + * reproduce, distribute copies to the public, prepare derivative works, and + * perform publicly and display publicly, and to permit other to do so. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "pdc.h" +#include "pdc_client_connect.h" +#include "pdc_client_server_common.h" +#define BUF_LEN 128 + + +int main(int argc, char **argv) { + pdcid_t pdc, cont_prop, cont, obj_prop, reg, reg_global; + perr_t ret; + pdcid_t obj1, obj2; + char cont_name[128], obj_name1[128], obj_name2[128]; + + int rank = 0, size = 1, i; + int ret_value = 0; + + uint64_t offset[3], offset_length[3]; + uint64_t dims[3]; + offset[0] = 0; + offset[1] = 0; + offset[2] = 0; + offset_length[0] = BUF_LEN/4; + offset_length[1] = 2; + offset_length[2] = 2; + + int *data = (int*)malloc(sizeof(int)*BUF_LEN); + int *data_read = (int*)malloc(sizeof(int)*BUF_LEN); + int *obj_data = (int *)calloc(BUF_LEN, sizeof(int)); + dims[0] = BUF_LEN / 4; + dims[1] = 2; + dims[2] = 2; + +#ifdef ENABLE_MPI + MPI_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); +#endif + // create a pdc + pdc = PDCinit("pdc"); + printf("create a new pdc\n"); + + // create a container property + cont_prop = PDCprop_create(PDC_CONT_CREATE, pdc); + if(cont_prop > 0) { + printf("Create a container property\n"); + } else { + printf("Fail to create container property @ line %d!\n", __LINE__); + ret_value = 1; + } + // create a container + sprintf(cont_name, "c%d", rank); + cont = PDCcont_create(cont_name, cont_prop); + if(cont > 0) { + printf("Create a container c1\n"); + } else { + printf("Fail to create container @ line %d!\n", __LINE__); + ret_value = 1; + } + // create an object property + obj_prop = PDCprop_create(PDC_OBJ_CREATE, pdc); + if(obj_prop > 0) { + printf("Create an object property\n"); + } else { + printf("Fail to create object property @ line %d!\n", __LINE__); + ret_value = 1; + } + + ret = PDCprop_set_obj_type(obj_prop, PDC_INT); + if ( ret != SUCCEED ) { + printf("Fail to set obj type @ line %d\n", __LINE__); + ret_value = 1; + } + PDCprop_set_obj_buf(obj_prop, obj_data); + PDCprop_set_obj_dims(obj_prop, 3, dims); + PDCprop_set_obj_user_id( obj_prop, getuid()); + PDCprop_set_obj_time_step( obj_prop, 0); + PDCprop_set_obj_app_name(obj_prop, "DataServerTest"); + PDCprop_set_obj_tags( obj_prop, "tag0=1"); + + + // create first object + sprintf(obj_name1, "o1_%d", rank); + obj1 = PDCobj_create(cont, obj_name1, obj_prop); + if(obj1 > 0) { + printf("Create an object o1\n"); + } else { + printf("Fail to create object @ line %d!\n", __LINE__); + ret_value = 1; + } + // create second object + sprintf(obj_name2, "o2_%d", rank); + obj2 = PDCobj_create(cont, obj_name2, obj_prop); + if(obj2 > 0) { + printf("Create an object o2\n"); + } else { + printf("Fail to create object @ line %d!\n", __LINE__); + ret_value = 1; + } + + //reg = PDCregion_create(1, offset, offset_length); + //reg_global = PDCregion_create(1, offset, offset_length); + reg = PDCregion_create(3, offset, offset_length); + reg_global = PDCregion_create(3, offset, offset_length); + + for ( i = 0; i < BUF_LEN; ++i ) { + data[i] = i; + } + ret = PDCbuf_obj_map(data, PDC_INT, reg, obj1, reg_global); + if(ret != SUCCEED) { + printf("PDCbuf_obj_map failed\n"); + ret_value = 1; + } + + for ( i = 0; i < BUF_LEN; ++i ) { + data[i] = i; + } + + ret = PDCreg_obtain_lock(obj1, reg, PDC_WRITE, PDC_BLOCK); + if(ret != SUCCEED) { + printf("PDCreg_obtain_lock failed\n"); + exit(-1); + } + + ret = PDCreg_release_lock(obj1, reg, PDC_WRITE); + if(ret != SUCCEED) { + printf("PDCreg_release_lock failed\n"); + ret_value = 1; + } + + ret = PDCbuf_obj_unmap(obj1, reg_global); + if(ret != SUCCEED) { + printf("PDCbuf_obj_unmap failed\n"); + ret_value = 1; + } + + //reg = PDCregion_create(1, offset, offset_length); + //reg_global = PDCregion_create(1, offset, offset_length); + reg = PDCregion_create(3, offset, offset_length); + reg_global = PDCregion_create(3, offset, offset_length); + + ret = PDCbuf_obj_map(data_read, PDC_INT, reg, obj1, reg_global); + if(ret != SUCCEED) { + printf("PDCbuf_obj_map failed\n"); + ret_value = 1; + } + + ret = PDCreg_obtain_lock(obj1, reg, PDC_READ, PDC_BLOCK); + if(ret != SUCCEED) { + printf("PDCreg_obtain_lock failed\n"); + ret_value = 1; + } + + + + ret = PDCreg_release_lock(obj1, reg, PDC_READ); + if(ret != SUCCEED) { + printf("PDCreg_release_lock failed\n"); + ret_value = 1; + } + + ret = PDCbuf_obj_unmap(obj1, reg_global); + if(ret != SUCCEED) { + printf("PDCbuf_obj_unmap failed\n"); + ret_value = 1; + } + + for ( i = 0; i < BUF_LEN; ++i ) { + if ( data_read[i] != i ) { + printf("wrong value %d!=%d\n", data_read[i], i); + ret_value = 1; + break; + } + } + + + // close object + if(PDCobj_close(obj1) < 0) { + printf("fail to close object o1\n"); + ret_value = 1; + } else { + printf("successfully close object o1\n"); + } + if(PDCobj_close(obj2) < 0) { + printf("fail to close object o2\n"); + ret_value = 1; + } else { + printf("successfully close object o2\n"); + } + // close a container + if(PDCcont_close(cont) < 0) { + printf("fail to close container c1\n"); + ret_value = 1; + } else { + printf("successfully close container c1\n"); + } + // close a object property + if(PDCprop_close(obj_prop) < 0) { + printf("Fail to close property @ line %d\n", __LINE__); + ret_value = 1; + } else { + printf("successfully close object property\n"); + } + // close a container property + if(PDCprop_close(cont_prop) < 0) { + printf("Fail to close property @ line %d\n", __LINE__); + ret_value = 1; + } else { + printf("successfully close container property\n"); + } + // close pdc + if(PDCclose(pdc) < 0) { + printf("fail to close PDC\n"); + ret_value = 1; + } +#ifdef ENABLE_MPI + MPI_Finalize(); +#endif + return ret_value; +} diff --git a/src/tests/run_test.sh b/src/tests/run_test.sh index 61e4fb72d..b41f10b24 100755 --- a/src/tests/run_test.sh +++ b/src/tests/run_test.sh @@ -6,15 +6,20 @@ if [ $# -lt 1 ]; then echo "missing test argument" && exit -1 ; fi # check the test to be run: test_exe="$1" +test_args="$2 $3 $4" shift # copy the remaining test input arguments (if any) -test_args="$*" if [ -x $test_exe ]; then echo "testing: $test_exe"; else echo "test: $test_exe not found or not and executable" && exit -2; fi +rm -rf pdc_tmp # START the server (in the background) ./pdc_server.exe & # WAIT a bit... sleep 1 # RUN the actual test -$test_exe $* +echo "$test_exe $test_args" +$test_exe $test_args +# Need to test the return value +ret="$?" # and shutdown the SERVER before exiting ./close_server +exit $ret diff --git a/src/tests/set_prop.c b/src/tests/set_prop.c new file mode 100644 index 000000000..2bd492b9b --- /dev/null +++ b/src/tests/set_prop.c @@ -0,0 +1,126 @@ +/* + * Copyright Notice for + * Proactive Data Containers (PDC) Software Library and Utilities + * ----------------------------------------------------------------------------- + + *** Copyright Notice *** + + * Proactive Data Containers (PDC) Copyright (c) 2017, The Regents of the + * University of California, through Lawrence Berkeley National Laboratory, + * UChicago Argonne, LLC, operator of Argonne National Laboratory, and The HDF + * Group (subject to receipt of any required approvals from the U.S. Dept. of + * Energy). All rights reserved. + + * If you have questions about your rights to use or distribute this software, + * please contact Berkeley Lab's Innovation & Partnerships Office at IPO@lbl.gov. + + * NOTICE. This Software was developed under funding from the U.S. Department of + * Energy and the U.S. Government consequently retains certain rights. As such, the + * U.S. Government has been granted for itself and others acting on its behalf a + * paid-up, nonexclusive, irrevocable, worldwide license in the Software to + * reproduce, distribute copies to the public, prepare derivative works, and + * perform publicly and display publicly, and to permit other to do so. + */ + +#include +#include +#include +#include "pdc.h" + +int main(int argc, char **argv) { + pdcid_t pdc, create_prop1, create_prop2; + perr_t ret; + pdc_prop_type_t type = PDC_CONT_CREATE; + int rank = 0, size = 1; + PDC_int_t ndim = 3; + uint64_t dims[3]; + int ret_value = 0; + + dims[0] = 64; + dims[1] = 3; + dims[2] = 4; +#ifdef ENABLE_MPI + MPI_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); +#endif + + // create a pdc + pdc = PDCinit("pdc"); + + // create an object property + create_prop1 = PDCprop_create(PDC_OBJ_CREATE, pdc); + if(create_prop1 <= 0) { + printf("Fail to create @ line %d\n", __LINE__); + ret_value = 1; + } + // create another object property + create_prop2 = PDCprop_create(PDC_OBJ_CREATE, pdc); + if(create_prop2 <= 0) { + printf("Fail to create @ line %d\n", __LINE__); + ret_value = 1; + } + + ret = PDCprop_set_obj_user_id(create_prop2, 666); + if ( ret != SUCCEED ) { + printf("Fail to set obj user id @ line %d\n", __LINE__); + ret_value = 1; + } + ret = PDCprop_set_obj_data_loc(create_prop2, "somewhere"); + if ( ret != SUCCEED ) { + printf("Fail to set obj user id @ line %d\n", __LINE__); + ret_value = 1; + } + ret = PDCprop_set_obj_app_name(create_prop2, "someapp name"); + if ( ret != SUCCEED ) { + printf("Fail to set obj user id @ line %d\n", __LINE__); + ret_value = 1; + } + ret = PDCprop_set_obj_time_step(create_prop2, 666); + if ( ret != SUCCEED ) { + printf("Fail to set obj time step @ line %d\n", __LINE__); + ret_value = 1; + } + ret = PDCprop_set_obj_tags(create_prop2, "sometag"); + if ( ret != SUCCEED ) { + printf("Fail to set obj time step @ line %d\n", __LINE__); + ret_value = 1; + } + ret = PDCprop_set_obj_dims(create_prop2, ndim, dims); + if ( ret != SUCCEED ) { + printf("Fail to set obj time step @ line %d\n", __LINE__); + ret_value = 1; + } + ret = PDCprop_set_obj_type(create_prop2, PDC_DOUBLE); + if ( ret != SUCCEED ) { + printf("Fail to set obj time step @ line %d\n", __LINE__); + ret_value = 1; + } + ret = PDCprop_set_obj_buf(create_prop2, NULL); + if ( ret != SUCCEED ) { + printf("Fail to set obj time step @ line %d\n", __LINE__); + ret_value = 1; + } + + if(PDCprop_close(create_prop1)<0) { + printf("Fail to close property @ line %d\n", __LINE__); + ret_value = 1; + } else { + printf("successfully close first property\n"); + } + if(PDCprop_close(create_prop2)<0) { + printf("Fail to close property @ line %d\n", __LINE__); + ret_value = 1; + } else { + printf("successfully close second property\n"); + } + // close a pdc + if(PDCclose(pdc) < 0) { + printf("fail to close PDC\n"); + ret_value = 1; + } +#ifdef ENABLE_MPI + MPI_Finalize(); +#endif + return ret_value; +} diff --git a/src/tests/vpicio.c b/src/tests/vpicio.c index c0ddcac11..b014f95b1 100644 --- a/src/tests/vpicio.c +++ b/src/tests/vpicio.c @@ -112,14 +112,16 @@ int main(int argc, char **argv) // create a container property cont_prop = PDCprop_create(PDC_CONT_CREATE, pdc_id); - if(cont_prop <= 0) + if(cont_prop <= 0) { printf("Fail to create container property @ line %d!\n", __LINE__); - + return 1; + } // create a container cont_id = PDCcont_create_col("c1", cont_prop); - if(cont_id <= 0) + if(cont_id <= 0) { printf("Fail to create container @ line %d!\n", __LINE__); - + return 1; + } // create an object property obj_prop_xx = PDCprop_create(PDC_OBJ_CREATE, pdc_id); @@ -226,37 +228,45 @@ int main(int argc, char **argv) gettimeofday(&ht_total_start, 0); ret = PDCbuf_obj_map(&x[0], PDC_FLOAT, region_x, obj_xx, region_xx); - if(ret < 0) + if(ret < 0) { printf("Array x PDCbuf_obj_map failed\n"); - + return 1; + } ret = PDCbuf_obj_map(&y[0], PDC_FLOAT, region_y, obj_yy, region_yy); - if(ret < 0) + if(ret < 0) { printf("Array y PDCbuf_obj_map failed\n"); - + return 1; + } ret = PDCbuf_obj_map(&z[0], PDC_FLOAT, region_z, obj_zz, region_zz); - if(ret < 0) + if(ret < 0) { printf("Array z PDCbuf_obj_map failed\n"); - + return 1; + } ret = PDCbuf_obj_map(&px[0], PDC_FLOAT, region_px, obj_pxx, region_pxx); - if(ret < 0) + if(ret < 0) { printf("Array px PDCbuf_obj_map failed\n"); - + return 1; + } ret = PDCbuf_obj_map(&py[0], PDC_FLOAT, region_py, obj_pyy, region_pyy); - if(ret < 0) + if(ret < 0) { printf("Array py PDCbuf_obj_map failed\n"); - + return 1; + } ret = PDCbuf_obj_map(&pz[0], PDC_FLOAT, region_pz, obj_pzz, region_pzz); - if(ret < 0) + if(ret < 0) { printf("Array pz PDCbuf_obj_map failed\n"); - + return 1; + } ret = PDCbuf_obj_map(&id1[0], PDC_INT, region_id1, obj_id11, region_id11); - if(ret < 0) + if(ret < 0) { printf("Array id1 PDCbuf_obj_map failed\n"); - + return 1; + } ret = PDCbuf_obj_map(&id2[0], PDC_INT, region_id2, obj_id22, region_id22); - if(ret < 0) + if(ret < 0) { printf("Array id2 PDCbuf_obj_map failed\n"); - + return 1; + } #ifdef ENABLE_MPI MPI_Barrier(MPI_COMM_WORLD); #endif @@ -274,37 +284,45 @@ int main(int argc, char **argv) gettimeofday(&ht_total_start, 0); ret = PDCreg_obtain_lock(obj_xx, region_xx, PDC_WRITE, PDC_NOBLOCK); - if (ret != SUCCEED) + if (ret != SUCCEED) { printf("Failed to obtain lock for region_xx\n"); - + return 1; + } ret = PDCreg_obtain_lock(obj_yy, region_yy, PDC_WRITE, PDC_NOBLOCK); - if (ret != SUCCEED) + if (ret != SUCCEED) { printf("Failed to obtain lock for region_yy\n"); - + return 1; + } ret = PDCreg_obtain_lock(obj_zz, region_zz, PDC_WRITE, PDC_NOBLOCK); - if (ret != SUCCEED) + if (ret != SUCCEED) { printf("Failed to obtain lock for region_zz\n"); - + return 1; + } ret = PDCreg_obtain_lock(obj_pxx, region_pxx, PDC_WRITE, PDC_NOBLOCK); - if (ret != SUCCEED) + if (ret != SUCCEED) { printf("Failed to obtain lock for region_pxx\n"); - + return 1; + } ret = PDCreg_obtain_lock(obj_pyy, region_pyy, PDC_WRITE, PDC_NOBLOCK); - if (ret != SUCCEED) + if (ret != SUCCEED) { printf("Failed to obtain lock for region_pyy\n"); - + return 1; + } ret = PDCreg_obtain_lock(obj_pzz, region_pzz, PDC_WRITE, PDC_NOBLOCK); - if (ret != SUCCEED) + if (ret != SUCCEED) { printf("Failed to obtain lock for region_pzz\n"); - + return 1; + } ret = PDCreg_obtain_lock(obj_id11, region_id11, PDC_WRITE, PDC_NOBLOCK); - if (ret != SUCCEED) + if (ret != SUCCEED) { printf("Failed to obtain lock for region_id11\n"); - + return 1; + } ret = PDCreg_obtain_lock(obj_id22, region_id22, PDC_WRITE, PDC_NOBLOCK); - if (ret != SUCCEED) + if (ret != SUCCEED) { printf("Failed to obtain lock for region_id22\n"); - + return 1; + } #ifdef ENABLE_MPI MPI_Barrier(MPI_COMM_WORLD); #endif @@ -333,37 +351,45 @@ int main(int argc, char **argv) gettimeofday(&ht_total_start, 0); ret = PDCreg_release_lock(obj_xx, region_xx, PDC_WRITE); - if (ret != SUCCEED) + if (ret != SUCCEED) { printf("Failed to release lock for region_xx\n"); - + return 1; + } ret = PDCreg_release_lock(obj_yy, region_yy, PDC_WRITE); - if (ret != SUCCEED) + if (ret != SUCCEED) { printf("Failed to release lock for region_yy\n"); - + return 1; + } ret = PDCreg_release_lock(obj_zz, region_zz, PDC_WRITE); - if (ret != SUCCEED) + if (ret != SUCCEED) { printf("Failed to release lock for region_zz\n"); - + return 1; + } ret = PDCreg_release_lock(obj_pxx, region_pxx, PDC_WRITE); - if (ret != SUCCEED) + if (ret != SUCCEED) { printf("Failed to release lock for region_pxx\n"); - + return 1; + } ret = PDCreg_release_lock(obj_pyy, region_pyy, PDC_WRITE); - if (ret != SUCCEED) + if (ret != SUCCEED) { printf("Failed to release lock for region_pyy\n"); - + return 1; + } ret = PDCreg_release_lock(obj_pzz, region_pzz, PDC_WRITE); - if (ret != SUCCEED) + if (ret != SUCCEED) { printf("Failed to release lock for region_pzz\n"); - + return 1; + } ret = PDCreg_release_lock(obj_id11, region_id11, PDC_WRITE); - if (ret != SUCCEED) + if (ret != SUCCEED) { printf("Failed to release lock for region_id11\n"); - + return 1; + } ret = PDCreg_release_lock(obj_id22, region_id22, PDC_WRITE); - if (ret != SUCCEED) + if (ret != SUCCEED) { printf("Failed to release lock for region_id22\n"); - + return 1; + } #ifdef ENABLE_MPI MPI_Barrier(MPI_COMM_WORLD); #endif @@ -380,148 +406,192 @@ int main(int argc, char **argv) #endif ret = PDCbuf_obj_unmap(obj_xx, region_xx); - if (ret != SUCCEED) + if (ret != SUCCEED) { printf("region xx unmap failed\n"); - + return 1; + } ret = PDCbuf_obj_unmap(obj_yy, region_yy); - if (ret != SUCCEED) + if (ret != SUCCEED) { printf("region yy unmap failed\n"); - + return 1; + } ret = PDCbuf_obj_unmap(obj_zz, region_zz); - if (ret != SUCCEED) + if (ret != SUCCEED) { printf("region zz unmap failed\n"); - + return 1; + } ret = PDCbuf_obj_unmap(obj_pxx, region_pxx); - if (ret != SUCCEED) + if (ret != SUCCEED) { printf("region pxx unmap failed\n"); - + return 1; + } ret = PDCbuf_obj_unmap(obj_pyy, region_pyy); - if (ret != SUCCEED) + if (ret != SUCCEED) { printf("region pyy unmap failed\n"); - + return 1; + } ret = PDCbuf_obj_unmap(obj_pzz, region_pzz); - if (ret != SUCCEED) + if (ret != SUCCEED) { printf("region pzz unmap failed\n"); - + return 1; + } ret = PDCbuf_obj_unmap(obj_id11, region_id11); - if (ret != SUCCEED) + if (ret != SUCCEED) { printf("region id11 unmap failed\n"); - + return 1; + } ret = PDCbuf_obj_unmap(obj_id22, region_id22); - if (ret != SUCCEED) + if (ret != SUCCEED) { printf("region id22 unmap failed\n"); - + return 1; + } #ifdef ENABLE_MPI MPI_Barrier(MPI_COMM_WORLD); #endif - if(PDCobj_close(obj_xx) < 0) + if(PDCobj_close(obj_xx) < 0) { printf("fail to close obj_xx\n"); + return 1; + } - if(PDCobj_close(obj_yy) < 0) + if(PDCobj_close(obj_yy) < 0) { printf("fail to close object obj_yy\n"); - - if(PDCobj_close(obj_zz) < 0) + return 1; + } + if(PDCobj_close(obj_zz) < 0) { printf("fail to close object obj_zz\n"); - - if(PDCobj_close(obj_pxx) < 0) + return 1; + } + if(PDCobj_close(obj_pxx) < 0) { printf("fail to close object obj_pxx\n"); - - if(PDCobj_close(obj_pyy) < 0) + return 1; + } + if(PDCobj_close(obj_pyy) < 0) { printf("fail to close object obj_pyy\n"); - - if(PDCobj_close(obj_pzz) < 0) + return 1; + } + if(PDCobj_close(obj_pzz) < 0) { printf("fail to close object obj_pzz\n"); - - if(PDCobj_close(obj_id11) < 0) + return 1; + } + if(PDCobj_close(obj_id11) < 0) { printf("fail to close object obj_id11\n"); - - if(PDCobj_close(obj_id22) < 0) + return 1; + } + if(PDCobj_close(obj_id22) < 0) { printf("fail to close object obj_id22\n"); - - if(PDCprop_close(obj_prop_xx) < 0) + return 1; + } + if(PDCprop_close(obj_prop_xx) < 0) { printf("Fail to close obj property obj_prop_xx\n"); - - if(PDCprop_close(obj_prop_yy) < 0) + return 1; + } + if(PDCprop_close(obj_prop_yy) < 0) { printf("Fail to close obj property obj_prop_yy\n"); - - if(PDCprop_close(obj_prop_zz) < 0) + return 1; + } + if(PDCprop_close(obj_prop_zz) < 0) { printf("Fail to close obj property obj_prop_zz\n"); - - if(PDCprop_close(obj_prop_pxx) < 0) + return 1; + } + if(PDCprop_close(obj_prop_pxx) < 0) { printf("Fail to close obj property obj_prop_pxx\n"); - - if(PDCprop_close(obj_prop_pyy) < 0) + return 1; + } + if(PDCprop_close(obj_prop_pyy) < 0) { printf("Fail to close obj property obj_prop_pyy\n"); - - if(PDCprop_close(obj_prop_pzz) < 0) + return 1; + } + if(PDCprop_close(obj_prop_pzz) < 0) { printf("Fail to close obj property obj_prop_pzz\n"); - - if(PDCprop_close(obj_prop_id11) < 0) + return 1; + } + if(PDCprop_close(obj_prop_id11) < 0) { printf("Fail to close obj property obj_prop_id11\n"); - - if(PDCprop_close(obj_prop_id22) < 0) + return 1; + } + if(PDCprop_close(obj_prop_id22) < 0) { printf("Fail to close obj property obj_prop_id22\n"); - - if(PDCregion_close(region_x) < 0) + return 1; + } + if(PDCregion_close(region_x) < 0) { printf("fail to close region region_x\n"); - - if(PDCregion_close(region_y) < 0) + return 1; + } + if(PDCregion_close(region_y) < 0) { printf("fail to close region region_y\n"); - - if(PDCregion_close(region_z) < 0) + return 1; + } + if(PDCregion_close(region_z) < 0) { printf("fail to close region region_z\n"); - - if(PDCregion_close(region_px) < 0) + return 1; + } + if(PDCregion_close(region_px) < 0) { printf("fail to close region region_px\n"); - - if(PDCregion_close(region_py) < 0) + return 1; + } + if(PDCregion_close(region_py) < 0) { printf("fail to close region region_py\n"); - - if(PDCobj_close(region_pz) < 0) + return 1; + } + if(PDCobj_close(region_pz) < 0) { printf("fail to close region region_pz\n"); - - if(PDCobj_close(region_id1) < 0) + return 1; + } + if(PDCobj_close(region_id1) < 0) { printf("fail to close region region_id1\n"); - - if(PDCobj_close(region_id2) < 0) + return 1; + } + if(PDCobj_close(region_id2) < 0) { printf("fail to close region region_id2\n"); - - if(PDCregion_close(region_xx) < 0) + return 1; + } + if(PDCregion_close(region_xx) < 0) { printf("fail to close region region_xx\n"); - - if(PDCregion_close(region_yy) < 0) + return 1; + } + if(PDCregion_close(region_yy) < 0) { printf("fail to close region region_yy\n"); - - if(PDCregion_close(region_zz) < 0) + return 1; + } + if(PDCregion_close(region_zz) < 0) { printf("fail to close region region_zz\n"); - - if(PDCregion_close(region_pxx) < 0) + return 1; + } + if(PDCregion_close(region_pxx) < 0) { printf("fail to close region region_pxx\n"); - - if(PDCregion_close(region_pyy) < 0) + return 1; + } + if(PDCregion_close(region_pyy) < 0) { printf("fail to close region region_pyy\n"); - - if(PDCregion_close(region_pzz) < 0) + return 1; + } + if(PDCregion_close(region_pzz) < 0) { printf("fail to close region region_pzz\n"); - - if(PDCobj_close(region_id11) < 0) + return 1; + } + if(PDCobj_close(region_id11) < 0) { printf("fail to close region region_id11\n"); - - if(PDCobj_close(region_id22) < 0) + return 1; + } + if(PDCobj_close(region_id22) < 0) { printf("fail to close region region_id22\n"); - + return 1; + } // close a container - if(PDCcont_close(cont_id) < 0) + if(PDCcont_close(cont_id) < 0) { printf("fail to close container c1\n"); - + return 1; + } // close a container property - if(PDCprop_close(cont_prop) < 0) + if(PDCprop_close(cont_prop) < 0) { printf("Fail to close property @ line %d\n", __LINE__); - - if(PDCclose(pdc_id) < 0) + return 1; + } + if(PDCclose(pdc_id) < 0) { printf("fail to close PDC\n"); - + return 1; + } free(offset); free(offset_remote); free(mysize); diff --git a/src/tests/write_obj.c b/src/tests/write_obj.c new file mode 100644 index 000000000..f199a52a4 --- /dev/null +++ b/src/tests/write_obj.c @@ -0,0 +1,251 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include "pdc.h" +#include "pdc_client_connect.h" +#include "pdc_client_server_common.h" + +void print_usage() { + printf("Usage: srun -n ./write_obj obj_name size_MB type\n"); +} + +int main(int argc, char **argv) +{ + int rank = 0, size = 1; + uint64_t size_MB, size_B; + perr_t ret; + int ndim = 1; + int ret_value = 0; +#ifdef ENABLE_MPI + MPI_Comm comm; +#else + int comm = 1; +#endif + struct timeval pdc_timer_start; + struct timeval pdc_timer_end; + double write_time = 0.0; + pdcid_t global_obj = 0; + pdcid_t local_region, global_region; + pdcid_t pdc, cont_prop, cont, obj_prop; + + uint64_t *offset, *local_offset; + uint64_t *mysize; + int i, j; + char *mydata, *obj_data; + char obj_name[128], cont_name[128]; + + uint64_t my_data_size; + uint64_t dims[1]; + + pdc_var_type_t var_type = PDC_UNKNOWN; + size_t type_size = 1; + +#ifdef ENABLE_MPI + MPI_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); + MPI_Comm_dup(MPI_COMM_WORLD, &comm); +#endif + + if (argc != 4) { + print_usage(); + ret_value = 1; +#ifdef ENABLE_MPI + MPI_Finalize(); +#endif + return ret_value; + } + + sprintf(obj_name, "%s_%d", argv[1],rank); + + size_MB = atoi(argv[2]); + + if (!strcmp(argv[3], "float")){ + var_type = PDC_FLOAT; + type_size = sizeof(float); + } else if (!strcmp(argv[3], "int")){ + var_type = PDC_INT; + type_size = sizeof(int); + } else if (!strcmp(argv[3], "double")){ + var_type = PDC_DOUBLE; + type_size = sizeof(double); + } else if (!strcmp(argv[3], "char")){ + var_type = PDC_CHAR; + type_size = sizeof(char); + } else if (!strcmp(argv[3], "uint")){ + var_type = PDC_UINT; + type_size = sizeof(unsigned); + } else if (!strcmp(argv[3], "int64")){ + var_type = PDC_INT64; + type_size = sizeof(int64_t); + } else if (!strcmp(argv[3], "uint64")){ + var_type = PDC_UINT64; + type_size = sizeof(uint64_t); + } else if (!strcmp(argv[3], "int16")){ + var_type = PDC_INT16; + type_size = sizeof(int16_t); + } else if (!strcmp(argv[3], "int8")){ + var_type = PDC_INT8; + type_size = sizeof(int8_t); + } + + + printf("Writing a %" PRIu64 " MB object [%s] with %d clients.\n", size_MB, obj_name, size); + //size_B = 1; + size_B = size_MB * 1048576; + + // create a pdc + pdc = PDCinit("pdc"); + printf("create a new pdc\n"); + + // create a container property + cont_prop = PDCprop_create(PDC_CONT_CREATE, pdc); + if(cont_prop <= 0) { + printf("Fail to create container property @ line %d!\n", __LINE__); + ret_value = 1; + } + // create a container + sprintf(cont_name, "c%d", rank); + cont = PDCcont_create(cont_name, cont_prop); + if(cont <= 0) { + printf("Fail to create container @ line %d!\n", __LINE__); + ret_value = 1; + } + // create an object property + obj_prop = PDCprop_create(PDC_OBJ_CREATE, pdc); + if(obj_prop <= 0) { + printf("Fail to create object property @ line %d!\n", __LINE__); + ret_value = 1; + } + dims[0] = size_B; + my_data_size = size_B / size; + printf("my_data_size at rank %d is %llu\n", rank, (long long unsigned)my_data_size); + + obj_data = (char*)malloc(my_data_size*type_size); + mydata = (char*)malloc(my_data_size*type_size); + + + PDCprop_set_obj_type(obj_prop, var_type); + PDCprop_set_obj_buf(obj_prop, obj_data); + PDCprop_set_obj_dims(obj_prop, 1, dims); + PDCprop_set_obj_user_id( obj_prop, getuid()); + PDCprop_set_obj_time_step( obj_prop, 0); + PDCprop_set_obj_app_name(obj_prop, "DataServerTest"); + PDCprop_set_obj_tags( obj_prop, "tag0=1"); + + // Create a object +#ifdef ENABLE_MPI + global_obj = PDCobj_create_mpi(cont, obj_name, obj_prop, 0, comm); +#else + global_obj = PDCobj_create(cont, obj_name, obj_prop); +#endif + + if (global_obj <= 0) { + printf("Error creating an object [%s], exit...\n", obj_name); + ret_value = 1; + } + + offset = (uint64_t*)malloc(sizeof(uint64_t) * ndim); + local_offset = (uint64_t*)malloc(sizeof(uint64_t) * ndim); + mysize = (uint64_t*)malloc(sizeof(uint64_t) * ndim); + offset[0] = rank * my_data_size; + local_offset[0] = 0; + mysize[0] = my_data_size; + printf("rank %d offset = %lu, length = %lu, unit size = %ld\n", rank, offset[0], mysize[0], type_size); + + local_region = PDCregion_create(ndim, local_offset, mysize); + global_region = PDCregion_create(ndim, offset, mysize); + + for (i = 0; i < (int) my_data_size; i++) { + for ( j = 0; j < (int) type_size; ++j ) { + mydata[i * type_size + j] = i; + } + } + ret = PDCbuf_obj_map(mydata, var_type, local_region, global_obj, global_region); + if(ret != SUCCEED) { + printf("PDCbuf_obj_map failed\n"); + ret_value = 1; + } + /* fprintf(stderr, "rank %d done PDCbuf_obj_map\n", rank); */ +#ifdef ENABLE_MPI + MPI_Barrier(MPI_COMM_WORLD); +#endif + gettimeofday(&pdc_timer_start, 0); + ret = PDCreg_obtain_lock(global_obj, global_region, PDC_WRITE, PDC_BLOCK); + if (ret != SUCCEED) { + printf("Failed to obtain lock for region\n"); + ret_value = 1; + goto done; + } + /* fprintf(stderr, "rank %d done PDCreg_obtain_lock\n", rank); */ + + ret = PDCreg_release_lock(global_obj, global_region, PDC_WRITE); + if (ret != SUCCEED) { + printf("Failed to release lock for region\n"); + ret_value = 1; + goto done; + } + + /* fprintf(stderr, "rank %d done PDCreg_release_lock\n", rank); */ + + ret = PDCbuf_obj_unmap(global_obj, global_region); + if(ret != SUCCEED) { + printf("PDCbuf_obj_unmap failed\n"); + ret_value = 1; + } + + /* fprintf(stderr, "rank %d done PDCbuf_obj_unmap\n", rank); */ +#ifdef ENABLE_MPI + MPI_Barrier(MPI_COMM_WORLD); +#endif + gettimeofday(&pdc_timer_end, 0); + write_time = PDC_get_elapsed_time_double(&pdc_timer_start, &pdc_timer_end); + + if (rank == 0) { + printf("Time to lock and release data with %d ranks: %.6f\n", size, write_time); + fflush(stdout); + } + + free(offset); + free(local_offset); + free(mysize); + free(obj_data); + free(mydata); +done: + if(PDCobj_close(global_obj) < 0) { + printf("fail to close global obj\n"); + ret_value = 1; + } + + if(PDCregion_close(local_region) < 0) { + printf("fail to close local region\n"); + ret_value = 1; + } + + if(PDCregion_close(global_region) < 0) { + printf("fail to close global region\n"); + ret_value = 1; + } + if(PDCcont_close(cont) < 0) { + printf("fail to close container\n"); + ret_value = 1; + } + if(PDCprop_close(cont_prop) < 0) { + printf("Fail to close property @ line %d\n", __LINE__); + ret_value = 1; + } + if(PDCclose(pdc) < 0) { + printf("fail to close PDC\n"); + ret_value = 1; + } +#ifdef ENABLE_MPI + MPI_Finalize(); +#endif + + return ret_value; +} diff --git a/src/tests/write_1obj.c b/src/tests/write_obj_shared.c similarity index 51% rename from src/tests/write_1obj.c rename to src/tests/write_obj_shared.c index 0ffcb62a4..3759ed463 100644 --- a/src/tests/write_1obj.c +++ b/src/tests/write_obj_shared.c @@ -11,7 +11,7 @@ #include "pdc_client_server_common.h" void print_usage() { - printf("Usage: srun -n ./data_server_read obj_name size_MB\n"); + printf("Usage: srun -n ./write_obj obj_name size_MB type\n"); } int main(int argc, char **argv) @@ -20,6 +20,7 @@ int main(int argc, char **argv) uint64_t size_MB, size_B; perr_t ret; int ndim = 1; + int ret_value = 0; #ifdef ENABLE_MPI MPI_Comm comm; #else @@ -29,19 +30,21 @@ int main(int argc, char **argv) struct timeval pdc_timer_end; double write_time = 0.0; pdcid_t global_obj = 0; - pdcid_t local_obj = 0; pdcid_t local_region, global_region; pdcid_t pdc, cont_prop, cont, obj_prop; uint64_t *offset; uint64_t *mysize; - int i; - float *mydata, *obj_data; - char *obj_name; + int i, j; + char *mydata, *obj_data; + char obj_name[128], cont_name[128]; uint64_t my_data_size; uint64_t dims[1]; + pdc_var_type_t var_type = PDC_UNKNOWN; + size_t type_size = 1; + #ifdef ENABLE_MPI MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); @@ -49,44 +52,85 @@ int main(int argc, char **argv) MPI_Comm_dup(MPI_COMM_WORLD, &comm); #endif - if (argc < 3) { + if (argc != 4) { print_usage(); - return 0; + ret_value = 1; +#ifdef ENABLE_MPI + MPI_Finalize(); +#endif + return ret_value; } - obj_name = argv[1]; + sprintf(obj_name, "%s", argv[1],rank); + size_MB = atoi(argv[2]); - if (rank == 0) { - printf("Writing a %" PRIu64 " MB object [%s] with %d clients.\n", size_MB, obj_name, size); + if (!strcmp(argv[3], "float")){ + var_type = PDC_FLOAT; + type_size = sizeof(float); + } else if (!strcmp(argv[3], "int")){ + var_type = PDC_INT; + type_size = sizeof(int); + } else if (!strcmp(argv[3], "double")){ + var_type = PDC_DOUBLE; + type_size = sizeof(double); + } else if (!strcmp(argv[3], "char")){ + var_type = PDC_CHAR; + type_size = sizeof(char); + } else if (!strcmp(argv[3], "uint")){ + var_type = PDC_UINT; + type_size = sizeof(unsigned); + } else if (!strcmp(argv[3], "int64")){ + var_type = PDC_INT64; + type_size = sizeof(int64_t); + } else if (!strcmp(argv[3], "uint64")){ + var_type = PDC_UINT64; + type_size = sizeof(uint64_t); + } else if (!strcmp(argv[3], "int16")){ + var_type = PDC_INT16; + type_size = sizeof(int16_t); + } else if (!strcmp(argv[3], "int8")){ + var_type = PDC_INT8; + type_size = sizeof(int8_t); } + + + printf("Writing a %" PRIu64 " MB object [%s] with %d clients.\n", size_MB, obj_name, size); + //size_B = 1; size_B = size_MB * 1048576; // create a pdc pdc = PDCinit("pdc"); + printf("create a new pdc\n"); // create a container property cont_prop = PDCprop_create(PDC_CONT_CREATE, pdc); - if(cont_prop <= 0) + if(cont_prop <= 0) { printf("Fail to create container property @ line %d!\n", __LINE__); - + ret_value = 1; + } // create a container - cont = PDCcont_create("c1", cont_prop); - if(cont <= 0) + sprintf(cont_name, "c%d", rank); + cont = PDCcont_create(cont_name, cont_prop); + if(cont <= 0) { printf("Fail to create container @ line %d!\n", __LINE__); - + ret_value = 1; + } // create an object property obj_prop = PDCprop_create(PDC_OBJ_CREATE, pdc); - if(obj_prop <= 0) + if(obj_prop <= 0) { printf("Fail to create object property @ line %d!\n", __LINE__); - + ret_value = 1; + } dims[0] = size_B; my_data_size = size_B / size; + printf("my_data_size at rank %d is %llu\n", rank, (long long unsigned)my_data_size); + + obj_data = (char*)malloc(my_data_size*type_size); + mydata = (char*)malloc(my_data_size*type_size); - obj_data = (float *)calloc(1, my_data_size); - mydata = (float *)calloc(1, my_data_size); - PDCprop_set_obj_type(obj_prop, PDC_FLOAT); + PDCprop_set_obj_type(obj_prop, var_type); PDCprop_set_obj_buf(obj_prop, obj_data); PDCprop_set_obj_dims(obj_prop, 1, dims); PDCprop_set_obj_user_id( obj_prop, getuid()); @@ -96,56 +140,54 @@ int main(int argc, char **argv) // Create a object global_obj = PDCobj_create_mpi(cont, obj_name, obj_prop, 0, comm); + //global_obj = PDCobj_create(cont, obj_name, obj_prop); + if (global_obj <= 0) { printf("Error creating an object [%s], exit...\n", obj_name); - exit(-1); + ret_value = 1; } offset = (uint64_t*)malloc(sizeof(uint64_t) * ndim); mysize = (uint64_t*)malloc(sizeof(uint64_t) * ndim); offset[0] = rank * my_data_size; mysize[0] = my_data_size; + printf("rank %d offset = %lu, length = %lu, unit size = %ld\n", rank, offset[0], mysize[0], type_size); local_region = PDCregion_create(ndim, offset, mysize); global_region = PDCregion_create(ndim, offset, mysize); - ret = PDCbuf_obj_map(mydata, PDC_FLOAT, local_region, global_obj, global_region); + for (i = 0; i < (int) my_data_size; i++) { + for ( j = 0; j < (int) type_size; ++j ) { + mydata[i * type_size + j] = i; + } + } + ret = PDCbuf_obj_map(mydata, var_type, local_region, global_obj, global_region); if(ret != SUCCEED) { printf("PDCbuf_obj_map failed\n"); - exit(-1); + ret_value = 1; } - #ifdef ENABLE_MPI MPI_Barrier(MPI_COMM_WORLD); #endif gettimeofday(&pdc_timer_start, 0); - - ret = PDCreg_obtain_lock(local_obj, local_region, PDC_WRITE, PDC_NOBLOCK); - if (ret != SUCCEED) { - printf("Failed to obtain lock for region\n"); - goto done; - } - - ret = PDCreg_obtain_lock(global_obj, global_region, PDC_WRITE, PDC_NOBLOCK); + ret = PDCreg_obtain_lock(global_obj, local_region, PDC_WRITE, PDC_BLOCK); if (ret != SUCCEED) { printf("Failed to obtain lock for region\n"); + ret_value = 1; goto done; } - for (i = 0; i < 5; i++) { - mydata[i] = i * 1.01; - } - - ret = PDCreg_release_lock(local_obj, local_region, PDC_WRITE); + ret = PDCreg_release_lock(global_obj, local_region, PDC_WRITE); if (ret != SUCCEED) { printf("Failed to release lock for region\n"); + ret_value = 1; goto done; } - ret = PDCreg_release_lock(global_obj, global_region, PDC_WRITE); - if (ret != SUCCEED) { - printf("Failed to release lock for region\n"); - goto done; + ret = PDCbuf_obj_unmap(global_obj, global_region); + if(ret != SUCCEED) { + printf("PDCbuf_obj_unmap failed\n"); + ret_value = 1; } #ifdef ENABLE_MPI @@ -158,32 +200,36 @@ int main(int argc, char **argv) printf("Time to lock and release data with %d ranks: %.6f\n", size, write_time); fflush(stdout); } - done: - if(PDCobj_close(local_obj) < 0) - printf("fail to close local obj\n"); - - if(PDCobj_close(global_obj) < 0) + if(PDCobj_close(global_obj) < 0) { printf("fail to close global obj\n"); + ret_value = 1; + } - if(PDCregion_close(local_region) < 0) + if(PDCregion_close(local_region) < 0) { printf("fail to close local region\n"); + ret_value = 1; + } - if(PDCregion_close(global_region) < 0) + if(PDCregion_close(global_region) < 0) { printf("fail to close global region\n"); - - if(PDCcont_close(cont) < 0) + ret_value = 1; + } + if(PDCcont_close(cont) < 0) { printf("fail to close container\n"); - - if(PDCprop_close(cont_prop) < 0) + ret_value = 1; + } + if(PDCprop_close(cont_prop) < 0) { printf("Fail to close property @ line %d\n", __LINE__); - - if(PDCclose(pdc) < 0) - printf("fail to close PDC\n"); - + ret_value = 1; + } + if(PDCclose(pdc) < 0) { + printf("fail to close PDC\n"); + ret_value = 1; + } #ifdef ENABLE_MPI MPI_Finalize(); #endif - return 0; + return ret_value; }