Skip to content

Commit c0bbd99

Browse files
committedFeb 16, 2016
examples/transport: tweak for profiling
1 parent 2ce3c08 commit c0bbd99

File tree

2 files changed

+44
-24
lines changed

2 files changed

+44
-24
lines changed
 

Diff for: ‎examples/master/device_db.pyon

+18-6
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,18 @@
5454
"class": "TTLOut",
5555
"arguments": {"channel": 5}
5656
},
57+
"ttl4": {
58+
"type": "local",
59+
"module": "artiq.coredevice.ttl",
60+
"class": "TTLOut",
61+
"arguments": {"channel": 6}
62+
},
63+
"ttl5": {
64+
"type": "local",
65+
"module": "artiq.coredevice.ttl",
66+
"class": "TTLOut",
67+
"arguments": {"channel": 7}
68+
},
5769
"ttl_sma": {
5870
"type": "local",
5971
"module": "artiq.coredevice.ttl",
@@ -106,34 +118,34 @@
106118
# that it always resolves to a network-visible IP address (see documentation).
107119
"host": "::1",
108120
"port": 4000,
109-
"command": "pdq2_controller -p {port} --bind {bind} --simulation --dump qc_q1_0.bin"
121+
"command": "pdq2_controller --no-localhost-bind -p {port} --bind {bind} --simulation --dump qc_q1_0.bin"
110122
},
111123
"qc_q1_1": {
112124
"type": "controller",
113125
"host": "::1",
114126
"port": 4001,
115-
"command": "pdq2_controller -p {port} --bind {bind} --simulation --dump qc_q1_1.bin"
127+
"command": "pdq2_controller --no-localhost-bind -p {port} --bind {bind} --simulation --dump qc_q1_1.bin"
116128
},
117129
"qc_q1_2": {
118130
"type": "controller",
119131
"host": "::1",
120132
"port": 4002,
121-
"command": "pdq2_controller -p {port} --bind {bind} --simulation --dump qc_q1_2.bin"
133+
"command": "pdq2_controller --no-localhost-bind -p {port} --bind {bind} --simulation --dump qc_q1_2.bin"
122134
},
123135
"qc_q1_3": {
124136
"type": "controller",
125137
"host": "::1",
126138
"port": 4003,
127-
"command": "pdq2_controller -p {port} --bind {bind} --simulation --dump qc_q1_3.bin"
139+
"command": "pdq2_controller --no-localhost-bind -p {port} --bind {bind} --simulation --dump qc_q1_3.bin"
128140
},
129141
"electrodes": {
130142
"type": "local",
131143
"module": "artiq.devices.pdq2",
132144
"class": "CompoundPDQ2",
133145
"arguments": {
134146
"pdq2_devices": ["qc_q1_0", "qc_q1_1", "qc_q1_2", "qc_q1_3"],
135-
"trigger_device": "ttl3",
136-
"frame_devices": ["ttl0", "ttl1", "ttl2"]
147+
"trigger_device": "ttl2",
148+
"frame_devices": ["ttl3", "ttl4", "ttl5"]
137149
}
138150
},
139151

Diff for: ‎examples/master/repository/coredevice_examples/transport.py

+26-18
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,29 @@
33
import numpy as np
44

55
from artiq.experiment import *
6-
76
from artiq.wavesynth.coefficients import SplineSource
87

8+
99
transport = SplineSource(
1010
x=np.linspace(0, 10, 101), # waveform time
1111
y=np.random.rand(4*3*3, 101)*1e-6, # waveform data,
1212
# 4 devices, 3 board each, 3 dacs each
1313
)
1414

15+
1516
class Transport(EnvExperiment):
1617
"""Transport"""
1718

1819
def build(self):
19-
self.core = self.get_device("core")
20-
self.bd_sw = self.get_device("bd_sw")
21-
self.pmt = self.get_device("pmt")
22-
self.electrodes = self.get_device("electrodes")
20+
self.setattr_device("core")
21+
self.setattr_device("bd_sw")
22+
self.setattr_device("pmt")
23+
self.setattr_device("electrodes")
2324

24-
self.wait_at_stop = self.get_argument("wait_at_stop",
25-
NumberValue(100*us))
26-
self.speed = self.get_argument("speed", NumberValue(1.5))
27-
self.repeats = self.get_argument("repeats", NumberValue(100))
28-
self.nbins = self.get_argument("nbins", NumberValue(100))
25+
self.setattr_argument("wait_at_stop", NumberValue(100*us))
26+
self.setattr_argument("speed", NumberValue(1.5))
27+
self.setattr_argument("repeats", NumberValue(100))
28+
self.setattr_argument("bins", NumberValue(100))
2929

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

7575
@kernel
7676
def repeat(self):
77-
self.histogram[:] = [0 for _ in range(self.nbins)]
78-
77+
hist = [0 for _ in range(self.bins)]
7978
for i in range(self.repeats):
8079
n = self.one()
81-
if n >= self.nbins:
82-
n = self.nbins - 1
83-
self.histogram[n] += 1
80+
if n >= self.bins:
81+
n = self.bins - 1
82+
hist[n] += 1
83+
self.set_dataset("hist", hist)
8484

8585
def scan(self, stops):
8686
for s in stops:
87-
self.histogram = []
87+
self.histogram = [0 for _ in range(self.bins)]
8888
# non-kernel, build frames
8989
# could also be rpc'ed from repeat()
9090
self.calc_waveforms(s)
9191
# kernel part
9292
self.repeat()
93-
# live update 2d plot with current self.histogram
94-
# broadcast(s, self.histogram)
9593

9694
def run(self):
9795
# scan transport endpoint
9896
stops = range(10, len(transport.x), 10)
9997
self.scan(stops)
98+
99+
100+
# class Benchmark(Transport):
101+
# def build(self):
102+
# Transport.build(self)
103+
# self.calc_waveforms(.3)
104+
#
105+
# @kernel
106+
# def run(self):
107+
# self.repeat()

0 commit comments

Comments
 (0)
Please sign in to comment.