diff --git a/pystencils/backends/simd_instruction_sets.py b/pystencils/backends/simd_instruction_sets.py index 8ac0beeb7d6f0c099b667bd752e7d24764607ebc..f2df619639ac8fe2352f4d61bd37a6841defe406 100644 --- a/pystencils/backends/simd_instruction_sets.py +++ b/pystencils/backends/simd_instruction_sets.py @@ -98,12 +98,13 @@ def get_cacheline_size(instruction_set): return _cachelinesize import pystencils as ps + from pystencils.astnodes import SympyAssignment import numpy as np from pystencils.cpu.vectorization import CachelineSize arr = np.zeros((1, 1), dtype=np.float32) f = ps.Field.create_from_numpy_array('f', arr, index_dimensions=0) - ass = [CachelineSize(), ps.Assignment(f.center, CachelineSize.symbol)] + ass = [CachelineSize(), SympyAssignment(f.center, CachelineSize.symbol)] ast = ps.create_kernel(ass, cpu_vectorize_info={'instruction_set': instruction_set}) kernel = ast.compile() kernel(**{f.name: arr, CachelineSize.symbol.name: 0}) diff --git a/pystencils/cpu/vectorization.py b/pystencils/cpu/vectorization.py index ac25639b1866a72c7fc75045c180093fb6173295..6d59be9b0c35692d364e971ff190f32590b923d1 100644 --- a/pystencils/cpu/vectorization.py +++ b/pystencils/cpu/vectorization.py @@ -254,7 +254,7 @@ def insert_vector_casts(ast_node, instruction_set, default_float_type='double'): """Inserts necessary casts from scalar values to vector values.""" handled_functions = (sp.Add, sp.Mul, fast_division, fast_sqrt, fast_inv_sqrt, vec_any, vec_all, DivFunc, - sp.UnevaluatedExpr) + sp.UnevaluatedExpr, sp.Abs) def visit_expr(expr, default_type='double'): # TODO get rid of default_type if isinstance(expr, VectorMemoryAccess): diff --git a/pystencils_tests/test_vectorization.py b/pystencils_tests/test_vectorization.py index 8b685c28ae439352ae2860d36694d48dd68e4aa1..c058691b7fa471e32e0334e561b90a2465ad56cb 100644 --- a/pystencils_tests/test_vectorization.py +++ b/pystencils_tests/test_vectorization.py @@ -42,7 +42,8 @@ def test_vector_type_propagation(instruction_set=instruction_set): np.testing.assert_equal(dst[1:-1, 1:-1], 2 * 10.0 + 3) -def test_aligned_and_nt_stores(instruction_set=instruction_set, openmp=False): +@pytest.mark.parametrize('openmp', [True, False]) +def test_aligned_and_nt_stores(openmp, instruction_set=instruction_set): domain_size = (24, 24) # create a datahandling object dh = ps.create_data_handling(domain_size, periodicity=(True, True), parallel=False, default_target=Target.CPU) @@ -76,10 +77,6 @@ def test_aligned_and_nt_stores(instruction_set=instruction_set, openmp=False): np.testing.assert_equal(np.sum(dh.cpu_arrays['f']), np.prod(domain_size)) -def test_aligned_and_nt_stores_openmp(instruction_set=instruction_set): - test_aligned_and_nt_stores(instruction_set, True) - - def test_inplace_update(instruction_set=instruction_set): shape = (9, 9, 3) arr = np.ones(shape, order='f') diff --git a/pystencils_tests/test_vectorization_specific.py b/pystencils_tests/test_vectorization_specific.py index 3a56970667a445158c78af1ecc136cc686bc1c59..e118930b06083b64fef9f0020c2044abea54410d 100644 --- a/pystencils_tests/test_vectorization_specific.py +++ b/pystencils_tests/test_vectorization_specific.py @@ -128,7 +128,7 @@ def test_cacheline_size(instruction_set): @pytest.mark.parametrize('instruction_set', sorted(set(supported_instruction_sets) - {test_vectorization.instruction_set})) @pytest.mark.parametrize('function', - [f for f in test_vectorization.__dict__ if f.startswith('test_') and f != 'test_hardware_query']) + [f for f in test_vectorization.__dict__ if f.startswith('test_') and f not in ['test_hardware_query', 'test_aligned_and_nt_stores']]) def test_vectorization_other(instruction_set, function): test_vectorization.__dict__[function](instruction_set)