Updated formatting

Signed-off-by: Alejandro Saucedo <axsauze@gmail.com>
This commit is contained in:
Alejandro Saucedo 2021-11-16 23:03:07 +00:00
parent 5308141d0e
commit 797ba87c2a
12 changed files with 161 additions and 112 deletions

View file

@ -168,8 +168,10 @@ TEST(TestAsyncOperations, TestManagerAsyncExecution)
// AMD Drivers in Windows may see an error in this line due to timeout.
// In order to fix this, it requires a change on Windows registries.
// More details on this can be found here: https://docs.substance3d.com/spdoc/gpu-drivers-crash-with-long-computations-128745489.html
// Context on solution discussed in github: https://github.com/KomputeProject/kompute/issues/196#issuecomment-808866505
// More details on this can be found here:
// https://docs.substance3d.com/spdoc/gpu-drivers-crash-with-long-computations-128745489.html
// Context on solution discussed in github:
// https://github.com/KomputeProject/kompute/issues/196#issuecomment-808866505
sq1->evalAsync<kp::OpAlgoDispatch>(algo1);
sq2->evalAsync<kp::OpAlgoDispatch>(algo2);
@ -232,8 +234,10 @@ TEST(TestAsyncOperations, TestManagerAsyncExecutionTimeout)
// AMD Drivers in Windows may see an error in this line due to timeout.
// In order to fix this, it requires a change on Windows registries.
// More details on this can be found here: https://docs.substance3d.com/spdoc/gpu-drivers-crash-with-long-computations-128745489.html
// Context on solution discussed in github: https://github.com/KomputeProject/kompute/issues/196#issuecomment-808866505
// More details on this can be found here:
// https://docs.substance3d.com/spdoc/gpu-drivers-crash-with-long-computations-128745489.html
// Context on solution discussed in github:
// https://github.com/KomputeProject/kompute/issues/196#issuecomment-808866505
sq1->evalAsync<kp::OpAlgoDispatch>(algo1);
sq2->evalAsync<kp::OpAlgoDispatch>(algo2);
@ -245,7 +249,8 @@ TEST(TestAsyncOperations, TestManagerAsyncExecutionTimeout)
std::chrono::duration_cast<std::chrono::microseconds>(endSync - startSync)
.count();
// The time should several orders of magnitude smaller (in this 100k instead of 1m ns)
// The time should several orders of magnitude smaller (in this 100k instead
// of 1m ns)
EXPECT_LT(duration, 100000);
sq1->evalAsync<kp::OpTensorSyncLocal>({ tensorA, tensorB });

View file

@ -126,8 +126,8 @@ TEST(TestLogisticRegression, TestMainLogisticRegressionManualCopy)
kp::shader_data::
shaders_glsl_logisticregression_comp_spv_len));
std::shared_ptr<kp::Algorithm> algorithm =
mgr.algorithm(params, spirv, kp::Workgroup(), std::vector<float>({ 5.0 }));
std::shared_ptr<kp::Algorithm> algorithm = mgr.algorithm(
params, spirv, kp::Workgroup(), std::vector<float>({ 5.0 }));
std::shared_ptr<kp::Sequence> sq =
mgr.sequence()

View file

