Skip to content

Commit

Permalink
Reformatted
Browse files Browse the repository at this point in the history
  • Loading branch information
axsaucedo committed Oct 18, 2020
1 parent 06917b8 commit 267f927
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 30 deletions.
8 changes: 4 additions & 4 deletions src/Manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ Manager::createManagedSequence(std::string sequenceName, uint32_t queueIndex)

if (sequenceName.empty()) {
this->mCurrentSequenceIndex++;
this->mManagedSequences.insert({ KP_DEFAULT_SESSION + std::to_string(this->mCurrentSequenceIndex), sq });
}
else
{
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 });
}
Expand Down
3 changes: 2 additions & 1 deletion src/Sequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ Sequence::begin()
}

if (this->isRunning()) {
SPDLOG_WARN("Kompute Sequence begin called when sequence still running");
SPDLOG_WARN(
"Kompute Sequence begin called when sequence still running");
return false;
}

Expand Down
27 changes: 18 additions & 9 deletions src/include/kompute/Manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ 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, if empty then default indexed value is used
* @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
*/
Expand Down Expand Up @@ -125,8 +126,10 @@ class Manager
{
SPDLOG_DEBUG("Kompute Manager evalOp Default triggered");
this->mCurrentSequenceIndex++;
this->evalOp<T>(
tensors, KP_DEFAULT_SESSION + std::to_string(this->mCurrentSequenceIndex), std::forward<TArgs>(params)...);
this->evalOp<T>(tensors,
KP_DEFAULT_SESSION +
std::to_string(this->mCurrentSequenceIndex),
std::forward<TArgs>(params)...);
}

/**
Expand Down Expand Up @@ -168,20 +171,23 @@ class Manager
}

/**
* Operation that evaluates operation against default sequence asynchronously.
* Operation that evaluates operation against default sequence
* asynchronously.
*
* @param tensors The tensors to be used in the operation recorded
* @param params Template parameters that will be used to initialise
* Operation to allow for extensible configurations on initialisation
*/
template<typename T, typename... TArgs>
void evalOpAsyncDefault(std::vector<std::shared_ptr<Tensor>> tensors,
TArgs&&... params)
TArgs&&... params)
{
SPDLOG_DEBUG("Kompute Manager evalOpAsyncDefault triggered");
this->mCurrentSequenceIndex++;
this->evalOpAsync<T>(
tensors, KP_DEFAULT_SESSION + std::to_string(this->mCurrentSequenceIndex), std::forward<TArgs>(params)...);
this->evalOpAsync<T>(tensors,
KP_DEFAULT_SESSION +
std::to_string(this->mCurrentSequenceIndex),
std::forward<TArgs>(params)...);
}

/**
Expand All @@ -192,7 +198,8 @@ class Manager
*/
void evalOpAwait(std::string sequenceName, uint64_t waitFor = UINT64_MAX)
{
SPDLOG_DEBUG("Kompute Manager evalOpAwait triggered with sequence {}", sequenceName);
SPDLOG_DEBUG("Kompute Manager evalOpAwait triggered with sequence {}",
sequenceName);
std::unordered_map<std::string, std::shared_ptr<Sequence>>::iterator
found = this->mManagedSequences.find(sequenceName);

Expand Down Expand Up @@ -221,7 +228,9 @@ class Manager
void evalOpAwaitDefault(uint64_t waitFor = UINT64_MAX)
{
SPDLOG_DEBUG("Kompute Manager evalOpAwaitDefault triggered");
this->evalOpAwait(KP_DEFAULT_SESSION + std::to_string(this->mCurrentSequenceIndex), waitFor);
this->evalOpAwait(KP_DEFAULT_SESSION +
std::to_string(this->mCurrentSequenceIndex),
waitFor);
}

/**
Expand Down
11 changes: 3 additions & 8 deletions test/TestAsyncOperations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ TEST(TestAsyncOperations, TestManagerParallelExecution)

for (uint32_t i = 0; i < numParallel; i++) {
mgr.evalOpDefault<kp::OpAlgoBase<>>(
{ inputsSyncB[i] },
std::vector<char>(shader.begin(), shader.end()));
{ inputsSyncB[i] }, std::vector<char>(shader.begin(), shader.end()));
}

auto endSync = std::chrono::high_resolution_clock::now();
Expand Down Expand Up @@ -153,14 +152,10 @@ TEST(TestAsyncOperations, TestManagerAsyncExecution)
mgr.evalOpDefault<kp::OpTensorCreate>({ tensorA, tensorB });

mgr.evalOpAsync<kp::OpAlgoBase<>>(
{ tensorA },
"asyncOne",
std::vector<char>(shader.begin(), shader.end()));
{ tensorA }, "asyncOne", std::vector<char>(shader.begin(), shader.end()));

mgr.evalOpAsync<kp::OpAlgoBase<>>(
{ tensorB },
"asyncTwo",
std::vector<char>(shader.begin(), shader.end()));
{ tensorB }, "asyncTwo", std::vector<char>(shader.begin(), shader.end()));

mgr.evalOpAwait("asyncOne");
mgr.evalOpAwait("asyncTwo");
Expand Down
6 changes: 2 additions & 4 deletions test/TestLogisticRegression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ TEST(TestLogisticRegressionAlgorithm, TestMainLogisticRegression)
sqTensor->end();
sqTensor->eval();

std::shared_ptr<kp::Sequence> sq =
mgr.createManagedSequence().lock();
std::shared_ptr<kp::Sequence> sq = mgr.createManagedSequence().lock();

// Record op algo base
sq->begin();
Expand Down Expand Up @@ -123,8 +122,7 @@ TEST(TestLogisticRegressionAlgorithm, TestMainLogisticRegressionManualCopy)
sqTensor->end();
sqTensor->eval();

std::shared_ptr<kp::Sequence> sq =
mgr.createManagedSequence().lock();
std::shared_ptr<kp::Sequence> sq = mgr.createManagedSequence().lock();

// Record op algo base
sq->begin();
Expand Down
6 changes: 2 additions & 4 deletions test/TestMultipleAlgoExecutions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,9 @@ TEST(TestMultipleAlgoExecutions, MultipleCmdBufRecords)
pa[index] = pa[index] + 1;
})");

std::shared_ptr<kp::Sequence> sqTensor =
mgr.createManagedSequence().lock();
std::shared_ptr<kp::Sequence> sqTensor = mgr.createManagedSequence().lock();

std::shared_ptr<kp::Sequence> sq =
mgr.createManagedSequence().lock();
std::shared_ptr<kp::Sequence> sq = mgr.createManagedSequence().lock();

// First create the tensor in a separate sequence
sqTensor->begin();
Expand Down

0 comments on commit 267f927

Please sign in to comment.