Skip to content

Commit

Permalink
BDCATS fix (#193)
Browse files Browse the repository at this point in the history
* Fix issues with bdcats_batch

* Committing clang-format changes

---------

Co-authored-by: github-actions <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
houjun and github-actions[bot] authored Apr 11, 2024
1 parent 5a6e943 commit 90567f1
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 43 deletions.
2 changes: 1 addition & 1 deletion examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 $<
Expand Down
50 changes: 41 additions & 9 deletions examples/bdcats.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
99 changes: 66 additions & 33 deletions examples/bdcats_batch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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]);
Expand All @@ -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));
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 90567f1

Please sign in to comment.