Skip to content
Snippets Groups Projects
Commit 356a8343 authored by Frederik Hennig's avatar Frederik Hennig
Browse files

WIP: GPU thread range tests

parent 428424d1
No related branches found
No related tags found
1 merge request!384Fundamental GPU Support
Pipeline #67185 failed
...@@ -19,7 +19,7 @@ from ...config import GpuIndexingConfig ...@@ -19,7 +19,7 @@ from ...config import GpuIndexingConfig
class SyclPlatform(GenericGpu): class SyclPlatform(GenericGpu):
def __init__( def __init__(
self, ctx: KernelCreationContext, indexing_cfg: GpuIndexingConfig | None self, ctx: KernelCreationContext, indexing_cfg: GpuIndexingConfig | None = None
): ):
super().__init__(ctx) super().__init__(ctx)
self._cfg = indexing_cfg if indexing_cfg is not None else GpuIndexingConfig() self._cfg = indexing_cfg if indexing_cfg is not None else GpuIndexingConfig()
......
#%%
import pytest import pytest
from pystencils.field import Field from pystencils.field import Field
...@@ -11,18 +12,34 @@ from pystencils.backend.ast.structural import PsBlock, PsLoop, PsComment ...@@ -11,18 +12,34 @@ from pystencils.backend.ast.structural import PsBlock, PsLoop, PsComment
from pystencils.backend.ast.expressions import PsExpression from pystencils.backend.ast.expressions import PsExpression
from pystencils.backend.ast import dfs_preorder from pystencils.backend.ast import dfs_preorder
from pystencils.backend.platforms import CudaPlatform from pystencils.backend.platforms import CudaPlatform, SyclPlatform
@pytest.mark.parametrize("layout", ["fzyx", "zyxf", "c", "f"]) @pytest.mark.parametrize("layout", ["fzyx", "zyxf", "c", "f"])
def test_loop_nest(layout): @pytest.mark.parametrize("platform_class", [CudaPlatform, SyclPlatform])
def test_thread_range(platform_class, layout):
ctx = KernelCreationContext() ctx = KernelCreationContext()
body = PsBlock([PsComment("Loop body goes here")]) body = PsBlock([PsComment("Kernel body goes here")])
platform = CudaPlatform(ctx) platform = platform_class(ctx)
# FZYX Order dim = 3
archetype_field = Field.create_generic("fzyx_field", spatial_dimensions=3, layout=layout) archetype_field = Field.create_generic("field", spatial_dimensions=dim, layout=layout)
ispace = FullIterationSpace.create_with_ghost_layers(ctx, 0, archetype_field) ispace = FullIterationSpace.create_with_ghost_layers(ctx, 1, archetype_field)
_ = platform.materialize_iteration_space(body, ispace) _, threads_range = platform.materialize_iteration_space(body, ispace)
assert threads_range.dim == dim
loop_order = archetype_field.layout
for i in range(dim):
coordinate = loop_order[i]
dimension = ispace.dimensions[coordinate]
witems = threads_range.num_work_items[i]
desired = (dimension.stop - dimension.start) / dimension.step
assert witems.structurally_equal(desired)
#%%
test_thread_range(CudaPlatform, "fzyx")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment