forked from M-Labs/artiq
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:
parent
7a5d28b73d
commit
90c9fa446f
|
@ -22,6 +22,10 @@ class _Transfer(EnvExperiment):
|
||||||
def sink(self, data):
|
def sink(self, data):
|
||||||
assert data == self.data
|
assert data == self.data
|
||||||
|
|
||||||
|
@rpc(flags={"async"})
|
||||||
|
def sink_array(self, data):
|
||||||
|
assert data == [0]*(1 << 15)
|
||||||
|
|
||||||
@kernel
|
@kernel
|
||||||
def host_to_device(self):
|
def host_to_device(self):
|
||||||
t0 = self.core.get_rtio_counter_mu()
|
t0 = self.core.get_rtio_counter_mu()
|
||||||
|
@ -36,6 +40,16 @@ class _Transfer(EnvExperiment):
|
||||||
t1 = self.core.get_rtio_counter_mu()
|
t1 = self.core.get_rtio_counter_mu()
|
||||||
return len(self.data)/self.core.mu_to_seconds(t1-t0)
|
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):
|
class TransferTest(ExperimentCase):
|
||||||
@unittest.skipUnless(artiq_low_latency,
|
@unittest.skipUnless(artiq_low_latency,
|
||||||
|
@ -54,6 +68,14 @@ class TransferTest(ExperimentCase):
|
||||||
print(device_to_host_rate, "B/s")
|
print(device_to_host_rate, "B/s")
|
||||||
self.assertGreater(device_to_host_rate, 2.3e6)
|
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):
|
class _KernelOverhead(EnvExperiment):
|
||||||
def build(self):
|
def build(self):
|
||||||
|
|
Loading…
Reference in New Issue