diff --git a/examples/Makefile b/examples/Makefile new file mode 100644 index 000000000..b36fa2628 --- /dev/null +++ b/examples/Makefile @@ -0,0 +1,33 @@ +CC = mpicc +CFLAGS = -O2 -Wall -Wextra + +INCLUDES = -I. -I$(PDC_DIR)/include +LDFLAGS = -L$(PDC_DIR)/lib + +LIBS = -lpdc + +.c.o: + $(CC) $(CFLAGS) $(INCLUDES) -c $< + +all: region_obj_map_2D region_obj_map_3D pdc_init obj_get_data bdcats vpicio + +region_obj_map_2D: region_obj_map_2D.o + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) + +region_obj_map_3D: region_obj_map_3D.o + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) + +obj_get_data: obj_get_data.o + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) + +pdc_init: pdc_init.o + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) + +bdcats: bdcats.o + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) + +vpicio: vpicio.o + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) + +clean: + rm -f *.o region_obj_map_2D region_obj_map_3D pdc_init obj_get_data vpicio bdcats diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 000000000..5e3857035 --- /dev/null +++ b/examples/README.md @@ -0,0 +1,73 @@ +# PDC Examples + + PDC regression tests can be found in https://github.com/hpc-io/pdc/tree/stable/src/tests. + + Please follow the instructions for PDC installations. + + PDC programs start with PDC servers running in the background. + + Client programs uses PDC APIs to forward requests to PDC servers. + + Scripts run_test.sh, mpi_test.sh, and run_multiple_tests.sh automatically run start and close PDC servers + + Usage: +``` +./run_test.sh ./pdc_client_application arg1 arg2 ..... +./mpi_test.sh ./pdc_client_application MPIRUN_CMD number_of_servers number_of_clients arg1 arg2 .... +./run_multiple_test.sh ./pdc_client_application_1 ./pdc_client_application_2 ...... +``` + ## PDC Hello world + + pdc_init.c + + A PDC program starts with PDCinit and finishes with PDCclose. + + To a simple hello world program for PDC, use the following command. +``` +0. make pdc_init +1. ./run_test.sh ./pdc_init +``` + + The script "run_test.sh" starts a server first. Then program "obj_get_data" is executed. Finally, the PDC servers are closed. + + Alternatively, the following command can be used for multile MPI processes. +``` +0. make pdc_init +1. ./mpi_test.sh ./pdc_init mpiexec 2 4 +``` + + The above command will start a server with 2 processes. Then it will start the application program with 4 processes. Finally, all servers are closed. + + On supercomputers, "mpiexec" can be replaced with "srun", "jsrun" or "aprun". + ## Simple I-O + + This example provides a easy way for PDC beginners to write and read data with PDC servers. It can be found in obj_get_data.c + + Functions PDCobj_put_data and PDCobj_get_data are the easist way to write/read data from/to a contiguous memory buffer. + + This example writes different size of data to two objects. It then read back the data to check whether the data is correct or not. + + To run this example, use the following command lines. +``` +0. make obj_get_data +1. ./run_test.sh ./obj_get_data +2. ./mpi_test.sh ./obj_get_data mpiexec 2 4 +``` + ## I-O with region mapping. + + The simple I/O can only handles 1D data that is contiguous. PDC supports data dimension up to 3. Simple I/O functions PDCobj_put_data and PDCobj_get_data are wrappers for object create, region mapping, I/O, and object close. The examples in this section breakdowns the wrappers, which allows more flexibility. + + Check region_obj_map_2D.c and region_obj_map_3D.c for how to write 2D and 3D data. + + Generally, PDC perform I/O with the PDCbuf_obj_map, PDCreg_obtain_lock, PDCreg_release_lock, and PDCbuf_obj_unmap. The logic is similar to HDF5 dataspace and memory space. In PDC language, they are remote region and local region. The lock functions for remote regions allow PDC servers to handle concurrent requests from different clients without undefined behaviors. + + To run thie example, use the following command lines. +``` +0. make +1. ./run_test.sh ./region_obj_map_2D +2. ./mpi_test.sh ./region_obj_map_2D mpiexec 2 4 +3. ./run_test.sh ./region_obj_map_3D +4. ./mpi_test.sh ./region_obj_map_3D mpiexec 2 4 +``` + ## VPIC-IO and BD-CATS-IO + + VPIC is a particle simulation code developed at Los Alamos National Laboratory (LANL). + VPIC-IO benchmark is an I/O kernel representing the I/O pattern of a space weather simulation + exploring the magnetic reconnection phenomenon. More details of the simulation itself can be + found at vpic.pdf . + + BD-CATS is a Big Data clustering (DBSCAN) algorithm that uses HPC systems to analyze trillions of + particles. BD-CATS typically analyze data produced by simulations such as VPIC. + BD-CATS-IO represents the I/O kernel of the clustering algorithm. More details of BD-CATS + can be found at https://sdm.lbl.gov/~sbyna/research/papers/201511-SC15-BD-CATS.pdf . + + To run VPIC-IO and BD-CATS-IO together: Go to the bin folder first after make. + Then type ./run_multiple_test.sh ./vpicio ./bdcats + + VPIC-IO: + - vpicio.c + - VPIC I/O is an example for writing multiple objects using PDC, where each object is a variable of particles. + - We collectively create containers and objects. PDC region map is used to write data to individual objects. + + BD-CATS-IO: + - bdcats.c + - BD-CATS-IO is an example for reading data written by VIPIC I/O. + + To run this example +``` +0. cd make +1. ./run_multiple_test.sh ./vpicio ./bdcats +``` diff --git a/examples/bdcats.c b/examples/bdcats.c new file mode 100644 index 000000000..08f1924b4 --- /dev/null +++ b/examples/bdcats.c @@ -0,0 +1,451 @@ +/* + * 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 +#include "pdc.h" + +#define NPARTICLES 8388608 + +double uniform_random_number() +{ + return (((double)rand())/((double)(RAND_MAX))); +} + +void print_usage() { + printf("Usage: srun -n ./vpicio #particles\n"); +} + +int main(int argc, char **argv) +{ + int rank = 0, size = 1; + pdcid_t pdc_id, cont_id; + pdcid_t obj_xx, obj_yy, obj_zz, obj_pxx, obj_pyy, obj_pzz, obj_id11, obj_id22; + pdcid_t region_x, region_y, region_z, region_px, region_py, region_pz, region_id1, region_id2; + pdcid_t region_xx, region_yy, region_zz, region_pxx, region_pyy, region_pzz, region_id11, region_id22; + perr_t ret; + struct timeval ht_total_start; + struct timeval ht_total_end; + long long ht_total_elapsed; + double ht_total_sec; + float *x, *y, *z; + float *px, *py, *pz; + int *id1, *id2; + uint64_t numparticles; + int ndim = 1; + uint64_t *offset; + uint64_t *offset_remote; + uint64_t *mysize; + +#ifdef ENABLE_MPI + MPI_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); +#endif + + numparticles = NPARTICLES; + + x = (float *)malloc(numparticles*sizeof(float)); + y = (float *)malloc(numparticles*sizeof(float)); + z = (float *)malloc(numparticles*sizeof(float)); + + px = (float *)malloc(numparticles*sizeof(float)); + py = (float *)malloc(numparticles*sizeof(float)); + pz = (float *)malloc(numparticles*sizeof(float)); + + id1 = (int *)malloc(numparticles*sizeof(int)); + id2 = (int *)malloc(numparticles*sizeof(int)); + + // create a pdc + pdc_id = PDCinit("pdc"); + + // open a container + cont_id = PDCcont_open("c1", pdc_id); + if(cont_id == 0) + printf("Fail to create container @ line %d!\n", __LINE__); + + // open objects + obj_xx = PDCobj_open("obj-var-xx", pdc_id); + if (obj_xx == 0) { + printf("Error when open object %s\n", "obj-var-xx"); + exit(-1); + } + obj_yy = PDCobj_open("obj-var-yy", pdc_id); + if (obj_yy == 0) { + printf("Error when open object %s\n", "obj-var-yy"); + exit(-1); + } + obj_zz = PDCobj_open("obj-var-zz", pdc_id); + if (obj_zz == 0) { + printf("Error when open object %s\n", "obj-var-zz"); + exit(-1); + } + obj_pxx = PDCobj_open("obj-var-pxx", pdc_id); + if (obj_pxx == 0) { + printf("Error when open object %s\n", "obj-var-pxx"); + exit(-1); + } + obj_pyy = PDCobj_open("obj-var-pyy", pdc_id); + if (obj_pyy == 0) { + printf("Error when open object %s\n", "obj-var-pyy"); + exit(-1); + } + obj_pzz = PDCobj_open("obj-var-pzz", pdc_id); + if (obj_pzz == 0) { + printf("Error when open object %s\n", "obj-var-pzz"); + exit(-1); + } + obj_id11 = PDCobj_open("id11", pdc_id); + if (obj_id11 == 0) { + printf("Error when open object %s\n", "id11"); + exit(-1); + } + obj_id22 = PDCobj_open("id22", pdc_id); + if (obj_id22 == 0) { + printf("Error when open object %s\n", "id22"); + exit(-1); + } + + offset = (uint64_t *)malloc(sizeof(uint64_t) * ndim); + offset_remote = (uint64_t *)malloc(sizeof(uint64_t) * ndim); + mysize = (uint64_t *)malloc(sizeof(uint64_t) * ndim); + offset[0] = 0; + offset_remote[0] = rank * numparticles; + mysize[0] = numparticles; + + // create a region + region_x = PDCregion_create(ndim, offset, mysize); + region_y = PDCregion_create(ndim, offset, mysize); + region_z = PDCregion_create(ndim, offset, mysize); + region_px = PDCregion_create(ndim, offset, mysize); + region_py = PDCregion_create(ndim, offset, mysize); + region_pz = PDCregion_create(ndim, offset, mysize); + region_id1 = PDCregion_create(ndim, offset, mysize); + region_id2 = PDCregion_create(ndim, offset, mysize); + + region_xx = PDCregion_create(ndim, offset_remote, mysize); + region_yy = PDCregion_create(ndim, offset_remote, mysize); + region_zz = PDCregion_create(ndim, offset_remote, mysize); + region_pxx = PDCregion_create(ndim, offset_remote, mysize); + region_pyy = PDCregion_create(ndim, offset_remote, mysize); + region_pzz = PDCregion_create(ndim, offset_remote, mysize); + region_id11 = PDCregion_create(ndim, offset_remote, mysize); + region_id22 = PDCregion_create(ndim, offset_remote, mysize); + +#ifdef ENABLE_MPI + MPI_Barrier(MPI_COMM_WORLD); +#endif + gettimeofday(&ht_total_start, 0); + + ret = PDCbuf_obj_map(&x[0], PDC_FLOAT, region_x, obj_xx, region_xx); + if(ret < 0) + printf("Array x PDCbuf_obj_map failed\n"); + + ret = PDCbuf_obj_map(&y[0], PDC_FLOAT, region_y, obj_yy, region_yy); + if(ret < 0) + printf("Array y PDCbuf_obj_map failed\n"); + + ret = PDCbuf_obj_map(&z[0], PDC_FLOAT, region_z, obj_zz, region_zz); + if(ret < 0) + printf("Array z PDCbuf_obj_map failed\n"); + + ret = PDCbuf_obj_map(&px[0], PDC_FLOAT, region_px, obj_pxx, region_pxx); + if(ret < 0) + printf("Array px PDCbuf_obj_map failed\n"); + + ret = PDCbuf_obj_map(&py[0], PDC_FLOAT, region_py, obj_pyy, region_pyy); + if(ret < 0) + printf("Array py PDCbuf_obj_map failed\n"); + + ret = PDCbuf_obj_map(&pz[0], PDC_FLOAT, region_pz, obj_pzz, region_pzz); + if(ret < 0) + printf("Array pz PDCbuf_obj_map failed\n"); + + ret = PDCbuf_obj_map(&id1[0], PDC_INT, region_id1, obj_id11, region_id11); + if(ret < 0) + printf("Array id1 PDCbuf_obj_map failed\n"); + + ret = PDCbuf_obj_map(&id2[0], PDC_INT, region_id2, obj_id22, region_id22); + if(ret < 0) + printf("Array id2 PDCbuf_obj_map failed\n"); + +#ifdef ENABLE_MPI + MPI_Barrier(MPI_COMM_WORLD); +#endif + gettimeofday(&ht_total_end, 0); + ht_total_elapsed = (ht_total_end.tv_sec-ht_total_start.tv_sec)*1000000LL + ht_total_end.tv_usec-ht_total_start.tv_usec; + ht_total_sec = ht_total_elapsed / 1000000.0; + if (rank == 0) { + printf("Time to map with %d ranks: %.6f\n", size, ht_total_sec); + fflush(stdout); + } + +#ifdef ENABLE_MPI + MPI_Barrier(MPI_COMM_WORLD); +#endif + gettimeofday(&ht_total_start, 0); + + ret = PDCreg_obtain_lock(obj_xx, region_xx, PDC_READ, PDC_NOBLOCK); + if (ret != SUCCEED) + printf("Failed to obtain lock for region_xx\n"); + + ret = PDCreg_obtain_lock(obj_yy, region_yy, PDC_READ, PDC_NOBLOCK); + if (ret != SUCCEED) + printf("Failed to obtain lock for region_yy\n"); + + ret = PDCreg_obtain_lock(obj_zz, region_zz, PDC_READ, PDC_NOBLOCK); + if (ret != SUCCEED) + printf("Failed to obtain lock for region_zz\n"); + + ret = PDCreg_obtain_lock(obj_pxx, region_pxx, PDC_READ, PDC_NOBLOCK); + if (ret != SUCCEED) + printf("Failed to obtain lock for region_pxx\n"); + + ret = PDCreg_obtain_lock(obj_pyy, region_pyy, PDC_READ, PDC_NOBLOCK); + if (ret != SUCCEED) + printf("Failed to obtain lock for region_pyy\n"); + + ret = PDCreg_obtain_lock(obj_pzz, region_pzz, PDC_READ, PDC_NOBLOCK); + if (ret != SUCCEED) + printf("Failed to obtain lock for region_pzz\n"); + + ret = PDCreg_obtain_lock(obj_id11, region_id11, PDC_READ, PDC_NOBLOCK); + if (ret != SUCCEED) + printf("Failed to obtain lock for region_id11\n"); + + ret = PDCreg_obtain_lock(obj_id22, region_id22, PDC_READ, PDC_NOBLOCK); + if (ret != SUCCEED) + printf("Failed to obtain lock for region_id22\n"); + +#ifdef ENABLE_MPI + MPI_Barrier(MPI_COMM_WORLD); +#endif + gettimeofday(&ht_total_end, 0); + ht_total_elapsed = (ht_total_end.tv_sec-ht_total_start.tv_sec)*1000000LL + ht_total_end.tv_usec-ht_total_start.tv_usec; + ht_total_sec = ht_total_elapsed / 1000000.0; + if (rank == 0) { + printf("Time to lock with %d ranks: %.6f\n", size, ht_total_sec); + fflush(stdout); + } + +#ifdef ENABLE_MPI + MPI_Barrier(MPI_COMM_WORLD); +#endif + gettimeofday(&ht_total_start, 0); + + ret = PDCreg_release_lock(obj_xx, region_xx, PDC_READ); + if (ret != SUCCEED) + printf("Failed to release lock for region_xx\n"); + + ret = PDCreg_release_lock(obj_yy, region_yy, PDC_READ); + if (ret != SUCCEED) + printf("Failed to release lock for region_yy\n"); + + ret = PDCreg_release_lock(obj_zz, region_zz, PDC_READ); + if (ret != SUCCEED) + printf("Failed to release lock for region_zz\n"); + + ret = PDCreg_release_lock(obj_pxx, region_pxx, PDC_READ); + if (ret != SUCCEED) + printf("Failed to release lock for region_pxx\n"); + + ret = PDCreg_release_lock(obj_pyy, region_pyy, PDC_READ); + if (ret != SUCCEED) + printf("Failed to release lock for region_pyy\n"); + + ret = PDCreg_release_lock(obj_pzz, region_pzz, PDC_READ); + if (ret != SUCCEED) + printf("Failed to release lock for region_pzz\n"); + + ret = PDCreg_release_lock(obj_id11, region_id11, PDC_READ); + if (ret != SUCCEED) + printf("Failed to release lock for region_id11\n"); + + ret = PDCreg_release_lock(obj_id22, region_id22, PDC_READ); + if (ret != SUCCEED) + printf("Failed to release lock for region_id22\n"); + +#ifdef ENABLE_MPI + MPI_Barrier(MPI_COMM_WORLD); +#endif + gettimeofday(&ht_total_end, 0); + ht_total_elapsed = (ht_total_end.tv_sec-ht_total_start.tv_sec)*1000000LL + ht_total_end.tv_usec-ht_total_start.tv_usec; + ht_total_sec = ht_total_elapsed / 1000000.0; + if (rank == 0) { + printf("Time to relese lock with %d ranks: %.6f\n", size, ht_total_sec); + fflush(stdout); + } + +#ifdef ENABLE_MPI + MPI_Barrier(MPI_COMM_WORLD); +#endif + + ret = PDCbuf_obj_unmap(obj_xx, region_xx); + if (ret != SUCCEED) + printf("region xx unmap failed\n"); + + ret = PDCbuf_obj_unmap(obj_yy, region_yy); + if (ret != SUCCEED) + printf("region yy unmap failed\n"); + + ret = PDCbuf_obj_unmap(obj_zz, region_zz); + if (ret != SUCCEED) + printf("region zz unmap failed\n"); + + ret = PDCbuf_obj_unmap(obj_pxx, region_pxx); + if (ret != SUCCEED) + printf("region pxx unmap failed\n"); + + ret = PDCbuf_obj_unmap(obj_pyy, region_pyy); + if (ret != SUCCEED) + printf("region pyy unmap failed\n"); + + ret = PDCbuf_obj_unmap(obj_pzz, region_pzz); + if (ret != SUCCEED) + printf("region pzz unmap failed\n"); + + ret = PDCbuf_obj_unmap(obj_id11, region_id11); + if (ret != SUCCEED) + printf("region id11 unmap failed\n"); + + ret = PDCbuf_obj_unmap(obj_id22, region_id22); + if (ret != SUCCEED) + printf("region id22 unmap failed\n"); + +#ifdef ENABLE_MPI + MPI_Barrier(MPI_COMM_WORLD); +#endif + gettimeofday(&ht_total_end, 0); + ht_total_elapsed = (ht_total_end.tv_sec-ht_total_start.tv_sec)*1000000LL + ht_total_end.tv_usec-ht_total_start.tv_usec; + ht_total_sec = ht_total_elapsed / 1000000.0; + if (rank == 0) { + printf("Time to read data with %d ranks: %.6f\n", size, ht_total_sec); + fflush(stdout); + } + + if(PDCobj_close(obj_xx) < 0) + printf("fail to close obj_xx\n"); + + if(PDCobj_close(obj_yy) < 0) + printf("fail to close object obj_yy\n"); + + if(PDCobj_close(obj_zz) < 0) + printf("fail to close object obj_zz\n"); + + if(PDCobj_close(obj_pxx) < 0) + printf("fail to close object obj_pxx\n"); + + if(PDCobj_close(obj_pyy) < 0) + printf("fail to close object obj_pyy\n"); + + if(PDCobj_close(obj_pzz) < 0) + printf("fail to close object obj_pzz\n"); + + if(PDCobj_close(obj_id11) < 0) + printf("fail to close object obj_id11\n"); + + if(PDCobj_close(obj_id22) < 0) + printf("fail to close object obj_id22\n"); + + if(PDCregion_close(region_x) < 0) + printf("fail to close region region_x\n"); + + if(PDCregion_close(region_y) < 0) + printf("fail to close region region_y\n"); + + if(PDCregion_close(region_z) < 0) + printf("fail to close region region_z\n"); + + if(PDCregion_close(region_px) < 0) + printf("fail to close region region_px\n"); + + if(PDCregion_close(region_py) < 0) + printf("fail to close region region_py\n"); + + if(PDCobj_close(region_pz) < 0) + printf("fail to close region region_pz\n"); + + if(PDCobj_close(region_id1) < 0) + printf("fail to close region region_id1\n"); + + if(PDCobj_close(region_id2) < 0) + printf("fail to close region region_id2\n"); + + if(PDCregion_close(region_xx) < 0) + printf("fail to close region region_xx\n"); + + if(PDCregion_close(region_yy) < 0) + printf("fail to close region region_yy\n"); + + if(PDCregion_close(region_zz) < 0) + printf("fail to close region region_zz\n"); + + if(PDCregion_close(region_pxx) < 0) + printf("fail to close region region_pxx\n"); + + if(PDCregion_close(region_pyy) < 0) + printf("fail to close region region_pyy\n"); + + if(PDCregion_close(region_pzz) < 0) + printf("fail to close region region_pzz\n"); + + if(PDCobj_close(region_id11) < 0) + printf("fail to close region region_id11\n"); + + if(PDCobj_close(region_id22) < 0) + printf("fail to close region region_id22\n"); + + // close a container + if(PDCcont_close(cont_id) < 0) + printf("fail to close container c1\n"); + + if(PDCclose(pdc_id) < 0) + printf("fail to close PDC\n"); + + free(x); + free(y); + free(z); + free(px); + free(py); + free(pz); + free(id1); + free(id2); + free(offset); + free(offset_remote); + free(mysize); + +#ifdef ENABLE_MPI + MPI_Finalize(); +#endif + + return 0; +} + diff --git a/examples/mpi_test.sh b/examples/mpi_test.sh new file mode 100755 index 000000000..127bf2c74 --- /dev/null +++ b/examples/mpi_test.sh @@ -0,0 +1,32 @@ +#!/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 +#include +#include +#include "pdc.h" + + +int main(int argc, char **argv) { + pdcid_t pdc, cont_prop, cont; + pdcid_t obj1, obj2; + perr_t error_code; + char cont_name[128], obj_name1[128], obj_name2[128]; + + int rank = 0, size = 1; + unsigned i; + int ret_value = 0; + + char *data = (char*)malloc(sizeof(double)*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("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; + } + + memset(data, 1, 128 * sizeof(double)); + 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; + } + + memset(data, 2, 128 * sizeof(double)); + 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; + } + + memset(data, 0, 128 * sizeof(double)); + error_code = PDCobj_get_data(obj1, (void*)(data), 16 * sizeof(double)); + if (error_code!= SUCCEED) { + printf("Fail to get obj 1 data\n"); + ret_value = 1; + } + for ( i = 0; i < 16*sizeof(double); ++i ) { + if (data[i] != 1) { + printf("wrong value at obj 1\n"); + ret_value = 1; + break; + } + } + memset(data, 0, 128 * sizeof(double)); + error_code = PDCobj_get_data(obj2, (void*)(data), 128 * sizeof(double)); + if (error_code!= SUCCEED) { + printf("Fail to get obj 1 data\n"); + ret_value = 1; + } + for ( i = 0; i < 128*sizeof(double); ++i ) { + if (data[i] != 2) { + printf("wrong value at obj 2\n"); + 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 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/examples/pdc_init.c b/examples/pdc_init.c new file mode 100644 index 000000000..e0d822f82 --- /dev/null +++ b/examples/pdc_init.c @@ -0,0 +1,54 @@ +/* + * 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; + 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) { + printf("fail to close PDC\n"); + ret_value = 1; + } +#ifdef ENABLE_MPI + MPI_Finalize(); +#endif + return ret_value; +} diff --git a/examples/region_obj_map_2D.c b/examples/region_obj_map_2D.c new file mode 100644 index 000000000..8113bd599 --- /dev/null +++ b/examples/region_obj_map_2D.c @@ -0,0 +1,268 @@ +/* + * 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" +#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; + } + + ret = PDCreg_obtain_lock(obj1, reg_global, PDC_WRITE, PDC_BLOCK); + if(ret != SUCCEED) { + printf("PDCreg_obtain_lock failed\n"); + exit(-1); + } + + ret = PDCreg_release_lock(obj1, reg_global, 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; + } + + if(PDCregion_close(reg) < 0) { + printf("fail to close local region\n"); + ret_value = 1; + } else { + printf("successfully local region\n"); + } + + if(PDCregion_close(reg_global) < 0) { + printf("fail to close global region\n"); + ret_value = 1; + } else { + printf("successfully global region\n"); + } + + 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_global, PDC_READ, PDC_BLOCK); + if(ret != SUCCEED) { + printf("PDCreg_obtain_lock failed\n"); + ret_value = 1; + } + + + + ret = PDCreg_release_lock(obj1, reg_global, 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; + } + } + + if(PDCregion_close(reg) < 0) { + printf("fail to close local region\n"); + ret_value = 1; + } else { + printf("successfully local region\n"); + } + + if(PDCregion_close(reg_global) < 0) { + printf("fail to close global region\n"); + ret_value = 1; + } else { + printf("successfully global region\n"); + } + + + // 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/examples/region_obj_map_3D.c b/examples/region_obj_map_3D.c new file mode 100644 index 000000000..d676076a8 --- /dev/null +++ b/examples/region_obj_map_3D.c @@ -0,0 +1,268 @@ +/* + * 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" +#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; + } + + ret = PDCreg_obtain_lock(obj1, reg_global, PDC_WRITE, PDC_BLOCK); + if(ret != SUCCEED) { + printf("PDCreg_obtain_lock failed\n"); + exit(-1); + } + + ret = PDCreg_release_lock(obj1, reg_global, 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; + } + + if(PDCregion_close(reg) < 0) { + printf("fail to close local region\n"); + ret_value = 1; + } else { + printf("successfully local region\n"); + } + + if(PDCregion_close(reg_global) < 0) { + printf("fail to close global region\n"); + ret_value = 1; + } else { + printf("successfully global region\n"); + } + + 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_global, PDC_READ, PDC_BLOCK); + if(ret != SUCCEED) { + printf("PDCreg_obtain_lock failed\n"); + ret_value = 1; + } + + ret = PDCreg_release_lock(obj1, reg_global, 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; + } + } + + if(PDCregion_close(reg) < 0) { + printf("fail to close local region\n"); + ret_value = 1; + } else { + printf("successfully local region\n"); + } + + if(PDCregion_close(reg_global) < 0) { + printf("fail to close global region\n"); + ret_value = 1; + } else { + printf("successfully global region\n"); + } + + + // 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/examples/run_multiple_test.sh b/examples/run_multiple_test.sh new file mode 100755 index 000000000..58d2e1d28 --- /dev/null +++ b/examples/run_multiple_test.sh @@ -0,0 +1,25 @@ +#!/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 +#include +#include +#include +#include +#include +#include +#include +#include +#include "pdc.h" + +#define NPARTICLES 8388608 + +double uniform_random_number() +{ + return (((double)rand())/((double)(RAND_MAX))); +} + +void print_usage() { + printf("Usage: srun -n ./vpicio #particles\n"); +} + +int main(int argc, char **argv) +{ + int rank = 0, size = 1; + pdcid_t pdc_id, cont_prop, cont_id; + pdcid_t obj_prop_xx, obj_prop_yy, obj_prop_zz, obj_prop_pxx, obj_prop_pyy, obj_prop_pzz, obj_prop_id11, obj_prop_id22; + pdcid_t obj_xx, obj_yy, obj_zz, obj_pxx, obj_pyy, obj_pzz, obj_id11, obj_id22; + pdcid_t region_x, region_y, region_z, region_px, region_py, region_pz, region_id1, region_id2; + pdcid_t region_xx, region_yy, region_zz, region_pxx, region_pyy, region_pzz, region_id11, region_id22; + perr_t ret; +#ifdef ENABLE_MPI + MPI_Comm comm; +#else + int comm = 1; +#endif + struct timeval ht_total_start; + struct timeval ht_total_end; + long long ht_total_elapsed; + double ht_total_sec; + float *x, *y, *z; + float *px, *py, *pz; + int *id1, *id2; + int x_dim = 64; + int y_dim = 64; + int z_dim = 64; + uint64_t numparticles, i; + uint64_t dims[1]; + int ndim = 1; + uint64_t *offset; + uint64_t *offset_remote; + uint64_t *mysize; + +#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 < 2) { + print_usage(); + return 0; + } + numparticles = atoll(argv[1]) * 1024 * 1024; + if (rank == 0) { + printf("Writing %" PRIu64 " number of particles with %d clients.\n", numparticles, size); + } +*/ + + numparticles = NPARTICLES; + dims[0] = numparticles; + + x = (float *)malloc(numparticles*sizeof(float)); + y = (float *)malloc(numparticles*sizeof(float)); + z = (float *)malloc(numparticles*sizeof(float)); + + px = (float *)malloc(numparticles*sizeof(float)); + py = (float *)malloc(numparticles*sizeof(float)); + pz = (float *)malloc(numparticles*sizeof(float)); + + id1 = (int *)malloc(numparticles*sizeof(int)); + id2 = (int *)malloc(numparticles*sizeof(int)); + + // 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__); + return 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__); + return 1; + } + // create an object property + obj_prop_xx = PDCprop_create(PDC_OBJ_CREATE, pdc_id); + + PDCprop_set_obj_dims(obj_prop_xx, 1, dims); + PDCprop_set_obj_type(obj_prop_xx, PDC_FLOAT); + PDCprop_set_obj_time_step(obj_prop_xx, 0); + PDCprop_set_obj_user_id(obj_prop_xx, getuid()); + PDCprop_set_obj_app_name(obj_prop_xx, "VPICIO"); + PDCprop_set_obj_tags(obj_prop_xx, "tag0=1"); + + obj_prop_yy = PDCprop_obj_dup(obj_prop_xx); + PDCprop_set_obj_type(obj_prop_yy, PDC_FLOAT); + + obj_prop_zz = PDCprop_obj_dup(obj_prop_xx); + PDCprop_set_obj_type(obj_prop_zz, PDC_FLOAT); + + obj_prop_pxx = PDCprop_obj_dup(obj_prop_xx); + PDCprop_set_obj_type(obj_prop_pxx, PDC_FLOAT); + + obj_prop_pyy = PDCprop_obj_dup(obj_prop_xx); + PDCprop_set_obj_type(obj_prop_pyy, PDC_FLOAT); + + obj_prop_pzz = PDCprop_obj_dup(obj_prop_xx); + PDCprop_set_obj_type(obj_prop_pzz, PDC_FLOAT); + + obj_prop_id11 = PDCprop_obj_dup(obj_prop_xx); + PDCprop_set_obj_type(obj_prop_id11, PDC_INT); + + obj_prop_id22 = PDCprop_obj_dup(obj_prop_xx); + PDCprop_set_obj_type(obj_prop_id22, PDC_INT); + +#ifdef ENABLE_MPI + obj_xx = PDCobj_create_mpi(cont_id, "obj-var-xx", obj_prop_xx, 0, comm); +#else + obj_xx = PDCobj_create(cont_id, "obj-var-xx", obj_prop_xx); +#endif + if (obj_xx == 0) { + printf("Error getting an object id of %s from server, exit...\n", "obj-var-xx"); + exit(-1); + } + +#ifdef ENABLE_MPI + obj_yy = PDCobj_create_mpi(cont_id, "obj-var-yy", obj_prop_yy, 0, comm); +#else + obj_yy = PDCobj_create(cont_id, "obj-var-yy", obj_prop_yy); +#endif + if (obj_yy == 0) { + printf("Error getting an object id of %s from server, exit...\n", "obj-var-yy"); + exit(-1); + } +#ifdef ENABLE_MPI + obj_zz = PDCobj_create_mpi(cont_id, "obj-var-zz", obj_prop_zz, 0, comm); +#else + obj_zz = PDCobj_create(cont_id, "obj-var-zz", obj_prop_zz); +#endif + if (obj_zz == 0) { + printf("Error getting an object id of %s from server, exit...\n", "obj-var-zz"); + exit(-1); + } +#ifdef ENABLE_MPI + obj_pxx = PDCobj_create_mpi(cont_id, "obj-var-pxx", obj_prop_pxx, 0, comm); +#else + obj_pxx = PDCobj_create(cont_id, "obj-var-pxx", obj_prop_pxx); +#endif + if (obj_pxx == 0) { + printf("Error getting an object id of %s from server, exit...\n", "obj-var-pxx"); + exit(-1); + } +#ifdef ENABLE_MPI + obj_pyy = PDCobj_create_mpi(cont_id, "obj-var-pyy", obj_prop_pyy, 0, comm); +#else + obj_pyy = PDCobj_create(cont_id, "obj-var-pyy", obj_prop_pyy); +#endif + if (obj_pyy == 0) { + printf("Error getting an object id of %s from server, exit...\n", "obj-var-pyy"); + exit(-1); + } +#ifdef ENABLE_MPI + obj_pzz = PDCobj_create_mpi(cont_id, "obj-var-pzz", obj_prop_pzz, 0, comm); +#else + obj_pzz = PDCobj_create(cont_id, "obj-var-pzz", obj_prop_pzz); +#endif + if (obj_pzz == 0) { + printf("Error getting an object id of %s from server, exit...\n", "obj-var-pzz"); + exit(-1); + } + +#ifdef ENABLE_MPI + obj_id11 = PDCobj_create_mpi(cont_id, "id11", obj_prop_id11, 0, comm); +#else + obj_id11 = PDCobj_create(cont_id, "id11", obj_prop_id11); +#endif + if (obj_id11 == 0) { + printf("Error getting an object id of %s from server, exit...\n", "obj_id11"); + exit(-1); + } +#ifdef ENABLE_MPI + obj_id22 = PDCobj_create_mpi(cont_id, "id22", obj_prop_id22, 0, comm); +#else + obj_id22 = PDCobj_create(cont_id, "id22", obj_prop_id22); +#endif + if (obj_id22 == 0) { + printf("Error getting an object id of %s from server, exit...\n", "obj_id22"); + exit(-1); + } + + offset = (uint64_t *)malloc(sizeof(uint64_t) * ndim); + offset_remote = (uint64_t *)malloc(sizeof(uint64_t) * ndim); + mysize = (uint64_t *)malloc(sizeof(uint64_t) * ndim); + offset[0] = 0; + offset_remote[0] = rank * numparticles; + mysize[0] = numparticles; + + // create a region + region_x = PDCregion_create(ndim, offset, mysize); + region_y = PDCregion_create(ndim, offset, mysize); + region_z = PDCregion_create(ndim, offset, mysize); + region_px = PDCregion_create(ndim, offset, mysize); + region_py = PDCregion_create(ndim, offset, mysize); + region_pz = PDCregion_create(ndim, offset, mysize); + region_id1 = PDCregion_create(ndim, offset, mysize); + region_id2 = PDCregion_create(ndim, offset, mysize); + + region_xx = PDCregion_create(ndim, offset_remote, mysize); + region_yy = PDCregion_create(ndim, offset_remote, mysize); + region_zz = PDCregion_create(ndim, offset_remote, mysize); + region_pxx = PDCregion_create(ndim, offset_remote, mysize); + region_pyy = PDCregion_create(ndim, offset_remote, mysize); + region_pzz = PDCregion_create(ndim, offset_remote, mysize); + region_id11 = PDCregion_create(ndim, offset_remote, mysize); + region_id22 = PDCregion_create(ndim, offset_remote, mysize); + +#ifdef ENABLE_MPI + MPI_Barrier(MPI_COMM_WORLD); +#endif + gettimeofday(&ht_total_start, 0); + + ret = PDCbuf_obj_map(&x[0], PDC_FLOAT, region_x, obj_xx, region_xx); + 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) { + 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) { + 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) { + 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) { + 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) { + 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) { + 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) { + printf("Array id2 PDCbuf_obj_map failed\n"); + return 1; + } +#ifdef ENABLE_MPI + MPI_Barrier(MPI_COMM_WORLD); +#endif + gettimeofday(&ht_total_end, 0); + ht_total_elapsed = (ht_total_end.tv_sec-ht_total_start.tv_sec)*1000000LL + ht_total_end.tv_usec-ht_total_start.tv_usec; + ht_total_sec = ht_total_elapsed / 1000000.0; + if (rank == 0) { + printf("Time to map with %d ranks: %.6f\n", size, ht_total_sec); + fflush(stdout); + } + +#ifdef ENABLE_MPI + MPI_Barrier(MPI_COMM_WORLD); +#endif + gettimeofday(&ht_total_start, 0); + + ret = PDCreg_obtain_lock(obj_xx, region_xx, PDC_WRITE, PDC_NOBLOCK); + 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) { + 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) { + 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) { + 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) { + 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) { + 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) { + 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) { + printf("Failed to obtain lock for region_id22\n"); + return 1; + } +#ifdef ENABLE_MPI + MPI_Barrier(MPI_COMM_WORLD); +#endif + gettimeofday(&ht_total_end, 0); + ht_total_elapsed = (ht_total_end.tv_sec-ht_total_start.tv_sec)*1000000LL + ht_total_end.tv_usec-ht_total_start.tv_usec; + ht_total_sec = ht_total_elapsed / 1000000.0; + if (rank == 0) { + printf("Time to lock with %d ranks: %.6f\n", size, ht_total_sec); + fflush(stdout); + } + + for (i=0; iname); p = PDC_FREE(struct _pdc_class, p); diff --git a/src/api/pdc_client_connect.c b/src/api/pdc_client_connect.c index 615001d91..b751256cf 100644 --- a/src/api/pdc_client_connect.c +++ b/src/api/pdc_client_connect.c @@ -59,6 +59,8 @@ #include #include +#include "pdc_timing.h" + int is_client_debug_g = 0; pdc_server_selection_t pdc_server_selection_g = PDC_SERVER_DEFAULT; int pdc_client_mpi_rank_g = 0; @@ -1723,7 +1725,7 @@ perr_t PDC_Client_delete_metadata_by_id(uint64_t obj_id) work_todo_g = 1; PDC_Client_check_response(&send_context_g); - if (lookup_args.ret != 1) + if (lookup_args.ret < 0) PGOTO_ERROR(FAIL, "PDC_CLIENT: delete_by_id NOT successful ..."); done: @@ -2189,15 +2191,26 @@ perr_t PDC_Client_buf_unmap(pdcid_t remote_obj_id, pdcid_t remote_reg_id, struct PGOTO_ERROR(FAIL, "==CLIENT[%d]: ERROR with PDC_Client_try_lookup_server", pdc_client_mpi_rank_g); HG_Create(send_context_g, pdc_server_info_g[data_server_id].addr, buf_unmap_register_id_g, &client_send_buf_unmap_handle); - +#if PDC_TIMING == 1 + double start = MPI_Wtime(), end; +#endif hg_ret = HG_Forward(client_send_buf_unmap_handle, client_send_buf_unmap_rpc_cb, &unmap_args, &in); if (hg_ret != HG_SUCCESS) PGOTO_ERROR(FAIL, "PDC_Client_send_buf_unmap(): Could not start HG_Forward()"); - +#if PDC_TIMING == 1 + timings.PDCbuf_obj_unmap_rpc += MPI_Wtime() - start; +#endif // Wait for response from server work_todo_g = 1; +#if PDC_TIMING == 1 + start = MPI_Wtime(); +#endif PDC_Client_check_response(&send_context_g); - +#if PDC_TIMING == 1 + end = MPI_Wtime(); + timings.PDCbuf_obj_unmap_rpc_wait += end - start; + pdc_timestamp_register(client_buf_obj_unmap_timestamps, start, end); +#endif if (unmap_args.ret != 1) PGOTO_ERROR(FAIL, "PDC_CLIENT: buf unmap failed..."); @@ -2330,15 +2343,27 @@ perr_t PDC_Client_buf_map(pdcid_t local_region_id, pdcid_t remote_obj_id, size_t hg_ret = HG_Bulk_create(hg_class, local_count, (void**)data_ptrs, (hg_size_t *)data_size, HG_BULK_READWRITE, &(in.local_bulk_handle)); if (hg_ret != HG_SUCCESS) PGOTO_ERROR(FAIL, "PDC_Client_buf_map(): Could not create local bulk data handle"); - +#if PDC_TIMING == 1 + double start = MPI_Wtime(), end; +#endif hg_ret = HG_Forward(client_send_buf_map_handle, client_send_buf_map_rpc_cb, &map_args, &in); +#if PDC_TIMING == 1 + timings.PDCbuf_obj_map_rpc += MPI_Wtime() - start; +#endif if (hg_ret != HG_SUCCESS) PGOTO_ERROR(FAIL, "PDC_Client_send_buf_map(): Could not start HG_Forward()"); // Wait for response from server work_todo_g = 1; +#if PDC_TIMING == 1 + start = MPI_Wtime(); +#endif PDC_Client_check_response(&send_context_g); - +#if PDC_TIMING == 1 + end = MPI_Wtime(); + timings.PDCbuf_obj_map_rpc_wait += end - start; + pdc_timestamp_register(client_buf_obj_map_timestamps, start, end); +#endif if (map_args.ret != 1) PGOTO_ERROR(FAIL,"PDC_CLIENT: buf map failed..."); @@ -2399,15 +2424,27 @@ perr_t PDC_Client_region_lock(struct _pdc_obj_info *object_info, struct pdc_regi HG_Create(send_context_g, pdc_server_info_g[server_id].addr, region_lock_register_id_g, ®ion_lock_handle); - +#if PDC_TIMING == 1 + double start = MPI_Wtime(), end; +#endif hg_ret = HG_Forward(region_lock_handle, client_region_lock_rpc_cb, &lookup_args, &in); +#if PDC_TIMING == 1 + timings.PDCreg_obtain_lock_rpc += MPI_Wtime() - start; +#endif if (hg_ret != HG_SUCCESS) PGOTO_ERROR(FAIL, "PDC_Client_send_name_to_server(): Could not start HG_Forward()"); // Wait for response from server work_todo_g = 1; +#if PDC_TIMING == 1 + start = MPI_Wtime(); +#endif PDC_Client_check_response(&send_context_g); - +#if PDC_TIMING == 1 + end = MPI_Wtime(); + timings.PDCreg_obtain_lock_rpc_wait += end - start; + pdc_timestamp_register(client_obtain_lock_timestamps, start, end); +#endif // Now the return value is stored in lookup_args.ret if (lookup_args.ret == 1) { *status = TRUE; @@ -3030,15 +3067,27 @@ perr_t PDC_Client_region_release(struct _pdc_obj_info *object_info, struct pdc_r HG_Create(send_context_g, pdc_server_info_g[server_id].addr, region_release_register_id_g, ®ion_release_handle); - +#if PDC_TIMING == 1 + double start = MPI_Wtime(), end; +#endif hg_ret = HG_Forward(region_release_handle, client_region_release_rpc_cb, &lookup_args, &in); +#if PDC_TIMING == 1 + timings.PDCreg_release_lock_rpc += MPI_Wtime() - start; +#endif if (hg_ret != HG_SUCCESS) PGOTO_ERROR(FAIL, "PDC_Client_send_name_to_server(): Could not start HG_Forward()"); // Wait for response from server work_todo_g = 1; +#if PDC_TIMING == 1 + start = MPI_Wtime(); +#endif PDC_Client_check_response(&send_context_g); - +#if PDC_TIMING == 1 + end = MPI_Wtime(); + timings.PDCreg_release_lock_rpc_wait += end - start; + pdc_timestamp_register(client_release_lock_timestamps, start, end); +#endif // Now the return value is stored in lookup_args.ret if (lookup_args.ret == 1) { *status = TRUE; @@ -3831,6 +3880,7 @@ perr_t PDC_Client_write_id(pdcid_t local_obj_id, struct pdc_region_info *region, request.n_update = 1; request.n_client = 1; ret_value = PDC_Client_iwrite(meta, region, &request, buf); + if (ret_value != SUCCEED) PGOTO_ERROR(FAIL, "==PDC_CLIENT: PDC_Client_write - PDC_Client_iwrite error"); @@ -4332,6 +4382,7 @@ struct pdc_request *PDC_find_request_from_list_by_seq_id(struct pdc_request **li perr_t PDC_Client_query_name_read_entire_obj(int nobj, char **obj_names, void ***out_buf, uint64_t *out_buf_sizes) { + perr_t ret_value = SUCCEED; hg_return_t hg_ret = HG_SUCCESS; hg_handle_t rpc_handle; @@ -6094,7 +6145,7 @@ PDCcont_del(pdcid_t cont_id) FUNC_ENTER(NULL); - ret_value = PDCobj_del_data(cont_id); + ret_value = PDC_Client_del_metadata(cont_id, 1); if (ret_value != SUCCEED) PGOTO_ERROR(FAIL, "==PDC_CLIENT[%d]: error with PDC_Client_del_objects_to_container", pdc_client_mpi_rank_g); @@ -6325,16 +6376,23 @@ perr_t PDCobj_get_data(pdcid_t obj_id, void *data, uint64_t size) } perr_t -PDCobj_del_data(pdcid_t obj_id) +PDC_Client_del_metadata(pdcid_t obj_id, int is_cont) { perr_t ret_value = SUCCEED; uint64_t meta_id; 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) { + cont_prop = PDC_cont_get_info(obj_id); + meta_id = cont_prop->cont_info_pub->meta_id; + } + else { + obj_prop = PDC_obj_get_info(obj_id); + meta_id = obj_prop->obj_info_pub->meta_id; + } ret_value = PDC_Client_delete_metadata_by_id(meta_id); if (ret_value != SUCCEED) diff --git a/src/api/pdc_client_connect.h b/src/api/pdc_client_connect.h index 3a32f3b13..c3e44b91f 100644 --- a/src/api/pdc_client_connect.h +++ b/src/api/pdc_client_connect.h @@ -830,4 +830,6 @@ int PDC_get_nproc_per_node(); */ perr_t PDC_free_kvtag(pdc_kvtag_t **kvtag); +perr_t PDC_Client_del_metadata(pdcid_t id, int is_cont); + #endif /* PDC_CLIENT_CONNECT_H */ diff --git a/src/api/pdc_client_server_common.c b/src/api/pdc_client_server_common.c index 50cd02603..7fbd6a50f 100644 --- a/src/api/pdc_client_server_common.c +++ b/src/api/pdc_client_server_common.c @@ -50,6 +50,153 @@ #include #include +#include "pdc_timing.h" +#if PDC_TIMING == 1 + +static int pdc_timestamp_clean(pdc_timestamp *timestamp) { + if (timestamp->timestamp_max_size) { + free(timestamp->start); + } + return 0; +} + +static int timestamp_log(FILE *stream, const char* header, pdc_timestamp *timestamp) { + size_t i; + fprintf(stream, "%s" ,header); + for ( i = 0; i < timestamp->timestamp_size; ++i ) { + fprintf(stream, ",%4f-%4f", timestamp->start[i], timestamp->end[i]); + } + fprintf(stream, "\n"); +} + + +int PDC_timing_init() { + memset(&timings, 0, sizeof(pdc_timing)); + + client_buf_obj_map_timestamps = calloc(4, sizeof(pdc_timestamp)); + client_buf_obj_unmap_timestamps = client_buf_obj_map_timestamps + 1; + client_obtain_lock_timestamps = client_buf_obj_map_timestamps + 2; + client_release_lock_timestamps = client_buf_obj_map_timestamps + 3; +} + +int PDC_timing_finalize() { + pdc_timestamp_clean(client_buf_obj_map_timestamps); + pdc_timestamp_clean(client_buf_obj_unmap_timestamps); + pdc_timestamp_clean(client_obtain_lock_timestamps); + pdc_timestamp_clean(client_release_lock_timestamps); + free(client_buf_obj_map_timestamps); + return 0; +} + + +int PDC_timing_report(const char* prefix) { + pdc_timing max_timings; + int rank; + char filename[256], header[256]; + FILE *stream; + + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + + MPI_Reduce(&timings, &max_timings, sizeof(pdc_timing)/sizeof(double), MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD); + if (rank == 0) { + printf("PDCbuf_obj_map_rpc = %lf, wait = %lf\n", max_timings.PDCbuf_obj_map_rpc, max_timings.PDCbuf_obj_map_rpc_wait); + printf("PDCreg_obtain_lock_rpc = %lf, wait = %lf\n", max_timings.PDCreg_obtain_lock_rpc, max_timings.PDCreg_obtain_lock_rpc_wait); + printf("PDCreg_release_lock_rpc = %lf, wait = %lf\n", max_timings.PDCreg_release_lock_rpc, max_timings.PDCreg_release_lock_rpc_wait); + printf("PDCbuf_obj_unmap_rpc = %lf, wait = %lf\n", max_timings.PDCbuf_obj_unmap_rpc, max_timings.PDCbuf_obj_unmap_rpc_wait); + } + + sprintf(filename, "pdc_client_log_rank_%d.csv", rank); + stream = fopen(filename,"r"); + if (stream){ + fclose(stream); + stream = fopen(filename,"a"); + } else { + stream = fopen(filename,"w"); + } + sprintf(header, "buf_obj_map_%s", prefix); + timestamp_log(stream, header, client_buf_obj_map_timestamps); + sprintf(header, "buf_obj_unmap_%s", prefix); + timestamp_log(stream, header, client_buf_obj_unmap_timestamps); + sprintf(header, "obtain_lock_%s", prefix); + timestamp_log(stream, header, client_obtain_lock_timestamps); + sprintf(header, "release_lock_%s", prefix); + timestamp_log(stream, header, client_release_lock_timestamps); + fclose(stream); + + client_buf_obj_map_timestamps->timestamp_size = 0; + client_buf_obj_unmap_timestamps->timestamp_size = 0; + client_obtain_lock_timestamps->timestamp_size = 0; + client_release_lock_timestamps->timestamp_size = 0; +} + +int PDC_server_timing_init() { + server_timings = calloc(1, sizeof(pdc_server_timing)); + buf_obj_map_timestamps = calloc(5, sizeof(pdc_timestamp)); + buf_obj_unmap_timestamps = buf_obj_map_timestamps + 1; + obtain_lock_timestamps = buf_obj_map_timestamps + 2; + release_lock_timestamps = buf_obj_map_timestamps + 3; + release_lock_bulk_transfer_timestamps = buf_obj_map_timestamps + 4; + base_time = MPI_Wtime(); +} + +int pdc_timestamp_register(pdc_timestamp *timestamp, double start, double end) { + double *temp; + + if (timestamp->timestamp_max_size == 0) { + timestamp->timestamp_max_size = 256; + timestamp->start = (double*) malloc(sizeof(double) * timestamp->timestamp_max_size * 2); + timestamp->end = timestamp->start + timestamp->timestamp_max_size; + } else if (timestamp->timestamp_size == timestamp->timestamp_max_size) { + temp = (double *) malloc(sizeof(double) * timestamp->timestamp_max_size * 4); + memcpy(temp, timestamp->start, sizeof(double) * timestamp->timestamp_max_size); + memcpy(temp + timestamp->timestamp_max_size * 2, timestamp->end, sizeof(double) * timestamp->timestamp_max_size); + timestamp->start = temp; + timestamp->end = temp + timestamp->timestamp_max_size * 2; + timestamp->timestamp_max_size *= 2; + } + timestamp->start[timestamp->timestamp_size] = start; + timestamp->end[timestamp->timestamp_size] = end; + timestamp->timestamp_size += 1; + return 0; +} + +int PDC_server_timing_report() { + pdc_server_timing max_timings; + int rank; + char filename[256]; + FILE* stream; + + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + + printf("rank = %d, PDCbuf_obj_map_rpc = %lf, PDCreg_obtain_lock_rpc = %lf, PDCreg_release_lock_rpc = %lf, PDCbuf_obj_unmap_rpc = %lf, region_release_bulk_transfer_cb = %lf\n", rank, server_timings->PDCbuf_obj_map_rpc, server_timings->PDCreg_obtain_lock_rpc, server_timings->PDCreg_release_lock_rpc, server_timings->PDCbuf_obj_unmap_rpc, server_timings->PDCreg_release_lock_bulk_transfer_rpc); + + MPI_Reduce(server_timings, &max_timings, sizeof(pdc_server_timing)/sizeof(double), MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD); + if (rank == 0) { + printf("rank = %d, maximum timing among all processes, PDCbuf_obj_map_rpc = %lf, PDCreg_obtain_lock_rpc = %lf, PDCreg_release_lock_rpc = %lf, PDCbuf_obj_unmap_rpc = %lf, region_release_bulk_transfer_cb = %lf\n", rank, max_timings.PDCbuf_obj_map_rpc, max_timings.PDCreg_obtain_lock_rpc, max_timings.PDCreg_release_lock_rpc, max_timings.PDCbuf_obj_unmap_rpc, max_timings.PDCreg_release_lock_bulk_transfer_rpc); + } + + + sprintf(filename, "pdc_server_log_rank_%d.csv", rank); + + stream = fopen(filename,"w"); + timestamp_log(stream, "buf_obj_map", buf_obj_map_timestamps); + timestamp_log(stream, "buf_obj_unmap", buf_obj_unmap_timestamps); + timestamp_log(stream, "obtain_lock", obtain_lock_timestamps); + timestamp_log(stream, "release_lock", release_lock_timestamps); + timestamp_log(stream, "release_lock_bulk_transfer", release_lock_bulk_transfer_timestamps); + fclose(stream); + + free(server_timings); + pdc_timestamp_clean(buf_obj_map_timestamps); + pdc_timestamp_clean(buf_obj_unmap_timestamps); + pdc_timestamp_clean(obtain_lock_timestamps); + pdc_timestamp_clean(release_lock_timestamps); + pdc_timestamp_clean(release_lock_bulk_transfer_timestamps); + free(buf_obj_map_timestamps); +} + +#endif + #ifdef ENABLE_MULTITHREAD hg_thread_mutex_t insert_metadata_mutex_g = HG_THREAD_MUTEX_INITIALIZER; @@ -1935,7 +2082,9 @@ buf_map_region_release_bulk_transfer_cb(const struct hg_cb_info *hg_cb_info) #endif FUNC_ENTER(NULL); - +#if PDC_TIMING == 1 + double start = MPI_Wtime(), end; +#endif bulk_args = (struct buf_map_release_bulk_args *)hg_cb_info->arg; if (hg_cb_info->ret == HG_CANCELED) { @@ -2018,6 +2167,11 @@ buf_map_region_release_bulk_transfer_cb(const struct hg_cb_info *hg_cb_info) free(bulk_args); #endif +#if PDC_TIMING == 1 + end = MPI_Wtime(); + server_timings->PDCreg_release_lock_bulk_transfer_rpc += end - start; + pdc_timestamp_register(release_lock_bulk_transfer_timestamps, start, end); +#endif FUNC_LEAVE(ret_value); } @@ -2031,7 +2185,9 @@ obj_map_region_release_bulk_transfer_cb(const struct hg_cb_info *hg_cb_info) struct buf_map_release_bulk_args *bulk_args = NULL; FUNC_ENTER(NULL); - +#if PDC_TIMING == 1 + double start = MPI_Wtime(), end; +#endif bulk_args = (struct buf_map_release_bulk_args *)hg_cb_info->arg; if (hg_cb_info->ret == HG_CANCELED) { @@ -2052,7 +2208,11 @@ obj_map_region_release_bulk_transfer_cb(const struct hg_cb_info *hg_cb_info) HG_Free_input(bulk_args->handle, &(bulk_args->in)); HG_Destroy(bulk_args->handle); free(bulk_args); - +#if PDC_TIMING == 1 + end = MPI_Wtime(); + server_timings->PDCreg_release_lock_bulk_transfer_rpc += end - start; + pdc_timestamp_register(release_lock_bulk_transfer_timestamps, start, end); +#endif FUNC_LEAVE(ret_value); } #endif @@ -2115,9 +2275,14 @@ HG_TEST_RPC_CB(region_release, handle) size_t *data_size_to = NULL; size_t type_size = 0; size_t dims[4] = {0,0,0,0}; +#if PDC_TIMING == 1 + double start, end; +#endif FUNC_ENTER(NULL); - +#if PDC_TIMING == 1 + start = MPI_Wtime(); +#endif // Decode input HG_Get_input(handle, &in); /* Get info from handle */ @@ -2476,7 +2641,6 @@ HG_TEST_RPC_CB(region_release, handle) HG_Destroy(handle); } } - done: /* t = time(NULL); */ /* tm = *localtime(&t); */ @@ -2487,7 +2651,11 @@ HG_TEST_RPC_CB(region_release, handle) HG_Free_input(handle, &in); HG_Destroy(handle); } - +#if PDC_TIMING == 1 + end = MPI_Wtime(); + server_timings->PDCreg_release_lock_rpc += end - start; + pdc_timestamp_register(release_lock_timestamps, start, end); +#endif FUNC_LEAVE(ret_value); } @@ -3282,9 +3450,14 @@ HG_TEST_RPC_CB(region_lock, handle) perr_t ret = SUCCEED; region_lock_in_t in; region_lock_out_t out; +#if PDC_TIMING == 1 + double start, end; +#endif FUNC_ENTER(NULL); - +#if PDC_TIMING == 1 + start = MPI_Wtime(); +#endif HG_Get_input(handle, &in); // Perform lock function @@ -3295,7 +3468,11 @@ HG_TEST_RPC_CB(region_lock, handle) HG_Respond(handle, NULL, NULL, &out); HG_Destroy(handle); } - +#if PDC_TIMING == 1 + end = MPI_Wtime(); + server_timings->PDCreg_obtain_lock_rpc += end - start; + pdc_timestamp_register(obtain_lock_timestamps, start, end); +#endif FUNC_LEAVE(ret_value); } @@ -3308,9 +3485,14 @@ HG_TEST_RPC_CB(buf_unmap, handle) buf_unmap_in_t in; buf_unmap_out_t out; const struct hg_info *info; +#if PDC_TIMING == 1 + double start, end; +#endif FUNC_ENTER(NULL); - +#if PDC_TIMING == 1 + start = MPI_Wtime(); +#endif // Decode input HG_Get_input(handle, &in); info = HG_Get_info(handle); @@ -3332,9 +3514,13 @@ HG_TEST_RPC_CB(buf_unmap, handle) ret = PDC_Meta_Server_buf_unmap(&in, &handle); if (ret != SUCCEED) PGOTO_ERROR(HG_OTHER_ERROR, "===PDC_DATA_SERVER: HG_TEST_RPC_CB(buf_unmap, handle) - PDC_Meta_Server_buf_unmap() failed"); - done: fflush(stdout); +#if PDC_TIMING == 1 + end = MPI_Wtime(); + server_timings->PDCbuf_obj_unmap_rpc += end - start; + pdc_timestamp_register(buf_obj_unmap_timestamps, start, end); +#endif FUNC_LEAVE(ret_value); } @@ -3490,9 +3676,14 @@ HG_TEST_RPC_CB(buf_map, handle) region_buf_map_t *new_buf_map_ptr = NULL; void *data_ptr; size_t ndim; +#if PDC_TIMING == 1 + double start, end; +#endif FUNC_ENTER(NULL); - +#if PDC_TIMING == 1 + start = MPI_Wtime(); +#endif // Decode input HG_Get_input(handle, &in); @@ -3536,7 +3727,11 @@ HG_TEST_RPC_CB(buf_map, handle) if (ret != SUCCEED) PGOTO_ERROR(HG_OTHER_ERROR, "===PDC Data Server: PDC_Meta_Server_buf_map() failed"); } - +#if PDC_TIMING == 1 + end = MPI_Wtime(); + server_timings->PDCbuf_obj_map_rpc += end - start; + pdc_timestamp_register(buf_obj_map_timestamps, start, end); +#endif done: fflush(stdout); FUNC_LEAVE(ret_value); @@ -4241,6 +4436,7 @@ HG_TEST_RPC_CB(cont_add_del_objs_rpc, handle) ret_value = HG_Bulk_transfer(hg_info->context, cont_add_del_objs_bulk_cb, bulk_args, HG_BULK_PULL, hg_info->addr, origin_bulk_handle, 0, local_bulk_handle, 0, bulk_args->nbytes, HG_OP_ID_IGNORE); + if (ret_value != HG_SUCCESS) PGOTO_ERROR(ret_value, "Could not read bulk data"); @@ -5671,6 +5867,7 @@ int PDC_is_contiguous_start_count_overlap(uint32_t ndim, uint64_t *a_start, uint } perr_t PDC_get_overlap_start_count(uint32_t ndim, uint64_t *start_a, uint64_t *count_a, + uint64_t *start_b, uint64_t *count_b, uint64_t *overlap_start, uint64_t *overlap_count) { diff --git a/src/api/pdc_obj.c b/src/api/pdc_obj.c index 237465f2a..4a738b16b 100644 --- a/src/api/pdc_obj.c +++ b/src/api/pdc_obj.c @@ -939,3 +939,13 @@ struct pdc_obj_info *PDCobj_get_info(pdcid_t obj_id) fflush(stdout); FUNC_LEAVE(ret_value); } + +perr_t PDCobj_del(pdcid_t obj_id) +{ + FUNC_ENTER(NULL); + + perr_t ret_value = PDC_Client_del_metadata(obj_id, 0); + +done: + FUNC_LEAVE(ret_value); +} diff --git a/src/api/pdc_obj.h b/src/api/pdc_obj.h index d4c5c6210..81aa2fcb4 100644 --- a/src/api/pdc_obj.h +++ b/src/api/pdc_obj.h @@ -288,7 +288,7 @@ perr_t PDCobj_get_data(pdcid_t obj_id, void *data, uint64_t size); * * \return Non-negative on success/Negative on failure */ -perr_t PDCobj_del_data(pdcid_t obj_id); +perr_t PDCobj_del(pdcid_t obj_id); /** * Add a tag to an object diff --git a/src/api/pdc_timing.h b/src/api/pdc_timing.h new file mode 100644 index 000000000..ac2ad17e5 --- /dev/null +++ b/src/api/pdc_timing.h @@ -0,0 +1,64 @@ +#ifndef PDC_TIMING_H +#define PDC_TIMING_H + +#define PDC_TIMING 0 +#if PDC_TIMING == 1 + +#include +#include +#include +#include + +typedef struct pdc_timing { + double PDCbuf_obj_map_rpc; + double PDCbuf_obj_unmap_rpc; + double PDCreg_obtain_lock_rpc; + double PDCreg_release_lock_rpc; + + double PDCbuf_obj_map_rpc_wait; + double PDCbuf_obj_unmap_rpc_wait; + double PDCreg_obtain_lock_rpc_wait; + double PDCreg_release_lock_rpc_wait; +} pdc_timing; + +pdc_timing timings; + + +typedef struct pdc_server_timing { + double PDCbuf_obj_map_rpc; + double PDCbuf_obj_unmap_rpc; + double PDCreg_obtain_lock_rpc; + double PDCreg_release_lock_rpc; + double PDCreg_release_lock_bulk_transfer_rpc; +} pdc_server_timing; + +typedef struct pdc_timestamp { + double *start; + double *end; + size_t timestamp_max_size; + size_t timestamp_size; +} pdc_timestamp; + +pdc_server_timing *server_timings; +pdc_timestamp *buf_obj_map_timestamps; +pdc_timestamp *buf_obj_unmap_timestamps; +pdc_timestamp *obtain_lock_timestamps; +pdc_timestamp *release_lock_timestamps; +pdc_timestamp *release_lock_bulk_transfer_timestamps; + +pdc_timestamp *client_buf_obj_map_timestamps; +pdc_timestamp *client_buf_obj_unmap_timestamps; +pdc_timestamp *client_obtain_lock_timestamps; +pdc_timestamp *client_release_lock_timestamps; +double base_time; + +int PDC_timing_init(); +int PDC_timing_finalize(); +int PDC_timing_report(const char* prefix); +int PDC_server_timing_init(); +int pdc_timestamp_register(pdc_timestamp *timestamp, double start, double end); +int PDC_server_timing_report(); + +#endif + +#endif diff --git a/src/server/pdc_server.c b/src/server/pdc_server.c index 6786bd205..9ac1b9ae6 100644 --- a/src/server/pdc_server.c +++ b/src/server/pdc_server.c @@ -53,6 +53,7 @@ #include "pdc_server.h" #include "pdc_server_metadata.h" #include "pdc_server_data.h" +#include "pdc_timing.h" #ifdef PDC_HAS_CRAY_DRC # include @@ -1818,7 +1819,9 @@ int main(int argc, char *argv[]) printf("==PDC_SERVER[%d]: Error with Mercury init\n", pdc_server_rank_g); goto done; } - +#if PDC_TIMING == 1 + PDC_server_timing_init(); +#endif // Register Mercury RPC/bulk PDC_Server_mercury_register(); @@ -1877,6 +1880,9 @@ int main(int argc, char *argv[]) #endif done: +#if PDC_TIMING == 1 + PDC_server_timing_report(); +#endif PDC_Server_finalize(); #ifdef ENABLE_MPI MPI_Finalize(); diff --git a/src/server/pdc_server_data.c b/src/server/pdc_server_data.c index d5db307f2..530ac0d12 100644 --- a/src/server/pdc_server_data.c +++ b/src/server/pdc_server_data.c @@ -4464,7 +4464,8 @@ perr_t PDC_Server_data_read_from(uint64_t obj_id, struct pdc_region_info *region if (storage_region) { if(region_info->ndim == 1) { - read_bytes = pread(region->fd, buf, unit*(region_info->size[0]), storage_region->offset+region_info->offset[0]); + /* printf("storage offset %llu, region offset %llu\n", storage_region->offset, region_info->offset[0]*unit); */ + read_bytes = pread(region->fd, buf, unit*(region_info->size[0]), storage_region->offset+region_info->offset[0]*unit); } else if(region_info->ndim == 2) { void *tmp_buf = malloc(storage_region->data_size); @@ -4473,7 +4474,7 @@ perr_t PDC_Server_data_read_from(uint64_t obj_id, struct pdc_region_info *region // Extract requested data uint64_t pos = 0; for (int i = region_info->offset[0]; i < region_info->offset[0]+region_info->size[0]; i++) { - memcpy(buf+pos, tmp_buf + i*storage_region->count[1]*unit+region_info->offset[1], region_info->size[1]*unit); + memcpy(buf+pos, tmp_buf + i*storage_region->count[1]*unit+region_info->offset[1]*unit, region_info->size[1]*unit); pos += region_info->size[1]*unit; } free(tmp_buf); @@ -4490,7 +4491,7 @@ perr_t PDC_Server_data_read_from(uint64_t obj_id, struct pdc_region_info *region /* i*storage_region->count[2]*storage_region->count[1]*unit +j*storage_region->count[2]*unit+region_info->offset[2], */ /* region_info->size[2]*unit, storage_region->data_size); */ memcpy(buf+pos, tmp_buf + i*storage_region->count[2]*storage_region->count[1]*unit + - j*storage_region->count[2]*unit+region_info->offset[2], region_info->size[2]*unit); + j*storage_region->count[2]*unit+region_info->offset[2]*unit, region_info->size[2]*unit); pos += region_info->size[2]*unit; } } diff --git a/src/server/pdc_server_metadata.c b/src/server/pdc_server_metadata.c index b2d03e5d6..0513592f4 100644 --- a/src/server/pdc_server_metadata.c +++ b/src/server/pdc_server_metadata.c @@ -935,7 +935,29 @@ perr_t PDC_Server_delete_metadata_by_id(metadata_delete_by_id_in_t *in, metadata hg_thread_mutex_lock(&pdc_metadata_hash_table_mutex_g); #endif - if (metadata_hash_table_g != NULL) { + + if (container_hash_table_g != NULL) { + pdc_cont_hash_table_entry_t *cont_entry; + + // Since we only have the obj id, need to iterate the entire hash table + n_entry = hash_table_num_entries(container_hash_table_g); + hash_table_iterate(container_hash_table_g, &hash_table_iter); + + while (n_entry != 0 && hash_table_iter_has_more(&hash_table_iter)) { + pair = hash_table_iter_next(&hash_table_iter); + cont_entry = pair.value; + if (cont_entry == NULL) + continue; + + if (cont_entry->cont_id == target_obj_id) { + hash_table_remove(container_hash_table_g, &pair.key); + out->ret = 1; + ret_value = SUCCEED; + goto done; + } + } + } + if (out->ret == -1 && metadata_hash_table_g != NULL) { // Since we only have the obj id, need to iterate the entire hash table pdc_hash_table_entry_head *head; @@ -981,6 +1003,7 @@ perr_t PDC_Server_delete_metadata_by_id(metadata_delete_by_id_in_t *in, metadata goto done; } +done: #ifdef ENABLE_MULTITHREAD // ^ Release hash table lock hg_thread_mutex_unlock(&pdc_metadata_hash_table_mutex_g); @@ -1014,7 +1037,6 @@ perr_t PDC_Server_delete_metadata_by_id(metadata_delete_by_id_in_t *in, metadata hg_thread_mutex_unlock(&n_metadata_mutex_g); #endif -done: #ifdef ENABLE_MULTITHREAD if (unlocked == 0) hg_thread_mutex_unlock(&pdc_metadata_hash_table_mutex_g); diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 2020af883..1b149b64a 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -16,15 +16,18 @@ set(PROGRAMS write_obj write_obj_shared create_cont + create_cont_coll open_cont cont_life cont_iter cont_info + cont_del cont_getid cont_tags create_obj open_obj obj_info + obj_del obj_iter obj_life obj_dim @@ -32,11 +35,16 @@ set(PROGRAMS obj_tags obj_put_data obj_get_data + read_write_perf + read_write_col_perf open_obj_round_robin + region_obj_map region_obj_map_2D region_obj_map_3D + region_obj_map_partial + region_obj_map_2D_partial + region_obj_map_3D_partial obj_round_robin_io - region_obj_map create_obj_scale close_server update_obj @@ -134,7 +142,9 @@ add_test(NAME cont_iter WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTO 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 cont_del WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./cont_del ) add_test(NAME create_obj WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./create_obj ) +add_test(NAME obj_del WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./obj_del ) 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 ) @@ -148,6 +158,9 @@ add_test(NAME create_region WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTO 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 region_obj_map_partial WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./region_obj_map_partial ) +add_test(NAME region_obj_map_2D_partial WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./region_obj_map_2D_partial ) +add_test(NAME region_obj_map_3D_partial WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_test.sh ./region_obj_map_3D_partial ) 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) @@ -171,7 +184,9 @@ set_tests_properties(cont_iter PROPERTIES LABELS serial ) set_tests_properties(cont_info PROPERTIES LABELS serial ) set_tests_properties(cont_getid PROPERTIES LABELS serial ) set_tests_properties(cont_tags PROPERTIES LABELS serial ) +set_tests_properties(cont_del PROPERTIES LABELS serial ) set_tests_properties(create_obj PROPERTIES LABELS serial ) +set_tests_properties(obj_del PROPERTIES LABELS serial ) set_tests_properties(open_obj PROPERTIES LABELS serial ) set_tests_properties(obj_iter PROPERTIES LABELS serial ) set_tests_properties(obj_life PROPERTIES LABELS serial ) @@ -185,6 +200,9 @@ set_tests_properties(create_region PROPERTIES LABELS serial ) set_tests_properties(region_obj_map PROPERTIES LABELS serial ) set_tests_properties(region_obj_map_2D PROPERTIES LABELS serial ) set_tests_properties(region_obj_map_3D PROPERTIES LABELS serial ) +set_tests_properties(region_obj_map_partial PROPERTIES LABELS serial ) +set_tests_properties(region_obj_map_2D_partial PROPERTIES LABELS serial ) +set_tests_properties(region_obj_map_3D_partial PROPERTIES LABELS serial ) set_tests_properties(write_obj_int PROPERTIES LABELS serial ) set_tests_properties(write_obj_float PROPERTIES LABELS serial ) set_tests_properties(write_obj_double PROPERTIES LABELS serial ) @@ -217,6 +235,7 @@ if(BUILD_MPI_TESTING) add_test(NAME write_obj_shared_int16 WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./write_obj_shared ${MPI_RUN_CMD} 2 2 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 2 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 2 ) + add_test(NAME create_cont_coll WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./create_cont_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 2 ) 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 2 ) 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 2 ) diff --git a/src/tests/cont_del.c b/src/tests/cont_del.c new file mode 100644 index 000000000..b8e71dfe1 --- /dev/null +++ b/src/tests/cont_del.c @@ -0,0 +1,95 @@ +/* + * 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_prop, cont; + int rank = 0, size = 1; + perr_t ret; + + int ret_value = 0; + char cont_name[128]; + +#ifdef ENABLE_MPI + MPI_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); +#endif + sprintf(cont_name, "c%d", rank); + // create a pdc + pdc = PDCinit("pdc"); + printf("create a new pdc\n"); + + // create a container property + create_prop = PDCprop_create(PDC_CONT_CREATE, pdc); + if(create_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(cont_name, create_prop); + if(cont > 0) { + printf("Create a container c1\n"); + } else { + printf("Fail to create container @ line %d!\n", __LINE__); + ret_value = 1; + } + ret = PDCcont_del(cont); + if (ret != SUCCEED) { + printf("Fail to delete container @ line %d!\n", __LINE__); + 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(create_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_coll.c b/src/tests/create_cont_coll.c new file mode 100644 index 000000000..3287486c2 --- /dev/null +++ b/src/tests/create_cont_coll.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_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); + MPI_Comm_size(MPI_COMM_WORLD, &size); +#endif + + // create a pdc + pdc = PDCinit("pdc"); + printf("create a new pdc\n"); + + // create a container property + create_prop = PDCprop_create(PDC_CONT_CREATE, pdc); + if(create_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_col("c1", create_prop); + if(cont > 0) { + printf("Create a container c1\n"); + } else { + printf("Fail to create container @ line %d!\n", __LINE__); + 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(create_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/kvtag_add_get.c b/src/tests/kvtag_add_get.c index e0ac38419..d56520296 100644 --- a/src/tests/kvtag_add_get.c +++ b/src/tests/kvtag_add_get.c @@ -111,17 +111,17 @@ int main() { else printf("successfully added a kvtag to o1\n"); - if (PDCobj_get_tag(obj1, kvtag1.name, &value1, &value_size) < 0) + if (PDCobj_get_tag(obj1, kvtag1.name, (void*)&value1, (void*)&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 (PDCobj_get_tag(obj2, kvtag2.name, &value2, &value_size) < 0) + if (PDCobj_get_tag(obj2, kvtag2.name, (void*)&value2, (void*)&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 (PDCobj_get_tag(obj2, kvtag3.name, &value3, &value_size) < 0) + if (PDCobj_get_tag(obj2, kvtag3.name, (void*)&value3, (void*)&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); @@ -141,7 +141,7 @@ int main() { PDC_free_kvtag(&value1); - if (PDCobj_get_tag(obj1, kvtag1.name, &value1, &value_size) < 0) + if (PDCobj_get_tag(obj1, kvtag1.name, (void*)&value1, (void*)&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 b9971aed1..dc08caa71 100644 --- a/src/tests/kvtag_add_get_scale.c +++ b/src/tests/kvtag_add_get_scale.c @@ -161,7 +161,7 @@ int main(int argc, char *argv[]) stime = MPI_Wtime(); #endif for (i = 0; i < my_query; i++) { - if (PDCobj_get_tag(obj_ids[i], kvtag.name, &values[i], &value_size) < 0) + if (PDCobj_get_tag(obj_ids[i], kvtag.name, (void*)&values[i], (void*)&value_size) < 0) printf("fail to get a kvtag from o%d\n", i+my_query_s); } diff --git a/src/tests/kvtag_get.c b/src/tests/kvtag_get.c index 2e31dc326..55aee141f 100644 --- a/src/tests/kvtag_get.c +++ b/src/tests/kvtag_get.c @@ -80,24 +80,24 @@ int main() { else printf("Fail to create object @ line %d!\n", __LINE__); - if (PDCobj_get_tag(obj1, "key1string", &value1, &value_size) < 0) + if (PDCobj_get_tag(obj1, "key1string", (void*)&value1, (void*)&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 (PDCobj_get_tag(obj2, "key2int", &value2, &value_size) < 0) + if (PDCobj_get_tag(obj2, "key2int", (void*)&value2, (void*)&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 (PDCobj_get_tag(obj2, "key3double", &value3, &value_size) < 0) + if (PDCobj_get_tag(obj2, "key3double", (void*)&value3, (void*)&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 (PDCobj_get_tag(obj1, "key1string", &value1, &value_size) < 0) + if (PDCobj_get_tag(obj1, "key1string", (void*)&value1, (void*)&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_scale.c b/src/tests/kvtag_query_scale.c index 9c80f665c..addae12bf 100644 --- a/src/tests/kvtag_query_scale.c +++ b/src/tests/kvtag_query_scale.c @@ -157,9 +157,8 @@ int main(int argc, char *argv[]) #ifdef ENABLE_MPI MPI_Barrier(MPI_COMM_WORLD); -#endif - stime = MPI_Wtime(); +#endif if (PDC_Client_query_kvtag_col(&kvtag, &nres, &pdc_ids) < 0) { printf("fail to query kvtag [%s] with rank %d\n", kvtag.name, my_rank); @@ -169,8 +168,8 @@ int main(int argc, char *argv[]) #ifdef ENABLE_MPI MPI_Barrier(MPI_COMM_WORLD); MPI_Reduce(&nres, &ntotal, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD); -#endif total_time = MPI_Wtime() - stime; +#endif if (my_rank == 0) printf("Total time to query %d objects with tag: %.4f\n", ntotal, total_time); diff --git a/src/tests/obj_del.c b/src/tests/obj_del.c new file mode 100644 index 000000000..c4b2a4a5b --- /dev/null +++ b/src/tests/obj_del.c @@ -0,0 +1,137 @@ +/* + * 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) { + 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) { + 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; + } + // 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; + } + + if (PDCobj_del(obj1) != SUCCEED) { + printf("Fail to delete object @ line %d!\n", __LINE__); + } + + if (PDCobj_del(obj2) != SUCCEED) { + printf("Fail to delete object @ line %d!\n", __LINE__); + } + + // close first object + if(PDCobj_close(obj1) < 0) { + printf("fail to close object o1\n"); + ret_value = 1; + } else { + printf("successfully close object o1\n"); + } + // close second object + 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/open_obj.c b/src/tests/open_obj.c index 849322862..867c2dd8a 100644 --- a/src/tests/open_obj.c +++ b/src/tests/open_obj.c @@ -108,7 +108,7 @@ int main(int argc, char **argv) { printf("Rank %d Fail to open object o2\n", rank); ret_value = 1; } else { - printf("Rank %d Open object o2\n"); + printf("Rank %d Open object o2\n", rank); } // close object if(PDCobj_close(obj1) < 0) { diff --git a/src/tests/read_write_col_perf.c b/src/tests/read_write_col_perf.c new file mode 100644 index 000000000..70ecc215e --- /dev/null +++ b/src/tests/read_write_col_perf.c @@ -0,0 +1,385 @@ +/* + * 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" +#include "pdc_analysis.h" +#include "pdc_timing.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; + char cont_name[128], obj_name1[128]; + + int rank = 0, size = 1, i, ndim = 0, ret_value = 0; + + uint64_t offset[3], offset_length[3], local_offset[3], dims[3]; + int data_size, data_size_array[3], n_objects; +#ifdef ENABLE_MPI + double start, write_buf_map_time = 0, write_lock_time = 0, write_release_time = 0, write_unbuf_map_time = 0, read_buf_map_time = 0, read_lock_time = 0, read_release_time = 0, read_unbuf_map_time = 0; +#endif +#ifdef ENABLE_MPI + MPI_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); +#endif + + data_size_array[0] = 0; + data_size_array[1] = 0; + data_size_array[2] = 0; + + if ( argc == 3 ) { + ndim = 1; + } else if (argc == 4) { + ndim = 2; + } else if (argc == 5) { + ndim = 3; + } else { + printf("usage: ./read_write_perf n_objects data_size1 datasize2 datasize3 @ line %d\n", __LINE__); + } + + local_offset[0] = 0; + data_size_array[0] = atoi(argv[2]); + if ( ndim == 1 ) { + offset[0] = rank * data_size_array[0] * 1048576; + offset_length[0] = data_size_array[0] * 1048576; + data_size = data_size_array[0] * 1048576; + } else { + offset[0] = rank * data_size_array[0]; + offset_length[0] = data_size_array[0]; + data_size = data_size_array[0]; + } + if ( ndim == 2 ) { + local_offset[1] = 0; + offset[1] = 0; + data_size_array[1] = atoi(argv[3]); + offset_length[1] = data_size_array[1] * 1048576; + data_size *= data_size_array[1] * 1048576; + } else if ( ndim == 3 ) { + local_offset[1] = 0; + offset[1] = 0; + data_size_array[1] = atoi(argv[3]); + offset_length[1] = data_size_array[1]; + + local_offset[2] = 0; + offset[2] = 0; + data_size_array[2] = atoi(argv[4]); + offset_length[2] = data_size_array[2] * 1048576; + data_size *= (data_size_array[1] * data_size_array[2] * 1048576); + } + n_objects = atoi(argv[1]); + int *data = (int*)malloc(sizeof(int)*data_size); + int *data_read = (int*)malloc(sizeof(int)*data_size); + int *obj_data = (int *)calloc(data_size, sizeof(int)); + + memcpy(dims, offset_length, sizeof(uint64_t) * ndim); + + if ( rank == 0 ) { + printf("number of dimensions in this test is %d\n", ndim); + printf("data size = %llu\n", (long long unsigned) data_size ); + printf("first dim has size %d\n", data_size_array[0]); + if ( ndim >= 2 ) { + printf("second dim has size %d\n", data_size_array[1]); + } + if ( ndim == 3) { + printf("third dim has size %d\n", data_size_array[2]); + } + } + + // create a pdc + pdc = PDCinit("pdc"); + + // 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; + } + + 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"); + + for ( i = 0; i < n_objects; ++i ) { + // create first object + sprintf(obj_name1, "o1_%d", i); + + //obj1 = PDCobj_create(cont, obj_name1, obj_prop); + obj1 = PDCobj_create_mpi(cont, obj_name1, obj_prop, 0, MPI_COMM_WORLD); + + if(obj1<= 0) { + printf("Fail to create object @ line %d!\n", __LINE__); + ret_value = 1; + } + + reg = PDCregion_create(ndim, local_offset, offset_length); + reg_global = PDCregion_create(ndim, offset, offset_length); + + + memset(data, (char) i, sizeof(int) * data_size); + MPI_Barrier(MPI_COMM_WORLD); +#ifdef ENABLE_MPI + start = MPI_Wtime(); +#endif + ret = PDCbuf_obj_map(data, PDC_INT, reg, obj1, reg_global); +#ifdef ENABLE_MPI + write_buf_map_time += MPI_Wtime() - start; +#endif + if(ret != SUCCEED) { + printf("PDCbuf_obj_map failed @ line %d\n", __LINE__); + ret_value = 1; + } +#ifdef ENABLE_MPI + start = MPI_Wtime(); +#endif + ret = PDCreg_obtain_lock(obj1, reg_global, PDC_WRITE, PDC_BLOCK); +#ifdef ENABLE_MPI + write_lock_time += MPI_Wtime() - start; +#endif + if(ret != SUCCEED) { + printf("PDCreg_obtain_lock failed @ line %d\n", __LINE__); + exit(-1); + } +#ifdef ENABLE_MPI + start = MPI_Wtime(); +#endif + ret = PDCreg_release_lock(obj1, reg_global, PDC_WRITE); +#ifdef ENABLE_MPI + write_release_time += MPI_Wtime() - start; +#endif + if(ret != SUCCEED) { + printf("PDCreg_release_lock failed @ line %d\n", __LINE__); + ret_value = 1; + } +#ifdef ENABLE_MPI + start = MPI_Wtime(); +#endif + ret = PDCbuf_obj_unmap(obj1, reg_global); +#ifdef ENABLE_MPI + write_unbuf_map_time += MPI_Wtime() - start; +#endif + if(ret != SUCCEED) { + printf("PDCbuf_obj_unmap failed @ line %d\n", __LINE__); + ret_value = 1; + } + + if(PDCregion_close(reg) < 0) { + printf("fail to close local region @ line %d\n", __LINE__); + ret_value = 1; + } + + if(PDCregion_close(reg_global) < 0) { + printf("fail to close global region @ line %d\n", __LINE__); + ret_value = 1; + } + if(PDCobj_close(obj1) < 0) { + printf("fail to close object o1 @ line %d\n", __LINE__); + ret_value = 1; + } + } +#if PDC_TIMING == 1 + MPI_Barrier(MPI_COMM_WORLD); + PDC_timing_report("write"); +#endif + for ( i = 0; i < n_objects; ++i ) { + sprintf(obj_name1, "o1_%d", i); + obj1 = PDCobj_open(obj_name1, pdc); + if(obj1 <= 0) { + printf("Fail to open object @ line %d!\n", __LINE__); + ret_value = 1; + } + + reg = PDCregion_create(ndim, local_offset, offset_length); + reg_global = PDCregion_create(ndim, offset, offset_length); + + memset(data, 0, sizeof(int) * data_size); + MPI_Barrier(MPI_COMM_WORLD); +#ifdef ENABLE_MPI + start = MPI_Wtime(); +#endif + ret = PDCbuf_obj_map(data_read, PDC_INT, reg, obj1, reg_global); +#ifdef ENABLE_MPI + read_buf_map_time += MPI_Wtime() - start; +#endif + if(ret != SUCCEED) { + printf("PDCbuf_obj_map failed @ line %d\n", __LINE__); + ret_value = 1; + } +#ifdef ENABLE_MPI + start = MPI_Wtime(); +#endif + ret = PDCreg_obtain_lock(obj1, reg_global, PDC_READ, PDC_BLOCK); +#ifdef ENABLE_MPI + read_lock_time += MPI_Wtime() - start; +#endif + if(ret != SUCCEED) { + printf("PDCreg_obtain_lock failed @ line %d\n", __LINE__); + ret_value = 1; + } +#ifdef ENABLE_MPI + start = MPI_Wtime(); +#endif + ret = PDCreg_release_lock(obj1, reg_global, PDC_READ); +#ifdef ENABLE_MPI + read_release_time += MPI_Wtime() - start; +#endif + if(ret != SUCCEED) { + printf("PDCreg_release_lock failed @ line %d\n", __LINE__); + ret_value = 1; + } +#ifdef ENABLE_MPI + start = MPI_Wtime(); +#endif + ret = PDCbuf_obj_unmap(obj1, reg_global); +#ifdef ENABLE_MPI + read_unbuf_map_time += MPI_Wtime() - start; +#endif + if(ret != SUCCEED) { + printf("PDCbuf_obj_unmap failed @ line %d\n", __LINE__); + ret_value = 1; + } + + if(PDCregion_close(reg) < 0) { + printf("fail to close local region @ line %d\n", __LINE__); + ret_value = 1; + } + + if(PDCregion_close(reg_global) < 0) { + printf("fail to close global region @ line %d\n", __LINE__); + ret_value = 1; + } + + if(PDCobj_close(obj1) < 0) { + printf("fail to close object o1 @ line %d\n", __LINE__); + ret_value = 1; + } + } +#if PDC_TIMING == 1 + PDC_timing_report("read"); +#endif + // close a container + if(PDCcont_close(cont) < 0) { + printf("fail to close container c1 @ line %d\n", __LINE__); + ret_value = 1; + } + // close a object property + if(PDCprop_close(obj_prop) < 0) { + printf("Fail to close property @ line %d\n", __LINE__); + 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; + } + // close pdc + if(PDCclose(pdc) < 0) { + printf("fail to close PDC @ line %d\n", __LINE__); + ret_value = 1; + } +#ifdef ENABLE_MPI + MPI_Reduce(&write_buf_map_time, &start, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD); + write_buf_map_time = start; + if (!rank) { + printf("write buf map obj time: %lf\n", write_buf_map_time); + } + MPI_Reduce(&write_lock_time, &start, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD); + write_lock_time = start; + if (!rank) { + printf("write lock obtain time: %lf\n", write_lock_time); + } + + MPI_Reduce(&write_release_time, &start, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD); + write_release_time = start; + if (!rank) { + printf("write lock release time: %lf\n", write_release_time); + } + + MPI_Reduce(&write_unbuf_map_time, &start, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD); + write_unbuf_map_time = start; + if (!rank) { + printf("write buf unmap obj time: %lf\n", write_unbuf_map_time); + } + + MPI_Reduce(&read_buf_map_time, &start, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD); + read_buf_map_time = start; + if (!rank) { + printf("read buf map obj time: %lf\n", read_buf_map_time); + } + MPI_Reduce(&read_lock_time, &start, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD); + read_lock_time = start; + if (!rank) { + printf("read lock obtain time: %lf\n", read_lock_time); + } + + MPI_Reduce(&read_release_time, &start, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD); + read_release_time = start; + if (!rank) { + printf("read lock release time: %lf\n", read_release_time); + } + + MPI_Reduce(&read_unbuf_map_time, &start, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD); + read_unbuf_map_time = start; + if (!rank) { + printf("read buf unmap obj time: %lf\n", read_unbuf_map_time); + } +#endif +#ifdef ENABLE_MPI + MPI_Finalize(); +#endif + return ret_value; +} diff --git a/src/tests/read_write_perf.c b/src/tests/read_write_perf.c new file mode 100644 index 000000000..64386909a --- /dev/null +++ b/src/tests/read_write_perf.c @@ -0,0 +1,368 @@ +/* + * 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" +#include "pdc_analysis.h" + +#include "pdc_timing.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; + char cont_name[128], obj_name1[128]; + + int rank = 0, size = 1, i, ndim = 0, ret_value = 0; + + uint64_t offset[3], offset_length[3], local_offset[3], dims[3]; + int data_size, data_size_array[3], n_objects; +#ifdef ENABLE_MPI + double start, write_buf_map_time = 0, write_lock_time = 0, write_release_time = 0, write_unbuf_map_time = 0, read_buf_map_time = 0, read_lock_time = 0, read_release_time = 0, read_unbuf_map_time = 0; +#endif + data_size_array[0] = 0; + data_size_array[1] = 0; + data_size_array[2] = 0; + + if ( argc == 3 ) { + ndim = 1; + } else if (argc == 4) { + ndim = 2; + } else if (argc == 5) { + ndim = 3; + } else { + printf("usage: ./read_write_perf n_objects data_size1 datasize2 datasize3 @ line %d\n", __LINE__); + } + + local_offset[0] = 0; + offset[0] = 0; + data_size_array[0] = atoi(argv[2]); + if ( ndim == 1 ) { + offset_length[0] = data_size_array[0] * 1048576; + data_size = data_size_array[0] * 1048576; + } else { + offset_length[0] = data_size_array[0]; + data_size = data_size_array[0]; + } + if ( ndim == 2 ) { + local_offset[1] = 0; + offset[1] = 0; + data_size_array[1] = atoi(argv[3]); + offset_length[1] = data_size_array[1] * 1048576; + data_size *= data_size_array[1] * 1048576; + } else if ( ndim == 3 ) { + local_offset[1] = 0; + offset[1] = 0; + data_size_array[1] = atoi(argv[3]); + offset_length[1] = data_size_array[1]; + + local_offset[2] = 0; + offset[2] = 0; + data_size_array[2] = atoi(argv[4]); + offset_length[2] = data_size_array[2] * 1048576; + data_size *= (data_size_array[1] * data_size_array[2] * 1048576); + } + n_objects = atoi(argv[1]); + int *data = (int*)malloc(sizeof(int)*data_size); + int *data_read = (int*)malloc(sizeof(int)*data_size); + int *obj_data = (int *)calloc(data_size, sizeof(int)); + + memcpy(dims, offset_length, sizeof(uint64_t) * ndim); +#ifdef ENABLE_MPI + MPI_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); +#endif + char hostname[256]; + gethostname(hostname, 256); + printf("Client program read_write_perf Rank %d at hostname %s\n", rank, hostname); + if ( rank == 0 ) { + printf("number of dimensions in this test is %d\n", ndim); + printf("data size = %llu\n", (long long unsigned) data_size ); + printf("first dim has size %d\n", data_size_array[0]); + if ( ndim >= 2 ) { + printf("second dim has size %d\n", data_size_array[1]); + } + if ( ndim == 3) { + printf("third dim has size %d\n", data_size_array[2]); + } + } + + // create a pdc + pdc = PDCinit("pdc"); + + // 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; + } + + 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"); + + for ( i = 0; i < n_objects; ++i ) { + // create first object + sprintf(obj_name1, "o1_%d_%d", rank, i); + obj1 = PDCobj_create(cont, obj_name1, obj_prop); + if(obj1<= 0) { + printf("Fail to create object @ line %d!\n", __LINE__); + ret_value = 1; + } + + reg = PDCregion_create(ndim, offset, offset_length); + reg_global = PDCregion_create(ndim, offset, offset_length); + + + memset(data, (char) i, sizeof(int) * data_size); + MPI_Barrier(MPI_COMM_WORLD); +#ifdef ENABLE_MPI + start = MPI_Wtime(); + ret = PDCbuf_obj_map(data, PDC_INT, reg, obj1, reg_global); + write_buf_map_time += MPI_Wtime() - start; +#endif + if(ret != SUCCEED) { + printf("PDCbuf_obj_map failed @ line %d\n", __LINE__); + ret_value = 1; + } +#ifdef ENABLE_MPI + start = MPI_Wtime(); + ret = PDCreg_obtain_lock(obj1, reg_global, PDC_WRITE, PDC_BLOCK); + write_lock_time += MPI_Wtime() - start; +#endif + if(ret != SUCCEED) { + printf("PDCreg_obtain_lock failed @ line %d\n", __LINE__); + exit(-1); + } +#ifdef ENABLE_MPI + start = MPI_Wtime(); + ret = PDCreg_release_lock(obj1, reg_global, PDC_WRITE); + write_release_time += MPI_Wtime() - start; +#endif + if(ret != SUCCEED) { + printf("PDCreg_release_lock failed @ line %d\n", __LINE__); + ret_value = 1; + } +#ifdef ENABLE_MPI + start = MPI_Wtime(); + ret = PDCbuf_obj_unmap(obj1, reg_global); + write_unbuf_map_time += MPI_Wtime() - start; +#endif + if(ret != SUCCEED) { + printf("PDCbuf_obj_unmap failed @ line %d\n", __LINE__); + ret_value = 1; + } + + if(PDCregion_close(reg) < 0) { + printf("fail to close local region @ line %d\n", __LINE__); + ret_value = 1; + } + + if(PDCregion_close(reg_global) < 0) { + printf("fail to close global region @ line %d\n", __LINE__); + ret_value = 1; + } + if(PDCobj_close(obj1) < 0) { + printf("fail to close object o1 @ line %d\n", __LINE__); + ret_value = 1; + } + } +#if PDC_TIMING == 1 + MPI_Barrier(MPI_COMM_WORLD); + PDC_timing_report("write"); +#endif + for ( i = 0; i < n_objects; ++i ) { + sprintf(obj_name1, "o1_%d_%d", rank, i); + obj1 = PDCobj_open(obj_name1, pdc); + if(obj1 <= 0) { + printf("Fail to open object @ line %d!\n", __LINE__); + ret_value = 1; + } + + reg = PDCregion_create(ndim, local_offset, offset_length); + reg_global = PDCregion_create(ndim, offset, offset_length); + + memset(data, 0, sizeof(int) * data_size); + MPI_Barrier(MPI_COMM_WORLD); +#ifdef ENABLE_MPI + start = MPI_Wtime(); + ret = PDCbuf_obj_map(data_read, PDC_INT, reg, obj1, reg_global); + read_buf_map_time += MPI_Wtime() - start; +#endif + if(ret != SUCCEED) { + printf("PDCbuf_obj_map failed @ line %d\n", __LINE__); + ret_value = 1; + } +#ifdef ENABLE_MPI + start = MPI_Wtime(); + ret = PDCreg_obtain_lock(obj1, reg_global, PDC_READ, PDC_BLOCK); + read_lock_time += MPI_Wtime() - start; +#endif + if(ret != SUCCEED) { + printf("PDCreg_obtain_lock failed @ line %d\n", __LINE__); + ret_value = 1; + } +#ifdef ENABLE_MPI + start = MPI_Wtime(); + ret = PDCreg_release_lock(obj1, reg_global, PDC_READ); + read_release_time += MPI_Wtime() - start; +#endif + if(ret != SUCCEED) { + printf("PDCreg_release_lock failed @ line %d\n", __LINE__); + ret_value = 1; + } +#ifdef ENABLE_MPI + start = MPI_Wtime(); + ret = PDCbuf_obj_unmap(obj1, reg_global); + read_unbuf_map_time += MPI_Wtime() - start; +#endif + if(ret != SUCCEED) { + printf("PDCbuf_obj_unmap failed @ line %d\n", __LINE__); + ret_value = 1; + } + + if(PDCregion_close(reg) < 0) { + printf("fail to close local region @ line %d\n", __LINE__); + ret_value = 1; + } + + if(PDCregion_close(reg_global) < 0) { + printf("fail to close global region @ line %d\n", __LINE__); + ret_value = 1; + } + + if(PDCobj_close(obj1) < 0) { + printf("fail to close object o1 @ line %d\n", __LINE__); + ret_value = 1; + } + } +#if PDC_TIMING == 1 + PDC_timing_report("read"); +#endif + // close a container + if(PDCcont_close(cont) < 0) { + printf("fail to close container c1 @ line %d\n", __LINE__); + ret_value = 1; + } + // close a object property + if(PDCprop_close(obj_prop) < 0) { + printf("Fail to close property @ line %d\n", __LINE__); + 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; + } + // close pdc + if(PDCclose(pdc) < 0) { + printf("fail to close PDC @ line %d\n", __LINE__); + ret_value = 1; + } +#ifdef ENABLE_MPI + MPI_Reduce(&write_buf_map_time, &start, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD); + write_buf_map_time = start; + if (!rank) { + printf("write buf map obj time: %lf\n", write_buf_map_time); + } + MPI_Reduce(&write_lock_time, &start, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD); + write_lock_time = start; + if (!rank) { + printf("write lock obtain time: %lf\n", write_lock_time); + } + + MPI_Reduce(&write_release_time, &start, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD); + write_release_time = start; + if (!rank) { + printf("write lock release time: %lf\n", write_release_time); + } + + MPI_Reduce(&write_unbuf_map_time, &start, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD); + write_unbuf_map_time = start; + if (!rank) { + printf("write buf unmap obj time: %lf\n", write_unbuf_map_time); + } + + MPI_Reduce(&read_buf_map_time, &start, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD); + read_buf_map_time = start; + if (!rank) { + printf("read buf map obj time: %lf\n", read_buf_map_time); + } + MPI_Reduce(&read_lock_time, &start, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD); + read_lock_time = start; + if (!rank) { + printf("read lock obtain time: %lf\n", read_lock_time); + } + + MPI_Reduce(&read_release_time, &start, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD); + read_release_time = start; + if (!rank) { + printf("read lock release time: %lf\n", read_release_time); + } + + MPI_Reduce(&read_unbuf_map_time, &start, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD); + read_unbuf_map_time = start; + if (!rank) { + printf("read buf unmap obj time: %lf\n", read_unbuf_map_time); + } +#endif +#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 index 586197782..a1325be96 100644 --- a/src/tests/region_obj_map_2D.c +++ b/src/tests/region_obj_map_2D.c @@ -144,13 +144,13 @@ int main(int argc, char **argv) { data[i] = i; } - ret = PDCreg_obtain_lock(obj1, reg, PDC_WRITE, PDC_BLOCK); + ret = PDCreg_obtain_lock(obj1, reg_global, PDC_WRITE, PDC_BLOCK); if(ret != SUCCEED) { printf("PDCreg_obtain_lock failed\n"); exit(-1); } - ret = PDCreg_release_lock(obj1, reg, PDC_WRITE); + ret = PDCreg_release_lock(obj1, reg_global, PDC_WRITE); if(ret != SUCCEED) { printf("PDCreg_release_lock failed\n"); ret_value = 1; @@ -201,6 +201,20 @@ int main(int argc, char **argv) { } } + if(PDCregion_close(reg) < 0) { + printf("fail to close local region\n"); + ret_value = 1; + } else { + printf("successfully local region\n"); + } + + if(PDCregion_close(reg_global) < 0) { + printf("fail to close global region\n"); + ret_value = 1; + } else { + printf("successfully global region\n"); + } + // close object if(PDCobj_close(obj1) < 0) { diff --git a/src/tests/region_obj_map_2D_partial.c b/src/tests/region_obj_map_2D_partial.c new file mode 100644 index 000000000..988c4bfeb --- /dev/null +++ b/src/tests/region_obj_map_2D_partial.c @@ -0,0 +1,276 @@ +/* + * 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 32 + + +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); + offset[0] = 0; + offset[1] = 0; + offset_length[0] = BUF_LEN/2; + offset_length[1] = 2; + reg = PDCregion_create(ndim, offset, offset_length); + offset[0] = 0; + offset[1] = 0; + offset_length[0] = BUF_LEN/2; + offset_length[1] = 2; + 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_global, PDC_WRITE, PDC_BLOCK); + if(ret != SUCCEED) { + printf("PDCreg_obtain_lock failed\n"); + exit(-1); + } + + ret = PDCreg_release_lock(obj1, reg_global, 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); + offset[0] = 0; + offset_length[0] = BUF_LEN/2; + reg = PDCregion_create(1, offset, offset_length); + offset[0] = 0; + offset[1] = 1; + offset_length[0] = BUF_LEN/2; + offset_length[1] = 1; + reg_global = PDCregion_create(ndim, offset, offset_length); + + memset(data_read, 0, BUF_LEN); + + 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_global, PDC_READ, PDC_BLOCK); + if(ret != SUCCEED) { + printf("PDCreg_obtain_lock failed\n"); + ret_value = 1; + } + + ret = PDCreg_release_lock(obj1, reg_global, 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/2; ++i ) { + if ( data_read[i] != i * 2 + 1 ) { + printf("wrong value %d!=%d\n", data_read[i], i * 2 + 1); + ret_value = 1; + break; + } + } + + if(PDCregion_close(reg) < 0) { + printf("fail to close local region\n"); + ret_value = 1; + } else { + printf("successfully local region\n"); + } + + if(PDCregion_close(reg_global) < 0) { + printf("fail to close global region\n"); + ret_value = 1; + } else { + printf("successfully global region\n"); + } + + + // 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 index d7570a480..e6f6bde51 100644 --- a/src/tests/region_obj_map_3D.c +++ b/src/tests/region_obj_map_3D.c @@ -175,15 +175,13 @@ int main(int argc, char **argv) { ret_value = 1; } - ret = PDCreg_obtain_lock(obj1, reg, PDC_READ, PDC_BLOCK); + ret = PDCreg_obtain_lock(obj1, reg_global, PDC_READ, PDC_BLOCK); if(ret != SUCCEED) { printf("PDCreg_obtain_lock failed\n"); ret_value = 1; } - - - ret = PDCreg_release_lock(obj1, reg, PDC_READ); + ret = PDCreg_release_lock(obj1, reg_global, PDC_READ); if(ret != SUCCEED) { printf("PDCreg_release_lock failed\n"); ret_value = 1; @@ -203,6 +201,20 @@ int main(int argc, char **argv) { } } + if(PDCregion_close(reg) < 0) { + printf("fail to close local region\n"); + ret_value = 1; + } else { + printf("successfully local region\n"); + } + + if(PDCregion_close(reg_global) < 0) { + printf("fail to close global region\n"); + ret_value = 1; + } else { + printf("successfully global region\n"); + } + // close object if(PDCobj_close(obj1) < 0) { diff --git a/src/tests/region_obj_map_3D_partial.c b/src/tests/region_obj_map_3D_partial.c new file mode 100644 index 000000000..aea851b4f --- /dev/null +++ b/src/tests/region_obj_map_3D_partial.c @@ -0,0 +1,274 @@ +/* + * 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 32 + + +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_global, PDC_WRITE, PDC_BLOCK); + if(ret != SUCCEED) { + printf("PDCreg_obtain_lock failed\n"); + exit(-1); + } + + ret = PDCreg_release_lock(obj1, reg_global, 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); + offset[0] = 0; + offset[1] = 0; + offset[2] = 0; + offset_length[0] = BUF_LEN/32; + offset_length[1] = 2; + offset_length[2] = 2; + reg = PDCregion_create(3, offset, offset_length); + offset[0] = BUF_LEN/8; + offset[1] = 1; + offset[2] = 1; + offset_length[0] = BUF_LEN/8; + offset_length[1] = 1; + offset_length[2] = 1; + 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_global, PDC_READ, PDC_BLOCK); + if(ret != SUCCEED) { + printf("PDCreg_obtain_lock failed\n"); + ret_value = 1; + } + + ret = PDCreg_release_lock(obj1, reg_global, 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/8; ++i ) { + if ( data_read[i] != (BUF_LEN/8 + i) * 4 + 3 ) { + printf("wrong value %d!=%d\n", data_read[i], (BUF_LEN/8 + i) * 4 + 3); + ret_value = 1; + break; + } + } + + if(PDCregion_close(reg) < 0) { + printf("fail to close local region\n"); + ret_value = 1; + } else { + printf("successfully local region\n"); + } + + if(PDCregion_close(reg_global) < 0) { + printf("fail to close global region\n"); + ret_value = 1; + } else { + printf("successfully global region\n"); + } + + + // 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_partial.c b/src/tests/region_obj_map_partial.c new file mode 100644 index 000000000..d7321c290 --- /dev/null +++ b/src/tests/region_obj_map_partial.c @@ -0,0 +1,261 @@ +/* + * 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], local_offset[1]; + uint64_t dims[1]; + local_offset[0] = 0; + 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; + } + + offset[0] = 0; + offset_length[0] = BUF_LEN; + 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; + } + + ret = PDCreg_obtain_lock(obj1, reg_global, PDC_WRITE, PDC_BLOCK); + if(ret != SUCCEED) { + printf("PDCreg_obtain_lock failed\n"); + exit(-1); + } + + ret = PDCreg_release_lock(obj1, reg_global, 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; + } + + offset[0] = 0; + offset_length[0] = BUF_LEN/2; + reg = PDCregion_create(1, offset, offset_length); + offset[0] = BUF_LEN / 2; + offset_length[0] = BUF_LEN/2; + reg_global = PDCregion_create(1, offset, offset_length); + + memset(data_read, 0, BUF_LEN); + + 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_global, PDC_READ, PDC_BLOCK); + if(ret != SUCCEED) { + printf("PDCreg_obtain_lock failed\n"); + ret_value = 1; + } + + ret = PDCreg_release_lock(obj1, reg_global, 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/2; ++i ) { + if ( data_read[i] != i + BUF_LEN/2 ) { + printf("wrong value %d!=%d\n", data_read[i], i + BUF_LEN/2); + ret_value = 1; + break; + } + } + + if(PDCregion_close(reg) < 0) { + printf("fail to close local region\n"); + ret_value = 1; + } else { + printf("successfully local region\n"); + } + + if(PDCregion_close(reg_global) < 0) { + printf("fail to close global region\n"); + ret_value = 1; + } else { + printf("successfully global region\n"); + } + + + // 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; +}