diff --git a/pystencils_tests/test_simplifications.py b/pystencils_tests/test_simplifications.py index 21a5d5a9b54114288ea33468951d88dbee9dfc1c..ef8ae7ce61a07c992d09807933061c73e61484a1 100644 --- a/pystencils_tests/test_simplifications.py +++ b/pystencils_tests/test_simplifications.py @@ -175,7 +175,7 @@ def test_evaluate_constant_terms(target, simplification): pytest.importorskip("pycuda") src, dst = ps.fields('src, dst: float32[2d]') - # Triggers Sympy's cos optimization + # cos of a number will always be simplified assignments = ps.AssignmentCollection({ src[0, 0]: -sp.cos(1) + dst[0, 0] }) @@ -183,8 +183,4 @@ def test_evaluate_constant_terms(target, simplification): config = pystencils.config.CreateKernelConfig(target=target, default_assignment_simplifications=simplification) ast = ps.create_kernel(assignments, config=config) code = ps.get_code_str(ast) - if simplification: - assert 'cos(' not in code - else: - assert 'cos(' in code - print(code) + assert 'cos(' not in code diff --git a/pystencils_tests/test_vectorization_specific.py b/pystencils_tests/test_vectorization_specific.py index e118930b06083b64fef9f0020c2044abea54410d..2dc4e2de998afe02cd207308ebe11f6264fee43a 100644 --- a/pystencils_tests/test_vectorization_specific.py +++ b/pystencils_tests/test_vectorization_specific.py @@ -61,24 +61,28 @@ def test_vectorized_abs(instruction_set, dtype): @pytest.mark.parametrize('dtype', ('float', 'double')) @pytest.mark.parametrize('instruction_set', supported_instruction_sets) def test_strided(instruction_set, dtype): - f, g = ps.fields(f"f, g : float{64 if dtype == 'double' else 32}[2D]") + npdtype = np.float64 if dtype == 'double' else np.float32 + + f, g = ps.fields(f"f, g : float{64 if dtype=='double' else 32}[2D]") update_rule = [ps.Assignment(g[0, 0], f[0, 0] + f[-1, 0] + f[1, 0] + f[0, 1] + f[0, -1] + 42.0)] - if 'storeS' not in get_vector_instruction_set(dtype, instruction_set) and not instruction_set in ['avx512', 'rvv'] and not instruction_set.startswith('sve'): + if 'storeS' not in get_vector_instruction_set(dtype, instruction_set) and instruction_set not in ['avx512', 'rvv'] and not instruction_set.startswith('sve'): with pytest.warns(UserWarning) as warn: - config = pystencils.config.CreateKernelConfig(cpu_vectorize_info={'instruction_set': instruction_set}) + config = pystencils.config.CreateKernelConfig(cpu_vectorize_info={'instruction_set': instruction_set}, + default_number_float=npdtype) ast = ps.create_kernel(update_rule, config=config) assert 'Could not vectorize loop' in warn[0].message.args[0] else: with pytest.warns(None) as warn: - config = pystencils.config.CreateKernelConfig(cpu_vectorize_info={'instruction_set': instruction_set}) + config = pystencils.config.CreateKernelConfig(cpu_vectorize_info={'instruction_set': instruction_set}, + default_number_float=npdtype) ast = ps.create_kernel(update_rule, config=config) assert len(warn) == 0 func = ast.compile() ref_func = ps.create_kernel(update_rule).compile() - arr = np.random.random((23 + 2, 17 + 2)).astype(np.float64 if dtype == 'double' else np.float32) - dst = np.zeros_like(arr, dtype=np.float64 if dtype == 'double' else np.float32) - ref = np.zeros_like(arr, dtype=np.float64 if dtype == 'double' else np.float32) + arr = np.random.random((23 + 2, 17 + 2)).astype(npdtype) + dst = np.zeros_like(arr, dtype=npdtype) + ref = np.zeros_like(arr, dtype=npdtype) func(g=dst, f=arr) ref_func(g=ref, f=arr)