37 const std::vector<uint32_t>& familyQueueIndices = {},
38 const std::vector<std::string>& desiredExtensions = {});
49 Manager(std::shared_ptr<vk::Instance> instance,
50 std::shared_ptr<vk::PhysicalDevice> physicalDevice,
51 std::shared_ptr<vk::Device> device);
78 std::shared_ptr<Sequence>
sequence(uint32_t queueIndex = 0,
79 uint32_t totalTimestamps = 0);
91 const std::vector<T>& data,
94 KP_LOG_DEBUG(
"Kompute Manager tensor creation triggered");
97 this->mPhysicalDevice, this->mDevice, data, tensorType) };
99 if (this->mManageResources) {
100 this->mManagedMemObjects.push_back(tensor);
119 KP_LOG_DEBUG(
"Kompute Manager tensor creation triggered");
122 this->mPhysicalDevice, this->mDevice, size, tensorType) };
124 if (this->mManageResources) {
125 this->mManagedMemObjects.push_back(tensor);
130 std::shared_ptr<TensorT<float>> tensor(
131 const std::vector<float>& data,
134 return this->tensorT<float>(data, tensorType);
137 std::shared_ptr<Tensor> tensor(
139 uint32_t elementTotalCount,
140 uint32_t elementMemorySize,
141 const Memory::DataTypes& dataType,
144 std::shared_ptr<Tensor> tensor{
new kp::Tensor(this->mPhysicalDevice,
152 if (this->mManageResources) {
153 this->mManagedMemObjects.push_back(tensor);
159 std::shared_ptr<Tensor> tensor(
160 uint32_t elementTotalCount,
161 uint32_t elementMemorySize,
162 const Memory::DataTypes& dataType,
165 std::shared_ptr<Tensor> tensor{
new kp::Tensor(this->mPhysicalDevice,
172 if (this->mManageResources) {
173 this->mManagedMemObjects.push_back(tensor);
189 const std::vector<T>& data,
192 uint32_t numChannels,
193 vk::ImageTiling tiling,
196 KP_LOG_DEBUG(
"Kompute Manager image creation triggered");
199 this->mPhysicalDevice,
208 if (this->mManageResources) {
209 this->mManagedMemObjects.push_back(image);
216 std::shared_ptr<ImageT<T>>
imageT(
217 const std::vector<T>& data,
220 uint32_t numChannels,
223 KP_LOG_DEBUG(
"Kompute Manager image creation triggered");
226 this->mPhysicalDevice,
234 if (this->mManageResources) {
235 this->mManagedMemObjects.push_back(image);
242 std::shared_ptr<ImageT<T>>
imageT(
245 uint32_t numChannels,
246 vk::ImageTiling tiling,
249 KP_LOG_DEBUG(
"Kompute Manager image creation triggered");
252 this->mPhysicalDevice,
260 if (this->mManageResources) {
261 this->mManagedMemObjects.push_back(image);
268 std::shared_ptr<ImageT<T>>
imageT(
271 uint32_t numChannels,
274 KP_LOG_DEBUG(
"Kompute Manager image creation triggered");
277 this->mPhysicalDevice,
284 if (this->mManageResources) {
285 this->mManagedMemObjects.push_back(image);
290 std::shared_ptr<ImageT<float>> image(
291 const std::vector<float>& data,
294 uint32_t numChannels,
295 vk::ImageTiling tiling,
298 return this->imageT<float>(
299 data, width, height, numChannels, tiling, imageType);
302 std::shared_ptr<ImageT<float>> image(
303 const std::vector<float>& data,
306 uint32_t numChannels,
309 return this->imageT<float>(data, width, height, numChannels, imageType);
312 std::shared_ptr<ImageT<float>> image(
315 uint32_t numChannels,
316 vk::ImageTiling tiling,
319 return this->imageT<float>(
320 width, height, numChannels, tiling, imageType);
323 std::shared_ptr<ImageT<float>> image(
326 uint32_t numChannels,
329 return this->imageT<float>(width, height, numChannels, imageType);
332 std::shared_ptr<Image> image(
337 uint32_t numChannels,
338 const Image::DataTypes& dataType,
339 vk::ImageTiling tiling,
342 std::shared_ptr<Image> image{
new kp::Image(this->mPhysicalDevice,
353 if (this->mManageResources) {
354 this->mManagedMemObjects.push_back(image);
360 std::shared_ptr<Image> image(
365 uint32_t numChannels,
366 const Memory::DataTypes& dataType,
369 std::shared_ptr<Image> image{
new kp::Image(this->mPhysicalDevice,
379 if (this->mManageResources) {
380 this->mManagedMemObjects.push_back(image);
386 std::shared_ptr<Image> image(
389 uint32_t numChannels,
390 const Memory::DataTypes& dataType,
391 vk::ImageTiling tiling,
394 std::shared_ptr<Image> image{
new kp::Image(this->mPhysicalDevice,
403 if (this->mManageResources) {
404 this->mManagedMemObjects.push_back(image);
410 std::shared_ptr<Image> image(
413 uint32_t numChannels,
414 const Memory::DataTypes& dataType,
417 std::shared_ptr<Image> image{
new kp::Image(this->mPhysicalDevice,
425 if (this->mManageResources) {
426 this->mManagedMemObjects.push_back(image);
449 const std::vector<std::shared_ptr<Memory>>& memObjects = {},
450 const std::vector<uint32_t>& spirv = {},
451 const Workgroup& workgroup = {},
452 const std::vector<float>& specializationConstants = {},
453 const std::vector<float>& pushConstants = {})
455 return this->algorithm<>(
456 memObjects, spirv, workgroup, specializationConstants, pushConstants);
474 template<
typename S =
float,
typename P =
float>
476 const std::vector<std::shared_ptr<Memory>>& memObjects,
477 const std::vector<uint32_t>& spirv,
478 const Workgroup& workgroup,
479 const std::vector<S>& specializationConstants,
480 const std::vector<P>& pushConstants)
483 KP_LOG_DEBUG(
"Kompute Manager algorithm creation triggered");
490 specializationConstants,
493 if (this->mManageResources) {
494 this->mManagedAlgorithms.push_back(
algorithm);
535 std::shared_ptr<vk::Instance> mInstance =
nullptr;
536 bool mFreeInstance =
false;
537 std::shared_ptr<vk::PhysicalDevice> mPhysicalDevice =
nullptr;
538 std::shared_ptr<vk::Device> mDevice =
nullptr;
539 bool mFreeDevice =
false;
542 std::vector<std::weak_ptr<Memory>> mManagedMemObjects;
543 std::vector<std::weak_ptr<Sequence>> mManagedSequences;
544 std::vector<std::weak_ptr<Algorithm>> mManagedAlgorithms;
546 std::vector<uint32_t> mComputeQueueFamilyIndices;
547 std::vector<std::shared_ptr<vk::Queue>> mComputeQueues;
549 bool mManageResources =
false;
551#ifndef KOMPUTE_DISABLE_VK_DEBUG_LAYERS
552 vk::DebugReportCallbackEXT mDebugReportCallback;
554 vk::detail::DispatchLoaderDynamic mDebugDispatcher;
556 vk::DispatchLoaderDynamic mDebugDispatcher;
561 void createInstance();
562 void createDevice(
const std::vector<uint32_t>& familyQueueIndices = {},
563 uint32_t hysicalDeviceIndex = 0,
564 const std::vector<std::string>& desiredExtensions = {});