forked from M-Labs/artiq
compiler: remove obsolete watchdog code (#1458)
This commit is contained in:
parent
ccdc741e73
commit
072053c3b2
|
@ -222,9 +222,6 @@ def obj_interleave():
|
||||||
def obj_sequential():
|
def obj_sequential():
|
||||||
return types.TBuiltin("sequential")
|
return types.TBuiltin("sequential")
|
||||||
|
|
||||||
def fn_watchdog():
|
|
||||||
return types.TBuiltinFunction("watchdog")
|
|
||||||
|
|
||||||
def fn_delay():
|
def fn_delay():
|
||||||
return types.TBuiltinFunction("delay")
|
return types.TBuiltinFunction("delay")
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,6 @@ def globals():
|
||||||
"parallel": builtins.obj_parallel(),
|
"parallel": builtins.obj_parallel(),
|
||||||
"interleave": builtins.obj_interleave(),
|
"interleave": builtins.obj_interleave(),
|
||||||
"sequential": builtins.obj_sequential(),
|
"sequential": builtins.obj_sequential(),
|
||||||
"watchdog": builtins.fn_watchdog(),
|
|
||||||
|
|
||||||
# ARTIQ time management functions
|
# ARTIQ time management functions
|
||||||
"delay": builtins.fn_delay(),
|
"delay": builtins.fn_delay(),
|
||||||
|
|
|
@ -851,35 +851,23 @@ class ARTIQIRGenerator(algorithm.Visitor):
|
||||||
|
|
||||||
cleanup = []
|
cleanup = []
|
||||||
for item_node in node.items:
|
for item_node in node.items:
|
||||||
|
# user-defined context manager
|
||||||
context_expr_node = item_node.context_expr
|
context_expr_node = item_node.context_expr
|
||||||
optional_vars_node = item_node.optional_vars
|
optional_vars_node = item_node.optional_vars
|
||||||
|
context_mgr = self.visit(context_expr_node)
|
||||||
|
enter_fn = self.append(ir.GetAttr(context_mgr, '__enter__'))
|
||||||
|
exit_fn = self.append(ir.GetAttr(context_mgr, '__exit__'))
|
||||||
|
|
||||||
if isinstance(context_expr_node, asttyped.CallT) and \
|
try:
|
||||||
types.is_builtin(context_expr_node.func.type, "watchdog"):
|
self.current_assign = self._user_call(enter_fn, [], {})
|
||||||
timeout = self.visit(context_expr_node.args[0])
|
if optional_vars_node is not None:
|
||||||
timeout_ms = self.append(ir.Arith(ast.Mult(loc=None), timeout,
|
self.visit(optional_vars_node)
|
||||||
ir.Constant(1000, builtins.TFloat())))
|
finally:
|
||||||
timeout_ms_int = self.append(ir.Coerce(timeout_ms, builtins.TInt64()))
|
self.current_assign = None
|
||||||
|
|
||||||
watchdog_id = self.append(ir.Builtin("watchdog_set", [timeout_ms_int],
|
none = self.append(ir.Alloc([], builtins.TNone()))
|
||||||
builtins.TInt32()))
|
cleanup.append(lambda:
|
||||||
cleanup.append(lambda:
|
self._user_call(exit_fn, [none, none, none], {}))
|
||||||
self.append(ir.Builtin("watchdog_clear", [watchdog_id], builtins.TNone())))
|
|
||||||
else: # user-defined context manager
|
|
||||||
context_mgr = self.visit(context_expr_node)
|
|
||||||
enter_fn = self.append(ir.GetAttr(context_mgr, '__enter__'))
|
|
||||||
exit_fn = self.append(ir.GetAttr(context_mgr, '__exit__'))
|
|
||||||
|
|
||||||
try:
|
|
||||||
self.current_assign = self._user_call(enter_fn, [], {})
|
|
||||||
if optional_vars_node is not None:
|
|
||||||
self.visit(optional_vars_node)
|
|
||||||
finally:
|
|
||||||
self.current_assign = None
|
|
||||||
|
|
||||||
none = self.append(ir.Alloc([], builtins.TNone()))
|
|
||||||
cleanup.append(lambda:
|
|
||||||
self._user_call(exit_fn, [none, none, none], {}))
|
|
||||||
|
|
||||||
self._try_finally(
|
self._try_finally(
|
||||||
body_gen=lambda: self.visit(node.body),
|
body_gen=lambda: self.visit(node.body),
|
||||||
|
|
|
@ -1211,9 +1211,6 @@ class Inferencer(algorithm.Visitor):
|
||||||
elif types.is_builtin(typ, "at_mu"):
|
elif types.is_builtin(typ, "at_mu"):
|
||||||
simple_form("at_mu(time_mu:numpy.int64) -> None",
|
simple_form("at_mu(time_mu:numpy.int64) -> None",
|
||||||
[builtins.TInt64()])
|
[builtins.TInt64()])
|
||||||
elif types.is_builtin(typ, "watchdog"):
|
|
||||||
simple_form("watchdog(time:float) -> [builtin context manager]",
|
|
||||||
[builtins.TFloat()], builtins.TNone())
|
|
||||||
elif types.is_constructor(typ):
|
elif types.is_constructor(typ):
|
||||||
# An user-defined class.
|
# An user-defined class.
|
||||||
self._unify(node.type, typ.find().instance,
|
self._unify(node.type, typ.find().instance,
|
||||||
|
@ -1458,9 +1455,7 @@ class Inferencer(algorithm.Visitor):
|
||||||
|
|
||||||
typ = node.context_expr.type
|
typ = node.context_expr.type
|
||||||
if (types.is_builtin(typ, "interleave") or types.is_builtin(typ, "sequential") or
|
if (types.is_builtin(typ, "interleave") or types.is_builtin(typ, "sequential") or
|
||||||
types.is_builtin(typ, "parallel") or
|
types.is_builtin(typ, "parallel")):
|
||||||
(isinstance(node.context_expr, asttyped.CallT) and
|
|
||||||
types.is_builtin(node.context_expr.func.type, "watchdog"))):
|
|
||||||
# builtin context managers
|
# builtin context managers
|
||||||
if node.optional_vars is not None:
|
if node.optional_vars is not None:
|
||||||
self._unify(node.optional_vars.type, builtins.TNone(),
|
self._unify(node.optional_vars.type, builtins.TNone(),
|
||||||
|
|
|
@ -395,10 +395,6 @@ class LLVMIRGenerator:
|
||||||
elif name == "delay_mu":
|
elif name == "delay_mu":
|
||||||
llty = ll.FunctionType(llvoid, [lli64])
|
llty = ll.FunctionType(llvoid, [lli64])
|
||||||
|
|
||||||
elif name == "watchdog_set":
|
|
||||||
llty = ll.FunctionType(lli32, [lli64])
|
|
||||||
elif name == "watchdog_clear":
|
|
||||||
llty = ll.FunctionType(llvoid, [lli32])
|
|
||||||
else:
|
else:
|
||||||
assert False
|
assert False
|
||||||
|
|
||||||
|
@ -407,7 +403,6 @@ class LLVMIRGenerator:
|
||||||
if name in ("__artiq_raise", "__artiq_reraise", "llvm.trap"):
|
if name in ("__artiq_raise", "__artiq_reraise", "llvm.trap"):
|
||||||
llglobal.attributes.add("noreturn")
|
llglobal.attributes.add("noreturn")
|
||||||
if name in ("rtio_log", "rpc_send", "rpc_send_async",
|
if name in ("rtio_log", "rpc_send", "rpc_send_async",
|
||||||
"watchdog_set", "watchdog_clear",
|
|
||||||
self.target.print_function):
|
self.target.print_function):
|
||||||
llglobal.attributes.add("nounwind")
|
llglobal.attributes.add("nounwind")
|
||||||
if name.find("__py_") == 0:
|
if name.find("__py_") == 0:
|
||||||
|
@ -1239,12 +1234,6 @@ class LLVMIRGenerator:
|
||||||
return llstore_lo
|
return llstore_lo
|
||||||
else:
|
else:
|
||||||
return self.llbuilder.call(self.llbuiltin("delay_mu"), [llinterval])
|
return self.llbuilder.call(self.llbuiltin("delay_mu"), [llinterval])
|
||||||
elif insn.op == "watchdog_set":
|
|
||||||
interval, = insn.operands
|
|
||||||
return self.llbuilder.call(self.llbuiltin("watchdog_set"), [self.map(interval)])
|
|
||||||
elif insn.op == "watchdog_clear":
|
|
||||||
id, = insn.operands
|
|
||||||
return self.llbuilder.call(self.llbuiltin("watchdog_clear"), [self.map(id)])
|
|
||||||
else:
|
else:
|
||||||
assert False
|
assert False
|
||||||
|
|
||||||
|
|
|
@ -76,14 +76,3 @@ fn terminate(exception: &eh_artiq::Exception, mut _backtrace: &mut [usize]) -> !
|
||||||
|
|
||||||
#[export_name = "now"]
|
#[export_name = "now"]
|
||||||
pub static mut NOW: i64 = 0;
|
pub static mut NOW: i64 = 0;
|
||||||
|
|
||||||
#[export_name = "watchdog_set"]
|
|
||||||
pub extern fn watchdog_set(ms: i64) -> i32 {
|
|
||||||
println!("watchdog_set {}", ms);
|
|
||||||
ms as i32
|
|
||||||
}
|
|
||||||
|
|
||||||
#[export_name = "watchdog_clear"]
|
|
||||||
pub extern fn watchdog_clear(id: i32) {
|
|
||||||
println!("watchdog_clear {}", id);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
# RUN: %python -m artiq.compiler.testbench.signature +diag %s >%t
|
|
||||||
# RUN: OutputCheck %s --file-to-check=%t
|
|
||||||
|
|
||||||
# CHECK-L: ${LINE:+1}: error: builtin function 'watchdog' cannot be used in this context
|
|
||||||
watchdog(1.0)
|
|
|
@ -1,36 +0,0 @@
|
||||||
# RUN: %python -m artiq.compiler.testbench.jit %s >%t
|
|
||||||
# RUN: OutputCheck %s --file-to-check=%t
|
|
||||||
# REQUIRES: time
|
|
||||||
|
|
||||||
def f():
|
|
||||||
with watchdog(1.0):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def g():
|
|
||||||
with watchdog(2.0):
|
|
||||||
raise Exception()
|
|
||||||
|
|
||||||
def h():
|
|
||||||
try:
|
|
||||||
g()
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def i():
|
|
||||||
try:
|
|
||||||
with watchdog(3.0):
|
|
||||||
raise Exception()
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# CHECK-L: watchdog_set 1000
|
|
||||||
# CHECK-L: watchdog_clear 1000
|
|
||||||
f()
|
|
||||||
|
|
||||||
# CHECK-L: watchdog_set 2000
|
|
||||||
# CHECK-L: watchdog_clear 2000
|
|
||||||
h()
|
|
||||||
|
|
||||||
# CHECK-L: watchdog_set 3000
|
|
||||||
# CHECK-L: watchdog_clear 3000
|
|
||||||
i()
|
|
Loading…
Reference in New Issue