forked from M-Labs/nac3
nac3artiq: add kernel destination to compilation
This commit is contained in:
parent
c9b234b0a5
commit
2ef8b300b2
|
@ -6,6 +6,7 @@ class EmbeddingMap:
|
||||||
self.string_reverse_map = {}
|
self.string_reverse_map = {}
|
||||||
self.function_map = {}
|
self.function_map = {}
|
||||||
self.attributes_writeback = []
|
self.attributes_writeback = []
|
||||||
|
self.subkernel_map = {}
|
||||||
self.subkernel_message_map = {}
|
self.subkernel_message_map = {}
|
||||||
|
|
||||||
if not old_embedding_map is None:
|
if not old_embedding_map is None:
|
||||||
|
@ -45,6 +46,10 @@ class EmbeddingMap:
|
||||||
self.function_map[key] = fun
|
self.function_map[key] = fun
|
||||||
return key
|
return key
|
||||||
|
|
||||||
|
def store_subkernel(self, key, fun):
|
||||||
|
self.subkernel_map[key] = fun
|
||||||
|
return key
|
||||||
|
|
||||||
def store_object(self, obj):
|
def store_object(self, obj):
|
||||||
obj_id = id(obj)
|
obj_id = id(obj)
|
||||||
if obj_id in self.object_inverse_map:
|
if obj_id in self.object_inverse_map:
|
||||||
|
@ -72,11 +77,7 @@ class EmbeddingMap:
|
||||||
return self.string_map[key]
|
return self.string_map[key]
|
||||||
|
|
||||||
def subkernels(self):
|
def subkernels(self):
|
||||||
subkernels = {}
|
return self.subkernel_map
|
||||||
for k, v in self.object_map.items():
|
|
||||||
if getattr(v, "__artiq_destination__") is not None:
|
|
||||||
subkernels[k] = v
|
|
||||||
return subkernels
|
|
||||||
|
|
||||||
def subkernel_messages(self):
|
def subkernel_messages(self):
|
||||||
messages = {}
|
messages = {}
|
||||||
|
|
|
@ -227,7 +227,9 @@ class Core:
|
||||||
obj = method
|
obj = method
|
||||||
name = ""
|
name = ""
|
||||||
|
|
||||||
compiler.compile_method_to_file(obj, name, args, "module.elf", embedding)
|
dest = getattr(method, "__artiq_destination__", 0)
|
||||||
|
|
||||||
|
compiler.compile_method_to_file(obj, name, dest, args, "module.elf", embedding)
|
||||||
|
|
||||||
@kernel
|
@kernel
|
||||||
def reset(self):
|
def reset(self):
|
||||||
|
|
|
@ -361,6 +361,7 @@ impl Nac3 {
|
||||||
&self,
|
&self,
|
||||||
obj: &PyAny,
|
obj: &PyAny,
|
||||||
method_name: &str,
|
method_name: &str,
|
||||||
|
destination: u8,
|
||||||
args: Vec<&PyAny>,
|
args: Vec<&PyAny>,
|
||||||
embedding_map: &PyAny,
|
embedding_map: &PyAny,
|
||||||
py: Python,
|
py: Python,
|
||||||
|
@ -1175,6 +1176,7 @@ impl Nac3 {
|
||||||
&mut self,
|
&mut self,
|
||||||
obj: &PyAny,
|
obj: &PyAny,
|
||||||
method_name: &str,
|
method_name: &str,
|
||||||
|
destination: u8,
|
||||||
args: Vec<&PyAny>,
|
args: Vec<&PyAny>,
|
||||||
filename: &str,
|
filename: &str,
|
||||||
embedding_map: &PyAny,
|
embedding_map: &PyAny,
|
||||||
|
@ -1195,7 +1197,7 @@ impl Nac3 {
|
||||||
Ok(())
|
Ok(())
|
||||||
};
|
};
|
||||||
|
|
||||||
self.compile_method(obj, method_name, args, embedding_map, py, &link_fn)
|
self.compile_method(obj, method_name, destination, args, embedding_map, py, &link_fn)
|
||||||
} else {
|
} else {
|
||||||
let link_fn = |module: &Module| {
|
let link_fn = |module: &Module| {
|
||||||
let object_mem = target_machine
|
let object_mem = target_machine
|
||||||
|
@ -1213,7 +1215,7 @@ impl Nac3 {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
self.compile_method(obj, method_name, args, embedding_map, py, &link_fn)
|
self.compile_method(obj, method_name, destination, args, embedding_map, py, &link_fn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1221,6 +1223,7 @@ impl Nac3 {
|
||||||
&mut self,
|
&mut self,
|
||||||
obj: &PyAny,
|
obj: &PyAny,
|
||||||
method_name: &str,
|
method_name: &str,
|
||||||
|
destination: u8,
|
||||||
args: Vec<&PyAny>,
|
args: Vec<&PyAny>,
|
||||||
embedding_map: &PyAny,
|
embedding_map: &PyAny,
|
||||||
py: Python,
|
py: Python,
|
||||||
|
@ -1244,7 +1247,7 @@ impl Nac3 {
|
||||||
Ok(PyBytes::new(py, &fs::read(filename).unwrap()).into())
|
Ok(PyBytes::new(py, &fs::read(filename).unwrap()).into())
|
||||||
};
|
};
|
||||||
|
|
||||||
self.compile_method(obj, method_name, args, embedding_map, py, &link_fn)
|
self.compile_method(obj, method_name, destination, args, embedding_map, py, &link_fn)
|
||||||
} else {
|
} else {
|
||||||
let link_fn = |module: &Module| {
|
let link_fn = |module: &Module| {
|
||||||
let object_mem = target_machine
|
let object_mem = target_machine
|
||||||
|
@ -1257,7 +1260,7 @@ impl Nac3 {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
self.compile_method(obj, method_name, args, embedding_map, py, &link_fn)
|
self.compile_method(obj, method_name, destination, args, embedding_map, py, &link_fn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue