Updated tests to match new functions and added test to ensure seuqence is destroyed

This commit is contained in:
Alejandro Saucedo 2021-02-09 21:29:43 +00:00
parent 0d9a9758da
commit 4baba33681
11 changed files with 75 additions and 75 deletions

View file

@ -49,7 +49,7 @@ TEST(TestAsyncOperations, TestManagerParallelExecution)
inputsSyncB.push_back(std::make_shared<kp::Tensor>(kp::Tensor(data)));
}
mgr.rebuildTensors(inputsSyncB);
mgr.rebuild(inputsSyncB);
auto startSync = std::chrono::high_resolution_clock::now();
@ -77,10 +77,10 @@ TEST(TestAsyncOperations, TestManagerParallelExecution)
inputsAsyncB.push_back(std::make_shared<kp::Tensor>(kp::Tensor(data)));
}
mgrAsync.rebuildTensors(inputsAsyncB);
mgrAsync.rebuild(inputsAsyncB);
for (uint32_t i = 0; i < numParallel; i++) {
mgrAsync.createManagedSequence("async" + std::to_string(i), i);
mgrAsync.sequence("async" + std::to_string(i), i);
}
auto startAsync = std::chrono::high_resolution_clock::now();
@ -146,10 +146,10 @@ TEST(TestAsyncOperations, TestManagerAsyncExecution)
std::shared_ptr<kp::Tensor> tensorA{ new kp::Tensor(data) };
std::shared_ptr<kp::Tensor> tensorB{ new kp::Tensor(data) };
mgr.createManagedSequence("asyncOne");
mgr.createManagedSequence("asyncTwo");
mgr.sequence("asyncOne");
mgr.sequence("asyncTwo");
mgr.rebuildTensors({ tensorA, tensorB });
mgr.rebuild({ tensorA, tensorB });
mgr.evalOpAsync<kp::OpAlgoBase>(
{ tensorA }, "asyncOne", std::vector<char>(shader.begin(), shader.end()));

View file

