5 #include <unordered_map>
7 #include "kompute/Core.hpp"
9 #include "kompute/Sequence.hpp"
10 #include "logger/Logger.hpp"
12 #define KP_DEFAULT_SESSION "DEFAULT"
39 const std::vector<uint32_t>& familyQueueIndices = {},
40 const std::vector<std::string>& desiredExtensions = {});
51 Manager(std::shared_ptr<vk::Instance> instance,
52 std::shared_ptr<vk::PhysicalDevice> physicalDevice,
53 std::shared_ptr<vk::Device> device);
70 std::shared_ptr<Sequence>
sequence(uint32_t queueIndex = 0,
71 uint32_t totalTimestamps = 0);
83 const std::vector<T>& data,
86 KP_LOG_DEBUG(
"Kompute Manager tensor creation triggered");
89 this->mPhysicalDevice, this->mDevice, data, tensorType) };
91 if (this->mManageResources) {
92 this->mManagedTensors.push_back(tensor);
98 std::shared_ptr<TensorT<float>> tensor(
99 const std::vector<float>& data,
102 return this->tensorT<float>(data, tensorType);
105 std::shared_ptr<Tensor> tensor(
107 uint32_t elementTotalCount,
108 uint32_t elementMemorySize,
109 const Tensor::TensorDataTypes& dataType,
112 std::shared_ptr<Tensor> tensor{
new kp::Tensor(this->mPhysicalDevice,
120 if (this->mManageResources) {
121 this->mManagedTensors.push_back(tensor);
143 const std::vector<std::shared_ptr<Tensor>>& tensors = {},
144 const std::vector<uint32_t>& spirv = {},
145 const Workgroup& workgroup = {},
146 const std::vector<float>& specializationConstants = {},
147 const std::vector<float>& pushConstants = {})
149 return this->algorithm<>(
150 tensors, spirv, workgroup, specializationConstants, pushConstants);
167 template<
typename S =
float,
typename P =
float>
169 const std::vector<std::shared_ptr<Tensor>>& tensors,
170 const std::vector<uint32_t>& spirv,
171 const Workgroup& workgroup,
172 const std::vector<S>& specializationConstants,
173 const std::vector<P>& pushConstants)
176 KP_LOG_DEBUG(
"Kompute Manager algorithm creation triggered");
183 specializationConstants,
186 if (this->mManageResources) {
187 this->mManagedAlgorithms.push_back(
algorithm);
228 std::shared_ptr<vk::Instance> mInstance =
nullptr;
229 bool mFreeInstance =
false;
230 std::shared_ptr<vk::PhysicalDevice> mPhysicalDevice =
nullptr;
231 std::shared_ptr<vk::Device> mDevice =
nullptr;
232 bool mFreeDevice =
false;
235 std::vector<std::weak_ptr<Tensor>> mManagedTensors;
236 std::vector<std::weak_ptr<Sequence>> mManagedSequences;
237 std::vector<std::weak_ptr<Algorithm>> mManagedAlgorithms;
239 std::vector<uint32_t> mComputeQueueFamilyIndices;
240 std::vector<std::shared_ptr<vk::Queue>> mComputeQueues;
242 bool mManageResources =
false;
244 #ifndef KOMPUTE_DISABLE_VK_DEBUG_LAYERS
245 vk::DebugReportCallbackEXT mDebugReportCallback;
246 vk::DispatchLoaderDynamic mDebugDispatcher;
250 void createInstance();
251 void createDevice(
const std::vector<uint32_t>& familyQueueIndices = {},
252 uint32_t hysicalDeviceIndex = 0,
253 const std::vector<std::string>& desiredExtensions = {});
Definition: Algorithm.hpp:17
Definition: Manager.hpp:20
std::shared_ptr< Algorithm > 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)
Definition: Manager.hpp:168
Manager(uint32_t physicalDeviceIndex, const std::vector< uint32_t > &familyQueueIndices={}, const std::vector< std::string > &desiredExtensions={})
vk::PhysicalDeviceProperties getDeviceProperties() const
std::vector< vk::PhysicalDevice > listDevices() const
std::shared_ptr< Sequence > sequence(uint32_t queueIndex=0, uint32_t totalTimestamps=0)
std::shared_ptr< vk::Instance > getVkInstance() const
std::shared_ptr< Algorithm > 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={})
Definition: Manager.hpp:142
std::shared_ptr< TensorT< T > > tensorT(const std::vector< T > &data, Tensor::TensorTypes tensorType=Tensor::TensorTypes::eDevice)
Definition: Manager.hpp:82
Manager(std::shared_ptr< vk::Instance > instance, std::shared_ptr< vk::PhysicalDevice > physicalDevice, std::shared_ptr< vk::Device > device)
Definition: Tensor.hpp:300
Definition: Tensor.hpp:20
TensorTypes
Definition: Tensor.hpp:29
@ eDevice
Type is device memory, source and destination.