Skip to content

Commit 4912a1a

Browse files
authored
Merge pull request pmodels#7336 from dalcinl/fix-pack-ext32
datatype: Fix pack external by using the MPIR layer Approved-by: Hui Zhou
2 parents 057311f + b1c5d65 commit 4912a1a

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

src/include/mpir_datatype.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,17 @@ void MPII_Datatype_printf(MPI_Datatype type, int depth, MPI_Aint displacement, i
416416
} \
417417
} while (0)
418418

419+
#define MPIR_Datatype_is_complex(a, is_complex) do { \
420+
MPI_Datatype basic_type; \
421+
MPIR_Datatype_get_basic_type(a, basic_type); \
422+
int type = basic_type & MPIR_TYPE_TYPE_MASK; \
423+
if (type == MPIR_TYPE_COMPLEX || type == MPIR_TYPE_ALT_COMPLEX) { \
424+
is_complex = true; \
425+
} else { \
426+
is_complex = false; \
427+
} \
428+
} while (0)
429+
419430
#define MPIR_Datatype_get_ptr(a,ptr) MPIR_Getb_ptr(Datatype,DATATYPE,a,0x000000ff,ptr)
420431

421432
/* Note: Probably there is some clever way to build all of these from a macro.

src/mpi/datatype/typerep/dataloop/looputil.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,16 @@ static int contig_pack_to_iov(MPI_Aint * blocks_p,
102102

103103
static inline int is_float_type(MPI_Datatype el_type)
104104
{
105-
return ((el_type == MPI_FLOAT) || (el_type == MPI_DOUBLE) ||
106-
(el_type == MPI_LONG_DOUBLE) ||
107-
(el_type == MPI_DOUBLE_PRECISION) ||
108-
(el_type == MPI_COMPLEX) || (el_type == MPI_DOUBLE_COMPLEX));
109-
/* (el_type == MPI_REAL4) || (el_type == MPI_REAL8) || */
110-
/* (el_type == MPI_REAL16)); */
105+
bool is_float;
106+
MPIR_Datatype_is_float(el_type, is_float);
107+
return is_float;
108+
}
109+
110+
static inline int is_complex_type(MPI_Datatype el_type)
111+
{
112+
bool is_complex;
113+
MPIR_Datatype_is_complex(el_type, is_complex);
114+
return is_complex;
111115
}
112116

113117
static int external32_basic_convert(char *dest_buf,
@@ -683,7 +687,7 @@ static int contig_pack_external32_to_buf(MPI_Aint * blocks_p,
683687
/* TODO: DEAL WITH CASE WHERE ALL DATA DOESN'T FIT! */
684688
if ((src_el_size == dest_el_size) && (src_el_size == 1)) {
685689
MPIR_Memcpy(paramp->u.pack.pack_buffer, ((char *) bufp) + rel_off, *blocks_p);
686-
} else if (MPII_Typerep_basic_type_is_complex(el_type)) {
690+
} else if (is_complex_type(el_type)) {
687691
/* treat as 2x floating point */
688692
external32_float_convert(paramp->u.pack.pack_buffer,
689693
((char *) bufp) + rel_off,

0 commit comments

Comments
 (0)