Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/artiq
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ef2af8c3311a
Choose a base ref
...
head repository: m-labs/artiq
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c8dc6ca07c12
Choose a head ref
  • 2 commits
  • 19 files changed
  • 1 contributor

Commits on Jun 28, 2016

  1. Revert "runtime: save now on RPC"

    This reverts commit 155794a.
    sbourdeauducq committed Jun 28, 2016
    Copy the full SHA
    ef8f60c View commit details
  2. Copy the full SHA
    c8dc6ca View commit details
19 changes: 17 additions & 2 deletions artiq/coredevice/core.py
Original file line number Diff line number Diff line change
@@ -37,6 +37,10 @@ def __str__(self):
return "\n" + _render_diagnostic(self.diagnostic, colored=colors_supported)


@syscall
def rtio_init():
raise NotImplementedError("syscall not simulated")

@syscall(flags={"nounwind", "nowrite"})
def rtio_get_counter() -> TInt64:
raise NotImplementedError("syscall not simulated")
@@ -121,10 +125,21 @@ def set_result(new_result):
def get_rtio_counter_mu(self):
return rtio_get_counter()

@kernel
def reset(self):
"""Clear RTIO FIFOs, release RTIO PHY reset, and set the time cursor
at the current value of the hardware RTIO counter plus a margin of
125000 machine units."""
rtio_init()
at_mu(rtio_get_counter() + 125000)

@kernel
def break_realtime(self):
"""Set the timeline to the current value of the hardware RTIO counter
plus a margin of 125000 machine units."""
"""Set the time cursor after the current value of the hardware RTIO
counter plus a margin of 125000 machine units.
If the time cursor is already after that position, this function
does nothing."""
min_now = rtio_get_counter() + 125000
if now_mu() < min_now:
at_mu(min_now)
21 changes: 21 additions & 0 deletions artiq/examples/master/idle_kernel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from artiq.experiment import *


class IdleKernel(EnvExperiment):
def build(self):
self.setattr_device("core")
self.setattr_device("led")

@kernel
def run(self):
start_time = now_mu() + seconds_to_mu(500*ms)
while self.core.get_rtio_counter_mu() < start_time:
pass
self.core.reset()
while True:
self.led.pulse(250*ms)
delay(125*ms)
self.led.pulse(125*ms)
delay(125*ms)
self.led.pulse(125*ms)
delay(250*ms)
Original file line number Diff line number Diff line change
@@ -38,6 +38,7 @@ def one(self):
return self.pmt.count()

def run(self):
self.core.reset()
offsets = np.arange(0, 3)
for o in offsets:
self.setup(o)
Original file line number Diff line number Diff line change
@@ -48,6 +48,7 @@ def cool_detect(self):

@kernel
def run(self):
self.core.reset()
self.program_cooling()

hist = [0 for _ in range(self.nbins)]
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ def build(self):

@kernel
def run(self):
self.core.reset()
self.dac.setup_bus(write_div=30, read_div=40)
self.dac.write_offsets()
self.led.on()
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ def build(self):

@kernel
def run(self):
self.core.reset()
while True:
self.led.pulse(100*ms)
delay(100*ms)
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ def build(self):

@kernel
def run(self):
self.core.reset()
with self.core_dds.batch:
self.dds1.set(120*MHz)
self.dds2.set(200*MHz)
Original file line number Diff line number Diff line change
@@ -12,5 +12,6 @@ def blink_once(self):
delay(250*ms)

def run(self):
self.core.reset()
while True:
self.blink_once()
Original file line number Diff line number Diff line change
@@ -36,6 +36,7 @@ def build(self):
self.setattr_device("ttl2")

def run(self):
self.core.reset()
n = 1000 # repetitions
latency = 50e-9 # calibrated latency without a transmission line
pulse = 1e-6 # pulse length, larger than rtt
Original file line number Diff line number Diff line change
@@ -91,6 +91,7 @@ def scan(self, stops):
self.repeat()

def run(self):
self.core.reset()
# scan transport endpoint
stops = np.linspace(0, 10, 10)
self.scan(stops)
2 changes: 1 addition & 1 deletion artiq/runtime/kloader.c
Original file line number Diff line number Diff line change
@@ -149,7 +149,7 @@ int kloader_is_essential_kmsg(int msgtype)
}
}

long long int now;
static long long int now = 0;

void kloader_service_essential_kmsg(void)
{
2 changes: 0 additions & 2 deletions artiq/runtime/kloader.h
Original file line number Diff line number Diff line change
@@ -8,8 +8,6 @@
#define KERNELCPU_LAST_ADDRESS (0x4fffffff - 1024*1024)
#define KSUPPORT_HEADER_SIZE 0x80

extern long long int now;

int kloader_load_library(const void *code);
void kloader_filter_backtrace(struct artiq_backtrace_item *backtrace,
size_t *backtrace_size);
7 changes: 1 addition & 6 deletions artiq/runtime/ksupport.c
Original file line number Diff line number Diff line change
@@ -111,6 +111,7 @@ static const struct symbol runtime_exports[] = {
{"recv_rpc", &recv_rpc},

/* direct syscalls */
{"rtio_init", &rtio_init},
{"rtio_get_counter", &rtio_get_counter},
{"rtio_log", &rtio_log},
{"rtio_output", &rtio_output},
@@ -351,11 +352,6 @@ static void now_init(void)
}
now = reply->now;
mailbox_acknowledge();

if(now < 0) {
rtio_init();
now = rtio_get_counter() + (272000 << CONFIG_RTIO_FINE_TS_WIDTH);
}
}

