Skip to content

Commit

Permalink
examples/transport: tweak for profiling
Browse files Browse the repository at this point in the history
jordens committed Feb 16, 2016
1 parent 2ce3c08 commit c0bbd99
Showing 2 changed files with 44 additions and 24 deletions.
24 changes: 18 additions & 6 deletions examples/master/device_db.pyon
Original file line number Diff line number Diff line change
@@ -54,6 +54,18 @@
"class": "TTLOut",
"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": {
"type": "local",
"module": "artiq.coredevice.ttl",
@@ -106,34 +118,34 @@
# that it always resolves to a network-visible IP address (see documentation).
"host": "::1",
"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": {
"type": "controller",
"host": "::1",
"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": {
"type": "controller",
"host": "::1",
"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": {
"type": "controller",
"host": "::1",
"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": {
"type": "local",
"module": "artiq.devices.pdq2",
"class": "CompoundPDQ2",
"arguments": {
"pdq2_devices": ["qc_q1_0", "qc_q1_1", "qc_q1_2", "qc_q1_3"],
"trigger_device": "ttl3",
"frame_devices": ["ttl0", "ttl1", "ttl2"]
"trigger_device": "ttl2",
"frame_devices": ["ttl3", "ttl4", "ttl5"]
}
},

44 changes: 26 additions & 18 deletions examples/master/repository/coredevice_examples/transport.py
Original file line number Diff line number Diff line change
@@ -3,29 +3,29 @@
import numpy as np

from artiq.experiment import *

from artiq.wavesynth.coefficients import SplineSource


transport = SplineSource(
x=np.linspace(0, 10, 101), # waveform time
y=np.random.rand(4*3*3, 101)*1e-6, # waveform data,
# 4 devices, 3 board each, 3 dacs each
)


class Transport(EnvExperiment):
"""Transport"""

def build(self):
self.core = self.get_device("core")
self.bd_sw = self.get_device("bd_sw")
self.pmt = self.get_device("pmt")
self.electrodes = self.get_device("electrodes")
self.setattr_device("core")
self.setattr_device("bd_sw")
self.setattr_device("pmt")
self.setattr_device("electrodes")

self.wait_at_stop = self.get_argument("wait_at_stop",
NumberValue(100*us))
self.speed = self.get_argument("speed", NumberValue(1.5))
self.repeats = self.get_argument("repeats", NumberValue(100))
self.nbins = self.get_argument("nbins", NumberValue(100))
self.setattr_argument("wait_at_stop", NumberValue(100*us))
self.setattr_argument("speed", NumberValue(1.5))
self.setattr_argument("repeats", NumberValue(100))
self.setattr_argument("bins", NumberValue(100))

def calc_waveforms(self, stop):
self.electrodes.disarm()
@@ -74,26 +74,34 @@ def one(self):

@kernel
def repeat(self):
self.histogram[:] = [0 for _ in range(self.nbins)]

hist = [0 for _ in range(self.bins)]
for i in range(self.repeats):
n = self.one()
if n >= self.nbins:
n = self.nbins - 1
self.histogram[n] += 1
if n >= self.bins:
n = self.bins - 1
hist[n] += 1
self.set_dataset("hist", hist)

def scan(self, stops):
for s in stops:
self.histogram = []
self.histogram = [0 for _ in range(self.bins)]
# non-kernel, build frames
# could also be rpc'ed from repeat()
self.calc_waveforms(s)
# kernel part
self.repeat()
# live update 2d plot with current self.histogram
# broadcast(s, self.histogram)

def run(self):
# scan transport endpoint
stops = range(10, len(transport.x), 10)
self.scan(stops)


# class Benchmark(Transport):
# def build(self):
# Transport.build(self)
# self.calc_waveforms(.3)
#
# @kernel
# def run(self):
# self.repeat()

0 comments on commit c0bbd99

Please sign in to comment.