From 90567f14bb609c907d0ec428cb111bbcfa156561 Mon Sep 17 00:00:00 2001 From: Houjun Tang Date: Thu, 11 Apr 2024 16:21:40 -0700 Subject: [PATCH] BDCATS fix (#193) * Fix issues with bdcats_batch * Committing clang-format changes --------- Co-authored-by: github-actions --- examples/Makefile | 2 +- examples/bdcats.c | 50 +++++++++++++++++---- examples/bdcats_batch.c | 99 +++++++++++++++++++++++++++-------------- 3 files changed, 108 insertions(+), 43 deletions(-) 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;