提交 21035e70 编写于 作者: Z zhangjun

auto detect cpu avx instruction set

上级 8ba5a838
...@@ -330,12 +330,21 @@ class Server(object): ...@@ -330,12 +330,21 @@ class Server(object):
def use_mkl(self, flag): def use_mkl(self, flag):
self.mkl_flag = flag self.mkl_flag = flag
def check_avx(self):
p = subprocess.Popen(['cat /proc/cpuinfo | grep avx 2>/dev/null'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
out, err = p.communicate()
if err == '' and len(out) > 0:
return True
else:
return False
def get_device_version(self): def get_device_version(self):
avx_flag = False avx_flag = False
mkl_flag = self.mkl_flag avx_support = self.check_avx()
r = os.system("cat /proc/cpuinfo | grep avx > /dev/null 2>&1") if avx_suppport:
if r == 0:
avx_flag = True avx_flag = True
self.use_mkl(True)
mkl_flag = self.mkl_flag
if avx_flag: if avx_flag:
if mkl_flag: if mkl_flag:
device_version = "cpu-avx-mkl" device_version = "cpu-avx-mkl"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册