From 76018fcef5f4fd9808a833a7e52926ee21efb0bb Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Fri, 30 Apr 2021 00:49:22 -0500 Subject: [PATCH 01/47] This commit contains PDC examples and PDC_TIMING code. --- README.md | 2 +- examples/Makefile | 33 ++ examples/README.md | 73 ++++ examples/bdcats.c | 451 ++++++++++++++++++++ examples/mpi_test.sh | 32 ++ examples/obj_get_data.c | 154 +++++++ examples/pdc_init.c | 54 +++ examples/region_obj_map_2D.c | 268 ++++++++++++ examples/region_obj_map_3D.c | 270 ++++++++++++ examples/run_multiple_test.sh | 25 ++ examples/run_test.sh | 25 ++ examples/vpicio.c | 645 +++++++++++++++++++++++++++++ src/api/CMakeLists.txt | 1 + src/api/pdc.c | 7 +- src/api/pdc_client_connect.c | 65 ++- src/api/pdc_client_server_common.c | 184 +++++++- src/api/pdc_timing.h | 62 +++ src/tests/CMakeLists.txt | 2 + src/tests/read_write_col_perf.c | 357 ++++++++++++++++ src/tests/read_write_perf.c | 356 ++++++++++++++++ src/tests/region_obj_map_2D.c | 14 + src/tests/region_obj_map_3D.c | 14 + 22 files changed, 3075 insertions(+), 19 deletions(-) create mode 100644 examples/Makefile create mode 100644 examples/README.md create mode 100644 examples/bdcats.c create mode 100644 examples/mpi_test.sh create mode 100644 examples/obj_get_data.c create mode 100644 examples/pdc_init.c create mode 100644 examples/region_obj_map_2D.c create mode 100644 examples/region_obj_map_3D.c create mode 100644 examples/run_multiple_test.sh create mode 100644 examples/run_test.sh create mode 100644 examples/vpicio.c create mode 100644 src/api/pdc_timing.h create mode 100644 src/tests/read_write_col_perf.c create mode 100644 src/tests/read_write_perf.c diff --git a/README.md b/README.md index 0a93a4c3f..0cd89e83e 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ ctest contains both sequential and MPI tests for the PDC settings. These can be ``` 0. git clone https://github.com/hpc-io/pdc.git 1. cd pdc -2. git checkout qiao_develop +2. git checkout stable 3. cd src 4. mkdir install 5. cd install 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 100644 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..2dba1918d --- /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, PDC_WRITE, PDC_BLOCK); + if(ret != SUCCEED) { + printf("PDCreg_obtain_lock failed\n"); + exit(-1); + } + + ret = PDCreg_release_lock(obj1, reg, PDC_WRITE); + if(ret != SUCCEED) { + printf("PDCreg_release_lock failed\n"); + ret_value = 1; + } + + ret = PDCbuf_obj_unmap(obj1, reg_global); + if(ret != SUCCEED) { + printf("PDCbuf_obj_unmap failed\n"); + ret_value = 1; + } + + 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..c53467dd9 --- /dev/null +++ b/examples/region_obj_map_3D.c @@ -0,0 +1,270 @@ +/* + * 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, PDC_READ, PDC_BLOCK); + if(ret != SUCCEED) { + printf("PDCreg_obtain_lock failed\n"); + ret_value = 1; + } + + + + ret = PDCreg_release_lock(obj1, reg, PDC_READ); + if(ret != SUCCEED) { + printf("PDCreg_release_lock failed\n"); + ret_value = 1; + } + + ret = PDCbuf_obj_unmap(obj1, reg_global); + if(ret != SUCCEED) { + printf("PDCbuf_obj_unmap failed\n"); + ret_value = 1; + } + + for ( i = 0; i < BUF_LEN; ++i ) { + if ( data_read[i] != i ) { + printf("wrong value %d!=%d\n", data_read[i], i); + ret_value = 1; + break; + } + } + + 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 100644 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..0ea22df2b 100644 --- a/src/api/pdc_client_connect.c +++ b/src/api/pdc_client_connect.c @@ -2189,15 +2189,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 +2341,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 +2422,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 +3065,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; diff --git a/src/api/pdc_client_server_common.c b/src/api/pdc_client_server_common.c index 50cd02603..0b061eef7 100644 --- a/src/api/pdc_client_server_common.c +++ b/src/api/pdc_client_server_common.c @@ -50,6 +50,150 @@ #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(4, 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; + 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\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); + + 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\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); + } + + + 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); + 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); + free(buf_obj_map_timestamps); +} + +#endif + #ifdef ENABLE_MULTITHREAD hg_thread_mutex_t insert_metadata_mutex_g = HG_THREAD_MUTEX_INITIALIZER; @@ -2117,7 +2261,9 @@ HG_TEST_RPC_CB(region_release, handle) size_t dims[4] = {0,0,0,0}; FUNC_ENTER(NULL); - +#if PDC_TIMING == 1 + start = MPI_Wtime(); +#endif // Decode input HG_Get_input(handle, &in); /* Get info from handle */ @@ -2476,7 +2622,11 @@ HG_TEST_RPC_CB(region_release, handle) 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 done: /* t = time(NULL); */ /* tm = *localtime(&t); */ @@ -3284,7 +3434,9 @@ HG_TEST_RPC_CB(region_lock, handle) region_lock_out_t out; FUNC_ENTER(NULL); - +#if PDC_TIMING == 1 + start = MPI_Wtime(); +#endif HG_Get_input(handle, &in); // Perform lock function @@ -3295,7 +3447,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); } @@ -3310,7 +3466,9 @@ HG_TEST_RPC_CB(buf_unmap, handle) const struct hg_info *info; FUNC_ENTER(NULL); - +#if PDC_TIMING == 1 + start = MPI_Wtime(); +#endif // Decode input HG_Get_input(handle, &in); info = HG_Get_info(handle); @@ -3332,7 +3490,11 @@ 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"); - +#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 done: fflush(stdout); FUNC_LEAVE(ret_value); @@ -3492,7 +3654,9 @@ HG_TEST_RPC_CB(buf_map, handle) size_t ndim; FUNC_ENTER(NULL); - +#if PDC_TIMING == 1 + start = MPI_Wtime(); +#endif // Decode input HG_Get_input(handle, &in); @@ -3536,7 +3700,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); diff --git a/src/api/pdc_timing.h b/src/api/pdc_timing.h new file mode 100644 index 000000000..f0126e5ea --- /dev/null +++ b/src/api/pdc_timing.h @@ -0,0 +1,62 @@ +#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; +} 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 *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/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 2020af883..89f0a2643 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -32,6 +32,8 @@ set(PROGRAMS obj_tags obj_put_data obj_get_data + read_write_perf + read_write_col_perf open_obj_round_robin region_obj_map_2D region_obj_map_3D diff --git a/src/tests/read_write_col_perf.c b/src/tests/read_write_col_perf.c new file mode 100644 index 000000000..f2e81ee29 --- /dev/null +++ b/src/tests/read_write_col_perf.c @@ -0,0 +1,357 @@ +/* + * 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" +#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; + 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; + +#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); + start = MPI_Wtime(); + ret = PDCbuf_obj_map(data, PDC_INT, reg, obj1, reg_global); + write_buf_map_time += MPI_Wtime() - start; + if(ret != SUCCEED) { + printf("PDCbuf_obj_map failed @ line %d\n", __LINE__); + ret_value = 1; + } + + start = MPI_Wtime(); + ret = PDCreg_obtain_lock(obj1, reg_global, PDC_WRITE, PDC_BLOCK); + write_lock_time += MPI_Wtime() - start; + if(ret != SUCCEED) { + printf("PDCreg_obtain_lock failed @ line %d\n", __LINE__); + exit(-1); + } + + start = MPI_Wtime(); + ret = PDCreg_release_lock(obj1, reg_global, PDC_WRITE); + write_release_time += MPI_Wtime() - start; + if(ret != SUCCEED) { + printf("PDCreg_release_lock failed @ line %d\n", __LINE__); + ret_value = 1; + } + + start = MPI_Wtime(); + ret = PDCbuf_obj_unmap(obj1, reg_global); + write_unbuf_map_time += MPI_Wtime() - start; + 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); + + start = MPI_Wtime(); + ret = PDCbuf_obj_map(data_read, PDC_INT, reg, obj1, reg_global); + read_buf_map_time += MPI_Wtime() - start; + if(ret != SUCCEED) { + printf("PDCbuf_obj_map failed @ line %d\n", __LINE__); + ret_value = 1; + } + + start = MPI_Wtime(); + ret = PDCreg_obtain_lock(obj1, reg_global, PDC_READ, PDC_BLOCK); + read_lock_time += MPI_Wtime() - start; + if(ret != SUCCEED) { + printf("PDCreg_obtain_lock failed @ line %d\n", __LINE__); + ret_value = 1; + } + + start = MPI_Wtime(); + ret = PDCreg_release_lock(obj1, reg_global, PDC_READ); + read_release_time += MPI_Wtime() - start; + if(ret != SUCCEED) { + printf("PDCreg_release_lock failed @ line %d\n", __LINE__); + ret_value = 1; + } + + start = MPI_Wtime(); + ret = PDCbuf_obj_unmap(obj1, reg_global); + read_unbuf_map_time += MPI_Wtime() - start; + 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; + } + + 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); + } +#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..4cd825e8b --- /dev/null +++ b/src/tests/read_write_perf.c @@ -0,0 +1,356 @@ +/* + * 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; + 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; + 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); + start = MPI_Wtime(); + ret = PDCbuf_obj_map(data, PDC_INT, reg, obj1, reg_global); + write_buf_map_time += MPI_Wtime() - start; + if(ret != SUCCEED) { + printf("PDCbuf_obj_map failed @ line %d\n", __LINE__); + ret_value = 1; + } + + start = MPI_Wtime(); + ret = PDCreg_obtain_lock(obj1, reg_global, PDC_WRITE, PDC_BLOCK); + write_lock_time += MPI_Wtime() - start; + if(ret != SUCCEED) { + printf("PDCreg_obtain_lock failed @ line %d\n", __LINE__); + exit(-1); + } + + start = MPI_Wtime(); + ret = PDCreg_release_lock(obj1, reg_global, PDC_WRITE); + write_release_time += MPI_Wtime() - start; + if(ret != SUCCEED) { + printf("PDCreg_release_lock failed @ line %d\n", __LINE__); + ret_value = 1; + } + + start = MPI_Wtime(); + ret = PDCbuf_obj_unmap(obj1, reg_global); + write_unbuf_map_time += MPI_Wtime() - start; + 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); + + start = MPI_Wtime(); + ret = PDCbuf_obj_map(data_read, PDC_INT, reg, obj1, reg_global); + read_buf_map_time += MPI_Wtime() - start; + if(ret != SUCCEED) { + printf("PDCbuf_obj_map failed @ line %d\n", __LINE__); + ret_value = 1; + } + + start = MPI_Wtime(); + ret = PDCreg_obtain_lock(obj1, reg_global, PDC_READ, PDC_BLOCK); + read_lock_time += MPI_Wtime() - start; + if(ret != SUCCEED) { + printf("PDCreg_obtain_lock failed @ line %d\n", __LINE__); + ret_value = 1; + } + + start = MPI_Wtime(); + ret = PDCreg_release_lock(obj1, reg_global, PDC_READ); + read_release_time += MPI_Wtime() - start; + if(ret != SUCCEED) { + printf("PDCreg_release_lock failed @ line %d\n", __LINE__); + ret_value = 1; + } + + start = MPI_Wtime(); + ret = PDCbuf_obj_unmap(obj1, reg_global); + read_unbuf_map_time += MPI_Wtime() - start; + 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; + } + + 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); + } +#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..6d3f0d917 100644 --- a/src/tests/region_obj_map_2D.c +++ b/src/tests/region_obj_map_2D.c @@ -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_3D.c b/src/tests/region_obj_map_3D.c index d7570a480..0c1ecfd6b 100644 --- a/src/tests/region_obj_map_3D.c +++ b/src/tests/region_obj_map_3D.c @@ -203,6 +203,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) { From 85f781e20b283e8d2bbbe95005c1a99e96b75086 Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Fri, 30 Apr 2021 01:10:17 -0500 Subject: [PATCH 02/47] Add a few more tests --- src/tests/CMakeLists.txt | 5 ++ src/tests/cont_del.c | 95 ++++++++++++++++++++++++ src/tests/create_cont_coll.c | 87 ++++++++++++++++++++++ src/tests/obj_del.c | 137 +++++++++++++++++++++++++++++++++++ 4 files changed, 324 insertions(+) create mode 100644 src/tests/cont_del.c create mode 100644 src/tests/create_cont_coll.c create mode 100644 src/tests/obj_del.c diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 89f0a2643..fc5ba5d1c 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -136,7 +136,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 ) @@ -173,7 +175,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 ) @@ -219,6 +223,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/obj_del.c b/src/tests/obj_del.c new file mode 100644 index 000000000..bf5dd7cfc --- /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_data(obj1) != SUCCEED) { + printf("Fail to delete object @ line %d!\n", __LINE__); + } + + if (PDCobj_del_data(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; +} From 79b139a7fe31ec9f6326ab3672b897c6b177969a Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Fri, 30 Apr 2021 01:50:32 -0500 Subject: [PATCH 03/47] Update CMakeLists.txt --- src/tests/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index fc5ba5d1c..eeedcd72f 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 From d75cd7554a1f5c0fb6c81d0453fdf7dacfdb7636 Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Fri, 30 Apr 2021 00:21:16 -0700 Subject: [PATCH 04/47] fixed a path bug in the example run script --- examples/mpi_test.sh | 0 examples/run_multiple_test.sh | 0 examples/run_test.sh | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 examples/mpi_test.sh mode change 100644 => 100755 examples/run_multiple_test.sh mode change 100644 => 100755 examples/run_test.sh diff --git a/examples/mpi_test.sh b/examples/mpi_test.sh old mode 100644 new mode 100755 diff --git a/examples/run_multiple_test.sh b/examples/run_multiple_test.sh old mode 100644 new mode 100755 diff --git a/examples/run_test.sh b/examples/run_test.sh old mode 100644 new mode 100755 index ca1ec253c..bb54598ee --- a/examples/run_test.sh +++ b/examples/run_test.sh @@ -12,7 +12,7 @@ shift if [ -x $test_exe ]; then echo "testing: $test_exe"; else echo "test: $test_exe not found or not and executable" && exit -2; fi rm -rf pdc_tmp # START the server (in the background) -$PDC_DIR/install/bin/./pdc_server.exe & +$PDC_DIR/bin/./pdc_server.exe & # WAIT a bit... sleep 1 # RUN the actual test From fc056401a4f1b27b52b1e1b1d9aba9b497e93330 Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Fri, 30 Apr 2021 12:58:02 -0500 Subject: [PATCH 05/47] add partial region test --- src/tests/CMakeLists.txt | 5 +- src/tests/region_obj_map_2D_partial.c | 262 +++++++++++++++++++++++++ src/tests/region_obj_map_3D_partial.c | 264 +++++++++++++++++++++++++ src/tests/region_obj_map_partial.c | 266 ++++++++++++++++++++++++++ 4 files changed, 796 insertions(+), 1 deletion(-) create mode 100644 src/tests/region_obj_map_2D_partial.c create mode 100644 src/tests/region_obj_map_3D_partial.c create mode 100644 src/tests/region_obj_map_partial.c diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index eeedcd72f..ec5573776 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -38,10 +38,13 @@ set(PROGRAMS 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 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..6d3f0d917 --- /dev/null +++ b/src/tests/region_obj_map_2D_partial.c @@ -0,0 +1,262 @@ +/* + * 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); + reg = PDCregion_create(ndim, offset, offset_length); + reg_global = PDCregion_create(ndim, offset, offset_length); + + for ( i = 0; i < BUF_LEN; ++i ) { + data[i] = i; + } + ret = PDCbuf_obj_map(data, PDC_INT, reg, obj1, reg_global); + if(ret != SUCCEED) { + printf("PDCbuf_obj_map failed\n"); + ret_value = 1; + } + + for ( i = 0; i < BUF_LEN; ++i ) { + data[i] = i; + } + + ret = PDCreg_obtain_lock(obj1, reg, PDC_WRITE, PDC_BLOCK); + if(ret != SUCCEED) { + printf("PDCreg_obtain_lock failed\n"); + exit(-1); + } + + ret = PDCreg_release_lock(obj1, reg, PDC_WRITE); + if(ret != SUCCEED) { + printf("PDCreg_release_lock failed\n"); + ret_value = 1; + } + + ret = PDCbuf_obj_unmap(obj1, reg_global); + if(ret != SUCCEED) { + printf("PDCbuf_obj_unmap failed\n"); + ret_value = 1; + } + + //reg = PDCregion_create(1, offset, offset_length); + //reg_global = PDCregion_create(1, offset, offset_length); + reg = PDCregion_create(ndim, offset, offset_length); + reg_global = PDCregion_create(ndim, offset, offset_length); + + ret = PDCbuf_obj_map(data_read, PDC_INT, reg, obj1, reg_global); + if(ret != SUCCEED) { + printf("PDCbuf_obj_map failed\n"); + ret_value = 1; + } + + ret = PDCreg_obtain_lock(obj1, reg_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/src/tests/region_obj_map_3D_partial.c b/src/tests/region_obj_map_3D_partial.c new file mode 100644 index 000000000..0c1ecfd6b --- /dev/null +++ b/src/tests/region_obj_map_3D_partial.c @@ -0,0 +1,264 @@ +/* + * 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); + reg = PDCregion_create(3, offset, offset_length); + reg_global = PDCregion_create(3, offset, offset_length); + + ret = PDCbuf_obj_map(data_read, PDC_INT, reg, obj1, reg_global); + if(ret != SUCCEED) { + printf("PDCbuf_obj_map failed\n"); + ret_value = 1; + } + + ret = PDCreg_obtain_lock(obj1, reg, PDC_READ, PDC_BLOCK); + if(ret != SUCCEED) { + printf("PDCreg_obtain_lock failed\n"); + ret_value = 1; + } + + + + ret = PDCreg_release_lock(obj1, reg, PDC_READ); + if(ret != SUCCEED) { + printf("PDCreg_release_lock failed\n"); + ret_value = 1; + } + + ret = PDCbuf_obj_unmap(obj1, reg_global); + if(ret != SUCCEED) { + printf("PDCbuf_obj_unmap failed\n"); + ret_value = 1; + } + + for ( i = 0; i < BUF_LEN; ++i ) { + if ( data_read[i] != i ) { + printf("wrong value %d!=%d\n", data_read[i], i); + ret_value = 1; + break; + } + } + + 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..abd5926be --- /dev/null +++ b/src/tests/region_obj_map_partial.c @@ -0,0 +1,266 @@ +/* + * 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/2; + reg = PDCregion_create(1, offset, offset_length); + offset[0] = BUF_LEN/2 - 1; + offset_length[0] = BUF_LEN/2; + reg_global = PDCregion_create(1, offset, offset_length); + + for ( i = 0; i < BUF_LEN; ++i ) { + data[i] = i; + } + ret = PDCbuf_obj_map(data, PDC_INT, reg, obj1, reg_global); + if(ret != SUCCEED) { + printf("PDCbuf_obj_map failed\n"); + ret_value = 1; + } + + for ( i = 0; i < BUF_LEN; ++i ) { + data[i] = -i; + } + + ret = PDCreg_obtain_lock(obj1, reg_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, local_offset, offset_length); + offset[0] = BUF_LEN/2 - 1; + offset_length[0] = BUF_LEN/2; + reg_global = PDCregion_create(1, offset, offset_length); + ret = PDCbuf_obj_map(data_read, PDC_INT, reg, obj1, reg_global); + if(ret != SUCCEED) { + printf("PDCbuf_obj_map failed\n"); + ret_value = 1; + } + + ret = PDCreg_obtain_lock(obj1, reg_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; +} From d655a2fc653e6fd9714f7621781ace88477d78d0 Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Fri, 30 Apr 2021 19:49:33 -0500 Subject: [PATCH 06/47] test --- src/tests/region_obj_map_2D_partial.c | 11 ++++++++++- src/tests/region_obj_map_partial.c | 4 +++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/tests/region_obj_map_2D_partial.c b/src/tests/region_obj_map_2D_partial.c index 6d3f0d917..bee9ef7b1 100644 --- a/src/tests/region_obj_map_2D_partial.c +++ b/src/tests/region_obj_map_2D_partial.c @@ -128,7 +128,15 @@ int main(int argc, char **argv) { //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/4; + offset_length[1] = 1; reg = PDCregion_create(ndim, offset, offset_length); + offset[0] = BUF_LEN/4; + offset[1] = 1; + offset_length[0] = BUF_LEN/4; + offset_length[1] = 1; reg_global = PDCregion_create(ndim, offset, offset_length); for ( i = 0; i < BUF_LEN; ++i ) { @@ -167,6 +175,7 @@ int main(int argc, char **argv) { reg = PDCregion_create(ndim, offset, offset_length); reg_global = PDCregion_create(ndim, offset, offset_length); + memset(data_read, 0, BUF_LEN/4); ret = PDCbuf_obj_map(data_read, PDC_INT, reg, obj1, reg_global); if(ret != SUCCEED) { printf("PDCbuf_obj_map failed\n"); @@ -193,7 +202,7 @@ int main(int argc, char **argv) { ret_value = 1; } - for ( i = 0; i < BUF_LEN; ++i ) { + for ( i = 0; i < BUF_LEN/4; ++i ) { if ( data_read[i] != i ) { printf("wrong value %d!=%d\n", data_read[i], i); ret_value = 1; diff --git a/src/tests/region_obj_map_partial.c b/src/tests/region_obj_map_partial.c index abd5926be..9960ccd23 100644 --- a/src/tests/region_obj_map_partial.c +++ b/src/tests/region_obj_map_partial.c @@ -171,6 +171,8 @@ int main(int argc, char **argv) { offset[0] = BUF_LEN/2 - 1; offset_length[0] = BUF_LEN/2; reg_global = PDCregion_create(1, offset, offset_length); + + memset(data_read, 0, BUF_LEN/2) ret = PDCbuf_obj_map(data_read, PDC_INT, reg, obj1, reg_global); if(ret != SUCCEED) { printf("PDCbuf_obj_map failed\n"); @@ -197,7 +199,7 @@ int main(int argc, char **argv) { ret_value = 1; } - for ( i = 0; i < BUF_LEN; ++i ) { + for ( i = 0; i < BUF_LEN/2; ++i ) { if ( data_read[i] != i ) { printf("wrong value %d!=%d\n", data_read[i], i); ret_value = 1; From 7a28b05663e55ea4acb57e2875f0b80c84b44262 Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Fri, 30 Apr 2021 19:52:55 -0500 Subject: [PATCH 07/47] Update region_obj_map_partial.c --- src/tests/region_obj_map_partial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/region_obj_map_partial.c b/src/tests/region_obj_map_partial.c index 9960ccd23..82b543b67 100644 --- a/src/tests/region_obj_map_partial.c +++ b/src/tests/region_obj_map_partial.c @@ -172,7 +172,7 @@ int main(int argc, char **argv) { offset_length[0] = BUF_LEN/2; reg_global = PDCregion_create(1, offset, offset_length); - memset(data_read, 0, BUF_LEN/2) + memset(data_read, 0, BUF_LEN/2); ret = PDCbuf_obj_map(data_read, PDC_INT, reg, obj1, reg_global); if(ret != SUCCEED) { printf("PDCbuf_obj_map failed\n"); From f43a085d88fd82ea1728fbfdf0b1f140e1061fef Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Fri, 30 Apr 2021 23:10:46 -0500 Subject: [PATCH 08/47] Update region_obj_map_partial.c --- src/tests/region_obj_map_partial.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/tests/region_obj_map_partial.c b/src/tests/region_obj_map_partial.c index 82b543b67..f83ca4e00 100644 --- a/src/tests/region_obj_map_partial.c +++ b/src/tests/region_obj_map_partial.c @@ -128,10 +128,8 @@ int main(int argc, char **argv) { } offset[0] = 0; - offset_length[0] = BUF_LEN/2; + offset_length[0] = BUF_LEN; reg = PDCregion_create(1, offset, offset_length); - offset[0] = BUF_LEN/2 - 1; - offset_length[0] = BUF_LEN/2; reg_global = PDCregion_create(1, offset, offset_length); for ( i = 0; i < BUF_LEN; ++i ) { @@ -172,7 +170,7 @@ int main(int argc, char **argv) { offset_length[0] = BUF_LEN/2; reg_global = PDCregion_create(1, offset, offset_length); - memset(data_read, 0, BUF_LEN/2); + 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"); @@ -185,8 +183,6 @@ int main(int argc, char **argv) { ret_value = 1; } - - ret = PDCreg_release_lock(obj1, reg_global, PDC_READ); if(ret != SUCCEED) { printf("PDCreg_release_lock failed\n"); @@ -200,7 +196,7 @@ int main(int argc, char **argv) { } for ( i = 0; i < BUF_LEN/2; ++i ) { - if ( data_read[i] != i ) { + if ( data_read[i] != i + BUF_LEN/2 ) { printf("wrong value %d!=%d\n", data_read[i], i); ret_value = 1; break; From 170bb1cad5c2fb19c8b06f20e5285e6a01d9d368 Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Fri, 30 Apr 2021 23:11:09 -0500 Subject: [PATCH 09/47] Update region_obj_map_partial.c --- src/tests/region_obj_map_partial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/region_obj_map_partial.c b/src/tests/region_obj_map_partial.c index f83ca4e00..054e0c70d 100644 --- a/src/tests/region_obj_map_partial.c +++ b/src/tests/region_obj_map_partial.c @@ -197,7 +197,7 @@ int main(int argc, char **argv) { 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); + printf("wrong value %d!=%d\n", (int)data_read[i], (int)i); ret_value = 1; break; } From 60511ba965e1a10aca75f231a4a7554baf8e6b94 Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Fri, 30 Apr 2021 23:15:58 -0500 Subject: [PATCH 10/47] Update region_obj_map_partial.c --- src/tests/region_obj_map_partial.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tests/region_obj_map_partial.c b/src/tests/region_obj_map_partial.c index 054e0c70d..9bbae5563 100644 --- a/src/tests/region_obj_map_partial.c +++ b/src/tests/region_obj_map_partial.c @@ -164,10 +164,10 @@ int main(int argc, char **argv) { } offset[0] = 0; - offset_length[0] = BUF_LEN/2; + offset_length[0] = BUF_LEN; reg = PDCregion_create(1, local_offset, offset_length); - offset[0] = BUF_LEN/2 - 1; - offset_length[0] = BUF_LEN/2; + offset[0] = 0; + offset_length[0] = BUF_LEN; reg_global = PDCregion_create(1, offset, offset_length); memset(data_read, 0, BUF_LEN); @@ -196,7 +196,7 @@ int main(int argc, char **argv) { } for ( i = 0; i < BUF_LEN/2; ++i ) { - if ( data_read[i] != i + BUF_LEN/2 ) { + if ( data_read[i] != i ) { printf("wrong value %d!=%d\n", (int)data_read[i], (int)i); ret_value = 1; break; From f2bdf9a918c81f669401bba307717e5416f2b5d7 Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Fri, 30 Apr 2021 23:19:42 -0500 Subject: [PATCH 11/47] Update region_obj_map_partial.c --- src/tests/region_obj_map_partial.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tests/region_obj_map_partial.c b/src/tests/region_obj_map_partial.c index 9bbae5563..47629c49e 100644 --- a/src/tests/region_obj_map_partial.c +++ b/src/tests/region_obj_map_partial.c @@ -164,10 +164,10 @@ int main(int argc, char **argv) { } offset[0] = 0; - offset_length[0] = BUF_LEN; + offset_length[0] = BUF_LEN/2; reg = PDCregion_create(1, local_offset, offset_length); offset[0] = 0; - offset_length[0] = BUF_LEN; + offset_length[0] = BUF_LEN/2; reg_global = PDCregion_create(1, offset, offset_length); memset(data_read, 0, BUF_LEN); From 3d86845e1faaec094d1c73d4835fd7615c903a6c Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Fri, 30 Apr 2021 23:23:06 -0500 Subject: [PATCH 12/47] Update region_obj_map_partial.c --- src/tests/region_obj_map_partial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/region_obj_map_partial.c b/src/tests/region_obj_map_partial.c index 47629c49e..b655e8d0d 100644 --- a/src/tests/region_obj_map_partial.c +++ b/src/tests/region_obj_map_partial.c @@ -166,7 +166,7 @@ int main(int argc, char **argv) { offset[0] = 0; offset_length[0] = BUF_LEN/2; reg = PDCregion_create(1, local_offset, offset_length); - offset[0] = 0; + offset[0] = BUF_LEN/2; offset_length[0] = BUF_LEN/2; reg_global = PDCregion_create(1, offset, offset_length); From 8a445cec956fd29e13797036f9c0438f1d0fbd33 Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Fri, 30 Apr 2021 23:26:40 -0500 Subject: [PATCH 13/47] Update region_obj_map_partial.c --- src/tests/region_obj_map_partial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/region_obj_map_partial.c b/src/tests/region_obj_map_partial.c index b655e8d0d..435d61299 100644 --- a/src/tests/region_obj_map_partial.c +++ b/src/tests/region_obj_map_partial.c @@ -196,7 +196,7 @@ int main(int argc, char **argv) { } for ( i = 0; i < BUF_LEN/2; ++i ) { - if ( data_read[i] != i ) { + if ( data_read[i] != i + BUF_LEN/2 ) { printf("wrong value %d!=%d\n", (int)data_read[i], (int)i); ret_value = 1; break; From 8aaa44e37a57b3b10fc6da708e468a5e5f0a275d Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Fri, 30 Apr 2021 23:28:16 -0500 Subject: [PATCH 14/47] Update region_obj_map_partial.c --- src/tests/region_obj_map_partial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/region_obj_map_partial.c b/src/tests/region_obj_map_partial.c index 435d61299..1bd3c49ef 100644 --- a/src/tests/region_obj_map_partial.c +++ b/src/tests/region_obj_map_partial.c @@ -197,7 +197,7 @@ int main(int argc, char **argv) { for ( i = 0; i < BUF_LEN/2; ++i ) { if ( data_read[i] != i + BUF_LEN/2 ) { - printf("wrong value %d!=%d\n", (int)data_read[i], (int)i); + printf("wrong value %d!=%d\n", data_read[i], i + BUF_LEN/2); ret_value = 1; break; } From 62e8a27d01e5e65fb72c7a5b3abf48b78bb38aef Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Fri, 30 Apr 2021 23:35:36 -0500 Subject: [PATCH 15/47] Update region_obj_map_partial.c --- src/tests/region_obj_map_partial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/region_obj_map_partial.c b/src/tests/region_obj_map_partial.c index 1bd3c49ef..4fa45ca78 100644 --- a/src/tests/region_obj_map_partial.c +++ b/src/tests/region_obj_map_partial.c @@ -163,7 +163,7 @@ int main(int argc, char **argv) { ret_value = 1; } - offset[0] = 0; + offset[0] = BUF_LEN/2; offset_length[0] = BUF_LEN/2; reg = PDCregion_create(1, local_offset, offset_length); offset[0] = BUF_LEN/2; From bd5aad1ebdbefa5a200cfe87b3519804dd6d6e29 Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Fri, 30 Apr 2021 23:36:43 -0500 Subject: [PATCH 16/47] Update region_obj_map_partial.c --- src/tests/region_obj_map_partial.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/tests/region_obj_map_partial.c b/src/tests/region_obj_map_partial.c index 4fa45ca78..92b8943f0 100644 --- a/src/tests/region_obj_map_partial.c +++ b/src/tests/region_obj_map_partial.c @@ -163,7 +163,7 @@ int main(int argc, char **argv) { ret_value = 1; } - offset[0] = BUF_LEN/2; + offset[0] = 0; offset_length[0] = BUF_LEN/2; reg = PDCregion_create(1, local_offset, offset_length); offset[0] = BUF_LEN/2; @@ -171,6 +171,7 @@ int main(int argc, char **argv) { 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"); @@ -194,7 +195,7 @@ int main(int argc, char **argv) { 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); From ce6e51b61dfaf30e620c854cb8ecbf84acba29c9 Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Fri, 30 Apr 2021 23:37:42 -0500 Subject: [PATCH 17/47] Update region_obj_map_partial.c --- src/tests/region_obj_map_partial.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tests/region_obj_map_partial.c b/src/tests/region_obj_map_partial.c index 92b8943f0..b4f9c6a23 100644 --- a/src/tests/region_obj_map_partial.c +++ b/src/tests/region_obj_map_partial.c @@ -166,12 +166,12 @@ int main(int argc, char **argv) { offset[0] = 0; offset_length[0] = BUF_LEN/2; reg = PDCregion_create(1, local_offset, offset_length); - offset[0] = BUF_LEN/2; + 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"); @@ -195,7 +195,7 @@ int main(int argc, char **argv) { 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); From 81cc0b982e7e222a92b9ec96f19d11841b1cdfed Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Fri, 30 Apr 2021 23:39:45 -0500 Subject: [PATCH 18/47] Update region_obj_map_partial.c --- src/tests/region_obj_map_partial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/region_obj_map_partial.c b/src/tests/region_obj_map_partial.c index b4f9c6a23..6c1e8264d 100644 --- a/src/tests/region_obj_map_partial.c +++ b/src/tests/region_obj_map_partial.c @@ -166,7 +166,7 @@ int main(int argc, char **argv) { offset[0] = 0; offset_length[0] = BUF_LEN/2; reg = PDCregion_create(1, local_offset, offset_length); - offset[0] = BUF_LEN * 2; + offset[0] = BUF_LEN / 2; offset_length[0] = BUF_LEN/2; reg_global = PDCregion_create(1, offset, offset_length); From 6e3f218f6dae6933389c2a9154a0f86b1d6609df Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Fri, 30 Apr 2021 23:42:25 -0500 Subject: [PATCH 19/47] Update region_obj_map_partial.c --- src/tests/region_obj_map_partial.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tests/region_obj_map_partial.c b/src/tests/region_obj_map_partial.c index 6c1e8264d..ad0c675db 100644 --- a/src/tests/region_obj_map_partial.c +++ b/src/tests/region_obj_map_partial.c @@ -142,7 +142,7 @@ int main(int argc, char **argv) { } for ( i = 0; i < BUF_LEN; ++i ) { - data[i] = -i; + data[i] = i; } ret = PDCreg_obtain_lock(obj1, reg_global, PDC_WRITE, PDC_BLOCK); @@ -165,7 +165,7 @@ int main(int argc, char **argv) { offset[0] = 0; offset_length[0] = BUF_LEN/2; - reg = PDCregion_create(1, local_offset, offset_length); + 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); From f125b4c64f9a08df32112ae0c1c2044c28b0111f Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Sat, 1 May 2021 00:03:02 -0500 Subject: [PATCH 20/47] test --- src/tests/region_obj_map_2D_partial.c | 26 +++++++++++++++++--------- src/tests/region_obj_map_partial.c | 4 ---- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/tests/region_obj_map_2D_partial.c b/src/tests/region_obj_map_2D_partial.c index bee9ef7b1..095393f84 100644 --- a/src/tests/region_obj_map_2D_partial.c +++ b/src/tests/region_obj_map_2D_partial.c @@ -130,13 +130,13 @@ int main(int argc, char **argv) { //reg_global = PDCregion_create(1, offset, offset_length); offset[0] = 0; offset[1] = 0; - offset_length[0] = BUF_LEN/4; - offset_length[1] = 1; + offset_length[0] = BUF_LEN/2; + offset_length[1] = 2; reg = PDCregion_create(ndim, offset, offset_length); - offset[0] = BUF_LEN/4; - offset[1] = 1; - offset_length[0] = BUF_LEN/4; - offset_length[1] = 1; + 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 ) { @@ -172,10 +172,18 @@ int main(int argc, char **argv) { //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] = 1; reg = PDCregion_create(ndim, 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/4); + 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"); @@ -203,8 +211,8 @@ int main(int argc, char **argv) { } for ( i = 0; i < BUF_LEN/4; ++i ) { - if ( data_read[i] != i ) { - printf("wrong value %d!=%d\n", data_read[i], i); + if ( data_read[i] != i * 2 ) { + printf("wrong value %d!=%d\n", data_read[i], i * 2); ret_value = 1; break; } diff --git a/src/tests/region_obj_map_partial.c b/src/tests/region_obj_map_partial.c index ad0c675db..d7321c290 100644 --- a/src/tests/region_obj_map_partial.c +++ b/src/tests/region_obj_map_partial.c @@ -141,10 +141,6 @@ int main(int argc, char **argv) { 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"); From 2c1295f3b2015174a2fc87e9f1acf4b85bfbeb01 Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Sat, 1 May 2021 00:04:37 -0500 Subject: [PATCH 21/47] Update region_obj_map_2D_partial.c --- src/tests/region_obj_map_2D_partial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/region_obj_map_2D_partial.c b/src/tests/region_obj_map_2D_partial.c index 095393f84..f06bc391e 100644 --- a/src/tests/region_obj_map_2D_partial.c +++ b/src/tests/region_obj_map_2D_partial.c @@ -210,7 +210,7 @@ int main(int argc, char **argv) { ret_value = 1; } - for ( i = 0; i < BUF_LEN/4; ++i ) { + for ( i = 0; i < BUF_LEN/2; ++i ) { if ( data_read[i] != i * 2 ) { printf("wrong value %d!=%d\n", data_read[i], i * 2); ret_value = 1; From 765ba80a00b02334a4885a9b3ee3aa9415058068 Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Sat, 1 May 2021 00:05:24 -0500 Subject: [PATCH 22/47] Update region_obj_map_2D_partial.c --- src/tests/region_obj_map_2D_partial.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/tests/region_obj_map_2D_partial.c b/src/tests/region_obj_map_2D_partial.c index f06bc391e..9519bcd41 100644 --- a/src/tests/region_obj_map_2D_partial.c +++ b/src/tests/region_obj_map_2D_partial.c @@ -184,6 +184,7 @@ int main(int argc, char **argv) { 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"); @@ -196,8 +197,6 @@ int main(int argc, char **argv) { ret_value = 1; } - - ret = PDCreg_release_lock(obj1, reg_global, PDC_READ); if(ret != SUCCEED) { printf("PDCreg_release_lock failed\n"); @@ -209,7 +208,7 @@ int main(int argc, char **argv) { printf("PDCbuf_obj_unmap failed\n"); ret_value = 1; } - +*/ for ( i = 0; i < BUF_LEN/2; ++i ) { if ( data_read[i] != i * 2 ) { printf("wrong value %d!=%d\n", data_read[i], i * 2); From 7e13025411618e328983c8500609fb25c77a6316 Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Sat, 1 May 2021 00:07:23 -0500 Subject: [PATCH 23/47] Update region_obj_map_2D_partial.c --- src/tests/region_obj_map_2D_partial.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tests/region_obj_map_2D_partial.c b/src/tests/region_obj_map_2D_partial.c index 9519bcd41..e015a87a1 100644 --- a/src/tests/region_obj_map_2D_partial.c +++ b/src/tests/region_obj_map_2D_partial.c @@ -184,7 +184,7 @@ int main(int argc, char **argv) { 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"); @@ -208,10 +208,10 @@ int main(int argc, char **argv) { printf("PDCbuf_obj_unmap failed\n"); ret_value = 1; } -*/ + for ( i = 0; i < BUF_LEN/2; ++i ) { - if ( data_read[i] != i * 2 ) { - printf("wrong value %d!=%d\n", data_read[i], i * 2); + if ( data_read[i] != i * 2 + 1 ) { + printf("wrong value %d!=%d\n", data_read[i], i * 2 + 1); ret_value = 1; break; } From 9d8c243dfca65fa0173b50e859120ce48833d9ee Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Sat, 1 May 2021 00:08:53 -0500 Subject: [PATCH 24/47] Update region_obj_map_2D_partial.c --- src/tests/region_obj_map_2D_partial.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tests/region_obj_map_2D_partial.c b/src/tests/region_obj_map_2D_partial.c index e015a87a1..0d069af61 100644 --- a/src/tests/region_obj_map_2D_partial.c +++ b/src/tests/region_obj_map_2D_partial.c @@ -174,8 +174,8 @@ int main(int argc, char **argv) { //reg_global = PDCregion_create(1, offset, offset_length); offset[0] = 0; offset[1] = 0; - offset_length[0] = BUF_LEN/2; - offset_length[1] = 1; + offset_length[0] = BUF_LEN/4; + offset_length[1] = 2; reg = PDCregion_create(ndim, offset, offset_length); offset[0] = 0; offset[1] = 1; From 935148f3f08ca680ebc835ab64b4b13c598452ca Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Sat, 1 May 2021 00:10:03 -0500 Subject: [PATCH 25/47] Update region_obj_map_2D_partial.c --- src/tests/region_obj_map_2D_partial.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/tests/region_obj_map_2D_partial.c b/src/tests/region_obj_map_2D_partial.c index 0d069af61..f3976152c 100644 --- a/src/tests/region_obj_map_2D_partial.c +++ b/src/tests/region_obj_map_2D_partial.c @@ -173,10 +173,8 @@ int main(int argc, char **argv) { //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/4; - offset_length[1] = 2; - reg = PDCregion_create(ndim, offset, offset_length); + offset_length[0] = BUF_LEN; + reg = PDCregion_create(1, offset, offset_length); offset[0] = 0; offset[1] = 1; offset_length[0] = BUF_LEN/2; From 788915e6ba62758f65807ef98a0f34136236f0bc Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Sat, 1 May 2021 00:10:51 -0500 Subject: [PATCH 26/47] Update region_obj_map_2D_partial.c --- src/tests/region_obj_map_2D_partial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/region_obj_map_2D_partial.c b/src/tests/region_obj_map_2D_partial.c index f3976152c..458436529 100644 --- a/src/tests/region_obj_map_2D_partial.c +++ b/src/tests/region_obj_map_2D_partial.c @@ -173,7 +173,7 @@ int main(int argc, char **argv) { //reg = PDCregion_create(1, offset, offset_length); //reg_global = PDCregion_create(1, offset, offset_length); offset[0] = 0; - offset_length[0] = BUF_LEN; + offset_length[0] = BUF_LEN/2; reg = PDCregion_create(1, offset, offset_length); offset[0] = 0; offset[1] = 1; From f6e697997b35ea1f86e4ac175d85eb94fa6e3143 Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Sat, 1 May 2021 00:13:14 -0500 Subject: [PATCH 27/47] Update CMakeLists.txt --- src/tests/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index ec5573776..fc9e02b0b 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -158,6 +158,8 @@ 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 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) From 6d1435bfdb54e5fd186b0af82972eb22fdf24b9e Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Sat, 1 May 2021 00:15:24 -0500 Subject: [PATCH 28/47] Update pdc_server.c --- src/server/pdc_server.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/server/pdc_server.c b/src/server/pdc_server.c index 6786bd205..1c206f461 100644 --- a/src/server/pdc_server.c +++ b/src/server/pdc_server.c @@ -1818,7 +1818,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 +1879,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(); From 44b0154a6a5c490e80839741eb3208e404fc9150 Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Sat, 1 May 2021 01:36:11 -0500 Subject: [PATCH 29/47] Update pdc_client_server_common.c --- src/api/pdc_client_server_common.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/api/pdc_client_server_common.c b/src/api/pdc_client_server_common.c index 0b061eef7..b459e6159 100644 --- a/src/api/pdc_client_server_common.c +++ b/src/api/pdc_client_server_common.c @@ -2259,6 +2259,9 @@ 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 @@ -3432,6 +3435,9 @@ 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 @@ -3464,6 +3470,9 @@ 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 @@ -3652,6 +3661,9 @@ 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 From d223b230682ed913c66668a240a02f743c044e94 Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Sat, 1 May 2021 01:41:23 -0500 Subject: [PATCH 30/47] Update run_test.sh --- examples/run_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/run_test.sh b/examples/run_test.sh index bb54598ee..b6ccfcf71 100755 --- a/examples/run_test.sh +++ b/examples/run_test.sh @@ -21,5 +21,5 @@ $test_exe $test_args # Need to test the return value ret="$?" # and shutdown the SERVER before exiting -$PDC_DIR/install/bin/./close_server +$PDC_DIR/bin/./close_server exit $ret From f52d860d8224a191dcecdb3ec21181c0160691c2 Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Sat, 1 May 2021 02:16:43 -0500 Subject: [PATCH 31/47] Update pdc_server.c --- src/server/pdc_server.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/server/pdc_server.c b/src/server/pdc_server.c index 1c206f461..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 From e81d8cc70c63b4f4317a5f8103314b789a2fc569 Mon Sep 17 00:00:00 2001 From: Houjun Tang Date: Mon, 3 May 2021 16:41:46 -0700 Subject: [PATCH 32/47] Fix void* cast warnings --- src/tests/kvtag_add_get_scale.c | 2 +- src/tests/kvtag_get.c | 8 ++++---- src/tests/kvtag_query_scale.c | 5 ++--- 3 files changed, 7 insertions(+), 8 deletions(-) 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); From c42743553ddd2fea74876e34283bb415e437d4da Mon Sep 17 00:00:00 2001 From: Houjun Tang Date: Mon, 3 May 2021 17:05:03 -0700 Subject: [PATCH 33/47] Fix container delete bug --- src/api/pdc_client_connect.c | 17 ++++++++++++----- src/api/pdc_client_connect.h | 2 ++ src/api/pdc_obj.c | 10 ++++++++++ src/api/pdc_obj.h | 2 +- src/server/pdc_server_metadata.c | 26 ++++++++++++++++++++++++-- src/tests/obj_del.c | 4 ++-- 6 files changed, 51 insertions(+), 10 deletions(-) diff --git a/src/api/pdc_client_connect.c b/src/api/pdc_client_connect.c index 0ea22df2b..45a0f4f97 100644 --- a/src/api/pdc_client_connect.c +++ b/src/api/pdc_client_connect.c @@ -1723,7 +1723,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: @@ -6141,7 +6141,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); @@ -6372,16 +6372,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_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/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/obj_del.c b/src/tests/obj_del.c index bf5dd7cfc..c4b2a4a5b 100644 --- a/src/tests/obj_del.c +++ b/src/tests/obj_del.c @@ -89,11 +89,11 @@ int main(int argc, char **argv) { ret_value = 1; } - if (PDCobj_del_data(obj1) != SUCCEED) { + if (PDCobj_del(obj1) != SUCCEED) { printf("Fail to delete object @ line %d!\n", __LINE__); } - if (PDCobj_del_data(obj2) != SUCCEED) { + if (PDCobj_del(obj2) != SUCCEED) { printf("Fail to delete object @ line %d!\n", __LINE__); } From 68bcf02838b2f0c3a8b556e7d5a9f6a11261fddd Mon Sep 17 00:00:00 2001 From: Houjun Tang Date: Mon, 3 May 2021 17:26:57 -0700 Subject: [PATCH 34/47] Fix 1d partial read, pass region_obj_map_partial test --- src/server/pdc_server_data.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/server/pdc_server_data.c b/src/server/pdc_server_data.c index d5db307f2..c16bda1c2 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); From 5d15c1276082841182f37149f18028220cdb6b46 Mon Sep 17 00:00:00 2001 From: Houjun Tang Date: Mon, 3 May 2021 17:35:27 -0700 Subject: [PATCH 35/47] Fix compile warnings --- src/tests/kvtag_add_get.c | 8 ++++---- src/tests/open_obj.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) 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/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) { From c275449717e569b020d295563d1b69cc1faee8de Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Mon, 3 May 2021 19:39:37 -0500 Subject: [PATCH 36/47] add new timing features --- src/api/pdc_client_server_common.c | 45 ++++++++++++++++++++---------- src/api/pdc_timing.h | 2 ++ 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/src/api/pdc_client_server_common.c b/src/api/pdc_client_server_common.c index b459e6159..7fbd6a50f 100644 --- a/src/api/pdc_client_server_common.c +++ b/src/api/pdc_client_server_common.c @@ -131,10 +131,11 @@ int PDC_timing_report(const char* prefix) { int PDC_server_timing_init() { server_timings = calloc(1, sizeof(pdc_server_timing)); - buf_obj_map_timestamps = calloc(4, sizeof(pdc_timestamp)); + 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(); } @@ -167,11 +168,11 @@ int PDC_server_timing_report() { 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\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); + 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\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); + 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); } @@ -182,6 +183,7 @@ int PDC_server_timing_report() { 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); @@ -189,6 +191,7 @@ int PDC_server_timing_report() { 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); } @@ -2079,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) { @@ -2162,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); } @@ -2175,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) { @@ -2196,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 @@ -2625,11 +2641,6 @@ HG_TEST_RPC_CB(region_release, handle) 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 done: /* t = time(NULL); */ /* tm = *localtime(&t); */ @@ -2640,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); } @@ -3499,13 +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 -done: - fflush(stdout); FUNC_LEAVE(ret_value); } @@ -4421,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"); @@ -5851,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_timing.h b/src/api/pdc_timing.h index f0126e5ea..ac2ad17e5 100644 --- a/src/api/pdc_timing.h +++ b/src/api/pdc_timing.h @@ -29,6 +29,7 @@ typedef struct pdc_server_timing { 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 { @@ -43,6 +44,7 @@ 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; From 10d9f1b6ebe2c80c1040b0f232e579a7386d4b07 Mon Sep 17 00:00:00 2001 From: Houjun Tang Date: Mon, 3 May 2021 17:41:16 -0700 Subject: [PATCH 37/47] Fix 2D read, passing region_obj_map_2D_partial test --- src/server/pdc_server_data.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/server/pdc_server_data.c b/src/server/pdc_server_data.c index c16bda1c2..530ac0d12 100644 --- a/src/server/pdc_server_data.c +++ b/src/server/pdc_server_data.c @@ -4474,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); @@ -4491,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; } } From b224ef021c78f21fc4eab8a1403ba6fe9802ab35 Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Tue, 4 May 2021 12:50:02 -0500 Subject: [PATCH 38/47] Cast enable MPI features for performance tests --- src/tests/read_write_col_perf.c | 45 ++++++++++++++++++++++++++------- src/tests/read_write_perf.c | 28 ++++++++++++++------ 2 files changed, 56 insertions(+), 17 deletions(-) diff --git a/src/tests/read_write_col_perf.c b/src/tests/read_write_col_perf.c index f2e81ee29..261193fd8 100644 --- a/src/tests/read_write_col_perf.c +++ b/src/tests/read_write_col_perf.c @@ -47,8 +47,9 @@ int main(int argc, char **argv) { 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); @@ -170,33 +171,46 @@ int main(int argc, char **argv) { 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; @@ -233,34 +247,46 @@ int main(int argc, char **argv) { 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; @@ -304,7 +330,7 @@ int main(int argc, char **argv) { 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) { @@ -350,6 +376,7 @@ int main(int argc, char **argv) { if (!rank) { printf("read buf unmap obj time: %lf\n", read_unbuf_map_time); } +#endif #ifdef ENABLE_MPI MPI_Finalize(); #endif diff --git a/src/tests/read_write_perf.c b/src/tests/read_write_perf.c index 4cd825e8b..64386909a 100644 --- a/src/tests/read_write_perf.c +++ b/src/tests/read_write_perf.c @@ -50,7 +50,9 @@ int main(int argc, char **argv) { 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; @@ -169,33 +171,38 @@ int main(int argc, char **argv) { 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; @@ -232,34 +239,38 @@ int main(int argc, char **argv) { 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; @@ -303,7 +314,7 @@ int main(int argc, char **argv) { 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) { @@ -349,6 +360,7 @@ int main(int argc, char **argv) { if (!rank) { printf("read buf unmap obj time: %lf\n", read_unbuf_map_time); } +#endif #ifdef ENABLE_MPI MPI_Finalize(); #endif From 315da9c81c68120373f4ed6005e1c292acaff4cb Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Tue, 4 May 2021 14:54:11 -0500 Subject: [PATCH 39/47] Update region_obj_map_3D_partial.c --- src/tests/region_obj_map_3D_partial.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/tests/region_obj_map_3D_partial.c b/src/tests/region_obj_map_3D_partial.c index 0c1ecfd6b..5e8e08903 100644 --- a/src/tests/region_obj_map_3D_partial.c +++ b/src/tests/region_obj_map_3D_partial.c @@ -166,7 +166,19 @@ int main(int argc, char **argv) { //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/8; + offset_length[1] = 1; + offset_length[2] = 1; reg = PDCregion_create(3, offset, offset_length); + offset[0] = BUF/_LEN/8; + offset[1] = 1; + offset[2] = 1; + offset_length[0] = BUF_LEN/4; + 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); @@ -181,8 +193,6 @@ int main(int argc, char **argv) { ret_value = 1; } - - ret = PDCreg_release_lock(obj1, reg, PDC_READ); if(ret != SUCCEED) { printf("PDCreg_release_lock failed\n"); @@ -195,9 +205,9 @@ int main(int argc, char **argv) { 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); + 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; } From 5cd0fb20eb8774e98583913fa8501d38128f9614 Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Tue, 4 May 2021 14:55:50 -0500 Subject: [PATCH 40/47] Add 3D partial test to cmake file --- src/tests/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index fc9e02b0b..1b149b64a 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -160,6 +160,7 @@ add_test(NAME region_obj_map_2D WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTO 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) @@ -199,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 ) From 0db4a6bab72257e40f9126cb698e77fee6a56e22 Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Tue, 4 May 2021 14:58:27 -0500 Subject: [PATCH 41/47] Compile typo --- src/tests/region_obj_map_3D_partial.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tests/region_obj_map_3D_partial.c b/src/tests/region_obj_map_3D_partial.c index 5e8e08903..cc36dfbb4 100644 --- a/src/tests/region_obj_map_3D_partial.c +++ b/src/tests/region_obj_map_3D_partial.c @@ -173,10 +173,10 @@ int main(int argc, char **argv) { offset_length[1] = 1; offset_length[2] = 1; reg = PDCregion_create(3, offset, offset_length); - offset[0] = BUF/_LEN/8; + offset[0] = BUF_LEN/8; offset[1] = 1; offset[2] = 1; - offset_length[0] = BUF_LEN/4; + offset_length[0] = BUF_LEN/8; offset_length[1] = 1; offset_length[2] = 1; reg_global = PDCregion_create(3, offset, offset_length); From f6defe1940207ded77ce0b68d094a6b4770c9e3a Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Tue, 4 May 2021 15:01:56 -0500 Subject: [PATCH 42/47] Update region_obj_map_3D_partial.c --- src/tests/region_obj_map_3D_partial.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tests/region_obj_map_3D_partial.c b/src/tests/region_obj_map_3D_partial.c index cc36dfbb4..2105837b9 100644 --- a/src/tests/region_obj_map_3D_partial.c +++ b/src/tests/region_obj_map_3D_partial.c @@ -169,9 +169,9 @@ int main(int argc, char **argv) { offset[0] = 0; offset[1] = 0; offset[2] = 0; - offset_length[0] = BUF_LEN/8; - offset_length[1] = 1; - offset_length[2] = 1; + 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; From b51a629cbe9b93b7df56c05b3040962395868edb Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Tue, 4 May 2021 16:18:37 -0500 Subject: [PATCH 43/47] Update region_obj_map_3D_partial.c --- src/tests/region_obj_map_3D_partial.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tests/region_obj_map_3D_partial.c b/src/tests/region_obj_map_3D_partial.c index 2105837b9..aea851b4f 100644 --- a/src/tests/region_obj_map_3D_partial.c +++ b/src/tests/region_obj_map_3D_partial.c @@ -187,13 +187,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; From d56c2ce58b1def5584b9ddc731ad30fcb7aa443b Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Tue, 4 May 2021 17:12:53 -0500 Subject: [PATCH 44/47] Local region to global region for lock and release --- src/tests/region_obj_map_2D.c | 4 ++-- src/tests/region_obj_map_2D_partial.c | 4 ++-- src/tests/region_obj_map_3D.c | 6 ++---- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/tests/region_obj_map_2D.c b/src/tests/region_obj_map_2D.c index 6d3f0d917..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; diff --git a/src/tests/region_obj_map_2D_partial.c b/src/tests/region_obj_map_2D_partial.c index 458436529..988c4bfeb 100644 --- a/src/tests/region_obj_map_2D_partial.c +++ b/src/tests/region_obj_map_2D_partial.c @@ -152,13 +152,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; diff --git a/src/tests/region_obj_map_3D.c b/src/tests/region_obj_map_3D.c index 0c1ecfd6b..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; From 0b6d70ccbedeb2d28acf01e160de13cf9caf35bf Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Tue, 4 May 2021 18:14:51 -0500 Subject: [PATCH 45/47] Change local regions to global regions for lock/release in example --- examples/region_obj_map_2D.c | 4 ++-- examples/region_obj_map_3D.c | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/examples/region_obj_map_2D.c b/examples/region_obj_map_2D.c index 2dba1918d..8113bd599 100644 --- a/examples/region_obj_map_2D.c +++ b/examples/region_obj_map_2D.c @@ -138,13 +138,13 @@ int main(int argc, char **argv) { ret_value = 1; } - 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; diff --git a/examples/region_obj_map_3D.c b/examples/region_obj_map_3D.c index c53467dd9..d676076a8 100644 --- a/examples/region_obj_map_3D.c +++ b/examples/region_obj_map_3D.c @@ -181,15 +181,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; From 7b671fe4704cecbedce7611eef582b992afecb8b Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Wed, 5 May 2021 01:35:28 -0500 Subject: [PATCH 46/47] Add PDC timings --- src/tests/read_write_col_perf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tests/read_write_col_perf.c b/src/tests/read_write_col_perf.c index 261193fd8..70ecc215e 100644 --- a/src/tests/read_write_col_perf.c +++ b/src/tests/read_write_col_perf.c @@ -34,6 +34,7 @@ #include "pdc_client_connect.h" #include "pdc_client_server_common.h" #include "pdc_analysis.h" +#include "pdc_timing.h" #define BUF_LEN 128 From 633a03351dc041cd458bc5e41c87621094a12d58 Mon Sep 17 00:00:00 2001 From: Qiao Kang Date: Wed, 5 May 2021 11:25:04 -0500 Subject: [PATCH 47/47] Add pdc timer header --- src/api/pdc_client_connect.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/api/pdc_client_connect.c b/src/api/pdc_client_connect.c index 45a0f4f97..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; @@ -3878,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"); @@ -4379,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;