Async RPC support #540
No reviewers
Labels
No Milestone
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: M-Labs/nac3#540
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "mwojcik/nac3:async_rpc"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Starting out with support for asynchronous RPCs. Work in progress as I am open to feedback from more experienced contributors.
RPC codegen path seems straightforward enough, but I did wonder how to pass the flags to
rpc_codegen_callback
. So I am proposing to extendFunSignature
to include options, which for now only includeAsync
- they could also includeFastMath
(like in old kernel) andSubkernelDestination(u8)
(will for subkernels). That will mean also that codegen callbacks don't have to change their signature to include flags.Additionally, decorators with arguments have been missing (compiler would say the called function does not exist) - took me a while to find them again - see nac3artiq/src/lib.rs - the body.retain function. The
ExprKind::Name
that the function was looking for is nested inside anExprKind::Call
. I am not sure if this is the correct course of action.Additionally, I am not sure where to find
__artiq_rpc_flags__
defined in the Python part that could be safely passed to theFunSignature
. Otherwise I could still find the flag within theStmt::FunctionDef
.@ -200,1 +200,4 @@
|| id.to_string() == "rpc"
} else if let ExprKind::Call { func, .. } = &decorator.node {
// decorators with flags (e.g. rpc async) have Call for the node;
// this is to remove the middle part
Why remove it? Then you don't know what it is afterwards.
And you could potentially have Call for any decorator. I suggest writing a helper function like:
and using it consistently to process decorators consistently, including for
@nac3
above.@nac3()
,@kernel()
should potentially also be legal.@ -119,0 +118,4 @@
@wraps(function)
def wrapped(function)
return function
wrapped.__artiq_rpc_flags__ = flags
Actually, processing
__artiq_rpc_flags__
doesn't work easily with NAC3, contrary to what I said earlier in the chat, sorry for that mistake. Probably better to process the AST after all.@ -77,6 +77,7 @@ pub fn get_exn_constructor(
args: exn_cons_args,
ret: exn_type,
vars: VarMap::default(),
opts: vec![],
Can this be handled (1) entirely in nac3artiq and (2) without passing
opts
all over the place?b79e3312ef
to94f0c467fa
733dc218d0
to50e9ccb7c4
50e9ccb7c4
to201a89b6d3
No need for
FuncOptions
, I can just passis_async
(extracted from the decorator arguments) to the rpc gen function.Similarly, other ARTIQ-only options (like for subkernels later) would be still handled within
nac3artiq
in similar fashion.Seems alright now, just need to test with ARTIQ.
I did test it successfully with the kc705. No changes required in ARTIQ besides flake update (and removing the restriction with
#nac3todo
in few examples.I believe there may be comments about code style though, but I'm taking off WIP now.
Testing experiment:
[WIP] Async RPC supportto Async RPC support201a89b6d3
to613159da39
613159da39
toc94f407732
Please run
cargo fmt
andcargo clippy
before merging.@ -844,6 +863,38 @@ impl Nac3 {
}
}
fn decorator_id_string(decorator: &Located<ExprKind>) -> Option<String> {
Please add documentation for these two functions.
@ -2060,0 +2063,4 @@
if matches!(&func.node,
ast::ExprKind::Name{ id, .. } if id == &"rpc".into())
{
instance_to_symbol.insert(String::new(), simple_name.to_string());
What exactly is this for?
Mimics the check above it - for decorators with arguments the Name is behind a Call as I mentioned before. Without it, it wouldn't be considered an external function and compiler would try to compile it together with the kernel.
c94f407732
to5a5656e983