Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests[cartesian]: Increase horizontal region test coverage #1851

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,13 @@ def validation(field_in, field_out, *, domain, origin):
field_out[:, -1, :] = field_in[:, -1, :] - 1.0


class TestHorizontalRegionsCorners(gt_testing.StencilTestSuite):
class TestHorizontalRegionsPartialWrites(gt_testing.StencilTestSuite):
"""Use horizontal regions to only write to certain parts of the field.

This test is different from the corner case below because the corner
case follows a different code path (we have specific optimizations for
them)."""

dtypes = {"field_in": np.float32, "field_out": np.float32}
domain_range = [(4, 4), (4, 4), (2, 2)]
backends = ALL_BACKENDS
Expand All @@ -885,8 +891,40 @@ class TestHorizontalRegionsCorners(gt_testing.StencilTestSuite):
in_range=(-10, 10), axes="IJK", boundary=[(0, 0), (0, 0), (0, 0)]
),
"field_out": gt_testing.field(
in_range=(42, 42), axes="IJK", boundary=[(0, 0), (0, 0), (0, 0)]
),
}

def definition(field_in, field_out):
with computation(PARALLEL), interval(...):
with horizontal(region[I[0], :], region[I[-1], :]):
field_out = ( # noqa: F841 [unused-variable]
field_in + 1.0
)
with horizontal(region[:, J[0]], region[:, J[-1]]):
field_out = ( # noqa: F841 [unused-variable]
field_in - 1.0
)

def validation(field_in, field_out, *, domain, origin):
field_out[:, :, :] = 42
field_out[0, :, :] = field_in[0, :, :] + 1.0
field_out[-1, :, :] = field_in[-1, :, :] + 1.0
field_out[:, 0, :] = field_in[:, 0, :] - 1.0
field_out[:, -1, :] = field_in[:, -1, :] - 1.0


class TestHorizontalRegionsCorners(gt_testing.StencilTestSuite):
dtypes = {"field_in": np.float32, "field_out": np.float32}
domain_range = [(4, 4), (4, 4), (2, 2)]
backends = ALL_BACKENDS
symbols = {
"field_in": gt_testing.field(
in_range=(-10, 10), axes="IJK", boundary=[(0, 0), (0, 0), (0, 0)]
),
"field_out": gt_testing.field(
in_range=(42, 42), axes="IJK", boundary=[(0, 0), (0, 0), (0, 0)]
),
}

def definition(field_in, field_out):
Expand All @@ -901,6 +939,7 @@ def definition(field_in, field_out):
)

def validation(field_in, field_out, *, domain, origin):
field_out[:, :, :] = 42
field_out[0:2, 0:2, :] = field_in[0:2, 0:2, :] + 1.0
field_out[-3:-1, -3:-1, :] = field_in[-3:-1, -3:-1, :] + 1.0
field_out[0:2, -3:-1, :] = field_in[0:2, -3:-1, :] - 1.0
Expand Down