@ -87,7 +87,8 @@ TEST(TestManager, TestClearDestroy)
{
std::shared_ptr<kp::TensorT<float>> tensorLHS = mgr.tensor({ 0, 1, 2 });
std::shared_ptr<kp::TensorT<float>> tensorRHS = mgr.tensor({ 2, 4, 6 });
std::shared_ptr<kp::TensorT<float>> tensorOutput = mgr.tensor({ 0, 0, 0 });
std::shared_ptr<kp::TensorT<float>> tensorOutput =
mgr.tensor({ 0, 0, 0 });
std::vector<std::shared_ptr<kp::Tensor>> params = { tensorLHS,
tensorRHS,

View file

@ -53,11 +53,8 @@ TEST(TestMultipleAlgoExecutions, TestEndToEndFunctionality)
std::vector<float> pushConstsA({ 2.0 });
std::vector<float> pushConstsB({ 3.0 });
auto algorithm = mgr.algorithm(params,
compileSource(shader),
workgroup,
specConsts,
pushConstsA);
auto algorithm = mgr.algorithm(
params, compileSource(shader), workgroup, specConsts, pushConstsA);
// 3. Run operation with string shader synchronously
mgr.sequence()
@ -97,11 +94,11 @@ TEST(TestMultipleAlgoExecutions, SingleSequenceRecord)
{
// A sharedMemoryBarrier is required as the shader is not thread-safe:w
std::shared_ptr<kp::OpMemoryBarrier> shaderBarrier{
new kp::OpMemoryBarrier({ tensorA },
vk::AccessFlagBits::eTransferRead,
vk::AccessFlagBits::eShaderWrite,
vk::PipelineStageFlagBits::eComputeShader,
vk::PipelineStageFlagBits::eComputeShader)
new kp::OpMemoryBarrier({ tensorA },
vk::AccessFlagBits::eTransferRead,
vk::AccessFlagBits::eShaderWrite,
vk::PipelineStageFlagBits::eComputeShader,
vk::PipelineStageFlagBits::eComputeShader)
};
mgr.sequence()
@ -266,11 +263,8 @@ TEST(TestMultipleAlgoExecutions, TestAlgorithmUtilFunctions)
std::vector<float> specConsts({ 2 });
std::vector<float> pushConsts({ 2.0 });
auto algorithm = mgr.algorithm(params,
compileSource(shader),
workgroup,
specConsts,
pushConsts);
auto algorithm = mgr.algorithm(
params, compileSource(shader), workgroup, specConsts, pushConsts);
EXPECT_EQ(algorithm->getWorkgroup(), workgroup);
EXPECT_EQ(algorithm->getPushConstants<float>(), pushConsts);

View file

@ -44,8 +44,10 @@ TEST(TestPushConstants, TestConstantsAlgoDispatchOverride)
// We need to run this in sequence to avoid race condition
// We can't use atomicAdd as swiftshader doesn't support it for
// float
sq->eval<kp::OpAlgoDispatch>(algo, std::vector<float>{ 0.1, 0.2, 0.3 });
sq->eval<kp::OpAlgoDispatch>(algo, std::vector<float>{ 0.3, 0.2, 0.1 });
sq->eval<kp::OpAlgoDispatch>(algo,
std::vector<float>{ 0.1, 0.2, 0.3 });
sq->eval<kp::OpAlgoDispatch>(algo,
std::vector<float>{ 0.3, 0.2, 0.1 });
sq->eval<kp::OpTensorSyncLocal>({ tensor });
EXPECT_EQ(tensor->vector(), std::vector<float>({ 0.4, 0.4, 0.4 }));
@ -90,7 +92,8 @@ TEST(TestPushConstants, TestConstantsAlgoDispatchNoOverride)
// We can't use atomicAdd as swiftshader doesn't support it for
// float
sq->eval<kp::OpAlgoDispatch>(algo);
sq->eval<kp::OpAlgoDispatch>(algo, std::vector<float>{ 0.3, 0.2, 0.1 });
sq->eval<kp::OpAlgoDispatch>(algo,
std::vector<float>{ 0.3, 0.2, 0.1 });
sq->eval<kp::OpTensorSyncLocal>({ tensor });
EXPECT_EQ(tensor->vector(), std::vector<float>({ 0.4, 0.4, 0.4 }));
@ -156,22 +159,22 @@ TEST(TestPushConstants, TestConstantsWrongSize)
// pa[1] += pcs.y;
// pa[2] += pcs.z;
// })");
//
//
// std::vector<uint32_t> spirv = compileSource(shader);
//
//
// std::shared_ptr<kp::Sequence> sq = nullptr;
//
//
// {
// kp::Manager mgr;
//
//
// std::shared_ptr<kp::TensorT<float>> tensor =
// mgr.tensor({ 0, 0, 0 });
//
//
// std::shared_ptr<kp::Algorithm> algo = mgr.algorithm(
// { tensor }, spirv, kp::Workgroup({ 1 }), {}, { 0.0 });
//
//
// sq = mgr.sequence()->record<kp::OpTensorSyncDevice>({ tensor });
//
//
// EXPECT_THROW(sq->record<kp::OpAlgoDispatch>(
// algo, std::vector<uint32_t>{ 1, 2, 3 }),
// std::runtime_error);
@ -197,7 +200,8 @@ TEST(TestPushConstants, TestConstantsMixedTypes)
pa[2] += pcs.z;
})");
struct TestConsts{
struct TestConsts
{
float x;
uint32_t y;
int32_t z;
@ -213,16 +217,19 @@ TEST(TestPushConstants, TestConstantsMixedTypes)
std::shared_ptr<kp::TensorT<float>> tensor =
mgr.tensorT<float>({ 0, 0, 0 });
std::shared_ptr<kp::Algorithm> algo = mgr.algorithm<float, TestConsts>(
{ tensor }, spirv, kp::Workgroup({ 1 }), {}, {{ 0, 0, 0 }});
std::shared_ptr<kp::Algorithm> algo =
mgr.algorithm<float, TestConsts>(
{ tensor }, spirv, kp::Workgroup({ 1 }), {}, { { 0, 0, 0 } });
sq = mgr.sequence()->eval<kp::OpTensorSyncDevice>({ tensor });
// We need to run this in sequence to avoid race condition
// We can't use atomicAdd as swiftshader doesn't support it for
// float
sq->eval<kp::OpAlgoDispatch>(algo, std::vector<TestConsts>{{ 15.32, 2147483650, 10 }});
sq->eval<kp::OpAlgoDispatch>(algo, std::vector<TestConsts>{{ 30.32, 2147483650, -3 }});
sq->eval<kp::OpAlgoDispatch>(
algo, std::vector<TestConsts>{ { 15.32, 2147483650, 10 } });
sq->eval<kp::OpAlgoDispatch>(
algo, std::vector<TestConsts>{ { 30.32, 2147483650, -3 } });
sq->eval<kp::OpTensorSyncLocal>({ tensor });
EXPECT_EQ(tensor->vector(), std::vector<float>({ 45.64, 1300, 7 }));
@ -258,16 +265,19 @@ TEST(TestPushConstants, TestConstantsInt)
std::shared_ptr<kp::TensorT<int32_t>> tensor =
mgr.tensorT<int32_t>({ -1, -1, -1 });
std::shared_ptr<kp::Algorithm> algo = mgr.algorithm<int32_t , int32_t>(
{ tensor }, spirv, kp::Workgroup({ 1 }), {}, {{ 0, 0, 0 }});
std::shared_ptr<kp::Algorithm> algo =
mgr.algorithm<int32_t, int32_t>(
{ tensor }, spirv, kp::Workgroup({ 1 }), {}, { { 0, 0, 0 } });
sq = mgr.sequence()->eval<kp::OpTensorSyncDevice>({ tensor });
// We need to run this in sequence to avoid race condition
// We can't use atomicAdd as swiftshader doesn't support it for
// float
sq->eval<kp::OpAlgoDispatch>(algo, std::vector<int32_t>{{ -1, -1, -1 }});
sq->eval<kp::OpAlgoDispatch>(algo, std::vector<int32_t>{{ -1, -1, -1 }});
sq->eval<kp::OpAlgoDispatch>(
algo, std::vector<int32_t>{ { -1, -1, -1 } });
sq->eval<kp::OpAlgoDispatch>(
algo, std::vector<int32_t>{ { -1, -1, -1 } });
sq->eval<kp::OpTensorSyncLocal>({ tensor });
EXPECT_EQ(tensor->vector(), std::vector<int32_t>({ -3, -3, -3 }));
@ -303,19 +313,25 @@ TEST(TestPushConstants, TestConstantsUnsignedInt)
std::shared_ptr<kp::TensorT<uint32_t>> tensor =
mgr.tensorT<uint32_t>({ 0, 0, 0 });
std::shared_ptr<kp::Algorithm> algo = mgr.algorithm<uint32_t , uint32_t>(
{ tensor }, spirv, kp::Workgroup({ 1 }), {}, {{ 0, 0, 0 }});
std::shared_ptr<kp::Algorithm> algo =
mgr.algorithm<uint32_t, uint32_t>(
{ tensor }, spirv, kp::Workgroup({ 1 }), {}, { { 0, 0, 0 } });
sq = mgr.sequence()->eval<kp::OpTensorSyncDevice>({ tensor });
// We need to run this in sequence to avoid race condition
// We can't use atomicAdd as swiftshader doesn't support it for
// float
sq->eval<kp::OpAlgoDispatch>(algo, std::vector<uint32_t>{{ 2147483650, 2147483650, 2147483650 }});
sq->eval<kp::OpAlgoDispatch>(algo, std::vector<uint32_t>{{ 5, 5, 5 }});
sq->eval<kp::OpAlgoDispatch>(
algo,
std::vector<uint32_t>{ { 2147483650, 2147483650, 2147483650 } });
sq->eval<kp::OpAlgoDispatch>(algo,
std::vector<uint32_t>{ { 5, 5, 5 } });
sq->eval<kp::OpTensorSyncLocal>({ tensor });
EXPECT_EQ(tensor->vector(), std::vector<uint32_t>({ 2147483655, 2147483655, 2147483655 }));
EXPECT_EQ(
tensor->vector(),
std::vector<uint32_t>({ 2147483655, 2147483655, 2147483655 }));
}
}
}
@ -349,18 +365,29 @@ TEST(TestPushConstants, TestConstantsDouble)
mgr.tensorT<double>({ 0, 0, 0 });
std::shared_ptr<kp::Algorithm> algo = mgr.algorithm<double, double>(
{ tensor }, spirv, kp::Workgroup({ 1 }), {}, {{ 0, 0, 0 }});
{ tensor }, spirv, kp::Workgroup({ 1 }), {}, { { 0, 0, 0 } });
sq = mgr.sequence()->eval<kp::OpTensorSyncDevice>({ tensor });
// We need to run this in sequence to avoid race condition
// We can't use atomicAdd as swiftshader doesn't support it for
// float
sq->eval<kp::OpAlgoDispatch>(algo, std::vector<double>{{ 1.1111222233334444, 2.1111222233334444, 3.1111222233334444 }});
sq->eval<kp::OpAlgoDispatch>(algo, std::vector<double>{{ 1.1111222233334444, 2.1111222233334444, 3.1111222233334444 }});
sq->eval<kp::OpAlgoDispatch>(
algo,
std::vector<double>{ { 1.1111222233334444,
2.1111222233334444,
3.1111222233334444 } });
sq->eval<kp::OpAlgoDispatch>(
algo,
std::vector<double>{ { 1.1111222233334444,
2.1111222233334444,
3.1111222233334444 } });
sq->eval<kp::OpTensorSyncLocal>({ tensor });
EXPECT_EQ(tensor->vector(), std::vector<double>({ 2.2222444466668888, 4.2222444466668888, 6.2222444466668888 }));
EXPECT_EQ(tensor->vector(),
std::vector<double>({ 2.2222444466668888,
4.2222444466668888,
6.2222444466668888 }));
}
}
}

View file

@ -101,4 +101,3 @@ TEST(TestSpecializationConstants, TestConstantsInt)
}
}
}

View file

@ -33,7 +33,8 @@ TEST(TestTensor, DataTypes)
{
std::vector<uint32_t> vec{ 0, 1, 2 };
std::shared_ptr<kp::TensorT<uint32_t>> tensor = mgr.tensorT(vec);
EXPECT_EQ(tensor->dataType(), kp::Tensor::TensorDataTypes::eUnsignedInt);
EXPECT_EQ(tensor->dataType(),
kp::Tensor::TensorDataTypes::eUnsignedInt);
}
{