Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add MPI communicator to collective calls.
  • Loading branch information
TheAssembler1 committed Oct 21, 2025
commit 2401eb8595aa9b4d6f23d011cb49b6b1ceabc5ce
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,11 @@ endif()
# MPI option
#-----------------------------------------------------------------------------
option(PDC_ENABLE_MPI "Enable MPI." ON)

if(PDC_ENABLE_MPI)
find_package(MPI)
if(MPI_FOUND)
set(ENABLE_MPI 1)
add_compile_definitions(ENABLE_MPI=1)
endif()
endif()

Expand Down
7 changes: 4 additions & 3 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,19 @@ PDC container APIs

.. function:: pdcid_t PDCcont_create(const char *cont_name, pdcid_t cont_prop_id)

:param cont_name: the name of container. e.g "c1", "c2"
:param cont_name: the name of container. e.g "c1", "c2".
:param cont_prop_id: property ID for inheriting a PDC property for container.
:returns: pdc_id for future referencing of this container, returned from PDC servers.

Create a PDC container for future use.

For developers: currently implemented in `pdc_cont.c`. This function will send a name to server and receive a container id. This function will allocate necessary memories and initialize properties for a container.

.. function:: pdcid_t PDCcont_create_coll(const char *cont_name, pdcid_t cont_prop_id)
.. function:: pdcid_t PDCcont_create_coll(const char *cont_name, pdcid_t cont_prop_id, MPI_Comm mpi_comm)

:param cont_name: the name to be assigned to a container. e.g "c1", "c2"
:param cont_name: the name to be assigned to a container. e.g "c1", "c2".
:param cont_prop_id: property ID for inheriting a PDC property for container.
:param mpi_comm: MPI communicator.
:returns: pdc_id for future referencing.

Exactly the same as ``PDCcont_create``, except all processes must call this function collectively. Create a PDC container for future use collectively.
Expand Down
38 changes: 19 additions & 19 deletions examples/bdcats.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ main(int argc, char **argv)
pdcid_t region_xx, region_yy, region_zz, region_pxx, region_pyy, region_pzz, region_id11, region_id22;
perr_t ret;

float * x, *y, *z;
float * px, *py, *pz;
int * id1, *id2;
float *x, *y, *z;
float *px, *py, *pz;
int *id1, *id2;
uint64_t numparticles;
int ndim = 1;
uint64_t *offset;
Expand Down Expand Up @@ -101,63 +101,63 @@ main(int argc, char **argv)
if (cont_id == 0)
LOG_ERROR("Failed to create container");

