Skip to content

Commit 1b605bd

Browse files
committed
Adjust the datatype tests to new API
Signed-off-by: Joseph Schuchart <[email protected]>
1 parent cfa8186 commit 1b605bd

File tree

6 files changed

+48
-29
lines changed

6 files changed

+48
-29
lines changed

ompi/datatype/ompi_datatype_args.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,8 @@ static inline int __ompi_datatype_pack_description( ompi_datatype_t* datatype,
450450
ompi_datatype_args_t* args = (ompi_datatype_args_t*)datatype->args;
451451
char* next_packed = (char*)*packed_buffer;
452452

453+
iposition = (int*)next_packed;
454+
453455
if( ompi_datatype_is_predefined(datatype) ) {
454456
iposition[0] = MPI_COMBINER_NAMED;
455457
iposition[1] = datatype->id; /* On the OMPI - layer, copy the ompi_datatype.id */
@@ -482,6 +484,7 @@ static inline int __ompi_datatype_pack_description( ompi_datatype_t* datatype,
482484
memcpy( next_packed, args->l, sizeof(size_t) * args->cl );
483485
next_packed += sizeof(size_t) * args->cl;
484486
}
487+
/* advance int pointer */
485488
iposition = (int*)next_packed;
486489

487490
/* skip the datatypes */

test/datatype/ddt_lib.c

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ ompi_datatype_t *upper_matrix(unsigned int mat_size)
134134
blocklen[i] = mat_size - i;
135135
}
136136

137-
ompi_datatype_create_indexed(mat_size, blocklen, disp, &ompi_mpi_double.dt, &upper);
137+
ompi_datatype_create_indexed(mat_size, OMPI_COUNT_ARRAY_CREATE(blocklen),
138+
OMPI_DISP_ARRAY_CREATE(disp), &ompi_mpi_double.dt, &upper);
138139
ompi_datatype_commit(&upper);
139140
if (outputFlags & DUMP_DATA_AFTER_COMMIT) {
140141
ompi_datatype_dump(upper);
@@ -158,7 +159,8 @@ ompi_datatype_t *lower_matrix(unsigned int mat_size)
158159
blocklen[i] = i;
159160
}
160161

161-
ompi_datatype_create_indexed(mat_size, blocklen, disp, &ompi_mpi_double.dt, &upper);
162+
ompi_datatype_create_indexed(mat_size, OMPI_COUNT_ARRAY_CREATE(blocklen),
163+
OMPI_DISP_ARRAY_CREATE(disp), &ompi_mpi_double.dt, &upper);
162164
free(disp);
163165
free(blocklen);
164166
return upper;
@@ -175,7 +177,8 @@ ompi_datatype_t *test_matrix_borders(unsigned int size, unsigned int width)
175177
disp[1] = (size - width) * sizeof(double);
176178
blocklen[1] = width;
177179

178-
ompi_datatype_create_indexed(2, blocklen, disp, &ompi_mpi_double.dt, &pdt_line);
180+
ompi_datatype_create_indexed(2, OMPI_COUNT_ARRAY_CREATE(blocklen),
181+
OMPI_DISP_ARRAY_CREATE(disp), &ompi_mpi_double.dt, &pdt_line);
179182
ompi_datatype_create_contiguous(size, pdt_line, &pdt);
180183
OBJ_RELEASE(pdt_line); /*assert( pdt_line == NULL );*/
181184
return pdt;
@@ -224,7 +227,8 @@ ompi_datatype_t *test_struct_char_double(void)
224227
displ[0] = (char *) &(data.c) - (char *) &(data);
225228
displ[1] = (char *) &(data.d) - (char *) &(data);
226229

227-
ompi_datatype_create_struct(2, lengths, displ, types, &pdt);
230+
ompi_datatype_create_struct(2, OMPI_COUNT_ARRAY_CREATE(lengths),
231+
OMPI_DISP_ARRAY_CREATE(displ), types, &pdt);
228232
ompi_datatype_commit(&pdt);
229233
if (outputFlags & DUMP_DATA_AFTER_COMMIT) {
230234
ompi_datatype_dump(pdt);
@@ -276,7 +280,8 @@ ompi_datatype_t *test_create_blacs_type(void)
276280
{
277281
ompi_datatype_t *pdt;
278282

279-
ompi_datatype_create_indexed(18, blacs_length, blacs_indices, &ompi_mpi_int.dt, &pdt);
283+
ompi_datatype_create_indexed(18, OMPI_COUNT_ARRAY_CREATE(blacs_length),
284+
OMPI_DISP_ARRAY_CREATE(blacs_indices), &ompi_mpi_int.dt, &pdt);
280285
ompi_datatype_commit(&pdt);
281286
if (outputFlags & DUMP_DATA_AFTER_COMMIT) {
282287
ompi_datatype_dump(pdt);
@@ -327,7 +332,8 @@ ompi_datatype_t *test_struct(void)
327332

328333
types[1] = pdt1;
329334

330-
ompi_datatype_create_struct(3, lengths, disp, types, &pdt);
335+
ompi_datatype_create_struct(3, OMPI_COUNT_ARRAY_CREATE(lengths),
336+
OMPI_DISP_ARRAY_CREATE(disp), types, &pdt);
331337
OBJ_RELEASE(pdt1); /*assert( pdt1 == NULL );*/
332338
if (outputFlags & DUMP_DATA_AFTER_COMMIT) {
333339
ompi_datatype_dump(pdt);
@@ -356,7 +362,8 @@ ompi_datatype_t *create_struct_constant_gap_resized_ddt(ompi_datatype_t *type)
356362
disps[1] -= disps[2]; /* 8 */
357363
disps[0] -= disps[2]; /* 16 */
358364

359-
ompi_datatype_create_struct(2, blocklens, disps, types, &temp_type);
365+
ompi_datatype_create_struct(2, OMPI_COUNT_ARRAY_CREATE(blocklens),
366+
OMPI_DISP_ARRAY_CREATE(disps), types, &temp_type);
360367
ompi_datatype_create_resized(temp_type, 0, sizeof(data[0]), &struct_type);
361368
ompi_datatype_commit(&struct_type);
362369
OBJ_RELEASE(temp_type);
@@ -394,7 +401,7 @@ ompi_datatype_t *create_strange_dt(void)
394401

395402
dispi[0] = (int) ((char *) &(v[0].i1) - (char *) &(v[0])); /* 0 */
396403
dispi[1] = (int) (((char *) (&(v[0].i2)) - (char *) &(v[0])) / sizeof(int)); /* 2 */
397-
ompi_datatype_create_indexed_block(2, 1, dispi, &ompi_mpi_int.dt, &pdtTemp);
404+
ompi_datatype_create_indexed_block(2, 1, OMPI_DISP_ARRAY_CREATE(dispi), &ompi_mpi_int.dt, &pdtTemp);
398405
#ifdef USE_RESIZED
399406
/* optional */
400407
displ[0] = 0;
@@ -411,7 +418,8 @@ ompi_datatype_t *create_strange_dt(void)
411418
displ[0] = 0;
412419
displ[1] = (long) ((char *) &(t[0].v[0]) - (char *) &(t[0]));
413420
displ[2] = (long) ((char *) &(t[0].last) - (char *) &(t[0]));
414-
ompi_datatype_create_struct(3, pBlock, displ, types, &pdtTemp);
421+
ompi_datatype_create_struct(3, OMPI_COUNT_ARRAY_CREATE(pBlock),
422+
OMPI_DISP_ARRAY_CREATE(displ), types, &pdtTemp);
415423
#ifdef USE_RESIZED
416424
/* optional */
417425
displ[1] = (char *) &(t[1]) - (char *) &(t[0]);

test/datatype/ddt_pack.c

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,14 @@ int main(int argc, char *argv[])
118118
types[1] = &ompi_mpi_int.dt;
119119
types[2] = &ompi_mpi_int.dt;
120120
types[3] = &ompi_mpi_int.dt;
121-
ret = ompi_datatype_create_struct(4, blen, disp, types, &struct_type);
121+
ret = ompi_datatype_create_struct(4, OMPI_COUNT_ARRAY_CREATE(blen), OMPI_DISP_ARRAY_CREATE(disp), types, &struct_type);
122122
if (ret != 0)
123123
goto cleanup;
124124

125125
{
126126
int count = 4;
127-
const int *a_i[2] = {&count, blen};
128-
ret = ompi_datatype_set_args(struct_type, count + 1, a_i, count, disp, count, types,
127+
const ompi_count_array_t a_i[2] = {OMPI_COUNT_ARRAY_CREATE(&count), OMPI_COUNT_ARRAY_CREATE(blen)};
128+
ret = ompi_datatype_set_args(struct_type, count + 1, 0, a_i, count, OMPI_DISP_ARRAY_CREATE(disp), count, types,
129129
MPI_COMBINER_STRUCT);
130130
if (ret != 0)
131131
goto cleanup;
@@ -190,9 +190,11 @@ int main(int argc, char *argv[])
190190
int count = 2;
191191
int blocklength = 1;
192192
int stride = 1;
193-
const int *a_i[3] = {&count, &blocklength, &stride};
193+
const ompi_count_array_t a_i[3] = {OMPI_COUNT_ARRAY_CREATE(&count),
194+
OMPI_COUNT_ARRAY_CREATE(&blocklength),
195+
OMPI_COUNT_ARRAY_CREATE(&stride)};
194196
ompi_datatype_t *type = &ompi_mpi_int.dt;
195-
ret = ompi_datatype_set_args(vec_type, 3, a_i, 0, NULL, 1, &type, MPI_COMBINER_VECTOR);
197+
ret = ompi_datatype_set_args(vec_type, 3, 0, a_i, 0, OMPI_DISP_ARRAY_NULL, 1, &type, MPI_COMBINER_VECTOR);
196198
if (ret != 0)
197199
goto cleanup;
198200
}
@@ -251,16 +253,18 @@ int main(int argc, char *argv[])
251253
blen[0] = 0;
252254
blen[1] = 20 * sizeof(double);
253255

254-
ret = ompi_datatype_create_indexed_block(2, 10, blen, &ompi_mpi_double.dt, &newType);
256+
ret = ompi_datatype_create_indexed_block(2, 10, OMPI_COUNT_ARRAY_CREATE(blen), &ompi_mpi_double.dt, &newType);
255257
if (ret != 0)
256258
goto cleanup;
257259

258260
{
259261
int count = 2;
260262
int blocklength = 10;
261-
const int *a_i[3] = {&count, &blocklength, blen};
263+
const ompi_count_array_t a_i[3] = {OMPI_COUNT_ARRAY_CREATE(&count),
264+
OMPI_COUNT_ARRAY_CREATE(&blocklength),
265+
OMPI_COUNT_ARRAY_CREATE(blen)};
262266
ompi_datatype_t *oldtype = &ompi_mpi_double.dt;
263-
ompi_datatype_set_args(newType, 2 + count, a_i, 0, NULL, 1, &oldtype,
267+
ompi_datatype_set_args(newType, 2 + count, 0, a_i, 0, OMPI_DISP_ARRAY_NULL, 1, &oldtype,
264268
MPI_COMBINER_INDEXED_BLOCK);
265269
if (ret != 0)
266270
goto cleanup;
@@ -322,15 +326,16 @@ int main(int argc, char *argv[])
322326
disp[0] = 0;
323327
disp[1] = 20 * sizeof(double);
324328

325-
ret = ompi_datatype_create_hindexed(2, blen, disp, &ompi_mpi_double.dt, &newType);
329+
ret = ompi_datatype_create_hindexed(2, OMPI_COUNT_ARRAY_CREATE(blen),
330+
OMPI_DISP_ARRAY_CREATE(disp), &ompi_mpi_double.dt, &newType);
326331
if (ret != 0)
327332
goto cleanup;
328333

329334
{
330335
int count = 2;
331-
const int *a_i[2] = {&count, blen};
336+
const ompi_count_array_t a_i[2] = {OMPI_COUNT_ARRAY_CREATE(&count), OMPI_COUNT_ARRAY_CREATE(blen)};
332337
ompi_datatype_t *oldtype = &ompi_mpi_double.dt;
333-
ret = ompi_datatype_set_args(newType, count + 1, a_i, count, disp, 1, &oldtype,
338+
ret = ompi_datatype_set_args(newType, count + 1, 0, a_i, count, OMPI_DISP_ARRAY_CREATE(disp), 1, &oldtype,
334339
MPI_COMBINER_HINDEXED);
335340
if (ret != 0)
336341
goto cleanup;
@@ -388,14 +393,14 @@ int main(int argc, char *argv[])
388393
disp[1] = 64;
389394
types[0] = &ompi_mpi_int.dt;
390395
types[1] = newType;
391-
ret = ompi_datatype_create_struct(2, blen, disp, types, &struct_type);
396+
ret = ompi_datatype_create_struct(2, OMPI_COUNT_ARRAY_CREATE(blen), OMPI_DISP_ARRAY_CREATE(disp), types, &struct_type);
392397
if (ret != 0)
393398
goto cleanup;
394399

395400
{
396401
int count = 2;
397-
const int *a_i[2] = {&count, blen};
398-
ret = ompi_datatype_set_args(struct_type, count + 1, a_i, count, disp, count, types,
402+
const ompi_count_array_t a_i[2] = {OMPI_COUNT_ARRAY_CREATE(&count), OMPI_COUNT_ARRAY_CREATE(blen)};
403+
ret = ompi_datatype_set_args(struct_type, count + 1, 0, a_i, count, OMPI_DISP_ARRAY_CREATE(disp), count, types,
399404
MPI_COMBINER_STRUCT);
400405
if (ret != 0)
401406
goto cleanup;
@@ -461,7 +466,7 @@ int main(int argc, char *argv[])
461466
if (ret != 0)
462467
goto cleanup;
463468
ompi_datatype_t *type = &ompi_mpi_int.dt;
464-
ret = ompi_datatype_set_args(dup_type, 0, NULL, 0, NULL, 1, &type, MPI_COMBINER_DUP);
469+
ret = ompi_datatype_set_args(dup_type, 0, 0, NULL, 0, OMPI_DISP_ARRAY_NULL, 1, &type, MPI_COMBINER_DUP);
465470
if (ret != 0)
466471
goto cleanup;
467472
packed_ddt_len = ompi_datatype_pack_description_length(dup_type);

test/datatype/external32.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,12 @@ int main(int argc, char *argv[])
230230

231231
ompi_datatype_create_vector(count, blocklength, stride, &ompi_mpi_int.dt, &ddt);
232232
{
233-
const int *a_i[3] = {&count, &blocklength, &stride};
233+
const ompi_count_array_t a_i[3] = {OMPI_COUNT_ARRAY_CREATE(&count),
234+
OMPI_COUNT_ARRAY_CREATE(&blocklength),
235+
OMPI_COUNT_ARRAY_CREATE(&stride)};
234236
ompi_datatype_t *type = &ompi_mpi_int.dt;
235237

236-
ompi_datatype_set_args(ddt, 3, a_i, 0, NULL, 1, &type, MPI_COMBINER_VECTOR);
238+
ompi_datatype_set_args(ddt, 3, 0, a_i, 0, OMPI_DISP_ARRAY_NULL, 1, &type, MPI_COMBINER_VECTOR);
237239
}
238240
ompi_datatype_commit(&ddt);
239241

test/datatype/large_data.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ int main(int argc, char *argv[])
105105
/*
106106
* Large sparse datatype: indexed contiguous
107107
*/
108-
ompi_datatype_create_indexed(2, scounts, sdispls, ddt, &stype);
108+
ompi_datatype_create_indexed(2, OMPI_COUNT_ARRAY_CREATE(scounts), OMPI_DISP_ARRAY_CREATE(sdispls), ddt, &stype);
109109
ompi_datatype_commit(&stype);
110110

111111
packed = count_length_via_convertor_raw("1. INDEX", stype, 1);
@@ -121,7 +121,7 @@ int main(int argc, char *argv[])
121121
/*
122122
* Large contiguous datatype: indexed contiguous
123123
*/
124-
ompi_datatype_create_indexed(2, rcounts, rdispls, ddt, &rtype);
124+
ompi_datatype_create_indexed(2, OMPI_COUNT_ARRAY_CREATE(rcounts), OMPI_DISP_ARRAY_CREATE(rdispls), ddt, &rtype);
125125
ompi_datatype_commit(&rtype);
126126

127127
packed = count_length_via_convertor_raw("2. INDEX", rtype, 1);

test/datatype/unpack_ooo.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,8 @@ static int unpack_ooo(void)
264264
len[0] = 1;
265265
len[1] = 1;
266266

267-
rc = ompi_datatype_create_struct(2, len, disp, type, &newtype);
267+
rc = ompi_datatype_create_struct(2, OMPI_COUNT_ARRAY_CREATE(len),
268+
OMPI_DISP_ARRAY_CREATE(disp), type, &newtype);
268269
if (OMPI_SUCCESS != rc) {
269270
fprintf(stderr, "could not create struct\n");
270271
return 1;

0 commit comments

Comments
 (0)