|
| enum class | MemoryTypes { eDevice = 0
, eHost = 1
, eStorage = 2
, eDeviceAndHost
} |
| |
| enum class | DataTypes {
eBool = 0
, eInt = 1
, eUnsignedInt = 2
, eFloat = 3
,
eDouble = 4
, eCustom = 5
, eShort = 6
, eUnsignedShort = 7
,
eChar = 8
, eUnsignedChar = 9
} |
| |
| enum class | Type { eTensor = 0
, eImage = 1
} |
| |
|
|
| Memory (std::shared_ptr< vk::PhysicalDevice > physicalDevice, std::shared_ptr< vk::Device > device, const DataTypes &dataType, const MemoryTypes &memoryType, uint32_t x, uint32_t y) |
| |
|
| Memory (const Memory &)=delete |
| | Make Memory uncopyable.
|
| |
|
| Memory (const Memory &&)=delete |
| |
|
Memory & | operator= (const Memory &)=delete |
| |
|
Memory & | operator= (const Memory &&)=delete |
| |
| virtual | ~Memory () |
| |
| virtual void | destroy () |
| |
| MemoryTypes | memoryType () |
| |
| DataTypes | dataType () |
| |
| virtual bool | isInit ()=0 |
| |
| virtual void | recordCopyFromStagingToDevice (const vk::CommandBuffer &commandBuffer)=0 |
| |
| virtual void | recordCopyFromDeviceToStaging (const vk::CommandBuffer &commandBuffer)=0 |
| |
| virtual void | recordPrimaryMemoryBarrier (const vk::CommandBuffer &commandBuffer, vk::AccessFlagBits srcAccessMask, vk::AccessFlagBits dstAccessMask, vk::PipelineStageFlagBits srcStageMask, vk::PipelineStageFlagBits dstStageMask)=0 |
| |
| virtual void | recordStagingMemoryBarrier (const vk::CommandBuffer &commandBuffer, vk::AccessFlagBits srcAccessMask, vk::AccessFlagBits dstAccessMask, vk::PipelineStageFlagBits srcStageMask, vk::PipelineStageFlagBits dstStageMask)=0 |
| |
| void | recordCopyFrom (const vk::CommandBuffer &commandBuffer, std::shared_ptr< Memory > copyFromMemory) |
| |
| virtual vk::WriteDescriptorSet | constructDescriptorSet (vk::DescriptorSet descriptorSet, uint32_t binding)=0 |
| |
| uint32_t | size () |
| |
| uint32_t | dataTypeMemorySize () |
| |
| uint32_t | memorySize () |
| |
|
vk::DescriptorType | getDescriptorType () |
| |
| void * | rawData () |
| |
| void | setData (const void *data, size_t size) |
| |
| template<typename T > |
| void | setData (const std::vector< T > &data) |
| |
| template<typename T > |
| T * | data () |
| |
| template<typename T > |
| std::vector< T > | vector () |
| |
|
uint32_t | getX () |
| |
|
uint32_t | getY () |
| |
| virtual Type | type ()=0 |
| |
|
|
MemoryTypes | mMemoryType |
| |
|
DataTypes | mDataType |
| |
|
uint32_t | mSize |
| |
|
uint32_t | mDataTypeMemorySize |
| |
|
void * | mRawData = nullptr |
| |
|
vk::DescriptorType | mDescriptorType |
| |
|
bool | mUnmapMemory = false |
| |
|
uint32_t | mX |
| |
|
uint32_t | mY |
| |
|
std::shared_ptr< vk::PhysicalDevice > | mPhysicalDevice |
| |
|
std::shared_ptr< vk::Device > | mDevice |
| |
|
std::shared_ptr< vk::DeviceMemory > | mPrimaryMemory |
| |
|
bool | mFreePrimaryMemory = false |
| |
|
std::shared_ptr< vk::DeviceMemory > | mStagingMemory |
| |
|
bool | mFreeStagingMemory = false |
| |
◆ MemoryTypes
Type for memory created: Device allows memory to be transferred from staging memory. Staging are host memory visible. Storage are device visible but are not set up to transfer or receive data (only for shader storage).
| Enumerator |
|---|
| eDevice | Type is device memory, source and destination.
|
| eHost | Type is host memory, source and destination.
|
| eStorage | Type is Device memory (only)
|
| eDeviceAndHost | Type is host-visible and host-coherent device memory.
|
◆ ~Memory()
Destructor which is in charge of freeing vulkan resources unless they have been provided externally.
◆ constructDescriptorSet()
| virtual vk::WriteDescriptorSet kp::Memory::constructDescriptorSet |
( |
vk::DescriptorSet |
descriptorSet, |
|
|
uint32_t |
binding |
|
) |
| |
|
pure virtual |
Adds this object to a Vulkan descriptor set at binding.
- Parameters
-
| descriptorSet | The descriptor set to add to. |
| binding | The binding number to use. |
- Returns
- Add this object to a descriptor set at
binding.
Implemented in kp::Image, and kp::Tensor.
◆ data()
Template to return the pointer data converted by specific type, which would be any of the supported types including float, double, int32, uint32 and bool.
- Returns
- Pointer to raw memory containing raw bytes data of Tensor/Image.
◆ dataType() [1/2]
Retrieve the data type for T
- Returns
- Data type of T of type kp::Memory::DataTypes
◆ dataType() [2/2]
| DataTypes kp::Memory::dataType |
( |
| ) |
|
Retrieve the data type of the tensor (int, float, unsigned short etc.)
- Returns
- Data type of memory of type kp::Memory::DataTypes
◆ dataTypeMemorySize() [1/2]
| uint32_t kp::Memory::dataTypeMemorySize |
( |
| ) |
|
Returns the total size of a single element of the respective data type that this memory object holds.
- Returns
- Unsigned integer representing the memory of a single element of the respective data type.
◆ dataTypeMemorySize() [2/2]
Returns the total size of a single element of the respective data type
- Returns
- Unsigned integer representing the memory of a single element of the respective data type.
◆ destroy()
Destroys and frees the GPU resources which includes the memory.
Reimplemented in kp::Image, and kp::Tensor.
◆ isInit()
Check whether memory object is initialized based on the created gpu resources.
- Returns
- Boolean stating whether memory object is initialized
Implemented in kp::Image, and kp::Tensor.
◆ memorySize()
Returns the total memory size of the data contained by the memory object which would equate to (this->size() * this->dataTypeMemorySize())
- Returns
- Unsigned integer representing the total memory size of the data contained by the image object.
◆ memoryType()
Retrieve the memory type of the memory
- Returns
- memory type of memory
◆ rawData()
| void * kp::Memory::rawData |
( |
| ) |
|
Retrieve the raw data via the pointer to the memory that contains the raw memory of this current tensor. This tensor gets changed to a nullptr when the Tensor is removed.
- Returns
- Pointer to raw memory containing raw bytes data of Tensor/Image.
◆ recordCopyFrom() [1/3]
| virtual void kp::Memory::recordCopyFrom |
( |
const vk::CommandBuffer & |
commandBuffer, |
|
|
std::shared_ptr< Image > |
copyFromMemory |
|
) |
| |
|
protectedpure virtual |
◆ recordCopyFrom() [2/3]
| void kp::Memory::recordCopyFrom |
( |
const vk::CommandBuffer & |
commandBuffer, |
|
|
std::shared_ptr< Memory > |
copyFromMemory |
|
) |
| |
Records a copy from the memory provided to the current memory. This is intended to pass memory into a processing, to perform a staging image transfer, or to gather output (between others).
- Parameters
-
| commandBuffer | Vulkan Command Buffer to record the commands into |
| copyFromMemory | Memory to copy the data from |
◆ recordCopyFrom() [3/3]
| virtual void kp::Memory::recordCopyFrom |
( |
const vk::CommandBuffer & |
commandBuffer, |
|
|
std::shared_ptr< Tensor > |
copyFromMemory |
|
) |
| |
|
protectedpure virtual |
◆ recordCopyFromDeviceToStaging()
| virtual void kp::Memory::recordCopyFromDeviceToStaging |
( |
const vk::CommandBuffer & |
commandBuffer | ) |
|
|
pure virtual |
Records a copy from the internal device memory to the staging memory using an optional barrier to wait for the operation. This function would only be relevant for kp::Tensors of type eDevice.
- Parameters
-
| commandBuffer | Vulkan Command Buffer to record the commands into |
Implemented in kp::Image, and kp::Tensor.
◆ recordCopyFromStagingToDevice()
| virtual void kp::Memory::recordCopyFromStagingToDevice |
( |
const vk::CommandBuffer & |
commandBuffer | ) |
|
|
pure virtual |
Records a copy from the internal staging memory to the device memory using an optional barrier to wait for the operation. This function would only be relevant for kp::Tensors of type eDevice.
- Parameters
-
| commandBuffer | Vulkan Command Buffer to record the commands into |
Implemented in kp::Image, and kp::Tensor.
◆ recordPrimaryMemoryBarrier()
| virtual void kp::Memory::recordPrimaryMemoryBarrier |
( |
const vk::CommandBuffer & |
commandBuffer, |
|
|
vk::AccessFlagBits |
srcAccessMask, |
|
|
vk::AccessFlagBits |
dstAccessMask, |
|
|
vk::PipelineStageFlagBits |
srcStageMask, |
|
|
vk::PipelineStageFlagBits |
dstStageMask |
|
) |
| |
|
pure virtual |
Records the buffer memory barrier into the primary buffer and command buffer which ensures that relevant data transfers are carried out correctly.
- Parameters
-
| commandBuffer | Vulkan Command Buffer to record the commands into |
| srcAccessMask | Access flags for source access mask |
| dstAccessMask | Access flags for destination access mask |
| scrStageMask | Pipeline stage flags for source stage mask |
| dstStageMask | Pipeline stage flags for destination stage mask |
Implemented in kp::Image, and kp::Tensor.
◆ recordStagingMemoryBarrier()
| virtual void kp::Memory::recordStagingMemoryBarrier |
( |
const vk::CommandBuffer & |
commandBuffer, |
|
|
vk::AccessFlagBits |
srcAccessMask, |
|
|
vk::AccessFlagBits |
dstAccessMask, |
|
|
vk::PipelineStageFlagBits |
srcStageMask, |
|
|
vk::PipelineStageFlagBits |
dstStageMask |
|
) |
| |
|
pure virtual |
Records the buffer memory barrier into the staging buffer and command buffer which ensures that relevant data transfers are carried out correctly.
- Parameters
-
| commandBuffer | Vulkan Command Buffer to record the commands into |
| srcAccessMask | Access flags for source access mask |
| dstAccessMask | Access flags for destination access mask |
| scrStageMask | Pipeline stage flags for source stage mask |
| dstStageMask | Pipeline stage flags for destination stage mask |
Implemented in kp::Image, and kp::Tensor.
◆ setData() [1/2]
| void kp::Memory::setData |
( |
const std::vector< T > & |
data | ) |
|
|
inline |
Sets / resets the data of the tensor/image which is directly done on the GPU host visible memory available by the tensor/image.
◆ setData() [2/2]
Sets / resets the data of the tensor/image which is directly done on the GPU host visible memory available by the tensor/image.
◆ size()
Returns the size/magnitude of the Tensor/Image, which will be the total number of elements across all dimensions
- Returns
- Unsigned integer representing the total number of elements
◆ type()
◆ vector()
template<typename T >
| std::vector< T > kp::Memory::vector |
( |
| ) |
|
|
inline |
Template to get the data of the current tensor/image as a vector of specific type, which would be any of the supported types including float, double, int32, uint32 and bool.
- Returns
- Vector of type provided by template.
The documentation for this class was generated from the following file:
- /home/me/development/kompute/src/include/kompute/Memory.hpp