Skip to content

Commit 1d9186c

Browse files
committed
Use HAVE_MPI_LARGE_COUNT to check availability of large-count MPI APIs
This should avoid issue of using large-count APIs to create MPI datatypes which is later used in non-large-count APIs.
1 parent 0e4cc93 commit 1d9186c

2 files changed

Lines changed: 15 additions & 15 deletions

File tree

src/drivers/common/dtype_decode.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ dtype_filter(MPI_Datatype type)
225225
static MPI_Offset
226226
darray_get_totalblks(int rank,
227227
int ndims,
228-
#ifdef HAVE_MPI_TYPE_GET_CONTENTS_C
228+
#ifdef HAVE_MPI_LARGE_COUNT
229229
MPI_Count array_of_gsizes[],
230230
#else
231231
int array_of_gsizes[],
@@ -324,7 +324,7 @@ int ncmpii_dtype_decode(MPI_Datatype dtype,
324324
}
325325

326326
is_large_type = 0;
327-
#ifdef HAVE_MPI_TYPE_GET_ENVELOPE_C
327+
#ifdef HAVE_MPI_LARGE_COUNT
328328
/* MPI_Type_get_envelope_c is introduced in MPI 4.0 */
329329
mpireturn = MPI_Type_get_envelope_c(dtype, &num_ints, &num_adds, &num_larges, &num_dtypes, &combiner);
330330
if (mpireturn != MPI_SUCCESS)
@@ -366,7 +366,7 @@ int ncmpii_dtype_decode(MPI_Datatype dtype,
366366
array_of_dtypes = (MPI_Datatype *) NCI_Malloc((size_t)num_dtypes * sizeof(MPI_Datatype));
367367

368368
if (is_large_type) {
369-
#ifdef HAVE_MPI_TYPE_GET_CONTENTS_C
369+
#ifdef HAVE_MPI_LARGE_COUNT
370370
array_of_larges = (MPI_Count *) NCI_Malloc(sizeof(MPI_Count) * num_larges);
371371
mpireturn = MPI_Type_get_contents_c(dtype, num_ints, num_adds, num_larges, num_dtypes,
372372
array_of_ints, array_of_adds, array_of_larges, array_of_dtypes);
@@ -414,7 +414,7 @@ int ncmpii_dtype_decode(MPI_Datatype dtype,
414414
case MPI_COMBINER_STRUCT_INTEGER:
415415
#endif
416416
if (is_large_type)
417-
#ifdef HAVE_MPI_TYPE_GET_CONTENTS_C
417+
#ifdef HAVE_MPI_LARGE_COUNT
418418
count = array_of_larges[0];
419419
#else
420420
return ncmpii_error_mpi2nc(MPI_ERR_IO, "MPI_COMBINER_STRUCT");
@@ -431,7 +431,7 @@ int ncmpii_dtype_decode(MPI_Datatype dtype,
431431
if (status != NC_NOERR) return status;
432432
if (isderived) MPI_Type_free(array_of_dtypes+i);
433433
if (is_large_type) {
434-
#ifdef HAVE_MPI_TYPE_GET_CONTENTS_C
434+
#ifdef HAVE_MPI_LARGE_COUNT
435435
/* product of array_of_blocklengths[] */
436436
if (el_size > 0) nelems *= array_of_larges[1+i];
437437
#else
@@ -457,13 +457,13 @@ int ncmpii_dtype_decode(MPI_Datatype dtype,
457457
NCI_Free(array_of_ints);
458458
NCI_Free(array_of_adds);
459459
NCI_Free(array_of_dtypes);
460-
#ifdef HAVE_MPI_TYPE_GET_CONTENTS_C
460+
#ifdef HAVE_MPI_LARGE_COUNT
461461
if (is_large_type) NCI_Free(array_of_larges);
462462
#endif
463463
DEBUG_RETURN_ERROR(NC_EMULTITYPES)
464464
}
465465
if (is_large_type)
466-
#ifdef HAVE_MPI_TYPE_GET_CONTENTS_C
466+
#ifdef HAVE_MPI_LARGE_COUNT
467467
/* product of array_of_blocklengths[] */
468468
nelems += tmpnelems * array_of_larges[1+i];
469469
#else
@@ -484,7 +484,7 @@ int ncmpii_dtype_decode(MPI_Datatype dtype,
484484
/* single etype */
485485
case MPI_COMBINER_CONTIGUOUS:
486486
if (is_large_type)
487-
#ifdef HAVE_MPI_TYPE_GET_CONTENTS_C
487+
#ifdef HAVE_MPI_LARGE_COUNT
488488
total_blocks = array_of_larges[0];
489489
#else
490490
return ncmpii_error_mpi2nc(MPI_ERR_IO, "MPI_COMBINER_CONTIGUOUS");
@@ -500,7 +500,7 @@ int ncmpii_dtype_decode(MPI_Datatype dtype,
500500
case MPI_COMBINER_INDEXED_BLOCK:
501501
if (iscontig_of_ptypes) *iscontig_of_ptypes = 0;
502502
if (is_large_type)
503-
#ifdef HAVE_MPI_TYPE_GET_CONTENTS_C
503+
#ifdef HAVE_MPI_LARGE_COUNT
504504
/* count x blocklength */
505505
total_blocks = array_of_larges[0]*array_of_larges[1];
506506
#else
@@ -517,7 +517,7 @@ int ncmpii_dtype_decode(MPI_Datatype dtype,
517517
#endif
518518
if (iscontig_of_ptypes) *iscontig_of_ptypes = 0;
519519
if (is_large_type) {
520-
#ifdef HAVE_MPI_TYPE_GET_CONTENTS_C
520+
#ifdef HAVE_MPI_LARGE_COUNT
521521
/* sum of array_of_blocklengths[] */
522522
for (i=0, total_blocks=0; i<array_of_larges[0]; i++)
523523
total_blocks += array_of_larges[1+i];
@@ -535,7 +535,7 @@ int ncmpii_dtype_decode(MPI_Datatype dtype,
535535
if (iscontig_of_ptypes) *iscontig_of_ptypes = 0;
536536
ndims = array_of_ints[0];
537537
if (is_large_type) {
538-
#ifdef HAVE_MPI_TYPE_GET_CONTENTS_C
538+
#ifdef HAVE_MPI_LARGE_COUNT
539539
/* calculate product of array_of_subsizes[] */
540540
for (i=0, total_blocks=1; i<ndims; i++)
541541
total_blocks *= array_of_larges[ndims+i];
@@ -552,7 +552,7 @@ int ncmpii_dtype_decode(MPI_Datatype dtype,
552552
case MPI_COMBINER_DARRAY:
553553
if (iscontig_of_ptypes) *iscontig_of_ptypes = 0;
554554
ndims = array_of_ints[2];
555-
#ifdef HAVE_MPI_TYPE_GET_CONTENTS_C
555+
#ifdef HAVE_MPI_LARGE_COUNT
556556
int *distribs, *dargs, *psizes;
557557
MPI_Count *gzises;
558558
if (is_large_type) {
@@ -577,7 +577,7 @@ int ncmpii_dtype_decode(MPI_Datatype dtype,
577577
/* seldom reached, so put it in a separate function */
578578
total_blocks = darray_get_totalblks(array_of_ints[1], /* rank */
579579
ndims, gzises, distribs, dargs, psizes);
580-
#ifdef HAVE_MPI_TYPE_GET_CONTENTS_C
580+
#ifdef HAVE_MPI_LARGE_COUNT
581581
if (!is_large_type) NCI_Free(gzises);
582582
#endif
583583
break;
@@ -599,7 +599,7 @@ int ncmpii_dtype_decode(MPI_Datatype dtype,
599599
NCI_Free(array_of_ints);
600600
NCI_Free(array_of_adds);
601601
NCI_Free(array_of_dtypes);
602-
#ifdef HAVE_MPI_TYPE_GET_CONTENTS_C
602+
#ifdef HAVE_MPI_LARGE_COUNT
603603
if (is_large_type) NCI_Free(array_of_larges);
604604
#endif
605605

src/drivers/ncmpio/ncmpio_filetype.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ ncmpio_filetype_create_vars(const NC *ncp,
563563
}
564564

565565
if (isLargeReq) {
566-
#ifdef HAVE_MPI_TYPE_CREATE_HINDEXED_C
566+
#ifdef HAVE_MPI_LARGE_COUNT
567567
MPI_Count *blocklens_c, *disps_c;
568568
blocklens_c = (MPI_Count*) NCI_Malloc(sizeof(MPI_Count) * nblocks);
569569
disps_c = (MPI_Count*) NCI_Malloc(sizeof(MPI_Count) * nblocks);

0 commit comments

Comments
 (0)