artiq_{compile,run}: adapt to new compiler.

This commit is contained in:
whitequark 2015-08-28 01:43:46 -05:00
parent 6b55e3bd80
commit d473d58b41
6 changed files with 27 additions and 18 deletions

View File

@ -33,6 +33,10 @@ class ObjectMap:
def retrieve(self, 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:
def __init__(self, type_map, value_map, quote_function=None, expanded_from=None):
self.source = ""

View File

@ -145,6 +145,8 @@ class Target:
backtrace = []
for function_name, location, address in zip(lines[::2], lines[1::2], addresses):
filename, line = location.rsplit(":", 1)
if filename == '??':
continue
# can't get column out of addr2line D:
backtrace.append((filename, int(line), -1, function_name, address))
return backtrace

View File

@ -45,29 +45,27 @@ def main():
arguments = parse_arguments(args.arguments)
exp_inst = exp(dmgr, pdb, **arguments)
if (not hasattr(exp.run, "k_function_info")
or not exp.run.k_function_info):
if not hasattr(exp.run, "artiq_embedded"):
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)
binary, rpc_map, _ = core.compile(exp.run.k_function_info.k_function,
[exp_inst], {},
with_attr_writeback=False)
object_map, kernel_library, symbolizer = \
core.compile(exp.run, [exp_inst], {},
with_attr_writeback=False)
finally:
dmgr.close_devices()
if rpc_map:
if object_map.has_rpc():
raise ValueError("Experiment must not use RPC")
output = args.output
if output is None:
output = args.file
if output.endswith(".py"):
output = output[:-3]
output += ".elf"
basename, ext = os.path.splitext(args.file)
output = "{}.elf".format(basename)
with open(output, "wb") as f:
f.write(binary)
f.write(kernel_library)
if __name__ == "__main__":
main()

View File

@ -13,7 +13,7 @@ def to_bytes(string):
def get_argparser():
parser = argparse.ArgumentParser(description="ARTIQ core device "
"remote access tool")
parser.add_argument("--ddb", default="ddb.pyon",
parser.add_argument("-d", "--ddb", default="ddb.pyon",
help="device database file")
subparsers = parser.add_subparsers(dest="action")

View File

@ -13,7 +13,8 @@ from artiq.language.environment import EnvExperiment
from artiq.protocols.file_db import FlatFileDB
from artiq.master.worker_db import DeviceManager, ResultDB
from artiq.tools import *
from artiq.compiler.embedding import ObjectMap
from artiq.compiler.targets import OR1KTarget
logger = logging.getLogger(__name__)
@ -25,9 +26,13 @@ class ELFRunner(EnvExperiment):
def run(self):
with open(self.file, "rb") as f:
self.core.comm.load(f.read())
self.core.comm.run("run")
self.core.comm.serve(dict(), dict())
kernel_library = f.read()
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:

View File

@ -182,7 +182,7 @@ def kernel(arg):
def inner_decorator(function):
@wraps(function)
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(
core_name=arg, function=function, syscall=None)
return run_on_core