Updated manager to have unique sequence added on default operations
This commit is contained in:
parent
1053cde1f0
commit
ba71c7ab46
3 changed files with 35 additions and 15 deletions
|
|
@ -95,6 +95,7 @@ std::weak_ptr<Sequence>
|
|||
Manager::getOrCreateManagedSequence(std::string sequenceName)
|
||||
{
|
||||
SPDLOG_DEBUG("Kompute Manager creating Sequence object");
|
||||
|
||||
std::unordered_map<std::string, std::shared_ptr<Sequence>>::iterator found =
|
||||
this->mManagedSequences.find(sequenceName);
|
||||
|
||||
|
|
@ -120,7 +121,16 @@ Manager::createManagedSequence(std::string sequenceName, uint32_t queueIndex)
|
|||
this->mComputeQueues[queueIndex],
|
||||
this->mComputeQueueFamilyIndeces[queueIndex]);
|
||||
sq->init();
|
||||
this->mManagedSequences.insert({ sequenceName, sq });
|
||||
|
||||
if (sequenceName.empty()) {
|
||||
this->mCurrentSequenceIndex++;
|
||||
this->mManagedSequences.insert({ KP_DEFAULT_SESSION + std::to_string(this->mCurrentSequenceIndex), sq });
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: Check if sequence doens't already exist
|
||||
this->mManagedSequences.insert({ sequenceName, sq });
|
||||
}
|
||||
return sq;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -75,10 +75,20 @@ Sequence::begin()
|
|||
return false;
|
||||
}
|
||||
|
||||
if (this->isRunning()) {
|
||||
SPDLOG_WARN("Kompute Sequence begin called when sequence still running");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!this->mCommandPool) {
|
||||
throw std::runtime_error("Kompute Sequence command pool is null");
|
||||
}
|
||||
|
||||
if (this->mOperations.size()) {
|
||||
SPDLOG_INFO("Kompute Sequence clearing previous operations");
|
||||
this->mOperations.clear();
|
||||
}
|
||||
|
||||
if (!this->mRecording) {
|
||||
SPDLOG_INFO("Kompute Sequence command recording BEGIN");
|
||||
this->mCommandBuffer->begin(vk::CommandBufferBeginInfo());
|
||||
|
|
@ -177,9 +187,10 @@ Sequence::evalAwait(uint64_t waitFor)
|
|||
this->mDevice->waitForFences(1, &this->mFence, VK_TRUE, waitFor);
|
||||
this->mDevice->destroy(this->mFence);
|
||||
|
||||
this->mIsRunning = false;
|
||||
|
||||
if (result == vk::Result::eTimeout) {
|
||||
SPDLOG_WARN("Kompute Sequence evalAwait timed out");
|
||||
this->mIsRunning = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -187,8 +198,6 @@ Sequence::evalAwait(uint64_t waitFor)
|
|||
this->mOperations[i]->postEval();
|
||||
}
|
||||
|
||||
this->mIsRunning = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -72,11 +72,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<Sequence> createManagedSequence(std::string sequenceName,
|
||||
std::weak_ptr<Sequence> createManagedSequence(std::string sequenceName = "",
|
||||
uint32_t queueIndex = 0);
|
||||
|
||||
/**
|
||||
|
|
@ -113,7 +113,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
|
||||
|
|
@ -124,8 +124,9 @@ class Manager
|
|||
TArgs&&... params)
|
||||
{
|
||||
SPDLOG_DEBUG("Kompute Manager evalOp Default triggered");
|
||||
this->mCurrentSequenceIndex++;
|
||||
this->evalOp<T>(
|
||||
tensors, KP_DEFAULT_SESSION, std::forward<TArgs>(params)...);
|
||||
tensors, KP_DEFAULT_SESSION + std::to_string(this->mCurrentSequenceIndex), std::forward<TArgs>(params)...);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -142,14 +143,11 @@ class Manager
|
|||
TArgs&&... params)
|
||||
{
|
||||
SPDLOG_DEBUG("Kompute Manager evalOpAsync triggered");
|
||||
|
||||
std::weak_ptr<Sequence> sqWeakPtr =
|
||||
this->getOrCreateManagedSequence(sequenceName);
|
||||
|
||||
std::unordered_map<std::string, std::shared_ptr<Sequence>>::iterator
|
||||
found = this->mManagedSequences.find(sequenceName);
|
||||
|
||||
if (found != this->mManagedSequences.end()) {
|
||||
std::shared_ptr<Sequence> sq = found->second;
|
||||
if (std::shared_ptr<kp::Sequence> sq = sqWeakPtr.lock()) {
|
||||
|
||||
SPDLOG_DEBUG("Kompute Manager evalOpAsync running sequence BEGIN");
|
||||
sq->begin();
|
||||
|
|
@ -181,8 +179,9 @@ class Manager
|
|||
TArgs&&... params)
|
||||
{
|
||||
SPDLOG_DEBUG("Kompute Manager evalOpAsyncDefault triggered");
|
||||
this->mCurrentSequenceIndex++;
|
||||
this->evalOpAsync<T>(
|
||||
tensors, KP_DEFAULT_SESSION, std::forward<TArgs>(params)...);
|
||||
tensors, KP_DEFAULT_SESSION + std::to_string(this->mCurrentSequenceIndex), std::forward<TArgs>(params)...);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -222,7 +221,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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -266,6 +265,8 @@ class Manager
|
|||
std::vector<uint32_t> mComputeQueueFamilyIndeces;
|
||||
std::vector<std::shared_ptr<vk::Queue>> mComputeQueues;
|
||||
|
||||
uint32_t mCurrentSequenceIndex = -1;
|
||||
|
||||
#if DEBUG
|
||||
#ifndef KOMPUTE_DISABLE_VK_DEBUG_LAYERS
|
||||
vk::DebugReportCallbackEXT mDebugReportCallback;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue