Skip to content

Commit a27bc75

Browse files
committed
datatype: Fix pack external by using the MPIR layer
1 parent 19921e3 commit a27bc75

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

src/include/mpir_datatype.h

+11
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,17 @@ void MPII_Datatype_printf(MPI_Datatype type, int depth, MPI_Aint displacement, i
380380
} \
381381
} while (0)
382382

383+
#define MPIR_Datatype_is_complex(a, is_complex) do { \
384+
MPI_Datatype basic_type; \
385+
MPIR_Datatype_get_basic_type(a, basic_type); \
386+
int type = basic_type & MPIR_TYPE_TYPE_MASK; \
387+
if (type == MPIR_TYPE_COMPLEX || type == MPIR_TYPE_ALT_COMPLEX) { \
388+
is_complex = true; \
389+
} else { \
390+
is_complex = false; \
391+
} \
392+
} while (0)
393+
383394
#define MPIR_Datatype_get_ptr(a,ptr) MPIR_Getb_ptr(Datatype,DATATYPE,a,0x000000ff,ptr)
384395

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

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

+11-7
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)