Skip to content

Commit 4e56e83

Browse files
committed
Long live MPI_LONG and MPI_UNSIGNED_LONG
The only 2 types that have an external32 representation with a different size than most current architectures, and as a result are more challenging to handle. This patch also brings back the support for packing and unpacking to and from external32 for all datatypes and does a little cleaning in the datatype API and comments. Signed-off-by: George Bosilca <[email protected]>
1 parent 47273fb commit 4e56e83

15 files changed

+364
-137
lines changed

ompi/datatype/ompi_datatype.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ BEGIN_C_DECLS
5959
#define OMPI_DATATYPE_FLAG_DATA_FORTRAN 0xC000
6060
#define OMPI_DATATYPE_FLAG_DATA_LANGUAGE 0xC000
6161

62-
#define OMPI_DATATYPE_MAX_PREDEFINED 50
62+
#define OMPI_DATATYPE_MAX_PREDEFINED 52
6363

6464
#if OMPI_DATATYPE_MAX_PREDEFINED > OPAL_DATATYPE_MAX_SUPPORTED
6565
#error Need to increase the number of supported dataypes by OPAL (value OPAL_DATATYPE_MAX_SUPPORTED).

ompi/datatype/ompi_datatype_external.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ int ompi_datatype_pack_external_size(const char datarep[], int incount,
126126
CONVERTOR_SEND_CONVERSION,
127127
&local_convertor );
128128

129-
opal_convertor_get_unpacked_size( &local_convertor, &length );
129+
opal_convertor_get_packed_size( &local_convertor, &length );
130130
*size = (MPI_Aint)length;
131131
OBJ_DESTRUCT( &local_convertor );
132132

ompi/datatype/ompi_datatype_internal.h

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,14 @@
109109
#define OMPI_DATATYPE_MPI_SHORT_FLOAT 0x30
110110
#define OMPI_DATATYPE_MPI_C_SHORT_FLOAT_COMPLEX 0x31
111111

112+
/*
113+
* Datatypes that have a different external32 length.
114+
*/
115+
#define OMPI_DATATYPE_MPI_LONG 0x32
116+
#define OMPI_DATATYPE_MPI_UNSIGNED_LONG 0x33
117+
112118
/* This should __ALWAYS__ stay last */
113-
#define OMPI_DATATYPE_MPI_UNAVAILABLE 0x32
119+
#define OMPI_DATATYPE_MPI_UNAVAILABLE 0x34
114120

115121

116122
#define OMPI_DATATYPE_MPI_MAX_PREDEFINED (OMPI_DATATYPE_MPI_UNAVAILABLE+1)
@@ -177,20 +183,6 @@
177183
#define OMPI_DATATYPE_MPI_UNSIGNED OMPI_DATATYPE_MPI_UINT64_T
178184
#endif
179185

