Skip to content
Snippets Groups Projects
Commit dc431ef2 authored by Markus Holzer's avatar Markus Holzer
Browse files

Fix original tests

parent b7205955
No related branches found
No related tags found
1 merge request!396[BUGFIX] GPU slicing
......@@ -2,6 +2,7 @@ import pytest
import numpy as np
import sympy as sp
import math
from scipy.ndimage import convolve
from pystencils import Assignment, Field, fields, CreateKernelConfig, create_kernel, Target, get_code_str
......@@ -231,15 +232,26 @@ def test_guards_with_iteration_slices(start, end, step, shape):
field_1 = fields(f"f(1) : double{list(shape)}")
assignment = Assignment(field_1.center, 1)
ast = create_kernel(assignment, config=kernel_config_gpu)
code_str = get_code_str(ast)
test_strings = list()
iteration_ranges = list()
for i, s in enumerate(iter_slice):
end = shape[i] + s.stop
end = end // s.step
test_strings.append(f"{s.start} < {end}")
e = ((shape[i] + end) - s.start) / s.step
e = math.ceil(e) + s.start
test_strings.append(f"{s.start} < {e}")
a = s.start
counter = 0
while a < e:
a += 1
counter += 1
iteration_ranges.append(counter)
# check if the expected if statement is in the GPU code
for s in test_strings:
assert s in code_str
# check if these bounds lead to same lengths as the range function would produce
for i in range(len(iter_slice)):
assert iteration_ranges[i] == len(range(iter_slice[i].start, shape[i] + end, iter_slice[i].step))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment