diff --git a/single_include/kompute/Kompute.hpp b/single_include/kompute/Kompute.hpp index bd7b3a125..31a3b8cc0 100755 --- a/single_include/kompute/Kompute.hpp +++ b/single_include/kompute/Kompute.hpp @@ -1310,11 +1310,11 @@ class Manager * Create a new managed Kompute sequence so it's available within the * manager. * - * @param sequenceName The name for the named sequence to be created + * @param sequenceName The name for the named sequence to be created, if empty then default indexed value is used * @param queueIndex The queue to use from the available queues * @return Weak pointer to the manager owned sequence resource */ - std::weak_ptr createManagedSequence(std::string sequenceName, + std::weak_ptr createManagedSequence(std::string sequenceName = "", uint32_t queueIndex = 0); /** @@ -1351,7 +1351,7 @@ class Manager } /** - * Function that evaluates operation against default sequence. + * Function that evaluates operation against a newly created sequence. * * @param tensors The tensors to be used in the operation recorded * @param TArgs Template parameters that will be used to initialise @@ -1362,8 +1362,9 @@ class Manager TArgs&&... params) { SPDLOG_DEBUG("Kompute Manager evalOp Default triggered"); + this->mCurrentSequenceIndex++; this->evalOp( - tensors, KP_DEFAULT_SESSION, std::forward(params)...); + tensors, KP_DEFAULT_SESSION + std::to_string(this->mCurrentSequenceIndex), std::forward(params)...); } /** @@ -1380,14 +1381,11 @@ class Manager TArgs&&... params) { SPDLOG_DEBUG("Kompute Manager evalOpAsync triggered"); + std::weak_ptr sqWeakPtr = this->getOrCreateManagedSequence(sequenceName); - std::unordered_map>::iterator - found = this->mManagedSequences.find(sequenceName); - - if (found != this->mManagedSequences.end()) { - std::shared_ptr sq = found->second; + if (std::shared_ptr sq = sqWeakPtr.lock()) { SPDLOG_DEBUG("Kompute Manager evalOpAsync running sequence BEGIN"); sq->begin(); @@ -1419,8 +1417,9 @@ class Manager TArgs&&... params) { SPDLOG_DEBUG("Kompute Manager evalOpAsyncDefault triggered"); + this->mCurrentSequenceIndex++; this->evalOpAsync( - tensors, KP_DEFAULT_SESSION, std::forward(params)...); + tensors, KP_DEFAULT_SESSION + std::to_string(this->mCurrentSequenceIndex), std::forward(params)...); } /** @@ -1460,7 +1459,7 @@ class Manager void evalOpAwaitDefault(uint64_t waitFor = UINT64_MAX) { SPDLOG_DEBUG("Kompute Manager evalOpAwaitDefault triggered"); - this->evalOpAwait(KP_DEFAULT_SESSION, waitFor); + this->evalOpAwait(KP_DEFAULT_SESSION + std::to_string(this->mCurrentSequenceIndex), waitFor); } /** @@ -1504,6 +1503,8 @@ class Manager std::vector mComputeQueueFamilyIndeces; std::vector> mComputeQueues; + uint32_t mCurrentSequenceIndex = -1; + #if DEBUG #ifndef KOMPUTE_DISABLE_VK_DEBUG_LAYERS vk::DebugReportCallbackEXT mDebugReportCallback;