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: b14fcd41e4cf
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: aedb6747f296
Choose a head ref
Loading
Showing with 1,021 additions and 321 deletions.
  1. +22 −2 artiq/compiler/embedding.py
  2. +4 −2 artiq/compiler/module.py
  3. +1 −0 artiq/compiler/prelude.py
  4. +1 −4 artiq/compiler/targets.py
  5. +41 −41 artiq/compiler/transforms/artiq_ir_generator.py
  6. +1 −1 artiq/compiler/transforms/asttyped_rewriter.py
  7. +48 −35 artiq/compiler/transforms/llvm_ir_generator.py
  8. +10 −5 artiq/compiler/types.py
  9. +23 −12 artiq/coredevice/comm_generic.py
  10. +5 −2 artiq/coredevice/core.py
  11. +37 −31 artiq/dashboard/moninj.py
  12. +1 −1 artiq/frontend/artiq_compile.py
  13. +154 −0 artiq/frontend/artiq_devtool.py
  14. +2 −4 artiq/frontend/artiq_run.py
  15. +1 −1 artiq/gateware/amp/kernel_cpu.py
  16. +2 −2 artiq/gateware/amp/mailbox.py
  17. +2 −4 artiq/gateware/rtio/core.py
  18. +72 −50 artiq/gateware/targets/kc705.py
  19. +2 −1 artiq/gateware/targets/pipistrello.py
  20. +22 −6 artiq/language/core.py
  21. +3 −0 artiq/language/environment.py
  22. +1 −1 artiq/runtime.rs/Cargo.toml
  23. +22 −0 artiq/runtime.rs/libksupport/Cargo.lock
  24. +4 −0 artiq/runtime.rs/libksupport/Cargo.toml
  25. +7 −3 artiq/runtime.rs/libksupport/api.rs
  26. +0 −1 artiq/runtime.rs/libksupport/dyld.rs
  27. +58 −5 artiq/runtime.rs/libksupport/lib.rs
  28. +1 −0 artiq/runtime.rs/liblwip-sys/lib.rs
  29. +1 −1 artiq/runtime.rs/liblwip/Cargo.toml
  30. +1 −0 artiq/runtime.rs/liblwip/lib.rs
  31. +3 −0 artiq/runtime.rs/libstd_artiq/Cargo.toml
  32. +42 −3 artiq/runtime.rs/libstd_artiq/io/error.rs
  33. +10 −48 artiq/runtime.rs/libstd_artiq/lib.rs
  34. +7 −0 artiq/runtime.rs/src/clock.rs
  35. +3 −0 artiq/runtime.rs/src/kernel.rs
  36. +3 −3 artiq/runtime.rs/src/kernel_proto.rs
  37. +55 −3 artiq/runtime.rs/src/lib.rs
  38. +9 −5 artiq/runtime.rs/src/logger.rs
  39. +2 −1 artiq/runtime.rs/src/proto.rs
  40. +9 −5 artiq/runtime.rs/src/{rpc.rs → rpc_proto.rs}
  41. +61 −0 artiq/runtime.rs/src/rpc_queue.rs
  42. +33 −12 artiq/runtime.rs/src/session.rs
  43. +3 −3 artiq/runtime.rs/src/session_proto.rs
  44. +3 −0 artiq/runtime/Makefile
  45. +5 −1 artiq/runtime/ksupport.ld
  46. +28 −5 artiq/runtime/ksupport_glue.c
  47. +4 −0 artiq/runtime/main.c
  48. +2 −0 artiq/runtime/rtio.c
  49. +1 −3 artiq/runtime/runtime.ld
  50. +21 −0 artiq/test/coredevice/test_embedding.py
  51. +5 −3 artiq/test/coredevice/test_rtio.py
  52. +15 −0 artiq/test/lit/embedding/async_rpc.py
  53. +15 −0 artiq/test/lit/embedding/error_rpc_async_return.py
  54. +26 −0 artiq/test/lit/embedding/invariant_propagation.py
  55. +24 −0 artiq/test/lit/integration/for.py
  56. +24 −0 artiq/test/lit/integration/while.py
  57. +2 −2 conda/artiq/meta.yaml
  58. +43 −2 doc/manual/compiler.rst
  59. +13 −7 doc/manual/installing_from_source.rst
  60. +1 −0 setup.py
