Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f47436073 |
@@ -80,11 +80,12 @@ 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_child, run._gather_halo
|
advance, gather = run._advance, run._gather_halo
|
||||||
def record_feed(buffer, **kw):
|
def record_feed(index, buffer, **kw): # index 2: L1 hop feeds L2
|
||||||
|
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))
|
||||||
@@ -95,7 +96,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_child", side_effect=record_feed), \
|
with patch.object(run, "_advance", 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])
|
||||||
@@ -105,8 +106,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_child", side_effect=lambda buffer, **kw:
|
with patch.object(run, "_advance", side_effect=lambda index, buffer, **kw:
|
||||||
record_feed(f.current, **kw)):
|
record_feed(index, f.current if index == 2 else buffer, **kw)):
|
||||||
with self.assertRaises(AssertionError):
|
with self.assertRaises(AssertionError):
|
||||||
run.step()
|
run.step()
|
||||||
run.close()
|
run.close()
|
||||||
@@ -172,11 +173,12 @@ 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_child
|
feeds, original = [], run._advance
|
||||||
def record(buffer, **kw):
|
def record(index, buffer, **kw): # index 2: L1 hop feeds L2
|
||||||
|
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