Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ESI][PyCDE] Callback service #7153

Merged
merged 9 commits into from
Jun 19, 2024
Merged

[ESI][PyCDE] Callback service #7153

merged 9 commits into from
Jun 19, 2024

Conversation

teqdruid
Copy link
Contributor

@teqdruid teqdruid commented Jun 11, 2024

Call software functions from hardware.

@teqdruid teqdruid added the ESI label Jun 11, 2024
Call functions that the host software registers from hardware.
@teqdruid teqdruid marked this pull request as ready for review June 11, 2024 04:24
@teqdruid teqdruid requested a review from mortbopet June 11, 2024 04:24
Comment on lines +39 to +45
class EsiTesterTop(Module):
clk = Clock()
rst = Reset()

@generator
def construct(ports):
PrintfExample(clk=ports.clk, rst=ports.rst)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to have EsiTesterTop here? Can't we just instantiate PrintfExample in the pycde.System? It just looks a bit redundant to have a secondary top module which does nothing but instantiate the first.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is that this test would expand to test multiple new advanced features.

@@ -0,0 +1,53 @@
# REQUIRES: esi-runtime, esi-cosim, rtl-sim, esitester
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

esitester seems very vague for the purpose of this file. I presume that this file is intended to test the callback service, and callback service only? I'd really like to the see the testing story for ESI be elaborated, and also made easier to wrap ones' head around. Part of this - in my opinion - is to properly split out test files into more meaningfully named things (e.g. would this be more meaningfully named PyCDE/integration_test/esi/test_callbackservice.py?).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I lean the opposite direction. I would like to see a monolithic test for ESI features which could be synthesized to a single FPGA image. Medium term, it'd probably be useful for board and BSP developers to test correctness and performance. This test was named with that intention in mind.

Comment on lines +529 to +530
"""Expose a bundle to the host as a function. Bundle _must_ have 'arg' and
'result' channels going FROM the server and TO the server, respectively."""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a lot of this host/server/... split brain terminology that needs to be refactored in our upcoming work 👀... Seeing as we're trending towards supporting everything-can-call-everything in the system, alternatives could be source/target,caller/calle, or just unify on using from/to.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I agree. We'll have to decide on appropriate terms, which actually won't be easy given the multiple processes we'll be developing for CAM.

def CallServiceDeclOp : ESI_Op<"service.std.call",
[SingleBlock, NoTerminator, HasParent<"::mlir::ModuleOp">,
Symbol, DeclareOpInterfaceMethods<ServiceDeclOpInterface>]> {
let summary = "Service against which hardware can call into software";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessarily hardware calling software? Again, this might be refactored in upcoming work, but in theory this service could be served by things other than software, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The calls which this service exposes could be implemented in hardware, but it's intended for software. For making calls in hardware, I suspect this service wouldn't make a lot of sense. I think directly connecting function calls to functions makes more sense.

lib/Dialect/ESI/runtime/cpp/include/esi/Common.h Outdated Show resolved Hide resolved
lib/Dialect/ESI/runtime/cpp/include/esi/Common.h Outdated Show resolved Hide resolved
lib/Dialect/ESI/runtime/cpp/lib/Accelerator.cpp Outdated Show resolved Hide resolved
Comment on lines +113 to +119
std::lock_guard<std::mutex> g(listenerMutex);
for (auto &[channel, cb] : listeners) {
assert(channel && "Null channel in listener list");
if (channel->read(data))
portUnlockWorkList.emplace_back(channel, cb, std::move(data));
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the implementation of ReadChannelPort's read functions, nothings going to be particularly performant here. However, i was wondering whether it'd be more futureproof to base your implementation here on ReadChannelPort::readAsync, and then instead of looping over the listeners map, you'd signal a condition variable whenever a new listener was added, modify readAsync s.t. it also takes an optional callback, and in that callback, assign portUnlockWorkList. This, with the goal of making AcceleratorServiceThread::Impl::loop the final implementation, which will be performant, once readAsync is properly implemented.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I'm considering re-implementing the other PR using this service loop.

@@ -0,0 +1,86 @@
//===- esitester.cpp - ESI accelerator test/example tool ------------------===//
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above... esitester makes it sound like this is applicable for testing any ESI application, but it seems like a callback-specific thing.

@teqdruid teqdruid merged commit 1f6c29f into main Jun 19, 2024
4 checks passed
@teqdruid teqdruid deleted the teqdruid/esi-callbacks branch June 19, 2024 05:14
uenoku pushed a commit that referenced this pull request Jul 3, 2024
Call software functions from hardware.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants