CIRCT 24.0.0git
Loading...
Searching...
No Matches
esi::services::HostMemRegion Struct Referenceabstract

RAII memory region for host memory in accelerator-accessible address space. More...

#include <Services.h>

Inheritance diagram for esi::services::HostMemRegion:

Public Member Functions

virtual ~HostMemRegion ()=default
virtual void * getPtr () const =0
 Get a pointer to the host memory.
virtual void * getDevicePtr () const
 Sometimes the pointer the device sees is different from the pointer the host sees.
 operator void * () const
virtual std::size_t getSize () const =0
std::optional< uint64_t > getDeviceAddress (const void *ptr, std::size_t size) const
 Device address of the host range [ptr, ptr + size) if that range lies entirely inside this region; std::nullopt otherwise (including when size == 0 or the range would overflow the host or device address space).
virtual void flush ()
 Flush the memory region to ensure that the device sees the latest contents.

Detailed Description

RAII memory region for host memory in accelerator-accessible address space.

Automatically frees the memory when deconstructed. Allocated via HostMem::allocate() and also available as HostMem::HostMemRegion. Defined at namespace scope so that Common.h can forward declare it.

Definition at line 237 of file Services.h.

Constructor & Destructor Documentation

◆ ~HostMemRegion()

virtual esi::services::HostMemRegion::~HostMemRegion ( )
virtualdefault

Member Function Documentation

◆ flush()

virtual void esi::services::HostMemRegion::flush ( )
inlinevirtual

Flush the memory region to ensure that the device sees the latest contents.

Because some platforms require it before DMA transactions, it is recommended to call this before any DMA on all platforms. On platforms which don't require it, it is a cheap no-op virtual method call.

Definition at line 256 of file Services.h.

Referenced by hostmemReadBandwidthTest(), hostmemReadTest(), hostmemWriteBandwidthTest(), and hostmemWriteTest().

◆ getDeviceAddress()

std::optional< uint64_t > HostMemRegion::getDeviceAddress ( const void * ptr,
std::size_t size ) const

Device address of the host range [ptr, ptr + size) if that range lies entirely inside this region; std::nullopt otherwise (including when size == 0 or the range would overflow the host or device address space).

Definition at line 187 of file Services.cpp.

References getDevicePtr(), getPtr(), and getSize().

◆ getDevicePtr()

virtual void * esi::services::HostMemRegion::getDevicePtr ( ) const
inlinevirtual

Sometimes the pointer the device sees is different from the pointer the host sees.

Call this function to get the device pointer.

Definition at line 243 of file Services.h.

References getPtr().

Referenced by getDeviceAddress(), hostmemReadBandwidthTest(), hostmemReadTest(), hostmemWriteBandwidthTest(), and hostmemWriteTest().

◆ getPtr()

virtual void * esi::services::HostMemRegion::getPtr ( ) const
pure virtual

◆ getSize()

virtual std::size_t esi::services::HostMemRegion::getSize ( ) const
pure virtual

◆ operator void *()

esi::services::HostMemRegion::operator void * ( ) const
inline

Definition at line 244 of file Services.h.

References getPtr().


The documentation for this struct was generated from the following files: