Kompute
|
#include <Algorithm.hpp>
Public Member Functions | |
template<typename S = float, typename P = float> | |
Algorithm (std::shared_ptr< vk::Device > device, const std::vector< std::shared_ptr< Tensor >> &tensors={}, const std::vector< uint32_t > &spirv={}, const Workgroup &workgroup={}, const std::vector< S > &specializationConstants={}, const std::vector< P > &pushConstants={}) | |
template<typename S = float, typename P = float> | |
void | rebuild (const std::vector< std::shared_ptr< Tensor >> &tensors, const std::vector< uint32_t > &spirv, const Workgroup &workgroup={}, const std::vector< S > &specializationConstants={}, const std::vector< P > &pushConstants={}) |
~Algorithm () | |
void | recordDispatch (const vk::CommandBuffer &commandBuffer) |
void | recordBindCore (const vk::CommandBuffer &commandBuffer) |
void | recordBindPush (const vk::CommandBuffer &commandBuffer) |
bool | isInit () |
void | setWorkgroup (const Workgroup &workgroup, uint32_t minSize=1) |
template<typename T > | |
void | setPushConstants (const std::vector< T > &pushConstants) |
void | setPushConstants (void *data, uint32_t size, uint32_t memorySize) |
const Workgroup & | getWorkgroup () |
template<typename T > | |
const std::vector< T > | getSpecializationConstants () |
template<typename T > | |
const std::vector< T > | getPushConstants () |
const std::vector< std::shared_ptr< Tensor > > & | getTensors () |
void | destroy () |
Abstraction for compute shaders that are run on top of tensors grouped via ParameterGroups (which group descriptorsets)
|
inline |
Main constructor for algorithm with configuration parameters to create the underlying resources.
device | The Vulkan device to use for creating resources |
tensors | (optional) The tensors to use to create the descriptor resources |
spirv | (optional) The spirv code to use to create the algorithm |
workgroup | (optional) The kp::Workgroup to use for the dispatch which defaults to kp::Workgroup(tensor[0].size(), 1, 1) if not set. |
specializationConstants | (optional) The templatable param is to be used to initialize the specialization constants which cannot be changed once set. |
pushConstants | (optional) This templatable param is to be used when initializing the pipeline, which set the size of the push constants
|
kp::Algorithm::~Algorithm | ( | ) |
Destructor for Algorithm which is responsible for freeing and desroying respective pipelines and owned parameter groups.
|
inline |
Gets the specialization constants of the current algorithm.
|
inline |
Gets the specialization constants of the current algorithm.
const std::vector<std::shared_ptr<Tensor> >& kp::Algorithm::getTensors | ( | ) |
Gets the current tensors that are used in the algorithm.
const Workgroup& kp::Algorithm::getWorkgroup | ( | ) |
Gets the current workgroup from the algorithm.
The | kp::Constant to use to set the push constants to use in the next bindPush(...) calls. The constants provided must be of the same size as the ones created during initialization. |
bool kp::Algorithm::isInit | ( | ) |
function that checks all the gpu resource components to verify if these have been created and returns true if all are valid.
|
inline |
Rebuild function to reconstruct algorithm with configuration parameters to create the underlying resources.
tensors | The tensors to use to create the descriptor resources |
spirv | The spirv code to use to create the algorithm |
workgroup | (optional) The kp::Workgroup to use for the dispatch which defaults to kp::Workgroup(tensor[0].size(), 1, 1) if not set. |
specializationConstants | (optional) The std::vector<float> to use to initialize the specialization constants which cannot be changed once set. |
pushConstants | (optional) The std::vector<float> to use when initializing the pipeline, which set the size of the push constants - these can be modified but all new values must have the same vector size as this initial value. |
void kp::Algorithm::recordBindCore | ( | const vk::CommandBuffer & | commandBuffer | ) |
Records command that binds the "core" algorithm components which consist of binding the pipeline and binding the descriptorsets.
commandBuffer | Command buffer to record the algorithm resources to |
void kp::Algorithm::recordBindPush | ( | const vk::CommandBuffer & | commandBuffer | ) |
Records command that binds the push constants to the command buffer provided
commandBuffer | Command buffer to record the algorithm resources to |
void kp::Algorithm::recordDispatch | ( | const vk::CommandBuffer & | commandBuffer | ) |
Records the dispatch function with the provided template parameters or alternatively using the size of the tensor by default.
commandBuffer | Command buffer to record the algorithm resources to |
|
inline |
Sets the push constants to the new value provided to use in the next bindPush()
pushConstants | The templatable vector is to be used to set the push constants to use in the next bindPush(...) calls. The constants provided must be of the same size as the ones created during initialization. |
|
inline |
Sets the push constants to the new value provided to use in the next bindPush() with the raw memory block location and memory size to be used.
data | The raw data point to copy the data from, without modifying the pointer. |
size | The number of data elements provided in the data |
memorySize | The memory size of each of the data elements in bytes. |
void kp::Algorithm::setWorkgroup | ( | const Workgroup & | workgroup, |
uint32_t | minSize = 1 |
||
) |
Sets the work group to use in the recordDispatch
workgroup | The kp::Workgroup value to use to update the algorithm. It must have a value greater than 1 on the x value (index 1) otherwise it will be initialized on the size of the first tensor (ie. this->mTensor[0]->size()) |