DeviceMem Struct Reference#
ck_tile::DeviceMem Struct Reference
Manages device memory allocation and host-device data transfers. More...
#include <device_memory.hpp>
Public Member Functions | |
DeviceMem () | |
DeviceMem (std::size_t mem_size) | |
template<typename T > | |
DeviceMem (const HostTensor< T > &t) | |
void | Realloc (std::size_t mem_size) |
void * | GetDeviceBuffer () const |
std::size_t | GetBufferSize () const |
void | ToDevice (const void *p) const |
void | ToDevice (const void *p, const std::size_t cpySize) const |
void | FromDevice (void *p) const |
void | FromDevice (void *p, const std::size_t cpySize) const |
template<typename T > | |
HostTensor< T > | ToHost (std::size_t cpySize) |
template<typename T > | |
HostTensor< T > | ToHost () |
void | SetZero () const |
template<typename T > | |
void | SetValue (T x) const |
~DeviceMem () | |
Public Attributes | |
void * | mpDeviceBuf |
pointer to device buffer More... | |
std::size_t | mMemSize |
size of device buffer in bytes More... | |
Detailed Description
Manages device memory allocation and host-device data transfers.
DeviceMem encapsulates GPU memory management operations using HIP runtime API. It provides functionality for allocating device memory, transferring data between host and device, and performing basic memory operations.
Key features:
- Automatic memory allocation and deallocation
- Host-to-device and device-to-host data transfers
- Memory initialization operations
- Integration with HostTensor for simplified data handling
Usage example:
// Allocate device memory
BHostTensor<float> AHostData({256});
DeviceMem d_mem(BHostData.get_element_space_size_in_bytes());
// Transfer data to device
HostTensor<float> AHostTensor({256});
d_mem.ToDevice(AHostData.data());
// Retrieve data from device
HostTensor<float> ResultHostTensor({256});
d_mem.FromDevice(ResultHostTensor.data());
Constructor & Destructor Documentation
◆ DeviceMem() [1/3]
|
inline |
◆ DeviceMem() [2/3]
|
inline |
◆ DeviceMem() [3/3]
template<typename T >
|
inline |
◆ ~DeviceMem()
|
inline |
Member Function Documentation
◆ FromDevice() [1/2]
|
inline |
◆ FromDevice() [2/2]
|
inline |
◆ GetBufferSize()
|
inline |
◆ GetDeviceBuffer()
|
inline |
◆ Realloc()
|
inline |
◆ SetValue()
template<typename T >
|
inline |
◆ SetZero()
|
inline |
◆ ToDevice() [1/2]
|
inline |
◆ ToDevice() [2/2]
|
inline |
◆ ToHost() [1/2]
template<typename T >
|
inline |
◆ ToHost() [2/2]
template<typename T >
|
inline |
Member Data Documentation
◆ mMemSize
std::size_t ck_tile::DeviceMem::mMemSize |
size of device buffer in bytes
◆ mpDeviceBuf
void* ck_tile::DeviceMem::mpDeviceBuf |
pointer to device buffer
The documentation for this struct was generated from the following file:
- /home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-composable-kernel/checkouts/develop/include/ck_tile/host/device_memory.hpp