Fix TestCPUFeature test; more explicit.
This commit is contained in:
parent
6bc5b72c71
commit
0cb552a1ca
1 changed files with 32 additions and 10 deletions
|
|
@ -866,7 +866,7 @@ class TestCPUSupport(unittest.TestCase):
|
||||||
def _build_test_module(self):
|
def _build_test_module(self):
|
||||||
mod = Module.new('test')
|
mod = Module.new('test')
|
||||||
|
|
||||||
float = Type.float()
|
float = Type.double()
|
||||||
mysinty = Type.function( float, [float] )
|
mysinty = Type.function( float, [float] )
|
||||||
mysin = mod.add_function(mysinty, "mysin")
|
mysin = mod.add_function(mysinty, "mysin")
|
||||||
block = mysin.append_basic_block("entry")
|
block = mysin.append_basic_block("entry")
|
||||||
|
|
@ -890,11 +890,11 @@ class TestCPUSupport(unittest.TestCase):
|
||||||
mod, func = self._build_test_module()
|
mod, func = self._build_test_module()
|
||||||
ee = self._build_engine(mod, mattrs=mattrs)
|
ee = self._build_engine(mod, mattrs=mattrs)
|
||||||
|
|
||||||
arg = le.GenericValue.real(Type.float(), 1.234)
|
arg = le.GenericValue.real(Type.double(), 1.234)
|
||||||
retval = ee.run_function(func, [arg])
|
retval = ee.run_function(func, [arg])
|
||||||
|
|
||||||
golden = math.sin(1.234)
|
golden = math.sin(1.234)
|
||||||
answer = retval.as_real(Type.float())
|
answer = retval.as_real(Type.double())
|
||||||
self.assertTrue(abs(answer-golden)/golden < 1e-5)
|
self.assertTrue(abs(answer-golden)/golden < 1e-5)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -904,13 +904,35 @@ class TestCPUSupport(unittest.TestCase):
|
||||||
else:
|
else:
|
||||||
return EngineBuilder.new(mod).create()
|
return EngineBuilder.new(mod).create()
|
||||||
|
|
||||||
def test_cpu_support(self):
|
def test_cpu_support2(self):
|
||||||
features = 'sse2', 'sse3', 'sse41', 'sse42', 'avx'
|
features = 'sse3', 'sse41', 'sse42', 'avx'
|
||||||
n = len(features)
|
mattrs = ','.join(map(lambda s: '-%s' % s, features))
|
||||||
for i in range(n):
|
print 'disable mattrs', mattrs
|
||||||
mattrs = ','.join(map(lambda s: '-%s' % s, features[i:]))
|
self._template(mattrs)
|
||||||
print 'disable mattrs', mattrs
|
|
||||||
self._template(mattrs)
|
def test_cpu_support3(self):
|
||||||
|
features = 'sse41', 'sse42', 'avx'
|
||||||
|
mattrs = ','.join(map(lambda s: '-%s' % s, features))
|
||||||
|
print 'disable mattrs', mattrs
|
||||||
|
self._template(mattrs)
|
||||||
|
|
||||||
|
def test_cpu_support4(self):
|
||||||
|
features = 'sse42', 'avx'
|
||||||
|
mattrs = ','.join(map(lambda s: '-%s' % s, features))
|
||||||
|
print 'disable mattrs', mattrs
|
||||||
|
self._template(mattrs)
|
||||||
|
|
||||||
|
def test_cpu_support5(self):
|
||||||
|
features = 'avx',
|
||||||
|
mattrs = ','.join(map(lambda s: '-%s' % s, features))
|
||||||
|
print 'disable mattrs', mattrs
|
||||||
|
self._template(mattrs)
|
||||||
|
|
||||||
|
def test_cpu_support6(self):
|
||||||
|
features = []
|
||||||
|
mattrs = ','.join(map(lambda s: '-%s' % s, features))
|
||||||
|
print 'disable mattrs', mattrs
|
||||||
|
self._template(mattrs)
|
||||||
|
|
||||||
tests.append(TestCPUSupport)
|
tests.append(TestCPUSupport)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue