examples/transport: tweak for profiling

This commit is contained in:
Robert Jördens 2016-02-16 17:42:28 +01:00
parent 2ce3c08697
commit c0bbd99bfa
2 changed files with 44 additions and 24 deletions

View File

@ -54,6 +54,18 @@
"class": "TTLOut", "class": "TTLOut",
"arguments": {"channel": 5} "arguments": {"channel": 5}
}, },
"ttl4": {
"type": "local",
"module": "artiq.coredevice.ttl",
"class": "TTLOut",
"arguments": {"channel": 6}
},
"ttl5": {
"type": "local",
"module": "artiq.coredevice.ttl",
"class": "TTLOut",
"arguments": {"channel": 7}
},
"ttl_sma": { "ttl_sma": {
"type": "local", "type": "local",
"module": "artiq.coredevice.ttl", "module": "artiq.coredevice.ttl",
@ -106,25 +118,25 @@
# that it always resolves to a network-visible IP address (see documentation). # that it always resolves to a network-visible IP address (see documentation).
"host": "::1", "host": "::1",
"port": 4000, "port": 4000,
"command": "pdq2_controller -p {port} --bind {bind} --simulation --dump qc_q1_0.bin" "command": "pdq2_controller --no-localhost-bind -p {port} --bind {bind} --simulation --dump qc_q1_0.bin"
}, },
"qc_q1_1": { "qc_q1_1": {
"type": "controller", "type": "controller",
"host": "::1", "host": "::1",
"port": 4001, "port": 4001,
"command": "pdq2_controller -p {port} --bind {bind} --simulation --dump qc_q1_1.bin" "command": "pdq2_controller --no-localhost-bind -p {port} --bind {bind} --simulation --dump qc_q1_1.bin"
}, },
"qc_q1_2": { "qc_q1_2": {
"type": "controller", "type": "controller",
"host": "::1", "host": "::1",
"port": 4002, "port": 4002,
"command": "pdq2_controller -p {port} --bind {bind} --simulation --dump qc_q1_2.bin" "command": "pdq2_controller --no-localhost-bind -p {port} --bind {bind} --simulation --dump qc_q1_2.bin"
}, },
"qc_q1_3": { "qc_q1_3": {
"type": "controller", "type": "controller",
"host": "::1", "host": "::1",
"port": 4003, "port": 4003,
"command": "pdq2_controller -p {port} --bind {bind} --simulation --dump qc_q1_3.bin" "command": "pdq2_controller --no-localhost-bind -p {port} --bind {bind} --simulation --dump qc_q1_3.bin"
}, },
"electrodes": { "electrodes": {
"type": "local", "type": "local",
@ -132,8 +144,8 @@
"class": "CompoundPDQ2", "class": "CompoundPDQ2",
"arguments": { "arguments": {
"pdq2_devices": ["qc_q1_0", "qc_q1_1", "qc_q1_2", "qc_q1_3"], "pdq2_devices": ["qc_q1_0", "qc_q1_1", "qc_q1_2", "qc_q1_3"],
"trigger_device": "ttl3", "trigger_device": "ttl2",
"frame_devices": ["ttl0", "ttl1", "ttl2"] "frame_devices": ["ttl3", "ttl4", "ttl5"]
} }
}, },

View File

@ -3,29 +3,29 @@
import numpy as np import numpy as np
from artiq.experiment import * from artiq.experiment import *
from artiq.wavesynth.coefficients import SplineSource from artiq.wavesynth.coefficients import SplineSource
transport = SplineSource( transport = SplineSource(
x=np.linspace(0, 10, 101), # waveform time x=np.linspace(0, 10, 101), # waveform time
y=np.random.rand(4*3*3, 101)*1e-6, # waveform data, y=np.random.rand(4*3*3, 101)*1e-6, # waveform data,
# 4 devices, 3 board each, 3 dacs each # 4 devices, 3 board each, 3 dacs each
) )
class Transport(EnvExperiment): class Transport(EnvExperiment):
"""Transport""" """Transport"""
def build(self): def build(self):
self.core = self.get_device("core") self.setattr_device("core")
self.bd_sw = self.get_device("bd_sw") self.setattr_device("bd_sw")
self.pmt = self.get_device("pmt") self.setattr_device("pmt")
self.electrodes = self.get_device("electrodes") self.setattr_device("electrodes")
self.wait_at_stop = self.get_argument("wait_at_stop", self.setattr_argument("wait_at_stop", NumberValue(100*us))
NumberValue(100*us)) self.setattr_argument("speed", NumberValue(1.5))
self.speed = self.get_argument("speed", NumberValue(1.5)) self.setattr_argument("repeats", NumberValue(100))
self.repeats = self.get_argument("repeats", NumberValue(100)) self.setattr_argument("bins", NumberValue(100))
self.nbins = self.get_argument("nbins", NumberValue(100))
def calc_waveforms(self, stop): def calc_waveforms(self, stop):
self.electrodes.disarm() self.electrodes.disarm()
@ -74,26 +74,34 @@ class Transport(EnvExperiment):
@kernel @kernel
def repeat(self): def repeat(self):
self.histogram[:] = [0 for _ in range(self.nbins)] hist = [0 for _ in range(self.bins)]
for i in range(self.repeats): for i in range(self.repeats):
n = self.one() n = self.one()
if n >= self.nbins: if n >= self.bins:
n = self.nbins - 1 n = self.bins - 1
self.histogram[n] += 1 hist[n] += 1
self.set_dataset("hist", hist)
def scan(self, stops): def scan(self, stops):
for s in stops: for s in stops:
self.histogram = [] self.histogram = [0 for _ in range(self.bins)]
# non-kernel, build frames # non-kernel, build frames
# could also be rpc'ed from repeat() # could also be rpc'ed from repeat()
self.calc_waveforms(s) self.calc_waveforms(s)
# kernel part # kernel part
self.repeat() self.repeat()
# live update 2d plot with current self.histogram
# broadcast(s, self.histogram)
def run(self): def run(self):
# scan transport endpoint # scan transport endpoint
stops = range(10, len(transport.x), 10) stops = range(10, len(transport.x), 10)
self.scan(stops) self.scan(stops)
# class Benchmark(Transport):
# def build(self):
# Transport.build(self)
# self.calc_waveforms(.3)
#
# @kernel
# def run(self):
# self.repeat()