forked from M-Labs/artiq
artiq_{compile,run}: adapt to new compiler.
This commit is contained in:
parent
6b55e3bd80
commit
d473d58b41
|
@ -33,6 +33,10 @@ class ObjectMap:
|
||||||
def retrieve(self, obj_key):
|
def retrieve(self, obj_key):
|
||||||
return self.forward_map[obj_key]
|
return self.forward_map[obj_key]
|
||||||
|
|
||||||
|
def has_rpc(self):
|
||||||
|
return any(filter(lambda x: inspect.isfunction(x) or inspect.ismethod(x),
|
||||||
|
self.forward_map.values()))
|
||||||
|
|
||||||
class ASTSynthesizer:
|
class ASTSynthesizer:
|
||||||
def __init__(self, type_map, value_map, quote_function=None, expanded_from=None):
|
def __init__(self, type_map, value_map, quote_function=None, expanded_from=None):
|
||||||
self.source = ""
|
self.source = ""
|
||||||
|
|
|
@ -145,6 +145,8 @@ class Target:
|
||||||
backtrace = []
|
backtrace = []
|
||||||
for function_name, location, address in zip(lines[::2], lines[1::2], addresses):
|
for function_name, location, address in zip(lines[::2], lines[1::2], addresses):
|
||||||
filename, line = location.rsplit(":", 1)
|
filename, line = location.rsplit(":", 1)
|
||||||
|
if filename == '??':
|
||||||
|
continue
|
||||||
# can't get column out of addr2line D:
|
# can't get column out of addr2line D:
|
||||||
backtrace.append((filename, int(line), -1, function_name, address))
|
backtrace.append((filename, int(line), -1, function_name, address))
|
||||||
return backtrace
|
return backtrace
|
||||||
|
|
|
@ -45,29 +45,27 @@ def main():
|
||||||
arguments = parse_arguments(args.arguments)
|
arguments = parse_arguments(args.arguments)
|
||||||
exp_inst = exp(dmgr, pdb, **arguments)
|
exp_inst = exp(dmgr, pdb, **arguments)
|
||||||
|
|
||||||
if (not hasattr(exp.run, "k_function_info")
|
if not hasattr(exp.run, "artiq_embedded"):
|
||||||
or not exp.run.k_function_info):
|
|
||||||
raise ValueError("Experiment entry point must be a kernel")
|
raise ValueError("Experiment entry point must be a kernel")
|
||||||
core_name = exp.run.k_function_info.core_name
|
core_name = exp.run.artiq_embedded.core_name
|
||||||
core = getattr(exp_inst, core_name)
|
core = getattr(exp_inst, core_name)
|
||||||
|
|
||||||
binary, rpc_map, _ = core.compile(exp.run.k_function_info.k_function,
|
object_map, kernel_library, symbolizer = \
|
||||||
[exp_inst], {},
|
core.compile(exp.run, [exp_inst], {},
|
||||||
with_attr_writeback=False)
|
with_attr_writeback=False)
|
||||||
finally:
|
finally:
|
||||||
dmgr.close_devices()
|
dmgr.close_devices()
|
||||||
|
|
||||||
if rpc_map:
|
if object_map.has_rpc():
|
||||||
raise ValueError("Experiment must not use RPC")
|
raise ValueError("Experiment must not use RPC")
|
||||||
|
|
||||||
output = args.output
|
output = args.output
|
||||||
if output is None:
|
if output is None:
|
||||||
output = args.file
|
basename, ext = os.path.splitext(args.file)
|
||||||
if output.endswith(".py"):
|
output = "{}.elf".format(basename)
|
||||||
output = output[:-3]
|
|
||||||
output += ".elf"
|
|
||||||
with open(output, "wb") as f:
|
with open(output, "wb") as f:
|
||||||
f.write(binary)
|
f.write(kernel_library)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -13,7 +13,7 @@ def to_bytes(string):
|
||||||
def get_argparser():
|
def get_argparser():
|
||||||
parser = argparse.ArgumentParser(description="ARTIQ core device "
|
parser = argparse.ArgumentParser(description="ARTIQ core device "
|
||||||
"remote access tool")
|
"remote access tool")
|
||||||
parser.add_argument("--ddb", default="ddb.pyon",
|
parser.add_argument("-d", "--ddb", default="ddb.pyon",
|
||||||
help="device database file")
|
help="device database file")
|
||||||
|
|
||||||
subparsers = parser.add_subparsers(dest="action")
|
subparsers = parser.add_subparsers(dest="action")
|
||||||
|
|
|
@ -13,7 +13,8 @@ from artiq.language.environment import EnvExperiment
|
||||||
from artiq.protocols.file_db import FlatFileDB
|
from artiq.protocols.file_db import FlatFileDB
|
||||||
from artiq.master.worker_db import DeviceManager, ResultDB
|
from artiq.master.worker_db import DeviceManager, ResultDB
|
||||||
from artiq.tools import *
|
from artiq.tools import *
|
||||||
|
from artiq.compiler.embedding import ObjectMap
|
||||||
|
from artiq.compiler.targets import OR1KTarget
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -25,9 +26,13 @@ class ELFRunner(EnvExperiment):
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
with open(self.file, "rb") as f:
|
with open(self.file, "rb") as f:
|
||||||
self.core.comm.load(f.read())
|
kernel_library = f.read()
|
||||||
self.core.comm.run("run")
|
|
||||||
self.core.comm.serve(dict(), dict())
|
target = OR1KTarget()
|
||||||
|
self.core.comm.load(kernel_library)
|
||||||
|
self.core.comm.run()
|
||||||
|
self.core.comm.serve(ObjectMap(),
|
||||||
|
lambda addresses: target.symbolize(kernel_library, addresses))
|
||||||
|
|
||||||
|
|
||||||
class SimpleParamLogger:
|
class SimpleParamLogger:
|
||||||
|
|
|
@ -182,7 +182,7 @@ def kernel(arg):
|
||||||
def inner_decorator(function):
|
def inner_decorator(function):
|
||||||
@wraps(function)
|
@wraps(function)
|
||||||
def run_on_core(self, *k_args, **k_kwargs):
|
def run_on_core(self, *k_args, **k_kwargs):
|
||||||
return getattr(self, arg).run(function, ((self,) + k_args), k_kwargs)
|
return getattr(self, arg).run(run_on_core, ((self,) + k_args), k_kwargs)
|
||||||
run_on_core.artiq_embedded = _ARTIQEmbeddedInfo(
|
run_on_core.artiq_embedded = _ARTIQEmbeddedInfo(
|
||||||
core_name=arg, function=function, syscall=None)
|
core_name=arg, function=function, syscall=None)
|
||||||
return run_on_core
|
return run_on_core
|
||||||
|
|
Loading…
Reference in New Issue