Default to building native code
authorJens Axboe <axboe@kernel.dk>
Tue, 6 Mar 2018 21:28:16 +0000 (14:28 -0700)
committerJens Axboe <axboe@kernel.dk>
Tue, 6 Mar 2018 21:28:16 +0000 (14:28 -0700)
If the local compiler supports it, use -march=native to ensure we
take full advantage of a local build.

If building distro packages, or otherwise for a different platform
than the host, then use --disable-native with configure to remove
this optimization.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
Makefile
configure

index c25b4222e43729a2ca961718158470acaa807b52..19ba40a078703d58e77ab8f877b30fb86b6af384 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -31,6 +31,9 @@ SCRIPTS = $(addprefix $(SRCDIR)/,tools/fio_generate_plots tools/plot/fio2gnuplot
 ifndef CONFIG_FIO_NO_OPT
   CFLAGS += -O3 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
 endif
+ifdef CONFIG_BUILD_NATIVE
+  CFLAGS += -march=native
+endif
 
 ifdef CONFIG_GFIO
   PROGS += gfio
index 2e8eb180ef50b20db7996c3bbac3e1f5330940fe..eb673adc22c083fc59ec7184f473d7776fed9684 100755 (executable)
--- a/configure
+++ b/configure
@@ -145,6 +145,7 @@ devdax="no"
 pmem="no"
 disable_lex=""
 disable_pmem="no"
+disable_native="no"
 prefix=/usr/local
 
 # parse options
@@ -195,6 +196,8 @@ for opt do
   ;;
   --enable-cuda) enable_cuda="yes"
   ;;
+  --disable-native) disable_native="yes"
+  ;;
   --help)
     show_help="yes"
     ;;
@@ -224,6 +227,7 @@ if test "$show_help" = "yes" ; then
   echo "--disable-shm           Disable SHM support"
   echo "--disable-optimizations Don't enable compiler optimizations"
   echo "--enable-cuda           Enable GPUDirect RDMA support"
+  echo "--disable-native        Don't build for native host"
   exit $exit_val
 fi
 
@@ -2131,6 +2135,20 @@ if compile_prog "" "" "mkdir(a, b)"; then
 fi
 print_config "mkdir(a, b)" "$mkdir_two"
 
+##########################################
+# check for cc -march=native
+build_native="no"
+cat > $TMPC << EOF
+int main(int argc, char **argv)
+{
+  return 0;
+}
+EOF
+if test "$disable_native" = "no" && compile_prog "-march=native" "" "march=native"; then
+  build_native="yes"
+fi
+print_config "Build march=native" "$build_native"
+
 #############################################################################
 
 if test "$wordsize" = "64" ; then
@@ -2377,6 +2395,9 @@ fi
 if test "$mkdir_two" = "yes" ; then
   output_sym "CONFIG_HAVE_MKDIR_TWO"
 fi
+if test "$build_native" = "yes" ; then
+  output_sym "CONFIG_BUILD_NATIVE"
+fi
 
 echo "LIBS+=$LIBS" >> $config_host_mak
 echo "GFIO_LIBS+=$GFIO_LIBS" >> $config_host_mak