forked from M-Labs/artiq
1
0
Fork 0

test: relax timing requirements when not using DMA handle

core_dma.playback() without handle incurs a round-trip with the comms
CPU and should not be used in critical real-time sections.

Closes #834.
This commit is contained in:
Sebastien Bourdeauducq 2017-10-30 22:57:12 +08:00
parent acb25f549b
commit 9bf189ca10
1 changed files with 20 additions and 10 deletions

View File

@ -491,7 +491,7 @@ class RPCTest(ExperimentCase):
class _DMA(EnvExperiment): class _DMA(EnvExperiment):
def build(self, trace_name="foobar"): def build(self, trace_name="test_rtio"):
self.setattr_device("core") self.setattr_device("core")
self.setattr_device("core_dma") self.setattr_device("core_dma")
self.setattr_device("ttl1") self.setattr_device("ttl1")
@ -499,8 +499,12 @@ class _DMA(EnvExperiment):
self.delta = np.int64(0) self.delta = np.int64(0)
@kernel @kernel
def record(self): def record(self, for_handle=True):
with self.core_dma.record(self.trace_name): with self.core_dma.record(self.trace_name):
# When not using the handle, retrieving the DMA trace
# in dma.playback() can be slow. Allow some time.
if not for_handle:
delay(1*ms)
delay(100*ns) delay(100*ns)
self.ttl1.on() self.ttl1.on()
delay(100*ns) delay(100*ns)
@ -519,20 +523,22 @@ class _DMA(EnvExperiment):
self.set_dataset("dma_record_time", self.core.mu_to_seconds(t2 - t1)) self.set_dataset("dma_record_time", self.core.mu_to_seconds(t2 - t1))
@kernel @kernel
def playback(self, use_handle=False): def playback(self, use_handle=True):
self.core.break_realtime()
start = now_mu()
if use_handle: if use_handle:
handle = self.core_dma.get_handle(self.trace_name) handle = self.core_dma.get_handle(self.trace_name)
self.core.break_realtime()
start = now_mu()
self.core_dma.playback_handle(handle) self.core_dma.playback_handle(handle)
else: else:
self.core.break_realtime()
start = now_mu()
self.core_dma.playback(self.trace_name) self.core_dma.playback(self.trace_name)
self.delta = now_mu() - start self.delta = now_mu() - start
@kernel @kernel
def playback_many(self, n): def playback_many(self, n):
self.core.break_realtime()
handle = self.core_dma.get_handle(self.trace_name) handle = self.core_dma.get_handle(self.trace_name)
self.core.break_realtime()
t1 = self.core.get_rtio_counter_mu() t1 = self.core.get_rtio_counter_mu()
for i in range(n): for i in range(n):
self.core_dma.playback_handle(handle) self.core_dma.playback_handle(handle)
@ -579,9 +585,9 @@ class DMATest(ExperimentCase):
core_host = self.device_mgr.get_desc("core")["arguments"]["host"] core_host = self.device_mgr.get_desc("core")["arguments"]["host"]
exp = self.create(_DMA) exp = self.create(_DMA)
exp.record()
for use_handle in [False, True]: for use_handle in [False, True]:
exp.record(use_handle)
get_analyzer_dump(core_host) # clear analyzer buffer get_analyzer_dump(core_host) # clear analyzer buffer
exp.playback(use_handle) exp.playback(use_handle)
@ -603,9 +609,13 @@ class DMATest(ExperimentCase):
exp = self.create(_DMA) exp = self.create(_DMA)
exp.record() exp.record()
for use_handle in [False, True]: exp.record(False)
exp.playback(use_handle) exp.playback(False)
self.assertEqual(exp.delta, 200) self.assertEqual(exp.delta, 1000200)
exp.record(True)
exp.playback(True)
self.assertEqual(exp.delta, 200)
def test_dma_record_time(self): def test_dma_record_time(self):
exp = self.create(_DMA) exp = self.create(_DMA)