Skip to content

Commit

Permalink
[ESI][Runtime] Add service context to bundle requests
Browse files Browse the repository at this point in the history
Pass the current services table when requesting bundle ports. Not (yet)
used in CIRCT but is required for an internal DMA engine. Useful for any
DMA engine but we haven't open sourced any.
  • Loading branch information
teqdruid committed Oct 18, 2024
1 parent 555de19 commit d6b191a
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 20 deletions.
9 changes: 8 additions & 1 deletion lib/Dialect/ESI/runtime/cpp/include/esi/Accelerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,17 @@ class AcceleratorConnection {
/// Disconnect from the accelerator cleanly.
virtual void disconnect();

// While building the design, keep around a std::map of active services
// indexed by the service name. When a new service is encountered during
// descent, add it to the table (perhaps overwriting one). Modifications to
// the table only apply to the current branch, so copy this and update it at
// each level of the tree.
using ServiceTable = std::map<std::string, services::Service *>;

/// Request the host side channel ports for a particular instance (identified
/// by the AppID path). For convenience, provide the bundle type.
virtual std::map<std::string, ChannelPort &>
requestChannelsFor(AppIDPath, const BundleType *) = 0;
requestChannelsFor(AppIDPath, const BundleType *, const ServiceTable &) = 0;

/// Return a pointer to the accelerator 'service' thread (or threads). If the
/// thread(s) are not running, they will be started when this method is
Expand Down
3 changes: 2 additions & 1 deletion lib/Dialect/ESI/runtime/cpp/include/esi/backends/Cosim.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ class CosimAccelerator : public esi::AcceleratorConnection {
/// by the AppID path). For convenience, provide the bundle type and direction
/// of the bundle port.
virtual std::map<std::string, ChannelPort &>
requestChannelsFor(AppIDPath, const BundleType *) override;
requestChannelsFor(AppIDPath, const BundleType *,
const ServiceTable &) override;

// C++ doesn't have a mechanism to forward declare a nested class and we don't
// want to include the generated header here. So we have to wrap it in a
Expand Down
3 changes: 2 additions & 1 deletion lib/Dialect/ESI/runtime/cpp/include/esi/backends/Trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ class TraceAccelerator : public esi::AcceleratorConnection {
/// Request the host side channel ports for a particular instance (identified
/// by the AppID path). For convenience, provide the bundle type.
std::map<std::string, ChannelPort &>
requestChannelsFor(AppIDPath, const BundleType *) override;
requestChannelsFor(AppIDPath, const BundleType *,
const ServiceTable &) override;

protected:
virtual Service *createService(Service::Type service, AppIDPath idPath,
Expand Down
3 changes: 2 additions & 1 deletion lib/Dialect/ESI/runtime/cpp/include/esi/backends/Xrt.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class XrtAccelerator : public esi::AcceleratorConnection {
/// by the AppID path). For convenience, provide the bundle type and direction
/// of the bundle port.
std::map<std::string, ChannelPort &>
requestChannelsFor(AppIDPath, const BundleType *) override;
requestChannelsFor(AppIDPath, const BundleType *,
const ServiceTable &) override;

protected:
virtual Service *createService(Service::Type service, AppIDPath path,
Expand Down
9 changes: 2 additions & 7 deletions lib/Dialect/ESI/runtime/cpp/lib/Manifest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@
#include <sstream>

using namespace ::esi;

// While building the design, keep around a std::map of active services indexed
// by the service name. When a new service is encountered during descent, add it
// to the table (perhaps overwriting one). Modifications to the table only apply
// to the current branch, so copy this and update it at each level of the tree.
using ServiceTable = std::map<std::string, services::Service *>;
using ServiceTable = AcceleratorConnection::ServiceTable;

// This is a proxy class to the manifest JSON. It is used to avoid having to
// include the JSON parser in the header. Forward references don't work since
Expand Down Expand Up @@ -454,7 +449,7 @@ Manifest::Impl::getBundlePorts(AcceleratorConnection &acc, AppIDPath idPath,

idPath.push_back(parseID(content.at("appID")));
std::map<std::string, ChannelPort &> portChannels =
acc.requestChannelsFor(idPath, bundleType);
acc.requestChannelsFor(idPath, bundleType, activeServices);

services::ServicePort *svcPort =
svc->getPort(idPath, bundleType, portChannels, acc);
Expand Down
5 changes: 2 additions & 3 deletions lib/Dialect/ESI/runtime/cpp/lib/backends/Cosim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,8 @@ class ReadCosimChannelPort

} // namespace

std::map<std::string, ChannelPort &>
CosimAccelerator::requestChannelsFor(AppIDPath idPath,
const BundleType *bundleType) {
std::map<std::string, ChannelPort &> CosimAccelerator::requestChannelsFor(
AppIDPath idPath, const BundleType *bundleType, const ServiceTable &) {
std::map<std::string, ChannelPort &> channelResults;

// Find the client details for the port at 'fullPath'.
Expand Down
5 changes: 2 additions & 3 deletions lib/Dialect/ESI/runtime/cpp/lib/backends/Trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,8 @@ TraceAccelerator::Impl::requestChannelsFor(AppIDPath idPath,
return channels;
}

std::map<std::string, ChannelPort &>
TraceAccelerator::requestChannelsFor(AppIDPath idPath,
const BundleType *bundleType) {
std::map<std::string, ChannelPort &> TraceAccelerator::requestChannelsFor(
AppIDPath idPath, const BundleType *bundleType, const ServiceTable &) {
return impl->requestChannelsFor(idPath, bundleType);
}

Expand Down
5 changes: 2 additions & 3 deletions lib/Dialect/ESI/runtime/cpp/lib/backends/Xrt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,8 @@ class XrtMMIO : public MMIO {
};
} // namespace

std::map<std::string, ChannelPort &>
XrtAccelerator::requestChannelsFor(AppIDPath idPath,
const BundleType *bundleType) {
std::map<std::string, ChannelPort &> XrtAccelerator::requestChannelsFor(
AppIDPath idPath, const BundleType *bundleType, const ServiceTable &) {
return impl->requestChannelsFor(idPath, bundleType);
}

Expand Down

0 comments on commit d6b191a

Please sign in to comment.