Skip to content

Commit cf45c2c

Browse files
authored
Merge pull request #709 from bertwesarg/fix-dart-mpi-type-cont-max
dart/mpi: Correctly use `MPI_DATATYPE_NULL` to denote an invalid type
2 parents 22f6487 + 48aca08 commit cf45c2c

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

dart-impl/mpi/include/dash/dart/mpi/dart_communication_priv.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ dart_ret_t dart__mpi__op_fini();
7575
*/
7676
#define MAX_CONTIG_ELEMENTS (INT_MAX)
7777

78-
#define DART_MPI_TYPE_UNDEFINED (MPI_Datatype)MPI_UNDEFINED
79-
8078
typedef enum {
8179
DART_KIND_BASIC = 0,
8280
DART_KIND_STRIDED,
@@ -190,7 +188,7 @@ MPI_Datatype dart__mpi__datatype_maxtype(dart_datatype_t dart_type) {
190188
dart_datatype_struct_t *dts = dart__mpi__datatype_struct(dart_type);
191189
MPI_Datatype res;
192190
if (dart__mpi__datatype_iscontiguous(dart_type)) {
193-
if (dts->contiguous.max_type == DART_MPI_TYPE_UNDEFINED) {
191+
if (dts->contiguous.max_type == MPI_DATATYPE_NULL) {
194192
dts->contiguous.max_type = dart__mpi__datatype_create_max_datatype(
195193
dts->contiguous.mpi_type);
196194
}

dart-impl/mpi/src/dart_communication.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,11 +391,11 @@ dart__mpi__put_basic(
391391
CHECK_MPI_RET(
392392
dart__mpi__put(src_ptr,
393393
nchunks,
394-
dart__mpi__datatype_struct(dtype)->contiguous.max_type,
394+
dart__mpi__datatype_maxtype(dtype),
395395
team_unit_id.id,
396396
offset,
397397
nchunks,
398-
dart__mpi__datatype_struct(dtype)->contiguous.max_type,
398+
dart__mpi__datatype_maxtype(dtype),
399399
win,
400400
reqs, num_reqs),
401401
"MPI_Put");

dart-impl/mpi/src/dart_mpi_types.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ dart_type_create_custom(
312312
new_struct->contiguous.size = num_bytes;
313313
new_struct->contiguous.mpi_type = new_mpi_dtype;
314314
// max_type will be created on-demand for custom types
315-
new_struct->contiguous.max_type = DART_MPI_TYPE_UNDEFINED;
315+
new_struct->contiguous.max_type = MPI_DATATYPE_NULL;
316316

317317
*newtype = (dart_datatype_t)new_struct;
318318
DART_LOG_TRACE("Created new custom data type %p with %zu bytes`",
@@ -343,7 +343,7 @@ dart_type_destroy(dart_datatype_t *dart_type_ptr)
343343
MPI_Type_free(&dart_type->indexed.mpi_type);
344344
} else if (dart_type->kind == DART_KIND_CUSTOM) {
345345
MPI_Type_free(&dart_type->contiguous.mpi_type);
346-
if (dart_type->contiguous.max_type != DART_MPI_TYPE_UNDEFINED) {
346+
if (dart_type->contiguous.max_type != MPI_DATATYPE_NULL) {
347347
MPI_Type_free(&dart_type->contiguous.max_type);
348348
}
349349
}
@@ -357,7 +357,8 @@ dart_type_destroy(dart_datatype_t *dart_type_ptr)
357357
static void destroy_basic_type(dart_datatype_t dart_type_id)
358358
{
359359
dart_datatype_struct_t *dart_type = dart__mpi__datatype_struct(dart_type_id);
360-
MPI_Type_free(&dart_type->contiguous.max_type);
360+
if (dart_type->contiguous.max_type != MPI_DATATYPE_NULL)
361+
MPI_Type_free(&dart_type->contiguous.max_type);
361362
dart_type->contiguous.max_type = MPI_DATATYPE_NULL;
362363
}
363364

0 commit comments

Comments
 (0)