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: 8e2c664e8bca
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: 9ad6287dd0c5
Choose a head ref
  • 6 commits
  • 5 files changed
  • 1 contributor

Commits on Jun 19, 2016

  1. Copy the full SHA
    2ae20fb View commit details
  2. Copy the full SHA
    8e30848 View commit details
  3. Copy the full SHA
    917cc05 View commit details
  4. runtime: minor cleanup

    sbourdeauducq committed Jun 19, 2016
    Copy the full SHA
    0acc52d View commit details
  5. Copy the full SHA
    155794a View commit details

Commits on Jun 20, 2016

  1. Copy the full SHA
    9ad6287 View commit details
Showing with 81 additions and 45 deletions.
  1. +43 −36 artiq/runtime/ksupport.c
  2. +0 −2 artiq/runtime/ksupport.h
  3. +1 −7 artiq/runtime/messages.h
  4. +6 −0 artiq/runtime/session.c
  5. +31 −0 artiq/test/coredevice/test_rtio.py
79 changes: 43 additions & 36 deletions artiq/runtime/ksupport.c
Original file line number Diff line number Diff line change
@@ -335,6 +335,38 @@ void exception_handler(unsigned long vect, unsigned long *regs,
vect, pc, ea);
}

static void now_init(void)
{
struct msg_base request;
struct msg_now_init_reply *reply;

request.type = MESSAGE_TYPE_NOW_INIT_REQUEST;
mailbox_send_and_wait(&request);

reply = mailbox_wait_and_receive();
if(reply->type != MESSAGE_TYPE_NOW_INIT_REPLY) {
core_log("Malformed MESSAGE_TYPE_NOW_INIT_REQUEST reply type %d\n",
reply->type);
while(1);
}
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)
{
struct msg_now_save request;

request.type = MESSAGE_TYPE_NOW_SAVE;
request.now = now;
mailbox_send_and_wait(&request);
}

int main(void);
int main(void)
{
@@ -387,9 +419,12 @@ int main(void)
/* called from __artiq_personality */
void __artiq_terminate(struct artiq_exception *artiq_exn,
struct artiq_backtrace_item *backtrace,
size_t backtrace_size) {
size_t backtrace_size)
{
struct msg_exception msg;

now_save();

msg.type = MESSAGE_TYPE_EXCEPTION;
msg.exception = artiq_exn;
msg.backtrace = backtrace;
@@ -399,43 +434,12 @@ void __artiq_terminate(struct artiq_exception *artiq_exn,
while(1);
}

void ksupport_abort() {
void ksupport_abort()
{
artiq_raise_from_c("InternalError", "abort() called; check device log for details",
0, 0, 0);
}

void now_init(void)
{
struct msg_base request;
struct msg_now_init_reply *reply;

request.type = MESSAGE_TYPE_NOW_INIT_REQUEST;
mailbox_send_and_wait(&request);

reply = mailbox_wait_and_receive();
if(reply->type != MESSAGE_TYPE_NOW_INIT_REPLY) {
core_log("Malformed MESSAGE_TYPE_NOW_INIT_REQUEST reply type %d\n",
reply->type);
while(1);
}
now = reply->now;
mailbox_acknowledge();

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

void now_save(void)
{
struct msg_now_save request;

request.type = MESSAGE_TYPE_NOW_SAVE;
request.now = now;
mailbox_send_and_wait(&request);
}

int watchdog_set(int ms)
{
struct msg_watchdog_set_request request;
@@ -471,6 +475,7 @@ 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
@@ -482,7 +487,8 @@ void send_rpc(int service, const char *tag, ...)
va_end(request.args);
}

int recv_rpc(void *slot) {
int recv_rpc(void *slot)
{
struct msg_rpc_recv_request request;
struct msg_rpc_recv_reply *reply;

@@ -521,7 +527,8 @@ struct type_desc {
void **objects;
};

void attribute_writeback(void *utypes) {
void attribute_writeback(void *utypes)
{
struct type_desc **types = (struct type_desc **)utypes;
while(*types) {
struct type_desc *type = *types++;
2 changes: 0 additions & 2 deletions artiq/runtime/ksupport.h
Original file line number Diff line number Diff line change
@@ -6,8 +6,6 @@ struct artiq_list {
int32_t *elements;
};

void now_init(void);
void now_save(void);
int watchdog_set(int ms);
void watchdog_clear(int id);
void send_rpc(int service, const char *tag, ...);
8 changes: 1 addition & 7 deletions artiq/runtime/messages.h
Original file line number Diff line number Diff line change
@@ -87,6 +87,7 @@ struct msg_watchdog_clear {

struct msg_rpc_send {
int type;
long long int now;
int service;
const char *tag;
va_list args;
@@ -103,13 +104,6 @@ struct msg_rpc_recv_reply {
struct artiq_exception *exception;
};

struct msg_rpc_batch {
int type;
int service;
const char *tag;
void *ptr;
};

struct msg_cache_get_request {
int type;
const char *key;
6 changes: 6 additions & 0 deletions artiq/runtime/session.c
Original file line number Diff line number Diff line change
@@ -983,6 +983,12 @@ 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);
31 changes: 31 additions & 0 deletions artiq/test/coredevice/test_rtio.py
Original file line number Diff line number Diff line change
@@ -238,6 +238,31 @@ def run(self):
self.k("t2")


class DummyException(Exception):
pass


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

@kernel
def k(self, var):
self.set_dataset(var, now_mu())
delay_mu(1234)
raise DummyException()

def run(self):
try:
self.k("t1")
except DummyException:
pass
try:
self.k("t2")
except DummyException:
pass


class CoredeviceTest(ExperimentCase):
def test_loopback(self):
self.execute(Loopback)
@@ -314,6 +339,12 @@ def test_handover(self):
self.assertEqual(self.dataset_mgr.get("t1") + 1234,
self.dataset_mgr.get("t2"))

def test_handover_exception(self):
self.execute(HandoverException)
self.assertEqual(self.dataset_mgr.get("t1") + 1234,
self.dataset_mgr.get("t2"))



class RPCTiming(EnvExperiment):
def build(self, repeats=100):