Skip to content

Commit 2401eb8

Browse files
committed
Add MPI communicator to collective calls.
1 parent f406528 commit 2401eb8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+596
-435
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,10 +358,11 @@ endif()
358358
# MPI option
359359
#-----------------------------------------------------------------------------
360360
option(PDC_ENABLE_MPI "Enable MPI." ON)
361+
361362
if(PDC_ENABLE_MPI)
362363
find_package(MPI)
363364
if(MPI_FOUND)
364-
set(ENABLE_MPI 1)
365+
add_compile_definitions(ENABLE_MPI=1)
365366
endif()
366367
endif()
367368

docs/source/api.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,19 @@ PDC container APIs
4040

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

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

4747
Create a PDC container for future use.
4848

4949
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.
5050

51-
.. function:: pdcid_t PDCcont_create_coll(const char *cont_name, pdcid_t cont_prop_id)
51+
.. function:: pdcid_t PDCcont_create_coll(const char *cont_name, pdcid_t cont_prop_id, MPI_Comm mpi_comm)
5252

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

5758
Exactly the same as ``PDCcont_create``, except all processes must call this function collectively. Create a PDC container for future use collectively.

examples/bdcats.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ main(int argc, char **argv)
5757
pdcid_t region_xx, region_yy, region_zz, region_pxx, region_pyy, region_pzz, region_id11, region_id22;
5858
perr_t ret;
5959

60-
float * x, *y, *z;
61-
float * px, *py, *pz;
62-
int * id1, *id2;
60+
float *x, *y, *z;
61+
float *px, *py, *pz;
62+
int *id1, *id2;
6363
uint64_t numparticles;
6464
int ndim = 1;
6565
uint64_t *offset;
@@ -101,63 +101,63 @@ main(int argc, char **argv)
101101
if (cont_id == 0)
102102
LOG_ERROR("Failed to create container");
103103

