From 4869d94f8a05009932fd5bfcaf8c63674de7598c Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Tue, 10 May 2022 09:31:10 +0200 Subject: [PATCH 001/107] Added clangd .cahce folder to .gitignore Signed-off-by: Fabian Sauter --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 4c684dc3a..97a39b2b8 100644 --- a/.gitignore +++ b/.gitignore @@ -169,10 +169,9 @@ Content/StarterContent/* # VSCode Files /.vscode/* BuildingEscape.code-workspace - compile_commands.json - .clangd/ +.cache/ # Project files bin/ From 50ffbbc01ac7653f0fc7a70a2e2575faab14abd8 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Tue, 10 May 2022 09:31:30 +0200 Subject: [PATCH 002/107] Replaced .gitmodules with fetch_content Signed-off-by: Fabian Sauter --- .gitmodules | 20 --------- CMakeLists.txt | 90 ++++++++++++++++++++++++++++++++++------- external/Vulkan-Headers | 1 - external/fmt | 1 - external/googletest | 1 - external/spdlog | 1 - python/CMakeLists.txt | 1 - python/pybind11 | 1 - src/CMakeLists.txt | 51 +++-------------------- test/CMakeLists.txt | 23 +---------- 10 files changed, 83 insertions(+), 107 deletions(-) delete mode 100644 .gitmodules delete mode 160000 external/Vulkan-Headers delete mode 160000 external/fmt delete mode 160000 external/googletest delete mode 160000 external/spdlog delete mode 160000 python/pybind11 diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 3c710d619..000000000 --- a/.gitmodules +++ /dev/null @@ -1,20 +0,0 @@ -[submodule "external/googletest"] - path = external/googletest - url = https://github.com/google/googletest - branch = release-1.10.0 -[submodule "external/Vulkan-Headers"] - path = external/Vulkan-Headers - url = https://github.com/KhronosGroup/Vulkan-Headers - branch = v1.2.158 -[submodule "external/spdlog"] - path = external/spdlog - url = https://github.com/gabime/spdlog - branch = v1.8.1 -[submodule "python/pybind11"] - path = python/pybind11 - url = https://github.com/pybind/pybind11 - branch = v2.6.1 -[submodule "external/fmt"] - path = external/fmt - url = https://github.com/fmtlib/fmt - branch = 7.1.3 diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b014c4a2..0eb8a9ac8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_VERBOSE_MAKEFILE on) # Enable or disable targets -option(KOMPUTE_OPT_BUILD_TESTS "Enable if you want to build tests" 0) +option(KOMPUTE_OPT_BUILD_TESTS "Enable if you want to build tests" 1) option(KOMPUTE_OPT_CODE_COVERAGE "Enable if you want code coverage" 0) option(KOMPUTE_OPT_BUILD_DOCS "Enable if you want to build documentation" 0) option(KOMPUTE_OPT_BUILD_SHADERS "Enable if you want to re-build all shader files" 0) @@ -18,7 +18,14 @@ option(KOMPUTE_OPT_INSTALL "Enable if you want to enable installation" 0) # Build options option(KOMPUTE_OPT_BUILD_PYTHON "Enable if you want to build python bindings" 0) option(KOMPUTE_OPT_ENABLE_SPDLOG "Enable to compile with spdlog as the internal logging framework" 0) -option(KOMPUTE_OPT_REPO_SUBMODULE_BUILD "Use the submodule repos instead of external package manager" 0) + +# option(KOMPUTE_OPT_REPO_SUBMODULE_BUILD "Use the submodule repos instead of external package manager" 0) +option(KOMPUTE_OPT_USE_BUILD_IN_SPDLOG "Use the build in version of Spdlog" 1) +option(KOMPUTE_OPT_USE_BUILD_IN_FMT "Use the build in version of fmt" 1) +option(KOMPUTE_OPT_USE_BUILD_IN_GOOGLE_TEST "Use the build in version of GoogleTest" 1) +option(KOMPUTE_OPT_USE_BUILD_IN_PYBIND11 "Use the build in version of pybind11" 1) + + option(KOMPUTE_OPT_ANDROID_BUILD "Enable android compilation flags required" 0) option(KOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS "Explicitly disable debug layers even on debug" 0) option(KOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS "Whether to use shared libraries for dependencies for install" 0) @@ -26,22 +33,77 @@ option(KOMPUTE_OPT_BUILD_AS_SHARED_LIB "Whether to build kompute as shared libra # Build flags set(KOMPUTE_EXTRA_CXX_FLAGS "" CACHE STRING "Extra compile flags for Kompute, see docs for full list") -if(KOMPUTE_OPT_ENABLE_SPDLOG) - set(KOMPUTE_EXTRA_CXX_FLAGS "${KOMPUTE_EXTRA_CXX_FLAGS} -DKOMPUTE_ENABLE_SPDLOG=1") - set(SPDLOG_FMT_EXTERNAL ON CACHE BOOL "Enables external fmt as its current dep" FORCE) - if(KOMPUTE_OPT_INSTALL) - # Enable install parameters for spdlog (overrides parameters passed) - set(SPDLOG_INSTALL ON CACHE BOOL "Enables install of spdlog" FORCE) - if(KOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS) - set(SPDLOG_BUILD_SHARED ON CACHE BOOL "Enables build of shared libraries" FORCE) - endif() +########################################################################################### +# Dependencies +########################################################################################### +include(FetchContent) + +# Vulkan +# We don't import Vulkan library if Android build as its build dynamically +# Otherwise it is expected that the Vulkan SDK and dependencies are installed +if(NOT KOMPUTE_OPT_ANDROID_BUILD) + find_package(Vulkan REQUIRED) +endif() + +# Spdlog +if(KOMPUTE_OPT_ENABLE_SPDLOG) + if(KOMPUTE_OPT_USE_BUILD_IN_SPDLOG) + set(SPDLOG_INSTALL ${KOMPUTE_OPT_INSTALL}) + set(SPDLOG_BUILD_SHARED ${KOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS}) + + FetchContent_Declare(spdlog GIT_REPOSITORY https://github.com/gabime/spdlog.git + GIT_TAG v1.10.0) # Source: https://github.com/gabime/spdlog/releases + FetchContent_MakeAvailable(spdlog) + else() + find_package(spdlog REQUIRED) endif() endif() -if(KOMPUTE_OPT_INSTALL) - # Enable install parameters for fmt (overrides parameters passed) - set(FMT_INSTALL ON CACHE BOOL "Enables install of fmt" FORCE) +# fmt +if(KOMPUTE_OPT_USE_BUILD_IN_FMT) + set(FMT_INSTALL ${KOMPUTE_OPT_INSTALL}) + set(BUILD_SHARED_LIBS_BKP ${KOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS}) + set(SPDLOG_BUILD_SHARED ${KOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS}) + FetchContent_Declare(fmt GIT_REPOSITORY https://github.com/fmtlib/fmt.git + GIT_TAG 8.1.1) # Source: https://github.com/fmtlib/fmt/releases + FetchContent_MakeAvailable(fmt) + set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_BKP}) +else() + find_package(fmt REQUIRED) +endif() + +# GoogleTest +if(KOMPUTE_OPT_BUILD_TESTS) + if(KOMPUTE_OPT_USE_BUILD_IN_GOOGLE_TEST) + FetchContent_Declare(googletest GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG release-1.11.0) # Source: https://github.com/google/googletest/releases + FetchContent_MakeAvailable(googletest) + + add_library(gtest_int INTERFACE) + target_link_libraries(gtest_int INTERFACE gtest) + target_include_directories(gtest_int INTERFACE ${googletest_SOURCE_DIR}/include) + + add_library(GTest::GTest ALIAS gtest_int) + + # Group under the "tests/gtest" project folder in IDEs such as Visual Studio. + set_property(TARGET gtest PROPERTY FOLDER "tests/gtest") + set_property(TARGET gtest_main PROPERTY FOLDER "tests/gtest") + else() + find_package(GTest CONFIG REQUIRED) + endif() +endif() + +# pybind11 +if(KOMPUTE_OPT_BUILD_PYTHON) + if(KOMPUTE_OPT_USE_BUILD_IN_PYBIND11) + FetchContent_Declare(pybind GIT_REPOSITORY https://github.com/pybind/pybind11.git + GIT_TAG v2.9.2) # Source: https://github.com/pybind/pybind11/releases + FetchContent_MakeAvailable(pybind) + else() + find_package(pybind11 REQUIRED) + endif() + find_package(PythonLibs REQUIRED) endif() if(KOMPUTE_OPT_ANDROID_BUILD) diff --git a/external/Vulkan-Headers b/external/Vulkan-Headers deleted file mode 160000 index 320af06cb..000000000 --- a/external/Vulkan-Headers +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 320af06cbdd29848e1d7100d9b8e4e517db1dfd5 diff --git a/external/fmt b/external/fmt deleted file mode 160000 index 7bdf0628b..000000000 --- a/external/fmt +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 7bdf0628b1276379886c7f6dda2cef2b3b374f0b diff --git a/external/googletest b/external/googletest deleted file mode 160000 index 703bd9caa..000000000 --- a/external/googletest +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 703bd9caab50b139428cea1aaff9974ebee5742e diff --git a/external/spdlog b/external/spdlog deleted file mode 160000 index 01b350de9..000000000 --- a/external/spdlog +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 01b350de96483cf00b267c6db4c25f3b739b3fee diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 5f3036986..cad7f4ffa 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -1,5 +1,4 @@ -add_subdirectory(pybind11) pybind11_add_module(kp src/main.cpp) include_directories( diff --git a/python/pybind11 b/python/pybind11 deleted file mode 160000 index 06a54018c..000000000 --- a/python/pybind11 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 06a54018c8a9fd9a7be5f5b56414b5da9259f637 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9747694fe..38889c33d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,12 +4,6 @@ if(KOMPUTE_OPT_ANDROID_BUILD) find_library(android android) endif() -# We don't import Vulkan library if Android build as its build dynamically -# Otherwise it is expected that the Vulkan SDK and dependencies are installed -if(NOT KOMPUTE_OPT_ANDROID_BUILD) - find_package(Vulkan REQUIRED) -endif() - if(KOMPUTE_OPT_BUILD_SHADERS) # all shaders are compiled into cpp files kompute_make(build_shaders @@ -60,49 +54,20 @@ if(NOT KOMPUTE_OPT_ANDROID_BUILD) target_link_libraries( kompute Vulkan::Vulkan + fmt::fmt ) else() target_link_libraries( kompute + fmt::fmt ) endif() -if(KOMPUTE_OPT_REPO_SUBMODULE_BUILD) -# Override the default Vulkan::Vulkan headers -# In this case we only use the build interface due to https://github.com/KhronosGroup/Vulkan-Headers/issues/157 - add_subdirectory(${PROJECT_SOURCE_DIR}/external/Vulkan-Headers ${CMAKE_CURRENT_BINARY_DIR}/kompute_vulkan_headers) - get_target_property(VULKAN_HEADERS_INCLUDES Vulkan-Headers INTERFACE_INCLUDE_DIRECTORIES) - target_include_directories( - kompute PUBLIC - $) -endif() - ##################################################### -#################### fmt ####################### -##################################################### - -if(KOMPUTE_OPT_REPO_SUBMODULE_BUILD) - add_subdirectory(${PROJECT_SOURCE_DIR}/external/fmt ${CMAKE_CURRENT_BINARY_DIR}/kompute_fmt) -else() - find_package(fmt REQUIRED) -endif() - -target_link_libraries( - kompute - fmt::fmt -) - -##################################################### -#################### SPDLOG ####################### +#################### SPDLOG ######################### ##################################################### if(KOMPUTE_OPT_ENABLE_SPDLOG) - if(KOMPUTE_OPT_REPO_SUBMODULE_BUILD) - add_subdirectory(${PROJECT_SOURCE_DIR}/external/spdlog ${CMAKE_CURRENT_BINARY_DIR}/kompute_spdlog) - else() - find_package(spdlog REQUIRED) - endif() - target_link_libraries( kompute spdlog::spdlog @@ -110,7 +75,7 @@ if(KOMPUTE_OPT_ENABLE_SPDLOG) endif() ##################################################### -#################### Android ####################### +#################### Android ######################## ##################################################### if(KOMPUTE_OPT_ANDROID_BUILD) @@ -132,7 +97,7 @@ if(KOMPUTE_OPT_BUILD_SHADERS) endif() ##################################################### -#################### Single Header ####################### +#################### Single Header ################## ##################################################### if(KOMPUTE_OPT_BUILD_SINGLE_HEADER) @@ -161,9 +126,3 @@ if(KOMPUTE_OPT_INSTALL) NAMESPACE kompute:: DESTINATION lib/cmake/kompute) endif() - -if(KOMPUTE_OPT_BUILD_PYTHON) - include_directories(${PROJECT_SOURCE_DIR}/python/pybind11/include) - find_package(PythonLibs REQUIRED) - include_directories(${PYTHON_INCLUDE_DIRS}) -endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 562f1890e..d1d949bdb 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,15 +1,9 @@ # SPDX-License-Identifier: Apache-2.0 ##################################################### -#################### GETEST ####################### +#################### GOOGLETEST ##################### ##################################################### enable_testing() -if(KOMPUTE_OPT_REPO_SUBMODULE_BUILD) - add_subdirectory(${PROJECT_SOURCE_DIR}/external/googletest EXCLUDE_FROM_ALL - ${CMAKE_CURRENT_BINARY_DIR}/kompute_googletest) -else() - find_package(GTest CONFIG REQUIRED) -endif() file(GLOB test_kompute_CPP "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp" @@ -23,20 +17,7 @@ target_include_directories( $ $ ) - -if(KOMPUTE_OPT_REPO_SUBMODULE_BUILD) - target_include_directories( - test_kompute PRIVATE - ${gtest_SOURCE_DIR}/include) - - target_link_libraries(test_kompute - gtest_main) -else() - target_link_libraries(test_kompute - GTest::gtest) -endif() - -target_link_libraries(test_kompute kompute) +target_link_libraries(test_kompute kompute GTest::GTest) add_test(NAME test_kompute COMMAND test_kompute) From 92aa7642e15ea34cbc76526d0c4a6221390a3790 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Tue, 10 May 2022 09:33:08 +0200 Subject: [PATCH 003/107] CMakeLists option cleanup Signed-off-by: Fabian Sauter --- CMakeLists.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0eb8a9ac8..85e4eeb29 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_VERBOSE_MAKEFILE on) # Enable or disable targets -option(KOMPUTE_OPT_BUILD_TESTS "Enable if you want to build tests" 1) +option(KOMPUTE_OPT_BUILD_TESTS "Enable if you want to build tests" 0) option(KOMPUTE_OPT_CODE_COVERAGE "Enable if you want code coverage" 0) option(KOMPUTE_OPT_BUILD_DOCS "Enable if you want to build documentation" 0) option(KOMPUTE_OPT_BUILD_SHADERS "Enable if you want to re-build all shader files" 0) @@ -19,13 +19,12 @@ option(KOMPUTE_OPT_INSTALL "Enable if you want to enable installation" 0) option(KOMPUTE_OPT_BUILD_PYTHON "Enable if you want to build python bindings" 0) option(KOMPUTE_OPT_ENABLE_SPDLOG "Enable to compile with spdlog as the internal logging framework" 0) -# option(KOMPUTE_OPT_REPO_SUBMODULE_BUILD "Use the submodule repos instead of external package manager" 0) +# External komponents option(KOMPUTE_OPT_USE_BUILD_IN_SPDLOG "Use the build in version of Spdlog" 1) option(KOMPUTE_OPT_USE_BUILD_IN_FMT "Use the build in version of fmt" 1) option(KOMPUTE_OPT_USE_BUILD_IN_GOOGLE_TEST "Use the build in version of GoogleTest" 1) option(KOMPUTE_OPT_USE_BUILD_IN_PYBIND11 "Use the build in version of pybind11" 1) - option(KOMPUTE_OPT_ANDROID_BUILD "Enable android compilation flags required" 0) option(KOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS "Explicitly disable debug layers even on debug" 0) option(KOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS "Whether to use shared libraries for dependencies for install" 0) From 0ac7d82383c84396620c30a8ee450cce8128ab24 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Tue, 10 May 2022 13:37:38 +0200 Subject: [PATCH 004/107] CMake 0 -> OFF, 1 -> ON Signed-off-by: Fabian Sauter --- CMakeLists.txt | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 85e4eeb29..852cd364e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,33 +9,32 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_VERBOSE_MAKEFILE on) # Enable or disable targets -option(KOMPUTE_OPT_BUILD_TESTS "Enable if you want to build tests" 0) -option(KOMPUTE_OPT_CODE_COVERAGE "Enable if you want code coverage" 0) -option(KOMPUTE_OPT_BUILD_DOCS "Enable if you want to build documentation" 0) -option(KOMPUTE_OPT_BUILD_SHADERS "Enable if you want to re-build all shader files" 0) -option(KOMPUTE_OPT_BUILD_SINGLE_HEADER "Enable if you want to build the single header file" 0) -option(KOMPUTE_OPT_INSTALL "Enable if you want to enable installation" 0) +option(KOMPUTE_OPT_BUILD_TESTS "Enable if you want to build tests" OFF) +option(KOMPUTE_OPT_CODE_COVERAGE "Enable if you want code coverage" OFF) +option(KOMPUTE_OPT_BUILD_DOCS "Enable if you want to build documentation" OFF) +option(KOMPUTE_OPT_BUILD_SHADERS "Enable if you want to re-build all shader files" OFF) +option(KOMPUTE_OPT_BUILD_SINGLE_HEADER "Enable if you want to build the single header file" OFF) +option(KOMPUTE_OPT_INSTALL "Enable if you want to enable installation" OFF) # Build options -option(KOMPUTE_OPT_BUILD_PYTHON "Enable if you want to build python bindings" 0) -option(KOMPUTE_OPT_ENABLE_SPDLOG "Enable to compile with spdlog as the internal logging framework" 0) +option(KOMPUTE_OPT_BUILD_PYTHON "Enable if you want to build python bindings" OFF) +option(KOMPUTE_OPT_ENABLE_SPDLOG "Enable to compile with spdlog as the internal logging framework" OFF) # External komponents -option(KOMPUTE_OPT_USE_BUILD_IN_SPDLOG "Use the build in version of Spdlog" 1) -option(KOMPUTE_OPT_USE_BUILD_IN_FMT "Use the build in version of fmt" 1) -option(KOMPUTE_OPT_USE_BUILD_IN_GOOGLE_TEST "Use the build in version of GoogleTest" 1) -option(KOMPUTE_OPT_USE_BUILD_IN_PYBIND11 "Use the build in version of pybind11" 1) +option(KOMPUTE_OPT_USE_BUILD_IN_SPDLOG "Use the build in version of Spdlog" ON) +option(KOMPUTE_OPT_USE_BUILD_IN_FMT "Use the build in version of fmt" ON) +option(KOMPUTE_OPT_USE_BUILD_IN_GOOGLE_TEST "Use the build in version of GoogleTest" ON) +option(KOMPUTE_OPT_USE_BUILD_IN_PYBIND11 "Use the build in version of pybind11" ON) -option(KOMPUTE_OPT_ANDROID_BUILD "Enable android compilation flags required" 0) -option(KOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS "Explicitly disable debug layers even on debug" 0) -option(KOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS "Whether to use shared libraries for dependencies for install" 0) -option(KOMPUTE_OPT_BUILD_AS_SHARED_LIB "Whether to build kompute as shared library" 0) +option(KOMPUTE_OPT_ANDROID_BUILD "Enable android compilation flags required" OFF) +option(KOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS "Explicitly disable debug layers even on debug" OFF) +option(KOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS "Whether to use shared libraries for dependencies for install" OFF) +option(KOMPUTE_OPT_BUILD_AS_SHARED_LIB "Whether to build kompute as shared library" OFF) # Build flags set(KOMPUTE_EXTRA_CXX_FLAGS "" CACHE STRING "Extra compile flags for Kompute, see docs for full list") - -########################################################################################### -# Dependencies -########################################################################################### +##################################################### +#################### Dependencies ################### +##################################################### include(FetchContent) # Vulkan @@ -105,6 +104,10 @@ if(KOMPUTE_OPT_BUILD_PYTHON) find_package(PythonLibs REQUIRED) endif() +##################################################### +#################### Other Options ################## +##################################################### + if(KOMPUTE_OPT_ANDROID_BUILD) set(KOMPUTE_EXTRA_CXX_FLAGS "${KOMPUTE_EXTRA_CXX_FLAGS} -DVK_USE_PLATFORM_ANDROID_KHR") endif() From bf0d938428debf7882da82cac3b3cfeb0ae7c010 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Tue, 10 May 2022 13:49:48 +0200 Subject: [PATCH 005/107] Linking against Vulkan-Headers Signed-off-by: Fabian Sauter --- CMakeLists.txt | 5 +++++ src/CMakeLists.txt | 1 + 2 files changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 852cd364e..d34a7a962 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,6 +44,11 @@ if(NOT KOMPUTE_OPT_ANDROID_BUILD) find_package(Vulkan REQUIRED) endif() +# Vulkan Header +FetchContent_Declare(vulkan_header GIT_REPOSITORY https://github.com/KhronosGroup/Vulkan-Headers.git + GIT_TAG v1.3.213) # Source: https://github.com/KhronosGroup/Vulkan-Headers/tags +FetchContent_MakeAvailable(vulkan_header) + # Spdlog if(KOMPUTE_OPT_ENABLE_SPDLOG) if(KOMPUTE_OPT_USE_BUILD_IN_SPDLOG) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 38889c33d..baf4fc037 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -54,6 +54,7 @@ if(NOT KOMPUTE_OPT_ANDROID_BUILD) target_link_libraries( kompute Vulkan::Vulkan + Vulkan-Headers fmt::fmt ) else() From ffc9e9acf8a8d40ba7cb6e5a3238c3799bbe6b11 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Tue, 10 May 2022 14:21:19 +0200 Subject: [PATCH 006/107] Downgraded Vulkan to 1.2 Signed-off-by: Fabian Sauter --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d34a7a962..7e61be8be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,7 +46,7 @@ endif() # Vulkan Header FetchContent_Declare(vulkan_header GIT_REPOSITORY https://github.com/KhronosGroup/Vulkan-Headers.git - GIT_TAG v1.3.213) # Source: https://github.com/KhronosGroup/Vulkan-Headers/tags + GIT_TAG v1.2.203) # Source: https://github.com/KhronosGroup/Vulkan-Headers/tags FetchContent_MakeAvailable(vulkan_header) # Spdlog From 5dae50c8d959f15781526e77930949d92f170023 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Tue, 10 May 2022 16:30:48 +0200 Subject: [PATCH 007/107] Vulkan driver version check Signed-off-by: Fabian Sauter --- CMakeLists.txt | 41 ++++++++++++++----- cmake/check_vulkan_version.cmake | 70 ++++++++++++++++++++++++++++++++ src/CMakeLists.txt | 37 ++++++++--------- 3 files changed, 117 insertions(+), 31 deletions(-) create mode 100644 cmake/check_vulkan_version.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e61be8be..4fbb5b45e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,39 +15,60 @@ option(KOMPUTE_OPT_BUILD_DOCS "Enable if you want to build documentation" OFF) option(KOMPUTE_OPT_BUILD_SHADERS "Enable if you want to re-build all shader files" OFF) option(KOMPUTE_OPT_BUILD_SINGLE_HEADER "Enable if you want to build the single header file" OFF) option(KOMPUTE_OPT_INSTALL "Enable if you want to enable installation" OFF) + # Build options option(KOMPUTE_OPT_BUILD_PYTHON "Enable if you want to build python bindings" OFF) option(KOMPUTE_OPT_ENABLE_SPDLOG "Enable to compile with spdlog as the internal logging framework" OFF) +option(KOMPUTE_OPT_ANDROID_BUILD "Enable android compilation flags required" OFF) +option(KOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS "Explicitly disable debug layers even on debug" OFF) +option(KOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS "Whether to use shared libraries for dependencies for install" OFF) +option(KOMPUTE_OPT_BUILD_AS_SHARED_LIB "Whether to build kompute as shared library" OFF) +option(KOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK "Whether to check if your driver supports the Vulkan-Header version you are linking against." OFF) # External komponents option(KOMPUTE_OPT_USE_BUILD_IN_SPDLOG "Use the build in version of Spdlog" ON) option(KOMPUTE_OPT_USE_BUILD_IN_FMT "Use the build in version of fmt" ON) option(KOMPUTE_OPT_USE_BUILD_IN_GOOGLE_TEST "Use the build in version of GoogleTest" ON) option(KOMPUTE_OPT_USE_BUILD_IN_PYBIND11 "Use the build in version of pybind11" ON) +option(KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER "Use the build in version of Vulkan-Headers. This could be helpful in case your system Vulkan-Headers are to new for your driver. If you set this to false, please make sure your system Vulkan-Header are supported by your driver." ON) -option(KOMPUTE_OPT_ANDROID_BUILD "Enable android compilation flags required" OFF) -option(KOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS "Explicitly disable debug layers even on debug" OFF) -option(KOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS "Whether to use shared libraries for dependencies for install" OFF) -option(KOMPUTE_OPT_BUILD_AS_SHARED_LIB "Whether to build kompute as shared library" OFF) # Build flags set(KOMPUTE_EXTRA_CXX_FLAGS "" CACHE STRING "Extra compile flags for Kompute, see docs for full list") +##################################################### +#################### Deprecated Options ############# +##################################################### +if(KOMPUTE_OPT_REPO_SUBMODULE_BUILD) + message(FATAL_ERROR "'KOMPUTE_OPT_REPO_SUBMODULE_BUILD' got replaced by 'KOMPUTE_OPT_USE_BUILD_IN_SPDLOG', 'KOMPUTE_OPT_USE_BUILD_IN_FMT', 'KOMPUTE_OPT_USE_BUILD_IN_GOOGLE_TEST', 'KOMPUTE_OPT_USE_BUILD_IN_PYBIND11' and 'KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER'. Please use them instead.") +endif() + ##################################################### #################### Dependencies ################### ##################################################### include(FetchContent) +include(cmake/check_vulkan_version.cmake) -# Vulkan +# Vulkan Header # We don't import Vulkan library if Android build as its build dynamically # Otherwise it is expected that the Vulkan SDK and dependencies are installed if(NOT KOMPUTE_OPT_ANDROID_BUILD) find_package(Vulkan REQUIRED) endif() - -# Vulkan Header -FetchContent_Declare(vulkan_header GIT_REPOSITORY https://github.com/KhronosGroup/Vulkan-Headers.git - GIT_TAG v1.2.203) # Source: https://github.com/KhronosGroup/Vulkan-Headers/tags -FetchContent_MakeAvailable(vulkan_header) +if(KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER) + FetchContent_Declare(vulkan_header GIT_REPOSITORY https://github.com/KhronosGroup/Vulkan-Headers.git + GIT_TAG v1.2.203) # Source: https://github.com/KhronosGroup/Vulkan-Headers/tags + FetchContent_MakeAvailable(vulkan_header) + + if(NOT KOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK) + # Ensure the driver supports this Vulkan version + check_vulkan_version(INCLUDE_DIR "${vulkan_header_SOURCE_DIR}/include") + endif() +else() + if(NOT KOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK) + # Ensure the driver supports this Vulkan version + check_vulkan_version(INCLUDE_DIR ${Vulkan_INCLUDE_DIR}) + endif() +endif() # Spdlog if(KOMPUTE_OPT_ENABLE_SPDLOG) diff --git a/cmake/check_vulkan_version.cmake b/cmake/check_vulkan_version.cmake new file mode 100644 index 000000000..7873056b6 --- /dev/null +++ b/cmake/check_vulkan_version.cmake @@ -0,0 +1,70 @@ +function(check_vulkan_version) + message(STATUS "Ensuring the currently installed driver supports the Vulkan version requested by the Vulkan-Header.") + cmake_parse_arguments(VULKAN_CHECK_VERSION "" "INCLUDE_DIR" "" ${ARGN}) + + # Get the current Vulkan-Header version (e.g. 1.2.189). + # This snippet is based on: https://gitlab.kitware.com/cmake/cmake/-/blob/v3.23.1/Modules/FindVulkan.cmake#L140-156 + if(VULKAN_CHECK_VERSION_INCLUDE_DIR) + set(VULKAN_CORE_H ${VULKAN_CHECK_VERSION_INCLUDE_DIR}/vulkan/vulkan_core.h) + if(EXISTS ${VULKAN_CORE_H}) + file(STRINGS ${VULKAN_CORE_H} VulkanHeaderVersionLine REGEX "^#define VK_HEADER_VERSION ") + string(REGEX MATCHALL "[0-9]+" VulkanHeaderVersion "${VulkanHeaderVersionLine}") + file(STRINGS ${VULKAN_CORE_H} VulkanHeaderVersionLine2 REGEX "^#define VK_HEADER_VERSION_COMPLETE ") + string(REGEX MATCHALL "[0-9]+" VulkanHeaderVersion2 "${VulkanHeaderVersionLine2}") + list(LENGTH VulkanHeaderVersion2 _len) + # Versions >= 1.2.175 have an additional numbers in front of e.g. '0, 1, 2' instead of '1, 2' + if(_len EQUAL 3) + list(REMOVE_AT VulkanHeaderVersion2 0) + endif() + list(APPEND VulkanHeaderVersion2 ${VulkanHeaderVersion}) + list(JOIN VulkanHeaderVersion2 "." VULKAN_HEADER_VERSION) + else() + message(FATAL_ERROR "'${VULKAN_CORE_H}' does not exist. Try calling 'find_package(Vulkan REQUIRED)' before you call this function or set 'Vulkan_INCLUDE_DIR' manually!") + return() + endif() + else() + message(FATAL_ERROR "Invalid Vulkan include directory given. Try calling 'find_package(Vulkan REQUIRED)' before you call this function or set 'Vulkan_INCLUDE_DIR' manually!") + return() + endif() + message(STATUS "Found Vulkan Header version ${VULKAN_HEADER_VERSION}.") + + # Get Vulkan version supported by driver + find_program(VULKAN_INFO_PATH NAMES vulkaninfo) + if(${VULKAN_INFO_PATH}) + message(FATAL_ERROR "vulkaninfo not found. The Vulkan SDK might not be installed properly.") + return() + endif() + + execute_process(COMMAND "vulkaninfo" + OUTPUT_VARIABLE VULKAN_INFO_OUTPUT) + if(${VULKAN_INFO_OUTPUT} MATCHES ".*Vulkan version ([0-9]+.[0-9]+.[0-9]+).*") + set(VULKAN_DRIVER_VERSION ${CMAKE_MATCH_1}) + message(STATUS "vulkaninfo reported supported version ${VULKAN_DRIVER_VERSION}") + else() + message(FATAL_ERROR "No valid version found in vulkaninfo. Does your GPU (driver) support Vulkan?") + return() + endif() + + # Compare driver and header version + if(${VULKAN_DRIVER_VERSION} VERSION_LESS ${VULKAN_HEADER_VERSION}) + # Version missmatch. Let us check if the major version is the same. + if(${VULKAN_DRIVER_VERSION} MATCHES "[0-9]+.([0-9]+).[0-9]+") + set(VULKAN_DRIVER_MAJOR_VERSION ${CMAKE_MATCH_1}) + else() + message(FATAL_ERROR "Invalid Vulkan driver version '${VULKAN_DRIVER_VERSION}' found. Expected version in the following format: '[0-9]+.[0-9]+.[0-9]+'") + endif() + if(${VULKAN_HEADER_VERSION} MATCHES "[0-9]+.([0-9]+).[0-9]+") + set(VULKAN_HEADER_MAJOR_VERSION ${CMAKE_MATCH_1}) + else() + message(FATAL_ERROR "Invalid Vulkan-Header version '${VULKAN_HEADER_VERSION}' found. Expected version in the following format: '[0-9]+.[0-9]+.[0-9]+'") + endif() + + if(${VULKAN_DRIVER_MAJOR_VERSION} EQUAL ${VULKAN_HEADER_MAJOR_VERSION}) + message(WARNING "Your GPU driver does not support Vulkan > ${VULKAN_DRIVER_VERSION}, but you try to use Vulkan-Header ${VULKAN_HEADER_VERSION}. At least your driver supports the same major version (${VULKAN_DRIVER_MAJOR_VERSION}), so this should be fine but keep it in mind if encounter some strange behavior.") + else() + message(FATAL_ERROR "Your GPU driver does not support Vulkan > ${VULKAN_DRIVER_VERSION}, but you try to use Vulkan-Header ${VULKAN_HEADER_VERSION}.") + endif() + else() + message(STATUS "Vulkan version check successful!") + endif() +endfunction() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index baf4fc037..44753cd4c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -50,18 +50,18 @@ target_include_directories( $ ) -if(NOT KOMPUTE_OPT_ANDROID_BUILD) - target_link_libraries( - kompute - Vulkan::Vulkan - Vulkan-Headers - fmt::fmt - ) +if(KOMPUTE_OPT_ANDROID_BUILD) + target_link_libraries(kompute + fmt::fmt) else() - target_link_libraries( - kompute - fmt::fmt - ) + target_link_libraries(kompute + Vulkan::Vulkan + fmt::fmt) +endif() + +if(KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER) + target_link_libraries(kompute + Vulkan-Headers) endif() ##################################################### @@ -69,10 +69,7 @@ endif() ##################################################### if(KOMPUTE_OPT_ENABLE_SPDLOG) - target_link_libraries( - kompute - spdlog::spdlog - ) + target_link_libraries(kompute spdlog::spdlog) endif() ##################################################### @@ -80,12 +77,10 @@ endif() ##################################################### if(KOMPUTE_OPT_ANDROID_BUILD) - target_link_libraries( - kompute - kompute_vk_ndk_wrapper - log - android - ) + target_link_libraries(kompute + kompute_vk_ndk_wrapper + log + android) endif() ##################################################### From df8c8ce567936cefde2273e3d3382b750f591cfa Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Tue, 10 May 2022 18:01:54 +0200 Subject: [PATCH 008/107] Vulkan version check now supports oder vulkan versions Signed-off-by: Fabian Sauter --- cmake/check_vulkan_version.cmake | 52 ++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/cmake/check_vulkan_version.cmake b/cmake/check_vulkan_version.cmake index 7873056b6..66e59dc6e 100644 --- a/cmake/check_vulkan_version.cmake +++ b/cmake/check_vulkan_version.cmake @@ -1,23 +1,37 @@ function(check_vulkan_version) - message(STATUS "Ensuring the currently installed driver supports the Vulkan version requested by the Vulkan-Header.") cmake_parse_arguments(VULKAN_CHECK_VERSION "" "INCLUDE_DIR" "" ${ARGN}) + message(STATUS "Ensuring the currently installed driver supports the Vulkan version requested by the Vulkan Header.") - # Get the current Vulkan-Header version (e.g. 1.2.189). + # Get the current Vulkan Header version (e.g. 1.2.189). # This snippet is based on: https://gitlab.kitware.com/cmake/cmake/-/blob/v3.23.1/Modules/FindVulkan.cmake#L140-156 if(VULKAN_CHECK_VERSION_INCLUDE_DIR) set(VULKAN_CORE_H ${VULKAN_CHECK_VERSION_INCLUDE_DIR}/vulkan/vulkan_core.h) if(EXISTS ${VULKAN_CORE_H}) - file(STRINGS ${VULKAN_CORE_H} VulkanHeaderVersionLine REGEX "^#define VK_HEADER_VERSION ") - string(REGEX MATCHALL "[0-9]+" VulkanHeaderVersion "${VulkanHeaderVersionLine}") - file(STRINGS ${VULKAN_CORE_H} VulkanHeaderVersionLine2 REGEX "^#define VK_HEADER_VERSION_COMPLETE ") - string(REGEX MATCHALL "[0-9]+" VulkanHeaderVersion2 "${VulkanHeaderVersionLine2}") - list(LENGTH VulkanHeaderVersion2 _len) - # Versions >= 1.2.175 have an additional numbers in front of e.g. '0, 1, 2' instead of '1, 2' - if(_len EQUAL 3) - list(REMOVE_AT VulkanHeaderVersion2 0) + file(STRINGS ${VULKAN_CORE_H} VULKAN_HEADER_VERSION_LINE REGEX "^#define VK_HEADER_VERSION ") + string(REGEX MATCHALL "[0-9]+" VULKAN_HEADER_VERSION "${VULKAN_HEADER_VERSION_LINE}") + file(STRINGS ${VULKAN_CORE_H} VULKAN_HEADER_VERSION_LINE2 REGEX "^#define VK_HEADER_VERSION_COMPLETE ") + if(${VULKAN_HEADER_VERSION_LINE2}) + string(REGEX MATCHALL "[0-9]+" VULKAN_HEADER_VERSION2 "${VULKAN_HEADER_VERSION_LINE2}") + list(LENGTH VULKAN_HEADER_VERSION2 _len) + # Versions >= 1.2.175 have an additional numbers in front of e.g. '0, 1, 2' instead of '1, 2' + if(_len EQUAL 3) + list(REMOVE_AT VULKAN_HEADER_VERSION2 0) + endif() + list(APPEND VULKAN_HEADER_VERSION2 ${VULKAN_HEADER_VERSION}) + list(JOIN VULKAN_HEADER_VERSION2 "." VULKAN_HEADER_VERSION) + else() + file(STRINGS ${VULKAN_CORE_H} VULKAN_HEADER_API_VERSION_1_2 REGEX "^#define VK_API_VERSION_1_2.*") + if(NOT ${VULKAN_HEADER_API_VERSION_1_2} STREQUAL "") + set(VULKAN_HEADER_VERSION "1.2.${VULKAN_HEADER_VERSION}") + else() + file(STRINGS ${VULKAN_CORE_H} VULKAN_HEADER_API_VERSION_1_1 REGEX "^#define VK_API_VERSION_1_1.*") + if(NOT ${VULKAN_HEADER_API_VERSION_1_1} STREQUAL "") + set(VULKAN_HEADER_VERSION "1.1.${VULKAN_HEADER_VERSION}") + else() + message(FATAL_ERROR "'${VULKAN_CORE_H}' does not contain a supported Vulkan version. Probably because its < 1.2.0.") + endif() + endif() endif() - list(APPEND VulkanHeaderVersion2 ${VulkanHeaderVersion}) - list(JOIN VulkanHeaderVersion2 "." VULKAN_HEADER_VERSION) else() message(FATAL_ERROR "'${VULKAN_CORE_H}' does not exist. Try calling 'find_package(Vulkan REQUIRED)' before you call this function or set 'Vulkan_INCLUDE_DIR' manually!") return() @@ -47,22 +61,22 @@ function(check_vulkan_version) # Compare driver and header version if(${VULKAN_DRIVER_VERSION} VERSION_LESS ${VULKAN_HEADER_VERSION}) - # Version missmatch. Let us check if the major version is the same. + # Version missmatch. Let us check if the minor version is the same. if(${VULKAN_DRIVER_VERSION} MATCHES "[0-9]+.([0-9]+).[0-9]+") - set(VULKAN_DRIVER_MAJOR_VERSION ${CMAKE_MATCH_1}) + set(VULKAN_DRIVER_MINOR_VERSION ${CMAKE_MATCH_1}) else() message(FATAL_ERROR "Invalid Vulkan driver version '${VULKAN_DRIVER_VERSION}' found. Expected version in the following format: '[0-9]+.[0-9]+.[0-9]+'") endif() if(${VULKAN_HEADER_VERSION} MATCHES "[0-9]+.([0-9]+).[0-9]+") - set(VULKAN_HEADER_MAJOR_VERSION ${CMAKE_MATCH_1}) + set(VULKAN_HEADER_MINOR_VERSION ${CMAKE_MATCH_1}) else() - message(FATAL_ERROR "Invalid Vulkan-Header version '${VULKAN_HEADER_VERSION}' found. Expected version in the following format: '[0-9]+.[0-9]+.[0-9]+'") + message(FATAL_ERROR "Invalid Vulkan Header version '${VULKAN_HEADER_VERSION}' found. Expected version in the following format: '[0-9]+.[0-9]+.[0-9]+'") endif() - if(${VULKAN_DRIVER_MAJOR_VERSION} EQUAL ${VULKAN_HEADER_MAJOR_VERSION}) - message(WARNING "Your GPU driver does not support Vulkan > ${VULKAN_DRIVER_VERSION}, but you try to use Vulkan-Header ${VULKAN_HEADER_VERSION}. At least your driver supports the same major version (${VULKAN_DRIVER_MAJOR_VERSION}), so this should be fine but keep it in mind if encounter some strange behavior.") + if(${VULKAN_DRIVER_MINOR_VERSION} EQUAL ${VULKAN_HEADER_MINOR_VERSION}) + message(WARNING "Your GPU driver does not support Vulkan > ${VULKAN_DRIVER_VERSION}, but you try to use Vulkan Header ${VULKAN_HEADER_VERSION}. At least your driver supports the same minor version (${VULKAN_DRIVER_MINOR_VERSION}), so this should be fine but keep it in mind if encounter some strange behavior.") else() - message(FATAL_ERROR "Your GPU driver does not support Vulkan > ${VULKAN_DRIVER_VERSION}, but you try to use Vulkan-Header ${VULKAN_HEADER_VERSION}.") + message(FATAL_ERROR "Your GPU driver does not support Vulkan > ${VULKAN_DRIVER_VERSION}, but you try to use Vulkan Header ${VULKAN_HEADER_VERSION}.") endif() else() message(STATUS "Vulkan version check successful!") From c4552bf5f1c90951e6e911ccf8b5134cb3901e62 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Tue, 10 May 2022 18:08:16 +0200 Subject: [PATCH 009/107] Added an option to specify the Vulkan header git tag Signed-off-by: Fabian Sauter --- CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4fbb5b45e..b018d3698 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,14 +23,15 @@ option(KOMPUTE_OPT_ANDROID_BUILD "Enable android compilation flags required" OFF option(KOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS "Explicitly disable debug layers even on debug" OFF) option(KOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS "Whether to use shared libraries for dependencies for install" OFF) option(KOMPUTE_OPT_BUILD_AS_SHARED_LIB "Whether to build kompute as shared library" OFF) -option(KOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK "Whether to check if your driver supports the Vulkan-Header version you are linking against." OFF) +option(KOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK "Whether to check if your driver supports the Vulkan Header version you are linking against. This might be useful in case you build shared on a different system than you run later." OFF) # External komponents option(KOMPUTE_OPT_USE_BUILD_IN_SPDLOG "Use the build in version of Spdlog" ON) option(KOMPUTE_OPT_USE_BUILD_IN_FMT "Use the build in version of fmt" ON) option(KOMPUTE_OPT_USE_BUILD_IN_GOOGLE_TEST "Use the build in version of GoogleTest" ON) option(KOMPUTE_OPT_USE_BUILD_IN_PYBIND11 "Use the build in version of pybind11" ON) -option(KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER "Use the build in version of Vulkan-Headers. This could be helpful in case your system Vulkan-Headers are to new for your driver. If you set this to false, please make sure your system Vulkan-Header are supported by your driver." ON) +option(KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER "Use the build in version of Vulkan Headers. This could be helpful in case your system Vulkan Headers are to new for your driver. If you set this to false, please make sure your system Vulkan Header are supported by your driver." ON) +set(KOMPUTE_OPT_BUILD_IN_VULKAN_HEADER_TAG "v1.2.203" CACHE STRING "The git tag used for the build in Vulkan Headers when 'KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER' is enabled. A list of tags can be found here: https://github.com/KhronosGroup/Vulkan-Headers/tags") # Build flags set(KOMPUTE_EXTRA_CXX_FLAGS "" CACHE STRING "Extra compile flags for Kompute, see docs for full list") @@ -56,7 +57,7 @@ if(NOT KOMPUTE_OPT_ANDROID_BUILD) endif() if(KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER) FetchContent_Declare(vulkan_header GIT_REPOSITORY https://github.com/KhronosGroup/Vulkan-Headers.git - GIT_TAG v1.2.203) # Source: https://github.com/KhronosGroup/Vulkan-Headers/tags + GIT_TAG ${KOMPUTE_OPT_BUILD_IN_VULKAN_HEADER_TAG}) # Source: https://github.com/KhronosGroup/Vulkan-Headers/tags FetchContent_MakeAvailable(vulkan_header) if(NOT KOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK) From 662174bc1ba42ccf703544c19320f24d8622acc0 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Wed, 11 May 2022 13:25:11 +0200 Subject: [PATCH 010/107] More CI runs Signed-off-by: Fabian Sauter --- .github/workflows/cpp_tests.yml | 105 +++++++++++++++++++++++++------- 1 file changed, 84 insertions(+), 21 deletions(-) diff --git a/.github/workflows/cpp_tests.yml b/.github/workflows/cpp_tests.yml index 2a564796a..7b714bf3c 100644 --- a/.github/workflows/cpp_tests.yml +++ b/.github/workflows/cpp_tests.yml @@ -7,27 +7,90 @@ on: branches: [ master ] jobs: - cpp-tests: - - runs-on: ubuntu-18.04 + cpp-tests-debug-with-debug-layers: + runs-on: ubuntu-latest container: axsauze/kompute-builder:0.3 - steps: - - uses: actions/checkout@v2 + - name: Checkout + uses: actions/checkout@v3 with: - submodules: recursive - - name: configure-cpp - run: | - cmake -Bbuild/ \ - -DCMAKE_BUILD_TYPE=Debug \ - -DKOMPUTE_OPT_INSTALL=0 \ - -DKOMPUTE_OPT_REPO_SUBMODULE_BUILD=1 \ - -DKOMPUTE_OPT_BUILD_TESTS=1 \ - -DKOMPUTE_OPT_ENABLE_SPDLOG=1 - - name: build-cpp - run: | - make mk_build_tests - - name: test-cpp - run: | - export VK_ICD_FILENAMES=/swiftshader/vk_swiftshader_icd.json - make mk_run_tests + submodules: false + - name: "[Release g++] Build & Test" + env: + VK_ICD_FILENAMES: "/swiftshader/vk_swiftshader_icd.json" + uses: ashutoshvarma/action-cmake-build@master + with: + build-dir: ${{github.workspace}}/build + source-dir: ${{github.workspace}} + cc: gcc + cxx: g++ + build-type: Debug + run-test: true + ctest-options: -V + configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=OFF -DKOMPUTE_OPT_ENABLE_SPDLOG=1 + + cpp-tests-release-with-debug-layers: + runs-on: ubuntu-latest + container: axsauze/kompute-builder:0.3 + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: false + - name: "[Release g++] Build & Test" + env: + VK_ICD_FILENAMES: "/swiftshader/vk_swiftshader_icd.json" + uses: ashutoshvarma/action-cmake-build@master + with: + build-dir: ${{github.workspace}}/build + source-dir: ${{github.workspace}} + cc: gcc + cxx: g++ + build-type: Release + run-test: true + ctest-options: -V + configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=OFF -DKOMPUTE_OPT_ENABLE_SPDLOG=1 + + cpp-tests-debug-without-debug-layers: + runs-on: ubuntu-latest + container: axsauze/kompute-builder:0.3 + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: false + - name: "[Release g++] Build & Test" + env: + VK_ICD_FILENAMES: "/swiftshader/vk_swiftshader_icd.json" + uses: ashutoshvarma/action-cmake-build@master + with: + build-dir: ${{github.workspace}}/build + source-dir: ${{github.workspace}} + cc: gcc + cxx: g++ + build-type: Debug + run-test: true + ctest-options: -V + configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=ON -DKOMPUTE_OPT_ENABLE_SPDLOG=1 + + cpp-tests-release-without-debug-layers: + runs-on: ubuntu-latest + container: axsauze/kompute-builder:0.3 + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: false + - name: "[Release g++] Build & Test" + env: + VK_ICD_FILENAMES: "/swiftshader/vk_swiftshader_icd.json" + uses: ashutoshvarma/action-cmake-build@master + with: + build-dir: ${{github.workspace}}/build + source-dir: ${{github.workspace}} + cc: gcc + cxx: g++ + build-type: Release + run-test: true + ctest-options: -V + configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=ON -DKOMPUTE_OPT_ENABLE_SPDLOG=1 From 07c1ea9e3fcbbb87c5cf2cc8c8ce0825064df2d0 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Wed, 11 May 2022 13:26:58 +0200 Subject: [PATCH 011/107] Fixed cpp ci indentation Signed-off-by: Fabian Sauter --- .github/workflows/cpp_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cpp_tests.yml b/.github/workflows/cpp_tests.yml index 7b714bf3c..5c3faf5a1 100644 --- a/.github/workflows/cpp_tests.yml +++ b/.github/workflows/cpp_tests.yml @@ -51,7 +51,7 @@ jobs: ctest-options: -V configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=OFF -DKOMPUTE_OPT_ENABLE_SPDLOG=1 - cpp-tests-debug-without-debug-layers: + cpp-tests-debug-without-debug-layers: runs-on: ubuntu-latest container: axsauze/kompute-builder:0.3 steps: From 79a2978eaf9798e986897d40ddcf5caafbaeb749 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Wed, 11 May 2022 13:52:16 +0200 Subject: [PATCH 012/107] Updated CMake flags docs Signed-off-by: Fabian Sauter --- Makefile | 2 - docs/overview/build-system.rst | 53 +++++++++++-------- .../android/android-simple/app/build.gradle | 1 - examples/array_multiplication/README.md | 1 - examples/logistic_regression/README.md | 1 - setup.py | 1 - 6 files changed, 32 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index 7e28ea46b..f7093b59c 100644 --- a/Makefile +++ b/Makefile @@ -60,7 +60,6 @@ mk_cmake: -DCMAKE_BUILD_TYPE=$(MK_BUILD_TYPE) \ -DCMAKE_INSTALL_PREFIX=$(MK_INSTALL_PATH) \ -DKOMPUTE_OPT_INSTALL=1 \ - -DKOMPUTE_OPT_REPO_SUBMODULE_BUILD=1 \ -DKOMPUTE_OPT_BUILD_TESTS=1 \ -DKOMPUTE_OPT_BUILD_DOCS=1 \ -DKOMPUTE_OPT_BUILD_SHADERS=1 \ @@ -115,7 +114,6 @@ vs_cmake: -DKOMPUTE_EXTRA_CXX_FLAGS=$(VS_KOMPUTE_EXTRA_CXX_FLAGS) \ -DCMAKE_INSTALL_PREFIX=$(VS_INSTALL_PATH) \ -DKOMPUTE_OPT_INSTALL=1 \ - -DKOMPUTE_OPT_REPO_SUBMODULE_BUILD=1 \ -DKOMPUTE_OPT_BUILD_TESTS=1 \ -DKOMPUTE_OPT_BUILD_SHADERS=1 \ -DKOMPUTE_OPT_BUILD_SINGLE_HEADER=1 \ diff --git a/docs/overview/build-system.rst b/docs/overview/build-system.rst index ddb84ebda..d6c264d22 100644 --- a/docs/overview/build-system.rst +++ b/docs/overview/build-system.rst @@ -21,36 +21,47 @@ This by default configures without any of the extra build tasks (such as buildin - Enables local installation (which won't require admin privileges) * - -DCMAKE_TOOLCHAIN_FILE="..." - This is the path for your package manager if you use it such as vcpkg - * - -DKOMPUTE_OPT_BUILD_TESTS=1 + * - -DKOMPUTE_OPT_BUILD_TESTS=ON - Enable if you wish to build and run the tests (must have deps installed. - * - -DKOMPUTE_OPT_CODE_COVERAGE=1 + * - -DKOMPUTE_OPT_CODE_COVERAGE=ON - Enable if you wish to build and run code coverage (must have deps installed which are limited to Windows platform) - * - -DKOMPUTE_OPT_BUILD_DOCS=1 + * - -DKOMPUTE_OPT_BUILD_DOCS=ON - Enable if you wish to build the docs (must have docs deps installed) - * - -DKOMPUTE_OPT_BUILD_SHADERS=1 + * - -DKOMPUTE_OPT_BUILD_SHADERS=ON - Enable if you wish to build the shaders into header files (must have docs deps installed) - * - -DKOMPUTE_OPT_BUILD_SINGLE_HEADER=1 + * - -DKOMPUTE_OPT_BUILD_SINGLE_HEADER=ON - Option to build the single header file using "quom" utility - * - -DKOMPUTE_OPT_INSTALL=0 + * - -DKOMPUTE_OPT_INSTALL=OFF - Disables the install step in the cmake file (useful for android build) - * - -DKOMPUTE_OPT_BUILD_PYTHON=1 + * - -DKOMPUTE_OPT_BUILD_PYTHON=ON - Enable to build python bindings (used internally for python package) - * - -DKOMPUTE_OPT_ENABLE_SPDLOG=1 + * - -DKOMPUTE_OPT_ENABLE_SPDLOG=ON - Enable to compile with spdlog as the internal logging framework - * - -DKOMPUTE_OPT_REPO_SUBMODULE_BUILD=1 - - Use the submodule repos instead of external packages / manager - * - -DKOMPUTE_OPT_ANDROID_BUILD=1 + * - -DKOMPUTE_OPT_USE_BUILD_IN_SPDLOG=ON + - Use the build in version of Spdlog + * - -KOMPUTE_OPT_USE_BUILD_IN_FMT=ON + - Use the build in version of fmt + * - -KOMPUTE_OPT_USE_BUILD_IN_GOOGLE_TEST=ON + - Use the build in version of GoogleTest + * - -KOMPUTE_OPT_USE_BUILD_IN_PYBIND11=ON + - Use the build in version of pybind11 + * - -KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER=ON + - Use the build in version of Vulkan Headers. This could be helpful in case your system Vulkan Headers are to new for your driver. If you set this to false, please make sure your system Vulkan Header are supported by your driver. + * - -KOMPUTE_OPT_BUILD_IN_VULKAN_HEADER_TAG="v1.2.203" + - The git tag used for the build in Vulkan Headers when 'KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER' is enabled. A list of tags can be found here: https://github.com/KhronosGroup/Vulkan-Headers/tags + * - -KOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=OFF + - Whether to check if your driver supports the Vulkan Header version you are linking against. This might be useful in case you build shared on a different system than you run later. + * - -DKOMPUTE_OPT_ANDROID_BUILD=ON - Enables android build which includes and excludes relevant libraries - * - -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=1 + * - -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=ON - Explicitly disables debug layers even when on debug mode - * - -DKOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS=1 + * - -DKOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS=ON - Ensures dependencies are referenced as shared libraries for kompute install - * - -DKOMPUTE_OPT_BUILD_AS_SHARED_LIB=1 + * - -DKOMPUTE_OPT_BUILD_AS_SHARED_LIB=ON - Whether to build Kompute as shared lib instead of static * - -DKOMPUTE_EXTRA_CXX_FLAGS="..." - Allows you to pass extra config flags to compiler - Compile Flags ~~~~~~~~~~~~~ @@ -63,21 +74,21 @@ Compile Flags - Ensure the return value of createPipeline is processed as ResultValue instead of Result * - -DKOMPUTE_VK_API_VERSION="..." - Sets the default api version to use for kompute api - * - -DKOMPUTE_VK_API_MAJOR_VERSION=1 + * - -DKOMPUTE_VK_API_MAJOR_VERSION=ON - Major version to use for the Vulkan SDK - * - -DKOMPUTE_VK_API_MINOR_VERSION=1 + * - -DKOMPUTE_VK_API_MINOR_VERSION=ON - Minor version to use for the Vulkan SDK - * - -DKOMPUTE_ENABLE_SPDLOG=1 + * - -DKOMPUTE_ENABLE_SPDLOG=ON - Enables the build with SPDLOG and FMT dependencies (must be installed) - * - -DKOMPUTE_LOG_OVERRIDE=1 + * - -DKOMPUTE_LOG_OVERRIDE=ON - Does not define the SPDLOG_\ :raw-html-m2r:`` macros if these are to be overridden * - -DKOMPUTE_LOG_LEVEL - The level for the log level on compile level (also sets spdlog level if enabled) * - -DVVK_USE_PLATFORM_ANDROID_KHR - Flag to enable android imports in kompute (enabled with -DKOMPUTE_OPT_ANDROID_BUILD) - * - -DRELEASE=1 + * - -DRELEASE=ON - Enable release build (enabled by cmake release build) - * - -DDEBUG=1 + * - -DDEBUG=ON - Enable debug build including debug flags (enabled by cmake debug build) * - -DKOMPUTE_DISABLE_VK_DEBUG_LAYERS - Disable the debug Vulkan SDK Layers, mainly used for android builds diff --git a/examples/android/android-simple/app/build.gradle b/examples/android/android-simple/app/build.gradle index 146bb4163..aef4b49b1 100644 --- a/examples/android/android-simple/app/build.gradle +++ b/examples/android/android-simple/app/build.gradle @@ -18,7 +18,6 @@ android { arguments '-DANDROID_TOOLCHAIN=clang', '-DANDROID_STL=c++_static', '-DKOMPUTE_OPT_ANDROID_BUILD=1', - '-DKOMPUTE_OPT_REPO_SUBMODULE_BUILD=1', '-DKOMPUTE_OPT_INSTALL=0', '-DKOMPUTE_OPT_ENABLE_SPDLOG=0', '-DKOMPUTE_OPT_BUILD_SINGLE_HEADER=0', diff --git a/examples/array_multiplication/README.md b/examples/array_multiplication/README.md index c783e133c..bc6de129c 100644 --- a/examples/array_multiplication/README.md +++ b/examples/array_multiplication/README.md @@ -18,7 +18,6 @@ To build you just need to run the cmake command in this folder as follows: cmake -Bbuild/ \ -DCMAKE_BUILD_TYPE=Debug \ -DKOMPUTE_OPT_INSTALL=0 \ - -DKOMPUTE_OPT_REPO_SUBMODULE_BUILD=1 \ -DKOMPUTE_OPT_ENABLE_SPDLOG=1 ``` diff --git a/examples/logistic_regression/README.md b/examples/logistic_regression/README.md index 9f21968ff..f6be72e60 100644 --- a/examples/logistic_regression/README.md +++ b/examples/logistic_regression/README.md @@ -18,7 +18,6 @@ To build you just need to run the cmake command in this folder as follows: cmake -Bbuild/ \ -DCMAKE_BUILD_TYPE=Debug \ -DKOMPUTE_OPT_INSTALL=0 \ - -DKOMPUTE_OPT_REPO_SUBMODULE_BUILD=1 \ -DKOMPUTE_OPT_ENABLE_SPDLOG=1 ``` diff --git a/setup.py b/setup.py index e6feb9ab8..c0d5d6d3d 100644 --- a/setup.py +++ b/setup.py @@ -43,7 +43,6 @@ class CMakeBuild(build_ext): cmake_args = ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + extdir, '-DKOMPUTE_OPT_BUILD_PYTHON=1', '-DKOMPUTE_OPT_ENABLE_SPDLOG=0', - '-DKOMPUTE_OPT_REPO_SUBMODULE_BUILD=1', '-DPYTHON_EXECUTABLE=' + sys.executable, '-DPYTHON_INCLUDE_DIR=' + sysconfig.get_path('include'), '-DPYTHON_LIBRARY=' + sysconfig.get_path('stdlib'), From 280f983a97d690b14485b00010a4a6751f0a17f5 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Wed, 11 May 2022 13:55:20 +0200 Subject: [PATCH 013/107] Printing vulkaninfo in CI Signed-off-by: Fabian Sauter --- .github/workflows/cpp_tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/cpp_tests.yml b/.github/workflows/cpp_tests.yml index 5c3faf5a1..b83247e49 100644 --- a/.github/workflows/cpp_tests.yml +++ b/.github/workflows/cpp_tests.yml @@ -11,6 +11,8 @@ jobs: runs-on: ubuntu-latest container: axsauze/kompute-builder:0.3 steps: + - name: Print vulkaninfo + run: vulkaninfo - name: Checkout uses: actions/checkout@v3 with: From b9e2ae15eea23be52373669d1aaafb83e89292e5 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Wed, 11 May 2022 14:02:45 +0200 Subject: [PATCH 014/107] Installing vulkaninfo in the CI Signed-off-by: Fabian Sauter --- .github/workflows/cpp_tests.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cpp_tests.yml b/.github/workflows/cpp_tests.yml index b83247e49..fcc7f60d3 100644 --- a/.github/workflows/cpp_tests.yml +++ b/.github/workflows/cpp_tests.yml @@ -11,8 +11,8 @@ jobs: runs-on: ubuntu-latest container: axsauze/kompute-builder:0.3 steps: - - name: Print vulkaninfo - run: vulkaninfo + - name: Install vulkaninfo + run: apt update -y && apt install -y vulkan-tools - name: Checkout uses: actions/checkout@v3 with: @@ -35,6 +35,8 @@ jobs: runs-on: ubuntu-latest container: axsauze/kompute-builder:0.3 steps: + - name: Install vulkaninfo + run: apt update -y && apt install -y vulkan-tools - name: Checkout uses: actions/checkout@v3 with: @@ -57,6 +59,8 @@ jobs: runs-on: ubuntu-latest container: axsauze/kompute-builder:0.3 steps: + - name: Install vulkaninfo + run: apt update -y && apt install -y vulkan-tools - name: Checkout uses: actions/checkout@v3 with: @@ -79,6 +83,8 @@ jobs: runs-on: ubuntu-latest container: axsauze/kompute-builder:0.3 steps: + - name: Install vulkaninfo + run: apt update -y && apt install -y vulkan-tools - name: Checkout uses: actions/checkout@v3 with: From 49780c235db061dba09c0352e7abf270a8d09d42 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Wed, 11 May 2022 14:07:46 +0200 Subject: [PATCH 015/107] Ensuring vulkaninfo is installed Signed-off-by: Fabian Sauter --- cmake/check_vulkan_version.cmake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmake/check_vulkan_version.cmake b/cmake/check_vulkan_version.cmake index 66e59dc6e..88d2456f6 100644 --- a/cmake/check_vulkan_version.cmake +++ b/cmake/check_vulkan_version.cmake @@ -50,7 +50,12 @@ function(check_vulkan_version) endif() execute_process(COMMAND "vulkaninfo" - OUTPUT_VARIABLE VULKAN_INFO_OUTPUT) + OUTPUT_VARIABLE VULKAN_INFO_OUTPUT + RESULT_VARIABLE VULKAN_INFO_RETURN) + if(NOT ${VULKAN_INFO_RETURN} EQUAL 0) + message(FATAL_ERROR "Running vulkaninfo failed with return code ${VULKAN_INFO_RETURN}. Make sure you have 'vulkan-tools' installed. Result:\n${VULKAN_INFO_OUTPUT}?") + return() + endif() if(${VULKAN_INFO_OUTPUT} MATCHES ".*Vulkan version ([0-9]+.[0-9]+.[0-9]+).*") set(VULKAN_DRIVER_VERSION ${CMAKE_MATCH_1}) message(STATUS "vulkaninfo reported supported version ${VULKAN_DRIVER_VERSION}") From c6a2b022f9d975685ccb442d080e8147110fb1ba Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Wed, 11 May 2022 16:11:51 +0200 Subject: [PATCH 016/107] Improved vulkan version regex parsing Signed-off-by: Fabian Sauter --- cmake/check_vulkan_version.cmake | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cmake/check_vulkan_version.cmake b/cmake/check_vulkan_version.cmake index 88d2456f6..b0902b5f0 100644 --- a/cmake/check_vulkan_version.cmake +++ b/cmake/check_vulkan_version.cmake @@ -1,3 +1,4 @@ +# Current issue: Only checks the result of GPU0 function(check_vulkan_version) cmake_parse_arguments(VULKAN_CHECK_VERSION "" "INCLUDE_DIR" "" ${ARGN}) message(STATUS "Ensuring the currently installed driver supports the Vulkan version requested by the Vulkan Header.") @@ -49,14 +50,14 @@ function(check_vulkan_version) return() endif() - execute_process(COMMAND "vulkaninfo" + execute_process(COMMAND "vulkaninfo" "--summary" OUTPUT_VARIABLE VULKAN_INFO_OUTPUT RESULT_VARIABLE VULKAN_INFO_RETURN) if(NOT ${VULKAN_INFO_RETURN} EQUAL 0) message(FATAL_ERROR "Running vulkaninfo failed with return code ${VULKAN_INFO_RETURN}. Make sure you have 'vulkan-tools' installed. Result:\n${VULKAN_INFO_OUTPUT}?") return() endif() - if(${VULKAN_INFO_OUTPUT} MATCHES ".*Vulkan version ([0-9]+.[0-9]+.[0-9]+).*") + if(${VULKAN_INFO_OUTPUT} MATCHES "apiVersion[ ]+=[ ]+[0-9]+[ ]+[(]([0-9]+[.][0-9]+[.][0-9]+)[)]") set(VULKAN_DRIVER_VERSION ${CMAKE_MATCH_1}) message(STATUS "vulkaninfo reported supported version ${VULKAN_DRIVER_VERSION}") else() @@ -67,12 +68,12 @@ function(check_vulkan_version) # Compare driver and header version if(${VULKAN_DRIVER_VERSION} VERSION_LESS ${VULKAN_HEADER_VERSION}) # Version missmatch. Let us check if the minor version is the same. - if(${VULKAN_DRIVER_VERSION} MATCHES "[0-9]+.([0-9]+).[0-9]+") + if(${VULKAN_DRIVER_VERSION} MATCHES "[0-9]+[.]([0-9]+)[.][0-9]+") set(VULKAN_DRIVER_MINOR_VERSION ${CMAKE_MATCH_1}) else() message(FATAL_ERROR "Invalid Vulkan driver version '${VULKAN_DRIVER_VERSION}' found. Expected version in the following format: '[0-9]+.[0-9]+.[0-9]+'") endif() - if(${VULKAN_HEADER_VERSION} MATCHES "[0-9]+.([0-9]+).[0-9]+") + if(${VULKAN_HEADER_VERSION} MATCHES "[0-9]+[.]([0-9]+)[.][0-9]+") set(VULKAN_HEADER_MINOR_VERSION ${CMAKE_MATCH_1}) else() message(FATAL_ERROR "Invalid Vulkan Header version '${VULKAN_HEADER_VERSION}' found. Expected version in the following format: '[0-9]+.[0-9]+.[0-9]+'") From b95df8d0a0dde37dedef943cca0c95814d8ba828 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Wed, 18 May 2022 21:10:21 +0200 Subject: [PATCH 017/107] First pass for rewriting the build system * Refactored all CMake files * Started working on compiling shaders to header files in CMake Signed-off-by: Fabian Sauter --- CMakeLists.txt | 169 +- Makefile | 4 +- cmake/bin2h.cmake | 98 + cmake/bin_file_to_header.cmake | 19 + cmake/code_coverage.cmake | 34 + cmake/deprecation_warnings.cmake | 3 + cmake/komputeConfig.cmake.in | 8 + cmake/vulkan_shader_compiler.cmake | 36 + docs/overview/build-system.rst | 2 - .../android/android-simple/app/build.gradle | 1 - kompute-config.cmake | 28 + single_include/AggregateHeaders.cpp | 15 - single_include/kompute/Kompute.hpp | 2432 ----------------- src/CMakeLists.txt | 173 +- src/include/CMakeLists.txt | 27 + src/include/kompute/Kompute.hpp | 18 + test/CMakeLists.txt | 103 +- test/TestAsyncOperations.cpp | 2 - test/TestDestroy.cpp | 2 +- test/TestLogisticRegression.cpp | 13 +- test/TestMultipleAlgoExecutions.cpp | 2 +- test/TestOpShadersFromStringAndFile.cpp | 2 +- test/TestOpTensorCopy.cpp | 2 +- test/TestPushConstant.cpp | 2 +- test/TestSequence.cpp | 2 +- test/TestSpecializationConstant.cpp | 2 +- test/shaders/CMakeLists.txt | 8 + .../Shader.hpp => shaders/Utils.cpp} | 23 +- test/shaders/Utils.hpp | 19 + test/shaders/glsl/CMakeLists.txt | 22 + .../glsl/test_logistic_regression.comp.spv | Bin 4816 -> 0 bytes .../glsl/test_op_custom_shader.comp.spv | Bin 1096 -> 0 bytes test/shaders/glsl/test_workgroup.comp.spv | Bin 1396 -> 0 bytes 33 files changed, 559 insertions(+), 2712 deletions(-) create mode 100644 cmake/bin2h.cmake create mode 100644 cmake/bin_file_to_header.cmake create mode 100644 cmake/code_coverage.cmake create mode 100644 cmake/deprecation_warnings.cmake create mode 100644 cmake/komputeConfig.cmake.in create mode 100644 cmake/vulkan_shader_compiler.cmake create mode 100644 kompute-config.cmake delete mode 100644 single_include/AggregateHeaders.cpp create mode 100644 src/include/CMakeLists.txt create mode 100644 src/include/kompute/Kompute.hpp create mode 100644 test/shaders/CMakeLists.txt rename test/{utils/kompute_test/Shader.hpp => shaders/Utils.cpp} (51%) create mode 100644 test/shaders/Utils.hpp create mode 100644 test/shaders/glsl/CMakeLists.txt delete mode 100755 test/shaders/glsl/test_logistic_regression.comp.spv delete mode 100755 test/shaders/glsl/test_op_custom_shader.comp.spv delete mode 100755 test/shaders/glsl/test_workgroup.comp.spv diff --git a/CMakeLists.txt b/CMakeLists.txt index b018d3698..e6ce10cc3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,51 +1,103 @@ # SPDX-License-Identifier: Apache-2.0 -cmake_minimum_required(VERSION 3.4.1) -project(kompute VERSION 0.8.1) +cmake_minimum_required(VERSION 3.15) +project(kompute VERSION 1.8.1 LANGUAGES CXX) set(CMAKE_CXX_STANDARD 14) -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -set(CMAKE_VERBOSE_MAKEFILE on) +# Only change the folder behaviour if kompute is not a subproject +if(${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME}) + set_property(GLOBAL PROPERTY USE_FOLDERS ON) + set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMake") + set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin) + set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib) +endif() +# Avoid the dll boilerplate code for windows +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}") + +set(KOMPUTE_LIBRARIES kompute CACHE INTERNAL "") + +##################################################### +# Options +##################################################### + +macro(kompute_option OPTION_NAME OPTION_TEXT OPTION_DEFAULT) + option(${OPTION_NAME} ${OPTION_TEXT} ${OPTION_DEFAULT}) + if(DEFINED ENV{${OPTION_NAME}}) + # Allow overriding the option through an environment variable + set(${OPTION_NAME} $ENV{${OPTION_NAME}}) + endif() + if(${OPTION_NAME}) + add_definitions(-D${OPTION_NAME}) + endif() + message(STATUS " ${OPTION_NAME}: ${${OPTION_NAME}}") +endmacro() + +macro(kompute_log_level OPTION_NAME OPTION_TEXT OPTION_DEFAULT) + set(${OPTION_NAME} ${OPTION_DEFAULT} CACHE STRING ${OPTION_TEXT}) + set_property(CACHE ${OPTION_NAME} PROPERTY STRINGS "Trace" "Debug" "Info" "Warn" "Error" "Critical") + if(DEFINED ENV{${OPTION_NAME}}) + # Allow setting the option through an environment variable + set(${OPTION_NAME} $ENV{${OPTION_NAME}}) + endif() + if(${OPTION_NAME}) + add_definitions(-D${OPTION_NAME}) + endif() + message(STATUS " ${OPTION_NAME}: ${${OPTION_NAME}}") +endmacro() + +macro(kompute_option_string OPTION_NAME OPTION_TEXT OPTION_DEFAULT) + set(${OPTION_NAME} ${OPTION_DEFAULT} CACHE STRING ${OPTION_TEXT}) + if(DEFINED ENV{${OPTION_NAME}}) + # Allow setting the option through an environment variable + set(${OPTION_NAME} $ENV{${OPTION_NAME}}) + endif() + if(${OPTION_NAME}) + add_definitions(-D${OPTION_NAME}) + endif() + message(STATUS " ${OPTION_NAME}: ${${OPTION_NAME}}") +endmacro() + +option(BUILD_SHARED_LIBS "Build libraries as shared libraries" ON) +message(STATUS "General purpose GPU compute framework built on Vulkan") +message(STATUS "=======================================================") # Enable or disable targets -option(KOMPUTE_OPT_BUILD_TESTS "Enable if you want to build tests" OFF) -option(KOMPUTE_OPT_CODE_COVERAGE "Enable if you want code coverage" OFF) -option(KOMPUTE_OPT_BUILD_DOCS "Enable if you want to build documentation" OFF) -option(KOMPUTE_OPT_BUILD_SHADERS "Enable if you want to re-build all shader files" OFF) -option(KOMPUTE_OPT_BUILD_SINGLE_HEADER "Enable if you want to build the single header file" OFF) -option(KOMPUTE_OPT_INSTALL "Enable if you want to enable installation" OFF) +kompute_option(KOMPUTE_OPT_BUILD_TESTS "Enable if you want to build tests" ON) +kompute_option(KOMPUTE_OPT_CODE_COVERAGE "Enable if you want code coverage" OFF) +kompute_option(KOMPUTE_OPT_BUILD_DOCS "Enable if you want to build documentation" OFF) +kompute_option(KOMPUTE_OPT_INSTALL "Enable if you want to enable installation" OFF) # Build options -option(KOMPUTE_OPT_BUILD_PYTHON "Enable if you want to build python bindings" OFF) -option(KOMPUTE_OPT_ENABLE_SPDLOG "Enable to compile with spdlog as the internal logging framework" OFF) -option(KOMPUTE_OPT_ANDROID_BUILD "Enable android compilation flags required" OFF) -option(KOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS "Explicitly disable debug layers even on debug" OFF) -option(KOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS "Whether to use shared libraries for dependencies for install" OFF) -option(KOMPUTE_OPT_BUILD_AS_SHARED_LIB "Whether to build kompute as shared library" OFF) -option(KOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK "Whether to check if your driver supports the Vulkan Header version you are linking against. This might be useful in case you build shared on a different system than you run later." OFF) +kompute_option(KOMPUTE_OPT_BUILD_PYTHON "Enable if you want to build python bindings" OFF) +kompute_option(KOMPUTE_OPT_ENABLE_LOGGING "Internally we use spdlog for logging. The log output can be either enabled or disabled." OFF) +kompute_log_level(KOMPUTE_OPT_LOG_LEVEL "Internally we use spdlog for logging. The log level used can be changed here." "Debug") +kompute_option(KOMPUTE_OPT_ANDROID_BUILD "Enable android compilation flags required" OFF) +kompute_option(KOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS "Explicitly disable debug layers even on debug" OFF) +kompute_option(KOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK "Whether to check if your driver supports the Vulkan Header version you are linking against. This might be useful in case you build shared on a different system than you run later." OFF) -# External komponents +# External components option(KOMPUTE_OPT_USE_BUILD_IN_SPDLOG "Use the build in version of Spdlog" ON) option(KOMPUTE_OPT_USE_BUILD_IN_FMT "Use the build in version of fmt" ON) option(KOMPUTE_OPT_USE_BUILD_IN_GOOGLE_TEST "Use the build in version of GoogleTest" ON) option(KOMPUTE_OPT_USE_BUILD_IN_PYBIND11 "Use the build in version of pybind11" ON) option(KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER "Use the build in version of Vulkan Headers. This could be helpful in case your system Vulkan Headers are to new for your driver. If you set this to false, please make sure your system Vulkan Header are supported by your driver." ON) -set(KOMPUTE_OPT_BUILD_IN_VULKAN_HEADER_TAG "v1.2.203" CACHE STRING "The git tag used for the build in Vulkan Headers when 'KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER' is enabled. A list of tags can be found here: https://github.com/KhronosGroup/Vulkan-Headers/tags") - -# Build flags -set(KOMPUTE_EXTRA_CXX_FLAGS "" CACHE STRING "Extra compile flags for Kompute, see docs for full list") +kompute_option_string(KOMPUTE_OPT_BUILD_IN_VULKAN_HEADER_TAG "The git tag used for the build in Vulkan Headers when 'KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER' is enabled. A list of tags can be found here: https://github.com/KhronosGroup/Vulkan-Headers/tags" "v1.2.203") +message(STATUS "=======================================================") ##################################################### -#################### Deprecated Options ############# +# Deprecated Options ##################################################### -if(KOMPUTE_OPT_REPO_SUBMODULE_BUILD) - message(FATAL_ERROR "'KOMPUTE_OPT_REPO_SUBMODULE_BUILD' got replaced by 'KOMPUTE_OPT_USE_BUILD_IN_SPDLOG', 'KOMPUTE_OPT_USE_BUILD_IN_FMT', 'KOMPUTE_OPT_USE_BUILD_IN_GOOGLE_TEST', 'KOMPUTE_OPT_USE_BUILD_IN_PYBIND11' and 'KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER'. Please use them instead.") -endif() +include(cmake/deprecation_warnings.cmake) ##################################################### -#################### Dependencies ################### +# Dependencies ##################################################### +include(cmake/vulkan_shader_compiler.cmake) include(FetchContent) include(cmake/check_vulkan_version.cmake) @@ -72,16 +124,18 @@ else() endif() # Spdlog -if(KOMPUTE_OPT_ENABLE_SPDLOG) - if(KOMPUTE_OPT_USE_BUILD_IN_SPDLOG) - set(SPDLOG_INSTALL ${KOMPUTE_OPT_INSTALL}) - set(SPDLOG_BUILD_SHARED ${KOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS}) +if(KOMPUTE_OPT_ENABLE_LOGGING) + if(KOMPUTE_OPT_ENABLE_SPDLOG) + if(KOMPUTE_OPT_USE_BUILD_IN_SPDLOG) + set(SPDLOG_INSTALL ${KOMPUTE_OPT_INSTALL}) + set(SPDLOG_BUILD_SHARED ${KOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS}) - FetchContent_Declare(spdlog GIT_REPOSITORY https://github.com/gabime/spdlog.git - GIT_TAG v1.10.0) # Source: https://github.com/gabime/spdlog/releases - FetchContent_MakeAvailable(spdlog) - else() - find_package(spdlog REQUIRED) + FetchContent_Declare(spdlog GIT_REPOSITORY https://github.com/gabime/spdlog.git + GIT_TAG v1.10.0) # Source: https://github.com/gabime/spdlog/releases + FetchContent_MakeAvailable(spdlog) + else() + find_package(spdlog REQUIRED) + endif() endif() endif() @@ -132,48 +186,43 @@ if(KOMPUTE_OPT_BUILD_PYTHON) endif() ##################################################### -#################### Other Options ################## +# Preprocessor Macros ##################################################### - if(KOMPUTE_OPT_ANDROID_BUILD) - set(KOMPUTE_EXTRA_CXX_FLAGS "${KOMPUTE_EXTRA_CXX_FLAGS} -DVK_USE_PLATFORM_ANDROID_KHR") + add_compile_definitions(VK_USE_PLATFORM_ANDROID_KHR=1) endif() if(KOMPUTE_OPT_BUILD_PYTHON) - set(KOMPUTE_EXTRA_CXX_FLAGS "${KOMPUTE_EXTRA_CXX_FLAGS} -DKOMPUTE_BUILD_PYTHON") + add_compile_definitions(KOMPUTE_BUILD_PYTHON=1) endif() if(KOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS) - set(KOMPUTE_EXTRA_CXX_FLAGS "${KOMPUTE_EXTRA_CXX_FLAGS} -DKOMPUTE_DISABLE_VK_DEBUG_LAYERS=1") + add_compile_definitions(KOMPUTE_DISABLE_VK_DEBUG_LAYERS=1) endif() +if(KOMPUTE_OPT_ENABLE_LOGGING) + add_compile_definitions(KOMPUTE_OPT_ENABLE_LOGGING=1) +endif() + +##################################################### +# Misc Options +##################################################### if(KOMPUTE_OPT_INSTALL) # Enable install parameters for glslang (overrides parameters passed) # When install is enabled the glslang libraries become shared set(ENABLE_GLSLANG_INSTALL ON CACHE BOOL "Enables install of glslang" FORCE) - - # By default we enable shared library based installation - if(KOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS) - set(BUILD_SHARED_LIBS ON CACHE BOOL "Enables build of shared libraries" FORCE) - endif() endif() -set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG=1 ${KOMPUTE_EXTRA_CXX_FLAGS} -DUSE_DEBUG_EXTENTIONS") -set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DRELEASE=1 ${KOMPUTE_EXTRA_CXX_FLAGS}") +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") +else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Werror") +endif() if(KOMPUTE_OPT_CODE_COVERAGE) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage --coverage") - - set(CODECOV_DIR - ${CMAKE_CURRENT_BINARY_DIR}/codecov/) - set(CODECOV_DIR_LCOV - ${CODECOV_DIR}lcov/) - set(CODECOV_FILENAME_LCOV_INFO - lcov.info) - set(CODECOV_FILENAME_LCOV_INFO_FULL - lcov_full.info) - set(CODECOV_DIR_HTML - ${CODECOV_DIR}html/) + if(NOT UNIX) + message(FATAL_ERROR "KOMPUTE_OPT_CODE_COVERAGE can only be enabled in unix based systems due to limitation on gcov.") + endif() + include(cmake/code_coverage.cmake) endif() # If glslang is cloned, then SPIRV/GlslangToSpv.h will be used instead of glslang/SPIRV/GlslangToSpv.h diff --git a/Makefile b/Makefile index f7093b59c..3142ebc10 100644 --- a/Makefile +++ b/Makefile @@ -63,7 +63,6 @@ mk_cmake: -DKOMPUTE_OPT_BUILD_TESTS=1 \ -DKOMPUTE_OPT_BUILD_DOCS=1 \ -DKOMPUTE_OPT_BUILD_SHADERS=1 \ - -DKOMPUTE_OPT_BUILD_SINGLE_HEADER=1 \ -DKOMPUTE_OPT_ENABLE_SPDLOG=1 \ -DKOMPUTE_OPT_CODE_COVERAGE=1 \ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ @@ -116,7 +115,6 @@ vs_cmake: -DKOMPUTE_OPT_INSTALL=1 \ -DKOMPUTE_OPT_BUILD_TESTS=1 \ -DKOMPUTE_OPT_BUILD_SHADERS=1 \ - -DKOMPUTE_OPT_BUILD_SINGLE_HEADER=1 \ -DKOMPUTE_OPT_ENABLE_SPDLOG=1 \ -DKOMPUTE_OPT_CODE_COVERAGE=0 \ -DKOMPUTE_OPT_BUILD_DOCS=0 \ @@ -161,7 +159,7 @@ run_ci: generate_python_docstrings: python -m pybind11_mkdoc \ -o python/src/docstrings.hpp \ - single_include/kompute/Kompute.hpp \ + kompute/Kompute.hpp \ -Iexternal/fmt/include/ \ -Iexternal/spdlog/include/ \ -Iexternal/glslang/ \ diff --git a/cmake/bin2h.cmake b/cmake/bin2h.cmake new file mode 100644 index 000000000..4243ca0ff --- /dev/null +++ b/cmake/bin2h.cmake @@ -0,0 +1,98 @@ +################################################################################## +# Based on: https://github.com/sivachandran/cmake-bin2h +# +# Copyright 2020 Sivachandran Paramasivam +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +################################################################################## + +include(CMakeParseArguments) + +# Function to wrap a given string into multiple lines at the given column position. +# Parameters: +# VARIABLE - The name of the CMake variable holding the string. +# AT_COLUMN - The column position at which string will be wrapped. +function(WRAP_STRING) + set(oneValueArgs VARIABLE AT_COLUMN) + cmake_parse_arguments(WRAP_STRING "${options}" "${oneValueArgs}" "" ${ARGN}) + + string(LENGTH ${${WRAP_STRING_VARIABLE}} stringLength) + math(EXPR offset "0") + + while(stringLength GREATER 0) + + if(stringLength GREATER ${WRAP_STRING_AT_COLUMN}) + math(EXPR length "${WRAP_STRING_AT_COLUMN}") + else() + math(EXPR length "${stringLength}") + endif() + + string(SUBSTRING ${${WRAP_STRING_VARIABLE}} ${offset} ${length} line) + set(lines "${lines}\n${line}") + + math(EXPR stringLength "${stringLength} - ${length}") + math(EXPR offset "${offset} + ${length}") + endwhile() + + set(${WRAP_STRING_VARIABLE} "${lines}" PARENT_SCOPE) +endfunction() + +# Function to embed contents of a file as byte array in C/C++ header file(.h). The header file +# will contain a byte array and integer variable holding the size of the array. +# Parameters +# SOURCE_FILE - The path of source file whose contents will be embedded in the header file. +# VARIABLE_NAME - The name of the variable for the byte array. The string "_SIZE" will be append +# to this name and will be used a variable name for size variable. +# HEADER_FILE - The path of header file. +# APPEND - If specified appends to the header file instead of overwriting it +# NULL_TERMINATE - If specified a null byte(zero) will be append to the byte array. This will be +# useful if the source file is a text file and we want to use the file contents +# as string. But the size variable holds size of the byte array without this +# null byte. +# HEADER_NAMESPACE - The namespace, where the array should be located in. +# Usage: +# bin2h(SOURCE_FILE "Logo.png" HEADER_FILE "Logo.h" VARIABLE_NAME "LOGO_PNG") +function(BIN2H) + set(options APPEND NULL_TERMINATE) + set(oneValueArgs SOURCE_FILE VARIABLE_NAME HEADER_FILE) + cmake_parse_arguments(BIN2H "${options}" "${oneValueArgs}" "" ${ARGN}) + + # reads source file contents as hex string + file(READ ${BIN2H_SOURCE_FILE} hexString HEX) + string(LENGTH ${hexString} hexStringLength) + + # appends null byte if asked + if(BIN2H_NULL_TERMINATE) + set(hexString "${hexString}00") + endif() + + # 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") + + # 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}) + # removes trailing comma + string(REGEX REPLACE ", $" "" arrayValues ${arrayValues}) + + # converts the variable name into proper C identifier + string(MAKE_C_IDENTIFIER "${BIN2H_VARIABLE_NAME}" BIN2H_VARIABLE_NAME) + string(TOUPPER "${BIN2H_VARIABLE_NAME}" BIN2H_VARIABLE_NAME) + + # declares byte array and the length variables + set(namespaceStart "namespace ${HEADER_NAMESPACE} {") + set(namespaceEnd "} // ${HEADER_NAMESPACE}") + set(arrayIncludes "#pragma once\n#include \n#include ") + set(arrayDefinition "const std::array ${BIN2H_VARIABLE_NAME} = { ${arrayValues} };") + + set(declarations "${arrayIncludes}\n\n${namespaceStart}\n${arrayDefinition}\n${namespaceEnd}\n\n") + if(BIN2H_APPEND) + file(APPEND ${BIN2H_HEADER_FILE} "${declarations}") + else() + file(WRITE ${BIN2H_HEADER_FILE} "${declarations}") + endif() +endfunction() \ No newline at end of file diff --git a/cmake/bin_file_to_header.cmake b/cmake/bin_file_to_header.cmake new file mode 100644 index 000000000..814aac907 --- /dev/null +++ b/cmake/bin_file_to_header.cmake @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.15) + +if(${INPUT_SHADER_FILE} STREQUAL "") + message(FATAL_ERROR "No input file path provided via 'INPUT_SHADER_FILE'.") +endif() + +if(${OUTPUT_HEADER_FILE} STREQUAL "") + message(FATAL_ERROR "No output file path provided via 'OUTPUT_HEADER_FILE'.") +endif() + +if(${HEADER_NAMESPACE} STREQUAL "") + message(FATAL_ERROR "No header namespace provided via 'HEADER_NAMESPACE'.") +endif() + +include(bin2h.cmake) + +get_filename_component(BINARY_FILE_CONTENT ${INPUT_SHADER_FILE} NAME) +bin2h(SOURCE_FILE ${INPUT_SHADER_FILE} HEADER_FILE ${OUTPUT_HEADER_FILE} VARIABLE_NAME ${BINARY_FILE_CONTENT} HEADER_NAMESPACE ${HEADER_NAMESPACE}) +file(APPEND ${OUTPUT_HEADER_FILE} "\n") \ No newline at end of file diff --git a/cmake/code_coverage.cmake b/cmake/code_coverage.cmake new file mode 100644 index 000000000..b1f748668 --- /dev/null +++ b/cmake/code_coverage.cmake @@ -0,0 +1,34 @@ +# Code coverage +set(CMAKE_BUILD_TYPE COVERAGE CACHE INTERNAL "Coverage build enabled") +message(STATUS "Enabling gcov support") +if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + set(COVERAGE_FLAG "--coverage") +endif() +set(CMAKE_CXX_FLAGS_COVERAGE + "-g -O0 ${COVERAGE_FLAG} -fprofile-arcs -ftest-coverage" + CACHE STRING "Flags used by the C++ compiler during coverage builds." + FORCE) +set(CMAKE_C_FLAGS_COVERAGE + "-g -O0 ${COVERAGE_FLAG} -fprofile-arcs -ftest-coverage" + CACHE STRING "Flags used by the C compiler during coverage builds." + FORCE) +set(CMAKE_EXE_LINKER_FLAGS_COVERAGE + "" + CACHE STRING "Flags used for linking binaries during coverage builds." + FORCE) +set(CMAKE_SHARED_LINKER_FLAGS_COVERAGE + "" + CACHE STRING "Flags used by the shared libraries linker during coverage builds." + FORCE) + +set(CODECOV_DIR ${CMAKE_CURRENT_BINARY_DIR}/codecov/) +set(CODECOV_DIR_LCOV ${CODECOV_DIR}lcov/) +set(CODECOV_FILENAME_LCOV_INFO lcov.info) +set(CODECOV_FILENAME_LCOV_INFO_FULL lcov_full.info) +set(CODECOV_DIR_HTML ${CODECOV_DIR}html/) + +mark_as_advanced(CMAKE_CXX_FLAGS_COVERAGE + CMAKE_C_FLAGS_COVERAGE + CMAKE_EXE_LINKER_FLAGS_COVERAGE + CMAKE_SHARED_LINKER_FLAGS_COVERAGE) +endif() diff --git a/cmake/deprecation_warnings.cmake b/cmake/deprecation_warnings.cmake new file mode 100644 index 000000000..95c81c28c --- /dev/null +++ b/cmake/deprecation_warnings.cmake @@ -0,0 +1,3 @@ +if(KOMPUTE_OPT_REPO_SUBMODULE_BUILD) + message(FATAL_ERROR "'KOMPUTE_OPT_REPO_SUBMODULE_BUILD' got replaced by 'KOMPUTE_OPT_USE_BUILD_IN_SPDLOG', 'KOMPUTE_OPT_USE_BUILD_IN_FMT', 'KOMPUTE_OPT_USE_BUILD_IN_GOOGLE_TEST', 'KOMPUTE_OPT_USE_BUILD_IN_PYBIND11' and 'KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER'. Please use them instead.") +endif() \ No newline at end of file diff --git a/cmake/komputeConfig.cmake.in b/cmake/komputeConfig.cmake.in new file mode 100644 index 000000000..87e8a99e2 --- /dev/null +++ b/cmake/komputeConfig.cmake.in @@ -0,0 +1,8 @@ +include(CMakeFindDependencyMacro) +@PACKAGE_INIT@ + +find_dependency(VULKAN REQUIRED) + +include(${CMAKE_CURRENT_LIST_DIR}/komputeTargets.cmake) + +check_required_components(kompute) \ No newline at end of file diff --git a/cmake/vulkan_shader_compiler.cmake b/cmake/vulkan_shader_compiler.cmake new file mode 100644 index 000000000..4526b796a --- /dev/null +++ b/cmake/vulkan_shader_compiler.cmake @@ -0,0 +1,36 @@ +function(vulkan_compile_shader) + find_program(GLS_LANG_VALIDATOR_PATH NAMES glslangValidator) + if(${GLS_LANG_VALIDATOR_PATH}) + message(FATAL_ERROR "glslangValidator not found.") + return() + endif() + + cmake_parse_arguments(SHADER_COMPILE "" "INFILE;OUTFILE;NAMESPACE" "" ${ARGN}) + set(SHADER_COMPILE_INFILE_FULL "${CMAKE_CURRENT_SOURCE_DIR}/${SHADER_COMPILE_INFILE}") + set(SHADER_COMPILE_SPV_FILE_FULL "${CMAKE_CURRENT_BINARY_DIR}/${SHADER_COMPILE_INFILE}.spv") + set(SHADER_COMPILE_HEADER_FILE_FULL "${CMAKE_CURRENT_BINARY_DIR}/${SHADER_COMPILE_OUTFILE}") + + # .comp -> .spv + add_custom_command(OUTPUT "${SHADER_COMPILE_SPV_FILE_FULL}" + COMMAND "${GLS_LANG_VALIDATOR_PATH}" + ARGS "-V" + "-o" + "${SHADER_COMPILE_SPV_FILE_FULL}" + "--target-env" + "vulkan1.2" + "${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}") + + # .spv -> .hpp + add_custom_command(OUTPUT "${SHADER_COMPILE_HEADER_FILE_FULL}" + COMMAND ${CMAKE_COMMAND} + ARGS "-DINPUT_SHADER_FILE=${SHADER_COMPILE_SPV_FILE_FULL}" + "-DOUTPUT_HEADER_FILE=${SHADER_COMPILE_HEADER_FILE_FULL}" + "-DHEADER_NAMESPACE=${SHADER_COMPILE_NAMESPACE}" + "-P" + "${CMAKE_SOURCE_DIR}/cmake/bin_file_to_header.cmake" + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/cmake" + COMMENT "Converting compiled shader '${SHADER_COMPILE_SPV_FILE_FULL}' to header file '${SHADER_COMPILE_HEADER_FILE_FULL}'." + MAIN_DEPENDENCY "${SHADER_COMPILE_SPV_FILE_FULL}") +endfunction() diff --git a/docs/overview/build-system.rst b/docs/overview/build-system.rst index d6c264d22..34b041f60 100644 --- a/docs/overview/build-system.rst +++ b/docs/overview/build-system.rst @@ -28,8 +28,6 @@ This by default configures without any of the extra build tasks (such as buildin * - -DKOMPUTE_OPT_BUILD_DOCS=ON - Enable if you wish to build the docs (must have docs deps installed) * - -DKOMPUTE_OPT_BUILD_SHADERS=ON - - Enable if you wish to build the shaders into header files (must have docs deps installed) - * - -DKOMPUTE_OPT_BUILD_SINGLE_HEADER=ON - Option to build the single header file using "quom" utility * - -DKOMPUTE_OPT_INSTALL=OFF - Disables the install step in the cmake file (useful for android build) diff --git a/examples/android/android-simple/app/build.gradle b/examples/android/android-simple/app/build.gradle index aef4b49b1..a115ef77d 100644 --- a/examples/android/android-simple/app/build.gradle +++ b/examples/android/android-simple/app/build.gradle @@ -20,7 +20,6 @@ android { '-DKOMPUTE_OPT_ANDROID_BUILD=1', '-DKOMPUTE_OPT_INSTALL=0', '-DKOMPUTE_OPT_ENABLE_SPDLOG=0', - '-DKOMPUTE_OPT_BUILD_SINGLE_HEADER=0', '-DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=1', '-DKOMPUTE_EXTRA_CXX_FLAGS=-DKOMPUTE_VK_API_MINOR_VERSION=0' } diff --git a/kompute-config.cmake b/kompute-config.cmake new file mode 100644 index 000000000..10425252c --- /dev/null +++ b/kompute-config.cmake @@ -0,0 +1,28 @@ +# General purpose GPU compute framework built on Vulkan to +# support 1000s of cross vendor graphics cards +# (AMD, Qualcomm, NVIDIA & friends). Blazing fast, mobile-enabled, +# asynchronous and optimized for advanced GPU data processing use cases. +# Backed by the Linux Foundation. +# +# Finding this module will define the following variables: +# KOMPUTE_FOUND - True if the core library has been found +# KOMPUTE_LIBRARIES - Path to the core library archive +# KOMPUTE_INCLUDE_DIRS - Path to the include directories. Gives access +# to kompute.h, as a single include which must be included in every +# file that uses this interface. Else it also points to the +# directory for individual includes. + +find_path(KOMPUTE_INCLUDE_DIR + NAMES kompute.h) + +find_library(KOMPUTE_LIBRARY + NAMES kompute + HINTS ${KOMPUTE_LIBRARY_ROOT}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(KOMPUTE REQUIRED_VARS KOMPUTE_LIBRARY KOMPUTE_INCLUDE_DIR) + +if(KOMPUTE_FOUND) + set(KOMPUTE_LIBRARIES ${KOMPUTE_LIBRARY}) + set(KOMPUTE_INCLUDE_DIRS ${KOMPUTE_INCLUDE_DIR}) +endif() diff --git a/single_include/AggregateHeaders.cpp b/single_include/AggregateHeaders.cpp deleted file mode 100644 index 0498fc01a..000000000 --- a/single_include/AggregateHeaders.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once -#include "kompute/Algorithm.hpp" -#include "kompute/Core.hpp" -#include "kompute/Manager.hpp" -#include "kompute/Sequence.hpp" -#include "kompute/Tensor.hpp" -#include "kompute/operations/OpAlgoDispatch.hpp" -#include "kompute/operations/OpBase.hpp" -#include "kompute/operations/OpMemoryBarrier.hpp" -#include "kompute/operations/OpMult.hpp" -#include "kompute/operations/OpTensorCopy.hpp" -#include "kompute/operations/OpTensorSyncDevice.hpp" -#include "kompute/operations/OpTensorSyncLocal.hpp" -#include "kompute/shaders/shaderlogisticregression.hpp" -#include "kompute/shaders/shaderopmult.hpp" diff --git a/single_include/kompute/Kompute.hpp b/single_include/kompute/Kompute.hpp index e725b8bbd..e69de29bb 100644 --- a/single_include/kompute/Kompute.hpp +++ b/single_include/kompute/Kompute.hpp @@ -1,2432 +0,0 @@ -#pragma once -/* - THIS FILE HAS BEEN AUTOMATICALLY GENERATED - DO NOT EDIT - - --- - - Copyright 2020 The Institute for Ethical AI & Machine Learning - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#ifndef SHADEROP_SHADEROPMULT_HPP -#define SHADEROP_SHADEROPMULT_HPP - -namespace kp { -namespace shader_data { -static const unsigned char shaders_glsl_opmult_comp_spv[] = { - 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x0a, 0x00, 0x08, 0x00, - 0x2e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, - 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x06, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, - 0x0b, 0x00, 0x00, 0x00, 0x10, 0x00, 0x06, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x11, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x02, 0x00, 0x00, 0x00, - 0xc2, 0x01, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, - 0x08, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x08, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x47, - 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x49, 0x6e, 0x76, 0x6f, 0x63, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x49, 0x44, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, - 0x12, 0x00, 0x00, 0x00, 0x74, 0x65, 0x6e, 0x73, 0x6f, 0x72, 0x4f, 0x75, - 0x74, 0x70, 0x75, 0x74, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x07, 0x00, - 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x73, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x03, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x05, 0x00, 0x19, 0x00, 0x00, 0x00, 0x74, 0x65, 0x6e, 0x73, - 0x6f, 0x72, 0x4c, 0x68, 0x73, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, - 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x73, 0x4c, 0x68, 0x73, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, - 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, - 0x21, 0x00, 0x00, 0x00, 0x74, 0x65, 0x6e, 0x73, 0x6f, 0x72, 0x52, 0x68, - 0x73, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0x21, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x52, 0x68, - 0x73, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x23, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x29, 0x00, 0x00, 0x00, - 0x4c, 0x45, 0x4e, 0x5f, 0x4c, 0x48, 0x53, 0x00, 0x05, 0x00, 0x04, 0x00, - 0x2a, 0x00, 0x00, 0x00, 0x4c, 0x45, 0x4e, 0x5f, 0x52, 0x48, 0x53, 0x00, - 0x05, 0x00, 0x04, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x4c, 0x45, 0x4e, 0x5f, - 0x4f, 0x55, 0x54, 0x00, 0x47, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, - 0x0b, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x11, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x48, 0x00, 0x05, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, - 0x12, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x14, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x14, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x18, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, - 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x19, 0x00, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x1b, 0x00, 0x00, 0x00, - 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x1b, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x20, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x21, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x03, 0x00, 0x21, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x23, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x23, 0x00, 0x00, 0x00, - 0x21, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x29, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x2b, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x2d, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, - 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, - 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, - 0x0a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, - 0x0d, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x16, 0x00, 0x03, 0x00, 0x10, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, - 0x1d, 0x00, 0x03, 0x00, 0x11, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, - 0x1e, 0x00, 0x03, 0x00, 0x12, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x04, 0x00, 0x13, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x12, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x13, 0x00, 0x00, 0x00, - 0x14, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, - 0x15, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x2b, 0x00, 0x04, 0x00, 0x15, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x03, 0x00, 0x18, 0x00, 0x00, 0x00, - 0x10, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, 0x19, 0x00, 0x00, 0x00, - 0x18, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x1a, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x1a, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x04, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x10, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x03, 0x00, 0x20, 0x00, 0x00, 0x00, - 0x10, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, 0x21, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x22, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x22, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x32, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x06, 0x00, 0x09, 0x00, 0x00, 0x00, - 0x2d, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, - 0x2c, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x05, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, - 0x0b, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x08, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, - 0x08, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x1c, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, - 0x1d, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, - 0x16, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x10, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, - 0x08, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x1d, 0x00, 0x00, 0x00, - 0x25, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, - 0x24, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00, - 0x26, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, - 0x10, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, - 0x26, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x1d, 0x00, 0x00, 0x00, - 0x28, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, - 0x17, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x28, 0x00, 0x00, 0x00, - 0x27, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00 -}; -static const unsigned int shaders_glsl_opmult_comp_spv_len = 1464; -} -} -#endif // define SHADEROP_SHADEROPMULT_HPP - -/* - THIS FILE HAS BEEN AUTOMATICALLY GENERATED - DO NOT EDIT - - --- - - Copyright 2020 The Institute for Ethical AI & Machine Learning - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#ifndef SHADEROP_SHADERLOGISTICREGRESSION_HPP -#define SHADEROP_SHADERLOGISTICREGRESSION_HPP - -namespace kp { -namespace shader_data { -static const unsigned char shaders_glsl_logisticregression_comp_spv[] = { - 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x0a, 0x00, 0x08, 0x00, - 0xae, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, - 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x06, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x00, 0x00, 0x10, 0x00, 0x06, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x11, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x02, 0x00, 0x00, 0x00, - 0xc2, 0x01, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, - 0x0a, 0x00, 0x00, 0x00, 0x73, 0x69, 0x67, 0x6d, 0x6f, 0x69, 0x64, 0x28, - 0x66, 0x31, 0x3b, 0x00, 0x05, 0x00, 0x03, 0x00, 0x09, 0x00, 0x00, 0x00, - 0x7a, 0x00, 0x00, 0x00, 0x05, 0x00, 0x08, 0x00, 0x12, 0x00, 0x00, 0x00, - 0x69, 0x6e, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x28, 0x76, 0x66, - 0x32, 0x3b, 0x76, 0x66, 0x32, 0x3b, 0x66, 0x31, 0x3b, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x03, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x03, 0x00, 0x10, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x03, 0x00, 0x11, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x08, 0x00, 0x17, 0x00, 0x00, 0x00, 0x63, 0x61, 0x6c, 0x63, - 0x75, 0x6c, 0x61, 0x74, 0x65, 0x4c, 0x6f, 0x73, 0x73, 0x28, 0x66, 0x31, - 0x3b, 0x66, 0x31, 0x3b, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, - 0x15, 0x00, 0x00, 0x00, 0x79, 0x48, 0x61, 0x74, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x03, 0x00, 0x16, 0x00, 0x00, 0x00, 0x79, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x03, 0x00, 0x21, 0x00, 0x00, 0x00, 0x7a, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x04, 0x00, 0x27, 0x00, 0x00, 0x00, 0x79, 0x48, 0x61, 0x74, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x28, 0x00, 0x00, 0x00, - 0x70, 0x61, 0x72, 0x61, 0x6d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, - 0x3e, 0x00, 0x00, 0x00, 0x69, 0x64, 0x78, 0x00, 0x05, 0x00, 0x08, 0x00, - 0x41, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x47, 0x6c, 0x6f, 0x62, 0x61, - 0x6c, 0x49, 0x6e, 0x76, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, - 0x44, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x46, 0x00, 0x00, 0x00, - 0x77, 0x43, 0x75, 0x72, 0x72, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, - 0x48, 0x00, 0x00, 0x00, 0x62, 0x77, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x04, 0x00, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x77, 0x69, 0x6e, 0x00, 0x05, 0x00, 0x03, 0x00, 0x4a, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x54, 0x00, 0x00, 0x00, - 0x62, 0x43, 0x75, 0x72, 0x72, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, - 0x56, 0x00, 0x00, 0x00, 0x62, 0x62, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x04, 0x00, 0x56, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x62, 0x69, 0x6e, 0x00, 0x05, 0x00, 0x03, 0x00, 0x58, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x5b, 0x00, 0x00, 0x00, - 0x78, 0x43, 0x75, 0x72, 0x72, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, - 0x5d, 0x00, 0x00, 0x00, 0x62, 0x78, 0x69, 0x00, 0x06, 0x00, 0x04, 0x00, - 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x69, 0x00, 0x00, - 0x05, 0x00, 0x03, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x03, 0x00, 0x64, 0x00, 0x00, 0x00, 0x62, 0x78, 0x6a, 0x00, - 0x06, 0x00, 0x04, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x78, 0x6a, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x66, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x6b, 0x00, 0x00, 0x00, - 0x79, 0x43, 0x75, 0x72, 0x72, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, - 0x6d, 0x00, 0x00, 0x00, 0x62, 0x79, 0x00, 0x00, 0x06, 0x00, 0x04, 0x00, - 0x6d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x79, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x03, 0x00, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x04, 0x00, 0x73, 0x00, 0x00, 0x00, 0x79, 0x48, 0x61, 0x74, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x74, 0x00, 0x00, 0x00, - 0x70, 0x61, 0x72, 0x61, 0x6d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, - 0x76, 0x00, 0x00, 0x00, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x04, 0x00, 0x78, 0x00, 0x00, 0x00, 0x70, 0x61, 0x72, 0x61, - 0x6d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x7b, 0x00, 0x00, 0x00, - 0x64, 0x5a, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x00, 0x00, - 0x64, 0x57, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x6d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x86, 0x00, 0x00, 0x00, - 0x64, 0x42, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x8b, 0x00, 0x00, 0x00, - 0x62, 0x77, 0x6f, 0x75, 0x74, 0x69, 0x00, 0x00, 0x06, 0x00, 0x05, 0x00, - 0x8b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x6f, 0x75, 0x74, - 0x69, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x8d, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x93, 0x00, 0x00, 0x00, - 0x62, 0x77, 0x6f, 0x75, 0x74, 0x6a, 0x00, 0x00, 0x06, 0x00, 0x05, 0x00, - 0x93, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x6f, 0x75, 0x74, - 0x6a, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x95, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x9c, 0x00, 0x00, 0x00, - 0x62, 0x62, 0x6f, 0x75, 0x74, 0x00, 0x00, 0x00, 0x06, 0x00, 0x05, 0x00, - 0x9c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x6f, 0x75, 0x74, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x9e, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0xa3, 0x00, 0x00, 0x00, - 0x62, 0x6c, 0x6f, 0x75, 0x74, 0x00, 0x00, 0x00, 0x06, 0x00, 0x05, 0x00, - 0xa3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x6f, 0x75, 0x74, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0xa5, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0xa7, 0x00, 0x00, 0x00, - 0x70, 0x61, 0x72, 0x61, 0x6d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, - 0xa9, 0x00, 0x00, 0x00, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x41, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, - 0x1c, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x47, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, - 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x48, 0x00, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x4a, 0x00, 0x00, 0x00, - 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x4a, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x55, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x56, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x03, 0x00, 0x56, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x58, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x58, 0x00, 0x00, 0x00, - 0x21, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x5c, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x48, 0x00, 0x05, 0x00, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, - 0x5d, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x5f, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x63, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, - 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x64, 0x00, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x66, 0x00, 0x00, 0x00, - 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x66, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x6d, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x03, 0x00, 0x6d, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x6f, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x6f, 0x00, 0x00, 0x00, - 0x21, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x80, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x8b, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x03, 0x00, 0x8b, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x8d, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x8d, 0x00, 0x00, 0x00, - 0x21, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x92, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x48, 0x00, 0x05, 0x00, 0x93, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, - 0x93, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x95, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x95, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x9b, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, - 0x9c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x9c, 0x00, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x9e, 0x00, 0x00, 0x00, - 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x9e, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0xa2, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0xa3, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x03, 0x00, 0xa3, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0xa5, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0xa5, 0x00, 0x00, 0x00, - 0x21, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0xad, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, - 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, - 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x21, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, - 0x0d, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x21, 0x00, 0x06, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x0d, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x21, 0x00, 0x05, 0x00, 0x14, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, - 0x15, 0x00, 0x04, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x3d, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, - 0x3f, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x04, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x3f, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x40, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, - 0x3c, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x04, 0x00, 0x43, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x3c, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x03, 0x00, 0x47, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, 0x48, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x49, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x49, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x15, 0x00, 0x04, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x4b, 0x00, 0x00, 0x00, - 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, - 0x4d, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x2b, 0x00, 0x04, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x03, 0x00, 0x55, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, 0x56, 0x00, 0x00, 0x00, - 0x55, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x57, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x57, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x1d, 0x00, 0x03, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x1e, 0x00, 0x03, 0x00, 0x5d, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x04, 0x00, 0x5e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x5d, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x5e, 0x00, 0x00, 0x00, - 0x5f, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x03, 0x00, - 0x63, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, - 0x64, 0x00, 0x00, 0x00, 0x63, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, - 0x65, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x65, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x03, 0x00, 0x6c, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, 0x6d, 0x00, 0x00, 0x00, - 0x6c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x6e, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x6e, 0x00, 0x00, 0x00, 0x6f, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x32, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x03, 0x00, 0x8a, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, 0x8b, 0x00, 0x00, 0x00, - 0x8a, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x8c, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x8b, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x8c, 0x00, 0x00, 0x00, 0x8d, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x1d, 0x00, 0x03, 0x00, 0x92, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x1e, 0x00, 0x03, 0x00, 0x93, 0x00, 0x00, 0x00, 0x92, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x04, 0x00, 0x94, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x93, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x94, 0x00, 0x00, 0x00, - 0x95, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, - 0x3c, 0x00, 0x00, 0x00, 0x97, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x1d, 0x00, 0x03, 0x00, 0x9b, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x1e, 0x00, 0x03, 0x00, 0x9c, 0x00, 0x00, 0x00, 0x9b, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x04, 0x00, 0x9d, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x9c, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x9d, 0x00, 0x00, 0x00, - 0x9e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x03, 0x00, - 0xa2, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, - 0xa3, 0x00, 0x00, 0x00, 0xa2, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, - 0xa4, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa3, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0xa4, 0x00, 0x00, 0x00, 0xa5, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x06, 0x00, 0x3f, 0x00, 0x00, 0x00, - 0xad, 0x00, 0x00, 0x00, 0x97, 0x00, 0x00, 0x00, 0x97, 0x00, 0x00, 0x00, - 0x97, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x3d, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x54, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x0d, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x73, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x0d, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x76, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x78, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x86, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x07, 0x00, 0x00, 0x00, 0xa7, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0xa9, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x43, 0x00, 0x00, 0x00, - 0x44, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, - 0x44, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x3e, 0x00, 0x00, 0x00, - 0x45, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x4d, 0x00, 0x00, 0x00, - 0x4e, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, - 0x4c, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x4f, 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, - 0x4d, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, - 0x4c, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, - 0x50, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x53, 0x00, 0x00, 0x00, - 0x4f, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0x46, 0x00, 0x00, 0x00, 0x53, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, - 0x4d, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, - 0x4c, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x54, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x4d, 0x00, 0x00, 0x00, - 0x61, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, - 0x60, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x62, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x3c, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x06, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, - 0x66, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x69, 0x00, 0x00, 0x00, - 0x68, 0x00, 0x00, 0x00, 0x50, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x6a, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x69, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x6a, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x4d, 0x00, 0x00, 0x00, - 0x71, 0x00, 0x00, 0x00, 0x6f, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, - 0x70, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x72, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0x6b, 0x00, 0x00, 0x00, 0x72, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x74, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, - 0x46, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x76, 0x00, 0x00, 0x00, - 0x77, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x79, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0x78, 0x00, 0x00, 0x00, 0x79, 0x00, 0x00, 0x00, 0x39, 0x00, 0x07, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x7a, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, - 0x74, 0x00, 0x00, 0x00, 0x76, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x73, 0x00, 0x00, 0x00, 0x7a, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, - 0x73, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x7d, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x83, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, - 0x7d, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x7b, 0x00, 0x00, 0x00, - 0x7e, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x81, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, - 0x5b, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x83, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, - 0x7b, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x85, 0x00, 0x00, 0x00, 0x83, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, - 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, - 0x19, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x00, - 0x85, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x89, 0x00, 0x00, 0x00, - 0x87, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0x86, 0x00, 0x00, 0x00, 0x89, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x3c, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x8f, 0x00, 0x00, 0x00, - 0x7f, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x8f, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x06, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0x00, - 0x8d, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x91, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x96, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x98, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x97, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x99, 0x00, 0x00, 0x00, - 0x98, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x4d, 0x00, 0x00, 0x00, - 0x9a, 0x00, 0x00, 0x00, 0x95, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, - 0x96, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x9a, 0x00, 0x00, 0x00, - 0x99, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x3c, 0x00, 0x00, 0x00, - 0x9f, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x86, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x06, 0x00, 0x4d, 0x00, 0x00, 0x00, 0xa1, 0x00, 0x00, 0x00, - 0x9e, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x9f, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0xa1, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x3c, 0x00, 0x00, 0x00, 0xa6, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0xa8, 0x00, 0x00, 0x00, 0x73, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0xa7, 0x00, 0x00, 0x00, 0xa8, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0xaa, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0xa9, 0x00, 0x00, 0x00, 0xaa, 0x00, 0x00, 0x00, - 0x39, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, 0xab, 0x00, 0x00, 0x00, - 0x17, 0x00, 0x00, 0x00, 0xa7, 0x00, 0x00, 0x00, 0xa9, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x06, 0x00, 0x4d, 0x00, 0x00, 0x00, 0xac, 0x00, 0x00, 0x00, - 0xa5, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0xa6, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0xac, 0x00, 0x00, 0x00, 0xab, 0x00, 0x00, 0x00, - 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00, 0x36, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x08, 0x00, 0x00, 0x00, 0x37, 0x00, 0x03, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x0b, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x1b, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x1b, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, - 0x1c, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x1e, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, - 0xfe, 0x00, 0x02, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x38, 0x00, 0x01, 0x00, - 0x36, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x37, 0x00, 0x03, 0x00, - 0x0d, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x37, 0x00, 0x03, 0x00, - 0x0d, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x37, 0x00, 0x03, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, - 0x13, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x21, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x22, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, - 0x94, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, - 0x22, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, - 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, - 0x24, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0x21, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x28, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, - 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, - 0x0a, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0x27, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, - 0xfe, 0x00, 0x02, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x38, 0x00, 0x01, 0x00, - 0x36, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x37, 0x00, 0x03, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x37, 0x00, 0x03, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, - 0x18, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x2e, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, - 0x0c, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x00, - 0x85, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, - 0x2e, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, - 0x83, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, - 0x19, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, - 0x83, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, - 0x19, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x1c, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, - 0x36, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x38, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, - 0x7f, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00, - 0x38, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x02, 0x00, 0x39, 0x00, 0x00, 0x00, - 0x38, 0x00, 0x01, 0x00 -}; -static const unsigned int shaders_glsl_logisticregression_comp_spv_len = 4816; -} -} -#endif // define SHADEROP_SHADERLOGISTICREGRESSION_HPP - -// SPDX-License-Identifier: Apache-2.0 - -#if VK_USE_PLATFORM_ANDROID_KHR -#include -#include -// VK_NO_PROTOTYPES required before vulkan import but after wrapper.hpp -#undef VK_NO_PROTOTYPES -static const char* KOMPUTE_LOG_TAG = "KomputeLog"; -#endif - -#include -#include -#include - -#include - -// Typedefs to simplify interaction with core types -namespace kp { -typedef std::array Workgroup; -typedef std::vector Constants; -} - -// Must be after vulkan is included -#ifndef KOMPUTE_VK_API_VERSION -#ifndef KOMPUTE_VK_API_MAJOR_VERSION -#define KOMPUTE_VK_API_MAJOR_VERSION 1 -#endif // KOMPUTE_VK_API_MAJOR_VERSION -#ifndef KOMPUTE_VK_API_MINOR_VERSION -#define KOMPUTE_VK_API_MINOR_VERSION 1 -#endif // KOMPUTE_VK_API_MINOR_VERSION -#define KOMPUTE_VK_API_VERSION \ - VK_MAKE_VERSION( \ - KOMPUTE_VK_API_MAJOR_VERSION, KOMPUTE_VK_API_MINOR_VERSION, 0) -#endif // KOMPUTE_VK_API_VERSION - -// Defining kompute log levels analogous to spdlog log levels -#define KOMPUTE_LOG_LEVEL_TRACE 0 -#define KOMPUTE_LOG_LEVEL_DEBUG 1 -#define KOMPUTE_LOG_LEVEL_INFO 2 -#define KOMPUTE_LOG_LEVEL_WARN 3 -#define KOMPUTE_LOG_LEVEL_ERROR 4 -#define KOMPUTE_LOG_LEVEL_CRITICAL 5 -#define KOMPUTE_LOG_LEVEL_OFF 6 - -#ifndef KOMPUTE_LOG_LEVEL -#if DEBUG -#define KOMPUTE_LOG_LEVEL KOMPUTE_LOG_LEVEL_DEBUG -#else -#define KOMPUTE_LOG_LEVEL KOMPUTE_LOG_LEVEL_INFO -#endif -#endif // KOMPUTE_LOG_LEVEL - -// SPDLOG_ACTIVE_LEVEL must be defined before spdlog.h import -// It is recommended that it's set via KOMPUTE_LOG_LEVEL -// but if required it can be set directly as override -#ifndef SPDLOG_ACTIVE_LEVEL -#define SPDLOG_ACTIVE_LEVEL KOMPUTE_LOG_LEVEL -#endif - -#if defined(KOMPUTE_BUILD_PYTHON) -#include -namespace py = pybind11; -// from python/src/main.cpp -extern py::object kp_debug, kp_info, kp_warning, kp_error; -#endif - -#ifndef KOMPUTE_LOG_OVERRIDE -#if KOMPUTE_ENABLE_SPDLOG -#include -#define KP_LOG_DEBUG(...) SPDLOG_DEBUG(__VA_ARGS__) -#define KP_LOG_INFO(...) SPDLOG_INFO(__VA_ARGS__) -#define KP_LOG_WARN(...) SPDLOG_WARN(__VA_ARGS__) -#define KP_LOG_ERROR(...) SPDLOG_ERROR(__VA_ARGS__) -#else -#include -#if KOMPUTE_LOG_LEVEL > 1 -#define KP_LOG_DEBUG(...) -#else -#if defined(VK_USE_PLATFORM_ANDROID_KHR) -#define KP_LOG_DEBUG(...) \ - ((void)__android_log_write( \ - ANDROID_LOG_DEBUG, KOMPUTE_LOG_TAG, fmt::format(__VA_ARGS__).c_str())) -#elif defined(KOMPUTE_BUILD_PYTHON) -#define KP_LOG_DEBUG(...) kp_debug(fmt::format(__VA_ARGS__)) -#else -#define KP_LOG_DEBUG(...) \ - fmt::print("[{} {}] [debug] [{}:{}] {}\n", \ - __DATE__, \ - __TIME__, \ - __FILE__, \ - __LINE__, \ - fmt::format(__VA_ARGS__)) -#endif // VK_USE_PLATFORM_ANDROID_KHR -#endif // KOMPUTE_LOG_LEVEL > 1 - -#if KOMPUTE_LOG_LEVEL > 2 -#define KP_LOG_INFO(...) -#else -#if defined(VK_USE_PLATFORM_ANDROID_KHR) -#define KP_LOG_INFO(...) \ - ((void)__android_log_write( \ - ANDROID_LOG_INFO, KOMPUTE_LOG_TAG, fmt::format(__VA_ARGS__).c_str())) -#elif defined(KOMPUTE_BUILD_PYTHON) -#define KP_LOG_INFO(...) kp_info(fmt::format(__VA_ARGS__)) -#else -#define KP_LOG_INFO(...) \ - fmt::print("[{} {}] [debug] [{}:{}] {}\n", \ - __DATE__, \ - __TIME__, \ - __FILE__, \ - __LINE__, \ - fmt::format(__VA_ARGS__)) -#endif // VK_USE_PLATFORM_ANDROID_KHR -#endif // KOMPUTE_LOG_LEVEL > 2 - -#if KOMPUTE_LOG_LEVEL > 3 -#define KP_LOG_WARN(...) -#else -#if defined(VK_USE_PLATFORM_ANDROID_KHR) -#define KP_LOG_WARN(...) \ - ((void)__android_log_write( \ - ANDROID_LOG_WARN, KOMPUTE_LOG_TAG, fmt::format(__VA_ARGS__).c_str())) -#elif defined(KOMPUTE_BUILD_PYTHON) -#define KP_LOG_WARN(...) kp_warning(fmt::format(__VA_ARGS__)) -#else -#define KP_LOG_WARN(...) \ - fmt::print("[{} {}] [debug] [{}:{}] {}\n", \ - __DATE__, \ - __TIME__, \ - __FILE__, \ - __LINE__, \ - fmt::format(__VA_ARGS__)) -#endif // VK_USE_PLATFORM_ANDROID_KHR -#endif // KOMPUTE_LOG_LEVEL > 3 - -#if KOMPUTE_LOG_LEVEL > 4 -#define KP_LOG_ERROR(...) -#else -#if defined(VK_USE_PLATFORM_ANDROID_KHR) -#define KP_LOG_ERROR(...) \ - ((void)__android_log_write( \ - ANDROID_LOG_ERROR, KOMPUTE_LOG_TAG, fmt::format(__VA_ARGS__).c_str())) -#elif defined(KOMPUTE_BUILD_PYTHON) -#define KP_LOG_ERROR(...) kp_error(fmt::format(__VA_ARGS__)) -#else -#define KP_LOG_ERROR(...) \ - fmt::print("[{} {}] [debug] [{}:{}] {}\n", \ - __DATE__, \ - __TIME__, \ - __FILE__, \ - __LINE__, \ - fmt::format(__VA_ARGS__)) -#endif // VK_USE_PLATFORM_ANDROID_KHR -#endif // KOMPUTE_LOG_LEVEL > 4 -#endif // KOMPUTE_SPDLOG_ENABLED -#endif // KOMPUTE_LOG_OVERRIDE - -// SPDX-License-Identifier: Apache-2.0 - -namespace kp { - -/** - * Structured data used in GPU operations. - * - * Tensors are the base building block in Kompute to perform operations across - * GPUs. Each tensor would have a respective Vulkan memory and buffer, which - * would be used to store their respective data. The tensors can be used for GPU - * data storage or transfer. - */ -class Tensor -{ - public: - /** - * Type for tensors created: Device allows memory to be transferred from - * staging buffers. Staging are host memory visible. Storage are device - * visible but are not set up to transfer or receive data (only for shader - * storage). - */ - enum class TensorTypes - { - eDevice = 0, ///< Type is device memory, source and destination - eHost = 1, ///< Type is host memory, source and destination - eStorage = 2, ///< Type is Device memory (only) - }; - enum class TensorDataTypes - { - eBool = 0, - eInt = 1, - eUnsignedInt = 2, - eFloat = 3, - eDouble = 4, - }; - - /** - * Constructor with data provided which would be used to create the - * respective vulkan buffer and memory. - * - * @param physicalDevice The physical device to use to fetch properties - * @param device The device to use to create the buffer and memory from - * @param data Non-zero-sized vector of data that will be used by the - * tensor - * @param tensorTypes Type for the tensor which is of type TensorTypes - */ - Tensor(std::shared_ptr physicalDevice, - std::shared_ptr device, - void* data, - uint32_t elementTotalCount, - uint32_t elementMemorySize, - const TensorDataTypes& dataType, - const TensorTypes& tensorType = TensorTypes::eDevice); - - /** - * Destructor which is in charge of freeing vulkan resources unless they - * have been provided externally. - */ - virtual ~Tensor(); - - /** - * Function to trigger reinitialisation of the tensor buffer and memory with - * new data as well as new potential device type. - * - * @param data Vector of data to use to initialise vector from - * @param tensorType The type to use for the tensor - */ - void rebuild(void* data, - uint32_t elementTotalCount, - uint32_t elementMemorySize); - - /** - * Destroys and frees the GPU resources which include the buffer and memory. - */ - void destroy(); - - /** - * Check whether tensor is initialized based on the created gpu resources. - * - * @returns Boolean stating whether tensor is initialized - */ - bool isInit(); - - /** - * Retrieve the tensor type of the Tensor - * - * @return Tensor type of tensor - */ - TensorTypes tensorType(); - - /** - * Records a copy from the memory of the tensor provided to the current - * thensor. This is intended to pass memory into a processing, to perform - * a staging buffer transfer, or to gather output (between others). - * - * @param commandBuffer Vulkan Command Buffer to record the commands into - * @param copyFromTensor Tensor to copy the data from - */ - void recordCopyFrom(const vk::CommandBuffer& commandBuffer, - std::shared_ptr copyFromTensor); - - /** - * Records a copy from the internal staging memory to the device memory - * using an optional barrier to wait for the operation. This function would - * only be relevant for kp::Tensors of type eDevice. - * - * @param commandBuffer Vulkan Command Buffer to record the commands into - */ - void recordCopyFromStagingToDevice(const vk::CommandBuffer& commandBuffer); - - /** - * Records a copy from the internal device memory to the staging memory - * using an optional barrier to wait for the operation. This function would - * only be relevant for kp::Tensors of type eDevice. - * - * @param commandBuffer Vulkan Command Buffer to record the commands into - */ - void recordCopyFromDeviceToStaging(const vk::CommandBuffer& commandBuffer); - - /** - * Records the buffer memory barrier into the primary buffer and command - * buffer which ensures that relevant data transfers are carried out - * correctly. - * - * @param commandBuffer Vulkan Command Buffer to record the commands into - * @param srcAccessMask Access flags for source access mask - * @param dstAccessMask Access flags for destination access mask - * @param scrStageMask Pipeline stage flags for source stage mask - * @param dstStageMask Pipeline stage flags for destination stage mask - */ - void recordPrimaryBufferMemoryBarrier( - const vk::CommandBuffer& commandBuffer, - vk::AccessFlagBits srcAccessMask, - vk::AccessFlagBits dstAccessMask, - vk::PipelineStageFlagBits srcStageMask, - vk::PipelineStageFlagBits dstStageMask); - /** - * Records the buffer memory barrier into the staging buffer and command - * buffer which ensures that relevant data transfers are carried out - * correctly. - * - * @param commandBuffer Vulkan Command Buffer to record the commands into - * @param srcAccessMask Access flags for source access mask - * @param dstAccessMask Access flags for destination access mask - * @param scrStageMask Pipeline stage flags for source stage mask - * @param dstStageMask Pipeline stage flags for destination stage mask - */ - void recordStagingBufferMemoryBarrier( - const vk::CommandBuffer& commandBuffer, - vk::AccessFlagBits srcAccessMask, - vk::AccessFlagBits dstAccessMask, - vk::PipelineStageFlagBits srcStageMask, - vk::PipelineStageFlagBits dstStageMask); - - /** - * Constructs a vulkan descriptor buffer info which can be used to specify - * and reference the underlying buffer component of the tensor without - * exposing it. - * - * @return Descriptor buffer info with own buffer - */ - vk::DescriptorBufferInfo constructDescriptorBufferInfo(); - - /** - * Returns the size/magnitude of the Tensor, which will be the total number - * of elements across all dimensions - * - * @return Unsigned integer representing the total number of elements - */ - uint32_t size(); - - /** - * Returns the total size of a single element of the respective data type - * that this tensor holds. - * - * @return Unsigned integer representing the memory of a single element of - * the respective data type. - */ - uint32_t dataTypeMemorySize(); - - /** - * Returns the total memory size of the data contained by the Tensor object - * which would equate to (this->size() * this->dataTypeMemorySize()) - * - * @return Unsigned integer representing the memory of a single element of - * the respective data type. - */ - uint32_t memorySize(); - - /** - * Retrieve the data type of the tensor (host, device, storage) - * - * @return Data type of tensor of type kp::Tensor::TensorDataTypes - */ - TensorDataTypes dataType(); - - /** - * Retrieve the raw data via the pointer to the memory that contains the raw - * memory of this current tensor. This tensor gets changed to a nullptr when - * the Tensor is removed. - * - * @return Pointer to raw memory containing raw bytes data of Tensor. - */ - void* rawData(); - - /** - * Sets / resets the data of the tensor which is directly done on the GPU - * host visible memory available by the tensor. - */ - void setRawData(const void* data); - - /** - * Template to return the pointer data converted by specific type, which - * would be any of the supported types including float, double, int32, - * uint32 and bool. - * - * @return Pointer to raw memory containing raw bytes data of Tensor. - */ - template - T* data() - { - return (T*)this->mRawData; - } - - /** - * Template to get the data of the current tensor as a vector of specific - * type, which would be any of the supported types including float, double, - * int32, uint32 and bool. - * - * @return Vector of type provided by template. - */ - template - std::vector vector() - { - return { (T*)this->mRawData, ((T*)this->mRawData) + this->size() }; - } - - protected: - // -------------- ALWAYS OWNED RESOURCES - TensorTypes mTensorType; - TensorDataTypes mDataType; - uint32_t mSize; - uint32_t mDataTypeMemorySize; - void* mRawData; - - private: - // -------------- NEVER OWNED RESOURCES - std::shared_ptr mPhysicalDevice; - std::shared_ptr mDevice; - - // -------------- OPTIONALLY OWNED RESOURCES - std::shared_ptr mPrimaryBuffer; - bool mFreePrimaryBuffer = false; - std::shared_ptr mStagingBuffer; - bool mFreeStagingBuffer = false; - std::shared_ptr mPrimaryMemory; - bool mFreePrimaryMemory = false; - std::shared_ptr mStagingMemory; - bool mFreeStagingMemory = false; - - void allocateMemoryCreateGPUResources(); // Creates the vulkan buffer - void createBuffer(std::shared_ptr buffer, - vk::BufferUsageFlags bufferUsageFlags); - void allocateBindMemory(std::shared_ptr buffer, - std::shared_ptr memory, - vk::MemoryPropertyFlags memoryPropertyFlags); - void recordCopyBuffer(const vk::CommandBuffer& commandBuffer, - std::shared_ptr bufferFrom, - std::shared_ptr bufferTo, - vk::DeviceSize bufferSize, - vk::BufferCopy copyRegion); - void recordBufferMemoryBarrier(const vk::CommandBuffer& commandBuffer, - const vk::Buffer& buffer, - vk::AccessFlagBits srcAccessMask, - vk::AccessFlagBits dstAccessMask, - vk::PipelineStageFlagBits srcStageMask, - vk::PipelineStageFlagBits dstStageMask); - - // Private util functions - vk::BufferUsageFlags getPrimaryBufferUsageFlags(); - vk::MemoryPropertyFlags getPrimaryMemoryPropertyFlags(); - vk::BufferUsageFlags getStagingBufferUsageFlags(); - vk::MemoryPropertyFlags getStagingMemoryPropertyFlags(); - - void mapRawData(); - void unmapRawData(); -}; - -template -class TensorT : public Tensor -{ - - public: - TensorT(std::shared_ptr physicalDevice, - std::shared_ptr device, - const std::vector& data, - const TensorTypes& tensorType = TensorTypes::eDevice) - : Tensor(physicalDevice, - device, - (void*)data.data(), - data.size(), - sizeof(T), - this->dataType(), - tensorType) - { - KP_LOG_DEBUG("Kompute TensorT constructor with data size {}", - data.size()); - } - - ~TensorT() { KP_LOG_DEBUG("Kompute TensorT destructor"); } - - T* data() { return (T*)this->mRawData; } - - std::vector vector() - { - return { (T*)this->mRawData, ((T*)this->mRawData) + this->size() }; - } - - T& operator[](int index) { return *(((T*)this->mRawData) + index); } - - void setData(const std::vector& data) - { - - KP_LOG_DEBUG("Kompute TensorT setting data with data size {}", - data.size()); - - if (data.size() != this->mSize) { - throw std::runtime_error( - "Kompute TensorT Cannot set data of different sizes"); - } - - Tensor::setRawData(data.data()); - } - - TensorDataTypes dataType(); -}; - -} // End namespace kp - -// SPDX-License-Identifier: Apache-2.0 - -namespace kp { - -/** - Abstraction for compute shaders that are run on top of tensors grouped via - ParameterGroups (which group descriptorsets) -*/ -class Algorithm -{ - public: - /** - * Main constructor for algorithm with configuration parameters to create - * the underlying resources. - * - * @param device The Vulkan device to use for creating resources - * @param tensors (optional) The tensors to use to create the descriptor - * resources - * @param spirv (optional) The spirv code to use to create the algorithm - * @param workgroup (optional) The kp::Workgroup to use for the dispatch - * which defaults to kp::Workgroup(tensor[0].size(), 1, 1) if not set. - * @param specializationConstants (optional) The templatable param is to be - * used to initialize the specialization constants which cannot be changed - * once set. - * @param pushConstants (optional) This templatable param is to be used - * when initializing the pipeline, which set the size of the push constants - * - these can be modified but all new values must have the same data type - * and length as otherwise it will result in errors. - */ - template - Algorithm(std::shared_ptr device, - const std::vector>& tensors = {}, - const std::vector& spirv = {}, - const Workgroup& workgroup = {}, - const std::vector& specializationConstants = {}, - const std::vector

& pushConstants = {}) - { - KP_LOG_DEBUG("Kompute Algorithm Constructor with device"); - - this->mDevice = device; - - if (tensors.size() && spirv.size()) { - KP_LOG_INFO( - "Kompute Algorithm initialising with tensor size: {} and " - "spirv size: {}", - tensors.size(), - spirv.size()); - this->rebuild(tensors, - spirv, - workgroup, - specializationConstants, - pushConstants); - } else { - KP_LOG_INFO( - "Kompute Algorithm constructor with empty tensors and or " - "spirv so not rebuilding vulkan components"); - } - } - - /** - * Rebuild function to reconstruct algorithm with configuration parameters - * to create the underlying resources. - * - * @param tensors The tensors to use to create the descriptor resources - * @param spirv The spirv code to use to create the algorithm - * @param workgroup (optional) The kp::Workgroup to use for the dispatch - * which defaults to kp::Workgroup(tensor[0].size(), 1, 1) if not set. - * @param specializationConstants (optional) The std::vector to use - * to initialize the specialization constants which cannot be changed once - * set. - * @param pushConstants (optional) The std::vector to use when - * initializing the pipeline, which set the size of the push constants - - * these can be modified but all new values must have the same vector size - * as this initial value. - */ - template - void rebuild(const std::vector>& tensors, - const std::vector& spirv, - const Workgroup& workgroup = {}, - const std::vector& specializationConstants = {}, - const std::vector

& pushConstants = {}) - { - KP_LOG_DEBUG("Kompute Algorithm rebuild started"); - - this->mTensors = tensors; - this->mSpirv = spirv; - - if (specializationConstants.size()) { - if (this->mSpecializationConstantsData) { - free(this->mSpecializationConstantsData); - } - uint32_t memorySize = - sizeof(decltype(specializationConstants.back())); - uint32_t size = specializationConstants.size(); - uint32_t totalSize = size * memorySize; - this->mSpecializationConstantsData = malloc(totalSize); - memcpy(this->mSpecializationConstantsData, - specializationConstants.data(), - totalSize); - this->mSpecializationConstantsDataTypeMemorySize = memorySize; - this->mSpecializationConstantsSize = size; - } - - if (pushConstants.size()) { - if (this->mPushConstantsData) { - free(this->mPushConstantsData); - } - uint32_t memorySize = sizeof(decltype(pushConstants.back())); - uint32_t size = pushConstants.size(); - uint32_t totalSize = size * memorySize; - this->mPushConstantsData = malloc(totalSize); - memcpy(this->mPushConstantsData, pushConstants.data(), totalSize); - this->mPushConstantsDataTypeMemorySize = memorySize; - this->mPushConstantsSize = size; - } - - this->setWorkgroup( - workgroup, this->mTensors.size() ? this->mTensors[0]->size() : 1); - - // Descriptor pool is created first so if available then destroy all - // before rebuild - if (this->isInit()) { - this->destroy(); - } - - this->createParameters(); - this->createShaderModule(); - this->createPipeline(); - } - - /** - * Destructor for Algorithm which is responsible for freeing and desroying - * respective pipelines and owned parameter groups. - */ - ~Algorithm(); - - /** - * Records the dispatch function with the provided template parameters or - * alternatively using the size of the tensor by default. - * - * @param commandBuffer Command buffer to record the algorithm resources to - */ - void recordDispatch(const vk::CommandBuffer& commandBuffer); - - /** - * Records command that binds the "core" algorithm components which consist - * of binding the pipeline and binding the descriptorsets. - * - * @param commandBuffer Command buffer to record the algorithm resources to - */ - void recordBindCore(const vk::CommandBuffer& commandBuffer); - - /** - * Records command that binds the push constants to the command buffer - * provided - * - it is required that the pushConstants provided are of the same size as - * the ones provided during initialization. - * - * @param commandBuffer Command buffer to record the algorithm resources to - */ - void recordBindPush(const vk::CommandBuffer& commandBuffer); - - /** - * function that checks all the gpu resource components to verify if these - * have been created and returns true if all are valid. - * - * @returns returns true if the algorithm is currently initialized. - */ - bool isInit(); - - /** - * Sets the work group to use in the recordDispatch - * - * @param workgroup The kp::Workgroup value to use to update the algorithm. - * It must have a value greater than 1 on the x value (index 1) otherwise it - * will be initialized on the size of the first tensor (ie. - * this->mTensor[0]->size()) - */ - void setWorkgroup(const Workgroup& workgroup, uint32_t minSize = 1); - /** - * Sets the push constants to the new value provided to use in the next - * bindPush() - * - * @param pushConstants The templatable vector is to be used to set the push - * constants to use in the next bindPush(...) calls. The constants provided - * must be of the same size as the ones created during initialization. - */ - template - void setPushConstants(const std::vector& pushConstants) - { - uint32_t memorySize = sizeof(decltype(pushConstants.back())); - uint32_t size = pushConstants.size(); - - this->setPushConstants(pushConstants.data(), size, memorySize); - } - - /** - * Sets the push constants to the new value provided to use in the next - * bindPush() with the raw memory block location and memory size to be used. - * - * @param data The raw data point to copy the data from, without modifying - * the pointer. - * @param size The number of data elements provided in the data - * @param memorySize The memory size of each of the data elements in bytes. - */ - void setPushConstants(void* data, uint32_t size, uint32_t memorySize) - { - - uint32_t totalSize = memorySize * size; - uint32_t previousTotalSize = - this->mPushConstantsDataTypeMemorySize * this->mPushConstantsSize; - - if (totalSize != previousTotalSize) { - throw std::runtime_error(fmt::format( - "Kompute Algorithm push " - "constant total memory size provided is {} but expected {} bytes", - totalSize, - previousTotalSize)); - } - if (this->mPushConstantsData) { - free(this->mPushConstantsData); - } - - this->mPushConstantsData = malloc(totalSize); - memcpy(this->mPushConstantsData, data, totalSize); - this->mPushConstantsDataTypeMemorySize = memorySize; - this->mPushConstantsSize = size; - } - - /** - * Gets the current workgroup from the algorithm. - * - * @param The kp::Constant to use to set the push constants to use in the - * next bindPush(...) calls. The constants provided must be of the same size - * as the ones created during initialization. - */ - const Workgroup& getWorkgroup(); - /** - * Gets the specialization constants of the current algorithm. - * - * @returns The std::vector currently set for specialization - * constants - */ - template - const std::vector getSpecializationConstants() - { - return { (T*)this->mSpecializationConstantsData, - ((T*)this->mSpecializationConstantsData) + - this->mSpecializationConstantsSize }; - } - /** - * Gets the specialization constants of the current algorithm. - * - * @returns The std::vector currently set for push constants - */ - template - const std::vector getPushConstants() - { - return { (T*)this->mPushConstantsData, - ((T*)this->mPushConstantsData) + this->mPushConstantsSize }; - } - /** - * Gets the current tensors that are used in the algorithm. - * - * @returns The list of tensors used in the algorithm. - */ - const std::vector>& getTensors(); - - void destroy(); - - private: - // -------------- NEVER OWNED RESOURCES - std::shared_ptr mDevice; - std::vector> mTensors; - - // -------------- OPTIONALLY OWNED RESOURCES - std::shared_ptr mDescriptorSetLayout; - bool mFreeDescriptorSetLayout = false; - std::shared_ptr mDescriptorPool; - bool mFreeDescriptorPool = false; - std::shared_ptr mDescriptorSet; - bool mFreeDescriptorSet = false; - std::shared_ptr mShaderModule; - bool mFreeShaderModule = false; - std::shared_ptr mPipelineLayout; - bool mFreePipelineLayout = false; - std::shared_ptr mPipelineCache; - bool mFreePipelineCache = false; - std::shared_ptr mPipeline; - bool mFreePipeline = false; - - // -------------- ALWAYS OWNED RESOURCES - std::vector mSpirv; - void* mSpecializationConstantsData = nullptr; - uint32_t mSpecializationConstantsDataTypeMemorySize = 0; - uint32_t mSpecializationConstantsSize = 0; - void* mPushConstantsData = nullptr; - uint32_t mPushConstantsDataTypeMemorySize = 0; - uint32_t mPushConstantsSize = 0; - Workgroup mWorkgroup; - - // Create util functions - void createShaderModule(); - void createPipeline(); - - // Parameters - void createParameters(); -}; - -} // End namespace kp - -// SPDX-License-Identifier: Apache-2.0 - -namespace kp { - -/** - * Base Operation which provides the high level interface that Kompute - * operations implement in order to perform a set of actions in the GPU. - * - * Operations can perform actions on tensors, and optionally can also own an - * Algorithm with respective parameters. kp::Operations with kp::Algorithms - * would inherit from kp::OpBaseAlgo. - */ -class OpBase -{ - public: - /** - * Default destructor for OpBase class. This OpBase destructor class should - * always be called to destroy and free owned resources unless it is - * intended to destroy the resources in the parent class. - */ - virtual ~OpBase() { KP_LOG_DEBUG("Kompute OpBase destructor started"); } - - /** - * The record function is intended to only send a record command or run - * commands that are expected to record operations that are to be submitted - * as a batch into the GPU. - * - * @param commandBuffer The command buffer to record the command into. - */ - virtual void record(const vk::CommandBuffer& commandBuffer) = 0; - - /** - * Pre eval is called before the Sequence has called eval and submitted the - * commands to the GPU for processing, and can be used to perform any - * per-eval setup steps required as the computation iteration begins. It's - * worth noting that there are situations where eval can be called multiple - * times, so the resources that are created should be idempotent in case - * it's called multiple times in a row. - * - * @param commandBuffer The command buffer to record the command into. - */ - virtual void preEval(const vk::CommandBuffer& commandBuffer) = 0; - - /** - * Post eval is called after the Sequence has called eval and submitted the - * commands to the GPU for processing, and can be used to perform any - * tear-down steps required as the computation iteration finishes. It's - * worth noting that there are situations where eval can be called multiple - * times, so the resources that are destroyed should not require a re-init - * unless explicitly provided by the user. - * - * @param commandBuffer The command buffer to record the command into. - */ - virtual void postEval(const vk::CommandBuffer& commandBuffer) = 0; -}; - -} // End namespace kp - -// SPDX-License-Identifier: Apache-2.0 - -namespace kp { - -/** - * Operation that provides a general abstraction that simplifies the use of - * algorithm and parameter components which can be used with shaders. - * It exposes the pipeline barrier functionality specifically for memory - * barriers that can be configured through the respective source and destination - * masks - */ -class OpMemoryBarrier : public OpBase -{ - public: - /** - * Constructor that stores tensors as well as memory barrier parameters to - * be used to create a pipeline barrier on the respective primary or staging - * tensor. - * - * @param tensors The tensors to apply the memory barriers on - * @param srcAccessMask The kp::AccessFlagBits for the source access mask - * @param dstAccessMask The kp::AccessFlagBits for the destination access - * mask - * @param srcStageMask The kp::PipelineStageFlagBits for the source stage - * mask - * @param dstStageMask The kp::PipelineStageFlagBits for the destination - * stage mask - * @param barrierOnPrimary Boolean to select primary or secondary buffers on - * tensors - */ - OpMemoryBarrier(const std::vector>& tensors, - const vk::AccessFlagBits& srcAccessMask, - const vk::AccessFlagBits& dstAccessMask, - const vk::PipelineStageFlagBits& srcStageMask, - const vk::PipelineStageFlagBits& dstStageMask, - bool barrierOnPrimary = true); - - /** - * Default destructor, which is in charge of destroying the reference to the - * tensors and all the relevant access / stage masks created - */ - virtual ~OpMemoryBarrier() override; - - /** - * This records the memory barrier with the access and stage masks provided - * across all relevant tensors. - * - * @param commandBuffer The command buffer to record the command into. - */ - virtual void record(const vk::CommandBuffer& commandBuffer) override; - - /** - * Does not perform any preEval commands. - * - * @param commandBuffer The command buffer to record the command into. - */ - virtual void preEval(const vk::CommandBuffer& commandBuffer) override; - - /** - * Does not perform any postEval commands. - * - * @param commandBuffer The command buffer to record the command into. - */ - virtual void postEval(const vk::CommandBuffer& commandBuffer) override; - - private: - const vk::AccessFlagBits mSrcAccessMask; - const vk::AccessFlagBits mDstAccessMask; - const vk::PipelineStageFlagBits mSrcStageMask; - const vk::PipelineStageFlagBits mDstStageMask; - const bool mBarrierOnPrimary; - const std::vector> mTensors; -}; - -} // End namespace kp - -// SPDX-License-Identifier: Apache-2.0 - -namespace kp { - -/** - * Operation that copies the data from the first tensor to the rest of the - * tensors provided, using a record command for all the vectors. This operation - * does not own/manage the memory of the tensors passed to it. The operation - * must only receive tensors of type - */ -class OpTensorCopy : public OpBase -{ - public: - /** - * Default constructor with parameters that provides the core vulkan - * resources and the tensors that will be used in the operation. - * - * @param tensors Tensors that will be used to create in operation. - */ - OpTensorCopy(const std::vector>& tensors); - - /** - * Default destructor. This class does not manage memory so it won't be - * expecting the parent to perform a release. - */ - ~OpTensorCopy() override; - - /** - * Records the copy commands from the first tensor into all the other - * tensors provided. Also optionally records a barrier. - * - * @param commandBuffer The command buffer to record the command into. - */ - void record(const vk::CommandBuffer& commandBuffer) override; - - /** - * Does not perform any preEval commands. - * - * @param commandBuffer The command buffer to record the command into. - */ - virtual void preEval(const vk::CommandBuffer& commandBuffer) override; - - /** - * Copies the local vectors for all the tensors to sync the data with the - * gpu. - * - * @param commandBuffer The command buffer to record the command into. - */ - virtual void postEval(const vk::CommandBuffer& commandBuffer) override; - - private: - // -------------- ALWAYS OWNED RESOURCES - std::vector> mTensors; -}; - -} // End namespace kp - -// SPDX-License-Identifier: Apache-2.0 - -namespace kp { - -/** - * Operation that syncs tensor's device by mapping local data into the device - * memory. For TensorTypes::eDevice it will use a record operation for the - * memory to be syncd into GPU memory which means that the operation will be - * done in sync with GPU commands. For TensorTypes::eHost it will only map the - * data into host memory which will happen during preEval before the recorded - * commands are dispatched. - */ -class OpTensorSyncDevice : public OpBase -{ - public: - /** - * Default constructor with parameters that provides the core vulkan - * resources and the tensors that will be used in the operation. The tensos - * provided cannot be of type TensorTypes::eStorage. - * - * @param tensors Tensors that will be used to create in operation. - */ - OpTensorSyncDevice(const std::vector>& tensors); - - /** - * Default destructor. This class does not manage memory so it won't be - * expecting the parent to perform a release. - */ - ~OpTensorSyncDevice() override; - - /** - * For device tensors, it records the copy command for the tensor to copy - * the data from its staging to device memory. - * - * @param commandBuffer The command buffer to record the command into. - */ - void record(const vk::CommandBuffer& commandBuffer) override; - - /** - * Does not perform any preEval commands. - * - * @param commandBuffer The command buffer to record the command into. - */ - virtual void preEval(const vk::CommandBuffer& commandBuffer) override; - - /** - * Does not perform any postEval commands. - * - * @param commandBuffer The command buffer to record the command into. - */ - virtual void postEval(const vk::CommandBuffer& commandBuffer) override; - - private: - // -------------- ALWAYS OWNED RESOURCES - std::vector> mTensors; -}; - -} // End namespace kp - -// SPDX-License-Identifier: Apache-2.0 - -namespace kp { - -/** - * Operation that syncs tensor's local memory by mapping device data into the - * local CPU memory. For TensorTypes::eDevice it will use a record operation - * for the memory to be syncd into GPU memory which means that the operation - * will be done in sync with GPU commands. For TensorTypes::eHost it will - * only map the data into host memory which will happen during preEval before - * the recorded commands are dispatched. - */ -class OpTensorSyncLocal : public OpBase -{ - public: - /** - * Default constructor with parameters that provides the core vulkan - * resources and the tensors that will be used in the operation. The tensors - * provided cannot be of type TensorTypes::eStorage. - * - * @param tensors Tensors that will be used to create in operation. - */ - OpTensorSyncLocal(const std::vector>& tensors); - - /** - * Default destructor. This class does not manage memory so it won't be - * expecting the parent to perform a release. - */ - ~OpTensorSyncLocal() override; - - /** - * For device tensors, it records the copy command for the tensor to copy - * the data from its device to staging memory. - * - * @param commandBuffer The command buffer to record the command into. - */ - void record(const vk::CommandBuffer& commandBuffer) override; - - /** - * Does not perform any preEval commands. - * - * @param commandBuffer The command buffer to record the command into. - */ - virtual void preEval(const vk::CommandBuffer& commandBuffer) override; - - /** - * For host tensors it performs the map command from the host memory into - * local memory. - * - * @param commandBuffer The command buffer to record the command into. - */ - virtual void postEval(const vk::CommandBuffer& commandBuffer) override; - - private: - // -------------- ALWAYS OWNED RESOURCES - std::vector> mTensors; -}; - -} // End namespace kp - -// SPDX-License-Identifier: Apache-2.0 - -namespace kp { - -/** - * Operation that provides a general abstraction that simplifies the use of - * algorithm and parameter components which can be used with shaders. - * By default it enables the user to provide a dynamic number of tensors - * which are then passed as inputs. - */ -class OpAlgoDispatch : public OpBase -{ - public: - /** - * Constructor that stores the algorithm to use as well as the relevant - * push constants to override when recording. - * - * @param algorithm The algorithm object to use for dispatch - * @param pushConstants The push constants to use for override - */ - template - OpAlgoDispatch(const std::shared_ptr& algorithm, - const std::vector& pushConstants = {}) - { - KP_LOG_DEBUG("Kompute OpAlgoDispatch constructor"); - - this->mAlgorithm = algorithm; - - if (pushConstants.size()) { - uint32_t memorySize = sizeof(decltype(pushConstants.back())); - uint32_t size = pushConstants.size(); - uint32_t totalSize = size * memorySize; - this->mPushConstantsData = malloc(totalSize); - memcpy(this->mPushConstantsData, pushConstants.data(), totalSize); - this->mPushConstantsDataTypeMemorySize = memorySize; - this->mPushConstantsSize = size; - } - } - - /** - * Default destructor, which is in charge of destroying the algorithm - * components but does not destroy the underlying tensors - */ - virtual ~OpAlgoDispatch() override; - - /** - * This records the commands that are to be sent to the GPU. This includes - * the barriers that ensure the memory has been copied before going in and - * out of the shader, as well as the dispatch operation that sends the - * shader processing to the gpu. This function also records the GPU memory - * copy of the output data for the staging buffer so it can be read by the - * host. - * - * @param commandBuffer The command buffer to record the command into. - */ - virtual void record(const vk::CommandBuffer& commandBuffer) override; - - /** - * Does not perform any preEval commands. - * - * @param commandBuffer The command buffer to record the command into. - */ - virtual void preEval(const vk::CommandBuffer& commandBuffer) override; - - /** - * Does not perform any postEval commands. - * - * @param commandBuffer The command buffer to record the command into. - */ - virtual void postEval(const vk::CommandBuffer& commandBuffer) override; - - private: - // -------------- ALWAYS OWNED RESOURCES - std::shared_ptr mAlgorithm; - void* mPushConstantsData = nullptr; - uint32_t mPushConstantsDataTypeMemorySize = 0; - uint32_t mPushConstantsSize = 0; -}; - -} // End namespace kp - -// SPDX-License-Identifier: Apache-2.0 - -#include - -namespace kp { - -/** - * Operation that performs multiplication on two tensors and outpus on third - * tensor. - */ -class OpMult : public OpAlgoDispatch -{ - public: - /** - * Default constructor with parameters that provides the bare minimum - * requirements for the operations to be able to create and manage their - * sub-components. - * - * @param tensors Tensors that are to be used in this operation - * @param algorithm An algorithm that will be overridden with the OpMult - * shader data and the tensors provided which are expected to be 3 - */ - OpMult(std::vector> tensors, - std::shared_ptr algorithm) - : OpAlgoDispatch(algorithm) - { - KP_LOG_DEBUG("Kompute OpMult constructor with params"); - - if (tensors.size() != 3) { - throw std::runtime_error( - "Kompute OpMult expected 3 tensors but got " + tensors.size()); - } - - std::vector spirv( - (uint32_t*)shader_data::shaders_glsl_opmult_comp_spv, - (uint32_t*)(shader_data::shaders_glsl_opmult_comp_spv + - kp::shader_data::shaders_glsl_opmult_comp_spv_len)); - - algorithm->rebuild<>(tensors, spirv); - } - - /** - * Default destructor, which is in charge of destroying the algorithm - * components but does not destroy the underlying tensors - */ - virtual ~OpMult() override - { - KP_LOG_DEBUG("Kompute OpMult destructor started"); - } -}; - -} // End namespace kp - -// SPDX-License-Identifier: Apache-2.0 - -namespace kp { - -/** - * Container of operations that can be sent to GPU as batch - */ -class Sequence : public std::enable_shared_from_this -{ - public: - /** - * Main constructor for sequence which requires core vulkan components to - * generate all dependent resources. - * - * @param physicalDevice Vulkan physical device - * @param device Vulkan logical device - * @param computeQueue Vulkan compute queue - * @param queueIndex Vulkan compute queue index in device - * @param totalTimestamps Maximum number of timestamps to allocate - */ - Sequence(std::shared_ptr physicalDevice, - std::shared_ptr device, - std::shared_ptr computeQueue, - uint32_t queueIndex, - uint32_t totalTimestamps = 0); - /** - * Destructor for sequence which is responsible for cleaning all subsequent - * owned operations. - */ - ~Sequence(); - - /** - * Record function for operation to be added to the GPU queue in batch. This - * template requires classes to be derived from the OpBase class. This - * function also requires the Sequence to be recording, otherwise it will - * not be able to add the operation. - * - * @param op Object derived from kp::BaseOp that will be recoreded by the - * sequence which will be used when the operation is evaluated. - * @return shared_ptr of the Sequence class itself - */ - std::shared_ptr record(std::shared_ptr op); - - /** - * Record function for operation to be added to the GPU queue in batch. This - * template requires classes to be derived from the OpBase class. This - * function also requires the Sequence to be recording, otherwise it will - * not be able to add the operation. - * - * @param tensors Vector of tensors to use for the operation - * @param TArgs Template parameters that are used to initialise operation - * which allows for extensible configurations on initialisation. - * @return shared_ptr of the Sequence class itself - */ - template - std::shared_ptr record( - std::vector> tensors, - TArgs&&... params) - { - std::shared_ptr op{ new T(tensors, std::forward(params)...) }; - return this->record(op); - } - /** - * Record function for operation to be added to the GPU queue in batch. This - * template requires classes to be derived from the OpBase class. This - * function also requires the Sequence to be recording, otherwise it will - * not be able to add the operation. - * - * @param algorithm Algorithm to use for the record often used for OpAlgo - * operations - * @param TArgs Template parameters that are used to initialise operation - * which allows for extensible configurations on initialisation. - * @return shared_ptr of the Sequence class itself - */ - template - std::shared_ptr record(std::shared_ptr algorithm, - TArgs&&... params) - { - std::shared_ptr op{ new T(algorithm, - std::forward(params)...) }; - return this->record(op); - } - - /** - * Eval sends all the recorded and stored operations in the vector of - * operations into the gpu as a submit job synchronously (with a barrier). - * - * @return shared_ptr of the Sequence class itself - */ - std::shared_ptr eval(); - - /** - * Resets all the recorded and stored operations, records the operation - * provided and submits into the gpu as a submit job synchronously (with a - * barrier). - * - * @return shared_ptr of the Sequence class itself - */ - std::shared_ptr eval(std::shared_ptr op); - - /** - * Eval sends all the recorded and stored operations in the vector of - * operations into the gpu as a submit job with a barrier. - * - * @param tensors Vector of tensors to use for the operation - * @param TArgs Template parameters that are used to initialise operation - * which allows for extensible configurations on initialisation. - * @return shared_ptr of the Sequence class itself - */ - template - std::shared_ptr eval(std::vector> tensors, - TArgs&&... params) - { - std::shared_ptr op{ new T(tensors, std::forward(params)...) }; - return this->eval(op); - } - /** - * Eval sends all the recorded and stored operations in the vector of - * operations into the gpu as a submit job with a barrier. - * - * @param algorithm Algorithm to use for the record often used for OpAlgo - * operations - * @param TArgs Template parameters that are used to initialise operation - * which allows for extensible configurations on initialisation. - * @return shared_ptr of the Sequence class itself - */ - template - std::shared_ptr eval(std::shared_ptr algorithm, - TArgs&&... params) - { - std::shared_ptr op{ new T(algorithm, - std::forward(params)...) }; - return this->eval(op); - } - - /** - * Eval Async sends all the recorded and stored operations in the vector of - * operations into the gpu as a submit job without a barrier. EvalAwait() - * must ALWAYS be called after to ensure the sequence is terminated - * correctly. - * - * @return Boolean stating whether execution was successful. - */ - std::shared_ptr evalAsync(); - /** - * Clears currnet operations to record provided one in the vector of - * operations into the gpu as a submit job without a barrier. EvalAwait() - * must ALWAYS be called after to ensure the sequence is terminated - * correctly. - * - * @return Boolean stating whether execution was successful. - */ - std::shared_ptr evalAsync(std::shared_ptr op); - /** - * Eval sends all the recorded and stored operations in the vector of - * operations into the gpu as a submit job with a barrier. - * - * @param tensors Vector of tensors to use for the operation - * @param TArgs Template parameters that are used to initialise operation - * which allows for extensible configurations on initialisation. - * @return shared_ptr of the Sequence class itself - */ - template - std::shared_ptr evalAsync( - std::vector> tensors, - TArgs&&... params) - { - std::shared_ptr op{ new T(tensors, std::forward(params)...) }; - return this->evalAsync(op); - } - /** - * Eval sends all the recorded and stored operations in the vector of - * operations into the gpu as a submit job with a barrier. - * - * @param algorithm Algorithm to use for the record often used for OpAlgo - * operations - * @param TArgs Template parameters that are used to initialise operation - * which allows for extensible configurations on initialisation. - * @return shared_ptr of the Sequence class itself - */ - template - std::shared_ptr evalAsync(std::shared_ptr algorithm, - TArgs&&... params) - { - std::shared_ptr op{ new T(algorithm, - std::forward(params)...) }; - return this->evalAsync(op); - } - - /** - * Eval Await waits for the fence to finish processing and then once it - * finishes, it runs the postEval of all operations. - * - * @param waitFor Number of milliseconds to wait before timing out. - * @return shared_ptr of the Sequence class itself - */ - std::shared_ptr evalAwait(uint64_t waitFor = UINT64_MAX); - - /** - * Clear function clears all operations currently recorded and starts - * recording again. - */ - void clear(); - - /** - * Return the timestamps that were latched at the beginning and - * after each operation during the last eval() call. - */ - std::vector getTimestamps(); - - /** - * Begins recording commands for commands to be submitted into the command - * buffer. - * - * @return Boolean stating whether execution was successful. - */ - void begin(); - - /** - * Ends the recording and stops recording commands when the record command - * is sent. - * - * @return Boolean stating whether execution was successful. - */ - void end(); - - /** - * Returns true if the sequence is currently in recording activated. - * - * @return Boolean stating if recording ongoing. - */ - [[nodiscard]] bool isRecording() const; - - /** - * Returns true if the sequence has been initialised, and it's based on the - * GPU resources being referenced. - * - * @return Boolean stating if is initialized - */ - [[nodiscard]] bool isInit() const; - - /** - * Clears command buffer and triggers re-record of all the current - * operations saved, which is useful if the underlying kp::Tensors or - * kp::Algorithms are modified and need to be re-recorded. - */ - void rerecord(); - - /** - * Returns true if the sequence is currently running - mostly used for async - * workloads. - * - * @return Boolean stating if currently running. - */ - [[nodiscard]] bool isRunning() const; - - /** - * Destroys and frees the GPU resources which include the buffer and memory - * and sets the sequence as init=False. - */ - void destroy(); - - private: - // -------------- NEVER OWNED RESOURCES - std::shared_ptr mPhysicalDevice = nullptr; - std::shared_ptr mDevice = nullptr; - std::shared_ptr mComputeQueue = nullptr; - uint32_t mQueueIndex = -1; - - // -------------- OPTIONALLY OWNED RESOURCES - std::shared_ptr mCommandPool = nullptr; - bool mFreeCommandPool = false; - std::shared_ptr mCommandBuffer = nullptr; - bool mFreeCommandBuffer = false; - - // -------------- ALWAYS OWNED RESOURCES - vk::Fence mFence; - std::vector> mOperations; - std::shared_ptr timestampQueryPool = nullptr; - - // State - bool mRecording = false; - bool mIsRunning = false; - - // Create functions - void createCommandPool(); - void createCommandBuffer(); - void createTimestampQueryPool(uint32_t totalTimestamps); -}; - -} // End namespace kp - -// SPDX-License-Identifier: Apache-2.0 - -#include -#include - -#define KP_DEFAULT_SESSION "DEFAULT" - -namespace kp { - -/** - Base orchestrator which creates and manages device and child components -*/ -class Manager -{ - public: - /** - Base constructor and default used which creates the base resources - including choosing the device 0 by default. - */ - Manager(); - - /** - * Similar to base constructor but allows for further configuration to use - * when creating the Vulkan resources. - * - * @param physicalDeviceIndex The index of the physical device to use - * @param familyQueueIndices (Optional) List of queue indices to add for - * explicit allocation - * @param desiredExtensions The desired extensions to load from - * physicalDevice - */ - Manager(uint32_t physicalDeviceIndex, - const std::vector& familyQueueIndices = {}, - const std::vector& desiredExtensions = {}); - - /** - * Manager constructor which allows your own vulkan application to integrate - * with the kompute use. - * - * @param instance Vulkan compute instance to base this application - * @param physicalDevice Vulkan physical device to use for application - * @param device Vulkan logical device to use for all base resources - * @param physicalDeviceIndex Index for vulkan physical device used - */ - Manager(std::shared_ptr instance, - std::shared_ptr physicalDevice, - std::shared_ptr device); - - /** - * Manager destructor which would ensure all owned resources are destroyed - * unless explicitly stated that resources should not be destroyed or freed. - */ - ~Manager(); - - /** - * Create a managed sequence that will be destroyed by this manager - * if it hasn't been destroyed by its reference count going to zero. - * - * @param queueIndex The queue to use from the available queues - * @param nrOfTimestamps The maximum number of timestamps to allocate. - * If zero (default), disables latching of timestamps. - * @returns Shared pointer with initialised sequence - */ - std::shared_ptr sequence(uint32_t queueIndex = 0, - uint32_t totalTimestamps = 0); - - /** - * Create a managed tensor that will be destroyed by this manager - * if it hasn't been destroyed by its reference count going to zero. - * - * @param data The data to initialize the tensor with - * @param tensorType The type of tensor to initialize - * @returns Shared pointer with initialised tensor - */ - template - std::shared_ptr> tensorT( - const std::vector& data, - Tensor::TensorTypes tensorType = Tensor::TensorTypes::eDevice) - { - KP_LOG_DEBUG("Kompute Manager tensor creation triggered"); - - std::shared_ptr> tensor{ new kp::TensorT( - this->mPhysicalDevice, this->mDevice, data, tensorType) }; - - if (this->mManageResources) { - this->mManagedTensors.push_back(tensor); - } - - return tensor; - } - - std::shared_ptr> tensor( - const std::vector& data, - Tensor::TensorTypes tensorType = Tensor::TensorTypes::eDevice) - { - return this->tensorT(data, tensorType); - } - - std::shared_ptr tensor( - void* data, - uint32_t elementTotalCount, - uint32_t elementMemorySize, - const Tensor::TensorDataTypes& dataType, - Tensor::TensorTypes tensorType = Tensor::TensorTypes::eDevice) - { - std::shared_ptr tensor{ new kp::Tensor(this->mPhysicalDevice, - this->mDevice, - data, - elementTotalCount, - elementMemorySize, - dataType, - tensorType) }; - - if (this->mManageResources) { - this->mManagedTensors.push_back(tensor); - } - - return tensor; - } - - /** - * Default non-template function that can be used to create algorithm - * objects which provides default types to the push and spec constants as - * floats. - * - * @param tensors (optional) The tensors to initialise the algorithm with - * @param spirv (optional) The SPIRV bytes for the algorithm to dispatch - * @param workgroup (optional) kp::Workgroup for algorithm to use, and - * defaults to (tensor[0].size(), 1, 1) - * @param specializationConstants (optional) float vector to use for - * specialization constants, and defaults to an empty constant - * @param pushConstants (optional) float vector to use for push constants, - * and defaults to an empty constant - * @returns Shared pointer with initialised algorithm - */ - std::shared_ptr algorithm( - const std::vector>& tensors = {}, - const std::vector& spirv = {}, - const Workgroup& workgroup = {}, - const std::vector& specializationConstants = {}, - const std::vector& pushConstants = {}) - { - return this->algorithm<>( - tensors, spirv, workgroup, specializationConstants, pushConstants); - } - - /** - * Create a managed algorithm that will be destroyed by this manager - * if it hasn't been destroyed by its reference count going to zero. - * - * @param tensors (optional) The tensors to initialise the algorithm with - * @param spirv (optional) The SPIRV bytes for the algorithm to dispatch - * @param workgroup (optional) kp::Workgroup for algorithm to use, and - * defaults to (tensor[0].size(), 1, 1) - * @param specializationConstants (optional) templatable vector parameter to - * use for specialization constants, and defaults to an empty constant - * @param pushConstants (optional) templatable vector parameter to use for - * push constants, and defaults to an empty constant - * @returns Shared pointer with initialised algorithm - */ - template - std::shared_ptr algorithm( - const std::vector>& tensors, - const std::vector& spirv, - const Workgroup& workgroup, - const std::vector& specializationConstants, - const std::vector

& pushConstants) - { - - KP_LOG_DEBUG("Kompute Manager algorithm creation triggered"); - - std::shared_ptr algorithm{ new kp::Algorithm( - this->mDevice, - tensors, - spirv, - workgroup, - specializationConstants, - pushConstants) }; - - if (this->mManageResources) { - this->mManagedAlgorithms.push_back(algorithm); - } - - return algorithm; - } - - /** - * Destroy the GPU resources and all managed resources by manager. - **/ - void destroy(); - /** - * Run a pseudo-garbage collection to release all the managed resources - * that have been already freed due to these reaching to zero ref count. - **/ - void clear(); - - /** - * Information about the current device. - * - * @return vk::PhysicalDeviceProperties containing information about the - *device - **/ - vk::PhysicalDeviceProperties getDeviceProperties() const; - - /** - * List the devices available in the current vulkan instance. - * - * @return vector of physical devices containing their respective properties - **/ - std::vector listDevices() const; - - private: - // -------------- OPTIONALLY OWNED RESOURCES - std::shared_ptr mInstance = nullptr; - bool mFreeInstance = false; - std::shared_ptr mPhysicalDevice = nullptr; - std::shared_ptr mDevice = nullptr; - bool mFreeDevice = false; - - // -------------- ALWAYS OWNED RESOURCES - std::vector> mManagedTensors; - std::vector> mManagedSequences; - std::vector> mManagedAlgorithms; - - std::vector mComputeQueueFamilyIndices; - std::vector> mComputeQueues; - - bool mManageResources = false; - -#if DEBUG -#ifndef KOMPUTE_DISABLE_VK_DEBUG_LAYERS - vk::DebugReportCallbackEXT mDebugReportCallback; - vk::DispatchLoaderDynamic mDebugDispatcher; -#endif -#endif - - // Create functions - void createInstance(); - void createDevice(const std::vector& familyQueueIndices = {}, - uint32_t hysicalDeviceIndex = 0, - const std::vector& desiredExtensions = {}); -}; - -} // End namespace kp - -/** - * fmt fromater for kp::Tensor::TensorDataTypes. - */ -template<> -struct fmt::formatter : formatter -{ - template - auto format(kp::Tensor::TensorDataTypes dt, FormatContext& ctx) - { - std::string name = "unknown"; - switch (dt) { - case kp::Tensor::TensorDataTypes::eBool: - name = "eBool"; - break; - case kp::Tensor::TensorDataTypes::eDouble: - name = "eDouble"; - break; - case kp::Tensor::TensorDataTypes::eFloat: - name = "eFloat"; - break; - case kp::Tensor::TensorDataTypes::eInt: - name = "eInt"; - break; - case kp::Tensor::TensorDataTypes::eUnsignedInt: - name = "eUnsignedInt"; - break; - } - return formatter::format(name, ctx); - } -}; - -/** - * fmt fromater for kp::Tensor::TensorTypes. - */ -template<> -struct fmt::formatter : formatter -{ - template - auto format(kp::Tensor::TensorTypes dt, FormatContext& ctx) - { - std::string name = "unknown"; - switch (dt) { - case kp::Tensor::TensorTypes::eDevice: - name = "eDevice"; - break; - case kp::Tensor::TensorTypes::eHost: - name = "eHost"; - break; - case kp::Tensor::TensorTypes::eStorage: - name = "eStorage"; - break; - } - return formatter::format(name, ctx); - } -}; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 44753cd4c..ae472e62b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,124 +1,103 @@ # SPDX-License-Identifier: Apache-2.0 +cmake_minimum_required(VERSION 3.15) + if(KOMPUTE_OPT_ANDROID_BUILD) find_library(android android) endif() -if(KOMPUTE_OPT_BUILD_SHADERS) -# all shaders are compiled into cpp files - kompute_make(build_shaders - OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/include) +cmake_minimum_required(VERSION 3.15) + +add_library(kompute Algorithm.cpp + Manager.cpp + OpAlgoDispatch.cpp + OpMemoryBarrier.cpp + OpTensorCopy.cpp + OpTensorSyncDevice.cpp + OpTensorSyncLocal.cpp + Sequence.cpp + Tensor.cpp) + +add_library(kompute::kompute ALIAS kompute) + +# Set version for shared libraries. +set_target_properties(kompute + PROPERTIES + VERSION ${${PROJECT_NAME}_VERSION} + SOVERSION ${${PROJECT_NAME}_VERSION_MAJOR}) + +# Import GNU common install directory variables +include(GNUInstallDirs) + +if(CPR_FORCE_USE_SYSTEM_CURL) + install(TARGETS kompute + EXPORT komputeTargets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) + + # Include CMake helpers for package config files + # Follow this installation guideline: https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html + include(CMakePackageConfigHelpers) + + configure_package_config_file(${PROJECT_SOURCE_DIR}/cmake/komputeConfig.cmake.in + "${PROJECT_BINARY_DIR}/kompute/komputeConfig.cmake" + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kompute) + + install(EXPORT komputeTargets + FILE komputeTargets.cmake + NAMESPACE kompute:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kompute) + + install(FILES ${PROJECT_BINARY_DIR}/kompute/komputeConfig.cmake + ${PROJECT_BINARY_DIR}/kompute/komputeConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kompute) + +else() + install(TARGETS kompute + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() -if(KOMPUTE_OPT_BUILD_SINGLE_HEADER) -# all headers are compiled into a single header - kompute_make(build_single_header - OUTPUT ${PROJECT_SOURCE_DIR}/single_include) -endif() - -file(GLOB kompute_CPP - "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp" -) +##################################################### +# Android +##################################################### if(KOMPUTE_OPT_ANDROID_BUILD) set(VK_ANDROID_COMMON_DIR ${ANDROID_NDK}/sources/third_party/vulkan/src/common) set(VK_ANDROID_PATCH_DIR ${PROJECT_SOURCE_DIR}/vk_ndk_wrapper_include/) set(VK_ANDROID_INCLUDE_DIR ${ANDROID_NDK}/sources/third_party/vulkan/src/include) - include_directories( - ${VK_ANDROID_COMMON_DIR} - ${VK_ANDROID_PATCH_DIR} - ${VK_ANDROID_INCLUDE_DIR}) + include_directories(${VK_ANDROID_COMMON_DIR} + ${VK_ANDROID_PATCH_DIR} + ${VK_ANDROID_INCLUDE_DIR}) - add_library(kompute_vk_ndk_wrapper STATIC - ${PROJECT_SOURCE_DIR}/vk_ndk_wrapper_include/kompute_vk_ndk_wrapper.cpp) + add_library(kompute_vk_ndk_wrapper STATIC ${PROJECT_SOURCE_DIR}/vk_ndk_wrapper_include/kompute_vk_ndk_wrapper.cpp) endif() -if(NOT KOMPUTE_OPT_BUILD_AS_SHARED_LIB) - add_library( - kompute STATIC - ${kompute_CPP}) -else() - add_library( - kompute SHARED - ${kompute_CPP}) -endif() - -target_include_directories( - kompute PUBLIC - $ - $ -) +##################################################### +# Linking +##################################################### if(KOMPUTE_OPT_ANDROID_BUILD) - target_link_libraries(kompute - fmt::fmt) + target_link_libraries(kompute PRIVATE fmt::fmt + kompute_vk_ndk_wrapper + log + android) else() - target_link_libraries(kompute - Vulkan::Vulkan - fmt::fmt) + target_link_libraries(kompute PRIVATE Vulkan::Vulkan + fmt::fmt) endif() if(KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER) - target_link_libraries(kompute - Vulkan-Headers) + target_link_libraries(kompute PUBLIC Vulkan-Headers) +endif() + +if(KOMPUTE_OPT_ENABLE_LOGGING) + target_link_libraries(kompute PRIVATE spdlog::spdlog) endif() ##################################################### -#################### SPDLOG ######################### +# Misc ##################################################### - -if(KOMPUTE_OPT_ENABLE_SPDLOG) - target_link_libraries(kompute spdlog::spdlog) -endif() - -##################################################### -#################### Android ######################## -##################################################### - -if(KOMPUTE_OPT_ANDROID_BUILD) - target_link_libraries(kompute - kompute_vk_ndk_wrapper - log - android) -endif() - -##################################################### -########## Built C++ Header SHADERS ################# -##################################################### - -if(KOMPUTE_OPT_BUILD_SHADERS) - add_dependencies(kompute - build_shaders) -endif() - -##################################################### -#################### Single Header ################## -##################################################### - -if(KOMPUTE_OPT_BUILD_SINGLE_HEADER) - add_dependencies(kompute - build_single_header) -endif() - - -add_library(kompute::kompute ALIAS kompute) - -if(KOMPUTE_OPT_INSTALL) - install(TARGETS kompute EXPORT KomputeTargets - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - INCLUDES DESTINATION include) - - target_include_directories(kompute PUBLIC $) - - install(DIRECTORY include/ DESTINATION include) - - install(DIRECTORY ${PROJECT_SOURCE_DIR}/single_include/ - DESTINATION include) - - install(EXPORT KomputeTargets - FILE komputeConfig.cmake - NAMESPACE kompute:: - DESTINATION lib/cmake/kompute) -endif() +add_subdirectory(include) diff --git a/src/include/CMakeLists.txt b/src/include/CMakeLists.txt new file mode 100644 index 000000000..9f75d06a0 --- /dev/null +++ b/src/include/CMakeLists.txt @@ -0,0 +1,27 @@ +cmake_minimum_required(VERSION 3.15) + +target_include_directories(kompute PUBLIC $ + $) + +target_sources(kompute PRIVATE + # Header files (useful in IDEs) + kompute/Algorithm.hpp + kompute/Core.hpp + kompute/Kompute.hpp + kompute/Manager.hpp + kompute/Sequence.hpp + kompute/Tensor.hpp + + kompute/operations/OpAlgoDispatch.hpp + kompute/operations/OpBase.hpp + kompute/operations/OpMemoryBarrier.hpp + kompute/operations/OpMult.hpp + kompute/operations/OpTensorCopy.hpp + kompute/operations/OpTensorSyncDevice.hpp + kompute/operations/OpTensorSyncLocal.hpp + + kompute/shaders/shaderlogisticregression.hpp + kompute/shaders/shaderopmult.hpp +) + +install(DIRECTORY kompute DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) diff --git a/src/include/kompute/Kompute.hpp b/src/include/kompute/Kompute.hpp new file mode 100644 index 000000000..c5663ab74 --- /dev/null +++ b/src/include/kompute/Kompute.hpp @@ -0,0 +1,18 @@ +#pragma once + +#include "Algorithm.hpp" +#include "Core.hpp" +#include "Manager.hpp" +#include "Sequence.hpp" +#include "Tensor.hpp" + +#include "operations/OpAlgoDispatch.hpp" +#include "operations/OpBase.hpp" +#include "operations/OpMemoryBarrier.hpp" +#include "operations/OpMult.hpp" +#include "operations/OpTensorCopy.hpp" +#include "operations/OpTensorSyncDevice.hpp" +#include "operations/OpTensorSyncLocal.hpp" + +#include "shaders/shaderlogisticregression.hpp" +#include "shaders/shaderopmult.hpp" diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d1d949bdb..8311253a1 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,81 +1,42 @@ # SPDX-License-Identifier: Apache-2.0 +####################### +cmake_minimum_required(VERSION 3.15) ##################################################### -#################### GOOGLETEST ##################### +# Shaders ##################################################### -enable_testing() - -file(GLOB test_kompute_CPP - "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp" -) - -add_executable(test_kompute ${test_kompute_CPP}) - -target_include_directories( - test_kompute PUBLIC - $ - $ - $ -) -target_link_libraries(test_kompute kompute GTest::GTest) - -add_test(NAME test_kompute COMMAND test_kompute) - +add_subdirectory(shaders) ##################################################### -#################### CODECOV ####################### +# Tests ##################################################### -if (KOMPUTE_OPT_CODE_COVERAGE) - if(NOT UNIX) - message( - FATAL_ERROR - "KOMPUTE_OPT_CODE_COVERAGE can only be enabled in unix based systems due to limitation on gcov") +macro(add_kompute_test _TEST_NAME) + add_executable("${_TEST_NAME}_tests" "Test${_TEST_NAME}.cpp" + ${ARGN}) + target_link_libraries("${_TEST_NAME}_tests" PRIVATE GTest::GTest + kompute::kompute + test_shaders + test_shaders_glsl) + add_test(NAME "kompute_${_TEST_NAME}_tests" COMMAND "${_TEST_NAME}_tests") + # Group under the "tests" project folder in IDEs such as Visual Studio. + set_property(TARGET ${_TEST_NAME}_tests PROPERTY FOLDER "tests") + if(WIN32 AND BUILD_SHARED_LIBS) + add_custom_command(TARGET ${_TEST_NAME}_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ $) + add_custom_command(TARGET ${_TEST_NAME}_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ $) endif() +endmacro() - add_custom_target(codecov_run_tests - COMMAND make -C ${PROJECT_SOURCE_DIR} mk_run_tests - DEPENDS test_kompute) - - add_custom_target(codecov_copy_files - COMMAND ${CMAKE_COMMAND} - -E copy_directory - ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/test_kompute.dir/ - ${CODECOV_DIR} - COMMAND ${CMAKE_COMMAND} - -E copy_directory - ${CMAKE_CURRENT_BINARY_DIR}/../src/CMakeFiles/kompute.dir/ - ${CODECOV_DIR} - DEPENDS test_kompute codecov_run_tests) - - add_custom_target(codecov_gcov - COMMAND gcov - -b -c "*.gcno" - WORKING_DIRECTORY ${CODECOV_DIR} - DEPENDS codecov_copy_files) - - add_custom_target(codecov_lcov_capture - COMMAND lcov - --capture - -o ${CODECOV_FILENAME_LCOV_INFO_FULL} - -d . - WORKING_DIRECTORY ${CODECOV_DIR} - DEPENDS codecov_gcov) - add_custom_target(codecov_lcov_extract - COMMAND lcov - --extract - ${CODECOV_FILENAME_LCOV_INFO_FULL} - -o ${CODECOV_FILENAME_LCOV_INFO} - -d . - "*/src/*" - WORKING_DIRECTORY ${CODECOV_DIR} - DEPENDS codecov_lcov_capture) - - add_custom_target(codecov_genhtml - COMMAND genhtml - ${CODECOV_FILENAME_LCOV_INFO} - --output-directory ${CODECOV_DIR_HTML} - WORKING_DIRECTORY ${CODECOV_DIR} - DEPENDS codecov_lcov_extract) -endif() - +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) +add_kompute_test(OpTensorCopy) +add_kompute_test(OpTensorCreate) +add_kompute_test(PushConstant) +add_kompute_test(Sequence) +add_kompute_test(SpecializationConstant) +add_kompute_test(Workgroup) diff --git a/test/TestAsyncOperations.cpp b/test/TestAsyncOperations.cpp index cacc41da4..bd52ff390 100644 --- a/test/TestAsyncOperations.cpp +++ b/test/TestAsyncOperations.cpp @@ -6,8 +6,6 @@ #include "kompute/Kompute.hpp" -#include "kompute_test/Shader.hpp" - TEST(TestAsyncOperations, TestManagerParallelExecution) { // This test is built for NVIDIA 1650. It assumes: diff --git a/test/TestDestroy.cpp b/test/TestDestroy.cpp index 8ae824756..e81e3903c 100644 --- a/test/TestDestroy.cpp +++ b/test/TestDestroy.cpp @@ -4,7 +4,7 @@ #include "kompute/Kompute.hpp" -#include "kompute_test/Shader.hpp" +#include "shaders/Utils.hpp" TEST(TestDestroy, TestDestroyTensorSingle) { diff --git a/test/TestLogisticRegression.cpp b/test/TestLogisticRegression.cpp index b1ffaef84..d149c4772 100644 --- a/test/TestLogisticRegression.cpp +++ b/test/TestLogisticRegression.cpp @@ -4,7 +4,7 @@ #include "kompute/Kompute.hpp" -#include "kompute_test/shaders/shadertest_logistic_regression.hpp" +#include "test_logistic_regression.hpp" TEST(TestLogisticRegression, TestMainLogisticRegression) { @@ -40,12 +40,11 @@ TEST(TestLogisticRegression, TestMainLogisticRegression) mgr.sequence()->eval(params); std::vector spirv = std::vector( - (uint32_t*)kp::shader_data:: - test_shaders_glsl_test_logistic_regression_comp_spv, - (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)); + (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::shared_ptr algorithm = mgr.algorithm( params, spirv, kp::Workgroup({ 5 }), std::vector({ 5.0 })); diff --git a/test/TestMultipleAlgoExecutions.cpp b/test/TestMultipleAlgoExecutions.cpp index f554f54fe..40d15d6e7 100644 --- a/test/TestMultipleAlgoExecutions.cpp +++ b/test/TestMultipleAlgoExecutions.cpp @@ -4,7 +4,7 @@ #include "kompute/Kompute.hpp" -#include "kompute_test/Shader.hpp" +#include "shaders/Utils.hpp" TEST(TestMultipleAlgoExecutions, TestEndToEndFunctionality) { diff --git a/test/TestOpShadersFromStringAndFile.cpp b/test/TestOpShadersFromStringAndFile.cpp index 7033816e1..550f9e26c 100644 --- a/test/TestOpShadersFromStringAndFile.cpp +++ b/test/TestOpShadersFromStringAndFile.cpp @@ -6,7 +6,7 @@ #include "kompute_test/shaders/shadertest_op_custom_shader.hpp" -#include "kompute_test/Shader.hpp" +#include "shaders/Utils.hpp" TEST(TestOpAlgoCreate, ShaderRawDataFromConstructor) { diff --git a/test/TestOpTensorCopy.cpp b/test/TestOpTensorCopy.cpp index c76db8979..a272efbd4 100644 --- a/test/TestOpTensorCopy.cpp +++ b/test/TestOpTensorCopy.cpp @@ -4,7 +4,7 @@ #include "kompute/Kompute.hpp" -#include "kompute_test/Shader.hpp" +#include "shaders/Utils.hpp" TEST(TestOpTensorCopy, CopyDeviceToDeviceTensor) { diff --git a/test/TestPushConstant.cpp b/test/TestPushConstant.cpp index c305f089c..94f6afc47 100644 --- a/test/TestPushConstant.cpp +++ b/test/TestPushConstant.cpp @@ -4,7 +4,7 @@ #include "kompute/Kompute.hpp" -#include "kompute_test/Shader.hpp" +#include "shaders/Utils.hpp" #include "fmt/ranges.h" diff --git a/test/TestSequence.cpp b/test/TestSequence.cpp index 6e9687562..7ab14a646 100644 --- a/test/TestSequence.cpp +++ b/test/TestSequence.cpp @@ -4,7 +4,7 @@ #include "kompute/Kompute.hpp" -#include "kompute_test/Shader.hpp" +#include "shaders/Utils.hpp" TEST(TestSequence, SequenceDestructorViaManager) { diff --git a/test/TestSpecializationConstant.cpp b/test/TestSpecializationConstant.cpp index e7bb39266..a1fc4bb3e 100644 --- a/test/TestSpecializationConstant.cpp +++ b/test/TestSpecializationConstant.cpp @@ -4,7 +4,7 @@ #include "kompute/Kompute.hpp" -#include "kompute_test/Shader.hpp" +#include "shaders/Utils.hpp" TEST(TestSpecializationConstants, TestTwoConstants) { diff --git a/test/shaders/CMakeLists.txt b/test/shaders/CMakeLists.txt new file mode 100644 index 000000000..64fd07f51 --- /dev/null +++ b/test/shaders/CMakeLists.txt @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: Apache-2.0 +####################### +cmake_minimum_required(VERSION 3.15) + +add_library(test_shaders "Utils.cpp" + "Utils.hpp") + +add_subdirectory(glsl) \ No newline at end of file diff --git a/test/utils/kompute_test/Shader.hpp b/test/shaders/Utils.cpp similarity index 51% rename from test/utils/kompute_test/Shader.hpp rename to test/shaders/Utils.cpp index 33f81f122..85a38b568 100644 --- a/test/utils/kompute_test/Shader.hpp +++ b/test/shaders/Utils.cpp @@ -1,21 +1,13 @@ // SPDX-License-Identifier: Apache-2.0 -#pragma once - +#include "Utils.hpp" +#include #include #include +#include #include -/** - * Compile a single glslang source from string value. This is only meant - * to be used for testing as it's non threadsafe, and it had to be removed - * from the glslang dependency and now can only run the CLI directly due to - * license issues: see https://github.com/KomputeProject/kompute/pull/235 - * - * @param source An individual raw glsl shader in string format - * @return The compiled SPIR-V binary in unsigned int32 format - */ -static std::vector +std::vector compileSource(const std::string& source) { std::ofstream fileOut("tmp_kp_shader.comp"); @@ -24,12 +16,13 @@ compileSource(const std::string& source) if (system( std::string( "glslangValidator -V tmp_kp_shader.comp -o tmp_kp_shader.comp.spv") - .c_str())) + .c_str())) { throw std::runtime_error("Error running glslangValidator command"); + } std::ifstream fileStream("tmp_kp_shader.comp.spv", std::ios::binary); std::vector buffer; buffer.insert( buffer.begin(), std::istreambuf_iterator(fileStream), {}); - return { (uint32_t*)buffer.data(), - (uint32_t*)(buffer.data() + buffer.size()) }; + return { reinterpret_cast(buffer.data()), + reinterpret_cast(buffer.data() + buffer.size()) }; } diff --git a/test/shaders/Utils.hpp b/test/shaders/Utils.hpp new file mode 100644 index 000000000..fa8aa9729 --- /dev/null +++ b/test/shaders/Utils.hpp @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include +#include +#include + +/** + * Compile a single glslang source from string value. This is only meant + * to be used for testing as it's non threadsafe, and it had to be removed + * from the glslang dependency and now can only run the CLI directly due to + * license issues: see https://github.com/KomputeProject/kompute/pull/235 + * + * @param source An individual raw glsl shader in string format + * @return The compiled SPIR-V binary in unsigned int32 format + */ +std::vector +compileSource(const std::string& source); diff --git a/test/shaders/glsl/CMakeLists.txt b/test/shaders/glsl/CMakeLists.txt new file mode 100644 index 000000000..41e207728 --- /dev/null +++ b/test/shaders/glsl/CMakeLists.txt @@ -0,0 +1,22 @@ +# SPDX-License-Identifier: Apache-2.0 +####################### +cmake_minimum_required(VERSION 3.15) + +vulkan_compile_shader(INFILE test_logistic_regression.comp + OUTFILE test_logistic_regression.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 + NAMESPACE "kp") + +add_library(test_shaders_glsl "${CMAKE_CURRENT_BINARY_DIR}/test_logistic_regression.hpp" + "${CMAKE_CURRENT_BINARY_DIR}/test_op_custom_shader.hpp" + "${CMAKE_CURRENT_BINARY_DIR}/test_workgroup.hpp") + +set_target_properties(test_shaders_glsl PROPERTIES LINKER_LANGUAGE CXX) +target_include_directories(test_shaders_glsl PUBLIC $) diff --git a/test/shaders/glsl/test_logistic_regression.comp.spv b/test/shaders/glsl/test_logistic_regression.comp.spv deleted file mode 100755 index 2f6883dac6c1f40a2928ccf8e8b37c6fa6d68ac1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4816 zcmZ9P_jgrA6on^wFNzQlR6uNthy}|+#eyt~2GD@U-UZ8hDHsijCV>PSQ3NaY-W3)5 zAK_o+FS`7`d*_&0xoe$u_TF>Op1E^pUZByr=H!$*(!#VL{h8`#S?WYdX;C_<%63I7YBi;A+Z3uPf= zlOucgjgJhj9lmN4N+X?u_AJrG8c!pSj13P>42=y8tvxWjev@IP;|*66_g(bm*Z|M=vjGu0M&G}Cg%5AJMDkt)v>@{D`P^;(+gV)g&)nrSWk z>DEMRU#{Is9vPge*4+!+(*gY2WwjO?gr2N-`hx!ST{3LeLb-cwCa1T zrWGCpw`ZQL>cl?KYHYZsmH$)VgN46)(`GY$C$UfL?RZVAzDf0BZ~Yi^d)rJ0=5fFI z+;}5B2OoU6Ue6)%12vun$M-p^zD>QE-UPR&$M;Y1uAXSQPnJ*`=~yjQ^&fz%dfwT3 zxsUZoRsBbmQu}`iZnqgETQB#?QdR$TErFZqxMQPp^>UvqRrNpCQdNHfJoo<1^h?3} z@bmmFBF-V?edLn}@83=w;(V=v`}Fa?YTk6~J#Xg|KEb^UF@7Jo^ouiB`l&^|XR!2> z>!*kQdoqso#aS%<)WXlRS^CNK^U-gBT&^$9Z0V;Ke#79>Pp)4Fq2DOE^oz4x`l*GV zXS?*1>(@!>H%r#rNB#!6^pEpc`m2S%XS4K|>+k;Q_ddDwi}PCgsfC|sxAc?i=Wo4! zUyw_`IM1b@TKIXkOFy}O{PC&$z9*M{$KgJupIZ2N_DesxehUcK_XpYYzKS@VUG60J z&~3kX1<3hUSJAB2;ab#s=+{TAwi4c*xxK65i}RRz50y*uxO$BBuv=$jT_58zdi8Z( zDb3!n9KIQ}TFRsM7P7VK&V571uHEq)$sL6Hrp$Y@roVmL2p{XWldV@jm-p@?yN2_? z-f_8gyU4zun!a-Hy_)O1mAsnJ%X#Gegpd8Vk*(D`#_t4M@4WFF;k^D9$nE2&x$0AM zUb(*qdfB&!9P9PY%k6uVY>k?Ia_@cg4S=K1yDhhGDA%ajCm+t5^TpkEo%_(`_W6$+ zz18fKdym!D!<}oE@X;skus+^Zxjt`^?NQT5ek^PD#a*?}J1MvC!(5|gpWJ(?SA6$R zz#W7>aYyy}5>2kpS7dwC^pSfX)$IG89Q$@0EVu6mvNdY<$-Q@Km($^S{DW`}5!Z1C z9B&dn4dQQVE=7Ou=TX4sB7u@lu=JCmbTR%0AA1Ju}{@WquH$PW! z`wtb|@uTzjiFw?=z1H>emfOiYDqP>mExhAq_)S^g%8vN{@?Q4vHuCL+_pU#OJ${cn z2*;xCE^yR&&!X;buw!>Je>eFa!d`XfbAQ#s=OM87ZT@`x^C>xIkKaHZ>wmn`=R8_) z@17oy6S0;y*sTc!wv!da1h}&wyI^K3(Z^zR$qDoBBEy zz7t@_^zhus9qT6VC-im9Gb4|&X|Vg|nCC|xo(IA1k7J%C`9@BF-^~9joJQzppX1hf zMjZ=}=fP^hUjVzl!+b-1UL>qhx8F0W_F5i)3A~D!C1TAlgMFX3^Eo&SRtO5D^*Bmab576x+m-IO>Z_YQvj4eY&xqr3ZqCb^WB)Rbyj+ua#AgZNn*7~8wZKa=cCE_@*LphHzZq&h zggN-d^Z44#eYbA#`GlUq*MObx!~6~xfUQxF{kRb9-0_|lfvr>bTe$|csJ{fP=9u%# zH)j7!!F~sI$6c>l^j-#5bFakZUitlf&LHCZEidp2u={f+IsDdv)q`IFwkN*jm0-W6 z-^{VN%U6Nzbv%04gY}BvrmMkzZ}q6T2CRS7Tnn~FJ?6X)9CJDzb8Z0Z>3Hn*^;B>X=;QO{=;ZX+jQNmH6U`}+Q^1dd z_jae}!3-#)t5tw`5qWBJ@E?Q%8QD5{k+V+k<@Fn1fZ6M<``GICpW5BK-dF#*{n_dF z?rzfad|1Fg0jC*j1B3!|mWDKq*NEG|JY#KuVBW@%h8Abe6PrNp{U?C;yd^u%Xu!1= z^=fX!d}r2y7I}@B=carWpY0d#lI^D!`+2u)Ke_!h`#164*P2B(o5RcFGouPIBH+L3j=Fj0hQ(vY_In_hhB6ffBZDRK%w`LLV z{nVTxcX#p5RpJEL*O~HVpxM_w#=gE?Zr^phJ=E+gcV}vzZ;fJW<6HKKopZC7^yq2lM6eY=u}Ya{oX1HI?3Z z8~6@);F)>8VF!2?^AckBXr4WtmEg^by=%nTS@jVgjCwZUYO&`oahz?fJ=M(nV{_-= EABCPRS^xk5 diff --git a/test/shaders/glsl/test_workgroup.comp.spv b/test/shaders/glsl/test_workgroup.comp.spv deleted file mode 100755 index 533d994feb3fe3ecf697622d395a8c9205aaa08d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1396 zcmYk5TThcg5Qdl59s~su0Z-sps(1jaF=|YVCL|_>gmB}9m!^m@jnEQkjox|TFY{M< zW8(8{JLcPDI`h6eJMZl5*J`ERNNFa`re=DYCTlTOU{ab(_3XR*@Ao_BqodCA7dd4< zRdb>_3!JOrFJLFV{=khn>*I~r25!|G1HQk<2>^5`1)ao7& z4|~UZgKxu6y-|NSP%78EkGI}4y!FH`>;1sjxYNVTq}1gO_N=KZb|&KMQ+xwo$GrP4 zztNxkF4Y3J!LBa#<($6t?0o}s1#V4X#s#r@=DEL#FY87Bp%=KUCl`9&t*j?jk0;Fa zpWxNA-V(3t`?fgkdE;ezP`|)j1-OCNbZ^&_W3z&T5TqSmn>O{^GvHUOUc;*`BIr%uZOlf$_I@VK1&b+^ACcVP`0k*VA^8f$< From 34f9d587222d15e17daaabe8211b8386a5f29b58 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Thu, 19 May 2022 13:06:55 +0200 Subject: [PATCH 018/107] Fixed compiling tests with the new test layout Signed-off-by: Fabian Sauter --- cmake/bin2h.cmake | 8 ++--- cmake/vulkan_shader_compiler.cmake | 2 +- src/CMakeLists.txt | 14 ++++---- test/CMakeLists.txt | 1 - test/TestAsyncOperations.cpp | 14 ++++++++ test/TestDestroy.cpp | 13 +++++++ test/TestLogisticRegression.cpp | 36 +++++++++++-------- test/TestMain.cpp | 18 ---------- test/TestManager.cpp | 13 +++++++ test/TestMultipleAlgoExecutions.cpp | 13 +++++++ test/TestOpShadersFromStringAndFile.cpp | 26 ++++++++------ test/TestOpTensorCopy.cpp | 13 +++++++ test/TestOpTensorCreate.cpp | 13 +++++++ test/TestOpTensorSync.cpp | 13 +++++++ test/TestPushConstant.cpp | 13 +++++++ test/TestSequence.cpp | 13 +++++++ test/TestSpecializationConstant.cpp | 13 +++++++ test/TestTensor.cpp | 13 +++++++ test/TestWorkgroup.cpp | 24 ++++++++----- test/shaders/glsl/CMakeLists.txt | 12 +++---- ...p => test_logistic_regression_shader.comp} | 0 ...kgroup.comp => test_workgroup_shader.comp} | 0 22 files changed, 216 insertions(+), 69 deletions(-) delete mode 100644 test/TestMain.cpp rename test/shaders/glsl/{test_logistic_regression.comp => test_logistic_regression_shader.comp} (100%) rename test/shaders/glsl/{test_workgroup.comp => test_workgroup_shader.comp} (100%) diff --git a/cmake/bin2h.cmake b/cmake/bin2h.cmake index 4243ca0ff..deea3923a 100644 --- a/cmake/bin2h.cmake +++ b/cmake/bin2h.cmake @@ -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 \n#include ") - set(arrayDefinition "const std::array ${BIN2H_VARIABLE_NAME} = { ${arrayValues} };") + set(arrayDefinition "const std::array ${BIN2H_VARIABLE_NAME} = { ${arrayValues} };") set(declarations "${arrayIncludes}\n\n${namespaceStart}\n${arrayDefinition}\n${namespaceEnd}\n\n") if(BIN2H_APPEND) diff --git a/cmake/vulkan_shader_compiler.cmake b/cmake/vulkan_shader_compiler.cmake index 4526b796a..e09ff4381 100644 --- a/cmake/vulkan_shader_compiler.cmake +++ b/cmake/vulkan_shader_compiler.cmake @@ -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}") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ae472e62b..c312bde52 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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() ##################################################### diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8311253a1..49e8f0356 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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) diff --git a/test/TestAsyncOperations.cpp b/test/TestAsyncOperations.cpp index bd52ff390..a1c8de852 100644 --- a/test/TestAsyncOperations.cpp +++ b/test/TestAsyncOperations.cpp @@ -5,6 +5,7 @@ #include #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(KOMPUTE_LOG_LEVEL)); +#endif + + return RUN_ALL_TESTS(); +} diff --git a/test/TestDestroy.cpp b/test/TestDestroy.cpp index e81e3903c..6a4fdb345 100644 --- a/test/TestDestroy.cpp +++ b/test/TestDestroy.cpp @@ -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(KOMPUTE_LOG_LEVEL)); +#endif + + return RUN_ALL_TESTS(); +} diff --git a/test/TestLogisticRegression.cpp b/test/TestLogisticRegression.cpp index d149c4772..2ac52e31c 100644 --- a/test/TestLogisticRegression.cpp +++ b/test/TestLogisticRegression.cpp @@ -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(params); - std::vector spirv = std::vector( - (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 spirv2{ 0x1, 0x2 }; + + std::vector spirv( + kp::TEST_LOGISTIC_REGRESSION_SHADER_COMP_SPV.begin(), + kp::TEST_LOGISTIC_REGRESSION_SHADER_COMP_SPV.end()); std::shared_ptr algorithm = mgr.algorithm( params, spirv, kp::Workgroup({ 5 }), std::vector({ 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(params)->eval(); - std::vector spirv = std::vector( - (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 spirv( + kp::TEST_LOGISTIC_REGRESSION_SHADER_COMP_SPV.begin(), + kp::TEST_LOGISTIC_REGRESSION_SHADER_COMP_SPV.end()); std::shared_ptr algorithm = mgr.algorithm( params, spirv, kp::Workgroup(), std::vector({ 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(KOMPUTE_LOG_LEVEL)); +#endif + + return RUN_ALL_TESTS(); +} diff --git a/test/TestMain.cpp b/test/TestMain.cpp deleted file mode 100644 index 4f777f0b2..000000000 --- a/test/TestMain.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 - -#include - -#include - -int -main(int argc, char* argv[]) -{ - testing::InitGoogleTest(&argc, argv); - -#if KOMPUTE_ENABLE_SPDLOG - spdlog::set_level( - static_cast(KOMPUTE_LOG_LEVEL)); -#endif - - return RUN_ALL_TESTS(); -} diff --git a/test/TestManager.cpp b/test/TestManager.cpp index e882421fc..ca787a066 100644 --- a/test/TestManager.cpp +++ b/test/TestManager.cpp @@ -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(KOMPUTE_LOG_LEVEL)); +#endif + + return RUN_ALL_TESTS(); +} diff --git a/test/TestMultipleAlgoExecutions.cpp b/test/TestMultipleAlgoExecutions.cpp index 40d15d6e7..0311fcb21 100644 --- a/test/TestMultipleAlgoExecutions.cpp +++ b/test/TestMultipleAlgoExecutions.cpp @@ -270,3 +270,16 @@ TEST(TestMultipleAlgoExecutions, TestAlgorithmUtilFunctions) EXPECT_EQ(algorithm->getPushConstants(), pushConsts); EXPECT_EQ(algorithm->getSpecializationConstants(), specConsts); } + +int +main(int argc, char* argv[]) +{ + testing::InitGoogleTest(&argc, argv); + +#if KOMPUTE_ENABLE_SPDLOG + spdlog::set_level( + static_cast(KOMPUTE_LOG_LEVEL)); +#endif + + return RUN_ALL_TESTS(); +} diff --git a/test/TestOpShadersFromStringAndFile.cpp b/test/TestOpShadersFromStringAndFile.cpp index 550f9e26c..b4431e041 100644 --- a/test/TestOpShadersFromStringAndFile.cpp +++ b/test/TestOpShadersFromStringAndFile.cpp @@ -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> tensorA = mgr.tensor({ 3, 4, 5 }); std::shared_ptr> tensorB = mgr.tensor({ 0, 0, 0 }); - std::vector spirv = std::vector( - (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 spirv(kp::TEST_OP_CUSTOM_SHADER_COMP_SPV.begin(), + kp::TEST_OP_CUSTOM_SHADER_COMP_SPV.end()); std::vector> params = { tensorA, tensorB }; mgr.sequence() @@ -87,3 +80,16 @@ TEST(TestOpAlgoCreate, ShaderCompiledDataFromConstructor) // EXPECT_EQ(tensorA->vector(), std::vector({ 0, 1, 2 })); // EXPECT_EQ(tensorB->vector(), std::vector({ 3, 4, 5 })); //} + +int +main(int argc, char* argv[]) +{ + testing::InitGoogleTest(&argc, argv); + +#if KOMPUTE_ENABLE_SPDLOG + spdlog::set_level( + static_cast(KOMPUTE_LOG_LEVEL)); +#endif + + return RUN_ALL_TESTS(); +} diff --git a/test/TestOpTensorCopy.cpp b/test/TestOpTensorCopy.cpp index a272efbd4..9cebee34c 100644 --- a/test/TestOpTensorCopy.cpp +++ b/test/TestOpTensorCopy.cpp @@ -156,3 +156,16 @@ TEST(TestOpTensorCopy, SingleTensorShouldFail) EXPECT_THROW(mgr.sequence()->eval({ tensorA }), std::runtime_error); } + +int +main(int argc, char* argv[]) +{ + testing::InitGoogleTest(&argc, argv); + +#if KOMPUTE_ENABLE_SPDLOG + spdlog::set_level( + static_cast(KOMPUTE_LOG_LEVEL)); +#endif + + return RUN_ALL_TESTS(); +} diff --git a/test/TestOpTensorCreate.cpp b/test/TestOpTensorCreate.cpp index 8ad552e6c..40133508f 100644 --- a/test/TestOpTensorCreate.cpp +++ b/test/TestOpTensorCreate.cpp @@ -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(KOMPUTE_LOG_LEVEL)); +#endif + + return RUN_ALL_TESTS(); +} diff --git a/test/TestOpTensorSync.cpp b/test/TestOpTensorSync.cpp index 9fecb85f9..7c9d6cf06 100644 --- a/test/TestOpTensorSync.cpp +++ b/test/TestOpTensorSync.cpp @@ -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(KOMPUTE_LOG_LEVEL)); +#endif + + return RUN_ALL_TESTS(); +} diff --git a/test/TestPushConstant.cpp b/test/TestPushConstant.cpp index 94f6afc47..a78224fc0 100644 --- a/test/TestPushConstant.cpp +++ b/test/TestPushConstant.cpp @@ -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(KOMPUTE_LOG_LEVEL)); +#endif + + return RUN_ALL_TESTS(); +} diff --git a/test/TestSequence.cpp b/test/TestSequence.cpp index 7ab14a646..27c422450 100644 --- a/test/TestSequence.cpp +++ b/test/TestSequence.cpp @@ -242,3 +242,16 @@ TEST(TestSequence, CorrectSequenceRunningError) EXPECT_EQ(tensorOut->vector(), std::vector({ 2, 4, 6 })); } + +int +main(int argc, char* argv[]) +{ + testing::InitGoogleTest(&argc, argv); + +#if KOMPUTE_ENABLE_SPDLOG + spdlog::set_level( + static_cast(KOMPUTE_LOG_LEVEL)); +#endif + + return RUN_ALL_TESTS(); +} diff --git a/test/TestSpecializationConstant.cpp b/test/TestSpecializationConstant.cpp index a1fc4bb3e..1421aaa97 100644 --- a/test/TestSpecializationConstant.cpp +++ b/test/TestSpecializationConstant.cpp @@ -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(KOMPUTE_LOG_LEVEL)); +#endif + + return RUN_ALL_TESTS(); +} diff --git a/test/TestTensor.cpp b/test/TestTensor.cpp index e6af04f25..dc358fc82 100644 --- a/test/TestTensor.cpp +++ b/test/TestTensor.cpp @@ -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(KOMPUTE_LOG_LEVEL)); +#endif + + return RUN_ALL_TESTS(); +} diff --git a/test/TestWorkgroup.cpp b/test/TestWorkgroup.cpp index 164166ee3..bd87bbab3 100644 --- a/test/TestWorkgroup.cpp +++ b/test/TestWorkgroup.cpp @@ -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> params = { tensorA, tensorB }; - std::vector 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(KOMPUTE_LOG_LEVEL)); +#endif + + return RUN_ALL_TESTS(); +} diff --git a/test/shaders/glsl/CMakeLists.txt b/test/shaders/glsl/CMakeLists.txt index 41e207728..579a73841 100644 --- a/test/shaders/glsl/CMakeLists.txt +++ b/test/shaders/glsl/CMakeLists.txt @@ -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 $) diff --git a/test/shaders/glsl/test_logistic_regression.comp b/test/shaders/glsl/test_logistic_regression_shader.comp similarity index 100% rename from test/shaders/glsl/test_logistic_regression.comp rename to test/shaders/glsl/test_logistic_regression_shader.comp diff --git a/test/shaders/glsl/test_workgroup.comp b/test/shaders/glsl/test_workgroup_shader.comp similarity index 100% rename from test/shaders/glsl/test_workgroup.comp rename to test/shaders/glsl/test_workgroup_shader.comp From a53d2b9a4eb27087b39314e1bc1a09c14b734449 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Thu, 19 May 2022 14:25:18 +0200 Subject: [PATCH 019/107] Fixed shader to header endianness Signed-off-by: Fabian Sauter --- cmake/bin2h.cmake | 10 +++- cmake/vulkan_shader_compiler.cmake | 65 +++++++++++++------------ test/TestOpShadersFromStringAndFile.cpp | 27 ++++++++++ test/shaders/glsl/CMakeLists.txt | 7 ++- test/shaders/glsl/test_shader.comp | 12 +++++ 5 files changed, 88 insertions(+), 33 deletions(-) create mode 100644 test/shaders/glsl/test_shader.comp diff --git a/cmake/bin2h.cmake b/cmake/bin2h.cmake index deea3923a..21ad56cb1 100644 --- a/cmake/bin2h.cmake +++ b/cmake/bin2h.cmake @@ -54,6 +54,8 @@ endfunction() # as string. But the size variable holds size of the byte array without this # null byte. # HEADER_NAMESPACE - The namespace, where the array should be located in. +# IS_BIG_ENDIAN - If set to true, will not revers the byte order for the uint32_t to match the +# big endian system architecture # Usage: # bin2h(SOURCE_FILE "Logo.png" HEADER_FILE "Logo.h" VARIABLE_NAME "LOGO_PNG") function(BIN2H) @@ -75,7 +77,13 @@ function(BIN2H) 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][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f])" "0x\\1, " arrayValues ${hexString}) + if(IS_BIG_ENDIAN) + message(STATUS "Interpreting shader in big endian...") + 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\\2\\3\\4, " arrayValues ${hexString}) + else() + message(STATUS "Interpreting shader in little endian...") + 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\\4\\3\\2\\1, " arrayValues ${hexString}) + endif() # removes trailing comma string(REGEX REPLACE ", $" "" arrayValues ${arrayValues}) diff --git a/cmake/vulkan_shader_compiler.cmake b/cmake/vulkan_shader_compiler.cmake index e09ff4381..bce7fdab9 100644 --- a/cmake/vulkan_shader_compiler.cmake +++ b/cmake/vulkan_shader_compiler.cmake @@ -1,36 +1,39 @@ function(vulkan_compile_shader) - find_program(GLS_LANG_VALIDATOR_PATH NAMES glslangValidator) - if(${GLS_LANG_VALIDATOR_PATH}) - message(FATAL_ERROR "glslangValidator not found.") - return() - endif() + find_program(GLS_LANG_VALIDATOR_PATH NAMES glslangValidator) + if(${GLS_LANG_VALIDATOR_PATH}) + message(FATAL_ERROR "glslangValidator not found.") + return() + endif() - cmake_parse_arguments(SHADER_COMPILE "" "INFILE;OUTFILE;NAMESPACE" "" ${ARGN}) - set(SHADER_COMPILE_INFILE_FULL "${CMAKE_CURRENT_SOURCE_DIR}/${SHADER_COMPILE_INFILE}") - set(SHADER_COMPILE_SPV_FILE_FULL "${CMAKE_CURRENT_BINARY_DIR}/${SHADER_COMPILE_INFILE}.spv") - set(SHADER_COMPILE_HEADER_FILE_FULL "${CMAKE_CURRENT_BINARY_DIR}/${SHADER_COMPILE_OUTFILE}") + cmake_parse_arguments(SHADER_COMPILE "" "INFILE;OUTFILE;NAMESPACE" "" ${ARGN}) + set(SHADER_COMPILE_INFILE_FULL "${CMAKE_CURRENT_SOURCE_DIR}/${SHADER_COMPILE_INFILE}") + set(SHADER_COMPILE_SPV_FILE_FULL "${CMAKE_CURRENT_BINARY_DIR}/${SHADER_COMPILE_INFILE}.spv") + set(SHADER_COMPILE_HEADER_FILE_FULL "${CMAKE_CURRENT_BINARY_DIR}/${SHADER_COMPILE_OUTFILE}") - # .comp -> .spv - add_custom_command(OUTPUT "${SHADER_COMPILE_SPV_FILE_FULL}" - COMMAND "${GLS_LANG_VALIDATOR_PATH}" - ARGS "-V" - "-o" - "${SHADER_COMPILE_SPV_FILE_FULL}" - "--target-env" - "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}") + # .comp -> .spv + add_custom_command(OUTPUT "${SHADER_COMPILE_SPV_FILE_FULL}" + COMMAND "${GLS_LANG_VALIDATOR_PATH}" + ARGS "-V" + "${SHADER_COMPILE_INFILE_FULL}" + "-o" + "${SHADER_COMPILE_SPV_FILE_FULL}" + COMMENT "Compile vulkan compute shader from file '${SHADER_COMPILE_INFILE_FULL}' to '${SHADER_COMPILE_SPV_FILE_FULL}'." + MAIN_DEPENDENCY "${SHADER_COMPILE_INFILE_FULL}") - # .spv -> .hpp - add_custom_command(OUTPUT "${SHADER_COMPILE_HEADER_FILE_FULL}" - COMMAND ${CMAKE_COMMAND} - ARGS "-DINPUT_SHADER_FILE=${SHADER_COMPILE_SPV_FILE_FULL}" - "-DOUTPUT_HEADER_FILE=${SHADER_COMPILE_HEADER_FILE_FULL}" - "-DHEADER_NAMESPACE=${SHADER_COMPILE_NAMESPACE}" - "-P" - "${CMAKE_SOURCE_DIR}/cmake/bin_file_to_header.cmake" - WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/cmake" - COMMENT "Converting compiled shader '${SHADER_COMPILE_SPV_FILE_FULL}' to header file '${SHADER_COMPILE_HEADER_FILE_FULL}'." - MAIN_DEPENDENCY "${SHADER_COMPILE_SPV_FILE_FULL}") + # Check if big or little endian + include (TestBigEndian) + TEST_BIG_ENDIAN(IS_BIG_ENDIAN) + + # .spv -> .hpp + add_custom_command(OUTPUT "${SHADER_COMPILE_HEADER_FILE_FULL}" + COMMAND ${CMAKE_COMMAND} + ARGS "-DINPUT_SHADER_FILE=${SHADER_COMPILE_SPV_FILE_FULL}" + "-DOUTPUT_HEADER_FILE=${SHADER_COMPILE_HEADER_FILE_FULL}" + "-DHEADER_NAMESPACE=${SHADER_COMPILE_NAMESPACE}" + "-DIS_BIG_ENDIAN=${IS_BIG_ENDIAN}" + "-P" + "${CMAKE_SOURCE_DIR}/cmake/bin_file_to_header.cmake" + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/cmake" + COMMENT "Converting compiled shader '${SHADER_COMPILE_SPV_FILE_FULL}' to header file '${SHADER_COMPILE_HEADER_FILE_FULL}'." + MAIN_DEPENDENCY "${SHADER_COMPILE_SPV_FILE_FULL}") endfunction() diff --git a/test/TestOpShadersFromStringAndFile.cpp b/test/TestOpShadersFromStringAndFile.cpp index b4431e041..ea1a924de 100644 --- a/test/TestOpShadersFromStringAndFile.cpp +++ b/test/TestOpShadersFromStringAndFile.cpp @@ -6,6 +6,33 @@ #include "shaders/Utils.hpp" #include "test_op_custom_shader.hpp" +#include "test_shader.hpp" + +TEST(TestShaderEndianness, ShaderRawDataFromConstructor) +{ + std::string shader(R"( + #version 450 + + layout (local_size_x = 1) in; + + layout(set = 0, binding = 0) buffer a { float pa[]; }; + layout(set = 0, binding = 1) buffer b { float pb[]; }; + + void main() { + uint index = gl_GlobalInvocationID.x; + pb[index] = pa[index]; + pa[index] = index; + } + )"); + + std::vector spirv = compileSource(shader); + std::vector spirv2(kp::TEST_SHADER_COMP_SPV.begin(), + kp::TEST_SHADER_COMP_SPV.end()); + EXPECT_EQ(spirv.size(), spirv2.size()); + for (size_t i = 0; i < spirv.size(); i++) { + EXPECT_EQ(spirv[i], spirv2[i]); + } +} TEST(TestOpAlgoCreate, ShaderRawDataFromConstructor) { diff --git a/test/shaders/glsl/CMakeLists.txt b/test/shaders/glsl/CMakeLists.txt index 579a73841..171e6c23a 100644 --- a/test/shaders/glsl/CMakeLists.txt +++ b/test/shaders/glsl/CMakeLists.txt @@ -14,9 +14,14 @@ vulkan_compile_shader(INFILE test_workgroup_shader.comp OUTFILE test_workgroup_shader.hpp NAMESPACE "kp") +vulkan_compile_shader(INFILE test_shader.comp + OUTFILE test_shader.hpp + NAMESPACE "kp") + 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_shader.hpp") + "${CMAKE_CURRENT_BINARY_DIR}/test_workgroup_shader.hpp" + "${CMAKE_CURRENT_BINARY_DIR}/test_shader.hpp") set_target_properties(test_shaders_glsl PROPERTIES LINKER_LANGUAGE CXX) target_include_directories(test_shaders_glsl PUBLIC $) diff --git a/test/shaders/glsl/test_shader.comp b/test/shaders/glsl/test_shader.comp new file mode 100644 index 000000000..fb4a7ab62 --- /dev/null +++ b/test/shaders/glsl/test_shader.comp @@ -0,0 +1,12 @@ +#version 450 + +layout (local_size_x = 1) in; + +layout(set = 0, binding = 0) buffer a { float pa[]; }; +layout(set = 0, binding = 1) buffer b { float pb[]; }; + +void main() { + uint index = gl_GlobalInvocationID.x; + pb[index] = pa[index]; + pa[index] = index; +} \ No newline at end of file From e58bc7525a2fe0bc0ee39b11f06cdcbe896b6a96 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Thu, 19 May 2022 15:19:32 +0200 Subject: [PATCH 020/107] Added multi GPU support for the vulkan version check Signed-off-by: Fabian Sauter --- cmake/check_vulkan_version.cmake | 85 +++++++++++++++++++++++--------- 1 file changed, 63 insertions(+), 22 deletions(-) diff --git a/cmake/check_vulkan_version.cmake b/cmake/check_vulkan_version.cmake index b0902b5f0..29ad2da0d 100644 --- a/cmake/check_vulkan_version.cmake +++ b/cmake/check_vulkan_version.cmake @@ -57,34 +57,75 @@ function(check_vulkan_version) message(FATAL_ERROR "Running vulkaninfo failed with return code ${VULKAN_INFO_RETURN}. Make sure you have 'vulkan-tools' installed. Result:\n${VULKAN_INFO_OUTPUT}?") return() endif() - if(${VULKAN_INFO_OUTPUT} MATCHES "apiVersion[ ]+=[ ]+[0-9]+[ ]+[(]([0-9]+[.][0-9]+[.][0-9]+)[)]") - set(VULKAN_DRIVER_VERSION ${CMAKE_MATCH_1}) - message(STATUS "vulkaninfo reported supported version ${VULKAN_DRIVER_VERSION}") - else() - message(FATAL_ERROR "No valid version found in vulkaninfo. Does your GPU (driver) support Vulkan?") - return() + + string(REGEX MATCHALL "(GPU[0-9]+)" GPU_IDS ${VULKAN_INFO_OUTPUT}) + if(NOT GPU_IDS) + message(FATAL_ERROR "No GPU supporting Vulkan found in vulkaninfo. Does your GPU (driver) support Vulkan?") endif() - # Compare driver and header version - if(${VULKAN_DRIVER_VERSION} VERSION_LESS ${VULKAN_HEADER_VERSION}) + string(REGEX MATCHALL "apiVersion[ ]*=[ ]*[0-9a-fA-F]+[ ]+[(]([0-9]+[.][0-9]+[.][0-9]+)[)]" GPU_API_VERSIONS ${VULKAN_INFO_OUTPUT}) + if(NOT GPU_API_VERSIONS) + message(FATAL_ERROR "No valid Vulkan API version found in vulkaninfo. Does your GPU (driver) support Vulkan?") + endif() + + # Check length + # message(FATAL_ERROR "GPUS: ${GPU_IDS}") + list(LENGTH GPU_IDS GPU_IDS_LENGTH) + list(LENGTH GPU_API_VERSIONS GPU_API_VERSIONS_LENGTH) + if(NOT ${GPU_IDS_LENGTH} EQUAL ${GPU_API_VERSIONS_LENGTH}) + message(FATAL_ERROR "Found ${GPU_IDS_LENGTH} GPUs, but ${GPU_API_VERSIONS_LENGTH} API versions in vulkaninfo. We expected to find an equal amount of them.") + endif() + + # Compare versions + set(VALID_GPU "") + set(VALID_VULKAN_VERSION "") + math(EXPR ITER_LEN "${GPU_IDS_LENGTH} - 1") + foreach(INDEX RANGE ${ITER_LEN}) + list(GET GPU_IDS ${INDEX} GPU) + list(GET GPU_API_VERSIONS ${INDEX} API_VERSION) + + # Extract API version + if(${API_VERSION} MATCHES "apiVersion[ ]*=[ ]*[0-9a-fA-F]+[ ]+[(]([0-9]+[.][0-9]+[.][0-9]+)[)]") + set(VULKAN_DRIVER_VERSION ${CMAKE_MATCH_1}) + else() + message(FATAL_ERROR "API version match failed. This should not have happened...") + endif() + + message(STATUS "${GPU} supports Vulkan API version '${VULKAN_DRIVER_VERSION}'.") + + # Compare driver and header version + if(${VULKAN_DRIVER_VERSION} VERSION_LESS ${VULKAN_HEADER_VERSION}) # Version missmatch. Let us check if the minor version is the same. - if(${VULKAN_DRIVER_VERSION} MATCHES "[0-9]+[.]([0-9]+)[.][0-9]+") - set(VULKAN_DRIVER_MINOR_VERSION ${CMAKE_MATCH_1}) - else() - message(FATAL_ERROR "Invalid Vulkan driver version '${VULKAN_DRIVER_VERSION}' found. Expected version in the following format: '[0-9]+.[0-9]+.[0-9]+'") - endif() - if(${VULKAN_HEADER_VERSION} MATCHES "[0-9]+[.]([0-9]+)[.][0-9]+") - set(VULKAN_HEADER_MINOR_VERSION ${CMAKE_MATCH_1}) - else() - message(FATAL_ERROR "Invalid Vulkan Header version '${VULKAN_HEADER_VERSION}' found. Expected version in the following format: '[0-9]+.[0-9]+.[0-9]+'") - endif() + if(${VULKAN_DRIVER_VERSION} MATCHES "[0-9]+[.]([0-9]+)[.][0-9]+") + set(VULKAN_DRIVER_MINOR_VERSION ${CMAKE_MATCH_1}) + else() + message(FATAL_ERROR "Invalid Vulkan driver version '${VULKAN_DRIVER_VERSION}' found. Expected version in the following format: '[0-9]+.[0-9]+.[0-9]+'") + endif() + if(${VULKAN_HEADER_VERSION} MATCHES "[0-9]+[.]([0-9]+)[.][0-9]+") + set(VULKAN_HEADER_MINOR_VERSION ${CMAKE_MATCH_1}) + else() + message(FATAL_ERROR "Invalid Vulkan Header version '${VULKAN_HEADER_VERSION}' found. Expected version in the following format: '[0-9]+.[0-9]+.[0-9]+'") + endif() - if(${VULKAN_DRIVER_MINOR_VERSION} EQUAL ${VULKAN_HEADER_MINOR_VERSION}) - message(WARNING "Your GPU driver does not support Vulkan > ${VULKAN_DRIVER_VERSION}, but you try to use Vulkan Header ${VULKAN_HEADER_VERSION}. At least your driver supports the same minor version (${VULKAN_DRIVER_MINOR_VERSION}), so this should be fine but keep it in mind if encounter some strange behavior.") + if(${VULKAN_DRIVER_MINOR_VERSION} EQUAL ${VULKAN_HEADER_MINOR_VERSION}) + message(WARNING "Your GPU driver does not support Vulkan > ${VULKAN_DRIVER_VERSION}, but you try to use Vulkan Header ${VULKAN_HEADER_VERSION}. At least your driver supports the same minor version (${VULKAN_DRIVER_MINOR_VERSION}), so this should be fine but keep it in mind if encounter some strange behavior.") + set(VALID_GPU ${GPU}) + set(VALID_VULKAN_VERSION ${VULKAN_DRIVER_VERSION}) + break() + else() + message(STATUS "${GPU} does not support Vulkan > ${VULKAN_DRIVER_VERSION}.") + endif() else() - message(FATAL_ERROR "Your GPU driver does not support Vulkan > ${VULKAN_DRIVER_VERSION}, but you try to use Vulkan Header ${VULKAN_HEADER_VERSION}.") + set(VALID_GPU ${GPU}) + set(VALID_VULKAN_VERSION ${VULKAN_DRIVER_VERSION}) + break() endif() + endforeach() + + if(${GPU} STREQUAL "") + message(FATAL_ERROR "None of your GPUs supports Vulkan Header ${VULKAN_HEADER_VERSION}. Please try updating your driver, or downgrade Vulkan header.") else() - message(STATUS "Vulkan version check successful!") + message("Valid GPU (${VALID_GPU}) for Vulkan header version ${VULKAN_HEADER_VERSION} found. ${VALID_GPU} supports up to Vulkan ${VALID_VULKAN_VERSION}.") endif() + endfunction() From ce89855fa532bd272cecc9a25e8ff601e8ab9158 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Thu, 19 May 2022 15:30:12 +0200 Subject: [PATCH 021/107] Removed summary command from vulkaninfo Signed-off-by: Fabian Sauter --- cmake/check_vulkan_version.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/check_vulkan_version.cmake b/cmake/check_vulkan_version.cmake index 29ad2da0d..2adf63058 100644 --- a/cmake/check_vulkan_version.cmake +++ b/cmake/check_vulkan_version.cmake @@ -50,7 +50,7 @@ function(check_vulkan_version) return() endif() - execute_process(COMMAND "vulkaninfo" "--summary" + execute_process(COMMAND "vulkaninfo" OUTPUT_VARIABLE VULKAN_INFO_OUTPUT RESULT_VARIABLE VULKAN_INFO_RETURN) if(NOT ${VULKAN_INFO_RETURN} EQUAL 0) From 2fe219ee3ac68f9a91b0028d92d60e1412c1f7c5 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Thu, 19 May 2022 15:43:42 +0200 Subject: [PATCH 022/107] Removed old CI logging option Signed-off-by: Fabian Sauter --- .github/workflows/cpp_tests.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cpp_tests.yml b/.github/workflows/cpp_tests.yml index fcc7f60d3..2d5069330 100644 --- a/.github/workflows/cpp_tests.yml +++ b/.github/workflows/cpp_tests.yml @@ -29,7 +29,7 @@ jobs: build-type: Debug run-test: true ctest-options: -V - configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=OFF -DKOMPUTE_OPT_ENABLE_SPDLOG=1 + configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=OFF cpp-tests-release-with-debug-layers: runs-on: ubuntu-latest @@ -53,7 +53,7 @@ jobs: build-type: Release run-test: true ctest-options: -V - configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=OFF -DKOMPUTE_OPT_ENABLE_SPDLOG=1 + configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=OFF cpp-tests-debug-without-debug-layers: runs-on: ubuntu-latest @@ -77,7 +77,7 @@ jobs: build-type: Debug run-test: true ctest-options: -V - configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=ON -DKOMPUTE_OPT_ENABLE_SPDLOG=1 + configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=ON cpp-tests-release-without-debug-layers: runs-on: ubuntu-latest @@ -101,4 +101,4 @@ jobs: build-type: Release run-test: true ctest-options: -V - configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=ON -DKOMPUTE_OPT_ENABLE_SPDLOG=1 + configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=ON From f01bcb68a502e361a887830d2fcd650b2e3bea53 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Fri, 20 May 2022 16:12:18 +0200 Subject: [PATCH 023/107] New logging framework Signed-off-by: Fabian Sauter --- CMakeLists.txt | 28 +- python/src/main.cpp | 751 +++++++++++++++++--------- src/CMakeLists.txt | 15 +- src/Manager.cpp | 18 +- src/OpTensorCopy.cpp | 5 +- src/Tensor.cpp | 38 +- src/include/CMakeLists.txt | 20 + src/include/kompute/Algorithm.hpp | 1 + src/include/kompute/Core.hpp | 119 ---- src/include/kompute/Manager.hpp | 1 + src/include/kompute/Tensor.hpp | 65 +-- src/include/kompute/logger/Logger.hpp | 36 ++ src/logger/CMakeLists.txt | 37 ++ src/logger/Logger.cpp | 192 +++++++ test/TestPushConstant.cpp | 2 - 15 files changed, 848 insertions(+), 480 deletions(-) create mode 100644 src/include/kompute/logger/Logger.hpp create mode 100644 src/logger/CMakeLists.txt create mode 100644 src/logger/Logger.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index e6ce10cc3..e9302b643 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,8 +74,7 @@ kompute_option(KOMPUTE_OPT_INSTALL "Enable if you want to enable installation" O # Build options kompute_option(KOMPUTE_OPT_BUILD_PYTHON "Enable if you want to build python bindings" OFF) -kompute_option(KOMPUTE_OPT_ENABLE_LOGGING "Internally we use spdlog for logging. The log output can be either enabled or disabled." OFF) -kompute_log_level(KOMPUTE_OPT_LOG_LEVEL "Internally we use spdlog for logging. The log level used can be changed here." "Debug") +kompute_log_level(KOMPUTE_OPT_LOG_LEVEL "Internally we use spdlog for logging. The log level used can be changed here." "Off") kompute_option(KOMPUTE_OPT_ANDROID_BUILD "Enable android compilation flags required" OFF) kompute_option(KOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS "Explicitly disable debug layers even on debug" OFF) kompute_option(KOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK "Whether to check if your driver supports the Vulkan Header version you are linking against. This might be useful in case you build shared on a different system than you run later." OFF) @@ -124,26 +123,21 @@ else() endif() # Spdlog -if(KOMPUTE_OPT_ENABLE_LOGGING) - if(KOMPUTE_OPT_ENABLE_SPDLOG) - if(KOMPUTE_OPT_USE_BUILD_IN_SPDLOG) - set(SPDLOG_INSTALL ${KOMPUTE_OPT_INSTALL}) - set(SPDLOG_BUILD_SHARED ${KOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS}) +if(KOMPUTE_OPT_USE_BUILD_IN_SPDLOG) + set(SPDLOG_INSTALL ${KOMPUTE_OPT_INSTALL}) + set(SPDLOG_BUILD_SHARED ${KOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS}) - FetchContent_Declare(spdlog GIT_REPOSITORY https://github.com/gabime/spdlog.git - GIT_TAG v1.10.0) # Source: https://github.com/gabime/spdlog/releases - FetchContent_MakeAvailable(spdlog) - else() - find_package(spdlog REQUIRED) - endif() - endif() + FetchContent_Declare(spdlog GIT_REPOSITORY https://github.com/gabime/spdlog.git + GIT_TAG v1.10.0) # Source: https://github.com/gabime/spdlog/releases + FetchContent_MakeAvailable(spdlog) +else() + find_package(spdlog REQUIRED) endif() # fmt if(KOMPUTE_OPT_USE_BUILD_IN_FMT) set(FMT_INSTALL ${KOMPUTE_OPT_INSTALL}) set(BUILD_SHARED_LIBS_BKP ${KOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS}) - set(SPDLOG_BUILD_SHARED ${KOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS}) FetchContent_Declare(fmt GIT_REPOSITORY https://github.com/fmtlib/fmt.git GIT_TAG 8.1.1) # Source: https://github.com/fmtlib/fmt/releases FetchContent_MakeAvailable(fmt) @@ -200,10 +194,6 @@ if(KOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS) add_compile_definitions(KOMPUTE_DISABLE_VK_DEBUG_LAYERS=1) endif() -if(KOMPUTE_OPT_ENABLE_LOGGING) - add_compile_definitions(KOMPUTE_OPT_ENABLE_LOGGING=1) -endif() - ##################################################### # Misc Options ##################################################### diff --git a/python/src/main.cpp b/python/src/main.cpp index d0447fe8e..0ea2793cb 100644 --- a/python/src/main.cpp +++ b/python/src/main.cpp @@ -1,333 +1,555 @@ +#include #include #include -#include #include -#include "fmt/ranges.h" - -#include "utils.hpp" #include "docstrings.hpp" +#include "utils.hpp" namespace py = pybind11; -//used in Core.hpp +// used in Core.hpp py::object kp_debug, kp_info, kp_warning, kp_error; -std::unique_ptr opAlgoDispatchPyInit( - std::shared_ptr& algorithm, - const py::array& push_consts) { - const py::buffer_info info = push_consts.request(); - KP_LOG_DEBUG("Kompute Python Manager creating tensor_T with push_consts size {} dtype {}", - push_consts.size(), std::string(py::str(push_consts.dtype()))); - +std::unique_ptr +opAlgoDispatchPyInit(std::shared_ptr& algorithm, + const py::array& push_consts) +{ + const py::buffer_info info = push_consts.request(); + KP_LOG_DEBUG("Kompute Python Manager creating tensor_T with push_consts " + "size {} dtype {}", + push_consts.size(), + std::string(py::str(push_consts.dtype()))); if (push_consts.dtype() == py::dtype::of()) { - std::vector dataVec((float*)info.ptr, ((float*)info.ptr) + info.size); - return std::unique_ptr{new kp::OpAlgoDispatch(algorithm, dataVec)}; + std::vector dataVec((float*)info.ptr, + ((float*)info.ptr) + info.size); + return std::unique_ptr{ new kp::OpAlgoDispatch( + algorithm, dataVec) }; } else if (push_consts.dtype() == py::dtype::of()) { - std::vector dataVec((uint32_t*)info.ptr, ((uint32_t*)info.ptr) + info.size); - return std::unique_ptr{new kp::OpAlgoDispatch(algorithm, dataVec)}; + std::vector dataVec((uint32_t*)info.ptr, + ((uint32_t*)info.ptr) + info.size); + return std::unique_ptr{ new kp::OpAlgoDispatch( + algorithm, dataVec) }; } else if (push_consts.dtype() == py::dtype::of()) { - std::vector dataVec((int32_t*)info.ptr, ((int32_t*)info.ptr) + info.size); - return std::unique_ptr{new kp::OpAlgoDispatch(algorithm, dataVec)}; + std::vector dataVec((int32_t*)info.ptr, + ((int32_t*)info.ptr) + info.size); + return std::unique_ptr{ new kp::OpAlgoDispatch( + algorithm, dataVec) }; } else if (push_consts.dtype() == py::dtype::of()) { - std::vector dataVec((double*)info.ptr, ((double*)info.ptr) + info.size); - return std::unique_ptr{new kp::OpAlgoDispatch(algorithm, dataVec)}; + std::vector dataVec((double*)info.ptr, + ((double*)info.ptr) + info.size); + return std::unique_ptr{ new kp::OpAlgoDispatch( + algorithm, dataVec) }; } else { throw std::runtime_error("Kompute Python no valid dtype supported"); } } -PYBIND11_MODULE(kp, m) { +PYBIND11_MODULE(kp, m) +{ // The logging modules are used in the Kompute.hpp file - py::module_ logging = py::module_::import("logging"); + py::module_ logging = py::module_::import("logging"); py::object kp_logger = logging.attr("getLogger")("kp"); - kp_debug = kp_logger.attr("debug"); - kp_info = kp_logger.attr("info"); - kp_warning = kp_logger.attr("warning"); - kp_error = kp_logger.attr("error"); + kp_debug = kp_logger.attr("debug"); + kp_info = kp_logger.attr("info"); + kp_warning = kp_logger.attr("warning"); + kp_error = kp_logger.attr("error"); logging.attr("basicConfig")(); py::module_ np = py::module_::import("numpy"); py::enum_(m, "TensorTypes") - .value("device", kp::Tensor::TensorTypes::eDevice, DOC(kp, Tensor, TensorTypes, eDevice)) - .value("host", kp::Tensor::TensorTypes::eHost, DOC(kp, Tensor, TensorTypes, eHost)) - .value("storage", kp::Tensor::TensorTypes::eStorage, DOC(kp, Tensor, TensorTypes, eStorage)) - .export_values(); + .value("device", + kp::Tensor::TensorTypes::eDevice, + DOC(kp, Tensor, TensorTypes, eDevice)) + .value("host", + kp::Tensor::TensorTypes::eHost, + DOC(kp, Tensor, TensorTypes, eHost)) + .value("storage", + kp::Tensor::TensorTypes::eStorage, + DOC(kp, Tensor, TensorTypes, eStorage)) + .export_values(); - py::class_>(m, "OpBase", DOC(kp, OpBase)); + py::class_>( + m, "OpBase", DOC(kp, OpBase)); py::class_>( - m, "OpTensorSyncDevice", py::base(), DOC(kp, OpTensorSyncDevice)) - .def(py::init>&>(), DOC(kp, OpTensorSyncDevice, OpTensorSyncDevice)); + m, + "OpTensorSyncDevice", + py::base(), + DOC(kp, OpTensorSyncDevice)) + .def(py::init>&>(), + DOC(kp, OpTensorSyncDevice, OpTensorSyncDevice)); py::class_>( - m, "OpTensorSyncLocal", py::base(), DOC(kp, OpTensorSyncLocal)) - .def(py::init>&>(), DOC(kp, OpTensorSyncLocal, OpTensorSyncLocal)); + m, + "OpTensorSyncLocal", + py::base(), + DOC(kp, OpTensorSyncLocal)) + .def(py::init>&>(), + DOC(kp, OpTensorSyncLocal, OpTensorSyncLocal)); py::class_>( - m, "OpTensorCopy", py::base(), DOC(kp, OpTensorCopy)) - .def(py::init>&>(), DOC(kp, OpTensorCopy, OpTensorCopy)); + m, "OpTensorCopy", py::base(), DOC(kp, OpTensorCopy)) + .def(py::init>&>(), + DOC(kp, OpTensorCopy, OpTensorCopy)); py::class_>( - m, "OpAlgoDispatch", py::base(), DOC(kp, OpAlgoDispatch)) - .def(py::init&,const std::vector&>(), - DOC(kp, OpAlgoDispatch, OpAlgoDispatch), - py::arg("algorithm"), py::arg("push_consts") = std::vector()) - .def(py::init(&opAlgoDispatchPyInit), - DOC(kp, OpAlgoDispatch, OpAlgoDispatch), - py::arg("algorithm"), py::arg("push_consts")); + m, "OpAlgoDispatch", py::base(), DOC(kp, OpAlgoDispatch)) + .def(py::init&, + const std::vector&>(), + DOC(kp, OpAlgoDispatch, OpAlgoDispatch), + py::arg("algorithm"), + py::arg("push_consts") = std::vector()) + .def(py::init(&opAlgoDispatchPyInit), + DOC(kp, OpAlgoDispatch, OpAlgoDispatch), + py::arg("algorithm"), + py::arg("push_consts")); py::class_>( - m, "OpMult", py::base(), DOC(kp, OpMult)) - .def(py::init>&,const std::shared_ptr&>(), - DOC(kp, OpMult, OpMult)); + m, "OpMult", py::base(), DOC(kp, OpMult)) + .def(py::init>&, + const std::shared_ptr&>(), + DOC(kp, OpMult, OpMult)); - py::class_>(m, "Algorithm", DOC(kp, Algorithm, Algorithm)) - .def("get_tensors", &kp::Algorithm::getTensors, DOC(kp, Algorithm, getTensors)) - .def("destroy", &kp::Algorithm::destroy, DOC(kp, Algorithm, destroy)) - .def("is_init", &kp::Algorithm::isInit, DOC(kp, Algorithm, isInit)); + py::class_>( + m, "Algorithm", DOC(kp, Algorithm, Algorithm)) + .def("get_tensors", + &kp::Algorithm::getTensors, + DOC(kp, Algorithm, getTensors)) + .def("destroy", &kp::Algorithm::destroy, DOC(kp, Algorithm, destroy)) + .def("is_init", &kp::Algorithm::isInit, DOC(kp, Algorithm, isInit)); - py::class_>(m, "Tensor", DOC(kp, Tensor)) - .def("data", [](kp::Tensor& self) { - // Non-owning container exposing the underlying pointer - switch (self.dataType()) { + py::class_>( + m, "Tensor", DOC(kp, Tensor)) + .def( + "data", + [](kp::Tensor& self) { + // Non-owning container exposing the underlying pointer + switch (self.dataType()) { case kp::Tensor::TensorDataTypes::eFloat: - return py::array(self.size(), self.data(), py::cast(&self)); + return py::array( + self.size(), self.data(), py::cast(&self)); case kp::Tensor::TensorDataTypes::eUnsignedInt: - return py::array(self.size(), self.data(), py::cast(&self)); + return py::array( + self.size(), self.data(), py::cast(&self)); case kp::Tensor::TensorDataTypes::eInt: - return py::array(self.size(), self.data(), py::cast(&self)); + return py::array( + self.size(), self.data(), py::cast(&self)); case kp::Tensor::TensorDataTypes::eDouble: - return py::array(self.size(), self.data(), py::cast(&self)); + return py::array( + self.size(), self.data(), py::cast(&self)); case kp::Tensor::TensorDataTypes::eBool: - return py::array(self.size(), self.data(), py::cast(&self)); + return py::array( + self.size(), self.data(), py::cast(&self)); default: - throw std::runtime_error("Kompute Python data type not supported"); - } - }, DOC(kp, Tensor, data)) - .def("size", &kp::Tensor::size, DOC(kp, Tensor, size)) - .def("__len__", &kp::Tensor::size, DOC(kp, Tensor, size)) - .def("tensor_type", &kp::Tensor::tensorType, DOC(kp, Tensor, tensorType)) - .def("data_type", &kp::Tensor::dataType, DOC(kp, Tensor, dataType)) - .def("is_init", &kp::Tensor::isInit, DOC(kp, Tensor, isInit)) - .def("destroy", &kp::Tensor::destroy, DOC(kp, Tensor, destroy)); + throw std::runtime_error( + "Kompute Python data type not supported"); + } + }, + DOC(kp, Tensor, data)) + .def("size", &kp::Tensor::size, DOC(kp, Tensor, size)) + .def("__len__", &kp::Tensor::size, DOC(kp, Tensor, size)) + .def("tensor_type", &kp::Tensor::tensorType, DOC(kp, Tensor, tensorType)) + .def("data_type", &kp::Tensor::dataType, DOC(kp, Tensor, dataType)) + .def("is_init", &kp::Tensor::isInit, DOC(kp, Tensor, isInit)) + .def("destroy", &kp::Tensor::destroy, DOC(kp, Tensor, destroy)); py::class_>(m, "Sequence") - .def("record", [](kp::Sequence& self, std::shared_ptr op) { return self.record(op); }, - DOC(kp, Sequence, record)) - .def("eval", [](kp::Sequence& self) { return self.eval(); }, - DOC(kp, Sequence, eval)) - .def("eval", [](kp::Sequence& self, std::shared_ptr op) { return self.eval(op); }, - DOC(kp, Sequence, eval_2)) - .def("eval_async", [](kp::Sequence& self) { return self.eval(); }, - DOC(kp, Sequence, evalAwait)) - .def("eval_async", [](kp::Sequence& self, std::shared_ptr op) { return self.evalAsync(op); }, - DOC(kp, Sequence, evalAsync)) - .def("eval_await", [](kp::Sequence& self) { return self.evalAwait(); }, - DOC(kp, Sequence, evalAwait)) - .def("eval_await", [](kp::Sequence& self, uint32_t wait) { return self.evalAwait(wait); }, - DOC(kp, Sequence, evalAwait)) - .def("is_recording", &kp::Sequence::isRecording, - DOC(kp, Sequence, isRecording)) - .def("is_running", &kp::Sequence::isRunning, - DOC(kp, Sequence, isRunning)) - .def("is_init", &kp::Sequence::isInit, - DOC(kp, Sequence, isInit)) - .def("clear", &kp::Sequence::clear, - DOC(kp, Sequence, clear)) - .def("rerecord", &kp::Sequence::rerecord, - DOC(kp, Sequence, rerecord)) - .def("get_timestamps", &kp::Sequence::getTimestamps, - DOC(kp, Sequence, getTimestamps)) - .def("destroy", &kp::Sequence::destroy, - DOC(kp, Sequence, destroy)); + .def( + "record", + [](kp::Sequence& self, std::shared_ptr op) { + return self.record(op); + }, + DOC(kp, Sequence, record)) + .def( + "eval", + [](kp::Sequence& self) { return self.eval(); }, + DOC(kp, Sequence, eval)) + .def( + "eval", + [](kp::Sequence& self, std::shared_ptr op) { + return self.eval(op); + }, + DOC(kp, Sequence, eval_2)) + .def( + "eval_async", + [](kp::Sequence& self) { return self.eval(); }, + DOC(kp, Sequence, evalAwait)) + .def( + "eval_async", + [](kp::Sequence& self, std::shared_ptr op) { + return self.evalAsync(op); + }, + DOC(kp, Sequence, evalAsync)) + .def( + "eval_await", + [](kp::Sequence& self) { return self.evalAwait(); }, + DOC(kp, Sequence, evalAwait)) + .def( + "eval_await", + [](kp::Sequence& self, uint32_t wait) { return self.evalAwait(wait); }, + DOC(kp, Sequence, evalAwait)) + .def("is_recording", + &kp::Sequence::isRecording, + DOC(kp, Sequence, isRecording)) + .def("is_running", &kp::Sequence::isRunning, DOC(kp, Sequence, isRunning)) + .def("is_init", &kp::Sequence::isInit, DOC(kp, Sequence, isInit)) + .def("clear", &kp::Sequence::clear, DOC(kp, Sequence, clear)) + .def("rerecord", &kp::Sequence::rerecord, DOC(kp, Sequence, rerecord)) + .def("get_timestamps", + &kp::Sequence::getTimestamps, + DOC(kp, Sequence, getTimestamps)) + .def("destroy", &kp::Sequence::destroy, DOC(kp, Sequence, destroy)); - py::class_>(m, "Manager", DOC(kp, Manager)) - .def(py::init(), DOC(kp, Manager, Manager)) - .def(py::init(), DOC(kp, Manager, Manager_2)) - .def(py::init&,const std::vector&>(), - DOC(kp, Manager, Manager_2), - py::arg("device") = 0, - py::arg("family_queue_indices") = std::vector(), - py::arg("desired_extensions") = std::vector()) - .def("destroy", &kp::Manager::destroy, - DOC(kp, Manager, destroy)) - .def("sequence", &kp::Manager::sequence, DOC(kp, Manager, sequence), - py::arg("queue_index") = 0, py::arg("total_timestamps") = 0) - .def("tensor", [np](kp::Manager& self, - const py::array_t& data, - kp::Tensor::TensorTypes tensor_type) { - const py::array_t& flatdata = np.attr("ravel")(data); - const py::buffer_info info = flatdata.request(); - KP_LOG_DEBUG("Kompute Python Manager tensor() creating tensor float with data size {}", flatdata.size()); - return self.tensor( - info.ptr, - flatdata.size(), - sizeof(float), - kp::Tensor::TensorDataTypes::eFloat, - tensor_type); - }, - DOC(kp, Manager, tensor), - py::arg("data"), py::arg("tensor_type") = kp::Tensor::TensorTypes::eDevice) - .def("tensor_t", [np](kp::Manager& self, - const py::array& data, - kp::Tensor::TensorTypes tensor_type) { - // TODO: Suppport strides in numpy format - const py::array& flatdata = np.attr("ravel")(data); - const py::buffer_info info = flatdata.request(); - KP_LOG_DEBUG("Kompute Python Manager creating tensor_T with data size {} dtype {}", - flatdata.size(), std::string(py::str(flatdata.dtype()))); - if (flatdata.dtype() == py::dtype::of()) { - return self.tensor( - info.ptr, flatdata.size(), sizeof(float), kp::Tensor::TensorDataTypes::eFloat, tensor_type); - } else if (flatdata.dtype() == py::dtype::of()) { - return self.tensor( - info.ptr, flatdata.size(), sizeof(uint32_t), kp::Tensor::TensorDataTypes::eUnsignedInt, tensor_type); - } else if (flatdata.dtype() == py::dtype::of()) { - return self.tensor( - info.ptr, flatdata.size(), sizeof(int32_t), kp::Tensor::TensorDataTypes::eInt, tensor_type); - } else if (flatdata.dtype() == py::dtype::of()) { - return self.tensor( - info.ptr, flatdata.size(), sizeof(double), kp::Tensor::TensorDataTypes::eDouble, tensor_type); - } else if (flatdata.dtype() == py::dtype::of()) { - return self.tensor( - info.ptr, flatdata.size(), sizeof(bool), kp::Tensor::TensorDataTypes::eBool, tensor_type); - } else { - throw std::runtime_error("Kompute Python no valid dtype supported"); - } - }, - DOC(kp, Manager, tensorT), - py::arg("data"), py::arg("tensor_type") = kp::Tensor::TensorTypes::eDevice) - .def("algorithm", [](kp::Manager& self, - const std::vector>& tensors, - const py::bytes& spirv, - const kp::Workgroup& workgroup, - const std::vector& spec_consts, - const std::vector& push_consts) { - py::buffer_info info(py::buffer(spirv).request()); - const char *data = reinterpret_cast(info.ptr); - size_t length = static_cast(info.size); - std::vector spirvVec((uint32_t*)data, (uint32_t*)(data + length)); - return self.algorithm(tensors, spirvVec, workgroup, spec_consts, push_consts); - }, - DOC(kp, Manager, algorithm), - py::arg("tensors"), - py::arg("spirv"), - py::arg("workgroup") = kp::Workgroup(), - py::arg("spec_consts") = std::vector(), - py::arg("push_consts") = std::vector()) - .def("algorithm", [np](kp::Manager& self, - const std::vector>& tensors, - const py::bytes& spirv, - const kp::Workgroup& workgroup, - const py::array& spec_consts, - const py::array& push_consts) { + py::class_>( + m, "Manager", DOC(kp, Manager)) + .def(py::init(), DOC(kp, Manager, Manager)) + .def(py::init(), DOC(kp, Manager, Manager_2)) + .def(py::init&, + const std::vector&>(), + DOC(kp, Manager, Manager_2), + py::arg("device") = 0, + py::arg("family_queue_indices") = std::vector(), + py::arg("desired_extensions") = std::vector()) + .def("destroy", &kp::Manager::destroy, DOC(kp, Manager, destroy)) + .def("sequence", + &kp::Manager::sequence, + DOC(kp, Manager, sequence), + py::arg("queue_index") = 0, + py::arg("total_timestamps") = 0) + .def( + "tensor", + [np](kp::Manager& self, + const py::array_t& data, + kp::Tensor::TensorTypes tensor_type) { + const py::array_t& flatdata = np.attr("ravel")(data); + const py::buffer_info info = flatdata.request(); + KP_LOG_DEBUG("Kompute Python Manager tensor() creating tensor " + "float with data size {}", + flatdata.size()); + return self.tensor(info.ptr, + flatdata.size(), + sizeof(float), + kp::Tensor::TensorDataTypes::eFloat, + tensor_type); + }, + DOC(kp, Manager, tensor), + py::arg("data"), + py::arg("tensor_type") = kp::Tensor::TensorTypes::eDevice) + .def( + "tensor_t", + [np](kp::Manager& self, + const py::array& data, + kp::Tensor::TensorTypes tensor_type) { + // TODO: Suppport strides in numpy format + const py::array& flatdata = np.attr("ravel")(data); + const py::buffer_info info = flatdata.request(); + KP_LOG_DEBUG("Kompute Python Manager creating tensor_T with data " + "size {} dtype {}", + flatdata.size(), + std::string(py::str(flatdata.dtype()))); + if (flatdata.dtype() == py::dtype::of()) { + return self.tensor(info.ptr, + flatdata.size(), + sizeof(float), + kp::Tensor::TensorDataTypes::eFloat, + tensor_type); + } else if (flatdata.dtype() == py::dtype::of()) { + return self.tensor(info.ptr, + flatdata.size(), + sizeof(uint32_t), + kp::Tensor::TensorDataTypes::eUnsignedInt, + tensor_type); + } else if (flatdata.dtype() == py::dtype::of()) { + return self.tensor(info.ptr, + flatdata.size(), + sizeof(int32_t), + kp::Tensor::TensorDataTypes::eInt, + tensor_type); + } else if (flatdata.dtype() == py::dtype::of()) { + return self.tensor(info.ptr, + flatdata.size(), + sizeof(double), + kp::Tensor::TensorDataTypes::eDouble, + tensor_type); + } else if (flatdata.dtype() == py::dtype::of()) { + return self.tensor(info.ptr, + flatdata.size(), + sizeof(bool), + kp::Tensor::TensorDataTypes::eBool, + tensor_type); + } else { + throw std::runtime_error( + "Kompute Python no valid dtype supported"); + } + }, + DOC(kp, Manager, tensorT), + py::arg("data"), + py::arg("tensor_type") = kp::Tensor::TensorTypes::eDevice) + .def( + "algorithm", + [](kp::Manager& self, + const std::vector>& tensors, + const py::bytes& spirv, + const kp::Workgroup& workgroup, + const std::vector& spec_consts, + const std::vector& push_consts) { + py::buffer_info info(py::buffer(spirv).request()); + const char* data = reinterpret_cast(info.ptr); + size_t length = static_cast(info.size); + std::vector spirvVec((uint32_t*)data, + (uint32_t*)(data + length)); + return self.algorithm( + tensors, spirvVec, workgroup, spec_consts, push_consts); + }, + DOC(kp, Manager, algorithm), + py::arg("tensors"), + py::arg("spirv"), + py::arg("workgroup") = kp::Workgroup(), + py::arg("spec_consts") = std::vector(), + py::arg("push_consts") = std::vector()) + .def( + "algorithm", + [np](kp::Manager& self, + const std::vector>& tensors, + const py::bytes& spirv, + const kp::Workgroup& workgroup, + const py::array& spec_consts, + const py::array& push_consts) { + py::buffer_info info(py::buffer(spirv).request()); + const char* data = reinterpret_cast(info.ptr); + size_t length = static_cast(info.size); + std::vector spirvVec((uint32_t*)data, + (uint32_t*)(data + length)); - py::buffer_info info(py::buffer(spirv).request()); - const char *data = reinterpret_cast(info.ptr); - size_t length = static_cast(info.size); - std::vector spirvVec((uint32_t*)data, (uint32_t*)(data + length)); + const py::buffer_info pushInfo = push_consts.request(); + const py::buffer_info specInfo = spec_consts.request(); - const py::buffer_info pushInfo = push_consts.request(); - const py::buffer_info specInfo = spec_consts.request(); + KP_LOG_DEBUG("Kompute Python Manager creating Algorithm_T with " + "push consts data size {} dtype {} and spec const " + "data size {} dtype {}", + push_consts.size(), + std::string(py::str(push_consts.dtype())), + spec_consts.size(), + std::string(py::str(spec_consts.dtype()))); - KP_LOG_DEBUG("Kompute Python Manager creating Algorithm_T with " - "push consts data size {} dtype {} and spec const data size {} dtype {}", - push_consts.size(), std::string(py::str(push_consts.dtype())), - spec_consts.size(), std::string(py::str(spec_consts.dtype()))); - - // We have to iterate across a combination of parameters due to the lack of support for templating + // We have to iterate across a combination of parameters due to the + // lack of support for templating + if (spec_consts.dtype() == py::dtype::of()) { + std::vector specConstsVec( + (float*)specInfo.ptr, ((float*)specInfo.ptr) + specInfo.size); if (spec_consts.dtype() == py::dtype::of()) { - std::vector specConstsVec((float*)specInfo.ptr, ((float*)specInfo.ptr) + specInfo.size); - if (spec_consts.dtype() == py::dtype::of()) { - std::vector pushConstsVec((float*)pushInfo.ptr, ((float*)pushInfo.ptr) + pushInfo.size); - return self.algorithm(tensors, spirvVec, workgroup, specConstsVec, pushConstsVec); - } else if (spec_consts.dtype() == py::dtype::of()) { - std::vector pushConstsVec((int32_t*)pushInfo.ptr, ((int32_t*)pushInfo.ptr) + pushInfo.size); - return self.algorithm(tensors, spirvVec, workgroup, specConstsVec, pushConstsVec); - } else if (spec_consts.dtype() == py::dtype::of()) { - std::vector pushConstsVec((uint32_t*)pushInfo.ptr, ((uint32_t*)pushInfo.ptr) + pushInfo.size); - return self.algorithm(tensors, spirvVec, workgroup, specConstsVec, pushConstsVec); - } else if (spec_consts.dtype() == py::dtype::of()) { - std::vector pushConstsVec((double*)pushInfo.ptr, ((double*)pushInfo.ptr) + pushInfo.size); - return self.algorithm(tensors, spirvVec, workgroup, specConstsVec, pushConstsVec); - } - } else if (spec_consts.dtype() == py::dtype::of()) { - std::vector specconstsvec((int32_t*)specInfo.ptr, ((int32_t*)specInfo.ptr) + specInfo.size); - if (spec_consts.dtype() == py::dtype::of()) { - std::vector pushconstsvec((float*)pushInfo.ptr, ((float*)pushInfo.ptr) + pushInfo.size); - return self.algorithm(tensors, spirvVec, workgroup, specconstsvec, pushconstsvec); - } else if (spec_consts.dtype() == py::dtype::of()) { - std::vector pushconstsvec((int32_t*)pushInfo.ptr, ((int32_t*)pushInfo.ptr) + pushInfo.size); - return self.algorithm(tensors, spirvVec, workgroup, specconstsvec, pushconstsvec); - } else if (spec_consts.dtype() == py::dtype::of()) { - std::vector pushconstsvec((uint32_t*)pushInfo.ptr, ((uint32_t*)pushInfo.ptr) + pushInfo.size); - return self.algorithm(tensors, spirvVec, workgroup, specconstsvec, pushconstsvec); - } else if (spec_consts.dtype() == py::dtype::of()) { - std::vector pushconstsvec((double*)pushInfo.ptr, ((double*)pushInfo.ptr) + pushInfo.size); - return self.algorithm(tensors, spirvVec, workgroup, specconstsvec, pushconstsvec); - } - } else if (spec_consts.dtype() == py::dtype::of()) { - std::vector specconstsvec((uint32_t*)specInfo.ptr, ((uint32_t*)specInfo.ptr) + specInfo.size); - if (spec_consts.dtype() == py::dtype::of()) { - std::vector pushconstsvec((float*)pushInfo.ptr, ((float*)pushInfo.ptr) + pushInfo.size); - return self.algorithm(tensors, spirvVec, workgroup, specconstsvec, pushconstsvec); - } else if (spec_consts.dtype() == py::dtype::of()) { - std::vector pushconstsvec((int32_t*)pushInfo.ptr, ((int32_t*)pushInfo.ptr) + pushInfo.size); - return self.algorithm(tensors, spirvVec, workgroup, specconstsvec, pushconstsvec); - } else if (spec_consts.dtype() == py::dtype::of()) { - std::vector pushconstsvec((uint32_t*)pushInfo.ptr, ((uint32_t*)pushInfo.ptr) + pushInfo.size); - return self.algorithm(tensors, spirvVec, workgroup, specconstsvec, pushconstsvec); - } else if (spec_consts.dtype() == py::dtype::of()) { - std::vector pushconstsvec((double*)pushInfo.ptr, ((double*)pushInfo.ptr) + pushInfo.size); - return self.algorithm(tensors, spirvVec, workgroup, specconstsvec, pushconstsvec); - } - } else if (spec_consts.dtype() == py::dtype::of()) { - std::vector specconstsvec((double*)specInfo.ptr, ((double*)specInfo.ptr) + specInfo.size); - if (spec_consts.dtype() == py::dtype::of()) { - std::vector pushconstsvec((float*)pushInfo.ptr, ((float*)pushInfo.ptr) + pushInfo.size); - return self.algorithm(tensors, spirvVec, workgroup, specconstsvec, pushconstsvec); - } else if (spec_consts.dtype() == py::dtype::of()) { - std::vector pushconstsvec((int32_t*)pushInfo.ptr, ((int32_t*)pushInfo.ptr) + pushInfo.size); - return self.algorithm(tensors, spirvVec, workgroup, specconstsvec, pushconstsvec); - } else if (spec_consts.dtype() == py::dtype::of()) { - std::vector pushconstsvec((uint32_t*)pushInfo.ptr, ((uint32_t*)pushInfo.ptr) + pushInfo.size); - return self.algorithm(tensors, spirvVec, workgroup, specconstsvec, pushconstsvec); - } else if (spec_consts.dtype() == py::dtype::of()) { - std::vector pushconstsvec((double*)pushInfo.ptr, ((double*)pushInfo.ptr) + pushInfo.size); - return self.algorithm(tensors, spirvVec, workgroup, specconstsvec, pushconstsvec); - } - } else { - // If reach then no valid dtype supported - throw std::runtime_error("Kompute Python no valid dtype supported"); + std::vector pushConstsVec((float*)pushInfo.ptr, + ((float*)pushInfo.ptr) + + pushInfo.size); + return self.algorithm(tensors, + spirvVec, + workgroup, + specConstsVec, + pushConstsVec); + } else if (spec_consts.dtype() == + py::dtype::of()) { + std::vector pushConstsVec( + (int32_t*)pushInfo.ptr, + ((int32_t*)pushInfo.ptr) + pushInfo.size); + return self.algorithm(tensors, + spirvVec, + workgroup, + specConstsVec, + pushConstsVec); + } else if (spec_consts.dtype() == + py::dtype::of()) { + std::vector pushConstsVec( + (uint32_t*)pushInfo.ptr, + ((uint32_t*)pushInfo.ptr) + pushInfo.size); + return self.algorithm(tensors, + spirvVec, + workgroup, + specConstsVec, + pushConstsVec); + } else if (spec_consts.dtype() == + py::dtype::of()) { + std::vector pushConstsVec((double*)pushInfo.ptr, + ((double*)pushInfo.ptr) + + pushInfo.size); + return self.algorithm(tensors, + spirvVec, + workgroup, + specConstsVec, + pushConstsVec); } - }, - DOC(kp, Manager, algorithm), - py::arg("tensors"), - py::arg("spirv"), - py::arg("workgroup") = kp::Workgroup(), - py::arg("spec_consts") = std::vector(), - py::arg("push_consts") = std::vector()) - .def("list_devices", [](kp::Manager& self){ + } else if (spec_consts.dtype() == py::dtype::of()) { + std::vector specconstsvec((int32_t*)specInfo.ptr, + ((int32_t*)specInfo.ptr) + + specInfo.size); + if (spec_consts.dtype() == py::dtype::of()) { + std::vector pushconstsvec((float*)pushInfo.ptr, + ((float*)pushInfo.ptr) + + pushInfo.size); + return self.algorithm(tensors, + spirvVec, + workgroup, + specconstsvec, + pushconstsvec); + } else if (spec_consts.dtype() == + py::dtype::of()) { + std::vector pushconstsvec( + (int32_t*)pushInfo.ptr, + ((int32_t*)pushInfo.ptr) + pushInfo.size); + return self.algorithm(tensors, + spirvVec, + workgroup, + specconstsvec, + pushconstsvec); + } else if (spec_consts.dtype() == + py::dtype::of()) { + std::vector pushconstsvec( + (uint32_t*)pushInfo.ptr, + ((uint32_t*)pushInfo.ptr) + pushInfo.size); + return self.algorithm(tensors, + spirvVec, + workgroup, + specconstsvec, + pushconstsvec); + } else if (spec_consts.dtype() == + py::dtype::of()) { + std::vector pushconstsvec((double*)pushInfo.ptr, + ((double*)pushInfo.ptr) + + pushInfo.size); + return self.algorithm(tensors, + spirvVec, + workgroup, + specconstsvec, + pushconstsvec); + } + } else if (spec_consts.dtype() == py::dtype::of()) { + std::vector specconstsvec((uint32_t*)specInfo.ptr, + ((uint32_t*)specInfo.ptr) + + specInfo.size); + if (spec_consts.dtype() == py::dtype::of()) { + std::vector pushconstsvec((float*)pushInfo.ptr, + ((float*)pushInfo.ptr) + + pushInfo.size); + return self.algorithm(tensors, + spirvVec, + workgroup, + specconstsvec, + pushconstsvec); + } else if (spec_consts.dtype() == + py::dtype::of()) { + std::vector pushconstsvec( + (int32_t*)pushInfo.ptr, + ((int32_t*)pushInfo.ptr) + pushInfo.size); + return self.algorithm(tensors, + spirvVec, + workgroup, + specconstsvec, + pushconstsvec); + } else if (spec_consts.dtype() == + py::dtype::of()) { + std::vector pushconstsvec( + (uint32_t*)pushInfo.ptr, + ((uint32_t*)pushInfo.ptr) + pushInfo.size); + return self.algorithm(tensors, + spirvVec, + workgroup, + specconstsvec, + pushconstsvec); + } else if (spec_consts.dtype() == + py::dtype::of()) { + std::vector pushconstsvec((double*)pushInfo.ptr, + ((double*)pushInfo.ptr) + + pushInfo.size); + return self.algorithm(tensors, + spirvVec, + workgroup, + specconstsvec, + pushconstsvec); + } + } else if (spec_consts.dtype() == py::dtype::of()) { + std::vector specconstsvec((double*)specInfo.ptr, + ((double*)specInfo.ptr) + + specInfo.size); + if (spec_consts.dtype() == py::dtype::of()) { + std::vector pushconstsvec((float*)pushInfo.ptr, + ((float*)pushInfo.ptr) + + pushInfo.size); + return self.algorithm(tensors, + spirvVec, + workgroup, + specconstsvec, + pushconstsvec); + } else if (spec_consts.dtype() == + py::dtype::of()) { + std::vector pushconstsvec((int32_t*)pushInfo.ptr, + ((int32_t*)pushInfo.ptr) + + pushInfo.size); + return self.algorithm(tensors, + spirvVec, + workgroup, + specconstsvec, + pushconstsvec); + } else if (spec_consts.dtype() == + py::dtype::of()) { + std::vector pushconstsvec((uint32_t*)pushInfo.ptr, + ((uint32_t*)pushInfo.ptr) + + pushInfo.size); + return self.algorithm(tensors, + spirvVec, + workgroup, + specconstsvec, + pushconstsvec); + } else if (spec_consts.dtype() == + py::dtype::of()) { + std::vector pushconstsvec((double*)pushInfo.ptr, + ((double*)pushInfo.ptr) + + pushInfo.size); + return self.algorithm(tensors, + spirvVec, + workgroup, + specconstsvec, + pushconstsvec); + } + } else { + // If reach then no valid dtype supported + throw std::runtime_error( + "Kompute Python no valid dtype supported"); + } + }, + DOC(kp, Manager, algorithm), + py::arg("tensors"), + py::arg("spirv"), + py::arg("workgroup") = kp::Workgroup(), + py::arg("spec_consts") = std::vector(), + py::arg("push_consts") = std::vector()) + .def( + "list_devices", + [](kp::Manager& self) { const std::vector devices = self.listDevices(); py::list list; for (const vk::PhysicalDevice& device : devices) { list.append(kp::py::vkPropertiesToDict(device.getProperties())); } return list; - }, "Return a dict containing information about the device") - .def("get_device_properties", [](kp::Manager& self){ - const vk::PhysicalDeviceProperties properties = self.getDeviceProperties(); + }, + "Return a dict containing information about the device") + .def( + "get_device_properties", + [](kp::Manager& self) { + const vk::PhysicalDeviceProperties properties = + self.getDeviceProperties(); return kp::py::vkPropertiesToDict(properties); - }, "Return a dict containing information about the device"); + }, + "Return a dict containing information about the device"); auto atexit = py::module_::import("atexit"); - atexit.attr("register")(py::cpp_function([](){ + atexit.attr("register")(py::cpp_function([]() { kp_debug = py::none(); kp_info = py::none(); kp_warning = py::none(); @@ -340,4 +562,3 @@ PYBIND11_MODULE(kp, m) { m.attr("__version__") = "dev"; #endif } - diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c312bde52..3ed805d14 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -80,24 +80,23 @@ endif() ##################################################### if(KOMPUTE_OPT_ANDROID_BUILD) - target_link_libraries(kompute PUBLIC fmt::fmt - kompute_vk_ndk_wrapper + target_link_libraries(kompute PUBLIC kompute_vk_ndk_wrapper + fmt::fmt log - android) + android + logger) else() target_link_libraries(kompute PUBLIC Vulkan::Vulkan - fmt::fmt) + fmt::fmt + logger) endif() if(KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER) target_link_libraries(kompute PUBLIC Vulkan-Headers) endif() -if(KOMPUTE_OPT_ENABLE_LOGGING) - target_link_libraries(kompute PUBLIC spdlog::spdlog) -endif() - ##################################################### # Misc ##################################################### +add_subdirectory(logger) add_subdirectory(include) diff --git a/src/Manager.cpp b/src/Manager.cpp index fd6e654e9..2e58d714a 100644 --- a/src/Manager.cpp +++ b/src/Manager.cpp @@ -6,8 +6,8 @@ #include #include "kompute/Manager.hpp" - -#include "fmt/ranges.h" +#include "kompute/logger/Logger.hpp" +#include "spdlog/common.h" namespace kp { @@ -40,6 +40,9 @@ Manager::Manager(uint32_t physicalDeviceIndex, { this->mManageResources = true; + // Make sure the logger is setup + logger::setupLogger(); + this->createInstance(); this->createDevice( familyQueueIndices, physicalDeviceIndex, desiredExtensions); @@ -54,6 +57,9 @@ Manager::Manager(std::shared_ptr instance, this->mInstance = instance; this->mPhysicalDevice = physicalDevice; this->mDevice = device; + + // Make sure the logger is setup + logger::setupLogger(); } Manager::~Manager() @@ -311,8 +317,10 @@ Manager::createDevice(const std::vector& familyQueueIndices, this->mPhysicalDevice = std::make_shared(physicalDevice); +#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_INFO vk::PhysicalDeviceProperties physicalDeviceProperties = physicalDevice.getProperties(); +#endif KP_LOG_INFO("Using physical device index {} found {}", physicalDeviceIndex, @@ -369,7 +377,7 @@ Manager::createDevice(const std::vector& familyQueueIndices, } KP_LOG_DEBUG("Kompute Manager desired extension layers {}", - desiredExtensions); + logger::vecToString(desiredExtensions)); std::vector deviceExtensions = this->mPhysicalDevice->enumerateDeviceExtensionProperties(); @@ -379,7 +387,7 @@ Manager::createDevice(const std::vector& familyQueueIndices, uniqueExtensionNames.insert(ext.extensionName); } KP_LOG_DEBUG("Kompute Manager available extensions {}", - uniqueExtensionNames); + logger::setToString(uniqueExtensionNames)); std::vector validExtensions; for (const std::string& ext : desiredExtensions) { if (uniqueExtensionNames.count(ext) != 0) { @@ -388,7 +396,7 @@ Manager::createDevice(const std::vector& familyQueueIndices, } if (desiredExtensions.size() != validExtensions.size()) { KP_LOG_ERROR("Kompute Manager not all extensions were added: {}", - validExtensions); + logger::vecToString(validExtensions)); } vk::DeviceCreateInfo deviceCreateInfo(vk::DeviceCreateFlags(), diff --git a/src/OpTensorCopy.cpp b/src/OpTensorCopy.cpp index 3180fa3cd..aae727533 100644 --- a/src/OpTensorCopy.cpp +++ b/src/OpTensorCopy.cpp @@ -1,6 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 #include "kompute/operations/OpTensorCopy.hpp" +#include "kompute/Tensor.hpp" namespace kp { @@ -21,8 +22,8 @@ OpTensorCopy::OpTensorCopy(const std::vector>& tensors) if (tensor->dataType() != dataType) { throw std::runtime_error(fmt::format( "Attempting to copy tensors of different types from {} to {}", - dataType, - tensor->dataType())); + Tensor::toString(dataType), + Tensor::toString(tensor->dataType()))); } if (tensor->size() != size) { throw std::runtime_error(fmt::format( diff --git a/src/Tensor.cpp b/src/Tensor.cpp index 4f5e866f9..ab62eb828 100644 --- a/src/Tensor.cpp +++ b/src/Tensor.cpp @@ -4,6 +4,40 @@ namespace kp { +std::string +Tensor::toString(Tensor::TensorDataTypes dt) +{ + switch (dt) { + case TensorDataTypes::eBool: + return "eBool"; + case TensorDataTypes::eInt: + return "eInt"; + case TensorDataTypes::eUnsignedInt: + return "eUnsignedInt"; + case TensorDataTypes::eFloat: + return "eFloat"; + case TensorDataTypes::eDouble: + return "eDouble"; + default: + return "unknown"; + } +} + +std::string +Tensor::toString(Tensor::TensorTypes dt) +{ + switch (dt) { + case TensorTypes::eDevice: + return "eDevice"; + case TensorTypes::eHost: + return "eHost"; + case TensorTypes::eStorage: + return "eStorage"; + default: + return "unknown"; + } +} + Tensor::Tensor(std::shared_ptr physicalDevice, std::shared_ptr device, void* data, @@ -14,7 +48,7 @@ Tensor::Tensor(std::shared_ptr physicalDevice, { KP_LOG_DEBUG("Kompute Tensor constructor data length: {}, and type: {}", elementTotalCount, - tensorType); + Tensor::toString(tensorType)); this->mPhysicalDevice = physicalDevice; this->mDevice = device; @@ -27,7 +61,7 @@ Tensor::Tensor(std::shared_ptr physicalDevice, Tensor::~Tensor() { KP_LOG_DEBUG("Kompute Tensor destructor started. Type: {}", - this->tensorType()); + Tensor::toString(this->tensorType())); if (this->mDevice) { this->destroy(); diff --git a/src/include/CMakeLists.txt b/src/include/CMakeLists.txt index 9f75d06a0..6535a1222 100644 --- a/src/include/CMakeLists.txt +++ b/src/include/CMakeLists.txt @@ -1,5 +1,9 @@ cmake_minimum_required(VERSION 3.15) +##################################################### +# Kompute +##################################################### + target_include_directories(kompute PUBLIC $ $) @@ -22,6 +26,22 @@ target_sources(kompute PRIVATE kompute/shaders/shaderlogisticregression.hpp kompute/shaders/shaderopmult.hpp + + kompute/logger/Logger.hpp ) install(DIRECTORY kompute DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + +##################################################### +# Logger +##################################################### + +target_include_directories(logger PUBLIC $ + $) + +target_sources(logger PRIVATE + # Header files (useful in IDEs) + kompute/logger/Logger.hpp +) + +install(DIRECTORY logger DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) \ No newline at end of file diff --git a/src/include/kompute/Algorithm.hpp b/src/include/kompute/Algorithm.hpp index bb6b9faa5..804a70900 100644 --- a/src/include/kompute/Algorithm.hpp +++ b/src/include/kompute/Algorithm.hpp @@ -4,6 +4,7 @@ #include "kompute/Core.hpp" #include "kompute/Tensor.hpp" +#include "logger/Logger.hpp" namespace kp { diff --git a/src/include/kompute/Core.hpp b/src/include/kompute/Core.hpp index 2c49f29ef..65936460d 100644 --- a/src/include/kompute/Core.hpp +++ b/src/include/kompute/Core.hpp @@ -2,15 +2,11 @@ #pragma once #if VK_USE_PLATFORM_ANDROID_KHR -#include #include // VK_NO_PROTOTYPES required before vulkan import but after wrapper.hpp #undef VK_NO_PROTOTYPES -static const char* KOMPUTE_LOG_TAG = "KomputeLog"; #endif -#include - #include // Typedefs to simplify interaction with core types @@ -32,124 +28,9 @@ typedef std::vector Constants; KOMPUTE_VK_API_MAJOR_VERSION, KOMPUTE_VK_API_MINOR_VERSION, 0) #endif // KOMPUTE_VK_API_VERSION -// Defining kompute log levels analogous to spdlog log levels -#define KOMPUTE_LOG_LEVEL_TRACE 0 -#define KOMPUTE_LOG_LEVEL_DEBUG 1 -#define KOMPUTE_LOG_LEVEL_INFO 2 -#define KOMPUTE_LOG_LEVEL_WARN 3 -#define KOMPUTE_LOG_LEVEL_ERROR 4 -#define KOMPUTE_LOG_LEVEL_CRITICAL 5 -#define KOMPUTE_LOG_LEVEL_OFF 6 - -#ifndef KOMPUTE_LOG_LEVEL -#if DEBUG -#define KOMPUTE_LOG_LEVEL KOMPUTE_LOG_LEVEL_DEBUG -#else -#define KOMPUTE_LOG_LEVEL KOMPUTE_LOG_LEVEL_INFO -#endif -#endif // KOMPUTE_LOG_LEVEL - -// SPDLOG_ACTIVE_LEVEL must be defined before spdlog.h import -// It is recommended that it's set via KOMPUTE_LOG_LEVEL -// but if required it can be set directly as override -#ifndef SPDLOG_ACTIVE_LEVEL -#define SPDLOG_ACTIVE_LEVEL KOMPUTE_LOG_LEVEL -#endif - #if defined(KOMPUTE_BUILD_PYTHON) #include namespace py = pybind11; // from python/src/main.cpp extern py::object kp_debug, kp_info, kp_warning, kp_error; #endif - -#ifndef KOMPUTE_LOG_OVERRIDE -#if KOMPUTE_ENABLE_SPDLOG -#include -#define KP_LOG_DEBUG(...) SPDLOG_DEBUG(__VA_ARGS__) -#define KP_LOG_INFO(...) SPDLOG_INFO(__VA_ARGS__) -#define KP_LOG_WARN(...) SPDLOG_WARN(__VA_ARGS__) -#define KP_LOG_ERROR(...) SPDLOG_ERROR(__VA_ARGS__) -#else -#include -#if KOMPUTE_LOG_LEVEL > 1 -#define KP_LOG_DEBUG(...) -#else -#if defined(VK_USE_PLATFORM_ANDROID_KHR) -#define KP_LOG_DEBUG(...) \ - ((void)__android_log_write( \ - ANDROID_LOG_DEBUG, KOMPUTE_LOG_TAG, fmt::format(__VA_ARGS__).c_str())) -#elif defined(KOMPUTE_BUILD_PYTHON) -#define KP_LOG_DEBUG(...) kp_debug(fmt::format(__VA_ARGS__)) -#else -#define KP_LOG_DEBUG(...) \ - fmt::print("[{} {}] [debug] [{}:{}] {}\n", \ - __DATE__, \ - __TIME__, \ - __FILE__, \ - __LINE__, \ - fmt::format(__VA_ARGS__)) -#endif // VK_USE_PLATFORM_ANDROID_KHR -#endif // KOMPUTE_LOG_LEVEL > 1 - -#if KOMPUTE_LOG_LEVEL > 2 -#define KP_LOG_INFO(...) -#else -#if defined(VK_USE_PLATFORM_ANDROID_KHR) -#define KP_LOG_INFO(...) \ - ((void)__android_log_write( \ - ANDROID_LOG_INFO, KOMPUTE_LOG_TAG, fmt::format(__VA_ARGS__).c_str())) -#elif defined(KOMPUTE_BUILD_PYTHON) -#define KP_LOG_INFO(...) kp_info(fmt::format(__VA_ARGS__)) -#else -#define KP_LOG_INFO(...) \ - fmt::print("[{} {}] [debug] [{}:{}] {}\n", \ - __DATE__, \ - __TIME__, \ - __FILE__, \ - __LINE__, \ - fmt::format(__VA_ARGS__)) -#endif // VK_USE_PLATFORM_ANDROID_KHR -#endif // KOMPUTE_LOG_LEVEL > 2 - -#if KOMPUTE_LOG_LEVEL > 3 -#define KP_LOG_WARN(...) -#else -#if defined(VK_USE_PLATFORM_ANDROID_KHR) -#define KP_LOG_WARN(...) \ - ((void)__android_log_write( \ - ANDROID_LOG_WARN, KOMPUTE_LOG_TAG, fmt::format(__VA_ARGS__).c_str())) -#elif defined(KOMPUTE_BUILD_PYTHON) -#define KP_LOG_WARN(...) kp_warning(fmt::format(__VA_ARGS__)) -#else -#define KP_LOG_WARN(...) \ - fmt::print("[{} {}] [debug] [{}:{}] {}\n", \ - __DATE__, \ - __TIME__, \ - __FILE__, \ - __LINE__, \ - fmt::format(__VA_ARGS__)) -#endif // VK_USE_PLATFORM_ANDROID_KHR -#endif // KOMPUTE_LOG_LEVEL > 3 - -#if KOMPUTE_LOG_LEVEL > 4 -#define KP_LOG_ERROR(...) -#else -#if defined(VK_USE_PLATFORM_ANDROID_KHR) -#define KP_LOG_ERROR(...) \ - ((void)__android_log_write( \ - ANDROID_LOG_ERROR, KOMPUTE_LOG_TAG, fmt::format(__VA_ARGS__).c_str())) -#elif defined(KOMPUTE_BUILD_PYTHON) -#define KP_LOG_ERROR(...) kp_error(fmt::format(__VA_ARGS__)) -#else -#define KP_LOG_ERROR(...) \ - fmt::print("[{} {}] [debug] [{}:{}] {}\n", \ - __DATE__, \ - __TIME__, \ - __FILE__, \ - __LINE__, \ - fmt::format(__VA_ARGS__)) -#endif // VK_USE_PLATFORM_ANDROID_KHR -#endif // KOMPUTE_LOG_LEVEL > 4 -#endif // KOMPUTE_SPDLOG_ENABLED -#endif // KOMPUTE_LOG_OVERRIDE diff --git a/src/include/kompute/Manager.hpp b/src/include/kompute/Manager.hpp index 5ff325225..53261c06d 100644 --- a/src/include/kompute/Manager.hpp +++ b/src/include/kompute/Manager.hpp @@ -7,6 +7,7 @@ #include "kompute/Core.hpp" #include "kompute/Sequence.hpp" +#include "logger/Logger.hpp" #define KP_DEFAULT_SESSION "DEFAULT" diff --git a/src/include/kompute/Tensor.hpp b/src/include/kompute/Tensor.hpp index 05c402ac4..948a55130 100644 --- a/src/include/kompute/Tensor.hpp +++ b/src/include/kompute/Tensor.hpp @@ -1,10 +1,12 @@ // SPDX-License-Identifier: Apache-2.0 #pragma once -#include "kompute/Core.hpp" -#include #include +#include "kompute/Core.hpp" + +#include "logger/Logger.hpp" + namespace kp { /** @@ -39,6 +41,9 @@ class Tensor eDouble = 4, }; + static std::string toString(TensorDataTypes dt); + static std::string toString(TensorTypes dt); + /** * Constructor with data provided which would be used to create the * respective vulkan buffer and memory. @@ -341,59 +346,3 @@ class TensorT : public Tensor }; } // End namespace kp - -/** - * fmt fromater for kp::Tensor::TensorDataTypes. - */ -template<> -struct fmt::formatter : formatter -{ - template - auto format(kp::Tensor::TensorDataTypes dt, FormatContext& ctx) - { - std::string name = "unknown"; - switch (dt) { - case kp::Tensor::TensorDataTypes::eBool: - name = "eBool"; - break; - case kp::Tensor::TensorDataTypes::eDouble: - name = "eDouble"; - break; - case kp::Tensor::TensorDataTypes::eFloat: - name = "eFloat"; - break; - case kp::Tensor::TensorDataTypes::eInt: - name = "eInt"; - break; - case kp::Tensor::TensorDataTypes::eUnsignedInt: - name = "eUnsignedInt"; - break; - } - return formatter::format(name, ctx); - } -}; - -/** - * fmt fromater for kp::Tensor::TensorTypes. - */ -template<> -struct fmt::formatter : formatter -{ - template - auto format(kp::Tensor::TensorTypes dt, FormatContext& ctx) - { - std::string name = "unknown"; - switch (dt) { - case kp::Tensor::TensorTypes::eDevice: - name = "eDevice"; - break; - case kp::Tensor::TensorTypes::eHost: - name = "eHost"; - break; - case kp::Tensor::TensorTypes::eStorage: - name = "eStorage"; - break; - } - return formatter::format(name, ctx); - } -}; diff --git a/src/include/kompute/logger/Logger.hpp b/src/include/kompute/logger/Logger.hpp new file mode 100644 index 000000000..92b2872c5 --- /dev/null +++ b/src/include/kompute/logger/Logger.hpp @@ -0,0 +1,36 @@ +#pragma once + +#include +#include +#include +#include + +#define KP_LOG_TRACE(...) SPDLOG_TRACE(__VA_ARGS__) +#define KP_LOG_DEBUG(...) SPDLOG_DEBUG(__VA_ARGS__) +#define KP_LOG_INFO(...) SPDLOG_INFO(__VA_ARGS__) +#define KP_LOG_WARN(...) SPDLOG_WARN(__VA_ARGS__) +#define KP_LOG_ERROR(...) SPDLOG_ERROR(__VA_ARGS__) + +namespace logger { +const std::string logFolder("kompute_logs"); +// Setup the logger, note the loglevel can not be set below the CMake log level +// (To change this use -DKOMPUTE_OPT_LOG_LEVEL=...) +void +setupLogger(); +void +setLogLevel(spdlog::level::level_enum level); +void +deactivateLogger(); + +spdlog::level::level_enum +getLogLevel(); + +std::string +setToString(const std::set& set); + +std::string +vecToString(const std::vector& vec); + +std::string +vecToString(const std::vector& vec); +} // namespace logger diff --git a/src/logger/CMakeLists.txt b/src/logger/CMakeLists.txt new file mode 100644 index 000000000..02c50f612 --- /dev/null +++ b/src/logger/CMakeLists.txt @@ -0,0 +1,37 @@ +cmake_minimum_required(VERSION 3.16) + +set(LOGGER_SOURCES Logger.cpp) + +add_library(logger ${LOGGER_SOURCES}) +target_link_libraries(logger PUBLIC spdlog::spdlog) + +if(${KOMPUTE_OPT_LOG_LEVEL} STREQUAL "Trace") + set (KOMPUTE_OPT_LOG_LEVEL TRACE) + message(STATUS "Using log level Trace") +elseif(${KOMPUTE_OPT_LOG_LEVEL} STREQUAL "Debug") + set (KOMPUTE_OPT_LOG_LEVEL DEBUG) + message(STATUS "Using log level Debug") +elseif(${KOMPUTE_OPT_LOG_LEVEL} STREQUAL "Info") + set (KOMPUTE_OPT_LOG_LEVEL INFO) + message(STATUS "Using log level Info") +elseif(${KOMPUTE_OPT_LOG_LEVEL} STREQUAL "Warn") + set (KOMPUTE_OPT_LOG_LEVEL WARN) + message(STATUS "Using log level Warn") +elseif(${KOMPUTE_OPT_LOG_LEVEL} STREQUAL "Error") + set (KOMPUTE_OPT_LOG_LEVEL ERROR) + message(STATUS "Using log level Error") +elseif(${KOMPUTE_OPT_LOG_LEVEL} STREQUAL "Critical") + set (KOMPUTE_OPT_LOG_LEVEL CRITICAL) + message(STATUS "Using log level Critical") +elseif(${KOMPUTE_OPT_LOG_LEVEL} STREQUAL Off) + set (KOMPUTE_OPT_LOG_LEVEL OFF) + message(STATUS "Using log level Off") +else() + if((NOT ${KOMPUTE_OPT_LOG_LEVEL} STREQUAL Default) AND (NOT KOMPUTE_OPT_LOG_LEVEL STREQUAL "")) + message(WARNING "Log level '${KOMPUTE_OPT_LOG_LEVEL}' unknown, use -DKOMPUTE_OPT_LOG_LEVEL=[Trace, Debug, Info, Warn, Error, Critical, Off]") + endif() + set (KOMPUTE_OPT_LOG_LEVEL $,DEBUG,INFO>) + message(STATUS "Setting KOMPUTE_OPT_LOG_LEVEL to according to build type") +endif() + +target_compile_definitions(logger INTERFACE SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${KOMPUTE_OPT_LOG_LEVEL}) diff --git a/src/logger/Logger.cpp b/src/logger/Logger.cpp new file mode 100644 index 000000000..698ead8e5 --- /dev/null +++ b/src/logger/Logger.cpp @@ -0,0 +1,192 @@ +#include "kompute/logger/Logger.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#ifdef _WIN32 +#include +#endif // _WIN32 + +namespace logger { +constexpr int THREAD_QUEUE_LENGTH = 8192; +constexpr int FILE_ROTATION_TIME = 1048576 * 5; + +/** + * Should be replaced with: + * std::filesystem::exists(path) + * when switching to cpp17 + **/ +bool +exists(const std::string& path) +{ + struct stat info + {}; + if (stat(path.c_str(), &info) != 0) { + // std::cerr << "Failed to check if '" << path + // << "' exists. Cannot access!\n"; + // assert(false); + return false; + } + return info.st_mode & S_IFDIR; +} + +/** + * Based on: https://stackoverflow.com/a/35109823 + * Should be replaced with: + * std::filesystem::create_directory(path); + * when switching to cpp17 + **/ +void +createDir(const std::string& path) +{ + mode_t nMode = 0733; // UNIX style permissions + int nError = 0; +#if defined(_WIN32) + nError = _mkdir(sPath.c_str()); // can be used on Windows +#else + nError = mkdir(path.c_str(), nMode); // can be used on non-Windows +#endif + if (nError != 0) { + std::cerr << "Failed to create '" << path << "' with: " << nError + << '\n'; + assert(false); + } +} + +void +setupLogger() +{ + // Ensure we setup the logger only once + static bool setup = false; + static std::mutex setupMutex{}; + setupMutex.lock(); + if (setup) { + setupMutex.unlock(); + return; + } + setup = true; + setupMutex.unlock(); + + if (!exists(logger::logFolder)) { + createDir(logger::logFolder); + } + spdlog::init_thread_pool(THREAD_QUEUE_LENGTH, 1); + spdlog::sink_ptr console_sink = + std::make_shared(); + console_sink->set_pattern("[%H:%M:%S %z] [%=8l] [thread %t] [%@]\t%v"); +#ifdef _WIN32 + std::string s = (logger::log_folder / "kompute.log").string(); + spdlog::sink_ptr file_sink = + std::make_shared( + s, FILE_ROTATION_TIME, 3); +#else // _WIN32 + spdlog::sink_ptr file_sink = + std::make_shared( + logger::logFolder + "/kompute.log", FILE_ROTATION_TIME, 3); +#endif + file_sink->set_pattern("[%H:%M:%S %z] [%=8l] [thread %t] [%@]\t%v"); + std::vector sinks{ file_sink, console_sink }; + std::shared_ptr logger = + std::make_shared( + "", + sinks.begin(), + sinks.end(), + spdlog::thread_pool(), + spdlog::async_overflow_policy::block); + + logger->set_level(getLogLevel()); + spdlog::set_default_logger(logger); +} + +spdlog::level::level_enum +getLogLevel() +{ +#if SPDLOG_ACTIVE_LEVEL == SPDLOG_LEVEL_TRACE + return spdlog::level::trace; +#endif + +#if SPDLOG_ACTIVE_LEVEL == SPDLOG_LEVEL_DEBUG + return spdlog::level::debug; +#endif + +#if SPDLOG_ACTIVE_LEVEL == SPDLOG_LEVEL_INFO + return spdlog::level::info; +#endif + +#if SPDLOG_ACTIVE_LEVEL == SPDLOG_LEVEL_WARN + return spdlog::level::warn; +#endif + +#if SPDLOG_ACTIVE_LEVEL == SPDLOG_LEVEL_ERROR + return spdlog::level::error; +#endif + +#if SPDLOG_ACTIVE_LEVEL == SPDLOG_LEVEL_CRITICAL + return spdlog::level::critical; +#endif + + return spdlog::level::off; +} + +void +setLogLevel(const spdlog::level::level_enum level) +{ + spdlog::default_logger()->set_level(level); +} + +void +deactivateLogger() +{ + logger::setLogLevel(spdlog::level::off); +} + +std::string +setToString(const std::set& set) +{ + std::string result; + for (const std::string& entry : set) { + result += entry + ", "; + } + if (result.empty()) { + return result; + } + return result.substr(0, result.size() - 2); // Remove the tailing ", " +} + +std::string +vecToString(const std::vector& vec) +{ + std::string result; + for (const char* entry : vec) { + result += std::string(entry) + ", "; + } + if (result.empty()) { + return result; + } + return result.substr(0, result.size() - 2); // Remove the tailing ", " +} + +std::string +vecToString(const std::vector& vec) +{ + std::string result; + for (const std::string& entry : vec) { + result += entry + ", "; + } + if (result.empty()) { + return result; + } + return result.substr(0, result.size() - 2); // Remove the tailing ", " +} +} // namespace logger diff --git a/test/TestPushConstant.cpp b/test/TestPushConstant.cpp index a78224fc0..777ac95ec 100644 --- a/test/TestPushConstant.cpp +++ b/test/TestPushConstant.cpp @@ -6,8 +6,6 @@ #include "shaders/Utils.hpp" -#include "fmt/ranges.h" - TEST(TestPushConstants, TestConstantsAlgoDispatchOverride) { { From f0773d6005a8aefc05df1c56d8f2694f83a13ec2 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Fri, 20 May 2022 16:17:55 +0200 Subject: [PATCH 024/107] Private linking when ever possible Signed-off-by: Fabian Sauter --- src/CMakeLists.txt | 11 +++++------ test/CMakeLists.txt | 6 +++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3ed805d14..a16f0563a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -47,7 +47,7 @@ if(CPR_FORCE_USE_SYSTEM_CURL) install(EXPORT komputeTargets FILE komputeTargets.cmake NAMESPACE kompute:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kompute) + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kompute) install(FILES ${PROJECT_BINARY_DIR}/kompute/komputeConfig.cmake ${PROJECT_BINARY_DIR}/kompute/komputeConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kompute) @@ -81,14 +81,13 @@ endif() if(KOMPUTE_OPT_ANDROID_BUILD) target_link_libraries(kompute PUBLIC kompute_vk_ndk_wrapper - fmt::fmt - log android - logger) + PRIVATE logger + fmt::fmt) else() target_link_libraries(kompute PUBLIC Vulkan::Vulkan - fmt::fmt - logger) + PRIVATE fmt::fmt + logger) endif() if(KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 49e8f0356..31cb1b792 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -15,9 +15,9 @@ macro(add_kompute_test _TEST_NAME) add_executable("${_TEST_NAME}_tests" "Test${_TEST_NAME}.cpp" ${ARGN}) target_link_libraries("${_TEST_NAME}_tests" PRIVATE GTest::GTest - kompute::kompute - test_shaders - test_shaders_glsl) + kompute::kompute + test_shaders + test_shaders_glsl) add_test(NAME "kompute_${_TEST_NAME}_tests" COMMAND "${_TEST_NAME}_tests") # Group under the "tests" project folder in IDEs such as Visual Studio. set_property(TARGET ${_TEST_NAME}_tests PROPERTY FOLDER "tests") From 3f7ca2830e8e32ebbb9a5dc17ba54749d8252bae Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Fri, 20 May 2022 16:23:24 +0200 Subject: [PATCH 025/107] Renamed logger target Signed-off-by: Fabian Sauter --- src/CMakeLists.txt | 4 ++-- src/include/CMakeLists.txt | 4 ++-- src/logger/CMakeLists.txt | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a16f0563a..68dd739b1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -82,12 +82,12 @@ endif() if(KOMPUTE_OPT_ANDROID_BUILD) target_link_libraries(kompute PUBLIC kompute_vk_ndk_wrapper android - PRIVATE logger + PRIVATE kp_logger fmt::fmt) else() target_link_libraries(kompute PUBLIC Vulkan::Vulkan PRIVATE fmt::fmt - logger) + kp_logger) endif() if(KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER) diff --git a/src/include/CMakeLists.txt b/src/include/CMakeLists.txt index 6535a1222..16f7f5092 100644 --- a/src/include/CMakeLists.txt +++ b/src/include/CMakeLists.txt @@ -36,10 +36,10 @@ install(DIRECTORY kompute DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) # Logger ##################################################### -target_include_directories(logger PUBLIC $ +target_include_directories(kp_logger PUBLIC $ $) -target_sources(logger PRIVATE +target_sources(kp_logger PRIVATE # Header files (useful in IDEs) kompute/logger/Logger.hpp ) diff --git a/src/logger/CMakeLists.txt b/src/logger/CMakeLists.txt index 02c50f612..087de1771 100644 --- a/src/logger/CMakeLists.txt +++ b/src/logger/CMakeLists.txt @@ -2,8 +2,8 @@ cmake_minimum_required(VERSION 3.16) set(LOGGER_SOURCES Logger.cpp) -add_library(logger ${LOGGER_SOURCES}) -target_link_libraries(logger PUBLIC spdlog::spdlog) +add_library(kp_logger ${LOGGER_SOURCES}) +target_link_libraries(kp_logger PUBLIC spdlog::spdlog) if(${KOMPUTE_OPT_LOG_LEVEL} STREQUAL "Trace") set (KOMPUTE_OPT_LOG_LEVEL TRACE) @@ -34,4 +34,4 @@ else() message(STATUS "Setting KOMPUTE_OPT_LOG_LEVEL to according to build type") endif() -target_compile_definitions(logger INTERFACE SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${KOMPUTE_OPT_LOG_LEVEL}) +target_compile_definitions(kp_logger INTERFACE SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${KOMPUTE_OPT_LOG_LEVEL}) From ff51d4528b7e91ba5f200b41268a74fa6d00e76b Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Fri, 20 May 2022 16:33:56 +0200 Subject: [PATCH 026/107] Fixed vulkan shader compining when in sub project Signed-off-by: Fabian Sauter --- cmake/vulkan_shader_compiler.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/vulkan_shader_compiler.cmake b/cmake/vulkan_shader_compiler.cmake index bce7fdab9..abd927ec0 100644 --- a/cmake/vulkan_shader_compiler.cmake +++ b/cmake/vulkan_shader_compiler.cmake @@ -32,8 +32,8 @@ function(vulkan_compile_shader) "-DHEADER_NAMESPACE=${SHADER_COMPILE_NAMESPACE}" "-DIS_BIG_ENDIAN=${IS_BIG_ENDIAN}" "-P" - "${CMAKE_SOURCE_DIR}/cmake/bin_file_to_header.cmake" - WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/cmake" + "${PROJECT_SOURCE_DIR}/cmake/bin_file_to_header.cmake" + WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/cmake" COMMENT "Converting compiled shader '${SHADER_COMPILE_SPV_FILE_FULL}' to header file '${SHADER_COMPILE_HEADER_FILE_FULL}'." MAIN_DEPENDENCY "${SHADER_COMPILE_SPV_FILE_FULL}") endfunction() From fffc720adf5b11dc6da01f68fbdad92e721fa4d7 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Fri, 20 May 2022 16:40:59 +0200 Subject: [PATCH 027/107] Disabled building tests Signed-off-by: Fabian Sauter --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e9302b643..092ab931b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,7 +67,7 @@ option(BUILD_SHARED_LIBS "Build libraries as shared libraries" ON) message(STATUS "General purpose GPU compute framework built on Vulkan") message(STATUS "=======================================================") # Enable or disable targets -kompute_option(KOMPUTE_OPT_BUILD_TESTS "Enable if you want to build tests" ON) +kompute_option(KOMPUTE_OPT_BUILD_TESTS "Enable if you want to build tests" OFF) kompute_option(KOMPUTE_OPT_CODE_COVERAGE "Enable if you want code coverage" OFF) kompute_option(KOMPUTE_OPT_BUILD_DOCS "Enable if you want to build documentation" OFF) kompute_option(KOMPUTE_OPT_INSTALL "Enable if you want to enable installation" OFF) From 210fa21a3af27e21001447caeee15f7cdacd33ef Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Sun, 29 May 2022 09:46:25 +0200 Subject: [PATCH 028/107] [[nodiscard]] is cpp17 Signed-off-by: Fabian Sauter --- src/include/kompute/Sequence.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/include/kompute/Sequence.hpp b/src/include/kompute/Sequence.hpp index 544344f14..e950b4ff0 100644 --- a/src/include/kompute/Sequence.hpp +++ b/src/include/kompute/Sequence.hpp @@ -235,7 +235,7 @@ class Sequence : public std::enable_shared_from_this * * @return Boolean stating if recording ongoing. */ - [[nodiscard]] bool isRecording() const; + bool isRecording() const; /** * Returns true if the sequence has been initialised, and it's based on the @@ -243,7 +243,7 @@ class Sequence : public std::enable_shared_from_this * * @return Boolean stating if is initialized */ - [[nodiscard]] bool isInit() const; + bool isInit() const; /** * Clears command buffer and triggers re-record of all the current @@ -258,7 +258,7 @@ class Sequence : public std::enable_shared_from_this * * @return Boolean stating if currently running. */ - [[nodiscard]] bool isRunning() const; + bool isRunning() const; /** * Destroys and frees the GPU resources which include the buffer and memory From 55f6df6160773cc6905ed4f8ea30d147fd2328d9 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Wed, 8 Jun 2022 10:00:58 +0200 Subject: [PATCH 029/107] Updated python tests to the lates CI template Signed-off-by: Fabian Sauter --- .github/workflows/python_tests.yml | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/.github/workflows/python_tests.yml b/.github/workflows/python_tests.yml index e28bcd2a4..a5de7032e 100644 --- a/.github/workflows/python_tests.yml +++ b/.github/workflows/python_tests.yml @@ -8,21 +8,16 @@ on: jobs: python-tests: - - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest container: axsauze/kompute-builder:0.3 - steps: - - uses: actions/checkout@v2 - with: - submodules: recursive - - name: configure-python - run: | - pip3 install -r python/test/requirements-dev.txt - - name: build-python - run: | - pip3 install . - - name: test-python + - name: Install vulkaninfo + run: apt update -y && apt install -y vulkan-tools + - name: Install Python Requirements + run: pip3 install -r python/test/requirements-dev.txt + - name: Python Build + run: pip3 install . + - name: Python run Tests run: | export VK_ICD_FILENAMES=/swiftshader/vk_swiftshader_icd.json make test_python From 0648fefa49135601576d680b2850b10d841276f7 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Wed, 8 Jun 2022 10:05:26 +0200 Subject: [PATCH 030/107] Added python test checkout Signed-off-by: Fabian Sauter --- .github/workflows/python_tests.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python_tests.yml b/.github/workflows/python_tests.yml index a5de7032e..8019f1172 100644 --- a/.github/workflows/python_tests.yml +++ b/.github/workflows/python_tests.yml @@ -11,12 +11,16 @@ jobs: runs-on: ubuntu-latest container: axsauze/kompute-builder:0.3 steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: false - name: Install vulkaninfo run: apt update -y && apt install -y vulkan-tools - name: Install Python Requirements - run: pip3 install -r python/test/requirements-dev.txt + run: pip3 install --user -r python/test/requirements-dev.txt - name: Python Build - run: pip3 install . + run: pip3 install --user . - name: Python run Tests run: | export VK_ICD_FILENAMES=/swiftshader/vk_swiftshader_icd.json From e028b1f83890f7d9f990d000eca467f593e20eb0 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Thu, 9 Jun 2022 10:49:44 +0200 Subject: [PATCH 031/107] Fixed vulkan version check wording and GPU validation Signed-off-by: Fabian Sauter --- cmake/check_vulkan_version.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/check_vulkan_version.cmake b/cmake/check_vulkan_version.cmake index 2adf63058..3ac8b0572 100644 --- a/cmake/check_vulkan_version.cmake +++ b/cmake/check_vulkan_version.cmake @@ -108,7 +108,7 @@ function(check_vulkan_version) endif() if(${VULKAN_DRIVER_MINOR_VERSION} EQUAL ${VULKAN_HEADER_MINOR_VERSION}) - message(WARNING "Your GPU driver does not support Vulkan > ${VULKAN_DRIVER_VERSION}, but you try to use Vulkan Header ${VULKAN_HEADER_VERSION}. At least your driver supports the same minor version (${VULKAN_DRIVER_MINOR_VERSION}), so this should be fine but keep it in mind if encounter some strange behavior.") + message(WARNING "Your GPU driver does not support Vulkan > ${VULKAN_DRIVER_VERSION}, but you try to use Vulkan Header ${VULKAN_HEADER_VERSION}. At least your driver supports the same minor version (${VULKAN_DRIVER_MINOR_VERSION}), so this should be fine but keep it in mind in case you encounter any strange behavior.") set(VALID_GPU ${GPU}) set(VALID_VULKAN_VERSION ${VULKAN_DRIVER_VERSION}) break() @@ -122,7 +122,7 @@ function(check_vulkan_version) endif() endforeach() - if(${GPU} STREQUAL "") + if(${VALID_GPU} STREQUAL "") message(FATAL_ERROR "None of your GPUs supports Vulkan Header ${VULKAN_HEADER_VERSION}. Please try updating your driver, or downgrade Vulkan header.") else() message("Valid GPU (${VALID_GPU}) for Vulkan header version ${VULKAN_HEADER_VERSION} found. ${VALID_GPU} supports up to Vulkan ${VALID_VULKAN_VERSION}.") From a58065bfee83b1c3b6f8abf1f4c69ee72e492d0f Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Thu, 9 Jun 2022 10:50:08 +0200 Subject: [PATCH 032/107] Updated python setup script Signed-off-by: Fabian Sauter --- setup.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/setup.py b/setup.py index c0d5d6d3d..3d828da7c 100644 --- a/setup.py +++ b/setup.py @@ -28,8 +28,8 @@ class CMakeBuild(build_ext): ", ".join(e.name for e in self.extensions)) cmake_version = LooseVersion(re.search(r'version\s*([\d.]+)', out.decode()).group(1)) - if cmake_version < '3.4.1': - raise RuntimeError("CMake >= 3.4.1 is required") + if cmake_version < '3.15': + raise RuntimeError("CMake >= 3.15 is required") for ext in self.extensions: self.build_extension(ext) @@ -41,8 +41,8 @@ class CMakeBuild(build_ext): extdir += os.path.sep cmake_args = ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + extdir, - '-DKOMPUTE_OPT_BUILD_PYTHON=1', - '-DKOMPUTE_OPT_ENABLE_SPDLOG=0', + '-DKOMPUTE_OPT_BUILD_PYTHON=ON', + '-DKOMPUTE_OPT_LOG_LEVEL=Off', '-DPYTHON_EXECUTABLE=' + sys.executable, '-DPYTHON_INCLUDE_DIR=' + sysconfig.get_path('include'), '-DPYTHON_LIBRARY=' + sysconfig.get_path('stdlib'), @@ -51,20 +51,20 @@ class CMakeBuild(build_ext): cfg = 'Debug' if self.debug else 'Release' build_args = ['--config', cfg] + env = os.environ.copy() + oldCxxFlags = env.get('CXXFLAGS', '') + env['CXXFLAGS'] = f'{oldCxxFlags} -DVERSION_INFO=\\"{self.distribution.get_version()}\\"' + if platform.system() == "Windows": - cmake_args += ['-DKOMPUTE_EXTRA_CXX_FLAGS=""'] - cmake_args += ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{}={}'.format(cfg.upper(), extdir)] + cmake_args += [f'-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{cfg.upper()}={extdir}'] if sys.maxsize > 2**32: cmake_args += ['-A', 'x64'] build_args += ['--', '/m'] else: - cmake_args += ['-DKOMPUTE_EXTRA_CXX_FLAGS="-fPIC"'] + env['CXXFLAGS'] += ' -fPIC' cmake_args += ['-DCMAKE_BUILD_TYPE=' + cfg] build_args += ['--', '-j'] - env = os.environ.copy() - env['CXXFLAGS'] = '{} -DVERSION_INFO=\\"{}\\"'.format(env.get('CXXFLAGS', ''), - self.distribution.get_version()) if not os.path.exists(self.build_temp): os.makedirs(self.build_temp) From b0acaef2262019201dd9aa2cabef268736c0b787 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Thu, 9 Jun 2022 10:56:58 +0200 Subject: [PATCH 033/107] Disabled Vulkan version check in CI for now Signed-off-by: Fabian Sauter --- .github/workflows/cpp_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cpp_tests.yml b/.github/workflows/cpp_tests.yml index 2d5069330..f29081dc5 100644 --- a/.github/workflows/cpp_tests.yml +++ b/.github/workflows/cpp_tests.yml @@ -29,7 +29,7 @@ jobs: build-type: Debug run-test: true ctest-options: -V - configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=OFF + configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=OFF -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON cpp-tests-release-with-debug-layers: runs-on: ubuntu-latest From fb719e96b092ae849685c157be1d5f0440ca9df9 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Thu, 9 Jun 2022 11:02:39 +0200 Subject: [PATCH 034/107] Consequently using kompute_option Signed-off-by: Fabian Sauter --- CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 092ab931b..66d1e88b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,11 +80,11 @@ kompute_option(KOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS "Explicitly disable debug lay kompute_option(KOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK "Whether to check if your driver supports the Vulkan Header version you are linking against. This might be useful in case you build shared on a different system than you run later." OFF) # External components -option(KOMPUTE_OPT_USE_BUILD_IN_SPDLOG "Use the build in version of Spdlog" ON) -option(KOMPUTE_OPT_USE_BUILD_IN_FMT "Use the build in version of fmt" ON) -option(KOMPUTE_OPT_USE_BUILD_IN_GOOGLE_TEST "Use the build in version of GoogleTest" ON) -option(KOMPUTE_OPT_USE_BUILD_IN_PYBIND11 "Use the build in version of pybind11" ON) -option(KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER "Use the build in version of Vulkan Headers. This could be helpful in case your system Vulkan Headers are to new for your driver. If you set this to false, please make sure your system Vulkan Header are supported by your driver." ON) +kompute_option(KOMPUTE_OPT_USE_BUILD_IN_SPDLOG "Use the build in version of Spdlog" ON) +kompute_option(KOMPUTE_OPT_USE_BUILD_IN_FMT "Use the build in version of fmt" ON) +kompute_option(KOMPUTE_OPT_USE_BUILD_IN_GOOGLE_TEST "Use the build in version of GoogleTest" ON) +kompute_option(KOMPUTE_OPT_USE_BUILD_IN_PYBIND11 "Use the build in version of pybind11" ON) +kompute_option(KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER "Use the build in version of Vulkan Headers. This could be helpful in case your system Vulkan Headers are to new for your driver. If you set this to false, please make sure your system Vulkan Header are supported by your driver." ON) kompute_option_string(KOMPUTE_OPT_BUILD_IN_VULKAN_HEADER_TAG "The git tag used for the build in Vulkan Headers when 'KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER' is enabled. A list of tags can be found here: https://github.com/KhronosGroup/Vulkan-Headers/tags" "v1.2.203") message(STATUS "=======================================================") From c47fbd18d3c2f9842caf3665b60142ad0761942c Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Thu, 9 Jun 2022 11:14:05 +0200 Subject: [PATCH 035/107] Fixed vulkan check valid gpu check Signed-off-by: Fabian Sauter --- cmake/check_vulkan_version.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/check_vulkan_version.cmake b/cmake/check_vulkan_version.cmake index 3ac8b0572..99eb129eb 100644 --- a/cmake/check_vulkan_version.cmake +++ b/cmake/check_vulkan_version.cmake @@ -122,7 +122,7 @@ function(check_vulkan_version) endif() endforeach() - if(${VALID_GPU} STREQUAL "") + if("${VALID_GPU}" STREQUAL "") message(FATAL_ERROR "None of your GPUs supports Vulkan Header ${VULKAN_HEADER_VERSION}. Please try updating your driver, or downgrade Vulkan header.") else() message("Valid GPU (${VALID_GPU}) for Vulkan header version ${VULKAN_HEADER_VERSION} found. ${VALID_GPU} supports up to Vulkan ${VALID_VULKAN_VERSION}.") From ff6d7a3a6311f184f2dae3b270298625f4df4420 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Thu, 9 Jun 2022 11:36:25 +0200 Subject: [PATCH 036/107] Fixed missing logger linking for tests Signed-off-by: Fabian Sauter --- test/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 31cb1b792..587c52e37 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -16,6 +16,7 @@ macro(add_kompute_test _TEST_NAME) ${ARGN}) target_link_libraries("${_TEST_NAME}_tests" PRIVATE GTest::GTest kompute::kompute + kp_logger test_shaders test_shaders_glsl) add_test(NAME "kompute_${_TEST_NAME}_tests" COMMAND "${_TEST_NAME}_tests") From f35fc2d9a30375a39775ae287a985f23821fea94 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Thu, 9 Jun 2022 12:33:00 +0200 Subject: [PATCH 037/107] Updated downgrade vulkan header instructions Signed-off-by: Fabian Sauter --- cmake/check_vulkan_version.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/check_vulkan_version.cmake b/cmake/check_vulkan_version.cmake index 99eb129eb..c12bee917 100644 --- a/cmake/check_vulkan_version.cmake +++ b/cmake/check_vulkan_version.cmake @@ -123,7 +123,7 @@ function(check_vulkan_version) endforeach() if("${VALID_GPU}" STREQUAL "") - message(FATAL_ERROR "None of your GPUs supports Vulkan Header ${VULKAN_HEADER_VERSION}. Please try updating your driver, or downgrade Vulkan header.") + message(FATAL_ERROR "None of your GPUs supports Vulkan Header ${VULKAN_HEADER_VERSION}. Please try updating your driver, or downgrade your Vulkan headers.") else() message("Valid GPU (${VALID_GPU}) for Vulkan header version ${VULKAN_HEADER_VERSION} found. ${VALID_GPU} supports up to Vulkan ${VALID_VULKAN_VERSION}.") endif() From aa7b29d61b0e5eb42899472f794f09218e387863 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Thu, 9 Jun 2022 12:33:40 +0200 Subject: [PATCH 038/107] Disabling vulkan header check for all tests Signed-off-by: Fabian Sauter --- .github/workflows/cpp_tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cpp_tests.yml b/.github/workflows/cpp_tests.yml index f29081dc5..4a7dcbad2 100644 --- a/.github/workflows/cpp_tests.yml +++ b/.github/workflows/cpp_tests.yml @@ -53,7 +53,7 @@ jobs: build-type: Release run-test: true ctest-options: -V - configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=OFF + configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=OFF -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON cpp-tests-debug-without-debug-layers: runs-on: ubuntu-latest @@ -77,7 +77,7 @@ jobs: build-type: Debug run-test: true ctest-options: -V - configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=ON + configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=ON -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON cpp-tests-release-without-debug-layers: runs-on: ubuntu-latest @@ -101,4 +101,4 @@ jobs: build-type: Release run-test: true ctest-options: -V - configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=ON + configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=ON -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON From 0b7236db9fda10523d4dc52c7e360cfa6e0833fd Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Thu, 9 Jun 2022 12:34:56 +0200 Subject: [PATCH 039/107] Disabling vulkan header check when building python Signed-off-by: Fabian Sauter --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 3d828da7c..0b39e9080 100644 --- a/setup.py +++ b/setup.py @@ -43,6 +43,7 @@ class CMakeBuild(build_ext): cmake_args = ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + extdir, '-DKOMPUTE_OPT_BUILD_PYTHON=ON', '-DKOMPUTE_OPT_LOG_LEVEL=Off', + '-DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON' '-DPYTHON_EXECUTABLE=' + sys.executable, '-DPYTHON_INCLUDE_DIR=' + sysconfig.get_path('include'), '-DPYTHON_LIBRARY=' + sysconfig.get_path('stdlib'), From baa84827d6684ad18a1457dbd742cfdddd03df9b Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Thu, 9 Jun 2022 12:50:04 +0200 Subject: [PATCH 040/107] Updated pip packages to support python 3.10 Signed-off-by: Fabian Sauter --- python/test/requirements-dev.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/test/requirements-dev.txt b/python/test/requirements-dev.txt index 85d2f72a2..99d811d39 100644 --- a/python/test/requirements-dev.txt +++ b/python/test/requirements-dev.txt @@ -1,4 +1,4 @@ pyshader==0.7.0 -numpy==1.19.5 -pytest==6.2.1 +numpy==1.22.4 +pytest==7.1.2 From 2ec35acba518dd49b020706b68a5149efb58b53b Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Mon, 13 Jun 2022 14:57:04 +0200 Subject: [PATCH 041/107] Updated pybind11 bindings Signed-off-by: Fabian Sauter --- python/src/main.cpp | 120 ++++++++++++++++++++++---------------------- src/CMakeLists.txt | 14 ++++-- 2 files changed, 69 insertions(+), 65 deletions(-) diff --git a/python/src/main.cpp b/python/src/main.cpp index 0ea2793cb..3f3f19d10 100644 --- a/python/src/main.cpp +++ b/python/src/main.cpp @@ -22,22 +22,22 @@ opAlgoDispatchPyInit(std::shared_ptr& algorithm, push_consts.size(), std::string(py::str(push_consts.dtype()))); - if (push_consts.dtype() == py::dtype::of()) { + if (push_consts.dtype().is(py::dtype::of())) { std::vector dataVec((float*)info.ptr, ((float*)info.ptr) + info.size); return std::unique_ptr{ new kp::OpAlgoDispatch( algorithm, dataVec) }; - } else if (push_consts.dtype() == py::dtype::of()) { + } else if (push_consts.dtype().is(py::dtype::of())) { std::vector dataVec((uint32_t*)info.ptr, ((uint32_t*)info.ptr) + info.size); return std::unique_ptr{ new kp::OpAlgoDispatch( algorithm, dataVec) }; - } else if (push_consts.dtype() == py::dtype::of()) { + } else if (push_consts.dtype().is(py::dtype::of())) { std::vector dataVec((int32_t*)info.ptr, ((int32_t*)info.ptr) + info.size); return std::unique_ptr{ new kp::OpAlgoDispatch( algorithm, dataVec) }; - } else if (push_consts.dtype() == py::dtype::of()) { + } else if (push_consts.dtype().is(py::dtype::of())) { std::vector dataVec((double*)info.ptr, ((double*)info.ptr) + info.size); return std::unique_ptr{ new kp::OpAlgoDispatch( @@ -76,29 +76,29 @@ PYBIND11_MODULE(kp, m) py::class_>( m, "OpBase", DOC(kp, OpBase)); - py::class_>( - m, - "OpTensorSyncDevice", - py::base(), - DOC(kp, OpTensorSyncDevice)) + py::class_>( + m, "OpTensorSyncDevice", DOC(kp, OpTensorSyncDevice)) .def(py::init>&>(), DOC(kp, OpTensorSyncDevice, OpTensorSyncDevice)); - py::class_>( - m, - "OpTensorSyncLocal", - py::base(), - DOC(kp, OpTensorSyncLocal)) + py::class_>( + m, "OpTensorSyncLocal", DOC(kp, OpTensorSyncLocal)) .def(py::init>&>(), DOC(kp, OpTensorSyncLocal, OpTensorSyncLocal)); - py::class_>( - m, "OpTensorCopy", py::base(), DOC(kp, OpTensorCopy)) + py::class_>( + m, "OpTensorCopy", DOC(kp, OpTensorCopy)) .def(py::init>&>(), DOC(kp, OpTensorCopy, OpTensorCopy)); - py::class_>( - m, "OpAlgoDispatch", py::base(), DOC(kp, OpAlgoDispatch)) + py::class_>( + m, "OpAlgoDispatch", DOC(kp, OpAlgoDispatch)) .def(py::init&, const std::vector&>(), DOC(kp, OpAlgoDispatch, OpAlgoDispatch), @@ -109,8 +109,8 @@ PYBIND11_MODULE(kp, m) py::arg("algorithm"), py::arg("push_consts")); - py::class_>( - m, "OpMult", py::base(), DOC(kp, OpMult)) + py::class_>( + m, "OpMult", DOC(kp, OpMult)) .def(py::init>&, const std::shared_ptr&>(), DOC(kp, OpMult, OpMult)); @@ -253,31 +253,31 @@ PYBIND11_MODULE(kp, m) "size {} dtype {}", flatdata.size(), std::string(py::str(flatdata.dtype()))); - if (flatdata.dtype() == py::dtype::of()) { + if (flatdata.dtype().is(py::dtype::of())) { return self.tensor(info.ptr, flatdata.size(), sizeof(float), kp::Tensor::TensorDataTypes::eFloat, tensor_type); - } else if (flatdata.dtype() == py::dtype::of()) { + } else if (flatdata.dtype().is(py::dtype::of())) { return self.tensor(info.ptr, flatdata.size(), sizeof(uint32_t), kp::Tensor::TensorDataTypes::eUnsignedInt, tensor_type); - } else if (flatdata.dtype() == py::dtype::of()) { + } else if (flatdata.dtype().is(py::dtype::of())) { return self.tensor(info.ptr, flatdata.size(), sizeof(int32_t), kp::Tensor::TensorDataTypes::eInt, tensor_type); - } else if (flatdata.dtype() == py::dtype::of()) { + } else if (flatdata.dtype().is(py::dtype::of())) { return self.tensor(info.ptr, flatdata.size(), sizeof(double), kp::Tensor::TensorDataTypes::eDouble, tensor_type); - } else if (flatdata.dtype() == py::dtype::of()) { + } else if (flatdata.dtype().is(py::dtype::of())) { return self.tensor(info.ptr, flatdata.size(), sizeof(bool), @@ -340,10 +340,10 @@ PYBIND11_MODULE(kp, m) // We have to iterate across a combination of parameters due to the // lack of support for templating - if (spec_consts.dtype() == py::dtype::of()) { + if (spec_consts.dtype().is(py::dtype::of())) { std::vector specConstsVec( (float*)specInfo.ptr, ((float*)specInfo.ptr) + specInfo.size); - if (spec_consts.dtype() == py::dtype::of()) { + if (spec_consts.dtype().is(py::dtype::of())) { std::vector pushConstsVec((float*)pushInfo.ptr, ((float*)pushInfo.ptr) + pushInfo.size); @@ -352,8 +352,8 @@ PYBIND11_MODULE(kp, m) workgroup, specConstsVec, pushConstsVec); - } else if (spec_consts.dtype() == - py::dtype::of()) { + } else if (spec_consts.dtype().is( + py::dtype::of())) { std::vector pushConstsVec( (int32_t*)pushInfo.ptr, ((int32_t*)pushInfo.ptr) + pushInfo.size); @@ -362,8 +362,8 @@ PYBIND11_MODULE(kp, m) workgroup, specConstsVec, pushConstsVec); - } else if (spec_consts.dtype() == - py::dtype::of()) { + } else if (spec_consts.dtype().is( + py::dtype::of())) { std::vector pushConstsVec( (uint32_t*)pushInfo.ptr, ((uint32_t*)pushInfo.ptr) + pushInfo.size); @@ -372,8 +372,8 @@ PYBIND11_MODULE(kp, m) workgroup, specConstsVec, pushConstsVec); - } else if (spec_consts.dtype() == - py::dtype::of()) { + } else if (spec_consts.dtype().is( + py::dtype::of())) { std::vector pushConstsVec((double*)pushInfo.ptr, ((double*)pushInfo.ptr) + pushInfo.size); @@ -383,11 +383,11 @@ PYBIND11_MODULE(kp, m) specConstsVec, pushConstsVec); } - } else if (spec_consts.dtype() == py::dtype::of()) { + } else if (spec_consts.dtype().is(py::dtype::of())) { std::vector specconstsvec((int32_t*)specInfo.ptr, ((int32_t*)specInfo.ptr) + specInfo.size); - if (spec_consts.dtype() == py::dtype::of()) { + if (spec_consts.dtype().is(py::dtype::of())) { std::vector pushconstsvec((float*)pushInfo.ptr, ((float*)pushInfo.ptr) + pushInfo.size); @@ -396,8 +396,8 @@ PYBIND11_MODULE(kp, m) workgroup, specconstsvec, pushconstsvec); - } else if (spec_consts.dtype() == - py::dtype::of()) { + } else if (spec_consts.dtype().is( + py::dtype::of())) { std::vector pushconstsvec( (int32_t*)pushInfo.ptr, ((int32_t*)pushInfo.ptr) + pushInfo.size); @@ -406,8 +406,8 @@ PYBIND11_MODULE(kp, m) workgroup, specconstsvec, pushconstsvec); - } else if (spec_consts.dtype() == - py::dtype::of()) { + } else if (spec_consts.dtype().is( + py::dtype::of())) { std::vector pushconstsvec( (uint32_t*)pushInfo.ptr, ((uint32_t*)pushInfo.ptr) + pushInfo.size); @@ -416,8 +416,8 @@ PYBIND11_MODULE(kp, m) workgroup, specconstsvec, pushconstsvec); - } else if (spec_consts.dtype() == - py::dtype::of()) { + } else if (spec_consts.dtype().is( + py::dtype::of())) { std::vector pushconstsvec((double*)pushInfo.ptr, ((double*)pushInfo.ptr) + pushInfo.size); @@ -427,11 +427,11 @@ PYBIND11_MODULE(kp, m) specconstsvec, pushconstsvec); } - } else if (spec_consts.dtype() == py::dtype::of()) { + } else if (spec_consts.dtype().is(py::dtype::of())) { std::vector specconstsvec((uint32_t*)specInfo.ptr, ((uint32_t*)specInfo.ptr) + specInfo.size); - if (spec_consts.dtype() == py::dtype::of()) { + if (spec_consts.dtype().is(py::dtype::of())) { std::vector pushconstsvec((float*)pushInfo.ptr, ((float*)pushInfo.ptr) + pushInfo.size); @@ -440,8 +440,8 @@ PYBIND11_MODULE(kp, m) workgroup, specconstsvec, pushconstsvec); - } else if (spec_consts.dtype() == - py::dtype::of()) { + } else if (spec_consts.dtype().is( + py::dtype::of())) { std::vector pushconstsvec( (int32_t*)pushInfo.ptr, ((int32_t*)pushInfo.ptr) + pushInfo.size); @@ -450,8 +450,8 @@ PYBIND11_MODULE(kp, m) workgroup, specconstsvec, pushconstsvec); - } else if (spec_consts.dtype() == - py::dtype::of()) { + } else if (spec_consts.dtype().is( + py::dtype::of())) { std::vector pushconstsvec( (uint32_t*)pushInfo.ptr, ((uint32_t*)pushInfo.ptr) + pushInfo.size); @@ -460,8 +460,8 @@ PYBIND11_MODULE(kp, m) workgroup, specconstsvec, pushconstsvec); - } else if (spec_consts.dtype() == - py::dtype::of()) { + } else if (spec_consts.dtype().is( + py::dtype::of())) { std::vector pushconstsvec((double*)pushInfo.ptr, ((double*)pushInfo.ptr) + pushInfo.size); @@ -471,11 +471,11 @@ PYBIND11_MODULE(kp, m) specconstsvec, pushconstsvec); } - } else if (spec_consts.dtype() == py::dtype::of()) { + } else if (spec_consts.dtype().is(py::dtype::of())) { std::vector specconstsvec((double*)specInfo.ptr, ((double*)specInfo.ptr) + specInfo.size); - if (spec_consts.dtype() == py::dtype::of()) { + if (spec_consts.dtype().is(py::dtype::of())) { std::vector pushconstsvec((float*)pushInfo.ptr, ((float*)pushInfo.ptr) + pushInfo.size); @@ -484,8 +484,8 @@ PYBIND11_MODULE(kp, m) workgroup, specconstsvec, pushconstsvec); - } else if (spec_consts.dtype() == - py::dtype::of()) { + } else if (spec_consts.dtype().is( + py::dtype::of())) { std::vector pushconstsvec((int32_t*)pushInfo.ptr, ((int32_t*)pushInfo.ptr) + pushInfo.size); @@ -494,8 +494,8 @@ PYBIND11_MODULE(kp, m) workgroup, specconstsvec, pushconstsvec); - } else if (spec_consts.dtype() == - py::dtype::of()) { + } else if (spec_consts.dtype().is( + py::dtype::of())) { std::vector pushconstsvec((uint32_t*)pushInfo.ptr, ((uint32_t*)pushInfo.ptr) + pushInfo.size); @@ -504,8 +504,8 @@ PYBIND11_MODULE(kp, m) workgroup, specconstsvec, pushconstsvec); - } else if (spec_consts.dtype() == - py::dtype::of()) { + } else if (spec_consts.dtype().is( + py::dtype::of())) { std::vector pushconstsvec((double*)pushInfo.ptr, ((double*)pushInfo.ptr) + pushInfo.size); @@ -515,11 +515,9 @@ PYBIND11_MODULE(kp, m) specconstsvec, pushconstsvec); } - } else { - // If reach then no valid dtype supported - throw std::runtime_error( - "Kompute Python no valid dtype supported"); } + // If reach then no valid dtype supported + throw std::runtime_error("Kompute Python no valid dtype supported"); }, DOC(kp, Manager, algorithm), py::arg("tensors"), diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 68dd739b1..cd1787dd3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -82,12 +82,18 @@ endif() if(KOMPUTE_OPT_ANDROID_BUILD) target_link_libraries(kompute PUBLIC kompute_vk_ndk_wrapper android - PRIVATE kp_logger - fmt::fmt) + kp_logger + PRIVATE fmt::fmt) else() target_link_libraries(kompute PUBLIC Vulkan::Vulkan - PRIVATE fmt::fmt - kp_logger) + kp_logger + PRIVATE fmt::fmt) +endif() + +if(KOMPUTE_OPT_BUILD_PYTHON) + include_directories(${PYTHON_INCLUDE_DIRS}) + + target_link_libraries(kompute PRIVATE pybind11::headers ${PYTHON_LIBRARIES}) endif() if(KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER) From 917b6f68720abcba85273ec817037427881615d4 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Mon, 20 Jun 2022 17:32:11 +0200 Subject: [PATCH 042/107] Added an option to get the current vk instance Signed-off-by: Fabian Sauter --- src/Manager.cpp | 6 ++++++ src/include/kompute/Manager.hpp | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/src/Manager.cpp b/src/Manager.cpp index 2e58d714a..eefff07da 100644 --- a/src/Manager.cpp +++ b/src/Manager.cpp @@ -458,4 +458,10 @@ Manager::listDevices() const return this->mInstance->enumeratePhysicalDevices(); } +std::shared_ptr +Manager::getVkInstance() const +{ + return mInstance; +} + } diff --git a/src/include/kompute/Manager.hpp b/src/include/kompute/Manager.hpp index 53261c06d..a0e727cae 100644 --- a/src/include/kompute/Manager.hpp +++ b/src/include/kompute/Manager.hpp @@ -215,6 +215,14 @@ class Manager **/ std::vector listDevices() const; + /** + * The current Vulkan instance. + * + * @return a shared pointer to the current Vulkan instance held by this + *object + **/ + std::shared_ptr getVkInstance() const; + private: // -------------- OPTIONALLY OWNED RESOURCES std::shared_ptr mInstance = nullptr; From 726fae58f1dcc06af3d45ef7a594e52017cbb80f Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Tue, 21 Jun 2022 09:08:30 +0200 Subject: [PATCH 043/107] Added an option to get the current vk instance Signed-off-by: Fabian Sauter --- src/Manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Manager.cpp b/src/Manager.cpp index eefff07da..fdfc0e969 100644 --- a/src/Manager.cpp +++ b/src/Manager.cpp @@ -461,7 +461,7 @@ Manager::listDevices() const std::shared_ptr Manager::getVkInstance() const { - return mInstance; + return this->mInstance; } } From 6fac581fa90d0e2dab2cba9e9f1972409b63f410 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Fri, 24 Jun 2022 09:56:22 +0200 Subject: [PATCH 044/107] Accepting a relative path when compiling shaders to work via fetch_content Signed-off-by: Fabian Sauter --- cmake/vulkan_shader_compiler.cmake | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cmake/vulkan_shader_compiler.cmake b/cmake/vulkan_shader_compiler.cmake index abd927ec0..7c10cc831 100644 --- a/cmake/vulkan_shader_compiler.cmake +++ b/cmake/vulkan_shader_compiler.cmake @@ -5,10 +5,14 @@ function(vulkan_compile_shader) return() endif() - cmake_parse_arguments(SHADER_COMPILE "" "INFILE;OUTFILE;NAMESPACE" "" ${ARGN}) + cmake_parse_arguments(SHADER_COMPILE "" "INFILE;OUTFILE;NAMESPACE;RELATIVE_PATH" "" ${ARGN}) set(SHADER_COMPILE_INFILE_FULL "${CMAKE_CURRENT_SOURCE_DIR}/${SHADER_COMPILE_INFILE}") set(SHADER_COMPILE_SPV_FILE_FULL "${CMAKE_CURRENT_BINARY_DIR}/${SHADER_COMPILE_INFILE}.spv") set(SHADER_COMPILE_HEADER_FILE_FULL "${CMAKE_CURRENT_BINARY_DIR}/${SHADER_COMPILE_OUTFILE}") + + if(NOT SHADER_COMPILE_RELATIVE_PATH) + set(SHADER_COMPILE_RELATIVE_PATH "${PROJECT_SOURCE_DIR}/cmake") + endif() # .comp -> .spv add_custom_command(OUTPUT "${SHADER_COMPILE_SPV_FILE_FULL}" @@ -32,8 +36,8 @@ function(vulkan_compile_shader) "-DHEADER_NAMESPACE=${SHADER_COMPILE_NAMESPACE}" "-DIS_BIG_ENDIAN=${IS_BIG_ENDIAN}" "-P" - "${PROJECT_SOURCE_DIR}/cmake/bin_file_to_header.cmake" - WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/cmake" + "${SHADER_COMPILE_RELATIVE_PATH}/bin_file_to_header.cmake" + WORKING_DIRECTORY "${SHADER_COMPILE_RELATIVE_PATH}" COMMENT "Converting compiled shader '${SHADER_COMPILE_SPV_FILE_FULL}' to header file '${SHADER_COMPILE_HEADER_FILE_FULL}'." MAIN_DEPENDENCY "${SHADER_COMPILE_SPV_FILE_FULL}") endfunction() From 7d16b73d14c098020ca7d1fe0afc58ced4422dd1 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Fri, 24 Jun 2022 09:56:37 +0200 Subject: [PATCH 045/107] Updated the array_multiplication example Signed-off-by: Fabian Sauter --- examples/array_multiplication/CMakeLists.txt | 55 ++++++------- examples/array_multiplication/README.md | 54 ++++++------- .../shader/CMakeLists.txt | 20 +++++ .../shader/my_shader.comp | 14 ++++ .../array_multiplication/src/CMakeLists.txt | 4 + examples/array_multiplication/src/Main.cpp | 79 ------------------- examples/array_multiplication/src/main.cpp | 41 ++++++++++ 7 files changed, 130 insertions(+), 137 deletions(-) create mode 100644 examples/array_multiplication/shader/CMakeLists.txt create mode 100644 examples/array_multiplication/shader/my_shader.comp create mode 100644 examples/array_multiplication/src/CMakeLists.txt delete mode 100644 examples/array_multiplication/src/Main.cpp create mode 100644 examples/array_multiplication/src/main.cpp diff --git a/examples/array_multiplication/CMakeLists.txt b/examples/array_multiplication/CMakeLists.txt index bfc4c1c79..b278d8126 100644 --- a/examples/array_multiplication/CMakeLists.txt +++ b/examples/array_multiplication/CMakeLists.txt @@ -1,40 +1,37 @@ -cmake_minimum_required(VERSION 3.4.1) -project(kompute_array_mult VERSION 0.1.0) +cmake_minimum_required(VERSION 3.15) +project(kompute_array_mult) set(CMAKE_CXX_STANDARD 14) -option(KOMPUTE_ARR_OPT_INSTALLED_KOMPUTE "Enable if you prefer to use your installed Kompute library" 0) -option(KOMPUTE_OPT_ENABLE_SPDLOG "Extra compile flags for Kompute, see docs for full list" 0) -set(KOMPUTE_EXTRA_CXX_FLAGS "" CACHE STRING "Extra compile flags for Kompute, see docs for full list") +# Set a default build type if none was specified +# Based on: https://github.com/openchemistry/tomviz/blob/master/cmake/BuildType.cmake +set(DEFAULT_BUILD_TYPE "Release") -if(KOMPUTE_OPT_ENABLE_SPDLOG) - set(KOMPUTE_EXTRA_CXX_FLAGS "${KOMPUTE_EXTRA_CXX_FLAGS} -DKOMPUTE_ENABLE_SPDLOG=1") +if(EXISTS "${CMAKE_SOURCE_DIR}/.git") + set(DEFAULT_BUILD_TYPE "Debug") endif() -# It is necessary to pass the DEBUG or RELEASE flag accordingly to Kompute -set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG=1 ${KOMPUTE_EXTRA_CXX_FLAGS}") -set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DRELEASE=1 ${KOMPUTE_EXTRA_CXX_FLAGS}") +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + message(STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' as none was specified.") + set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE STRING "Choose the type of build." FORCE) -if(KOMPUTE_ARR_OPT_INSTALLED_KOMPUTE) - find_package(kompute REQUIRED) -else() - add_subdirectory(../../ ${CMAKE_CURRENT_BINARY_DIR}/kompute_build) + # Set the possible values of build type for cmake-gui + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") endif() -find_package(Vulkan REQUIRED) - -add_executable(kompute_array_mult - src/Main.cpp) - -target_link_libraries(kompute_array_mult - kompute::kompute - Vulkan::Vulkan) - -include_directories( - ../../single_include/) - -if(KOMPUTE_OPT_ENABLE_SPDLOG) - target_link_libraries(kompute_array_mult - spdlog::spdlog) +if(WIN32) # Install dlls in the same directory as the executable on Windows + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) endif() +include(FetchContent) +FetchContent_Declare(kompute GIT_REPOSITORY https://github.com/COM8/kompute.git + GIT_TAG 01a0485f461e3d080b277aeb43c06a3ede8bd75d) # The commit hash for a dev version before v0.9.0. Replace with the latest from: https://github.com/KomputeProject/kompute/releases +FetchContent_MakeAvailable(kompute) +include_directories(${kompute_SOURCE_DIR}/src/include) + +# Add to the list, so CMake can later find the code to compile shaders to header files +list(APPEND CMAKE_PREFIX_PATH "${kompute_SOURCE_DIR}/cmake") + +add_subdirectory(shader) +add_subdirectory(src) diff --git a/examples/array_multiplication/README.md b/examples/array_multiplication/README.md index bc6de129c..ba6f9cab5 100644 --- a/examples/array_multiplication/README.md +++ b/examples/array_multiplication/README.md @@ -1,30 +1,39 @@ # Kompute Array Multiplication Example This folder contains an end to end Kompute Example that implements logistic regression. - This example is structured such that you will be able to extend it for your project. - -It contains a cmake build configuration that can be used in your production applications. +It contains a CMake build configuration that can be used in your production applications. ## Building the example You will notice that it's a standalone project, so you can re-use it for your application. +It uses CMake's [`fetch_content`](https://cmake.org/cmake/help/latest/module/FetchContent.html) to consume Kompute as a dependency. +To build you just need to run the CMake command in this folder as follows: -This project has the option to either import the Kompute dependency relative to the project or use your existing installation of Kompute. - -To build you just need to run the cmake command in this folder as follows: - -``` -cmake -Bbuild/ \ - -DCMAKE_BUILD_TYPE=Debug \ - -DKOMPUTE_OPT_INSTALL=0 \ - -DKOMPUTE_OPT_ENABLE_SPDLOG=1 +```bash +git clone https://github.com/KomputeProject/kompute.git +cd kompute/examples/array_multiplication +mkdir build +cd build +cmake .. +cmake --build . ``` -You can pass the following optional parameters based on your desired configuration: -* If you wish to install with spdlog support you just have to pass `-DKOMPUTE_OPT_ENABLE_SPDLOG=1`. -* If you are using a package manager such as `vcpkg` make sure you pass the `-DCMAKE_TOOLCHAIN_FILE=` parameter -* If you wish to load shader from raw glsl string instead of spirv bytes you can use `-DKOMPUTE_ANDROID_SHADER_FROM_STRING` +## Executing + +Form inside the `build/` directory run: + +### Linux + +```bash +./kompute_array_mult +``` + +### Windows + +```bash +.\Debug\kompute_array_mult.exe +``` ## Pre-requisites @@ -32,18 +41,5 @@ In order to run this example, you will need the following dependencies: * REQUIRED + The Vulkan SDK must be installed -* OPTIONAL - + Kompute library must be accessible (by default it uses the source directory) - + SPDLOG - for logging - + FMT - for text formatting - -We will cover how you can install Kompute in the next section. For the Vulkan SDK, the simplest way to install it is through [their website](https://vulkan.lunarg.com/sdk/home). You just have to follow the instructions for the relevant platform. - -For the other libraries, because they are optional you can just make sure you build and install Kompute with these disabled (this will be covered in more detail below). - -Alternatively you can use package managers such as vcpkg to help you install them, although to simplify things you can start without the dependencies first. - - - diff --git a/examples/array_multiplication/shader/CMakeLists.txt b/examples/array_multiplication/shader/CMakeLists.txt new file mode 100644 index 000000000..bb01a0059 --- /dev/null +++ b/examples/array_multiplication/shader/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.15) + +# To add more shaders simply copy the vulkan_compile_shader command and replace it with your new shader +vulkan_compile_shader(INFILE my_shader.comp + OUTFILE my_shader.hpp + NAMESPACE "shader" + RELATIVE_PATH "${kompute_SOURCE_DIR}/cmake") + +# vulkan_compile_shader(INFILE my_shader2.comp +# OUTFILE my_shader2.hpp +# NAMESPACE "shader" +# RELATIVE_PATH "${kompute_SOURCE_DIR}/cmake") + +# Then add it to the library, so you can access it later in your code +add_library(shader "${CMAKE_CURRENT_BINARY_DIR}/my_shader.hpp" +# "${CMAKE_CURRENT_BINARY_DIR}/my_shader2.hpp" +) + +set_target_properties(shader PROPERTIES LINKER_LANGUAGE CXX) +target_include_directories(shader PUBLIC $) diff --git a/examples/array_multiplication/shader/my_shader.comp b/examples/array_multiplication/shader/my_shader.comp new file mode 100644 index 000000000..d4cfe6990 --- /dev/null +++ b/examples/array_multiplication/shader/my_shader.comp @@ -0,0 +1,14 @@ +#version 450 + +// The execution structure +layout (local_size_x = 1) in; + +// The buffers are provided via the tensors +layout(binding = 0) buffer bufA { float a[]; }; +layout(binding = 1) buffer bufB { float b[]; }; +layout(binding = 2) buffer bufOut { float o[]; }; + +void main() { + uint index = gl_GlobalInvocationID.x; + o[index] = a[index] * b[index]; +} \ No newline at end of file diff --git a/examples/array_multiplication/src/CMakeLists.txt b/examples/array_multiplication/src/CMakeLists.txt new file mode 100644 index 000000000..3a912ec1d --- /dev/null +++ b/examples/array_multiplication/src/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 3.15) + +add_executable(kompute_array_mult main.cpp) +target_link_libraries(kompute_array_mult PRIVATE shader kompute::kompute) diff --git a/examples/array_multiplication/src/Main.cpp b/examples/array_multiplication/src/Main.cpp deleted file mode 100644 index 4ba17cef1..000000000 --- a/examples/array_multiplication/src/Main.cpp +++ /dev/null @@ -1,79 +0,0 @@ - -#include -#include -#include - -#include "kompute/Kompute.hpp" - -static std::vector -compileSource(const std::string& source) -{ - std::ofstream fileOut("tmp_kp_shader.comp"); - fileOut << source; - fileOut.close(); - if (system( - std::string( - "glslangValidator -V tmp_kp_shader.comp -o tmp_kp_shader.comp.spv") - .c_str())) - throw std::runtime_error("Error running glslangValidator command"); - std::ifstream fileStream("tmp_kp_shader.comp.spv", std::ios::binary); - std::vector buffer; - buffer.insert( - buffer.begin(), std::istreambuf_iterator(fileStream), {}); - return { (uint32_t*)buffer.data(), - (uint32_t*)(buffer.data() + buffer.size()) }; -} - -int -main() -{ -#if KOMPUTE_ENABLE_SPDLOG - spdlog::set_level( - static_cast(SPDLOG_ACTIVE_LEVEL)); -#endif - - kp::Manager mgr; - - auto tensorInA = mgr.tensor({ 2.0, 4.0, 6.0 }); - auto tensorInB = mgr.tensor({ 0.0, 1.0, 2.0 }); - auto tensorOut = mgr.tensor({ 0.0, 0.0, 0.0 }); - - std::string shader(R"( - // The version to use - #version 450 - - // The execution structure - layout (local_size_x = 1) in; - - // The buffers are provided via the tensors - layout(binding = 0) buffer bufA { float a[]; }; - layout(binding = 1) buffer bufB { float b[]; }; - layout(binding = 2) buffer bufOut { float o[]; }; - - void main() { - uint index = gl_GlobalInvocationID.x; - - o[index] = a[index] * b[index]; - } - )"); - - std::vector> params = { tensorInA, - tensorInB, - tensorOut }; - - std::shared_ptr algo = - mgr.algorithm(params, compileSource(shader)); - - mgr.sequence() - ->record(params) - ->record(algo) - ->record(params) - ->eval(); - - // prints "Output { 0 4 12 }" - std::cout << "Output: { "; - for (const float& elem : tensorOut->vector()) { - std::cout << elem << " "; - } - std::cout << "}" << std::endl; -} diff --git a/examples/array_multiplication/src/main.cpp b/examples/array_multiplication/src/main.cpp new file mode 100644 index 000000000..56e1c06d2 --- /dev/null +++ b/examples/array_multiplication/src/main.cpp @@ -0,0 +1,41 @@ + +#include +#include +#include + +#include "my_shader.hpp" +#include + +int +main() +{ + kp::Manager mgr; + + std::shared_ptr> tensorInA = + mgr.tensor({ 2.0, 4.0, 6.0 }); + std::shared_ptr> tensorInB = + mgr.tensor({ 0.0, 1.0, 2.0 }); + std::shared_ptr> tensorOut = + mgr.tensor({ 0.0, 0.0, 0.0 }); + + const std::vector> params = { tensorInA, + tensorInB, + tensorOut }; + + const std::vector shader = std::vector( + shader::MY_SHADER_COMP_SPV.begin(), shader::MY_SHADER_COMP_SPV.end()); + std::shared_ptr algo = mgr.algorithm(params, shader); + + mgr.sequence() + ->record(params) + ->record(algo) + ->record(params) + ->eval(); + + // prints "Output { 0 4 12 }" + std::cout << "Output: { "; + for (const float& elem : tensorOut->vector()) { + std::cout << elem << " "; + } + std::cout << "}" << std::endl; +} From 4b9b6607d08fc350d7ff387397be2ddea793dfd8 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Fri, 24 Jun 2022 10:10:11 +0200 Subject: [PATCH 046/107] Updated logistic regression example Signed-off-by: Fabian Sauter --- examples/logistic_regression/CMakeLists.txt | 56 +++++++-------- examples/logistic_regression/README.md | 46 ++++++------ .../logistic_regression/shader/CMakeLists.txt | 20 ++++++ .../my_shader.comp} | 2 - .../logistic_regression/src/CMakeLists.txt | 4 ++ examples/logistic_regression/src/Main.cpp | 72 ------------------- examples/logistic_regression/src/main.cpp | 66 +++++++++++++++++ 7 files changed, 142 insertions(+), 124 deletions(-) create mode 100644 examples/logistic_regression/shader/CMakeLists.txt rename examples/logistic_regression/{shaders/glsl/logistic_regression.comp => shader/my_shader.comp} (99%) create mode 100644 examples/logistic_regression/src/CMakeLists.txt delete mode 100644 examples/logistic_regression/src/Main.cpp create mode 100644 examples/logistic_regression/src/main.cpp diff --git a/examples/logistic_regression/CMakeLists.txt b/examples/logistic_regression/CMakeLists.txt index 8c8e0eb8f..aa48f4231 100644 --- a/examples/logistic_regression/CMakeLists.txt +++ b/examples/logistic_regression/CMakeLists.txt @@ -1,41 +1,37 @@ -cmake_minimum_required(VERSION 3.4.1) -project(kompute_linear_reg VERSION 0.1.0) +cmake_minimum_required(VERSION 3.15) +project(kompute_logistic_regression) set(CMAKE_CXX_STANDARD 14) -option(KOMPUTE_ARR_OPT_INSTALLED_KOMPUTE "Enable if you prefer to use your installed Kompute library" 0) -option(KOMPUTE_OPT_ENABLE_SPDLOG "Extra compile flags for Kompute, see docs for full list" 0) -set(KOMPUTE_EXTRA_CXX_FLAGS "" CACHE STRING "Extra compile flags for Kompute, see docs for full list") +# Set a default build type if none was specified +# Based on: https://github.com/openchemistry/tomviz/blob/master/cmake/BuildType.cmake +set(DEFAULT_BUILD_TYPE "Release") -if(KOMPUTE_OPT_ENABLE_SPDLOG) - set(KOMPUTE_EXTRA_CXX_FLAGS "${KOMPUTE_EXTRA_CXX_FLAGS} -DKOMPUTE_ENABLE_SPDLOG=1") +if(EXISTS "${CMAKE_SOURCE_DIR}/.git") + set(DEFAULT_BUILD_TYPE "Debug") endif() -# It is necessary to pass the DEBUG or RELEASE flag accordingly to Kompute -set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG=1 ${KOMPUTE_EXTRA_CXX_FLAGS}") -set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DRELEASE=1 ${KOMPUTE_EXTRA_CXX_FLAGS}") +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + message(STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' as none was specified.") + set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE STRING "Choose the type of build." FORCE) -if(KOMPUTE_ARR_OPT_INSTALLED_KOMPUTE) - find_package(kompute REQUIRED) -else() - add_subdirectory(../../ ${CMAKE_CURRENT_BINARY_DIR}/kompute_build) + # Set the possible values of build type for cmake-gui + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") endif() -find_package(Vulkan REQUIRED) - -add_executable(kompute_linear_reg - src/Main.cpp) - -target_link_libraries(kompute_linear_reg - kompute::kompute - Vulkan::Vulkan -) - -include_directories( - ../../single_include/) - -if(KOMPUTE_OPT_ENABLE_SPDLOG) - target_link_libraries(kompute_linear_reg - spdlog::spdlog) +if(WIN32) # Install dlls in the same directory as the executable on Windows + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) endif() +include(FetchContent) +FetchContent_Declare(kompute GIT_REPOSITORY https://github.com/COM8/kompute.git + GIT_TAG 528e80515918b314d51a8082220572d27e20d94d) # The commit hash for a dev version before v0.9.0. Replace with the latest from: https://github.com/KomputeProject/kompute/releases +FetchContent_MakeAvailable(kompute) +include_directories(${kompute_SOURCE_DIR}/src/include) + +# Add to the list, so CMake can later find the code to compile shaders to header files +list(APPEND CMAKE_PREFIX_PATH "${kompute_SOURCE_DIR}/cmake") + +add_subdirectory(shader) +add_subdirectory(src) diff --git a/examples/logistic_regression/README.md b/examples/logistic_regression/README.md index f6be72e60..204180f0a 100644 --- a/examples/logistic_regression/README.md +++ b/examples/logistic_regression/README.md @@ -1,30 +1,39 @@ # Kompute Logistic Regression Example This folder contains an end to end Kompute Example that implements logistic regression. - This example is structured such that you will be able to extend it for your project. - -It contains a cmake build configuration that can be used in your production applications. +It contains a CMake build configuration that can be used in your production applications. ## Building the example You will notice that it's a standalone project, so you can re-use it for your application. +It uses CMake's [`fetch_content`](https://cmake.org/cmake/help/latest/module/FetchContent.html) to consume Kompute as a dependency. +To build you just need to run the CMake command in this folder as follows: -This project has the option to either import the Kompute dependency relative to the project or use your existing installation of Kompute. - -To build you just need to run the cmake command in this folder as follows: - -``` -cmake -Bbuild/ \ - -DCMAKE_BUILD_TYPE=Debug \ - -DKOMPUTE_OPT_INSTALL=0 \ - -DKOMPUTE_OPT_ENABLE_SPDLOG=1 +```bash +git clone https://github.com/KomputeProject/kompute.git +cd kompute/examples/logistic_regression +mkdir build +cd build +cmake .. +cmake --build . ``` -You can pass the following optional parameters based on your desired configuration: -* If you wish to install with spdlog support you just have to pass `-DKOMPUTE_OPT_ENABLE_SPDLOG=1`. -* If you are using a package manager such as `vcpkg` make sure you pass the `-DCMAKE_TOOLCHAIN_FILE=` parameter -* If you wish to load shader from raw glsl string instead of spirv bytes you can use `-DKOMPUTE_ANDROID_SHADER_FROM_STRING` +## Executing + +Form inside the `build/` directory run: + +### Linux + +```bash +./kompute_logistic_regression +``` + +### Windows + +```bash +.\Debug\kompute_logistic_regression.exe +``` ## Pre-requisites @@ -32,8 +41,5 @@ In order to run this example, you will need the following dependencies: * REQUIRED + The Vulkan SDK must be installed -* OPTIONAL - + Kompute library must be accessible (by default it uses the source directory) - + SPDLOG - for logging - + FMT - for text formatting +For the Vulkan SDK, the simplest way to install it is through [their website](https://vulkan.lunarg.com/sdk/home). You just have to follow the instructions for the relevant platform. diff --git a/examples/logistic_regression/shader/CMakeLists.txt b/examples/logistic_regression/shader/CMakeLists.txt new file mode 100644 index 000000000..bb01a0059 --- /dev/null +++ b/examples/logistic_regression/shader/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.15) + +# To add more shaders simply copy the vulkan_compile_shader command and replace it with your new shader +vulkan_compile_shader(INFILE my_shader.comp + OUTFILE my_shader.hpp + NAMESPACE "shader" + RELATIVE_PATH "${kompute_SOURCE_DIR}/cmake") + +# vulkan_compile_shader(INFILE my_shader2.comp +# OUTFILE my_shader2.hpp +# NAMESPACE "shader" +# RELATIVE_PATH "${kompute_SOURCE_DIR}/cmake") + +# Then add it to the library, so you can access it later in your code +add_library(shader "${CMAKE_CURRENT_BINARY_DIR}/my_shader.hpp" +# "${CMAKE_CURRENT_BINARY_DIR}/my_shader2.hpp" +) + +set_target_properties(shader PROPERTIES LINKER_LANGUAGE CXX) +target_include_directories(shader PUBLIC $) diff --git a/examples/logistic_regression/shaders/glsl/logistic_regression.comp b/examples/logistic_regression/shader/my_shader.comp similarity index 99% rename from examples/logistic_regression/shaders/glsl/logistic_regression.comp rename to examples/logistic_regression/shader/my_shader.comp index 9fd76619b..a7f75b0f3 100644 --- a/examples/logistic_regression/shaders/glsl/logistic_regression.comp +++ b/examples/logistic_regression/shader/my_shader.comp @@ -52,5 +52,3 @@ void main() { lout[idx] = calculateLoss(yHat, yCurr); } - - diff --git a/examples/logistic_regression/src/CMakeLists.txt b/examples/logistic_regression/src/CMakeLists.txt new file mode 100644 index 000000000..8a2dfe8c9 --- /dev/null +++ b/examples/logistic_regression/src/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 3.15) + +add_executable(kompute_logistic_regression main.cpp) +target_link_libraries(kompute_logistic_regression PRIVATE shader kompute::kompute) diff --git a/examples/logistic_regression/src/Main.cpp b/examples/logistic_regression/src/Main.cpp deleted file mode 100644 index 8feee258f..000000000 --- a/examples/logistic_regression/src/Main.cpp +++ /dev/null @@ -1,72 +0,0 @@ - -#include -#include -#include - -#include "kompute/Kompute.hpp" - -int -main() -{ -#if KOMPUTE_ENABLE_SPDLOG - spdlog::set_level( - static_cast(SPDLOG_ACTIVE_LEVEL)); -#endif - - uint32_t ITERATIONS = 100; - float learningRate = 0.1; - - kp::Manager mgr; - - auto xI = mgr.tensor({ 0, 1, 1, 1, 1 }); - auto xJ = mgr.tensor({ 0, 0, 0, 1, 1 }); - - auto y = mgr.tensor({ 0, 0, 0, 1, 1 }); - - auto wIn = mgr.tensor({ 0.001, 0.001 }); - auto wOutI = mgr.tensor({ 0, 0, 0, 0, 0 }); - auto wOutJ = mgr.tensor({ 0, 0, 0, 0, 0 }); - - auto bIn = mgr.tensor({ 0 }); - auto bOut = mgr.tensor({ 0, 0, 0, 0, 0 }); - - auto lOut = mgr.tensor({ 0, 0, 0, 0, 0 }); - - std::vector> params = { xI, xJ, y, - wIn, wOutI, wOutJ, - bIn, bOut, lOut }; - - std::vector spirv( - (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::shared_ptr algo = mgr.algorithm( - params, spirv, kp::Workgroup({ 5 }), std::vector({ 5.0 })); - - mgr.sequence()->eval(params); - - std::shared_ptr sq = - mgr.sequence() - ->record({ wIn, bIn }) - ->record(algo) - ->record({ wOutI, wOutJ, bOut, lOut }); - - // Iterate across all expected iterations - for (size_t i = 0; i < ITERATIONS; i++) { - - sq->eval(); - - for (size_t j = 0; j < bOut->size(); j++) { - wIn->data()[0] -= learningRate * wOutI->data()[j]; - wIn->data()[1] -= learningRate * wOutJ->data()[j]; - bIn->data()[0] -= learningRate * bOut->data()[j]; - } - } - - std::cout << "RESULTS" << std::endl; - std::cout << "w1: " << wIn->data()[0] << std::endl; - std::cout << "w2: " << wIn->data()[1] << std::endl; - std::cout << "b: " << bIn->data()[0] << std::endl; -} diff --git a/examples/logistic_regression/src/main.cpp b/examples/logistic_regression/src/main.cpp new file mode 100644 index 000000000..bc249a36f --- /dev/null +++ b/examples/logistic_regression/src/main.cpp @@ -0,0 +1,66 @@ + +#include +#include +#include + +#include "kompute/Tensor.hpp" +#include "my_shader.hpp" +#include + +int +main() +{ + uint32_t ITERATIONS = 100; + float learningRate = 0.1; + + kp::Manager mgr; + + std::shared_ptr> xI = mgr.tensor({ 0, 1, 1, 1, 1 }); + std::shared_ptr> xJ = mgr.tensor({ 0, 0, 0, 1, 1 }); + + std::shared_ptr> y = mgr.tensor({ 0, 0, 0, 1, 1 }); + + std::shared_ptr> wIn = mgr.tensor({ 0.001, 0.001 }); + std::shared_ptr> wOutI = mgr.tensor({ 0, 0, 0, 0, 0 }); + std::shared_ptr> wOutJ = mgr.tensor({ 0, 0, 0, 0, 0 }); + + std::shared_ptr> bIn = mgr.tensor({ 0 }); + std::shared_ptr> bOut = mgr.tensor({ 0, 0, 0, 0, 0 }); + + std::shared_ptr> lOut = mgr.tensor({ 0, 0, 0, 0, 0 }); + + const std::vector> params = { + xI, xJ, y, wIn, wOutI, wOutJ, bIn, bOut, lOut + }; + + const std::vector shader = std::vector( + shader::MY_SHADER_COMP_SPV.begin(), shader::MY_SHADER_COMP_SPV.end()); + + std::shared_ptr algo = mgr.algorithm( + params, shader, kp::Workgroup({ 5 }), std::vector({ 5.0 })); + + mgr.sequence()->eval(params); + + std::shared_ptr sq = + mgr.sequence() + ->record({ wIn, bIn }) + ->record(algo) + ->record({ wOutI, wOutJ, bOut, lOut }); + + // Iterate across all expected iterations + for (size_t i = 0; i < ITERATIONS; i++) { + + sq->eval(); + + for (size_t j = 0; j < bOut->size(); j++) { + wIn->data()[0] -= learningRate * wOutI->data()[j]; + wIn->data()[1] -= learningRate * wOutJ->data()[j]; + bIn->data()[0] -= learningRate * bOut->data()[j]; + } + } + + std::cout << "RESULTS" << std::endl; + std::cout << "w1: " << wIn->data()[0] << std::endl; + std::cout << "w2: " << wIn->data()[1] << std::endl; + std::cout << "b: " << bIn->data()[0] << std::endl; +} \ No newline at end of file From 287adcbdcf4a6c2f7292f169394988e68eaff564 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Fri, 24 Jun 2022 10:34:30 +0200 Subject: [PATCH 047/107] Added error messages for all deprecated CMake options Signed-off-by: Fabian Sauter --- cmake/deprecation_warnings.cmake | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cmake/deprecation_warnings.cmake b/cmake/deprecation_warnings.cmake index 95c81c28c..1a325e639 100644 --- a/cmake/deprecation_warnings.cmake +++ b/cmake/deprecation_warnings.cmake @@ -1,3 +1,19 @@ if(KOMPUTE_OPT_REPO_SUBMODULE_BUILD) message(FATAL_ERROR "'KOMPUTE_OPT_REPO_SUBMODULE_BUILD' got replaced by 'KOMPUTE_OPT_USE_BUILD_IN_SPDLOG', 'KOMPUTE_OPT_USE_BUILD_IN_FMT', 'KOMPUTE_OPT_USE_BUILD_IN_GOOGLE_TEST', 'KOMPUTE_OPT_USE_BUILD_IN_PYBIND11' and 'KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER'. Please use them instead.") +endif() + +if(KOMPUTE_OPT_BUILD_SHADERS) + message(FATAL_ERROR "'KOMPUTE_OPT_BUILD_SHADERS' is deprecated and should not be used. Instead use the default 'BUILD_SHARED_LIBS' CMake switch.") +endif() + +if(KOMPUTE_OPT_BUILD_AS_SHARED_LIB) + message(FATAL_ERROR "'KOMPUTE_OPT_BUILD_AS_SHARED_LIB' is deprecated and should not be used. Instead use the default 'BUILD_SHARED_LIBS' CMake switch.") +endif() + +if(KOMPUTE_OPT_BUILD_SINGLE_HEADER) + message(FATAL_ERROR "'KOMPUTE_OPT_BUILD_SINGLE_HEADER' is deprecated and should not be used. The single header will now always be build and can be included via '#include'.") +endif() + +if(KOMPUTE_OPT_ENABLE_SPDLOG) + message(FATAL_ERROR "'KOMPUTE_OPT_ENABLE_SPDLOG' is deprecated and should not be used. It got replaced by 'KOMPUTE_OPT_LOG_LEVEL'. This option can be set to a variety of log levels (e.g. 'Off', 'Trace', 'Debug', 'Default', ...).") endif() \ No newline at end of file From fd036558a3186c592d851a7227fc718d7ef6edf4 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Fri, 24 Jun 2022 12:02:07 +0200 Subject: [PATCH 048/107] Fixed logger when running on Windows Signed-off-by: Fabian Sauter --- src/logger/Logger.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/logger/Logger.cpp b/src/logger/Logger.cpp index 698ead8e5..c82a882b6 100644 --- a/src/logger/Logger.cpp +++ b/src/logger/Logger.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -16,6 +17,7 @@ #ifdef _WIN32 #include +#include #endif // _WIN32 namespace logger { @@ -50,11 +52,11 @@ exists(const std::string& path) void createDir(const std::string& path) { - mode_t nMode = 0733; // UNIX style permissions int nError = 0; #if defined(_WIN32) - nError = _mkdir(sPath.c_str()); // can be used on Windows + nError = _mkdir(path.c_str()); // can be used on Windows #else + mode_t nMode = 0733; // UNIX style permissions nError = mkdir(path.c_str(), nMode); // can be used on non-Windows #endif if (nError != 0) { @@ -86,7 +88,7 @@ setupLogger() std::make_shared(); console_sink->set_pattern("[%H:%M:%S %z] [%=8l] [thread %t] [%@]\t%v"); #ifdef _WIN32 - std::string s = (logger::log_folder / "kompute.log").string(); + std::string s = logger::logFolder + "\\kompute.log"; spdlog::sink_ptr file_sink = std::make_shared( s, FILE_ROTATION_TIME, 3); From 49f494701d14ab30e2585c4169f37d12c574eaf6 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Fri, 24 Jun 2022 12:42:44 +0200 Subject: [PATCH 049/107] Fixed tests linking against libcurl Signed-off-by: Fabian Sauter --- test/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 587c52e37..71b6fa239 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -23,7 +23,6 @@ macro(add_kompute_test _TEST_NAME) # Group under the "tests" project folder in IDEs such as Visual Studio. set_property(TARGET ${_TEST_NAME}_tests PROPERTY FOLDER "tests") if(WIN32 AND BUILD_SHARED_LIBS) - add_custom_command(TARGET ${_TEST_NAME}_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ $) add_custom_command(TARGET ${_TEST_NAME}_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ $) endif() endmacro() From b9ec269b11d6ddeb3af0aad2467487fadbf4eb5a Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Fri, 24 Jun 2022 12:43:01 +0200 Subject: [PATCH 050/107] Using interface libs for shader only libs Signed-off-by: Fabian Sauter --- examples/array_multiplication/CMakeLists.txt | 2 +- examples/array_multiplication/shader/CMakeLists.txt | 7 +++---- examples/logistic_regression/CMakeLists.txt | 2 +- examples/logistic_regression/shader/CMakeLists.txt | 7 +++---- test/shaders/glsl/CMakeLists.txt | 11 +++++------ 5 files changed, 13 insertions(+), 16 deletions(-) diff --git a/examples/array_multiplication/CMakeLists.txt b/examples/array_multiplication/CMakeLists.txt index b278d8126..37a0af21b 100644 --- a/examples/array_multiplication/CMakeLists.txt +++ b/examples/array_multiplication/CMakeLists.txt @@ -26,7 +26,7 @@ endif() include(FetchContent) FetchContent_Declare(kompute GIT_REPOSITORY https://github.com/COM8/kompute.git - GIT_TAG 01a0485f461e3d080b277aeb43c06a3ede8bd75d) # The commit hash for a dev version before v0.9.0. Replace with the latest from: https://github.com/KomputeProject/kompute/releases + GIT_TAG f4d72e2aa7b23ffe05d5ea3191bf72ad00def0ec) # The commit hash for a dev version before v0.9.0. Replace with the latest from: https://github.com/KomputeProject/kompute/releases FetchContent_MakeAvailable(kompute) include_directories(${kompute_SOURCE_DIR}/src/include) diff --git a/examples/array_multiplication/shader/CMakeLists.txt b/examples/array_multiplication/shader/CMakeLists.txt index bb01a0059..0a2544039 100644 --- a/examples/array_multiplication/shader/CMakeLists.txt +++ b/examples/array_multiplication/shader/CMakeLists.txt @@ -12,9 +12,8 @@ vulkan_compile_shader(INFILE my_shader.comp # RELATIVE_PATH "${kompute_SOURCE_DIR}/cmake") # Then add it to the library, so you can access it later in your code -add_library(shader "${CMAKE_CURRENT_BINARY_DIR}/my_shader.hpp" -# "${CMAKE_CURRENT_BINARY_DIR}/my_shader2.hpp" +add_library(shader INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/my_shader.hpp" +# "${CMAKE_CURRENT_BINARY_DIR}/my_shader2.hpp" ) -set_target_properties(shader PROPERTIES LINKER_LANGUAGE CXX) -target_include_directories(shader PUBLIC $) +target_include_directories(shader INTERFACE $) diff --git a/examples/logistic_regression/CMakeLists.txt b/examples/logistic_regression/CMakeLists.txt index aa48f4231..91a249d19 100644 --- a/examples/logistic_regression/CMakeLists.txt +++ b/examples/logistic_regression/CMakeLists.txt @@ -26,7 +26,7 @@ endif() include(FetchContent) FetchContent_Declare(kompute GIT_REPOSITORY https://github.com/COM8/kompute.git - GIT_TAG 528e80515918b314d51a8082220572d27e20d94d) # The commit hash for a dev version before v0.9.0. Replace with the latest from: https://github.com/KomputeProject/kompute/releases + GIT_TAG f4d72e2aa7b23ffe05d5ea3191bf72ad00def0ec) # The commit hash for a dev version before v0.9.0. Replace with the latest from: https://github.com/KomputeProject/kompute/releases FetchContent_MakeAvailable(kompute) include_directories(${kompute_SOURCE_DIR}/src/include) diff --git a/examples/logistic_regression/shader/CMakeLists.txt b/examples/logistic_regression/shader/CMakeLists.txt index bb01a0059..0a2544039 100644 --- a/examples/logistic_regression/shader/CMakeLists.txt +++ b/examples/logistic_regression/shader/CMakeLists.txt @@ -12,9 +12,8 @@ vulkan_compile_shader(INFILE my_shader.comp # RELATIVE_PATH "${kompute_SOURCE_DIR}/cmake") # Then add it to the library, so you can access it later in your code -add_library(shader "${CMAKE_CURRENT_BINARY_DIR}/my_shader.hpp" -# "${CMAKE_CURRENT_BINARY_DIR}/my_shader2.hpp" +add_library(shader INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/my_shader.hpp" +# "${CMAKE_CURRENT_BINARY_DIR}/my_shader2.hpp" ) -set_target_properties(shader PROPERTIES LINKER_LANGUAGE CXX) -target_include_directories(shader PUBLIC $) +target_include_directories(shader INTERFACE $) diff --git a/test/shaders/glsl/CMakeLists.txt b/test/shaders/glsl/CMakeLists.txt index 171e6c23a..e0bd475ff 100644 --- a/test/shaders/glsl/CMakeLists.txt +++ b/test/shaders/glsl/CMakeLists.txt @@ -18,10 +18,9 @@ vulkan_compile_shader(INFILE test_shader.comp OUTFILE test_shader.hpp NAMESPACE "kp") -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_shader.hpp" - "${CMAKE_CURRENT_BINARY_DIR}/test_shader.hpp") +add_library(test_shaders_glsl INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/test_logistic_regression_shader.hpp" + "${CMAKE_CURRENT_BINARY_DIR}/test_op_custom_shader.hpp" + "${CMAKE_CURRENT_BINARY_DIR}/test_workgroup_shader.hpp" + "${CMAKE_CURRENT_BINARY_DIR}/test_shader.hpp") -set_target_properties(test_shaders_glsl PROPERTIES LINKER_LANGUAGE CXX) -target_include_directories(test_shaders_glsl PUBLIC $) +target_include_directories(test_shaders_glsl INTERFACE $) From f15d1f2187947f7c8bec07d27d1805e13595306d Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Fri, 24 Jun 2022 13:22:57 +0200 Subject: [PATCH 051/107] Fixed missing dlls for tests on Windows Signed-off-by: Fabian Sauter --- test/CMakeLists.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 71b6fa239..aff841bbf 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -22,8 +22,12 @@ macro(add_kompute_test _TEST_NAME) add_test(NAME "kompute_${_TEST_NAME}_tests" COMMAND "${_TEST_NAME}_tests") # Group under the "tests" project folder in IDEs such as Visual Studio. set_property(TARGET ${_TEST_NAME}_tests PROPERTY FOLDER "tests") - if(WIN32 AND BUILD_SHARED_LIBS) - add_custom_command(TARGET ${_TEST_NAME}_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ $) + if(WIN32 AND BUILD_SHARED_LIBS AND NOT FILES_COPYED) # Install dlls in the same directory as the executable on Windows so one can simply double click them + set(FILES_COPYED "DONE") + add_custom_command(TARGET ${_TEST_NAME}_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ $) + add_custom_command(TARGET ${_TEST_NAME}_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ $) + add_custom_command(TARGET ${_TEST_NAME}_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ $) + add_custom_command(TARGET ${_TEST_NAME}_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ $) endif() endmacro() From efdad4af73f0b57eff00df282bc179a485a0b4bf Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Fri, 24 Jun 2022 15:48:21 +0200 Subject: [PATCH 052/107] Updaed compiling shaders docs Signed-off-by: Fabian Sauter --- .gitignore | 3 + docs/overview/shaders-to-headers.rst | 88 ++++++++++++++++++---------- 2 files changed, 61 insertions(+), 30 deletions(-) diff --git a/.gitignore b/.gitignore index 97a39b2b8..9dc07073f 100644 --- a/.gitignore +++ b/.gitignore @@ -189,3 +189,6 @@ vk_swiftshader_icd.json tmp_kp_shader.comp.spv tmp_kp_shader.comp +# Docs +_build/ + diff --git a/docs/overview/shaders-to-headers.rst b/docs/overview/shaders-to-headers.rst index 77d46ddc4..8f5517bc8 100644 --- a/docs/overview/shaders-to-headers.rst +++ b/docs/overview/shaders-to-headers.rst @@ -1,37 +1,10 @@ Processing Shaders with Kompute -===================== - -Demo / testing function to compile shaders ----------------------------------- - -GLSLANG was initially integrated as part of the framework but it now has been removed due to the license of the glslang pre-processor being under a custom NVIDIA license which explicitly excludes grant of any licenses to NVIDIA's patents in the preprocessor. This is covered in more detail here: https://github.com/KomputeProject/kompute/pull/235 - -For users that are looking to quickly test the processors it is possible to use the function that is provided in the examples which provides a (non-thread-safe / non-robust) implementation that compiles a shader string into spirv bytes. It is not recommended to use in production but it does enable for faster iteration cycles during development. - -.. code-block:: cpp - :linenos: - - static - std::vector - compileSource( - const std::string& source) - { - std::ofstream fileOut("tmp_kp_shader.comp"); - fileOut << source; - fileOut.close(); - if (system(std::string("glslangValidator -V tmp_kp_shader.comp -o tmp_kp_shader.comp.spv").c_str())) - throw std::runtime_error("Error running glslangValidator command"); - std::ifstream fileStream("tmp_kp_shader.comp.spv", std::ios::binary); - std::vector buffer; - buffer.insert(buffer.begin(), std::istreambuf_iterator(fileStream), {}); - return {(uint32_t*)buffer.data(), (uint32_t*)(buffer.data() + buffer.size())}; - } - +=============================== Converting Shaders into C / C++ Header Files ----------------------------------- +-------------------------------------------- Kompute allows for shaders to be loaded directly through the :class:`kp::OpAlgoBase` as either raw strings (through shaderc) or compiled SPIRV bytes. For this latter, the traditional method of including the SPIRV bytes is by loading the SPIRV file directly and passing the contents. @@ -69,9 +42,64 @@ You can run `python3 scripts/convert_shaders.py --help` to see all the options a -c, --header-path TEXT The (optional) output file for the cpp header files - -v, --verbose Enable versbosity if flag is provided + -v, --verbose Enable verbosity if flag is provided --help Show this message and exit. You can see the command that converts the shaders `in the makefile `_ to get an idea of how you would be able to use this utility. +Compiling Shaders Using CMake +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +If you are using CMake as build system you can use CMake to directly convert your compute shaders into C++ header files. + +.. code-block:: cmake + :linenos: + + # Consume Kompute via CMake fetch_content + include(FetchContent) + FetchContent_Declare(kompute GIT_REPOSITORY https://github.com/KomputeProject/kompute.git + GIT_TAG f4d72e2aa7b23ffe05d5ea3191bf72ad00def0ec) # The commit hash for a dev version before v0.9.0. Replace with the latest from: https://github.com/KomputeProject/kompute/releases + FetchContent_MakeAvailable(kompute) + include_directories(${kompute_SOURCE_DIR}/src/include) + + # Add to the list, so CMake can later find the code to compile shaders to header files + list(APPEND CMAKE_PREFIX_PATH "${kompute_SOURCE_DIR}/cmake") + + # To add more shaders simply copy the vulkan_compile_shader command and replace it with your new shader + vulkan_compile_shader(INFILE my_shader.comp + OUTFILE my_shader.hpp + NAMESPACE "shader" + RELATIVE_PATH "${kompute_SOURCE_DIR}/cmake") + + # vulkan_compile_shader(INFILE my_shader2.comp + # OUTFILE my_shader2.hpp + # NAMESPACE "shader" + # RELATIVE_PATH "${kompute_SOURCE_DIR}/cmake") + + # Then add it to the library, so you can access it later in your code + add_library(shader INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/my_shader.hpp" + # "${CMAKE_CURRENT_BINARY_DIR}/my_shader2.hpp" + ) + + target_include_directories(shader INTERFACE $) + +Once your code then compiles, you can simply include and use your shader header files. + +.. code-block:: cpp + :linenos: + + #include + + #include "my_shader.hpp" + + int main() { + // [...] + + const std::vector> params = ... + + const std::vector shader = std::vector(shader::MY_SHADER_COMP_SPV.begin(), shader::MY_SHADER_COMP_SPV.end()); + std::shared_ptr algo = mgr.algorithm(params, shader); + + // [...] + } From 7e55c076d4818fbc8ea55d0e9b4d552292e5024a Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Fri, 24 Jun 2022 16:09:53 +0200 Subject: [PATCH 053/107] Updated build system documentation Signed-off-by: Fabian Sauter --- CMakeLists.txt | 26 ++++----- docs/overview/build-system.rst | 98 +++++++++------------------------- 2 files changed, 39 insertions(+), 85 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 66d1e88b1..fa608c3f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,25 +67,25 @@ option(BUILD_SHARED_LIBS "Build libraries as shared libraries" ON) message(STATUS "General purpose GPU compute framework built on Vulkan") message(STATUS "=======================================================") # Enable or disable targets -kompute_option(KOMPUTE_OPT_BUILD_TESTS "Enable if you want to build tests" OFF) -kompute_option(KOMPUTE_OPT_CODE_COVERAGE "Enable if you want code coverage" OFF) -kompute_option(KOMPUTE_OPT_BUILD_DOCS "Enable if you want to build documentation" OFF) -kompute_option(KOMPUTE_OPT_INSTALL "Enable if you want to enable installation" OFF) +kompute_option(KOMPUTE_OPT_BUILD_TESTS "Enable if you want to build tests." OFF) +kompute_option(KOMPUTE_OPT_CODE_COVERAGE "Enable if you want code coverage." OFF) +kompute_option(KOMPUTE_OPT_BUILD_DOCS "Enable if you want to build documentation." OFF) +kompute_option(KOMPUTE_OPT_INSTALL "Enable if you want to enable installation." OFF) # Build options -kompute_option(KOMPUTE_OPT_BUILD_PYTHON "Enable if you want to build python bindings" OFF) -kompute_log_level(KOMPUTE_OPT_LOG_LEVEL "Internally we use spdlog for logging. The log level used can be changed here." "Off") -kompute_option(KOMPUTE_OPT_ANDROID_BUILD "Enable android compilation flags required" OFF) -kompute_option(KOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS "Explicitly disable debug layers even on debug" OFF) +kompute_option(KOMPUTE_OPT_BUILD_PYTHON "Enable if you want to build python bindings." OFF) +kompute_log_level(KOMPUTE_OPT_LOG_LEVEL "Internally we use spdlog for logging. The log level used can be changed here." "Default") +kompute_option(KOMPUTE_OPT_ANDROID_BUILD "Enable android compilation flags required." OFF) +kompute_option(KOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS "Explicitly disable debug layers even on debug." OFF) kompute_option(KOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK "Whether to check if your driver supports the Vulkan Header version you are linking against. This might be useful in case you build shared on a different system than you run later." OFF) # External components -kompute_option(KOMPUTE_OPT_USE_BUILD_IN_SPDLOG "Use the build in version of Spdlog" ON) -kompute_option(KOMPUTE_OPT_USE_BUILD_IN_FMT "Use the build in version of fmt" ON) -kompute_option(KOMPUTE_OPT_USE_BUILD_IN_GOOGLE_TEST "Use the build in version of GoogleTest" ON) -kompute_option(KOMPUTE_OPT_USE_BUILD_IN_PYBIND11 "Use the build in version of pybind11" ON) +kompute_option(KOMPUTE_OPT_USE_BUILD_IN_SPDLOG "Use the build in version of Spdlog." ON) +kompute_option(KOMPUTE_OPT_USE_BUILD_IN_FMT "Use the build in version of fmt." ON) +kompute_option(KOMPUTE_OPT_USE_BUILD_IN_GOOGLE_TEST "Use the build in version of GoogleTest." ON) +kompute_option(KOMPUTE_OPT_USE_BUILD_IN_PYBIND11 "Use the build in version of pybind11." ON) kompute_option(KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER "Use the build in version of Vulkan Headers. This could be helpful in case your system Vulkan Headers are to new for your driver. If you set this to false, please make sure your system Vulkan Header are supported by your driver." ON) -kompute_option_string(KOMPUTE_OPT_BUILD_IN_VULKAN_HEADER_TAG "The git tag used for the build in Vulkan Headers when 'KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER' is enabled. A list of tags can be found here: https://github.com/KhronosGroup/Vulkan-Headers/tags" "v1.2.203") +kompute_option_string(KOMPUTE_OPT_BUILD_IN_VULKAN_HEADER_TAG "The git tag used for the build in Vulkan Headers when 'KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER' is enabled. A list of tags can be found here: https://github.com/KhronosGroup/Vulkan-Headers/tags" "v1.2.203") message(STATUS "=======================================================") ##################################################### diff --git a/docs/overview/build-system.rst b/docs/overview/build-system.rst index 34b041f60..9b90a350f 100644 --- a/docs/overview/build-system.rst +++ b/docs/overview/build-system.rst @@ -20,45 +20,37 @@ This by default configures without any of the extra build tasks (such as buildin * - -DCMAKE_INSTALL_PREFIX="build/src/CMakefiles/Export/" - Enables local installation (which won't require admin privileges) * - -DCMAKE_TOOLCHAIN_FILE="..." - - This is the path for your package manager if you use it such as vcpkg + - This is the path for your package manager if you use it such as vcpkg. * - -DKOMPUTE_OPT_BUILD_TESTS=ON - - Enable if you wish to build and run the tests (must have deps installed. + - Enable if you want to build tests. * - -DKOMPUTE_OPT_CODE_COVERAGE=ON - - Enable if you wish to build and run code coverage (must have deps installed which are limited to Windows platform) + - Enable if you want code coverage. * - -DKOMPUTE_OPT_BUILD_DOCS=ON - - Enable if you wish to build the docs (must have docs deps installed) - * - -DKOMPUTE_OPT_BUILD_SHADERS=ON - - Option to build the single header file using "quom" utility - * - -DKOMPUTE_OPT_INSTALL=OFF - - Disables the install step in the cmake file (useful for android build) + - Enable if you want to build documentation. + * - -DKOMPUTE_OPT_INSTALL=ON + - Enable if you want to enable installation. * - -DKOMPUTE_OPT_BUILD_PYTHON=ON - - Enable to build python bindings (used internally for python package) - * - -DKOMPUTE_OPT_ENABLE_SPDLOG=ON - - Enable to compile with spdlog as the internal logging framework - * - -DKOMPUTE_OPT_USE_BUILD_IN_SPDLOG=ON - - Use the build in version of Spdlog - * - -KOMPUTE_OPT_USE_BUILD_IN_FMT=ON - - Use the build in version of fmt - * - -KOMPUTE_OPT_USE_BUILD_IN_GOOGLE_TEST=ON - - Use the build in version of GoogleTest - * - -KOMPUTE_OPT_USE_BUILD_IN_PYBIND11=ON - - Use the build in version of pybind11 - * - -KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER=ON - - Use the build in version of Vulkan Headers. This could be helpful in case your system Vulkan Headers are to new for your driver. If you set this to false, please make sure your system Vulkan Header are supported by your driver. - * - -KOMPUTE_OPT_BUILD_IN_VULKAN_HEADER_TAG="v1.2.203" - - The git tag used for the build in Vulkan Headers when 'KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER' is enabled. A list of tags can be found here: https://github.com/KhronosGroup/Vulkan-Headers/tags - * - -KOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=OFF - - Whether to check if your driver supports the Vulkan Header version you are linking against. This might be useful in case you build shared on a different system than you run later. + - Enable if you want to build python bindings. + * - -DKOMPUTE_OPT_LOG_LEVEL="Trace" + - Internally we use spdlog for logging. The log level used can be changed here. * - -DKOMPUTE_OPT_ANDROID_BUILD=ON - - Enables android build which includes and excludes relevant libraries + - Enable android compilation flags required. * - -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=ON - - Explicitly disables debug layers even when on debug mode - * - -DKOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS=ON - - Ensures dependencies are referenced as shared libraries for kompute install - * - -DKOMPUTE_OPT_BUILD_AS_SHARED_LIB=ON - - Whether to build Kompute as shared lib instead of static - * - -DKOMPUTE_EXTRA_CXX_FLAGS="..." - - Allows you to pass extra config flags to compiler + - Explicitly disable debug layers even on debug. + * - -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON + - Whether to check if your driver supports the Vulkan Header version you are linking against. This might be useful in case you build shared on a different system than you run later. + * - -DKOMPUTE_OPT_USE_BUILD_IN_SPDLOG=ON + - Use the build in version of Spdlog. + * - -DKOMPUTE_OPT_USE_BUILD_IN_FMT=ON + - Use the build in version of fmt. + * - -DKOMPUTE_OPT_USE_BUILD_IN_GOOGLE_TEST=ON + - Use the build in version of GoogleTest. + * - -DKOMPUTE_OPT_USE_BUILD_IN_PYBIND11=ON + - Use the build in version of pybind11. + * - -DKOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER=ON + - Use the build in version of Vulkan Headers. This could be helpful in case your system Vulkan Headers are to new for your driver. If you set this to false, please make sure your system Vulkan Header are supported by your driver. + * - -DKOMPUTE_OPT_BUILD_IN_VULKAN_HEADER_TAG="v1.2.203" + - The git tag used for the build in Vulkan Headers when 'KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER' is enabled. A list of tags can be found here: https://github.com/KhronosGroup/Vulkan-Headers/tags Compile Flags ~~~~~~~~~~~~~ @@ -70,27 +62,7 @@ Compile Flags - Description * - KOMPUTE_CREATE_PIPELINE_RESULT_VALUE - Ensure the return value of createPipeline is processed as ResultValue instead of Result - * - -DKOMPUTE_VK_API_VERSION="..." - - Sets the default api version to use for kompute api - * - -DKOMPUTE_VK_API_MAJOR_VERSION=ON - - Major version to use for the Vulkan SDK - * - -DKOMPUTE_VK_API_MINOR_VERSION=ON - - Minor version to use for the Vulkan SDK - * - -DKOMPUTE_ENABLE_SPDLOG=ON - - Enables the build with SPDLOG and FMT dependencies (must be installed) - * - -DKOMPUTE_LOG_OVERRIDE=ON - - Does not define the SPDLOG_\ :raw-html-m2r:`` macros if these are to be overridden - * - -DKOMPUTE_LOG_LEVEL - - The level for the log level on compile level (also sets spdlog level if enabled) - * - -DVVK_USE_PLATFORM_ANDROID_KHR - - Flag to enable android imports in kompute (enabled with -DKOMPUTE_OPT_ANDROID_BUILD) - * - -DRELEASE=ON - - Enable release build (enabled by cmake release build) - * - -DDEBUG=ON - - Enable debug build including debug flags (enabled by cmake debug build) - * - -DKOMPUTE_DISABLE_VK_DEBUG_LAYERS - - Disable the debug Vulkan SDK Layers, mainly used for android builds - + Other CMake Flags ~~~~~~~~~~~~~~~~~ @@ -115,21 +87,3 @@ Required dependencies ~~~~~~~~~~~~~~~~~~~~~ The only required dependency in the build is the Vulkan SDK. More specifically, the header files vulkan.h and vulkan.hpp, which are both part of the Vulkan SDK. If you haven't installed the Vulkan SDK yet, you can `download it here `_. - -Optional dependencies -~~~~~~~~~~~~~~~~~~~~~ - -SPDLOG is the preferred logging library, however by default Kompute runs without SPDLOG by overriding the macros. It also provides an easy way to override the macros if you prefer to bring your own logging framework. The macro override is the following: - -.. code-block:: c++ - - #ifndef KOMPUTE_LOG_OVERRIDE // Use this if you want to define custom macro overrides - #if KOMPUTE_SPDLOG_ENABLED // Use this if you want to enable SPDLOG - #include - #endif //KOMPUTE_SPDLOG_ENABLED - // ... Otherwise it adds macros that use std::cout (and only print first element) - #endif // KOMPUTE_LOG_OVERRIDE - -You can choose to build with or without SPDLOG by using the cmake flag ``KOMPUTE_OPT_ENABLE_SPDLOG``. - -Finally, remember that you will still need to set both the compile time log level with ``SPDLOG_ACTIVE_LEVEL``\ , and the runtime log level with ``spdlog::set_level(spdlog::level::debug);``. From 9de0847911fa0e22726adfa3b327eb681223f47c Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Fri, 24 Jun 2022 16:21:45 +0200 Subject: [PATCH 054/107] Updated build instructions Signed-off-by: Fabian Sauter --- docs/overview/build-system.rst | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/overview/build-system.rst b/docs/overview/build-system.rst index 9b90a350f..a508125cb 100644 --- a/docs/overview/build-system.rst +++ b/docs/overview/build-system.rst @@ -2,13 +2,18 @@ C++ Build System Deep Dive ====================== -The recommended approach to build the project is as out-of-source build in the ``build`` folder. This project comes with a ``Makefile`` that provides a set of commands that help with developer workflows. You can see some of the commands if you want to add some of the more advanced commands. +The recommended approach to build the project is as out-of-source build in the ``build`` folder. This project uses CMake as build system. For a base build you just have to run: -.. code-block:: +.. code-block:: bash - cmake -Bbuild + git clone https://github.com/KomputeProject/kompute.git + cd kompute + mkdir build + cd build + cmake .. + cmake --build . This by default configures without any of the extra build tasks (such as building shaders) and compiles without the optional dependencies. The table below provides more detail. From 661abb26291ace026df3f6c221a3d18fa96c2499 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Mon, 11 Jul 2022 14:16:14 +0200 Subject: [PATCH 055/107] build in -> built-in Signed-off-by: Fabian Sauter --- CMakeLists.txt | 12 ++++++------ docs/overview/build-system.rst | 14 +++++++------- examples/android/android-simple/README.md | 4 ++-- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fa608c3f8..d815ab04e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,12 +80,12 @@ kompute_option(KOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS "Explicitly disable debug lay kompute_option(KOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK "Whether to check if your driver supports the Vulkan Header version you are linking against. This might be useful in case you build shared on a different system than you run later." OFF) # External components -kompute_option(KOMPUTE_OPT_USE_BUILD_IN_SPDLOG "Use the build in version of Spdlog." ON) -kompute_option(KOMPUTE_OPT_USE_BUILD_IN_FMT "Use the build in version of fmt." ON) -kompute_option(KOMPUTE_OPT_USE_BUILD_IN_GOOGLE_TEST "Use the build in version of GoogleTest." ON) -kompute_option(KOMPUTE_OPT_USE_BUILD_IN_PYBIND11 "Use the build in version of pybind11." ON) -kompute_option(KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER "Use the build in version of Vulkan Headers. This could be helpful in case your system Vulkan Headers are to new for your driver. If you set this to false, please make sure your system Vulkan Header are supported by your driver." ON) -kompute_option_string(KOMPUTE_OPT_BUILD_IN_VULKAN_HEADER_TAG "The git tag used for the build in Vulkan Headers when 'KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER' is enabled. A list of tags can be found here: https://github.com/KhronosGroup/Vulkan-Headers/tags" "v1.2.203") +kompute_option(KOMPUTE_OPT_USE_BUILD_IN_SPDLOG "Use the built-in version of Spdlog." ON) +kompute_option(KOMPUTE_OPT_USE_BUILD_IN_FMT "Use the built-in version of fmt." ON) +kompute_option(KOMPUTE_OPT_USE_BUILD_IN_GOOGLE_TEST "Use the built-in version of GoogleTest." ON) +kompute_option(KOMPUTE_OPT_USE_BUILD_IN_PYBIND11 "Use the built-in version of pybind11." ON) +kompute_option(KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER "Use the built-in version of Vulkan Headers. This could be helpful in case your system Vulkan Headers are to new for your driver. If you set this to false, please make sure your system Vulkan Header are supported by your driver." ON) +kompute_option_string(KOMPUTE_OPT_BUILD_IN_VULKAN_HEADER_TAG "The git tag used for the built-in Vulkan Headers when 'KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER' is enabled. A list of tags can be found here: https://github.com/KhronosGroup/Vulkan-Headers/tags" "v1.2.203") message(STATUS "=======================================================") ##################################################### diff --git a/docs/overview/build-system.rst b/docs/overview/build-system.rst index a508125cb..db652372f 100644 --- a/docs/overview/build-system.rst +++ b/docs/overview/build-system.rst @@ -2,7 +2,7 @@ C++ Build System Deep Dive ====================== -The recommended approach to build the project is as out-of-source build in the ``build`` folder. This project uses CMake as build system. +The recommended approach to build the project is as out-of-source built-in the ``build`` folder. This project uses CMake as build system. For a base build you just have to run: @@ -45,17 +45,17 @@ This by default configures without any of the extra build tasks (such as buildin * - -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON - Whether to check if your driver supports the Vulkan Header version you are linking against. This might be useful in case you build shared on a different system than you run later. * - -DKOMPUTE_OPT_USE_BUILD_IN_SPDLOG=ON - - Use the build in version of Spdlog. + - Use the built-in version of Spdlog. * - -DKOMPUTE_OPT_USE_BUILD_IN_FMT=ON - - Use the build in version of fmt. + - Use the built-in version of fmt. * - -DKOMPUTE_OPT_USE_BUILD_IN_GOOGLE_TEST=ON - - Use the build in version of GoogleTest. + - Use the built-in version of GoogleTest. * - -DKOMPUTE_OPT_USE_BUILD_IN_PYBIND11=ON - - Use the build in version of pybind11. + - Use the built-in version of pybind11. * - -DKOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER=ON - - Use the build in version of Vulkan Headers. This could be helpful in case your system Vulkan Headers are to new for your driver. If you set this to false, please make sure your system Vulkan Header are supported by your driver. + - Use the built-in version of Vulkan Headers. This could be helpful in case your system Vulkan Headers are to new for your driver. If you set this to false, please make sure your system Vulkan Header are supported by your driver. * - -DKOMPUTE_OPT_BUILD_IN_VULKAN_HEADER_TAG="v1.2.203" - - The git tag used for the build in Vulkan Headers when 'KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER' is enabled. A list of tags can be found here: https://github.com/KhronosGroup/Vulkan-Headers/tags + - The git tag used for the built-in Vulkan Headers when 'KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER' is enabled. A list of tags can be found here: https://github.com/KhronosGroup/Vulkan-Headers/tags Compile Flags ~~~~~~~~~~~~~ diff --git a/examples/android/android-simple/README.md b/examples/android/android-simple/README.md index 23678e520..8ef2e21fe 100644 --- a/examples/android/android-simple/README.md +++ b/examples/android/android-simple/README.md @@ -12,9 +12,9 @@ This is the accompanying code for the Blog post ["Supercharging your Mobile Apps

This example provides an end to end example that can be run using android studio. -The example uses the Kompute build in the relative folder to build the respective binaries for android. +The example uses the Kompute built-in the relative folder to build the respective binaries for android. -The build structure provides a range of options to build in different Android hardware. This example was tested in various emulators including Pixel 2, and a physical Samsung S7 phone. +The build structure provides a range of options to built-in different Android hardware. This example was tested in various emulators including Pixel 2, and a physical Samsung S7 phone.


From a86736e332dabde836828f4f63030201ebc01249 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Mon, 11 Jul 2022 14:14:38 +0200 Subject: [PATCH 056/107] Removed BUILD_SHARED_LIBS option Signed-off-by: Fabian Sauter --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d815ab04e..b489f989e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,7 +63,6 @@ macro(kompute_option_string OPTION_NAME OPTION_TEXT OPTION_DEFAULT) message(STATUS " ${OPTION_NAME}: ${${OPTION_NAME}}") endmacro() -option(BUILD_SHARED_LIBS "Build libraries as shared libraries" ON) message(STATUS "General purpose GPU compute framework built on Vulkan") message(STATUS "=======================================================") # Enable or disable targets From dab8492376268897ac5cacdc7bfef261fbe5244b Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Mon, 11 Jul 2022 14:13:35 +0200 Subject: [PATCH 057/107] Downgraded CMake minimum version to 3.14 from 3.15 Signed-off-by: Fabian Sauter --- CMakeLists.txt | 56 ++++++++----- cmake/bin_file_to_header.cmake | 2 +- examples/array_multiplication/CMakeLists.txt | 4 +- .../shader/CMakeLists.txt | 17 ++-- .../array_multiplication/src/CMakeLists.txt | 2 +- examples/logistic_regression/CMakeLists.txt | 4 +- .../logistic_regression/shader/CMakeLists.txt | 17 ++-- .../logistic_regression/src/CMakeLists.txt | 2 +- src/CMakeLists.txt | 82 +++++++++---------- src/include/CMakeLists.txt | 22 ++--- src/logger/CMakeLists.txt | 21 ++--- test/CMakeLists.txt | 27 +++--- test/shaders/CMakeLists.txt | 6 +- test/shaders/glsl/CMakeLists.txt | 26 +++--- 14 files changed, 151 insertions(+), 137 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b489f989e..3c69ea1f9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ # SPDX-License-Identifier: Apache-2.0 -cmake_minimum_required(VERSION 3.15) -project(kompute VERSION 1.8.1 LANGUAGES CXX) +cmake_minimum_required(VERSION 3.14) +project(kompute VERSION 0.8.1 LANGUAGES CXX) set(CMAKE_CXX_STANDARD 14) @@ -22,49 +22,58 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}") set(KOMPUTE_LIBRARIES kompute CACHE INTERNAL "") -##################################################### +# #################################################### # Options -##################################################### - +# #################################################### macro(kompute_option OPTION_NAME OPTION_TEXT OPTION_DEFAULT) option(${OPTION_NAME} ${OPTION_TEXT} ${OPTION_DEFAULT}) + if(DEFINED ENV{${OPTION_NAME}}) # Allow overriding the option through an environment variable set(${OPTION_NAME} $ENV{${OPTION_NAME}}) endif() + if(${OPTION_NAME}) add_definitions(-D${OPTION_NAME}) endif() + message(STATUS " ${OPTION_NAME}: ${${OPTION_NAME}}") endmacro() macro(kompute_log_level OPTION_NAME OPTION_TEXT OPTION_DEFAULT) set(${OPTION_NAME} ${OPTION_DEFAULT} CACHE STRING ${OPTION_TEXT}) set_property(CACHE ${OPTION_NAME} PROPERTY STRINGS "Trace" "Debug" "Info" "Warn" "Error" "Critical") + if(DEFINED ENV{${OPTION_NAME}}) # Allow setting the option through an environment variable set(${OPTION_NAME} $ENV{${OPTION_NAME}}) endif() + if(${OPTION_NAME}) add_definitions(-D${OPTION_NAME}) endif() + message(STATUS " ${OPTION_NAME}: ${${OPTION_NAME}}") endmacro() macro(kompute_option_string OPTION_NAME OPTION_TEXT OPTION_DEFAULT) set(${OPTION_NAME} ${OPTION_DEFAULT} CACHE STRING ${OPTION_TEXT}) + if(DEFINED ENV{${OPTION_NAME}}) # Allow setting the option through an environment variable set(${OPTION_NAME} $ENV{${OPTION_NAME}}) endif() + if(${OPTION_NAME}) add_definitions(-D${OPTION_NAME}) endif() + message(STATUS " ${OPTION_NAME}: ${${OPTION_NAME}}") endmacro() message(STATUS "General purpose GPU compute framework built on Vulkan") message(STATUS "=======================================================") + # Enable or disable targets kompute_option(KOMPUTE_OPT_BUILD_TESTS "Enable if you want to build tests." OFF) kompute_option(KOMPUTE_OPT_CODE_COVERAGE "Enable if you want code coverage." OFF) @@ -87,14 +96,14 @@ kompute_option(KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER "Use the built-in version kompute_option_string(KOMPUTE_OPT_BUILD_IN_VULKAN_HEADER_TAG "The git tag used for the built-in Vulkan Headers when 'KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER' is enabled. A list of tags can be found here: https://github.com/KhronosGroup/Vulkan-Headers/tags" "v1.2.203") message(STATUS "=======================================================") -##################################################### +# #################################################### # Deprecated Options -##################################################### +# #################################################### include(cmake/deprecation_warnings.cmake) -##################################################### +# #################################################### # Dependencies -##################################################### +# #################################################### include(cmake/vulkan_shader_compiler.cmake) include(FetchContent) include(cmake/check_vulkan_version.cmake) @@ -105,11 +114,12 @@ include(cmake/check_vulkan_version.cmake) if(NOT KOMPUTE_OPT_ANDROID_BUILD) find_package(Vulkan REQUIRED) endif() + if(KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER) FetchContent_Declare(vulkan_header GIT_REPOSITORY https://github.com/KhronosGroup/Vulkan-Headers.git - GIT_TAG ${KOMPUTE_OPT_BUILD_IN_VULKAN_HEADER_TAG}) # Source: https://github.com/KhronosGroup/Vulkan-Headers/tags + GIT_TAG ${KOMPUTE_OPT_BUILD_IN_VULKAN_HEADER_TAG}) # Source: https://github.com/KhronosGroup/Vulkan-Headers/tags FetchContent_MakeAvailable(vulkan_header) - + if(NOT KOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK) # Ensure the driver supports this Vulkan version check_vulkan_version(INCLUDE_DIR "${vulkan_header_SOURCE_DIR}/include") @@ -127,7 +137,7 @@ if(KOMPUTE_OPT_USE_BUILD_IN_SPDLOG) set(SPDLOG_BUILD_SHARED ${KOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS}) FetchContent_Declare(spdlog GIT_REPOSITORY https://github.com/gabime/spdlog.git - GIT_TAG v1.10.0) # Source: https://github.com/gabime/spdlog/releases + GIT_TAG v1.10.0) # Source: https://github.com/gabime/spdlog/releases FetchContent_MakeAvailable(spdlog) else() find_package(spdlog REQUIRED) @@ -138,7 +148,7 @@ if(KOMPUTE_OPT_USE_BUILD_IN_FMT) set(FMT_INSTALL ${KOMPUTE_OPT_INSTALL}) set(BUILD_SHARED_LIBS_BKP ${KOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS}) FetchContent_Declare(fmt GIT_REPOSITORY https://github.com/fmtlib/fmt.git - GIT_TAG 8.1.1) # Source: https://github.com/fmtlib/fmt/releases + GIT_TAG 8.1.1) # Source: https://github.com/fmtlib/fmt/releases FetchContent_MakeAvailable(fmt) set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_BKP}) else() @@ -149,7 +159,7 @@ endif() if(KOMPUTE_OPT_BUILD_TESTS) if(KOMPUTE_OPT_USE_BUILD_IN_GOOGLE_TEST) FetchContent_Declare(googletest GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG release-1.11.0) # Source: https://github.com/google/googletest/releases + GIT_TAG release-1.11.0) # Source: https://github.com/google/googletest/releases FetchContent_MakeAvailable(googletest) add_library(gtest_int INTERFACE) @@ -157,7 +167,7 @@ if(KOMPUTE_OPT_BUILD_TESTS) target_include_directories(gtest_int INTERFACE ${googletest_SOURCE_DIR}/include) add_library(GTest::GTest ALIAS gtest_int) - + # Group under the "tests/gtest" project folder in IDEs such as Visual Studio. set_property(TARGET gtest PROPERTY FOLDER "tests/gtest") set_property(TARGET gtest_main PROPERTY FOLDER "tests/gtest") @@ -170,17 +180,18 @@ endif() if(KOMPUTE_OPT_BUILD_PYTHON) if(KOMPUTE_OPT_USE_BUILD_IN_PYBIND11) FetchContent_Declare(pybind GIT_REPOSITORY https://github.com/pybind/pybind11.git - GIT_TAG v2.9.2) # Source: https://github.com/pybind/pybind11/releases + GIT_TAG v2.9.2) # Source: https://github.com/pybind/pybind11/releases FetchContent_MakeAvailable(pybind) else() find_package(pybind11 REQUIRED) endif() + find_package(PythonLibs REQUIRED) endif() -##################################################### +# #################################################### # Preprocessor Macros -##################################################### +# #################################################### if(KOMPUTE_OPT_ANDROID_BUILD) add_compile_definitions(VK_USE_PLATFORM_ANDROID_KHR=1) endif() @@ -193,16 +204,16 @@ if(KOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS) add_compile_definitions(KOMPUTE_DISABLE_VK_DEBUG_LAYERS=1) endif() -##################################################### +# #################################################### # Misc Options -##################################################### +# #################################################### if(KOMPUTE_OPT_INSTALL) # Enable install parameters for glslang (overrides parameters passed) # When install is enabled the glslang libraries become shared set(ENABLE_GLSLANG_INSTALL ON CACHE BOOL "Enables install of glslang" FORCE) endif() -if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Werror") endif() @@ -211,13 +222,14 @@ if(KOMPUTE_OPT_CODE_COVERAGE) if(NOT UNIX) message(FATAL_ERROR "KOMPUTE_OPT_CODE_COVERAGE can only be enabled in unix based systems due to limitation on gcov.") endif() + include(cmake/code_coverage.cmake) endif() # If glslang is cloned, then SPIRV/GlslangToSpv.h will be used instead of glslang/SPIRV/GlslangToSpv.h # As after installation, SPIRV/ header files will be found in glslang/SPIRV/ , more info in #193 if(KOMPUTE_OPT_REPO_SUBMODULE_BUILD) - add_definitions(-DUSE_EXTERNAL_GLSLANG) + add_definitions(-DUSE_EXTERNAL_GLSLANG) endif() # Allow scripts to call main kompute Makefile diff --git a/cmake/bin_file_to_header.cmake b/cmake/bin_file_to_header.cmake index 814aac907..e03931907 100644 --- a/cmake/bin_file_to_header.cmake +++ b/cmake/bin_file_to_header.cmake @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.14) if(${INPUT_SHADER_FILE} STREQUAL "") message(FATAL_ERROR "No input file path provided via 'INPUT_SHADER_FILE'.") diff --git a/examples/array_multiplication/CMakeLists.txt b/examples/array_multiplication/CMakeLists.txt index 37a0af21b..ae28c8a84 100644 --- a/examples/array_multiplication/CMakeLists.txt +++ b/examples/array_multiplication/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.14) project(kompute_array_mult) set(CMAKE_CXX_STANDARD 14) @@ -26,7 +26,7 @@ endif() include(FetchContent) FetchContent_Declare(kompute GIT_REPOSITORY https://github.com/COM8/kompute.git - GIT_TAG f4d72e2aa7b23ffe05d5ea3191bf72ad00def0ec) # The commit hash for a dev version before v0.9.0. Replace with the latest from: https://github.com/KomputeProject/kompute/releases + GIT_TAG f4d72e2aa7b23ffe05d5ea3191bf72ad00def0ec) # The commit hash for a dev version before v0.9.0. Replace with the latest from: https://github.com/KomputeProject/kompute/releases FetchContent_MakeAvailable(kompute) include_directories(${kompute_SOURCE_DIR}/src/include) diff --git a/examples/array_multiplication/shader/CMakeLists.txt b/examples/array_multiplication/shader/CMakeLists.txt index 0a2544039..fdf5eee2c 100644 --- a/examples/array_multiplication/shader/CMakeLists.txt +++ b/examples/array_multiplication/shader/CMakeLists.txt @@ -1,19 +1,20 @@ -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.14) # To add more shaders simply copy the vulkan_compile_shader command and replace it with your new shader vulkan_compile_shader(INFILE my_shader.comp - OUTFILE my_shader.hpp - NAMESPACE "shader" - RELATIVE_PATH "${kompute_SOURCE_DIR}/cmake") + OUTFILE my_shader.hpp + NAMESPACE "shader" + RELATIVE_PATH "${kompute_SOURCE_DIR}/cmake") # vulkan_compile_shader(INFILE my_shader2.comp -# OUTFILE my_shader2.hpp -# NAMESPACE "shader" -# RELATIVE_PATH "${kompute_SOURCE_DIR}/cmake") +# OUTFILE my_shader2.hpp +# NAMESPACE "shader" +# RELATIVE_PATH "${kompute_SOURCE_DIR}/cmake") # Then add it to the library, so you can access it later in your code add_library(shader INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/my_shader.hpp" -# "${CMAKE_CURRENT_BINARY_DIR}/my_shader2.hpp" + + # "${CMAKE_CURRENT_BINARY_DIR}/my_shader2.hpp" ) target_include_directories(shader INTERFACE $) diff --git a/examples/array_multiplication/src/CMakeLists.txt b/examples/array_multiplication/src/CMakeLists.txt index 3a912ec1d..549f1ab44 100644 --- a/examples/array_multiplication/src/CMakeLists.txt +++ b/examples/array_multiplication/src/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.14) add_executable(kompute_array_mult main.cpp) target_link_libraries(kompute_array_mult PRIVATE shader kompute::kompute) diff --git a/examples/logistic_regression/CMakeLists.txt b/examples/logistic_regression/CMakeLists.txt index 91a249d19..1c20d8b59 100644 --- a/examples/logistic_regression/CMakeLists.txt +++ b/examples/logistic_regression/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.14) project(kompute_logistic_regression) set(CMAKE_CXX_STANDARD 14) @@ -26,7 +26,7 @@ endif() include(FetchContent) FetchContent_Declare(kompute GIT_REPOSITORY https://github.com/COM8/kompute.git - GIT_TAG f4d72e2aa7b23ffe05d5ea3191bf72ad00def0ec) # The commit hash for a dev version before v0.9.0. Replace with the latest from: https://github.com/KomputeProject/kompute/releases + GIT_TAG f4d72e2aa7b23ffe05d5ea3191bf72ad00def0ec) # The commit hash for a dev version before v0.9.0. Replace with the latest from: https://github.com/KomputeProject/kompute/releases FetchContent_MakeAvailable(kompute) include_directories(${kompute_SOURCE_DIR}/src/include) diff --git a/examples/logistic_regression/shader/CMakeLists.txt b/examples/logistic_regression/shader/CMakeLists.txt index 0a2544039..fdf5eee2c 100644 --- a/examples/logistic_regression/shader/CMakeLists.txt +++ b/examples/logistic_regression/shader/CMakeLists.txt @@ -1,19 +1,20 @@ -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.14) # To add more shaders simply copy the vulkan_compile_shader command and replace it with your new shader vulkan_compile_shader(INFILE my_shader.comp - OUTFILE my_shader.hpp - NAMESPACE "shader" - RELATIVE_PATH "${kompute_SOURCE_DIR}/cmake") + OUTFILE my_shader.hpp + NAMESPACE "shader" + RELATIVE_PATH "${kompute_SOURCE_DIR}/cmake") # vulkan_compile_shader(INFILE my_shader2.comp -# OUTFILE my_shader2.hpp -# NAMESPACE "shader" -# RELATIVE_PATH "${kompute_SOURCE_DIR}/cmake") +# OUTFILE my_shader2.hpp +# NAMESPACE "shader" +# RELATIVE_PATH "${kompute_SOURCE_DIR}/cmake") # Then add it to the library, so you can access it later in your code add_library(shader INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/my_shader.hpp" -# "${CMAKE_CURRENT_BINARY_DIR}/my_shader2.hpp" + + # "${CMAKE_CURRENT_BINARY_DIR}/my_shader2.hpp" ) target_include_directories(shader INTERFACE $) diff --git a/examples/logistic_regression/src/CMakeLists.txt b/examples/logistic_regression/src/CMakeLists.txt index 8a2dfe8c9..c7c39aa96 100644 --- a/examples/logistic_regression/src/CMakeLists.txt +++ b/examples/logistic_regression/src/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.14) add_executable(kompute_logistic_regression main.cpp) target_link_libraries(kompute_logistic_regression PRIVATE shader kompute::kompute) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cd1787dd3..aec0df052 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,93 +1,91 @@ # SPDX-License-Identifier: Apache-2.0 -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.14) if(KOMPUTE_OPT_ANDROID_BUILD) find_library(android android) endif() -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.14) add_library(kompute Algorithm.cpp - Manager.cpp - OpAlgoDispatch.cpp - OpMemoryBarrier.cpp - OpTensorCopy.cpp - OpTensorSyncDevice.cpp - OpTensorSyncLocal.cpp - Sequence.cpp - Tensor.cpp) + Manager.cpp + OpAlgoDispatch.cpp + OpMemoryBarrier.cpp + OpTensorCopy.cpp + OpTensorSyncDevice.cpp + OpTensorSyncLocal.cpp + Sequence.cpp + Tensor.cpp) add_library(kompute::kompute ALIAS kompute) # Set version for shared libraries. set_target_properties(kompute - PROPERTIES - VERSION ${${PROJECT_NAME}_VERSION} - SOVERSION ${${PROJECT_NAME}_VERSION_MAJOR}) + PROPERTIES + VERSION ${${PROJECT_NAME}_VERSION} + SOVERSION ${${PROJECT_NAME}_VERSION_MAJOR}) # Import GNU common install directory variables include(GNUInstallDirs) if(CPR_FORCE_USE_SYSTEM_CURL) install(TARGETS kompute - EXPORT komputeTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) + EXPORT komputeTargets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) # Include CMake helpers for package config files # Follow this installation guideline: https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html include(CMakePackageConfigHelpers) configure_package_config_file(${PROJECT_SOURCE_DIR}/cmake/komputeConfig.cmake.in - "${PROJECT_BINARY_DIR}/kompute/komputeConfig.cmake" - INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kompute) + "${PROJECT_BINARY_DIR}/kompute/komputeConfig.cmake" + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kompute) install(EXPORT komputeTargets - FILE komputeTargets.cmake - NAMESPACE kompute:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kompute) + FILE komputeTargets.cmake + NAMESPACE kompute:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kompute) install(FILES ${PROJECT_BINARY_DIR}/kompute/komputeConfig.cmake - ${PROJECT_BINARY_DIR}/kompute/komputeConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kompute) - + ${PROJECT_BINARY_DIR}/kompute/komputeConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kompute) + else() install(TARGETS kompute - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() -##################################################### +# #################################################### # Android -##################################################### - +# #################################################### if(KOMPUTE_OPT_ANDROID_BUILD) set(VK_ANDROID_COMMON_DIR ${ANDROID_NDK}/sources/third_party/vulkan/src/common) set(VK_ANDROID_PATCH_DIR ${PROJECT_SOURCE_DIR}/vk_ndk_wrapper_include/) set(VK_ANDROID_INCLUDE_DIR ${ANDROID_NDK}/sources/third_party/vulkan/src/include) include_directories(${VK_ANDROID_COMMON_DIR} - ${VK_ANDROID_PATCH_DIR} - ${VK_ANDROID_INCLUDE_DIR}) + ${VK_ANDROID_PATCH_DIR} + ${VK_ANDROID_INCLUDE_DIR}) add_library(kompute_vk_ndk_wrapper STATIC ${PROJECT_SOURCE_DIR}/vk_ndk_wrapper_include/kompute_vk_ndk_wrapper.cpp) endif() -##################################################### +# #################################################### # Linking -##################################################### - +# #################################################### if(KOMPUTE_OPT_ANDROID_BUILD) target_link_libraries(kompute PUBLIC kompute_vk_ndk_wrapper - android - kp_logger - PRIVATE fmt::fmt) + android + kp_logger + PRIVATE fmt::fmt) else() target_link_libraries(kompute PUBLIC Vulkan::Vulkan - kp_logger - PRIVATE fmt::fmt) + kp_logger + PRIVATE fmt::fmt) endif() if(KOMPUTE_OPT_BUILD_PYTHON) @@ -100,8 +98,8 @@ if(KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER) target_link_libraries(kompute PUBLIC Vulkan-Headers) endif() -##################################################### +# #################################################### # Misc -##################################################### +# #################################################### add_subdirectory(logger) add_subdirectory(include) diff --git a/src/include/CMakeLists.txt b/src/include/CMakeLists.txt index 16f7f5092..099113813 100644 --- a/src/include/CMakeLists.txt +++ b/src/include/CMakeLists.txt @@ -1,14 +1,14 @@ -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.14) -##################################################### +# #################################################### # Kompute -##################################################### - +# #################################################### target_include_directories(kompute PUBLIC $ - $) + $) target_sources(kompute PRIVATE - # Header files (useful in IDEs) + + # Header files (useful in IDEs) kompute/Algorithm.hpp kompute/Core.hpp kompute/Kompute.hpp @@ -32,15 +32,15 @@ target_sources(kompute PRIVATE install(DIRECTORY kompute DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) -##################################################### +# #################################################### # Logger -##################################################### - +# #################################################### target_include_directories(kp_logger PUBLIC $ - $) + $) target_sources(kp_logger PRIVATE - # Header files (useful in IDEs) + + # Header files (useful in IDEs) kompute/logger/Logger.hpp ) diff --git a/src/logger/CMakeLists.txt b/src/logger/CMakeLists.txt index 087de1771..86b954794 100644 --- a/src/logger/CMakeLists.txt +++ b/src/logger/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.16) +cmake_minimum_required(VERSION 3.14) set(LOGGER_SOURCES Logger.cpp) @@ -6,31 +6,32 @@ add_library(kp_logger ${LOGGER_SOURCES}) target_link_libraries(kp_logger PUBLIC spdlog::spdlog) if(${KOMPUTE_OPT_LOG_LEVEL} STREQUAL "Trace") - set (KOMPUTE_OPT_LOG_LEVEL TRACE) + set(KOMPUTE_OPT_LOG_LEVEL TRACE) message(STATUS "Using log level Trace") elseif(${KOMPUTE_OPT_LOG_LEVEL} STREQUAL "Debug") - set (KOMPUTE_OPT_LOG_LEVEL DEBUG) + set(KOMPUTE_OPT_LOG_LEVEL DEBUG) message(STATUS "Using log level Debug") elseif(${KOMPUTE_OPT_LOG_LEVEL} STREQUAL "Info") - set (KOMPUTE_OPT_LOG_LEVEL INFO) + set(KOMPUTE_OPT_LOG_LEVEL INFO) message(STATUS "Using log level Info") elseif(${KOMPUTE_OPT_LOG_LEVEL} STREQUAL "Warn") - set (KOMPUTE_OPT_LOG_LEVEL WARN) + set(KOMPUTE_OPT_LOG_LEVEL WARN) message(STATUS "Using log level Warn") elseif(${KOMPUTE_OPT_LOG_LEVEL} STREQUAL "Error") - set (KOMPUTE_OPT_LOG_LEVEL ERROR) + set(KOMPUTE_OPT_LOG_LEVEL ERROR) message(STATUS "Using log level Error") elseif(${KOMPUTE_OPT_LOG_LEVEL} STREQUAL "Critical") - set (KOMPUTE_OPT_LOG_LEVEL CRITICAL) + set(KOMPUTE_OPT_LOG_LEVEL CRITICAL) message(STATUS "Using log level Critical") elseif(${KOMPUTE_OPT_LOG_LEVEL} STREQUAL Off) - set (KOMPUTE_OPT_LOG_LEVEL OFF) + set(KOMPUTE_OPT_LOG_LEVEL OFF) message(STATUS "Using log level Off") else() - if((NOT ${KOMPUTE_OPT_LOG_LEVEL} STREQUAL Default) AND (NOT KOMPUTE_OPT_LOG_LEVEL STREQUAL "")) + if((NOT ${KOMPUTE_OPT_LOG_LEVEL} STREQUAL Default) AND(NOT KOMPUTE_OPT_LOG_LEVEL STREQUAL "")) message(WARNING "Log level '${KOMPUTE_OPT_LOG_LEVEL}' unknown, use -DKOMPUTE_OPT_LOG_LEVEL=[Trace, Debug, Info, Warn, Error, Critical, Off]") endif() - set (KOMPUTE_OPT_LOG_LEVEL $,DEBUG,INFO>) + + set(KOMPUTE_OPT_LOG_LEVEL $,DEBUG,INFO>) message(STATUS "Setting KOMPUTE_OPT_LOG_LEVEL to according to build type") endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index aff841bbf..eb52d9b52 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,28 +1,29 @@ # SPDX-License-Identifier: Apache-2.0 -####################### -cmake_minimum_required(VERSION 3.15) +# ###################### +cmake_minimum_required(VERSION 3.14) -##################################################### +# #################################################### # Shaders -##################################################### +# #################################################### add_subdirectory(shaders) -##################################################### +# #################################################### # Tests -##################################################### - +# #################################################### macro(add_kompute_test _TEST_NAME) add_executable("${_TEST_NAME}_tests" "Test${_TEST_NAME}.cpp" - ${ARGN}) + ${ARGN}) target_link_libraries("${_TEST_NAME}_tests" PRIVATE GTest::GTest - kompute::kompute - kp_logger - test_shaders - test_shaders_glsl) + kompute::kompute + kp_logger + test_shaders + test_shaders_glsl) add_test(NAME "kompute_${_TEST_NAME}_tests" COMMAND "${_TEST_NAME}_tests") + # Group under the "tests" project folder in IDEs such as Visual Studio. set_property(TARGET ${_TEST_NAME}_tests PROPERTY FOLDER "tests") - if(WIN32 AND BUILD_SHARED_LIBS AND NOT FILES_COPYED) # Install dlls in the same directory as the executable on Windows so one can simply double click them + + if(WIN32 AND BUILD_SHARED_LIBS AND NOT FILES_COPYED) # Install dlls in the same directory as the executable on Windows so one can simply double click them set(FILES_COPYED "DONE") add_custom_command(TARGET ${_TEST_NAME}_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ $) add_custom_command(TARGET ${_TEST_NAME}_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ $) diff --git a/test/shaders/CMakeLists.txt b/test/shaders/CMakeLists.txt index 64fd07f51..b41e9f6a3 100644 --- a/test/shaders/CMakeLists.txt +++ b/test/shaders/CMakeLists.txt @@ -1,8 +1,8 @@ # SPDX-License-Identifier: Apache-2.0 -####################### -cmake_minimum_required(VERSION 3.15) +# ###################### +cmake_minimum_required(VERSION 3.14) add_library(test_shaders "Utils.cpp" - "Utils.hpp") + "Utils.hpp") add_subdirectory(glsl) \ No newline at end of file diff --git a/test/shaders/glsl/CMakeLists.txt b/test/shaders/glsl/CMakeLists.txt index e0bd475ff..625000552 100644 --- a/test/shaders/glsl/CMakeLists.txt +++ b/test/shaders/glsl/CMakeLists.txt @@ -1,26 +1,26 @@ # SPDX-License-Identifier: Apache-2.0 -####################### -cmake_minimum_required(VERSION 3.15) +# ###################### +cmake_minimum_required(VERSION 3.14) vulkan_compile_shader(INFILE test_logistic_regression_shader.comp - OUTFILE test_logistic_regression_shader.hpp - NAMESPACE "kp") + 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") + OUTFILE test_op_custom_shader.hpp + NAMESPACE "kp") vulkan_compile_shader(INFILE test_workgroup_shader.comp - OUTFILE test_workgroup_shader.hpp - NAMESPACE "kp") + OUTFILE test_workgroup_shader.hpp + NAMESPACE "kp") vulkan_compile_shader(INFILE test_shader.comp - OUTFILE test_shader.hpp - NAMESPACE "kp") + OUTFILE test_shader.hpp + NAMESPACE "kp") add_library(test_shaders_glsl INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/test_logistic_regression_shader.hpp" - "${CMAKE_CURRENT_BINARY_DIR}/test_op_custom_shader.hpp" - "${CMAKE_CURRENT_BINARY_DIR}/test_workgroup_shader.hpp" - "${CMAKE_CURRENT_BINARY_DIR}/test_shader.hpp") + "${CMAKE_CURRENT_BINARY_DIR}/test_op_custom_shader.hpp" + "${CMAKE_CURRENT_BINARY_DIR}/test_workgroup_shader.hpp" + "${CMAKE_CURRENT_BINARY_DIR}/test_shader.hpp") target_include_directories(test_shaders_glsl INTERFACE $) From 0b305517f79766cbb9aab12660111d4a4a2d3317 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Mon, 11 Jul 2022 14:38:10 +0200 Subject: [PATCH 058/107] Removed old comments Signed-off-by: Fabian Sauter --- examples/array_multiplication/shader/CMakeLists.txt | 5 ----- examples/logistic_regression/shader/CMakeLists.txt | 5 ----- 2 files changed, 10 deletions(-) diff --git a/examples/array_multiplication/shader/CMakeLists.txt b/examples/array_multiplication/shader/CMakeLists.txt index fdf5eee2c..c403373ad 100644 --- a/examples/array_multiplication/shader/CMakeLists.txt +++ b/examples/array_multiplication/shader/CMakeLists.txt @@ -6,11 +6,6 @@ vulkan_compile_shader(INFILE my_shader.comp NAMESPACE "shader" RELATIVE_PATH "${kompute_SOURCE_DIR}/cmake") -# vulkan_compile_shader(INFILE my_shader2.comp -# OUTFILE my_shader2.hpp -# NAMESPACE "shader" -# RELATIVE_PATH "${kompute_SOURCE_DIR}/cmake") - # Then add it to the library, so you can access it later in your code add_library(shader INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/my_shader.hpp" diff --git a/examples/logistic_regression/shader/CMakeLists.txt b/examples/logistic_regression/shader/CMakeLists.txt index fdf5eee2c..c403373ad 100644 --- a/examples/logistic_regression/shader/CMakeLists.txt +++ b/examples/logistic_regression/shader/CMakeLists.txt @@ -6,11 +6,6 @@ vulkan_compile_shader(INFILE my_shader.comp NAMESPACE "shader" RELATIVE_PATH "${kompute_SOURCE_DIR}/cmake") -# vulkan_compile_shader(INFILE my_shader2.comp -# OUTFILE my_shader2.hpp -# NAMESPACE "shader" -# RELATIVE_PATH "${kompute_SOURCE_DIR}/cmake") - # Then add it to the library, so you can access it later in your code add_library(shader INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/my_shader.hpp" From 6f0916d32545a2ea27086a795eee9a56416d95c3 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Mon, 11 Jul 2022 14:51:08 +0200 Subject: [PATCH 059/107] Removed CPR code Signed-off-by: Fabian Sauter --- src/CMakeLists.txt | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index aec0df052..421b12480 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -29,35 +29,21 @@ set_target_properties(kompute # Import GNU common install directory variables include(GNUInstallDirs) -if(CPR_FORCE_USE_SYSTEM_CURL) - install(TARGETS kompute - EXPORT komputeTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) +install(TARGETS kompute + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) - # Include CMake helpers for package config files - # Follow this installation guideline: https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html - include(CMakePackageConfigHelpers) +# Include CMake helpers for package config files +# Follow this installation guideline: https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html +include(CMakePackageConfigHelpers) - configure_package_config_file(${PROJECT_SOURCE_DIR}/cmake/komputeConfig.cmake.in - "${PROJECT_BINARY_DIR}/kompute/komputeConfig.cmake" - INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kompute) +configure_package_config_file(${PROJECT_SOURCE_DIR}/cmake/komputeConfig.cmake.in + "${PROJECT_BINARY_DIR}/kompute/komputeConfig.cmake" + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kompute) - install(EXPORT komputeTargets - FILE komputeTargets.cmake - NAMESPACE kompute:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kompute) - - install(FILES ${PROJECT_BINARY_DIR}/kompute/komputeConfig.cmake - ${PROJECT_BINARY_DIR}/kompute/komputeConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kompute) - -else() - install(TARGETS kompute - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) -endif() +install(FILES ${PROJECT_BINARY_DIR}/kompute/komputeConfig.cmake + ${PROJECT_BINARY_DIR}/kompute/komputeConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kompute) # #################################################### # Android From 7bdde2e6f16ed07f10ef81a5f520d235de6f5ffc Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Tue, 12 Jul 2022 09:39:14 +0200 Subject: [PATCH 060/107] Updated the log level documentation Signed-off-by: Fabian Sauter --- CMakeLists.txt | 2 +- docs/overview/build-system.rst | 2 +- src/logger/CMakeLists.txt | 10 ++++------ 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c69ea1f9..5a6dd6edf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,7 +82,7 @@ kompute_option(KOMPUTE_OPT_INSTALL "Enable if you want to enable installation." # Build options kompute_option(KOMPUTE_OPT_BUILD_PYTHON "Enable if you want to build python bindings." OFF) -kompute_log_level(KOMPUTE_OPT_LOG_LEVEL "Internally we use spdlog for logging. The log level used can be changed here." "Default") +kompute_log_level(KOMPUTE_OPT_LOG_LEVEL "Internally we use spdlog for logging. The log level used can be changed here. Possible values: 'Trace', 'Debug', 'Info', 'Warn', 'Error', 'Critical', 'Off', 'Default'. If set to 'Off' spdlog will be deactivated completely. If set to 'Default', the log level will be set to 'Info' for release builds and 'Debug' else." "Default") kompute_option(KOMPUTE_OPT_ANDROID_BUILD "Enable android compilation flags required." OFF) kompute_option(KOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS "Explicitly disable debug layers even on debug." OFF) kompute_option(KOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK "Whether to check if your driver supports the Vulkan Header version you are linking against. This might be useful in case you build shared on a different system than you run later." OFF) diff --git a/docs/overview/build-system.rst b/docs/overview/build-system.rst index db652372f..370510115 100644 --- a/docs/overview/build-system.rst +++ b/docs/overview/build-system.rst @@ -37,7 +37,7 @@ This by default configures without any of the extra build tasks (such as buildin * - -DKOMPUTE_OPT_BUILD_PYTHON=ON - Enable if you want to build python bindings. * - -DKOMPUTE_OPT_LOG_LEVEL="Trace" - - Internally we use spdlog for logging. The log level used can be changed here. + - Internally we use spdlog for logging. The log level used can be changed here. Possible values: 'Trace', 'Debug', 'Info', 'Warn', 'Error', 'Critical', 'Off', 'Default'. If set to 'Off' spdlog will be deactivated completely. If set to 'Default', the log level will be set to 'Info' for release builds and 'Debug' else. * - -DKOMPUTE_OPT_ANDROID_BUILD=ON - Enable android compilation flags required. * - -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=ON diff --git a/src/logger/CMakeLists.txt b/src/logger/CMakeLists.txt index 86b954794..0f54ef670 100644 --- a/src/logger/CMakeLists.txt +++ b/src/logger/CMakeLists.txt @@ -23,16 +23,14 @@ elseif(${KOMPUTE_OPT_LOG_LEVEL} STREQUAL "Error") elseif(${KOMPUTE_OPT_LOG_LEVEL} STREQUAL "Critical") set(KOMPUTE_OPT_LOG_LEVEL CRITICAL) message(STATUS "Using log level Critical") -elseif(${KOMPUTE_OPT_LOG_LEVEL} STREQUAL Off) +elseif(${KOMPUTE_OPT_LOG_LEVEL} STREQUAL "Off") set(KOMPUTE_OPT_LOG_LEVEL OFF) message(STATUS "Using log level Off") -else() - if((NOT ${KOMPUTE_OPT_LOG_LEVEL} STREQUAL Default) AND(NOT KOMPUTE_OPT_LOG_LEVEL STREQUAL "")) - message(WARNING "Log level '${KOMPUTE_OPT_LOG_LEVEL}' unknown, use -DKOMPUTE_OPT_LOG_LEVEL=[Trace, Debug, Info, Warn, Error, Critical, Off]") - endif() - +elseif(${KOMPUTE_OPT_LOG_LEVEL} STREQUAL "Default") set(KOMPUTE_OPT_LOG_LEVEL $,DEBUG,INFO>) message(STATUS "Setting KOMPUTE_OPT_LOG_LEVEL to according to build type") +else() + message(FATAL_ERROR "Log level '${KOMPUTE_OPT_LOG_LEVEL}' unknown, use -DKOMPUTE_OPT_LOG_LEVEL={Trace, Debug, Info, Warn, Error, Critical, Off, Default} to set it to a correct value.") endif() target_compile_definitions(kp_logger INTERFACE SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${KOMPUTE_OPT_LOG_LEVEL}) From cf721cc21a7f7606a25b8bb9aea6669cba106cba Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Tue, 12 Jul 2022 10:32:11 +0200 Subject: [PATCH 061/107] Option to disable logging completely. Signed-off-by: Fabian Sauter --- CMakeLists.txt | 26 ++++++++++++++++--------- src/Manager.cpp | 8 ++++++-- src/include/kompute/Algorithm.hpp | 1 + src/include/kompute/logger/Logger.hpp | 10 ++++++++++ src/logger/CMakeLists.txt | 5 ++++- src/logger/Logger.cpp | 9 ++++++--- test/TestAsyncOperations.cpp | 6 +++--- test/TestDestroy.cpp | 6 +++--- test/TestLogisticRegression.cpp | 6 +++--- test/TestManager.cpp | 6 +++--- test/TestMultipleAlgoExecutions.cpp | 6 +++--- test/TestOpShadersFromStringAndFile.cpp | 6 +++--- test/TestOpTensorCopy.cpp | 6 +++--- test/TestOpTensorCreate.cpp | 6 +++--- test/TestOpTensorSync.cpp | 6 +++--- test/TestPushConstant.cpp | 6 +++--- test/TestSequence.cpp | 6 +++--- test/TestSpecializationConstant.cpp | 6 +++--- test/TestTensor.cpp | 6 +++--- test/TestWorkgroup.cpp | 6 +++--- 20 files changed, 86 insertions(+), 57 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a6dd6edf..48153e102 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,7 +42,7 @@ endmacro() macro(kompute_log_level OPTION_NAME OPTION_TEXT OPTION_DEFAULT) set(${OPTION_NAME} ${OPTION_DEFAULT} CACHE STRING ${OPTION_TEXT}) - set_property(CACHE ${OPTION_NAME} PROPERTY STRINGS "Trace" "Debug" "Info" "Warn" "Error" "Critical") + set_property(CACHE ${OPTION_NAME} PROPERTY STRINGS "Trace" "Debug" "Info" "Warn" "Error" "Critical" "Default" "Off") if(DEFINED ENV{${OPTION_NAME}}) # Allow setting the option through an environment variable @@ -53,6 +53,12 @@ macro(kompute_log_level OPTION_NAME OPTION_TEXT OPTION_DEFAULT) add_definitions(-D${OPTION_NAME}) endif() + # Allow disabling logging completely and prevent linking against it: + if(${KOMPUTE_OPT_LOG_LEVEL} STREQUAL "Off") + set(${OPTION_NAME}_DISABLED ON) + add_compile_definitions(${OPTION_NAME}_DISABLED=1) + endif() + message(STATUS " ${OPTION_NAME}: ${${OPTION_NAME}}") endmacro() @@ -132,15 +138,17 @@ else() endif() # Spdlog -if(KOMPUTE_OPT_USE_BUILD_IN_SPDLOG) - set(SPDLOG_INSTALL ${KOMPUTE_OPT_INSTALL}) - set(SPDLOG_BUILD_SHARED ${KOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS}) +if(NOT KOMPUTE_OPT_LOG_LEVEL_DISABLED) + if(KOMPUTE_OPT_USE_BUILD_IN_SPDLOG) + set(SPDLOG_INSTALL ${KOMPUTE_OPT_INSTALL}) + set(SPDLOG_BUILD_SHARED ${KOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS}) - FetchContent_Declare(spdlog GIT_REPOSITORY https://github.com/gabime/spdlog.git - GIT_TAG v1.10.0) # Source: https://github.com/gabime/spdlog/releases - FetchContent_MakeAvailable(spdlog) -else() - find_package(spdlog REQUIRED) + FetchContent_Declare(spdlog GIT_REPOSITORY https://github.com/gabime/spdlog.git + GIT_TAG v1.10.0) # Source: https://github.com/gabime/spdlog/releases + FetchContent_MakeAvailable(spdlog) + else() + find_package(spdlog REQUIRED) + endif() endif() # fmt diff --git a/src/Manager.cpp b/src/Manager.cpp index fdfc0e969..d50704228 100644 --- a/src/Manager.cpp +++ b/src/Manager.cpp @@ -40,8 +40,10 @@ Manager::Manager(uint32_t physicalDeviceIndex, { this->mManageResources = true; - // Make sure the logger is setup +// Make sure the logger is setup +#if !KOMPUTE_OPT_LOG_LEVEL_DISABLED logger::setupLogger(); +#endif this->createInstance(); this->createDevice( @@ -58,8 +60,10 @@ Manager::Manager(std::shared_ptr instance, this->mPhysicalDevice = physicalDevice; this->mDevice = device; - // Make sure the logger is setup +// Make sure the logger is setup +#if !KOMPUTE_OPT_LOG_LEVEL_DISABLED logger::setupLogger(); +#endif } Manager::~Manager() diff --git a/src/include/kompute/Algorithm.hpp b/src/include/kompute/Algorithm.hpp index 804a70900..1917dd37a 100644 --- a/src/include/kompute/Algorithm.hpp +++ b/src/include/kompute/Algorithm.hpp @@ -3,6 +3,7 @@ #include "kompute/Core.hpp" +#include "fmt/format.h" #include "kompute/Tensor.hpp" #include "logger/Logger.hpp" diff --git a/src/include/kompute/logger/Logger.hpp b/src/include/kompute/logger/Logger.hpp index 92b2872c5..f24ad3a80 100644 --- a/src/include/kompute/logger/Logger.hpp +++ b/src/include/kompute/logger/Logger.hpp @@ -1,5 +1,13 @@ #pragma once +#if KOMPUTE_OPT_LOG_LEVEL_DISABLED +#define KP_LOG_TRACE(...) +#define KP_LOG_DEBUG(...) +#define KP_LOG_INFO(...) +#define KP_LOG_WARN(...) +#define KP_LOG_ERROR(...) +#else + #include #include #include @@ -34,3 +42,5 @@ vecToString(const std::vector& vec); std::string vecToString(const std::vector& vec); } // namespace logger + +#endif \ No newline at end of file diff --git a/src/logger/CMakeLists.txt b/src/logger/CMakeLists.txt index 0f54ef670..6132c1d21 100644 --- a/src/logger/CMakeLists.txt +++ b/src/logger/CMakeLists.txt @@ -3,7 +3,10 @@ cmake_minimum_required(VERSION 3.14) set(LOGGER_SOURCES Logger.cpp) add_library(kp_logger ${LOGGER_SOURCES}) -target_link_libraries(kp_logger PUBLIC spdlog::spdlog) + +if(NOT KOMPUTE_OPT_LOG_LEVEL_DISABLED) + target_link_libraries(kp_logger PUBLIC spdlog::spdlog) +endif() if(${KOMPUTE_OPT_LOG_LEVEL} STREQUAL "Trace") set(KOMPUTE_OPT_LOG_LEVEL TRACE) diff --git a/src/logger/Logger.cpp b/src/logger/Logger.cpp index c82a882b6..bb02023a2 100644 --- a/src/logger/Logger.cpp +++ b/src/logger/Logger.cpp @@ -1,9 +1,10 @@ #include "kompute/logger/Logger.hpp" +#if KOMPUTE_OPT_LOG_LEVEL_DISABLED +#else #include #include #include -#include #include #include #include @@ -11,13 +12,14 @@ #include #include #include +#include #include #include #ifdef _WIN32 -#include #include +#include #endif // _WIN32 namespace logger { @@ -56,7 +58,7 @@ createDir(const std::string& path) #if defined(_WIN32) nError = _mkdir(path.c_str()); // can be used on Windows #else - mode_t nMode = 0733; // UNIX style permissions + mode_t nMode = 0733; // UNIX style permissions nError = mkdir(path.c_str(), nMode); // can be used on non-Windows #endif if (nError != 0) { @@ -192,3 +194,4 @@ vecToString(const std::vector& vec) return result.substr(0, result.size() - 2); // Remove the tailing ", " } } // namespace logger +#endif diff --git a/test/TestAsyncOperations.cpp b/test/TestAsyncOperations.cpp index a1c8de852..91a8fab1b 100644 --- a/test/TestAsyncOperations.cpp +++ b/test/TestAsyncOperations.cpp @@ -5,6 +5,7 @@ #include #include "kompute/Kompute.hpp" +#include "kompute/logger/Logger.hpp" #include "shaders/Utils.hpp" TEST(TestAsyncOperations, TestManagerParallelExecution) @@ -264,9 +265,8 @@ main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); -#if KOMPUTE_ENABLE_SPDLOG - spdlog::set_level( - static_cast(KOMPUTE_LOG_LEVEL)); +#if !KOMPUTE_OPT_LOG_LEVEL_DISABLED + logger::setupLogger(); #endif return RUN_ALL_TESTS(); diff --git a/test/TestDestroy.cpp b/test/TestDestroy.cpp index 6a4fdb345..c58557bc7 100644 --- a/test/TestDestroy.cpp +++ b/test/TestDestroy.cpp @@ -3,6 +3,7 @@ #include "gtest/gtest.h" #include "kompute/Kompute.hpp" +#include "kompute/logger/Logger.hpp" #include "shaders/Utils.hpp" @@ -145,9 +146,8 @@ main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); -#if KOMPUTE_ENABLE_SPDLOG - spdlog::set_level( - static_cast(KOMPUTE_LOG_LEVEL)); +#if !KOMPUTE_OPT_LOG_LEVEL_DISABLED + logger::setupLogger(); #endif return RUN_ALL_TESTS(); diff --git a/test/TestLogisticRegression.cpp b/test/TestLogisticRegression.cpp index 2ac52e31c..072463a18 100644 --- a/test/TestLogisticRegression.cpp +++ b/test/TestLogisticRegression.cpp @@ -3,6 +3,7 @@ #include "gtest/gtest.h" #include "kompute/Kompute.hpp" +#include "kompute/logger/Logger.hpp" #include "test_logistic_regression_shader.hpp" @@ -162,9 +163,8 @@ main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); -#if KOMPUTE_ENABLE_SPDLOG - spdlog::set_level( - static_cast(KOMPUTE_LOG_LEVEL)); +#if !KOMPUTE_OPT_LOG_LEVEL_DISABLED + logger::setupLogger(); #endif return RUN_ALL_TESTS(); diff --git a/test/TestManager.cpp b/test/TestManager.cpp index ca787a066..5b78d5c7f 100644 --- a/test/TestManager.cpp +++ b/test/TestManager.cpp @@ -3,6 +3,7 @@ #include "gtest/gtest.h" #include "kompute/Kompute.hpp" +#include "kompute/logger/Logger.hpp" TEST(TestManager, EndToEndOpMultEvalFlow) { @@ -111,9 +112,8 @@ main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); -#if KOMPUTE_ENABLE_SPDLOG - spdlog::set_level( - static_cast(KOMPUTE_LOG_LEVEL)); +#if !KOMPUTE_OPT_LOG_LEVEL_DISABLED + logger::setupLogger(); #endif return RUN_ALL_TESTS(); diff --git a/test/TestMultipleAlgoExecutions.cpp b/test/TestMultipleAlgoExecutions.cpp index 0311fcb21..75547b86c 100644 --- a/test/TestMultipleAlgoExecutions.cpp +++ b/test/TestMultipleAlgoExecutions.cpp @@ -3,6 +3,7 @@ #include "gtest/gtest.h" #include "kompute/Kompute.hpp" +#include "kompute/logger/Logger.hpp" #include "shaders/Utils.hpp" @@ -276,9 +277,8 @@ main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); -#if KOMPUTE_ENABLE_SPDLOG - spdlog::set_level( - static_cast(KOMPUTE_LOG_LEVEL)); +#if !KOMPUTE_OPT_LOG_LEVEL_DISABLED + logger::setupLogger(); #endif return RUN_ALL_TESTS(); diff --git a/test/TestOpShadersFromStringAndFile.cpp b/test/TestOpShadersFromStringAndFile.cpp index ea1a924de..12948d780 100644 --- a/test/TestOpShadersFromStringAndFile.cpp +++ b/test/TestOpShadersFromStringAndFile.cpp @@ -3,6 +3,7 @@ #include "gtest/gtest.h" #include "kompute/Kompute.hpp" +#include "kompute/logger/Logger.hpp" #include "shaders/Utils.hpp" #include "test_op_custom_shader.hpp" @@ -113,9 +114,8 @@ main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); -#if KOMPUTE_ENABLE_SPDLOG - spdlog::set_level( - static_cast(KOMPUTE_LOG_LEVEL)); +#if !KOMPUTE_OPT_LOG_LEVEL_DISABLED + logger::setupLogger(); #endif return RUN_ALL_TESTS(); diff --git a/test/TestOpTensorCopy.cpp b/test/TestOpTensorCopy.cpp index 9cebee34c..2ebb50c2a 100644 --- a/test/TestOpTensorCopy.cpp +++ b/test/TestOpTensorCopy.cpp @@ -3,6 +3,7 @@ #include "gtest/gtest.h" #include "kompute/Kompute.hpp" +#include "kompute/logger/Logger.hpp" #include "shaders/Utils.hpp" @@ -162,9 +163,8 @@ main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); -#if KOMPUTE_ENABLE_SPDLOG - spdlog::set_level( - static_cast(KOMPUTE_LOG_LEVEL)); +#if !KOMPUTE_OPT_LOG_LEVEL_DISABLED + logger::setupLogger(); #endif return RUN_ALL_TESTS(); diff --git a/test/TestOpTensorCreate.cpp b/test/TestOpTensorCreate.cpp index 40133508f..ec725915a 100644 --- a/test/TestOpTensorCreate.cpp +++ b/test/TestOpTensorCreate.cpp @@ -3,6 +3,7 @@ #include "gtest/gtest.h" #include "kompute/Kompute.hpp" +#include "kompute/logger/Logger.hpp" TEST(TestOpTensorCreate, CreateSingleTensorSingleOp) { @@ -63,9 +64,8 @@ main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); -#if KOMPUTE_ENABLE_SPDLOG - spdlog::set_level( - static_cast(KOMPUTE_LOG_LEVEL)); +#if !KOMPUTE_OPT_LOG_LEVEL_DISABLED + logger::setupLogger(); #endif return RUN_ALL_TESTS(); diff --git a/test/TestOpTensorSync.cpp b/test/TestOpTensorSync.cpp index 7c9d6cf06..fa4f76932 100644 --- a/test/TestOpTensorSync.cpp +++ b/test/TestOpTensorSync.cpp @@ -3,6 +3,7 @@ #include "gtest/gtest.h" #include "kompute/Kompute.hpp" +#include "kompute/logger/Logger.hpp" TEST(TestOpTensorSync, SyncToDeviceMemorySingleTensor) { @@ -58,9 +59,8 @@ main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); -#if KOMPUTE_ENABLE_SPDLOG - spdlog::set_level( - static_cast(KOMPUTE_LOG_LEVEL)); +#if !KOMPUTE_OPT_LOG_LEVEL_DISABLED + logger::setupLogger(); #endif return RUN_ALL_TESTS(); diff --git a/test/TestPushConstant.cpp b/test/TestPushConstant.cpp index 777ac95ec..ec03bc08c 100644 --- a/test/TestPushConstant.cpp +++ b/test/TestPushConstant.cpp @@ -3,6 +3,7 @@ #include "gtest/gtest.h" #include "kompute/Kompute.hpp" +#include "kompute/logger/Logger.hpp" #include "shaders/Utils.hpp" @@ -395,9 +396,8 @@ main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); -#if KOMPUTE_ENABLE_SPDLOG - spdlog::set_level( - static_cast(KOMPUTE_LOG_LEVEL)); +#if !KOMPUTE_OPT_LOG_LEVEL_DISABLED + logger::setupLogger(); #endif return RUN_ALL_TESTS(); diff --git a/test/TestSequence.cpp b/test/TestSequence.cpp index 27c422450..5e5e3254c 100644 --- a/test/TestSequence.cpp +++ b/test/TestSequence.cpp @@ -3,6 +3,7 @@ #include "gtest/gtest.h" #include "kompute/Kompute.hpp" +#include "kompute/logger/Logger.hpp" #include "shaders/Utils.hpp" @@ -248,9 +249,8 @@ main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); -#if KOMPUTE_ENABLE_SPDLOG - spdlog::set_level( - static_cast(KOMPUTE_LOG_LEVEL)); +#if !KOMPUTE_OPT_LOG_LEVEL_DISABLED + logger::setupLogger(); #endif return RUN_ALL_TESTS(); diff --git a/test/TestSpecializationConstant.cpp b/test/TestSpecializationConstant.cpp index 1421aaa97..3140ba5b4 100644 --- a/test/TestSpecializationConstant.cpp +++ b/test/TestSpecializationConstant.cpp @@ -3,6 +3,7 @@ #include "gtest/gtest.h" #include "kompute/Kompute.hpp" +#include "kompute/logger/Logger.hpp" #include "shaders/Utils.hpp" @@ -107,9 +108,8 @@ main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); -#if KOMPUTE_ENABLE_SPDLOG - spdlog::set_level( - static_cast(KOMPUTE_LOG_LEVEL)); +#if !KOMPUTE_OPT_LOG_LEVEL_DISABLED + logger::setupLogger(); #endif return RUN_ALL_TESTS(); diff --git a/test/TestTensor.cpp b/test/TestTensor.cpp index dc358fc82..0a53220dd 100644 --- a/test/TestTensor.cpp +++ b/test/TestTensor.cpp @@ -3,6 +3,7 @@ #include "gtest/gtest.h" #include "kompute/Kompute.hpp" +#include "kompute/logger/Logger.hpp" TEST(TestTensor, ConstructorData) { @@ -49,9 +50,8 @@ main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); -#if KOMPUTE_ENABLE_SPDLOG - spdlog::set_level( - static_cast(KOMPUTE_LOG_LEVEL)); +#if !KOMPUTE_OPT_LOG_LEVEL_DISABLED + logger::setupLogger(); #endif return RUN_ALL_TESTS(); diff --git a/test/TestWorkgroup.cpp b/test/TestWorkgroup.cpp index bd87bbab3..a2e41865b 100644 --- a/test/TestWorkgroup.cpp +++ b/test/TestWorkgroup.cpp @@ -3,6 +3,7 @@ #include "gtest/gtest.h" #include "kompute/Kompute.hpp" +#include "kompute/logger/Logger.hpp" #include "test_workgroup_shader.hpp" @@ -68,9 +69,8 @@ main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); -#if KOMPUTE_ENABLE_SPDLOG - spdlog::set_level( - static_cast(KOMPUTE_LOG_LEVEL)); +#if !KOMPUTE_OPT_LOG_LEVEL_DISABLED + logger::setupLogger(); #endif return RUN_ALL_TESTS(); From bc31ee47824772731483b1fbf66c3d8c80f68d24 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Tue, 12 Jul 2022 12:35:25 +0200 Subject: [PATCH 062/107] Removed deprecated option for building shared libs Signed-off-by: Fabian Sauter --- CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 48153e102..e534f2ac9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -141,7 +141,7 @@ endif() if(NOT KOMPUTE_OPT_LOG_LEVEL_DISABLED) if(KOMPUTE_OPT_USE_BUILD_IN_SPDLOG) set(SPDLOG_INSTALL ${KOMPUTE_OPT_INSTALL}) - set(SPDLOG_BUILD_SHARED ${KOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS}) + set(SPDLOG_BUILD_SHARED ${BUILD_SHARED_LIBS}) FetchContent_Declare(spdlog GIT_REPOSITORY https://github.com/gabime/spdlog.git GIT_TAG v1.10.0) # Source: https://github.com/gabime/spdlog/releases @@ -154,11 +154,9 @@ endif() # fmt if(KOMPUTE_OPT_USE_BUILD_IN_FMT) set(FMT_INSTALL ${KOMPUTE_OPT_INSTALL}) - set(BUILD_SHARED_LIBS_BKP ${KOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS}) FetchContent_Declare(fmt GIT_REPOSITORY https://github.com/fmtlib/fmt.git GIT_TAG 8.1.1) # Source: https://github.com/fmtlib/fmt/releases FetchContent_MakeAvailable(fmt) - set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_BKP}) else() find_package(fmt REQUIRED) endif() From c85dd89200c40b37bdabf78e7a709e9ee6480f4b Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Tue, 12 Jul 2022 12:53:59 +0200 Subject: [PATCH 063/107] Potential fix for empty strings inside VULKAN_INFO_OUTPUT Signed-off-by: Fabian Sauter --- cmake/check_vulkan_version.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/check_vulkan_version.cmake b/cmake/check_vulkan_version.cmake index c12bee917..ec69c1044 100644 --- a/cmake/check_vulkan_version.cmake +++ b/cmake/check_vulkan_version.cmake @@ -58,7 +58,7 @@ function(check_vulkan_version) return() endif() - string(REGEX MATCHALL "(GPU[0-9]+)" GPU_IDS ${VULKAN_INFO_OUTPUT}) + string(REGEX MATCHALL "(GPU[0-9]+)" GPU_IDS "${VULKAN_INFO_OUTPUT}") if(NOT GPU_IDS) message(FATAL_ERROR "No GPU supporting Vulkan found in vulkaninfo. Does your GPU (driver) support Vulkan?") endif() From c7db29a6e5d12af204c3644c68c6c5891df16dda Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Tue, 12 Jul 2022 13:05:34 +0200 Subject: [PATCH 064/107] Added inline compilation of shaders again. Signed-off-by: Fabian Sauter --- docs/overview/shaders-to-headers.rst | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/overview/shaders-to-headers.rst b/docs/overview/shaders-to-headers.rst index 8f5517bc8..9b8419a13 100644 --- a/docs/overview/shaders-to-headers.rst +++ b/docs/overview/shaders-to-headers.rst @@ -3,6 +3,32 @@ Processing Shaders with Kompute =============================== +Demo / testing function to compile shaders +------------------------------------------ + +GLSLANG was initially integrated as part of the framework but it now has been removed due to the license of the glslang pre-processor being under a custom NVIDIA license which explicitly excludes grant of any licenses to NVIDIA's patents in the preprocessor. This is covered in more detail here: https://github.com/KomputeProject/kompute/pull/235 + +For users that are looking to quickly test the processors it is possible to use the function that is provided in the examples which provides a (non-thread-safe / non-robust) implementation that compiles a shader string into spirv bytes. It is not recommended to use in production but it does enable for faster iteration cycles during development. + +.. code-block:: cpp + :linenos: + + static + std::vector + compileSource( + const std::string& source) + { + std::ofstream fileOut("tmp_kp_shader.comp"); + fileOut << source; + fileOut.close(); + if (system(std::string("glslangValidator -V tmp_kp_shader.comp -o tmp_kp_shader.comp.spv").c_str())) + throw std::runtime_error("Error running glslangValidator command"); + std::ifstream fileStream("tmp_kp_shader.comp.spv", std::ios::binary); + std::vector buffer; + buffer.insert(buffer.begin(), std::istreambuf_iterator(fileStream), {}); + return {(uint32_t*)buffer.data(), (uint32_t*)(buffer.data() + buffer.size())}; + } + Converting Shaders into C / C++ Header Files -------------------------------------------- From d2ca970870e9a39e3acac01820000cf60324de56 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Tue, 12 Jul 2022 13:07:19 +0200 Subject: [PATCH 065/107] Ignoring header include order Signed-off-by: Fabian Sauter --- src/include/kompute/Tensor.hpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/include/kompute/Tensor.hpp b/src/include/kompute/Tensor.hpp index 948a55130..5d7524ee0 100644 --- a/src/include/kompute/Tensor.hpp +++ b/src/include/kompute/Tensor.hpp @@ -1,11 +1,9 @@ // SPDX-License-Identifier: Apache-2.0 #pragma once -#include - #include "kompute/Core.hpp" - #include "logger/Logger.hpp" +#include namespace kp { From bd3ed04be8a6a14b7c9265c79163b1a4eb4eae7a Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Tue, 12 Jul 2022 14:27:30 +0200 Subject: [PATCH 066/107] Option to either use precompiled shaders or compile them on build Signed-off-by: Fabian Sauter --- CMakeLists.txt | 1 + cmake/deprecation_warnings.cmake | 4 - shaders/glsl/logisticregression.comp.spv | Bin 4816 -> 0 bytes shaders/glsl/opmult.comp.spv | Bin 1464 -> 0 bytes src/CMakeLists.txt | 3 + src/include/CMakeLists.txt | 3 - src/include/kompute/Kompute.hpp | 4 +- src/include/kompute/operations/OpMult.hpp | 16 +- .../shaders/shaderlogisticregression.hpp | 433 ------------------ src/include/kompute/shaders/shaderopmult.hpp | 153 ------- src/shaders/CMakeLists.txt | 5 + src/shaders/glsl/CMakeLists.txt | 26 ++ .../glsl/ShaderLogisticRegression.comp | 0 .../glsl/ShaderLogisticRegression.hpp.in | 310 +++++++++++++ .../shaders/glsl/ShaderOpMult.comp | 0 src/shaders/glsl/ShaderOpMult.hpp.in | 101 ++++ .../shaders}/hlsl/computeheadless.comp | 0 17 files changed, 454 insertions(+), 605 deletions(-) delete mode 100755 shaders/glsl/logisticregression.comp.spv delete mode 100755 shaders/glsl/opmult.comp.spv delete mode 100755 src/include/kompute/shaders/shaderlogisticregression.hpp delete mode 100755 src/include/kompute/shaders/shaderopmult.hpp create mode 100644 src/shaders/CMakeLists.txt create mode 100644 src/shaders/glsl/CMakeLists.txt rename shaders/glsl/logisticregression.comp => src/shaders/glsl/ShaderLogisticRegression.comp (100%) create mode 100644 src/shaders/glsl/ShaderLogisticRegression.hpp.in rename shaders/glsl/opmult.comp => src/shaders/glsl/ShaderOpMult.comp (100%) create mode 100644 src/shaders/glsl/ShaderOpMult.hpp.in rename {shaders => src/shaders}/hlsl/computeheadless.comp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index e534f2ac9..35533b326 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -92,6 +92,7 @@ kompute_log_level(KOMPUTE_OPT_LOG_LEVEL "Internally we use spdlog for logging. T kompute_option(KOMPUTE_OPT_ANDROID_BUILD "Enable android compilation flags required." OFF) kompute_option(KOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS "Explicitly disable debug layers even on debug." OFF) kompute_option(KOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK "Whether to check if your driver supports the Vulkan Header version you are linking against. This might be useful in case you build shared on a different system than you run later." OFF) +kompute_option(KOMPUTE_OPT_BUILD_SHADERS "Rebuilds all compute shaders during compilation and does not use the already precompiled versions. Requires glslangValidator to be installed on your system." OFF) # External components kompute_option(KOMPUTE_OPT_USE_BUILD_IN_SPDLOG "Use the built-in version of Spdlog." ON) diff --git a/cmake/deprecation_warnings.cmake b/cmake/deprecation_warnings.cmake index 1a325e639..9d6337376 100644 --- a/cmake/deprecation_warnings.cmake +++ b/cmake/deprecation_warnings.cmake @@ -2,10 +2,6 @@ if(KOMPUTE_OPT_REPO_SUBMODULE_BUILD) message(FATAL_ERROR "'KOMPUTE_OPT_REPO_SUBMODULE_BUILD' got replaced by 'KOMPUTE_OPT_USE_BUILD_IN_SPDLOG', 'KOMPUTE_OPT_USE_BUILD_IN_FMT', 'KOMPUTE_OPT_USE_BUILD_IN_GOOGLE_TEST', 'KOMPUTE_OPT_USE_BUILD_IN_PYBIND11' and 'KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER'. Please use them instead.") endif() -if(KOMPUTE_OPT_BUILD_SHADERS) - message(FATAL_ERROR "'KOMPUTE_OPT_BUILD_SHADERS' is deprecated and should not be used. Instead use the default 'BUILD_SHARED_LIBS' CMake switch.") -endif() - if(KOMPUTE_OPT_BUILD_AS_SHARED_LIB) message(FATAL_ERROR "'KOMPUTE_OPT_BUILD_AS_SHARED_LIB' is deprecated and should not be used. Instead use the default 'BUILD_SHARED_LIBS' CMake switch.") endif() diff --git a/shaders/glsl/logisticregression.comp.spv b/shaders/glsl/logisticregression.comp.spv deleted file mode 100755 index 2f6883dac6c1f40a2928ccf8e8b37c6fa6d68ac1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4816 zcmZ9P_jgrA6on^wFNzQlR6uNthy}|+#eyt~2GD@U-UZ8hDHsijCV>PSQ3NaY-W3)5 zAK_o+FS`7`d*_&0xoe$u_TF>Op1E^pUZByr=H!$*(!#VL{h8`#S?WYdX;C_<%63I7YBi;A+Z3uPf= zlOucgjgJhj9lmN4N+X?u_AJrG8c!pSj13P>42=y8tvxWjev@IP;|*66_g(bm*Z|M=vjGu0M&G}Cg%5AJMDkt)v>@{D`P^;(+gV)g&)nrSWk z>DEMRU#{Is9vPge*4+!+(*gY2WwjO?gr2N-`hx!ST{3LeLb-cwCa1T zrWGCpw`ZQL>cl?KYHYZsmH$)VgN46)(`GY$C$UfL?RZVAzDf0BZ~Yi^d)rJ0=5fFI z+;}5B2OoU6Ue6)%12vun$M-p^zD>QE-UPR&$M;Y1uAXSQPnJ*`=~yjQ^&fz%dfwT3 zxsUZoRsBbmQu}`iZnqgETQB#?QdR$TErFZqxMQPp^>UvqRrNpCQdNHfJoo<1^h?3} z@bmmFBF-V?edLn}@83=w;(V=v`}Fa?YTk6~J#Xg|KEb^UF@7Jo^ouiB`l&^|XR!2> z>!*kQdoqso#aS%<)WXlRS^CNK^U-gBT&^$9Z0V;Ke#79>Pp)4Fq2DOE^oz4x`l*GV zXS?*1>(@!>H%r#rNB#!6^pEpc`m2S%XS4K|>+k;Q_ddDwi}PCgsfC|sxAc?i=Wo4! zUyw_`IM1b@TKIXkOFy}O{PC&$z9*M{$KgJupIZ2N_DesxehUcK_XpYYzKS@VUG60J z&~3kX1<3hUSJAB2;ab#s=+{TAwi4c*xxK65i}RRz50y*uxO$BBuv=$jT_58zdi8Z( zDb3!n9KIQ}TFRsM7P7VK&V571uHEq)$sL6Hrp$Y@roVmL2p{XWldV@jm-p@?yN2_? z-f_8gyU4zun!a-Hy_)O1mAsnJ%X#Gegpd8Vk*(D`#_t4M@4WFF;k^D9$nE2&x$0AM zUb(*qdfB&!9P9PY%k6uVY>k?Ia_@cg4S=K1yDhhGDA%ajCm+t5^TpkEo%_(`_W6$+ zz18fKdym!D!<}oE@X;skus+^Zxjt`^?NQT5ek^PD#a*?}J1MvC!(5|gpWJ(?SA6$R zz#W7>aYyy}5>2kpS7dwC^pSfX)$IG89Q$@0EVu6mvNdY<$-Q@Km($^S{DW`}5!Z1C z9B&dn4dQQVE=7Ou=TX4sB7u@lu=JCmbTR%0AA1Ju}{@WquH$PW! z`wtb|@uTzjiFw?=z1H>emfOiYDqP>mExhAq_)S^g%8vN{@?Q4vHuCL+_pU#OJ${cn z2*;xCE^yR&&!X;buw!>Je>eFa!d`XfbAQ#s=OM87ZT@`x^C>xIkKaHZ>wmn`=R8_) z@17oy6S0;y*sTc!wv!da1h}&wyI^K3(Z^zR$qDoBBEy zz7t@_^zhus9qT6VC-im9Gb4|&X|Vg|nCC|xo(IA1k7J%C`9@BF-^~9joJQzppX1hf zMjZ=}=fP^hUjVzl!+b-1UL>qhx8F0W_F5i)3A~D!C1TAlgMFX3^Eo&SRtO5D^*Bmab576x+m-IO>Z_YQvj4eY&xqr3ZqCb^WB)Rbyj+ua#AgZNn*7~8wZKa=cCE_@*LphHzZq&h zggN-d^Z44#eYbA#`GlUq*MObx!~6~xfUQxF{kRb9-0_|lfvr>bTe$|csJ{fP=9u%# zH)j7!!F~sI$6c>l^j-#5bFakZUitlf&LHCZEidp2u={f+IsDdv)q`IFwkN*jm0-W6 z-^{VN%U6Nzbv%04gY}BvrmMkzZ}q6T2CRS7Tnn~FJ?6X)9CJDzb8Z0Z>3Hn*^)tTLanabN{r}AAaog z4+rPNPn~gZI5>Qh#p~%ZcHA9|hTo4S<8PBOkdtRJUjMw)pL9q6V>QmdVgRY}xrWW_ z+h0cbbv|-RUYqmQ-N@;zu8E)59sjG7Q}Vi;w{AP9shds@@Y`?Sowg57GW@W>#|7Rg z@X?3&sYSl;S8t+X=UGRc+W{SXzY=G(I8V+EneSV-P$jVUbO++A*mA#kd%2%n^m7K~ ze&Tqy{TkqMzlfFl$wfc;azC;03Ti*+rLTycmpJ0iOF!Q82;X^m=M`A_CZ~Cx{wh7Z zUjtPdV159Z%CCbjVD+srK8N)T`IiOu47nY!xffBz{7YD4@@sTi%J`Hv@ZFzy6W=|F zty#f(KRM43ySupaDt-gCuV;$aP{qFPG5Y#;v3;*&?ICAhu{)D9zESwr+NXhyK23bF zd0SX(1&-s4a-|xEOK7Paaf8!n8 zoBtQueOTwdfVvy^@v6AjV!^+rgZbi!t>eoD_ID=U=T6RM6LntB+L(FH=N4)#>Tctg q>+XP^k9EeP?k>KupWN3z_fUJu$C>x>-MzKm&wI<6`-h3WK>q?HWK!?| diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 421b12480..eebe6104c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -67,10 +67,12 @@ if(KOMPUTE_OPT_ANDROID_BUILD) target_link_libraries(kompute PUBLIC kompute_vk_ndk_wrapper android kp_logger + kp_shader PRIVATE fmt::fmt) else() target_link_libraries(kompute PUBLIC Vulkan::Vulkan kp_logger + kp_shader PRIVATE fmt::fmt) endif() @@ -88,4 +90,5 @@ endif() # Misc # #################################################### add_subdirectory(logger) +add_subdirectory(shaders) add_subdirectory(include) diff --git a/src/include/CMakeLists.txt b/src/include/CMakeLists.txt index 099113813..350313eb5 100644 --- a/src/include/CMakeLists.txt +++ b/src/include/CMakeLists.txt @@ -24,9 +24,6 @@ target_sources(kompute PRIVATE kompute/operations/OpTensorSyncDevice.hpp kompute/operations/OpTensorSyncLocal.hpp - kompute/shaders/shaderlogisticregression.hpp - kompute/shaders/shaderopmult.hpp - kompute/logger/Logger.hpp ) diff --git a/src/include/kompute/Kompute.hpp b/src/include/kompute/Kompute.hpp index c5663ab74..2413dd139 100644 --- a/src/include/kompute/Kompute.hpp +++ b/src/include/kompute/Kompute.hpp @@ -14,5 +14,5 @@ #include "operations/OpTensorSyncDevice.hpp" #include "operations/OpTensorSyncLocal.hpp" -#include "shaders/shaderlogisticregression.hpp" -#include "shaders/shaderopmult.hpp" +#include "ShaderLogisticRegression.hpp" +#include "ShaderOpMult.hpp" diff --git a/src/include/kompute/operations/OpMult.hpp b/src/include/kompute/operations/OpMult.hpp index d148087c7..f75ccc4fb 100644 --- a/src/include/kompute/operations/OpMult.hpp +++ b/src/include/kompute/operations/OpMult.hpp @@ -5,7 +5,7 @@ #include "kompute/Core.hpp" -#include "kompute/shaders/shaderopmult.hpp" +#include "ShaderOpMult.hpp" #include "kompute/Algorithm.hpp" #include "kompute/Tensor.hpp" @@ -38,13 +38,12 @@ class OpMult : public OpAlgoDispatch if (tensors.size() != 3) { throw std::runtime_error( - "Kompute OpMult expected 3 tensors but got " + tensors.size()); + "Kompute OpMult expected 3 tensors but got " + + std::to_string(tensors.size())); } - std::vector spirv( - (uint32_t*)shader_data::shaders_glsl_opmult_comp_spv, - (uint32_t*)(shader_data::shaders_glsl_opmult_comp_spv + - kp::shader_data::shaders_glsl_opmult_comp_spv_len)); + const std::vector spirv = std::vector( + SHADEROPMULT_COMP_SPV.begin(), SHADEROPMULT_COMP_SPV.end()); algorithm->rebuild<>(tensors, spirv); } @@ -53,10 +52,7 @@ class OpMult : public OpAlgoDispatch * Default destructor, which is in charge of destroying the algorithm * components but does not destroy the underlying tensors */ - virtual ~OpMult() override - { - KP_LOG_DEBUG("Kompute OpMult destructor started"); - } + ~OpMult() override { KP_LOG_DEBUG("Kompute OpMult destructor started"); } }; } // End namespace kp diff --git a/src/include/kompute/shaders/shaderlogisticregression.hpp b/src/include/kompute/shaders/shaderlogisticregression.hpp deleted file mode 100755 index f456ac1cf..000000000 --- a/src/include/kompute/shaders/shaderlogisticregression.hpp +++ /dev/null @@ -1,433 +0,0 @@ -/* - THIS FILE HAS BEEN AUTOMATICALLY GENERATED - DO NOT EDIT - - --- - - Copyright 2020 The Institute for Ethical AI & Machine Learning - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#ifndef SHADEROP_SHADERLOGISTICREGRESSION_HPP -#define SHADEROP_SHADERLOGISTICREGRESSION_HPP - -namespace kp { -namespace shader_data { -static const unsigned char shaders_glsl_logisticregression_comp_spv[] = { - 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x0a, 0x00, 0x08, 0x00, - 0xae, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, - 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x06, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x00, 0x00, 0x10, 0x00, 0x06, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x11, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x02, 0x00, 0x00, 0x00, - 0xc2, 0x01, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, - 0x0a, 0x00, 0x00, 0x00, 0x73, 0x69, 0x67, 0x6d, 0x6f, 0x69, 0x64, 0x28, - 0x66, 0x31, 0x3b, 0x00, 0x05, 0x00, 0x03, 0x00, 0x09, 0x00, 0x00, 0x00, - 0x7a, 0x00, 0x00, 0x00, 0x05, 0x00, 0x08, 0x00, 0x12, 0x00, 0x00, 0x00, - 0x69, 0x6e, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x28, 0x76, 0x66, - 0x32, 0x3b, 0x76, 0x66, 0x32, 0x3b, 0x66, 0x31, 0x3b, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x03, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x03, 0x00, 0x10, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x03, 0x00, 0x11, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x08, 0x00, 0x17, 0x00, 0x00, 0x00, 0x63, 0x61, 0x6c, 0x63, - 0x75, 0x6c, 0x61, 0x74, 0x65, 0x4c, 0x6f, 0x73, 0x73, 0x28, 0x66, 0x31, - 0x3b, 0x66, 0x31, 0x3b, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, - 0x15, 0x00, 0x00, 0x00, 0x79, 0x48, 0x61, 0x74, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x03, 0x00, 0x16, 0x00, 0x00, 0x00, 0x79, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x03, 0x00, 0x21, 0x00, 0x00, 0x00, 0x7a, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x04, 0x00, 0x27, 0x00, 0x00, 0x00, 0x79, 0x48, 0x61, 0x74, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x28, 0x00, 0x00, 0x00, - 0x70, 0x61, 0x72, 0x61, 0x6d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, - 0x3e, 0x00, 0x00, 0x00, 0x69, 0x64, 0x78, 0x00, 0x05, 0x00, 0x08, 0x00, - 0x41, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x47, 0x6c, 0x6f, 0x62, 0x61, - 0x6c, 0x49, 0x6e, 0x76, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, - 0x44, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x46, 0x00, 0x00, 0x00, - 0x77, 0x43, 0x75, 0x72, 0x72, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, - 0x48, 0x00, 0x00, 0x00, 0x62, 0x77, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x04, 0x00, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x77, 0x69, 0x6e, 0x00, 0x05, 0x00, 0x03, 0x00, 0x4a, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x54, 0x00, 0x00, 0x00, - 0x62, 0x43, 0x75, 0x72, 0x72, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, - 0x56, 0x00, 0x00, 0x00, 0x62, 0x62, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x04, 0x00, 0x56, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x62, 0x69, 0x6e, 0x00, 0x05, 0x00, 0x03, 0x00, 0x58, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x5b, 0x00, 0x00, 0x00, - 0x78, 0x43, 0x75, 0x72, 0x72, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, - 0x5d, 0x00, 0x00, 0x00, 0x62, 0x78, 0x69, 0x00, 0x06, 0x00, 0x04, 0x00, - 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x69, 0x00, 0x00, - 0x05, 0x00, 0x03, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x03, 0x00, 0x64, 0x00, 0x00, 0x00, 0x62, 0x78, 0x6a, 0x00, - 0x06, 0x00, 0x04, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x78, 0x6a, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x66, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x6b, 0x00, 0x00, 0x00, - 0x79, 0x43, 0x75, 0x72, 0x72, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, - 0x6d, 0x00, 0x00, 0x00, 0x62, 0x79, 0x00, 0x00, 0x06, 0x00, 0x04, 0x00, - 0x6d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x79, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x03, 0x00, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x04, 0x00, 0x73, 0x00, 0x00, 0x00, 0x79, 0x48, 0x61, 0x74, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x74, 0x00, 0x00, 0x00, - 0x70, 0x61, 0x72, 0x61, 0x6d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, - 0x76, 0x00, 0x00, 0x00, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x04, 0x00, 0x78, 0x00, 0x00, 0x00, 0x70, 0x61, 0x72, 0x61, - 0x6d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x7b, 0x00, 0x00, 0x00, - 0x64, 0x5a, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x00, 0x00, - 0x64, 0x57, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x6d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x86, 0x00, 0x00, 0x00, - 0x64, 0x42, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x8b, 0x00, 0x00, 0x00, - 0x62, 0x77, 0x6f, 0x75, 0x74, 0x69, 0x00, 0x00, 0x06, 0x00, 0x05, 0x00, - 0x8b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x6f, 0x75, 0x74, - 0x69, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x8d, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x93, 0x00, 0x00, 0x00, - 0x62, 0x77, 0x6f, 0x75, 0x74, 0x6a, 0x00, 0x00, 0x06, 0x00, 0x05, 0x00, - 0x93, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x6f, 0x75, 0x74, - 0x6a, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x95, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x9c, 0x00, 0x00, 0x00, - 0x62, 0x62, 0x6f, 0x75, 0x74, 0x00, 0x00, 0x00, 0x06, 0x00, 0x05, 0x00, - 0x9c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x6f, 0x75, 0x74, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x9e, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0xa3, 0x00, 0x00, 0x00, - 0x62, 0x6c, 0x6f, 0x75, 0x74, 0x00, 0x00, 0x00, 0x06, 0x00, 0x05, 0x00, - 0xa3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x6f, 0x75, 0x74, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0xa5, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0xa7, 0x00, 0x00, 0x00, - 0x70, 0x61, 0x72, 0x61, 0x6d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, - 0xa9, 0x00, 0x00, 0x00, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x41, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, - 0x1c, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x47, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, - 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x48, 0x00, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x4a, 0x00, 0x00, 0x00, - 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x4a, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x55, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x56, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x03, 0x00, 0x56, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x58, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x58, 0x00, 0x00, 0x00, - 0x21, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x5c, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x48, 0x00, 0x05, 0x00, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, - 0x5d, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x5f, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x63, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, - 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x64, 0x00, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x66, 0x00, 0x00, 0x00, - 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x66, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x6d, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x03, 0x00, 0x6d, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x6f, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x6f, 0x00, 0x00, 0x00, - 0x21, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x80, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x8b, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x03, 0x00, 0x8b, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x8d, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x8d, 0x00, 0x00, 0x00, - 0x21, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x92, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x48, 0x00, 0x05, 0x00, 0x93, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, - 0x93, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x95, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x95, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x9b, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, - 0x9c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x9c, 0x00, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x9e, 0x00, 0x00, 0x00, - 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x9e, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0xa2, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0xa3, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x03, 0x00, 0xa3, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0xa5, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0xa5, 0x00, 0x00, 0x00, - 0x21, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0xad, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, - 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, - 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x21, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, - 0x0d, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x21, 0x00, 0x06, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x0d, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x21, 0x00, 0x05, 0x00, 0x14, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, - 0x15, 0x00, 0x04, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x3d, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, - 0x3f, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x04, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x3f, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x40, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, - 0x3c, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x04, 0x00, 0x43, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x3c, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x03, 0x00, 0x47, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, 0x48, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x49, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x49, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x15, 0x00, 0x04, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x4b, 0x00, 0x00, 0x00, - 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, - 0x4d, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x2b, 0x00, 0x04, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x03, 0x00, 0x55, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, 0x56, 0x00, 0x00, 0x00, - 0x55, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x57, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x57, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x1d, 0x00, 0x03, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x1e, 0x00, 0x03, 0x00, 0x5d, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x04, 0x00, 0x5e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x5d, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x5e, 0x00, 0x00, 0x00, - 0x5f, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x03, 0x00, - 0x63, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, - 0x64, 0x00, 0x00, 0x00, 0x63, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, - 0x65, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x65, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x03, 0x00, 0x6c, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, 0x6d, 0x00, 0x00, 0x00, - 0x6c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x6e, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x6e, 0x00, 0x00, 0x00, 0x6f, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x32, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x03, 0x00, 0x8a, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, 0x8b, 0x00, 0x00, 0x00, - 0x8a, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x8c, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x8b, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x8c, 0x00, 0x00, 0x00, 0x8d, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x1d, 0x00, 0x03, 0x00, 0x92, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x1e, 0x00, 0x03, 0x00, 0x93, 0x00, 0x00, 0x00, 0x92, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x04, 0x00, 0x94, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x93, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x94, 0x00, 0x00, 0x00, - 0x95, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, - 0x3c, 0x00, 0x00, 0x00, 0x97, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x1d, 0x00, 0x03, 0x00, 0x9b, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x1e, 0x00, 0x03, 0x00, 0x9c, 0x00, 0x00, 0x00, 0x9b, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x04, 0x00, 0x9d, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x9c, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x9d, 0x00, 0x00, 0x00, - 0x9e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x03, 0x00, - 0xa2, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, - 0xa3, 0x00, 0x00, 0x00, 0xa2, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, - 0xa4, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa3, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0xa4, 0x00, 0x00, 0x00, 0xa5, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x06, 0x00, 0x3f, 0x00, 0x00, 0x00, - 0xad, 0x00, 0x00, 0x00, 0x97, 0x00, 0x00, 0x00, 0x97, 0x00, 0x00, 0x00, - 0x97, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x3d, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x54, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x0d, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x73, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x0d, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x76, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x78, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x86, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x07, 0x00, 0x00, 0x00, 0xa7, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0xa9, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x43, 0x00, 0x00, 0x00, - 0x44, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, - 0x44, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x3e, 0x00, 0x00, 0x00, - 0x45, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x4d, 0x00, 0x00, 0x00, - 0x4e, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, - 0x4c, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x4f, 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, - 0x4d, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, - 0x4c, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, - 0x50, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x53, 0x00, 0x00, 0x00, - 0x4f, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0x46, 0x00, 0x00, 0x00, 0x53, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, - 0x4d, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, - 0x4c, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x54, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x4d, 0x00, 0x00, 0x00, - 0x61, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, - 0x60, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x62, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x3c, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x06, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, - 0x66, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x69, 0x00, 0x00, 0x00, - 0x68, 0x00, 0x00, 0x00, 0x50, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x6a, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x69, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x6a, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x4d, 0x00, 0x00, 0x00, - 0x71, 0x00, 0x00, 0x00, 0x6f, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, - 0x70, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x72, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0x6b, 0x00, 0x00, 0x00, 0x72, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x74, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, - 0x46, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x76, 0x00, 0x00, 0x00, - 0x77, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x79, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0x78, 0x00, 0x00, 0x00, 0x79, 0x00, 0x00, 0x00, 0x39, 0x00, 0x07, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x7a, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, - 0x74, 0x00, 0x00, 0x00, 0x76, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x73, 0x00, 0x00, 0x00, 0x7a, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, - 0x73, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x7d, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x83, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, - 0x7d, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x7b, 0x00, 0x00, 0x00, - 0x7e, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x81, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, - 0x5b, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x83, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, - 0x7b, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x85, 0x00, 0x00, 0x00, 0x83, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, - 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, - 0x19, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x00, - 0x85, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x89, 0x00, 0x00, 0x00, - 0x87, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0x86, 0x00, 0x00, 0x00, 0x89, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x3c, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x8f, 0x00, 0x00, 0x00, - 0x7f, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x8f, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x06, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0x00, - 0x8d, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x91, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x96, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x98, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x97, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x99, 0x00, 0x00, 0x00, - 0x98, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x4d, 0x00, 0x00, 0x00, - 0x9a, 0x00, 0x00, 0x00, 0x95, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, - 0x96, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x9a, 0x00, 0x00, 0x00, - 0x99, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x3c, 0x00, 0x00, 0x00, - 0x9f, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x86, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x06, 0x00, 0x4d, 0x00, 0x00, 0x00, 0xa1, 0x00, 0x00, 0x00, - 0x9e, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x9f, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0xa1, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x3c, 0x00, 0x00, 0x00, 0xa6, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0xa8, 0x00, 0x00, 0x00, 0x73, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0xa7, 0x00, 0x00, 0x00, 0xa8, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0xaa, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0xa9, 0x00, 0x00, 0x00, 0xaa, 0x00, 0x00, 0x00, - 0x39, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, 0xab, 0x00, 0x00, 0x00, - 0x17, 0x00, 0x00, 0x00, 0xa7, 0x00, 0x00, 0x00, 0xa9, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x06, 0x00, 0x4d, 0x00, 0x00, 0x00, 0xac, 0x00, 0x00, 0x00, - 0xa5, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0xa6, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0xac, 0x00, 0x00, 0x00, 0xab, 0x00, 0x00, 0x00, - 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00, 0x36, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x08, 0x00, 0x00, 0x00, 0x37, 0x00, 0x03, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x0b, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x1b, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x1b, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, - 0x1c, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x1e, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, - 0xfe, 0x00, 0x02, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x38, 0x00, 0x01, 0x00, - 0x36, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x37, 0x00, 0x03, 0x00, - 0x0d, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x37, 0x00, 0x03, 0x00, - 0x0d, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x37, 0x00, 0x03, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, - 0x13, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x21, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x22, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, - 0x94, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, - 0x22, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, - 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, - 0x24, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0x21, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x28, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, - 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, - 0x0a, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0x27, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, - 0xfe, 0x00, 0x02, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x38, 0x00, 0x01, 0x00, - 0x36, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x37, 0x00, 0x03, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x37, 0x00, 0x03, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, - 0x18, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x2e, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, - 0x0c, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x00, - 0x85, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, - 0x2e, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, - 0x83, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, - 0x19, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, - 0x83, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, - 0x19, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x1c, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, - 0x36, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x38, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, - 0x7f, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00, - 0x38, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x02, 0x00, 0x39, 0x00, 0x00, 0x00, - 0x38, 0x00, 0x01, 0x00 -}; -static const unsigned int shaders_glsl_logisticregression_comp_spv_len = 4816; -} -} -#endif // define SHADEROP_SHADERLOGISTICREGRESSION_HPP diff --git a/src/include/kompute/shaders/shaderopmult.hpp b/src/include/kompute/shaders/shaderopmult.hpp deleted file mode 100755 index f4015a58f..000000000 --- a/src/include/kompute/shaders/shaderopmult.hpp +++ /dev/null @@ -1,153 +0,0 @@ -/* - THIS FILE HAS BEEN AUTOMATICALLY GENERATED - DO NOT EDIT - - --- - - Copyright 2020 The Institute for Ethical AI & Machine Learning - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#ifndef SHADEROP_SHADEROPMULT_HPP -#define SHADEROP_SHADEROPMULT_HPP - -namespace kp { -namespace shader_data { -static const unsigned char shaders_glsl_opmult_comp_spv[] = { - 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x0a, 0x00, 0x08, 0x00, - 0x2e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, - 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x06, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, - 0x0b, 0x00, 0x00, 0x00, 0x10, 0x00, 0x06, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x11, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x02, 0x00, 0x00, 0x00, - 0xc2, 0x01, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, - 0x08, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x08, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x47, - 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x49, 0x6e, 0x76, 0x6f, 0x63, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x49, 0x44, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, - 0x12, 0x00, 0x00, 0x00, 0x74, 0x65, 0x6e, 0x73, 0x6f, 0x72, 0x4f, 0x75, - 0x74, 0x70, 0x75, 0x74, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x07, 0x00, - 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x73, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x03, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x05, 0x00, 0x19, 0x00, 0x00, 0x00, 0x74, 0x65, 0x6e, 0x73, - 0x6f, 0x72, 0x4c, 0x68, 0x73, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, - 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x73, 0x4c, 0x68, 0x73, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, - 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, - 0x21, 0x00, 0x00, 0x00, 0x74, 0x65, 0x6e, 0x73, 0x6f, 0x72, 0x52, 0x68, - 0x73, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0x21, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x52, 0x68, - 0x73, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x23, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x29, 0x00, 0x00, 0x00, - 0x4c, 0x45, 0x4e, 0x5f, 0x4c, 0x48, 0x53, 0x00, 0x05, 0x00, 0x04, 0x00, - 0x2a, 0x00, 0x00, 0x00, 0x4c, 0x45, 0x4e, 0x5f, 0x52, 0x48, 0x53, 0x00, - 0x05, 0x00, 0x04, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x4c, 0x45, 0x4e, 0x5f, - 0x4f, 0x55, 0x54, 0x00, 0x47, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, - 0x0b, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x11, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x48, 0x00, 0x05, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, - 0x12, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x14, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x14, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x18, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, - 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x19, 0x00, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x1b, 0x00, 0x00, 0x00, - 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x1b, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x20, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x21, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x03, 0x00, 0x21, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x23, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x23, 0x00, 0x00, 0x00, - 0x21, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x29, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x2b, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x2d, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, - 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, - 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, - 0x0a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, - 0x0d, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x16, 0x00, 0x03, 0x00, 0x10, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, - 0x1d, 0x00, 0x03, 0x00, 0x11, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, - 0x1e, 0x00, 0x03, 0x00, 0x12, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x04, 0x00, 0x13, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x12, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x13, 0x00, 0x00, 0x00, - 0x14, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, - 0x15, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x2b, 0x00, 0x04, 0x00, 0x15, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x03, 0x00, 0x18, 0x00, 0x00, 0x00, - 0x10, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, 0x19, 0x00, 0x00, 0x00, - 0x18, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x1a, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x1a, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x04, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x10, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x03, 0x00, 0x20, 0x00, 0x00, 0x00, - 0x10, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, 0x21, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x22, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x22, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x32, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x06, 0x00, 0x09, 0x00, 0x00, 0x00, - 0x2d, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, - 0x2c, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x05, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, - 0x0b, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x08, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, - 0x08, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x1c, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, - 0x1d, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, - 0x16, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x10, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, - 0x08, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x1d, 0x00, 0x00, 0x00, - 0x25, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, - 0x24, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00, - 0x26, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, - 0x10, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, - 0x26, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x1d, 0x00, 0x00, 0x00, - 0x28, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, - 0x17, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x28, 0x00, 0x00, 0x00, - 0x27, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00 -}; -static const unsigned int shaders_glsl_opmult_comp_spv_len = 1464; -} -} -#endif // define SHADEROP_SHADEROPMULT_HPP diff --git a/src/shaders/CMakeLists.txt b/src/shaders/CMakeLists.txt new file mode 100644 index 000000000..004c8ea1f --- /dev/null +++ b/src/shaders/CMakeLists.txt @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: Apache-2.0 +# ###################### +cmake_minimum_required(VERSION 3.14) + +add_subdirectory(glsl) \ No newline at end of file diff --git a/src/shaders/glsl/CMakeLists.txt b/src/shaders/glsl/CMakeLists.txt new file mode 100644 index 000000000..ed13d8988 --- /dev/null +++ b/src/shaders/glsl/CMakeLists.txt @@ -0,0 +1,26 @@ +# SPDX-License-Identifier: Apache-2.0 +# ###################### +cmake_minimum_required(VERSION 3.14) + +# Check if build shaders from source is enabled +if(KOMPUTE_OPT_BUILD_SHADERS) + vulkan_compile_shader(INFILE ShaderOpMult.comp + OUTFILE ShaderOpMult.hpp + NAMESPACE "kp") + + vulkan_compile_shader(INFILE ShaderLogisticRegression.comp + OUTFILE ShaderLogisticRegression.hpp + NAMESPACE "kp") +else() # Else we will use our precompiled versions + add_custom_command(OUTPUT $/ShaderOpMult.hpp COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/ShaderOpMult.hpp.in $/ShaderOpMult.hpp) + add_custom_command(OUTPUT $/ShaderLogisticRegression.hpp COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/ShaderLogisticRegression.hpp.in $/ShaderLogisticRegression.hpp) +endif() + +add_library(kp_shader INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/ShaderOpMult.hpp" + "${CMAKE_CURRENT_BINARY_DIR}/ShaderLogisticRegression.hpp") + +target_include_directories(kp_shader INTERFACE $) + +# Make sure we install shaders: +install(FILES $/ShaderOpMult.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +install(FILES $/ShaderLogisticRegression.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) diff --git a/shaders/glsl/logisticregression.comp b/src/shaders/glsl/ShaderLogisticRegression.comp similarity index 100% rename from shaders/glsl/logisticregression.comp rename to src/shaders/glsl/ShaderLogisticRegression.comp diff --git a/src/shaders/glsl/ShaderLogisticRegression.hpp.in b/src/shaders/glsl/ShaderLogisticRegression.hpp.in new file mode 100644 index 000000000..bfe7792c6 --- /dev/null +++ b/src/shaders/glsl/ShaderLogisticRegression.hpp.in @@ -0,0 +1,310 @@ +#pragma once +#include +#include + +namespace kp { +const std::array SHADERLOGISTICREGRESSION_COMP_SPV = { +0x07230203, 0x00010000, 0x0008000a, 0x000000ae, +0x00000000, 0x00020011, 0x00000001, 0x0006000b, +0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e, +0x00000000, 0x0003000e, 0x00000000, 0x00000001, +0x0006000f, 0x00000005, 0x00000004, 0x6e69616d, +0x00000000, 0x00000041, 0x00060010, 0x00000004, +0x00000011, 0x00000001, 0x00000001, 0x00000001, +0x00030003, 0x00000002, 0x000001c2, 0x00040005, +0x00000004, 0x6e69616d, 0x00000000, 0x00050005, +0x0000000a, 0x6d676973, 0x2864696f, 0x003b3166, +0x00030005, 0x00000009, 0x0000007a, 0x00080005, +0x00000012, 0x65666e69, 0x636e6572, 0x66762865, +0x66763b32, 0x31663b32, 0x0000003b, 0x00030005, +0x0000000f, 0x00000078, 0x00030005, 0x00000010, +0x00000077, 0x00030005, 0x00000011, 0x00000062, +0x00080005, 0x00000017, 0x636c6163, 0x74616c75, +0x736f4c65, 0x31662873, 0x3b31663b, 0x00000000, +0x00040005, 0x00000015, 0x74614879, 0x00000000, +0x00030005, 0x00000016, 0x00000079, 0x00030005, +0x00000021, 0x0000007a, 0x00040005, 0x00000027, +0x74614879, 0x00000000, 0x00040005, 0x00000028, +0x61726170, 0x0000006d, 0x00030005, 0x0000003e, +0x00786469, 0x00080005, 0x00000041, 0x475f6c67, +0x61626f6c, 0x766e496c, 0x7461636f, 0x496e6f69, +0x00000044, 0x00040005, 0x00000046, 0x72754377, +0x00000072, 0x00040005, 0x00000048, 0x6e697762, +0x00000000, 0x00040006, 0x00000048, 0x00000000, +0x006e6977, 0x00030005, 0x0000004a, 0x00000000, +0x00040005, 0x00000054, 0x72754362, 0x00000072, +0x00040005, 0x00000056, 0x6e696262, 0x00000000, +0x00040006, 0x00000056, 0x00000000, 0x006e6962, +0x00030005, 0x00000058, 0x00000000, 0x00040005, +0x0000005b, 0x72754378, 0x00000072, 0x00030005, +0x0000005d, 0x00697862, 0x00040006, 0x0000005d, +0x00000000, 0x00006978, 0x00030005, 0x0000005f, +0x00000000, 0x00030005, 0x00000064, 0x006a7862, +0x00040006, 0x00000064, 0x00000000, 0x00006a78, +0x00030005, 0x00000066, 0x00000000, 0x00040005, +0x0000006b, 0x72754379, 0x00000072, 0x00030005, +0x0000006d, 0x00007962, 0x00040006, 0x0000006d, +0x00000000, 0x00000079, 0x00030005, 0x0000006f, +0x00000000, 0x00040005, 0x00000073, 0x74614879, +0x00000000, 0x00040005, 0x00000074, 0x61726170, +0x0000006d, 0x00040005, 0x00000076, 0x61726170, +0x0000006d, 0x00040005, 0x00000078, 0x61726170, +0x0000006d, 0x00030005, 0x0000007b, 0x00005a64, +0x00030005, 0x0000007f, 0x00005764, 0x00030005, +0x00000080, 0x0000006d, 0x00030005, 0x00000086, +0x00004264, 0x00040005, 0x0000008b, 0x756f7762, +0x00006974, 0x00050006, 0x0000008b, 0x00000000, +0x74756f77, 0x00000069, 0x00030005, 0x0000008d, +0x00000000, 0x00040005, 0x00000093, 0x756f7762, +0x00006a74, 0x00050006, 0x00000093, 0x00000000, +0x74756f77, 0x0000006a, 0x00030005, 0x00000095, +0x00000000, 0x00040005, 0x0000009c, 0x756f6262, +0x00000074, 0x00050006, 0x0000009c, 0x00000000, +0x74756f62, 0x00000000, 0x00030005, 0x0000009e, +0x00000000, 0x00040005, 0x000000a3, 0x756f6c62, +0x00000074, 0x00050006, 0x000000a3, 0x00000000, +0x74756f6c, 0x00000000, 0x00030005, 0x000000a5, +0x00000000, 0x00040005, 0x000000a7, 0x61726170, +0x0000006d, 0x00040005, 0x000000a9, 0x61726170, +0x0000006d, 0x00040047, 0x00000041, 0x0000000b, +0x0000001c, 0x00040047, 0x00000047, 0x00000006, +0x00000004, 0x00050048, 0x00000048, 0x00000000, +0x00000023, 0x00000000, 0x00030047, 0x00000048, +0x00000003, 0x00040047, 0x0000004a, 0x00000022, +0x00000000, 0x00040047, 0x0000004a, 0x00000021, +0x00000003, 0x00040047, 0x00000055, 0x00000006, +0x00000004, 0x00050048, 0x00000056, 0x00000000, +0x00000023, 0x00000000, 0x00030047, 0x00000056, +0x00000003, 0x00040047, 0x00000058, 0x00000022, +0x00000000, 0x00040047, 0x00000058, 0x00000021, +0x00000006, 0x00040047, 0x0000005c, 0x00000006, +0x00000004, 0x00050048, 0x0000005d, 0x00000000, +0x00000023, 0x00000000, 0x00030047, 0x0000005d, +0x00000003, 0x00040047, 0x0000005f, 0x00000022, +0x00000000, 0x00040047, 0x0000005f, 0x00000021, +0x00000000, 0x00040047, 0x00000063, 0x00000006, +0x00000004, 0x00050048, 0x00000064, 0x00000000, +0x00000023, 0x00000000, 0x00030047, 0x00000064, +0x00000003, 0x00040047, 0x00000066, 0x00000022, +0x00000000, 0x00040047, 0x00000066, 0x00000021, +0x00000001, 0x00040047, 0x0000006c, 0x00000006, +0x00000004, 0x00050048, 0x0000006d, 0x00000000, +0x00000023, 0x00000000, 0x00030047, 0x0000006d, +0x00000003, 0x00040047, 0x0000006f, 0x00000022, +0x00000000, 0x00040047, 0x0000006f, 0x00000021, +0x00000002, 0x00040047, 0x00000080, 0x00000001, +0x00000000, 0x00040047, 0x0000008a, 0x00000006, +0x00000004, 0x00050048, 0x0000008b, 0x00000000, +0x00000023, 0x00000000, 0x00030047, 0x0000008b, +0x00000003, 0x00040047, 0x0000008d, 0x00000022, +0x00000000, 0x00040047, 0x0000008d, 0x00000021, +0x00000004, 0x00040047, 0x00000092, 0x00000006, +0x00000004, 0x00050048, 0x00000093, 0x00000000, +0x00000023, 0x00000000, 0x00030047, 0x00000093, +0x00000003, 0x00040047, 0x00000095, 0x00000022, +0x00000000, 0x00040047, 0x00000095, 0x00000021, +0x00000005, 0x00040047, 0x0000009b, 0x00000006, +0x00000004, 0x00050048, 0x0000009c, 0x00000000, +0x00000023, 0x00000000, 0x00030047, 0x0000009c, +0x00000003, 0x00040047, 0x0000009e, 0x00000022, +0x00000000, 0x00040047, 0x0000009e, 0x00000021, +0x00000007, 0x00040047, 0x000000a2, 0x00000006, +0x00000004, 0x00050048, 0x000000a3, 0x00000000, +0x00000023, 0x00000000, 0x00030047, 0x000000a3, +0x00000003, 0x00040047, 0x000000a5, 0x00000022, +0x00000000, 0x00040047, 0x000000a5, 0x00000021, +0x00000008, 0x00040047, 0x000000ad, 0x0000000b, +0x00000019, 0x00020013, 0x00000002, 0x00030021, +0x00000003, 0x00000002, 0x00030016, 0x00000006, +0x00000020, 0x00040020, 0x00000007, 0x00000007, +0x00000006, 0x00040021, 0x00000008, 0x00000006, +0x00000007, 0x00040017, 0x0000000c, 0x00000006, +0x00000002, 0x00040020, 0x0000000d, 0x00000007, +0x0000000c, 0x00060021, 0x0000000e, 0x00000006, +0x0000000d, 0x0000000d, 0x00000007, 0x00050021, +0x00000014, 0x00000006, 0x00000007, 0x00000007, +0x0004002b, 0x00000006, 0x00000019, 0x3f800000, +0x00040015, 0x0000003c, 0x00000020, 0x00000000, +0x00040020, 0x0000003d, 0x00000007, 0x0000003c, +0x00040017, 0x0000003f, 0x0000003c, 0x00000003, +0x00040020, 0x00000040, 0x00000001, 0x0000003f, +0x0004003b, 0x00000040, 0x00000041, 0x00000001, +0x0004002b, 0x0000003c, 0x00000042, 0x00000000, +0x00040020, 0x00000043, 0x00000001, 0x0000003c, +0x0003001d, 0x00000047, 0x00000006, 0x0003001e, +0x00000048, 0x00000047, 0x00040020, 0x00000049, +0x00000002, 0x00000048, 0x0004003b, 0x00000049, +0x0000004a, 0x00000002, 0x00040015, 0x0000004b, +0x00000020, 0x00000001, 0x0004002b, 0x0000004b, +0x0000004c, 0x00000000, 0x00040020, 0x0000004d, +0x00000002, 0x00000006, 0x0004002b, 0x0000004b, +0x00000050, 0x00000001, 0x0003001d, 0x00000055, +0x00000006, 0x0003001e, 0x00000056, 0x00000055, +0x00040020, 0x00000057, 0x00000002, 0x00000056, +0x0004003b, 0x00000057, 0x00000058, 0x00000002, +0x0003001d, 0x0000005c, 0x00000006, 0x0003001e, +0x0000005d, 0x0000005c, 0x00040020, 0x0000005e, +0x00000002, 0x0000005d, 0x0004003b, 0x0000005e, +0x0000005f, 0x00000002, 0x0003001d, 0x00000063, +0x00000006, 0x0003001e, 0x00000064, 0x00000063, +0x00040020, 0x00000065, 0x00000002, 0x00000064, +0x0004003b, 0x00000065, 0x00000066, 0x00000002, +0x0003001d, 0x0000006c, 0x00000006, 0x0003001e, +0x0000006d, 0x0000006c, 0x00040020, 0x0000006e, +0x00000002, 0x0000006d, 0x0004003b, 0x0000006e, +0x0000006f, 0x00000002, 0x00040032, 0x00000006, +0x00000080, 0x00000000, 0x0003001d, 0x0000008a, +0x00000006, 0x0003001e, 0x0000008b, 0x0000008a, +0x00040020, 0x0000008c, 0x00000002, 0x0000008b, +0x0004003b, 0x0000008c, 0x0000008d, 0x00000002, +0x0003001d, 0x00000092, 0x00000006, 0x0003001e, +0x00000093, 0x00000092, 0x00040020, 0x00000094, +0x00000002, 0x00000093, 0x0004003b, 0x00000094, +0x00000095, 0x00000002, 0x0004002b, 0x0000003c, +0x00000097, 0x00000001, 0x0003001d, 0x0000009b, +0x00000006, 0x0003001e, 0x0000009c, 0x0000009b, +0x00040020, 0x0000009d, 0x00000002, 0x0000009c, +0x0004003b, 0x0000009d, 0x0000009e, 0x00000002, +0x0003001d, 0x000000a2, 0x00000006, 0x0003001e, +0x000000a3, 0x000000a2, 0x00040020, 0x000000a4, +0x00000002, 0x000000a3, 0x0004003b, 0x000000a4, +0x000000a5, 0x00000002, 0x0006002c, 0x0000003f, +0x000000ad, 0x00000097, 0x00000097, 0x00000097, +0x00050036, 0x00000002, 0x00000004, 0x00000000, +0x00000003, 0x000200f8, 0x00000005, 0x0004003b, +0x0000003d, 0x0000003e, 0x00000007, 0x0004003b, +0x0000000d, 0x00000046, 0x00000007, 0x0004003b, +0x00000007, 0x00000054, 0x00000007, 0x0004003b, +0x0000000d, 0x0000005b, 0x00000007, 0x0004003b, +0x00000007, 0x0000006b, 0x00000007, 0x0004003b, +0x00000007, 0x00000073, 0x00000007, 0x0004003b, +0x0000000d, 0x00000074, 0x00000007, 0x0004003b, +0x0000000d, 0x00000076, 0x00000007, 0x0004003b, +0x00000007, 0x00000078, 0x00000007, 0x0004003b, +0x00000007, 0x0000007b, 0x00000007, 0x0004003b, +0x0000000d, 0x0000007f, 0x00000007, 0x0004003b, +0x00000007, 0x00000086, 0x00000007, 0x0004003b, +0x00000007, 0x000000a7, 0x00000007, 0x0004003b, +0x00000007, 0x000000a9, 0x00000007, 0x00050041, +0x00000043, 0x00000044, 0x00000041, 0x00000042, +0x0004003d, 0x0000003c, 0x00000045, 0x00000044, +0x0003003e, 0x0000003e, 0x00000045, 0x00060041, +0x0000004d, 0x0000004e, 0x0000004a, 0x0000004c, +0x0000004c, 0x0004003d, 0x00000006, 0x0000004f, +0x0000004e, 0x00060041, 0x0000004d, 0x00000051, +0x0000004a, 0x0000004c, 0x00000050, 0x0004003d, +0x00000006, 0x00000052, 0x00000051, 0x00050050, +0x0000000c, 0x00000053, 0x0000004f, 0x00000052, +0x0003003e, 0x00000046, 0x00000053, 0x00060041, +0x0000004d, 0x00000059, 0x00000058, 0x0000004c, +0x0000004c, 0x0004003d, 0x00000006, 0x0000005a, +0x00000059, 0x0003003e, 0x00000054, 0x0000005a, +0x0004003d, 0x0000003c, 0x00000060, 0x0000003e, +0x00060041, 0x0000004d, 0x00000061, 0x0000005f, +0x0000004c, 0x00000060, 0x0004003d, 0x00000006, +0x00000062, 0x00000061, 0x0004003d, 0x0000003c, +0x00000067, 0x0000003e, 0x00060041, 0x0000004d, +0x00000068, 0x00000066, 0x0000004c, 0x00000067, +0x0004003d, 0x00000006, 0x00000069, 0x00000068, +0x00050050, 0x0000000c, 0x0000006a, 0x00000062, +0x00000069, 0x0003003e, 0x0000005b, 0x0000006a, +0x0004003d, 0x0000003c, 0x00000070, 0x0000003e, +0x00060041, 0x0000004d, 0x00000071, 0x0000006f, +0x0000004c, 0x00000070, 0x0004003d, 0x00000006, +0x00000072, 0x00000071, 0x0003003e, 0x0000006b, +0x00000072, 0x0004003d, 0x0000000c, 0x00000075, +0x0000005b, 0x0003003e, 0x00000074, 0x00000075, +0x0004003d, 0x0000000c, 0x00000077, 0x00000046, +0x0003003e, 0x00000076, 0x00000077, 0x0004003d, +0x00000006, 0x00000079, 0x00000054, 0x0003003e, +0x00000078, 0x00000079, 0x00070039, 0x00000006, +0x0000007a, 0x00000012, 0x00000074, 0x00000076, +0x00000078, 0x0003003e, 0x00000073, 0x0000007a, +0x0004003d, 0x00000006, 0x0000007c, 0x00000073, +0x0004003d, 0x00000006, 0x0000007d, 0x0000006b, +0x00050083, 0x00000006, 0x0000007e, 0x0000007c, +0x0000007d, 0x0003003e, 0x0000007b, 0x0000007e, +0x00050088, 0x00000006, 0x00000081, 0x00000019, +0x00000080, 0x0004003d, 0x0000000c, 0x00000082, +0x0000005b, 0x0005008e, 0x0000000c, 0x00000083, +0x00000082, 0x00000081, 0x0004003d, 0x00000006, +0x00000084, 0x0000007b, 0x0005008e, 0x0000000c, +0x00000085, 0x00000083, 0x00000084, 0x0003003e, +0x0000007f, 0x00000085, 0x00050088, 0x00000006, +0x00000087, 0x00000019, 0x00000080, 0x0004003d, +0x00000006, 0x00000088, 0x0000007b, 0x00050085, +0x00000006, 0x00000089, 0x00000087, 0x00000088, +0x0003003e, 0x00000086, 0x00000089, 0x0004003d, +0x0000003c, 0x0000008e, 0x0000003e, 0x00050041, +0x00000007, 0x0000008f, 0x0000007f, 0x00000042, +0x0004003d, 0x00000006, 0x00000090, 0x0000008f, +0x00060041, 0x0000004d, 0x00000091, 0x0000008d, +0x0000004c, 0x0000008e, 0x0003003e, 0x00000091, +0x00000090, 0x0004003d, 0x0000003c, 0x00000096, +0x0000003e, 0x00050041, 0x00000007, 0x00000098, +0x0000007f, 0x00000097, 0x0004003d, 0x00000006, +0x00000099, 0x00000098, 0x00060041, 0x0000004d, +0x0000009a, 0x00000095, 0x0000004c, 0x00000096, +0x0003003e, 0x0000009a, 0x00000099, 0x0004003d, +0x0000003c, 0x0000009f, 0x0000003e, 0x0004003d, +0x00000006, 0x000000a0, 0x00000086, 0x00060041, +0x0000004d, 0x000000a1, 0x0000009e, 0x0000004c, +0x0000009f, 0x0003003e, 0x000000a1, 0x000000a0, +0x0004003d, 0x0000003c, 0x000000a6, 0x0000003e, +0x0004003d, 0x00000006, 0x000000a8, 0x00000073, +0x0003003e, 0x000000a7, 0x000000a8, 0x0004003d, +0x00000006, 0x000000aa, 0x0000006b, 0x0003003e, +0x000000a9, 0x000000aa, 0x00060039, 0x00000006, +0x000000ab, 0x00000017, 0x000000a7, 0x000000a9, +0x00060041, 0x0000004d, 0x000000ac, 0x000000a5, +0x0000004c, 0x000000a6, 0x0003003e, 0x000000ac, +0x000000ab, 0x000100fd, 0x00010038, 0x00050036, +0x00000006, 0x0000000a, 0x00000000, 0x00000008, +0x00030037, 0x00000007, 0x00000009, 0x000200f8, +0x0000000b, 0x0004003d, 0x00000006, 0x0000001a, +0x00000009, 0x0004007f, 0x00000006, 0x0000001b, +0x0000001a, 0x0006000c, 0x00000006, 0x0000001c, +0x00000001, 0x0000001b, 0x0000001b, 0x00050081, +0x00000006, 0x0000001d, 0x00000019, 0x0000001c, +0x00050088, 0x00000006, 0x0000001e, 0x00000019, +0x0000001d, 0x000200fe, 0x0000001e, 0x00010038, +0x00050036, 0x00000006, 0x00000012, 0x00000000, +0x0000000e, 0x00030037, 0x0000000d, 0x0000000f, +0x00030037, 0x0000000d, 0x00000010, 0x00030037, +0x00000007, 0x00000011, 0x000200f8, 0x00000013, +0x0004003b, 0x00000007, 0x00000021, 0x00000007, +0x0004003b, 0x00000007, 0x00000027, 0x00000007, +0x0004003b, 0x00000007, 0x00000028, 0x00000007, +0x0004003d, 0x0000000c, 0x00000022, 0x00000010, +0x0004003d, 0x0000000c, 0x00000023, 0x0000000f, +0x00050094, 0x00000006, 0x00000024, 0x00000022, +0x00000023, 0x0004003d, 0x00000006, 0x00000025, +0x00000011, 0x00050081, 0x00000006, 0x00000026, +0x00000024, 0x00000025, 0x0003003e, 0x00000021, +0x00000026, 0x0004003d, 0x00000006, 0x00000029, +0x00000021, 0x0003003e, 0x00000028, 0x00000029, +0x00050039, 0x00000006, 0x0000002a, 0x0000000a, +0x00000028, 0x0003003e, 0x00000027, 0x0000002a, +0x0004003d, 0x00000006, 0x0000002b, 0x00000027, +0x000200fe, 0x0000002b, 0x00010038, 0x00050036, +0x00000006, 0x00000017, 0x00000000, 0x00000014, +0x00030037, 0x00000007, 0x00000015, 0x00030037, +0x00000007, 0x00000016, 0x000200f8, 0x00000018, +0x0004003d, 0x00000006, 0x0000002e, 0x00000016, +0x0004003d, 0x00000006, 0x0000002f, 0x00000015, +0x0006000c, 0x00000006, 0x00000030, 0x00000001, +0x0000001c, 0x0000002f, 0x00050085, 0x00000006, +0x00000031, 0x0000002e, 0x00000030, 0x0004003d, +0x00000006, 0x00000032, 0x00000016, 0x00050083, +0x00000006, 0x00000033, 0x00000019, 0x00000032, +0x0004003d, 0x00000006, 0x00000034, 0x00000015, +0x00050083, 0x00000006, 0x00000035, 0x00000019, +0x00000034, 0x0006000c, 0x00000006, 0x00000036, +0x00000001, 0x0000001c, 0x00000035, 0x00050085, +0x00000006, 0x00000037, 0x00000033, 0x00000036, +0x00050081, 0x00000006, 0x00000038, 0x00000031, +0x00000037, 0x0004007f, 0x00000006, 0x00000039, +0x00000038, 0x000200fe, 0x00000039, 0x00010038 }; +} // namespace kp + + diff --git a/shaders/glsl/opmult.comp b/src/shaders/glsl/ShaderOpMult.comp similarity index 100% rename from shaders/glsl/opmult.comp rename to src/shaders/glsl/ShaderOpMult.comp diff --git a/src/shaders/glsl/ShaderOpMult.hpp.in b/src/shaders/glsl/ShaderOpMult.hpp.in new file mode 100644 index 000000000..5af29c66d --- /dev/null +++ b/src/shaders/glsl/ShaderOpMult.hpp.in @@ -0,0 +1,101 @@ +#pragma once +#include +#include + +namespace kp { +const std::array SHADEROPMULT_COMP_SPV = { +0x07230203, 0x00010000, 0x0008000a, 0x0000002e, +0x00000000, 0x00020011, 0x00000001, 0x0006000b, +0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e, +0x00000000, 0x0003000e, 0x00000000, 0x00000001, +0x0006000f, 0x00000005, 0x00000004, 0x6e69616d, +0x00000000, 0x0000000b, 0x00060010, 0x00000004, +0x00000011, 0x00000001, 0x00000001, 0x00000001, +0x00030003, 0x00000002, 0x000001c2, 0x00040005, +0x00000004, 0x6e69616d, 0x00000000, 0x00040005, +0x00000008, 0x65646e69, 0x00000078, 0x00080005, +0x0000000b, 0x475f6c67, 0x61626f6c, 0x766e496c, +0x7461636f, 0x496e6f69, 0x00000044, 0x00060005, +0x00000012, 0x736e6574, 0x754f726f, 0x74757074, +0x00000000, 0x00070006, 0x00000012, 0x00000000, +0x756c6176, 0x754f7365, 0x74757074, 0x00000000, +0x00030005, 0x00000014, 0x00000000, 0x00050005, +0x00000019, 0x736e6574, 0x684c726f, 0x00000073, +0x00060006, 0x00000019, 0x00000000, 0x756c6176, +0x684c7365, 0x00000073, 0x00030005, 0x0000001b, +0x00000000, 0x00050005, 0x00000021, 0x736e6574, +0x6852726f, 0x00000073, 0x00060006, 0x00000021, +0x00000000, 0x756c6176, 0x68527365, 0x00000073, +0x00030005, 0x00000023, 0x00000000, 0x00040005, +0x00000029, 0x5f4e454c, 0x0053484c, 0x00040005, +0x0000002a, 0x5f4e454c, 0x00534852, 0x00040005, +0x0000002b, 0x5f4e454c, 0x0054554f, 0x00040047, +0x0000000b, 0x0000000b, 0x0000001c, 0x00040047, +0x00000011, 0x00000006, 0x00000004, 0x00050048, +0x00000012, 0x00000000, 0x00000023, 0x00000000, +0x00030047, 0x00000012, 0x00000003, 0x00040047, +0x00000014, 0x00000022, 0x00000000, 0x00040047, +0x00000014, 0x00000021, 0x00000002, 0x00040047, +0x00000018, 0x00000006, 0x00000004, 0x00050048, +0x00000019, 0x00000000, 0x00000023, 0x00000000, +0x00030047, 0x00000019, 0x00000003, 0x00040047, +0x0000001b, 0x00000022, 0x00000000, 0x00040047, +0x0000001b, 0x00000021, 0x00000000, 0x00040047, +0x00000020, 0x00000006, 0x00000004, 0x00050048, +0x00000021, 0x00000000, 0x00000023, 0x00000000, +0x00030047, 0x00000021, 0x00000003, 0x00040047, +0x00000023, 0x00000022, 0x00000000, 0x00040047, +0x00000023, 0x00000021, 0x00000001, 0x00040047, +0x00000029, 0x00000001, 0x00000000, 0x00040047, +0x0000002a, 0x00000001, 0x00000001, 0x00040047, +0x0000002b, 0x00000001, 0x00000002, 0x00040047, +0x0000002d, 0x0000000b, 0x00000019, 0x00020013, +0x00000002, 0x00030021, 0x00000003, 0x00000002, +0x00040015, 0x00000006, 0x00000020, 0x00000000, +0x00040020, 0x00000007, 0x00000007, 0x00000006, +0x00040017, 0x00000009, 0x00000006, 0x00000003, +0x00040020, 0x0000000a, 0x00000001, 0x00000009, +0x0004003b, 0x0000000a, 0x0000000b, 0x00000001, +0x0004002b, 0x00000006, 0x0000000c, 0x00000000, +0x00040020, 0x0000000d, 0x00000001, 0x00000006, +0x00030016, 0x00000010, 0x00000020, 0x0003001d, +0x00000011, 0x00000010, 0x0003001e, 0x00000012, +0x00000011, 0x00040020, 0x00000013, 0x00000002, +0x00000012, 0x0004003b, 0x00000013, 0x00000014, +0x00000002, 0x00040015, 0x00000015, 0x00000020, +0x00000001, 0x0004002b, 0x00000015, 0x00000016, +0x00000000, 0x0003001d, 0x00000018, 0x00000010, +0x0003001e, 0x00000019, 0x00000018, 0x00040020, +0x0000001a, 0x00000002, 0x00000019, 0x0004003b, +0x0000001a, 0x0000001b, 0x00000002, 0x00040020, +0x0000001d, 0x00000002, 0x00000010, 0x0003001d, +0x00000020, 0x00000010, 0x0003001e, 0x00000021, +0x00000020, 0x00040020, 0x00000022, 0x00000002, +0x00000021, 0x0004003b, 0x00000022, 0x00000023, +0x00000002, 0x00040032, 0x00000006, 0x00000029, +0x00000000, 0x00040032, 0x00000006, 0x0000002a, +0x00000000, 0x00040032, 0x00000006, 0x0000002b, +0x00000000, 0x0004002b, 0x00000006, 0x0000002c, +0x00000001, 0x0006002c, 0x00000009, 0x0000002d, +0x0000002c, 0x0000002c, 0x0000002c, 0x00050036, +0x00000002, 0x00000004, 0x00000000, 0x00000003, +0x000200f8, 0x00000005, 0x0004003b, 0x00000007, +0x00000008, 0x00000007, 0x00050041, 0x0000000d, +0x0000000e, 0x0000000b, 0x0000000c, 0x0004003d, +0x00000006, 0x0000000f, 0x0000000e, 0x0003003e, +0x00000008, 0x0000000f, 0x0004003d, 0x00000006, +0x00000017, 0x00000008, 0x0004003d, 0x00000006, +0x0000001c, 0x00000008, 0x00060041, 0x0000001d, +0x0000001e, 0x0000001b, 0x00000016, 0x0000001c, +0x0004003d, 0x00000010, 0x0000001f, 0x0000001e, +0x0004003d, 0x00000006, 0x00000024, 0x00000008, +0x00060041, 0x0000001d, 0x00000025, 0x00000023, +0x00000016, 0x00000024, 0x0004003d, 0x00000010, +0x00000026, 0x00000025, 0x00050085, 0x00000010, +0x00000027, 0x0000001f, 0x00000026, 0x00060041, +0x0000001d, 0x00000028, 0x00000014, 0x00000016, +0x00000017, 0x0003003e, 0x00000028, 0x00000027, +0x000100fd, 0x00010038 }; +} // namespace kp + + diff --git a/shaders/hlsl/computeheadless.comp b/src/shaders/hlsl/computeheadless.comp similarity index 100% rename from shaders/hlsl/computeheadless.comp rename to src/shaders/hlsl/computeheadless.comp From 2bf799eeda33f03a92fdac823c830b4965961750 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Tue, 12 Jul 2022 14:29:16 +0200 Subject: [PATCH 067/107] Docs for building shaders Signed-off-by: Fabian Sauter --- docs/overview/build-system.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/overview/build-system.rst b/docs/overview/build-system.rst index 370510115..f5310bf58 100644 --- a/docs/overview/build-system.rst +++ b/docs/overview/build-system.rst @@ -44,6 +44,8 @@ This by default configures without any of the extra build tasks (such as buildin - Explicitly disable debug layers even on debug. * - -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON - Whether to check if your driver supports the Vulkan Header version you are linking against. This might be useful in case you build shared on a different system than you run later. + * - -DKOMPUTE_OPT_BUILD_SHADERS=OFF + - Rebuilds all compute shaders during compilation and does not use the already precompiled versions. Requires glslangValidator to be installed on your system. * - -DKOMPUTE_OPT_USE_BUILD_IN_SPDLOG=ON - Use the built-in version of Spdlog. * - -DKOMPUTE_OPT_USE_BUILD_IN_FMT=ON From 4e9cebb308f111ce2aa7c0b30ab6640b95b1cbe3 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Mon, 18 Jul 2022 12:17:05 +0200 Subject: [PATCH 068/107] BUILD_IN -> BUILT_IN Signed-off-by: Fabian Sauter --- CMakeLists.txt | 24 ++++++++++++------------ cmake/deprecation_warnings.cmake | 2 +- docs/overview/build-system.rst | 14 +++++++------- src/CMakeLists.txt | 2 +- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 35533b326..0ba4ef9b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,12 +95,12 @@ kompute_option(KOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK "Whether to check if you kompute_option(KOMPUTE_OPT_BUILD_SHADERS "Rebuilds all compute shaders during compilation and does not use the already precompiled versions. Requires glslangValidator to be installed on your system." OFF) # External components -kompute_option(KOMPUTE_OPT_USE_BUILD_IN_SPDLOG "Use the built-in version of Spdlog." ON) -kompute_option(KOMPUTE_OPT_USE_BUILD_IN_FMT "Use the built-in version of fmt." ON) -kompute_option(KOMPUTE_OPT_USE_BUILD_IN_GOOGLE_TEST "Use the built-in version of GoogleTest." ON) -kompute_option(KOMPUTE_OPT_USE_BUILD_IN_PYBIND11 "Use the built-in version of pybind11." ON) -kompute_option(KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER "Use the built-in version of Vulkan Headers. This could be helpful in case your system Vulkan Headers are to new for your driver. If you set this to false, please make sure your system Vulkan Header are supported by your driver." ON) -kompute_option_string(KOMPUTE_OPT_BUILD_IN_VULKAN_HEADER_TAG "The git tag used for the built-in Vulkan Headers when 'KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER' is enabled. A list of tags can be found here: https://github.com/KhronosGroup/Vulkan-Headers/tags" "v1.2.203") +kompute_option(KOMPUTE_OPT_USE_BUILT_IN_SPDLOG "Use the built-in version of Spdlog." ON) +kompute_option(KOMPUTE_OPT_USE_BUILT_IN_FMT "Use the built-in version of fmt." ON) +kompute_option(KOMPUTE_OPT_USE_BUILT_IN_GOOGLE_TEST "Use the built-in version of GoogleTest." ON) +kompute_option(KOMPUTE_OPT_USE_BUILT_IN_PYBIND11 "Use the built-in version of pybind11." ON) +kompute_option(KOMPUTE_OPT_USE_BUILT_IN_VULKAN_HEADER "Use the built-in version of Vulkan Headers. This could be helpful in case your system Vulkan Headers are to new for your driver. If you set this to false, please make sure your system Vulkan Header are supported by your driver." ON) +kompute_option_string(KOMPUTE_OPT_BUILT_IN_VULKAN_HEADER_TAG "The git tag used for the built-in Vulkan Headers when 'KOMPUTE_OPT_USE_BUILT_IN_VULKAN_HEADER' is enabled. A list of tags can be found here: https://github.com/KhronosGroup/Vulkan-Headers/tags" "v1.2.203") message(STATUS "=======================================================") # #################################################### @@ -122,9 +122,9 @@ if(NOT KOMPUTE_OPT_ANDROID_BUILD) find_package(Vulkan REQUIRED) endif() -if(KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER) +if(KOMPUTE_OPT_USE_BUILT_IN_VULKAN_HEADER) FetchContent_Declare(vulkan_header GIT_REPOSITORY https://github.com/KhronosGroup/Vulkan-Headers.git - GIT_TAG ${KOMPUTE_OPT_BUILD_IN_VULKAN_HEADER_TAG}) # Source: https://github.com/KhronosGroup/Vulkan-Headers/tags + GIT_TAG ${KOMPUTE_OPT_BUILT_IN_VULKAN_HEADER_TAG}) # Source: https://github.com/KhronosGroup/Vulkan-Headers/tags FetchContent_MakeAvailable(vulkan_header) if(NOT KOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK) @@ -140,7 +140,7 @@ endif() # Spdlog if(NOT KOMPUTE_OPT_LOG_LEVEL_DISABLED) - if(KOMPUTE_OPT_USE_BUILD_IN_SPDLOG) + if(KOMPUTE_OPT_USE_BUILT_IN_SPDLOG) set(SPDLOG_INSTALL ${KOMPUTE_OPT_INSTALL}) set(SPDLOG_BUILD_SHARED ${BUILD_SHARED_LIBS}) @@ -153,7 +153,7 @@ if(NOT KOMPUTE_OPT_LOG_LEVEL_DISABLED) endif() # fmt -if(KOMPUTE_OPT_USE_BUILD_IN_FMT) +if(KOMPUTE_OPT_USE_BUILT_IN_FMT) set(FMT_INSTALL ${KOMPUTE_OPT_INSTALL}) FetchContent_Declare(fmt GIT_REPOSITORY https://github.com/fmtlib/fmt.git GIT_TAG 8.1.1) # Source: https://github.com/fmtlib/fmt/releases @@ -164,7 +164,7 @@ endif() # GoogleTest if(KOMPUTE_OPT_BUILD_TESTS) - if(KOMPUTE_OPT_USE_BUILD_IN_GOOGLE_TEST) + if(KOMPUTE_OPT_USE_BUILT_IN_GOOGLE_TEST) FetchContent_Declare(googletest GIT_REPOSITORY https://github.com/google/googletest.git GIT_TAG release-1.11.0) # Source: https://github.com/google/googletest/releases FetchContent_MakeAvailable(googletest) @@ -185,7 +185,7 @@ endif() # pybind11 if(KOMPUTE_OPT_BUILD_PYTHON) - if(KOMPUTE_OPT_USE_BUILD_IN_PYBIND11) + if(KOMPUTE_OPT_USE_BUILT_IN_PYBIND11) FetchContent_Declare(pybind GIT_REPOSITORY https://github.com/pybind/pybind11.git GIT_TAG v2.9.2) # Source: https://github.com/pybind/pybind11/releases FetchContent_MakeAvailable(pybind) diff --git a/cmake/deprecation_warnings.cmake b/cmake/deprecation_warnings.cmake index 9d6337376..1ed1f4555 100644 --- a/cmake/deprecation_warnings.cmake +++ b/cmake/deprecation_warnings.cmake @@ -1,5 +1,5 @@ if(KOMPUTE_OPT_REPO_SUBMODULE_BUILD) - message(FATAL_ERROR "'KOMPUTE_OPT_REPO_SUBMODULE_BUILD' got replaced by 'KOMPUTE_OPT_USE_BUILD_IN_SPDLOG', 'KOMPUTE_OPT_USE_BUILD_IN_FMT', 'KOMPUTE_OPT_USE_BUILD_IN_GOOGLE_TEST', 'KOMPUTE_OPT_USE_BUILD_IN_PYBIND11' and 'KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER'. Please use them instead.") + message(FATAL_ERROR "'KOMPUTE_OPT_REPO_SUBMODULE_BUILD' got replaced by 'KOMPUTE_OPT_USE_BUILT_IN_SPDLOG', 'KOMPUTE_OPT_USE_BUILT_IN_FMT', 'KOMPUTE_OPT_USE_BUILT_IN_GOOGLE_TEST', 'KOMPUTE_OPT_USE_BUILT_IN_PYBIND11' and 'KOMPUTE_OPT_USE_BUILT_IN_VULKAN_HEADER'. Please use them instead.") endif() if(KOMPUTE_OPT_BUILD_AS_SHARED_LIB) diff --git a/docs/overview/build-system.rst b/docs/overview/build-system.rst index f5310bf58..e5c454932 100644 --- a/docs/overview/build-system.rst +++ b/docs/overview/build-system.rst @@ -46,18 +46,18 @@ This by default configures without any of the extra build tasks (such as buildin - Whether to check if your driver supports the Vulkan Header version you are linking against. This might be useful in case you build shared on a different system than you run later. * - -DKOMPUTE_OPT_BUILD_SHADERS=OFF - Rebuilds all compute shaders during compilation and does not use the already precompiled versions. Requires glslangValidator to be installed on your system. - * - -DKOMPUTE_OPT_USE_BUILD_IN_SPDLOG=ON + * - -DKOMPUTE_OPT_USE_BUILT_IN_SPDLOG=ON - Use the built-in version of Spdlog. - * - -DKOMPUTE_OPT_USE_BUILD_IN_FMT=ON + * - -DKOMPUTE_OPT_USE_BUILT_IN_FMT=ON - Use the built-in version of fmt. - * - -DKOMPUTE_OPT_USE_BUILD_IN_GOOGLE_TEST=ON + * - -DKOMPUTE_OPT_USE_BUILT_IN_GOOGLE_TEST=ON - Use the built-in version of GoogleTest. - * - -DKOMPUTE_OPT_USE_BUILD_IN_PYBIND11=ON + * - -DKOMPUTE_OPT_USE_BUILT_IN_PYBIND11=ON - Use the built-in version of pybind11. - * - -DKOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER=ON + * - -DKOMPUTE_OPT_USE_BUILT_IN_VULKAN_HEADER=ON - Use the built-in version of Vulkan Headers. This could be helpful in case your system Vulkan Headers are to new for your driver. If you set this to false, please make sure your system Vulkan Header are supported by your driver. - * - -DKOMPUTE_OPT_BUILD_IN_VULKAN_HEADER_TAG="v1.2.203" - - The git tag used for the built-in Vulkan Headers when 'KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER' is enabled. A list of tags can be found here: https://github.com/KhronosGroup/Vulkan-Headers/tags + * - -DKOMPUTE_OPT_BUILT_IN_VULKAN_HEADER_TAG="v1.2.203" + - The git tag used for the built-in Vulkan Headers when 'KOMPUTE_OPT_USE_BUILT_IN_VULKAN_HEADER' is enabled. A list of tags can be found here: https://github.com/KhronosGroup/Vulkan-Headers/tags Compile Flags ~~~~~~~~~~~~~ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index eebe6104c..f080af940 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -82,7 +82,7 @@ if(KOMPUTE_OPT_BUILD_PYTHON) target_link_libraries(kompute PRIVATE pybind11::headers ${PYTHON_LIBRARIES}) endif() -if(KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER) +if(KOMPUTE_OPT_USE_BUILT_IN_VULKAN_HEADER) target_link_libraries(kompute PUBLIC Vulkan-Headers) endif() From 1d99aebbfd27802c717359f446063711cbeb5ca1 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Mon, 18 Jul 2022 12:20:20 +0200 Subject: [PATCH 069/107] Completely removed main from tests Signed-off-by: Fabian Sauter --- test/CMakeLists.txt | 2 +- test/TestAsyncOperations.cpp | 12 ------------ test/TestDestroy.cpp | 12 ------------ test/TestLogisticRegression.cpp | 12 ------------ test/TestManager.cpp | 12 ------------ test/TestMultipleAlgoExecutions.cpp | 12 ------------ test/TestOpShadersFromStringAndFile.cpp | 12 ------------ test/TestOpTensorCopy.cpp | 12 ------------ test/TestOpTensorCreate.cpp | 12 ------------ test/TestOpTensorSync.cpp | 12 ------------ test/TestPushConstant.cpp | 12 ------------ test/TestSequence.cpp | 12 ------------ test/TestSpecializationConstant.cpp | 12 ------------ test/TestTensor.cpp | 12 ------------ test/TestWorkgroup.cpp | 12 ------------ 15 files changed, 1 insertion(+), 169 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index eb52d9b52..6f1ad80c6 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -13,7 +13,7 @@ add_subdirectory(shaders) macro(add_kompute_test _TEST_NAME) add_executable("${_TEST_NAME}_tests" "Test${_TEST_NAME}.cpp" ${ARGN}) - target_link_libraries("${_TEST_NAME}_tests" PRIVATE GTest::GTest + target_link_libraries("${_TEST_NAME}_tests" PRIVATE GTest::gtest_main kompute::kompute kp_logger test_shaders diff --git a/test/TestAsyncOperations.cpp b/test/TestAsyncOperations.cpp index 91a8fab1b..d549dda41 100644 --- a/test/TestAsyncOperations.cpp +++ b/test/TestAsyncOperations.cpp @@ -259,15 +259,3 @@ 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_OPT_LOG_LEVEL_DISABLED - logger::setupLogger(); -#endif - - return RUN_ALL_TESTS(); -} diff --git a/test/TestDestroy.cpp b/test/TestDestroy.cpp index c58557bc7..f6b92cd90 100644 --- a/test/TestDestroy.cpp +++ b/test/TestDestroy.cpp @@ -140,15 +140,3 @@ TEST(TestDestroy, TestDestroySequenceSingle) } } } - -int -main(int argc, char* argv[]) -{ - testing::InitGoogleTest(&argc, argv); - -#if !KOMPUTE_OPT_LOG_LEVEL_DISABLED - logger::setupLogger(); -#endif - - return RUN_ALL_TESTS(); -} diff --git a/test/TestLogisticRegression.cpp b/test/TestLogisticRegression.cpp index 072463a18..6b417a94c 100644 --- a/test/TestLogisticRegression.cpp +++ b/test/TestLogisticRegression.cpp @@ -157,15 +157,3 @@ TEST(TestLogisticRegression, TestMainLogisticRegressionManualCopy) bIn->data()[0]); } } - -int -main(int argc, char* argv[]) -{ - testing::InitGoogleTest(&argc, argv); - -#if !KOMPUTE_OPT_LOG_LEVEL_DISABLED - logger::setupLogger(); -#endif - - return RUN_ALL_TESTS(); -} diff --git a/test/TestManager.cpp b/test/TestManager.cpp index 5b78d5c7f..a7e488d11 100644 --- a/test/TestManager.cpp +++ b/test/TestManager.cpp @@ -106,15 +106,3 @@ TEST(TestManager, TestClearDestroy) mgr.destroy(); } - -int -main(int argc, char* argv[]) -{ - testing::InitGoogleTest(&argc, argv); - -#if !KOMPUTE_OPT_LOG_LEVEL_DISABLED - logger::setupLogger(); -#endif - - return RUN_ALL_TESTS(); -} diff --git a/test/TestMultipleAlgoExecutions.cpp b/test/TestMultipleAlgoExecutions.cpp index 75547b86c..f3d7315ba 100644 --- a/test/TestMultipleAlgoExecutions.cpp +++ b/test/TestMultipleAlgoExecutions.cpp @@ -271,15 +271,3 @@ TEST(TestMultipleAlgoExecutions, TestAlgorithmUtilFunctions) EXPECT_EQ(algorithm->getPushConstants(), pushConsts); EXPECT_EQ(algorithm->getSpecializationConstants(), specConsts); } - -int -main(int argc, char* argv[]) -{ - testing::InitGoogleTest(&argc, argv); - -#if !KOMPUTE_OPT_LOG_LEVEL_DISABLED - logger::setupLogger(); -#endif - - return RUN_ALL_TESTS(); -} diff --git a/test/TestOpShadersFromStringAndFile.cpp b/test/TestOpShadersFromStringAndFile.cpp index 12948d780..c95f2f516 100644 --- a/test/TestOpShadersFromStringAndFile.cpp +++ b/test/TestOpShadersFromStringAndFile.cpp @@ -108,15 +108,3 @@ TEST(TestOpAlgoCreate, ShaderCompiledDataFromConstructor) // EXPECT_EQ(tensorA->vector(), std::vector({ 0, 1, 2 })); // EXPECT_EQ(tensorB->vector(), std::vector({ 3, 4, 5 })); //} - -int -main(int argc, char* argv[]) -{ - testing::InitGoogleTest(&argc, argv); - -#if !KOMPUTE_OPT_LOG_LEVEL_DISABLED - logger::setupLogger(); -#endif - - return RUN_ALL_TESTS(); -} diff --git a/test/TestOpTensorCopy.cpp b/test/TestOpTensorCopy.cpp index 2ebb50c2a..22e8130c7 100644 --- a/test/TestOpTensorCopy.cpp +++ b/test/TestOpTensorCopy.cpp @@ -157,15 +157,3 @@ TEST(TestOpTensorCopy, SingleTensorShouldFail) EXPECT_THROW(mgr.sequence()->eval({ tensorA }), std::runtime_error); } - -int -main(int argc, char* argv[]) -{ - testing::InitGoogleTest(&argc, argv); - -#if !KOMPUTE_OPT_LOG_LEVEL_DISABLED - logger::setupLogger(); -#endif - - return RUN_ALL_TESTS(); -} diff --git a/test/TestOpTensorCreate.cpp b/test/TestOpTensorCreate.cpp index ec725915a..c3508ff89 100644 --- a/test/TestOpTensorCreate.cpp +++ b/test/TestOpTensorCreate.cpp @@ -58,15 +58,3 @@ TEST(TestOpTensorCreate, ExceptionOnZeroSizeTensor) std::string::npos); } } - -int -main(int argc, char* argv[]) -{ - testing::InitGoogleTest(&argc, argv); - -#if !KOMPUTE_OPT_LOG_LEVEL_DISABLED - logger::setupLogger(); -#endif - - return RUN_ALL_TESTS(); -} diff --git a/test/TestOpTensorSync.cpp b/test/TestOpTensorSync.cpp index fa4f76932..b59ee1481 100644 --- a/test/TestOpTensorSync.cpp +++ b/test/TestOpTensorSync.cpp @@ -53,15 +53,3 @@ 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_OPT_LOG_LEVEL_DISABLED - logger::setupLogger(); -#endif - - return RUN_ALL_TESTS(); -} diff --git a/test/TestPushConstant.cpp b/test/TestPushConstant.cpp index ec03bc08c..1356425cf 100644 --- a/test/TestPushConstant.cpp +++ b/test/TestPushConstant.cpp @@ -390,15 +390,3 @@ TEST(TestPushConstants, TestConstantsDouble) } } } - -int -main(int argc, char* argv[]) -{ - testing::InitGoogleTest(&argc, argv); - -#if !KOMPUTE_OPT_LOG_LEVEL_DISABLED - logger::setupLogger(); -#endif - - return RUN_ALL_TESTS(); -} diff --git a/test/TestSequence.cpp b/test/TestSequence.cpp index 5e5e3254c..d99107a96 100644 --- a/test/TestSequence.cpp +++ b/test/TestSequence.cpp @@ -243,15 +243,3 @@ TEST(TestSequence, CorrectSequenceRunningError) EXPECT_EQ(tensorOut->vector(), std::vector({ 2, 4, 6 })); } - -int -main(int argc, char* argv[]) -{ - testing::InitGoogleTest(&argc, argv); - -#if !KOMPUTE_OPT_LOG_LEVEL_DISABLED - logger::setupLogger(); -#endif - - return RUN_ALL_TESTS(); -} diff --git a/test/TestSpecializationConstant.cpp b/test/TestSpecializationConstant.cpp index 3140ba5b4..7f15f8443 100644 --- a/test/TestSpecializationConstant.cpp +++ b/test/TestSpecializationConstant.cpp @@ -102,15 +102,3 @@ TEST(TestSpecializationConstants, TestConstantsInt) } } } - -int -main(int argc, char* argv[]) -{ - testing::InitGoogleTest(&argc, argv); - -#if !KOMPUTE_OPT_LOG_LEVEL_DISABLED - logger::setupLogger(); -#endif - - return RUN_ALL_TESTS(); -} diff --git a/test/TestTensor.cpp b/test/TestTensor.cpp index 0a53220dd..7eeff4af3 100644 --- a/test/TestTensor.cpp +++ b/test/TestTensor.cpp @@ -44,15 +44,3 @@ TEST(TestTensor, DataTypes) EXPECT_EQ(tensor->dataType(), kp::Tensor::TensorDataTypes::eDouble); } } - -int -main(int argc, char* argv[]) -{ - testing::InitGoogleTest(&argc, argv); - -#if !KOMPUTE_OPT_LOG_LEVEL_DISABLED - logger::setupLogger(); -#endif - - return RUN_ALL_TESTS(); -} diff --git a/test/TestWorkgroup.cpp b/test/TestWorkgroup.cpp index a2e41865b..914ee721e 100644 --- a/test/TestWorkgroup.cpp +++ b/test/TestWorkgroup.cpp @@ -63,15 +63,3 @@ TEST(TestWorkgroup, TestSimpleWorkgroup) } } } - -int -main(int argc, char* argv[]) -{ - testing::InitGoogleTest(&argc, argv); - -#if !KOMPUTE_OPT_LOG_LEVEL_DISABLED - logger::setupLogger(); -#endif - - return RUN_ALL_TESTS(); -} From 6236f5b472a4ce92af5dc734e766e3fff618999c Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Mon, 18 Jul 2022 12:47:53 +0200 Subject: [PATCH 070/107] Improved find_program check and errors Signed-off-by: Fabian Sauter --- cmake/check_vulkan_version.cmake | 6 +++--- cmake/vulkan_shader_compiler.cmake | 2 +- config/FindSphinx.cmake | 14 +++++++++----- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/cmake/check_vulkan_version.cmake b/cmake/check_vulkan_version.cmake index ec69c1044..34d9fd907 100644 --- a/cmake/check_vulkan_version.cmake +++ b/cmake/check_vulkan_version.cmake @@ -41,12 +41,12 @@ function(check_vulkan_version) message(FATAL_ERROR "Invalid Vulkan include directory given. Try calling 'find_package(Vulkan REQUIRED)' before you call this function or set 'Vulkan_INCLUDE_DIR' manually!") return() endif() - message(STATUS "Found Vulkan Header version ${VULKAN_HEADER_VERSION}.") + message(STATUS "Found Vulkan Header version: ${VULKAN_HEADER_VERSION}") # Get Vulkan version supported by driver find_program(VULKAN_INFO_PATH NAMES vulkaninfo) - if(${VULKAN_INFO_PATH}) - message(FATAL_ERROR "vulkaninfo not found. The Vulkan SDK might not be installed properly.") + if(VULKAN_INFO_PATH STREQUAL "VULKAN_INFO_PATH-NOTFOUND") + message(FATAL_ERROR "vulkaninfo not found. The Vulkan SDK might not be installed properly. If you know what you are doing, you can disable the Vulkan version check by setting 'KOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK' to 'ON'. (-DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON)") return() endif() diff --git a/cmake/vulkan_shader_compiler.cmake b/cmake/vulkan_shader_compiler.cmake index 7c10cc831..acc27b57c 100644 --- a/cmake/vulkan_shader_compiler.cmake +++ b/cmake/vulkan_shader_compiler.cmake @@ -1,6 +1,6 @@ function(vulkan_compile_shader) find_program(GLS_LANG_VALIDATOR_PATH NAMES glslangValidator) - if(${GLS_LANG_VALIDATOR_PATH}) + if(GLS_LANG_VALIDATOR_PATH STREQUAL "GLS_LANG_VALIDATOR_PATH-NOTFOUND") message(FATAL_ERROR "glslangValidator not found.") return() endif() diff --git a/config/FindSphinx.cmake b/config/FindSphinx.cmake index 017ef1724..c645ccc9f 100644 --- a/config/FindSphinx.cmake +++ b/config/FindSphinx.cmake @@ -1,11 +1,15 @@ - -#Look for an executable called sphinx-build +# Look for an executable called sphinx-build find_program(SPHINX_EXECUTABLE - NAMES sphinx-build - DOC "Path to sphinx-build executable") + NAMES sphinx-build + DOC "Path to sphinx-build executable") + +if(SPHINX_EXECUTABLE STREQUAL "SPHINX_EXECUTABLE-NOTFOUND") + message(FATAL_ERROR "sphinx-build not found.") +endif() include(FindPackageHandleStandardArgs) -#Handle standard arguments to find_package like REQUIRED and QUIET + +# Handle standard arguments to find_package like REQUIRED and QUIET find_package_handle_standard_args( Sphinx "Failed to find sphinx-build executable" From 35b5e34b6cfaafc1e9d6861100b523997488dc39 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Mon, 18 Jul 2022 13:00:32 +0200 Subject: [PATCH 071/107] Further enhanced the vulkan version check Signed-off-by: Fabian Sauter --- cmake/check_vulkan_version.cmake | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cmake/check_vulkan_version.cmake b/cmake/check_vulkan_version.cmake index 34d9fd907..5bbcf6cb4 100644 --- a/cmake/check_vulkan_version.cmake +++ b/cmake/check_vulkan_version.cmake @@ -46,7 +46,7 @@ function(check_vulkan_version) # Get Vulkan version supported by driver find_program(VULKAN_INFO_PATH NAMES vulkaninfo) if(VULKAN_INFO_PATH STREQUAL "VULKAN_INFO_PATH-NOTFOUND") - message(FATAL_ERROR "vulkaninfo not found. The Vulkan SDK might not be installed properly. If you know what you are doing, you can disable the Vulkan version check by setting 'KOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK' to 'ON'. (-DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON)") + message(FATAL_ERROR "vulkaninfo not found. The Vulkan SDK might not be installed properly. If you know what you are doing, you can disable the Vulkan version check by setting 'KOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK' to 'ON' (-DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON).") return() endif() @@ -56,6 +56,14 @@ function(check_vulkan_version) if(NOT ${VULKAN_INFO_RETURN} EQUAL 0) message(FATAL_ERROR "Running vulkaninfo failed with return code ${VULKAN_INFO_RETURN}. Make sure you have 'vulkan-tools' installed. Result:\n${VULKAN_INFO_OUTPUT}?") return() + else() + message(STATUS "Running vulkaninfo was successful. Parsing the output...") + endif() + + # Check if running vulkaninfo was successfully + string(FIND "${VULKAN_INFO_OUTPUT}" "Vulkan Instance Version" VULKAN_INFO_SUCCESSFUL) + if(VULKAN_INFO_SUCCESSFUL LESS 0) + message(FATAL_ERROR "Running vulkaninfo failed. Make sure you have 'vulkan-tools' installed and DISPLAY is configured. If you know what you are doing, you can disable the Vulkan version check by setting 'KOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK' to 'ON' (-DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON). Result:\n${VULKAN_INFO_OUTPUT}?") endif() string(REGEX MATCHALL "(GPU[0-9]+)" GPU_IDS "${VULKAN_INFO_OUTPUT}") From 30563791607ffac2233fbffd47882aac77c26a6a Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Mon, 18 Jul 2022 13:05:06 +0200 Subject: [PATCH 072/107] Improved the Vulkan not found error message Signed-off-by: Fabian Sauter --- cmake/check_vulkan_version.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/check_vulkan_version.cmake b/cmake/check_vulkan_version.cmake index 5bbcf6cb4..56d8c44f7 100644 --- a/cmake/check_vulkan_version.cmake +++ b/cmake/check_vulkan_version.cmake @@ -131,7 +131,7 @@ function(check_vulkan_version) endforeach() if("${VALID_GPU}" STREQUAL "") - message(FATAL_ERROR "None of your GPUs supports Vulkan Header ${VULKAN_HEADER_VERSION}. Please try updating your driver, or downgrade your Vulkan headers.") + message(FATAL_ERROR "None of your GPUs supports Vulkan Header ${VULKAN_HEADER_VERSION}. Please try updating your driver, or downgrade your Vulkan headers. If you know what you are doing, you can disable the Vulkan version check by setting 'KOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK' to 'ON' (-DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON).") else() message("Valid GPU (${VALID_GPU}) for Vulkan header version ${VULKAN_HEADER_VERSION} found. ${VALID_GPU} supports up to Vulkan ${VALID_VULKAN_VERSION}.") endif() From b97b3c210df35882bd2cdc7624c06364ebb36661 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Mon, 18 Jul 2022 13:12:46 +0200 Subject: [PATCH 073/107] Removed additional endif() for coverage Signed-off-by: Fabian Sauter --- cmake/code_coverage.cmake | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cmake/code_coverage.cmake b/cmake/code_coverage.cmake index b1f748668..7fb6ce264 100644 --- a/cmake/code_coverage.cmake +++ b/cmake/code_coverage.cmake @@ -1,9 +1,11 @@ # Code coverage set(CMAKE_BUILD_TYPE COVERAGE CACHE INTERNAL "Coverage build enabled") message(STATUS "Enabling gcov support") + if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") set(COVERAGE_FLAG "--coverage") endif() + set(CMAKE_CXX_FLAGS_COVERAGE "-g -O0 ${COVERAGE_FLAG} -fprofile-arcs -ftest-coverage" CACHE STRING "Flags used by the C++ compiler during coverage builds." @@ -28,7 +30,6 @@ set(CODECOV_FILENAME_LCOV_INFO_FULL lcov_full.info) set(CODECOV_DIR_HTML ${CODECOV_DIR}html/) mark_as_advanced(CMAKE_CXX_FLAGS_COVERAGE - CMAKE_C_FLAGS_COVERAGE - CMAKE_EXE_LINKER_FLAGS_COVERAGE - CMAKE_SHARED_LINKER_FLAGS_COVERAGE) -endif() + CMAKE_C_FLAGS_COVERAGE + CMAKE_EXE_LINKER_FLAGS_COVERAGE + CMAKE_SHARED_LINKER_FLAGS_COVERAGE) From c1c95f64981d494f8846cd306ab41045ef093e03 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Fri, 22 Jul 2022 13:35:45 +0200 Subject: [PATCH 074/107] removed spdlog include outside logger Signed-off-by: Fabian Sauter --- src/Manager.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Manager.cpp b/src/Manager.cpp index d50704228..3f1f77f3a 100644 --- a/src/Manager.cpp +++ b/src/Manager.cpp @@ -7,7 +7,6 @@ #include "kompute/Manager.hpp" #include "kompute/logger/Logger.hpp" -#include "spdlog/common.h" namespace kp { From 2c68588c713ad3d1db51f623152e5021f9540c49 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Fri, 22 Jul 2022 13:49:13 +0200 Subject: [PATCH 075/107] Fixed checking for disabled logging Signed-off-by: Fabian Sauter --- src/Manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Manager.cpp b/src/Manager.cpp index 3f1f77f3a..53bcaa1ac 100644 --- a/src/Manager.cpp +++ b/src/Manager.cpp @@ -320,7 +320,7 @@ Manager::createDevice(const std::vector& familyQueueIndices, this->mPhysicalDevice = std::make_shared(physicalDevice); -#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_INFO +#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_INFO && SPDLOG_ACTIVE_LEVEL != SPDLOG_LEVEL_OFF vk::PhysicalDeviceProperties physicalDeviceProperties = physicalDevice.getProperties(); #endif From 85396abd54935f5797100857722a84904e37aac3 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Fri, 22 Jul 2022 13:57:31 +0200 Subject: [PATCH 076/107] Linking fmt public since it's included in a header Signed-off-by: Fabian Sauter --- src/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f080af940..723082887 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -68,12 +68,12 @@ if(KOMPUTE_OPT_ANDROID_BUILD) android kp_logger kp_shader - PRIVATE fmt::fmt) + fmt::fmt) else() target_link_libraries(kompute PUBLIC Vulkan::Vulkan kp_logger kp_shader - PRIVATE fmt::fmt) + fmt::fmt) endif() if(KOMPUTE_OPT_BUILD_PYTHON) From 0ab35094378f127512c18f616a9d330641f959da Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Fri, 22 Jul 2022 14:56:46 +0200 Subject: [PATCH 077/107] Fixed ctest integration Signed-off-by: Fabian Sauter --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ba4ef9b0..676360ef0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -248,6 +248,7 @@ endfunction() add_subdirectory(src) if(KOMPUTE_OPT_BUILD_TESTS) + enable_testing() add_subdirectory(test) endif() From ca2744f4f14e0e0a63d6b2a616fade53749904c8 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Fri, 22 Jul 2022 15:41:40 +0200 Subject: [PATCH 078/107] Removed additional '}' in docs CMake Signed-off-by: Fabian Sauter --- docs/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index c6bb09f4b..53dbdc4b1 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -28,7 +28,7 @@ set(SPHINX_BUILD set(CODECOV_DOCS_DIR ${SPHINX_BUILD}/codecov/) set(CODECOV_DOCS_INDEX_FILE - ${CODECOV_DOCS_DIR}/index.html}) + ${CODECOV_DOCS_DIR}/index.html) # Perform replacement with cmake vars inside Doxifine.in configure_file(${DOXYFILE_IN} ${DOXYFILE_OUT} @ONLY) From 652dad3d387fdd7f73a007379582362eca6fc7ee Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Fri, 22 Jul 2022 15:56:18 +0200 Subject: [PATCH 079/107] Updated Makefile to the new build Signed-off-by: Fabian Sauter --- Makefile | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 3142ebc10..7a9065c9e 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ VCPKG_WIN_PATH ?= "C:\\Users\\axsau\\Programming\\lib\\vcpkg\\scripts\\buildsyst VCPKG_UNIX_PATH ?= "/c/Users/axsau/Programming/lib/vcpkg/scripts/buildsystems/vcpkg.cmake" # These are the tests that don't work with swiftshader but can be run directly with vulkan -FILTER_TESTS ?= "-TestAsyncOperations.TestManagerParallelExecution:TestSequence.SequenceTimestamps:TestPushConstants.TestConstantsDouble" +FILTER_TESTS_REGEX ?= "(kompute_AsyncOperations_tests)|(kompute_PushConstant_tests)" ifeq ($(OS),Windows_NT) # is Windows_NT on XP, 2000, 7, Vista, 10... CMAKE_BIN ?= "C:\Program Files\CMake\bin\cmake.exe" @@ -56,15 +56,14 @@ MK_KOMPUTE_EXTRA_CXX_FLAGS ?= "" mk_cmake: cmake \ -Bbuild \ - -DKOMPUTE_EXTRA_CXX_FLAGS=$(MK_KOMPUTE_EXTRA_CXX_FLAGS) \ + -DCMAKE_CXX_FLAGS=$(MK_KOMPUTE_EXTRA_CXX_FLAGS) \ -DCMAKE_BUILD_TYPE=$(MK_BUILD_TYPE) \ -DCMAKE_INSTALL_PREFIX=$(MK_INSTALL_PATH) \ - -DKOMPUTE_OPT_INSTALL=1 \ - -DKOMPUTE_OPT_BUILD_TESTS=1 \ - -DKOMPUTE_OPT_BUILD_DOCS=1 \ - -DKOMPUTE_OPT_BUILD_SHADERS=1 \ - -DKOMPUTE_OPT_ENABLE_SPDLOG=1 \ - -DKOMPUTE_OPT_CODE_COVERAGE=1 \ + -DKOMPUTE_OPT_INSTALL=ON \ + -DKOMPUTE_OPT_BUILD_TESTS=ON \ + -DKOMPUTE_OPT_BUILD_DOCS=ON \ + -DKOMPUTE_OPT_BUILD_SHADERS=ON \ + -DKOMPUTE_OPT_CODE_COVERAGE=ON \ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ $(MK_CMAKE_EXTRA_FLAGS) \ -G "Unix Makefiles" @@ -79,13 +78,25 @@ mk_build_kompute: cmake --build build/. --target kompute --parallel mk_build_tests: - cmake --build build/ --target test_kompute --parallel + cmake --build build/. --target AsyncOperations_tests \ + Destroy_tests \ + LogisticRegression_tests \ + Manager_tests \ + MultipleAlgoExecutions_tests \ + OpShadersFromStringAndFile_tests \ + OpTensorCopy_tests \ + OpTensorCreate_tests \ + PushConstant_tests \ + Sequence_tests \ + SpecializationConstant_tests \ + Workgroup_tests \ + --parallel mk_run_docs: mk_build_docs (cd build/docs/sphinx && python2.7 -m SimpleHTTPServer) mk_run_tests: mk_build_tests - ./build/test/test_kompute --gtest_filter=$(FILTER_TESTS) + ctest -vv --exclude-regex $(FILTER_TESTS_REGEX) --test-dir build/. mk_build_swiftshader_library: git clone https://github.com/google/swiftshader || echo "Assuming already cloned" @@ -112,12 +123,11 @@ vs_cmake: -DCMAKE_TOOLCHAIN_FILE=$(VCPKG_WIN_PATH) \ -DKOMPUTE_EXTRA_CXX_FLAGS=$(VS_KOMPUTE_EXTRA_CXX_FLAGS) \ -DCMAKE_INSTALL_PREFIX=$(VS_INSTALL_PATH) \ - -DKOMPUTE_OPT_INSTALL=1 \ - -DKOMPUTE_OPT_BUILD_TESTS=1 \ - -DKOMPUTE_OPT_BUILD_SHADERS=1 \ - -DKOMPUTE_OPT_ENABLE_SPDLOG=1 \ - -DKOMPUTE_OPT_CODE_COVERAGE=0 \ - -DKOMPUTE_OPT_BUILD_DOCS=0 \ + -DKOMPUTE_OPT_INSTALL=ON \ + -DKOMPUTE_OPT_BUILD_TESTS=ON \ + -DKOMPUTE_OPT_BUILD_SHADERS=ON \ + -DKOMPUTE_OPT_CODE_COVERAGE=OFF \ + -DKOMPUTE_OPT_BUILD_DOCS=OFF \ -G "Visual Studio 16 2019" vs_build_all: @@ -139,7 +149,7 @@ vs_run_docs: vs_build_docs (cd build/docs/sphinx && python2.7 -m SimpleHTTPServer) vs_run_tests: vs_build_tests - ./build/test/$(VS_BUILD_TYPE)/test_kompute.exe --gtest_filter=$(FILTER_TESTS) + ctest -vv --exclude-regex $(FILTER_TESTS_REGEX) --test-dir build/. #### PYTHONG #### From 444c8fc1db8dacdf39b187c9114a369af9135479 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Tue, 26 Jul 2022 10:48:57 +0200 Subject: [PATCH 080/107] Spdlog is now optional for logging Signed-off-by: Fabian Sauter --- CMakeLists.txt | 29 ++++--- src/Manager.cpp | 2 +- src/include/kompute/logger/Logger.hpp | 107 +++++++++++++++++++++++--- src/logger/CMakeLists.txt | 23 ++++-- src/logger/Logger.cpp | 82 +++----------------- 5 files changed, 144 insertions(+), 99 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 676360ef0..a25f44162 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ project(kompute VERSION 0.8.1 LANGUAGES CXX) set(CMAKE_CXX_STANDARD 14) -# Only change the folder behaviour if kompute is not a subproject +# Only change the folder behavior if kompute is not a subproject if(${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME}) set_property(GLOBAL PROPERTY USE_FOLDERS ON) set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMake") @@ -88,14 +88,15 @@ kompute_option(KOMPUTE_OPT_INSTALL "Enable if you want to enable installation." # Build options kompute_option(KOMPUTE_OPT_BUILD_PYTHON "Enable if you want to build python bindings." OFF) -kompute_log_level(KOMPUTE_OPT_LOG_LEVEL "Internally we use spdlog for logging. The log level used can be changed here. Possible values: 'Trace', 'Debug', 'Info', 'Warn', 'Error', 'Critical', 'Off', 'Default'. If set to 'Off' spdlog will be deactivated completely. If set to 'Default', the log level will be set to 'Info' for release builds and 'Debug' else." "Default") +kompute_log_level(KOMPUTE_OPT_LOG_LEVEL "Internally we use Spdlog or fmt for logging, depending on the value of 'KOMPUTE_OPT_USE_SPDLOG'. The log level used can be changed here. Possible values: 'Trace', 'Debug', 'Info', 'Warn', 'Error', 'Critical', 'Off', 'Default'. If set to 'Off' logging will be deactivated completely. If set to 'Default', the log level will be set to 'Info' for release builds and 'Debug' else." "Default") +kompute_option(KOMPUTE_OPT_USE_SPDLOG "If enabled, logging via KP_LOG_ will happen through Spdlog instead of plan fmt." OFF) kompute_option(KOMPUTE_OPT_ANDROID_BUILD "Enable android compilation flags required." OFF) kompute_option(KOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS "Explicitly disable debug layers even on debug." OFF) kompute_option(KOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK "Whether to check if your driver supports the Vulkan Header version you are linking against. This might be useful in case you build shared on a different system than you run later." OFF) kompute_option(KOMPUTE_OPT_BUILD_SHADERS "Rebuilds all compute shaders during compilation and does not use the already precompiled versions. Requires glslangValidator to be installed on your system." OFF) # External components -kompute_option(KOMPUTE_OPT_USE_BUILT_IN_SPDLOG "Use the built-in version of Spdlog." ON) +kompute_option(KOMPUTE_OPT_USE_BUILT_IN_SPDLOG "Use the built-in version of Spdlog. Requires 'KOMPUTE_OPT_USE_SPDLOG' to be set to ON in order to have any effect." ON) kompute_option(KOMPUTE_OPT_USE_BUILT_IN_FMT "Use the built-in version of fmt." ON) kompute_option(KOMPUTE_OPT_USE_BUILT_IN_GOOGLE_TEST "Use the built-in version of GoogleTest." ON) kompute_option(KOMPUTE_OPT_USE_BUILT_IN_PYBIND11 "Use the built-in version of pybind11." ON) @@ -139,16 +140,20 @@ else() endif() # Spdlog -if(NOT KOMPUTE_OPT_LOG_LEVEL_DISABLED) - if(KOMPUTE_OPT_USE_BUILT_IN_SPDLOG) - set(SPDLOG_INSTALL ${KOMPUTE_OPT_INSTALL}) - set(SPDLOG_BUILD_SHARED ${BUILD_SHARED_LIBS}) +if(KOMPUTE_OPT_USE_SPDLOG) + add_compile_definitions(KOMPUTE_OPT_USE_SPDLOG=1) - FetchContent_Declare(spdlog GIT_REPOSITORY https://github.com/gabime/spdlog.git - GIT_TAG v1.10.0) # Source: https://github.com/gabime/spdlog/releases - FetchContent_MakeAvailable(spdlog) - else() - find_package(spdlog REQUIRED) + if(NOT KOMPUTE_OPT_LOG_LEVEL_DISABLED) + if(KOMPUTE_OPT_USE_BUILT_IN_SPDLOG) + set(SPDLOG_INSTALL ${KOMPUTE_OPT_INSTALL}) + set(SPDLOG_BUILD_SHARED ${BUILD_SHARED_LIBS}) + + FetchContent_Declare(spdlog GIT_REPOSITORY https://github.com/gabime/spdlog.git + GIT_TAG v1.10.0) # Source: https://github.com/gabime/spdlog/releases + FetchContent_MakeAvailable(spdlog) + else() + find_package(spdlog REQUIRED) + endif() endif() endif() diff --git a/src/Manager.cpp b/src/Manager.cpp index 53bcaa1ac..5e9ee9d31 100644 --- a/src/Manager.cpp +++ b/src/Manager.cpp @@ -320,7 +320,7 @@ Manager::createDevice(const std::vector& familyQueueIndices, this->mPhysicalDevice = std::make_shared(physicalDevice); -#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_INFO && SPDLOG_ACTIVE_LEVEL != SPDLOG_LEVEL_OFF +#if KOMPUTE_OPT_LOG_LEVEL <= KOMPUTE_LOG_LEVEL_INFO vk::PhysicalDeviceProperties physicalDeviceProperties = physicalDevice.getProperties(); #endif diff --git a/src/include/kompute/logger/Logger.hpp b/src/include/kompute/logger/Logger.hpp index f24ad3a80..43f119471 100644 --- a/src/include/kompute/logger/Logger.hpp +++ b/src/include/kompute/logger/Logger.hpp @@ -1,5 +1,14 @@ #pragma once +#define KOMPUTE_LOG_LEVEL_TRACE 0 +#define KOMPUTE_LOG_LEVEL_DEBUG 1 +#define KOMPUTE_LOG_LEVEL_INFO 2 +#define KOMPUTE_LOG_LEVEL_WARN 3 +#define KOMPUTE_LOG_LEVEL_ERROR 4 +#define KOMPUTE_LOG_LEVEL_CRITICAL 5 +#define KOMPUTE_LOG_LEVEL_OFF 6 + +// Logging is disabled entirely. #if KOMPUTE_OPT_LOG_LEVEL_DISABLED #define KP_LOG_TRACE(...) #define KP_LOG_DEBUG(...) @@ -8,10 +17,94 @@ #define KP_LOG_ERROR(...) #else -#include +#if !KOMPUTE_OPT_USE_SPDLOG +#include +#else #include +#endif // !KOMPUTE_OPT_USE_SPDLOG +#include #include #include +namespace logger { +// Setup the logger, note the loglevel can not be set below the CMake log level +// (To change this use -DKOMPUTE_OPT_LOG_LEVEL=...) +void +setupLogger(); + +// Logging is enabled, but we do not use Spdlog. So we use fmt in case nothing +// else is defined, overriding logging. +#if !KOMPUTE_OPT_USE_SPDLOG + +#ifndef KP_LOG_TRACE +#if KOMPUTE_OPT_LOG_LEVEL <= KOMPUTE_LOG_LEVEL_TRACE +#define KP_LOG_TRACE(...) \ + fmt::print("[{} {}] [trace] [{}:{}] {}\n", \ + __DATE__, \ + __TIME__, \ + __FILE__, \ + __LINE__, \ + fmt::format(__VA_ARGS__)) +#else +#define KP_LOG_TRACE(...) +#endif +#endif // !KP_LOG_TRACE + +#ifndef KP_LOG_DEBUG +#if KOMPUTE_OPT_LOG_LEVEL <= KOMPUTE_LOG_LEVEL_DEBUG +#define KP_LOG_DEBUG(...) \ + fmt::print("[{} {}] [debug] [{}:{}] {}\n", \ + __DATE__, \ + __TIME__, \ + __FILE__, \ + __LINE__, \ + fmt::format(__VA_ARGS__)) +#else +#define KP_LOG_DEBUG(...) +#endif +#endif // !KP_LOG_DEBUG + +#ifndef KP_LOG_INFO +#if KOMPUTE_OPT_LOG_LEVEL <= KOMPUTE_LOG_LEVEL_INFO +#define KP_LOG_INFO(...) \ + fmt::print("[{} {}] [info] [{}:{}] {}\n", \ + __DATE__, \ + __TIME__, \ + __FILE__, \ + __LINE__, \ + fmt::format(__VA_ARGS__)) +#else +#define KP_LOG_INFO(...) +#endif +#endif // !KP_LOG_INFO + +#ifndef KP_LOG_WARN +#if KOMPUTE_OPT_LOG_LEVEL <= KOMPUTE_LOG_LEVEL_WARN +#define KP_LOG_WARN(...) \ + fmt::print("[{} {}] [warn] [{}:{}] {}\n", \ + __DATE__, \ + __TIME__, \ + __FILE__, \ + __LINE__, \ + fmt::format(__VA_ARGS__)) +#else +#define KP_LOG_WARN(...) +#endif +#endif // !KP_LOG_WARN + +#ifndef KP_LOG_ERROR +#if KOMPUTE_OPT_LOG_LEVEL <= KOMPUTE_LOG_LEVEL_ERROR +#define KP_LOG_ERROR(...) \ + fmt::print("[{} {}] [error] [{}:{}] {}\n", \ + __DATE__, \ + __TIME__, \ + __FILE__, \ + __LINE__, \ + fmt::format(__VA_ARGS__)) +#else +#define KP_LOG_ERROR(...) +#endif +#endif // !KP_LOG_ERROR +#else #define KP_LOG_TRACE(...) SPDLOG_TRACE(__VA_ARGS__) #define KP_LOG_DEBUG(...) SPDLOG_DEBUG(__VA_ARGS__) @@ -19,20 +112,14 @@ #define KP_LOG_WARN(...) SPDLOG_WARN(__VA_ARGS__) #define KP_LOG_ERROR(...) SPDLOG_ERROR(__VA_ARGS__) -namespace logger { -const std::string logFolder("kompute_logs"); -// Setup the logger, note the loglevel can not be set below the CMake log level -// (To change this use -DKOMPUTE_OPT_LOG_LEVEL=...) -void -setupLogger(); void setLogLevel(spdlog::level::level_enum level); -void -deactivateLogger(); spdlog::level::level_enum getLogLevel(); +#endif // !KOMPUTE_OPT_USE_SPDLOG + std::string setToString(const std::set& set); @@ -43,4 +130,4 @@ std::string vecToString(const std::vector& vec); } // namespace logger -#endif \ No newline at end of file +#endif // KOMPUTE_OPT_LOG_LEVEL_DISABLED \ No newline at end of file diff --git a/src/logger/CMakeLists.txt b/src/logger/CMakeLists.txt index 6132c1d21..b73615a61 100644 --- a/src/logger/CMakeLists.txt +++ b/src/logger/CMakeLists.txt @@ -4,9 +4,14 @@ set(LOGGER_SOURCES Logger.cpp) add_library(kp_logger ${LOGGER_SOURCES}) -if(NOT KOMPUTE_OPT_LOG_LEVEL_DISABLED) - target_link_libraries(kp_logger PUBLIC spdlog::spdlog) -endif() +# Define log levels in code +add_compile_definitions(KOMPUTE_LOG_LEVEL_TRACE=0) +add_compile_definitions(KOMPUTE_LOG_LEVEL_DEBUG=1) +add_compile_definitions(KOMPUTE_LOG_LEVEL_INFO=2) +add_compile_definitions(KOMPUTE_LOG_LEVEL_WARN=3) +add_compile_definitions(KOMPUTE_LOG_LEVEL_ERROR=4) +add_compile_definitions(KOMPUTE_LOG_LEVEL_CRITICAL=5) +add_compile_definitions(KOMPUTE_LOG_LEVEL_OFF=6) if(${KOMPUTE_OPT_LOG_LEVEL} STREQUAL "Trace") set(KOMPUTE_OPT_LOG_LEVEL TRACE) @@ -31,9 +36,17 @@ elseif(${KOMPUTE_OPT_LOG_LEVEL} STREQUAL "Off") message(STATUS "Using log level Off") elseif(${KOMPUTE_OPT_LOG_LEVEL} STREQUAL "Default") set(KOMPUTE_OPT_LOG_LEVEL $,DEBUG,INFO>) - message(STATUS "Setting KOMPUTE_OPT_LOG_LEVEL to according to build type") + message(STATUS "Setting KOMPUTE_OPT_LOG_LEVEL to according to the build type") else() message(FATAL_ERROR "Log level '${KOMPUTE_OPT_LOG_LEVEL}' unknown, use -DKOMPUTE_OPT_LOG_LEVEL={Trace, Debug, Info, Warn, Error, Critical, Off, Default} to set it to a correct value.") endif() -target_compile_definitions(kp_logger INTERFACE SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${KOMPUTE_OPT_LOG_LEVEL}) +# Link depending on how the logger should be setup +if(NOT KOMPUTE_OPT_LOG_LEVEL_DISABLED) + if(KOMPUTE_OPT_USE_SPDLOG) + target_link_libraries(kp_logger PUBLIC spdlog::spdlog) + target_compile_definitions(kp_logger INTERFACE SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${KOMPUTE_OPT_LOG_LEVEL}) + else() + target_link_libraries(kp_logger PUBLIC fmt::fmt) + endif() +endif() diff --git a/src/logger/Logger.cpp b/src/logger/Logger.cpp index bb02023a2..79cb46686 100644 --- a/src/logger/Logger.cpp +++ b/src/logger/Logger.cpp @@ -1,6 +1,7 @@ #include "kompute/logger/Logger.hpp" -#if KOMPUTE_OPT_LOG_LEVEL_DISABLED +#if !KOMPUTE_OPT_LOG_LEVEL_DISABLED +#if !KOMPUTE_OPT_USE_SPDLOG #else #include #include @@ -9,65 +10,22 @@ #include #include #include -#include #include #include #include - -#include -#include - -#ifdef _WIN32 -#include -#include -#endif // _WIN32 +#endif // !KOMPUTE_OPT_USE_SPDLOG namespace logger { -constexpr int THREAD_QUEUE_LENGTH = 8192; -constexpr int FILE_ROTATION_TIME = 1048576 * 5; +#if !KOMPUTE_OPT_USE_SPDLOG -/** - * Should be replaced with: - * std::filesystem::exists(path) - * when switching to cpp17 - **/ -bool -exists(const std::string& path) -{ - struct stat info - {}; - if (stat(path.c_str(), &info) != 0) { - // std::cerr << "Failed to check if '" << path - // << "' exists. Cannot access!\n"; - // assert(false); - return false; - } - return info.st_mode & S_IFDIR; -} - -/** - * Based on: https://stackoverflow.com/a/35109823 - * Should be replaced with: - * std::filesystem::create_directory(path); - * when switching to cpp17 - **/ void -createDir(const std::string& path) +setupLogger() { - int nError = 0; -#if defined(_WIN32) - nError = _mkdir(path.c_str()); // can be used on Windows -#else - mode_t nMode = 0733; // UNIX style permissions - nError = mkdir(path.c_str(), nMode); // can be used on non-Windows -#endif - if (nError != 0) { - std::cerr << "Failed to create '" << path << "' with: " << nError - << '\n'; - assert(false); - } } +#else +constexpr int THREAD_QUEUE_LENGTH = 8192; + void setupLogger() { @@ -82,25 +40,11 @@ setupLogger() setup = true; setupMutex.unlock(); - if (!exists(logger::logFolder)) { - createDir(logger::logFolder); - } spdlog::init_thread_pool(THREAD_QUEUE_LENGTH, 1); spdlog::sink_ptr console_sink = std::make_shared(); console_sink->set_pattern("[%H:%M:%S %z] [%=8l] [thread %t] [%@]\t%v"); -#ifdef _WIN32 - std::string s = logger::logFolder + "\\kompute.log"; - spdlog::sink_ptr file_sink = - std::make_shared( - s, FILE_ROTATION_TIME, 3); -#else // _WIN32 - spdlog::sink_ptr file_sink = - std::make_shared( - logger::logFolder + "/kompute.log", FILE_ROTATION_TIME, 3); -#endif - file_sink->set_pattern("[%H:%M:%S %z] [%=8l] [thread %t] [%@]\t%v"); - std::vector sinks{ file_sink, console_sink }; + std::vector sinks{ console_sink }; std::shared_ptr logger = std::make_shared( "", @@ -148,12 +92,7 @@ setLogLevel(const spdlog::level::level_enum level) { spdlog::default_logger()->set_level(level); } - -void -deactivateLogger() -{ - logger::setLogLevel(spdlog::level::off); -} +#endif // !KOMPUTE_OPT_USE_SPDLOG std::string setToString(const std::set& set) @@ -194,4 +133,5 @@ vecToString(const std::vector& vec) return result.substr(0, result.size() - 2); // Remove the tailing ", " } } // namespace logger + #endif From 00cc533f80052e1ef4b4ab8f3e1e493faab17132 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Tue, 26 Jul 2022 11:07:58 +0200 Subject: [PATCH 081/107] Android and python logging Signed-off-by: Fabian Sauter --- python/src/main.cpp | 4 +- src/include/kompute/Core.hpp | 2 +- src/include/kompute/logger/Logger.hpp | 65 +++++++++++++++++++++++++++ src/logger/CMakeLists.txt | 8 ++++ 4 files changed, 77 insertions(+), 2 deletions(-) diff --git a/python/src/main.cpp b/python/src/main.cpp index 3f3f19d10..850a15a56 100644 --- a/python/src/main.cpp +++ b/python/src/main.cpp @@ -10,7 +10,7 @@ namespace py = pybind11; // used in Core.hpp -py::object kp_debug, kp_info, kp_warning, kp_error; +py::object kp_trace, kp_debug, kp_info, kp_warning, kp_error; std::unique_ptr opAlgoDispatchPyInit(std::shared_ptr& algorithm, @@ -53,6 +53,7 @@ PYBIND11_MODULE(kp, m) // The logging modules are used in the Kompute.hpp file py::module_ logging = py::module_::import("logging"); py::object kp_logger = logging.attr("getLogger")("kp"); + kp_trace = kp_logger.attr("trace"); kp_debug = kp_logger.attr("debug"); kp_info = kp_logger.attr("info"); kp_warning = kp_logger.attr("warning"); @@ -548,6 +549,7 @@ PYBIND11_MODULE(kp, m) auto atexit = py::module_::import("atexit"); atexit.attr("register")(py::cpp_function([]() { + kp_trace = py::none(); kp_debug = py::none(); kp_info = py::none(); kp_warning = py::none(); diff --git a/src/include/kompute/Core.hpp b/src/include/kompute/Core.hpp index 65936460d..307228d55 100644 --- a/src/include/kompute/Core.hpp +++ b/src/include/kompute/Core.hpp @@ -32,5 +32,5 @@ typedef std::vector Constants; #include namespace py = pybind11; // from python/src/main.cpp -extern py::object kp_debug, kp_info, kp_warning, kp_error; +extern py::object kp_trace, kp_debug, kp_info, kp_warning, kp_error; #endif diff --git a/src/include/kompute/logger/Logger.hpp b/src/include/kompute/logger/Logger.hpp index 43f119471..79b88a1bd 100644 --- a/src/include/kompute/logger/Logger.hpp +++ b/src/include/kompute/logger/Logger.hpp @@ -18,7 +18,22 @@ #else #if !KOMPUTE_OPT_USE_SPDLOG +#if VK_USE_PLATFORM_ANDROID_KHR +#include +#include +// VK_NO_PROTOTYPES required before vulkan import but after wrapper.hpp +#undef VK_NO_PROTOTYPES +static const char* KOMPUTE_LOG_TAG = "KomputeLog"; +#else +#if KOMPUTE_BUILD_PYTHON +#include +namespace py = pybind11; +// from python/src/main.cpp +extern py::object kp_trace, kp_debug, kp_info, kp_warning, kp_error; +#else #include +#endif // KOMPUTE_BUILD_PYTHON +#endif // VK_USE_PLATFORM_ANDROID_KHR #else #include #endif // !KOMPUTE_OPT_USE_SPDLOG @@ -37,6 +52,14 @@ setupLogger(); #ifndef KP_LOG_TRACE #if KOMPUTE_OPT_LOG_LEVEL <= KOMPUTE_LOG_LEVEL_TRACE +#if VK_USE_PLATFORM_ANDROID_KHR +#define KP_LOG_TRACE(...) \ + ((void)__android_log_write( \ + ANDROID_LOG_VERBOSE, KOMPUTE_LOG_TAG, fmt::format(__VA_ARGS__).c_str())) +#else +#if KOMPUTE_BUILD_PYTHON +#define KP_LOG_DEBUG(...) kp_trace(fmt::format(__VA_ARGS__)) +#else #define KP_LOG_TRACE(...) \ fmt::print("[{} {}] [trace] [{}:{}] {}\n", \ __DATE__, \ @@ -44,6 +67,8 @@ setupLogger(); __FILE__, \ __LINE__, \ fmt::format(__VA_ARGS__)) +#endif // KOMPUTE_BUILD_PYTHON +#endif // VK_USE_PLATFORM_ANDROID_KHR #else #define KP_LOG_TRACE(...) #endif @@ -51,6 +76,14 @@ setupLogger(); #ifndef KP_LOG_DEBUG #if KOMPUTE_OPT_LOG_LEVEL <= KOMPUTE_LOG_LEVEL_DEBUG +#if VK_USE_PLATFORM_ANDROID_KHR +#define KP_LOG_DEBUG(...) \ + ((void)__android_log_write( \ + ANDROID_LOG_DEBUG, KOMPUTE_LOG_TAG, fmt::format(__VA_ARGS__).c_str())) +#else +#if KOMPUTE_BUILD_PYTHON +#define KP_LOG_DEBUG(...) kp_debug(fmt::format(__VA_ARGS__)) +#else #define KP_LOG_DEBUG(...) \ fmt::print("[{} {}] [debug] [{}:{}] {}\n", \ __DATE__, \ @@ -58,6 +91,8 @@ setupLogger(); __FILE__, \ __LINE__, \ fmt::format(__VA_ARGS__)) +#endif // KOMPUTE_BUILD_PYTHON +#endif // VK_USE_PLATFORM_ANDROID_KHR #else #define KP_LOG_DEBUG(...) #endif @@ -65,6 +100,14 @@ setupLogger(); #ifndef KP_LOG_INFO #if KOMPUTE_OPT_LOG_LEVEL <= KOMPUTE_LOG_LEVEL_INFO +#if VK_USE_PLATFORM_ANDROID_KHR +#define KP_LOG_INFO(...) \ + ((void)__android_log_write( \ + ANDROID_LOG_INFO, KOMPUTE_LOG_TAG, fmt::format(__VA_ARGS__).c_str())) +#else +#if KOMPUTE_BUILD_PYTHON +#define KP_LOG_DEBUG(...) kp_info(fmt::format(__VA_ARGS__)) +#else #define KP_LOG_INFO(...) \ fmt::print("[{} {}] [info] [{}:{}] {}\n", \ __DATE__, \ @@ -72,6 +115,8 @@ setupLogger(); __FILE__, \ __LINE__, \ fmt::format(__VA_ARGS__)) +#endif // KOMPUTE_BUILD_PYTHON +#endif // VK_USE_PLATFORM_ANDROID_KHR #else #define KP_LOG_INFO(...) #endif @@ -79,6 +124,14 @@ setupLogger(); #ifndef KP_LOG_WARN #if KOMPUTE_OPT_LOG_LEVEL <= KOMPUTE_LOG_LEVEL_WARN +#if VK_USE_PLATFORM_ANDROID_KHR +#define KP_LOG_WARN(...) \ + ((void)__android_log_write( \ + ANDROID_LOG_WARN, KOMPUTE_LOG_TAG, fmt::format(__VA_ARGS__).c_str())) +#else +#if KOMPUTE_BUILD_PYTHON +#define KP_LOG_DEBUG(...) kp_warning(fmt::format(__VA_ARGS__)) +#else #define KP_LOG_WARN(...) \ fmt::print("[{} {}] [warn] [{}:{}] {}\n", \ __DATE__, \ @@ -86,6 +139,8 @@ setupLogger(); __FILE__, \ __LINE__, \ fmt::format(__VA_ARGS__)) +#endif // KOMPUTE_BUILD_PYTHON +#endif // VK_USE_PLATFORM_ANDROID_KHR #else #define KP_LOG_WARN(...) #endif @@ -93,6 +148,14 @@ setupLogger(); #ifndef KP_LOG_ERROR #if KOMPUTE_OPT_LOG_LEVEL <= KOMPUTE_LOG_LEVEL_ERROR +#if VK_USE_PLATFORM_ANDROID_KHR +#define KP_LOG_ERROR(...) \ + ((void)__android_log_write( \ + ANDROID_LOG_ERROR, KOMPUTE_LOG_TAG, fmt::format(__VA_ARGS__).c_str())) +#else +#if KOMPUTE_BUILD_PYTHON +#define KP_LOG_DEBUG(...) kp_error(fmt::format(__VA_ARGS__)) +#else #define KP_LOG_ERROR(...) \ fmt::print("[{} {}] [error] [{}:{}] {}\n", \ __DATE__, \ @@ -100,6 +163,8 @@ setupLogger(); __FILE__, \ __LINE__, \ fmt::format(__VA_ARGS__)) +#endif // KOMPUTE_BUILD_PYTHON +#endif // VK_USE_PLATFORM_ANDROID_KHR #else #define KP_LOG_ERROR(...) #endif diff --git a/src/logger/CMakeLists.txt b/src/logger/CMakeLists.txt index b73615a61..b4d2fea49 100644 --- a/src/logger/CMakeLists.txt +++ b/src/logger/CMakeLists.txt @@ -13,6 +13,14 @@ add_compile_definitions(KOMPUTE_LOG_LEVEL_ERROR=4) add_compile_definitions(KOMPUTE_LOG_LEVEL_CRITICAL=5) add_compile_definitions(KOMPUTE_LOG_LEVEL_OFF=6) +if(KOMPUTE_OPT_BUILD_PYTHON AND KOMPUTE_OPT_USE_SPDLOG) + message(FATAL_ERROR "'KOMPUTE_OPT_BUILD_PYTHON' is incompatible with 'KOMPUTE_OPT_USE_SPDLOG'. To continue set either one option to 'OFF'.") +endif() + +if(KOMPUTE_OPT_ANDROID_BUILD AND KOMPUTE_OPT_USE_SPDLOG) + message(FATAL_ERROR "'KOMPUTE_OPT_ANDROID_BUILD' is incompatible with 'KOMPUTE_OPT_USE_SPDLOG'. To continue set either one option to 'OFF'.") +endif() + if(${KOMPUTE_OPT_LOG_LEVEL} STREQUAL "Trace") set(KOMPUTE_OPT_LOG_LEVEL TRACE) message(STATUS "Using log level Trace") From 4b7e3b13f80b42a87925125a0e77682487d47edc Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Tue, 26 Jul 2022 12:36:46 +0200 Subject: [PATCH 082/107] Fixed building Python package Signed-off-by: Fabian Sauter --- python/CMakeLists.txt | 7 +++---- python/src/main.cpp | 5 ++++- python/src/utils.hpp | 28 ++++++++++++++++----------- setup.py | 1 + src/Manager.cpp | 2 +- src/include/kompute/Kompute.hpp | 1 + src/include/kompute/logger/Logger.hpp | 10 +++++----- src/logger/CMakeLists.txt | 3 +++ 8 files changed, 35 insertions(+), 22 deletions(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index cad7f4ffa..1b4598fb7 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -2,9 +2,8 @@ pybind11_add_module(kp src/main.cpp) include_directories( - ${PROJECT_SOURCE_DIR}/single_include/) + ${PROJECT_SOURCE_DIR}/include/) target_link_libraries( - kp PRIVATE - kompute::kompute) - + kp PRIVATE + kompute::kompute) diff --git a/python/src/main.cpp b/python/src/main.cpp index 850a15a56..6c0f640c6 100644 --- a/python/src/main.cpp +++ b/python/src/main.cpp @@ -2,6 +2,8 @@ #include #include +#include + #include #include "docstrings.hpp" @@ -53,7 +55,8 @@ PYBIND11_MODULE(kp, m) // The logging modules are used in the Kompute.hpp file py::module_ logging = py::module_::import("logging"); py::object kp_logger = logging.attr("getLogger")("kp"); - kp_trace = kp_logger.attr("trace"); + kp_trace = kp_logger.attr( + "debug"); // Same as for debug since python has no trace logging level kp_debug = kp_logger.attr("debug"); kp_info = kp_logger.attr("info"); kp_warning = kp_logger.attr("warning"); diff --git a/python/src/utils.hpp b/python/src/utils.hpp index 367871344..3c9e45c86 100644 --- a/python/src/utils.hpp +++ b/python/src/utils.hpp @@ -1,24 +1,30 @@ #include #include +#include using namespace pybind11::literals; // for the `_a` literal namespace kp { namespace py { -static pybind11::dict vkPropertiesToDict(const vk::PhysicalDeviceProperties& properties) { +static pybind11::dict +vkPropertiesToDict(const vk::PhysicalDeviceProperties& properties) +{ pybind11::dict pyDict( - "device_name"_a = std::string(properties.deviceName.data()), - "max_work_group_count"_a = pybind11::make_tuple(properties.limits.maxComputeWorkGroupCount[0], - properties.limits.maxComputeWorkGroupCount[1], - properties.limits.maxComputeWorkGroupCount[2]), - "max_work_group_invocations"_a = properties.limits.maxComputeWorkGroupInvocations, - "max_work_group_size"_a = pybind11::make_tuple(properties.limits.maxComputeWorkGroupSize[0], - properties.limits.maxComputeWorkGroupSize[1], - properties.limits.maxComputeWorkGroupSize[2]), - "timestamps_supported"_a = (bool)properties.limits.timestampComputeAndGraphics - ); + "device_name"_a = std::string(properties.deviceName.data()), + "max_work_group_count"_a = + pybind11::make_tuple(properties.limits.maxComputeWorkGroupCount[0], + properties.limits.maxComputeWorkGroupCount[1], + properties.limits.maxComputeWorkGroupCount[2]), + "max_work_group_invocations"_a = + properties.limits.maxComputeWorkGroupInvocations, + "max_work_group_size"_a = + pybind11::make_tuple(properties.limits.maxComputeWorkGroupSize[0], + properties.limits.maxComputeWorkGroupSize[1], + properties.limits.maxComputeWorkGroupSize[2]), + "timestamps_supported"_a = + (bool)properties.limits.timestampComputeAndGraphics); return pyDict; } diff --git a/setup.py b/setup.py index 0b39e9080..b94748007 100644 --- a/setup.py +++ b/setup.py @@ -43,6 +43,7 @@ class CMakeBuild(build_ext): cmake_args = ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + extdir, '-DKOMPUTE_OPT_BUILD_PYTHON=ON', '-DKOMPUTE_OPT_LOG_LEVEL=Off', + '-DKOMPUTE_OPT_USE_SPDLOG=Off', '-DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON' '-DPYTHON_EXECUTABLE=' + sys.executable, '-DPYTHON_INCLUDE_DIR=' + sysconfig.get_path('include'), diff --git a/src/Manager.cpp b/src/Manager.cpp index 5e9ee9d31..211cd7967 100644 --- a/src/Manager.cpp +++ b/src/Manager.cpp @@ -320,7 +320,7 @@ Manager::createDevice(const std::vector& familyQueueIndices, this->mPhysicalDevice = std::make_shared(physicalDevice); -#if KOMPUTE_OPT_LOG_LEVEL <= KOMPUTE_LOG_LEVEL_INFO +#if KOMPUTE_OPT_ACTIVE_LOG_LEVEL <= KOMPUTE_LOG_LEVEL_INFO vk::PhysicalDeviceProperties physicalDeviceProperties = physicalDevice.getProperties(); #endif diff --git a/src/include/kompute/Kompute.hpp b/src/include/kompute/Kompute.hpp index 2413dd139..e54adc1b7 100644 --- a/src/include/kompute/Kompute.hpp +++ b/src/include/kompute/Kompute.hpp @@ -14,5 +14,6 @@ #include "operations/OpTensorSyncDevice.hpp" #include "operations/OpTensorSyncLocal.hpp" +// Will be build by CMake and placed inside the build directory #include "ShaderLogisticRegression.hpp" #include "ShaderOpMult.hpp" diff --git a/src/include/kompute/logger/Logger.hpp b/src/include/kompute/logger/Logger.hpp index 79b88a1bd..977c6350e 100644 --- a/src/include/kompute/logger/Logger.hpp +++ b/src/include/kompute/logger/Logger.hpp @@ -51,7 +51,7 @@ setupLogger(); #if !KOMPUTE_OPT_USE_SPDLOG #ifndef KP_LOG_TRACE -#if KOMPUTE_OPT_LOG_LEVEL <= KOMPUTE_LOG_LEVEL_TRACE +#if KOMPUTE_OPT_ACTIVE_LOG_LEVEL <= KOMPUTE_LOG_LEVEL_TRACE #if VK_USE_PLATFORM_ANDROID_KHR #define KP_LOG_TRACE(...) \ ((void)__android_log_write( \ @@ -75,7 +75,7 @@ setupLogger(); #endif // !KP_LOG_TRACE #ifndef KP_LOG_DEBUG -#if KOMPUTE_OPT_LOG_LEVEL <= KOMPUTE_LOG_LEVEL_DEBUG +#if KOMPUTE_OPT_ACTIVE_LOG_LEVEL <= KOMPUTE_LOG_LEVEL_DEBUG #if VK_USE_PLATFORM_ANDROID_KHR #define KP_LOG_DEBUG(...) \ ((void)__android_log_write( \ @@ -99,7 +99,7 @@ setupLogger(); #endif // !KP_LOG_DEBUG #ifndef KP_LOG_INFO -#if KOMPUTE_OPT_LOG_LEVEL <= KOMPUTE_LOG_LEVEL_INFO +#if KOMPUTE_OPT_ACTIVE_LOG_LEVEL <= KOMPUTE_LOG_LEVEL_INFO #if VK_USE_PLATFORM_ANDROID_KHR #define KP_LOG_INFO(...) \ ((void)__android_log_write( \ @@ -123,7 +123,7 @@ setupLogger(); #endif // !KP_LOG_INFO #ifndef KP_LOG_WARN -#if KOMPUTE_OPT_LOG_LEVEL <= KOMPUTE_LOG_LEVEL_WARN +#if KOMPUTE_OPT_ACTIVE_LOG_LEVEL <= KOMPUTE_LOG_LEVEL_WARN #if VK_USE_PLATFORM_ANDROID_KHR #define KP_LOG_WARN(...) \ ((void)__android_log_write( \ @@ -147,7 +147,7 @@ setupLogger(); #endif // !KP_LOG_WARN #ifndef KP_LOG_ERROR -#if KOMPUTE_OPT_LOG_LEVEL <= KOMPUTE_LOG_LEVEL_ERROR +#if KOMPUTE_OPT_ACTIVE_LOG_LEVEL <= KOMPUTE_LOG_LEVEL_ERROR #if VK_USE_PLATFORM_ANDROID_KHR #define KP_LOG_ERROR(...) \ ((void)__android_log_write( \ diff --git a/src/logger/CMakeLists.txt b/src/logger/CMakeLists.txt index b4d2fea49..8e63aba05 100644 --- a/src/logger/CMakeLists.txt +++ b/src/logger/CMakeLists.txt @@ -49,6 +49,9 @@ else() message(FATAL_ERROR "Log level '${KOMPUTE_OPT_LOG_LEVEL}' unknown, use -DKOMPUTE_OPT_LOG_LEVEL={Trace, Debug, Info, Warn, Error, Critical, Off, Default} to set it to a correct value.") endif() +# Always make sure we define the Kompute log level independent of the Spdlog log level +target_compile_definitions(kp_logger INTERFACE KOMPUTE_OPT_ACTIVE_LOG_LEVEL=KOMPUTE_LOG_LEVEL_${KOMPUTE_OPT_LOG_LEVEL}) + # Link depending on how the logger should be setup if(NOT KOMPUTE_OPT_LOG_LEVEL_DISABLED) if(KOMPUTE_OPT_USE_SPDLOG) From f2457b32c796a3f3147d9cf9b15a0e705906bf9c Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Tue, 26 Jul 2022 12:45:00 +0200 Subject: [PATCH 083/107] Python building only with one job in parallel Signed-off-by: Fabian Sauter --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index b94748007..e7c634f7b 100644 --- a/setup.py +++ b/setup.py @@ -51,7 +51,8 @@ class CMakeBuild(build_ext): ] cfg = 'Debug' if self.debug else 'Release' - build_args = ['--config', cfg] + build_args = ['--config', cfg, + '--parallel', '1'] env = os.environ.copy() oldCxxFlags = env.get('CXXFLAGS', '') From 84bb62f39710afc9a6901835306f8a18f70d9d1a Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Tue, 26 Jul 2022 13:17:24 +0200 Subject: [PATCH 084/107] Switched back to a single executable for test Signed-off-by: Fabian Sauter --- .github/workflows/cpp_tests.yml | 8 ++--- Makefile | 22 ++++--------- test/CMakeLists.txt | 57 +++++++++++++++------------------ 3 files changed, 37 insertions(+), 50 deletions(-) diff --git a/.github/workflows/cpp_tests.yml b/.github/workflows/cpp_tests.yml index 4a7dcbad2..8f7ea42d3 100644 --- a/.github/workflows/cpp_tests.yml +++ b/.github/workflows/cpp_tests.yml @@ -27,7 +27,7 @@ jobs: cc: gcc cxx: g++ build-type: Debug - run-test: true + run-test: false ctest-options: -V configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=OFF -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON @@ -51,7 +51,7 @@ jobs: cc: gcc cxx: g++ build-type: Release - run-test: true + run-test: false ctest-options: -V configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=OFF -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON @@ -75,7 +75,7 @@ jobs: cc: gcc cxx: g++ build-type: Debug - run-test: true + run-test: false ctest-options: -V configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=ON -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON @@ -99,6 +99,6 @@ jobs: cc: gcc cxx: g++ build-type: Release - run-test: true + run-test: false ctest-options: -V configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=ON -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON diff --git a/Makefile b/Makefile index 7a9065c9e..945bbfcea 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ VCPKG_WIN_PATH ?= "C:\\Users\\axsau\\Programming\\lib\\vcpkg\\scripts\\buildsyst VCPKG_UNIX_PATH ?= "/c/Users/axsau/Programming/lib/vcpkg/scripts/buildsystems/vcpkg.cmake" # These are the tests that don't work with swiftshader but can be run directly with vulkan -FILTER_TESTS_REGEX ?= "(kompute_AsyncOperations_tests)|(kompute_PushConstant_tests)" +FILTER_TESTS ?= "-TestAsyncOperations.TestManagerParallelExecution:TestSequence.SequenceTimestamps:TestPushConstants.TestConstantsDouble" ifeq ($(OS),Windows_NT) # is Windows_NT on XP, 2000, 7, Vista, 10... CMAKE_BIN ?= "C:\Program Files\CMake\bin\cmake.exe" @@ -78,25 +78,17 @@ mk_build_kompute: cmake --build build/. --target kompute --parallel mk_build_tests: - cmake --build build/. --target AsyncOperations_tests \ - Destroy_tests \ - LogisticRegression_tests \ - Manager_tests \ - MultipleAlgoExecutions_tests \ - OpShadersFromStringAndFile_tests \ - OpTensorCopy_tests \ - OpTensorCreate_tests \ - PushConstant_tests \ - Sequence_tests \ - SpecializationConstant_tests \ - Workgroup_tests \ + cmake --build build/. --target kompute_tests \ --parallel mk_run_docs: mk_build_docs (cd build/docs/sphinx && python2.7 -m SimpleHTTPServer) +# An alternative would be: ctest -vv --test-dir build/. +# But this is not possible since we need to filter specific tests, not complete executables, which is not possible with ctest. +# https://gitlab.kitware.com/cmake/cmake/-/issues/13168 mk_run_tests: mk_build_tests - ctest -vv --exclude-regex $(FILTER_TESTS_REGEX) --test-dir build/. + ./build/bin/kompute_tests --gtest_filter=$(FILTER_TESTS) mk_build_swiftshader_library: git clone https://github.com/google/swiftshader || echo "Assuming already cloned" @@ -149,7 +141,7 @@ vs_run_docs: vs_build_docs (cd build/docs/sphinx && python2.7 -m SimpleHTTPServer) vs_run_tests: vs_build_tests - ctest -vv --exclude-regex $(FILTER_TESTS_REGEX) --test-dir build/. + ./build/test/$(VS_BUILD_TYPE)/bin/kompute_tests.exe --gtest_filter=$(FILTER_TESTS) #### PYTHONG #### diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 6f1ad80c6..0342a2822 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -10,37 +10,32 @@ add_subdirectory(shaders) # #################################################### # Tests # #################################################### -macro(add_kompute_test _TEST_NAME) - add_executable("${_TEST_NAME}_tests" "Test${_TEST_NAME}.cpp" - ${ARGN}) - target_link_libraries("${_TEST_NAME}_tests" PRIVATE GTest::gtest_main - kompute::kompute - kp_logger - test_shaders - test_shaders_glsl) - add_test(NAME "kompute_${_TEST_NAME}_tests" COMMAND "${_TEST_NAME}_tests") +add_executable(kompute_tests TestAsyncOperations.cpp + TestDestroy.cpp + TestLogisticRegression.cpp + TestManager.cpp + TestMultipleAlgoExecutions.cpp + TestOpShadersFromStringAndFile.cpp + TestOpTensorCopy.cpp + TestOpTensorCreate.cpp + TestPushConstant.cpp + TestSequence.cpp + TestSpecializationConstant.cpp + TestWorkgroup.cpp) - # Group under the "tests" project folder in IDEs such as Visual Studio. - set_property(TARGET ${_TEST_NAME}_tests PROPERTY FOLDER "tests") +target_link_libraries(kompute_tests PRIVATE GTest::gtest_main + kompute::kompute + kp_logger + test_shaders + test_shaders_glsl) +add_test(NAME kompute_tests COMMAND kompute_tests) - if(WIN32 AND BUILD_SHARED_LIBS AND NOT FILES_COPYED) # Install dlls in the same directory as the executable on Windows so one can simply double click them - set(FILES_COPYED "DONE") - add_custom_command(TARGET ${_TEST_NAME}_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ $) - add_custom_command(TARGET ${_TEST_NAME}_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ $) - add_custom_command(TARGET ${_TEST_NAME}_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ $) - add_custom_command(TARGET ${_TEST_NAME}_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ $) - endif() -endmacro() +# Group under the "tests" project folder in IDEs such as Visual Studio. +set_property(TARGET kompute_tests PROPERTY FOLDER "tests") -add_kompute_test(AsyncOperations) -add_kompute_test(Destroy) -add_kompute_test(LogisticRegression) -add_kompute_test(Manager) -add_kompute_test(MultipleAlgoExecutions) -add_kompute_test(OpShadersFromStringAndFile) -add_kompute_test(OpTensorCopy) -add_kompute_test(OpTensorCreate) -add_kompute_test(PushConstant) -add_kompute_test(Sequence) -add_kompute_test(SpecializationConstant) -add_kompute_test(Workgroup) +if(WIN32 AND BUILD_SHARED_LIBS) # Install dlls in the same directory as the executable on Windows so one can simply double click them + add_custom_command(TARGET kompute_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ $) + add_custom_command(TARGET kompute_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ $) + add_custom_command(TARGET kompute_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ $) + add_custom_command(TARGET kompute_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ $) +endif() From 48a096c7363495639da2ea90b19dcd4a19b6d722 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Tue, 26 Jul 2022 13:18:19 +0200 Subject: [PATCH 085/107] Typo Signed-off-by: Fabian Sauter --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a25f44162..540e42df8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -117,7 +117,7 @@ include(FetchContent) include(cmake/check_vulkan_version.cmake) # Vulkan Header -# We don't import Vulkan library if Android build as its build dynamically +# We don't import Vulkan library if Android build as its built dynamically # Otherwise it is expected that the Vulkan SDK and dependencies are installed if(NOT KOMPUTE_OPT_ANDROID_BUILD) find_package(Vulkan REQUIRED) From 9f2f3045f1f577f058eb2b20d7d8fa3478adf4e2 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Tue, 26 Jul 2022 13:18:34 +0200 Subject: [PATCH 086/107] Typo Signed-off-by: Fabian Sauter --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 540e42df8..f3777be3e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -117,7 +117,7 @@ include(FetchContent) include(cmake/check_vulkan_version.cmake) # Vulkan Header -# We don't import Vulkan library if Android build as its built dynamically +# We don't import Vulkan library if Android build as it is built dynamically # Otherwise it is expected that the Vulkan SDK and dependencies are installed if(NOT KOMPUTE_OPT_ANDROID_BUILD) find_package(Vulkan REQUIRED) From c43b62387550557903640a02b060e7e1aa06f908 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Tue, 26 Jul 2022 13:22:48 +0200 Subject: [PATCH 087/107] Running tests via the Makefile Signed-off-by: Fabian Sauter --- .github/workflows/cpp_tests.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/cpp_tests.yml b/.github/workflows/cpp_tests.yml index 8f7ea42d3..270b44b67 100644 --- a/.github/workflows/cpp_tests.yml +++ b/.github/workflows/cpp_tests.yml @@ -30,6 +30,8 @@ jobs: run-test: false ctest-options: -V configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=OFF -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON + - name: Run tests + run: make mk_run_tests cpp-tests-release-with-debug-layers: runs-on: ubuntu-latest @@ -54,6 +56,8 @@ jobs: run-test: false ctest-options: -V configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=OFF -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON + - name: Run tests + run: make mk_run_tests cpp-tests-debug-without-debug-layers: runs-on: ubuntu-latest @@ -78,6 +82,8 @@ jobs: run-test: false ctest-options: -V configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=ON -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON + - name: Run tests + run: make mk_run_tests cpp-tests-release-without-debug-layers: runs-on: ubuntu-latest @@ -102,3 +108,5 @@ jobs: run-test: false ctest-options: -V configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=ON -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON + - name: Run tests + run: make mk_run_tests From ac1831306a0d6fc7b1613195d952a665117fe4ca Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Tue, 26 Jul 2022 13:29:19 +0200 Subject: [PATCH 088/107] Setting the correct env for c++ test execution in the CI Signed-off-by: Fabian Sauter --- .github/workflows/cpp_tests.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/cpp_tests.yml b/.github/workflows/cpp_tests.yml index 270b44b67..e575d994c 100644 --- a/.github/workflows/cpp_tests.yml +++ b/.github/workflows/cpp_tests.yml @@ -18,8 +18,6 @@ jobs: with: submodules: false - name: "[Release g++] Build & Test" - env: - VK_ICD_FILENAMES: "/swiftshader/vk_swiftshader_icd.json" uses: ashutoshvarma/action-cmake-build@master with: build-dir: ${{github.workspace}}/build @@ -31,6 +29,8 @@ jobs: ctest-options: -V configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=OFF -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON - name: Run tests + env: + VK_ICD_FILENAMES: "/swiftshader/vk_swiftshader_icd.json" run: make mk_run_tests cpp-tests-release-with-debug-layers: @@ -44,8 +44,6 @@ jobs: with: submodules: false - name: "[Release g++] Build & Test" - env: - VK_ICD_FILENAMES: "/swiftshader/vk_swiftshader_icd.json" uses: ashutoshvarma/action-cmake-build@master with: build-dir: ${{github.workspace}}/build @@ -57,6 +55,8 @@ jobs: ctest-options: -V configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=OFF -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON - name: Run tests + env: + VK_ICD_FILENAMES: "/swiftshader/vk_swiftshader_icd.json" run: make mk_run_tests cpp-tests-debug-without-debug-layers: @@ -70,8 +70,6 @@ jobs: with: submodules: false - name: "[Release g++] Build & Test" - env: - VK_ICD_FILENAMES: "/swiftshader/vk_swiftshader_icd.json" uses: ashutoshvarma/action-cmake-build@master with: build-dir: ${{github.workspace}}/build @@ -83,6 +81,8 @@ jobs: ctest-options: -V configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=ON -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON - name: Run tests + env: + VK_ICD_FILENAMES: "/swiftshader/vk_swiftshader_icd.json" run: make mk_run_tests cpp-tests-release-without-debug-layers: @@ -96,8 +96,6 @@ jobs: with: submodules: false - name: "[Release g++] Build & Test" - env: - VK_ICD_FILENAMES: "/swiftshader/vk_swiftshader_icd.json" uses: ashutoshvarma/action-cmake-build@master with: build-dir: ${{github.workspace}}/build @@ -109,4 +107,6 @@ jobs: ctest-options: -V configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=ON -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON - name: Run tests + env: + VK_ICD_FILENAMES: "/swiftshader/vk_swiftshader_icd.json" run: make mk_run_tests From 089f258968df3c35a7cc6f52417696a36a3419f5 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Tue, 26 Jul 2022 13:35:02 +0200 Subject: [PATCH 089/107] Updated the build system docs Signed-off-by: Fabian Sauter --- docs/overview/build-system.rst | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/overview/build-system.rst b/docs/overview/build-system.rst index e5c454932..b84011489 100644 --- a/docs/overview/build-system.rst +++ b/docs/overview/build-system.rst @@ -36,8 +36,10 @@ This by default configures without any of the extra build tasks (such as buildin - Enable if you want to enable installation. * - -DKOMPUTE_OPT_BUILD_PYTHON=ON - Enable if you want to build python bindings. - * - -DKOMPUTE_OPT_LOG_LEVEL="Trace" - - Internally we use spdlog for logging. The log level used can be changed here. Possible values: 'Trace', 'Debug', 'Info', 'Warn', 'Error', 'Critical', 'Off', 'Default'. If set to 'Off' spdlog will be deactivated completely. If set to 'Default', the log level will be set to 'Info' for release builds and 'Debug' else. + * - -DKOMPUTE_OPT_LOG_LEVEL="Default" + - Internally we use Spdlog or fmt for logging, depending on the value of 'KOMPUTE_OPT_USE_SPDLOG'. The log level used can be changed here. Possible values: 'Trace', 'Debug', 'Info', 'Warn', 'Error', 'Critical', 'Off', 'Default'. If set to 'Off' logging will be deactivated completely. If set to 'Default', the log level will be set to 'Info' for release builds and 'Debug' else. + * - -DKOMPUTE_OPT_USE_SPDLOG=OFF + - If enabled, logging via KP_LOG_ will happen through Spdlog instead of plan fmt. * - -DKOMPUTE_OPT_ANDROID_BUILD=ON - Enable android compilation flags required. * - -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=ON @@ -47,7 +49,7 @@ This by default configures without any of the extra build tasks (such as buildin * - -DKOMPUTE_OPT_BUILD_SHADERS=OFF - Rebuilds all compute shaders during compilation and does not use the already precompiled versions. Requires glslangValidator to be installed on your system. * - -DKOMPUTE_OPT_USE_BUILT_IN_SPDLOG=ON - - Use the built-in version of Spdlog. + - Use the built-in version of Spdlog. Requires 'KOMPUTE_OPT_USE_SPDLOG' to be set to ON in order to have any effect. * - -DKOMPUTE_OPT_USE_BUILT_IN_FMT=ON - Use the built-in version of fmt. * - -DKOMPUTE_OPT_USE_BUILT_IN_GOOGLE_TEST=ON From 7673db695912ed5969a84e0262fdaecdc7c88249 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Tue, 26 Jul 2022 13:39:42 +0200 Subject: [PATCH 090/107] Replaced set and list to string with fmt::join Signed-off-by: Fabian Sauter --- src/Manager.cpp | 6 ++--- src/include/kompute/logger/Logger.hpp | 9 ------- src/logger/Logger.cpp | 39 --------------------------- 3 files changed, 3 insertions(+), 51 deletions(-) diff --git a/src/Manager.cpp b/src/Manager.cpp index 211cd7967..26670c627 100644 --- a/src/Manager.cpp +++ b/src/Manager.cpp @@ -380,7 +380,7 @@ Manager::createDevice(const std::vector& familyQueueIndices, } KP_LOG_DEBUG("Kompute Manager desired extension layers {}", - logger::vecToString(desiredExtensions)); + fmt::join(desiredExtensions, ", ")); std::vector deviceExtensions = this->mPhysicalDevice->enumerateDeviceExtensionProperties(); @@ -390,7 +390,7 @@ Manager::createDevice(const std::vector& familyQueueIndices, uniqueExtensionNames.insert(ext.extensionName); } KP_LOG_DEBUG("Kompute Manager available extensions {}", - logger::setToString(uniqueExtensionNames)); + fmt::join(uniqueExtensionNames, ", ")); std::vector validExtensions; for (const std::string& ext : desiredExtensions) { if (uniqueExtensionNames.count(ext) != 0) { @@ -399,7 +399,7 @@ Manager::createDevice(const std::vector& familyQueueIndices, } if (desiredExtensions.size() != validExtensions.size()) { KP_LOG_ERROR("Kompute Manager not all extensions were added: {}", - logger::vecToString(validExtensions)); + fmt::join(validExtensions, ", ")); } vk::DeviceCreateInfo deviceCreateInfo(vk::DeviceCreateFlags(), diff --git a/src/include/kompute/logger/Logger.hpp b/src/include/kompute/logger/Logger.hpp index 977c6350e..4e3c1bd2a 100644 --- a/src/include/kompute/logger/Logger.hpp +++ b/src/include/kompute/logger/Logger.hpp @@ -184,15 +184,6 @@ spdlog::level::level_enum getLogLevel(); #endif // !KOMPUTE_OPT_USE_SPDLOG - -std::string -setToString(const std::set& set); - -std::string -vecToString(const std::vector& vec); - -std::string -vecToString(const std::vector& vec); } // namespace logger #endif // KOMPUTE_OPT_LOG_LEVEL_DISABLED \ No newline at end of file diff --git a/src/logger/Logger.cpp b/src/logger/Logger.cpp index 79cb46686..b8628788c 100644 --- a/src/logger/Logger.cpp +++ b/src/logger/Logger.cpp @@ -93,45 +93,6 @@ setLogLevel(const spdlog::level::level_enum level) spdlog::default_logger()->set_level(level); } #endif // !KOMPUTE_OPT_USE_SPDLOG - -std::string -setToString(const std::set& set) -{ - std::string result; - for (const std::string& entry : set) { - result += entry + ", "; - } - if (result.empty()) { - return result; - } - return result.substr(0, result.size() - 2); // Remove the tailing ", " -} - -std::string -vecToString(const std::vector& vec) -{ - std::string result; - for (const char* entry : vec) { - result += std::string(entry) + ", "; - } - if (result.empty()) { - return result; - } - return result.substr(0, result.size() - 2); // Remove the tailing ", " -} - -std::string -vecToString(const std::vector& vec) -{ - std::string result; - for (const std::string& entry : vec) { - result += entry + ", "; - } - if (result.empty()) { - return result; - } - return result.substr(0, result.size() - 2); // Remove the tailing ", " -} } // namespace logger #endif From 7ad254e07af2cdabad6ab31d9af78cbd3cd754fa Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Wed, 27 Jul 2022 12:05:47 +0200 Subject: [PATCH 091/107] Removed "--paralle 1" from building python again Signed-off-by: Fabian Sauter --- setup.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup.py b/setup.py index e7c634f7b..b94748007 100644 --- a/setup.py +++ b/setup.py @@ -51,8 +51,7 @@ class CMakeBuild(build_ext): ] cfg = 'Debug' if self.debug else 'Release' - build_args = ['--config', cfg, - '--parallel', '1'] + build_args = ['--config', cfg] env = os.environ.copy() oldCxxFlags = env.get('CXXFLAGS', '') From 731b74610d68f0c44ed8ff1d7276b0043edd1d00 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Wed, 27 Jul 2022 12:19:34 +0200 Subject: [PATCH 092/107] Limiting the number of parallel builds for python CI Signed-off-by: Fabian Sauter --- .github/workflows/python_tests.yml | 4 +++- setup.py | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python_tests.yml b/.github/workflows/python_tests.yml index 8019f1172..db2965ba9 100644 --- a/.github/workflows/python_tests.yml +++ b/.github/workflows/python_tests.yml @@ -20,7 +20,9 @@ jobs: - name: Install Python Requirements run: pip3 install --user -r python/test/requirements-dev.txt - name: Python Build - run: pip3 install --user . + env: + KOMPUTE_PYTHON_NUM_PARALLEL_THREADS: 2 + run: pip3 install --user . -v - name: Python run Tests run: | export VK_ICD_FILENAMES=/swiftshader/vk_swiftshader_icd.json diff --git a/setup.py b/setup.py index b94748007..09faa8d1a 100644 --- a/setup.py +++ b/setup.py @@ -66,6 +66,9 @@ class CMakeBuild(build_ext): env['CXXFLAGS'] += ' -fPIC' cmake_args += ['-DCMAKE_BUILD_TYPE=' + cfg] build_args += ['--', '-j'] + # Optional environment variable to limit the number of parallel jobs for GitHub actions to reduce RAM usage + if 'KOMPUTE_PYTHON_NUM_PARALLEL_THREADS' in env: + build_args += env['KOMPUTE_PYTHON_NUM_PARALLEL_THREADS'] if not os.path.exists(self.build_temp): os.makedirs(self.build_temp) From 732704a9ee5fdc7a98e0b699b188e131c62a494e Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Wed, 27 Jul 2022 12:41:10 +0200 Subject: [PATCH 093/107] Removed .data() for deviceName Signed-off-by: Fabian Sauter --- python/src/utils.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/src/utils.hpp b/python/src/utils.hpp index 3c9e45c86..de557d7ba 100644 --- a/python/src/utils.hpp +++ b/python/src/utils.hpp @@ -12,7 +12,7 @@ vkPropertiesToDict(const vk::PhysicalDeviceProperties& properties) { pybind11::dict pyDict( - "device_name"_a = std::string(properties.deviceName.data()), + "device_name"_a = std::string(properties.deviceName), "max_work_group_count"_a = pybind11::make_tuple(properties.limits.maxComputeWorkGroupCount[0], properties.limits.maxComputeWorkGroupCount[1], From 53a3753caf997cee19a4c8021fafab0ae71de5d2 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Wed, 27 Jul 2022 12:59:08 +0200 Subject: [PATCH 094/107] Fixed deviceName conversion Signed-off-by: Fabian Sauter --- python/src/utils.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/src/utils.hpp b/python/src/utils.hpp index de557d7ba..69cd2a653 100644 --- a/python/src/utils.hpp +++ b/python/src/utils.hpp @@ -10,9 +10,9 @@ namespace py { static pybind11::dict vkPropertiesToDict(const vk::PhysicalDeviceProperties& properties) { - + std::string deviceName = properties.deviceName; pybind11::dict pyDict( - "device_name"_a = std::string(properties.deviceName), + "device_name"_a = deviceName, "max_work_group_count"_a = pybind11::make_tuple(properties.limits.maxComputeWorkGroupCount[0], properties.limits.maxComputeWorkGroupCount[1], From d1a80ded02e124561a5147feafb279dcfe0bb4e3 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Thu, 28 Jul 2022 10:06:15 +0200 Subject: [PATCH 095/107] Use shared (DLL) run-time lib even when Google Test is built as static lib Signed-off-by: Fabian Sauter --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index f3777be3e..fa88e4857 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -172,6 +172,9 @@ if(KOMPUTE_OPT_BUILD_TESTS) if(KOMPUTE_OPT_USE_BUILT_IN_GOOGLE_TEST) FetchContent_Declare(googletest GIT_REPOSITORY https://github.com/google/googletest.git GIT_TAG release-1.11.0) # Source: https://github.com/google/googletest/releases + + # Use a shared C runtime in case we build shared + set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) FetchContent_MakeAvailable(googletest) add_library(gtest_int INTERFACE) From 22f6f43a8688bc809d0351e6683b88753573812b Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Thu, 28 Jul 2022 10:32:45 +0200 Subject: [PATCH 096/107] Updated outdated Windows build flags Signed-off-by: Fabian Sauter --- Makefile | 4 ++-- examples/android/android-simple/app/build.gradle | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 945bbfcea..ca62922e0 100644 --- a/Makefile +++ b/Makefile @@ -105,7 +105,7 @@ mk_run_tests_cpu: mk_build_swiftshader_library mk_build_tests mk_run_tests_cpu_o VS_BUILD_TYPE ?= "Debug" # Run with multiprocessin / parallel build by default VS_CMAKE_EXTRA_FLAGS ?= "" -VS_KOMPUTE_EXTRA_CXX_FLAGS ?= "/MT" # /MP is for faster multiprocessing builds. You should add "/MT" for submodule builds for compatibility with gtest +VS_KOMPUTE_EXTRA_CXX_FLAGS ?= "" VS_INSTALL_PATH ?= "build/src/CMakeFiles/Export/" # Set to "" if prefer default vs_cmake: @@ -113,7 +113,7 @@ vs_cmake: -Bbuild \ $(VS_CMAKE_EXTRA_FLAGS) \ -DCMAKE_TOOLCHAIN_FILE=$(VCPKG_WIN_PATH) \ - -DKOMPUTE_EXTRA_CXX_FLAGS=$(VS_KOMPUTE_EXTRA_CXX_FLAGS) \ + -DCMAKE_CXX_FLAGS=$(VS_KOMPUTE_EXTRA_CXX_FLAGS) \ -DCMAKE_INSTALL_PREFIX=$(VS_INSTALL_PATH) \ -DKOMPUTE_OPT_INSTALL=ON \ -DKOMPUTE_OPT_BUILD_TESTS=ON \ diff --git a/examples/android/android-simple/app/build.gradle b/examples/android/android-simple/app/build.gradle index a115ef77d..cd8b9a42b 100644 --- a/examples/android/android-simple/app/build.gradle +++ b/examples/android/android-simple/app/build.gradle @@ -17,11 +17,11 @@ android { abiFilters "armeabi-v7a", 'arm64-v8a', 'x86', 'x86_64' arguments '-DANDROID_TOOLCHAIN=clang', '-DANDROID_STL=c++_static', - '-DKOMPUTE_OPT_ANDROID_BUILD=1', - '-DKOMPUTE_OPT_INSTALL=0', - '-DKOMPUTE_OPT_ENABLE_SPDLOG=0', - '-DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=1', - '-DKOMPUTE_EXTRA_CXX_FLAGS=-DKOMPUTE_VK_API_MINOR_VERSION=0' + '-DKOMPUTE_OPT_ANDROID_BUILD=ON', + '-DKOMPUTE_OPT_INSTALL=OFF', + '-DKOMPUTE_OPT_USE_SPDLOG=OFF', + '-DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=ON', + '-DCMAKE_CXX_FLAGS=-DKOMPUTE_VK_API_MINOR_VERSION=0' } } } From 2013bf9c68a9cacfa2cd5526a479fd38fb3f6506 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Thu, 28 Jul 2022 10:35:22 +0200 Subject: [PATCH 097/107] Increased the CMake minimum required version to 3.20 Turns out `OUTPUT` for `add_custom_command` requires CMake 3.20. https://cmake.org/cmake/help/latest/command/add_custom_command.html Signed-off-by: Fabian Sauter --- CMakeLists.txt | 2 +- cmake/bin_file_to_header.cmake | 2 +- examples/array_multiplication/CMakeLists.txt | 2 +- examples/array_multiplication/shader/CMakeLists.txt | 2 +- examples/array_multiplication/src/CMakeLists.txt | 2 +- examples/logistic_regression/CMakeLists.txt | 2 +- examples/logistic_regression/shader/CMakeLists.txt | 2 +- examples/logistic_regression/src/CMakeLists.txt | 2 +- src/CMakeLists.txt | 4 ++-- src/include/CMakeLists.txt | 2 +- src/logger/CMakeLists.txt | 2 +- src/shaders/CMakeLists.txt | 2 +- src/shaders/glsl/CMakeLists.txt | 2 +- test/CMakeLists.txt | 2 +- test/shaders/CMakeLists.txt | 2 +- test/shaders/glsl/CMakeLists.txt | 2 +- 16 files changed, 17 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fa88e4857..28ed254e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ # SPDX-License-Identifier: Apache-2.0 -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.20) project(kompute VERSION 0.8.1 LANGUAGES CXX) set(CMAKE_CXX_STANDARD 14) diff --git a/cmake/bin_file_to_header.cmake b/cmake/bin_file_to_header.cmake index e03931907..b47b36139 100644 --- a/cmake/bin_file_to_header.cmake +++ b/cmake/bin_file_to_header.cmake @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.20) if(${INPUT_SHADER_FILE} STREQUAL "") message(FATAL_ERROR "No input file path provided via 'INPUT_SHADER_FILE'.") diff --git a/examples/array_multiplication/CMakeLists.txt b/examples/array_multiplication/CMakeLists.txt index ae28c8a84..68f9b5ea7 100644 --- a/examples/array_multiplication/CMakeLists.txt +++ b/examples/array_multiplication/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.20) project(kompute_array_mult) set(CMAKE_CXX_STANDARD 14) diff --git a/examples/array_multiplication/shader/CMakeLists.txt b/examples/array_multiplication/shader/CMakeLists.txt index c403373ad..684a6a82a 100644 --- a/examples/array_multiplication/shader/CMakeLists.txt +++ b/examples/array_multiplication/shader/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.20) # To add more shaders simply copy the vulkan_compile_shader command and replace it with your new shader vulkan_compile_shader(INFILE my_shader.comp diff --git a/examples/array_multiplication/src/CMakeLists.txt b/examples/array_multiplication/src/CMakeLists.txt index 549f1ab44..4b85931b1 100644 --- a/examples/array_multiplication/src/CMakeLists.txt +++ b/examples/array_multiplication/src/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.20) add_executable(kompute_array_mult main.cpp) target_link_libraries(kompute_array_mult PRIVATE shader kompute::kompute) diff --git a/examples/logistic_regression/CMakeLists.txt b/examples/logistic_regression/CMakeLists.txt index 1c20d8b59..899739d97 100644 --- a/examples/logistic_regression/CMakeLists.txt +++ b/examples/logistic_regression/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.20) project(kompute_logistic_regression) set(CMAKE_CXX_STANDARD 14) diff --git a/examples/logistic_regression/shader/CMakeLists.txt b/examples/logistic_regression/shader/CMakeLists.txt index c403373ad..684a6a82a 100644 --- a/examples/logistic_regression/shader/CMakeLists.txt +++ b/examples/logistic_regression/shader/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.20) # To add more shaders simply copy the vulkan_compile_shader command and replace it with your new shader vulkan_compile_shader(INFILE my_shader.comp diff --git a/examples/logistic_regression/src/CMakeLists.txt b/examples/logistic_regression/src/CMakeLists.txt index c7c39aa96..75273e79c 100644 --- a/examples/logistic_regression/src/CMakeLists.txt +++ b/examples/logistic_regression/src/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.20) add_executable(kompute_logistic_regression main.cpp) target_link_libraries(kompute_logistic_regression PRIVATE shader kompute::kompute) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 723082887..0e4d6b2a5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,12 +1,12 @@ # SPDX-License-Identifier: Apache-2.0 -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.20) if(KOMPUTE_OPT_ANDROID_BUILD) find_library(android android) endif() -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.20) add_library(kompute Algorithm.cpp Manager.cpp diff --git a/src/include/CMakeLists.txt b/src/include/CMakeLists.txt index 350313eb5..e1652fdda 100644 --- a/src/include/CMakeLists.txt +++ b/src/include/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.20) # #################################################### # Kompute diff --git a/src/logger/CMakeLists.txt b/src/logger/CMakeLists.txt index 8e63aba05..026754c3c 100644 --- a/src/logger/CMakeLists.txt +++ b/src/logger/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.20) set(LOGGER_SOURCES Logger.cpp) diff --git a/src/shaders/CMakeLists.txt b/src/shaders/CMakeLists.txt index 004c8ea1f..901bf3e8a 100644 --- a/src/shaders/CMakeLists.txt +++ b/src/shaders/CMakeLists.txt @@ -1,5 +1,5 @@ # SPDX-License-Identifier: Apache-2.0 # ###################### -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.20) add_subdirectory(glsl) \ No newline at end of file diff --git a/src/shaders/glsl/CMakeLists.txt b/src/shaders/glsl/CMakeLists.txt index ed13d8988..3101a2b17 100644 --- a/src/shaders/glsl/CMakeLists.txt +++ b/src/shaders/glsl/CMakeLists.txt @@ -1,6 +1,6 @@ # SPDX-License-Identifier: Apache-2.0 # ###################### -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.20) # Check if build shaders from source is enabled if(KOMPUTE_OPT_BUILD_SHADERS) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0342a2822..0564458c6 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,6 +1,6 @@ # SPDX-License-Identifier: Apache-2.0 # ###################### -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.20) # #################################################### # Shaders diff --git a/test/shaders/CMakeLists.txt b/test/shaders/CMakeLists.txt index b41e9f6a3..9b134bac9 100644 --- a/test/shaders/CMakeLists.txt +++ b/test/shaders/CMakeLists.txt @@ -1,6 +1,6 @@ # SPDX-License-Identifier: Apache-2.0 # ###################### -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.20) add_library(test_shaders "Utils.cpp" "Utils.hpp") diff --git a/test/shaders/glsl/CMakeLists.txt b/test/shaders/glsl/CMakeLists.txt index 625000552..c8c3cba9a 100644 --- a/test/shaders/glsl/CMakeLists.txt +++ b/test/shaders/glsl/CMakeLists.txt @@ -1,6 +1,6 @@ # SPDX-License-Identifier: Apache-2.0 # ###################### -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.20) vulkan_compile_shader(INFILE test_logistic_regression_shader.comp OUTFILE test_logistic_regression_shader.hpp From 284ab873ea48b62464c82710410024ab8d71b6b6 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Thu, 28 Jul 2022 11:54:43 +0200 Subject: [PATCH 098/107] Fixed Windows make commands Signed-off-by: Fabian Sauter --- CMakeLists.txt | 15 ++++++++------- Makefile | 16 ++++++++-------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 28ed254e0..587505b68 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -116,13 +116,6 @@ include(cmake/vulkan_shader_compiler.cmake) include(FetchContent) include(cmake/check_vulkan_version.cmake) -# Vulkan Header -# We don't import Vulkan library if Android build as it is built dynamically -# Otherwise it is expected that the Vulkan SDK and dependencies are installed -if(NOT KOMPUTE_OPT_ANDROID_BUILD) - find_package(Vulkan REQUIRED) -endif() - if(KOMPUTE_OPT_USE_BUILT_IN_VULKAN_HEADER) FetchContent_Declare(vulkan_header GIT_REPOSITORY https://github.com/KhronosGroup/Vulkan-Headers.git GIT_TAG ${KOMPUTE_OPT_BUILT_IN_VULKAN_HEADER_TAG}) # Source: https://github.com/KhronosGroup/Vulkan-Headers/tags @@ -139,6 +132,14 @@ else() endif() endif() +# Vulkan Header +# We don't import Vulkan library if Android build as it is built dynamically +# Otherwise it is expected that the Vulkan SDK and dependencies are installed +# Has to happen AFTER using the build in vulkan headers to prevent multiple targets with the name Vulkan::Headers +if(NOT KOMPUTE_OPT_ANDROID_BUILD) + find_package(Vulkan REQUIRED) +endif() + # Spdlog if(KOMPUTE_OPT_USE_SPDLOG) add_compile_definitions(KOMPUTE_OPT_USE_SPDLOG=1) diff --git a/Makefile b/Makefile index ca62922e0..be34230ac 100644 --- a/Makefile +++ b/Makefile @@ -78,8 +78,7 @@ mk_build_kompute: cmake --build build/. --target kompute --parallel mk_build_tests: - cmake --build build/. --target kompute_tests \ - --parallel + cmake --build build/. --target kompute_tests --parallel mk_run_docs: mk_build_docs (cd build/docs/sphinx && python2.7 -m SimpleHTTPServer) @@ -120,22 +119,23 @@ vs_cmake: -DKOMPUTE_OPT_BUILD_SHADERS=ON \ -DKOMPUTE_OPT_CODE_COVERAGE=OFF \ -DKOMPUTE_OPT_BUILD_DOCS=OFF \ - -G "Visual Studio 16 2019" + -G "Visual Studio 16 2019" \ + -DCMAKE_BUILD_TYPE=$(VS_BUILD_TYPE) vs_build_all: - $(MSBUILD_BIN) build/kompute.sln -p:Configuration$(VS_BUILD_TYPE) + cmake --build build/. --parallel vs_build_docs: - $(MSBUILD_BIN) build/docs/gendocsall.vcxproj -p:Configuration=$(VS_BUILD_TYPE) + cmake --build build/. --target gendocsall --parallel vs_install_kompute: - $(MSBUILD_BIN) build/src/INSTALL.vcxproj -p:Configuration=$(VS_BUILD_TYPE) + cmake --build build/. --target install --parallel vs_build_kompute: - $(MSBUILD_BIN) build/src/kompute.vcxproj -p:Configuration=$(VS_BUILD_TYPE) + cmake --build build/. --target kompute --parallel vs_build_tests: - $(MSBUILD_BIN) build/test/test_kompute.vcxproj -p:Configuration=$(VS_BUILD_TYPE) + cmake --build build/. --target kompute_tests --parallel vs_run_docs: vs_build_docs (cd build/docs/sphinx && python2.7 -m SimpleHTTPServer) From ffc2dcc0b369a25e446948792ca9c9d94c1d607d Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Thu, 28 Jul 2022 13:00:26 +0200 Subject: [PATCH 099/107] Fixed KOMPUTE_OPT_USE_BUILT_IN_VULKAN_HEADERS Signed-off-by: Fabian Sauter --- CMakeLists.txt | 22 ++++++++++++++-------- docs/overview/build-system.rst | 4 ++-- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 587505b68..5d4537af4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,7 +100,7 @@ kompute_option(KOMPUTE_OPT_USE_BUILT_IN_SPDLOG "Use the built-in version of Spdl kompute_option(KOMPUTE_OPT_USE_BUILT_IN_FMT "Use the built-in version of fmt." ON) kompute_option(KOMPUTE_OPT_USE_BUILT_IN_GOOGLE_TEST "Use the built-in version of GoogleTest." ON) kompute_option(KOMPUTE_OPT_USE_BUILT_IN_PYBIND11 "Use the built-in version of pybind11." ON) -kompute_option(KOMPUTE_OPT_USE_BUILT_IN_VULKAN_HEADER "Use the built-in version of Vulkan Headers. This could be helpful in case your system Vulkan Headers are to new for your driver. If you set this to false, please make sure your system Vulkan Header are supported by your driver." ON) +kompute_option(KOMPUTE_OPT_USE_BUILT_IN_VULKAN_HEADER "Use the built-in version of Vulkan Headers. This could be helpful in case your system Vulkan Headers are too new for your driver. If you set this to OFF, please make sure your system Vulkan Headers are supported by your driver." OFF) kompute_option_string(KOMPUTE_OPT_BUILT_IN_VULKAN_HEADER_TAG "The git tag used for the built-in Vulkan Headers when 'KOMPUTE_OPT_USE_BUILT_IN_VULKAN_HEADER' is enabled. A list of tags can be found here: https://github.com/KhronosGroup/Vulkan-Headers/tags" "v1.2.203") message(STATUS "=======================================================") @@ -125,19 +125,25 @@ if(KOMPUTE_OPT_USE_BUILT_IN_VULKAN_HEADER) # Ensure the driver supports this Vulkan version check_vulkan_version(INCLUDE_DIR "${vulkan_header_SOURCE_DIR}/include") endif() -else() - if(NOT KOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK) - # Ensure the driver supports this Vulkan version - check_vulkan_version(INCLUDE_DIR ${Vulkan_INCLUDE_DIR}) - endif() endif() # Vulkan Header # We don't import Vulkan library if Android build as it is built dynamically # Otherwise it is expected that the Vulkan SDK and dependencies are installed -# Has to happen AFTER using the build in vulkan headers to prevent multiple targets with the name Vulkan::Headers +# Has to happen AFTER using the build-in Vulkan headers to prevent multiple targets with the name Vulkan::Headers if(NOT KOMPUTE_OPT_ANDROID_BUILD) find_package(Vulkan REQUIRED) + + if(Vulkan_FOUND AND NOT TARGET Vulkan::Headers) + add_library(Vulkan::Headers INTERFACE IMPORTED) + set_target_properties(Vulkan::Headers PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") + endif() + + if(NOT KOMPUTE_OPT_USE_BUILT_IN_VULKAN_HEADER AND NOT KOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK) + # Ensure the driver supports this Vulkan version + check_vulkan_version(INCLUDE_DIR ${Vulkan_INCLUDE_DIR}) + endif() endif() # Spdlog @@ -173,7 +179,7 @@ if(KOMPUTE_OPT_BUILD_TESTS) if(KOMPUTE_OPT_USE_BUILT_IN_GOOGLE_TEST) FetchContent_Declare(googletest GIT_REPOSITORY https://github.com/google/googletest.git GIT_TAG release-1.11.0) # Source: https://github.com/google/googletest/releases - + # Use a shared C runtime in case we build shared set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) FetchContent_MakeAvailable(googletest) diff --git a/docs/overview/build-system.rst b/docs/overview/build-system.rst index b84011489..7764ff4ed 100644 --- a/docs/overview/build-system.rst +++ b/docs/overview/build-system.rst @@ -56,8 +56,8 @@ This by default configures without any of the extra build tasks (such as buildin - Use the built-in version of GoogleTest. * - -DKOMPUTE_OPT_USE_BUILT_IN_PYBIND11=ON - Use the built-in version of pybind11. - * - -DKOMPUTE_OPT_USE_BUILT_IN_VULKAN_HEADER=ON - - Use the built-in version of Vulkan Headers. This could be helpful in case your system Vulkan Headers are to new for your driver. If you set this to false, please make sure your system Vulkan Header are supported by your driver. + * - -DKOMPUTE_OPT_USE_BUILT_IN_VULKAN_HEADER=OFF + - Use the built-in version of Vulkan Headers. This could be helpful in case your system Vulkan Headers are too new for your driver. If you set this to OFF, please make sure your system Vulkan Headers are supported by your driver. * - -DKOMPUTE_OPT_BUILT_IN_VULKAN_HEADER_TAG="v1.2.203" - The git tag used for the built-in Vulkan Headers when 'KOMPUTE_OPT_USE_BUILT_IN_VULKAN_HEADER' is enabled. A list of tags can be found here: https://github.com/KhronosGroup/Vulkan-Headers/tags From 513934219af35883accc08c4bfdc3c487d47657b Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Thu, 28 Jul 2022 13:19:10 +0200 Subject: [PATCH 100/107] Using Vulkan build in headers for python tests Signed-off-by: Fabian Sauter --- .github/workflows/python_tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/python_tests.yml b/.github/workflows/python_tests.yml index db2965ba9..08da971e3 100644 --- a/.github/workflows/python_tests.yml +++ b/.github/workflows/python_tests.yml @@ -22,6 +22,7 @@ jobs: - name: Python Build env: KOMPUTE_PYTHON_NUM_PARALLEL_THREADS: 2 + KOMPUTE_OPT_USE_BUILT_IN_VULKAN_HEADER: ON run: pip3 install --user . -v - name: Python run Tests run: | From a011673a8936d4b85340238de82e3e187b701f92 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Thu, 28 Jul 2022 13:22:59 +0200 Subject: [PATCH 101/107] Enabling Vulkan build in headers for cpp test Signed-off-by: Fabian Sauter --- .github/workflows/cpp_tests.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cpp_tests.yml b/.github/workflows/cpp_tests.yml index e575d994c..bd12f3a3b 100644 --- a/.github/workflows/cpp_tests.yml +++ b/.github/workflows/cpp_tests.yml @@ -27,7 +27,7 @@ jobs: build-type: Debug run-test: false ctest-options: -V - configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=OFF -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON + configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=OFF -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON -DKOMPUTE_OPT_USE_BUILT_IN_VULKAN_HEADER=ON - name: Run tests env: VK_ICD_FILENAMES: "/swiftshader/vk_swiftshader_icd.json" @@ -53,7 +53,7 @@ jobs: build-type: Release run-test: false ctest-options: -V - configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=OFF -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON + configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=OFF -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON -DKOMPUTE_OPT_USE_BUILT_IN_VULKAN_HEADER=ON - name: Run tests env: VK_ICD_FILENAMES: "/swiftshader/vk_swiftshader_icd.json" @@ -79,7 +79,7 @@ jobs: build-type: Debug run-test: false ctest-options: -V - configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=ON -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON + configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=ON -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON -DKOMPUTE_OPT_USE_BUILT_IN_VULKAN_HEADER=ON - name: Run tests env: VK_ICD_FILENAMES: "/swiftshader/vk_swiftshader_icd.json" @@ -105,7 +105,7 @@ jobs: build-type: Release run-test: false ctest-options: -V - configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=ON -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON + configure-options: -DKOMPUTE_OPT_BUILD_TESTS=ON -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=ON -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON -DKOMPUTE_OPT_USE_BUILT_IN_VULKAN_HEADER=ON - name: Run tests env: VK_ICD_FILENAMES: "/swiftshader/vk_swiftshader_icd.json" From eb00e02708e47c699447216438653af9396964aa Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Sun, 31 Jul 2022 11:54:28 +0200 Subject: [PATCH 102/107] Fixed Vulkan validation layer Signed-off-by: Fabian Sauter --- src/Manager.cpp | 44 ++++++++++++++------------------- src/include/kompute/Manager.hpp | 2 -- 2 files changed, 19 insertions(+), 27 deletions(-) diff --git a/src/Manager.cpp b/src/Manager.cpp index 26670c627..e4c4005a8 100644 --- a/src/Manager.cpp +++ b/src/Manager.cpp @@ -1,32 +1,31 @@ // SPDX-License-Identifier: Apache-2.0 +#include "kompute/Manager.hpp" +#include "fmt/format.h" +#include "kompute/logger/Logger.hpp" +#include #include #include #include #include -#include "kompute/Manager.hpp" -#include "kompute/logger/Logger.hpp" - namespace kp { -#if DEBUG #ifndef KOMPUTE_DISABLE_VK_DEBUG_LAYERS static VKAPI_ATTR VkBool32 VKAPI_CALL -debugMessageCallback(VkDebugReportFlagsEXT flags, - VkDebugReportObjectTypeEXT objectType, - uint64_t object, - size_t location, - int32_t messageCode, +debugMessageCallback(VkDebugReportFlagsEXT /*flags*/, + VkDebugReportObjectTypeEXT /*objectType*/, + uint64_t /*object*/, + size_t /*location*/, + int32_t /*messageCode*/, const char* pLayerPrefix, const char* pMessage, - void* pUserData) + void* /*pUserData*/) { KP_LOG_DEBUG("[VALIDATION]: {} - {}", pLayerPrefix, pMessage); return VK_FALSE; } #endif -#endif Manager::Manager() : Manager(0) @@ -129,14 +128,12 @@ Manager::destroy() return; } -#if DEBUG #ifndef KOMPUTE_DISABLE_VK_DEBUG_LAYERS if (this->mDebugReportCallback) { this->mInstance->destroyDebugReportCallbackEXT( this->mDebugReportCallback, nullptr, this->mDebugDispatcher); KP_LOG_DEBUG("Kompute Manager Destroyed Debug Report Callback"); } -#endif #endif if (this->mFreeInstance) { @@ -164,7 +161,7 @@ Manager::createInstance() std::vector applicationExtensions; -#if DEBUG +#ifndef KOMPUTE_DISABLE_VK_DEBUG_LAYERS applicationExtensions.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); #endif @@ -177,7 +174,6 @@ Manager::createInstance() applicationExtensions.data(); } -#if DEBUG #ifndef KOMPUTE_DISABLE_VK_DEBUG_LAYERS KP_LOG_DEBUG("Kompute Manager adding debug validation layers"); // We'll identify the layers that are supported @@ -189,16 +185,17 @@ Manager::createInstance() }; std::vector envLayerNames; const char* envLayerNamesVal = std::getenv("KOMPUTE_ENV_DEBUG_LAYERS"); - if (envLayerNamesVal != NULL && *envLayerNamesVal != '\0') { + if (envLayerNamesVal != nullptr && *envLayerNamesVal != '\0') { KP_LOG_DEBUG("Kompute Manager adding environment layers: {}", envLayerNamesVal); std::istringstream iss(envLayerNamesVal); - std::istream_iterator beg(iss), end; + std::istream_iterator beg(iss); + std::istream_iterator end; envLayerNames = std::vector(beg, end); for (const std::string& layerName : envLayerNames) { desiredLayerNames.push_back(layerName.c_str()); } - KP_LOG_DEBUG("Desired layers: {}", desiredLayerNames); + KP_LOG_DEBUG("Desired layers: {}", fmt::join(desiredLayerNames, ", ")); } // Identify the valid layer names based on the desiredLayerNames @@ -210,7 +207,7 @@ Manager::createInstance() std::string layerName(layerProperties.layerName.data()); uniqueLayerNames.insert(layerName); } - KP_LOG_DEBUG("Available layers: {}", uniqueLayerNames); + KP_LOG_DEBUG("Available layers: {}", fmt::join(uniqueLayerNames, ", ")); for (const char* desiredLayerName : desiredLayerNames) { if (uniqueLayerNames.count(desiredLayerName) != 0) { validLayerNames.push_back(desiredLayerName); @@ -218,18 +215,17 @@ Manager::createInstance() } } - if (validLayerNames.size() > 0) { + if (!validLayerNames.empty()) { KP_LOG_DEBUG( "Kompute Manager Initializing instance with valid layers: {}", - validLayerNames); + fmt::join(validLayerNames, ", ")); computeInstanceCreateInfo.enabledLayerCount = - (uint32_t)validLayerNames.size(); + static_cast(validLayerNames.size()); computeInstanceCreateInfo.ppEnabledLayerNames = validLayerNames.data(); } else { KP_LOG_WARN("Kompute Manager no valid layer names found from desired " "layer names"); } -#endif #endif this->mInstance = std::make_shared(); @@ -237,7 +233,6 @@ Manager::createInstance() &computeInstanceCreateInfo, nullptr, this->mInstance.get()); KP_LOG_DEBUG("Kompute Manager Instance Created"); -#if DEBUG #ifndef KOMPUTE_DISABLE_VK_DEBUG_LAYERS KP_LOG_DEBUG("Kompute Manager adding debug callbacks"); if (validLayerNames.size() > 0) { @@ -255,7 +250,6 @@ Manager::createInstance() debugCreateInfo, nullptr, this->mDebugDispatcher); } #endif -#endif } void diff --git a/src/include/kompute/Manager.hpp b/src/include/kompute/Manager.hpp index a0e727cae..52f9ada73 100644 --- a/src/include/kompute/Manager.hpp +++ b/src/include/kompute/Manager.hpp @@ -241,11 +241,9 @@ class Manager bool mManageResources = false; -#if DEBUG #ifndef KOMPUTE_DISABLE_VK_DEBUG_LAYERS vk::DebugReportCallbackEXT mDebugReportCallback; vk::DispatchLoaderDynamic mDebugDispatcher; -#endif #endif // Create functions From 3d6c5af302c7058fa79c6f14a3c9b5c4f7e3d92a Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Sun, 31 Jul 2022 14:24:49 +0200 Subject: [PATCH 103/107] Fixed unused var in Manager Signed-off-by: Fabian Sauter --- src/Manager.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Manager.cpp b/src/Manager.cpp index e4c4005a8..b1115a8fc 100644 --- a/src/Manager.cpp +++ b/src/Manager.cpp @@ -18,8 +18,13 @@ debugMessageCallback(VkDebugReportFlagsEXT /*flags*/, uint64_t /*object*/, size_t /*location*/, int32_t /*messageCode*/, +#if KOMPUTE_OPT_ACTIVE_LOG_LEVEL <= KOMPUTE_LOG_LEVEL_DEBUG const char* pLayerPrefix, const char* pMessage, +#else + const char* /*pLayerPrefix*/, + const char* /*pMessage*/, +#endif void* /*pUserData*/) { KP_LOG_DEBUG("[VALIDATION]: {} - {}", pLayerPrefix, pMessage); From 6506aba4667ed7ae9e846de29d8d4b46d43a90ee Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Thu, 27 Oct 2022 14:24:41 +0200 Subject: [PATCH 104/107] Fixed building Kompute for Android Signed-off-by: Fabian Sauter --- .ccls | 2 - CMakeLists.txt | 34 +- .../android/android-simple/app/build.gradle | 22 +- .../app/src/main/AndroidManifest.xml | 6 +- .../app/src/main/cpp/CMakeLists.txt | 37 +- .../app/src/main/cpp/KomputeJniNative.cpp | 12 +- .../app/src/main/cpp/KomputeModelML.cpp | 16 +- .../app/src/main/cpp/KomputeModelML.hpp | 66 +- .../app/src/main/cpp/shader/CMakeLists.txt | 15 + .../app/src/main/cpp/shader/my_shader.comp | 54 ++ examples/android/android-simple/build.gradle | 4 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- src/CMakeLists.txt | 20 +- src/Core.cpp | 19 + src/include/kompute/Core.hpp | 6 - src/include/kompute/logger/Logger.hpp | 4 +- .../kompute_vk_ndk_wrapper.cpp | 798 ------------------ .../kompute_vk_ndk_wrapper.hpp | 414 --------- .../kompute_vk_ndk_wrapper_patch.hpp | 185 ---- 19 files changed, 158 insertions(+), 1558 deletions(-) create mode 100644 examples/android/android-simple/app/src/main/cpp/shader/CMakeLists.txt create mode 100644 examples/android/android-simple/app/src/main/cpp/shader/my_shader.comp create mode 100644 src/Core.cpp delete mode 100755 vk_ndk_wrapper_include/kompute_vk_ndk_wrapper.cpp delete mode 100755 vk_ndk_wrapper_include/kompute_vk_ndk_wrapper.hpp delete mode 100644 vk_ndk_wrapper_include/kompute_vk_ndk_wrapper_patch.hpp diff --git a/.ccls b/.ccls index 4c0b28e46..47d3fc315 100644 --- a/.ccls +++ b/.ccls @@ -21,7 +21,5 @@ -I./external/spdlog/include/ -I./external/fmt/include/ -I./src/include/ --I./single_include/ --I./vk_ndk_wrapper_include/ -I./test/compiled_shaders_include/ -I./test/utils/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d4537af4..f5d2b477c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,25 +113,33 @@ include(cmake/deprecation_warnings.cmake) # Dependencies # #################################################### include(cmake/vulkan_shader_compiler.cmake) -include(FetchContent) include(cmake/check_vulkan_version.cmake) - -if(KOMPUTE_OPT_USE_BUILT_IN_VULKAN_HEADER) - FetchContent_Declare(vulkan_header GIT_REPOSITORY https://github.com/KhronosGroup/Vulkan-Headers.git - GIT_TAG ${KOMPUTE_OPT_BUILT_IN_VULKAN_HEADER_TAG}) # Source: https://github.com/KhronosGroup/Vulkan-Headers/tags - FetchContent_MakeAvailable(vulkan_header) - - if(NOT KOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK) - # Ensure the driver supports this Vulkan version - check_vulkan_version(INCLUDE_DIR "${vulkan_header_SOURCE_DIR}/include") - endif() -endif() +include(FetchContent) # Vulkan Header # We don't import Vulkan library if Android build as it is built dynamically # Otherwise it is expected that the Vulkan SDK and dependencies are installed # Has to happen AFTER using the build-in Vulkan headers to prevent multiple targets with the name Vulkan::Headers -if(NOT KOMPUTE_OPT_ANDROID_BUILD) +if(KOMPUTE_OPT_ANDROID_BUILD) + add_library(vulkanAndroid INTERFACE) + set(VULKAN_INCLUDE_DIR ${ANDROID_NDK}/sources/third_party/vulkan/src/include) + target_sources(vulkanAndroid INTERFACE ${VULKAN_INCLUDE_DIR}/vulkan/vulkan.hpp) + target_include_directories(vulkanAndroid INTERFACE ${VULKAN_INCLUDE_DIR}) + + target_compile_definitions(vulkanAndroid INTERFACE VK_NO_PROTOTYPES=1) + target_compile_definitions(vulkanAndroid INTERFACE VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1) +else() + if(KOMPUTE_OPT_USE_BUILT_IN_VULKAN_HEADER) + FetchContent_Declare(vulkan_header GIT_REPOSITORY https://github.com/KhronosGroup/Vulkan-Headers.git + GIT_TAG ${KOMPUTE_OPT_BUILT_IN_VULKAN_HEADER_TAG}) # Source: https://github.com/KhronosGroup/Vulkan-Headers/tags + FetchContent_MakeAvailable(vulkan_header) + + if(NOT KOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK) + # Ensure the driver supports this Vulkan version + check_vulkan_version(INCLUDE_DIR "${vulkan_header_SOURCE_DIR}/include") + endif() + endif() + find_package(Vulkan REQUIRED) if(Vulkan_FOUND AND NOT TARGET Vulkan::Headers) diff --git a/examples/android/android-simple/app/build.gradle b/examples/android/android-simple/app/build.gradle index cd8b9a42b..d49860eb2 100644 --- a/examples/android/android-simple/app/build.gradle +++ b/examples/android/android-simple/app/build.gradle @@ -3,27 +3,25 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' android { - compileSdkVersion 29 - ndkVersion '21.2.6472646' + compileSdkVersion 33 + ndkVersion '25.1.8937393' defaultConfig { applicationId "com.ethicalml.kompute" - minSdkVersion 23 - targetSdkVersion 29 + minSdkVersion 26 + targetSdkVersion 33 versionCode = 1 versionName = "0.0.1" externalNativeBuild { cmake { - abiFilters "armeabi-v7a", 'arm64-v8a', 'x86', 'x86_64' arguments '-DANDROID_TOOLCHAIN=clang', - '-DANDROID_STL=c++_static', - '-DKOMPUTE_OPT_ANDROID_BUILD=ON', - '-DKOMPUTE_OPT_INSTALL=OFF', - '-DKOMPUTE_OPT_USE_SPDLOG=OFF', - '-DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=ON', - '-DCMAKE_CXX_FLAGS=-DKOMPUTE_VK_API_MINOR_VERSION=0' + '-DANDROID_STL=c++_static' } } + ndk { + abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' + } + } buildFeatures { @@ -39,6 +37,7 @@ android { externalNativeBuild { cmake { path 'src/main/cpp/CMakeLists.txt' + version '3.22.2' } } @@ -62,6 +61,7 @@ android { // armeabi-v7a, arm64-v8a, x86, x86_64 } } + namespace 'com.ethicalml.kompute' } dependencies { diff --git a/examples/android/android-simple/app/src/main/AndroidManifest.xml b/examples/android/android-simple/app/src/main/AndroidManifest.xml index 4965abb44..8e8beb56c 100755 --- a/examples/android/android-simple/app/src/main/AndroidManifest.xml +++ b/examples/android/android-simple/app/src/main/AndroidManifest.xml @@ -1,7 +1,6 @@ - + - + diff --git a/examples/android/android-simple/app/src/main/cpp/CMakeLists.txt b/examples/android/android-simple/app/src/main/cpp/CMakeLists.txt index 868be9ca7..18feff433 100644 --- a/examples/android/android-simple/app/src/main/cpp/CMakeLists.txt +++ b/examples/android/android-simple/app/src/main/cpp/CMakeLists.txt @@ -1,27 +1,22 @@ -cmake_minimum_required(VERSION 3.4.1) +cmake_minimum_required(VERSION 3.20) -add_subdirectory(../../../../../../../ ${CMAKE_CURRENT_BINARY_DIR}/kompute_build) +set(CMAKE_CXX_STANDARD 17) -set(VK_ANDROID_INCLUDE_DIR ${ANDROID_NDK}/sources/third_party/vulkan/src/include) +include(FetchContent) +FetchContent_Declare(kompute GIT_REPOSITORY https://github.com/COM8/kompute.git + GIT_TAG b28d4ae0bec1d39003b97574623a52b0b5f7494d) # The commit hash for a dev version before v0.9.0. Replace with the latest from: https://github.com/KomputeProject/kompute/releases +set(KOMPUTE_OPT_ANDROID_BUILD ON) +set(KOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS ON) +FetchContent_MakeAvailable(kompute) +include_directories(${kompute_SOURCE_DIR}/src/include) -add_library(kompute-jni SHARED - KomputeJniNative.cpp - KomputeModelML.cpp) +# Add to the list, so CMake can later find the code to compile shaders to header files +list(APPEND CMAKE_PREFIX_PATH "${kompute_SOURCE_DIR}/cmake") +add_subdirectory(shader) -include_directories( - ${VK_ANDROID_COMMON_DIR} - ${VK_ANDROID_INCLUDE_DIR} - ../../../../../../../single_include/ - ../../../../../../../vk_ndk_wrapper_include/) +add_library(kompute-jni SHARED KomputeJniNative.cpp + KomputeModelML.cpp + KomputeModelML.hpp) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 \ - -DVK_USE_PLATFORM_ANDROID_KHR=1 \ - -DKOMPUTE_DISABLE_VK_DEBUG_LAYERS=1") +target_link_libraries(kompute-jni PRIVATE kompute::kompute shader log android) -target_link_libraries(kompute-jni - # Libraries from kompute build - kompute - kompute_vk_ndk_wrapper - # Libraries from android build - log - android) \ No newline at end of file diff --git a/examples/android/android-simple/app/src/main/cpp/KomputeJniNative.cpp b/examples/android/android-simple/app/src/main/cpp/KomputeJniNative.cpp index 92939c4de..2b9e75dca 100644 --- a/examples/android/android-simple/app/src/main/cpp/KomputeJniNative.cpp +++ b/examples/android/android-simple/app/src/main/cpp/KomputeJniNative.cpp @@ -24,10 +24,7 @@ // Allows us to use the C++ sleep function to wait when loading the // Vulkan library in android #include - -#ifndef KOMPUTE_VK_INIT_RETRIES -#define KOMPUTE_VK_INIT_RETRIES 5 -#endif +#include static std::vector jfloatArrayToVector(JNIEnv* env, const jfloatArray& fromArray) @@ -62,16 +59,17 @@ extern "C" uint32_t totalRetries = 0; - while (totalRetries < KOMPUTE_VK_INIT_RETRIES) { + /*while (totalRetries < KOMPUTE_VK_INIT_RETRIES) { KP_LOG_INFO("VULKAN LOAD TRY NUMBER: %u", totalRetries); if (InitVulkan()) { break; } sleep(1); totalRetries++; - } + }*/ - return totalRetries < KOMPUTE_VK_INIT_RETRIES; + // return totalRetries < KOMPUTE_VK_INIT_RETRIES; + return true; } JNIEXPORT jfloatArray JNICALL diff --git a/examples/android/android-simple/app/src/main/cpp/KomputeModelML.cpp b/examples/android/android-simple/app/src/main/cpp/KomputeModelML.cpp index 3f674a783..1ff158553 100644 --- a/examples/android/android-simple/app/src/main/cpp/KomputeModelML.cpp +++ b/examples/android/android-simple/app/src/main/cpp/KomputeModelML.cpp @@ -1,5 +1,8 @@ #include "KomputeModelML.hpp" +#include "my_shader.hpp" +#include + KomputeModelML::KomputeModelML() {} @@ -10,7 +13,6 @@ KomputeModelML::train(std::vector yData, std::vector xIData, std::vector xJData) { - std::vector zerosData; for (size_t i = 0; i < yData.size(); i++) { @@ -41,15 +43,11 @@ KomputeModelML::train(std::vector yData, wIn, wOutI, wOutJ, bIn, bOut, lOut }; - std::vector spirv = std::vector( - (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)); + const std::vector shader = std::vector( + shader::MY_SHADER_COMP_SPV.begin(), shader::MY_SHADER_COMP_SPV.end()); std::shared_ptr algorithm = mgr.algorithm( - params, spirv, kp::Workgroup({ 5 }), std::vector({ 5.0 })); + params, shader, kp::Workgroup({ 5 }), std::vector({ 5.0 })); mgr.sequence()->eval(params); @@ -84,7 +82,6 @@ KomputeModelML::train(std::vector yData, std::vector KomputeModelML::predict(std::vector xI, std::vector xJ) { - KP_LOG_INFO("Running prediction inference"); assert(xI.size() == xJ.size()); @@ -113,7 +110,6 @@ KomputeModelML::predict(std::vector xI, std::vector xJ) std::vector KomputeModelML::get_params() { - KP_LOG_INFO("Displaying results"); std::vector retVector; diff --git a/examples/android/android-simple/app/src/main/cpp/KomputeModelML.hpp b/examples/android/android-simple/app/src/main/cpp/KomputeModelML.hpp index 779c6db7f..633877376 100644 --- a/examples/android/android-simple/app/src/main/cpp/KomputeModelML.hpp +++ b/examples/android/android-simple/app/src/main/cpp/KomputeModelML.hpp @@ -1,13 +1,8 @@ -#ifndef KOMPUTEMODELML_HPP -#define KOMPUTEMODELML_HPP +#pragma once -#include -#include #include -#include "kompute/Kompute.hpp" - class KomputeModelML { @@ -27,62 +22,3 @@ class KomputeModelML std::vector mWeights; std::vector mBias; }; - -static std::string LR_SHADER = R"( -#version 450 - -layout (constant_id = 0) const uint M = 0; - -layout (local_size_x = 1) in; - -layout(set = 0, binding = 0) buffer bxi { float xi[]; }; -layout(set = 0, binding = 1) buffer bxj { float xj[]; }; -layout(set = 0, binding = 2) buffer by { float y[]; }; -layout(set = 0, binding = 3) buffer bwin { float win[]; }; -layout(set = 0, binding = 4) buffer bwouti { float wouti[]; }; -layout(set = 0, binding = 5) buffer bwoutj { float woutj[]; }; -layout(set = 0, binding = 6) buffer bbin { float bin[]; }; -layout(set = 0, binding = 7) buffer bbout { float bout[]; }; -layout(set = 0, binding = 8) buffer blout { float lout[]; }; - -float m = float(M); - -float sigmoid(float z) { - return 1.0 / (1.0 + exp(-z)); -} - -float inference(vec2 x, vec2 w, float b) { - // Compute the linear mapping function - float z = dot(w, x) + b; - // Calculate the y-hat with sigmoid - float yHat = sigmoid(z); - return yHat; -} - -float calculateLoss(float yHat, float y) { - return -(y * log(yHat) + (1.0 - y) * log(1.0 - yHat)); -} - -void main() { - uint idx = gl_GlobalInvocationID.x; - - vec2 wCurr = vec2(win[0], win[1]); - float bCurr = bin[0]; - - vec2 xCurr = vec2(xi[idx], xj[idx]); - float yCurr = y[idx]; - - float yHat = inference(xCurr, wCurr, bCurr); - - float dZ = yHat - yCurr; - vec2 dW = (1. / m) * xCurr * dZ; - float dB = (1. / m) * dZ; - wouti[idx] = dW.x; - woutj[idx] = dW.y; - bout[idx] = dB; - - lout[idx] = calculateLoss(yHat, yCurr); -} -)"; - -#endif // ANDROID_SIMPLE_KOMPUTEMODELML_HPP diff --git a/examples/android/android-simple/app/src/main/cpp/shader/CMakeLists.txt b/examples/android/android-simple/app/src/main/cpp/shader/CMakeLists.txt new file mode 100644 index 000000000..684a6a82a --- /dev/null +++ b/examples/android/android-simple/app/src/main/cpp/shader/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.20) + +# To add more shaders simply copy the vulkan_compile_shader command and replace it with your new shader +vulkan_compile_shader(INFILE my_shader.comp + OUTFILE my_shader.hpp + NAMESPACE "shader" + RELATIVE_PATH "${kompute_SOURCE_DIR}/cmake") + +# Then add it to the library, so you can access it later in your code +add_library(shader INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/my_shader.hpp" + + # "${CMAKE_CURRENT_BINARY_DIR}/my_shader2.hpp" +) + +target_include_directories(shader INTERFACE $) diff --git a/examples/android/android-simple/app/src/main/cpp/shader/my_shader.comp b/examples/android/android-simple/app/src/main/cpp/shader/my_shader.comp new file mode 100644 index 000000000..a448dde2e --- /dev/null +++ b/examples/android/android-simple/app/src/main/cpp/shader/my_shader.comp @@ -0,0 +1,54 @@ +#version 450 + +layout (constant_id = 0) const uint M = 0; + +layout (local_size_x = 1) in; + +layout(set = 0, binding = 0) buffer bxi { float xi[]; }; +layout(set = 0, binding = 1) buffer bxj { float xj[]; }; +layout(set = 0, binding = 2) buffer by { float y[]; }; +layout(set = 0, binding = 3) buffer bwin { float win[]; }; +layout(set = 0, binding = 4) buffer bwouti { float wouti[]; }; +layout(set = 0, binding = 5) buffer bwoutj { float woutj[]; }; +layout(set = 0, binding = 6) buffer bbin { float bin[]; }; +layout(set = 0, binding = 7) buffer bbout { float bout[]; }; +layout(set = 0, binding = 8) buffer blout { float lout[]; }; + +float m = float(M); + +float sigmoid(float z) { + return 1.0 / (1.0 + exp(-z)); +} + +float inference(vec2 x, vec2 w, float b) { + // Compute the linear mapping function + float z = dot(w, x) + b; + // Calculate the y-hat with sigmoid + float yHat = sigmoid(z); + return yHat; +} + +float calculateLoss(float yHat, float y) { + return -(y * log(yHat) + (1.0 - y) * log(1.0 - yHat)); +} + +void main() { + uint idx = gl_GlobalInvocationID.x; + + vec2 wCurr = vec2(win[0], win[1]); + float bCurr = bin[0]; + + vec2 xCurr = vec2(xi[idx], xj[idx]); + float yCurr = y[idx]; + + float yHat = inference(xCurr, wCurr, bCurr); + + float dZ = yHat - yCurr; + vec2 dW = (1. / m) * xCurr * dZ; + float dB = (1. / m) * dZ; + wouti[idx] = dW.x; + woutj[idx] = dW.y; + bout[idx] = dB; + + lout[idx] = calculateLoss(yHat, yCurr); +} \ No newline at end of file diff --git a/examples/android/android-simple/build.gradle b/examples/android/android-simple/build.gradle index 31a2d163f..6ed042a42 100644 --- a/examples/android/android-simple/build.gradle +++ b/examples/android/android-simple/build.gradle @@ -1,14 +1,14 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.3.72' + ext.kotlin_version = '1.6.20' repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:4.0.0' + classpath 'com.android.tools.build:gradle:7.3.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } diff --git a/examples/android/android-simple/gradle/wrapper/gradle-wrapper.properties b/examples/android/android-simple/gradle/wrapper/gradle-wrapper.properties index 12582e2e7..cfcf34b60 100644 --- a/examples/android/android-simple/gradle/wrapper/gradle-wrapper.properties +++ b/examples/android/android-simple/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0e4d6b2a5..dbb47dbe8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -16,7 +16,8 @@ add_library(kompute Algorithm.cpp OpTensorSyncDevice.cpp OpTensorSyncLocal.cpp Sequence.cpp - Tensor.cpp) + Tensor.cpp + Core.cpp) add_library(kompute::kompute ALIAS kompute) @@ -45,26 +46,11 @@ configure_package_config_file(${PROJECT_SOURCE_DIR}/cmake/komputeConfig.cmake.in install(FILES ${PROJECT_BINARY_DIR}/kompute/komputeConfig.cmake ${PROJECT_BINARY_DIR}/kompute/komputeConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kompute) -# #################################################### -# Android -# #################################################### -if(KOMPUTE_OPT_ANDROID_BUILD) - set(VK_ANDROID_COMMON_DIR ${ANDROID_NDK}/sources/third_party/vulkan/src/common) - set(VK_ANDROID_PATCH_DIR ${PROJECT_SOURCE_DIR}/vk_ndk_wrapper_include/) - set(VK_ANDROID_INCLUDE_DIR ${ANDROID_NDK}/sources/third_party/vulkan/src/include) - - include_directories(${VK_ANDROID_COMMON_DIR} - ${VK_ANDROID_PATCH_DIR} - ${VK_ANDROID_INCLUDE_DIR}) - - add_library(kompute_vk_ndk_wrapper STATIC ${PROJECT_SOURCE_DIR}/vk_ndk_wrapper_include/kompute_vk_ndk_wrapper.cpp) -endif() - # #################################################### # Linking # #################################################### if(KOMPUTE_OPT_ANDROID_BUILD) - target_link_libraries(kompute PUBLIC kompute_vk_ndk_wrapper + target_link_libraries(kompute PUBLIC vulkanAndroid android kp_logger kp_shader diff --git a/src/Core.cpp b/src/Core.cpp new file mode 100644 index 000000000..01c19ff36 --- /dev/null +++ b/src/Core.cpp @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: Apache-2.0 + +#include "kompute/Core.hpp" + +#if VK_USE_PLATFORM_ANDROID_KHR +#ifndef KOMPUTE_VK_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE +#define KOMPUTE_VK_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE +/** + * Ensures support for dynamic loading of Vulkan functions on Android. + * Acts as a default store for loaded functions. + * More information: + * https://github.com/KhronosGroup/Vulkan-Hpp#vulkan_hpp_default_dispatcher + **/ +VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE +#endif // !KOMPUTE_VK_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE +#endif // VK_USE_PLATFORM_ANDROID_KHR + +namespace kp { +} // namespace kp diff --git a/src/include/kompute/Core.hpp b/src/include/kompute/Core.hpp index 307228d55..2384e47b2 100644 --- a/src/include/kompute/Core.hpp +++ b/src/include/kompute/Core.hpp @@ -1,12 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 #pragma once -#if VK_USE_PLATFORM_ANDROID_KHR -#include -// VK_NO_PROTOTYPES required before vulkan import but after wrapper.hpp -#undef VK_NO_PROTOTYPES -#endif - #include // Typedefs to simplify interaction with core types diff --git a/src/include/kompute/logger/Logger.hpp b/src/include/kompute/logger/Logger.hpp index 4e3c1bd2a..29dfc8696 100644 --- a/src/include/kompute/logger/Logger.hpp +++ b/src/include/kompute/logger/Logger.hpp @@ -20,9 +20,7 @@ #if !KOMPUTE_OPT_USE_SPDLOG #if VK_USE_PLATFORM_ANDROID_KHR #include -#include -// VK_NO_PROTOTYPES required before vulkan import but after wrapper.hpp -#undef VK_NO_PROTOTYPES +#include static const char* KOMPUTE_LOG_TAG = "KomputeLog"; #else #if KOMPUTE_BUILD_PYTHON diff --git a/vk_ndk_wrapper_include/kompute_vk_ndk_wrapper.cpp b/vk_ndk_wrapper_include/kompute_vk_ndk_wrapper.cpp deleted file mode 100755 index e5a71e5dd..000000000 --- a/vk_ndk_wrapper_include/kompute_vk_ndk_wrapper.cpp +++ /dev/null @@ -1,798 +0,0 @@ -/* - * Copyright 2018 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// This file is generated. -#ifdef __cplusplus -extern "C" { -#endif - -#include "kompute_vk_ndk_wrapper.hpp" -#include - -PFN_vkCmdBuildAccelerationStructureNV vkCmdBuildAccelerationStructureNV; -PFN_vkCmdCopyAccelerationStructureNV vkCmdCopyAccelerationStructureNV; -PFN_vkCmdTraceRaysNV vkCmdTraceRaysNV; -PFN_vkCmdWriteAccelerationStructuresPropertiesNV vkCmdWriteAccelerationStructuresPropertiesNV; -PFN_vkBindAccelerationStructureMemoryNV vkBindAccelerationStructureMemoryNV; -PFN_vkCompileDeferredNV vkCompileDeferredNV; -PFN_vkCreateRayTracingPipelinesNV vkCreateRayTracingPipelinesNV; -PFN_vkDestroyAccelerationStructureNV vkDestroyAccelerationStructureNV; -PFN_vkGetAccelerationStructureHandleNV vkGetAccelerationStructureHandleNV; -PFN_vkGetAccelerationStructureMemoryRequirementsNV vkGetAccelerationStructureMemoryRequirementsNV; -PFN_vkGetRayTracingShaderGroupHandlesNV vkGetRayTracingShaderGroupHandlesNV; - -#ifdef VK_USE_PLATFORM_ANDROID_KHR -PFN_vkCreateAndroidSurfaceKHR vkCreateAndroidSurfaceKHR; -#endif - -#ifdef VK_USE_PLATFORM_ANDROID_KHR -PFN_vkGetAndroidHardwareBufferPropertiesANDROID vkGetAndroidHardwareBufferPropertiesANDROID; -PFN_vkGetMemoryAndroidHardwareBufferANDROID vkGetMemoryAndroidHardwareBufferANDROID; -#endif - - -int InitVulkan(void) { - void* libvulkan = dlopen("libvulkan.so", RTLD_NOW | RTLD_LOCAL); - if (!libvulkan) return 0; - - // Vulkan supported, set function addresses - vkCreateInstance = reinterpret_cast(dlsym(libvulkan, "vkCreateInstance")); - vkDestroyInstance = reinterpret_cast(dlsym(libvulkan, "vkDestroyInstance")); - vkEnumeratePhysicalDevices = reinterpret_cast(dlsym(libvulkan, "vkEnumeratePhysicalDevices")); - vkGetPhysicalDeviceFeatures = - reinterpret_cast(dlsym(libvulkan, "vkGetPhysicalDeviceFeatures")); - vkGetPhysicalDeviceFormatProperties = - reinterpret_cast(dlsym(libvulkan, "vkGetPhysicalDeviceFormatProperties")); - vkGetPhysicalDeviceImageFormatProperties = reinterpret_cast( - dlsym(libvulkan, "vkGetPhysicalDeviceImageFormatProperties")); - vkGetPhysicalDeviceProperties = - reinterpret_cast(dlsym(libvulkan, "vkGetPhysicalDeviceProperties")); - vkGetPhysicalDeviceQueueFamilyProperties = reinterpret_cast( - dlsym(libvulkan, "vkGetPhysicalDeviceQueueFamilyProperties")); - vkGetPhysicalDeviceMemoryProperties = - reinterpret_cast(dlsym(libvulkan, "vkGetPhysicalDeviceMemoryProperties")); - vkGetInstanceProcAddr = reinterpret_cast(dlsym(libvulkan, "vkGetInstanceProcAddr")); - vkGetDeviceProcAddr = reinterpret_cast(dlsym(libvulkan, "vkGetDeviceProcAddr")); - vkCreateDevice = reinterpret_cast(dlsym(libvulkan, "vkCreateDevice")); - vkDestroyDevice = reinterpret_cast(dlsym(libvulkan, "vkDestroyDevice")); - vkEnumerateInstanceExtensionProperties = - reinterpret_cast(dlsym(libvulkan, "vkEnumerateInstanceExtensionProperties")); - vkEnumerateDeviceExtensionProperties = - reinterpret_cast(dlsym(libvulkan, "vkEnumerateDeviceExtensionProperties")); - vkEnumerateInstanceLayerProperties = - reinterpret_cast(dlsym(libvulkan, "vkEnumerateInstanceLayerProperties")); - vkEnumerateDeviceLayerProperties = - reinterpret_cast(dlsym(libvulkan, "vkEnumerateDeviceLayerProperties")); - vkGetDeviceQueue = reinterpret_cast(dlsym(libvulkan, "vkGetDeviceQueue")); - vkQueueSubmit = reinterpret_cast(dlsym(libvulkan, "vkQueueSubmit")); - vkQueueWaitIdle = reinterpret_cast(dlsym(libvulkan, "vkQueueWaitIdle")); - vkDeviceWaitIdle = reinterpret_cast(dlsym(libvulkan, "vkDeviceWaitIdle")); - vkAllocateMemory = reinterpret_cast(dlsym(libvulkan, "vkAllocateMemory")); - vkFreeMemory = reinterpret_cast(dlsym(libvulkan, "vkFreeMemory")); - vkMapMemory = reinterpret_cast(dlsym(libvulkan, "vkMapMemory")); - vkUnmapMemory = reinterpret_cast(dlsym(libvulkan, "vkUnmapMemory")); - vkFlushMappedMemoryRanges = reinterpret_cast(dlsym(libvulkan, "vkFlushMappedMemoryRanges")); - vkInvalidateMappedMemoryRanges = - reinterpret_cast(dlsym(libvulkan, "vkInvalidateMappedMemoryRanges")); - vkGetDeviceMemoryCommitment = - reinterpret_cast(dlsym(libvulkan, "vkGetDeviceMemoryCommitment")); - vkBindBufferMemory = reinterpret_cast(dlsym(libvulkan, "vkBindBufferMemory")); - vkBindImageMemory = reinterpret_cast(dlsym(libvulkan, "vkBindImageMemory")); - vkGetBufferMemoryRequirements = - reinterpret_cast(dlsym(libvulkan, "vkGetBufferMemoryRequirements")); - vkGetImageMemoryRequirements = - reinterpret_cast(dlsym(libvulkan, "vkGetImageMemoryRequirements")); - vkGetImageSparseMemoryRequirements = - reinterpret_cast(dlsym(libvulkan, "vkGetImageSparseMemoryRequirements")); - vkGetPhysicalDeviceSparseImageFormatProperties = reinterpret_cast( - dlsym(libvulkan, "vkGetPhysicalDeviceSparseImageFormatProperties")); - vkQueueBindSparse = reinterpret_cast(dlsym(libvulkan, "vkQueueBindSparse")); - vkCreateFence = reinterpret_cast(dlsym(libvulkan, "vkCreateFence")); - vkDestroyFence = reinterpret_cast(dlsym(libvulkan, "vkDestroyFence")); - vkResetFences = reinterpret_cast(dlsym(libvulkan, "vkResetFences")); - vkGetFenceStatus = reinterpret_cast(dlsym(libvulkan, "vkGetFenceStatus")); - vkWaitForFences = reinterpret_cast(dlsym(libvulkan, "vkWaitForFences")); - vkCreateSemaphore = reinterpret_cast(dlsym(libvulkan, "vkCreateSemaphore")); - vkDestroySemaphore = reinterpret_cast(dlsym(libvulkan, "vkDestroySemaphore")); - vkCreateEvent = reinterpret_cast(dlsym(libvulkan, "vkCreateEvent")); - vkDestroyEvent = reinterpret_cast(dlsym(libvulkan, "vkDestroyEvent")); - vkGetEventStatus = reinterpret_cast(dlsym(libvulkan, "vkGetEventStatus")); - vkSetEvent = reinterpret_cast(dlsym(libvulkan, "vkSetEvent")); - vkResetEvent = reinterpret_cast(dlsym(libvulkan, "vkResetEvent")); - vkCreateQueryPool = reinterpret_cast(dlsym(libvulkan, "vkCreateQueryPool")); - vkDestroyQueryPool = reinterpret_cast(dlsym(libvulkan, "vkDestroyQueryPool")); - vkGetQueryPoolResults = reinterpret_cast(dlsym(libvulkan, "vkGetQueryPoolResults")); - vkCreateBuffer = reinterpret_cast(dlsym(libvulkan, "vkCreateBuffer")); - vkDestroyBuffer = reinterpret_cast(dlsym(libvulkan, "vkDestroyBuffer")); - vkCreateBufferView = reinterpret_cast(dlsym(libvulkan, "vkCreateBufferView")); - vkDestroyBufferView = reinterpret_cast(dlsym(libvulkan, "vkDestroyBufferView")); - vkCreateImage = reinterpret_cast(dlsym(libvulkan, "vkCreateImage")); - vkDestroyImage = reinterpret_cast(dlsym(libvulkan, "vkDestroyImage")); - vkGetImageSubresourceLayout = - reinterpret_cast(dlsym(libvulkan, "vkGetImageSubresourceLayout")); - vkCreateImageView = reinterpret_cast(dlsym(libvulkan, "vkCreateImageView")); - vkDestroyImageView = reinterpret_cast(dlsym(libvulkan, "vkDestroyImageView")); - vkCreateShaderModule = reinterpret_cast(dlsym(libvulkan, "vkCreateShaderModule")); - vkDestroyShaderModule = reinterpret_cast(dlsym(libvulkan, "vkDestroyShaderModule")); - vkCreatePipelineCache = reinterpret_cast(dlsym(libvulkan, "vkCreatePipelineCache")); - vkDestroyPipelineCache = reinterpret_cast(dlsym(libvulkan, "vkDestroyPipelineCache")); - vkGetPipelineCacheData = reinterpret_cast(dlsym(libvulkan, "vkGetPipelineCacheData")); - vkMergePipelineCaches = reinterpret_cast(dlsym(libvulkan, "vkMergePipelineCaches")); - vkCreateGraphicsPipelines = reinterpret_cast(dlsym(libvulkan, "vkCreateGraphicsPipelines")); - vkCreateComputePipelines = reinterpret_cast(dlsym(libvulkan, "vkCreateComputePipelines")); - vkDestroyPipeline = reinterpret_cast(dlsym(libvulkan, "vkDestroyPipeline")); - vkCreatePipelineLayout = reinterpret_cast(dlsym(libvulkan, "vkCreatePipelineLayout")); - vkDestroyPipelineLayout = reinterpret_cast(dlsym(libvulkan, "vkDestroyPipelineLayout")); - vkCreateSampler = reinterpret_cast(dlsym(libvulkan, "vkCreateSampler")); - vkDestroySampler = reinterpret_cast(dlsym(libvulkan, "vkDestroySampler")); - vkCreateDescriptorSetLayout = - reinterpret_cast(dlsym(libvulkan, "vkCreateDescriptorSetLayout")); - vkDestroyDescriptorSetLayout = - reinterpret_cast(dlsym(libvulkan, "vkDestroyDescriptorSetLayout")); - vkCreateDescriptorPool = reinterpret_cast(dlsym(libvulkan, "vkCreateDescriptorPool")); - vkDestroyDescriptorPool = reinterpret_cast(dlsym(libvulkan, "vkDestroyDescriptorPool")); - vkResetDescriptorPool = reinterpret_cast(dlsym(libvulkan, "vkResetDescriptorPool")); - vkAllocateDescriptorSets = reinterpret_cast(dlsym(libvulkan, "vkAllocateDescriptorSets")); - vkFreeDescriptorSets = reinterpret_cast(dlsym(libvulkan, "vkFreeDescriptorSets")); - vkUpdateDescriptorSets = reinterpret_cast(dlsym(libvulkan, "vkUpdateDescriptorSets")); - vkCreateFramebuffer = reinterpret_cast(dlsym(libvulkan, "vkCreateFramebuffer")); - vkDestroyFramebuffer = reinterpret_cast(dlsym(libvulkan, "vkDestroyFramebuffer")); - vkCreateRenderPass = reinterpret_cast(dlsym(libvulkan, "vkCreateRenderPass")); - vkDestroyRenderPass = reinterpret_cast(dlsym(libvulkan, "vkDestroyRenderPass")); - vkGetRenderAreaGranularity = reinterpret_cast(dlsym(libvulkan, "vkGetRenderAreaGranularity")); - vkCreateCommandPool = reinterpret_cast(dlsym(libvulkan, "vkCreateCommandPool")); - vkDestroyCommandPool = reinterpret_cast(dlsym(libvulkan, "vkDestroyCommandPool")); - vkResetCommandPool = reinterpret_cast(dlsym(libvulkan, "vkResetCommandPool")); - vkAllocateCommandBuffers = reinterpret_cast(dlsym(libvulkan, "vkAllocateCommandBuffers")); - vkFreeCommandBuffers = reinterpret_cast(dlsym(libvulkan, "vkFreeCommandBuffers")); - vkBeginCommandBuffer = reinterpret_cast(dlsym(libvulkan, "vkBeginCommandBuffer")); - vkEndCommandBuffer = reinterpret_cast(dlsym(libvulkan, "vkEndCommandBuffer")); - vkResetCommandBuffer = reinterpret_cast(dlsym(libvulkan, "vkResetCommandBuffer")); - vkCmdBindPipeline = reinterpret_cast(dlsym(libvulkan, "vkCmdBindPipeline")); - vkCmdSetViewport = reinterpret_cast(dlsym(libvulkan, "vkCmdSetViewport")); - vkCmdSetScissor = reinterpret_cast(dlsym(libvulkan, "vkCmdSetScissor")); - vkCmdSetLineWidth = reinterpret_cast(dlsym(libvulkan, "vkCmdSetLineWidth")); - vkCmdSetDepthBias = reinterpret_cast(dlsym(libvulkan, "vkCmdSetDepthBias")); - vkCmdSetBlendConstants = reinterpret_cast(dlsym(libvulkan, "vkCmdSetBlendConstants")); - vkCmdSetDepthBounds = reinterpret_cast(dlsym(libvulkan, "vkCmdSetDepthBounds")); - vkCmdSetStencilCompareMask = reinterpret_cast(dlsym(libvulkan, "vkCmdSetStencilCompareMask")); - vkCmdSetStencilWriteMask = reinterpret_cast(dlsym(libvulkan, "vkCmdSetStencilWriteMask")); - vkCmdSetStencilReference = reinterpret_cast(dlsym(libvulkan, "vkCmdSetStencilReference")); - vkCmdBindDescriptorSets = reinterpret_cast(dlsym(libvulkan, "vkCmdBindDescriptorSets")); - vkCmdBindIndexBuffer = reinterpret_cast(dlsym(libvulkan, "vkCmdBindIndexBuffer")); - vkCmdBindVertexBuffers = reinterpret_cast(dlsym(libvulkan, "vkCmdBindVertexBuffers")); - vkCmdDraw = reinterpret_cast(dlsym(libvulkan, "vkCmdDraw")); - vkCmdDrawIndexed = reinterpret_cast(dlsym(libvulkan, "vkCmdDrawIndexed")); - vkCmdDrawIndirect = reinterpret_cast(dlsym(libvulkan, "vkCmdDrawIndirect")); - vkCmdDrawIndexedIndirect = reinterpret_cast(dlsym(libvulkan, "vkCmdDrawIndexedIndirect")); - vkCmdDispatch = reinterpret_cast(dlsym(libvulkan, "vkCmdDispatch")); - vkCmdDispatchIndirect = reinterpret_cast(dlsym(libvulkan, "vkCmdDispatchIndirect")); - vkCmdCopyBuffer = reinterpret_cast(dlsym(libvulkan, "vkCmdCopyBuffer")); - vkCmdCopyImage = reinterpret_cast(dlsym(libvulkan, "vkCmdCopyImage")); - vkCmdBlitImage = reinterpret_cast(dlsym(libvulkan, "vkCmdBlitImage")); - vkCmdCopyBufferToImage = reinterpret_cast(dlsym(libvulkan, "vkCmdCopyBufferToImage")); - vkCmdCopyImageToBuffer = reinterpret_cast(dlsym(libvulkan, "vkCmdCopyImageToBuffer")); - vkCmdUpdateBuffer = reinterpret_cast(dlsym(libvulkan, "vkCmdUpdateBuffer")); - vkCmdFillBuffer = reinterpret_cast(dlsym(libvulkan, "vkCmdFillBuffer")); - vkCmdClearColorImage = reinterpret_cast(dlsym(libvulkan, "vkCmdClearColorImage")); - vkCmdClearDepthStencilImage = - reinterpret_cast(dlsym(libvulkan, "vkCmdClearDepthStencilImage")); - vkCmdClearAttachments = reinterpret_cast(dlsym(libvulkan, "vkCmdClearAttachments")); - vkCmdResolveImage = reinterpret_cast(dlsym(libvulkan, "vkCmdResolveImage")); - vkCmdSetEvent = reinterpret_cast(dlsym(libvulkan, "vkCmdSetEvent")); - vkCmdResetEvent = reinterpret_cast(dlsym(libvulkan, "vkCmdResetEvent")); - vkCmdWaitEvents = reinterpret_cast(dlsym(libvulkan, "vkCmdWaitEvents")); - vkCmdPipelineBarrier = reinterpret_cast(dlsym(libvulkan, "vkCmdPipelineBarrier")); - vkCmdBeginQuery = reinterpret_cast(dlsym(libvulkan, "vkCmdBeginQuery")); - vkCmdEndQuery = reinterpret_cast(dlsym(libvulkan, "vkCmdEndQuery")); - vkCmdResetQueryPool = reinterpret_cast(dlsym(libvulkan, "vkCmdResetQueryPool")); - vkCmdWriteTimestamp = reinterpret_cast(dlsym(libvulkan, "vkCmdWriteTimestamp")); - vkCmdCopyQueryPoolResults = reinterpret_cast(dlsym(libvulkan, "vkCmdCopyQueryPoolResults")); - vkCmdPushConstants = reinterpret_cast(dlsym(libvulkan, "vkCmdPushConstants")); - vkCmdBeginRenderPass = reinterpret_cast(dlsym(libvulkan, "vkCmdBeginRenderPass")); - vkCmdNextSubpass = reinterpret_cast(dlsym(libvulkan, "vkCmdNextSubpass")); - vkCmdEndRenderPass = reinterpret_cast(dlsym(libvulkan, "vkCmdEndRenderPass")); - vkCmdExecuteCommands = reinterpret_cast(dlsym(libvulkan, "vkCmdExecuteCommands")); - vkEnumerateInstanceVersion = reinterpret_cast(dlsym(libvulkan, "vkEnumerateInstanceVersion")); - vkBindBufferMemory2 = reinterpret_cast(dlsym(libvulkan, "vkBindBufferMemory2")); - vkBindImageMemory2 = reinterpret_cast(dlsym(libvulkan, "vkBindImageMemory2")); - vkGetDeviceGroupPeerMemoryFeatures = - reinterpret_cast(dlsym(libvulkan, "vkGetDeviceGroupPeerMemoryFeatures")); - vkCmdSetDeviceMask = reinterpret_cast(dlsym(libvulkan, "vkCmdSetDeviceMask")); - vkCmdDispatchBase = reinterpret_cast(dlsym(libvulkan, "vkCmdDispatchBase")); - vkEnumeratePhysicalDeviceGroups = - reinterpret_cast(dlsym(libvulkan, "vkEnumeratePhysicalDeviceGroups")); - vkGetImageMemoryRequirements2 = - reinterpret_cast(dlsym(libvulkan, "vkGetImageMemoryRequirements2")); - vkGetBufferMemoryRequirements2 = - reinterpret_cast(dlsym(libvulkan, "vkGetBufferMemoryRequirements2")); - vkGetImageSparseMemoryRequirements2 = - reinterpret_cast(dlsym(libvulkan, "vkGetImageSparseMemoryRequirements2")); - vkGetPhysicalDeviceFeatures2 = - reinterpret_cast(dlsym(libvulkan, "vkGetPhysicalDeviceFeatures2")); - vkGetPhysicalDeviceProperties2 = - reinterpret_cast(dlsym(libvulkan, "vkGetPhysicalDeviceProperties2")); - vkGetPhysicalDeviceFormatProperties2 = - reinterpret_cast(dlsym(libvulkan, "vkGetPhysicalDeviceFormatProperties2")); - vkGetPhysicalDeviceImageFormatProperties2 = reinterpret_cast( - dlsym(libvulkan, "vkGetPhysicalDeviceImageFormatProperties2")); - vkGetPhysicalDeviceQueueFamilyProperties2 = reinterpret_cast( - dlsym(libvulkan, "vkGetPhysicalDeviceQueueFamilyProperties2")); - vkGetPhysicalDeviceMemoryProperties2 = - reinterpret_cast(dlsym(libvulkan, "vkGetPhysicalDeviceMemoryProperties2")); - vkGetPhysicalDeviceSparseImageFormatProperties2 = reinterpret_cast( - dlsym(libvulkan, "vkGetPhysicalDeviceSparseImageFormatProperties2")); - vkTrimCommandPool = reinterpret_cast(dlsym(libvulkan, "vkTrimCommandPool")); - vkGetDeviceQueue2 = reinterpret_cast(dlsym(libvulkan, "vkGetDeviceQueue2")); - vkCreateSamplerYcbcrConversion = - reinterpret_cast(dlsym(libvulkan, "vkCreateSamplerYcbcrConversion")); - vkDestroySamplerYcbcrConversion = - reinterpret_cast(dlsym(libvulkan, "vkDestroySamplerYcbcrConversion")); - vkCreateDescriptorUpdateTemplate = - reinterpret_cast(dlsym(libvulkan, "vkCreateDescriptorUpdateTemplate")); - vkDestroyDescriptorUpdateTemplate = - reinterpret_cast(dlsym(libvulkan, "vkDestroyDescriptorUpdateTemplate")); - vkUpdateDescriptorSetWithTemplate = - reinterpret_cast(dlsym(libvulkan, "vkUpdateDescriptorSetWithTemplate")); - vkGetPhysicalDeviceExternalBufferProperties = reinterpret_cast( - dlsym(libvulkan, "vkGetPhysicalDeviceExternalBufferProperties")); - vkGetPhysicalDeviceExternalFenceProperties = reinterpret_cast( - dlsym(libvulkan, "vkGetPhysicalDeviceExternalFenceProperties")); - vkGetPhysicalDeviceExternalSemaphoreProperties = reinterpret_cast( - dlsym(libvulkan, "vkGetPhysicalDeviceExternalSemaphoreProperties")); - vkGetDescriptorSetLayoutSupport = - reinterpret_cast(dlsym(libvulkan, "vkGetDescriptorSetLayoutSupport")); - vkDestroySurfaceKHR = reinterpret_cast(dlsym(libvulkan, "vkDestroySurfaceKHR")); - vkGetPhysicalDeviceSurfaceSupportKHR = - reinterpret_cast(dlsym(libvulkan, "vkGetPhysicalDeviceSurfaceSupportKHR")); - vkGetPhysicalDeviceSurfaceCapabilitiesKHR = reinterpret_cast( - dlsym(libvulkan, "vkGetPhysicalDeviceSurfaceCapabilitiesKHR")); - vkGetPhysicalDeviceSurfaceFormatsKHR = - reinterpret_cast(dlsym(libvulkan, "vkGetPhysicalDeviceSurfaceFormatsKHR")); - vkGetPhysicalDeviceSurfacePresentModesKHR = reinterpret_cast( - dlsym(libvulkan, "vkGetPhysicalDeviceSurfacePresentModesKHR")); - vkCreateSwapchainKHR = reinterpret_cast(dlsym(libvulkan, "vkCreateSwapchainKHR")); - vkDestroySwapchainKHR = reinterpret_cast(dlsym(libvulkan, "vkDestroySwapchainKHR")); - vkGetSwapchainImagesKHR = reinterpret_cast(dlsym(libvulkan, "vkGetSwapchainImagesKHR")); - vkAcquireNextImageKHR = reinterpret_cast(dlsym(libvulkan, "vkAcquireNextImageKHR")); - vkQueuePresentKHR = reinterpret_cast(dlsym(libvulkan, "vkQueuePresentKHR")); - vkGetDeviceGroupPresentCapabilitiesKHR = - reinterpret_cast(dlsym(libvulkan, "vkGetDeviceGroupPresentCapabilitiesKHR")); - vkGetDeviceGroupSurfacePresentModesKHR = - reinterpret_cast(dlsym(libvulkan, "vkGetDeviceGroupSurfacePresentModesKHR")); - vkGetPhysicalDevicePresentRectanglesKHR = - reinterpret_cast(dlsym(libvulkan, "vkGetPhysicalDevicePresentRectanglesKHR")); - vkAcquireNextImage2KHR = reinterpret_cast(dlsym(libvulkan, "vkAcquireNextImage2KHR")); - vkGetPhysicalDeviceDisplayPropertiesKHR = - reinterpret_cast(dlsym(libvulkan, "vkGetPhysicalDeviceDisplayPropertiesKHR")); - vkGetPhysicalDeviceDisplayPlanePropertiesKHR = reinterpret_cast( - dlsym(libvulkan, "vkGetPhysicalDeviceDisplayPlanePropertiesKHR")); - vkGetDisplayPlaneSupportedDisplaysKHR = - reinterpret_cast(dlsym(libvulkan, "vkGetDisplayPlaneSupportedDisplaysKHR")); - vkGetDisplayModePropertiesKHR = - reinterpret_cast(dlsym(libvulkan, "vkGetDisplayModePropertiesKHR")); - vkCreateDisplayModeKHR = reinterpret_cast(dlsym(libvulkan, "vkCreateDisplayModeKHR")); - vkGetDisplayPlaneCapabilitiesKHR = - reinterpret_cast(dlsym(libvulkan, "vkGetDisplayPlaneCapabilitiesKHR")); - vkCreateDisplayPlaneSurfaceKHR = - reinterpret_cast(dlsym(libvulkan, "vkCreateDisplayPlaneSurfaceKHR")); - vkCreateSharedSwapchainsKHR = - reinterpret_cast(dlsym(libvulkan, "vkCreateSharedSwapchainsKHR")); - vkGetPhysicalDeviceFeatures2KHR = - reinterpret_cast(dlsym(libvulkan, "vkGetPhysicalDeviceFeatures2KHR")); - vkGetPhysicalDeviceProperties2KHR = - reinterpret_cast(dlsym(libvulkan, "vkGetPhysicalDeviceProperties2KHR")); - vkGetPhysicalDeviceFormatProperties2KHR = - reinterpret_cast(dlsym(libvulkan, "vkGetPhysicalDeviceFormatProperties2KHR")); - vkGetPhysicalDeviceImageFormatProperties2KHR = reinterpret_cast( - dlsym(libvulkan, "vkGetPhysicalDeviceImageFormatProperties2KHR")); - vkGetPhysicalDeviceQueueFamilyProperties2KHR = reinterpret_cast( - dlsym(libvulkan, "vkGetPhysicalDeviceQueueFamilyProperties2KHR")); - vkGetPhysicalDeviceMemoryProperties2KHR = - reinterpret_cast(dlsym(libvulkan, "vkGetPhysicalDeviceMemoryProperties2KHR")); - vkGetPhysicalDeviceSparseImageFormatProperties2KHR = reinterpret_cast( - dlsym(libvulkan, "vkGetPhysicalDeviceSparseImageFormatProperties2KHR")); - vkGetDeviceGroupPeerMemoryFeaturesKHR = - reinterpret_cast(dlsym(libvulkan, "vkGetDeviceGroupPeerMemoryFeaturesKHR")); - vkCmdSetDeviceMaskKHR = reinterpret_cast(dlsym(libvulkan, "vkCmdSetDeviceMaskKHR")); - vkCmdDispatchBaseKHR = reinterpret_cast(dlsym(libvulkan, "vkCmdDispatchBaseKHR")); - vkTrimCommandPoolKHR = reinterpret_cast(dlsym(libvulkan, "vkTrimCommandPoolKHR")); - vkEnumeratePhysicalDeviceGroupsKHR = - reinterpret_cast(dlsym(libvulkan, "vkEnumeratePhysicalDeviceGroupsKHR")); - vkGetPhysicalDeviceExternalBufferPropertiesKHR = reinterpret_cast( - dlsym(libvulkan, "vkGetPhysicalDeviceExternalBufferPropertiesKHR")); - vkGetMemoryFdKHR = reinterpret_cast(dlsym(libvulkan, "vkGetMemoryFdKHR")); - vkGetMemoryFdPropertiesKHR = reinterpret_cast(dlsym(libvulkan, "vkGetMemoryFdPropertiesKHR")); - vkGetPhysicalDeviceExternalSemaphorePropertiesKHR = reinterpret_cast( - dlsym(libvulkan, "vkGetPhysicalDeviceExternalSemaphorePropertiesKHR")); - vkImportSemaphoreFdKHR = reinterpret_cast(dlsym(libvulkan, "vkImportSemaphoreFdKHR")); - vkGetSemaphoreFdKHR = reinterpret_cast(dlsym(libvulkan, "vkGetSemaphoreFdKHR")); - vkCmdPushDescriptorSetKHR = reinterpret_cast(dlsym(libvulkan, "vkCmdPushDescriptorSetKHR")); - vkCmdPushDescriptorSetWithTemplateKHR = - reinterpret_cast(dlsym(libvulkan, "vkCmdPushDescriptorSetWithTemplateKHR")); - vkCreateDescriptorUpdateTemplateKHR = - reinterpret_cast(dlsym(libvulkan, "vkCreateDescriptorUpdateTemplateKHR")); - vkDestroyDescriptorUpdateTemplateKHR = - reinterpret_cast(dlsym(libvulkan, "vkDestroyDescriptorUpdateTemplateKHR")); - vkUpdateDescriptorSetWithTemplateKHR = - reinterpret_cast(dlsym(libvulkan, "vkUpdateDescriptorSetWithTemplateKHR")); - vkCreateRenderPass2KHR = reinterpret_cast(dlsym(libvulkan, "vkCreateRenderPass2KHR")); - vkCmdBeginRenderPass2KHR = reinterpret_cast(dlsym(libvulkan, "vkCmdBeginRenderPass2KHR")); - vkCmdNextSubpass2KHR = reinterpret_cast(dlsym(libvulkan, "vkCmdNextSubpass2KHR")); - vkCmdEndRenderPass2KHR = reinterpret_cast(dlsym(libvulkan, "vkCmdEndRenderPass2KHR")); - vkGetSwapchainStatusKHR = reinterpret_cast(dlsym(libvulkan, "vkGetSwapchainStatusKHR")); - vkGetPhysicalDeviceExternalFencePropertiesKHR = reinterpret_cast( - dlsym(libvulkan, "vkGetPhysicalDeviceExternalFencePropertiesKHR")); - vkImportFenceFdKHR = reinterpret_cast(dlsym(libvulkan, "vkImportFenceFdKHR")); - vkGetFenceFdKHR = reinterpret_cast(dlsym(libvulkan, "vkGetFenceFdKHR")); - vkGetPhysicalDeviceSurfaceCapabilities2KHR = reinterpret_cast( - dlsym(libvulkan, "vkGetPhysicalDeviceSurfaceCapabilities2KHR")); - vkGetPhysicalDeviceSurfaceFormats2KHR = - reinterpret_cast(dlsym(libvulkan, "vkGetPhysicalDeviceSurfaceFormats2KHR")); - vkGetPhysicalDeviceDisplayProperties2KHR = reinterpret_cast( - dlsym(libvulkan, "vkGetPhysicalDeviceDisplayProperties2KHR")); - vkGetPhysicalDeviceDisplayPlaneProperties2KHR = reinterpret_cast( - dlsym(libvulkan, "vkGetPhysicalDeviceDisplayPlaneProperties2KHR")); - vkGetDisplayModeProperties2KHR = - reinterpret_cast(dlsym(libvulkan, "vkGetDisplayModeProperties2KHR")); - vkGetDisplayPlaneCapabilities2KHR = - reinterpret_cast(dlsym(libvulkan, "vkGetDisplayPlaneCapabilities2KHR")); - vkGetImageMemoryRequirements2KHR = - reinterpret_cast(dlsym(libvulkan, "vkGetImageMemoryRequirements2KHR")); - vkGetBufferMemoryRequirements2KHR = - reinterpret_cast(dlsym(libvulkan, "vkGetBufferMemoryRequirements2KHR")); - vkGetImageSparseMemoryRequirements2KHR = - reinterpret_cast(dlsym(libvulkan, "vkGetImageSparseMemoryRequirements2KHR")); - vkCreateSamplerYcbcrConversionKHR = - reinterpret_cast(dlsym(libvulkan, "vkCreateSamplerYcbcrConversionKHR")); - vkDestroySamplerYcbcrConversionKHR = - reinterpret_cast(dlsym(libvulkan, "vkDestroySamplerYcbcrConversionKHR")); - vkBindBufferMemory2KHR = reinterpret_cast(dlsym(libvulkan, "vkBindBufferMemory2KHR")); - vkBindImageMemory2KHR = reinterpret_cast(dlsym(libvulkan, "vkBindImageMemory2KHR")); - vkGetDescriptorSetLayoutSupportKHR = - reinterpret_cast(dlsym(libvulkan, "vkGetDescriptorSetLayoutSupportKHR")); - vkCmdDrawIndirectCountKHR = reinterpret_cast(dlsym(libvulkan, "vkCmdDrawIndirectCountKHR")); - vkCmdDrawIndexedIndirectCountKHR = - reinterpret_cast(dlsym(libvulkan, "vkCmdDrawIndexedIndirectCountKHR")); - -#ifdef VK_USE_PLATFORM_ANDROID_KHR - vkCreateAndroidSurfaceKHR = reinterpret_cast(dlsym(libvulkan, "vkCreateAndroidSurfaceKHR")); -#endif - -#ifdef VK_USE_PLATFORM_WAYLAND_KHR - vkCreateWaylandSurfaceKHR = reinterpret_cast(dlsym(libvulkan, "vkCreateWaylandSurfaceKHR")); - vkGetPhysicalDeviceWaylandPresentationSupportKHR = reinterpret_cast( - dlsym(libvulkan, "vkGetPhysicalDeviceWaylandPresentationSupportKHR")); -#endif - -#ifdef VK_USE_PLATFORM_WIN32_KHR - vkCreateWin32SurfaceKHR = reinterpret_cast(dlsym(libvulkan, "vkCreateWin32SurfaceKHR")); - vkGetPhysicalDeviceWin32PresentationSupportKHR = reinterpret_cast( - dlsym(libvulkan, "vkGetPhysicalDeviceWin32PresentationSupportKHR")); -#endif - -#ifdef VK_USE_PLATFORM_WIN32_KHR - vkGetMemoryWin32HandleKHR = reinterpret_cast(dlsym(libvulkan, "vkGetMemoryWin32HandleKHR")); - vkGetMemoryWin32HandlePropertiesKHR = - reinterpret_cast(dlsym(libvulkan, "vkGetMemoryWin32HandlePropertiesKHR")); -#endif - -#ifdef VK_USE_PLATFORM_WIN32_KHR -#endif - -#ifdef VK_USE_PLATFORM_WIN32_KHR - vkImportSemaphoreWin32HandleKHR = - reinterpret_cast(dlsym(libvulkan, "vkImportSemaphoreWin32HandleKHR")); - vkGetSemaphoreWin32HandleKHR = - reinterpret_cast(dlsym(libvulkan, "vkGetSemaphoreWin32HandleKHR")); -#endif - -#ifdef VK_USE_PLATFORM_WIN32_KHR - vkImportFenceWin32HandleKHR = - reinterpret_cast(dlsym(libvulkan, "vkImportFenceWin32HandleKHR")); - vkGetFenceWin32HandleKHR = reinterpret_cast(dlsym(libvulkan, "vkGetFenceWin32HandleKHR")); -#endif - -#ifdef VK_USE_PLATFORM_XCB_KHR - vkCreateXcbSurfaceKHR = reinterpret_cast(dlsym(libvulkan, "vkCreateXcbSurfaceKHR")); - vkGetPhysicalDeviceXcbPresentationSupportKHR = reinterpret_cast( - dlsym(libvulkan, "vkGetPhysicalDeviceXcbPresentationSupportKHR")); -#endif - -#ifdef VK_USE_PLATFORM_XLIB_KHR - vkCreateXlibSurfaceKHR = reinterpret_cast(dlsym(libvulkan, "vkCreateXlibSurfaceKHR")); - vkGetPhysicalDeviceXlibPresentationSupportKHR = reinterpret_cast( - dlsym(libvulkan, "vkGetPhysicalDeviceXlibPresentationSupportKHR")); -#endif - return 1; -} - -// No Vulkan support, do not set function addresses -PFN_vkCreateInstance vkCreateInstance; -PFN_vkDestroyInstance vkDestroyInstance; -PFN_vkEnumeratePhysicalDevices vkEnumeratePhysicalDevices; -PFN_vkGetPhysicalDeviceFeatures vkGetPhysicalDeviceFeatures; -PFN_vkGetPhysicalDeviceFormatProperties vkGetPhysicalDeviceFormatProperties; -PFN_vkGetPhysicalDeviceImageFormatProperties vkGetPhysicalDeviceImageFormatProperties; -PFN_vkGetPhysicalDeviceProperties vkGetPhysicalDeviceProperties; -PFN_vkGetPhysicalDeviceQueueFamilyProperties vkGetPhysicalDeviceQueueFamilyProperties; -PFN_vkGetPhysicalDeviceMemoryProperties vkGetPhysicalDeviceMemoryProperties; -PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr; -PFN_vkGetDeviceProcAddr vkGetDeviceProcAddr; -PFN_vkCreateDevice vkCreateDevice; -PFN_vkDestroyDevice vkDestroyDevice; -PFN_vkEnumerateInstanceExtensionProperties vkEnumerateInstanceExtensionProperties; -PFN_vkEnumerateDeviceExtensionProperties vkEnumerateDeviceExtensionProperties; -PFN_vkEnumerateInstanceLayerProperties vkEnumerateInstanceLayerProperties; -PFN_vkEnumerateDeviceLayerProperties vkEnumerateDeviceLayerProperties; -PFN_vkGetDeviceQueue vkGetDeviceQueue; -PFN_vkQueueSubmit vkQueueSubmit; -PFN_vkQueueWaitIdle vkQueueWaitIdle; -PFN_vkDeviceWaitIdle vkDeviceWaitIdle; -PFN_vkAllocateMemory vkAllocateMemory; -PFN_vkFreeMemory vkFreeMemory; -PFN_vkMapMemory vkMapMemory; -PFN_vkUnmapMemory vkUnmapMemory; -PFN_vkFlushMappedMemoryRanges vkFlushMappedMemoryRanges; -PFN_vkInvalidateMappedMemoryRanges vkInvalidateMappedMemoryRanges; -PFN_vkGetDeviceMemoryCommitment vkGetDeviceMemoryCommitment; -PFN_vkBindBufferMemory vkBindBufferMemory; -PFN_vkBindImageMemory vkBindImageMemory; -PFN_vkGetBufferMemoryRequirements vkGetBufferMemoryRequirements; -PFN_vkGetImageMemoryRequirements vkGetImageMemoryRequirements; -PFN_vkGetImageSparseMemoryRequirements vkGetImageSparseMemoryRequirements; -PFN_vkGetPhysicalDeviceSparseImageFormatProperties vkGetPhysicalDeviceSparseImageFormatProperties; -PFN_vkQueueBindSparse vkQueueBindSparse; -PFN_vkCreateFence vkCreateFence; -PFN_vkDestroyFence vkDestroyFence; -PFN_vkResetFences vkResetFences; -PFN_vkGetFenceStatus vkGetFenceStatus; -PFN_vkWaitForFences vkWaitForFences; -PFN_vkCreateSemaphore vkCreateSemaphore; -PFN_vkDestroySemaphore vkDestroySemaphore; -PFN_vkCreateEvent vkCreateEvent; -PFN_vkDestroyEvent vkDestroyEvent; -PFN_vkGetEventStatus vkGetEventStatus; -PFN_vkSetEvent vkSetEvent; -PFN_vkResetEvent vkResetEvent; -PFN_vkCreateQueryPool vkCreateQueryPool; -PFN_vkDestroyQueryPool vkDestroyQueryPool; -PFN_vkGetQueryPoolResults vkGetQueryPoolResults; -PFN_vkCreateBuffer vkCreateBuffer; -PFN_vkDestroyBuffer vkDestroyBuffer; -PFN_vkCreateBufferView vkCreateBufferView; -PFN_vkDestroyBufferView vkDestroyBufferView; -PFN_vkCreateImage vkCreateImage; -PFN_vkDestroyImage vkDestroyImage; -PFN_vkGetImageSubresourceLayout vkGetImageSubresourceLayout; -PFN_vkCreateImageView vkCreateImageView; -PFN_vkDestroyImageView vkDestroyImageView; -PFN_vkCreateShaderModule vkCreateShaderModule; -PFN_vkDestroyShaderModule vkDestroyShaderModule; -PFN_vkCreatePipelineCache vkCreatePipelineCache; -PFN_vkDestroyPipelineCache vkDestroyPipelineCache; -PFN_vkGetPipelineCacheData vkGetPipelineCacheData; -PFN_vkMergePipelineCaches vkMergePipelineCaches; -PFN_vkCreateGraphicsPipelines vkCreateGraphicsPipelines; -PFN_vkCreateComputePipelines vkCreateComputePipelines; -PFN_vkDestroyPipeline vkDestroyPipeline; -PFN_vkCreatePipelineLayout vkCreatePipelineLayout; -PFN_vkDestroyPipelineLayout vkDestroyPipelineLayout; -PFN_vkCreateSampler vkCreateSampler; -PFN_vkDestroySampler vkDestroySampler; -PFN_vkCreateDescriptorSetLayout vkCreateDescriptorSetLayout; -PFN_vkDestroyDescriptorSetLayout vkDestroyDescriptorSetLayout; -PFN_vkCreateDescriptorPool vkCreateDescriptorPool; -PFN_vkDestroyDescriptorPool vkDestroyDescriptorPool; -PFN_vkResetDescriptorPool vkResetDescriptorPool; -PFN_vkAllocateDescriptorSets vkAllocateDescriptorSets; -PFN_vkFreeDescriptorSets vkFreeDescriptorSets; -PFN_vkUpdateDescriptorSets vkUpdateDescriptorSets; -PFN_vkCreateFramebuffer vkCreateFramebuffer; -PFN_vkDestroyFramebuffer vkDestroyFramebuffer; -PFN_vkCreateRenderPass vkCreateRenderPass; -PFN_vkDestroyRenderPass vkDestroyRenderPass; -PFN_vkGetRenderAreaGranularity vkGetRenderAreaGranularity; -PFN_vkCreateCommandPool vkCreateCommandPool; -PFN_vkDestroyCommandPool vkDestroyCommandPool; -PFN_vkResetCommandPool vkResetCommandPool; -PFN_vkAllocateCommandBuffers vkAllocateCommandBuffers; -PFN_vkFreeCommandBuffers vkFreeCommandBuffers; -PFN_vkBeginCommandBuffer vkBeginCommandBuffer; -PFN_vkEndCommandBuffer vkEndCommandBuffer; -PFN_vkResetCommandBuffer vkResetCommandBuffer; -PFN_vkCmdBindPipeline vkCmdBindPipeline; -PFN_vkCmdSetViewport vkCmdSetViewport; -PFN_vkCmdSetScissor vkCmdSetScissor; -PFN_vkCmdSetLineWidth vkCmdSetLineWidth; -PFN_vkCmdSetDepthBias vkCmdSetDepthBias; -PFN_vkCmdSetBlendConstants vkCmdSetBlendConstants; -PFN_vkCmdSetDepthBounds vkCmdSetDepthBounds; -PFN_vkCmdSetStencilCompareMask vkCmdSetStencilCompareMask; -PFN_vkCmdSetStencilWriteMask vkCmdSetStencilWriteMask; -PFN_vkCmdSetStencilReference vkCmdSetStencilReference; -PFN_vkCmdBindDescriptorSets vkCmdBindDescriptorSets; -PFN_vkCmdBindIndexBuffer vkCmdBindIndexBuffer; -PFN_vkCmdBindVertexBuffers vkCmdBindVertexBuffers; -PFN_vkCmdDraw vkCmdDraw; -PFN_vkCmdDrawIndexed vkCmdDrawIndexed; -PFN_vkCmdDrawIndirect vkCmdDrawIndirect; -PFN_vkCmdDrawIndexedIndirect vkCmdDrawIndexedIndirect; -PFN_vkCmdDispatch vkCmdDispatch; -PFN_vkCmdDispatchIndirect vkCmdDispatchIndirect; -PFN_vkCmdCopyBuffer vkCmdCopyBuffer; -PFN_vkCmdCopyImage vkCmdCopyImage; -PFN_vkCmdBlitImage vkCmdBlitImage; -PFN_vkCmdCopyBufferToImage vkCmdCopyBufferToImage; -PFN_vkCmdCopyImageToBuffer vkCmdCopyImageToBuffer; -PFN_vkCmdUpdateBuffer vkCmdUpdateBuffer; -PFN_vkCmdFillBuffer vkCmdFillBuffer; -PFN_vkCmdClearColorImage vkCmdClearColorImage; -PFN_vkCmdClearDepthStencilImage vkCmdClearDepthStencilImage; -PFN_vkCmdClearAttachments vkCmdClearAttachments; -PFN_vkCmdResolveImage vkCmdResolveImage; -PFN_vkCmdSetEvent vkCmdSetEvent; -PFN_vkCmdResetEvent vkCmdResetEvent; -PFN_vkCmdWaitEvents vkCmdWaitEvents; -PFN_vkCmdPipelineBarrier vkCmdPipelineBarrier; -PFN_vkCmdBeginQuery vkCmdBeginQuery; -PFN_vkCmdEndQuery vkCmdEndQuery; -PFN_vkCmdResetQueryPool vkCmdResetQueryPool; -PFN_vkCmdWriteTimestamp vkCmdWriteTimestamp; -PFN_vkCmdCopyQueryPoolResults vkCmdCopyQueryPoolResults; -PFN_vkCmdPushConstants vkCmdPushConstants; -PFN_vkCmdBeginRenderPass vkCmdBeginRenderPass; -PFN_vkCmdNextSubpass vkCmdNextSubpass; -PFN_vkCmdEndRenderPass vkCmdEndRenderPass; -PFN_vkCmdExecuteCommands vkCmdExecuteCommands; -PFN_vkEnumerateInstanceVersion vkEnumerateInstanceVersion; -PFN_vkBindBufferMemory2 vkBindBufferMemory2; -PFN_vkBindImageMemory2 vkBindImageMemory2; -PFN_vkGetDeviceGroupPeerMemoryFeatures vkGetDeviceGroupPeerMemoryFeatures; -PFN_vkCmdSetDeviceMask vkCmdSetDeviceMask; -PFN_vkCmdDispatchBase vkCmdDispatchBase; -PFN_vkEnumeratePhysicalDeviceGroups vkEnumeratePhysicalDeviceGroups; -PFN_vkGetImageMemoryRequirements2 vkGetImageMemoryRequirements2; -PFN_vkGetBufferMemoryRequirements2 vkGetBufferMemoryRequirements2; -PFN_vkGetImageSparseMemoryRequirements2 vkGetImageSparseMemoryRequirements2; -PFN_vkGetPhysicalDeviceFeatures2 vkGetPhysicalDeviceFeatures2; -PFN_vkGetPhysicalDeviceProperties2 vkGetPhysicalDeviceProperties2; -PFN_vkGetPhysicalDeviceFormatProperties2 vkGetPhysicalDeviceFormatProperties2; -PFN_vkGetPhysicalDeviceImageFormatProperties2 vkGetPhysicalDeviceImageFormatProperties2; -PFN_vkGetPhysicalDeviceQueueFamilyProperties2 vkGetPhysicalDeviceQueueFamilyProperties2; -PFN_vkGetPhysicalDeviceMemoryProperties2 vkGetPhysicalDeviceMemoryProperties2; -PFN_vkGetPhysicalDeviceSparseImageFormatProperties2 vkGetPhysicalDeviceSparseImageFormatProperties2; -PFN_vkTrimCommandPool vkTrimCommandPool; -PFN_vkGetDeviceQueue2 vkGetDeviceQueue2; -PFN_vkCreateSamplerYcbcrConversion vkCreateSamplerYcbcrConversion; -PFN_vkDestroySamplerYcbcrConversion vkDestroySamplerYcbcrConversion; -PFN_vkCreateDescriptorUpdateTemplate vkCreateDescriptorUpdateTemplate; -PFN_vkDestroyDescriptorUpdateTemplate vkDestroyDescriptorUpdateTemplate; -PFN_vkUpdateDescriptorSetWithTemplate vkUpdateDescriptorSetWithTemplate; -PFN_vkGetPhysicalDeviceExternalBufferProperties vkGetPhysicalDeviceExternalBufferProperties; -PFN_vkGetPhysicalDeviceExternalFenceProperties vkGetPhysicalDeviceExternalFenceProperties; -PFN_vkGetPhysicalDeviceExternalSemaphoreProperties vkGetPhysicalDeviceExternalSemaphoreProperties; -PFN_vkGetDescriptorSetLayoutSupport vkGetDescriptorSetLayoutSupport; -PFN_vkDestroySurfaceKHR vkDestroySurfaceKHR; -PFN_vkGetPhysicalDeviceSurfaceSupportKHR vkGetPhysicalDeviceSurfaceSupportKHR; -PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR vkGetPhysicalDeviceSurfaceCapabilitiesKHR; -PFN_vkGetPhysicalDeviceSurfaceFormatsKHR vkGetPhysicalDeviceSurfaceFormatsKHR; -PFN_vkGetPhysicalDeviceSurfacePresentModesKHR vkGetPhysicalDeviceSurfacePresentModesKHR; -PFN_vkCreateSwapchainKHR vkCreateSwapchainKHR; -PFN_vkDestroySwapchainKHR vkDestroySwapchainKHR; -PFN_vkGetSwapchainImagesKHR vkGetSwapchainImagesKHR; -PFN_vkAcquireNextImageKHR vkAcquireNextImageKHR; -PFN_vkQueuePresentKHR vkQueuePresentKHR; -PFN_vkGetDeviceGroupPresentCapabilitiesKHR vkGetDeviceGroupPresentCapabilitiesKHR; -PFN_vkGetDeviceGroupSurfacePresentModesKHR vkGetDeviceGroupSurfacePresentModesKHR; -PFN_vkGetPhysicalDevicePresentRectanglesKHR vkGetPhysicalDevicePresentRectanglesKHR; -PFN_vkAcquireNextImage2KHR vkAcquireNextImage2KHR; -PFN_vkGetPhysicalDeviceDisplayPropertiesKHR vkGetPhysicalDeviceDisplayPropertiesKHR; -PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR vkGetPhysicalDeviceDisplayPlanePropertiesKHR; -PFN_vkGetDisplayPlaneSupportedDisplaysKHR vkGetDisplayPlaneSupportedDisplaysKHR; -PFN_vkGetDisplayModePropertiesKHR vkGetDisplayModePropertiesKHR; -PFN_vkCreateDisplayModeKHR vkCreateDisplayModeKHR; -PFN_vkGetDisplayPlaneCapabilitiesKHR vkGetDisplayPlaneCapabilitiesKHR; -PFN_vkCreateDisplayPlaneSurfaceKHR vkCreateDisplayPlaneSurfaceKHR; -PFN_vkCreateSharedSwapchainsKHR vkCreateSharedSwapchainsKHR; -PFN_vkGetPhysicalDeviceFeatures2KHR vkGetPhysicalDeviceFeatures2KHR; -PFN_vkGetPhysicalDeviceProperties2KHR vkGetPhysicalDeviceProperties2KHR; -PFN_vkGetPhysicalDeviceFormatProperties2KHR vkGetPhysicalDeviceFormatProperties2KHR; -PFN_vkGetPhysicalDeviceImageFormatProperties2KHR vkGetPhysicalDeviceImageFormatProperties2KHR; -PFN_vkGetPhysicalDeviceQueueFamilyProperties2KHR vkGetPhysicalDeviceQueueFamilyProperties2KHR; -PFN_vkGetPhysicalDeviceMemoryProperties2KHR vkGetPhysicalDeviceMemoryProperties2KHR; -PFN_vkGetPhysicalDeviceSparseImageFormatProperties2KHR vkGetPhysicalDeviceSparseImageFormatProperties2KHR; -PFN_vkGetDeviceGroupPeerMemoryFeaturesKHR vkGetDeviceGroupPeerMemoryFeaturesKHR; -PFN_vkCmdSetDeviceMaskKHR vkCmdSetDeviceMaskKHR; -PFN_vkCmdDispatchBaseKHR vkCmdDispatchBaseKHR; -PFN_vkTrimCommandPoolKHR vkTrimCommandPoolKHR; -PFN_vkEnumeratePhysicalDeviceGroupsKHR vkEnumeratePhysicalDeviceGroupsKHR; -PFN_vkGetPhysicalDeviceExternalBufferPropertiesKHR vkGetPhysicalDeviceExternalBufferPropertiesKHR; -PFN_vkGetMemoryFdKHR vkGetMemoryFdKHR; -PFN_vkGetMemoryFdPropertiesKHR vkGetMemoryFdPropertiesKHR; -PFN_vkGetPhysicalDeviceExternalSemaphorePropertiesKHR vkGetPhysicalDeviceExternalSemaphorePropertiesKHR; -PFN_vkImportSemaphoreFdKHR vkImportSemaphoreFdKHR; -PFN_vkGetSemaphoreFdKHR vkGetSemaphoreFdKHR; -PFN_vkCmdPushDescriptorSetKHR vkCmdPushDescriptorSetKHR; -PFN_vkCmdPushDescriptorSetWithTemplateKHR vkCmdPushDescriptorSetWithTemplateKHR; -PFN_vkCreateDescriptorUpdateTemplateKHR vkCreateDescriptorUpdateTemplateKHR; -PFN_vkDestroyDescriptorUpdateTemplateKHR vkDestroyDescriptorUpdateTemplateKHR; -PFN_vkUpdateDescriptorSetWithTemplateKHR vkUpdateDescriptorSetWithTemplateKHR; -PFN_vkCreateRenderPass2KHR vkCreateRenderPass2KHR; -PFN_vkCmdBeginRenderPass2KHR vkCmdBeginRenderPass2KHR; -PFN_vkCmdNextSubpass2KHR vkCmdNextSubpass2KHR; -PFN_vkCmdEndRenderPass2KHR vkCmdEndRenderPass2KHR; -PFN_vkGetSwapchainStatusKHR vkGetSwapchainStatusKHR; -PFN_vkGetPhysicalDeviceExternalFencePropertiesKHR vkGetPhysicalDeviceExternalFencePropertiesKHR; -PFN_vkImportFenceFdKHR vkImportFenceFdKHR; -PFN_vkGetFenceFdKHR vkGetFenceFdKHR; -PFN_vkGetPhysicalDeviceSurfaceCapabilities2KHR vkGetPhysicalDeviceSurfaceCapabilities2KHR; -PFN_vkGetPhysicalDeviceSurfaceFormats2KHR vkGetPhysicalDeviceSurfaceFormats2KHR; -PFN_vkGetPhysicalDeviceDisplayProperties2KHR vkGetPhysicalDeviceDisplayProperties2KHR; -PFN_vkGetPhysicalDeviceDisplayPlaneProperties2KHR vkGetPhysicalDeviceDisplayPlaneProperties2KHR; -PFN_vkGetDisplayModeProperties2KHR vkGetDisplayModeProperties2KHR; -PFN_vkGetDisplayPlaneCapabilities2KHR vkGetDisplayPlaneCapabilities2KHR; -PFN_vkGetImageMemoryRequirements2KHR vkGetImageMemoryRequirements2KHR; -PFN_vkGetBufferMemoryRequirements2KHR vkGetBufferMemoryRequirements2KHR; -PFN_vkGetImageSparseMemoryRequirements2KHR vkGetImageSparseMemoryRequirements2KHR; -PFN_vkCreateSamplerYcbcrConversionKHR vkCreateSamplerYcbcrConversionKHR; -PFN_vkDestroySamplerYcbcrConversionKHR vkDestroySamplerYcbcrConversionKHR; -PFN_vkBindBufferMemory2KHR vkBindBufferMemory2KHR; -PFN_vkBindImageMemory2KHR vkBindImageMemory2KHR; -PFN_vkGetDescriptorSetLayoutSupportKHR vkGetDescriptorSetLayoutSupportKHR; -PFN_vkCmdDrawIndirectCountKHR vkCmdDrawIndirectCountKHR; -PFN_vkCmdDrawIndexedIndirectCountKHR vkCmdDrawIndexedIndirectCountKHR; -PFN_vkCreateDebugReportCallbackEXT vkCreateDebugReportCallbackEXT; -PFN_vkDestroyDebugReportCallbackEXT vkDestroyDebugReportCallbackEXT; -PFN_vkDebugReportMessageEXT vkDebugReportMessageEXT; -PFN_vkDebugMarkerSetObjectTagEXT vkDebugMarkerSetObjectTagEXT; -PFN_vkDebugMarkerSetObjectNameEXT vkDebugMarkerSetObjectNameEXT; -PFN_vkCmdDebugMarkerBeginEXT vkCmdDebugMarkerBeginEXT; -PFN_vkCmdDebugMarkerEndEXT vkCmdDebugMarkerEndEXT; -PFN_vkCmdDebugMarkerInsertEXT vkCmdDebugMarkerInsertEXT; -PFN_vkCmdBindTransformFeedbackBuffersEXT vkCmdBindTransformFeedbackBuffersEXT; -PFN_vkCmdBeginTransformFeedbackEXT vkCmdBeginTransformFeedbackEXT; -PFN_vkCmdEndTransformFeedbackEXT vkCmdEndTransformFeedbackEXT; -PFN_vkCmdBeginQueryIndexedEXT vkCmdBeginQueryIndexedEXT; -PFN_vkCmdEndQueryIndexedEXT vkCmdEndQueryIndexedEXT; -PFN_vkCmdDrawIndirectByteCountEXT vkCmdDrawIndirectByteCountEXT; -PFN_vkCmdDrawIndirectCountAMD vkCmdDrawIndirectCountAMD; -PFN_vkCmdDrawIndexedIndirectCountAMD vkCmdDrawIndexedIndirectCountAMD; -PFN_vkGetShaderInfoAMD vkGetShaderInfoAMD; -PFN_vkGetPhysicalDeviceExternalImageFormatPropertiesNV vkGetPhysicalDeviceExternalImageFormatPropertiesNV; -PFN_vkCmdBeginConditionalRenderingEXT vkCmdBeginConditionalRenderingEXT; -PFN_vkCmdEndConditionalRenderingEXT vkCmdEndConditionalRenderingEXT; -PFN_vkCmdProcessCommandsNVX vkCmdProcessCommandsNVX; -PFN_vkCmdReserveSpaceForCommandsNVX vkCmdReserveSpaceForCommandsNVX; -PFN_vkCreateIndirectCommandsLayoutNVX vkCreateIndirectCommandsLayoutNVX; -PFN_vkDestroyIndirectCommandsLayoutNVX vkDestroyIndirectCommandsLayoutNVX; -PFN_vkCreateObjectTableNVX vkCreateObjectTableNVX; -PFN_vkDestroyObjectTableNVX vkDestroyObjectTableNVX; -PFN_vkRegisterObjectsNVX vkRegisterObjectsNVX; -PFN_vkUnregisterObjectsNVX vkUnregisterObjectsNVX; -PFN_vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX; -PFN_vkCmdSetViewportWScalingNV vkCmdSetViewportWScalingNV; -PFN_vkReleaseDisplayEXT vkReleaseDisplayEXT; -PFN_vkGetPhysicalDeviceSurfaceCapabilities2EXT vkGetPhysicalDeviceSurfaceCapabilities2EXT; -PFN_vkDisplayPowerControlEXT vkDisplayPowerControlEXT; -PFN_vkRegisterDeviceEventEXT vkRegisterDeviceEventEXT; -PFN_vkRegisterDisplayEventEXT vkRegisterDisplayEventEXT; -PFN_vkGetSwapchainCounterEXT vkGetSwapchainCounterEXT; -PFN_vkGetRefreshCycleDurationGOOGLE vkGetRefreshCycleDurationGOOGLE; -PFN_vkGetPastPresentationTimingGOOGLE vkGetPastPresentationTimingGOOGLE; -PFN_vkCmdSetDiscardRectangleEXT vkCmdSetDiscardRectangleEXT; -PFN_vkSetHdrMetadataEXT vkSetHdrMetadataEXT; -PFN_vkSetDebugUtilsObjectNameEXT vkSetDebugUtilsObjectNameEXT; -PFN_vkSetDebugUtilsObjectTagEXT vkSetDebugUtilsObjectTagEXT; -PFN_vkQueueBeginDebugUtilsLabelEXT vkQueueBeginDebugUtilsLabelEXT; -PFN_vkQueueEndDebugUtilsLabelEXT vkQueueEndDebugUtilsLabelEXT; -PFN_vkQueueInsertDebugUtilsLabelEXT vkQueueInsertDebugUtilsLabelEXT; -PFN_vkCmdBeginDebugUtilsLabelEXT vkCmdBeginDebugUtilsLabelEXT; -PFN_vkCmdEndDebugUtilsLabelEXT vkCmdEndDebugUtilsLabelEXT; -PFN_vkCmdInsertDebugUtilsLabelEXT vkCmdInsertDebugUtilsLabelEXT; -PFN_vkCreateDebugUtilsMessengerEXT vkCreateDebugUtilsMessengerEXT; -PFN_vkDestroyDebugUtilsMessengerEXT vkDestroyDebugUtilsMessengerEXT; -PFN_vkSubmitDebugUtilsMessageEXT vkSubmitDebugUtilsMessageEXT; -PFN_vkCmdSetSampleLocationsEXT vkCmdSetSampleLocationsEXT; -PFN_vkGetPhysicalDeviceMultisamplePropertiesEXT vkGetPhysicalDeviceMultisamplePropertiesEXT; -PFN_vkGetImageDrmFormatModifierPropertiesEXT vkGetImageDrmFormatModifierPropertiesEXT; -PFN_vkCreateValidationCacheEXT vkCreateValidationCacheEXT; -PFN_vkDestroyValidationCacheEXT vkDestroyValidationCacheEXT; -PFN_vkMergeValidationCachesEXT vkMergeValidationCachesEXT; -PFN_vkGetValidationCacheDataEXT vkGetValidationCacheDataEXT; -PFN_vkCmdBindShadingRateImageNV vkCmdBindShadingRateImageNV; -PFN_vkCmdSetViewportShadingRatePaletteNV vkCmdSetViewportShadingRatePaletteNV; -PFN_vkCmdSetCoarseSampleOrderNV vkCmdSetCoarseSampleOrderNV; -PFN_vkCreateAccelerationStructureNV vkCreateAccelerationStructureNV; -PFN_vkGetMemoryHostPointerPropertiesEXT vkGetMemoryHostPointerPropertiesEXT; -PFN_vkCmdWriteBufferMarkerAMD vkCmdWriteBufferMarkerAMD; -PFN_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT vkGetPhysicalDeviceCalibrateableTimeDomainsEXT; -PFN_vkGetCalibratedTimestampsEXT vkGetCalibratedTimestampsEXT; -PFN_vkCmdDrawMeshTasksNV vkCmdDrawMeshTasksNV; -PFN_vkCmdDrawMeshTasksIndirectNV vkCmdDrawMeshTasksIndirectNV; -PFN_vkCmdDrawMeshTasksIndirectCountNV vkCmdDrawMeshTasksIndirectCountNV; -PFN_vkCmdSetExclusiveScissorNV vkCmdSetExclusiveScissorNV; -PFN_vkCmdSetCheckpointNV vkCmdSetCheckpointNV; -PFN_vkGetQueueCheckpointDataNV vkGetQueueCheckpointDataNV; - -#ifdef VK_USE_PLATFORM_FUCHSIA -PFN_vkCreateImagePipeSurfaceFUCHSIA vkCreateImagePipeSurfaceFUCHSIA; -#endif - -#ifdef VK_USE_PLATFORM_IOS_MVK -PFN_vkCreateIOSSurfaceMVK vkCreateIOSSurfaceMVK; -#endif - -#ifdef VK_USE_PLATFORM_MACOS_MVK -PFN_vkCreateMacOSSurfaceMVK vkCreateMacOSSurfaceMVK; -#endif - -#ifdef VK_USE_PLATFORM_VI_NN -PFN_vkCreateViSurfaceNN vkCreateViSurfaceNN; -#endif - -#ifdef VK_USE_PLATFORM_WAYLAND_KHR -PFN_vkCreateWaylandSurfaceKHR vkCreateWaylandSurfaceKHR; -PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR vkGetPhysicalDeviceWaylandPresentationSupportKHR; -#endif - -#ifdef VK_USE_PLATFORM_WIN32_KHR -PFN_vkCreateWin32SurfaceKHR vkCreateWin32SurfaceKHR; -PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR vkGetPhysicalDeviceWin32PresentationSupportKHR; -#endif - -#ifdef VK_USE_PLATFORM_WIN32_KHR -PFN_vkGetMemoryWin32HandleKHR vkGetMemoryWin32HandleKHR; -PFN_vkGetMemoryWin32HandlePropertiesKHR vkGetMemoryWin32HandlePropertiesKHR; -#endif - -#ifdef VK_USE_PLATFORM_WIN32_KHR -#endif - -#ifdef VK_USE_PLATFORM_WIN32_KHR -PFN_vkImportSemaphoreWin32HandleKHR vkImportSemaphoreWin32HandleKHR; -PFN_vkGetSemaphoreWin32HandleKHR vkGetSemaphoreWin32HandleKHR; -#endif - -#ifdef VK_USE_PLATFORM_WIN32_KHR -PFN_vkImportFenceWin32HandleKHR vkImportFenceWin32HandleKHR; -PFN_vkGetFenceWin32HandleKHR vkGetFenceWin32HandleKHR; -#endif - -#ifdef VK_USE_PLATFORM_WIN32_KHR -PFN_vkGetMemoryWin32HandleNV vkGetMemoryWin32HandleNV; -#endif - -#ifdef VK_USE_PLATFORM_WIN32_KHR -#endif - -#ifdef VK_USE_PLATFORM_XCB_KHR -PFN_vkCreateXcbSurfaceKHR vkCreateXcbSurfaceKHR; -PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR vkGetPhysicalDeviceXcbPresentationSupportKHR; -#endif - -#ifdef VK_USE_PLATFORM_XLIB_KHR -PFN_vkCreateXlibSurfaceKHR vkCreateXlibSurfaceKHR; -PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR vkGetPhysicalDeviceXlibPresentationSupportKHR; -#endif - -#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT -PFN_vkAcquireXlibDisplayEXT vkAcquireXlibDisplayEXT; -PFN_vkGetRandROutputDisplayEXT vkGetRandROutputDisplayEXT; -#endif - -#ifdef __cplusplus -} -#endif diff --git a/vk_ndk_wrapper_include/kompute_vk_ndk_wrapper.hpp b/vk_ndk_wrapper_include/kompute_vk_ndk_wrapper.hpp deleted file mode 100755 index b387bade3..000000000 --- a/vk_ndk_wrapper_include/kompute_vk_ndk_wrapper.hpp +++ /dev/null @@ -1,414 +0,0 @@ -/* - * Copyright 2018 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// This file is generated. -#ifndef VULKAN_WRAPPER_H -#define VULKAN_WRAPPER_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define VK_NO_PROTOTYPES 1 -#include -#include - -/* Initialize the Vulkan function pointer variables declared in this header. - * Returns 0 if vulkan is not available, non-zero if it is available. - */ -int InitVulkan(void); - -// VK_core_0 -extern PFN_vkCreateInstance vkCreateInstance; -extern PFN_vkDestroyInstance vkDestroyInstance; -extern PFN_vkEnumeratePhysicalDevices vkEnumeratePhysicalDevices; -extern PFN_vkGetPhysicalDeviceFeatures vkGetPhysicalDeviceFeatures; -extern PFN_vkGetPhysicalDeviceFormatProperties vkGetPhysicalDeviceFormatProperties; -extern PFN_vkGetPhysicalDeviceImageFormatProperties vkGetPhysicalDeviceImageFormatProperties; -extern PFN_vkGetPhysicalDeviceProperties vkGetPhysicalDeviceProperties; -extern PFN_vkGetPhysicalDeviceQueueFamilyProperties vkGetPhysicalDeviceQueueFamilyProperties; -extern PFN_vkGetPhysicalDeviceMemoryProperties vkGetPhysicalDeviceMemoryProperties; -extern PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr; -extern PFN_vkGetDeviceProcAddr vkGetDeviceProcAddr; -extern PFN_vkCreateDevice vkCreateDevice; -extern PFN_vkDestroyDevice vkDestroyDevice; -extern PFN_vkEnumerateInstanceExtensionProperties vkEnumerateInstanceExtensionProperties; -extern PFN_vkEnumerateDeviceExtensionProperties vkEnumerateDeviceExtensionProperties; -extern PFN_vkEnumerateInstanceLayerProperties vkEnumerateInstanceLayerProperties; -extern PFN_vkEnumerateDeviceLayerProperties vkEnumerateDeviceLayerProperties; -extern PFN_vkGetDeviceQueue vkGetDeviceQueue; -extern PFN_vkQueueSubmit vkQueueSubmit; -extern PFN_vkQueueWaitIdle vkQueueWaitIdle; -extern PFN_vkDeviceWaitIdle vkDeviceWaitIdle; -extern PFN_vkAllocateMemory vkAllocateMemory; -extern PFN_vkFreeMemory vkFreeMemory; -extern PFN_vkMapMemory vkMapMemory; -extern PFN_vkUnmapMemory vkUnmapMemory; -extern PFN_vkFlushMappedMemoryRanges vkFlushMappedMemoryRanges; -extern PFN_vkInvalidateMappedMemoryRanges vkInvalidateMappedMemoryRanges; -extern PFN_vkGetDeviceMemoryCommitment vkGetDeviceMemoryCommitment; -extern PFN_vkBindBufferMemory vkBindBufferMemory; -extern PFN_vkBindImageMemory vkBindImageMemory; -extern PFN_vkGetBufferMemoryRequirements vkGetBufferMemoryRequirements; -extern PFN_vkGetImageMemoryRequirements vkGetImageMemoryRequirements; -extern PFN_vkGetImageSparseMemoryRequirements vkGetImageSparseMemoryRequirements; -extern PFN_vkGetPhysicalDeviceSparseImageFormatProperties vkGetPhysicalDeviceSparseImageFormatProperties; -extern PFN_vkQueueBindSparse vkQueueBindSparse; -extern PFN_vkCreateFence vkCreateFence; -extern PFN_vkDestroyFence vkDestroyFence; -extern PFN_vkResetFences vkResetFences; -extern PFN_vkGetFenceStatus vkGetFenceStatus; -extern PFN_vkWaitForFences vkWaitForFences; -extern PFN_vkCreateSemaphore vkCreateSemaphore; -extern PFN_vkDestroySemaphore vkDestroySemaphore; -extern PFN_vkCreateEvent vkCreateEvent; -extern PFN_vkDestroyEvent vkDestroyEvent; -extern PFN_vkGetEventStatus vkGetEventStatus; -extern PFN_vkSetEvent vkSetEvent; -extern PFN_vkResetEvent vkResetEvent; -extern PFN_vkCreateQueryPool vkCreateQueryPool; -extern PFN_vkDestroyQueryPool vkDestroyQueryPool; -extern PFN_vkGetQueryPoolResults vkGetQueryPoolResults; -extern PFN_vkCreateBuffer vkCreateBuffer; -extern PFN_vkDestroyBuffer vkDestroyBuffer; -extern PFN_vkCreateBufferView vkCreateBufferView; -extern PFN_vkDestroyBufferView vkDestroyBufferView; -extern PFN_vkCreateImage vkCreateImage; -extern PFN_vkDestroyImage vkDestroyImage; -extern PFN_vkGetImageSubresourceLayout vkGetImageSubresourceLayout; -extern PFN_vkCreateImageView vkCreateImageView; -extern PFN_vkDestroyImageView vkDestroyImageView; -extern PFN_vkCreateShaderModule vkCreateShaderModule; -extern PFN_vkDestroyShaderModule vkDestroyShaderModule; -extern PFN_vkCreatePipelineCache vkCreatePipelineCache; -extern PFN_vkDestroyPipelineCache vkDestroyPipelineCache; -extern PFN_vkGetPipelineCacheData vkGetPipelineCacheData; -extern PFN_vkMergePipelineCaches vkMergePipelineCaches; -extern PFN_vkCreateGraphicsPipelines vkCreateGraphicsPipelines; -extern PFN_vkCreateComputePipelines vkCreateComputePipelines; -extern PFN_vkDestroyPipeline vkDestroyPipeline; -extern PFN_vkCreatePipelineLayout vkCreatePipelineLayout; -extern PFN_vkDestroyPipelineLayout vkDestroyPipelineLayout; -extern PFN_vkCreateSampler vkCreateSampler; -extern PFN_vkDestroySampler vkDestroySampler; -extern PFN_vkCreateDescriptorSetLayout vkCreateDescriptorSetLayout; -extern PFN_vkDestroyDescriptorSetLayout vkDestroyDescriptorSetLayout; -extern PFN_vkCreateDescriptorPool vkCreateDescriptorPool; -extern PFN_vkDestroyDescriptorPool vkDestroyDescriptorPool; -extern PFN_vkResetDescriptorPool vkResetDescriptorPool; -extern PFN_vkAllocateDescriptorSets vkAllocateDescriptorSets; -extern PFN_vkFreeDescriptorSets vkFreeDescriptorSets; -extern PFN_vkUpdateDescriptorSets vkUpdateDescriptorSets; -extern PFN_vkCreateFramebuffer vkCreateFramebuffer; -extern PFN_vkDestroyFramebuffer vkDestroyFramebuffer; -extern PFN_vkCreateRenderPass vkCreateRenderPass; -extern PFN_vkDestroyRenderPass vkDestroyRenderPass; -extern PFN_vkGetRenderAreaGranularity vkGetRenderAreaGranularity; -extern PFN_vkCreateCommandPool vkCreateCommandPool; -extern PFN_vkDestroyCommandPool vkDestroyCommandPool; -extern PFN_vkResetCommandPool vkResetCommandPool; -extern PFN_vkAllocateCommandBuffers vkAllocateCommandBuffers; -extern PFN_vkFreeCommandBuffers vkFreeCommandBuffers; -extern PFN_vkBeginCommandBuffer vkBeginCommandBuffer; -extern PFN_vkEndCommandBuffer vkEndCommandBuffer; -extern PFN_vkResetCommandBuffer vkResetCommandBuffer; -extern PFN_vkCmdBindPipeline vkCmdBindPipeline; -extern PFN_vkCmdSetViewport vkCmdSetViewport; -extern PFN_vkCmdSetScissor vkCmdSetScissor; -extern PFN_vkCmdSetLineWidth vkCmdSetLineWidth; -extern PFN_vkCmdSetDepthBias vkCmdSetDepthBias; -extern PFN_vkCmdSetBlendConstants vkCmdSetBlendConstants; -extern PFN_vkCmdSetDepthBounds vkCmdSetDepthBounds; -extern PFN_vkCmdSetStencilCompareMask vkCmdSetStencilCompareMask; -extern PFN_vkCmdSetStencilWriteMask vkCmdSetStencilWriteMask; -extern PFN_vkCmdSetStencilReference vkCmdSetStencilReference; -extern PFN_vkCmdBindDescriptorSets vkCmdBindDescriptorSets; -extern PFN_vkCmdBindIndexBuffer vkCmdBindIndexBuffer; -extern PFN_vkCmdBindVertexBuffers vkCmdBindVertexBuffers; -extern PFN_vkCmdDraw vkCmdDraw; -extern PFN_vkCmdDrawIndexed vkCmdDrawIndexed; -extern PFN_vkCmdDrawIndirect vkCmdDrawIndirect; -extern PFN_vkCmdDrawIndexedIndirect vkCmdDrawIndexedIndirect; -extern PFN_vkCmdDispatch vkCmdDispatch; -extern PFN_vkCmdDispatchIndirect vkCmdDispatchIndirect; -extern PFN_vkCmdCopyBuffer vkCmdCopyBuffer; -extern PFN_vkCmdCopyImage vkCmdCopyImage; -extern PFN_vkCmdBlitImage vkCmdBlitImage; -extern PFN_vkCmdCopyBufferToImage vkCmdCopyBufferToImage; -extern PFN_vkCmdCopyImageToBuffer vkCmdCopyImageToBuffer; -extern PFN_vkCmdUpdateBuffer vkCmdUpdateBuffer; -extern PFN_vkCmdFillBuffer vkCmdFillBuffer; -extern PFN_vkCmdClearColorImage vkCmdClearColorImage; -extern PFN_vkCmdClearDepthStencilImage vkCmdClearDepthStencilImage; -extern PFN_vkCmdClearAttachments vkCmdClearAttachments; -extern PFN_vkCmdResolveImage vkCmdResolveImage; -extern PFN_vkCmdSetEvent vkCmdSetEvent; -extern PFN_vkCmdResetEvent vkCmdResetEvent; -extern PFN_vkCmdWaitEvents vkCmdWaitEvents; -extern PFN_vkCmdPipelineBarrier vkCmdPipelineBarrier; -extern PFN_vkCmdBeginQuery vkCmdBeginQuery; -extern PFN_vkCmdEndQuery vkCmdEndQuery; -extern PFN_vkCmdResetQueryPool vkCmdResetQueryPool; -extern PFN_vkCmdWriteTimestamp vkCmdWriteTimestamp; -extern PFN_vkCmdCopyQueryPoolResults vkCmdCopyQueryPoolResults; -extern PFN_vkCmdPushConstants vkCmdPushConstants; -extern PFN_vkCmdBeginRenderPass vkCmdBeginRenderPass; -extern PFN_vkCmdNextSubpass vkCmdNextSubpass; -extern PFN_vkCmdEndRenderPass vkCmdEndRenderPass; -extern PFN_vkCmdExecuteCommands vkCmdExecuteCommands; - -// VK_core_1 -extern PFN_vkEnumerateInstanceVersion vkEnumerateInstanceVersion; -extern PFN_vkBindBufferMemory2 vkBindBufferMemory2; -extern PFN_vkBindImageMemory2 vkBindImageMemory2; -extern PFN_vkGetDeviceGroupPeerMemoryFeatures vkGetDeviceGroupPeerMemoryFeatures; -extern PFN_vkCmdSetDeviceMask vkCmdSetDeviceMask; -extern PFN_vkCmdDispatchBase vkCmdDispatchBase; -extern PFN_vkEnumeratePhysicalDeviceGroups vkEnumeratePhysicalDeviceGroups; -extern PFN_vkGetImageMemoryRequirements2 vkGetImageMemoryRequirements2; -extern PFN_vkGetBufferMemoryRequirements2 vkGetBufferMemoryRequirements2; -extern PFN_vkGetImageSparseMemoryRequirements2 vkGetImageSparseMemoryRequirements2; -extern PFN_vkGetPhysicalDeviceFeatures2 vkGetPhysicalDeviceFeatures2; -extern PFN_vkGetPhysicalDeviceProperties2 vkGetPhysicalDeviceProperties2; -extern PFN_vkGetPhysicalDeviceFormatProperties2 vkGetPhysicalDeviceFormatProperties2; -extern PFN_vkGetPhysicalDeviceImageFormatProperties2 vkGetPhysicalDeviceImageFormatProperties2; -extern PFN_vkGetPhysicalDeviceQueueFamilyProperties2 vkGetPhysicalDeviceQueueFamilyProperties2; -extern PFN_vkGetPhysicalDeviceMemoryProperties2 vkGetPhysicalDeviceMemoryProperties2; -extern PFN_vkGetPhysicalDeviceSparseImageFormatProperties2 vkGetPhysicalDeviceSparseImageFormatProperties2; -extern PFN_vkTrimCommandPool vkTrimCommandPool; -extern PFN_vkGetDeviceQueue2 vkGetDeviceQueue2; -extern PFN_vkCreateSamplerYcbcrConversion vkCreateSamplerYcbcrConversion; -extern PFN_vkDestroySamplerYcbcrConversion vkDestroySamplerYcbcrConversion; -extern PFN_vkCreateDescriptorUpdateTemplate vkCreateDescriptorUpdateTemplate; -extern PFN_vkDestroyDescriptorUpdateTemplate vkDestroyDescriptorUpdateTemplate; -extern PFN_vkUpdateDescriptorSetWithTemplate vkUpdateDescriptorSetWithTemplate; -extern PFN_vkGetPhysicalDeviceExternalBufferProperties vkGetPhysicalDeviceExternalBufferProperties; -extern PFN_vkGetPhysicalDeviceExternalFenceProperties vkGetPhysicalDeviceExternalFenceProperties; -extern PFN_vkGetPhysicalDeviceExternalSemaphoreProperties vkGetPhysicalDeviceExternalSemaphoreProperties; -extern PFN_vkGetDescriptorSetLayoutSupport vkGetDescriptorSetLayoutSupport; - -// VK_KHR_surface -extern PFN_vkDestroySurfaceKHR vkDestroySurfaceKHR; -extern PFN_vkGetPhysicalDeviceSurfaceSupportKHR vkGetPhysicalDeviceSurfaceSupportKHR; -extern PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR vkGetPhysicalDeviceSurfaceCapabilitiesKHR; -extern PFN_vkGetPhysicalDeviceSurfaceFormatsKHR vkGetPhysicalDeviceSurfaceFormatsKHR; -extern PFN_vkGetPhysicalDeviceSurfacePresentModesKHR vkGetPhysicalDeviceSurfacePresentModesKHR; - -// VK_KHR_swapchain -extern PFN_vkCreateSwapchainKHR vkCreateSwapchainKHR; -extern PFN_vkDestroySwapchainKHR vkDestroySwapchainKHR; -extern PFN_vkGetSwapchainImagesKHR vkGetSwapchainImagesKHR; -extern PFN_vkAcquireNextImageKHR vkAcquireNextImageKHR; -extern PFN_vkQueuePresentKHR vkQueuePresentKHR; -extern PFN_vkGetDeviceGroupPresentCapabilitiesKHR vkGetDeviceGroupPresentCapabilitiesKHR; -extern PFN_vkGetDeviceGroupSurfacePresentModesKHR vkGetDeviceGroupSurfacePresentModesKHR; -extern PFN_vkGetPhysicalDevicePresentRectanglesKHR vkGetPhysicalDevicePresentRectanglesKHR; -extern PFN_vkAcquireNextImage2KHR vkAcquireNextImage2KHR; - -// VK_KHR_display -extern PFN_vkGetPhysicalDeviceDisplayPropertiesKHR vkGetPhysicalDeviceDisplayPropertiesKHR; -extern PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR vkGetPhysicalDeviceDisplayPlanePropertiesKHR; -extern PFN_vkGetDisplayPlaneSupportedDisplaysKHR vkGetDisplayPlaneSupportedDisplaysKHR; -extern PFN_vkGetDisplayModePropertiesKHR vkGetDisplayModePropertiesKHR; -extern PFN_vkCreateDisplayModeKHR vkCreateDisplayModeKHR; -extern PFN_vkGetDisplayPlaneCapabilitiesKHR vkGetDisplayPlaneCapabilitiesKHR; -extern PFN_vkCreateDisplayPlaneSurfaceKHR vkCreateDisplayPlaneSurfaceKHR; - -// VK_KHR_display_swapchain -extern PFN_vkCreateSharedSwapchainsKHR vkCreateSharedSwapchainsKHR; - -// VK_KHR_sampler_mirror_clamp_to_edge - -// VK_KHR_multiview - -// VK_KHR_get_physical_device_properties2 -extern PFN_vkGetPhysicalDeviceFeatures2KHR vkGetPhysicalDeviceFeatures2KHR; -extern PFN_vkGetPhysicalDeviceProperties2KHR vkGetPhysicalDeviceProperties2KHR; -extern PFN_vkGetPhysicalDeviceFormatProperties2KHR vkGetPhysicalDeviceFormatProperties2KHR; -extern PFN_vkGetPhysicalDeviceImageFormatProperties2KHR vkGetPhysicalDeviceImageFormatProperties2KHR; -extern PFN_vkGetPhysicalDeviceQueueFamilyProperties2KHR vkGetPhysicalDeviceQueueFamilyProperties2KHR; -extern PFN_vkGetPhysicalDeviceMemoryProperties2KHR vkGetPhysicalDeviceMemoryProperties2KHR; -extern PFN_vkGetPhysicalDeviceSparseImageFormatProperties2KHR vkGetPhysicalDeviceSparseImageFormatProperties2KHR; - -// VK_KHR_device_group -extern PFN_vkGetDeviceGroupPeerMemoryFeaturesKHR vkGetDeviceGroupPeerMemoryFeaturesKHR; -extern PFN_vkCmdSetDeviceMaskKHR vkCmdSetDeviceMaskKHR; -extern PFN_vkCmdDispatchBaseKHR vkCmdDispatchBaseKHR; - -// VK_KHR_shader_draw_parameters - -// VK_KHR_maintenance1 -extern PFN_vkTrimCommandPoolKHR vkTrimCommandPoolKHR; - -// VK_KHR_device_group_creation -extern PFN_vkEnumeratePhysicalDeviceGroupsKHR vkEnumeratePhysicalDeviceGroupsKHR; - -// VK_KHR_external_memory_capabilities -extern PFN_vkGetPhysicalDeviceExternalBufferPropertiesKHR vkGetPhysicalDeviceExternalBufferPropertiesKHR; - -// VK_KHR_external_memory - -// VK_KHR_external_memory_fd -extern PFN_vkGetMemoryFdKHR vkGetMemoryFdKHR; -extern PFN_vkGetMemoryFdPropertiesKHR vkGetMemoryFdPropertiesKHR; - -// VK_KHR_external_semaphore_capabilities -extern PFN_vkGetPhysicalDeviceExternalSemaphorePropertiesKHR vkGetPhysicalDeviceExternalSemaphorePropertiesKHR; - -// VK_KHR_external_semaphore - -// VK_KHR_external_semaphore_fd -extern PFN_vkImportSemaphoreFdKHR vkImportSemaphoreFdKHR; -extern PFN_vkGetSemaphoreFdKHR vkGetSemaphoreFdKHR; - -// VK_KHR_push_descriptor -extern PFN_vkCmdPushDescriptorSetKHR vkCmdPushDescriptorSetKHR; -extern PFN_vkCmdPushDescriptorSetWithTemplateKHR vkCmdPushDescriptorSetWithTemplateKHR; - -// VK_KHR_16bit_storage - -// VK_KHR_incremental_present - -// VK_KHR_descriptor_update_template -extern PFN_vkCreateDescriptorUpdateTemplateKHR vkCreateDescriptorUpdateTemplateKHR; -extern PFN_vkDestroyDescriptorUpdateTemplateKHR vkDestroyDescriptorUpdateTemplateKHR; -extern PFN_vkUpdateDescriptorSetWithTemplateKHR vkUpdateDescriptorSetWithTemplateKHR; - -// VK_KHR_create_renderpass2 -extern PFN_vkCreateRenderPass2KHR vkCreateRenderPass2KHR; -extern PFN_vkCmdBeginRenderPass2KHR vkCmdBeginRenderPass2KHR; -extern PFN_vkCmdNextSubpass2KHR vkCmdNextSubpass2KHR; -extern PFN_vkCmdEndRenderPass2KHR vkCmdEndRenderPass2KHR; - -// VK_KHR_shared_presentable_image -extern PFN_vkGetSwapchainStatusKHR vkGetSwapchainStatusKHR; - -// VK_KHR_external_fence_capabilities -extern PFN_vkGetPhysicalDeviceExternalFencePropertiesKHR vkGetPhysicalDeviceExternalFencePropertiesKHR; - -// VK_KHR_external_fence - -// VK_KHR_external_fence_fd -extern PFN_vkImportFenceFdKHR vkImportFenceFdKHR; -extern PFN_vkGetFenceFdKHR vkGetFenceFdKHR; - -// VK_KHR_maintenance2 - -// VK_KHR_get_surface_capabilities2 -extern PFN_vkGetPhysicalDeviceSurfaceCapabilities2KHR vkGetPhysicalDeviceSurfaceCapabilities2KHR; -extern PFN_vkGetPhysicalDeviceSurfaceFormats2KHR vkGetPhysicalDeviceSurfaceFormats2KHR; - -// VK_KHR_variable_pointers - -// VK_KHR_get_display_properties2 -extern PFN_vkGetPhysicalDeviceDisplayProperties2KHR vkGetPhysicalDeviceDisplayProperties2KHR; -extern PFN_vkGetPhysicalDeviceDisplayPlaneProperties2KHR vkGetPhysicalDeviceDisplayPlaneProperties2KHR; -extern PFN_vkGetDisplayModeProperties2KHR vkGetDisplayModeProperties2KHR; -extern PFN_vkGetDisplayPlaneCapabilities2KHR vkGetDisplayPlaneCapabilities2KHR; - -// VK_KHR_dedicated_allocation - -// VK_KHR_storage_buffer_storage_class - -// VK_KHR_relaxed_block_layout - -// VK_KHR_get_memory_requirements2 -extern PFN_vkGetImageMemoryRequirements2KHR vkGetImageMemoryRequirements2KHR; -extern PFN_vkGetBufferMemoryRequirements2KHR vkGetBufferMemoryRequirements2KHR; -extern PFN_vkGetImageSparseMemoryRequirements2KHR vkGetImageSparseMemoryRequirements2KHR; - -// VK_KHR_image_format_list - -// VK_KHR_sampler_ycbcr_conversion -extern PFN_vkCreateSamplerYcbcrConversionKHR vkCreateSamplerYcbcrConversionKHR; -extern PFN_vkDestroySamplerYcbcrConversionKHR vkDestroySamplerYcbcrConversionKHR; - -// VK_KHR_bind_memory2 -extern PFN_vkBindBufferMemory2KHR vkBindBufferMemory2KHR; -extern PFN_vkBindImageMemory2KHR vkBindImageMemory2KHR; - -// VK_KHR_maintenance3 -extern PFN_vkGetDescriptorSetLayoutSupportKHR vkGetDescriptorSetLayoutSupportKHR; - -// VK_KHR_draw_indirect_count -extern PFN_vkCmdDrawIndirectCountKHR vkCmdDrawIndirectCountKHR; -extern PFN_vkCmdDrawIndexedIndirectCountKHR vkCmdDrawIndexedIndirectCountKHR; - -// VK_KHR_8bit_storage - -// VK_KHR_shader_atomic_int64 - -// VK_KHR_driver_properties - -// VK_KHR_vulkan_memory_model - -#ifdef VK_USE_PLATFORM_ANDROID_KHR -// VK_KHR_android_surface -extern PFN_vkCreateAndroidSurfaceKHR vkCreateAndroidSurfaceKHR; -#endif - -#ifdef VK_USE_PLATFORM_WAYLAND_KHR -// VK_KHR_wayland_surface -extern PFN_vkCreateWaylandSurfaceKHR vkCreateWaylandSurfaceKHR; -extern PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR vkGetPhysicalDeviceWaylandPresentationSupportKHR; -#endif - -#ifdef VK_USE_PLATFORM_WIN32_KHR -// VK_KHR_win32_surface -extern PFN_vkCreateWin32SurfaceKHR vkCreateWin32SurfaceKHR; -extern PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR vkGetPhysicalDeviceWin32PresentationSupportKHR; -#endif - -#ifdef VK_USE_PLATFORM_WIN32_KHR -// VK_KHR_external_memory_win32 -extern PFN_vkGetMemoryWin32HandleKHR vkGetMemoryWin32HandleKHR; -extern PFN_vkGetMemoryWin32HandlePropertiesKHR vkGetMemoryWin32HandlePropertiesKHR; -#endif - -#ifdef VK_USE_PLATFORM_WIN32_KHR -// VK_KHR_win32_keyed_mutex -#endif - -#ifdef VK_USE_PLATFORM_WIN32_KHR -// VK_KHR_external_semaphore_win32 -extern PFN_vkImportSemaphoreWin32HandleKHR vkImportSemaphoreWin32HandleKHR; -extern PFN_vkGetSemaphoreWin32HandleKHR vkGetSemaphoreWin32HandleKHR; -#endif - -#ifdef VK_USE_PLATFORM_WIN32_KHR -// VK_KHR_external_fence_win32 -extern PFN_vkImportFenceWin32HandleKHR vkImportFenceWin32HandleKHR; -extern PFN_vkGetFenceWin32HandleKHR vkGetFenceWin32HandleKHR; -#endif - -#ifdef VK_USE_PLATFORM_XCB_KHR -// VK_KHR_xcb_surface -extern PFN_vkCreateXcbSurfaceKHR vkCreateXcbSurfaceKHR; -extern PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR vkGetPhysicalDeviceXcbPresentationSupportKHR; -#endif - -#ifdef VK_USE_PLATFORM_XLIB_KHR -// VK_KHR_xlib_surface -extern PFN_vkCreateXlibSurfaceKHR vkCreateXlibSurfaceKHR; -extern PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR vkGetPhysicalDeviceXlibPresentationSupportKHR; -#endif - -#ifdef __cplusplus -} -#endif - - -#endif // VULKAN_WRAPPER_H - diff --git a/vk_ndk_wrapper_include/kompute_vk_ndk_wrapper_patch.hpp b/vk_ndk_wrapper_include/kompute_vk_ndk_wrapper_patch.hpp deleted file mode 100644 index f25f44c2b..000000000 --- a/vk_ndk_wrapper_include/kompute_vk_ndk_wrapper_patch.hpp +++ /dev/null @@ -1,185 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -#pragma once - -/* - * Vulkan API definitions to assist with issues in the `vulkan_wrapper.h/vulkan_wrapper.cpp` - * which ships with the Android NDK 20 when using the `vulkan.hpp` header. - */ - -#define VK_NO_PROTOTYPES 1 -#include - -// Adding references previously in vulkan_wrapper.cpp into here instead for vulkan.hpp -extern PFN_vkCmdBuildAccelerationStructureNV vkCmdBuildAccelerationStructureNV; -extern PFN_vkCmdCopyAccelerationStructureNV vkCmdCopyAccelerationStructureNV; -extern PFN_vkCmdTraceRaysNV vkCmdTraceRaysNV; -extern PFN_vkCmdWriteAccelerationStructuresPropertiesNV vkCmdWriteAccelerationStructuresPropertiesNV; -extern PFN_vkBindAccelerationStructureMemoryNV vkBindAccelerationStructureMemoryNV; -extern PFN_vkCompileDeferredNV vkCompileDeferredNV; -extern PFN_vkCreateRayTracingPipelinesNV vkCreateRayTracingPipelinesNV; -extern PFN_vkDestroyAccelerationStructureNV vkDestroyAccelerationStructureNV; -extern PFN_vkGetAccelerationStructureHandleNV vkGetAccelerationStructureHandleNV; -extern PFN_vkGetAccelerationStructureMemoryRequirementsNV vkGetAccelerationStructureMemoryRequirementsNV; -extern PFN_vkGetRayTracingShaderGroupHandlesNV vkGetRayTracingShaderGroupHandlesNV; - -#ifdef VK_USE_PLATFORM_ANDROID_KHR -extern PFN_vkCreateAndroidSurfaceKHR vkCreateAndroidSurfaceKHR; -#endif - -#ifdef VK_USE_PLATFORM_ANDROID_KHR -extern PFN_vkGetAndroidHardwareBufferPropertiesANDROID vkGetAndroidHardwareBufferPropertiesANDROID; -extern PFN_vkGetMemoryAndroidHardwareBufferANDROID vkGetMemoryAndroidHardwareBufferANDROID; -#endif - -extern PFN_vkCmdSetLineStippleEXT vkCmdSetLineStippleEXT; -extern PFN_vkCmdSetPerformanceMarkerINTEL vkCmdSetPerformanceMarkerINTEL; -extern PFN_vkCmdSetPerformanceOverrideINTEL vkCmdSetPerformanceOverrideINTEL; -extern PFN_vkCmdSetPerformanceStreamMarkerINTEL vkCmdSetPerformanceStreamMarkerINTEL; -extern PFN_vkAcquirePerformanceConfigurationINTEL vkAcquirePerformanceConfigurationINTEL; -extern PFN_vkGetBufferDeviceAddressEXT vkGetBufferDeviceAddressEXT; -extern PFN_vkGetImageViewHandleNVX vkGetImageViewHandleNVX; -extern PFN_vkGetPerformanceParameterINTEL vkGetPerformanceParameterINTEL; -extern PFN_vkGetPipelineExecutableInternalRepresentationsKHR vkGetPipelineExecutableInternalRepresentationsKHR; -extern PFN_vkGetPipelineExecutablePropertiesKHR vkGetPipelineExecutablePropertiesKHR; -extern PFN_vkGetPipelineExecutableStatisticsKHR vkGetPipelineExecutableStatisticsKHR; -extern PFN_vkInitializePerformanceApiINTEL vkInitializePerformanceApiINTEL; -extern PFN_vkReleasePerformanceConfigurationINTEL vkReleasePerformanceConfigurationINTEL; -extern PFN_vkResetQueryPoolEXT vkResetQueryPoolEXT; -extern PFN_vkSetLocalDimmingAMD vkSetLocalDimmingAMD; -extern PFN_vkUninitializePerformanceApiINTEL vkUninitializePerformanceApiINTEL; -extern PFN_vkCreateHeadlessSurfaceEXT vkCreateHeadlessSurfaceEXT; -extern PFN_vkGetPhysicalDeviceCooperativeMatrixPropertiesNV vkGetPhysicalDeviceCooperativeMatrixPropertiesNV; -extern PFN_vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV; -extern PFN_vkQueueSetPerformanceConfigurationINTEL vkQueueSetPerformanceConfigurationINTEL; - -typedef void *PFN_vkBindAccelerationStructureMemoryNVX; -typedef void *PFN_vkCmdBuildAccelerationStructureNVX; -typedef void *PFN_vkCmdCopyAccelerationStructureNVX; -typedef void *PFN_vkBindAccelerationStructureMemoryNVX; -typedef void *PFN_vkCmdBuildAccelerationStructureNVX; -typedef void *PFN_vkCmdCopyAccelerationStructureNVX; -typedef void *PFN_vkBindAccelerationStructureMemoryNVX; -typedef void *PFN_vkCmdTraceRaysNVX; -typedef void *PFN_vkCmdWriteAccelerationStructurePropertiesNVX; -typedef void *PFN_vkCompileDeferredNVX; -typedef void *PFN_vkCreateAccelerationStructureNVX; -typedef void *PFN_vkCreateRaytracingPipelinesNVX; -typedef void *PFN_vkDestroyAccelerationStructureNVX; -typedef void *PFN_vkGetAccelerationStructureHandleNVX; -typedef void *PFN_vkGetAccelerationStructureMemoryRequirementsNVX; -typedef void *PFN_vkGetAccelerationStructureScratchMemoryRequirementsNVX; -typedef void *PFN_vkGetRaytracingShaderHandlesNVX; -typedef void *PFN_vkBindAccelerationStructureMemoryNVX; -typedef void *PFN_vkCmdBuildAccelerationStructureNVX; -typedef void *PFN_vkCmdCopyAccelerationStructureNVX; - - -extern PFN_vkBindAccelerationStructureMemoryNVX vkBindAccelerationStructureMemoryNVX; -extern PFN_vkCmdBeginConditionalRenderingEXT vkCmdBeginConditionalRenderingEXT; -extern PFN_vkCmdBeginDebugUtilsLabelEXT vkCmdBeginDebugUtilsLabelEXT; -extern PFN_vkCmdBeginQueryIndexedEXT vkCmdBeginQueryIndexedEXT; -extern PFN_vkCmdBeginTransformFeedbackEXT vkCmdBeginTransformFeedbackEXT; -extern PFN_vkCmdBindShadingRateImageNV vkCmdBindShadingRateImageNV; -extern PFN_vkCmdBindTransformFeedbackBuffersEXT vkCmdBindTransformFeedbackBuffersEXT; -extern PFN_vkCmdBuildAccelerationStructureNVX vkCmdBuildAccelerationStructureNVX; -extern PFN_vkCmdCopyAccelerationStructureNVX vkCmdCopyAccelerationStructureNVX; -extern PFN_vkCmdDebugMarkerBeginEXT vkCmdDebugMarkerBeginEXT; -extern PFN_vkCmdDebugMarkerEndEXT vkCmdDebugMarkerEndEXT; -extern PFN_vkCmdDebugMarkerInsertEXT vkCmdDebugMarkerInsertEXT; -extern PFN_vkCmdDrawIndexedIndirectCountAMD vkCmdDrawIndexedIndirectCountAMD; -extern PFN_vkCmdDrawIndirectByteCountEXT vkCmdDrawIndirectByteCountEXT; -extern PFN_vkCmdDrawIndirectCountAMD vkCmdDrawIndirectCountAMD; -extern PFN_vkCmdDrawMeshTasksIndirectCountNV vkCmdDrawMeshTasksIndirectCountNV; -extern PFN_vkCmdDrawMeshTasksIndirectNV vkCmdDrawMeshTasksIndirectNV; -extern PFN_vkCmdDrawMeshTasksNV vkCmdDrawMeshTasksNV; -extern PFN_vkCmdEndConditionalRenderingEXT vkCmdEndConditionalRenderingEXT; -extern PFN_vkBindAccelerationStructureMemoryNVX vkBindAccelerationStructureMemoryNVX; -extern PFN_vkCmdBeginConditionalRenderingEXT vkCmdBeginConditionalRenderingEXT; -extern PFN_vkCmdBeginDebugUtilsLabelEXT vkCmdBeginDebugUtilsLabelEXT; -extern PFN_vkCmdBeginQueryIndexedEXT vkCmdBeginQueryIndexedEXT; -extern PFN_vkCmdBeginTransformFeedbackEXT vkCmdBeginTransformFeedbackEXT; -extern PFN_vkCmdBindShadingRateImageNV vkCmdBindShadingRateImageNV; -extern PFN_vkCmdBindTransformFeedbackBuffersEXT vkCmdBindTransformFeedbackBuffersEXT; -extern PFN_vkCmdBuildAccelerationStructureNVX vkCmdBuildAccelerationStructureNVX; -extern PFN_vkCmdCopyAccelerationStructureNVX vkCmdCopyAccelerationStructureNVX; -extern PFN_vkCmdDebugMarkerBeginEXT vkCmdDebugMarkerBeginEXT; -extern PFN_vkCmdDebugMarkerEndEXT vkCmdDebugMarkerEndEXT; -extern PFN_vkCmdDebugMarkerInsertEXT vkCmdDebugMarkerInsertEXT; -extern PFN_vkCmdDrawIndexedIndirectCountAMD vkCmdDrawIndexedIndirectCountAMD; -extern PFN_vkCmdDrawIndirectByteCountEXT vkCmdDrawIndirectByteCountEXT; -extern PFN_vkCmdDrawIndirectCountAMD vkCmdDrawIndirectCountAMD; -extern PFN_vkCmdDrawMeshTasksIndirectCountNV vkCmdDrawMeshTasksIndirectCountNV; -extern PFN_vkCmdDrawMeshTasksIndirectNV vkCmdDrawMeshTasksIndirectNV; -extern PFN_vkCmdDrawMeshTasksNV vkCmdDrawMeshTasksNV; -extern PFN_vkCmdEndConditionalRenderingEXT vkCmdEndConditionalRenderingEXT; -extern PFN_vkBindAccelerationStructureMemoryNVX vkBindAccelerationStructureMemoryNVX; -extern PFN_vkCmdBeginConditionalRenderingEXT vkCmdBeginConditionalRenderingEXT; -extern PFN_vkCmdBeginDebugUtilsLabelEXT vkCmdBeginDebugUtilsLabelEXT; -extern PFN_vkCmdBeginQueryIndexedEXT vkCmdBeginQueryIndexedEXT; -extern PFN_vkCmdEndDebugUtilsLabelEXT vkCmdEndDebugUtilsLabelEXT; -extern PFN_vkCmdEndQueryIndexedEXT vkCmdEndQueryIndexedEXT; -extern PFN_vkCmdEndTransformFeedbackEXT vkCmdEndTransformFeedbackEXT; -extern PFN_vkCmdInsertDebugUtilsLabelEXT vkCmdInsertDebugUtilsLabelEXT; -extern PFN_vkCmdProcessCommandsNVX vkCmdProcessCommandsNVX; -extern PFN_vkCmdReserveSpaceForCommandsNVX vkCmdReserveSpaceForCommandsNVX; -extern PFN_vkCmdSetCheckpointNV vkCmdSetCheckpointNV; -extern PFN_vkCmdSetCoarseSampleOrderNV vkCmdSetCoarseSampleOrderNV; -extern PFN_vkCmdSetDiscardRectangleEXT vkCmdSetDiscardRectangleEXT; -extern PFN_vkCmdSetExclusiveScissorNV vkCmdSetExclusiveScissorNV; -extern PFN_vkCmdSetSampleLocationsEXT vkCmdSetSampleLocationsEXT; -extern PFN_vkCmdSetViewportShadingRatePaletteNV vkCmdSetViewportShadingRatePaletteNV; -extern PFN_vkCmdSetViewportWScalingNV vkCmdSetViewportWScalingNV; -extern PFN_vkCmdTraceRaysNVX vkCmdTraceRaysNVX; -extern PFN_vkCmdWriteAccelerationStructurePropertiesNVX vkCmdWriteAccelerationStructurePropertiesNVX; -extern PFN_vkCmdWriteBufferMarkerAMD vkCmdWriteBufferMarkerAMD; -extern PFN_vkCompileDeferredNVX vkCompileDeferredNVX; -extern PFN_vkCreateAccelerationStructureNVX vkCreateAccelerationStructureNVX; -extern PFN_vkCreateDebugReportCallbackEXT vkCreateDebugReportCallbackEXT; -extern PFN_vkCreateDebugUtilsMessengerEXT vkCreateDebugUtilsMessengerEXT; -extern PFN_vkCreateIndirectCommandsLayoutNVX vkCreateIndirectCommandsLayoutNVX; -extern PFN_vkCreateObjectTableNVX vkCreateObjectTableNVX; -extern PFN_vkCreateRaytracingPipelinesNVX vkCreateRaytracingPipelinesNVX; -extern PFN_vkCreateValidationCacheEXT vkCreateValidationCacheEXT; -extern PFN_vkDebugMarkerSetObjectNameEXT vkDebugMarkerSetObjectNameEXT; -extern PFN_vkDebugMarkerSetObjectTagEXT vkDebugMarkerSetObjectTagEXT; -extern PFN_vkDebugReportMessageEXT vkDebugReportMessageEXT; -extern PFN_vkDestroyAccelerationStructureNVX vkDestroyAccelerationStructureNVX; -extern PFN_vkDestroyDebugReportCallbackEXT vkDestroyDebugReportCallbackEXT; -extern PFN_vkDestroyDebugUtilsMessengerEXT vkDestroyDebugUtilsMessengerEXT; -extern PFN_vkDestroyIndirectCommandsLayoutNVX vkDestroyIndirectCommandsLayoutNVX; -extern PFN_vkDestroyObjectTableNVX vkDestroyObjectTableNVX; -extern PFN_vkDestroyValidationCacheEXT vkDestroyValidationCacheEXT; -extern PFN_vkDisplayPowerControlEXT vkDisplayPowerControlEXT; -extern PFN_vkGetAccelerationStructureHandleNVX vkGetAccelerationStructureHandleNVX; -extern PFN_vkGetAccelerationStructureMemoryRequirementsNVX vkGetAccelerationStructureMemoryRequirementsNVX; -extern PFN_vkGetAccelerationStructureScratchMemoryRequirementsNVX vkGetAccelerationStructureScratchMemoryRequirementsNVX; -extern PFN_vkGetCalibratedTimestampsEXT vkGetCalibratedTimestampsEXT; -extern PFN_vkGetImageDrmFormatModifierPropertiesEXT vkGetImageDrmFormatModifierPropertiesEXT; -extern PFN_vkGetMemoryHostPointerPropertiesEXT vkGetMemoryHostPointerPropertiesEXT; -extern PFN_vkGetPastPresentationTimingGOOGLE vkGetPastPresentationTimingGOOGLE; -extern PFN_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT vkGetPhysicalDeviceCalibrateableTimeDomainsEXT; -extern PFN_vkGetPhysicalDeviceExternalImageFormatPropertiesNV vkGetPhysicalDeviceExternalImageFormatPropertiesNV; -extern PFN_vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX; -extern PFN_vkGetPhysicalDeviceMultisamplePropertiesEXT vkGetPhysicalDeviceMultisamplePropertiesEXT; -extern PFN_vkGetPhysicalDeviceSurfaceCapabilities2EXT vkGetPhysicalDeviceSurfaceCapabilities2EXT; -extern PFN_vkGetQueueCheckpointDataNV vkGetQueueCheckpointDataNV; -extern PFN_vkGetRaytracingShaderHandlesNVX vkGetRaytracingShaderHandlesNVX; -extern PFN_vkGetRefreshCycleDurationGOOGLE vkGetRefreshCycleDurationGOOGLE; -extern PFN_vkGetShaderInfoAMD vkGetShaderInfoAMD; -extern PFN_vkGetSwapchainCounterEXT vkGetSwapchainCounterEXT; -extern PFN_vkGetValidationCacheDataEXT vkGetValidationCacheDataEXT; -extern PFN_vkMergeValidationCachesEXT vkMergeValidationCachesEXT; -extern PFN_vkQueueBeginDebugUtilsLabelEXT vkQueueBeginDebugUtilsLabelEXT; -extern PFN_vkQueueEndDebugUtilsLabelEXT vkQueueEndDebugUtilsLabelEXT; -extern PFN_vkQueueInsertDebugUtilsLabelEXT vkQueueInsertDebugUtilsLabelEXT; -extern PFN_vkRegisterDeviceEventEXT vkRegisterDeviceEventEXT; -extern PFN_vkRegisterDisplayEventEXT vkRegisterDisplayEventEXT; -extern PFN_vkRegisterObjectsNVX vkRegisterObjectsNVX; -extern PFN_vkReleaseDisplayEXT vkReleaseDisplayEXT; -extern PFN_vkSetDebugUtilsObjectNameEXT vkSetDebugUtilsObjectNameEXT; -extern PFN_vkSetDebugUtilsObjectTagEXT vkSetDebugUtilsObjectTagEXT; -extern PFN_vkSetHdrMetadataEXT vkSetHdrMetadataEXT; -extern PFN_vkSubmitDebugUtilsMessageEXT vkSubmitDebugUtilsMessageEXT; -extern PFN_vkUnregisterObjectsNVX vkUnregisterObjectsNVX; -extern PFN_vkCreateAccelerationStructureNV vkCreateAccelerationStructureNV; - From 82c24601663fd158d1a6bac360a1854d3f42de7b Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Thu, 27 Oct 2022 14:26:26 +0200 Subject: [PATCH 105/107] Removed old Android init VK toast Signed-off-by: Fabian Sauter --- .../app/src/main/cpp/KomputeJniNative.cpp | 22 ------------------- .../java/com/ethicalml/kompute/KomputeJni.kt | 11 +--------- 2 files changed, 1 insertion(+), 32 deletions(-) diff --git a/examples/android/android-simple/app/src/main/cpp/KomputeJniNative.cpp b/examples/android/android-simple/app/src/main/cpp/KomputeJniNative.cpp index 2b9e75dca..ecbc70c40 100644 --- a/examples/android/android-simple/app/src/main/cpp/KomputeJniNative.cpp +++ b/examples/android/android-simple/app/src/main/cpp/KomputeJniNative.cpp @@ -50,28 +50,6 @@ vectorToJFloatArray(JNIEnv* env, const std::vector& fromVector) extern "C" { - - JNIEXPORT jboolean JNICALL - Java_com_ethicalml_kompute_KomputeJni_initVulkan(JNIEnv* env, jobject thiz) - { - - KP_LOG_INFO("Initialising vulkan"); - - uint32_t totalRetries = 0; - - /*while (totalRetries < KOMPUTE_VK_INIT_RETRIES) { - KP_LOG_INFO("VULKAN LOAD TRY NUMBER: %u", totalRetries); - if (InitVulkan()) { - break; - } - sleep(1); - totalRetries++; - }*/ - - // return totalRetries < KOMPUTE_VK_INIT_RETRIES; - return true; - } - JNIEXPORT jfloatArray JNICALL Java_com_ethicalml_kompute_KomputeJni_kompute(JNIEnv* env, jobject thiz, diff --git a/examples/android/android-simple/app/src/main/java/com/ethicalml/kompute/KomputeJni.kt b/examples/android/android-simple/app/src/main/java/com/ethicalml/kompute/KomputeJni.kt index b68e197eb..3221cf6d5 100755 --- a/examples/android/android-simple/app/src/main/java/com/ethicalml/kompute/KomputeJni.kt +++ b/examples/android/android-simple/app/src/main/java/com/ethicalml/kompute/KomputeJni.kt @@ -22,16 +22,7 @@ class KomputeJni : AppCompatActivity() { binding.komputeGifView.getSettings().setUseWideViewPort(true) binding.komputeGifView.getSettings().setLoadWithOverviewMode(true) - - val successVulkanInit = initVulkan() - if (successVulkanInit) { - Toast.makeText(applicationContext, "Vulkan Loaded SUCCESS", Toast.LENGTH_SHORT).show() - } else { - binding.KomputeButton.isEnabled = false - Toast.makeText(applicationContext, "Vulkan Load FAILED", Toast.LENGTH_SHORT).show() - } - Log.i("KomputeJni", "Vulkan Result: " + successVulkanInit) - + binding.predictionTextView.text = "N/A" } From 099f0e472540912ff4c2019957d3505ef1eb371c Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Fri, 28 Oct 2022 11:55:57 +0200 Subject: [PATCH 106/107] Loading vk lib dynamically on instance creation Signed-off-by: Fabian Sauter --- src/Manager.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Manager.cpp b/src/Manager.cpp index b1115a8fc..3c3e11652 100644 --- a/src/Manager.cpp +++ b/src/Manager.cpp @@ -233,9 +233,21 @@ Manager::createInstance() } #endif +#if VK_USE_PLATFORM_ANDROID_KHR + vk::DynamicLoader dl; + PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = + dl.getProcAddress("vkGetInstanceProcAddr"); + VULKAN_HPP_DEFAULT_DISPATCHER.init(vkGetInstanceProcAddr); +#endif // VK_USE_PLATFORM_ANDROID_KHR + this->mInstance = std::make_shared(); vk::createInstance( &computeInstanceCreateInfo, nullptr, this->mInstance.get()); + +#if VK_USE_PLATFORM_ANDROID_KHR + VULKAN_HPP_DEFAULT_DISPATCHER.init(*this->mInstance); +#endif // VK_USE_PLATFORM_ANDROID_KHR + KP_LOG_DEBUG("Kompute Manager Instance Created"); #ifndef KOMPUTE_DISABLE_VK_DEBUG_LAYERS From 13db27ccebe8df8a46a916bf920800461a9710c6 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Fri, 28 Oct 2022 11:56:43 +0200 Subject: [PATCH 107/107] Updated the Android example kp version Signed-off-by: Fabian Sauter --- examples/android/android-simple/app/src/main/cpp/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/android/android-simple/app/src/main/cpp/CMakeLists.txt b/examples/android/android-simple/app/src/main/cpp/CMakeLists.txt index 18feff433..e55114e6e 100644 --- a/examples/android/android-simple/app/src/main/cpp/CMakeLists.txt +++ b/examples/android/android-simple/app/src/main/cpp/CMakeLists.txt @@ -4,7 +4,7 @@ set(CMAKE_CXX_STANDARD 17) include(FetchContent) FetchContent_Declare(kompute GIT_REPOSITORY https://github.com/COM8/kompute.git - GIT_TAG b28d4ae0bec1d39003b97574623a52b0b5f7494d) # The commit hash for a dev version before v0.9.0. Replace with the latest from: https://github.com/KomputeProject/kompute/releases + GIT_TAG 675f6dc771cea044ead99a5467a9b817c2d8feb6) # The commit hash for a dev version before v0.9.0. Replace with the latest from: https://github.com/KomputeProject/kompute/releases set(KOMPUTE_OPT_ANDROID_BUILD ON) set(KOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS ON) FetchContent_MakeAvailable(kompute)