Close everything properly
This commit is contained in:
parent
8689d62f02
commit
b9cccbf9ae
1 changed files with 18 additions and 11 deletions
|
|
@ -12,7 +12,11 @@ http://software.intel.com/sites/default/files/m/a/b/3/4/d/41604-319433-012a.pdf
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import sys, os, subprocess
|
import sys
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import contextlib
|
||||||
|
|
||||||
|
|
||||||
def detect_avx_support(option='detect'):
|
def detect_avx_support(option='detect'):
|
||||||
'''Detect AVX support'''
|
'''Detect AVX support'''
|
||||||
|
|
@ -36,13 +40,14 @@ def detect_unix_like():
|
||||||
except IOError:
|
except IOError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
for line in info:
|
with contextlib.closing(info):
|
||||||
if line.lstrip().startswith('flags'):
|
for line in info:
|
||||||
features = line.split()
|
if line.lstrip().startswith('flags'):
|
||||||
if 'avx' in features and 'xsave' in features:
|
features = line.split()
|
||||||
# enable AVX if flags contain AVX
|
if 'avx' in features and 'xsave' in features:
|
||||||
return True
|
# enable AVX if flags contain AVX
|
||||||
return False
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def detect_osx_like():
|
def detect_osx_like():
|
||||||
try:
|
try:
|
||||||
|
|
@ -50,9 +55,11 @@ def detect_osx_like():
|
||||||
stdout=subprocess.PIPE)
|
stdout=subprocess.PIPE)
|
||||||
except OSError:
|
except OSError:
|
||||||
return False
|
return False
|
||||||
features = info.stdout.read().decode('UTF8')
|
|
||||||
features = features.split()
|
with info:
|
||||||
return 'AVX1.0' in features and 'OSXSAVE' in features and 'XSAVE' in features
|
features = info.stdout.read().decode('UTF8')
|
||||||
|
features = features.split()
|
||||||
|
return 'AVX1.0' in features and 'OSXSAVE' in features and 'XSAVE' in features
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue