Skip to content

Commit f6b3945

Browse files
committed
opal/datatype: Support short float
The type `short float` is proposed for the C language in ISO/IEC JTC 1/SC 22 WG 14 (C WG) for mainly IEEE 754-2008 binary16, a.k.a. half-precision floating point or FP16. By this commit, `short float` and `short float _Complex` are detected in `configure` and used in Open MPI internal code. `MPI_SHORT_FLOAT` and its complex number version are not added yet. This commit changes values of existing `OPAL_DATATYPE_*` macros. This change does not affect ABI compatibility of `libmpi.so` and the like because these values are only used in OPAL and OMPI internal code. Signed-off-by: KAWASHIMA Takahiro <t-kawashima@jp.fujitsu.com>
1 parent 2cf6944 commit f6b3945

File tree

8 files changed

+122
-30
lines changed

8 files changed

+122
-30
lines changed

configure.ac

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
# Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
2626
# Copyright (c) 2018 Amazon.com, Inc. or its affiliates.
2727
# All Rights reserved.
28+
# Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
2829
# $COPYRIGHT$
2930
#
3031
# Additional copyrights may follow
@@ -387,10 +388,12 @@ AC_CHECK_TYPES(uint128_t)
387388
AC_CHECK_TYPES(long long)
388389

389390
AC_CHECK_TYPES(__float128)
391+
AC_CHECK_TYPES(short float)
390392
AC_CHECK_TYPES(long double)
391393
# We only need these types if we're building the OMPI project, but
392394
# OPAL currently doesn't protect for their lack of presence well.
393395
AC_CHECK_HEADERS(complex.h)
396+
AC_CHECK_TYPES(short float _Complex)
394397
AC_CHECK_TYPES(float _Complex)
395398
AC_CHECK_TYPES(double _Complex)
396399
AC_CHECK_TYPES(long double _Complex)
@@ -411,6 +414,9 @@ AC_CHECK_SIZEOF(short)
411414
AC_CHECK_SIZEOF(int)
412415
AC_CHECK_SIZEOF(long)
413416
AC_CHECK_SIZEOF(long long)
417+
if test "$ac_cv_type_short_float" = yes; then
418+
AC_CHECK_SIZEOF(short float)
419+
fi
414420
AC_CHECK_SIZEOF(float)
415421
AC_CHECK_SIZEOF(double)
416422
AC_CHECK_SIZEOF(long double)
@@ -419,6 +425,9 @@ if test "$ac_cv_type___float128" = yes; then
419425
fi
420426
# We only need these types if we're building the OMPI project, but
421427
# OPAL currently doesn't protect for their lack of presence well.
428+
if test "$ac_cv_type_short_float__Complex" = yes; then
429+
AC_CHECK_SIZEOF(short float _Complex)
430+
fi
422431
AC_CHECK_SIZEOF(float _Complex)
423432
AC_CHECK_SIZEOF(double _Complex)
424433
AC_CHECK_SIZEOF(long double _Complex)
@@ -461,6 +470,9 @@ OPAL_C_GET_ALIGNMENT(wchar_t, OPAL_ALIGNMENT_WCHAR)
461470
OPAL_C_GET_ALIGNMENT(int, OPAL_ALIGNMENT_INT)
462471
OPAL_C_GET_ALIGNMENT(long, OPAL_ALIGNMENT_LONG)
463472
OPAL_C_GET_ALIGNMENT(long long, OPAL_ALIGNMENT_LONG_LONG)
473+
if test "$ac_cv_type_short_float" = yes; then
474+
OPAL_C_GET_ALIGNMENT(short float, OPAL_ALIGNMENT_SHORT_FLOAT)
475+
fi
464476
OPAL_C_GET_ALIGNMENT(float, OPAL_ALIGNMENT_FLOAT)
465477
OPAL_C_GET_ALIGNMENT(double, OPAL_ALIGNMENT_DOUBLE)
466478
OPAL_C_GET_ALIGNMENT(long double, OPAL_ALIGNMENT_LONG_DOUBLE)
@@ -471,6 +483,9 @@ fi
471483

472484
# We only need these types if we're building the OMPI project, but
473485
# OPAL currently doesn't protect for their lack of presence well.
486+
if test "$ac_cv_type_short_float__Complex" = yes; then
487+
OPAL_C_GET_ALIGNMENT(short float _Complex, OPAL_ALIGNMENT_SHORT_FLOAT_COMPLEX)
488+
fi
474489
OPAL_C_GET_ALIGNMENT(float _Complex, OPAL_ALIGNMENT_FLOAT_COMPLEX)
475490
OPAL_C_GET_ALIGNMENT(double _Complex, OPAL_ALIGNMENT_DOUBLE_COMPLEX)
476491
OPAL_C_GET_ALIGNMENT(long double _Complex, OPAL_ALIGNMENT_LONG_DOUBLE_COMPLEX)

