flow
1.3.0
Kokkos cut-cell IBM incompressible Navier-Stokes solver + pnm pore extraction
Loading...
Searching...
No Matches
test_iteration_order.py
Go to the documentation of this file.
1
#!/usr/bin/env python3
2
"""Iteration-order guard: every multidimensional kernel iterates x fastest, on every backend.
3
4
Fields are x-fastest (I = x + y*nx + z*nx*ny; suite/docs/CONVENTIONS.md). Kokkos' default
5
MDRange iteration is Iterate::Left (first index fastest) on CUDA/HIP but Iterate::Right (LAST index
6
fastest) on the host backends, so a bare `Kokkos::MDRangePolicy<Exec, Kokkos::Rank<3>>` strides
7
against memory on OpenMP/Serial -- measured 2026-09-25 on the bubble column. The policies are the
8
aliases `MDRange2` / `MDRange3` of `src/policy.hpp`, which pin Iterate::Left explicitly; this test
9
fails if `Kokkos::Rank<` or `MDRangePolicy<` appears in `src/` or `tests/` anywhere else.
10
"""
11
import
pathlib
12
import
re
13
import
sys
14
15
ROOT = pathlib.Path(__file__).resolve().parents[2]
16
ALIAS_HEADER = ROOT /
"src"
/
"policy.hpp"
17
BARE = re.compile(
r"Kokkos::Rank\s*<|MDRangePolicy\s*<"
)
18
19
20
def
test_iteration_order_follows_storage
():
21
offenders = []
22
for
top
in
(
"src"
,
"tests"
):
23
for
path
in
sorted((ROOT / top).rglob(
"*"
)):
24
if
path.suffix
not
in
(
".hpp"
,
".cpp"
,
".h"
)
or
path == ALIAS_HEADER:
25
continue
26
for
lineno, line
in
enumerate(path.read_text().splitlines(), 1):
27
if
BARE.search(line.split(
"//"
, 1)[0]):
28
offenders.append(f
"{path.relative_to(ROOT)}:{lineno}: {line.strip()}"
)
29
assert
not
offenders, (
30
"bare MDRange policies (backend-default iteration order) found -- use MDRange2/MDRange3 "
31
"from src/policy.hpp:\n "
+
"\n "
.join(offenders)
32
)
33
34
35
if
__name__ ==
"__main__"
:
36
try
:
37
test_iteration_order_follows_storage
()
38
except
AssertionError
as
e:
39
print(e)
40
sys.exit(1)
41
print(
"every MDRange kernel in src/ and tests/ uses the x-fastest aliases [OK]"
)
test_iteration_order.test_iteration_order_follows_storage
test_iteration_order_follows_storage()
Definition
test_iteration_order.py:20
tests
python
test_iteration_order.py
Generated by
1.9.8