summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPete Zaitcev <zaitcev@kotori.zaitcev.us>2017-05-24 14:35:15 -0600
committerPete Zaitcev <zaitcev@kotori.zaitcev.us>2017-05-24 14:42:36 -0600
commit0962144c51421a39be921876328bcecb912c7674 (patch)
treefe473286b7ad52dfc12c62fac4afd5a41129cefd
parentde984f59e7a6cca8c1f3cf1d93b87ff144a2b974 (diff)
Allow to disable optimizations for portability
We're having trouble on Fedora when the build system runs on Intel CPUs. The ./configure detects AVX instructions and builds liberasurecode with them. The resulting library crashes with SIGILL when users run it on ADM CPUs without AVX. See the details here: https://bugzilla.redhat.com/show_bug.cgi?id=1454543 The patch allows to disable the optimizations, so that distro packaging then can invoke this options and build portable libraries. For the record, "make test" runs about 16% slower on an Intel CPU if optimizations are disabled. So, there's a measurable performance impact. However, operators intersted in outright performance might want to consider Erasure Coding implementations other than the one built-in into liberasurecode. The library supports other back-ends that are significantly faster than even optimized built-in code. Change-Id: I09603b97ceeb833ba582cf3217e0be51c019d645
Notes
Notes (review): Code-Review+2: Tim Burke <tim@swiftstack.com> Code-Review+2: Thiago da Silva <thiago@redhat.com> Workflow+1: Thiago da Silva <thiago@redhat.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Thu, 25 May 2017 18:28:23 +0000 Reviewed-on: https://review.openstack.org/467761 Project: openstack/liberasurecode Branch: refs/heads/master
-rw-r--r--configure.ac133
1 files changed, 73 insertions, 60 deletions
diff --git a/configure.ac b/configure.ac
index c3509d2..69df9a3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -151,68 +151,81 @@ AC_SUBST(ac_aux_dir)
151AC_SUBST(OBJECTS) 151AC_SUBST(OBJECTS)
152 152
153dnl Do CPUID and associated compiler flag checks 153dnl Do CPUID and associated compiler flag checks
154dnl but allow to disable all of this in order to build portable binaries
154 155
155SUPPORTED_FLAGS="" 156AC_ARG_ENABLE([mmi], [ --disable-mmi do not use host-specific instructions],
156$CC - -E -mmmx </dev/null >/dev/null 2>&1 157[case "${enableval}" in
157if [[ $? == "0" ]]; then 158 yes) mmi=true ;;
158 SUPPORTED_FLAGS="-mmmx" 159 no) mmi=false ;;
159 AC_MSG_RESULT([$CC supports -mmmx]) 160 *) AC_MSG_ERROR([bad value ${enableval} for --disable-mmi]) ;;
160fi 161esac],[mmi=true])
161$CC - -E -msse </dev/null >/dev/null 2>&1 162
162if [[ $? == "0" ]]; then 163if test x$mmi = xtrue ; then
163 SUPPORTED_FLAGS="$SUPPORTED_FLAGS -msse" 164
164 AC_MSG_RESULT([$CC supports -msse]) 165 SUPPORTED_FLAGS=""
165fi 166 $CC - -E -mmmx </dev/null >/dev/null 2>&1
166$CC - -E -msse2 </dev/null >/dev/null 2>&1 167 if [[ $? == "0" ]]; then
167if [[ $? == "0" ]]; then 168 SUPPORTED_FLAGS="-mmmx"
168 SUPPORTED_FLAGS="$SUPPORTED_FLAGS -msse2" 169 AC_MSG_RESULT([$CC supports -mmmx])
169 AC_MSG_RESULT([$CC supports -msse2]) 170 fi
170fi 171 $CC - -E -msse </dev/null >/dev/null 2>&1
171$CC - -E -msse3 </dev/null >/dev/null 2>&1 172 if [[ $? == "0" ]]; then
172if [[ $? == "0" ]]; then 173 SUPPORTED_FLAGS="$SUPPORTED_FLAGS -msse"
173 SUPPORTED_FLAGS="$SUPPORTED_FLAGS -msse3" 174 AC_MSG_RESULT([$CC supports -msse])
174 AC_MSG_RESULT([$CC supports -msse3]) 175 fi
175fi 176 $CC - -E -msse2 </dev/null >/dev/null 2>&1
176$CC - -E -mssse3 </dev/null >/dev/null 2>&1 177 if [[ $? == "0" ]]; then
177if [[ $? == "0" ]]; then 178 SUPPORTED_FLAGS="$SUPPORTED_FLAGS -msse2"
178 SUPPORTED_FLAGS="$SUPPORTED_FLAGS -mssse3" 179 AC_MSG_RESULT([$CC supports -msse2])
179 AC_MSG_RESULT([$CC supports -mssse3]) 180 fi
180fi 181 $CC - -E -msse3 </dev/null >/dev/null 2>&1
181$CC - -E -msse4.1 </dev/null >/dev/null 2>&1 182 if [[ $? == "0" ]]; then
182if [[ $? == "0" ]]; then 183 SUPPORTED_FLAGS="$SUPPORTED_FLAGS -msse3"
183 SUPPORTED_FLAGS="$SUPPORTED_FLAGS -msse4.1" 184 AC_MSG_RESULT([$CC supports -msse3])
184 AC_MSG_RESULT([$CC supports -msse4.1]) 185 fi
185fi 186 $CC - -E -mssse3 </dev/null >/dev/null 2>&1
186$CC - -E -msse4.2 </dev/null >/dev/null 2>&1 187 if [[ $? == "0" ]]; then
187if [[ $? == "0" ]]; then 188 SUPPORTED_FLAGS="$SUPPORTED_FLAGS -mssse3"
188 SUPPORTED_FLAGS="$SUPPORTED_FLAGS -msse4.2" 189 AC_MSG_RESULT([$CC supports -mssse3])
189 AC_MSG_RESULT([$CC supports -msse4.2]) 190 fi
190fi 191 $CC - -E -msse4.1 </dev/null >/dev/null 2>&1
191$CC - -E -mavx </dev/null >/dev/null 2>&1 192 if [[ $? == "0" ]]; then
192if [[ $? == "0" ]]; then 193 SUPPORTED_FLAGS="$SUPPORTED_FLAGS -msse4.1"
193 SUPPORTED_FLAGS="$SUPPORTED_FLAGS -mavx" 194 AC_MSG_RESULT([$CC supports -msse4.1])
194 AC_MSG_RESULT([$CC supports -mavx]) 195 fi
195fi 196 $CC - -E -msse4.2 </dev/null >/dev/null 2>&1
197 if [[ $? == "0" ]]; then
198 SUPPORTED_FLAGS="$SUPPORTED_FLAGS -msse4.2"
199 AC_MSG_RESULT([$CC supports -msse4.2])
200 fi
201 $CC - -E -mavx </dev/null >/dev/null 2>&1
202 if [[ $? == "0" ]]; then
203 SUPPORTED_FLAGS="$SUPPORTED_FLAGS -mavx"
204 AC_MSG_RESULT([$CC supports -mavx])
205 fi
196 206
197# Detect the SIMD features supported by both the compiler and the CPU 207 # Detect the SIMD features supported by both the compiler and the CPU
198SIMD_FLAGS="" 208 SIMD_FLAGS=""
199cat "$srcdir/get_flags_from_cpuid.c" \ 209 cat "$srcdir/get_flags_from_cpuid.c" \
200 | sed "s/FLAGSFROMAUTOCONF/${SUPPORTED_FLAGS}/" \ 210 | sed "s/FLAGSFROMAUTOCONF/${SUPPORTED_FLAGS}/" \
201 | $CC -x c -g - -o get_flags_from_cpuid 211 | $CC -x c -g - -o get_flags_from_cpuid
202if [[ -e ./get_flags_from_cpuid ]]; then 212 if [[ -e ./get_flags_from_cpuid ]]; then
203 chmod 755 get_flags_from_cpuid; ./get_flags_from_cpuid; rm ./get_flags_from_cpuid 213 chmod 755 get_flags_from_cpuid
204 if [[ -e compiler_flags ]]; then 214 ./get_flags_from_cpuid
205 SIMD_FLAGS=`cat compiler_flags` 215 rm ./get_flags_from_cpuid
206 rm -f compiler_flags 216 if [[ -e compiler_flags ]]; then
207 else 217 SIMD_FLAGS=`cat compiler_flags`
208 AC_MSG_WARN([Could not run the CPUID detection program]) 218 rm -f compiler_flags
209 fi 219 else
210else 220 AC_MSG_WARN([Could not run the CPUID detection program])
211 AC_MSG_WARN([Could not compile the CPUID detection program]) 221 fi
212fi 222 else
223 AC_MSG_WARN([Could not compile the CPUID detection program])
224 fi
213 225
214AC_MSG_RESULT([Generating with SIMD flags: $SIMD_FLAGS]) 226 AC_MSG_RESULT([Generating with SIMD flags: $SIMD_FLAGS])
215CFLAGS="$CFLAGS $SIMD_FLAGS" 227 CFLAGS="$CFLAGS $SIMD_FLAGS"
228fi
216 229
217# Certain code may be dependent on 32 vs. 64-bit arch, so add a 230# Certain code may be dependent on 32 vs. 64-bit arch, so add a
218# flag for 64-bit 231# flag for 64-bit
@@ -231,7 +244,7 @@ AM_CONDITIONAL(HAVE_DOXYGEN, $DOXYGEN)
231AC_SUBST(HAVE_DOXYGEN) 244AC_SUBST(HAVE_DOXYGEN)
232 245
233dnl Let people disable the doxygen stuff. 246dnl Let people disable the doxygen stuff.
234AC_ARG_ENABLE(doxygen, [ --enable-doxygen Use doxygen to build documentation (default=auto)], 247AC_ARG_ENABLE(doxygen, [ --enable-doxygen use doxygen to build documentation (default=auto)],
235 enable_doxygen="$enableval", 248 enable_doxygen="$enableval",
236 enable_doxygen=auto) 249 enable_doxygen=auto)
237 250