ompi/mca/coll/hcoll/coll_hcoll_dtypes.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ extern mca_coll_hcoll_dtype_t zero_dte_mapping;
2727
#define OPAL_DATATYPE_FLOAT8 16
2828
#define OPAL_DATATYPE_FLOAT12 17
2929
#define OPAL_DATATYPE_FLOAT16 18
30-
#define OPAL_DATATYPE_FLOAT_COMPLEX 19
31-
#define OPAL_DATATYPE_DOUBLE_COMPLEX 20
30+
#define OPAL_DATATYPE_SHORT_FLOAT_COMPLEX 19
31+
#define OPAL_DATATYPE_FLOAT_COMPLEX 20
32+
#define OPAL_DATATYPE_DOUBLE_COMPLEX 21
3233
3334
total 15 types
3435
*/
@@ -61,32 +62,33 @@ static dte_data_representation_t* ompi_datatype_2_dte_data_rep[OMPI_DATATYPE_MAX
6162
&DTE_FLOAT64, /*OPAL_DATATYPE_FLOAT8 16 */
6263
&DTE_FLOAT96, /*OPAL_DATATYPE_FLOAT12 17 */
6364
&DTE_FLOAT128, /*OPAL_DATATYPE_FLOAT16 18 */
65+
&DTE_ZERO, /*OPAL_DATATYPE_SHORT_FLOAT_COMPLEX 19 */
6466
#if defined(DTE_FLOAT32_COMPLEX)
65-
&DTE_FLOAT32_COMPLEX, /*OPAL_DATATYPE_COMPLEX8 19 */
67+
&DTE_FLOAT32_COMPLEX, /*OPAL_DATATYPE_FLOAT_COMPLEX 20 */
6668
#else
6769
&DTE_ZERO,
6870
#endif
6971
#if defined(DTE_FLOAT64_COMPLEX)
70-
&DTE_FLOAT64_COMPLEX, /*OPAL_DATATYPE_COMPLEX32 20 */
72+
&DTE_FLOAT64_COMPLEX, /*OPAL_DATATYPE_DOUBLE_COMPLEX 21 */
7173
#else
7274
&DTE_ZERO,
7375
#endif
7476
#if defined(DTE_FLOAT128_COMPLEX)
75-
&DTE_FLOAT128_COMPLEX, /*OPAL_DATATYPE_COMPLEX64 21 */
77+
&DTE_FLOAT128_COMPLEX, /*OPAL_DATATYPE_LONG_DOUBLE_COMPLEX 22 */
7678
#else
7779
&DTE_ZERO,
7880
#endif
7981
#if defined(DTE_BOOL)
80-
&DTE_BOOL, /*OPAL_DATATYPE_BOOL 22 */
82+
&DTE_BOOL, /*OPAL_DATATYPE_BOOL 23 */
8183
#else
8284
&DTE_ZERO,
8385
#endif
8486
#if defined(DTE_WCHAR)
85-
&DTE_WCHAR, /*OPAL_DATATYPE_WCHAR 23 */
87+
&DTE_WCHAR, /*OPAL_DATATYPE_WCHAR 24 */
8688
#else
8789
&DTE_ZERO,
8890
#endif
89-
&DTE_ZERO /*OPAL_DATATYPE_UNAVAILABLE 24 */
91+
&DTE_ZERO /*OPAL_DATATYPE_UNAVAILABLE 25 */
9092
};
9193

