diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fd4c5e390..e0f03883f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,7 +9,12 @@ stages: perlmutter-no-cache-build: stage: build - when: manual + rules: + - if: '$METRICS == null' + when: manual + id_tokens: + SITE_ID_TOKEN: + aud: https://software.nersc.gov/ allow_failure: false tags: - perlmutter @@ -32,7 +37,12 @@ perlmutter-no-cache-build: perlmutter-cache-build: stage: build - when: manual + rules: + - if: '$METRICS == null' + when: manual + id_tokens: + SITE_ID_TOKEN: + aud: https://software.nersc.gov/ allow_failure: false tags: - perlmutter @@ -60,6 +70,9 @@ perlmutter-cache-build: perlmutter-no-cache-parallel-pdc: stage: test + id_tokens: + SITE_ID_TOKEN: + aud: https://software.nersc.gov/ rules: - if: '$METRICS == null' needs: @@ -80,6 +93,9 @@ perlmutter-no-cache-parallel-pdc: perlmutter-no-cache-parallel-obj: stage: test + id_tokens: + SITE_ID_TOKEN: + aud: https://software.nersc.gov/ rules: - if: '$METRICS == null' needs: @@ -101,6 +117,9 @@ perlmutter-no-cache-parallel-obj: perlmutter-no-cache-parallel-cont: stage: test + id_tokens: + SITE_ID_TOKEN: + aud: https://software.nersc.gov/ rules: - if: '$METRICS == null' needs: @@ -122,6 +141,9 @@ perlmutter-no-cache-parallel-cont: perlmutter-no-cache-parallel-prop: stage: test + id_tokens: + SITE_ID_TOKEN: + aud: https://software.nersc.gov/ rules: - if: '$METRICS == null' needs: @@ -143,6 +165,9 @@ perlmutter-no-cache-parallel-prop: perlmutter-no-cache-parallel-region: stage: test + id_tokens: + SITE_ID_TOKEN: + aud: https://software.nersc.gov/ rules: - if: '$METRICS == null' needs: @@ -164,6 +189,9 @@ perlmutter-no-cache-parallel-region: perlmutter-no-cache-parallel-region-all: stage: test + id_tokens: + SITE_ID_TOKEN: + aud: https://software.nersc.gov/ rules: - if: '$METRICS == null' needs: @@ -190,6 +218,9 @@ perlmutter-no-cache-parallel-region-all: perlmutter-cache-parallel-pdc: stage: test + id_tokens: + SITE_ID_TOKEN: + aud: https://software.nersc.gov/ rules: - if: '$METRICS == null' needs: @@ -210,6 +241,9 @@ perlmutter-cache-parallel-pdc: perlmutter-cache-parallel-obj: stage: test + id_tokens: + SITE_ID_TOKEN: + aud: https://software.nersc.gov/ rules: - if: '$METRICS == null' needs: @@ -231,6 +265,9 @@ perlmutter-cache-parallel-obj: perlmutter-cache-parallel-cont: stage: test + id_tokens: + SITE_ID_TOKEN: + aud: https://software.nersc.gov/ rules: - if: '$METRICS == null' needs: @@ -252,6 +289,9 @@ perlmutter-cache-parallel-cont: perlmutter-cache-parallel-prop: stage: test + id_tokens: + SITE_ID_TOKEN: + aud: https://software.nersc.gov/ rules: - if: '$METRICS == null' needs: @@ -273,6 +313,9 @@ perlmutter-cache-parallel-prop: perlmutter-cache-parallel-region: stage: test + id_tokens: + SITE_ID_TOKEN: + aud: https://software.nersc.gov/ rules: - if: '$METRICS == null' needs: @@ -294,6 +337,9 @@ perlmutter-cache-parallel-region: perlmutter-cache-parallel-region-all: stage: test + id_tokens: + SITE_ID_TOKEN: + aud: https://software.nersc.gov/ rules: - if: '$METRICS == null' needs: @@ -313,26 +359,54 @@ perlmutter-cache-parallel-region-all: - ctest -L parallel_region_transfer_all - rm -rf ${PDC_TMPDIR} ${PDC_DATA_LOC} +perlmutter-metrics-build: + stage: build + id_tokens: + SITE_ID_TOKEN: + aud: https://software.nersc.gov/ + rules: + - if: '$METRICS == "true"' + allow_failure: false + tags: + - perlmutter + variables: + SCHEDULER_PARAMETERS: "-A m2621 --qos=debug --constraint=cpu --tasks-per-node=64 -N 1 -t 00:30:00" + SUPERCOMPUTER: "perlmutter" + MERCURY_DIR: "/global/cfs/cdirs/m2621/pdc-perlmutter/mercury/install" + script: + - module load libfabric/1.15.2.0 + - module list + - mkdir -p ${PDC_BUILD_PATH}/perlmutter/metrics + - cd ${PDC_BUILD_PATH}/perlmutter/metrics + - cmake ../../.. -DBUILD_MPI_TESTING=ON -DBUILD_SHARED_LIBS=ON -DPDC_SERVER_CACHE=ON -DBUILD_TESTING=ON -DCMAKE_INSTALL_PREFIX=$PDC_DIR -DPDC_ENABLE_MPI=ON -DMERCURY_DIR=$MERCURY_DIR -DCMAKE_C_COMPILER=cc -DMPI_RUN_CMD="srun -A m2621 --qos=debug --constraint=cpu --tasks-per-node=64" -DCMAKE_INSTALL_PREFIX=${PDC_INSTALL_PATH}/perlmutter/metrics + - make -j + - make install + artifacts: + paths: + - ${PDC_BUILD_PATH}/perlmutter/metrics + - ${PDC_INSTALL_PATH}/perlmutter/metrics + perlmutter-metrics: stage: metrics + id_tokens: + SITE_ID_TOKEN: + aud: https://software.nersc.gov/ rules: - if: '$METRICS == "true"' needs: - - perlmutter-cache-build + - perlmutter-metrics-build tags: - perlmutter variables: - PDC_N_NODES: 64 - PDC_N_CLIENTS: 127 - SCHEDULER_PARAMETERS: "-A m2621 --qos=regular --constraint=cpu --tasks-per-node=${PDC_N_CLIENTS} -N ${PDC_N_NODES} -t 00:30:00" + SCHEDULER_PARAMETERS: "-A m2621 --qos=${PDC_QUEUE} --constraint=cpu --tasks-per-node=${PDC_N_CLIENTS} -N ${PDC_N_NODES} -t 00:30:00" SUPERCOMPUTER: "perlmutter" MERCURY_DIR: "/global/cfs/cdirs/m2621/pdc-perlmutter/mercury/install" PDC_TMPDIR: "${PDC_BUILD_PATH}/pdc-tmp-metrics" PDC_DATA_LOC: "${PDC_BUILD_PATH}/pdc-data-metrics" PDC_CLIENT_LOOKUP: "NONE" - PDC_SERVER: "${PDC_BUILD_PATH}/perlmutter/cache/bin/pdc_server.exe" - PDC_SERVER_CLOSE: "${PDC_BUILD_PATH}/perlmutter/cache/bin/close_server" - PDC_CLIENT: "${PDC_BUILD_PATH}/perlmutter/cache/bin/vpicio_mts" + PDC_SERVER: "${PDC_BUILD_PATH}/perlmutter/metrics/bin/pdc_server.exe" + PDC_SERVER_CLOSE: "${PDC_BUILD_PATH}/perlmutter/metrics/bin/close_server" + PDC_CLIENT: "${PDC_BUILD_PATH}/perlmutter/metrics/bin/vpicio_mts" PDC_JOB_OUTPUT: "pdc-metrics.log" script: - hostname diff --git a/CMakeLists.txt b/CMakeLists.txt index 70bc8ce2e..a3abd14bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -380,7 +380,7 @@ endif() #----------------------------------------------------------------------------- # SERVER CACHE option #----------------------------------------------------------------------------- -option(PDC_SERVER_CACHE "Enable Server Caching." OFF) +option(PDC_SERVER_CACHE "Enable Server Caching." ON) if(PDC_SERVER_CACHE) set(PDC_SERVER_CACHE 1) set(PDC_SERVER_CACHE_MAX_GB "3" CACHE STRING "Max GB for server cache") diff --git a/docs/source/getting_started.rst b/docs/source/getting_started.rst index 295517128..b2a767725 100644 --- a/docs/source/getting_started.rst +++ b/docs/source/getting_started.rst @@ -125,11 +125,8 @@ Install libfabric .. attention:: - If you're installing PDC on MacOS, you need to make sure you enable ``sockets``: - - .. code-block: Bash - - ./configure CFLAG=-O2 --enable-sockets=yes --enable-tcp=yes --enable-udp=yes --enable-rxm=yes + When installing on MacOS, make sure to enable ``sockets`` with the following configure command: + ``./configure CFLAG=-O2 --enable-sockets=yes --enable-tcp=yes --enable-udp=yes --enable-rxm=yes`` Install Mercury @@ -156,17 +153,13 @@ Install Mercury echo 'export PATH=$MERCURY_DIR/include:$MERCURY_DIR/lib:$PATH' >> $WORK_SPACE/pdc_env.sh .. note:: + ``CC=mpicc`` may need to be changed to the corresponding compiler in your system, e.g. ``-DCMAKE_C_COMPILER=cc`` or ``-DCMAKE_C_COMPILER=gcc``. Make sure the ctest passes. PDC may not work without passing all the tests of Mercury. .. attention:: - If you're installing PDC on MacOS, for the tests to work you need to specify the protocol used by Mercury: - - .. code-block: Bash - - cmake -DCMAKE_INSTALL_PREFIX=$MERCURY_DIR -DCMAKE_C_COMPILER=mpicc -DBUILD_SHARED_LIBS=ON \ - -DBUILD_TESTING=ON -DNA_USE_OFI=ON -DNA_USE_SM=OFF -DNA_OFI_TESTING_PROTOCOL=sockets + When installing on MacOS, specify the ``sockets`` protocol used by Mercury by replacing the cmake command from ``-DNA_OFI_TESTING_PROTOCOL=tcp`` to ``-DNA_OFI_TESTING_PROTOCOL=sockets`` Install PDC @@ -197,11 +190,7 @@ Install PDC If you are trying to compile PDC on MacOS, ``LibUUID`` needs to be installed on your MacOS first. Simple use ``brew install ossp-uuid`` to install it. If you are trying to compile PDC on Linux, you should also make sure ``LibUUID`` is installed on your system. If not, you can install it with ``sudo apt-get install uuid-dev`` on Ubuntu or ``yum install libuuid-devel`` on CentOS. - In MacOS you also need to export the following environment variable so PDC (i.e., Mercury) uses the ``socket`` protocol, the only one supported in MacOS: - - .. code-block: Bash - - export HG_TRANSPORT="sockets" + In MacOS you also need to export the following environment variable so PDC (i.e., Mercury) uses the ``socket`` protocol, the only one supported in MacOS: ``export HG_TRANSPORT="sockets"`` Test Your PDC Installation @@ -219,6 +208,7 @@ You can also specify a timeout (e.g., 2 minutes) for the tests by specifying the ctest --timeout 120 .. note:: + If you are using PDC on an HPC system, e.g. Perlmutter@NERSC, ``ctest`` should be run on a compute node, you can submit an interactive job on Perlmutter: ``salloc --nodes 1 --qos interactive --time 01:00:00 --constraint cpu --account=mxxxx`` @@ -232,23 +222,21 @@ But before adding any of your function, we need to enable the Julia support firs Prerequisite ^^^^^^^^^^^^ -Make sure you have Julia-lang installed. You can check with your system administrator to see if you already have Julia-lang installed. If not, you can either ask your system administrator to install it for you or you can install it yourself if permitted. On macOS, the best way to install Julia is via `Homebrew https://brew.sh`_. You may also refer to `Julia Download Page https://julialang.org/downloads/`_ for instructions on installing Julia. -Once you installed Julia, you can set `JULIA_HOME` to be where Julia-lang is installed. +Make sure you have Julia-lang installed. You can check with your system administrator to see if you already have Julia-lang installed. If not, you can either ask your system administrator to install it for you or you can install it yourself if permitted. On macOS, the best way to install Julia is via `Homebrew `_. You may also refer to `Julia Download Page `_ for instructions on installing Julia. +Once you installed Julia, you can set ``JULIA_HOME`` to be where Julia-lang is installed. .. code-block:: Bash - export JULIA_HOME=/path/to/julia/install/directory + export JULIA_HOME=/path/to/julia/install/directory -.. note:: Note on perlmutter: - You can easily perform `module load julia` to load the Julia-lang environment. Then, you can do the following to set `$JULIA_HOME`: +.. note:: - .. code-block:: Bash - export JULIA_HOME=$(dirname $(dirname $(which julia))) + On Perlmutter You can ``module load julia`` to load the Julia-lang module and set ``$JULIA_HOME`` with: ``export JULIA_HOME=$(dirname $(dirname $(which julia)))`` Enabling Julia Support for PDC Tests ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Once the Prerequisite is satisfied, you can enable Julia support by adding `--DPDC_ENABLE_JULIA_SUPPORT=ON` to your cmake command and re-run it. +Once the Prerequisite is satisfied, you can enable Julia support by adding ``--DPDC_ENABLE_JULIA_SUPPORT=ON`` to your cmake command and re-run it. Then you can compile your PDC project with Julia support. Now, see Developer Notes to know how you can add your own Julia functions to enhance your test cases in PDC. @@ -257,9 +245,10 @@ Now, see Developer Notes to know how you can add your own Julia functions to enh Build PDC in a Docker Container --------------------------------------------------- Simply run the following command from the project root directory to build PDC in a Docker container: + .. code-block:: Bash - .docker/run_dev_base.sh + .docker/run_dev_base.sh Build PDC in Github Codespace --------------------------------------------------- diff --git a/examples/Makefile b/examples/Makefile index 4dcbb0acf..e0ccbc987 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -4,7 +4,7 @@ CFLAGS = -O2 -Wall -Wextra INCLUDES = -I. -I$(PDC_DIR)/include LDFLAGS = -Wl,-rpath,$(PDC_DIR)/lib -L$(PDC_DIR)/lib -LIBS = -lpdc +LIBS = -lpdc -lpdc_commons .c.o: $(CC) $(CFLAGS) $(INCLUDES) -c $< diff --git a/examples/bdcats.c b/examples/bdcats.c index 13c052b24..b9c3102cb 100644 --- a/examples/bdcats.c +++ b/examples/bdcats.c @@ -101,43 +101,75 @@ main(int argc, char **argv) if (cont_id == 0) printf("Fail to create container @ line %d!\n", __LINE__); - // open objects - obj_xx = PDCobj_open("obj-var-xx", pdc_id); + // open objects +#ifdef ENABLE_MPI + obj_xx = PDCobj_open_col("obj-var-xx", pdc_id); +#else + obj_xx = PDCobj_open("obj-var-xx", pdc_id); +#endif 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); +#ifdef ENABLE_MPI + obj_yy = PDCobj_open_col("obj-var-yy", pdc_id); +#else + obj_yy = PDCobj_open("obj-var-xx", pdc_id); +#endif 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); +#ifdef ENABLE_MPI + obj_zz = PDCobj_open_col("obj-var-zz", pdc_id); +#else + obj_zz = PDCobj_open("obj-var-xx", pdc_id); +#endif 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); +#ifdef ENABLE_MPI + obj_pxx = PDCobj_open_col("obj-var-pxx", pdc_id); +#else + obj_pxx = PDCobj_open("obj-var-xx", pdc_id); +#endif 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); +#ifdef ENABLE_MPI + obj_pyy = PDCobj_open_col("obj-var-pyy", pdc_id); +#else + obj_pyy = PDCobj_open("obj-var-xx", pdc_id); +#endif 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); +#ifdef ENABLE_MPI + obj_pzz = PDCobj_open_col("obj-var-pzz", pdc_id); +#else + obj_pzz = PDCobj_open("obj-var-xx", pdc_id); +#endif if (obj_pzz == 0) { printf("Error when open object %s\n", "obj-var-pzz"); exit(-1); } - obj_id11 = PDCobj_open("id11", pdc_id); +#ifdef ENABLE_MPI + obj_id11 = PDCobj_open_col("id11", pdc_id); +#else + obj_id11 = PDCobj_open("obj-var-xx", pdc_id); +#endif if (obj_id11 == 0) { printf("Error when open object %s\n", "id11"); exit(-1); } - obj_id22 = PDCobj_open("id22", pdc_id); +#ifdef ENABLE_MPI + obj_id22 = PDCobj_open_col("id22", pdc_id); +#else + obj_id22 = PDCobj_open("obj-var-xx", pdc_id); +#endif if (obj_id22 == 0) { printf("Error when open object %s\n", "id22"); exit(-1); diff --git a/examples/bdcats_batch.c b/examples/bdcats_batch.c index 2bfb07f05..fab0f507a 100644 --- a/examples/bdcats_batch.c +++ b/examples/bdcats_batch.c @@ -45,7 +45,8 @@ uniform_random_number() void print_usage() { - printf("Usage: srun -n ./vpicio sleep_time timestamps #particles\n"); + printf("Usage: srun -n bdcats_batch sleep_time timestep #particles test_method(0:old API, 1:wait, " + "default 2:wait all)\n"); } int @@ -81,7 +82,7 @@ main(int argc, char **argv) *transfer_request_py, *transfer_request_pz, *transfer_request_id1, *transfer_request_id2, *ptr, *temp_requests; - uint64_t timestamps = 10; + uint64_t timestep = 10; double start, end, transfer_start = .0, transfer_wait = .0, transfer_create = .0, transfer_close = .0, max_time, min_time, avg_time, total_time, start_total_time; @@ -99,7 +100,7 @@ main(int argc, char **argv) sleep_time = (unsigned)atoi(argv[1]); } if (argc >= 3) { - timestamps = atoll(argv[2]); + timestep = atoll(argv[2]); } if (argc >= 4) { numparticles = atoll(argv[3]); @@ -110,8 +111,8 @@ main(int argc, char **argv) test_method = atoi(argv[4]); } if (!rank) { - printf("sleep time = %u, timestamps = %" PRIu64 ", numparticles = %" PRIu64 ", test_method = %d\n", - sleep_time, timestamps, numparticles, test_method); + printf("sleep time = %u, timestep = %" PRIu64 ", numparticles = %" PRIu64 ", test_method = %d\n", + sleep_time, timestep, numparticles, test_method); } x = (float *)malloc(numparticles * sizeof(float)); @@ -128,14 +129,14 @@ main(int argc, char **argv) // create a pdc pdc_id = PDCinit("pdc"); - obj_xx = (pdcid_t *)malloc(sizeof(pdcid_t) * timestamps); - obj_yy = (pdcid_t *)malloc(sizeof(pdcid_t) * timestamps); - obj_zz = (pdcid_t *)malloc(sizeof(pdcid_t) * timestamps); - obj_pxx = (pdcid_t *)malloc(sizeof(pdcid_t) * timestamps); - obj_pyy = (pdcid_t *)malloc(sizeof(pdcid_t) * timestamps); - obj_pzz = (pdcid_t *)malloc(sizeof(pdcid_t) * timestamps); - obj_id11 = (pdcid_t *)malloc(sizeof(pdcid_t) * timestamps); - obj_id22 = (pdcid_t *)malloc(sizeof(pdcid_t) * timestamps); + obj_xx = (pdcid_t *)malloc(sizeof(pdcid_t) * timestep); + obj_yy = (pdcid_t *)malloc(sizeof(pdcid_t) * timestep); + obj_zz = (pdcid_t *)malloc(sizeof(pdcid_t) * timestep); + obj_pxx = (pdcid_t *)malloc(sizeof(pdcid_t) * timestep); + obj_pyy = (pdcid_t *)malloc(sizeof(pdcid_t) * timestep); + obj_pzz = (pdcid_t *)malloc(sizeof(pdcid_t) * timestep); + obj_id11 = (pdcid_t *)malloc(sizeof(pdcid_t) * timestep); + obj_id22 = (pdcid_t *)malloc(sizeof(pdcid_t) * timestep); offset = (uint64_t *)malloc(sizeof(uint64_t) * ndim); offset_remote = (uint64_t *)malloc(sizeof(uint64_t) * ndim); @@ -153,69 +154,101 @@ main(int argc, char **argv) region_id1 = PDCregion_create(ndim, offset, mysize); region_id2 = PDCregion_create(ndim, offset, mysize); - transfer_request_x = (pdcid_t *)malloc(sizeof(pdcid_t) * (timestamps + 1) * N_OBJS); - ptr = transfer_request_x + timestamps; + transfer_request_x = (pdcid_t *)malloc(sizeof(pdcid_t) * (timestep + 1) * N_OBJS); + ptr = transfer_request_x + timestep; transfer_request_y = ptr; - ptr += timestamps; + ptr += timestep; transfer_request_z = ptr; - ptr += timestamps; + ptr += timestep; transfer_request_px = ptr; - ptr += timestamps; + ptr += timestep; transfer_request_py = ptr; - ptr += timestamps; + ptr += timestep; transfer_request_pz = ptr; - ptr += timestamps; + ptr += timestep; transfer_request_id1 = ptr; - ptr += timestamps; + ptr += timestep; transfer_request_id2 = ptr; - ptr += timestamps; + ptr += timestep; temp_requests = ptr; - for (i = 0; i < timestamps; ++i) { + for (i = 0; i < timestep; ++i) { sprintf(obj_name, "obj-var-xx %" PRIu64 "", i); +#ifdef ENABLE_MPI obj_xx[i] = PDCobj_open_col(obj_name, pdc_id); +#else + obj_xx[i] = PDCobj_open(obj_name, pdc_id); +#endif if (obj_xx[i] == 0) { printf("Error getting an object id of %s from server, exit...\n", "obj-var-xx"); exit(-1); } sprintf(obj_name, "obj-var-yy %" PRIu64 "", i); +#ifdef ENABLE_MPI obj_yy[i] = PDCobj_open_col(obj_name, pdc_id); +#else + obj_yy[i] = PDCobj_open(obj_name, pdc_id); +#endif if (obj_yy[i] == 0) { printf("Error getting an object id of %s from server, exit...\n", "obj-var-yy"); exit(-1); } sprintf(obj_name, "obj-var-zz %" PRIu64 "", i); +#ifdef ENABLE_MPI obj_zz[i] = PDCobj_open_col(obj_name, pdc_id); +#else + obj_zz[i] = PDCobj_open(obj_name, pdc_id); +#endif if (obj_zz[i] == 0) { printf("Error getting an object id of %s from server, exit...\n", "obj-var-zz"); exit(-1); } sprintf(obj_name, "obj-var-pxx %" PRIu64 "", i); +#ifdef ENABLE_MPI obj_pxx[i] = PDCobj_open_col(obj_name, pdc_id); +#else + obj_pxx[i] = PDCobj_open(obj_name, pdc_id); +#endif if (obj_pxx[i] == 0) { printf("Error getting an object id of %s from server, exit...\n", "obj-var-pxx"); exit(-1); } sprintf(obj_name, "obj-var-pyy %" PRIu64 "", i); +#ifdef ENABLE_MPI obj_pyy[i] = PDCobj_open_col(obj_name, pdc_id); +#else + obj_pyy[i] = PDCobj_open(obj_name, pdc_id); +#endif if (obj_pyy[i] == 0) { printf("Error getting an object id of %s from server, exit...\n", "obj-var-pyy"); exit(-1); } sprintf(obj_name, "obj-var-pzz %" PRIu64 "", i); +#ifdef ENABLE_MPI obj_pzz[i] = PDCobj_open_col(obj_name, pdc_id); +#else + obj_pzz[i] = PDCobj_open(obj_name, pdc_id); +#endif if (obj_pzz[i] == 0) { printf("Error getting an object id of %s from server, exit...\n", "obj-var-pzz"); exit(-1); } sprintf(obj_name, "id11 %" PRIu64 "", i); +#ifdef ENABLE_MPI obj_id11[i] = PDCobj_open_col(obj_name, pdc_id); +#else + obj_id11[i] = PDCobj_open(obj_name, pdc_id); +#endif if (obj_id11[i] == 0) { printf("Error getting an object id of %s from server, exit...\n", "obj_id11"); exit(-1); } sprintf(obj_name, "id22 %" PRIu64 "", i); +#ifdef ENABLE_MPI obj_id22[i] = PDCobj_open_col(obj_name, pdc_id); +#else + obj_id22[i] = PDCobj_open(obj_name, pdc_id); +#endif if (obj_id22[i] == 0) { printf("Error getting an object id of %s from server, exit...\n", "obj_id22"); exit(-1); @@ -227,7 +260,7 @@ main(int argc, char **argv) start_total_time = MPI_Wtime(); #endif - for (i = 0; i < timestamps; ++i) { + for (i = 0; i < timestep; ++i) { offset_remote[0] = rank * numparticles; region_xx = PDCregion_create(ndim, offset_remote, mysize); @@ -244,49 +277,49 @@ main(int argc, char **argv) #endif if (test_method) { transfer_request_x[i] = - PDCregion_transfer_create(&x[0], PDC_WRITE, obj_xx[i], region_x, region_xx); + PDCregion_transfer_create(&x[0], PDC_READ, obj_xx[i], region_x, region_xx); if (transfer_request_x[i] == 0) { printf("Array x transfer request creation failed\n"); return 1; } transfer_request_y[i] = - PDCregion_transfer_create(&y[0], PDC_WRITE, obj_yy[i], region_y, region_yy); + PDCregion_transfer_create(&y[0], PDC_READ, obj_yy[i], region_y, region_yy); if (transfer_request_y[i] == 0) { printf("Array y transfer request creation failed\n"); return 1; } transfer_request_z[i] = - PDCregion_transfer_create(&z[0], PDC_WRITE, obj_zz[i], region_z, region_zz); + PDCregion_transfer_create(&z[0], PDC_READ, obj_zz[i], region_z, region_zz); if (transfer_request_z[i] == 0) { printf("Array z transfer request creation failed\n"); return 1; } transfer_request_px[i] = - PDCregion_transfer_create(&px[0], PDC_WRITE, obj_pxx[i], region_px, region_pxx); + PDCregion_transfer_create(&px[0], PDC_READ, obj_pxx[i], region_px, region_pxx); if (transfer_request_px[i] == 0) { printf("Array px transfer request creation failed\n"); return 1; } transfer_request_py[i] = - PDCregion_transfer_create(&py[0], PDC_WRITE, obj_pyy[i], region_py, region_pyy); + PDCregion_transfer_create(&py[0], PDC_READ, obj_pyy[i], region_py, region_pyy); if (transfer_request_py[i] == 0) { printf("Array py transfer request creation failed\n"); return 1; } transfer_request_pz[i] = - PDCregion_transfer_create(&pz[0], PDC_WRITE, obj_pzz[i], region_pz, region_pzz); + PDCregion_transfer_create(&pz[0], PDC_READ, obj_pzz[i], region_pz, region_pzz); if (transfer_request_pz[i] == 0) { printf("Array pz transfer request creation failed\n"); return 1; } transfer_request_id1[i] = - PDCregion_transfer_create(&id1[0], PDC_WRITE, obj_id11[i], region_id1, region_id11); + PDCregion_transfer_create(&id1[0], PDC_READ, obj_id11[i], region_id1, region_id11); if (transfer_request_id1[i] == 0) { printf("Array id1 transfer request creation failed\n"); return 1; } transfer_request_id2[i] = - PDCregion_transfer_create(&id2[0], PDC_WRITE, obj_id22[i], region_id2, region_id22); + PDCregion_transfer_create(&id2[0], PDC_READ, obj_id22[i], region_id2, region_id22); if (transfer_request_id2[i] == 0) { printf("Array id2 transfer request creation failed\n"); return 1; @@ -549,7 +582,7 @@ main(int argc, char **argv) MPI_Barrier(MPI_COMM_WORLD); #endif - for (i = 0; i < timestamps; ++i) { + for (i = 0; i < timestep; ++i) { if (PDCobj_close(obj_xx[i]) < 0) { printf("fail to close obj_xx\n"); return 1; diff --git a/examples/mpi_test.sh b/examples/mpi_test.sh index de962fcaa..99b710919 100755 --- a/examples/mpi_test.sh +++ b/examples/mpi_test.sh @@ -4,8 +4,8 @@ # defined and points to the MPI libraries used by the linker (e.g. -Lname); - p = PDC_FREE(struct _pdc_class, p); + p = (struct _pdc_class *)(intptr_t)PDC_free(p); FUNC_LEAVE(ret_value); } @@ -214,7 +214,7 @@ PDCclose(pdcid_t pdcid) PDC_class_end(); - pdc_id_list_g = PDC_FREE(struct pdc_id_list, pdc_id_list_g); + pdc_id_list_g = (struct pdc_id_list *)(intptr_t)PDC_free(pdc_id_list_g); // Finalize METADATA PDC_Client_finalize(); diff --git a/src/api/pdc_analysis/pdc_analysis.c b/src/api/pdc_analysis/pdc_analysis.c index 3e603df4d..0add84746 100644 --- a/src/api/pdc_analysis/pdc_analysis.c +++ b/src/api/pdc_analysis/pdc_analysis.c @@ -453,7 +453,8 @@ PDCobj_analysis_register(char *func, pdcid_t iterIn, pdcid_t iterOut) if ((ftnPtr = ftnHandle) == NULL) PGOTO_ERROR(FAIL, "Analysis function lookup failed"); - if ((thisFtn = PDC_MALLOC(struct _pdc_region_analysis_ftn_info)) == NULL) + if ((thisFtn = (struct _pdc_region_analysis_ftn_info *)PDC_malloc( + sizeof(struct _pdc_region_analysis_ftn_info))) == NULL) PGOTO_ERROR(FAIL, "PDC register_obj_analysis memory allocation failed"); thisFtn->ftnPtr = (int (*)())ftnPtr; diff --git a/src/api/pdc_obj/pdc_cont.c b/src/api/pdc_obj/pdc_cont.c index b589188e6..4366c4156 100644 --- a/src/api/pdc_obj/pdc_cont.c +++ b/src/api/pdc_obj/pdc_cont.c @@ -61,11 +61,11 @@ PDCcont_create(const char *cont_name, pdcid_t cont_prop_id) FUNC_ENTER(NULL); - p = PDC_MALLOC(struct _pdc_cont_info); + p = (struct _pdc_cont_info *)PDC_malloc(sizeof(struct _pdc_cont_info)); if (!p) PGOTO_ERROR(0, "PDC container memory allocation failed"); - p->cont_info_pub = PDC_MALLOC(struct pdc_cont_info); + p->cont_info_pub = (struct pdc_cont_info *)PDC_malloc(sizeof(struct pdc_cont_info)); if (!p->cont_info_pub) PGOTO_ERROR(0, "PDC pub container memory allocation failed"); p->cont_info_pub->name = strdup(cont_name); @@ -73,12 +73,12 @@ PDCcont_create(const char *cont_name, pdcid_t cont_prop_id) id_info = PDC_find_id(cont_prop_id); cont_prop = (struct _pdc_cont_prop *)(id_info->obj_ptr); - p->cont_pt = PDC_CALLOC(1, struct _pdc_cont_prop); + p->cont_pt = (struct _pdc_cont_prop *)PDC_calloc(1, sizeof(struct _pdc_cont_prop)); if (!p->cont_pt) PGOTO_ERROR(0, "PDC container prop memory allocation failed"); memcpy(p->cont_pt, cont_prop, sizeof(struct _pdc_cont_prop)); - p->cont_pt->pdc = PDC_CALLOC(1, struct _pdc_class); + p->cont_pt->pdc = (struct _pdc_class *)PDC_calloc(1, sizeof(struct _pdc_class)); if (!p->cont_pt->pdc) PGOTO_ERROR(0, "PDC container pdc class memory allocation failed"); if (cont_prop->pdc->name) @@ -110,11 +110,11 @@ PDCcont_create_col(const char *cont_name, pdcid_t cont_prop_id) FUNC_ENTER(NULL); - p = PDC_MALLOC(struct _pdc_cont_info); + p = (struct _pdc_cont_info *)PDC_malloc(sizeof(struct _pdc_cont_info)); if (!p) PGOTO_ERROR(0, "PDC container memory allocation failed"); - p->cont_info_pub = PDC_MALLOC(struct pdc_cont_info); + p->cont_info_pub = (struct pdc_cont_info *)PDC_malloc(sizeof(struct pdc_cont_info)); if (!p->cont_info_pub) PGOTO_ERROR(0, "PDC pub container memory allocation failed"); p->cont_info_pub->name = strdup(cont_name); @@ -122,12 +122,12 @@ PDCcont_create_col(const char *cont_name, pdcid_t cont_prop_id) id_info = PDC_find_id(cont_prop_id); cont_prop = (struct _pdc_cont_prop *)(id_info->obj_ptr); - p->cont_pt = PDC_CALLOC(1, struct _pdc_cont_prop); + p->cont_pt = (struct _pdc_cont_prop *)PDC_calloc(1, sizeof(struct _pdc_cont_prop)); if (!p->cont_pt) PGOTO_ERROR(0, "PDC container prop memory allocation failed"); memcpy(p->cont_pt, cont_prop, sizeof(struct _pdc_cont_prop)); - p->cont_pt->pdc = PDC_CALLOC(1, struct _pdc_class); + p->cont_pt->pdc = (struct _pdc_class *)PDC_calloc(1, sizeof(struct _pdc_class)); if (!p->cont_pt->pdc) PGOTO_ERROR(0, "PDC container pdc class memory allocation failed"); if (cont_prop->pdc->name) @@ -157,11 +157,11 @@ PDC_cont_create_local(pdcid_t pdc, const char *cont_name, uint64_t cont_meta_id) FUNC_ENTER(NULL); - p = PDC_MALLOC(struct _pdc_cont_info); + p = (struct _pdc_cont_info *)PDC_malloc(sizeof(struct _pdc_cont_info)); if (!p) PGOTO_ERROR(0, "PDC container memory allocation failed"); - p->cont_info_pub = PDC_MALLOC(struct pdc_cont_info); + p->cont_info_pub = (struct pdc_cont_info *)PDC_malloc(sizeof(struct pdc_cont_info)); if (!p) PGOTO_ERROR(0, "PDC container memory allocation failed"); p->cont_info_pub->name = strdup(cont_name); @@ -171,12 +171,12 @@ PDC_cont_create_local(pdcid_t pdc, const char *cont_name, uint64_t cont_meta_id) id_info = PDC_find_id(cont_prop_id); cont_prop = (struct _pdc_cont_prop *)(id_info->obj_ptr); - p->cont_pt = PDC_CALLOC(1, struct _pdc_cont_prop); + p->cont_pt = (struct _pdc_cont_prop *)PDC_calloc(1, sizeof(struct _pdc_cont_prop)); if (!p->cont_pt) PGOTO_ERROR(0, "PDC container prop memory allocation failed"); memcpy(p->cont_pt, cont_prop, sizeof(struct _pdc_cont_prop)); - p->cont_pt->pdc = PDC_CALLOC(1, struct _pdc_class); + p->cont_pt->pdc = (struct _pdc_class *)PDC_calloc(1, sizeof(struct _pdc_class)); if (!p->cont_pt->pdc) PGOTO_ERROR(0, "PDC container pdc class memory allocation failed"); @@ -222,11 +222,11 @@ PDC_cont_close(struct _pdc_cont_info *cp) FUNC_ENTER(NULL); free((void *)(cp->cont_info_pub->name)); - cp->cont_info_pub = PDC_FREE(struct pdc_cont_info, cp->cont_info_pub); + cp->cont_info_pub = (struct pdc_cont_info *)(intptr_t)PDC_free(cp->cont_info_pub); free(cp->cont_pt->pdc->name); - cp->cont_pt->pdc = PDC_FREE(struct _pdc_class, cp->cont_pt->pdc); - cp->cont_pt = PDC_FREE(struct _pdc_cont_prop, cp->cont_pt); - cp = PDC_FREE(struct _pdc_cont_info, cp); + cp->cont_pt->pdc = (struct _pdc_class *)(intptr_t)PDC_free(cp->cont_pt->pdc); + cp->cont_pt = (struct _pdc_cont_prop *)(intptr_t)PDC_free(cp->cont_pt); + cp = (struct _pdc_cont_info *)(intptr_t)PDC_free(cp); FUNC_LEAVE(ret_value); } @@ -321,25 +321,25 @@ PDC_cont_get_info(pdcid_t cont_id) PGOTO_ERROR(NULL, "cannot locate object"); info = (struct _pdc_cont_info *)(id_info->obj_ptr); - ret_value = PDC_CALLOC(1, struct _pdc_cont_info); + ret_value = (struct _pdc_cont_info *)PDC_calloc(1, sizeof(struct _pdc_cont_info)); if (ret_value) memcpy(ret_value, info, sizeof(struct _pdc_cont_info)); else PGOTO_ERROR(NULL, "cannot allocate ret_value"); - ret_value->cont_info_pub = PDC_CALLOC(1, struct pdc_cont_info); + ret_value->cont_info_pub = (struct pdc_cont_info *)PDC_calloc(1, sizeof(struct pdc_cont_info)); if (ret_value->cont_info_pub) memcpy(ret_value->cont_info_pub, info->cont_info_pub, sizeof(struct pdc_cont_info)); if (info->cont_info_pub->name) ret_value->cont_info_pub->name = strdup(info->cont_info_pub->name); - ret_value->cont_pt = PDC_MALLOC(struct _pdc_cont_prop); + ret_value->cont_pt = (struct _pdc_cont_prop *)PDC_malloc(sizeof(struct _pdc_cont_prop)); if (ret_value->cont_pt) memcpy(ret_value->cont_pt, info->cont_pt, sizeof(struct _pdc_cont_prop)); else PGOTO_ERROR(NULL, "cannot allocate ret_value->cont_pt"); - ret_value->cont_pt->pdc = PDC_CALLOC(1, struct _pdc_class); + ret_value->cont_pt->pdc = (struct _pdc_class *)PDC_calloc(1, sizeof(struct _pdc_class)); if (ret_value->cont_pt->pdc) { ret_value->cont_pt->pdc->local_id = info->cont_pt->pdc->local_id; if (info->cont_pt->pdc->name) @@ -366,7 +366,7 @@ PDCcont_get_info(const char *cont_name) tmp = PDC_cont_get_info(cont_id); - ret_value = PDC_CALLOC(1, struct pdc_cont_info); + ret_value = (struct pdc_cont_info *)PDC_calloc(1, sizeof(struct pdc_cont_info)); if (!ret_value) PGOTO_ERROR(NULL, "cannot allocate memory"); @@ -440,7 +440,7 @@ PDCcont_iter_get_info(cont_handle *chandle) if (info == NULL) PGOTO_ERROR(NULL, "PDC container info memory allocation failed"); - ret_value = PDC_CALLOC(1, struct pdc_cont_info); + ret_value = (struct pdc_cont_info *)PDC_calloc(1, sizeof(struct pdc_cont_info)); if (!ret_value) PGOTO_ERROR(NULL, "failed to allocate memory"); diff --git a/src/api/pdc_obj/pdc_obj.c b/src/api/pdc_obj/pdc_obj.c index 95687826c..7457e4d79 100644 --- a/src/api/pdc_obj/pdc_obj.c +++ b/src/api/pdc_obj/pdc_obj.c @@ -72,7 +72,7 @@ PDCobj_create(pdcid_t cont_id, const char *obj_name, pdcid_t obj_prop_id) pdcid_t ret_value = 0; FUNC_ENTER(NULL); #if 0 - p = PDC_MALLOC(struct _pdc_obj_info); + p = (struct _pdc_obj_info *)PDC_malloc(sizeof(struct _pdc_obj_info)); if (!p) PGOTO_ERROR(0, "PDC object memory allocation failed"); p->metadata = NULL; @@ -86,24 +86,24 @@ PDCobj_create(pdcid_t cont_id, const char *obj_name, pdcid_t obj_prop_id) cont_info = (struct _pdc_cont_info *)(id_info->obj_ptr); /* struct _pdc_cont_info field */ - p->cont = PDC_CALLOC(1,struct _pdc_cont_info); + p->cont = (struct _pdc_cont_info *)PDC_calloc(1, sizeof(struct _pdc_cont_info)); if (!p->cont) PGOTO_ERROR(0, "PDC object container memory allocation failed"); memcpy(p->cont, cont_info, sizeof(struct _pdc_cont_info)); - p->cont->cont_info_pub = PDC_CALLOC(1,struct pdc_cont_info); + p->cont->cont_info_pub = (struct pdc_cont_info *)PDC_calloc(1, sizeof(struct pdc_cont_info)); if (!p->cont->cont_info_pub) PGOTO_ERROR(0, "PDC object pub container memory allocation failed"); memcpy(p->cont->cont_info_pub, cont_info->cont_info_pub, sizeof(struct pdc_cont_info)); if (cont_info->cont_info_pub->name) p->cont->cont_info_pub->name = strdup(cont_info->cont_info_pub->name); - p->cont->cont_pt = PDC_CALLOC(1,struct _pdc_cont_prop); + p->cont->cont_pt = (struct _pdc_cont_prop *)PDC_calloc(1, sizeof(struct _pdc_cont_prop)); if (!p->cont->cont_pt) PGOTO_ERROR(0, "PDC object container property memory allocation failed"); memcpy(p->cont->cont_pt, cont_info->cont_pt, sizeof(struct _pdc_cont_prop)); - p->cont->cont_pt->pdc = PDC_CALLOC(1,struct _pdc_class); + p->cont->cont_pt->pdc = (struct _pdc_class *)PDC_calloc(1, sizeof(struct _pdc_class)); if (!p->cont->cont_pt->pdc) PGOTO_ERROR(0, "PDC object container property pdc memory allocation failed"); p->cont->cont_pt->pdc->name = strdup(cont_info->cont_pt->pdc->name); @@ -115,20 +115,20 @@ PDCobj_create(pdcid_t cont_id, const char *obj_name, pdcid_t obj_prop_id) obj_prop = (struct _pdc_obj_prop *)(id_info->obj_ptr); /* struct _pdc_obj_prop field */ - p->obj_pt = PDC_CALLOC(1,struct _pdc_obj_prop); + p->obj_pt = (struct _pdc_obj_prop *)PDC_calloc(1, sizeof(struct _pdc_obj_prop)); if (!p->obj_pt) PGOTO_ERROR(0, "PDC object property memory allocation failed"); memcpy(p->obj_pt, obj_prop, sizeof(struct _pdc_obj_prop)); if (obj_prop->app_name) p->obj_pt->app_name = strdup(obj_prop->app_name); - p->obj_pt->pdc = PDC_CALLOC(1,struct _pdc_class); + p->obj_pt->pdc = (struct _pdc_class *)PDC_calloc(1, sizeof(struct _pdc_class)); if (!p->obj_pt->pdc) PGOTO_ERROR(0, "cannot allocate ret_value->pdc"); p->obj_pt->pdc->name = strdup(obj_prop->pdc->name); p->obj_pt->pdc->local_id = obj_prop->pdc->local_id; /* struct pdc_obj_prop field */ - p->obj_pt->obj_prop_pub = PDC_CALLOC(1,struct pdc_obj_prop); + p->obj_pt->obj_prop_pub = (struct pdc_obj_prop *)PDC_calloc(1, sizeof(struct pdc_obj_prop)); if (!p->obj_pt->obj_prop_pub) PGOTO_ERROR(0, "cannot allocate ret_value->obj_pt->obj_prop_pub"); p->obj_pt->obj_prop_pub->ndim = obj_prop->obj_prop_pub->ndim; @@ -146,7 +146,7 @@ PDCobj_create(pdcid_t cont_id, const char *obj_name, pdcid_t obj_prop_id) if (obj_prop->tags) p->obj_pt->tags = strdup(obj_prop->tags); - p->obj_info_pub = PDC_MALLOC(struct pdc_obj_info); + p->obj_info_pub = (struct pdc_obj_info *)PDC_malloc(sizeof(struct pdc_obj_info)); if (!p->obj_info_pub) PGOTO_ERROR(0, "PDC pub object memory allocation failed"); p->obj_info_pub->name = strdup(obj_name); @@ -156,7 +156,7 @@ PDCobj_create(pdcid_t cont_id, const char *obj_name, pdcid_t obj_prop_id) if (ret == FAIL) PGOTO_ERROR(0, "Unable to create object on server!"); - p->obj_info_pub->obj_pt = PDC_CALLOC(1,struct pdc_obj_prop); + p->obj_info_pub->obj_pt = (struct pdc_obj_prop *)PDC_calloc(1, sizeof(struct pdc_obj_prop)); if (!p->obj_info_pub->obj_pt) PGOTO_ERROR(0, "PDC object prop memory allocation failed"); memcpy(p->obj_info_pub->obj_pt, p->obj_pt->obj_prop_pub, sizeof(struct pdc_obj_prop)); @@ -239,7 +239,7 @@ PDC_obj_create(pdcid_t cont_id, const char *obj_name, pdcid_t obj_prop_id, _pdc_ FUNC_ENTER(NULL); - p = PDC_MALLOC(struct _pdc_obj_info); + p = (struct _pdc_obj_info *)PDC_malloc(sizeof(struct _pdc_obj_info)); if (!p) PGOTO_ERROR(0, "PDC object memory allocation failed"); p->metadata = NULL; @@ -254,13 +254,13 @@ PDC_obj_create(pdcid_t cont_id, const char *obj_name, pdcid_t obj_prop_id, _pdc_ /* struct _pdc_cont_info field */ cont_info = (struct _pdc_cont_info *)(id_info->obj_ptr); - p->cont = PDC_CALLOC(1, struct _pdc_cont_info); + p->cont = (struct _pdc_cont_info *)PDC_calloc(1, sizeof(struct _pdc_cont_info)); if (!p->cont) PGOTO_ERROR(0, "PDC object container memory allocation failed"); memcpy(p->cont, cont_info, sizeof(struct _pdc_cont_info)); /* struct pdc_cont_info field */ - p->cont->cont_info_pub = PDC_CALLOC(1, struct pdc_cont_info); + p->cont->cont_info_pub = (struct pdc_cont_info *)PDC_calloc(1, sizeof(struct pdc_cont_info)); if (!p->cont->cont_info_pub) PGOTO_ERROR(0, "PDC object pub container memory allocation failed"); memcpy(p->cont->cont_info_pub, cont_info->cont_info_pub, sizeof(struct pdc_cont_info)); @@ -268,13 +268,13 @@ PDC_obj_create(pdcid_t cont_id, const char *obj_name, pdcid_t obj_prop_id, _pdc_ p->cont->cont_info_pub->name = strdup(cont_info->cont_info_pub->name); /* struct _pdc_cont_prop field */ - p->cont->cont_pt = PDC_CALLOC(1, struct _pdc_cont_prop); + p->cont->cont_pt = (struct _pdc_cont_prop *)PDC_calloc(1, sizeof(struct _pdc_cont_prop)); if (!p->cont->cont_pt) PGOTO_ERROR(0, "PDC object container property memory allocation failed"); memcpy(p->cont->cont_pt, cont_info->cont_pt, sizeof(struct _pdc_cont_prop)); /* struct _pdc_class field */ - p->cont->cont_pt->pdc = PDC_CALLOC(1, struct _pdc_class); + p->cont->cont_pt->pdc = (struct _pdc_class *)PDC_calloc(1, sizeof(struct _pdc_class)); if (!p->cont->cont_pt->pdc) PGOTO_ERROR(0, "PDC object container property pdc memory allocation failed"); if (cont_info->cont_pt->pdc->name) @@ -287,7 +287,7 @@ PDC_obj_create(pdcid_t cont_id, const char *obj_name, pdcid_t obj_prop_id, _pdc_ obj_prop = (struct _pdc_obj_prop *)(id_info->obj_ptr); /* struct _pdc_obj_prop field */ - p->obj_pt = PDC_CALLOC(1, struct _pdc_obj_prop); + p->obj_pt = (struct _pdc_obj_prop *)PDC_calloc(1, sizeof(struct _pdc_obj_prop)); if (!p->obj_pt) PGOTO_ERROR(0, "PDC object property memory allocation failed"); memcpy(p->obj_pt, obj_prop, sizeof(struct _pdc_obj_prop)); @@ -299,7 +299,7 @@ PDC_obj_create(pdcid_t cont_id, const char *obj_name, pdcid_t obj_prop_id, _pdc_ p->obj_pt->tags = strdup(obj_prop->tags); p->obj_pt->locus = PDC_get_execution_locus(); - p->obj_pt->pdc = PDC_CALLOC(1, struct _pdc_class); + p->obj_pt->pdc = (struct _pdc_class *)PDC_calloc(1, sizeof(struct _pdc_class)); if (!p->obj_pt->pdc) PGOTO_ERROR(0, "cannot allocate ret_value->pdc"); if (obj_prop->pdc->name) @@ -307,7 +307,7 @@ PDC_obj_create(pdcid_t cont_id, const char *obj_name, pdcid_t obj_prop_id, _pdc_ p->obj_pt->pdc->local_id = obj_prop->pdc->local_id; /* struct pdc_obj_prop field */ - p->obj_pt->obj_prop_pub = PDC_CALLOC(1, struct pdc_obj_prop); + p->obj_pt->obj_prop_pub = (struct pdc_obj_prop *)PDC_calloc(1, sizeof(struct pdc_obj_prop)); if (!p->obj_pt->obj_prop_pub) PGOTO_ERROR(0, "cannot allocate ret_value->obj_pt->obj_prop_pub"); p->obj_pt->obj_prop_pub->ndim = obj_prop->obj_prop_pub->ndim; @@ -329,7 +329,7 @@ PDC_obj_create(pdcid_t cont_id, const char *obj_name, pdcid_t obj_prop_id, _pdc_ p->local_transfer_request_end = NULL; p->local_transfer_request_size = 0; /* struct pdc_obj_info field */ - p->obj_info_pub = PDC_MALLOC(struct pdc_obj_info); + p->obj_info_pub = (struct pdc_obj_info *)PDC_malloc(sizeof(struct pdc_obj_info)); if (!p->obj_info_pub) PGOTO_ERROR(0, "PDC pub object memory allocation failed"); p->obj_info_pub->name = strdup(obj_name); @@ -349,7 +349,7 @@ PDC_obj_create(pdcid_t cont_id, const char *obj_name, pdcid_t obj_prop_id, _pdc_ p->obj_pt->obj_prop_pub->region_partition, p->obj_pt->obj_prop_pub->consistency, p); - p->obj_info_pub->obj_pt = PDC_CALLOC(1, struct pdc_obj_prop); + p->obj_info_pub->obj_pt = (struct pdc_obj_prop *)PDC_calloc(1, sizeof(struct pdc_obj_prop)); if (!p->obj_info_pub->obj_pt) PGOTO_ERROR(0, "PDC object prop memory allocation failed"); memcpy(p->obj_info_pub->obj_pt, p->obj_pt->obj_prop_pub, sizeof(struct pdc_obj_prop)); @@ -393,23 +393,23 @@ PDC_obj_close(struct _pdc_obj_info *op) perr_t ret_value = SUCCEED; pdcid_t * transfer_request_id; pdc_local_transfer_request *temp, *previous; - int i; + int i, n; FUNC_ENTER(NULL); if (op->local_transfer_request_size) { transfer_request_id = (pdcid_t *)malloc(sizeof(pdcid_t) * op->local_transfer_request_size); temp = op->local_transfer_request_head; - i = 0; + n = 0; while (temp != NULL) { - transfer_request_id[i] = temp->local_id; + transfer_request_id[n] = temp->local_id; previous = temp; temp = temp->next; free(previous); - ++i; + ++n; } - PDCregion_transfer_wait_all(transfer_request_id, op->local_transfer_request_size); - for (i = 0; i < op->local_transfer_request_size; ++i) { + PDCregion_transfer_wait_all(transfer_request_id, n); + for (i = 0; i < n; ++i) { PDCregion_transfer_close(transfer_request_id[i]); } free(transfer_request_id); @@ -417,28 +417,28 @@ PDC_obj_close(struct _pdc_obj_info *op) free((void *)(op->obj_info_pub->name)); free(op->cont->cont_info_pub->name); - op->cont->cont_info_pub = PDC_FREE(struct pdc_cont_info, op->cont->cont_info_pub); + op->cont->cont_info_pub = (struct pdc_cont_info *)(intptr_t)PDC_free(op->cont->cont_info_pub); free(op->cont->cont_pt->pdc->name); - op->cont->cont_pt->pdc = PDC_FREE(struct _pdc_class, op->cont->cont_pt->pdc); - op->cont->cont_pt = PDC_FREE(struct _pdc_cont_prop, op->cont->cont_pt); - op->cont = PDC_FREE(struct _pdc_cont_info, op->cont); + op->cont->cont_pt->pdc = (struct _pdc_class *)(intptr_t)PDC_free(op->cont->cont_pt->pdc); + op->cont->cont_pt = (struct _pdc_cont_prop *)(intptr_t)PDC_free(op->cont->cont_pt); + op->cont = (struct _pdc_cont_info *)(intptr_t)PDC_free(op->cont); free(op->obj_pt->pdc->name); - op->obj_pt->pdc = PDC_FREE(struct _pdc_class, op->obj_pt->pdc); + op->obj_pt->pdc = (struct _pdc_class *)(intptr_t)PDC_free(op->obj_pt->pdc); free(op->obj_pt->obj_prop_pub->dims); - op->obj_pt->obj_prop_pub = PDC_FREE(struct pdc_obj_prop, op->obj_pt->obj_prop_pub); + op->obj_pt->obj_prop_pub = (struct pdc_obj_prop *)(intptr_t)PDC_free(op->obj_pt->obj_prop_pub); free(op->obj_pt->app_name); free(op->obj_pt->data_loc); free(op->obj_pt->tags); - op->obj_pt = PDC_FREE(struct _pdc_obj_prop, op->obj_pt); + op->obj_pt = (struct _pdc_obj_prop *)(intptr_t)PDC_free(op->obj_pt); if (op->metadata != NULL) free(op->metadata); free(op->obj_info_pub->obj_pt->dims); - op->obj_info_pub->obj_pt = PDC_FREE(struct pdc_obj_prop, op->obj_info_pub->obj_pt); - op->obj_info_pub = PDC_FREE(struct pdc_obj_info, op->obj_info_pub); + op->obj_info_pub->obj_pt = (struct pdc_obj_prop *)(intptr_t)PDC_free(op->obj_info_pub->obj_pt); + op->obj_info_pub = (struct pdc_obj_info *)(intptr_t)PDC_free(op->obj_info_pub); - op = PDC_FREE(struct _pdc_obj_info, op); + op = (struct _pdc_obj_info *)(intptr_t)PDC_free(op); FUNC_LEAVE(ret_value); } @@ -537,34 +537,34 @@ PDCobj_open_common(const char *obj_name, pdcid_t pdc, int is_col) FUNC_ENTER(NULL); - p = PDC_MALLOC(struct _pdc_obj_info); + p = (struct _pdc_obj_info *)PDC_malloc(sizeof(struct _pdc_obj_info)); if (!p) PGOTO_ERROR(0, "PDC object memory allocation failed"); - p->cont = PDC_CALLOC(1, struct _pdc_cont_info); + p->cont = (struct _pdc_cont_info *)PDC_calloc(1, sizeof(struct _pdc_cont_info)); if (!p->cont) PGOTO_ERROR(0, "PDC object container memory allocation failed"); - p->cont->cont_info_pub = PDC_CALLOC(1, struct pdc_cont_info); + p->cont->cont_info_pub = (struct pdc_cont_info *)PDC_calloc(1, sizeof(struct pdc_cont_info)); if (!p->cont->cont_info_pub) PGOTO_ERROR(0, "PDC object pub container memory allocation failed"); - p->cont->cont_pt = PDC_CALLOC(1, struct _pdc_cont_prop); + p->cont->cont_pt = (struct _pdc_cont_prop *)PDC_calloc(1, sizeof(struct _pdc_cont_prop)); if (!p->cont->cont_pt) PGOTO_ERROR(0, "PDC object container property memory allocation failed"); - p->cont->cont_pt->pdc = PDC_CALLOC(1, struct _pdc_class); + p->cont->cont_pt->pdc = (struct _pdc_class *)PDC_calloc(1, sizeof(struct _pdc_class)); if (!p->cont->cont_pt->pdc) PGOTO_ERROR(0, "PDC object container property pdc memory allocation failed"); - p->obj_pt = PDC_CALLOC(1, struct _pdc_obj_prop); + p->obj_pt = (struct _pdc_obj_prop *)PDC_calloc(1, sizeof(struct _pdc_obj_prop)); if (!p->obj_pt) PGOTO_ERROR(0, "PDC object property memory allocation failed"); - p->obj_pt->obj_prop_pub = PDC_CALLOC(1, struct pdc_obj_prop); + p->obj_pt->obj_prop_pub = (struct pdc_obj_prop *)PDC_calloc(1, sizeof(struct pdc_obj_prop)); if (!p->obj_pt->obj_prop_pub) PGOTO_ERROR(0, "PDC object property memory allocation failed"); - p->obj_info_pub = PDC_MALLOC(struct pdc_obj_info); + p->obj_info_pub = (struct pdc_obj_info *)PDC_malloc(sizeof(struct pdc_obj_info)); if (!p->obj_info_pub) PGOTO_ERROR(0, "PDC pub object memory allocation failed"); - p->obj_info_pub->obj_pt = PDC_CALLOC(1, struct pdc_obj_prop); + p->obj_info_pub->obj_pt = (struct pdc_obj_prop *)PDC_calloc(1, sizeof(struct pdc_obj_prop)); if (!p->obj_info_pub->obj_pt) PGOTO_ERROR(0, "PDC object prop memory allocation failed"); - p->obj_pt->pdc = PDC_CALLOC(1, struct _pdc_class); + p->obj_pt->pdc = (struct _pdc_class *)PDC_calloc(1, sizeof(struct _pdc_class)); if (!p->obj_pt->pdc) PGOTO_ERROR(0, "cannot allocate ret_value->pdc"); @@ -738,12 +738,12 @@ PDCobj_iter_get_info(obj_handle *ohandle) if (info == NULL) PGOTO_ERROR(NULL, "PDC container info memory allocation failed"); - ret_value = PDC_CALLOC(1, struct pdc_obj_info); + ret_value = (struct pdc_obj_info *)PDC_calloc(1, sizeof(struct pdc_obj_info)); if (!ret_value) PGOTO_ERROR(NULL, "failed to allocate memory"); memcpy(ret_value, info->obj_info_pub, sizeof(struct pdc_obj_info)); - ret_value->obj_pt = PDC_CALLOC(1, struct pdc_obj_prop); + ret_value->obj_pt = (struct pdc_obj_prop *)PDC_calloc(1, sizeof(struct pdc_obj_prop)); if (!ret_value->obj_pt) PGOTO_ERROR(NULL, "failed to allocate memory"); memcpy(ret_value->obj_pt, info->obj_info_pub->obj_pt, sizeof(struct pdc_obj_prop)); @@ -1058,14 +1058,14 @@ PDC_obj_get_info(pdcid_t obj_id) PGOTO_ERROR(NULL, "cannot locate object"); info = (struct _pdc_obj_info *)(obj->obj_ptr); - ret_value = PDC_CALLOC(1, struct _pdc_obj_info); + ret_value = (struct _pdc_obj_info *)PDC_calloc(1, sizeof(struct _pdc_obj_info)); if (ret_value) memcpy(ret_value, info, sizeof(struct _pdc_obj_info)); else PGOTO_ERROR(NULL, "cannot allocate ret_value"); /* struct pdc_obj_info field */ - ret_value->obj_info_pub = PDC_CALLOC(1, struct pdc_obj_info); + ret_value->obj_info_pub = (struct pdc_obj_info *)PDC_calloc(1, sizeof(struct pdc_obj_info)); if (ret_value->obj_info_pub) memcpy(ret_value->obj_info_pub, info->obj_info_pub, sizeof(struct pdc_obj_info)); else @@ -1075,7 +1075,7 @@ PDC_obj_get_info(pdcid_t obj_id) else ret_value->obj_info_pub->name = NULL; - ret_value->obj_info_pub->obj_pt = PDC_CALLOC(1, struct pdc_obj_prop); + ret_value->obj_info_pub->obj_pt = (struct pdc_obj_prop *)PDC_calloc(1, sizeof(struct pdc_obj_prop)); if (!ret_value->obj_info_pub->obj_pt) PGOTO_ERROR(NULL, "failed to allocate memory"); memcpy(ret_value->obj_info_pub->obj_pt, info->obj_info_pub->obj_pt, sizeof(struct pdc_obj_prop)); @@ -1089,13 +1089,13 @@ PDC_obj_get_info(pdcid_t obj_id) ret_value->metadata = NULL; // fill in struct _pdc_cont_info field in ret_value->cont - ret_value->cont = PDC_CALLOC(1, struct _pdc_cont_info); + ret_value->cont = (struct _pdc_cont_info *)PDC_calloc(1, sizeof(struct _pdc_cont_info)); if (ret_value->cont) memcpy(ret_value->cont, info->cont, sizeof(struct _pdc_cont_info)); else PGOTO_ERROR(NULL, "cannot allocate ret_value->cont"); - ret_value->cont->cont_info_pub = PDC_CALLOC(1, struct pdc_cont_info); + ret_value->cont->cont_info_pub = (struct pdc_cont_info *)PDC_calloc(1, sizeof(struct pdc_cont_info)); if (ret_value->cont->cont_info_pub) memcpy(ret_value->cont->cont_info_pub, info->cont->cont_info_pub, sizeof(struct pdc_cont_info)); else @@ -1105,12 +1105,12 @@ PDC_obj_get_info(pdcid_t obj_id) else ret_value->cont->cont_info_pub->name = NULL; - ret_value->cont->cont_pt = PDC_CALLOC(1, struct _pdc_cont_prop); + ret_value->cont->cont_pt = (struct _pdc_cont_prop *)PDC_calloc(1, sizeof(struct _pdc_cont_prop)); if (ret_value->cont->cont_pt) memcpy(ret_value->cont->cont_pt, info->cont->cont_pt, sizeof(struct _pdc_cont_prop)); else PGOTO_ERROR(NULL, "cannot allocate ret_value->cont->cont_pt"); - ret_value->cont->cont_pt->pdc = PDC_CALLOC(1, struct _pdc_class); + ret_value->cont->cont_pt->pdc = (struct _pdc_class *)PDC_calloc(1, sizeof(struct _pdc_class)); if (ret_value->cont->cont_pt->pdc) { ret_value->cont->cont_pt->pdc->local_id = info->cont->cont_pt->pdc->local_id; if (info->cont->cont_pt->pdc->name) @@ -1122,12 +1122,12 @@ PDC_obj_get_info(pdcid_t obj_id) PGOTO_ERROR(NULL, "cannot allocate ret_value->cont->cont_pt->pdc"); // fill in struct _pdc_obj_prop field in ret_value->obj_pt - ret_value->obj_pt = PDC_CALLOC(1, struct _pdc_obj_prop); + ret_value->obj_pt = (struct _pdc_obj_prop *)PDC_calloc(1, sizeof(struct _pdc_obj_prop)); if (ret_value->obj_pt) memcpy(ret_value->obj_pt, info->obj_pt, sizeof(struct _pdc_obj_prop)); else PGOTO_ERROR(NULL, "cannot allocate ret_value->obj_pt"); - ret_value->obj_pt->pdc = PDC_CALLOC(1, struct _pdc_class); + ret_value->obj_pt->pdc = (struct _pdc_class *)PDC_calloc(1, sizeof(struct _pdc_class)); if (ret_value->obj_pt->pdc) { ret_value->obj_pt->pdc->local_id = info->obj_pt->pdc->local_id; if (info->obj_pt->pdc->name) @@ -1138,7 +1138,7 @@ PDC_obj_get_info(pdcid_t obj_id) else PGOTO_ERROR(NULL, "cannot allocate ret_value->obj_pt->pdc"); - ret_value->obj_pt->obj_prop_pub = PDC_CALLOC(1, struct pdc_obj_prop); + ret_value->obj_pt->obj_prop_pub = (struct pdc_obj_prop *)PDC_calloc(1, sizeof(struct pdc_obj_prop)); if (ret_value->obj_pt->obj_prop_pub) memcpy(ret_value->obj_pt->obj_prop_pub, info->obj_pt->obj_prop_pub, sizeof(struct pdc_obj_prop)); else @@ -1182,7 +1182,7 @@ PDC_free_obj_info(struct _pdc_obj_info *obj) if (obj->obj_info_pub->name != NULL) free(obj->obj_info_pub->name); - obj->obj_info_pub = PDC_FREE(struct pdc_obj_info, obj->obj_info_pub); + obj->obj_info_pub = (struct pdc_obj_info *)(intptr_t)PDC_free(obj->obj_info_pub); if (obj->metadata != NULL) free(obj->metadata); @@ -1190,36 +1190,36 @@ PDC_free_obj_info(struct _pdc_obj_info *obj) if (obj->cont != NULL) { if (obj->cont->cont_info_pub->name != NULL) free(obj->cont->cont_info_pub->name); - obj->cont->cont_info_pub = PDC_FREE(struct pdc_cont_info, obj->cont->cont_info_pub); + obj->cont->cont_info_pub = (struct pdc_cont_info *)(intptr_t)PDC_free(obj->cont->cont_info_pub); if (obj->cont->cont_pt->pdc->name != NULL) free(obj->cont->cont_pt->pdc->name); - obj->cont->cont_pt->pdc = PDC_FREE(struct _pdc_class, obj->cont->cont_pt->pdc); - obj->cont->cont_pt = PDC_FREE(struct _pdc_cont_prop, obj->cont->cont_pt); - obj->cont = PDC_FREE(struct _pdc_cont_info, obj->cont); + obj->cont->cont_pt->pdc = (struct _pdc_class *)(intptr_t)PDC_free(obj->cont->cont_pt->pdc); + obj->cont->cont_pt = (struct _pdc_cont_prop *)(intptr_t)PDC_free(obj->cont->cont_pt); + obj->cont = (struct _pdc_cont_info *)(intptr_t)PDC_free(obj->cont); } if (obj->obj_pt != NULL) { if (obj->obj_pt->pdc != NULL) { if (obj->obj_pt->pdc->name != NULL) free(obj->obj_pt->pdc->name); - obj->obj_pt->pdc = PDC_FREE(struct _pdc_class, obj->obj_pt->pdc); + obj->obj_pt->pdc = (struct _pdc_class *)(intptr_t)PDC_free(obj->obj_pt->pdc); } if (obj->obj_pt->obj_prop_pub->dims != NULL) free(obj->obj_pt->obj_prop_pub->dims); - obj->obj_pt->obj_prop_pub = PDC_FREE(struct pdc_obj_prop, obj->obj_pt->obj_prop_pub); + obj->obj_pt->obj_prop_pub = (struct pdc_obj_prop *)(intptr_t)PDC_free(obj->obj_pt->obj_prop_pub); if (obj->obj_pt->app_name != NULL) free(obj->obj_pt->app_name); if (obj->obj_pt->data_loc != NULL) free(obj->obj_pt->data_loc); if (obj->obj_pt->tags != NULL) free(obj->obj_pt->tags); - obj->obj_pt = PDC_FREE(struct _pdc_obj_prop, obj->obj_pt); + obj->obj_pt = (struct _pdc_obj_prop *)(intptr_t)PDC_free(obj->obj_pt); } if (obj->region_list_head != NULL) free(obj->region_list_head); - obj = PDC_FREE(struct _pdc_obj_info, obj); + obj = (struct _pdc_obj_info *)(intptr_t)PDC_free(obj); FUNC_LEAVE(ret_value); } diff --git a/src/api/pdc_obj/pdc_prop.c b/src/api/pdc_obj/pdc_prop.c index e0632b733..65f1985ec 100644 --- a/src/api/pdc_obj/pdc_prop.c +++ b/src/api/pdc_obj/pdc_prop.c @@ -67,7 +67,7 @@ PDCprop_create(pdc_prop_type_t type, pdcid_t pdcid) FUNC_ENTER(NULL); if (type == PDC_CONT_CREATE) { - p = PDC_MALLOC(struct _pdc_cont_prop); + p = (struct _pdc_cont_prop *)PDC_malloc(sizeof(struct _pdc_cont_prop)); if (!p) PGOTO_ERROR(0, "PDC container property memory allocation failed"); p->cont_life = PDC_PERSIST; @@ -75,7 +75,7 @@ PDCprop_create(pdc_prop_type_t type, pdcid_t pdcid) p->cont_prop_id = new_id_c; id_info = PDC_find_id(pdcid); pdc_class = (struct _pdc_class *)(id_info->obj_ptr); - p->pdc = PDC_CALLOC(1, struct _pdc_class); + p->pdc = (struct _pdc_class *)PDC_calloc(1, sizeof(struct _pdc_class)); if (p->pdc == NULL) PGOTO_ERROR(0, "PDC class allocation failed"); if (pdc_class->name) @@ -85,10 +85,10 @@ PDCprop_create(pdc_prop_type_t type, pdcid_t pdcid) ret_value = new_id_c; } if (type == PDC_OBJ_CREATE) { - q = PDC_MALLOC(struct _pdc_obj_prop); + q = (struct _pdc_obj_prop *)PDC_malloc(sizeof(struct _pdc_obj_prop)); if (!q) PGOTO_ERROR(0, "PDC object property memory allocation failed"); - q->obj_prop_pub = PDC_MALLOC(struct pdc_obj_prop); + q->obj_prop_pub = (struct pdc_obj_prop *)PDC_malloc(sizeof(struct pdc_obj_prop)); if (!q->obj_prop_pub) PGOTO_ERROR(0, "PDC object pub property memory allocation failed"); q->obj_prop_pub->ndim = 0; @@ -105,7 +105,7 @@ PDCprop_create(pdc_prop_type_t type, pdcid_t pdcid) q->obj_prop_pub->obj_prop_id = new_id_o; id_info = PDC_find_id(pdcid); pdc_class = (struct _pdc_class *)(id_info->obj_ptr); - q->pdc = PDC_CALLOC(1, struct _pdc_class); + q->pdc = (struct _pdc_class *)PDC_calloc(1, sizeof(struct _pdc_class)); if (q->pdc == NULL) PGOTO_ERROR(0, "PDC class allocation failed"); if (pdc_class->name) @@ -141,7 +141,7 @@ PDCprop_obj_dup(pdcid_t prop_id) PGOTO_ERROR(0, "cannot locate object property"); info = (struct _pdc_obj_prop *)(prop->obj_ptr); - q = PDC_CALLOC(1, struct _pdc_obj_prop); + q = (struct _pdc_obj_prop *)PDC_calloc(1, sizeof(struct _pdc_obj_prop)); if (!q) PGOTO_ERROR(0, "PDC object property memory allocation failed"); if (info->app_name) @@ -153,7 +153,7 @@ PDCprop_obj_dup(pdcid_t prop_id) q->buf = NULL; /* struct obj_prop_pub field */ - q->obj_prop_pub = PDC_MALLOC(struct pdc_obj_prop); + q->obj_prop_pub = (struct pdc_obj_prop *)PDC_malloc(sizeof(struct pdc_obj_prop)); if (!q->obj_prop_pub) PGOTO_ERROR(0, "PDC object property memory allocation failed"); new_id = PDC_id_register(PDC_OBJ_PROP, q); @@ -166,7 +166,7 @@ PDCprop_obj_dup(pdcid_t prop_id) (q->obj_prop_pub->dims)[i] = (info->obj_prop_pub->dims)[i]; /* struct _pdc_class field */ - q->pdc = PDC_CALLOC(1, struct _pdc_class); + q->pdc = (struct _pdc_class *)PDC_calloc(1, sizeof(struct _pdc_class)); if (!q->pdc) PGOTO_ERROR(0, "PDC class memory allocation failed"); if (info->pdc->name) @@ -228,8 +228,8 @@ pdc_prop_cont_close(struct _pdc_cont_prop *cp) FUNC_ENTER(NULL); free(cp->pdc->name); - cp->pdc = PDC_FREE(struct _pdc_class, cp->pdc); - cp = PDC_FREE(struct _pdc_cont_prop, cp); + cp->pdc = (struct _pdc_class *)(intptr_t)PDC_free(cp->pdc); + cp = (struct _pdc_cont_prop *)(intptr_t)PDC_free(cp); FUNC_LEAVE(ret_value); } @@ -242,7 +242,7 @@ pdc_prop_obj_close(struct _pdc_obj_prop *cp) FUNC_ENTER(NULL); free(cp->pdc->name); - cp->pdc = PDC_FREE(struct _pdc_class, cp->pdc); + cp->pdc = (struct _pdc_class *)(intptr_t)PDC_free(cp->pdc); if (cp->obj_prop_pub->dims != NULL) { free(cp->obj_prop_pub->dims); cp->obj_prop_pub->dims = NULL; @@ -250,7 +250,7 @@ pdc_prop_obj_close(struct _pdc_obj_prop *cp) free(cp->app_name); free(cp->tags); free(cp->data_loc); - cp = PDC_FREE(struct _pdc_obj_prop, cp); + cp = (struct _pdc_obj_prop *)(intptr_t)PDC_free(cp); FUNC_LEAVE(ret_value); } @@ -303,13 +303,13 @@ PDCcont_prop_get_info(pdcid_t cont_prop) PGOTO_ERROR(NULL, "cannot allocate container property"); info = (struct _pdc_cont_prop *)(prop->obj_ptr); - ret_value = PDC_CALLOC(1, struct _pdc_cont_prop); + ret_value = (struct _pdc_cont_prop *)PDC_calloc(1, sizeof(struct _pdc_cont_prop)); if (!ret_value) PGOTO_ERROR(NULL, "PDC container property memory allocation failed"); ret_value->cont_life = info->cont_life; ret_value->cont_prop_id = info->cont_prop_id; - ret_value->pdc = PDC_CALLOC(1, struct _pdc_class); + ret_value->pdc = (struct _pdc_class *)PDC_calloc(1, sizeof(struct _pdc_class)); if (!ret_value->pdc) PGOTO_ERROR(NULL, "cannot allocate ret_value->pdc"); if (info->pdc->name) @@ -336,7 +336,7 @@ PDCobj_prop_get_info(pdcid_t obj_prop) PGOTO_ERROR(NULL, "cannot locate object property"); info = (struct _pdc_obj_prop *)(prop->obj_ptr); - ret_value = PDC_CALLOC(1, struct pdc_obj_prop); + ret_value = (struct pdc_obj_prop *)PDC_calloc(1, sizeof(struct pdc_obj_prop)); if (ret_value == NULL) PGOTO_ERROR(NULL, "PDC object property memory allocation failed"); memcpy(ret_value, info->obj_prop_pub, sizeof(struct pdc_obj_prop)); @@ -367,7 +367,7 @@ PDC_obj_prop_get_info(pdcid_t obj_prop) PGOTO_ERROR(NULL, "cannot locate object property"); info = (struct _pdc_obj_prop *)(prop->obj_ptr); - ret_value = PDC_CALLOC(1, struct _pdc_obj_prop); + ret_value = (struct _pdc_obj_prop *)PDC_calloc(1, sizeof(struct _pdc_obj_prop)); if (ret_value == NULL) PGOTO_ERROR(NULL, "PDC object property memory allocation failed"); memcpy(ret_value, info, sizeof(struct _pdc_obj_prop)); @@ -381,7 +381,7 @@ PDC_obj_prop_get_info(pdcid_t obj_prop) ret_value->tags = strdup(info->tags); /* struct _pdc_class field */ - ret_value->pdc = PDC_CALLOC(1, struct _pdc_class); + ret_value->pdc = (struct _pdc_class *)PDC_calloc(1, sizeof(struct _pdc_class)); if (ret_value->pdc == NULL) PGOTO_ERROR(NULL, "cannot allocate ret_value->pdc"); if (info->pdc->name) @@ -389,7 +389,7 @@ PDC_obj_prop_get_info(pdcid_t obj_prop) ret_value->pdc->local_id = info->pdc->local_id; /* struct pdc_obj_prop field */ - ret_value->obj_prop_pub = PDC_CALLOC(1, struct pdc_obj_prop); + ret_value->obj_prop_pub = (struct pdc_obj_prop *)PDC_calloc(1, sizeof(struct pdc_obj_prop)); if (ret_value->obj_prop_pub == NULL) PGOTO_ERROR(NULL, "PDC object pub property memory allocation failed"); memcpy(ret_value->obj_prop_pub, info->obj_prop_pub, sizeof(struct pdc_obj_prop)); diff --git a/src/api/pdc_region/pdc_region.c b/src/api/pdc_region/pdc_region.c index 7192c9234..5b5aa1fe3 100644 --- a/src/api/pdc_region/pdc_region.c +++ b/src/api/pdc_region/pdc_region.c @@ -106,8 +106,8 @@ pdc_region_close(struct pdc_region_info *op) free(op->size); free(op->offset); if (op->obj != NULL) - op->obj = PDC_FREE(struct _pdc_obj_info, op->obj); - op = PDC_FREE(struct pdc_region_info, op); + op->obj = (struct _pdc_obj_info *)(intptr_t)PDC_free(op->obj); + op = (struct pdc_region_info *)(intptr_t)PDC_free(op); FUNC_LEAVE(ret_value); } @@ -184,7 +184,7 @@ PDCregion_create(psize_t ndims, uint64_t *offset, uint64_t *size) FUNC_ENTER(NULL); - p = PDC_MALLOC(struct pdc_region_info); + p = (struct pdc_region_info *)PDC_malloc(sizeof(struct pdc_region_info)); if (!p) PGOTO_ERROR(ret_value, "PDC region memory allocation failed"); p->ndim = ndims; diff --git a/src/api/pdc_region/pdc_region_transfer.c b/src/api/pdc_region/pdc_region_transfer.c index 87f9f3625..aa528696e 100644 --- a/src/api/pdc_region/pdc_region_transfer.c +++ b/src/api/pdc_region/pdc_region_transfer.c @@ -44,10 +44,13 @@ #include "pdc_analysis_pkg.h" #include +#define PDC_MERGE_TRANSFER_MIN_COUNT 50 + // pdc region transfer class. Contains essential information for performing non-blocking PDC client I/O // perations. typedef struct pdc_transfer_request { pdcid_t obj_id; + pdcid_t local_obj_id; // Data server ID for sending data to, used by object static only. uint32_t data_server_id; // Metadata server ID for sending data to, used by region_dynamic only. @@ -102,6 +105,10 @@ typedef struct pdc_transfer_request { uint64_t *obj_dims; // Pointer to object info, can be useful sometimes. We do not want to go through PDC ID list many times. struct _pdc_obj_info *obj_pointer; + + // Tang: for merging transfer requests with transfer start_all/wait_all + pdcid_t merged_request_id; + int is_done; } pdc_transfer_request; // We pack all arguments for a start_all call to the same data server in a single structure, so we do not need @@ -208,9 +215,10 @@ PDCregion_transfer_create(void *buf, pdc_access_t access_type, pdcid_t obj_id, p obj2 = (struct _pdc_obj_info *)(objinfo2->obj_ptr); // remote_meta_id = obj2->obj_info_pub->meta_id; - p = PDC_MALLOC(pdc_transfer_request); + p = (pdc_transfer_request *)PDC_malloc(sizeof(pdc_transfer_request)); p->obj_pointer = obj2; p->mem_type = obj2->obj_pt->obj_prop_pub->type; + p->local_obj_id = obj_id; p->obj_id = obj2->obj_info_pub->meta_id; p->access_type = access_type; p->buf = buf; @@ -226,6 +234,8 @@ PDCregion_transfer_create(void *buf, pdc_access_t access_type, pdcid_t obj_id, p p->metadata_server_id = obj2->obj_info_pub->metadata_server_id; p->unit = PDC_get_var_type_size(p->mem_type); p->consistency = obj2->obj_pt->obj_prop_pub->consistency; + p->merged_request_id = 0; + p->is_done = 0; unit = p->unit; /* @@ -287,9 +297,9 @@ PDCregion_transfer_close(pdcid_t transfer_request_id) goto done; } transfer_request = (pdc_transfer_request *)(transferinfo->obj_ptr); - if (transfer_request->metadata_id == NULL) { - goto done; - } + /* if (transfer_request->metadata_id == NULL) { */ + /* goto done; */ + /* } */ // Check for consistency /* @@ -299,9 +309,12 @@ PDCregion_transfer_close(pdcid_t transfer_request_id) PDCregion_transfer_wait(transfer_request_id); } */ - free(transfer_request->local_region_offset); - free(transfer_request->metadata_id); - free(transfer_request); + if (transfer_request->local_region_offset) + free(transfer_request->local_region_offset); + if (transfer_request->metadata_id) + free(transfer_request->metadata_id); + if (transfer_request) + free(transfer_request); /* When the reference count reaches zero the resources are freed */ if (PDC_dec_ref(transfer_request_id) < 0) @@ -903,7 +916,7 @@ register_metadata(pdc_transfer_request_start_all_pkg **transfer_request_input, i * sorted in terms of data_server_id. We pack data from user buffer to contiguous buffers. Static partitioning * requires having at most n_data_servers number of contiguous regions. */ -static int +static perr_t prepare_start_all_requests(pdcid_t *transfer_request_id, int size, pdc_transfer_request_start_all_pkg ***write_transfer_request_ptr, pdc_transfer_request_start_all_pkg ***read_transfer_request_ptr, @@ -928,13 +941,14 @@ prepare_start_all_requests(pdcid_t *transfer_request_id, int size, *posix_transfer_request_id_ptr = (pdcid_t *)malloc(sizeof(pdcid_t) * size); for (i = 0; i < size; ++i) { - transferinfo = PDC_find_id(transfer_request_id[i]); + transferinfo = PDC_find_id(transfer_request_id[i]); + if (NULL == transferinfo) + continue; transfer_request = (pdc_transfer_request *)(transferinfo->obj_ptr); if (transfer_request->metadata_id != NULL) { - printf("PDC Client PDCregion_transfer_start_all attempt to start existing transfer request @ " - "line %d\n", - __LINE__); - return 1; + printf("==PDC_CLIENT[%d]: %s cannot start transfer request @ line %d\n", pdc_client_mpi_rank_g, + __func__, __LINE__); + return FAIL; } if (transfer_request->consistency == PDC_CONSISTENCY_POSIX) { posix_transfer_request_id_ptr[0][posix_size_ptr[0]] = transfer_request_id[i]; @@ -959,6 +973,11 @@ prepare_start_all_requests(pdcid_t *transfer_request_id, int size, &(transfer_request->n_obj_servers), &(transfer_request->obj_servers), &(transfer_request->sub_offsets), &(transfer_request->output_offsets), &(transfer_request->output_sizes), &(transfer_request->output_buf)); + if (transfer_request->n_obj_servers == 0) { + printf("PDC_Client %d, %s: error with static region partition, no server is selected!\n", + pdc_client_mpi_rank_g, __func__); + return FAIL; + } for (j = 0; j < transfer_request->n_obj_servers; ++j) { request_pkgs = (pdc_transfer_request_start_all_pkg *)malloc(sizeof(pdc_transfer_request_start_all_pkg)); @@ -1082,7 +1101,7 @@ prepare_start_all_requests(pdcid_t *transfer_request_id, int size, else { *read_size_ptr = 0; } - return 0; + return SUCCEED; } static int @@ -1310,19 +1329,139 @@ PDC_Client_start_all_requests(pdc_transfer_request_start_all_pkg **transfer_requ FUNC_LEAVE(ret_value); } +// Try to merge smaller requests to a large one, currently only merge write requests on same object and +// contiguous +static perr_t +merge_transfer_request_ids(pdcid_t *transfer_request_id, int size, pdcid_t *merged_request_id, + int *merged_size) +{ + struct _pdc_id_info * transferinfo; + pdcid_t obj_id, new_local_reg, new_remote_reg; + int flag = 0, i; + void * new_buf; + pdc_access_t access_type; + pdc_transfer_request **all_transfer_request; + uint64_t new_buf_size = 0, copy_off = 0; + uint64_t offset_local[3], size_local[3], offset_remote[3], size_remote[3]; + + all_transfer_request = (pdc_transfer_request **)PDC_calloc(size, sizeof(pdc_transfer_request *)); + + for (i = 0; i < size; ++i) { + transferinfo = PDC_find_id(transfer_request_id[i]); + if (NULL == transferinfo) { + printf("==PDC_CLIENT[%d]: %s cannot find transfer request info @ line %d\n", + pdc_client_mpi_rank_g, __func__, __LINE__); + return FAIL; + } + all_transfer_request[i] = (pdc_transfer_request *)(transferinfo->obj_ptr); + if (NULL == all_transfer_request[i]) { + printf("==PDC_CLIENT[%d]: %s transfer request is NULL @ line %d\n", pdc_client_mpi_rank_g, + __func__, __LINE__); + return FAIL; + } + + // Check if every requests are REGION_LOCAL + if (all_transfer_request[i]->region_partition != PDC_REGION_LOCAL) { + flag = 1; + break; + } + + /* // Check if every requests are write operations */ + /* if (all_transfer_request[i]->access_type != PDC_WRITE) { */ + /* flag = 1; */ + /* break; */ + /* } */ + + // Check if every requests are on the same object + if (i == 0) + obj_id = all_transfer_request[i]->local_obj_id; + else { + if (all_transfer_request[i]->local_obj_id != obj_id) { + flag = 1; + break; + } + // Check for contiguous + if (all_transfer_request[i]->local_region_ndim == 1) { + if (all_transfer_request[i]->remote_region_offset[0] != + all_transfer_request[i - 1]->remote_region_offset[0] + + all_transfer_request[i - 1]->remote_region_size[0]) { + flag = 1; + break; + } + } + else { + // TODO: currently only check for 1D + flag = 1; + break; + } + } + + new_buf_size += all_transfer_request[i]->total_data_size; + } + + if (flag == 0) { + // Copy data to merged new_buf + new_buf = (void *)PDC_malloc(new_buf_size); + + if (all_transfer_request[0]->local_region_ndim == 1) { + offset_local[0] = all_transfer_request[0]->local_region_offset[0]; + size_local[0] = new_buf_size; + new_local_reg = PDCregion_create(1, offset_local, size_local); + + offset_remote[0] = all_transfer_request[0]->remote_region_offset[0]; + size_remote[0] = new_buf_size; + new_remote_reg = PDCregion_create(1, offset_remote, size_remote); + + copy_off = offset_local[0]; + for (i = 0; i < size; ++i) { + memcpy(new_buf + copy_off, all_transfer_request[i]->buf, + all_transfer_request[i]->total_data_size); + copy_off += all_transfer_request[i]->total_data_size; + // Mark the original requests a done + all_transfer_request[i]->is_done = 1; + } + } + + /* *merged_request_id = */ + /* PDCregion_transfer_create(new_buf, PDC_WRITE, obj_id, new_local_reg, new_remote_reg); */ + *merged_request_id = PDCregion_transfer_create(new_buf, all_transfer_request[0]->access_type, obj_id, + new_local_reg, new_remote_reg); + *merged_size = 1; + // Add new xfer id to the first request for later wait_all use + all_transfer_request[0]->merged_request_id = *merged_request_id; + } + + free(all_transfer_request); + + return SUCCEED; +} + perr_t PDCregion_transfer_start_all(pdcid_t *transfer_request_id, int size) { perr_t ret_value = SUCCEED; - int write_size = 0, read_size = 0, posix_size = 0; + int write_size = 0, read_size = 0, posix_size = 0, merged_size = 0; pdc_transfer_request_start_all_pkg **write_transfer_requests = NULL, **read_transfer_requests = NULL; - pdcid_t * posix_transfer_request_id; + pdcid_t * posix_transfer_request_id, *merged_request_id; FUNC_ENTER(NULL); + + // TODO: Tang + // Merge the transfer_request_ids when they are operating on the same obj and have contiguous off, len + if (size > PDC_MERGE_TRANSFER_MIN_COUNT) { + merged_request_id = PDC_malloc(sizeof(pdcid_t)); + merge_transfer_request_ids(transfer_request_id, size, merged_request_id, &merged_size); + if (merged_size == 1) { + size = merged_size; + transfer_request_id = merged_request_id; + } + } + // Split write and read requests. Handle them separately. // printf("PDCregion_transfer_start_all: checkpoint %d\n", __LINE__); - prepare_start_all_requests(transfer_request_id, size, &write_transfer_requests, &read_transfer_requests, - &write_size, &read_size, &posix_transfer_request_id, &posix_size); + ret_value = prepare_start_all_requests(transfer_request_id, size, &write_transfer_requests, + &read_transfer_requests, &write_size, &read_size, + &posix_transfer_request_id, &posix_size); /* printf("PDCregion_transfer_start_all: checkpoint %d, write_size = %d, read_size = %d\n", __LINE__, write_size, read_size); @@ -1334,9 +1473,13 @@ PDCregion_transfer_start_all(pdcid_t *transfer_request_id, int size) */ // Start write requests + /* printf("==PDC_CLIENT[%d]: PDC_Client_start_all_requests write_size %d\n", pdc_client_mpi_rank_g, */ + /* write_size); */ PDC_Client_start_all_requests(write_transfer_requests, write_size); // printf("PDCregion_transfer_start_all: checkpoint %d\n", __LINE__); // Start read requests + /* printf("==PDC_CLIENT[%d]: PDC_Client_start_all_requests read_size %d\n", pdc_client_mpi_rank_g, */ + /* read_size); */ PDC_Client_start_all_requests(read_transfer_requests, read_size); /* fprintf(stderr, "PDCregion_transfer_start_all: checkpoint %d\n", __LINE__); @@ -1423,6 +1566,8 @@ PDCregion_transfer_start(pdcid_t transfer_request_id) FUNC_ENTER(NULL); transferinfo = PDC_find_id(transfer_request_id); + if (NULL == transferinfo) + goto done; transfer_request = (pdc_transfer_request *)(transferinfo->obj_ptr); @@ -1454,12 +1599,18 @@ PDCregion_transfer_start(pdcid_t transfer_request_id) if (transfer_request->region_partition == PDC_REGION_STATIC) { // Identify which part of the region is going to which data server. - static_region_partition(transfer_request->new_buf, transfer_request->remote_region_ndim, unit, - transfer_request->access_type, transfer_request->obj_dims, - transfer_request->remote_region_offset, transfer_request->remote_region_size, - 1, &(transfer_request->n_obj_servers), &(transfer_request->obj_servers), - &(transfer_request->sub_offsets), &(transfer_request->output_offsets), - &(transfer_request->output_sizes), &(transfer_request->output_buf)); + ret_value = static_region_partition( + transfer_request->new_buf, transfer_request->remote_region_ndim, unit, + transfer_request->access_type, transfer_request->obj_dims, transfer_request->remote_region_offset, + transfer_request->remote_region_size, 1, &(transfer_request->n_obj_servers), + &(transfer_request->obj_servers), &(transfer_request->sub_offsets), + &(transfer_request->output_offsets), &(transfer_request->output_sizes), + &(transfer_request->output_buf)); + if (transfer_request->n_obj_servers == 0) { + printf("PDC_Client %d, %s: error with static region partition, no server is selected!\n", + pdc_client_mpi_rank_g, __func__); + return FAIL; + } /* printf("n_obj_servers = %d\n", transfer_request->n_obj_servers); for ( i = 0; i < transfer_request->n_obj_servers; ++i ) { @@ -1585,7 +1736,12 @@ PDCregion_transfer_status(pdcid_t transfer_request_id, pdc_transfer_status_t *co FUNC_ENTER(NULL); - transferinfo = PDC_find_id(transfer_request_id); + transferinfo = PDC_find_id(transfer_request_id); + if (NULL == transferinfo) { + *completed = PDC_TRANSFER_STATUS_COMPLETE; + goto done; + } + transfer_request = (pdc_transfer_request *)(transferinfo->obj_ptr); if (transfer_request->metadata_id != NULL) { unit = transfer_request->unit; @@ -1666,6 +1822,7 @@ PDCregion_transfer_status(pdcid_t transfer_request_id, pdc_transfer_status_t *co } free(transfer_request->metadata_id); transfer_request->metadata_id = NULL; + transfer_request->is_done = 1; remove_local_transfer_request(transfer_request->obj_pointer, transfer_request_id); } else { @@ -1680,34 +1837,60 @@ perr_t PDCregion_transfer_wait_all(pdcid_t *transfer_request_id, int size) { perr_t ret_value = SUCCEED; - int index, i, j; + int index, i, j, merged_xfer = 0, ori_size = size, is_first = 1; size_t unit; int total_requests, n_objs; - uint64_t * metadata_ids; + uint64_t * metadata_ids, merge_off = 0, cur_off = 0; pdc_transfer_request_wait_all_pkg **transfer_requests, *transfer_request_head, *transfer_request_end, *temp; - struct _pdc_id_info * transferinfo; - pdc_transfer_request *transfer_request; + struct _pdc_id_info **transferinfo; + pdc_transfer_request *transfer_request, *merged_request; + pdcid_t * my_transfer_request_id = transfer_request_id; + + double t0, t1; FUNC_ENTER(NULL); if (!size) { goto done; } + transferinfo = (struct _pdc_id_info **)PDC_malloc(size * sizeof(struct _pdc_id_info *)); + +#ifdef ENABLE_MPI + t0 = MPI_Wtime(); +#endif + + // Tang + // Check if we merged the previous request + if (size > PDC_MERGE_TRANSFER_MIN_COUNT) { + transferinfo[0] = PDC_find_id(transfer_request_id[0]); + transfer_request = (pdc_transfer_request *)(transferinfo[0]->obj_ptr); + if (transfer_request->merged_request_id != 0) { + my_transfer_request_id = &transfer_request->merged_request_id; + size = 1; + merged_xfer = 1; + } + } + // printf("entered PDCregion_transfer_wait_all @ line %d\n", __LINE__); total_requests = 0; transfer_request_head = NULL; for (i = 0; i < size; ++i) { - transferinfo = PDC_find_id(transfer_request_id[i]); - transfer_request = (pdc_transfer_request *)(transferinfo->obj_ptr); + transferinfo[i] = PDC_find_id(my_transfer_request_id[i]); + if (NULL == transferinfo[i]) + continue; + transfer_request = (pdc_transfer_request *)(transferinfo[i]->obj_ptr); + if (1 == transfer_request->is_done) + continue; if (!transfer_request->metadata_id) { fprintf(stderr, "PDCregion_transfer_wait_all [rank %d] @ line %d: Attempt to wait for a transfer request " - "that has not been started.\n", - pdc_client_mpi_rank_g, __LINE__); - ret_value = FAIL; - goto done; + "that has not been started. %d/%d\n", + pdc_client_mpi_rank_g, __LINE__, i, size); + /* ret_value = FAIL; */ + continue; + /* goto done; */ } total_requests += transfer_request->n_obj_servers; for (j = 0; j < transfer_request->n_obj_servers; ++j) { @@ -1734,6 +1917,12 @@ PDCregion_transfer_wait_all(pdcid_t *transfer_request_id, int size) transfer_request_end->index = j; } } + +#ifdef ENABLE_MPI + t1 = MPI_Wtime(); +#endif + /* fprintf(stderr, "Part 1 took %.6f\n", t1-t0); */ + transfer_requests = (pdc_transfer_request_wait_all_pkg **)malloc( sizeof(pdc_transfer_request_wait_all_pkg *) * total_requests); temp = transfer_request_head; @@ -1751,6 +1940,11 @@ PDCregion_transfer_wait_all(pdcid_t *transfer_request_id, int size) // transfer_requests[i]->data_server_id, transfer_requests[i]->metadata_id); } +#ifdef ENABLE_MPI + t0 = MPI_Wtime(); + /* fprintf(stderr, "Part 2 took %.6f\n", t0-t1); */ +#endif + metadata_ids = (uint64_t *)malloc(sizeof(uint64_t) * total_requests); index = 0; for (i = 1; i < total_requests; ++i) { @@ -1794,6 +1988,12 @@ PDCregion_transfer_wait_all(pdcid_t *transfer_request_id, int size) index = i; } } + +#ifdef ENABLE_MPI + t1 = MPI_Wtime(); + /* fprintf(stderr, "Part 3 took %.6f\n", t1-t0); */ +#endif + if (total_requests) { // Freed at the wait operation (inside PDC_client_connect call) n_objs = total_requests - index; @@ -1839,10 +2039,38 @@ PDCregion_transfer_wait_all(pdcid_t *transfer_request_id, int size) } } +#ifdef ENABLE_MPI + t0 = MPI_Wtime(); + /* fprintf(stderr, "Part 4 took %.6f\n", t0-t1); */ +#endif + // Deal with merged read requests, need to copy a large buffer to each of the original request buf + // TODO: Currently only supports 1D merging, so only consider 1D for now + if (merged_xfer == 1) { + merged_request = (pdc_transfer_request *)(PDC_find_id(my_transfer_request_id[0])->obj_ptr); + for (i = 0; i < ori_size; ++i) { + transfer_request = (pdc_transfer_request *)(PDC_find_id(transfer_request_id[i])->obj_ptr); + if (transfer_request->access_type == PDC_READ) { + if (is_first == 1) + merge_off = transfer_request->remote_region_offset[0]; + cur_off = transfer_request->remote_region_offset[0] - merge_off; + if (!transfer_request->new_buf) + transfer_request->new_buf = PDC_malloc(transfer_request->total_data_size); + + memcpy(transfer_request->new_buf, merged_request->read_bulk_buf[0] + merge_off, + transfer_request->total_data_size); + + is_first = 0; + } + } + } + for (i = 0; i < size; ++i) { - transferinfo = PDC_find_id(transfer_request_id[i]); - transfer_request = (pdc_transfer_request *)(transferinfo->obj_ptr); - unit = transfer_request->unit; + if (NULL == transferinfo[i]) + continue; + transfer_request = (pdc_transfer_request *)(transferinfo[i]->obj_ptr); + if (1 == transfer_request->is_done) + continue; + unit = transfer_request->unit; if (transfer_request->region_partition == PDC_OBJ_STATIC && transfer_request->access_type == PDC_READ) { @@ -1869,14 +2097,21 @@ PDCregion_transfer_wait_all(pdcid_t *transfer_request_id, int size) } free(transfer_request->metadata_id); transfer_request->metadata_id = NULL; + transfer_request->is_done = 1; remove_local_transfer_request(transfer_request->obj_pointer, transfer_request_id[i]); } +#ifdef ENABLE_MPI + t1 = MPI_Wtime(); + /* fprintf(stderr, "Part 5 took %.6f\n", t1-t0); */ +#endif + for (i = 0; i < total_requests; ++i) { free(transfer_requests[i]); } free(transfer_requests); free(metadata_ids); + free(transferinfo); /* for (i = 0; i < size; ++i) { PDCregion_transfer_wait(transfer_request_id[i]); @@ -1898,7 +2133,10 @@ PDCregion_transfer_wait(pdcid_t transfer_request_id) FUNC_ENTER(NULL); - transferinfo = PDC_find_id(transfer_request_id); + transferinfo = PDC_find_id(transfer_request_id); + if (NULL == transferinfo) + goto done; + transfer_request = (pdc_transfer_request *)(transferinfo->obj_ptr); if (transfer_request->metadata_id != NULL) { // For region dynamic case, it is implemented in the aggregated version for portability. @@ -1978,6 +2216,7 @@ PDCregion_transfer_wait(pdcid_t transfer_request_id) } free(transfer_request->metadata_id); transfer_request->metadata_id = NULL; + transfer_request->is_done = 1; remove_local_transfer_request(transfer_request->obj_pointer, transfer_request_id); } else { diff --git a/src/api/pdc_transform/pdc_transform.c b/src/api/pdc_transform/pdc_transform.c index d2c8381f5..884cbf434 100644 --- a/src/api/pdc_transform/pdc_transform.c +++ b/src/api/pdc_transform/pdc_transform.c @@ -93,7 +93,8 @@ PDCobj_transform_register(char *func, pdcid_t obj_id, int current_state, int nex if ((ftnPtr = ftnHandle) == NULL) PGOTO_ERROR(FAIL, "Transforms function lookup failed"); - if ((thisFtn = PDC_MALLOC(struct _pdc_region_transform_ftn_info)) == NULL) + if ((thisFtn = (struct _pdc_region_transform_ftn_info *)PDC_malloc( + sizeof(struct _pdc_region_transform_ftn_info))) == NULL) PGOTO_ERROR(FAIL, "PDC register_obj_transforms memory allocation failed"); memset(thisFtn, 0, sizeof(struct _pdc_region_transform_ftn_info)); @@ -206,7 +207,8 @@ PDCbuf_map_transform_register(char *func, void *buf, pdcid_t src_region_id, pdci if ((ftnPtr = ftnHandle) == NULL) PGOTO_ERROR(FAIL, "Transforms function lookup failed\n"); - if ((thisFtn = PDC_MALLOC(struct _pdc_region_transform_ftn_info)) == NULL) + if ((thisFtn = (struct _pdc_region_transform_ftn_info *)PDC_malloc( + sizeof(struct _pdc_region_transform_ftn_info))) == NULL) PGOTO_ERROR(FAIL, "PDC register_obj_transforms memory allocation failed"); thisFtn->ftnPtr = (size_t(*)())ftnPtr; diff --git a/src/commons/utils/include/pdc_malloc.h b/src/commons/utils/include/pdc_malloc.h index 8c3a36335..e967c9032 100644 --- a/src/commons/utils/include/pdc_malloc.h +++ b/src/commons/utils/include/pdc_malloc.h @@ -76,9 +76,4 @@ void *PDC_free(void *mem); */ size_t PDC_get_global_mem_usage(); -#define PDC_MALLOC(t) (t *)PDC_malloc(sizeof(t)) -#define PDC_CALLOC(c, t) (t *)PDC_calloc(c, sizeof(t)) - -#define PDC_FREE(t, obj) (t *)(intptr_t) PDC_free(obj) - #endif /* PDC_MALLOC_H */ diff --git a/src/server/pdc_client_server_common.c b/src/server/pdc_client_server_common.c index d90f83bff..7b9afb903 100644 --- a/src/server/pdc_client_server_common.c +++ b/src/server/pdc_client_server_common.c @@ -2113,7 +2113,7 @@ HG_TEST_RPC_CB(close_server, handle) fflush(stdout); FUNC_LEAVE(ret_value); } -/* +#ifdef ENABLE_MULTITHREAD static HG_THREAD_RETURN_TYPE pdc_region_write_out_progress(void *arg) { @@ -2169,9 +2169,7 @@ pdc_region_write_out_progress(void *arg) FUNC_LEAVE(ret_value); } -*/ // enter this function, transfer is done, data is pushed to buffer -/* static hg_return_t obj_map_region_release_bulk_transfer_thread_cb(const struct hg_cb_info *hg_cb_info) { @@ -2181,8 +2179,6 @@ obj_map_region_release_bulk_transfer_thread_cb(const struct hg_cb_info *hg_cb_in FUNC_ENTER(NULL); - - bulk_args = (struct buf_map_release_bulk_args *)hg_cb_info->arg; if (hg_cb_info->ret == HG_CANCELED) { @@ -2216,9 +2212,7 @@ obj_map_region_release_bulk_transfer_thread_cb(const struct hg_cb_info *hg_cb_in FUNC_LEAVE(ret_value); } -*/ -/* static HG_THREAD_RETURN_TYPE pdc_region_read_from_progress(void *arg) { @@ -2268,7 +2262,8 @@ pdc_region_read_from_progress(void *arg) FUNC_LEAVE(ret_value); } -*/ +#endif + // enter this function, transfer is done, data is in data server static hg_return_t transform_and_region_release_bulk_transfer_cb(const struct hg_cb_info *hg_cb_info) @@ -6568,6 +6563,8 @@ HG_TEST_THREAD_CB(send_nhits) HG_TEST_THREAD_CB(send_bulk_rpc) HG_TEST_THREAD_CB(get_sel_data_rpc) HG_TEST_THREAD_CB(send_read_sel_obj_id_rpc) +HG_TEST_THREAD_CB(dart_get_server_info) +HG_TEST_THREAD_CB(dart_perform_one_server) PDC_FUNC_DECLARE_REGISTER(gen_obj_id) PDC_FUNC_DECLARE_REGISTER(gen_cont_id) diff --git a/src/server/pdc_server_metadata.c b/src/server/pdc_server_metadata.c index b33087173..11e80e2b4 100644 --- a/src/server/pdc_server_metadata.c +++ b/src/server/pdc_server_metadata.c @@ -1200,11 +1200,8 @@ PDC_insert_metadata_to_hash_table(gen_obj_id_in_t *in, gen_obj_id_out_t *out) perr_t ret_value = SUCCEED; pdc_metadata_t *metadata; uint32_t * hash_key, i; -#ifdef ENABLE_MULTITHREAD - // Obtain lock for hash table - int unlocked = 0; - hg_thread_mutex_lock(&pdc_metadata_hash_table_mutex_g); -#endif + int unlocked = 0; + // DEBUG int debug_flag = 0; @@ -1265,15 +1262,13 @@ PDC_insert_metadata_to_hash_table(gen_obj_id_in_t *in, gen_obj_id_out_t *out) pdc_hash_table_entry_head *lookup_value; pdc_metadata_t * found_identical; + if (debug_flag == 1) + printf("checking hash table with key=%d\n", *hash_key); + #ifdef ENABLE_MULTITHREAD // Obtain lock for hash table - unlocked = 0; hg_thread_mutex_lock(&pdc_metadata_hash_table_mutex_g); #endif - - if (debug_flag == 1) - printf("checking hash table with key=%d\n", *hash_key); - if (metadata_hash_table_g != NULL) { // lookup lookup_value = hash_table_lookup(metadata_hash_table_g, hash_key); @@ -2766,7 +2761,7 @@ PDC_add_kvtag_to_list(pdc_kvtag_list_t **list_head, pdc_kvtag_t *tag) FUNC_ENTER(NULL); PDC_kvtag_dup(tag, &newtag); - new_list_item = PDC_CALLOC(1, pdc_kvtag_list_t); + new_list_item = (pdc_kvtag_list_t *)PDC_calloc(1, sizeof(pdc_kvtag_list_t)); new_list_item->kvtag = newtag; DL_APPEND(*list_head, new_list_item); diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 13c2a5a31..1f8eaddf4 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -133,6 +133,7 @@ set(PROGRAMS #query_vpic_exyz_nopreload #query_vpic_exyz_preload query_data + producer_waitall ) # TODO: Check if import_vpic.c is needed. If yes, we have to add the following : @@ -207,6 +208,7 @@ set(SCRIPTS run_test.sh mpi_test.sh run_multiple_test.sh + run_multiple_mpi_test.sh run_checkpoint_restart_test.sh ) @@ -487,6 +489,7 @@ if(BUILD_MPI_TESTING) add_test(NAME obj_info_mpi WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./obj_info ${MPI_RUN_CMD} 4 6 ) add_test(NAME obj_put_data_mpi WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./obj_put_data ${MPI_RUN_CMD} 4 6 ) add_test(NAME obj_get_data_mpi WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND mpi_test.sh ./obj_get_data ${MPI_RUN_CMD} 4 6 ) + add_test(NAME vpicio_bdcats_mpi WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND run_multiple_mpi_test.sh ${MPI_RUN_CMD} 4 6 ./vpicio ./bdcats) set_tests_properties(read_obj_shared_int PROPERTIES LABELS "parallel;parallel_obj" ) set_tests_properties(read_obj_shared_float PROPERTIES LABELS "parallel;parallel_obj" ) @@ -514,6 +517,7 @@ if(BUILD_MPI_TESTING) # set_tests_properties(region_transfer_2D_skewed_mpi PROPERTIES LABELS "parallel;parallel_region_transfer" ) # set_tests_properties(region_transfer_3D_skewed_mpi PROPERTIES LABELS "parallel;parallel_region_transfer" ) set_tests_properties(region_transfer_write_read_mpi PROPERTIES LABELS "parallel;parallel_region_transfer" ) + set_tests_properties(vpicio_bdcats_mpi PROPERTIES LABELS "parallel;parallel_region_transfer" ) set_tests_properties(region_transfer_all_mpi PROPERTIES LABELS "parallel;parallel_region_transfer_all" ) set_tests_properties(region_transfer_all_2D_mpi PROPERTIES LABELS "parallel;parallel_region_transfer_all" ) set_tests_properties(region_transfer_all_3D_mpi PROPERTIES LABELS "parallel;parallel_region_transfer_all" ) diff --git a/src/tests/mpi_test.sh b/src/tests/mpi_test.sh index a434fbf07..1a4983168 100755 --- a/src/tests/mpi_test.sh +++ b/src/tests/mpi_test.sh @@ -4,12 +4,9 @@ # defined and points to the MPI libraries used by the linker (e.g. -L +#include +#include +#include + +#include "mpi.h" +#include "pdc.h" + +/** + * write -> read -> wait_all() + * + */ + +int mpi_rank, mpi_size; +MPI_Comm mpi_comm; + +void +write_read_wait_all(pdcid_t obj_id, int iterations) +{ + pdcid_t region_local, region_remote; + pdcid_t transfer_request; + perr_t ret; + + int ndim = 1; + uint64_t offset_local = 0; + uint64_t offset_remote = 0; + uint64_t chunk_size = 2880; + + char *data_out = (char *)malloc(chunk_size * sizeof(char)); + memset(data_out, 'a', chunk_size * sizeof(char)); + + double stime = MPI_Wtime(); + + pdcid_t *tids = (pdcid_t *)malloc(sizeof(pdcid_t) * (iterations)); + for (int i = 0; i < iterations; i++) { + region_local = PDCregion_create(ndim, &offset_local, &chunk_size); + region_remote = PDCregion_create(ndim, &offset_remote, &chunk_size); + offset_remote += chunk_size; + tids[i] = PDCregion_transfer_create(data_out, PDC_WRITE, obj_id, region_local, region_remote); + if (tids[i] == 0) + printf("transfer request creation failed\n"); + /* ret = PDCregion_transfer_start(tids[i]); */ + /* if (ret != SUCCEED) */ + /* printf("Failed to start transfer\n"); */ + } + + /* printf("rank %d call wait_all on tids.\n", mpi_rank); */ + fprintf(stderr, "Rank %4d: create took %.6f\n", mpi_rank, MPI_Wtime() - stime); + + /* MPI_Barrier(MPI_COMM_WORLD); */ + stime = MPI_Wtime(); + + ret = PDCregion_transfer_start_all(tids, iterations); + if (ret != SUCCEED) + printf("Failed to start transfer\n"); + + fprintf(stderr, "Rank %4d: start all tids took %.6f\n", mpi_rank, MPI_Wtime() - stime); + + stime = MPI_Wtime(); + + ret = PDCregion_transfer_wait_all(tids, iterations); + if (ret != SUCCEED) + printf("Failed to wait all transfer\n"); + + /* printf("rank %d read before wait_all()\n", mpi_rank); */ + /* MPI_Barrier(MPI_COMM_WORLD); */ + fprintf(stderr, "Rank %4d: wait all tids took %.6f\n", mpi_rank, MPI_Wtime() - stime); + + char *data_in = (char *)malloc(chunk_size * sizeof(char)); + offset_local = 0; + offset_remote = 0; + region_local = PDCregion_create(ndim, &offset_local, &chunk_size); + region_remote = PDCregion_create(ndim, &offset_remote, &chunk_size); + pdcid_t read_tid = PDCregion_transfer_create(data_in, PDC_READ, obj_id, region_local, region_remote); + ret = PDCregion_transfer_start(read_tid); + ret = PDCregion_transfer_wait(read_tid); + ret = PDCregion_transfer_close(read_tid); + /* printf("rank %d read success!\n", mpi_rank); */ + fprintf(stderr, "Rank %4d: wait read took %.6f\n", mpi_rank, MPI_Wtime() - stime); + + // Write more + stime = MPI_Wtime(); + int N = 10; + pdcid_t *tids2 = (pdcid_t *)malloc(sizeof(pdcid_t) * N); + offset_local = 0; + offset_remote = iterations * chunk_size; // start from the end of the last write + for (int i = 0; i < N; i++) { + region_local = PDCregion_create(ndim, &offset_local, &chunk_size); + region_remote = PDCregion_create(ndim, &offset_remote, &chunk_size); + offset_remote += chunk_size; + tids2[i] = PDCregion_transfer_create(data_out, PDC_WRITE, obj_id, region_local, region_remote); + if (tids2[i] == 0) + printf("transfer request creation failed\n"); + /* ret = PDCregion_transfer_start(tids2[i]); */ + /* if (ret != SUCCEED) */ + /* printf("Failed to start transfer\n"); */ + } + fprintf(stderr, "Rank %4d: create tids2 took %.6f\n", mpi_rank, MPI_Wtime() - stime); + + stime = MPI_Wtime(); + + ret = PDCregion_transfer_start_all(tids2, N); + if (ret != SUCCEED) + printf("Failed to start transfer\n"); + + fprintf(stderr, "Rank %4d: start tids2 took %.6f\n", mpi_rank, MPI_Wtime() - stime); + /* ret = PDCregion_transfer_wait_all(tids, (iterations)); */ + /* if (ret != SUCCEED) */ + /* printf("Failed to transfer wait\n"); */ + + stime = MPI_Wtime(); + /* printf("rank %d call wait_all on tids2.\n", mpi_rank); */ + ret = PDCregion_transfer_wait_all(tids2, (N)); + if (ret != SUCCEED) + printf("Failed to transfer wait\n"); + + fprintf(stderr, "Rank %4d: wait all tids2 took %.6f\n", mpi_rank, MPI_Wtime() - stime); + + for (int i = 0; i < iterations; i++) { + ret = PDCregion_transfer_close(tids[i]); + if (ret != SUCCEED) + printf("region transfer close failed\n"); + } + for (int i = 0; i < N; i++) { + ret = PDCregion_transfer_close(tids2[i]); + if (ret != SUCCEED) + printf("region transfer close failed\n"); + } + + free(data_in); + free(data_out); + free(tids); + free(tids2); +} + +int +main(int argc, char **argv) +{ + + pdcid_t pdc_id, cont_prop, cont_id; + pdcid_t obj_prop, obj_id; + + uint64_t dims[1] = {PDC_SIZE_UNLIMITED}; + + MPI_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); + MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); + MPI_Comm_dup(MPI_COMM_WORLD, &mpi_comm); + + // create a pdc + pdc_id = PDCinit("pdc"); + + // create a container property + cont_prop = PDCprop_create(PDC_CONT_CREATE, pdc_id); + if (cont_prop <= 0) { + printf("Fail to create container property @ line %d!\n", __LINE__); + } + // create a container + cont_id = PDCcont_create_col("c1", cont_prop); + if (cont_id <= 0) { + printf("Fail to create container @ line %d!\n", __LINE__); + } + + // create an object property + obj_prop = PDCprop_create(PDC_OBJ_CREATE, pdc_id); + PDCprop_set_obj_dims(obj_prop, 1, dims); + PDCprop_set_obj_type(obj_prop, PDC_CHAR); + PDCprop_set_obj_time_step(obj_prop, 0); + PDCprop_set_obj_user_id(obj_prop, getuid()); + PDCprop_set_obj_app_name(obj_prop, "producer"); + PDCprop_set_obj_transfer_region_type(obj_prop, PDC_REGION_LOCAL); + + char obj_name[100] = {0}; + sprintf(obj_name, "obj-var-%d", mpi_rank); + PDCprop_set_obj_tags(obj_prop, obj_name); + obj_id = PDCobj_create(cont_id, obj_name, obj_prop); + + MPI_Barrier(MPI_COMM_WORLD); + double stime = MPI_Wtime(); + write_read_wait_all(obj_id, 1000); + + MPI_Barrier(MPI_COMM_WORLD); + fprintf(stderr, "Rank %4d: Write read wait all took %.6f\n", mpi_rank, MPI_Wtime() - stime); + + if (PDCobj_close(obj_id) < 0) { + printf("fail to close obj_id\n"); + } + + if (PDCprop_close(cont_prop) < 0) { + printf("Fail to close property @ line %d\n", __LINE__); + } + + if (PDCclose(pdc_id) < 0) { + printf("fail to close PDC\n"); + } + + MPI_Finalize(); +} diff --git a/src/tests/run_checkpoint_restart_test.sh b/src/tests/run_checkpoint_restart_test.sh index 4986589d6..270c252b7 100755 --- a/src/tests/run_checkpoint_restart_test.sh +++ b/src/tests/run_checkpoint_restart_test.sh @@ -5,8 +5,8 @@ # Cori CI needs srun even for serial tests run_cmd="" -if [[ "$HOSTNAME" == "cori"* || "$HOSTNAME" == "nid"* ]]; then - run_cmd="srun -n 1 --mem=25600 --cpu_bind=cores --gres=craynetwork:1 --overlap" +if [[ "$HOSTNAME" == "*nid*" ]]; then + run_cmd="srun -n 1 --mem=25600 --cpu_bind=cores --overlap" fi if [ $# -lt 1 ]; then echo "missing test argument" && exit -1 ; fi diff --git a/src/tests/run_multiple_mpi_test.sh b/src/tests/run_multiple_mpi_test.sh new file mode 100644 index 000000000..957473fa8 --- /dev/null +++ b/src/tests/run_multiple_mpi_test.sh @@ -0,0 +1,52 @@ +#!/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. -LPDC_id_type_list_g)[type_id]) { /* Allocate the type information for new type */ - if (NULL == (type_ptr = PDC_CALLOC(1, struct PDC_id_type))) + if (NULL == (type_ptr = (struct PDC_id_type *)PDC_calloc(1, sizeof(struct PDC_id_type)))) PGOTO_ERROR(FAIL, "ID type allocation failed"); (pdc_id_list_g->PDC_id_type_list_g)[type_id] = type_ptr; } @@ -120,7 +120,7 @@ PDC_id_register(PDC_type_t type, void *object) type_ptr = (pdc_id_list_g->PDC_id_type_list_g)[type]; if (NULL == type_ptr || type_ptr->init_count <= 0) PGOTO_ERROR(ret_value, "invalid type"); - if (NULL == (id_ptr = PDC_MALLOC(struct _pdc_id_info))) + if (NULL == (id_ptr = (struct _pdc_id_info *)PDC_malloc(sizeof(struct _pdc_id_info)))) PGOTO_ERROR(ret_value, "memory allocation failed"); /* Create the struct & it's ID */ @@ -172,7 +172,7 @@ PDC_dec_ref(pdcid_t id) PDC_MUTEX_LOCK(type_ptr->ids); /* Remove the node from the type */ PDC_LIST_REMOVE(id_ptr, entry); - id_ptr = PDC_FREE(struct _pdc_id_info, id_ptr); + id_ptr = (struct _pdc_id_info *)(intptr_t)PDC_free(id_ptr); /* Decrement the number of IDs in the type */ (type_ptr->id_count)--; ret_value = 0; @@ -267,7 +267,7 @@ PDC_id_list_clear(PDC_type_t type) if (!type_ptr->free_func || (type_ptr->free_func)((void *)id_ptr->obj_ptr) >= 0) { PDC_MUTEX_LOCK(type_ptr->ids); PDC_LIST_REMOVE(id_ptr, entry); - id_ptr = PDC_FREE(struct _pdc_id_info, id_ptr); + id_ptr = (struct _pdc_id_info *)(intptr_t)PDC_free(id_ptr); (type_ptr->id_count)--; PDC_MUTEX_UNLOCK(type_ptr->ids); } @@ -289,7 +289,7 @@ PDC_destroy_type(PDC_type_t type) type_ptr = (pdc_id_list_g->PDC_id_type_list_g)[type]; if (type_ptr == NULL) PGOTO_ERROR(FAIL, "type was not initialized correctly"); - type_ptr = PDC_FREE(struct PDC_id_type, type_ptr); + type_ptr = (struct PDC_id_type *)(intptr_t)PDC_free(type_ptr); done: fflush(stdout);