static void now_save(void)
@@ -475,7 +471,6 @@ void send_rpc(int service, const char *tag, ...)
{
struct msg_rpc_send request;

request.now = now;
if(service != 0)
request.type = MESSAGE_TYPE_RPC_SEND;
else
1 change: 0 additions & 1 deletion artiq/runtime/messages.h
Original file line number Diff line number Diff line change
@@ -87,7 +87,6 @@ struct msg_watchdog_clear {

struct msg_rpc_send {
int type;
long long int now;
int service;
const char *tag;
va_list args;
9 changes: 0 additions & 9 deletions artiq/runtime/session.c
Original file line number Diff line number Diff line change
@@ -300,7 +300,6 @@ void session_startup_kernel(void)
{
struct msg_base *umsg;

now = -1;
watchdog_init();
if(!kloader_start_startup_kernel())
return;
@@ -341,14 +340,12 @@ void session_start(void)
out_packet_reset();

kloader_stop();
now = -1;
user_kernel_state = USER_KERNEL_NONE;
}

void session_end(void)
{
kloader_stop();
now = -1;
watchdog_init();
kloader_start_idle_kernel();
}
@@ -983,12 +980,6 @@ static int process_kmsg(struct msg_base *umsg)
case MESSAGE_TYPE_RPC_BATCH: {
struct msg_rpc_send *msg = (struct msg_rpc_send *)umsg;

/*
* save now in case the RPC stops the kernel
* (e.g. pause with preemption)
*/
now = msg->now;

if(!send_rpc_request(msg->service, msg->tag, msg->args)) {
core_log("Failed to send RPC request (service %d, tag %s)\n",
msg->service, msg->tag);
2 changes: 2 additions & 0 deletions artiq/test/coredevice/test_analyzer.py
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ def build(self):

@kernel
def initialize_io(self):
self.core.reset()
self.loop_in.input()
self.loop_out.off()

@@ -33,6 +34,7 @@ def build(self):

@kernel
def run(self):
self.core.reset()
rtio_log("foo", 32)


4 changes: 4 additions & 0 deletions artiq/test/coredevice/test_embedding.py
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ def build(self):
def roundtrip(self, obj, fn):
fn(obj)


class RoundtripTest(ExperimentCase):
def assertRoundtrip(self, obj):
exp = self.create(_Roundtrip)
@@ -55,6 +56,7 @@ def test(self, foo=42) -> TInt32:
def run(self):
return self.test()


class DefaultArgTest(ExperimentCase):
def test_default_arg(self):
exp = self.create(_DefaultArg)
@@ -103,6 +105,7 @@ def args1kwargs2(self):
def builtin(self):
sleep(1.0)


class RPCTest(ExperimentCase):
def test_args(self):
exp = self.create(_RPC)
@@ -128,6 +131,7 @@ def run(self):
data = [0 for _ in range(1000000//4)]
self.devnull(data)


class LargePayloadTest(ExperimentCase):
def test_1MB(self):
exp = self.create(_Payload1MB)
10 changes: 10 additions & 0 deletions artiq/test/coredevice/test_rtio.py
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@ def build(self):

@kernel
def run(self):
self.core.reset()
self.ttl_inout.output()
delay(1*us)
with interleave:
@@ -48,6 +49,7 @@ def build(self):

@kernel
def run(self):
self.core.reset()
self.loop_in.input()
self.loop_out.off()
delay(1*us)
@@ -71,6 +73,7 @@ def build(self):

@kernel
def run(self):
self.core.reset()
self.loop_clock_in.input()
self.loop_clock_out.stop()
delay(1*us)
@@ -89,6 +92,7 @@ def build(self):

@kernel
def run(self):
self.core.reset()
dt = seconds_to_mu(300*ns)
while True:
for i in range(10000):
@@ -113,6 +117,7 @@ def build(self):

@kernel
def run(self):
self.core.reset()
dt = seconds_to_mu(5*us)
while True:
delay(10*ms)
@@ -154,6 +159,7 @@ def set_count(self, count):

@kernel
def run(self):
self.core.reset()
self.loop_in.input()
self.loop_out.output()
delay(5*us)
@@ -173,6 +179,7 @@ def build(self):

@kernel
def run(self):
self.core.reset()
while True:
delay(25*ns)
self.ttl_out.pulse(25*ns)
@@ -185,6 +192,7 @@ def build(self):

@kernel
def run(self):
self.core.reset()
t = now_mu()
self.ttl_out.pulse(25*us)
at_mu(t)
@@ -198,6 +206,7 @@ def build(self):

@kernel
def run(self):
self.core.reset()
delay(5*ms) # make sure we won't get underflow
for i in range(16):
self.ttl_out_serdes.pulse_mu(1)
@@ -211,6 +220,7 @@ def build(self):

@kernel
def run(self):
self.core.reset()
self.loop_in.input()
self.loop_in.pulse(10*us)

5 changes: 3 additions & 2 deletions artiq/test/coredevice/test_spi.py
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ def build(self):

@kernel
def run(self):
self.core.break_realtime()
self.core.reset()
t = now_mu()
try:
self.spi0.set_config_mu()
@@ -31,8 +31,8 @@ def build(self):

@kernel
def run(self):
self.core.reset()
try:
self.core.break_realtime()
self.spi0.set_config_mu()
t = now_mu()
self.spi0.set_config_mu()
@@ -54,6 +54,7 @@ def build(self):

@kernel
def run(self):
self.core.reset()
while True:
try:
self.core.break_realtime()