Skip to content

Commit cf181fd

Browse files
committed
Properly handle AINT_COUNT_ARRAY arguments
For struct, hindex, and hindex_block MPI_Aint arguments turn into MPI_Count arguments for bigcount. This needs special handling. Signed-off-by: Joseph Schuchart <[email protected]>
1 parent 9090b44 commit cf181fd

File tree

4 files changed

+59
-10
lines changed

4 files changed

+59
-10
lines changed

ompi/datatype/ompi_datatype_args.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ int32_t ompi_datatype_set_args( ompi_datatype_t* pData,
171171
size_t count = opal_count_array_get(counts[0], 0);
172172
copy_count_array(1, &pi, &pl, counts[0]);
173173
copy_count_array(count, &pi, &pl, counts[1]);
174+
if (cl > 0) {
175+
// copy the displacements
176+
memcpy(pl, opal_count_array_ptr(counts[2]), count * sizeof(MPI_Count));
177+
pl += count;
178+
}
174179
break;
175180
}
176181

@@ -187,6 +192,11 @@ int32_t ompi_datatype_set_args( ompi_datatype_t* pData,
187192
size_t count = opal_count_array_get(counts[0], 0);
188193
copy_count_array(1, &pi, &pl, counts[0]);
189194
copy_count_array(count, &pi, &pl, counts[1]);
195+
if (cl > 0) {
196+
// copy the displacements
197+
memcpy(pl, opal_count_array_ptr(counts[2]), count * sizeof(MPI_Count));
198+
pl += count;
199+
}
190200
break;
191201
}
192202

@@ -229,6 +239,12 @@ int32_t ompi_datatype_set_args( ompi_datatype_t* pData,
229239
case MPI_COMBINER_HINDEXED_BLOCK:
230240
copy_count_array(1, &pi, &pl, counts[0]);
231241
copy_count_array(1, &pi, &pl, counts[1]);
242+
if (cl > 0) {
243+
// copy the displacements
244+
size_t count = opal_count_array_get(counts[0], 0);
245+
memcpy(pl, opal_count_array_ptr(counts[2]), count * sizeof(MPI_Count));
246+
pl += count;
247+
}
232248
break;
233249

234250
default:

ompi/mpi/c/type_create_hindexed.c.in

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ PROTOTYPE ERROR_CLASS type_create_hindexed(COUNT count,
6767
}
6868
}
6969