// open objects
// open objects
#ifdef ENABLE_MPI
obj_xx = PDCobj_open_coll("obj-var-xx", pdc_id);
obj_xx = PDCobj_open_coll("obj-var-xx", pdc_id, MPI_COMM_WORLD);
#else
obj_xx = PDCobj_open("obj-var-xx", pdc_id);
obj_xx = PDCobj_open("obj-var-xx", pdc_id);
#endif
if (obj_xx == 0) {
LOG_ERROR("Error when open object %s\n", "obj-var-xx");
exit(-1);
}
#ifdef ENABLE_MPI
obj_yy = PDCobj_open_coll("obj-var-yy", pdc_id);
obj_yy = PDCobj_open_coll("obj-var-yy", pdc_id, MPI_COMM_WORLD);
#else
obj_yy = PDCobj_open("obj-var-xx", pdc_id);
obj_yy = PDCobj_open("obj-var-xx", pdc_id);
#endif
if (obj_yy == 0) {
LOG_ERROR("Error when open object %s\n", "obj-var-yy");
exit(-1);
}
#ifdef ENABLE_MPI
obj_zz = PDCobj_open_coll("obj-var-zz", pdc_id);
obj_zz = PDCobj_open_coll("obj-var-zz", pdc_id, MPI_COMM_WORLD);
#else
obj_zz = PDCobj_open("obj-var-xx", pdc_id);
obj_zz = PDCobj_open("obj-var-xx", pdc_id);
#endif
if (obj_zz == 0) {
LOG_ERROR("Error when open object %s\n", "obj-var-zz");
exit(-1);
}
#ifdef ENABLE_MPI
obj_pxx = PDCobj_open_coll("obj-var-pxx", pdc_id);
obj_pxx = PDCobj_open_coll("obj-var-pxx", pdc_id, MPI_COMM_WORLD);
#else
obj_pxx = PDCobj_open("obj-var-xx", pdc_id);
obj_pxx = PDCobj_open("obj-var-xx", pdc_id);
#endif
if (obj_pxx == 0) {
LOG_ERROR("Error when open object %s\n", "obj-var-pxx");
exit(-1);
}
#ifdef ENABLE_MPI
obj_pyy = PDCobj_open_coll("obj-var-pyy", pdc_id);
obj_pyy = PDCobj_open_coll("obj-var-pyy", pdc_id, MPI_COMM_WORLD);
#else
obj_pyy = PDCobj_open("obj-var-xx", pdc_id);
obj_pyy = PDCobj_open("obj-var-xx", pdc_id);
#endif
if (obj_pyy == 0) {
LOG_ERROR("Error when open object %s\n", "obj-var-pyy");
exit(-1);
}
#ifdef ENABLE_MPI
obj_pzz = PDCobj_open_coll("obj-var-pzz", pdc_id);
obj_pzz = PDCobj_open_coll("obj-var-pzz", pdc_id, MPI_COMM_WORLD);
#else
obj_pzz = PDCobj_open("obj-var-xx", pdc_id);
obj_pzz = PDCobj_open("obj-var-xx", pdc_id);
#endif
if (obj_pzz == 0) {
LOG_ERROR("Error when open object %s\n", "obj-var-pzz");
exit(-1);
}
#ifdef ENABLE_MPI
obj_id11 = PDCobj_open_coll("id11", pdc_id);
obj_id11 = PDCobj_open_coll("id11", pdc_id, MPI_COMM_WORLD);
#else
obj_id11 = PDCobj_open("obj-var-xx", pdc_id);
#endif
Expand All @@ -166,9 +166,9 @@ main(int argc, char **argv)
exit(-1);
}
#ifdef ENABLE_MPI
obj_id22 = PDCobj_open_coll("id22", pdc_id);
obj_id22 = PDCobj_open_coll("id22", pdc_id, MPI_COMM_WORLD);
#else
obj_id22 = PDCobj_open("obj-var-xx", pdc_id);
obj_id22 = PDCobj_open("obj-var-xx", pdc_id, );
#endif
if (obj_id22 == 0) {
LOG_ERROR("Error when open object %s\n", "id22");
Expand Down
30 changes: 15 additions & 15 deletions examples/bdcats_batch.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ main(int argc, char **argv)
char obj_name[128];
float *x, *y, *z;
float *px, *py, *pz;
int * id1, *id2;
int *id1, *id2;
// int x_dim = 64;
// int y_dim = 64;
// int z_dim = 64;
Expand Down Expand Up @@ -175,67 +175,67 @@ main(int argc, char **argv)
for (i = 0; i < timestep; ++i) {
sprintf(obj_name, "obj-var-xx %" PRIu64 "", i);
#ifdef ENABLE_MPI
obj_xx[i] = PDCobj_open_coll(obj_name, pdc_id);
obj_xx[i] = PDCobj_open_coll(obj_name, pdc_id, comm);
#else
obj_xx[i] = PDCobj_open(obj_name, pdc_id);
obj_xx[i] = PDCobj_open(obj_name, pdc_id);
#endif
if (obj_xx[i] == 0) {
LOG_ERROR("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_coll(obj_name, pdc_id);
obj_yy[i] = PDCobj_open_coll(obj_name, pdc_id, comm);
#else
obj_yy[i] = PDCobj_open(obj_name, pdc_id);
obj_yy[i] = PDCobj_open(obj_name, pdc_id);
#endif
if (obj_yy[i] == 0) {
LOG_ERROR("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_coll(obj_name, pdc_id);
obj_zz[i] = PDCobj_open_coll(obj_name, pdc_id, comm);
#else
obj_zz[i] = PDCobj_open(obj_name, pdc_id);
obj_zz[i] = PDCobj_open(obj_name, pdc_id);
#endif
if (obj_zz[i] == 0) {
LOG_ERROR("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_coll(obj_name, pdc_id);
obj_pxx[i] = PDCobj_open_coll(obj_name, pdc_id, comm);
#else
obj_pxx[i] = PDCobj_open(obj_name, pdc_id);
obj_pxx[i] = PDCobj_open(obj_name, pdc_id);
#endif
if (obj_pxx[i] == 0) {
LOG_ERROR("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_coll(obj_name, pdc_id);
obj_pyy[i] = PDCobj_open_coll(obj_name, pdc_id, comm);
#else
obj_pyy[i] = PDCobj_open(obj_name, pdc_id);
obj_pyy[i] = PDCobj_open(obj_name, pdc_id);
#endif
if (obj_pyy[i] == 0) {
LOG_ERROR("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_coll(obj_name, pdc_id);
obj_pzz[i] = PDCobj_open_coll(obj_name, pdc_id, comm);
#else
obj_pzz[i] = PDCobj_open(obj_name, pdc_id);
obj_pzz[i] = PDCobj_open(obj_name, pdc_id);
#endif
if (obj_pzz[i] == 0) {
LOG_ERROR("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_coll(obj_name, pdc_id);
obj_id11[i] = PDCobj_open_coll(obj_name, pdc_id, comm);
#else
obj_id11[i] = PDCobj_open(obj_name, pdc_id);
#endif
Expand All @@ -245,7 +245,7 @@ main(int argc, char **argv)
}
sprintf(obj_name, "id22 %" PRIu64 "", i);
#ifdef ENABLE_MPI
obj_id22[i] = PDCobj_open_coll(obj_name, pdc_id);
obj_id22[i] = PDCobj_open_coll(obj_name, pdc_id, comm);
#else
obj_id22[i] = PDCobj_open(obj_name, pdc_id);
#endif
Expand Down
6 changes: 3 additions & 3 deletions examples/haccio.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ mask | int16 | 2 bytes
* ------------------
*/

static char * VAR_NAMES[NUM_VARS] = {"xx", "yy", "zz", "vx", "vy", "vz", "phi", "phd", "mask"};
static char *VAR_NAMES[NUM_VARS] = {"xx", "yy", "zz", "vx", "vy", "vz", "phi", "phd", "mask"};
static pdc_var_type_t VAR_TYPES[NUM_VARS] = {PDC_FLOAT, PDC_FLOAT, PDC_FLOAT, PDC_FLOAT, PDC_FLOAT,
PDC_FLOAT, PDC_FLOAT, PDC_INT64, PDC_INT16};
static int NUM_PARTICLES = (1 * 1024 * 1024);
void * buffers[NUM_VARS];
void *buffers[NUM_VARS];

MPI_Comm comm;

Expand Down Expand Up @@ -117,7 +117,7 @@ main(int argc, char **argv)
cont_prop = PDCprop_create(PDC_CONT_CREATE, pdc_id);

// create a container
cont_id = PDCcont_create_coll("c1", cont_prop);
cont_id = PDCcont_create_coll("c1", cont_prop, comm);

uint64_t offset = 0, offset_remote = mpi_rank * NUM_PARTICLES, mysize = NUM_PARTICLES;

Expand Down
8 changes: 4 additions & 4 deletions examples/haccio_v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ mask | int16 | 2 bytes
* ------------------
*/

static char * VAR_NAMES[NUM_VARS] = {"xx", "yy", "zz", "vx", "vy", "vz", "phi", "phd", "mask"};
static char *VAR_NAMES[NUM_VARS] = {"xx", "yy", "zz", "vx", "vy", "vz", "phi", "phd", "mask"};
static pdc_var_type_t VAR_TYPES[NUM_VARS] = {PDC_FLOAT, PDC_FLOAT, PDC_FLOAT, PDC_FLOAT, PDC_FLOAT,
PDC_FLOAT, PDC_FLOAT, PDC_INT64, PDC_INT16};
static int NUM_PARTICLES = (1 * 1024 * 1024);
void * buffers[NUM_VARS];
void *buffers[NUM_VARS];

MPI_Comm comm;

Expand Down Expand Up @@ -76,7 +76,7 @@ create_pdc_object(pdcid_t pdc_id, pdcid_t cont_id, const char *obj_name, pdc_var
PDCprop_set_obj_app_name(*obj_prop, "HACCIO");
PDCprop_set_obj_consistency_semantics(*obj_prop, PDC_CONSISTENCY_POSIX);

pdcid_t obj_id = PDCobj_create_coll(cont_id, obj_name, *obj_prop, 0, comm);
pdcid_t obj_id = PDCobj_create_coll(cont_id, obj_name, *obj_prop, 0, MPI_COMM_WORLD);
if (obj_id == 0) {
LOG_ERROR("Error getting an object id of %s from server, exit...\n", "obj-var-xx");
exit(-1);
Expand Down Expand Up @@ -119,7 +119,7 @@ main(int argc, char **argv)
cont_prop = PDCprop_create(PDC_CONT_CREATE, pdc_id);

// create a container
cont_id = PDCcont_create_coll("c1", cont_prop);
cont_id = PDCcont_create_coll("c1", cont_prop, MPI_COMM_WORLD);

uint64_t offset = 0, offset_remote = mpi_rank * NUM_PARTICLES, mysize = NUM_PARTICLES;

Expand Down
4 changes: 2 additions & 2 deletions examples/tileio.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ main(int argc, char **argv)
pdcid_t obj_id, obj_prop;
pdcid_t local_region_id, global_region_id;

double * local_buffer = (double *)malloc(g_x_ept * g_y_ept * sizeof(double));
double *local_buffer = (double *)malloc(g_x_ept * g_y_ept * sizeof(double));
uint64_t dims[NUM_DIMS] = {g_x_ept, g_y_ept};
uint64_t local_offsets[NUM_DIMS], global_offsets[NUM_DIMS];
local_offsets[0] = 0;
Expand All @@ -112,7 +112,7 @@ main(int argc, char **argv)

// Create containter
cont_prop = PDCprop_create(PDC_CONT_CREATE, pdc_id);
cont_id = PDCcont_create_coll("c1", cont_prop);
cont_id = PDCcont_create_coll("c1", cont_prop, MPI_COMM_WORLD);

// Craete object (and its prop)
obj_id = create_pdc_object(pdc_id, cont_id, "tile_io_obj", &obj_prop);
Expand Down
2 changes: 1 addition & 1 deletion examples/tileio_v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ main(int argc, char **argv)
// Init PDC
pdc_id = PDCinit("pdc");
cont_prop = PDCprop_create(PDC_CONT_CREATE, pdc_id);
cont_id = PDCcont_create_coll("c1", cont_prop);
cont_id = PDCcont_create_coll("c1", cont_prop, g_mpi_comm);
obj_id = create_pdc_object(pdc_id, cont_id, "tile_io_obj", &obj_prop);

// Create region
Expand Down
8 changes: 4 additions & 4 deletions examples/vpicio.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ main(int argc, char **argv)
#else
int comm = 1;
#endif
float * x, *y, *z;
float * px, *py, *pz;
int * id1, *id2;
float *x, *y, *z;
float *px, *py, *pz;
int *id1, *id2;
int x_dim = 64;
int y_dim = 64;
int z_dim = 64;
Expand Down Expand Up @@ -116,7 +116,7 @@ main(int argc, char **argv)
return 1;
}
// create a container
cont_id = PDCcont_create_coll("c1", cont_prop);
cont_id = PDCcont_create_coll("c1", cont_prop, comm);
if (cont_id <= 0) {
LOG_ERROR("Failed to create container");
return 1;
Expand Down
10 changes: 5 additions & 5 deletions examples/vpicio_batch.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ main(int argc, char **argv)
int comm = 1;
#endif
char obj_name[128];
float * x, *y, *z;
float * px, *py, *pz;
int * id1, *id2;
float *x, *y, *z;
float *px, *py, *pz;
int *id1, *id2;
int x_dim = 64;
int y_dim = 64;
int z_dim = 64;
Expand All @@ -82,7 +82,7 @@ main(int argc, char **argv)
unsigned sleep_time = 0;
int test_method = 2;
int do_flush = 0;
pdcid_t * transfer_request_x, *transfer_request_y, *transfer_request_z, *transfer_request_px,
pdcid_t *transfer_request_x, *transfer_request_y, *transfer_request_z, *transfer_request_px,
*transfer_request_py, *transfer_request_pz, *transfer_request_id1, *transfer_request_id2, *ptr,
*temp_requests;

Expand Down Expand Up @@ -149,7 +149,7 @@ main(int argc, char **argv)
return 1;
}
// create a container
cont_id = PDCcont_create_coll("c1", cont_prop);
cont_id = PDCcont_create_coll("c1", cont_prop, comm);
if (cont_id <= 0) {
LOG_ERROR("Failed to create container");
return 1;
Expand Down
8 changes: 4 additions & 4 deletions examples/vpicio_old.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ main(int argc, char **argv)
#else
int comm = 1;
#endif
float * x, *y, *z;
float * px, *py, *pz;
int * id1, *id2;
float *x, *y, *z;
float *px, *py, *pz;
int *id1, *id2;
int x_dim = 64;
int y_dim = 64;
int z_dim = 64;
Expand Down Expand Up @@ -113,7 +113,7 @@ main(int argc, char **argv)
return 1;
}
// create a container
cont_id = PDCcont_create_coll("c1", cont_prop);
cont_id = PDCcont_create_coll("c1", cont_prop, comm);
if (cont_id <= 0) {
LOG_ERROR("Failed to create container");
return 1;
Expand Down
Loading
Loading