Skip to content

Commit 03c1511

Browse files
authored
Merge pull request #3871 from ggouaillardet/topic/v3.0.x/hetero_fixes
v3.0.x: misc fixes for heterogeneous clusters
2 parents 641b9a2 + 25a8e86 commit 03c1511

File tree

9 files changed

+125
-18
lines changed

9 files changed

+125
-18
lines changed

config/opal_configure_options.m4

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,22 @@ fi
286286
AC_DEFINE_UNQUOTED(OPAL_ENABLE_DLOPEN_SUPPORT, $OPAL_ENABLE_DLOPEN_SUPPORT,
287287
[Whether we want to enable dlopen support])
288288

289-
opal_want_heterogeneous=0
289+
#
290+
# Heterogeneous support
291+
#
292+
293+
AC_MSG_CHECKING([if want heterogeneous support])
294+
AC_ARG_ENABLE([heterogeneous],
295+
[AC_HELP_STRING([--enable-heterogeneous],
296+
[Enable features required for heterogeneous
297+
platform support (default: disabled)])])
298+
if test "$enable_heterogeneous" = "yes" ; then
299+
AC_MSG_RESULT([yes])
300+
opal_want_heterogeneous=1
301+
else
302+
AC_MSG_RESULT([no])
303+
opal_want_heterogeneous=0
304+
fi
290305
AC_DEFINE_UNQUOTED([OPAL_ENABLE_HETEROGENEOUS_SUPPORT],
291306
[$opal_want_heterogeneous],
292307
[Enable features required for heterogeneous support])

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ AC_CHECK_HEADERS([alloca.h aio.h arpa/inet.h dirent.h \
599599
sys/types.h sys/uio.h sys/un.h net/uio.h sys/utsname.h sys/vfs.h sys/wait.h syslog.h \
600600
termios.h ulimit.h unistd.h util.h utmp.h malloc.h \
601601
ifaddrs.h crt_externs.h regex.h mntent.h paths.h \
602-
ioLib.h sockLib.h hostLib.h shlwapi.h sys/synch.h db.h ndbm.h zlib.h])
602+
ioLib.h sockLib.h hostLib.h shlwapi.h sys/synch.h db.h ndbm.h zlib.h ieee754.h])
603603