9294
enum {

ompi/tools/ompi_info/param.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* and Technology (RIST). All rights reserved.
1616
* Copyright (c) 2015 Intel, Inc. All rights reserved
1717
* Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved.
18+
* Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
1819
* $COPYRIGHT$
1920
*
2021
* Additional copyrights may follow
@@ -372,8 +373,12 @@ void ompi_info_do_config(bool want_all)
372373
opal_info_out_int("C short size", "compiler:c:sizeof:short", sizeof(short));
373374
opal_info_out_int("C int size", "compiler:c:sizeof:int", sizeof(int));
374375
opal_info_out_int("C long size", "compiler:c:sizeof:long", sizeof(long));
376+
#if defined(HAVE_SHORT_FLOAT)
377+
opal_info_out_int("C short float size", "compiler:c:sizeof:short_float", sizeof(short float));
378+
#endif
375379
opal_info_out_int("C float size", "compiler:c:sizeof:float", sizeof(float));
376380
opal_info_out_int("C double size", "compiler:c:sizeof:double", sizeof(double));
381+
opal_info_out_int("C long double size", "compiler:c:sizeof:long_double", sizeof(long double));
377382
opal_info_out_int("C pointer size", "compiler:c:sizeof:pointer", sizeof(void *));
378383
opal_info_out_int("C char align", "compiler:c:align:char", OPAL_ALIGNMENT_CHAR);
379384
#if OMPI_BUILD_CXX_BINDINGS
@@ -385,8 +390,12 @@ void ompi_info_do_config(bool want_all)
385390
opal_info_out("C bool align", "compiler:c:align:bool", "skipped");
386391
#endif
387392
opal_info_out_int("C int align", "compiler:c:align:int", OPAL_ALIGNMENT_INT);
393+
#if defined(HAVE_SHORT_FLOAT)
394+
opal_info_out_int("C short float align", "compiler:c:align:short_float", OPAL_ALIGNMENT_SHORT_FLOAT);
395+
#endif
388396
opal_info_out_int("C float align", "compiler:c:align:float", OPAL_ALIGNMENT_FLOAT);
389397
opal_info_out_int("C double align", "compiler:c:align:double", OPAL_ALIGNMENT_DOUBLE);
398+
opal_info_out_int("C long double align", "compiler:c:align:long_double", OPAL_ALIGNMENT_LONG_DOUBLE);
390399
}
391400

392401
opal_info_out("C++ compiler", "compiler:cxx:command", OMPI_CXX);

opal/datatype/opal_copy_functions.c

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Copyright (c) 2015-2018 Research Organization for Information Science
88
* and Technology (RIST). All rights reserved.
99
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
10+
* Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
1011
* $COPYRIGHT$
1112
*
1213
* Additional copyrights may follow
@@ -149,7 +150,9 @@ COPY_CONTIGUOUS_BYTES( bytes, 8 )
149150
COPY_CONTIGUOUS_BYTES( bytes, 16 )
150151
#endif
151152

152-
#if SIZEOF_FLOAT == 2
153+
#if defined(HAVE_SHORT_FLOAT) && SIZEOF_SHORT_FLOAT == 2
154+
COPY_TYPE( float_2, short float, 1 )
155+
#elif SIZEOF_FLOAT == 2
153156
COPY_TYPE( float_2, float, 1 )
154157
#elif SIZEOF_DOUBLE == 2
155158
COPY_TYPE( float_2, double, 1 )
@@ -160,7 +163,9 @@ COPY_TYPE( float_2, long double, 1 )
160163
#define copy_float_2 NULL
161164
#endif
162165

163-
#if SIZEOF_FLOAT == 4
166+
#if defined(HAVE_SHORT_FLOAT) && SIZEOF_SHORT_FLOAT == 4
167+
COPY_TYPE( float_4, short float, 1 )
168+
#elif SIZEOF_FLOAT == 4
164169
COPY_TYPE( float_4, float, 1 )
165170
#elif SIZEOF_DOUBLE == 4
166171
COPY_TYPE( float_4, double, 1 )
@@ -170,7 +175,9 @@ COPY_TYPE( float_4, long double, 1 )
170175
#error No basic type for copy function for opal_datatype_float4 found
171176
#endif
172177

173-
#if SIZEOF_FLOAT == 8
178+
#if defined(HAVE_SHORT_FLOAT) && SIZEOF_SHORT_FLOAT == 8
179+
COPY_TYPE( float_8, short float, 1 )
180+
#elif SIZEOF_FLOAT == 8
174181
COPY_TYPE( float_8, float, 1 )
175182
#elif SIZEOF_DOUBLE == 8
176183
COPY_TYPE( float_8, double, 1 )
@@ -180,7 +187,9 @@ COPY_TYPE( float_8, long double, 1 )
180187
#error No basic type for copy function for opal_datatype_float8 found
181188
#endif
182189

183-
#if SIZEOF_FLOAT == 12
190+
#if defined(HAVE_SHORT_FLOAT) && SIZEOF_SHORT_FLOAT == 12
191+
COPY_TYPE( float_12, short float, 1 )
192+
#elif SIZEOF_FLOAT == 12
184193
COPY_TYPE( float_12, float, 1 )
185194
#elif SIZEOF_DOUBLE == 12
186195
COPY_TYPE( float_12, double, 1 )
@@ -191,7 +200,9 @@ COPY_TYPE( float_12, long double, 1 )
191200
#define copy_float_12 NULL
192201
#endif
193202

