From d53a1abc7c3ee96a50dc36e1165ea3a09b2a7aa4 Mon Sep 17 00:00:00 2001 From: Takuya ASADA Date: Mon, 6 Apr 2015 15:00:19 +0900 Subject: [PATCH] dpdk: enable -mavx/-mavx2 if available To support HEAD version of DPDK, we need -mavx/-mavx2 on Seastar CFLAGS. But we cannot enable it until Host CPU has the feature, so we need to check it. Signed-off-by: Takuya ASADA --- configure.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/configure.py b/configure.py index 31a50cb553..d850e58706 100755 --- a/configure.py +++ b/configure.py @@ -20,6 +20,19 @@ import os, os.path, textwrap, argparse, sys, shlex, subprocess, tempfile, re configure_args = str.join(' ', [shlex.quote(x) for x in sys.argv[1:]]) +def get_flags(): + with open('/proc/cpuinfo') as f: + for line in f: + if line.strip(): + if line.rstrip('\n').startswith('flags'): + return re.sub(r'^flags\s+: ', '', line).split() + +def has_avx(): + return 'avx' in get_flags() + +def has_avx2(): + return 'avx2' in get_flags() + def add_tristate(arg_parser, name, dest, help): arg_parser.add_argument('--enable-' + name, dest = dest, action = 'store_true', default = None, help = 'Enable ' + help) @@ -404,7 +417,9 @@ if args.with_osv: if args.dpdk_target: args.user_cflags = (args.user_cflags + ' -DHAVE_DPDK -I' + - args.dpdk_target + '/include -Wno-error=literal-suffix -Wno-literal-suffix -Wno-invalid-offsetof') + args.dpdk_target + '/include -Wno-error=literal-suffix -Wno-literal-suffix -Wno-invalid-offsetof -m64' + + ' -mavx' if has_avx() else '' + + ' -mavx2' if has_avx2() else '') libs += (' -L' + args.dpdk_target + '/lib ' + '-lintel_dpdk -lrt -lm -ldl')