604604
AC_CHECK_HEADERS([sys/mount.h], [], [],
605605
[AC_INCLUDES_DEFAULT

opal/datatype/opal_convertor.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,9 @@ size_t opal_convertor_compute_remote_size( opal_convertor_t* pConvertor )
481481
pConvertor->remote_size = pConvertor->local_size;
482482
if( OPAL_UNLIKELY(datatype->bdt_used & pConvertor->master->hetero_mask) ) {
483483
pConvertor->flags &= (~CONVERTOR_HOMOGENEOUS);
484-
pConvertor->use_desc = &(datatype->desc);
484+
if (!(pConvertor->flags & CONVERTOR_SEND && pConvertor->flags & OPAL_DATATYPE_FLAG_CONTIGUOUS)) {
485+
pConvertor->use_desc = &(datatype->desc);
486+
}
485487
if( 0 == (pConvertor->flags & CONVERTOR_HAS_REMOTE_SIZE) ) {
486488
/* This is for a single datatype, we must update it with the count */
487489
pConvertor->remote_size = opal_datatype_compute_remote_size(datatype,
@@ -570,6 +572,7 @@ int32_t opal_convertor_prepare_for_recv( opal_convertor_t* convertor,
570572
mca_cuda_convertor_init(convertor, pUserBuf);
571573
#endif
572574

575+
assert(! (convertor->flags & CONVERTOR_SEND));
573576
OPAL_CONVERTOR_PREPARE( convertor, datatype, count, pUserBuf );
574577

575578
if( convertor->flags & CONVERTOR_WITH_CHECKSUM ) {

opal/datatype/opal_convertor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ static inline void opal_convertor_get_unpacked_size( const opal_convertor_t* pCo
218218
return;
219219
}
220220
if( 0 == (CONVERTOR_HAS_REMOTE_SIZE & pConv->flags) ) {
221+
assert(! (pConv->flags & CONVERTOR_SEND));
221222
opal_convertor_compute_remote_size( (opal_convertor_t*)pConv);
222223
}
223224
*pSize = pConv->remote_size;

opal/datatype/opal_copy_functions_heterogeneous.c

Lines changed: 88 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* reserved.
66
* Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
77
* Copyright (c) 2015-2017 Research Organization for Information Science
8+
* Copyright (c) 2015-2017 Research Organization for Information Science
89
* and Technology (RIST). All rights reserved.
910
* $COPYRIGHT$
1011
*
@@ -15,6 +16,10 @@
1516

1617
#include "opal_config.h"
1718

19+
#ifdef HAVE_IEEE754_H
20+
#include <ieee754.h>
21+
#endif
22+
1823
#include <stddef.h>
1924
#include <stdint.h>
2025

@@ -62,13 +67,78 @@ opal_dt_swap_bytes(void *to_p, const void *from_p, const size_t size, size_t cou
6267
}
6368
}
6469

70+
#ifdef HAVE_IEEE754_H
71+
struct bit128 {
72+
unsigned int mantissa3:32;
73+
unsigned int mantissa2:32;
74+
unsigned int mantissa1:32;
75+
unsigned int mantissa0:16;
76+
unsigned int exponent:15;
77+
unsigned int negative:1;
78+
};
79+
80+
struct bit80 {
81+
unsigned int pad:32;
82+
unsigned int empty:16;
83+
unsigned int negative:1;
84+
unsigned int exponent:15;
85+
unsigned int mantissa0:32;
86+
unsigned int mantissa1:32;
87+
};
88+
89+
static inline void
90+
opal_dt_swap_long_double(void *to_p, const void *from_p, const size_t size, size_t count, uint32_t remoteArch)
91+
{
92+
#ifdef HAVE_IEEE754_H
93+
size_t i;
94+
long double*to = (long double *) to_p;
95+
96+
if ((opal_local_arch&OPAL_ARCH_LDISINTEL) && !(remoteArch&OPAL_ARCH_LDISINTEL)) {
97+
#ifdef __x86_64
98+
for (i=0; i<count; i++, to++) {
99+
union ieee854_long_double ld;
100+
struct bit128 * b = (struct bit128 *)to;
101+
ld.ieee.empty = 0;
102+
ld.ieee.mantissa0 = 0x80000000 | (((unsigned int)b->mantissa0 << 15) & 0x7FFF8000) | ((b->mantissa1 >> 17) & 0x00007FFF);
103+
ld.ieee.mantissa1 = ((b->mantissa1 << 15) & 0xFFFF8000) | ((b->mantissa2 << 17) & 0x000007FFF);
104+
ld.ieee.exponent = b->exponent;
105+
ld.ieee.negative = b->negative;
106+
MEMCPY( to, &ld, sizeof(long double));
107+
}
108+
#endif
109+
} else if (!(opal_local_arch&OPAL_ARCH_LDISINTEL) && (remoteArch&OPAL_ARCH_LDISINTEL)) {
110+
#ifdef __sparcv9
111+
for (i=0; i<count; i++, to++) {
112+
union ieee854_long_double ld;
113+
struct bit80 * b = (struct bit80 *)to;
114+
ld.ieee.mantissa3 = 0;
115+
ld.ieee.mantissa2 = 0;
116+
ld.ieee.mantissa0 = (b->mantissa0 << 1) | (b->mantissa1 & 0x80000000);
117+
ld.ieee.mantissa1 = (b->mantissa1 << 1) & 0xFFFFFFFE;
118+
ld.ieee.exponent = b->exponent;
119+
ld.ieee.negative = b->negative;
120+
MEMCPY( to, &ld, sizeof(long double));
121+
}
122+
#endif
123+
}
124+
#else
125+
assert(0);
126+
#endif
127+
}
128+
#else
129+
#define opal_dt_swap_long_double(to_p, from_p, size, count, remoteArch)
130+
#endif
131+
65132
/**
66133
* BEWARE: Do not use the following macro with composed types such as
67134
* complex. As the swap is done using the entire type sizeof, the
68135
* wrong endianess translation will be done. Instead, use the
69136
* COPY_2SAMETYPE_HETEROGENEOUS.
70137
*/
71138
#define COPY_TYPE_HETEROGENEOUS( TYPENAME, TYPE ) \
139+
COPY_TYPE_HETEROGENEOUS_INTERNAL( TYPENAME, TYPE, 0 )
140+
141+
#define COPY_TYPE_HETEROGENEOUS_INTERNAL( TYPENAME, TYPE, LONG_DOUBLE ) \
72142
static int32_t \
73143
copy_##TYPENAME##_heterogeneous(opal_convertor_t *pConvertor, uint32_t count, \
74144
const char* from, size_t from_len, ptrdiff_t from_extent, \
@@ -85,9 +155,15 @@ copy_##TYPENAME##_heterogeneous(opal_convertor_t *pConvertor, uint32_t count,
85155
(opal_local_arch & OPAL_ARCH_ISBIGENDIAN)) { \
86156
if( (to_extent == from_extent) && (to_extent == sizeof(TYPE)) ) { \
87157
opal_dt_swap_bytes(to, from, sizeof(TYPE), count); \
158+
if (LONG_DOUBLE) { \
159+
opal_dt_swap_long_double(to, from, sizeof(TYPE), count, pConvertor->remoteArch);\
160+
} \
88161
} else { \
89162
for( i = 0; i < count; i++ ) { \
90163
opal_dt_swap_bytes(to, from, sizeof(TYPE), 1); \
164+
if (LONG_DOUBLE) { \
165+
opal_dt_swap_long_double(to, from, sizeof(TYPE), 1, pConvertor->remoteArch);\
166+
} \
91167
to += to_extent; \
92168
from += from_extent; \
93169
} \
@@ -108,6 +184,9 @@ copy_##TYPENAME##_heterogeneous(opal_convertor_t *pConvertor, uint32_t count,
108184
}
109185

110186
#define COPY_2SAMETYPE_HETEROGENEOUS( TYPENAME, TYPE ) \
187+
COPY_2SAMETYPE_HETEROGENEOUS_INTERNAL( TYPENAME, TYPE, 0)
188+
189+
#define COPY_2SAMETYPE_HETEROGENEOUS_INTERNAL( TYPENAME, TYPE, LONG_DOUBLE) \
111190
static int32_t \
112191
copy_##TYPENAME##_heterogeneous(opal_convertor_t *pConvertor, uint32_t count, \
113192
const char* from, size_t from_len, ptrdiff_t from_extent, \
@@ -122,11 +201,17 @@ copy_##TYPENAME##_heterogeneous(opal_convertor_t *pConvertor, uint32_t count,
122201
\
123202
if ((pConvertor->remoteArch & OPAL_ARCH_ISBIGENDIAN) != \
124203
(opal_local_arch & OPAL_ARCH_ISBIGENDIAN)) { \
125-
if( (to_extent == from_extent) && (to_extent == sizeof(TYPE)) ) { \
204+
if( (to_extent == from_extent) && (to_extent == (2 * sizeof(TYPE))) ) { \
126205
opal_dt_swap_bytes(to, from, sizeof(TYPE), 2 * count); \
206+
if (LONG_DOUBLE) { \
207+
opal_dt_swap_long_double(to, from, sizeof(TYPE), 2*count, pConvertor->remoteArch);\
208+
} \
127209
} else { \
128210
for( i = 0; i < count; i++ ) { \
129211
opal_dt_swap_bytes(to, from, sizeof(TYPE), 2); \
212+
if (LONG_DOUBLE) { \
213+
opal_dt_swap_long_double(to, from, sizeof(TYPE), 2, pConvertor->remoteArch);\
214+
} \
130215
to += to_extent; \
131216
from += from_extent; \
132217
} \
@@ -333,7 +418,7 @@ COPY_TYPE_HETEROGENEOUS( float16, float )
333418
#elif SIZEOF_DOUBLE == 16
334419
COPY_TYPE_HETEROGENEOUS( float16, double )
335420
#elif HAVE_LONG_DOUBLE && SIZEOF_LONG_DOUBLE == 16
336-
COPY_TYPE_HETEROGENEOUS( float16, long double )
421+
COPY_TYPE_HETEROGENEOUS_INTERNAL( float16, long double, 1)
337422
#else
338423
/* #error No basic type for copy function for opal_datatype_float16 found */
339424
#define copy_float16_heterogeneous NULL
@@ -354,7 +439,7 @@ COPY_2SAMETYPE_HETEROGENEOUS( double_complex, double )
354439
#endif
355440

356441
#if HAVE_LONG_DOUBLE__COMPLEX
357-
COPY_2SAMETYPE_HETEROGENEOUS( long_double_complex, long double )
442+
COPY_2SAMETYPE_HETEROGENEOUS_INTERNAL( long_double_complex, long double, 1)
358443
#else
359444
/* #error No basic type for copy function for opal_datatype_long_double_complex found */
360445
#define copy_long_double_complex_heterogeneous NULL

opal/datatype/opal_datatype_fake_stack.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ int opal_convertor_create_stack_with_pos_general( opal_convertor_t* pConvertor,
9191
}
9292

9393
/* remove from the main loop all the complete datatypes */
94+
assert (! (pConvertor->flags & CONVERTOR_SEND));
9495
remote_size = opal_convertor_compute_remote_size( pConvertor );
9596
count = (int32_t)(starting_point / remote_size);
9697
resting_place -= (remote_size * count);

opal/mca/btl/tcp/btl_tcp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* All rights reserved.
1313
* Copyright (c) 2006-2015 Los Alamos National Security, LLC. All rights
1414
* reserved.
15-
* Copyright (c) 2016 Research Organization for Information Science
15+
* Copyright (c) 2016-2017 Research Organization for Information Science
1616
* and Technology (RIST). All rights reserved.
1717
* Copyright (c) 2016 Intel, Inc. All rights reserved.
1818
*
@@ -381,6 +381,7 @@ int mca_btl_tcp_put (mca_btl_base_module_t *btl, struct mca_btl_base_endpoint_t
381381

382382
frag->segments[1].seg_addr.lval = remote_address;
383383
frag->segments[1].seg_len = size;
384+
if (endpoint->endpoint_nbo) MCA_BTL_BASE_SEGMENT_HTON(frag->segments[1]);
384385

385386
frag->base.des_flags = MCA_BTL_DES_FLAGS_BTL_OWNERSHIP | MCA_BTL_DES_SEND_ALWAYS_CALLBACK;
386387
frag->base.des_cbfunc = fake_rdma_complete;

opal/mca/btl/tcp/btl_tcp_frag.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* All rights reserved.
1313
* Copyright (c) 2014 Los Alamos National Security, LLC. All rights
1414
* reserved.
15-
* Copyright (c) 2015-2016 Research Organization for Information Science
15+
* Copyright (c) 2015-2017 Research Organization for Information Science
1616
* and Technology (RIST). All rights reserved.
1717
* Copyright (c) 2015-2016 Cisco Systems, Inc. All rights reserved.
1818
* $COPYRIGHT$
@@ -291,6 +291,7 @@ bool mca_btl_tcp_frag_recv(mca_btl_tcp_frag_t* frag, int sd)
291291
goto repeat;
292292
} else if (frag->iov_idx == 2) {
293293
for( i = 0; i < frag->hdr.count; i++ ) {
294+
if (btl_endpoint->endpoint_nbo) MCA_BTL_BASE_SEGMENT_NTOH(frag->segments[i]);
294295
frag->iov[i+2].iov_base = (IOVBASE_TYPE*)frag->segments[i].seg_addr.pval;
295296
frag->iov[i+2].iov_len = frag->segments[i].seg_len;
296297
}

orte/mca/oob/tcp/oob_tcp_hdr.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
* All rights reserved.
1414
* Copyright (c) 2010-2011 Cisco Systems, Inc. All rights reserved.
1515
* Copyright (c) 2014-2017 Intel, Inc. All rights reserved.
16+
* Copyright (c) 2017 Research Organization for Information Science
17+
* and Technology (RIST). All rights reserved.
1618
*
1719
* $COPYRIGHT$
1820
*
@@ -32,12 +34,12 @@
3234
* the message came from an external (to
3335
* this component) source
3436
*/
35-
typedef enum {
36-
MCA_OOB_TCP_IDENT,
37-
MCA_OOB_TCP_PROBE,
38-
MCA_OOB_TCP_PING,
39-
MCA_OOB_TCP_USER
40-
} mca_oob_tcp_msg_type_t;
37+
typedef uint8_t mca_oob_tcp_msg_type_t;
38+
39+
#define MCA_OOB_TCP_IDENT 1
40+
#define MCA_OOB_TCP_PROBE 2
41+
#define MCA_OOB_TCP_PING 3
42+
#define MCA_OOB_TCP_USER 4
4143

4244
#define ORTE_MAX_RTD_SIZE 31
4345

@@ -54,14 +56,14 @@ typedef struct {
5456
* and let some other module try to send it
5557
*/
5658
orte_process_name_t dst;
57-
/* type of message */
58-
mca_oob_tcp_msg_type_t type;
5959
/* the rml tag where this message is headed */
6060
orte_rml_tag_t tag;
6161
/* the seq number of this message */
6262
uint32_t seq_num;
6363
/* number of bytes in message */
6464
uint32_t nbytes;
65+
/* type of message */
66+
mca_oob_tcp_msg_type_t type;
6567
/* routed module to be used */
6668
char routed[ORTE_MAX_RTD_SIZE+1];
6769
} mca_oob_tcp_hdr_t;
@@ -71,7 +73,6 @@ typedef struct {
7173
#define MCA_OOB_TCP_HDR_NTOH(h) \
7274
ORTE_PROCESS_NAME_NTOH((h)->origin); \
7375
ORTE_PROCESS_NAME_NTOH((h)->dst); \
74-
(h)->type = ntohl((h)->type); \
7576
(h)->tag = ORTE_RML_TAG_NTOH((h)->tag); \
7677
(h)->nbytes = ntohl((h)->nbytes);
7778

@@ -81,7 +82,6 @@ typedef struct {
8182
#define MCA_OOB_TCP_HDR_HTON(h) \
8283
ORTE_PROCESS_NAME_HTON((h)->origin); \
8384
ORTE_PROCESS_NAME_HTON((h)->dst); \
84-
(h)->type = htonl((h)->type); \
8585
(h)->tag = ORTE_RML_TAG_HTON((h)->tag); \
8686
(h)->nbytes = htonl((h)->nbytes);
8787

0 commit comments

Comments
 (0)