P1 (9/n): refinement follow-up tests pass refinements=[bounds]
FixedPatchStepper and the PeriodicPatchStepper alias are called with refinements=[bounds] instead of the positional legacy bounds (same _legacy_levels result). Assertions, including the before-CUDA and four-cell/omega/layout rejections, unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2be80324ad
commit
ec3e3b928a
1 file changed
+11
-8
@@ -94,7 +94,8 @@ class FaultGuardsCPU(unittest.TestCase):
|
|||||||
("slot_reservoir", (12, 4, 20, 21))):
|
("slot_reservoir", (12, 4, 20, 21))):
|
||||||
with self.subTest(mode=mode, bounds=bounds):
|
with self.subTest(mode=mode, bounds=bounds):
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
implementation.FixedPatchStepper(cfg, bounds, context=context, coarse_boundary=mode)
|
implementation.FixedPatchStepper(cfg, context=context, coarse_boundary=mode,
|
||||||
|
refinements=[bounds])
|
||||||
context.activate.assert_not_called()
|
context.activate.assert_not_called()
|
||||||
# Both exact channel limits and the original periodic two-cell margin
|
# Both exact channel limits and the original periodic two-cell margin
|
||||||
# must reach context activation, with no allocation or device required.
|
# must reach context activation, with no allocation or device required.
|
||||||
@@ -102,7 +103,8 @@ class FaultGuardsCPU(unittest.TestCase):
|
|||||||
("periodic", (2, 2, 6, 5))):
|
("periodic", (2, 2, 6, 5))):
|
||||||
with self.subTest(mode=mode, bounds=bounds):
|
with self.subTest(mode=mode, bounds=bounds):
|
||||||
with self.assertRaisesRegex(RuntimeError, "validated before CUDA"):
|
with self.assertRaisesRegex(RuntimeError, "validated before CUDA"):
|
||||||
implementation.FixedPatchStepper(cfg, bounds, context=context, coarse_boundary=mode)
|
implementation.FixedPatchStepper(cfg, context=context, coarse_boundary=mode,
|
||||||
|
refinements=[bounds])
|
||||||
|
|
||||||
def fake_backend(self):
|
def fake_backend(self):
|
||||||
backend = PeriodicPatchStepper.__new__(PeriodicPatchStepper)
|
backend = PeriodicPatchStepper.__new__(PeriodicPatchStepper)
|
||||||
@@ -154,12 +156,12 @@ class FaultGuardsCPU(unittest.TestCase):
|
|||||||
context = Mock(activate=nullcontext, sm_arch="sm_70")
|
context = Mock(activate=nullcontext, sm_arch="sm_70")
|
||||||
with patch.object(implementation, "HALO", 2):
|
with patch.object(implementation, "HALO", 2):
|
||||||
with self.assertRaisesRegex(RuntimeError, "four-cell"):
|
with self.assertRaisesRegex(RuntimeError, "four-cell"):
|
||||||
PeriodicPatchStepper(cfg, (4, 4, 12, 12), context=context)
|
PeriodicPatchStepper(cfg, context=context, refinements=[(4, 4, 12, 12)])
|
||||||
p = implementation.FixedPatch2D.from_config(cfg, (4, 4, 12, 12))
|
p = implementation.FixedPatch2D.from_config(cfg, (4, 4, 12, 12))
|
||||||
with patch.object(cuda, "Stream"), patch.object(implementation.FixedPatch2D, "from_config",
|
with patch.object(cuda, "Stream"), patch.object(implementation.FixedPatch2D, "from_config",
|
||||||
return_value=replace(p, tau_coarse=.9)):
|
return_value=replace(p, tau_coarse=.9)):
|
||||||
with self.assertRaisesRegex(RuntimeError, "omega/tau"):
|
with self.assertRaisesRegex(RuntimeError, "omega/tau"):
|
||||||
PeriodicPatchStepper(cfg, p.bounds, context=context)
|
PeriodicPatchStepper(cfg, context=context, refinements=[p.bounds])
|
||||||
module = Mock()
|
module = Mock()
|
||||||
module.get_global.return_value = (Mock(), 16)
|
module.get_global.return_value = (Mock(), 16)
|
||||||
with patch.object(cuda, "Stream"), patch.object(compiler, "generate_config"), \
|
with patch.object(cuda, "Stream"), patch.object(compiler, "generate_config"), \
|
||||||
@@ -167,7 +169,7 @@ class FaultGuardsCPU(unittest.TestCase):
|
|||||||
patch.object(compiler, "load_module", return_value=module), \
|
patch.object(compiler, "load_module", return_value=module), \
|
||||||
patch.object(cuda, "memcpy_htod") as upload:
|
patch.object(cuda, "memcpy_htod") as upload:
|
||||||
with self.assertRaisesRegex(RuntimeError, "layout mismatch"):
|
with self.assertRaisesRegex(RuntimeError, "layout mismatch"):
|
||||||
PeriodicPatchStepper(cfg, p.bounds, context=context)
|
PeriodicPatchStepper(cfg, context=context, refinements=[p.bounds])
|
||||||
upload.assert_not_called()
|
upload.assert_not_called()
|
||||||
|
|
||||||
|
|
||||||
@@ -241,7 +243,7 @@ class NormalBuildGPU(unittest.TestCase):
|
|||||||
max_error = max_bc_error = 0.0
|
max_error = max_bc_error = 0.0
|
||||||
with CudaContext(0) as context:
|
with CudaContext(0) as context:
|
||||||
with patch.object(compiler, "generate_config", side_effect=record_config):
|
with patch.object(compiler, "generate_config", side_effect=record_config):
|
||||||
backend = implementation.FixedPatchStepper(cfg, bounds, context=context,
|
backend = implementation.FixedPatchStepper(cfg, context=context, refinements=[bounds],
|
||||||
coarse_boundary="slot_reservoir")
|
coarse_boundary="slot_reservoir")
|
||||||
with backend:
|
with backend:
|
||||||
self.assertEqual(len(generated), 2)
|
self.assertEqual(len(generated), 2)
|
||||||
@@ -311,7 +313,8 @@ class NormalBuildGPU(unittest.TestCase):
|
|||||||
for a in (initial.coarse_f, initial.fine_f)))
|
for a in (initial.coarse_f, initial.fine_f)))
|
||||||
max_pop = max_drift = max_moment = 0.0
|
max_pop = max_drift = max_moment = 0.0
|
||||||
with CudaContext(0) as context, PeriodicPatchStepper(
|
with CudaContext(0) as context, PeriodicPatchStepper(
|
||||||
LBMConfig(nx=16, ny=16, viscosity=.1), (4, 4, 12, 12), context=context) as backend:
|
LBMConfig(nx=16, ny=16, viscosity=.1), context=context,
|
||||||
|
refinements=[(4, 4, 12, 12)]) as backend:
|
||||||
backend.initialize(*postcollision(state, spec, maps))
|
backend.initialize(*postcollision(state, spec, maps))
|
||||||
before = totals(backend.download(), maps)
|
before = totals(backend.download(), maps)
|
||||||
for step in range(1, 9):
|
for step in range(1, 9):
|
||||||
@@ -342,7 +345,7 @@ class NormalBuildGPU(unittest.TestCase):
|
|||||||
fine_mask[4:-4, 4:-4] = True
|
fine_mask[4:-4, 4:-4] = True
|
||||||
initial[1][:, ~fine_mask] = np.nan
|
initial[1][:, ~fine_mask] = np.nan
|
||||||
expected = scalar_interval(*[a.astype(np.float64) for a in initial], bounds)
|
expected = scalar_interval(*[a.astype(np.float64) for a in initial], bounds)
|
||||||
with CudaContext(0) as context, PeriodicPatchStepper(cfg, bounds, context=context) as backend:
|
with CudaContext(0) as context, PeriodicPatchStepper(cfg, context=context, refinements=[bounds]) as backend:
|
||||||
self.assertEqual(backend.patch.fine_shape, (14, 16))
|
self.assertEqual(backend.patch.fine_shape, (14, 16))
|
||||||
p = backend.patch
|
p = backend.patch
|
||||||
allocated = 2 * 9 * (17*13+16*14) * 4 + sum(a.nbytes for a in
|
allocated = 2 * 9 * (17*13+16*14) * 4 + sum(a.nbytes for a in
|
||||||
|
|||||||
Reference in new issue
Block a user