Skip to content

Commit 7430124

Browse files
authored
Merge pull request #6331 from ggouaillardet/topic/v3.1.x/ompi_datatype_set_args
ompi/datatype: fix how we compute the space needed for the args
2 parents 8efcada + 98e4d27 commit 7430124

File tree

2 files changed

+52
-3
lines changed

2 files changed

+52
-3
lines changed

ompi/datatype/ompi_datatype_args.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
* Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
1414
* Copyright (c) 2013-2016 Los Alamos National Security, LLC. All rights
1515
* reserved.
16-
* Copyright (c) 2015-2017 Research Organization for Information Science
17-
* and Technology (RIST). All rights reserved.
16+
* Copyright (c) 2015-2019 Research Organization for Information Science
17+
* and Technology (RIST). All rights reserved.
1818
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1919
* $COPYRIGHT$
2020
*
@@ -237,6 +237,8 @@ int32_t ompi_datatype_set_args( ompi_datatype_t* pData,
237237
*/
238238
OBJ_RETAIN( d[pos] );
239239
pArgs->total_pack_size += ((ompi_datatype_args_t*)d[pos]->args)->total_pack_size;
240+
} else {
241+
pArgs->total_pack_size += sizeof(int); /* _NAMED */
240242
}
241243
pArgs->total_pack_size += sizeof(int); /* each data has an ID */
242244
}

test/datatype/ddt_pack.c

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ main(int argc, char* argv[])
5151
int ret = 0;
5252
int blen[4];
5353
ptrdiff_t disp[4];
54-
ompi_datatype_t *newType, *types[4], *struct_type, *vec_type;
54+
ompi_datatype_t *newType, *types[4], *struct_type, *vec_type, *dup_type;
5555
ptrdiff_t old_lb, old_extent, old_true_lb, old_true_extent;
5656
ptrdiff_t lb, extent, true_lb, true_extent;
5757

@@ -394,6 +394,53 @@ main(int argc, char* argv[])
394394
ret = ompi_datatype_destroy(&unpacked_dt);
395395
if (ret != 0) goto cleanup;
396396

397+
/**
398+
*
399+
* TEST 7
400+
*
401+
*/
402+
printf("---> Basic test with dup'ed MPI_INT\n");
403+
404+
ret = get_extents(&ompi_mpi_int.dt, &old_lb, &old_extent, &old_true_lb, &old_true_extent);
405+
if (ret != 0) goto cleanup;
406+
ret = ompi_datatype_duplicate(&ompi_mpi_int.dt, &dup_type);
407+
if (ret != 0) goto cleanup;
408+
ompi_datatype_t * type = &ompi_mpi_int.dt;
409+
ret = ompi_datatype_set_args(dup_type, 0, NULL, 0, NULL, 1, &type, MPI_COMBINER_DUP);
410+
if (ret != 0) goto cleanup;
411+
packed_ddt_len = ompi_datatype_pack_description_length(dup_type);
412+
ptr = payload = malloc(packed_ddt_len);
413+
ret = ompi_datatype_get_pack_description(dup_type, &packed_ddt);
414+
if (ret != 0) goto cleanup;
415+
416+
memcpy(payload, packed_ddt, packed_ddt_len);
417+
unpacked_dt = ompi_datatype_create_from_packed_description(&payload,
418+
ompi_proc_local());
419+
free(ptr);
420+
if (unpacked_dt == NULL) {
421+
printf("\tFAILED: could not unpack datatype\n");
422+
ret = 1;
423+
goto cleanup;
424+
} else {
425+
ret = get_extents(unpacked_dt, &lb, &extent, &true_lb, &true_extent);
426+
if (ret != 0) goto cleanup;
427+
428+
if (old_lb != lb || old_extent != extent ||
429+
old_true_lb != true_lb || old_true_extent != extent) {
430+
printf("\tFAILED: datatypes don't match\n");
431+
ret = 1;
432+
goto cleanup;
433+
}
434+
printf("\tPASSED\n");
435+
}
436+
if (unpacked_dt == &ompi_mpi_int32_t.dt) {
437+
printf("\tPASSED\n");
438+
} else {
439+
printf("\tFAILED: datatypes don't match\n");
440+
ret = 1;
441+
goto cleanup;
442+
}
443+
ompi_datatype_destroy(&dup_type);
397444

398445
cleanup:
399446
ompi_datatype_finalize();

0 commit comments

Comments
 (0)