@ -32,9 +32,9 @@ TEST(TestLogisticRegressionAlgorithm, TestMainLogisticRegression)
{
kp::Manager mgr;
mgr.rebuildTensors(params);
mgr.rebuild(params);
std::shared_ptr<kp::Sequence> sq = mgr.createManagedSequence();
std::shared_ptr<kp::Sequence> sq = mgr.sequence();
// Record op algo base
sq->begin();
@ -117,9 +117,9 @@ TEST(TestLogisticRegressionAlgorithm, TestMainLogisticRegressionManualCopy)
{
kp::Manager mgr;
mgr.rebuildTensors(params);
mgr.rebuild(params);
std::shared_ptr<kp::Sequence> sq = mgr.createManagedSequence();
std::shared_ptr<kp::Sequence> sq = mgr.sequence();
// Record op algo base
sq->begin();

View file

@ -8,14 +8,14 @@ TEST(TestManager, EndToEndOpMultFlow)
kp::Manager mgr;
std::shared_ptr<kp::Tensor> tensorLHS{ new kp::Tensor({ 0, 1, 2 }) };
mgr.rebuildTensors({ tensorLHS });
mgr.rebuild({ tensorLHS });
std::shared_ptr<kp::Tensor> tensorRHS{ new kp::Tensor({ 2, 4, 6 }) };
mgr.rebuildTensors({ tensorRHS });
mgr.rebuild({ tensorRHS });
std::shared_ptr<kp::Tensor> tensorOutput{ new kp::Tensor({ 0, 0, 0 }) };
mgr.rebuildTensors({ tensorOutput });
mgr.rebuild({ tensorOutput });
mgr.evalOpDefault<kp::OpMult>({ tensorLHS, tensorRHS, tensorOutput });
@ -36,10 +36,10 @@ TEST(TestManager, OpMultSequenceFlow)
kp::Manager mgr;
{
mgr.rebuildTensors({ tensorLHS, tensorRHS, tensorOutput });
mgr.rebuild({ tensorLHS, tensorRHS, tensorOutput });
std::shared_ptr<kp::Sequence> sq =
mgr.getOrCreateManagedSequence("newSequence");
mgr.sequence("newSequence");
sq->begin();
@ -59,16 +59,16 @@ TEST(TestManager, TestMultipleSequences)
kp::Manager mgr;
std::shared_ptr<kp::Sequence> sqOne =
mgr.getOrCreateManagedSequence("sqOne");
mgr.sequence("sqOne");
std::shared_ptr<kp::Sequence> sqTwo =
mgr.getOrCreateManagedSequence("sqTwo");
mgr.sequence("sqTwo");
std::shared_ptr<kp::Sequence> sqOneRef =
mgr.getOrCreateManagedSequence("sqOne");
mgr.sequence("sqOne");
std::shared_ptr<kp::Sequence> sqTwoRef =
mgr.getOrCreateManagedSequence("sqTwo");
mgr.sequence("sqTwo");
EXPECT_EQ(sqOne, sqOneRef);
EXPECT_NE(sqTwo, sqOneRef);
@ -88,10 +88,10 @@ TEST(TestManager, TestMultipleTensorsAtOnce)
kp::Manager mgr;
std::shared_ptr<kp::Sequence> sq =
mgr.getOrCreateManagedSequence("newSequence");
mgr.sequence("newSequence");
{
mgr.rebuildTensors({ tensorLHS, tensorRHS, tensorOutput });
mgr.rebuild({ tensorLHS, tensorRHS, tensorOutput });
EXPECT_TRUE(tensorLHS->isInit());
EXPECT_TRUE(tensorRHS->isInit());
@ -114,8 +114,8 @@ TEST(TestManager, TestCreateInitTensor)
{
kp::Manager mgr;
std::shared_ptr<kp::Tensor> tensorA = mgr.buildTensor({ 0, 1, 2 });
std::shared_ptr<kp::Tensor> tensorB = mgr.buildTensor({ 0, 0, 0 });
std::shared_ptr<kp::Tensor> tensorA = mgr.tensor({ 0, 1, 2 });
std::shared_ptr<kp::Tensor> tensorB = mgr.tensor({ 0, 0, 0 });
mgr.evalOpDefault<kp::OpTensorCopy>({ tensorA, tensorB });
@ -124,7 +124,7 @@ TEST(TestManager, TestCreateInitTensor)
EXPECT_EQ(tensorB->data(), std::vector<float>({ 0, 1, 2 }));
std::shared_ptr<kp::Tensor> tensorC =
mgr.buildTensor({ 0, 0, 0 }, kp::Tensor::TensorTypes::eHost);
mgr.tensor({ 0, 0, 0 }, kp::Tensor::TensorTypes::eHost);
mgr.evalOpDefault<kp::OpTensorCopy>({ tensorA, tensorC });

View file

@ -19,10 +19,10 @@ TEST(TestMultipleAlgoExecutions, SingleSequenceRecord)
pa[index] = pa[index] + 1;
})");
mgr.rebuildTensors({ tensorA });
mgr.rebuild({ tensorA });
std::shared_ptr<kp::Sequence> sq =
mgr.getOrCreateManagedSequence("newSequence");
mgr.sequence("newSequence");
{
sq->begin();
@ -58,11 +58,11 @@ TEST(TestMultipleAlgoExecutions, MultipleCmdBufRecords)
pa[index] = pa[index] + 1;
})");
mgr.rebuildTensors({ tensorA }, false);
mgr.rebuild({ tensorA }, false);
std::shared_ptr<kp::Sequence> sqTensor = mgr.createManagedSequence();
std::shared_ptr<kp::Sequence> sqTensor = mgr.sequence();
std::shared_ptr<kp::Sequence> sq = mgr.createManagedSequence();
std::shared_ptr<kp::Sequence> sq = mgr.sequence();
// First create the tensor in a separate sequence
sqTensor->begin();
@ -113,11 +113,11 @@ TEST(TestMultipleAlgoExecutions, MultipleSequences)
pa[index] = pa[index] + 1;
})");
mgr.rebuildTensors({ tensorA });
mgr.rebuild({ tensorA });
{
std::shared_ptr<kp::Sequence> sq =
mgr.getOrCreateManagedSequence("newSequence");
mgr.sequence("newSequence");
sq->begin();
@ -130,7 +130,7 @@ TEST(TestMultipleAlgoExecutions, MultipleSequences)
{
std::shared_ptr<kp::Sequence> sq =
mgr.getOrCreateManagedSequence("newSequence2");
mgr.sequence("newSequence2");
sq->begin();
@ -143,7 +143,7 @@ TEST(TestMultipleAlgoExecutions, MultipleSequences)
{
std::shared_ptr<kp::Sequence> sq =
mgr.getOrCreateManagedSequence("newSequence3");
mgr.sequence("newSequence3");
sq->begin();
@ -156,7 +156,7 @@ TEST(TestMultipleAlgoExecutions, MultipleSequences)
{
std::shared_ptr<kp::Sequence> sq =
mgr.getOrCreateManagedSequence("newSequence5");
mgr.sequence("newSequence5");
sq->begin();
@ -185,11 +185,11 @@ TEST(TestMultipleAlgoExecutions, SingleRecordMultipleEval)
pa[index] = pa[index] + 1;
})");
mgr.rebuildTensors({ tensorA }, false);
mgr.rebuild({ tensorA }, false);
{
std::shared_ptr<kp::Sequence> sq =
mgr.getOrCreateManagedSequence("newSequence");
mgr.sequence("newSequence");
sq->begin();
@ -201,7 +201,7 @@ TEST(TestMultipleAlgoExecutions, SingleRecordMultipleEval)
{
std::shared_ptr<kp::Sequence> sq =
mgr.getOrCreateManagedSequence("newSequence2");
mgr.sequence("newSequence2");
sq->begin();
@ -217,7 +217,7 @@ TEST(TestMultipleAlgoExecutions, SingleRecordMultipleEval)
{
std::shared_ptr<kp::Sequence> sq =
mgr.getOrCreateManagedSequence("newSequence3");
mgr.sequence("newSequence3");
sq->begin();
@ -242,7 +242,7 @@ TEST(TestMultipleAlgoExecutions, ManagerEvalMultSourceStrOpCreate)
std::shared_ptr<kp::Tensor> tensorInB{ new kp::Tensor({ 0.0, 1.0, 2.0 }) };
std::shared_ptr<kp::Tensor> tensorOut{ new kp::Tensor({ 0.0, 0.0, 0.0 }) };
mgr.rebuildTensors({ tensorInA, tensorInB, tensorOut });
mgr.rebuild({ tensorInA, tensorInB, tensorOut });
std::string shader(R"(
// The version to use
@ -277,11 +277,11 @@ TEST(TestMultipleAlgoExecutions, ManagerEvalMultSourceStrMgrCreate)
kp::Manager mgr;
auto tensorInA = mgr.buildTensor(
auto tensorInA = mgr.tensor(
{ 2.0, 4.0, 6.0 }, kp::Tensor::TensorTypes::eDevice, false);
auto tensorInB = mgr.buildTensor(
auto tensorInB = mgr.tensor(
{ 0.0, 1.0, 2.0 }, kp::Tensor::TensorTypes::eDevice, false);
auto tensorOut = mgr.buildTensor(
auto tensorOut = mgr.tensor(
{ 0.0, 0.0, 0.0 }, kp::Tensor::TensorTypes::eDevice, false);
std::string shader(R"(
@ -334,9 +334,9 @@ TEST(TestMultipleAlgoExecutions, SequenceAlgoDestroyOutsideManagerScope)
{
kp::Manager mgr;
mgr.rebuildTensors({ tensorA });
mgr.rebuild({ tensorA });
sq = mgr.createManagedSequence();
sq = mgr.sequence();
sq->begin();
sq->record<kp::OpAlgoBase>(

View file

@ -30,11 +30,11 @@ TEST(TestProcessingIterations, IterateThroughMultipleSumAndCopies)
}
)");
mgr.rebuildTensors({ tensorA, tensorB }, false);
mgr.rebuild({ tensorA, tensorB }, false);
{
std::shared_ptr<kp::Sequence> sq =
mgr.getOrCreateManagedSequence("default");
mgr.sequence("default");
sq->begin();
@ -47,7 +47,7 @@ TEST(TestProcessingIterations, IterateThroughMultipleSumAndCopies)
{
std::shared_ptr<kp::Sequence> sq =
mgr.getOrCreateManagedSequence("run");
mgr.sequence("run");
sq->begin();
@ -65,7 +65,7 @@ TEST(TestProcessingIterations, IterateThroughMultipleSumAndCopies)
{
std::shared_ptr<kp::Sequence> sq =
mgr.getOrCreateManagedSequence("export");
mgr.sequence("export");
sq->begin();

View file

@ -11,7 +11,7 @@ TEST(TestOpAlgoBase, ShaderRawDataFromConstructor)
std::shared_ptr<kp::Tensor> tensorA{ new kp::Tensor({ 3, 4, 5 }) };
std::shared_ptr<kp::Tensor> tensorB{ new kp::Tensor({ 0, 0, 0 }) };
mgr.rebuildTensors({ tensorA, tensorB });
mgr.rebuild({ tensorA, tensorB });
std::string shader(R"(
#version 450
@ -43,7 +43,7 @@ TEST(TestOpAlgoBase, ShaderCompiledDataFromConstructor)
std::shared_ptr<kp::Tensor> tensorA{ new kp::Tensor({ 3, 4, 5 }) };
std::shared_ptr<kp::Tensor> tensorB{ new kp::Tensor({ 0, 0, 0 }) };
mgr.rebuildTensors({ tensorA, tensorB });
mgr.rebuild({ tensorA, tensorB });
mgr.evalOpDefault<kp::OpAlgoBase>(
{ tensorA, tensorB },
@ -65,7 +65,7 @@ TEST(TestOpAlgoBase, ShaderRawDataFromFile)
std::shared_ptr<kp::Tensor> tensorA{ new kp::Tensor({ 3, 4, 5 }) };
std::shared_ptr<kp::Tensor> tensorB{ new kp::Tensor({ 0, 0, 0 }) };
mgr.rebuildTensors({ tensorA, tensorB });
mgr.rebuild({ tensorA, tensorB });
mgr.evalOpDefault<kp::OpAlgoBase>(
{ tensorA, tensorB }, "test/shaders/glsl/test_op_custom_shader.comp");
@ -82,7 +82,7 @@ TEST(TestOpAlgoBase, ShaderCompiledDataFromFile)
std::shared_ptr<kp::Tensor> tensorA{ new kp::Tensor({ 3, 4, 5 }) };
std::shared_ptr<kp::Tensor> tensorB{ new kp::Tensor({ 0, 0, 0 }) };
mgr.rebuildTensors({ tensorA, tensorB });
mgr.rebuild({ tensorA, tensorB });
mgr.evalOpDefault<kp::OpAlgoBase>(
{ tensorA, tensorB }, "test/shaders/glsl/test_op_custom_shader.comp.spv");

View file

@ -14,7 +14,7 @@ TEST(TestOpTensorCopy, CopyDeviceToDeviceTensor)
std::shared_ptr<kp::Tensor> tensorA{ new kp::Tensor(testVecA) };
std::shared_ptr<kp::Tensor> tensorB{ new kp::Tensor(testVecB) };
mgr.rebuildTensors({ tensorA, tensorB });
mgr.rebuild({ tensorA, tensorB });
EXPECT_TRUE(tensorA->isInit());
EXPECT_TRUE(tensorB->isInit());
@ -41,7 +41,7 @@ TEST(TestOpTensorCopy, CopyDeviceToDeviceTensorMulti)
std::shared_ptr<kp::Tensor> tensorB{ new kp::Tensor(testVecB) };
std::shared_ptr<kp::Tensor> tensorC{ new kp::Tensor(testVecC) };
mgr.rebuildTensors({ tensorA, tensorB, tensorC });
mgr.rebuild({ tensorA, tensorB, tensorC });
EXPECT_TRUE(tensorA->isInit());
EXPECT_TRUE(tensorB->isInit());
@ -70,7 +70,7 @@ TEST(TestOpTensorCopy, CopyDeviceToHostTensor)
std::shared_ptr<kp::Tensor> tensorB{ new kp::Tensor(
testVecB, kp::Tensor::TensorTypes::eHost) };
mgr.rebuildTensors({ tensorA, tensorB }, false);
mgr.rebuild({ tensorA, tensorB }, false);
// Only calling sync on device type tensor
mgr.evalOpDefault<kp::OpTensorSyncDevice>({ tensorA });
@ -99,7 +99,7 @@ TEST(TestOpTensorCopy, CopyHostToDeviceTensor)
testVecA, kp::Tensor::TensorTypes::eHost) };
std::shared_ptr<kp::Tensor> tensorB{ new kp::Tensor(testVecB) };
mgr.rebuildTensors({ tensorA, tensorB }, false);
mgr.rebuild({ tensorA, tensorB }, false);
// Only calling sync on device type tensor
mgr.evalOpDefault<kp::OpTensorSyncDevice>({ tensorB });
@ -129,7 +129,7 @@ TEST(TestOpTensorCopy, CopyHostToHostTensor)
std::shared_ptr<kp::Tensor> tensorB{ new kp::Tensor(
testVecB, kp::Tensor::TensorTypes::eHost) };
mgr.rebuildTensors({ tensorA, tensorB });
mgr.rebuild({ tensorA, tensorB });
EXPECT_TRUE(tensorA->isInit());
EXPECT_TRUE(tensorB->isInit());
@ -153,7 +153,7 @@ TEST(TestOpTensorCopy, SingleTensorShouldFail)
std::shared_ptr<kp::Tensor> tensorA{ new kp::Tensor(
testVecA, kp::Tensor::TensorTypes::eHost) };
mgr.rebuildTensors({ tensorA }, false);
mgr.rebuild({ tensorA }, false);
EXPECT_TRUE(tensorA->isInit());

View file

@ -11,7 +11,7 @@ TEST(TestOpTensorCreate, CreateSingleTensorSingleOp)
{
kp::Manager mgr;
mgr.rebuildTensors({ tensorA });
mgr.rebuild({ tensorA });
EXPECT_TRUE(tensorA->isInit());
@ -32,7 +32,7 @@ TEST(TestOpTensorCreate, CreateMultipleTensorSingleOp)
std::shared_ptr<kp::Tensor> tensorA{ new kp::Tensor(testVecA) };
std::shared_ptr<kp::Tensor> tensorB{ new kp::Tensor(testVecB) };
mgr.rebuildTensors({ tensorA, tensorB });
mgr.rebuild({ tensorA, tensorB });
EXPECT_TRUE(tensorA->isInit());
EXPECT_TRUE(tensorB->isInit());
@ -52,8 +52,8 @@ TEST(TestOpTensorCreate, CreateMultipleTensorMultipleOp)
std::shared_ptr<kp::Tensor> tensorA{ new kp::Tensor(testVecA) };
std::shared_ptr<kp::Tensor> tensorB{ new kp::Tensor(testVecB) };
mgr.rebuildTensors({ tensorA });
mgr.rebuildTensors({ tensorB });
mgr.rebuild({ tensorA });
mgr.rebuild({ tensorB });
EXPECT_TRUE(tensorA->isInit());
EXPECT_TRUE(tensorB->isInit());
@ -73,8 +73,8 @@ TEST(TestOpTensorCreate, TestTensorMemoryManagedByManagerDestroyed)
{
kp::Manager mgr;
mgr.rebuildTensors({ tensorA });
mgr.rebuildTensors({ tensorB });
mgr.rebuild({ tensorA });
mgr.rebuild({ tensorB });
EXPECT_TRUE(tensorA->isInit());
EXPECT_TRUE(tensorB->isInit());
@ -99,8 +99,8 @@ TEST(TestOpTensorCreate, TestTensorMemoryManagedByManagerNOTDestroyed)
kp::Manager mgr;
{
mgr.rebuildTensors({ tensorA });
mgr.rebuildTensors({ tensorB });
mgr.rebuild({ tensorA });
mgr.rebuild({ tensorB });
EXPECT_TRUE(tensorA->isInit());
EXPECT_TRUE(tensorB->isInit());
@ -124,8 +124,8 @@ TEST(TestOpTensorCreate, NoErrorIfTensorFreedBefore)
kp::Manager mgr;
mgr.rebuildTensors({ tensorA });
mgr.rebuildTensors({ tensorB });
mgr.rebuild({ tensorA });
mgr.rebuild({ tensorB });
EXPECT_TRUE(tensorA->isInit());
EXPECT_TRUE(tensorB->isInit());
@ -148,7 +148,7 @@ TEST(TestOpTensorCreate, ExceptionOnZeroSizeTensor)
kp::Manager mgr;
try {
mgr.rebuildTensors({ tensorA });
mgr.rebuild({ tensorA });
} catch (const std::runtime_error& err) {
// check exception
ASSERT_TRUE(std::string(err.what()).find("zero-sized") !=

View file

@ -13,7 +13,7 @@ TEST(TestOpTensorSync, SyncToDeviceMemorySingleTensor)
std::shared_ptr<kp::Tensor> tensorA{ new kp::Tensor(testVecPreA) };
mgr.rebuildTensors({ tensorA }, false);
mgr.rebuild({ tensorA }, false);
EXPECT_TRUE(tensorA->isInit());
@ -37,7 +37,7 @@ TEST(TestOpTensorSync, SyncToDeviceMemoryMultiTensor)
std::shared_ptr<kp::Tensor> tensorB{ new kp::Tensor({ 0, 0, 0 }) };
std::shared_ptr<kp::Tensor> tensorC{ new kp::Tensor({ 0, 0, 0 }) };
mgr.rebuildTensors({ tensorA, tensorB, tensorC }, false);
mgr.rebuild({ tensorA, tensorB, tensorC }, false);
EXPECT_TRUE(tensorA->isInit());
EXPECT_TRUE(tensorB->isInit());

View file

@ -9,7 +9,7 @@ TEST(TestSequence, CmdBufSequenceBeginEnd)
{
std::shared_ptr<kp::Sequence> sq =
mgr.getOrCreateManagedSequence("newSequence");
mgr.sequence("newSequence");
EXPECT_TRUE(sq->eval());
EXPECT_TRUE(!sq->isRecording());
@ -32,7 +32,7 @@ TEST(TestSequence, SequenceDestructorViaManager)
{
kp::Manager mgr;
sq = mgr.getOrCreateManagedSequence("newSequence");
sq = mgr.sequence("newSequence");
EXPECT_TRUE(sq->isInit());
}

View file

@ -23,10 +23,10 @@ TEST(TestTensor, CopyFromHostData)
kp::Manager mgr;
mgr.rebuildTensors({ tensorA, tensorB });
mgr.rebuild({ tensorA, tensorB });
if (std::shared_ptr<kp::Sequence> sq =
mgr.getOrCreateManagedSequence("new")) {
mgr.sequence("new")) {
sq->begin();
sq->record<kp::OpTensorCopy>({ tensorA, tensorB });