Skip to content

Commit 90567f1

Browse files
BDCATS fix (#193)
* Fix issues with bdcats_batch * Committing clang-format changes --------- Co-authored-by: github-actions <github-actions[bot]@users.noreply.github.com>
1 parent 5a6e943 commit 90567f1

File tree

3 files changed

+108
-43
lines changed

3 files changed

+108
-43
lines changed

examples/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ CFLAGS = -O2 -Wall -Wextra
44
INCLUDES = -I. -I$(PDC_DIR)/include
55
LDFLAGS = -Wl,-rpath,$(PDC_DIR)/lib -L$(PDC_DIR)/lib
66

7-
LIBS = -lpdc
7+
LIBS = -lpdc -lpdc_commons
88

99
.c.o:
1010
$(CC) $(CFLAGS) $(INCLUDES) -c $<

examples/bdcats.c

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,43 +101,75 @@ main(int argc, char **argv)
101101
if (cont_id == 0)
102102
printf("Fail to create container @ line %d!\n", __LINE__);
103103

104-
// open objects
105-
obj_xx = PDCobj_open("obj-var-xx", pdc_id);
104+
// open objects
105+
#ifdef ENABLE_MPI
106+
obj_xx = PDCobj_open_col("obj-var-xx", pdc_id);
107+
#else
108+
obj_xx = PDCobj_open("obj-var-xx", pdc_id);
109+
#endif
106110
if (obj_xx == 0) {
107111
printf("Error when open object %s\n", "obj-var-xx");
108112
exit(-1);
109113
}
110-
obj_yy = PDCobj_open("obj-var-yy", pdc_id);
114+
#ifdef ENABLE_MPI
115+
obj_yy = PDCobj_open_col("obj-var-yy", pdc_id);
116+
#else
117+
obj_yy = PDCobj_open("obj-var-xx", pdc_id);
118+
#endif
111119
if (obj_yy == 0) {
112120
printf("Error when open object %s\n", "obj-var-yy");
113121
exit(-1);
114122
}
115-
obj_zz = PDCobj_open("obj-var-zz", pdc_id);
123+
#ifdef ENABLE_MPI
124+
obj_zz = PDCobj_open_col("obj-var-zz", pdc_id);
125+
#else
126+
obj_zz = PDCobj_open("obj-var-xx", pdc_id);
127+
#endif
116128
if (obj_zz == 0) {
117129
printf("Error when open object %s\n", "obj-var-zz");
118130
exit(-1);
119131
}
120-
obj_pxx = PDCobj_open("obj-var-pxx", pdc_id);
132+
#ifdef ENABLE_MPI
133+
obj_pxx = PDCobj_open_col("obj-var-pxx", pdc_id);
134+
#else
135+
obj_pxx = PDCobj_open("obj-var-xx", pdc_id);
136+
#endif
121137
if (obj_pxx == 0) {
122138
printf("Error when open object %s\n", "obj-var-pxx");
123139
exit(-1);
124140
}
125-
obj_pyy = PDCobj_open("obj-var-pyy", pdc_id);
141+
#ifdef ENABLE_MPI
142+
obj_pyy = PDCobj_open_col("obj-var-pyy", pdc_id);
143+
#else
144+
obj_pyy = PDCobj_open("obj-var-xx", pdc_id);
145+
#endif
126146
if (obj_pyy == 0) {
127147
printf("Error when open object %s\n", "obj-var-pyy");
128148
exit(-1);
129149
}
130-
obj_pzz = PDCobj_open("obj-var-pzz", pdc_id);
150+
#ifdef ENABLE_MPI
151+
obj_pzz = PDCobj_open_col("obj-var-pzz", pdc_id);
152+
#else
153+
obj_pzz = PDCobj_open("obj-var-xx", pdc_id);
154+
#endif
131155
if (obj_pzz == 0) {
132156
printf("Error when open object %s\n", "obj-var-pzz");
133157
exit(-1);
134158
}
135-
obj_id11 = PDCobj_open("id11", pdc_id);
159+
#ifdef ENABLE_MPI
160+
obj_id11 = PDCobj_open_col("id11", pdc_id);
161+
#else
162+
obj_id11 = PDCobj_open("obj-var-xx", pdc_id);
163+
#endif
136164
if (obj_id11 == 0) {
137165
printf("Error when open object %s\n", "id11");
138166
exit(-1);
139167
}
140-
obj_id22 = PDCobj_open("id22", pdc_id);
168+
#ifdef ENABLE_MPI
169+
obj_id22 = PDCobj_open_col("id22", pdc_id);
170+
#else
171+
obj_id22 = PDCobj_open("obj-var-xx", pdc_id);
172+
#endif
141173
if (obj_id22 == 0) {
142174
printf("Error when open object %s\n", "id22");
143175
exit(-1);

examples/bdcats_batch.c

Lines changed: 66 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ uniform_random_number()
4545
void
4646
print_usage()
4747
{
48-
printf("Usage: srun -n ./vpicio sleep_time timestamps #particles\n");
48+
printf("Usage: srun -n bdcats_batch sleep_time timestep #particles test_method(0:old API, 1:wait, "
49+
"default 2:wait all)\n");
4950
}
5051

5152
int
@@ -81,7 +82,7 @@ main(int argc, char **argv)
8182
*transfer_request_py, *transfer_request_pz, *transfer_request_id1, *transfer_request_id2, *ptr,
8283
*temp_requests;
8384

84-
uint64_t timestamps = 10;
85+
uint64_t timestep = 10;
8586

8687
double start, end, transfer_start = .0, transfer_wait = .0, transfer_create = .0, transfer_close = .0,
8788
max_time, min_time, avg_time, total_time, start_total_time;
@@ -99,7 +100,7 @@ main(int argc, char **argv)
99100
sleep_time = (unsigned)atoi(argv[1]);
100101
}
101102
if (argc >= 3) {
102-
timestamps = atoll(argv[2]);
103+
timestep = atoll(argv[2]);
103104
}
104105
if (argc >= 4) {
105106
numparticles = atoll(argv[3]);
@@ -110,8 +111,8 @@ main(int argc, char **argv)
110111
test_method = atoi(argv[4]);
111112
}
112113
if (!rank) {
113-
printf("sleep time = %u, timestamps = %" PRIu64 ", numparticles = %" PRIu64 ", test_method = %d\n",
114-
sleep_time, timestamps, numparticles, test_method);
114+
printf("sleep time = %u, timestep = %" PRIu64 ", numparticles = %" PRIu64 ", test_method = %d\n",
115+
sleep_time, timestep, numparticles, test_method);
115116
}
116117

117118
x = (float *)malloc(numparticles * sizeof(float));
@@ -128,14 +129,14 @@ main(int argc, char **argv)
128129
// create a pdc
129130
pdc_id = PDCinit("pdc");
130131

131-
obj_xx = (pdcid_t *)malloc(sizeof(pdcid_t) * timestamps);
132-
obj_yy = (pdcid_t *)malloc(sizeof(pdcid_t) * timestamps);
133-
obj_zz = (pdcid_t *)malloc(sizeof(pdcid_t) * timestamps);
134-
obj_pxx = (pdcid_t *)malloc(sizeof(pdcid_t) * timestamps);
135-
obj_pyy = (pdcid_t *)malloc(sizeof(pdcid_t) * timestamps);
136-
obj_pzz = (pdcid_t *)malloc(sizeof(pdcid_t) * timestamps);
137-
obj_id11 = (pdcid_t *)malloc(sizeof(pdcid_t) * timestamps);
138-
obj_id22 = (pdcid_t *)malloc(sizeof(pdcid_t) * timestamps);
132+
obj_xx = (pdcid_t *)malloc(sizeof(pdcid_t) * timestep);
133+
obj_yy = (pdcid_t *)malloc(sizeof(pdcid_t) * timestep);
134+
obj_zz = (pdcid_t *)malloc(sizeof(pdcid_t) * timestep);
135+
obj_pxx = (pdcid_t *)malloc(sizeof(pdcid_t) * timestep);
136+
obj_pyy = (pdcid_t *)malloc(sizeof(pdcid_t) * timestep);
137+
obj_pzz = (pdcid_t *)malloc(sizeof(pdcid_t) * timestep);
138+
obj_id11 = (pdcid_t *)malloc(sizeof(pdcid_t) * timestep);
139+
obj_id22 = (pdcid_t *)malloc(sizeof(pdcid_t) * timestep);
139140

140141
offset = (uint64_t *)malloc(sizeof(uint64_t) * ndim);
141142
offset_remote = (uint64_t *)malloc(sizeof(uint64_t) * ndim);
@@ -153,69 +154,101 @@ main(int argc, char **argv)
153154
region_id1 = PDCregion_create(ndim, offset, mysize);
154155
region_id2 = PDCregion_create(ndim, offset, mysize);
155156

156-
transfer_request_x = (pdcid_t *)malloc(sizeof(pdcid_t) * (timestamps + 1) * N_OBJS);
157-
ptr = transfer_request_x + timestamps;
157+
transfer_request_x = (pdcid_t *)malloc(sizeof(pdcid_t) * (timestep + 1) * N_OBJS);
158+
ptr = transfer_request_x + timestep;
158159
transfer_request_y = ptr;
159-
ptr += timestamps;
160+
ptr += timestep;
160161
transfer_request_z = ptr;
161-
ptr += timestamps;
162+
ptr += timestep;
162163
transfer_request_px = ptr;
163-
ptr += timestamps;
164+
ptr += timestep;
164165
transfer_request_py = ptr;
165-
ptr += timestamps;
166+
ptr += timestep;
166167
transfer_request_pz = ptr;
167-
ptr += timestamps;
168+
ptr += timestep;
168169
transfer_request_id1 = ptr;
169-
ptr += timestamps;
170+
ptr += timestep;
170171
transfer_request_id2 = ptr;
171-
ptr += timestamps;
172+
ptr += timestep;
172173
temp_requests = ptr;
173174

174-
for (i = 0; i < timestamps; ++i) {
175+
for (i = 0; i < timestep; ++i) {
175176
sprintf(obj_name, "obj-var-xx %" PRIu64 "", i);
177+
#ifdef ENABLE_MPI
176178
obj_xx[i] = PDCobj_open_col(obj_name, pdc_id);
179+
#else
180+
obj_xx[i] = PDCobj_open(obj_name, pdc_id);
181+
#endif
177182
if (obj_xx[i] == 0) {
178183
printf("Error getting an object id of %s from server, exit...\n", "obj-var-xx");
179184
exit(-1);
180185
}
181186
sprintf(obj_name, "obj-var-yy %" PRIu64 "", i);
187+
#ifdef ENABLE_MPI
182188
obj_yy[i] = PDCobj_open_col(obj_name, pdc_id);
189+
#else
190+
obj_yy[i] = PDCobj_open(obj_name, pdc_id);
191+
#endif
183192
if (obj_yy[i] == 0) {
184193
printf("Error getting an object id of %s from server, exit...\n", "obj-var-yy");
185194
exit(-1);
186195
}
187196
sprintf(obj_name, "obj-var-zz %" PRIu64 "", i);
197+
#ifdef ENABLE_MPI
188198
obj_zz[i] = PDCobj_open_col(obj_name, pdc_id);
199+
#else
200+
obj_zz[i] = PDCobj_open(obj_name, pdc_id);
201+
#endif
189202
if (obj_zz[i] == 0) {
190203
printf("Error getting an object id of %s from server, exit...\n", "obj-var-zz");
191204
exit(-1);
192205
}
193206
sprintf(obj_name, "obj-var-pxx %" PRIu64 "", i);
207+
#ifdef ENABLE_MPI
194208
obj_pxx[i] = PDCobj_open_col(obj_name, pdc_id);
209+
#else
210+
obj_pxx[i] = PDCobj_open(obj_name, pdc_id);
211+
#endif
195212
if (obj_pxx[i] == 0) {
196213
printf("Error getting an object id of %s from server, exit...\n", "obj-var-pxx");
197214
exit(-1);
198215
}
199216
sprintf(obj_name, "obj-var-pyy %" PRIu64 "", i);
217+
#ifdef ENABLE_MPI
200218
obj_pyy[i] = PDCobj_open_col(obj_name, pdc_id);
219+
#else
220+
obj_pyy[i] = PDCobj_open(obj_name, pdc_id);
221+
#endif
201222
if (obj_pyy[i] == 0) {
202223
printf("Error getting an object id of %s from server, exit...\n", "obj-var-pyy");
203224
exit(-1);
204225
}
205226
sprintf(obj_name, "obj-var-pzz %" PRIu64 "", i);
227+
#ifdef ENABLE_MPI
206228
obj_pzz[i] = PDCobj_open_col(obj_name, pdc_id);
229+
#else
230+
obj_pzz[i] = PDCobj_open(obj_name, pdc_id);
231+
#endif
207232
if (obj_pzz[i] == 0) {
208233
printf("Error getting an object id of %s from server, exit...\n", "obj-var-pzz");
209234
exit(-1);
210235
}
211236
sprintf(obj_name, "id11 %" PRIu64 "", i);
237+
#ifdef ENABLE_MPI
212238
obj_id11[i] = PDCobj_open_col(obj_name, pdc_id);
239+
#else
240+
obj_id11[i] = PDCobj_open(obj_name, pdc_id);
241+
#endif
213242
if (obj_id11[i] == 0) {
214243
printf("Error getting an object id of %s from server, exit...\n", "obj_id11");
215244
exit(-1);
216245
}
217246
sprintf(obj_name, "id22 %" PRIu64 "", i);
247+
#ifdef ENABLE_MPI
218248
obj_id22[i] = PDCobj_open_col(obj_name, pdc_id);
249+
#else
250+
obj_id22[i] = PDCobj_open(obj_name, pdc_id);
251+
#endif
219252
if (obj_id22[i] == 0) {
220253
printf("Error getting an object id of %s from server, exit...\n", "obj_id22");
221254
exit(-1);
@@ -227,7 +260,7 @@ main(int argc, char **argv)
227260
start_total_time = MPI_Wtime();
228261
#endif
229262

230-
for (i = 0; i < timestamps; ++i) {
263+
for (i = 0; i < timestep; ++i) {
231264

232265
offset_remote[0] = rank * numparticles;
233266
region_xx = PDCregion_create(ndim, offset_remote, mysize);
@@ -244,49 +277,49 @@ main(int argc, char **argv)
244277
#endif
245278
if (test_method) {
246279
transfer_request_x[i] =
247-
PDCregion_transfer_create(&x[0], PDC_WRITE, obj_xx[i], region_x, region_xx);
280+
PDCregion_transfer_create(&x[0], PDC_READ, obj_xx[i], region_x, region_xx);
248281
if (transfer_request_x[i] == 0) {
249282
printf("Array x transfer request creation failed\n");
250283
return 1;
251284
}
252285
transfer_request_y[i] =
253-
PDCregion_transfer_create(&y[0], PDC_WRITE, obj_yy[i], region_y, region_yy);
286+
PDCregion_transfer_create(&y[0], PDC_READ, obj_yy[i], region_y, region_yy);
254287
if (transfer_request_y[i] == 0) {
255288
printf("Array y transfer request creation failed\n");
256289
return 1;
257290
}
258291
transfer_request_z[i] =
259-
PDCregion_transfer_create(&z[0], PDC_WRITE, obj_zz[i], region_z, region_zz);
292+
PDCregion_transfer_create(&z[0], PDC_READ, obj_zz[i], region_z, region_zz);
260293
if (transfer_request_z[i] == 0) {
261294
printf("Array z transfer request creation failed\n");
262295
return 1;
263296
}
264297
transfer_request_px[i] =
265-
PDCregion_transfer_create(&px[0], PDC_WRITE, obj_pxx[i], region_px, region_pxx);
298+
PDCregion_transfer_create(&px[0], PDC_READ, obj_pxx[i], region_px, region_pxx);
266299
if (transfer_request_px[i] == 0) {
267300
printf("Array px transfer request creation failed\n");
268301
return 1;
269302
}
270303
transfer_request_py[i] =
271-
PDCregion_transfer_create(&py[0], PDC_WRITE, obj_pyy[i], region_py, region_pyy);
304+
PDCregion_transfer_create(&py[0], PDC_READ, obj_pyy[i], region_py, region_pyy);
272305
if (transfer_request_py[i] == 0) {
273306
printf("Array py transfer request creation failed\n");
274307
return 1;
275308
}
276309
transfer_request_pz[i] =
277-
PDCregion_transfer_create(&pz[0], PDC_WRITE, obj_pzz[i], region_pz, region_pzz);
310+
PDCregion_transfer_create(&pz[0], PDC_READ, obj_pzz[i], region_pz, region_pzz);
278311
if (transfer_request_pz[i] == 0) {
279312
printf("Array pz transfer request creation failed\n");
280313
return 1;
281314
}
282315
transfer_request_id1[i] =
283-
PDCregion_transfer_create(&id1[0], PDC_WRITE, obj_id11[i], region_id1, region_id11);
316+
PDCregion_transfer_create(&id1[0], PDC_READ, obj_id11[i], region_id1, region_id11);
284317
if (transfer_request_id1[i] == 0) {
285318
printf("Array id1 transfer request creation failed\n");
286319
return 1;
287320
}
288321
transfer_request_id2[i] =
289-
PDCregion_transfer_create(&id2[0], PDC_WRITE, obj_id22[i], region_id2, region_id22);
322+
PDCregion_transfer_create(&id2[0], PDC_READ, obj_id22[i], region_id2, region_id22);
290323
if (transfer_request_id2[i] == 0) {
291324
printf("Array id2 transfer request creation failed\n");
292325
return 1;
@@ -549,7 +582,7 @@ main(int argc, char **argv)
549582
MPI_Barrier(MPI_COMM_WORLD);
550583
#endif
551584

552-
for (i = 0; i < timestamps; ++i) {
585+
for (i = 0; i < timestep; ++i) {
553586
if (PDCobj_close(obj_xx[i]) < 0) {
554587
printf("fail to close obj_xx\n");
555588
return 1;

0 commit comments

Comments
 (0)