180-
#if SIZEOF_LONG == 1
181-
#define OMPI_DATATYPE_MPI_LONG OMPI_DATATYPE_MPI_INT8_T
182-
#define OMPI_DATATYPE_MPI_UNSIGNED_LONG OMPI_DATATYPE_MPI_UINT8_T
183-
#elif SIZEOF_LONG == 2
184-
#define OMPI_DATATYPE_MPI_LONG OMPI_DATATYPE_MPI_INT16_T
185-
#define OMPI_DATATYPE_MPI_UNSIGNED_LONG OMPI_DATATYPE_MPI_UINT16_T
186-
#elif SIZEOF_LONG == 4
187-
#define OMPI_DATATYPE_MPI_LONG OMPI_DATATYPE_MPI_INT32_T
188-
#define OMPI_DATATYPE_MPI_UNSIGNED_LONG OMPI_DATATYPE_MPI_UINT32_T
189-
#elif SIZEOF_LONG == 8
190-
#define OMPI_DATATYPE_MPI_LONG OMPI_DATATYPE_MPI_INT64_T
191-
#define OMPI_DATATYPE_MPI_UNSIGNED_LONG OMPI_DATATYPE_MPI_UINT64_T
192-
#endif
193-
194186
#if SIZEOF_LONG_LONG == 1
195187
#define OMPI_DATATYPE_MPI_LONG_LONG_INT OMPI_DATATYPE_MPI_INT8_T
196188
#define OMPI_DATATYPE_MPI_UNSIGNED_LONG_LONG OMPI_DATATYPE_MPI_UINT8_T
@@ -571,16 +563,8 @@ extern const ompi_datatype_t* ompi_datatype_basicDatatypes[OMPI_DATATYPE_MPI_MAX
571563
#define OMPI_DATATYPE_INITIALIZER_UNSIGNED OPAL_DATATYPE_INITIALIZER_UINT8
572564
#endif
573565

574-
#if SIZEOF_LONG == 4
575-
#define OMPI_DATATYPE_INITIALIZER_LONG OPAL_DATATYPE_INITIALIZER_INT4
576-
#define OMPI_DATATYPE_INITIALIZER_UNSIGNED_LONG OPAL_DATATYPE_INITIALIZER_UINT4
577-
#elif SIZEOF_LONG == 8
578-
#define OMPI_DATATYPE_INITIALIZER_LONG OPAL_DATATYPE_INITIALIZER_INT8
579-
#define OMPI_DATATYPE_INITIALIZER_UNSIGNED_LONG OPAL_DATATYPE_INITIALIZER_UINT8
580-
#elif SIZEOF_LONG == 16
581-
#define OMPI_DATATYPE_INITIALIZER_LONG OPAL_DATATYPE_INITIALIZER_INT16
582-
#define OMPI_DATATYPE_INITIALIZER_UNSIGNED_LONG OPAL_DATATYPE_INITIALIZER_UINT16
583-
#endif
566+
#define OMPI_DATATYPE_INITIALIZER_LONG OPAL_DATATYPE_INITIALIZER_LONG
567+
#define OMPI_DATATYPE_INITIALIZER_UNSIGNED_LONG OPAL_DATATYPE_INITIALIZER_UNSIGNED_LONG
584568

585569
#if SIZEOF_LONG_LONG == 4
586570
#define OMPI_DATATYPE_INITIALIZER_LONG_LONG_INT OPAL_DATATYPE_INITIALIZER_INT4

ompi/datatype/ompi_datatype_module.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,8 @@ const ompi_datatype_t* ompi_datatype_basicDatatypes[OMPI_DATATYPE_MPI_MAX_PREDEF
366366
[OMPI_DATATYPE_MPI_LB] = &ompi_mpi_lb.dt,
367367
[OMPI_DATATYPE_MPI_UB] = &ompi_mpi_ub.dt,
368368

369+
[OMPI_DATATYPE_MPI_LONG] = &ompi_mpi_long.dt,
370+
[OMPI_DATATYPE_MPI_UNSIGNED_LONG] = &ompi_mpi_long.dt,
369371
/* MPI 3.0 types */
370372
[OMPI_DATATYPE_MPI_COUNT] = &ompi_mpi_count.dt,
371373

ompi/mca/pml/ob1/pml_ob1_recvreq.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,8 @@ static inline void prepare_recv_req_converter(mca_pml_ob1_recv_request_t *req)
234234
req->req_recv.req_base.req_addr,
235235
0,
236236
&req->req_recv.req_base.req_convertor);
237-
opal_convertor_get_unpacked_size(&req->req_recv.req_base.req_convertor,
238-
&req->req_bytes_expected);
237+
opal_convertor_get_packed_size(&req->req_recv.req_base.req_convertor,
238+
&req->req_bytes_expected);
239239
}
240240
}
241241