194-
#if SIZEOF_FLOAT == 16
203+
#if defined(HAVE_SHORT_FLOAT) && SIZEOF_SHORT_FLOAT == 16
204+
COPY_TYPE( float_16, short float, 1 )
205+
#elif SIZEOF_FLOAT == 16
195206
COPY_TYPE( float_16, float, 1 )
196207
#elif SIZEOF_DOUBLE == 16
197208
COPY_TYPE( float_16, double, 1 )
@@ -202,6 +213,13 @@ COPY_TYPE( float_16, long double, 1 )
202213
#define copy_float_16 NULL
203214
#endif
204215

216+
#if defined(HAVE_SHORT_FLOAT__COMPLEX)
217+
COPY_TYPE ( short_float_complex, short float _Complex, 1)
218+
#else
219+
/* #error No basic type for copy function for opal_datatype_short_float_complex found */
220+
#define copy_short_float_complex NULL
221+
#endif
222+
205223
COPY_TYPE ( float_complex, float _Complex, 1)
206224

207225
COPY_TYPE ( double_complex, double _Complex, 1)
@@ -245,6 +263,7 @@ conversion_fct_t opal_datatype_copy_functions[OPAL_DATATYPE_MAX_PREDEFINED] = {
245263
(conversion_fct_t)copy_float_8, /* OPAL_DATATYPE_FLOAT8 */
246264
(conversion_fct_t)copy_float_12, /* OPAL_DATATYPE_FLOAT12 */
247265
(conversion_fct_t)copy_float_16, /* OPAL_DATATYPE_FLOAT16 */
266+
(conversion_fct_t)copy_short_float_complex, /* OPAL_DATATYPE_SHORT_FLOAT_COMPLEX */
248267
(conversion_fct_t)copy_float_complex, /* OPAL_DATATYPE_FLOAT_COMPLEX */
249268
(conversion_fct_t)copy_double_complex, /* OPAL_DATATYPE_DOUBLE_COMPLEX */
250269
(conversion_fct_t)copy_long_double_complex, /* OPAL_DATATYPE_LONG_DOUBLE_COMPLEX */

opal/datatype/opal_copy_functions_heterogeneous.c

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
77
* Copyright (c) 2015-2018 Research Organization for Information Science
88
* and Technology (RIST). All rights reserved.
9+
* Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
910
* $COPYRIGHT$
1011
*
1112
* Additional copyrights may follow
@@ -366,7 +367,9 @@ COPY_TYPE_HETEROGENEOUS(int16, int128_t)
366367
#endif
367368

368369

369-
#if SIZEOF_FLOAT == 2
370+
#if defined(HAVE_SHORT_FLOAT) && SIZEOF_SHORT_FLOAT == 2
371+
COPY_TYPE_HETEROGENEOUS( float2, short float )
372+
#elif SIZEOF_FLOAT == 2
370373
COPY_TYPE_HETEROGENEOUS( float2, float )
371374
#elif SIZEOF_DOUBLE == 2
372375
COPY_TYPE_HETEROGENEOUS( float2, double )
@@ -377,7 +380,9 @@ COPY_TYPE_HETEROGENEOUS( float2, long double )
377380
#define copy_float2_heterogeneous NULL
378381
#endif
379382

380-
#if SIZEOF_FLOAT == 4
383+
#if defined(HAVE_SHORT_FLOAT) && SIZEOF_SHORT_FLOAT == 4
384+
COPY_TYPE_HETEROGENEOUS( float4, short float )
385+
#elif SIZEOF_FLOAT == 4
381386
COPY_TYPE_HETEROGENEOUS( float4, float )
382387
#elif SIZEOF_DOUBLE == 4
383388
COPY_TYPE_HETEROGENEOUS( float4, double )
@@ -388,7 +393,9 @@ COPY_TYPE_HETEROGENEOUS( float4, long double )
388393
#define copy_float4_heterogeneous NULL
389394
#endif
390395

391-
#if SIZEOF_FLOAT == 8
396+
#if defined(HAVE_SHORT_FLOAT) && SIZEOF_SHORT_FLOAT == 8
397+
COPY_TYPE_HETEROGENEOUS( float8, short float )
398+
#elif SIZEOF_FLOAT == 8
392399
COPY_TYPE_HETEROGENEOUS( float8, float )
393400
#elif SIZEOF_DOUBLE == 8
394401
COPY_TYPE_HETEROGENEOUS( float8, double )
@@ -399,7 +406,9 @@ COPY_TYPE_HETEROGENEOUS( float8, long double )
399406
#define copy_float8_heterogeneous NULL
400407
#endif
401408

402-
#if SIZEOF_FLOAT == 12
409+
#if defined(HAVE_SHORT_FLOAT) && SIZEOF_SHORT_FLOAT == 12
410+
COPY_TYPE_HETEROGENEOUS( float12, short float )
411+
#elif SIZEOF_FLOAT == 12
403412
COPY_TYPE_HETEROGENEOUS( float12, float )
404413
#elif SIZEOF_DOUBLE == 12
405414
COPY_TYPE_HETEROGENEOUS( float12, double )
@@ -410,7 +419,9 @@ COPY_TYPE_HETEROGENEOUS( float12, long double )
410419
#define copy_float12_heterogeneous NULL
411420
#endif
412421

413-
#if SIZEOF_FLOAT == 16
422+
#if defined(HAVE_SHORT_FLOAT) && SIZEOF_SHORT_FLOAT == 16
423+
COPY_TYPE_HETEROGENEOUS( float16, short float )
424+
#elif SIZEOF_FLOAT == 16
414425
COPY_TYPE_HETEROGENEOUS( float16, float )
415426
#elif SIZEOF_DOUBLE == 16
416427
COPY_TYPE_HETEROGENEOUS( float16, double )
@@ -421,6 +432,13 @@ COPY_TYPE_HETEROGENEOUS_INTERNAL( float16, long double, 1)
421432
#define copy_float16_heterogeneous NULL
422433
#endif
423434

435+
#if defined(HAVE_SHORT_FLOAT__COMPLEX)
436+
COPY_2SAMETYPE_HETEROGENEOUS( short_float_complex, short float _Complex )
437+
#else
438+
/* #error No basic type for copy function for opal_datatype_short_float_complex found */
439+
#define copy_short_float_complex_heterogeneous NULL
440+
#endif
441+
424442
COPY_2SAMETYPE_HETEROGENEOUS( float_complex, float )
425443

426444
COPY_2SAMETYPE_HETEROGENEOUS( double_complex, double )
@@ -450,6 +468,7 @@ conversion_fct_t opal_datatype_heterogeneous_copy_functions[OPAL_DATATYPE_MAX_PR
450468
[OPAL_DATATYPE_FLOAT8] = (conversion_fct_t) copy_float8_heterogeneous,
451469
[OPAL_DATATYPE_FLOAT12] = (conversion_fct_t) copy_float12_heterogeneous,
452470
[OPAL_DATATYPE_FLOAT16] = (conversion_fct_t) copy_float16_heterogeneous,
471+
[OPAL_DATATYPE_SHORT_FLOAT_COMPLEX] = (conversion_fct_t) copy_short_float_complex_heterogeneous,
453472
[OPAL_DATATYPE_FLOAT_COMPLEX] = (conversion_fct_t) copy_float_complex_heterogeneous,
454473
[OPAL_DATATYPE_DOUBLE_COMPLEX] = (conversion_fct_t) copy_double_complex_heterogeneous,
455474
[OPAL_DATATYPE_LONG_DOUBLE_COMPLEX] = (conversion_fct_t) copy_long_double_complex_heterogeneous,

opal/datatype/opal_datatype.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* and Technology (RIST). All rights reserved.
1919
* Copyright (c) 2018 Triad National Security, LLC. All rights
2020
* reserved.
21+
* Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
2122
* $COPYRIGHT$
2223
*
2324
* Additional copyrights may follow
@@ -51,7 +52,7 @@ BEGIN_C_DECLS
5152
* This must match the same definition as in opal_datatype_internal.h
5253
*/
5354
#if !defined(OPAL_DATATYPE_MAX_PREDEFINED)
54-
#define OPAL_DATATYPE_MAX_PREDEFINED 25
55+
#define OPAL_DATATYPE_MAX_PREDEFINED 26
5556
#endif
5657
/*
5758
* No more than this number of _Basic_ datatypes in C/CPP or Fortran
@@ -170,6 +171,7 @@ OPAL_DECLSPEC extern const opal_datatype_t opal_datatype_float4; /* in bytes
170171
OPAL_DECLSPEC extern const opal_datatype_t opal_datatype_float8; /* in bytes */
171172
OPAL_DECLSPEC extern const opal_datatype_t opal_datatype_float12; /* in bytes */
172173
OPAL_DECLSPEC extern const opal_datatype_t opal_datatype_float16; /* in bytes */
174+
OPAL_DECLSPEC extern const opal_datatype_t opal_datatype_short_float_complex;
173175
OPAL_DECLSPEC extern const opal_datatype_t opal_datatype_float_complex;
174176
OPAL_DECLSPEC extern const opal_datatype_t opal_datatype_double_complex;
175177
OPAL_DECLSPEC extern const opal_datatype_t opal_datatype_long_double_complex;

0 commit comments

Comments
 (0)