1313#
1414
1515# MCA_ompi_op_arm_CONFIG([action-if-can-compile],
16- # [action-if-cant-compile])
16+ # [action-if-cant-compile])
1717# ------------------------------------------------
1818AC_DEFUN([MCA_ompi_op_aarch64_CONFIG],[
1919 AC_CONFIG_FILES([ompi/mca/op/aarch64/Makefile])
@@ -74,33 +74,70 @@ AC_DEFUN([MCA_ompi_op_aarch64_CONFIG],[
7474 #
7575 # Check for SVE support
7676 #
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([[
77+ AC_CACHE_CHECK([for SVE support], [op_cv_sve_support], [
78+ AC_MSG_RESULT([])
79+ # initialize result variables
80+ op_cv_sve_support= no
81+ op_cv_sve_add_flags= no
82+
83+ # first attempt: no extra flags
84+ AC_MSG_CHECKING([for SVE support (no additional flags)])
85+ AC_LINK_IFELSE(
86+ [AC_LANG_SOURCE([[
8287# if defined(__aarch64__) && defined(__ARM_FEATURE_SVE)
8388# include <arm_sve.h>
8489# else
8590# error "No support for __aarch64__ or SVE"
8691# endif
87- ]],
88- [[
89- # if defined(__aarch64__) && defined(_ARM_FEATURE_SVE)
90- svfloat32_t vA;
91- vA = svdup_n_f32(0)
92+
93+ int main(void) {
94+ svfloat32_t vA;
95+ vA = svdup_n_f32(0);
96+ return 0;
97+ }
98+ ]])],
99+ [ op_cv_sve_support= yes
100+ AC_MSG_RESULT([yes]) ],
101+ [ AC_MSG_RESULT([no ]) ]
102+ )
103+
104+ # second attempt: use +sve attribute
105+ AS_IF([test " $op_cv_sve_support " = " no" ],[
106+ AC_MSG_CHECKING([for SVE support (with +sve)])
107+ AC_LINK_IFELSE(
108+ [AC_LANG_SOURCE([[
109+ # if defined(__aarch64__) && defined(__linux__)
110+ # include <arm_sve.h>
111+ # else
112+ # error "this feature is only supported on aarch64 + linux platforms"
92113# endif
93- ]])],
94- [op_cv_sve_support= yes],
95- [op_cv_sve_support= no])])])
96- ])
97114
115+ __attribute__(( __target__("+ sve")) )
116+ int main(void) {
117+ svbool_t pg = svptrue_b32 ();
118+ svuint32_t a = svdup_u32(0);
119+ svuint32_t b = svdup_u32(0);
120+ svuint32_t c = svadd_u32_m(pg, a, b);
121+ return (int)svaddv_u32(pg, c);
122+ }
123+ ]])],
124+ [ op_cv_sve_support= yes
125+ op_cv_sve_add_flags= yes
126+ AC_MSG_RESULT([yes]) ],
127+ [ AC_MSG_RESULT([no ]) ]
128+ )
129+ ])
130+ ])
131+
132+ AC_LANG_POP
133+ ])
98134 AM_CONDITIONAL([MCA_BUILD_ompi_op_has_neon_support],
99135 [test " $op_cv_neon_support " = " yes" ])
100136 AM_CONDITIONAL([MCA_BUILD_ompi_op_has_neon_fp_support],
101137 [test " $op_cv_neon_fp_support " = " yes" ])
102138 AM_CONDITIONAL([MCA_BUILD_ompi_op_has_sve_support],
103139 [test " $op_cv_sve_support " = " yes" ])
140+
104141 AC_SUBST(MCA_BUILD_ompi_op_has_neon_support)
105142 AC_SUBST(MCA_BUILD_ompi_op_has_neon_fp_support)
106143 AC_SUBST(MCA_BUILD_ompi_op_has_sve_support)
@@ -111,9 +148,12 @@ AC_DEFUN([MCA_ompi_op_aarch64_CONFIG],[
111148 [AC_DEFINE([OMPI_MCA_OP_HAVE_NEON_FP], [1],[NEON FP supported in the current build])])
112149 AS_IF([test " $op_cv_sve_support " = " yes" ],
113150 [AC_DEFINE([OMPI_MCA_OP_HAVE_SVE], [1],[SVE supported in the current build])])
151+ AS_IF([test " $op_cv_sve_add_flags " = " yes" ],
152+ [AC_DEFINE([OMPI_MCA_OP_SVE_EXTRA_FLAGS], [1],[SVE supported with additional compile attributes])],
153+ [AC_DEFINE([OMPI_MCA_OP_SVE_EXTRA_FLAGS], [0],[SVE not supported])])
114154
115- # If we have at least support for Neon
116- AS_IF([test " $op_cv_neon_support " = " yes" ],
155+ # If we have at least support for Neon or SVE
156+ AS_IF([test " $op_cv_neon_support " = " yes" || test " $op_cv_sve_support " = " yes " ],
117157 [$1 ],
118158 [$2 ])
119159])dnl
0 commit comments