24 changes: 22 additions & 2 deletions artiq/compiler/embedding.py
Original file line number Diff line number Diff line change
@@ -994,8 +994,24 @@ def _quote_rpc(self, function, loc):
else:
assert False

is_async = False
if hasattr(host_function, "artiq_embedded") and \
"async" in host_function.artiq_embedded.flags:
is_async = True

if not builtins.is_none(ret_type) and is_async:
note = diagnostic.Diagnostic("note",
"function called here", {},
loc)
diag = diagnostic.Diagnostic("fatal",
"functions that return a value cannot be defined as async RPCs", {},
self._function_loc(host_function.artiq_embedded.function),
notes=[note])
self.engine.process(diag)

function_type = types.TRPC(ret_type,
service=self.embedding_map.store_object(host_function))
service=self.embedding_map.store_object(host_function),
async=is_async)
self.functions[function] = function_type
return function_type

@@ -1007,7 +1023,11 @@ def _quote_function(self, function, loc):

if function in self.functions:
pass
elif not hasattr(host_function, "artiq_embedded"):
elif not hasattr(host_function, "artiq_embedded") or \
(host_function.artiq_embedded.core_name is None and
host_function.artiq_embedded.portable is False and
host_function.artiq_embedded.syscall is None and
host_function.artiq_embedded.forbidden is False):
self._quote_rpc(function, loc)
elif host_function.artiq_embedded.function is not None:
if host_function.__name__ == "<lambda>":
6 changes: 4 additions & 2 deletions artiq/compiler/module.py
Original file line number Diff line number Diff line change
@@ -40,7 +40,8 @@ def from_filename(cls, filename, engine=None):
return cls(source.Buffer(f.read(), filename, 1), engine=engine)

class Module:
def __init__(self, src, ref_period=1e-6):
def __init__(self, src, ref_period=1e-6, attribute_writeback=True):
self.attribute_writeback = attribute_writeback
self.engine = src.engine
self.embedding_map = src.embedding_map
self.name = src.name
@@ -79,7 +80,8 @@ def build_llvm_ir(self, target):
llvm_ir_generator = transforms.LLVMIRGenerator(
engine=self.engine, module_name=self.name, target=target,
embedding_map=self.embedding_map)
return llvm_ir_generator.process(self.artiq_ir, attribute_writeback=True)
return llvm_ir_generator.process(self.artiq_ir,
attribute_writeback=self.attribute_writeback)

def __repr__(self):
printer = types.TypePrinter()
1 change: 1 addition & 0 deletions artiq/compiler/prelude.py
Original file line number Diff line number Diff line change
@@ -31,6 +31,7 @@ def globals():
# ARTIQ decorators
"kernel": builtins.fn_kernel(),
"portable": builtins.fn_kernel(),
"rpc": builtins.fn_kernel(),

# ARTIQ context managers
"parallel": builtins.obj_parallel(),
5 changes: 1 addition & 4 deletions artiq/compiler/targets.py
Original file line number Diff line number Diff line change
@@ -86,14 +86,11 @@ def target_machine(self):
llmachine = lltarget.create_target_machine(
features=",".join(["+{}".format(f) for f in self.features]),
reloc="pic", codemodel="default")
llmachine.set_verbose(True)
llmachine.set_asm_verbosity(True)
return llmachine

def optimize(self, llmodule):
llmachine = self.target_machine()
llpassmgr = llvm.create_module_pass_manager()
llmachine.target_data.add_pass(llpassmgr)
llmachine.add_analysis_passes(llpassmgr)

