opal/datatype: Add opal_short_float_t
The type `short float`, which is proposed in ISO/IEC JTC 1/SC 22 WG 14 (C WG), is not supported by most compilers yet. But some compilers (including gcc 7 for AArch64 and clang 6) support `_Float16`, which is defined in ISO/IEC TS 18661-3:2015 (ISO/IEC JTC 1/SC 22/WG 14 N1945) as an extensions for C. If it is detected in `configure`, it is used as an alternate type of `short float` in Open MPI internal code. This commit adds a `configure` option `--enable-alt-short-float=TYPE`. It can be used to specify a type other than `short float` and `_Float16` as the alternate type. Signed-off-by: KAWASHIMA Takahiro <t-kawashima@jp.fujitsu.com>
Этот коммит содержится в:
родитель
f6b39452f6
Коммит
2ad1c09848
55
config/opal_check_alt_short_float.m4
Обычный файл
55
config/opal_check_alt_short_float.m4
Обычный файл
@ -0,0 +1,55 @@
|
||||
dnl -*- shell-script -*-
|
||||
dnl
|
||||
dnl Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
|
||||
dnl $COPYRIGHT$
|
||||
dnl
|
||||
dnl Additional copyrights may follow
|
||||
dnl
|
||||
dnl $HEADER$
|
||||
dnl
|
||||
|
||||
# Check whether the user wants to use an alternate type of C 'short float'.
|
||||
|
||||
# OPAL_CHECK_ALT_SHORT_FLOAT
|
||||
# ------------------------------------------------------------
|
||||
AC_DEFUN([OPAL_CHECK_ALT_SHORT_FLOAT], [
|
||||
AC_CHECK_TYPES(_Float16)
|
||||
AC_MSG_CHECKING([if want alternate C type of short float])
|
||||
AC_ARG_ENABLE(alt-short-float,
|
||||
AC_HELP_STRING([--enable-alt-short-float=TYPE],
|
||||
[Use an alternate C type TYPE of 'short float' if 'short float' is not available on the C compiler. 'short float' is a new C type proposed for the next C language standard in ISO/IEC JTC 1/SC 22 WG 14 (C WG). (default: "_Float16" if available, disabled otherwise)]))
|
||||
if test "$enable_alt_short_float" = "yes"; then
|
||||
AC_MSG_ERROR([--enable-alt-short-float must have an argument.])
|
||||
elif test "$enable_alt_short_float" = "no"; then
|
||||
:
|
||||
elif test "$enable_alt_short_float" != ""; then
|
||||
opal_short_float_type="$enable_alt_short_float"
|
||||
opal_short_float_complex_type="$enable_alt_short_float [[2]]"
|
||||
elif test "$ac_cv_type_short_float" = "yes" && \
|
||||
test "$ac_cv_type_short_float__Complex" = "yes"; then
|
||||
opal_short_float_type="short float"
|
||||
opal_short_float_complex_type="short float _Complex"
|
||||
elif test "$ac_cv_type__Float16" = "yes"; then
|
||||
opal_short_float_type="_Float16"
|
||||
opal_short_float_complex_type="_Float16 [[2]]"
|
||||
fi
|
||||
if test "$opal_short_float_type" != ""; then
|
||||
AC_MSG_RESULT([yes ($opal_short_float_type)])
|
||||
AC_CHECK_TYPES($opal_short_float_type, [opal_enable_short_float=1], [opal_enable_short_float=0])
|
||||
if test "$opal_enable_short_float" = 1; then
|
||||
AC_DEFINE_UNQUOTED(opal_short_float_t, [[$opal_short_float_type]],
|
||||
[User-selected alternate C type of short float])
|
||||
AC_DEFINE_UNQUOTED(opal_short_float_complex_t, [[$opal_short_float_complex_type]],
|
||||
[User-selected alternate C type of short float _Complex])
|
||||
AC_CHECK_TYPES(opal_short_float_t)
|
||||
AC_CHECK_TYPES(opal_short_float_complex_t)
|
||||
AC_CHECK_SIZEOF(opal_short_float_t)
|
||||
AC_CHECK_SIZEOF(opal_short_float_complex_t)
|
||||
OPAL_C_GET_ALIGNMENT(opal_short_float_t, OPAL_ALIGNMENT_OPAL_SHORT_FLOAT_T)
|
||||
elif test "$enable_alt_short_float" != ""; then
|
||||
AC_MSG_ERROR([Alternate C type of short float $opal_short_float_type requested but not available. Aborting])
|
||||
fi
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
])
|
@ -493,6 +493,12 @@ OPAL_C_GET_ALIGNMENT(long double _Complex, OPAL_ALIGNMENT_LONG_DOUBLE_COMPLEX)
|
||||
OPAL_C_GET_ALIGNMENT(void *, OPAL_ALIGNMENT_VOID_P)
|
||||
OPAL_C_GET_ALIGNMENT(size_t, OPAL_ALIGNMENT_SIZE_T)
|
||||
|
||||
#
|
||||
# Check for an alternate type of C 'short float'
|
||||
#
|
||||
|
||||
OPAL_CHECK_ALT_SHORT_FLOAT
|
||||
|
||||
#
|
||||
# Check for other compiler characteristics
|
||||
#
|
||||
|
@ -375,6 +375,8 @@ void ompi_info_do_config(bool want_all)
|
||||
opal_info_out_int("C long size", "compiler:c:sizeof:long", sizeof(long));
|
||||
#if defined(HAVE_SHORT_FLOAT)
|
||||
opal_info_out_int("C short float size", "compiler:c:sizeof:short_float", sizeof(short float));
|
||||
#elif defined(HAVE_OPAL_SHORT_FLOAT_T)
|
||||
opal_info_out_int("C short float size", "compiler:c:sizeof:short_float", sizeof(opal_short_float_t));
|
||||
#endif
|
||||
opal_info_out_int("C float size", "compiler:c:sizeof:float", sizeof(float));
|
||||
opal_info_out_int("C double size", "compiler:c:sizeof:double", sizeof(double));
|
||||
@ -392,6 +394,8 @@ void ompi_info_do_config(bool want_all)
|
||||
opal_info_out_int("C int align", "compiler:c:align:int", OPAL_ALIGNMENT_INT);
|
||||
#if defined(HAVE_SHORT_FLOAT)
|
||||
opal_info_out_int("C short float align", "compiler:c:align:short_float", OPAL_ALIGNMENT_SHORT_FLOAT);
|
||||
#elif defined(HAVE_OPAL_SHORT_FLOAT_T)
|
||||
opal_info_out_int("C short float align", "compiler:c:align:short_float", OPAL_ALIGNMENT_OPAL_SHORT_FLOAT_T);
|
||||
#endif
|
||||
opal_info_out_int("C float align", "compiler:c:align:float", OPAL_ALIGNMENT_FLOAT);
|
||||
opal_info_out_int("C double align", "compiler:c:align:double", OPAL_ALIGNMENT_DOUBLE);
|
||||
|
@ -158,6 +158,8 @@ COPY_TYPE( float_2, float, 1 )
|
||||
COPY_TYPE( float_2, double, 1 )
|
||||
#elif SIZEOF_LONG_DOUBLE == 2
|
||||
COPY_TYPE( float_2, long double, 1 )
|
||||
#elif defined(HAVE_OPAL_SHORT_FLOAT_T) && SIZEOF_OPAL_SHORT_FLOAT_T == 2
|
||||
COPY_TYPE( float_2, opal_short_float_t, 1 )
|
||||
#else
|
||||
/* #error No basic type for copy function for opal_datatype_float2 found */
|
||||
#define copy_float_2 NULL
|
||||
@ -171,6 +173,8 @@ COPY_TYPE( float_4, float, 1 )
|
||||
COPY_TYPE( float_4, double, 1 )
|
||||
#elif SIZEOF_LONG_DOUBLE == 4
|
||||
COPY_TYPE( float_4, long double, 1 )
|
||||
#elif defined(HAVE_OPAL_SHORT_FLOAT_T) && SIZEOF_OPAL_SHORT_FLOAT_T == 4
|
||||
COPY_TYPE( float_4, opal_short_float_t, 1 )
|
||||
#else
|
||||
#error No basic type for copy function for opal_datatype_float4 found
|
||||
#endif
|
||||
@ -183,6 +187,8 @@ COPY_TYPE( float_8, float, 1 )
|
||||
COPY_TYPE( float_8, double, 1 )
|
||||
#elif SIZEOF_LONG_DOUBLE == 8
|
||||
COPY_TYPE( float_8, long double, 1 )
|
||||
#elif defined(HAVE_OPAL_SHORT_FLOAT_T) && SIZEOF_OPAL_SHORT_FLOAT_T == 8
|
||||
COPY_TYPE( float_8, opal_short_float_t, 1 )
|
||||
#else
|
||||
#error No basic type for copy function for opal_datatype_float8 found
|
||||
#endif
|
||||
@ -195,6 +201,8 @@ COPY_TYPE( float_12, float, 1 )
|
||||
COPY_TYPE( float_12, double, 1 )
|
||||
#elif SIZEOF_LONG_DOUBLE == 12
|
||||
COPY_TYPE( float_12, long double, 1 )
|
||||
#elif defined(HAVE_OPAL_SHORT_FLOAT_T) && SIZEOF_OPAL_SHORT_FLOAT_T == 12
|
||||
COPY_TYPE( float_12, opal_short_float_t, 1 )
|
||||
#else
|
||||
/* #error No basic type for copy function for opal_datatype_float12 found */
|
||||
#define copy_float_12 NULL
|
||||
@ -208,6 +216,8 @@ COPY_TYPE( float_16, float, 1 )
|
||||
COPY_TYPE( float_16, double, 1 )
|
||||
#elif SIZEOF_LONG_DOUBLE == 16
|
||||
COPY_TYPE( float_16, long double, 1 )
|
||||
#elif defined(HAVE_OPAL_SHORT_FLOAT_T) && SIZEOF_OPAL_SHORT_FLOAT_T == 16
|
||||
COPY_TYPE( float_16, opal_short_float_t, 1 )
|
||||
#else
|
||||
/* #error No basic type for copy function for opal_datatype_float16 found */
|
||||
#define copy_float_16 NULL
|
||||
@ -215,6 +225,8 @@ COPY_TYPE( float_16, long double, 1 )
|
||||
|
||||
#if defined(HAVE_SHORT_FLOAT__COMPLEX)
|
||||
COPY_TYPE ( short_float_complex, short float _Complex, 1)
|
||||
#elif defined(HAVE_OPAL_SHORT_FLOAT_COMPLEX_T)
|
||||
COPY_TYPE ( short_float_complex, opal_short_float_complex_t, 1)
|
||||
#else
|
||||
/* #error No basic type for copy function for opal_datatype_short_float_complex found */
|
||||
#define copy_short_float_complex NULL
|
||||
|
@ -375,6 +375,8 @@ COPY_TYPE_HETEROGENEOUS( float2, float )
|
||||
COPY_TYPE_HETEROGENEOUS( float2, double )
|
||||
#elif SIZEOF_LONG_DOUBLE == 2
|
||||
COPY_TYPE_HETEROGENEOUS( float2, long double )
|
||||
#elif defined(HAVE_OPAL_SHORT_FLOAT_T) && SIZEOF_OPAL_SHORT_FLOAT_T == 2
|
||||
COPY_TYPE_HETEROGENEOUS( float2, opal_short_float_t )
|
||||
#else
|
||||
/* #error No basic type for copy function for opal_datatype_float2 found */
|
||||
#define copy_float2_heterogeneous NULL
|
||||
@ -388,6 +390,8 @@ COPY_TYPE_HETEROGENEOUS( float4, float )
|
||||
COPY_TYPE_HETEROGENEOUS( float4, double )
|
||||
#elif SIZEOF_LONG_DOUBLE == 4
|
||||
COPY_TYPE_HETEROGENEOUS( float4, long double )
|
||||
#elif defined(HAVE_OPAL_SHORT_FLOAT_T) && SIZEOF_OPAL_SHORT_FLOAT_T == 4
|
||||
COPY_TYPE_HETEROGENEOUS( float4, opal_short_float_t )
|
||||
#else
|
||||
/* #error No basic type for copy function for opal_datatype_float4 found */
|
||||
#define copy_float4_heterogeneous NULL
|
||||
@ -401,6 +405,8 @@ COPY_TYPE_HETEROGENEOUS( float8, float )
|
||||
COPY_TYPE_HETEROGENEOUS( float8, double )
|
||||
#elif SIZEOF_LONG_DOUBLE == 8
|
||||
COPY_TYPE_HETEROGENEOUS( float8, long double )
|
||||
#elif defined(HAVE_OPAL_SHORT_FLOAT_T) && SIZEOF_OPAL_SHORT_FLOAT_T == 8
|
||||
COPY_TYPE_HETEROGENEOUS( float8, opal_short_float_t )
|
||||
#else
|
||||
/* #error No basic type for copy function for opal_datatype_float8 found */
|
||||
#define copy_float8_heterogeneous NULL
|
||||
@ -414,6 +420,8 @@ COPY_TYPE_HETEROGENEOUS( float12, float )
|
||||
COPY_TYPE_HETEROGENEOUS( float12, double )
|
||||
#elif SIZEOF_LONG_DOUBLE == 12
|
||||
COPY_TYPE_HETEROGENEOUS( float12, long double )
|
||||
#elif defined(HAVE_OPAL_SHORT_FLOAT_T) && SIZEOF_OPAL_SHORT_FLOAT_T == 12
|
||||
COPY_TYPE_HETEROGENEOUS( float12, opal_short_float_t )
|
||||
#else
|
||||
/* #error No basic type for copy function for opal_datatype_float12 found */
|
||||
#define copy_float12_heterogeneous NULL
|
||||
@ -427,6 +435,8 @@ COPY_TYPE_HETEROGENEOUS( float16, float )
|
||||
COPY_TYPE_HETEROGENEOUS( float16, double )
|
||||
#elif SIZEOF_LONG_DOUBLE == 16
|
||||
COPY_TYPE_HETEROGENEOUS_INTERNAL( float16, long double, 1)
|
||||
#elif defined(HAVE_OPAL_SHORT_FLOAT_T) && SIZEOF_OPAL_SHORT_FLOAT_T == 16
|
||||
COPY_TYPE_HETEROGENEOUS( float16, opal_short_float_t )
|
||||
#else
|
||||
/* #error No basic type for copy function for opal_datatype_float16 found */
|
||||
#define copy_float16_heterogeneous NULL
|
||||
@ -434,6 +444,8 @@ COPY_TYPE_HETEROGENEOUS_INTERNAL( float16, long double, 1)
|
||||
|
||||
#if defined(HAVE_SHORT_FLOAT__COMPLEX)
|
||||
COPY_2SAMETYPE_HETEROGENEOUS( short_float_complex, short float _Complex )
|
||||
#elif defined(HAVE_OPAL_SHORT_FLOAT_COMPLEX_T)
|
||||
COPY_2SAMETYPE_HETEROGENEOUS( short_float_complex, opal_short_float_complex_t )
|
||||
#else
|
||||
/* #error No basic type for copy function for opal_datatype_short_float_complex found */
|
||||
#define copy_short_float_complex_heterogeneous NULL
|
||||
|
@ -361,6 +361,8 @@ struct opal_datatype_t;
|
||||
#define OPAL_DATATYPE_INITIALIZER_FLOAT2(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( double, OPAL_ALIGNMENT_DOUBLE, FLOAT2, FLAGS )
|
||||
#elif SIZEOF_LONG_DOUBLE == 2
|
||||
#define OPAL_DATATYPE_INITIALIZER_FLOAT2(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( long double, OPAL_ALIGNMENT_LONG_DOUBLE, FLOAT2, FLAGS )
|
||||
#elif defined(HAVE_OPAL_SHORT_FLOAT_T) && SIZEOF_OPAL_SHORT_FLOAT_T == 2
|
||||
#define OPAL_DATATYPE_INITIALIZER_FLOAT2(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( opal_short_float_t, OPAL_ALIGNMENT_OPAL_SHORT_FLOAT_T, FLOAT2, FLAGS )
|
||||
#else
|
||||
#define OPAL_DATATYPE_INITIALIZER_FLOAT2(FLAGS) OPAL_DATATYPE_INITIALIZER_UNAVAILABLE_NAMED( FLOAT2, FLAGS )
|
||||
#endif
|
||||
@ -373,6 +375,8 @@ struct opal_datatype_t;
|
||||
#define OPAL_DATATYPE_INITIALIZER_FLOAT4(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( double, OPAL_ALIGNMENT_DOUBLE, FLOAT4, FLAGS )
|
||||
#elif SIZEOF_LONG_DOUBLE == 4
|
||||
#define OPAL_DATATYPE_INITIALIZER_FLOAT4(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( long double, OPAL_ALIGNMENT_LONG_DOUBLE, FLOAT4, FLAGS )
|
||||
#elif defined(HAVE_OPAL_SHORT_FLOAT_T) && SIZEOF_OPAL_SHORT_FLOAT_T == 4
|
||||
#define OPAL_DATATYPE_INITIALIZER_FLOAT4(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( opal_short_float_t, OPAL_ALIGNMENT_OPAL_SHORT_FLOAT_T, FLOAT4, FLAGS )
|
||||
#else
|
||||
#define OPAL_DATATYPE_INITIALIZER_FLOAT4(FLAGS) OPAL_DATATYPE_INITIALIZER_UNAVAILABLE_NAMED( FLOAT4, FLAGS )
|
||||
#endif
|
||||
@ -385,6 +389,8 @@ struct opal_datatype_t;
|
||||
#define OPAL_DATATYPE_INITIALIZER_FLOAT8(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( double, OPAL_ALIGNMENT_DOUBLE, FLOAT8, FLAGS )
|
||||
#elif SIZEOF_LONG_DOUBLE == 8
|
||||
#define OPAL_DATATYPE_INITIALIZER_FLOAT8(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( long double, OPAL_ALIGNMENT_LONG_DOUBLE, FLOAT8, FLAGS )
|
||||
#elif defined(HAVE_OPAL_SHORT_FLOAT_T) && SIZEOF_OPAL_SHORT_FLOAT_T == 8
|
||||
#define OPAL_DATATYPE_INITIALIZER_FLOAT8(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( opal_short_float_t, OPAL_ALIGNMENT_OPAL_SHORT_FLOAT_T, FLOAT8, FLAGS )
|
||||
#else
|
||||
#define OPAL_DATATYPE_INITIALIZER_FLOAT8(FLAGS) OPAL_DATATYPE_INITIALIZER_UNAVAILABLE_NAMED( FLOAT8, FLAGS )
|
||||
#endif
|
||||
@ -397,6 +403,8 @@ struct opal_datatype_t;
|
||||
#define OPAL_DATATYPE_INITIALIZER_FLOAT12(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( double, OPAL_ALIGNMENT_DOUBLE, FLOAT12, FLAGS )
|
||||
#elif SIZEOF_LONG_DOUBLE == 12
|
||||
#define OPAL_DATATYPE_INITIALIZER_FLOAT12(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( long double, OPAL_ALIGNMENT_LONG_DOUBLE, FLOAT12, FLAGS )
|
||||
#elif defined(HAVE_OPAL_SHORT_FLOAT_T) && SIZEOF_OPAL_SHORT_FLOAT_T == 12
|
||||
#define OPAL_DATATYPE_INITIALIZER_FLOAT12(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( opal_short_float_t, OPAL_ALIGNMENT_OPAL_SHORT_FLOAT_T, FLOAT12, FLAGS )
|
||||
#else
|
||||
#define OPAL_DATATYPE_INITIALIZER_FLOAT12(FLAGS) OPAL_DATATYPE_INITIALIZER_UNAVAILABLE_NAMED( FLOAT12, FLAGS )
|
||||
#endif
|
||||
@ -409,12 +417,16 @@ struct opal_datatype_t;
|
||||
#define OPAL_DATATYPE_INITIALIZER_FLOAT16(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( double, OPAL_ALIGNMENT_DOUBLE, FLOAT16, FLAGS )
|
||||
#elif SIZEOF_LONG_DOUBLE == 16
|
||||
#define OPAL_DATATYPE_INITIALIZER_FLOAT16(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( long double, OPAL_ALIGNMENT_LONG_DOUBLE, FLOAT16, FLAGS )
|
||||
#elif defined(HAVE_OPAL_SHORT_FLOAT_T) && SIZEOF_OPAL_SHORT_FLOAT_T == 16
|
||||
#define OPAL_DATATYPE_INITIALIZER_FLOAT16(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( opal_short_float_t, OPAL_ALIGNMENT_OPAL_SHORT_FLOAT_T, FLOAT16, FLAGS )
|
||||
#else
|
||||
#define OPAL_DATATYPE_INITIALIZER_FLOAT16(FLAGS) OPAL_DATATYPE_INITIALIZER_UNAVAILABLE_NAMED( FLOAT16, FLAGS )
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_SHORT_FLOAT__COMPLEX)
|
||||
#define OPAL_DATATYPE_INITIALIZER_SHORT_FLOAT_COMPLEX(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( short float _Complex, OPAL_ALIGNMENT_SHORT_FLOAT_COMPLEX, SHORT_FLOAT_COMPLEX, FLAGS )
|
||||
#elif defined(HAVE_OPAL_SHORT_FLOAT_COMPLEX_T)
|
||||
#define OPAL_DATATYPE_INITIALIZER_SHORT_FLOAT_COMPLEX(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( opal_short_float_complex_t, OPAL_ALIGNMENT_OPAL_SHORT_FLOAT_T, SHORT_FLOAT_COMPLEX, FLAGS )
|
||||
#else
|
||||
#define OPAL_DATATYPE_INITIALIZER_SHORT_FLOAT_COMPLEX(FLAGS) OPAL_DATATYPE_INITIALIZER_UNAVAILABLE_NAMED( SHORT_FLOAT_COMPLEX, FLAGS)
|
||||
#endif
|
||||
|
@ -109,6 +109,8 @@ OPAL_DECLSPEC const size_t opal_datatype_local_sizes[OPAL_DATATYPE_MAX_PREDEFINE
|
||||
[OPAL_DATATYPE_FLOAT16] = 16, /* sizeof (float16) */
|
||||
#if defined(HAVE_SHORT_FLOAT__COMPLEX)
|
||||
[OPAL_DATATYPE_SHORT_FLOAT_COMPLEX] = sizeof(short float _Complex),
|
||||
#elif defined(HAVE_OPAL_SHORT_FLOAT_COMPLEX_T)
|
||||
[OPAL_DATATYPE_SHORT_FLOAT_COMPLEX] = sizeof(opal_short_float_complex_t),
|
||||
#else
|
||||
[OPAL_DATATYPE_SHORT_FLOAT_COMPLEX] = 4, /* typical sizeof(short float _Complex) */
|
||||
#endif
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user