opal/datatype/opal_convertor.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,13 @@ opal_convertor_master_t *opal_convertor_find_or_create_master(uint32_t remote_ar
142142
} else {
143143
opal_output(0, "Unknown sizeof(bool) for the remote architecture\n");
144144
}
145-
145+
if (opal_arch_checkmask(&master->remote_arch, OPAL_ARCH_LONGIS64)) {
146+
remote_sizes[OPAL_DATATYPE_LONG] = 8;
147+
remote_sizes[OPAL_DATATYPE_UNSIGNED_LONG] = 8;
148+
} else {
149+
remote_sizes[OPAL_DATATYPE_LONG] = 4;
150+
remote_sizes[OPAL_DATATYPE_UNSIGNED_LONG] = 4;
151+
}
146152
/**
147153
* Now we can compute the conversion mask. For all sizes where the remote
148154
* and local architecture differ a conversion is needed. Moreover, if the
@@ -434,7 +440,7 @@ int32_t opal_convertor_set_position_nocheck(opal_convertor_t *convertor, size_t
434440
}
435441
rc = opal_convertor_generic_simple_position(convertor, position);
436442
/**
437-
* If we have a non-contigous send convertor don't allow it move in the middle
443+
* If we have a non-contiguous send convertor don't allow it move in the middle
438444
* of a predefined datatype, it won't be able to copy out the left-overs
439445
* anyway. Instead force the position to stay on predefined datatypes
440446
* boundaries. As we allow partial predefined datatypes on the contiguous

opal/datatype/opal_convertor.h

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -199,22 +199,19 @@ static inline int32_t opal_convertor_need_buffers(const opal_convertor_t *pConve
199199
size_t opal_convertor_compute_remote_size(opal_convertor_t *pConv);
200200

201201
/**
202-
* Return the local size of the convertor (count times the size of the datatype).
202+
* Return the packed size of the memory layout represented by this
203+
* convertor. This is the size of the buffer that would be needed
204+
* for the conversion (takes in account the type of the operation,
205+
* aka pack or unpack, as well as which side is supposed to do the
206+
* type conversion).
203207
*/
204-
static inline void opal_convertor_get_packed_size(const opal_convertor_t *pConv, size_t *pSize)
208+
static inline void
209+
opal_convertor_get_packed_size(const opal_convertor_t *pConv, size_t *pSize)
205210
{
206211
*pSize = pConv->local_size;
207-
}
208-
209-
/**
210-
* Return the remote size of the convertor (count times the remote size of the
211-
* datatype). On homogeneous environments the local and remote sizes are
212-
* identical.
213-
*/
214-
static inline void opal_convertor_get_unpacked_size(const opal_convertor_t *pConv, size_t *pSize)
215-
{
216-
if (pConv->flags & CONVERTOR_HOMOGENEOUS) {
217-
*pSize = pConv->local_size;
212+
if ((pConv->flags & CONVERTOR_HOMOGENEOUS) ||
213+
((pConv->flags & CONVERTOR_SEND) && !(pConv->flags & CONVERTOR_SEND_CONVERSION)) ||
214+
((pConv->flags & CONVERTOR_RECV) && (pConv->flags & CONVERTOR_SEND_CONVERSION))) {
218215
return;
219216
}
220217
if (0 == (CONVERTOR_HAS_REMOTE_SIZE & pConv->flags)) {

opal/datatype/opal_copy_functions.c

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@
6262
\
6363
if ((from_extent == (ptrdiff_t) local_TYPE_size) \
6464
&& (to_extent == (ptrdiff_t) remote_TYPE_size)) { \
65-
/* copy of contigous data at both source and destination */ \
65+
/* copy of contiguous data at both source and destination */ \
6666
MEMCPY(to, from, count *local_TYPE_size); \
6767
} else { \
68-
/* source or destination are non-contigous */ \
68+
/* source or destination are non-contiguous */ \
6969
for (size_t i = 0; i < count; i++) { \
7070
MEMCPY(to, from, local_TYPE_size); \
7171
to += to_extent; \
@@ -254,30 +254,37 @@ COPY_TYPE(wchar, wchar_t, 1)
254254
/* Table of predefined copy functions - one for each OPAL type */
255255
/* NOTE: The order of this array *MUST* match the order in opal_datatype_basicDatatypes */
256256
conversion_fct_t opal_datatype_copy_functions[OPAL_DATATYPE_MAX_PREDEFINED] = {
257-
(conversion_fct_t) NULL, /* OPAL_DATATYPE_LOOP */
258-
(conversion_fct_t) NULL, /* OPAL_DATATYPE_END_LOOP */
259-
(conversion_fct_t) NULL, /* OPAL_DATATYPE_LB */
260-
(conversion_fct_t) NULL, /* OPAL_DATATYPE_UB */
261-
(conversion_fct_t) copy_bytes_1, /* OPAL_DATATYPE_INT1 */
262-
(conversion_fct_t) copy_bytes_2, /* OPAL_DATATYPE_INT2 */
263-
(conversion_fct_t) copy_bytes_4, /* OPAL_DATATYPE_INT4 */
264-
(conversion_fct_t) copy_bytes_8, /* OPAL_DATATYPE_INT8 */
265-
(conversion_fct_t) copy_bytes_16, /* OPAL_DATATYPE_INT16 */
266-
(conversion_fct_t) copy_bytes_1, /* OPAL_DATATYPE_UINT1 */
267-
(conversion_fct_t) copy_bytes_2, /* OPAL_DATATYPE_UINT2 */
268-
(conversion_fct_t) copy_bytes_4, /* OPAL_DATATYPE_UINT4 */
269-
(conversion_fct_t) copy_bytes_8, /* OPAL_DATATYPE_UINT8 */
270-
(conversion_fct_t) copy_bytes_16, /* OPAL_DATATYPE_UINT16 */
271-
(conversion_fct_t) copy_float_2, /* OPAL_DATATYPE_FLOAT2 */
272-
(conversion_fct_t) copy_float_4, /* OPAL_DATATYPE_FLOAT4 */
273-
(conversion_fct_t) copy_float_8, /* OPAL_DATATYPE_FLOAT8 */
274-
(conversion_fct_t) copy_float_12, /* OPAL_DATATYPE_FLOAT12 */
275-
(conversion_fct_t) copy_float_16, /* OPAL_DATATYPE_FLOAT16 */
276-
(conversion_fct_t) copy_short_float_complex, /* OPAL_DATATYPE_SHORT_FLOAT_COMPLEX */
277-
(conversion_fct_t) copy_float_complex, /* OPAL_DATATYPE_FLOAT_COMPLEX */
278-
(conversion_fct_t) copy_double_complex, /* OPAL_DATATYPE_DOUBLE_COMPLEX */
279-
(conversion_fct_t) copy_long_double_complex, /* OPAL_DATATYPE_LONG_DOUBLE_COMPLEX */
280-
(conversion_fct_t) copy_bool, /* OPAL_DATATYPE_BOOL */
281-
(conversion_fct_t) copy_wchar, /* OPAL_DATATYPE_WCHAR */
282-
(conversion_fct_t) NULL /* OPAL_DATATYPE_UNAVAILABLE */
257+
[OPAL_DATATYPE_LOOP] = (conversion_fct_t) NULL,
258+
[OPAL_DATATYPE_END_LOOP] = (conversion_fct_t) NULL,
259+
[OPAL_DATATYPE_LB] = (conversion_fct_t) NULL,
260+
[OPAL_DATATYPE_UB] = (conversion_fct_t) NULL,
261+
[OPAL_DATATYPE_INT1] = (conversion_fct_t) copy_bytes_1,
262+
[OPAL_DATATYPE_INT2] = (conversion_fct_t) copy_bytes_2,
263+
[OPAL_DATATYPE_INT4] = (conversion_fct_t) copy_bytes_4,
264+
[OPAL_DATATYPE_INT8] = (conversion_fct_t) copy_bytes_8,
265+
[OPAL_DATATYPE_INT16] = (conversion_fct_t) copy_bytes_16,
266+
[OPAL_DATATYPE_UINT1] = (conversion_fct_t) copy_bytes_1,
267+
[OPAL_DATATYPE_UINT2] = (conversion_fct_t) copy_bytes_2,
268+
[OPAL_DATATYPE_UINT4] = (conversion_fct_t) copy_bytes_4,
269+
[OPAL_DATATYPE_UINT8] = (conversion_fct_t) copy_bytes_8,
270+
[OPAL_DATATYPE_UINT16] = (conversion_fct_t) copy_bytes_16,
271+
[OPAL_DATATYPE_FLOAT2] = (conversion_fct_t) copy_float_2,
272+
[OPAL_DATATYPE_FLOAT4] = (conversion_fct_t) copy_float_4,
273+
[OPAL_DATATYPE_FLOAT8] = (conversion_fct_t) copy_float_8,
274+
[OPAL_DATATYPE_FLOAT12] = (conversion_fct_t) copy_float_12,
275+
[OPAL_DATATYPE_FLOAT16] = (conversion_fct_t) copy_float_16,
276+
[OPAL_DATATYPE_SHORT_FLOAT_COMPLEX] = (conversion_fct_t) copy_short_float_complex,
277+
[OPAL_DATATYPE_FLOAT_COMPLEX] = (conversion_fct_t) copy_float_complex,
278+
[OPAL_DATATYPE_DOUBLE_COMPLEX] = (conversion_fct_t) copy_double_complex,
279+
[OPAL_DATATYPE_LONG_DOUBLE_COMPLEX] = (conversion_fct_t) copy_long_double_complex,
280+
[OPAL_DATATYPE_BOOL] = (conversion_fct_t) copy_bool,
281+
[OPAL_DATATYPE_WCHAR] = (conversion_fct_t) copy_wchar,
282+
#if SIZEOF_LONG == 4
283+
[OPAL_DATATYPE_LONG] = (conversion_fct_t)copy_bytes_4,
284+
[OPAL_DATATYPE_UNSIGNED_LONG] = (conversion_fct_t)copy_bytes_4,
285+
#elif SIZEOF_LONG == 8
286+
[OPAL_DATATYPE_LONG] = (conversion_fct_t)copy_bytes_8,
287+
[OPAL_DATATYPE_UNSIGNED_LONG] = (conversion_fct_t)copy_bytes_8,
288+
#endif
289+
[OPAL_DATATYPE_UNAVAILABLE] = NULL,
283290
};

0 commit comments

Comments
 (0)