Skip to content

Commit 99a1c85

Browse files
committed
config: add SVE detection alongside NEON in aarch64 op component
- Introduce AC_CACHE_CHECK probes for ARM Scalable Vector Extension (SVE) using both a default compile test and a second test with __attribute__((__target__("+sve"))). - Define variables op_cv_sve_support and op_cv_sve_add_flags - Update AM_CONDITIONAL and AC_DEFINE to expose SVE support macros (OMPI_MCA_OP_HAVE_SVE, OMPI_MCA_OP_SVE_EXTRA_FLAGS). - Extend final AS_IF to enable the component when either NEON or SVE is available. Signed-off-by: Marco Vogel <marco.vogel@fernuni-hagen.de>
1 parent 08ac1be commit 99a1c85

File tree

1 file changed

+66
-19
lines changed

1 file changed

+66
-19
lines changed

ompi/mca/op/aarch64/configure.m4

Lines changed: 66 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# ------------------------------------------------
1818
AC_DEFUN([MCA_ompi_op_aarch64_CONFIG],[
1919
AC_CONFIG_FILES([ompi/mca/op/aarch64/Makefile])
20+
2021
case "${host}" in
2122
aarch64*|arm64*)
2223
op_aarch64_check="yes";;
@@ -71,49 +72,95 @@ AC_DEFUN([MCA_ompi_op_aarch64_CONFIG],[
7172
[op_cv_neon_fp_support=yes],
7273
[op_cv_neon_fp_support=no])])])
7374

74-
#
75+
76+
#
7577
# Check for SVE support
7678
#
77-
AC_CACHE_CHECK([for SVE support], op_cv_sve_support,
78-
[AS_IF([test "$op_cv_neon_support" = "yes"],
79-
[
80-
AC_LINK_IFELSE(
81-
[AC_LANG_PROGRAM([[
79+
AC_CACHE_CHECK([for SVE support], [op_cv_sve_support], [
80+
AC_MSG_RESULT([])
81+
# initialize result variables
82+
op_cv_sve_support=no
83+
op_cv_sve_add_flags=no
84+
85+
# first attempt: no extra flags
86+
AC_MSG_CHECKING([for SVE support (no additional flags)])
87+
AC_LINK_IFELSE(
88+
[AC_LANG_SOURCE([[
8289
#if defined(__aarch64__) && defined(__ARM_FEATURE_SVE)
83-
#include <arm_sve.h>
90+
#include <arm_sve.h>
8491
#else
85-
#error "No support for __aarch64__ or SVE"
92+
#error "No support for __aarch64__ or SVE"
8693
#endif
87-
]],
88-
[[
89-
#if defined(__aarch64__) && defined(_ARM_FEATURE_SVE)
90-
svfloat32_t vA;
91-
vA = svdup_n_f32(0)
94+
95+
int main(void) {
96+
svfloat32_t vA;
97+
vA = svdup_n_f32(0);
98+
return 0;
99+
}
100+
]])],
101+
[ op_cv_sve_support=yes
102+
AC_MSG_RESULT([yes]) ],
103+
[ AC_MSG_RESULT([no ]) ]
104+
)
105+
106+
# second attempt: use +sve attribute
107+
AS_IF([test "$op_cv_sve_support" = "no"],[
108+
AC_MSG_CHECKING([for SVE support (with +sve)])
109+
AC_LINK_IFELSE(
110+
[AC_LANG_SOURCE([[
111+
#if defined(__aarch64__)
112+
#include <arm_sve.h>
113+
#else
114+
#error "not on aarch64"
92115
#endif
93-
]])],
94-
[op_cv_sve_support=yes],
95-
[op_cv_sve_support=no])])])
96-
])
97116

117+
__attribute__((__target__("+sve")))
118+
int main(void) {
119+
svbool_t pg = svptrue_b32();
120+
svuint32_t a = svdup_u32(0);
121+
svuint32_t b = svdup_u32(0);
122+
svuint32_t c = svadd_u32_m(pg, a, b);
123+
return (int)svaddv_u32(pg, c);
124+
}
125+
]])],
126+
[ op_cv_sve_support=yes
127+
op_cv_sve_add_flags=yes
128+
AC_MSG_RESULT([yes]) ],
129+
[ AC_MSG_RESULT([no ]) ]
130+
)
131+
])
132+
])
133+
134+
# restore the language after our C tests
135+
AC_LANG_POP
136+
])
98137
AM_CONDITIONAL([MCA_BUILD_ompi_op_has_neon_support],
99138
[test "$op_cv_neon_support" = "yes"])
100139
AM_CONDITIONAL([MCA_BUILD_ompi_op_has_neon_fp_support],
101140
[test "$op_cv_neon_fp_support" = "yes"])
102141
AM_CONDITIONAL([MCA_BUILD_ompi_op_has_sve_support],
103142
[test "$op_cv_sve_support" = "yes"])
143+
AM_CONDITIONAL([MCA_BUILD_ompi_op_sve_add_flags],
144+
[test "$op_cv_sve_add_flags" = "yes"])
145+
104146
AC_SUBST(MCA_BUILD_ompi_op_has_neon_support)
105147
AC_SUBST(MCA_BUILD_ompi_op_has_neon_fp_support)
106148
AC_SUBST(MCA_BUILD_ompi_op_has_sve_support)
149+
AC_SUBST(MCA_BUILD_ompi_op_sve_add_flags)
107150

108151
AS_IF([test "$op_cv_neon_support" = "yes"],
109152
[AC_DEFINE([OMPI_MCA_OP_HAVE_NEON], [1],[NEON supported in the current build])])
110153
AS_IF([test "$op_cv_neon_fp_support" = "yes"],
111154
[AC_DEFINE([OMPI_MCA_OP_HAVE_NEON_FP], [1],[NEON FP supported in the current build])])
112155
AS_IF([test "$op_cv_sve_support" = "yes"],
113156
[AC_DEFINE([OMPI_MCA_OP_HAVE_SVE], [1],[SVE supported in the current build])])
157+
AS_IF([test "$op_cv_sve_add_flags" = "yes"],
158+
[AC_DEFINE([OMPI_MCA_OP_SVE_EXTRA_FLAGS], [1],[SVE supported with additional compile attributes])])
114159

115-
# If we have at least support for Neon
116-
AS_IF([test "$op_cv_neon_support" = "yes"],
160+
161+
# If we have at least support for Neon or SVE
162+
AS_IF([test "$op_cv_neon_support" = "yes" || test "$op_cv_sve_support" = "yes" ],
117163
[$1],
118164
[$2])
165+
119166
])dnl

0 commit comments

Comments
 (0)