104-
// open objects
104+
// open objects
105105
#ifdef ENABLE_MPI
106-
obj_xx = PDCobj_open_coll("obj-var-xx", pdc_id);
106+
obj_xx = PDCobj_open_coll("obj-var-xx", pdc_id, MPI_COMM_WORLD);
107107
#else
108-
obj_xx = PDCobj_open("obj-var-xx", pdc_id);
108+
obj_xx = PDCobj_open("obj-var-xx", pdc_id);
109109
#endif
110110
if (obj_xx == 0) {
111111
LOG_ERROR("Error when open object %s\n", "obj-var-xx");
112112
exit(-1);
113113
}
114114
#ifdef ENABLE_MPI
115-
obj_yy = PDCobj_open_coll("obj-var-yy", pdc_id);
115+
obj_yy = PDCobj_open_coll("obj-var-yy", pdc_id, MPI_COMM_WORLD);
116116
#else
117-
obj_yy = PDCobj_open("obj-var-xx", pdc_id);
117+
obj_yy = PDCobj_open("obj-var-xx", pdc_id);
118118
#endif
119119
if (obj_yy == 0) {
120120
LOG_ERROR("Error when open object %s\n", "obj-var-yy");
121121
exit(-1);
122122
}
123123
#ifdef ENABLE_MPI
124-
obj_zz = PDCobj_open_coll("obj-var-zz", pdc_id);
124+
obj_zz = PDCobj_open_coll("obj-var-zz", pdc_id, MPI_COMM_WORLD);
125125
#else
126-
obj_zz = PDCobj_open("obj-var-xx", pdc_id);
126+
obj_zz = PDCobj_open("obj-var-xx", pdc_id);
127127
#endif
128128
if (obj_zz == 0) {
129129
LOG_ERROR("Error when open object %s\n", "obj-var-zz");
130130
exit(-1);
131131
}
132132
#ifdef ENABLE_MPI
133-
obj_pxx = PDCobj_open_coll("obj-var-pxx", pdc_id);
133+
obj_pxx = PDCobj_open_coll("obj-var-pxx", pdc_id, MPI_COMM_WORLD);
134134
#else
135-
obj_pxx = PDCobj_open("obj-var-xx", pdc_id);
135+
obj_pxx = PDCobj_open("obj-var-xx", pdc_id);
136136
#endif
137137
if (obj_pxx == 0) {
138138
LOG_ERROR("Error when open object %s\n", "obj-var-pxx");
139139
exit(-1);
140140
}
141141
#ifdef ENABLE_MPI
142-
obj_pyy = PDCobj_open_coll("obj-var-pyy", pdc_id);
142+
obj_pyy = PDCobj_open_coll("obj-var-pyy", pdc_id, MPI_COMM_WORLD);
143143
#else
144-
obj_pyy = PDCobj_open("obj-var-xx", pdc_id);
144+
obj_pyy = PDCobj_open("obj-var-xx", pdc_id);
145145
#endif
146146
if (obj_pyy == 0) {
147147
LOG_ERROR("Error when open object %s\n", "obj-var-pyy");
148148
exit(-1);
149149
}
150150
#ifdef ENABLE_MPI
151-
obj_pzz = PDCobj_open_coll("obj-var-pzz", pdc_id);
151+
obj_pzz = PDCobj_open_coll("obj-var-pzz", pdc_id, MPI_COMM_WORLD);
152152
#else
153-
obj_pzz = PDCobj_open("obj-var-xx", pdc_id);
153+
obj_pzz = PDCobj_open("obj-var-xx", pdc_id);
154154
#endif
155155
if (obj_pzz == 0) {
156156
LOG_ERROR("Error when open object %s\n", "obj-var-pzz");
157157
exit(-1);
158158
}
159159
#ifdef ENABLE_MPI
160-
obj_id11 = PDCobj_open_coll("id11", pdc_id);
160+
obj_id11 = PDCobj_open_coll("id11", pdc_id, MPI_COMM_WORLD);
161161
#else
162162
obj_id11 = PDCobj_open("obj-var-xx", pdc_id);
163163
#endif
@@ -166,9 +166,9 @@ main(int argc, char **argv)
166166
exit(-1);
167167
}
168168
#ifdef ENABLE_MPI
169-
obj_id22 = PDCobj_open_coll("id22", pdc_id);
169+
obj_id22 = PDCobj_open_coll("id22", pdc_id, MPI_COMM_WORLD);
170170
#else
171-
obj_id22 = PDCobj_open("obj-var-xx", pdc_id);
171+
obj_id22 = PDCobj_open("obj-var-xx", pdc_id, );
172172
#endif
173173
if (obj_id22 == 0) {
174174
LOG_ERROR("Error when open object %s\n", "id22");

examples/bdcats_batch.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ main(int argc, char **argv)
6666
char obj_name[128];
6767
float *x, *y, *z;
6868
float *px, *py, *pz;
69-
int * id1, *id2;
69+
int *id1, *id2;
7070
// int x_dim = 64;
7171
// int y_dim = 64;
7272
// int z_dim = 64;
@@ -175,67 +175,67 @@ main(int argc, char **argv)
175175
for (i = 0; i < timestep; ++i) {
176176
sprintf(obj_name, "obj-var-xx %" PRIu64 "", i);
177177
#ifdef ENABLE_MPI
178-
obj_xx[i] = PDCobj_open_coll(obj_name, pdc_id);
178+
obj_xx[i] = PDCobj_open_coll(obj_name, pdc_id, comm);
179179
#else
180-
obj_xx[i] = PDCobj_open(obj_name, pdc_id);
180+
obj_xx[i] = PDCobj_open(obj_name, pdc_id);
181181
#endif
182182
if (obj_xx[i] == 0) {
183183
LOG_ERROR("Error getting an object id of %s from server, exit...\n", "obj-var-xx");
184184
exit(-1);
185185
}
186186
sprintf(obj_name, "obj-var-yy %" PRIu64 "", i);
187187
#ifdef ENABLE_MPI
188-
obj_yy[i] = PDCobj_open_coll(obj_name, pdc_id);
188+
obj_yy[i] = PDCobj_open_coll(obj_name, pdc_id, comm);
189189
#else
190-
obj_yy[i] = PDCobj_open(obj_name, pdc_id);
190+
obj_yy[i] = PDCobj_open(obj_name, pdc_id);
191191
#endif
192192
if (obj_yy[i] == 0) {
193193
LOG_ERROR("Error getting an object id of %s from server, exit...\n", "obj-var-yy");
194194
exit(-1);
195195
}
196196
sprintf(obj_name, "obj-var-zz %" PRIu64 "", i);
197197
#ifdef ENABLE_MPI
198-
obj_zz[i] = PDCobj_open_coll(obj_name, pdc_id);
198+
obj_zz[i] = PDCobj_open_coll(obj_name, pdc_id, comm);
199199
#else
200-
obj_zz[i] = PDCobj_open(obj_name, pdc_id);
200+
obj_zz[i] = PDCobj_open(obj_name, pdc_id);
201201
#endif
202202
if (obj_zz[i] == 0) {
203203
LOG_ERROR("Error getting an object id of %s from server, exit...\n", "obj-var-zz");
204204
exit(-1);
205205
}
206206
sprintf(obj_name, "obj-var-pxx %" PRIu64 "", i);
207207
#ifdef ENABLE_MPI
208-
obj_pxx[i] = PDCobj_open_coll(obj_name, pdc_id);
208+
obj_pxx[i] = PDCobj_open_coll(obj_name, pdc_id, comm);
209209
#else
210-
obj_pxx[i] = PDCobj_open(obj_name, pdc_id);
210+
obj_pxx[i] = PDCobj_open(obj_name, pdc_id);
211211
#endif
212212
if (obj_pxx[i] == 0) {
213213
LOG_ERROR("Error getting an object id of %s from server, exit...\n", "obj-var-pxx");
214214
exit(-1);
215215
}
216216
sprintf(obj_name, "obj-var-pyy %" PRIu64 "", i);
217217
#ifdef ENABLE_MPI
218-
obj_pyy[i] = PDCobj_open_coll(obj_name, pdc_id);
218+
obj_pyy[i] = PDCobj_open_coll(obj_name, pdc_id, comm);
219219
#else
220-
obj_pyy[i] = PDCobj_open(obj_name, pdc_id);
220+
obj_pyy[i] = PDCobj_open(obj_name, pdc_id);
221221
#endif
222222
if (obj_pyy[i] == 0) {
223223
LOG_ERROR("Error getting an object id of %s from server, exit...\n", "obj-var-pyy");
224224
exit(-1);
225225
}
226226
sprintf(obj_name, "obj-var-pzz %" PRIu64 "", i);
227227
#ifdef ENABLE_MPI
228-
obj_pzz[i] = PDCobj_open_coll(obj_name, pdc_id);
228+
obj_pzz[i] = PDCobj_open_coll(obj_name, pdc_id, comm);
229229
#else
230-
obj_pzz[i] = PDCobj_open(obj_name, pdc_id);
230+
obj_pzz[i] = PDCobj_open(obj_name, pdc_id);
231231
#endif
232232
if (obj_pzz[i] == 0) {
233233
LOG_ERROR("Error getting an object id of %s from server, exit...\n", "obj-var-pzz");
234234
exit(-1);
235235
}
236236
sprintf(obj_name, "id11 %" PRIu64 "", i);
237237
#ifdef ENABLE_MPI
238-
obj_id11[i] = PDCobj_open_coll(obj_name, pdc_id);
238+
obj_id11[i] = PDCobj_open_coll(obj_name, pdc_id, comm);
239239
#else
240240
obj_id11[i] = PDCobj_open(obj_name, pdc_id);
241241
#endif
@@ -245,7 +245,7 @@ main(int argc, char **argv)
245245
}
246246
sprintf(obj_name, "id22 %" PRIu64 "", i);
247247
#ifdef ENABLE_MPI
248-
obj_id22[i] = PDCobj_open_coll(obj_name, pdc_id);
248+
obj_id22[i] = PDCobj_open_coll(obj_name, pdc_id, comm);
249249
#else
250250
obj_id22[i] = PDCobj_open(obj_name, pdc_id);
251251
#endif

examples/haccio.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ mask | int16 | 2 bytes
2626
* ------------------
2727
*/
2828

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

3535
MPI_Comm comm;
3636

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

119119
// create a container
120-
cont_id = PDCcont_create_coll("c1", cont_prop);
120+
cont_id = PDCcont_create_coll("c1", cont_prop, comm);
121121

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

examples/haccio_v2.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ mask | int16 | 2 bytes
2626
* ------------------
2727
*/
2828

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

3535
MPI_Comm comm;
3636

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

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

121121
// create a container
122-
cont_id = PDCcont_create_coll("c1", cont_prop);
122+
cont_id = PDCcont_create_coll("c1", cont_prop, MPI_COMM_WORLD);
123123

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

examples/tileio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ main(int argc, char **argv)
9999
pdcid_t obj_id, obj_prop;
100100
pdcid_t local_region_id, global_region_id;
101101

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

113113
// Create containter
114114
cont_prop = PDCprop_create(PDC_CONT_CREATE, pdc_id);
115-
cont_id = PDCcont_create_coll("c1", cont_prop);
115+
cont_id = PDCcont_create_coll("c1", cont_prop, MPI_COMM_WORLD);
116116

117117
// Craete object (and its prop)
118118
obj_id = create_pdc_object(pdc_id, cont_id, "tile_io_obj", &obj_prop);

examples/tileio_v2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ main(int argc, char **argv)
115115
// Init PDC
116116
pdc_id = PDCinit("pdc");
117117
cont_prop = PDCprop_create(PDC_CONT_CREATE, pdc_id);
118-
cont_id = PDCcont_create_coll("c1", cont_prop);
118+
cont_id = PDCcont_create_coll("c1", cont_prop, g_mpi_comm);
119119
obj_id = create_pdc_object(pdc_id, cont_id, "tile_io_obj", &obj_prop);
120120

121121
// Create region

examples/vpicio.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ main(int argc, char **argv)
6363
#else
6464
int comm = 1;
6565
#endif
66-
float * x, *y, *z;
67-
float * px, *py, *pz;
68-
int * id1, *id2;
66+
float *x, *y, *z;
67+
float *px, *py, *pz;
68+
int *id1, *id2;
6969
int x_dim = 64;
7070
int y_dim = 64;
7171
int z_dim = 64;
@@ -116,7 +116,7 @@ main(int argc, char **argv)
116116
return 1;
117117
}
118118
// create a container
119-
cont_id = PDCcont_create_coll("c1", cont_prop);
119+
cont_id = PDCcont_create_coll("c1", cont_prop, comm);
120120
if (cont_id <= 0) {
121121
LOG_ERROR("Failed to create container");
122122
return 1;

examples/vpicio_batch.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ main(int argc, char **argv)
6767
int comm = 1;
6868
#endif
6969
char obj_name[128];
70-
float * x, *y, *z;
71-
float * px, *py, *pz;
72-
int * id1, *id2;
70+
float *x, *y, *z;
71+
float *px, *py, *pz;
72+
int *id1, *id2;
7373
int x_dim = 64;
7474
int y_dim = 64;
7575
int z_dim = 64;
@@ -82,7 +82,7 @@ main(int argc, char **argv)
8282
unsigned sleep_time = 0;
8383
int test_method = 2;
8484
int do_flush = 0;
85-
pdcid_t * transfer_request_x, *transfer_request_y, *transfer_request_z, *transfer_request_px,
85+
pdcid_t *transfer_request_x, *transfer_request_y, *transfer_request_z, *transfer_request_px,
8686
*transfer_request_py, *transfer_request_pz, *transfer_request_id1, *transfer_request_id2, *ptr,
8787
*temp_requests;
8888

@@ -149,7 +149,7 @@ main(int argc, char **argv)
149149
return 1;
150150
}
151151
// create a container
152-
cont_id = PDCcont_create_coll("c1", cont_prop);
152+
cont_id = PDCcont_create_coll("c1", cont_prop, comm);
153153
if (cont_id <= 0) {
154154
LOG_ERROR("Failed to create container");
155155
return 1;

0 commit comments

Comments
 (0)