14 #include <cynq/enums.hpp>
15 #include <cynq/execution-graph.hpp>
16 #include <cynq/memory.hpp>
17 #include <cynq/status.hpp>
21 struct HardwareParameters;
86 virtual Status Start(std::shared_ptr<IExecutionGraph> graph,
87 const StartMode mode);
111 virtual Status Stop(std::shared_ptr<IExecutionGraph> graph);
134 virtual Status Sync(std::shared_ptr<IExecutionGraph> graph);
166 const uint64_t addr);
190 static std::shared_ptr<IAccelerator>
Create(
192 const std::shared_ptr<HardwareParameters> hwparams);
213 template <
typename T>
215 const size_t elements = 1) {
216 return this->
WriteRegister(address,
reinterpret_cast<const uint8_t *
>(data),
217 elements *
sizeof(T));
244 template <
typename T>
245 Status Write(std::shared_ptr<IExecutionGraph> graph,
const uint64_t address,
246 const T *data,
const size_t elements = 1) {
248 reinterpret_cast<const uint8_t *
>(data),
249 elements *
sizeof(T));
271 template <
typename T>
272 Status Read(
const uint64_t address, T *data,
const size_t elements = 1) {
273 return this->
ReadRegister(address,
reinterpret_cast<uint8_t *
>(data),
274 elements *
sizeof(T));
301 template <
typename T>
302 Status Read(std::shared_ptr<IExecutionGraph> graph,
const uint64_t address,
303 T *data,
const size_t elements = 1) {
304 return this->
ReadRegister(graph, address,
reinterpret_cast<uint8_t *
>(data),
305 elements *
sizeof(T));
345 template <
typename T>
347 const RegisterAccess access = RegisterAccess::WO,
348 const size_t elements = 1) {
349 return this->
AttachRegister(index,
reinterpret_cast<uint8_t *
>(data),
350 access, elements *
sizeof(T));
359 template <
typename T>
361 const RegisterAccess access = RegisterAccess::WO) {
362 return this->
AttachRegister(index,
reinterpret_cast<uint8_t *
>(data),
363 access, elements *
sizeof(T));
378 virtual Status Attach(
const uint64_t addr, std::shared_ptr<IMemory> mem) = 0;
395 const size_t size) = 0;
409 const size_t size) = 0;
427 const uint64_t address,
const uint8_t *data,
445 const uint64_t address, uint8_t *data,
464 const RegisterAccess access,
465 const size_t size) = 0;
Interface for standardising the API for any Accelerator device: XRTAccelerator.
Definition: accelerator.hpp:37
virtual Status WriteRegister(const uint64_t address, const uint8_t *data, const size_t size)=0
Opaque Write Register method Writes to the register of the accelerator.
virtual Status ReadRegister(const uint64_t address, uint8_t *data, const size_t size)=0
Opaque Read Register method.
virtual ~IAccelerator()=default
~IAccelerator destructor method Destroy the IAccelerator object.
virtual Status AttachRegister(const uint64_t index, uint8_t *data, const RegisterAccess access, const size_t size)=0
Opaque Attach Register method.
Type
Type Type of runtime supported by the IAccelerator.
Definition: accelerator.hpp:50
@ XRT
Definition: accelerator.hpp:56
@ None
Definition: accelerator.hpp:52
@ MMIO
Definition: accelerator.hpp:54
Status Write(const uint64_t address, const T *data, const size_t elements=1)
Write method Performs a write operation to the accelerator through a register.
Definition: accelerator.hpp:214
virtual Status Stop()=0
Stop method This asynchronously turns off the accelerator by removing the autorestart and start bits ...
static std::shared_ptr< IAccelerator > Create(IAccelerator::Type impl, const uint64_t addr)
Create method Factory method used for creating specific subclasses of IAccelerator.
Definition: accelerator.cpp:16
Status Write(std::shared_ptr< IExecutionGraph > graph, const uint64_t address, const T *data, const size_t elements=1)
Write method (asynchronous) Performs a write operation to the accelerator through a register in an ex...
Definition: accelerator.hpp:245
Status Read(const uint64_t address, T *data, const size_t elements=1)
Read method Performs a write operation to the accelerator through a register.
Definition: accelerator.hpp:272
Status Read(std::shared_ptr< IExecutionGraph > graph, const uint64_t address, T *data, const size_t elements=1)
Read method (asynchronous) Performs a write operation to the accelerator through a register in an exe...
Definition: accelerator.hpp:302
Status Attach(const uint64_t index, T *data, const size_t elements, const RegisterAccess access=RegisterAccess::WO)
Overload of the Attach<T>()
Definition: accelerator.hpp:360
virtual Status Start(const StartMode mode)=0
Start method This method starts the accelerator in either once or continuous mode (with the autoresta...
virtual Status Sync()=0
Sync method This synchronises the execution and wait until the kernel/accelerator finishes its execut...
Status Attach(const uint64_t index, T *data, const RegisterAccess access=RegisterAccess::WO, const size_t elements=1)
Attach an argument Performs an attachment of the argument and the respective pointer....
Definition: accelerator.hpp:346
virtual Status Attach(const uint64_t addr, std::shared_ptr< IMemory > mem)=0
Attach a memory argument Performs an attachment of the argument and the respective pointer....
virtual DeviceStatus GetStatus()=0
GetStatus method This returns the accelerator state by using the DeviceStatus. This reads the control...
virtual int GetMemoryBank(const uint pos)=0
Get the memory bank ID.
Define an abstract representation of the accelerator parameters with some prefilled fields.
Definition: accelerator.hpp:27
virtual ~AcceleratorParameters()=default
Structure to define the return characteristics of each function.
Definition: status.hpp:19