From 0a3861b2287aa12c2b12c1118435a42e8a50f1dd Mon Sep 17 00:00:00 2001 From: Gilles Gouaillardet Date: Thu, 10 Apr 2025 15:02:30 +0900 Subject: [PATCH] configury: enhance short float detection with clang With clang, short float support requires --rtlib=compiler-rt to be passed to the linker. In order to avoid a false positive, it is necessary have the runtime called in the test program. The test program was hence updated with the function below that generates a call to the __extendhfsf2() runtime function. float extend (_Float16 v) { return (float)v; } Thanks Blaise Bourdin for reporting this. Refs: #13181 Signed-off-by: Gilles Gouaillardet --- config/opal_check_alt_short_float.m4 | 12 +++++++++--- ompi/mpiext/shortfloat/README.md | 6 ++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/config/opal_check_alt_short_float.m4 b/config/opal_check_alt_short_float.m4 index e7ff008ba6b..7f9b2fd9346 100644 --- a/config/opal_check_alt_short_float.m4 +++ b/config/opal_check_alt_short_float.m4 @@ -1,7 +1,9 @@ dnl -*- shell-script -*- dnl dnl Copyright (c) 2018-2021 FUJITSU LIMITED. All rights reserved. -dnl Copyright (c) 2020 Cisco Systems, Inc. All rights reserved. +dnl Copyright (c) 2020 Cisco Systems, Inc. All rights reserved. +dnl Copyright (c) 2025 Research Organization for Information Science +dnl and Technology (RIST). All rights reserved. dnl $COPYRIGHT$ dnl dnl Additional copyrights may follow @@ -50,8 +52,12 @@ AC_DEFUN([OPAL_CHECK_ALT_SHORT_FLOAT], [ AS_IF([test $opal_alt_short_float_exists -eq 1], [AC_MSG_CHECKING([if compiler supports arithmetic operations on $opal_short_float_type]) AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ -static $opal_short_float_type a = 2.5, b = 3.8; -a += b;]])], + static $opal_short_float_type a = 2.5, b = 3.8; + a += b; +} + +float extend ($opal_short_float_type v) { + return (float)v;]])], [AC_MSG_RESULT([yes]) opal_enable_short_float=1], [AC_MSG_RESULT([no]) diff --git a/ompi/mpiext/shortfloat/README.md b/ompi/mpiext/shortfloat/README.md index c41ac5941b9..d666734a021 100644 --- a/ompi/mpiext/shortfloat/README.md +++ b/ompi/mpiext/shortfloat/README.md @@ -25,11 +25,13 @@ to the Open MPI `configure` script. NOTE: The Clang 6.0.x and 7.0.x compilers support the `_Float16` type (via software emulation), but require an additional linker flag to function properly. If you wish to enable Clang 6.0.x or 7.0.x's -software emulation of `_Float16`, use the following CLI options to Open -MPI configure script: +software emulation of `_Float16`, or recent Clang, use the +following CLI options to Open MPI configure script: ``` ./configure \ LDFLAGS=--rtlib=compiler-rt \ --with-wrapper-ldflags=--rtlib=compiler-rt ... ``` +Depending on your `clang++` version/configuration, you might also have to add +`--stdlib=libc++` and/or `-lunwind`.