diff --git a/src/include/kompute/Algorithm.hpp b/src/include/kompute/Algorithm.hpp index 846525fb1..bef9cbaef 100644 --- a/src/include/kompute/Algorithm.hpp +++ b/src/include/kompute/Algorithm.hpp @@ -50,16 +50,15 @@ class Algorithm void recordDispatch(uint32_t x = 1, uint32_t y = 1, uint32_t z = 1); private: - // Never Owned Resources + // -------------- NEVER OWNED RESOURCES std::shared_ptr mDevice; std::shared_ptr mCommandBuffer; - // Optionally owned resources + // -------------- OPTIONALLY OWNED RESOURCES std::shared_ptr mDescriptorSetLayout; bool mFreeDescriptorSetLayout = false; std::shared_ptr mDescriptorPool; bool mFreeDescriptorPool = false; - // TODO: Explore design for multiple descriptor sets std::shared_ptr mDescriptorSet; bool mFreeDescriptorSet = false; diff --git a/src/include/kompute/Manager.hpp b/src/include/kompute/Manager.hpp index 797f84107..f71328199 100644 --- a/src/include/kompute/Manager.hpp +++ b/src/include/kompute/Manager.hpp @@ -84,6 +84,7 @@ class Manager } private: + // -------------- OPTIONALLY OWNED RESOURCES std::shared_ptr mInstance = nullptr; bool mFreeInstance = false; std::shared_ptr mPhysicalDevice = nullptr; @@ -93,7 +94,7 @@ class Manager uint32_t mComputeQueueFamilyIndex = -1; std::shared_ptr mComputeQueue = nullptr; - // Always owned resources + // -------------- ALWAYS OWNED RESOURCES std::unordered_map> mManagedSequences; diff --git a/src/include/kompute/Parameter.hpp b/src/include/kompute/Parameter.hpp index 9f9d2af2c..fc1e97007 100644 --- a/src/include/kompute/Parameter.hpp +++ b/src/include/kompute/Parameter.hpp @@ -21,10 +21,10 @@ class Algorithm ~Algorithm(); private: - // Shared resources + // -------------- NEVER OWNED RESOURCES std::shared_ptr mDevice; - // Resources owned by default + // -------------- OPTIONALLY OWNED RESOURCES std::shared_ptr mDescriptorSetLayout; bool mFreeDescriptorSetLayout = false; std::shared_ptr mDescriptorPool; diff --git a/src/include/kompute/Sequence.hpp b/src/include/kompute/Sequence.hpp index 7ee105c68..7be635577 100644 --- a/src/include/kompute/Sequence.hpp +++ b/src/include/kompute/Sequence.hpp @@ -104,10 +104,13 @@ class Sequence } private: + // -------------- NEVER OWNED RESOURCES std::shared_ptr mPhysicalDevice = nullptr; std::shared_ptr mDevice = nullptr; std::shared_ptr mComputeQueue = nullptr; uint32_t mQueueIndex = -1; + + // -------------- OPTIONALLY OWNED RESOURCES std::shared_ptr mCommandPool = nullptr; bool mFreeCommandPool = false; std::shared_ptr mCommandBuffer = nullptr; diff --git a/src/include/kompute/Tensor.hpp b/src/include/kompute/Tensor.hpp index 78a60fbbf..6e16af85e 100644 --- a/src/include/kompute/Tensor.hpp +++ b/src/include/kompute/Tensor.hpp @@ -132,15 +132,18 @@ class Tensor void mapDataIntoHostMemory(); private: + // -------------- NEVER OWNED RESOURCES std::shared_ptr mPhysicalDevice; std::shared_ptr mDevice; std::shared_ptr mCommandBuffer; + // -------------- OPTIONALLY OWNED RESOURCES std::shared_ptr mBuffer; bool mFreeBuffer; std::shared_ptr mMemory; bool mFreeMemory; + // -------------- ALWAYS OWNED RESOURCES std::vector mData; TensorTypes mTensorType = TensorTypes::eDevice; @@ -148,8 +151,7 @@ class Tensor std::array mShape; bool mIsInit = false; - // Creates the vulkan buffer - void createBuffer(); + void createBuffer(); // Creates the vulkan buffer // Private util functions vk::BufferUsageFlags getBufferUsageFlags(); diff --git a/src/include/kompute/operations/OpBase.hpp b/src/include/kompute/operations/OpBase.hpp index 34443be4e..41d8f50f3 100644 --- a/src/include/kompute/operations/OpBase.hpp +++ b/src/include/kompute/operations/OpBase.hpp @@ -96,19 +96,19 @@ class OpBase virtual void postSubmit() = 0; protected: - // OPTIONALLY OWNED RESOURCES - std::vector> - mTensors; ///< Tensors referenced by operation that can be managed - ///< optionally by operation - bool mFreeTensors = false; ///< Explicit boolean that specifies whether the - ///< tensors are freed (if they are managed) - - // NEVER OWNED RESOURCES + // -------------- NEVER OWNED RESOURCES std::shared_ptr mPhysicalDevice; ///< Vulkan Physical Device std::shared_ptr mDevice; ///< Vulkan Logical Device std::shared_ptr mCommandBuffer; ///< Vulkan Command Buffer + + // -------------- OPTIONALLY OWNED RESOURCES + std::vector> + mTensors; ///< Tensors referenced by operation that can be managed + ///< optionally by operation + bool mFreeTensors = false; ///< Explicit boolean that specifies whether the + ///< tensors are freed (if they are managed) }; } // End namespace kp diff --git a/src/include/kompute/operations/OpMult.hpp b/src/include/kompute/operations/OpMult.hpp index 4b120c931..aec4efa50 100644 --- a/src/include/kompute/operations/OpMult.hpp +++ b/src/include/kompute/operations/OpMult.hpp @@ -77,18 +77,18 @@ class OpMult : public OpBase void postSubmit() override; private: - // Always owned resources - std::shared_ptr mTensorOutputStaging; - - // Optionally owned resources - std::shared_ptr mAlgorithm; - bool mFreeAlgorithm = false; - - // Never owned resources + // -------------- NEVER OWNED RESOURCES std::shared_ptr mTensorLHS; std::shared_ptr mTensorRHS; std::shared_ptr mTensorOutput; + // -------------- OPTIONALLY OWNED RESOURCES + std::shared_ptr mAlgorithm; + bool mFreeAlgorithm = false; + + // -------------- ALWAYS OWNED RESOURCES + std::shared_ptr mTensorOutputStaging; + uint32_t mX; uint32_t mY; uint32_t mZ;