70+
/*
71+
* TODO: array_of_displacements can be either MPI_Aint or MPI_Count.
72+
* The call below takes a ompi_disp_array_t which maps to MPI_Aint.
73+
*/
7074
rc = ompi_datatype_create_hindexed( count, OMPI_COUNT_ARRAY_CREATE(array_of_blocklengths),
7175
OMPI_COUNT_ARRAY_CREATE(array_of_displacements),
7276
oldtype, newtype );
@@ -76,13 +80,21 @@ PROTOTYPE ERROR_CLASS type_create_hindexed(COUNT count,
7680
}
7781
/* data description */
7882
{
79-
ompi_count_array_t a_i[2] = {OMPI_COUNT_ARRAY_CREATE(&count), OMPI_COUNT_ARRAY_CREATE(array_of_blocklengths)};
83+
#if OMPI_BIGCOUNT_SRC
84+
ompi_count_array_t a_i[3] = {
85+
OMPI_COUNT_ARRAY_CREATE(&count),
86+
OMPI_COUNT_ARRAY_CREATE(array_of_blocklengths),
87+
OMPI_COUNT_ARRAY_CREATE(array_of_displacements)};
8088

81-
ompi_datatype_set_args( *newtype,
82-
(sizeof(count) != sizeof(size_t)) ? count + 1 : 0,
83-
(sizeof(count) == sizeof(size_t)) ? count + 1 : 0,
89+
ompi_datatype_set_args( *newtype, 0, 2*count + 1,
90+
a_i, 0, OMPI_DISP_ARRAY_NULL,
91+
1, &oldtype, MPI_COMBINER_HINDEXED );
92+
#else
93+
ompi_count_array_t a_i[2] = {OMPI_COUNT_ARRAY_CREATE(&count), OMPI_COUNT_ARRAY_CREATE(array_of_blocklengths)};
94+
ompi_datatype_set_args( *newtype, count + 1, 0,
8495
a_i, count, OMPI_DISP_ARRAY_CREATE(array_of_displacements),
8596
1, &oldtype, MPI_COMBINER_HINDEXED );
97+
#endif
8698
}
8799

88100
return MPI_SUCCESS;

ompi/mpi/c/type_create_hindexed_block.c.in

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,22 @@ PROTOTYPE ERROR_CLASS type_create_hindexed_block(COUNT count,
6060
OMPI_ERRHANDLER_NOHANDLE_RETURN( rc, rc, FUNC_NAME );
6161
}
6262
{
63+
#if OMPI_BIGCOUNT_SRC
64+
ompi_count_array_t a_i[3] = {
65+
OMPI_COUNT_ARRAY_CREATE(&count),
66+
OMPI_COUNT_ARRAY_CREATE(&blocklength),
67+
OMPI_COUNT_ARRAY_CREATE(array_of_displacements)};
68+
ompi_datatype_set_args( *newtype, 0, count + 2,
69+
a_i, 0, OMPI_DISP_ARRAY_NULL,
70+
1, &oldtype,
71+
MPI_COMBINER_HINDEXED_BLOCK );
72+
#else
6373
ompi_count_array_t a_i[2] = {OMPI_COUNT_ARRAY_CREATE(&count), OMPI_COUNT_ARRAY_CREATE(&blocklength)};
6474

65-
ompi_datatype_set_args( *newtype,
66-
(sizeof(count) != sizeof(size_t)) ? 2 : 0,
67-
(sizeof(count) == sizeof(size_t)) ? 2 : 0,
75+
ompi_datatype_set_args( *newtype, 2, 0,
6876
a_i, count, OMPI_DISP_ARRAY_CREATE(array_of_displacements), 1, &oldtype,
6977
MPI_COMBINER_HINDEXED_BLOCK );
78+
#endif
7079
}
7180

7281
return MPI_SUCCESS;

ompi/mpi/c/type_create_struct.c.in

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ PROTOTYPE ERROR_CLASS type_create_struct(COUNT count,
7272
}
7373
}
7474

75+
/**
76+
* TODO: The array of displacements can be either MPI_Aint or MPI_Count.
77+
* The call below takes a ompi_disp_array_t which maps to MPI_Aint.
78+
*/
7579
rc = ompi_datatype_create_struct( count, OMPI_COUNT_ARRAY_CREATE(array_of_blocklengths),
7680
OMPI_DISP_ARRAY_CREATE(array_of_displacements),
7781
array_of_types, newtype );
@@ -82,12 +86,20 @@ PROTOTYPE ERROR_CLASS type_create_struct(COUNT count,
8286
}
8387

8488
{
89+
#if OMPI_BIGCOUNT_SRC
90+
ompi_count_array_t a_i[3] = {
91+
OMPI_COUNT_ARRAY_CREATE(&count),
92+
OMPI_COUNT_ARRAY_CREATE(array_of_blocklengths),
93+
OMPI_COUNT_ARRAY_CREATE(array_of_displacements)};
94+
ompi_datatype_set_args( *newtype, 0, 2*count + 1,
95+
a_i, 0, OMPI_DISP_ARRAY_NULL,
96+
count, array_of_types, MPI_COMBINER_STRUCT );
97+
#else
8598
ompi_count_array_t a_i[2] = {OMPI_COUNT_ARRAY_CREATE(&count), OMPI_COUNT_ARRAY_CREATE(array_of_blocklengths)};
86-
ompi_datatype_set_args( *newtype,
87-
(sizeof(count) != sizeof(size_t)) ? count + 1 : 0,
88-
(sizeof(count) == sizeof(size_t)) ? count + 1 : 0,
99+
ompi_datatype_set_args( *newtype, count + 1, 0,
89100
a_i, count, OMPI_DISP_ARRAY_CREATE(array_of_displacements),
90101
count, array_of_types, MPI_COMBINER_STRUCT );
102+
#endif
91103
}
92104

93105
return MPI_SUCCESS;

0 commit comments

Comments
 (0)