Skip to content

Commit a3164b0

Browse files
committed
fabtests: fix complex fill cast
The previous implementation was trying to fill complex numbers with multiple chars in the integ_alphabet to randomize the data. Unfortunately, this resulted in many complex numbers becoming invalid numbers (NaN). Because of that, the data validation check would fail as NaN != NaN To fix this, when filling the data, set the real and imaginary parts as a single char element so the individual part is valid and can be used in the computation and check. Because the implementation of complex types differs on unix and Windows systems, this requires the addition of a new function that initializes the individual components of the complex number instead of the number as a whole. This requires moving the long_double typedef into the osd.h headers to help with the casting. Signed-off-by: Alexia Ingerson <[email protected]>
1 parent ce936d0 commit a3164b0

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

fabtests/include/ofi_atomic.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
extern "C" {
4141
#endif
4242

43-
typedef long double long_double;
4443

4544
#define OFI_WRITE_OP_START FI_MIN
4645
#define OFI_WRITE_OP_LAST (FI_ATOMIC_WRITE + 1)

fabtests/include/shared.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -775,8 +775,8 @@ static inline void *ft_get_page_end(const void *addr, size_t page_size)
775775
int i, a = 0; \
776776
OFI_COMPLEX(type) *d = (dst); \
777777
for (i = 0; i < cnt; i++) { \
778-
ofi_complex_set_##type (&d[i], \
779-
*(OFI_COMPLEX(type) *) &integ_alphabet[a]); \
778+
ofi_complex_fill_##type (&d[i], \
779+
(type) integ_alphabet[a]); \
780780
if (++a >= integ_alphabet_length) \
781781
a = 0; \
782782
} \

fabtests/include/unix/osd.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ static inline int ofi_sockerr(void)
8383
return errno;
8484
}
8585

86+
typedef long double long_double;
87+
8688
/* complex operations implementation */
8789
#define OFI_COMPLEX(name) ofi_complex_##name
8890
#define OFI_COMPLEX_OP(name, op) ofi_complex_##op##_##name
@@ -120,6 +122,10 @@ static inline OFI_COMPLEX(name) OFI_COMPLEX_OP(name, lxor)(OFI_COMPLEX(name) v1,
120122
static inline void OFI_COMPLEX_OP(name, set)(OFI_COMPLEX(name) *v1, OFI_COMPLEX(name) v2) \
121123
{ \
122124
*v1 = v2; \
125+
} \
126+
static inline void OFI_COMPLEX_OP(name, fill)(OFI_COMPLEX(name) *v1, name v2) \
127+
{ \
128+
*v1 = CMPLX(v2, v2); \
123129
}
124130

125131
OFI_COMPLEX_OPS(float)

fabtests/include/windows/osd.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,7 @@ ofi_send_socket(SOCKET fd, const void *buf, size_t count, int flags)
724724
return (ssize_t) send(fd, (const char*) buf, len, flags);
725725
}
726726

727+
typedef long double long_double;
727728

728729
/* complex operations implementation */
729730
#define OFI_COMPLEX(name) ofi_complex_##name
@@ -790,6 +791,11 @@ static inline void OFI_COMPLEX_OP(name, set)(OFI_COMPLEX(name) *v1, OFI_COMPLEX(
790791
{ \
791792
v1->re = v2.re; \
792793
v1->im = v2.im; \
794+
} \
795+
static inline void OFI_COMPLEX_OP(name, fill)(OFI_COMPLEX(name) *v1, char v2) \
796+
{ \
797+
v1->re = v2; \
798+
v1->im = v2; \
793799
}
794800

795801
OFI_COMPLEX_OPS(float)

0 commit comments

Comments
 (0)