35int main(
int argc,
const char *argv[]) {
38 std::cerr <<
"Expected usage: " << argv[0]
39 <<
" <backend> <connection specifier> [command]" << std::endl;
43 const char *backend = argv[1];
44 const char *conn = argv[2];
50 Context ctxt = Context::withLogger<StreamLogger>(Logger::Level::Debug);
51 std::unique_ptr<AcceleratorConnection> acc = ctxt.connect(backend, conn);
53 Manifest manifest(ctxt, info.getJsonManifest());
54 Accelerator *accel = manifest.buildAccelerator(*acc);
55 acc->getServiceThread()->addPoll(*accel);
61 std::this_thread::sleep_for(std::chrono::milliseconds(100));
63 }
else if (cmd ==
"wait") {
64 std::this_thread::sleep_for(std::chrono::seconds(1));
65 }
else if (cmd ==
"dmatest") {
70 std::cerr <<
"Exiting successfully\n";
73 }
catch (std::exception &e) {
74 std::cerr <<
"Error: " << e.what() << std::endl;
81 auto f = ports.find(
AppID(
"PrintfExample"));
82 if (f != ports.end()) {
88 [&](std::string &subsystem, std::string &msg,
89 std::unique_ptr<std::map<std::string, std::any>> &details) {
90 subsystem =
"ESITESTER";
91 msg =
"Received PrintfExample message";
92 details = std::make_unique<std::map<std::string, std::any>>();
93 details->emplace(
"data", data);
95 std::cout <<
"PrintfExample: " << *data.as<uint32_t>() << std::endl;
103 std::cout <<
"Running DMA test with width " << width << std::endl;
107 .at(
AppID(
"readmem", width))
109 .at(
AppID(
"ReadMem"))
112 for (
size_t i = 0; i < 8; ++i) {
113 dataPtr[0] = 0x12345678 << i;
114 dataPtr[1] = 0xDEADBEEF << i;
115 readMem->
write(8, (uint64_t)dataPtr);
120 uint64_t expected = dataPtr[0];
122 expected &= ((1ull << width) - 1);
123 for (
int i = 0; i < 100; ++i) {
124 val = readMem->read(0);
127 std::this_thread::sleep_for(std::chrono::microseconds(100));
131 throw std::runtime_error(
"DMA read test failed. Expected " +
132 std::to_string(expected) +
", got " +
133 std::to_string(val));
140 writeMem->
write(0, (uint64_t)dataPtr);
142 for (
int i = 0; i < 100; ++i) {
145 std::this_thread::sleep_for(std::chrono::microseconds(100));
148 throw std::runtime_error(
"DMA write test failed");
155 auto scratchRegion = hostmem->allocate(32, {});
156 uint64_t *dataPtr =
static_cast<uint64_t *
>(scratchRegion->getPtr());
Abstract class representing a connection to an accelerator.
ServiceClass * getService(AppIDPath id={}, std::string implName={}, ServiceImplDetails details={}, HWClientDetails clients={})
Get a typed reference to a particular service type.
Logger & getLogger() const
Top level accelerator class.
AcceleratorConnections, Accelerators, and Manifests must all share a context.
const std::map< AppID, const BundlePort & > & getPorts() const
Access the module's ports by ID.
const std::map< AppID, Instance * > & getChildren() const
Access the module's children by ID.
void debug(const std::string &subsystem, const std::string &msg, const std::map< std::string, std::any > *details=nullptr)
Report a debug message.
Class to parse a manifest.
A logical chunk of data representing serialized data.
A function call which gets attached to a service port.
void connect(std::function< MessageData(const MessageData &)> callback, bool quick=false)
Connect a callback to code which will be executed when the accelerator invokes the callback.
virtual void start()
In cases where necessary, enable host memory services.
A "slice" of some parent MMIO space.
virtual void write(uint32_t addr, uint64_t data)
Write a 64-bit value to this region, not the global address space.
Information about the Accelerator system.
static void registerCallbacks(AcceleratorConnection *, Accelerator *)
int main(int argc, const char *argv[])
static void dmaTest(AcceleratorConnection *, Accelerator *)