Kompute
Public Member Functions | List of all members
kp::Manager Class Reference

#include <Manager.hpp>

Public Member Functions

 Manager ()
 
 Manager (uint32_t physicalDeviceIndex, const std::vector< uint32_t > &familyQueueIndices={}, const std::vector< std::string > &desiredExtensions={})
 
 Manager (std::shared_ptr< vk::Instance > instance, std::shared_ptr< vk::PhysicalDevice > physicalDevice, std::shared_ptr< vk::Device > device)
 
 ~Manager ()
 
std::shared_ptr< Sequencesequence (uint32_t queueIndex=0, uint32_t totalTimestamps=0)
 
template<typename T >
std::shared_ptr< TensorT< T > > tensorT (const std::vector< T > &data, Tensor::TensorTypes tensorType=Tensor::TensorTypes::eDevice)
 
std::shared_ptr< TensorT< float > > tensor (const std::vector< float > &data, Tensor::TensorTypes tensorType=Tensor::TensorTypes::eDevice)
 
std::shared_ptr< Tensortensor (void *data, uint32_t elementTotalCount, uint32_t elementMemorySize, const Tensor::TensorDataTypes &dataType, Tensor::TensorTypes tensorType=Tensor::TensorTypes::eDevice)
 
std::shared_ptr< Algorithmalgorithm (const std::vector< std::shared_ptr< Tensor >> &tensors={}, const std::vector< uint32_t > &spirv={}, const Workgroup &workgroup={}, const std::vector< float > &specializationConstants={}, const std::vector< float > &pushConstants={})
 
template<typename S = float, typename P = float>
std::shared_ptr< Algorithmalgorithm (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)
 
void destroy ()
 
void clear ()
 
vk::PhysicalDeviceProperties getDeviceProperties () const
 
std::vector< vk::PhysicalDevice > listDevices () const
 
std::shared_ptr< vk::Instance > getVkInstance () const
 

Detailed Description

Base orchestrator which creates and manages device and child components

Constructor & Destructor Documentation

◆ Manager() [1/3]

kp::Manager::Manager ( )

Base constructor and default used which creates the base resources including choosing the device 0 by default.

◆ Manager() [2/3]

kp::Manager::Manager ( uint32_t  physicalDeviceIndex,
const std::vector< uint32_t > &  familyQueueIndices = {},
const std::vector< std::string > &  desiredExtensions = {} 
)

Similar to base constructor but allows for further configuration to use when creating the Vulkan resources.

Parameters
physicalDeviceIndexThe index of the physical device to use
familyQueueIndices(Optional) List of queue indices to add for explicit allocation
desiredExtensionsThe desired extensions to load from physicalDevice

◆ Manager() [3/3]

kp::Manager::Manager ( std::shared_ptr< vk::Instance >  instance,
std::shared_ptr< vk::PhysicalDevice >  physicalDevice,
std::shared_ptr< vk::Device >  device 
)

Manager constructor which allows your own vulkan application to integrate with the kompute use.

Parameters
instanceVulkan compute instance to base this application
physicalDeviceVulkan physical device to use for application
deviceVulkan logical device to use for all base resources
physicalDeviceIndexIndex for vulkan physical device used

◆ ~Manager()

kp::Manager::~Manager ( )

Manager destructor which would ensure all owned resources are destroyed unless explicitly stated that resources should not be destroyed or freed.

Member Function Documentation

◆ algorithm() [1/2]

template<typename S = float, typename P = float>
std::shared_ptr<Algorithm> kp::Manager::algorithm ( 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 
)
inline

Create a managed algorithm that will be destroyed by this manager if it hasn't been destroyed by its reference count going to zero.

Parameters
tensors(optional) The tensors to initialise the algorithm with
spirv(optional) The SPIRV bytes for the algorithm to dispatch
workgroup(optional) kp::Workgroup for algorithm to use, and defaults to (tensor[0].size(), 1, 1)
specializationConstants(optional) templatable vector parameter to use for specialization constants, and defaults to an empty constant
pushConstants(optional) templatable vector parameter to use for push constants, and defaults to an empty constant
Returns
Shared pointer with initialised algorithm

◆ algorithm() [2/2]

std::shared_ptr<Algorithm> kp::Manager::algorithm ( const std::vector< std::shared_ptr< Tensor >> &  tensors = {},
const std::vector< uint32_t > &  spirv = {},
const Workgroup &  workgroup = {},
const std::vector< float > &  specializationConstants = {},
const std::vector< float > &  pushConstants = {} 
)
inline

Default non-template function that can be used to create algorithm objects which provides default types to the push and spec constants as floats.

Parameters
tensors(optional) The tensors to initialise the algorithm with
spirv(optional) The SPIRV bytes for the algorithm to dispatch
workgroup(optional) kp::Workgroup for algorithm to use, and defaults to (tensor[0].size(), 1, 1)
specializationConstants(optional) float vector to use for specialization constants, and defaults to an empty constant
pushConstants(optional) float vector to use for push constants, and defaults to an empty constant
Returns
Shared pointer with initialised algorithm

◆ clear()

void kp::Manager::clear ( )

Run a pseudo-garbage collection to release all the managed resources that have been already freed due to these reaching to zero ref count.

◆ destroy()

void kp::Manager::destroy ( )

Destroy the GPU resources and all managed resources by manager.

◆ getDeviceProperties()

vk::PhysicalDeviceProperties kp::Manager::getDeviceProperties ( ) const

Information about the current device.

Returns
vk::PhysicalDeviceProperties containing information about the device

◆ getVkInstance()

std::shared_ptr<vk::Instance> kp::Manager::getVkInstance ( ) const

The current Vulkan instance.

Returns
a shared pointer to the current Vulkan instance held by this object

◆ listDevices()

std::vector<vk::PhysicalDevice> kp::Manager::listDevices ( ) const

List the devices available in the current vulkan instance.

Returns
vector of physical devices containing their respective properties

◆ sequence()

std::shared_ptr<Sequence> kp::Manager::sequence ( uint32_t  queueIndex = 0,
uint32_t  totalTimestamps = 0 
)

Create a managed sequence that will be destroyed by this manager if it hasn't been destroyed by its reference count going to zero.

Parameters
queueIndexThe queue to use from the available queues
nrOfTimestampsThe maximum number of timestamps to allocate. If zero (default), disables latching of timestamps.
Returns
Shared pointer with initialised sequence

◆ tensorT()

template<typename T >
std::shared_ptr<TensorT<T> > kp::Manager::tensorT ( const std::vector< T > &  data,
Tensor::TensorTypes  tensorType = Tensor::TensorTypes::eDevice 
)
inline

Create a managed tensor that will be destroyed by this manager if it hasn't been destroyed by its reference count going to zero.

Parameters
dataThe data to initialize the tensor with
tensorTypeThe type of tensor to initialize
Returns
Shared pointer with initialised tensor

The documentation for this class was generated from the following file: