diff --git a/tests/kernelcreation/test_reduction.py b/tests/kernelcreation/test_reduction.py index f8c2b187034aac4bd1cdb619c52b882137e41b91..0532b30f552e4800fb5fb3899d50ad539f46c0d4 100644 --- a/tests/kernelcreation/test_reduction.py +++ b/tests/kernelcreation/test_reduction.py @@ -6,39 +6,23 @@ import pystencils as ps from pystencils import AddReducedAssignment -@pytest.mark.parametrize('dtype', ["float64", "float32"]) -def test_log(dtype): - a = sp.Symbol("a") +@pytest.mark.parametrize('dtype', ["float64"]) +def test_reduction(dtype): x = ps.fields(f'x: {dtype}[1d]') + w = sp.Symbol("w") - # kernel with main assignments and no reduction + # kernel with reduction assignment - main_assignment = ps.AssignmentCollection({x.center(): a}) + reduction_assignment = AddReducedAssignment(w, x.center()) - ast_main = ps.create_kernel(main_assignment, default_dtype=dtype) - code_main = ps.get_code_str(ast_main) - kernel_main = ast_main.compile() + config = ps.CreateKernelConfig(cpu_openmp=True) - # ps.show_code(ast) - - if dtype == "float64": - assert "float" not in code_main - - array = np.zeros((10,), dtype=dtype) - kernel_main(x=array, a=100) - assert np.allclose(array, 4.60517019) - - # kernel with single reduction assignment - - omega = sp.Symbol("omega") - - reduction_assignment = AddReducedAssignment(omega, x.center()) - - ast_reduction = ps.create_kernel(reduction_assignment, default_dtype=dtype) - code_reduction = ps.get_code_str(ast_reduction) + ast_reduction = ps.create_kernel([reduction_assignment], config, default_dtype=dtype) + #code_reduction = ps.get_code_str(ast_reduction) kernel_reduction = ast_reduction.compile() - if dtype == "float64": - assert "float" not in code_reduction + ps.show_code(ast_reduction) - ps.show_code(ast_reduction) \ No newline at end of file + array = np.ones((10,), dtype=dtype) + kernel_reduction(x=array, w=0) + # TODO: check if "w = #points" \ No newline at end of file