Fixed compiling tests with the new test layout
Signed-off-by: Fabian Sauter <sauter.fabian@mailbox.org>
This commit is contained in:
parent
b95df8d0a0
commit
34f9d58722
22 changed files with 216 additions and 69 deletions
|
|
@ -72,10 +72,10 @@ function(BIN2H)
|
|||
|
||||
# wraps the hex string into multiple lines at column 32(i.e. 16 bytes per line)
|
||||
wrap_string(VARIABLE hexString AT_COLUMN 32)
|
||||
math(EXPR arraySize "${hexStringLength} / 2")
|
||||
math(EXPR arraySize "${hexStringLength} / 8")
|
||||
|
||||
# adds '0x' prefix and comma suffix before and after every byte respectively
|
||||
string(REGEX REPLACE "([0-9a-f][0-9a-f])" "0x\\1, " arrayValues ${hexString})
|
||||
string(REGEX REPLACE "([0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f])" "0x\\1, " arrayValues ${hexString})
|
||||
# removes trailing comma
|
||||
string(REGEX REPLACE ", $" "" arrayValues ${arrayValues})
|
||||
|
||||
|
|
@ -85,9 +85,9 @@ function(BIN2H)
|
|||
|
||||
# declares byte array and the length variables
|
||||
set(namespaceStart "namespace ${HEADER_NAMESPACE} {")
|
||||
set(namespaceEnd "} // ${HEADER_NAMESPACE}")
|
||||
set(namespaceEnd "} // namespace ${HEADER_NAMESPACE}")
|
||||
set(arrayIncludes "#pragma once\n#include <array>\n#include <cstdint>")
|
||||
set(arrayDefinition "const std::array<uint8_t, ${arraySize}> ${BIN2H_VARIABLE_NAME} = { ${arrayValues} };")
|
||||
set(arrayDefinition "const std::array<uint32_t, ${arraySize}> ${BIN2H_VARIABLE_NAME} = { ${arrayValues} };")
|
||||
|
||||
set(declarations "${arrayIncludes}\n\n${namespaceStart}\n${arrayDefinition}\n${namespaceEnd}\n\n")
|
||||
if(BIN2H_APPEND)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ function(vulkan_compile_shader)
|
|||
"-o"
|
||||
"${SHADER_COMPILE_SPV_FILE_FULL}"
|
||||
"--target-env"
|
||||
"vulkan1.2"
|
||||
"vulkan1.1"
|
||||
"${SHADER_COMPILE_INFILE_FULL}"
|
||||
COMMENT "Compile vulkan compute shader from file '${SHADER_COMPILE_INFILE_FULL}' to '${SHADER_COMPILE_SPV_FILE_FULL}'."
|
||||
MAIN_DEPENDENCY "${SHADER_COMPILE_INFILE_FULL}")
|
||||
|
|
|
|||
|
|
@ -80,13 +80,13 @@ endif()
|
|||
#####################################################
|
||||
|
||||
if(KOMPUTE_OPT_ANDROID_BUILD)
|
||||
target_link_libraries(kompute PRIVATE fmt::fmt
|
||||
kompute_vk_ndk_wrapper
|
||||
log
|
||||
android)
|
||||
target_link_libraries(kompute PUBLIC fmt::fmt
|
||||
kompute_vk_ndk_wrapper
|
||||
log
|
||||
android)
|
||||
else()
|
||||
target_link_libraries(kompute PRIVATE Vulkan::Vulkan
|
||||
fmt::fmt)
|
||||
target_link_libraries(kompute PUBLIC Vulkan::Vulkan
|
||||
fmt::fmt)
|
||||
endif()
|
||||
|
||||
if(KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER)
|
||||
|
|
@ -94,7 +94,7 @@ if(KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER)
|
|||
endif()
|
||||
|
||||
if(KOMPUTE_OPT_ENABLE_LOGGING)
|
||||
target_link_libraries(kompute PRIVATE spdlog::spdlog)
|
||||
target_link_libraries(kompute PUBLIC spdlog::spdlog)
|
||||
endif()
|
||||
|
||||
#####################################################
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ endmacro()
|
|||
add_kompute_test(AsyncOperations)
|
||||
add_kompute_test(Destroy)
|
||||
add_kompute_test(LogisticRegression)
|
||||
add_kompute_test(Main)
|
||||
add_kompute_test(Manager)
|
||||
add_kompute_test(MultipleAlgoExecutions)
|
||||
add_kompute_test(OpShadersFromStringAndFile)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#include <chrono>
|
||||
|
||||
#include "kompute/Kompute.hpp"
|
||||
#include "shaders/Utils.hpp"
|
||||
|
||||
TEST(TestAsyncOperations, TestManagerParallelExecution)
|
||||
{
|
||||
|
|
@ -257,3 +258,16 @@ TEST(TestAsyncOperations, TestManagerAsyncExecutionTimeout)
|
|||
EXPECT_EQ(tensorA->vector(), resultAsync);
|
||||
EXPECT_EQ(tensorB->vector(), resultAsync);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
|
||||
#if KOMPUTE_ENABLE_SPDLOG
|
||||
spdlog::set_level(
|
||||
static_cast<spdlog::level::level_enum>(KOMPUTE_LOG_LEVEL));
|
||||
#endif
|
||||
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -139,3 +139,16 @@ TEST(TestDestroy, TestDestroySequenceSingle)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
|
||||
#if KOMPUTE_ENABLE_SPDLOG
|
||||
spdlog::set_level(
|
||||
static_cast<spdlog::level::level_enum>(KOMPUTE_LOG_LEVEL));
|
||||
#endif
|
||||
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#include "kompute/Kompute.hpp"
|
||||
|
||||
#include "test_logistic_regression.hpp"
|
||||
#include "test_logistic_regression_shader.hpp"
|
||||
|
||||
TEST(TestLogisticRegression, TestMainLogisticRegression)
|
||||
{
|
||||
|
|
@ -39,12 +39,11 @@ TEST(TestLogisticRegression, TestMainLogisticRegression)
|
|||
|
||||
mgr.sequence()->eval<kp::OpTensorSyncDevice>(params);
|
||||
|
||||
std::vector<uint32_t> spirv = std::vector<uint32_t>(
|
||||
(const uint32_t*)kp::TEST_LOGISTIC_REGRESSION_COMP_SPV.data(),
|
||||
(const uint32_t*)(kp::shader_data::
|
||||
test_shaders_glsl_test_logistic_regression_comp_spv +
|
||||
kp::shader_data::
|
||||
test_shaders_glsl_test_logistic_regression_comp_spv_len));
|
||||
std::vector<uint32_t> spirv2{ 0x1, 0x2 };
|
||||
|
||||
std::vector<uint32_t> spirv(
|
||||
kp::TEST_LOGISTIC_REGRESSION_SHADER_COMP_SPV.begin(),
|
||||
kp::TEST_LOGISTIC_REGRESSION_SHADER_COMP_SPV.end());
|
||||
|
||||
std::shared_ptr<kp::Algorithm> algorithm = mgr.algorithm(
|
||||
params, spirv, kp::Workgroup({ 5 }), std::vector<float>({ 5.0 }));
|
||||
|
|
@ -57,7 +56,6 @@ TEST(TestLogisticRegression, TestMainLogisticRegression)
|
|||
|
||||
// Iterate across all expected iterations
|
||||
for (size_t i = 0; i < ITERATIONS; i++) {
|
||||
|
||||
sq->eval();
|
||||
|
||||
for (size_t j = 0; j < bOut->size(); j++) {
|
||||
|
|
@ -118,12 +116,9 @@ TEST(TestLogisticRegression, TestMainLogisticRegressionManualCopy)
|
|||
|
||||
mgr.sequence()->record<kp::OpTensorSyncDevice>(params)->eval();
|
||||
|
||||
std::vector<uint32_t> spirv = std::vector<uint32_t>(
|
||||
(uint32_t*)kp::shader_data::shaders_glsl_logisticregression_comp_spv,
|
||||
(uint32_t*)(kp::shader_data::
|
||||
shaders_glsl_logisticregression_comp_spv +
|
||||
kp::shader_data::
|
||||
shaders_glsl_logisticregression_comp_spv_len));
|
||||
std::vector<uint32_t> spirv(
|
||||
kp::TEST_LOGISTIC_REGRESSION_SHADER_COMP_SPV.begin(),
|
||||
kp::TEST_LOGISTIC_REGRESSION_SHADER_COMP_SPV.end());
|
||||
|
||||
std::shared_ptr<kp::Algorithm> algorithm = mgr.algorithm(
|
||||
params, spirv, kp::Workgroup(), std::vector<float>({ 5.0 }));
|
||||
|
|
@ -161,3 +156,16 @@ TEST(TestLogisticRegression, TestMainLogisticRegressionManualCopy)
|
|||
bIn->data()[0]);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
|
||||
#if KOMPUTE_ENABLE_SPDLOG
|
||||
spdlog::set_level(
|
||||
static_cast<spdlog::level::level_enum>(KOMPUTE_LOG_LEVEL));
|
||||
#endif
|
||||
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +0,0 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <kompute/Kompute.hpp>
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
|
||||
#if KOMPUTE_ENABLE_SPDLOG
|
||||
spdlog::set_level(
|
||||
static_cast<spdlog::level::level_enum>(KOMPUTE_LOG_LEVEL));
|
||||
#endif
|
||||
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
|
@ -105,3 +105,16 @@ TEST(TestManager, TestClearDestroy)
|
|||
|
||||
mgr.destroy();
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
|
||||
#if KOMPUTE_ENABLE_SPDLOG
|
||||
spdlog::set_level(
|
||||
static_cast<spdlog::level::level_enum>(KOMPUTE_LOG_LEVEL));
|
||||
#endif
|
||||
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -270,3 +270,16 @@ TEST(TestMultipleAlgoExecutions, TestAlgorithmUtilFunctions)
|
|||
EXPECT_EQ(algorithm->getPushConstants<float>(), pushConsts);
|
||||
EXPECT_EQ(algorithm->getSpecializationConstants<float>(), specConsts);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
|
||||
#if KOMPUTE_ENABLE_SPDLOG
|
||||
spdlog::set_level(
|
||||
static_cast<spdlog::level::level_enum>(KOMPUTE_LOG_LEVEL));
|
||||
#endif
|
||||
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,9 +4,8 @@
|
|||
|
||||
#include "kompute/Kompute.hpp"
|
||||
|
||||
#include "kompute_test/shaders/shadertest_op_custom_shader.hpp"
|
||||
|
||||
#include "shaders/Utils.hpp"
|
||||
#include "test_op_custom_shader.hpp"
|
||||
|
||||
TEST(TestOpAlgoCreate, ShaderRawDataFromConstructor)
|
||||
{
|
||||
|
|
@ -50,14 +49,8 @@ TEST(TestOpAlgoCreate, ShaderCompiledDataFromConstructor)
|
|||
std::shared_ptr<kp::TensorT<float>> tensorA = mgr.tensor({ 3, 4, 5 });
|
||||
std::shared_ptr<kp::TensorT<float>> tensorB = mgr.tensor({ 0, 0, 0 });
|
||||
|
||||
std::vector<uint32_t> spirv = std::vector<uint32_t>(
|
||||
(uint32_t*)
|
||||
kp::shader_data::test_shaders_glsl_test_op_custom_shader_comp_spv,
|
||||
(uint32_t*)(kp::shader_data::
|
||||
test_shaders_glsl_test_op_custom_shader_comp_spv +
|
||||
kp::shader_data::
|
||||
test_shaders_glsl_test_op_custom_shader_comp_spv_len));
|
||||
|
||||
std::vector<uint32_t> spirv(kp::TEST_OP_CUSTOM_SHADER_COMP_SPV.begin(),
|
||||
kp::TEST_OP_CUSTOM_SHADER_COMP_SPV.end());
|
||||
std::vector<std::shared_ptr<kp::Tensor>> params = { tensorA, tensorB };
|
||||
|
||||
mgr.sequence()
|
||||
|
|
@ -87,3 +80,16 @@ TEST(TestOpAlgoCreate, ShaderCompiledDataFromConstructor)
|
|||
// EXPECT_EQ(tensorA->vector(), std::vector<float>({ 0, 1, 2 }));
|
||||
// EXPECT_EQ(tensorB->vector(), std::vector<float>({ 3, 4, 5 }));
|
||||
//}
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
|
||||
#if KOMPUTE_ENABLE_SPDLOG
|
||||
spdlog::set_level(
|
||||
static_cast<spdlog::level::level_enum>(KOMPUTE_LOG_LEVEL));
|
||||
#endif
|
||||
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,3 +156,16 @@ TEST(TestOpTensorCopy, SingleTensorShouldFail)
|
|||
EXPECT_THROW(mgr.sequence()->eval<kp::OpTensorCopy>({ tensorA }),
|
||||
std::runtime_error);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
|
||||
#if KOMPUTE_ENABLE_SPDLOG
|
||||
spdlog::set_level(
|
||||
static_cast<spdlog::level::level_enum>(KOMPUTE_LOG_LEVEL));
|
||||
#endif
|
||||
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,3 +57,16 @@ TEST(TestOpTensorCreate, ExceptionOnZeroSizeTensor)
|
|||
std::string::npos);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
|
||||
#if KOMPUTE_ENABLE_SPDLOG
|
||||
spdlog::set_level(
|
||||
static_cast<spdlog::level::level_enum>(KOMPUTE_LOG_LEVEL));
|
||||
#endif
|
||||
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,3 +52,16 @@ TEST(TestOpTensorSync, SyncToDeviceMemoryMultiTensor)
|
|||
EXPECT_EQ(tensorB->vector(), testVec);
|
||||
EXPECT_EQ(tensorC->vector(), testVec);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
|
||||
#if KOMPUTE_ENABLE_SPDLOG
|
||||
spdlog::set_level(
|
||||
static_cast<spdlog::level::level_enum>(KOMPUTE_LOG_LEVEL));
|
||||
#endif
|
||||
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -391,3 +391,16 @@ TEST(TestPushConstants, TestConstantsDouble)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
|
||||
#if KOMPUTE_ENABLE_SPDLOG
|
||||
spdlog::set_level(
|
||||
static_cast<spdlog::level::level_enum>(KOMPUTE_LOG_LEVEL));
|
||||
#endif
|
||||
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -242,3 +242,16 @@ TEST(TestSequence, CorrectSequenceRunningError)
|
|||
|
||||
EXPECT_EQ(tensorOut->vector(), std::vector<float>({ 2, 4, 6 }));
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
|
||||
#if KOMPUTE_ENABLE_SPDLOG
|
||||
spdlog::set_level(
|
||||
static_cast<spdlog::level::level_enum>(KOMPUTE_LOG_LEVEL));
|
||||
#endif
|
||||
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,3 +101,16 @@ TEST(TestSpecializationConstants, TestConstantsInt)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
|
||||
#if KOMPUTE_ENABLE_SPDLOG
|
||||
spdlog::set_level(
|
||||
static_cast<spdlog::level::level_enum>(KOMPUTE_LOG_LEVEL));
|
||||
#endif
|
||||
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,3 +43,16 @@ TEST(TestTensor, DataTypes)
|
|||
EXPECT_EQ(tensor->dataType(), kp::Tensor::TensorDataTypes::eDouble);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
|
||||
#if KOMPUTE_ENABLE_SPDLOG
|
||||
spdlog::set_level(
|
||||
static_cast<spdlog::level::level_enum>(KOMPUTE_LOG_LEVEL));
|
||||
#endif
|
||||
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#include "kompute/Kompute.hpp"
|
||||
|
||||
#include "kompute_test/shaders/shadertest_workgroup.hpp"
|
||||
#include "test_workgroup_shader.hpp"
|
||||
|
||||
TEST(TestWorkgroup, TestSimpleWorkgroup)
|
||||
{
|
||||
|
|
@ -21,14 +21,9 @@ TEST(TestWorkgroup, TestSimpleWorkgroup)
|
|||
|
||||
std::vector<std::shared_ptr<kp::Tensor>> params = { tensorA,
|
||||
tensorB };
|
||||
|
||||
std::vector<uint32_t> spirv(
|
||||
(uint32_t*)
|
||||
kp::shader_data::test_shaders_glsl_test_workgroup_comp_spv,
|
||||
(uint32_t*)(kp::shader_data::
|
||||
test_shaders_glsl_test_workgroup_comp_spv +
|
||||
kp::shader_data::
|
||||
test_shaders_glsl_test_workgroup_comp_spv_len));
|
||||
kp::TEST_WORKGROUP_SHADER_COMP_SPV.begin(),
|
||||
kp::TEST_WORKGROUP_SHADER_COMP_SPV.end());
|
||||
|
||||
kp::Workgroup workgroup = { 16, 8, 1 };
|
||||
|
||||
|
|
@ -67,3 +62,16 @@ TEST(TestWorkgroup, TestSimpleWorkgroup)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
|
||||
#if KOMPUTE_ENABLE_SPDLOG
|
||||
spdlog::set_level(
|
||||
static_cast<spdlog::level::level_enum>(KOMPUTE_LOG_LEVEL));
|
||||
#endif
|
||||
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,21 +2,21 @@
|
|||
#######################
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
|
||||
vulkan_compile_shader(INFILE test_logistic_regression.comp
|
||||
OUTFILE test_logistic_regression.hpp
|
||||
vulkan_compile_shader(INFILE test_logistic_regression_shader.comp
|
||||
OUTFILE test_logistic_regression_shader.hpp
|
||||
NAMESPACE "kp")
|
||||
|
||||
vulkan_compile_shader(INFILE test_op_custom_shader.comp
|
||||
OUTFILE test_op_custom_shader.hpp
|
||||
NAMESPACE "kp")
|
||||
|
||||
vulkan_compile_shader(INFILE test_workgroup.comp
|
||||
OUTFILE test_workgroup.hpp
|
||||
vulkan_compile_shader(INFILE test_workgroup_shader.comp
|
||||
OUTFILE test_workgroup_shader.hpp
|
||||
NAMESPACE "kp")
|
||||
|
||||
add_library(test_shaders_glsl "${CMAKE_CURRENT_BINARY_DIR}/test_logistic_regression.hpp"
|
||||
add_library(test_shaders_glsl "${CMAKE_CURRENT_BINARY_DIR}/test_logistic_regression_shader.hpp"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/test_op_custom_shader.hpp"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/test_workgroup.hpp")
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/test_workgroup_shader.hpp")
|
||||
|
||||
set_target_properties(test_shaders_glsl PROPERTIES LINKER_LANGUAGE CXX)
|
||||
target_include_directories(test_shaders_glsl PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue