Support rtio.rpc op for OQD's AWG end to end pipeline#2577
Support rtio.rpc op for OQD's AWG end to end pipeline#2577
Conversation
|
Hello. You may have forgotten to update the changelog!
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2577 +/- ##
=======================================
Coverage 97.00% 97.00%
=======================================
Files 157 157
Lines 17470 17470
Branches 1686 1686
=======================================
Hits 16946 16946
Misses 387 387
Partials 137 137 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
mlir/include/RTIO/IR/RTIOOps.td
Outdated
| - callee: The symbolic name of the host-side callable to invoke. | ||
| - tag: type-tag string encoding the return and argument types, | ||
| which is compatiable with the ARTIQ RPC wire protocol. | ||
| (e.g. "n:" for void no-arg, "n:si" for void(str,i32)). |
There was a problem hiding this comment.
This ARTIQ related part seems out of context. Ideally we should try to not pollute this dialect with ARTIQ details.
There was a problem hiding this comment.
now that I think more, this could be a general enough scheme that is not ARTIQ dependant, but still you may want lower to any arbitrary tagging system, so not tying up it up to ARTIQ seams reasonable?
There was a problem hiding this comment.
Yeah, that's right, for ARTIQ that tag can be derived from this operand types I think
There was a problem hiding this comment.
I removed the tag adb3b83. which can be derived from the operand/result types during the conversion from rtio to artiq
mlir/include/RTIO/IR/RTIOOps.td
Outdated
| which is compatiable with the ARTIQ RPC wire protocol. | ||
| (e.g. "n:" for void no-arg, "n:si" for void(str,i32)). | ||
| - is_async: If present the call is async. | ||
| - rpc_id: Populated by the RPC-ID assignment sub-pass. |
There was a problem hiding this comment.
I think the rpc_id explanation is a bit too specific. We should explain what the attribute is or why it is useful. not what we do with it in the lowering.
There was a problem hiding this comment.
Thanks! I updated the explanation here. adb3b83
which is the only way that host device to communicate with the RPC server (through the rpc id to determine which function should be used)
mlir/lib/RTIO/IR/RTIOOps.cpp
Outdated
| //===----------------------------------------------------------------------===// | ||
|
|
||
| namespace { | ||
| /// ARTIQ RPC tag format: <return_type>:<arg_types> |
There was a problem hiding this comment.
Hmm again I am wondering if this would be better suited in a lower level place, maybe in the the lowering pass. What do you think?
There was a problem hiding this comment.
I think this is a bit nitpicky given that currently, we only use this dialect in the context of lowering to ARTIQ. So if the work needed to move it down is substantial, I think it would be fine to have it here with a TODO for now since the dialect is not used anywhere else, but keeping it independent of the ARTIQ internal details would be nice.
There was a problem hiding this comment.
Yes, adb3b83. I removed the tag, it will only be constructed when converting to the artiq llvm ir
| size_t colon = tag.find(':'); | ||
| StringRef returnPart = colon != StringRef::npos ? tag.take_front(colon) : "n"; | ||
|
|
||
| int slotSize = (returnPart == "n") ? 8 : getSlotSizeForReturnCode(returnPart[0]); |
There was a problem hiding this comment.
Why do we single out "n"? couldn't we include it in the switch case within getSlotSizeForReturnCode?
There was a problem hiding this comment.
originally I was want to distinguish the n with other types (since it's void). But yeah, I think it's fine to move it into the getSlotSzieForReturnCode function. It doesn't need to be separated out. d36e3b5
| StringRef returnPart = colon != StringRef::npos ? tag.take_front(colon) : "n"; | ||
|
|
||
| int slotSize = (returnPart == "n") ? 8 : getSlotSizeForReturnCode(returnPart[0]); | ||
| auto slotTy = LLVM::LLVMArrayType::get(i8Ty, slotSize); |
There was a problem hiding this comment.
Can you explain the logic here? I don't understand why we allocate an array of bytes instead of using a concrete resultTy?
There was a problem hiding this comment.
This is the wire protocol of the ARTIQ, they only allow you to pass raw bytes buffer with llvm ptr, except for the the rpc id (the first arg).
Co-authored-by: Mehrdad Malek <[email protected]>
Co-authored-by: Mehrdad Malek <[email protected]>
Context:
A new
rtio.rpcoperation is added to the RTIO dialect. It represents a host RPC call triggered by the kernel, optionally carrying runtime arguments and supporting both synchronous and async modes. The op is lowered torpc_send/rpc_recvLLVM calls (the ARTIQ RPC wire protocol). It is required by both AWG control (program_awg,awg_close) and measurement result collection (set_dataset,transfer_data).The RTIO dialect has no representation for RPC calls. Our use cases:
program_awgawg_closeset_datasettransfer_dataThe ARTIQ runtime exposes
rpc_send(int32_t service_id, const char *tag, ...)andrpc_recv(void *result)as extern C functions linked into the ELF.Description of the Change:
Added
rtio.rpcin RTIO dialect.This op contains the following attributes:
Benefits:
Possible Drawbacks:
Related GitHub Issues:
[sc-113163]