# Register our alias analysis passes.
llpassmgr.add_basic_alias_analysis_pass()
82 changes: 41 additions & 41 deletions artiq/compiler/transforms/artiq_ir_generator.py
Original file line number Diff line number Diff line change
@@ -452,29 +452,29 @@ def visit_While(self, node):
self.current_block = body
self.visit(node.body)
post_body = self.current_block
finally:
self.break_target = old_break
self.continue_target = old_continue

if any(node.orelse):
else_tail = self.add_block("while.else")
self.current_block = else_tail
self.visit(node.orelse)
post_else_tail = self.current_block
if any(node.orelse):
else_tail = self.add_block("while.else")
self.current_block = else_tail
self.visit(node.orelse)
post_else_tail = self.current_block

tail = self.add_block("while.tail")
self.current_block = tail
tail = self.add_block("while.tail")
self.current_block = tail

if any(node.orelse):
if not post_else_tail.is_terminated():
post_else_tail.append(ir.Branch(tail))
else:
else_tail = tail
if any(node.orelse):
if not post_else_tail.is_terminated():
post_else_tail.append(ir.Branch(tail))
else:
else_tail = tail

post_head.append(ir.BranchIf(cond, body, else_tail))
if not post_body.is_terminated():
post_body.append(ir.Branch(head))
break_block.append(ir.Branch(tail))
finally:
self.break_target = old_break
self.continue_target = old_continue
post_head.append(ir.BranchIf(cond, body, else_tail))
if not post_body.is_terminated():
post_body.append(ir.Branch(head))
break_block.append(ir.Branch(tail))

def iterable_len(self, value, typ=_size_type):
if builtins.is_listish(value.type):
@@ -541,32 +541,32 @@ def visit_ForT(self, node):
self.current_assign = None
self.visit(node.body)
post_body = self.current_block
finally:
self.break_target = old_break
self.continue_target = old_continue

if any(node.orelse):
else_tail = self.add_block("for.else")
self.current_block = else_tail
self.visit(node.orelse)
post_else_tail = self.current_block
if any(node.orelse):
else_tail = self.add_block("for.else")
self.current_block = else_tail
self.visit(node.orelse)
post_else_tail = self.current_block

tail = self.add_block("for.tail")
self.current_block = tail
tail = self.add_block("for.tail")
self.current_block = tail

if any(node.orelse):
if not post_else_tail.is_terminated():
post_else_tail.append(ir.Branch(tail))
else:
else_tail = tail
if any(node.orelse):
if not post_else_tail.is_terminated():
post_else_tail.append(ir.Branch(tail))
else:
else_tail = tail

if node.trip_count is not None:
head.append(ir.Loop(node.trip_count, phi, cond, body, else_tail))
else:
head.append(ir.BranchIf(cond, body, else_tail))
if not post_body.is_terminated():
post_body.append(ir.Branch(continue_block))
break_block.append(ir.Branch(tail))
finally:
self.break_target = old_break
self.continue_target = old_continue
if node.trip_count is not None:
head.append(ir.Loop(node.trip_count, phi, cond, body, else_tail))
else:
head.append(ir.BranchIf(cond, body, else_tail))
if not post_body.is_terminated():
post_body.append(ir.Branch(continue_block))
break_block.append(ir.Branch(tail))

def visit_Break(self, node):
self.append(ir.Branch(self.break_target))
2 changes: 1 addition & 1 deletion artiq/compiler/transforms/asttyped_rewriter.py
Original file line number Diff line number Diff line change
@@ -509,7 +509,7 @@ def visit_unsupported(self, node):
visit_DictComp = visit_unsupported
visit_Ellipsis = visit_unsupported
visit_GeneratorExp = visit_unsupported
visit_Set = visit_unsupported
# visit_Set = visit_unsupported
visit_SetComp = visit_unsupported
visit_Starred = visit_unsupported
visit_Yield = visit_unsupported
Loading