Skip to content
Snippets Groups Projects
Commit e9ee769d authored by Richard Angersbach's avatar Richard Angersbach
Browse files

Adaptations to reduction test

parent 9a8e6f9b
No related branches found
No related tags found
1 merge request!438Reduction Support
Pipeline #72114 failed
...@@ -6,39 +6,23 @@ import pystencils as ps ...@@ -6,39 +6,23 @@ import pystencils as ps
from pystencils import AddReducedAssignment from pystencils import AddReducedAssignment
@pytest.mark.parametrize('dtype', ["float64", "float32"]) @pytest.mark.parametrize('dtype', ["float64"])
def test_log(dtype): def test_reduction(dtype):
a = sp.Symbol("a")
x = ps.fields(f'x: {dtype}[1d]') 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) config = ps.CreateKernelConfig(cpu_openmp=True)
code_main = ps.get_code_str(ast_main)
kernel_main = ast_main.compile()
# ps.show_code(ast) ast_reduction = ps.create_kernel([reduction_assignment], config, default_dtype=dtype)
#code_reduction = ps.get_code_str(ast_reduction)
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)
kernel_reduction = ast_reduction.compile() kernel_reduction = ast_reduction.compile()
if dtype == "float64": ps.show_code(ast_reduction)
assert "float" not in code_reduction
ps.show_code(ast_reduction) array = np.ones((10,), dtype=dtype)
\ No newline at end of file kernel_reduction(x=array, w=0)
# TODO: check if "w = #points"
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment