test: add array transfer test

200 kB/s, more than a factor of 10 slower than the bare string transfer

Signed-off-by: Robert Jördens <rj@quartiq.de>
This commit is contained in:
Robert Jördens 2019-01-28 14:29:53 +00:00
parent 7a5d28b73d
commit 90c9fa446f
1 changed files with 22 additions and 0 deletions

View File

@ -22,6 +22,10 @@ class _Transfer(EnvExperiment):
def sink(self, data):
assert data == self.data
@rpc(flags={"async"})
def sink_array(self, data):
assert data == [0]*(1 << 15)
@kernel
def host_to_device(self):
t0 = self.core.get_rtio_counter_mu()
@ -36,6 +40,16 @@ class _Transfer(EnvExperiment):
t1 = self.core.get_rtio_counter_mu()
return len(self.data)/self.core.mu_to_seconds(t1-t0)
@kernel
def device_to_host_array(self):
#data = [[0]*8 for _ in range(1 << 12)]
data = [0]*(1 << 15)
t0 = self.core.get_rtio_counter_mu()
self.sink_array(data)
t1 = self.core.get_rtio_counter_mu()
return ((len(data)*4)/
self.core.mu_to_seconds(t1-t0))
class TransferTest(ExperimentCase):
@unittest.skipUnless(artiq_low_latency,
@ -54,6 +68,14 @@ class TransferTest(ExperimentCase):
print(device_to_host_rate, "B/s")
self.assertGreater(device_to_host_rate, 2.3e6)
@unittest.skipUnless(artiq_low_latency,
"timings are dependent on CPU load and network conditions")
def test_device_to_host_array(self):
exp = self.create(_Transfer)
rate = exp.device_to_host_array()
print(rate, "B/s")
self.assertGreater(rate, .15e6)
class _KernelOverhead(EnvExperiment):
def build(self):