Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
32da2d7324 | ||
|
|
56004f4482 |
No files matched your search
@@ -50,7 +50,7 @@ def test_masks_and_minimal_footprint():
|
|||||||
def test_actual_closure_read_conflicts():
|
def test_actual_closure_read_conflicts():
|
||||||
pair, layout, targets = transfer((6, 6, 18, 14))
|
pair, layout, targets = transfer((6, 6, 18, 14))
|
||||||
validate_channel_transfers(pair, layout, targets)
|
validate_channel_transfers(pair, layout, targets)
|
||||||
for target in (layout.slot(layout.owner[5, -1]-1, 2),
|
for target in (layout.slot(int(layout.owner[5, -1]) - 1, 2),
|
||||||
layout.slot(layout.owner[1, 4], 4),
|
layout.slot(layout.owner[1, 4], 4),
|
||||||
layout.slot(layout.owner[-2, 4], 3)):
|
layout.slot(layout.owner[-2, 4], 3)):
|
||||||
with pytest.raises(ValueError, match="immutable"):
|
with pytest.raises(ValueError, match="immutable"):
|
||||||
|
|||||||
@@ -78,13 +78,15 @@ class ShiftedStorage(unittest.TestCase):
|
|||||||
|
|
||||||
def test_shifted_density_and_tag_validation(self):
|
def test_shifted_density_and_tag_validation(self):
|
||||||
old,new = topology(A),topology(B)
|
old,new = topology(A),topology(B)
|
||||||
a = tuple(np.where(m[None], np.float32(-.001), np.nan).repeat(9,axis=0) for m in old.leaf_masks)
|
a = tuple(np.where(m[None], np.float32(-.001), np.float32(np.nan)).repeat(9,axis=0)
|
||||||
|
for m in old.leaf_masks) # FP32 under numpy 1 and 2 promotion rules
|
||||||
remap(old,new,a)
|
remap(old,new,a)
|
||||||
with self.assertRaisesRegex(ValueError,'representation'): remap(old,new,a,False)
|
with self.assertRaisesRegex(ValueError,'representation'): remap(old,new,a,False)
|
||||||
with self.assertRaisesRegex(ValueError,'FP32'): remap(old,new,tuple(x.astype(np.float64) for x in a))
|
with self.assertRaisesRegex(ValueError,'FP32'): remap(old,new,tuple(x.astype(np.float64) for x in a))
|
||||||
a[0][:,old.leaf_masks[0]] = -1
|
a[0][:,old.leaf_masks[0]] = -1
|
||||||
with self.assertRaisesRegex(ValueError,'positive density'): remap(old,new,a)
|
with self.assertRaisesRegex(ValueError,'positive density'): remap(old,new,a)
|
||||||
rest = tuple(np.where(m[None],np.float32(0),np.nan).repeat(9,axis=0) for m in old.leaf_masks)
|
rest = tuple(np.where(m[None],np.float32(0),np.float32(np.nan)).repeat(9,axis=0)
|
||||||
|
for m in old.leaf_masks)
|
||||||
remap(old,new,rest)
|
remap(old,new,rest)
|
||||||
with self.assertRaisesRegex(ValueError,'positive density'):
|
with self.assertRaisesRegex(ValueError,'positive density'):
|
||||||
remap_synchronized(old,new,rest,base_count=7,level_steps=(7,14,28),phase='postcollision_g')
|
remap_synchronized(old,new,rest,base_count=7,level_steps=(7,14,28),phase='postcollision_g')
|
||||||
|
|||||||
@@ -192,6 +192,7 @@ class CpuContracts(unittest.TestCase):
|
|||||||
backend._lock = RLock()
|
backend._lock = RLock()
|
||||||
backend._status = "ready"
|
backend._status = "ready"
|
||||||
backend._step_count = 0
|
backend._step_count = 0
|
||||||
|
backend._ddf_shifting = False # unshifted storage, as for the default config
|
||||||
backend._stream = Mock()
|
backend._stream = Mock()
|
||||||
backend._module = Mock()
|
backend._module = Mock()
|
||||||
backend._copy = backend._step = Mock()
|
backend._copy = backend._step = Mock()
|
||||||
|
|||||||
@@ -281,7 +281,8 @@ def test_fine_surface_four_hops(speed):
|
|||||||
@pytest.mark.parametrize("missing", ["surface_velocity_gpu", "link_exchange_gpu"])
|
@pytest.mark.parametrize("missing", ["surface_velocity_gpu", "link_exchange_gpu"])
|
||||||
def test_missing_surface_device_buffer_rejects_before_launch(missing):
|
def test_missing_surface_device_buffer_rejects_before_launch(missing):
|
||||||
backend = implementation.FixedPatchStepper.__new__(implementation.FixedPatchStepper)
|
backend = implementation.FixedPatchStepper.__new__(implementation.FixedPatchStepper)
|
||||||
backend.fine_boundary = SimpleNamespace(objects=[object_spec(.002)])
|
backend._boundary_hosts = [None, SimpleNamespace(objects=[object_spec(.002)])]
|
||||||
|
backend._level_jets = [(), ()]
|
||||||
backend._fine_curved = SimpleNamespace(fluid_idx_gpu=object(),
|
backend._fine_curved = SimpleNamespace(fluid_idx_gpu=object(),
|
||||||
surface_velocity_gpu=object(), link_exchange_gpu=object())
|
surface_velocity_gpu=object(), link_exchange_gpu=object())
|
||||||
setattr(backend._fine_curved, missing, None)
|
setattr(backend._fine_curved, missing, None)
|
||||||
|
|||||||
@@ -106,7 +106,9 @@ class FaultGuardsCPU(unittest.TestCase):
|
|||||||
|
|
||||||
def fake_backend(self):
|
def fake_backend(self):
|
||||||
backend = PeriodicPatchStepper.__new__(PeriodicPatchStepper)
|
backend = PeriodicPatchStepper.__new__(PeriodicPatchStepper)
|
||||||
backend.fine_layout = None # dense fine storage
|
backend._layouts = [None, None] # dense storage on both levels
|
||||||
|
backend._ddf_shifting = False # unshifted on every level, as _check_storage expects
|
||||||
|
backend._level_cfgs = [LBMConfig(nx=16, ny=16, viscosity=.1)] * 2 # ddf_shifting off
|
||||||
backend.ctx = Mock(activate=nullcontext)
|
backend.ctx = Mock(activate=nullcontext)
|
||||||
backend._lock = RLock()
|
backend._lock = RLock()
|
||||||
backend._status = "ready"
|
backend._status = "ready"
|
||||||
@@ -158,7 +160,9 @@ class FaultGuardsCPU(unittest.TestCase):
|
|||||||
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"):
|
# The hierarchy rejects a pair tau that disagrees with its level config
|
||||||
|
# (hierarchy.py) before the per-level omega/tau check can be reached.
|
||||||
|
with self.assertRaisesRegex(RuntimeError, "config chain is inconsistent"):
|
||||||
PeriodicPatchStepper(cfg, p.bounds, context=context)
|
PeriodicPatchStepper(cfg, p.bounds, context=context)
|
||||||
module = Mock()
|
module = Mock()
|
||||||
module.get_global.return_value = (Mock(), 16)
|
module.get_global.return_value = (Mock(), 16)
|
||||||
|
|||||||
@@ -80,12 +80,11 @@ class ThreeLevelCPU(unittest.TestCase):
|
|||||||
f, g = run._levels[1:]
|
f, g = run._levels[1:]
|
||||||
b = g.boundary
|
b = g.boundary
|
||||||
events, feeds = [], []
|
events, feeds = [], []
|
||||||
advance, gather = run._advance, run._gather_halo
|
advance, gather = run._advance_child, run._gather_halo
|
||||||
def record_feed(index, buffer, **kw): # index 2: L1 hop feeds L2
|
def record_feed(buffer, **kw):
|
||||||
if index == 2:
|
self.assertIs(buffer, (f.current, f.spare)[len(feeds)])
|
||||||
self.assertIs(buffer, (f.current, f.spare)[len(feeds)])
|
feeds.append(buffer)
|
||||||
feeds.append(buffer)
|
advance(buffer, **kw)
|
||||||
advance(index, buffer, **kw)
|
|
||||||
def record_halo(level, buffer, **kw):
|
def record_halo(level, buffer, **kw):
|
||||||
if level is g:
|
if level is g:
|
||||||
events.append(("halo", buffer))
|
events.append(("halo", buffer))
|
||||||
@@ -96,7 +95,7 @@ class ThreeLevelCPU(unittest.TestCase):
|
|||||||
self.assertIs(kind, g.kind)
|
self.assertIs(kind, g.kind)
|
||||||
events.append(("step", src))
|
events.append(("step", src))
|
||||||
g.kernel.side_effect = record_step
|
g.kernel.side_effect = record_step
|
||||||
with patch.object(run, "_advance", side_effect=record_feed), \
|
with patch.object(run, "_advance_child", side_effect=record_feed), \
|
||||||
patch.object(run, "_gather_halo", side_effect=record_halo):
|
patch.object(run, "_gather_halo", side_effect=record_halo):
|
||||||
run.step()
|
run.step()
|
||||||
self.assertEqual(feeds, [f.current, f.spare])
|
self.assertEqual(feeds, [f.current, f.spare])
|
||||||
@@ -106,8 +105,8 @@ class ThreeLevelCPU(unittest.TestCase):
|
|||||||
self.assertGreater(len(np.unique(b.tables["block"])), 1)
|
self.assertGreater(len(np.unique(b.tables["block"])), 1)
|
||||||
# Negative control: reusing L1's old source at the midpoint must fail.
|
# Negative control: reusing L1's old source at the midpoint must fail.
|
||||||
feeds.clear()
|
feeds.clear()
|
||||||
with patch.object(run, "_advance", side_effect=lambda index, buffer, **kw:
|
with patch.object(run, "_advance_child", side_effect=lambda buffer, **kw:
|
||||||
record_feed(index, f.current if index == 2 else buffer, **kw)):
|
record_feed(f.current, **kw)):
|
||||||
with self.assertRaises(AssertionError):
|
with self.assertRaises(AssertionError):
|
||||||
run.step()
|
run.step()
|
||||||
run.close()
|
run.close()
|
||||||
@@ -173,12 +172,11 @@ class ThreeLevelGPU(unittest.TestCase):
|
|||||||
p1, p2 = run.patch, run.child_patch
|
p1, p2 = run.patch, run.child_patch
|
||||||
run.initialize(state(16, 16, 1), state(*p1.fine_shape, 2), state(*p2.fine_shape, 3))
|
run.initialize(state(16, 16, 1), state(*p1.fine_shape, 2), state(*p2.fine_shape, 3))
|
||||||
f = run._levels[1]
|
f = run._levels[1]
|
||||||
feeds, original = [], run._advance
|
feeds, original = [], run._advance_child
|
||||||
def record(index, buffer, **kw): # index 2: L1 hop feeds L2
|
def record(buffer, **kw):
|
||||||
if index == 2:
|
feeds.append(int(buffer))
|
||||||
feeds.append(int(buffer))
|
original(buffer, **kw)
|
||||||
original(index, buffer, **kw)
|
with patch.object(run, "_advance_child", side_effect=record):
|
||||||
with patch.object(run, "_advance", side_effect=record):
|
|
||||||
cur, spare = int(f.current), int(f.spare)
|
cur, spare = int(f.current), int(f.spare)
|
||||||
run.step(1)
|
run.step(1)
|
||||||
self.assertEqual(feeds, [cur, spare]) # current G, then the new G of hop 1
|
self.assertEqual(feeds, [cur, spare]) # current G, then the new G of hop 1
|
||||||
|
|||||||
Reference in new issue
Block a user