commit
1344ece4ac
113 changed files with 3004 additions and 5933 deletions
2
.ccls
2
.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/
|
||||
|
|
|
|||
121
.github/workflows/cpp_tests.yml
vendored
121
.github/workflows/cpp_tests.yml
vendored
|
|
@ -7,27 +7,106 @@ 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: Install vulkaninfo
|
||||
run: apt update -y && apt install -y vulkan-tools
|
||||
- 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"
|
||||
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: 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 -DKOMPUTE_OPT_USE_BUILT_IN_VULKAN_HEADER=ON
|
||||
- name: Run tests
|
||||
env:
|
||||
VK_ICD_FILENAMES: "/swiftshader/vk_swiftshader_icd.json"
|
||||
run: make mk_run_tests
|
||||
|
||||
cpp-tests-release-with-debug-layers:
|
||||
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:
|
||||
submodules: false
|
||||
- name: "[Release g++] Build & Test"
|
||||
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: 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 -DKOMPUTE_OPT_USE_BUILT_IN_VULKAN_HEADER=ON
|
||||
- name: Run tests
|
||||
env:
|
||||
VK_ICD_FILENAMES: "/swiftshader/vk_swiftshader_icd.json"
|
||||
run: make mk_run_tests
|
||||
|
||||
cpp-tests-debug-without-debug-layers:
|
||||
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:
|
||||
submodules: false
|
||||
- name: "[Release g++] Build & Test"
|
||||
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: 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 -DKOMPUTE_OPT_USE_BUILT_IN_VULKAN_HEADER=ON
|
||||
- name: Run tests
|
||||
env:
|
||||
VK_ICD_FILENAMES: "/swiftshader/vk_swiftshader_icd.json"
|
||||
run: make mk_run_tests
|
||||
|
||||
cpp-tests-release-without-debug-layers:
|
||||
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:
|
||||
submodules: false
|
||||
- name: "[Release g++] Build & Test"
|
||||
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: 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 -DKOMPUTE_OPT_USE_BUILT_IN_VULKAN_HEADER=ON
|
||||
- name: Run tests
|
||||
env:
|
||||
VK_ICD_FILENAMES: "/swiftshader/vk_swiftshader_icd.json"
|
||||
run: make mk_run_tests
|
||||
|
|
|
|||
26
.github/workflows/python_tests.yml
vendored
26
.github/workflows/python_tests.yml
vendored
|
|
@ -8,21 +8,23 @@ on:
|
|||
|
||||
jobs:
|
||||
python-tests:
|
||||
|
||||
runs-on: ubuntu-18.04
|
||||
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-python
|
||||
run: |
|
||||
pip3 install -r python/test/requirements-dev.txt
|
||||
- name: build-python
|
||||
run: |
|
||||
pip3 install .
|
||||
- name: test-python
|
||||
submodules: false
|
||||
- name: Install vulkaninfo
|
||||
run: apt update -y && apt install -y vulkan-tools
|
||||
- name: Install Python Requirements
|
||||
run: pip3 install --user -r python/test/requirements-dev.txt
|
||||
- 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: |
|
||||
export VK_ICD_FILENAMES=/swiftshader/vk_swiftshader_icd.json
|
||||
make test_python
|
||||
|
|
|
|||
6
.gitignore
vendored
6
.gitignore
vendored
|
|
@ -169,10 +169,9 @@ Content/StarterContent/*
|
|||
# VSCode Files
|
||||
/.vscode/*
|
||||
BuildingEscape.code-workspace
|
||||
|
||||
compile_commands.json
|
||||
|
||||
.clangd/
|
||||
.cache/
|
||||
|
||||
# Project files
|
||||
bin/
|
||||
|
|
@ -190,3 +189,6 @@ vk_swiftshader_icd.json
|
|||
tmp_kp_shader.comp.spv
|
||||
tmp_kp_shader.comp
|
||||
|
||||
# Docs
|
||||
_build/
|
||||
|
||||
|
|
|
|||
20
.gitmodules
vendored
20
.gitmodules
vendored
|
|
@ -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
|
||||
276
CMakeLists.txt
276
CMakeLists.txt
|
|
@ -1,94 +1,265 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
cmake_minimum_required(VERSION 3.4.1)
|
||||
project(kompute VERSION 0.8.1)
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
project(kompute VERSION 0.8.1 LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
set(CMAKE_VERBOSE_MAKEFILE on)
|
||||
# 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")
|
||||
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" "Default" "Off")
|
||||
|
||||
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()
|
||||
|
||||
# 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()
|
||||
|
||||
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
|
||||
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)
|
||||
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
|
||||
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_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)
|
||||
# Build flags
|
||||
set(KOMPUTE_EXTRA_CXX_FLAGS "" CACHE STRING "Extra compile flags for Kompute, see docs for full list")
|
||||
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 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_<DEBUG, INFO, etc...> 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)
|
||||
|
||||
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)
|
||||
# External components
|
||||
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)
|
||||
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 "=======================================================")
|
||||
|
||||
if(KOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS)
|
||||
set(SPDLOG_BUILD_SHARED ON CACHE BOOL "Enables build of shared libraries" FORCE)
|
||||
# ####################################################
|
||||
# Deprecated Options
|
||||
# ####################################################
|
||||
include(cmake/deprecation_warnings.cmake)
|
||||
|
||||
# ####################################################
|
||||
# Dependencies
|
||||
# ####################################################
|
||||
include(cmake/vulkan_shader_compiler.cmake)
|
||||
include(cmake/check_vulkan_version.cmake)
|
||||
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(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)
|
||||
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
|
||||
if(KOMPUTE_OPT_USE_SPDLOG)
|
||||
add_compile_definitions(KOMPUTE_OPT_USE_SPDLOG=1)
|
||||
|
||||
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()
|
||||
|
||||
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_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
|
||||
FetchContent_MakeAvailable(fmt)
|
||||
else()
|
||||
find_package(fmt REQUIRED)
|
||||
endif()
|
||||
|
||||
# GoogleTest
|
||||
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)
|
||||
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_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)
|
||||
else()
|
||||
find_package(pybind11 REQUIRED)
|
||||
endif()
|
||||
|
||||
find_package(PythonLibs REQUIRED)
|
||||
endif()
|
||||
|
||||
# ####################################################
|
||||
# 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()
|
||||
|
||||
# ####################################################
|
||||
# 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")
|
||||
if(NOT UNIX)
|
||||
message(FATAL_ERROR "KOMPUTE_OPT_CODE_COVERAGE can only be enabled in unix based systems due to limitation on gcov.")
|
||||
endif()
|
||||
|
||||
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/)
|
||||
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
|
||||
|
|
@ -100,6 +271,7 @@ endfunction()
|
|||
add_subdirectory(src)
|
||||
|
||||
if(KOMPUTE_OPT_BUILD_TESTS)
|
||||
enable_testing()
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
||||
|
|
|
|||
56
Makefile
56
Makefile
|
|
@ -56,17 +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_REPO_SUBMODULE_BUILD=1 \
|
||||
-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 \
|
||||
-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"
|
||||
|
|
@ -81,13 +78,16 @@ mk_build_kompute:
|
|||
cmake --build build/. --target kompute --parallel
|
||||
|
||||
mk_build_tests:
|
||||
cmake --build build/ --target test_kompute --parallel
|
||||
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
|
||||
./build/test/test_kompute --gtest_filter=$(FILTER_TESTS)
|
||||
./build/bin/kompute_tests --gtest_filter=$(FILTER_TESTS)
|
||||
|
||||
mk_build_swiftshader_library:
|
||||
git clone https://github.com/google/swiftshader || echo "Assuming already cloned"
|
||||
|
|
@ -104,7 +104,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:
|
||||
|
|
@ -112,38 +112,36 @@ 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=1 \
|
||||
-DKOMPUTE_OPT_REPO_SUBMODULE_BUILD=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 \
|
||||
-G "Visual Studio 16 2019"
|
||||
-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" \
|
||||
-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)
|
||||
|
||||
vs_run_tests: vs_build_tests
|
||||
./build/test/$(VS_BUILD_TYPE)/test_kompute.exe --gtest_filter=$(FILTER_TESTS)
|
||||
./build/test/$(VS_BUILD_TYPE)/bin/kompute_tests.exe --gtest_filter=$(FILTER_TESTS)
|
||||
|
||||
|
||||
#### PYTHONG ####
|
||||
|
|
@ -163,7 +161,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/ \
|
||||
|
|
|
|||
106
cmake/bin2h.cmake
Normal file
106
cmake/bin2h.cmake
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
##################################################################################
|
||||
# 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.
|
||||
# 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)
|
||||
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} / 8")
|
||||
|
||||
# adds '0x' prefix and comma suffix before and after every byte respectively
|
||||
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})
|
||||
|
||||
# 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 "} // namespace ${HEADER_NAMESPACE}")
|
||||
set(arrayIncludes "#pragma once\n#include <array>\n#include <cstdint>")
|
||||
set(arrayDefinition "const std::array<uint32_t, ${arraySize}> ${BIN2H_VARIABLE_NAME} = { ${arrayValues} };")
|
||||
|
||||
set(declarations "${arrayIncludes}\n\n${namespaceStart}\n${arrayDefinition}\n${namespaceEnd}\n\n")
|
||||
if(BIN2H_APPEND)
|
||||
file(APPEND ${BIN2H_HEADER_FILE} "${declarations}")
|
||||
else()
|
||||
file(WRITE ${BIN2H_HEADER_FILE} "${declarations}")
|
||||
endif()
|
||||
endfunction()
|
||||
19
cmake/bin_file_to_header.cmake
Normal file
19
cmake/bin_file_to_header.cmake
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
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")
|
||||
139
cmake/check_vulkan_version.cmake
Normal file
139
cmake/check_vulkan_version.cmake
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
# 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.")
|
||||
|
||||
# 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} 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()
|
||||
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 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()
|
||||
|
||||
execute_process(COMMAND "vulkaninfo"
|
||||
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()
|
||||
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}")
|
||||
if(NOT GPU_IDS)
|
||||
message(FATAL_ERROR "No GPU supporting Vulkan found in vulkaninfo. Does your GPU (driver) support Vulkan?")
|
||||
endif()
|
||||
|
||||
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_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 in case you encounter any 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()
|
||||
set(VALID_GPU ${GPU})
|
||||
set(VALID_VULKAN_VERSION ${VULKAN_DRIVER_VERSION})
|
||||
break()
|
||||
endif()
|
||||
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. 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()
|
||||
|
||||
endfunction()
|
||||
35
cmake/code_coverage.cmake
Normal file
35
cmake/code_coverage.cmake
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
# 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)
|
||||
15
cmake/deprecation_warnings.cmake
Normal file
15
cmake/deprecation_warnings.cmake
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
if(KOMPUTE_OPT_REPO_SUBMODULE_BUILD)
|
||||
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)
|
||||
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<kompute/kompute.h>'.")
|
||||
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()
|
||||
8
cmake/komputeConfig.cmake.in
Normal file
8
cmake/komputeConfig.cmake.in
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
include(CMakeFindDependencyMacro)
|
||||
@PACKAGE_INIT@
|
||||
|
||||
find_dependency(VULKAN REQUIRED)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/komputeTargets.cmake)
|
||||
|
||||
check_required_components(kompute)
|
||||
43
cmake/vulkan_shader_compiler.cmake
Normal file
43
cmake/vulkan_shader_compiler.cmake
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
function(vulkan_compile_shader)
|
||||
find_program(GLS_LANG_VALIDATOR_PATH NAMES glslangValidator)
|
||||
if(GLS_LANG_VALIDATOR_PATH STREQUAL "GLS_LANG_VALIDATOR_PATH-NOTFOUND")
|
||||
message(FATAL_ERROR "glslangValidator not found.")
|
||||
return()
|
||||
endif()
|
||||
|
||||
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}"
|
||||
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}")
|
||||
|
||||
# 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"
|
||||
"${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()
|
||||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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 built-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.
|
||||
|
||||
|
|
@ -20,36 +25,41 @@ 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
|
||||
* - -DKOMPUTE_OPT_BUILD_TESTS=1
|
||||
- Enable if you wish to build and run the tests (must have deps installed.
|
||||
* - -DKOMPUTE_OPT_CODE_COVERAGE=1
|
||||
- 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
|
||||
- Enable if you wish to build the docs (must have docs deps installed)
|
||||
* - -DKOMPUTE_OPT_BUILD_SHADERS=1
|
||||
- Enable if you wish to build the shaders into header files (must have docs deps installed)
|
||||
* - -DKOMPUTE_OPT_BUILD_SINGLE_HEADER=1
|
||||
- Option to build the single header file using "quom" utility
|
||||
* - -DKOMPUTE_OPT_INSTALL=0
|
||||
- Disables the install step in the cmake file (useful for android build)
|
||||
* - -DKOMPUTE_OPT_BUILD_PYTHON=1
|
||||
- Enable to build python bindings (used internally for python package)
|
||||
* - -DKOMPUTE_OPT_ENABLE_SPDLOG=1
|
||||
- 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
|
||||
- Enables android build which includes and excludes relevant libraries
|
||||
* - -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=1
|
||||
- Explicitly disables debug layers even when on debug mode
|
||||
* - -DKOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS=1
|
||||
- Ensures dependencies are referenced as shared libraries for kompute install
|
||||
* - -DKOMPUTE_OPT_BUILD_AS_SHARED_LIB=1
|
||||
- Whether to build Kompute as shared lib instead of static
|
||||
* - -DKOMPUTE_EXTRA_CXX_FLAGS="..."
|
||||
- Allows you to pass extra config flags to compiler
|
||||
|
||||
- This is the path for your package manager if you use it such as vcpkg.
|
||||
* - -DKOMPUTE_OPT_BUILD_TESTS=ON
|
||||
- Enable if you want to build tests.
|
||||
* - -DKOMPUTE_OPT_CODE_COVERAGE=ON
|
||||
- Enable if you want code coverage.
|
||||
* - -DKOMPUTE_OPT_BUILD_DOCS=ON
|
||||
- Enable if you want to build documentation.
|
||||
* - -DKOMPUTE_OPT_INSTALL=ON
|
||||
- Enable if you want to enable installation.
|
||||
* - -DKOMPUTE_OPT_BUILD_PYTHON=ON
|
||||
- Enable if you want to build python bindings.
|
||||
* - -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_<DEBUG, INFO, etc...> 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
|
||||
- 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_BUILT_IN_SPDLOG=ON
|
||||
- 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
|
||||
- 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=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
|
||||
|
||||
Compile Flags
|
||||
~~~~~~~~~~~~~
|
||||
|
|
@ -61,27 +71,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=1
|
||||
- Major version to use for the Vulkan SDK
|
||||
* - -DKOMPUTE_VK_API_MINOR_VERSION=1
|
||||
- Minor version to use for the Vulkan SDK
|
||||
* - -DKOMPUTE_ENABLE_SPDLOG=1
|
||||
- Enables the build with SPDLOG and FMT dependencies (must be installed)
|
||||
* - -DKOMPUTE_LOG_OVERRIDE=1
|
||||
- Does not define the SPDLOG_\ :raw-html-m2r:`<LEVEL>` 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
|
||||
- Enable release build (enabled by cmake release build)
|
||||
* - -DDEBUG=1
|
||||
- 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
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
@ -106,21 +96,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 <https://vulkan.lunarg.com/>`_.
|
||||
|
||||
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 <spdlog/spdlog.h>
|
||||
#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);``.
|
||||
|
|
|
|||
|
|
@ -1,10 +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
|
||||
|
||||
|
|
@ -29,9 +29,8 @@ For users that are looking to quickly test the processors it is possible to use
|
|||
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 +68,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 <https://github.com/KomputeProject/kompute/blob/45ddfe524b9ed63c5fe1fc33773c8f93a18e2fac/Makefile#L143>`_ 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 $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
|
||||
|
||||
Once your code then compiles, you can simply include and use your shader header files.
|
||||
|
||||
.. code-block:: cpp
|
||||
:linenos:
|
||||
|
||||
#include <kompute/kompute.hpp>
|
||||
|
||||
#include "my_shader.hpp"
|
||||
|
||||
int main() {
|
||||
// [...]
|
||||
|
||||
const std::vector<std::shared_ptr<kp::Tensor>> params = ...
|
||||
|
||||
const std::vector<uint32_t> shader = std::vector<uint32_t>(shader::MY_SHADER_COMP_SPV.begin(), shader::MY_SHADER_COMP_SPV.end());
|
||||
std::shared_ptr<kp::Algorithm> algo = mgr.algorithm(params, shader);
|
||||
|
||||
// [...]
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@ This is the accompanying code for the Blog post ["Supercharging your Mobile Apps
|
|||
<p>
|
||||
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.
|
||||
</p>
|
||||
|
||||
<br>
|
||||
|
|
|
|||
|
|
@ -3,29 +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=1',
|
||||
'-DKOMPUTE_OPT_REPO_SUBMODULE_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'
|
||||
'-DANDROID_STL=c++_static'
|
||||
}
|
||||
}
|
||||
ndk {
|
||||
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
|
|
@ -41,6 +37,7 @@ android {
|
|||
externalNativeBuild {
|
||||
cmake {
|
||||
path 'src/main/cpp/CMakeLists.txt'
|
||||
version '3.22.2'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -64,6 +61,7 @@ android {
|
|||
// armeabi-v7a, arm64-v8a, x86, x86_64
|
||||
}
|
||||
}
|
||||
namespace 'com.ethicalml.kompute'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- BEGIN_INCLUDE(manifest) -->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.ethicalml.kompute">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
|
|
@ -9,7 +8,8 @@
|
|||
android:label="@string/app_name"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity android:name=".KomputeJni">
|
||||
<activity android:name=".KomputeJni"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
|
|
|
|||
|
|
@ -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 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)
|
||||
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)
|
||||
|
|
@ -24,10 +24,7 @@
|
|||
// Allows us to use the C++ sleep function to wait when loading the
|
||||
// Vulkan library in android
|
||||
#include <unistd.h>
|
||||
|
||||
#ifndef KOMPUTE_VK_INIT_RETRIES
|
||||
#define KOMPUTE_VK_INIT_RETRIES 5
|
||||
#endif
|
||||
#include <kompute/logger/Logger.hpp>
|
||||
|
||||
static std::vector<float>
|
||||
jfloatArrayToVector(JNIEnv* env, const jfloatArray& fromArray)
|
||||
|
|
@ -53,27 +50,6 @@ vectorToJFloatArray(JNIEnv* env, const std::vector<float>& 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;
|
||||
}
|
||||
|
||||
JNIEXPORT jfloatArray JNICALL
|
||||
Java_com_ethicalml_kompute_KomputeJni_kompute(JNIEnv* env,
|
||||
jobject thiz,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
|
||||
#include "KomputeModelML.hpp"
|
||||
#include "my_shader.hpp"
|
||||
#include <kompute/Kompute.hpp>
|
||||
|
||||
|
||||
KomputeModelML::KomputeModelML() {}
|
||||
|
||||
|
|
@ -10,7 +13,6 @@ KomputeModelML::train(std::vector<float> yData,
|
|||
std::vector<float> xIData,
|
||||
std::vector<float> xJData)
|
||||
{
|
||||
|
||||
std::vector<float> zerosData;
|
||||
|
||||
for (size_t i = 0; i < yData.size(); i++) {
|
||||
|
|
@ -41,15 +43,11 @@ KomputeModelML::train(std::vector<float> yData,
|
|||
wIn, wOutI, wOutJ,
|
||||
bIn, bOut, lOut };
|
||||
|
||||
std::vector<uint32_t> spirv = std::vector<uint32_t>(
|
||||
(uint32_t*)kp::shader_data::shaders_glsl_logisticregression_comp_spv,
|
||||
(uint32_t*)(kp::shader_data::
|
||||
shaders_glsl_logisticregression_comp_spv +
|
||||
kp::shader_data::
|
||||
shaders_glsl_logisticregression_comp_spv_len));
|
||||
const std::vector<uint32_t> shader = std::vector<uint32_t>(
|
||||
shader::MY_SHADER_COMP_SPV.begin(), shader::MY_SHADER_COMP_SPV.end());
|
||||
|
||||
std::shared_ptr<kp::Algorithm> algorithm = mgr.algorithm(
|
||||
params, spirv, kp::Workgroup({ 5 }), std::vector<float>({ 5.0 }));
|
||||
params, shader, kp::Workgroup({ 5 }), std::vector<float>({ 5.0 }));
|
||||
|
||||
mgr.sequence()->eval<kp::OpTensorSyncDevice>(params);
|
||||
|
||||
|
|
@ -84,7 +82,6 @@ KomputeModelML::train(std::vector<float> yData,
|
|||
std::vector<float>
|
||||
KomputeModelML::predict(std::vector<float> xI, std::vector<float> xJ)
|
||||
{
|
||||
|
||||
KP_LOG_INFO("Running prediction inference");
|
||||
|
||||
assert(xI.size() == xJ.size());
|
||||
|
|
@ -113,7 +110,6 @@ KomputeModelML::predict(std::vector<float> xI, std::vector<float> xJ)
|
|||
std::vector<float>
|
||||
KomputeModelML::get_params()
|
||||
{
|
||||
|
||||
KP_LOG_INFO("Displaying results");
|
||||
|
||||
std::vector<float> retVector;
|
||||
|
|
|
|||
|
|
@ -1,13 +1,8 @@
|
|||
|
||||
#ifndef KOMPUTEMODELML_HPP
|
||||
#define KOMPUTEMODELML_HPP
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "kompute/Kompute.hpp"
|
||||
|
||||
class KomputeModelML
|
||||
{
|
||||
|
||||
|
|
@ -27,62 +22,3 @@ class KomputeModelML
|
|||
std::vector<float> mWeights;
|
||||
std::vector<float> 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
|
||||
|
|
|
|||
|
|
@ -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 $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -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"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,40 +1,37 @@
|
|||
cmake_minimum_required(VERSION 3.4.1)
|
||||
project(kompute_array_mult VERSION 0.1.0)
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
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 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")
|
||||
|
||||
add_subdirectory(shader)
|
||||
add_subdirectory(src)
|
||||
|
|
|
|||
|
|
@ -1,31 +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_REPO_SUBMODULE_BUILD=1 \
|
||||
-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
|
||||
|
||||
|
|
@ -33,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.
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
15
examples/array_multiplication/shader/CMakeLists.txt
Normal file
15
examples/array_multiplication/shader/CMakeLists.txt
Normal file
|
|
@ -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 $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
|
||||
14
examples/array_multiplication/shader/my_shader.comp
Normal file
14
examples/array_multiplication/shader/my_shader.comp
Normal file
|
|
@ -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];
|
||||
}
|
||||
4
examples/array_multiplication/src/CMakeLists.txt
Normal file
4
examples/array_multiplication/src/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
add_executable(kompute_array_mult main.cpp)
|
||||
target_link_libraries(kompute_array_mult PRIVATE shader kompute::kompute)
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "kompute/Kompute.hpp"
|
||||
|
||||
static std::vector<uint32_t>
|
||||
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<char> buffer;
|
||||
buffer.insert(
|
||||
buffer.begin(), std::istreambuf_iterator<char>(fileStream), {});
|
||||
return { (uint32_t*)buffer.data(),
|
||||
(uint32_t*)(buffer.data() + buffer.size()) };
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
#if KOMPUTE_ENABLE_SPDLOG
|
||||
spdlog::set_level(
|
||||
static_cast<spdlog::level::level_enum>(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<std::shared_ptr<kp::Tensor>> params = { tensorInA,
|
||||
tensorInB,
|
||||
tensorOut };
|
||||
|
||||
std::shared_ptr<kp::Algorithm> algo =
|
||||
mgr.algorithm(params, compileSource(shader));
|
||||
|
||||
mgr.sequence()
|
||||
->record<kp::OpTensorSyncDevice>(params)
|
||||
->record<kp::OpAlgoDispatch>(algo)
|
||||
->record<kp::OpTensorSyncLocal>(params)
|
||||
->eval();
|
||||
|
||||
// prints "Output { 0 4 12 }"
|
||||
std::cout << "Output: { ";
|
||||
for (const float& elem : tensorOut->vector()) {
|
||||
std::cout << elem << " ";
|
||||
}
|
||||
std::cout << "}" << std::endl;
|
||||
}
|
||||
41
examples/array_multiplication/src/main.cpp
Normal file
41
examples/array_multiplication/src/main.cpp
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "my_shader.hpp"
|
||||
#include <kompute/Kompute.hpp>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
kp::Manager mgr;
|
||||
|
||||
std::shared_ptr<kp::TensorT<float>> tensorInA =
|
||||
mgr.tensor({ 2.0, 4.0, 6.0 });
|
||||
std::shared_ptr<kp::TensorT<float>> tensorInB =
|
||||
mgr.tensor({ 0.0, 1.0, 2.0 });
|
||||
std::shared_ptr<kp::TensorT<float>> tensorOut =
|
||||
mgr.tensor({ 0.0, 0.0, 0.0 });
|
||||
|
||||
const std::vector<std::shared_ptr<kp::Tensor>> params = { tensorInA,
|
||||
tensorInB,
|
||||
tensorOut };
|
||||
|
||||
const std::vector<uint32_t> shader = std::vector<uint32_t>(
|
||||
shader::MY_SHADER_COMP_SPV.begin(), shader::MY_SHADER_COMP_SPV.end());
|
||||
std::shared_ptr<kp::Algorithm> algo = mgr.algorithm(params, shader);
|
||||
|
||||
mgr.sequence()
|
||||
->record<kp::OpTensorSyncDevice>(params)
|
||||
->record<kp::OpAlgoDispatch>(algo)
|
||||
->record<kp::OpTensorSyncLocal>(params)
|
||||
->eval();
|
||||
|
||||
// prints "Output { 0 4 12 }"
|
||||
std::cout << "Output: { ";
|
||||
for (const float& elem : tensorOut->vector()) {
|
||||
std::cout << elem << " ";
|
||||
}
|
||||
std::cout << "}" << std::endl;
|
||||
}
|
||||
|
|
@ -1,41 +1,37 @@
|
|||
cmake_minimum_required(VERSION 3.4.1)
|
||||
project(kompute_linear_reg VERSION 0.1.0)
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
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 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")
|
||||
|
||||
add_subdirectory(shader)
|
||||
add_subdirectory(src)
|
||||
|
|
|
|||
|
|
@ -1,31 +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_REPO_SUBMODULE_BUILD=1 \
|
||||
-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
|
||||
|
||||
|
|
@ -33,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.
|
||||
|
|
|
|||
15
examples/logistic_regression/shader/CMakeLists.txt
Normal file
15
examples/logistic_regression/shader/CMakeLists.txt
Normal file
|
|
@ -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 $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
|
||||
|
|
@ -52,5 +52,3 @@ void main() {
|
|||
|
||||
lout[idx] = calculateLoss(yHat, yCurr);
|
||||
}
|
||||
|
||||
|
||||
4
examples/logistic_regression/src/CMakeLists.txt
Normal file
4
examples/logistic_regression/src/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
add_executable(kompute_logistic_regression main.cpp)
|
||||
target_link_libraries(kompute_logistic_regression PRIVATE shader kompute::kompute)
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "kompute/Kompute.hpp"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
#if KOMPUTE_ENABLE_SPDLOG
|
||||
spdlog::set_level(
|
||||
static_cast<spdlog::level::level_enum>(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<std::shared_ptr<kp::Tensor>> params = { xI, xJ, y,
|
||||
wIn, wOutI, wOutJ,
|
||||
bIn, bOut, lOut };
|
||||
|
||||
std::vector<uint32_t> 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<kp::Algorithm> algo = mgr.algorithm(
|
||||
params, spirv, kp::Workgroup({ 5 }), std::vector<float>({ 5.0 }));
|
||||
|
||||
mgr.sequence()->eval<kp::OpTensorSyncDevice>(params);
|
||||
|
||||
std::shared_ptr<kp::Sequence> sq =
|
||||
mgr.sequence()
|
||||
->record<kp::OpTensorSyncDevice>({ wIn, bIn })
|
||||
->record<kp::OpAlgoDispatch>(algo)
|
||||
->record<kp::OpTensorSyncLocal>({ 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;
|
||||
}
|
||||
66
examples/logistic_regression/src/main.cpp
Normal file
66
examples/logistic_regression/src/main.cpp
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "kompute/Tensor.hpp"
|
||||
#include "my_shader.hpp"
|
||||
#include <kompute/Kompute.hpp>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
uint32_t ITERATIONS = 100;
|
||||
float learningRate = 0.1;
|
||||
|
||||
kp::Manager mgr;
|
||||
|
||||
std::shared_ptr<kp::TensorT<float>> xI = mgr.tensor({ 0, 1, 1, 1, 1 });
|
||||
std::shared_ptr<kp::TensorT<float>> xJ = mgr.tensor({ 0, 0, 0, 1, 1 });
|
||||
|
||||
std::shared_ptr<kp::TensorT<float>> y = mgr.tensor({ 0, 0, 0, 1, 1 });
|
||||
|
||||
std::shared_ptr<kp::TensorT<float>> wIn = mgr.tensor({ 0.001, 0.001 });
|
||||
std::shared_ptr<kp::TensorT<float>> wOutI = mgr.tensor({ 0, 0, 0, 0, 0 });
|
||||
std::shared_ptr<kp::TensorT<float>> wOutJ = mgr.tensor({ 0, 0, 0, 0, 0 });
|
||||
|
||||
std::shared_ptr<kp::TensorT<float>> bIn = mgr.tensor({ 0 });
|
||||
std::shared_ptr<kp::TensorT<float>> bOut = mgr.tensor({ 0, 0, 0, 0, 0 });
|
||||
|
||||
std::shared_ptr<kp::TensorT<float>> lOut = mgr.tensor({ 0, 0, 0, 0, 0 });
|
||||
|
||||
const std::vector<std::shared_ptr<kp::Tensor>> params = {
|
||||
xI, xJ, y, wIn, wOutI, wOutJ, bIn, bOut, lOut
|
||||
};
|
||||
|
||||
const std::vector<uint32_t> shader = std::vector<uint32_t>(
|
||||
shader::MY_SHADER_COMP_SPV.begin(), shader::MY_SHADER_COMP_SPV.end());
|
||||
|
||||
std::shared_ptr<kp::Algorithm> algo = mgr.algorithm(
|
||||
params, shader, kp::Workgroup({ 5 }), std::vector<float>({ 5.0 }));
|
||||
|
||||
mgr.sequence()->eval<kp::OpTensorSyncDevice>(params);
|
||||
|
||||
std::shared_ptr<kp::Sequence> sq =
|
||||
mgr.sequence()
|
||||
->record<kp::OpTensorSyncDevice>({ wIn, bIn })
|
||||
->record<kp::OpAlgoDispatch>(algo)
|
||||
->record<kp::OpTensorSyncLocal>({ 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;
|
||||
}
|
||||
1
external/Vulkan-Headers
vendored
1
external/Vulkan-Headers
vendored
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 320af06cbdd29848e1d7100d9b8e4e517db1dfd5
|
||||
1
external/fmt
vendored
1
external/fmt
vendored
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 7bdf0628b1276379886c7f6dda2cef2b3b374f0b
|
||||
1
external/googletest
vendored
1
external/googletest
vendored
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 703bd9caab50b139428cea1aaff9974ebee5742e
|
||||
1
external/spdlog
vendored
1
external/spdlog
vendored
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 01b350de96483cf00b267c6db4c25f3b739b3fee
|
||||
28
kompute-config.cmake
Normal file
28
kompute-config.cmake
Normal file
|
|
@ -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()
|
||||
|
|
@ -1,11 +1,9 @@
|
|||
|
||||
add_subdirectory(pybind11)
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 06a54018c8a9fd9a7be5f5b56414b5da9259f637
|
||||
|
|
@ -1,333 +1,558 @@
|
|||
#include <pybind11/numpy.h>
|
||||
#include <pybind11/pybind11.h>
|
||||
#include <pybind11/stl.h>
|
||||
#include <pybind11/numpy.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <kompute/Kompute.hpp>
|
||||
|
||||
#include "fmt/ranges.h"
|
||||
|
||||
#include "utils.hpp"
|
||||
#include "docstrings.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
namespace py = pybind11;
|
||||
|
||||
//used in Core.hpp
|
||||
py::object kp_debug, kp_info, kp_warning, kp_error;
|
||||
// used in Core.hpp
|
||||
py::object kp_trace, kp_debug, kp_info, kp_warning, kp_error;
|
||||
|
||||
std::unique_ptr<kp::OpAlgoDispatch> opAlgoDispatchPyInit(
|
||||
std::shared_ptr<kp::Algorithm>& 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<kp::OpAlgoDispatch>
|
||||
opAlgoDispatchPyInit(std::shared_ptr<kp::Algorithm>& 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::float_t>()) {
|
||||
std::vector<float> dataVec((float*)info.ptr, ((float*)info.ptr) + info.size);
|
||||
return std::unique_ptr<kp::OpAlgoDispatch>{new kp::OpAlgoDispatch(algorithm, dataVec)};
|
||||
} else if (push_consts.dtype() == py::dtype::of<std::uint32_t>()) {
|
||||
std::vector<uint32_t> dataVec((uint32_t*)info.ptr, ((uint32_t*)info.ptr) + info.size);
|
||||
return std::unique_ptr<kp::OpAlgoDispatch>{new kp::OpAlgoDispatch(algorithm, dataVec)};
|
||||
} else if (push_consts.dtype() == py::dtype::of<std::int32_t>()) {
|
||||
std::vector<int32_t> dataVec((int32_t*)info.ptr, ((int32_t*)info.ptr) + info.size);
|
||||
return std::unique_ptr<kp::OpAlgoDispatch>{new kp::OpAlgoDispatch(algorithm, dataVec)};
|
||||
} else if (push_consts.dtype() == py::dtype::of<std::double_t>()) {
|
||||
std::vector<double> dataVec((double*)info.ptr, ((double*)info.ptr) + info.size);
|
||||
return std::unique_ptr<kp::OpAlgoDispatch>{new kp::OpAlgoDispatch(algorithm, dataVec)};
|
||||
if (push_consts.dtype().is(py::dtype::of<std::float_t>())) {
|
||||
std::vector<float> dataVec((float*)info.ptr,
|
||||
((float*)info.ptr) + info.size);
|
||||
return std::unique_ptr<kp::OpAlgoDispatch>{ new kp::OpAlgoDispatch(
|
||||
algorithm, dataVec) };
|
||||
} else if (push_consts.dtype().is(py::dtype::of<std::uint32_t>())) {
|
||||
std::vector<uint32_t> dataVec((uint32_t*)info.ptr,
|
||||
((uint32_t*)info.ptr) + info.size);
|
||||
return std::unique_ptr<kp::OpAlgoDispatch>{ new kp::OpAlgoDispatch(
|
||||
algorithm, dataVec) };
|
||||
} else if (push_consts.dtype().is(py::dtype::of<std::int32_t>())) {
|
||||
std::vector<int32_t> dataVec((int32_t*)info.ptr,
|
||||
((int32_t*)info.ptr) + info.size);
|
||||
return std::unique_ptr<kp::OpAlgoDispatch>{ new kp::OpAlgoDispatch(
|
||||
algorithm, dataVec) };
|
||||
} else if (push_consts.dtype().is(py::dtype::of<std::double_t>())) {
|
||||
std::vector<double> dataVec((double*)info.ptr,
|
||||
((double*)info.ptr) + info.size);
|
||||
return std::unique_ptr<kp::OpAlgoDispatch>{ 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_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");
|
||||
kp_error = kp_logger.attr("error");
|
||||
logging.attr("basicConfig")();
|
||||
|
||||
py::module_ np = py::module_::import("numpy");
|
||||
|
||||
py::enum_<kp::Tensor::TensorTypes>(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_<kp::OpBase, std::shared_ptr<kp::OpBase>>(m, "OpBase", DOC(kp, OpBase));
|
||||
py::class_<kp::OpBase, std::shared_ptr<kp::OpBase>>(
|
||||
m, "OpBase", DOC(kp, OpBase));
|
||||
|
||||
py::class_<kp::OpTensorSyncDevice, std::shared_ptr<kp::OpTensorSyncDevice>>(
|
||||
m, "OpTensorSyncDevice", py::base<kp::OpBase>(), DOC(kp, OpTensorSyncDevice))
|
||||
.def(py::init<const std::vector<std::shared_ptr<kp::Tensor>>&>(), DOC(kp, OpTensorSyncDevice, OpTensorSyncDevice));
|
||||
py::class_<kp::OpTensorSyncDevice,
|
||||
kp::OpBase,
|
||||
std::shared_ptr<kp::OpTensorSyncDevice>>(
|
||||
m, "OpTensorSyncDevice", DOC(kp, OpTensorSyncDevice))
|
||||
.def(py::init<const std::vector<std::shared_ptr<kp::Tensor>>&>(),
|
||||
DOC(kp, OpTensorSyncDevice, OpTensorSyncDevice));
|
||||
|
||||
py::class_<kp::OpTensorSyncLocal, std::shared_ptr<kp::OpTensorSyncLocal>>(
|
||||
m, "OpTensorSyncLocal", py::base<kp::OpBase>(), DOC(kp, OpTensorSyncLocal))
|
||||
.def(py::init<const std::vector<std::shared_ptr<kp::Tensor>>&>(), DOC(kp, OpTensorSyncLocal, OpTensorSyncLocal));
|
||||
py::class_<kp::OpTensorSyncLocal,
|
||||
kp::OpBase,
|
||||
std::shared_ptr<kp::OpTensorSyncLocal>>(
|
||||
m, "OpTensorSyncLocal", DOC(kp, OpTensorSyncLocal))
|
||||
.def(py::init<const std::vector<std::shared_ptr<kp::Tensor>>&>(),
|
||||
DOC(kp, OpTensorSyncLocal, OpTensorSyncLocal));
|
||||
|
||||
py::class_<kp::OpTensorCopy, std::shared_ptr<kp::OpTensorCopy>>(
|
||||
m, "OpTensorCopy", py::base<kp::OpBase>(), DOC(kp, OpTensorCopy))
|
||||
.def(py::init<const std::vector<std::shared_ptr<kp::Tensor>>&>(), DOC(kp, OpTensorCopy, OpTensorCopy));
|
||||
py::class_<kp::OpTensorCopy, kp::OpBase, std::shared_ptr<kp::OpTensorCopy>>(
|
||||
m, "OpTensorCopy", DOC(kp, OpTensorCopy))
|
||||
.def(py::init<const std::vector<std::shared_ptr<kp::Tensor>>&>(),
|
||||
DOC(kp, OpTensorCopy, OpTensorCopy));
|
||||
|
||||
py::class_<kp::OpAlgoDispatch, std::shared_ptr<kp::OpAlgoDispatch>>(
|
||||
m, "OpAlgoDispatch", py::base<kp::OpBase>(), DOC(kp, OpAlgoDispatch))
|
||||
.def(py::init<const std::shared_ptr<kp::Algorithm>&,const std::vector<float>&>(),
|
||||
DOC(kp, OpAlgoDispatch, OpAlgoDispatch),
|
||||
py::arg("algorithm"), py::arg("push_consts") = std::vector<float>())
|
||||
.def(py::init(&opAlgoDispatchPyInit),
|
||||
DOC(kp, OpAlgoDispatch, OpAlgoDispatch),
|
||||
py::arg("algorithm"), py::arg("push_consts"));
|
||||
py::class_<kp::OpAlgoDispatch,
|
||||
kp::OpBase,
|
||||
std::shared_ptr<kp::OpAlgoDispatch>>(
|
||||
m, "OpAlgoDispatch", DOC(kp, OpAlgoDispatch))
|
||||
.def(py::init<const std::shared_ptr<kp::Algorithm>&,
|
||||
const std::vector<float>&>(),
|
||||
DOC(kp, OpAlgoDispatch, OpAlgoDispatch),
|
||||
py::arg("algorithm"),
|
||||
py::arg("push_consts") = std::vector<float>())
|
||||
.def(py::init(&opAlgoDispatchPyInit),
|
||||
DOC(kp, OpAlgoDispatch, OpAlgoDispatch),
|
||||
py::arg("algorithm"),
|
||||
py::arg("push_consts"));
|
||||
|
||||
py::class_<kp::OpMult, std::shared_ptr<kp::OpMult>>(
|
||||
m, "OpMult", py::base<kp::OpBase>(), DOC(kp, OpMult))
|
||||
.def(py::init<const std::vector<std::shared_ptr<kp::Tensor>>&,const std::shared_ptr<kp::Algorithm>&>(),
|
||||
DOC(kp, OpMult, OpMult));
|
||||
py::class_<kp::OpMult, kp::OpBase, std::shared_ptr<kp::OpMult>>(
|
||||
m, "OpMult", DOC(kp, OpMult))
|
||||
.def(py::init<const std::vector<std::shared_ptr<kp::Tensor>>&,
|
||||
const std::shared_ptr<kp::Algorithm>&>(),
|
||||
DOC(kp, OpMult, OpMult));
|
||||
|
||||
py::class_<kp::Algorithm, std::shared_ptr<kp::Algorithm>>(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_<kp::Algorithm, std::shared_ptr<kp::Algorithm>>(
|
||||
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_<kp::Tensor, std::shared_ptr<kp::Tensor>>(m, "Tensor", DOC(kp, Tensor))
|
||||
.def("data", [](kp::Tensor& self) {
|
||||
// Non-owning container exposing the underlying pointer
|
||||
switch (self.dataType()) {
|
||||
py::class_<kp::Tensor, std::shared_ptr<kp::Tensor>>(
|
||||
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<float>(), py::cast(&self));
|
||||
return py::array(
|
||||
self.size(), self.data<float>(), py::cast(&self));
|
||||
case kp::Tensor::TensorDataTypes::eUnsignedInt:
|
||||
return py::array(self.size(), self.data<uint32_t>(), py::cast(&self));
|
||||
return py::array(
|
||||
self.size(), self.data<uint32_t>(), py::cast(&self));
|
||||
case kp::Tensor::TensorDataTypes::eInt:
|
||||
return py::array(self.size(), self.data<int32_t>(), py::cast(&self));
|
||||
return py::array(
|
||||
self.size(), self.data<int32_t>(), py::cast(&self));
|
||||
case kp::Tensor::TensorDataTypes::eDouble:
|
||||
return py::array(self.size(), self.data<double>(), py::cast(&self));
|
||||
return py::array(
|
||||
self.size(), self.data<double>(), py::cast(&self));
|
||||
case kp::Tensor::TensorDataTypes::eBool:
|
||||
return py::array(self.size(), self.data<bool>(), py::cast(&self));
|
||||
return py::array(
|
||||
self.size(), self.data<bool>(), 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_<kp::Sequence, std::shared_ptr<kp::Sequence>>(m, "Sequence")
|
||||
.def("record", [](kp::Sequence& self, std::shared_ptr<kp::OpBase> 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<kp::OpBase> 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<kp::OpBase> 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<kp::OpBase> 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<kp::OpBase> 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<kp::OpBase> 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_<kp::Manager, std::shared_ptr<kp::Manager>>(m, "Manager", DOC(kp, Manager))
|
||||
.def(py::init(), DOC(kp, Manager, Manager))
|
||||
.def(py::init<uint32_t>(), DOC(kp, Manager, Manager_2))
|
||||
.def(py::init<uint32_t,const std::vector<uint32_t>&,const std::vector<std::string>&>(),
|
||||
DOC(kp, Manager, Manager_2),
|
||||
py::arg("device") = 0,
|
||||
py::arg("family_queue_indices") = std::vector<uint32_t>(),
|
||||
py::arg("desired_extensions") = std::vector<std::string>())
|
||||
.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<float>& data,
|
||||
kp::Tensor::TensorTypes tensor_type) {
|
||||
const py::array_t<float>& 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<std::float_t>()) {
|
||||
return self.tensor(
|
||||
info.ptr, flatdata.size(), sizeof(float), kp::Tensor::TensorDataTypes::eFloat, tensor_type);
|
||||
} else if (flatdata.dtype() == py::dtype::of<std::uint32_t>()) {
|
||||
return self.tensor(
|
||||
info.ptr, flatdata.size(), sizeof(uint32_t), kp::Tensor::TensorDataTypes::eUnsignedInt, tensor_type);
|
||||
} else if (flatdata.dtype() == py::dtype::of<std::int32_t>()) {
|
||||
return self.tensor(
|
||||
info.ptr, flatdata.size(), sizeof(int32_t), kp::Tensor::TensorDataTypes::eInt, tensor_type);
|
||||
} else if (flatdata.dtype() == py::dtype::of<std::double_t>()) {
|
||||
return self.tensor(
|
||||
info.ptr, flatdata.size(), sizeof(double), kp::Tensor::TensorDataTypes::eDouble, tensor_type);
|
||||
} else if (flatdata.dtype() == py::dtype::of<bool>()) {
|
||||
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");
|
||||
py::class_<kp::Manager, std::shared_ptr<kp::Manager>>(
|
||||
m, "Manager", DOC(kp, Manager))
|
||||
.def(py::init(), DOC(kp, Manager, Manager))
|
||||
.def(py::init<uint32_t>(), DOC(kp, Manager, Manager_2))
|
||||
.def(py::init<uint32_t,
|
||||
const std::vector<uint32_t>&,
|
||||
const std::vector<std::string>&>(),
|
||||
DOC(kp, Manager, Manager_2),
|
||||
py::arg("device") = 0,
|
||||
py::arg("family_queue_indices") = std::vector<uint32_t>(),
|
||||
py::arg("desired_extensions") = std::vector<std::string>())
|
||||
.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<float>& data,
|
||||
kp::Tensor::TensorTypes tensor_type) {
|
||||
const py::array_t<float>& 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().is(py::dtype::of<std::float_t>())) {
|
||||
return self.tensor(info.ptr,
|
||||
flatdata.size(),
|
||||
sizeof(float),
|
||||
kp::Tensor::TensorDataTypes::eFloat,
|
||||
tensor_type);
|
||||
} else if (flatdata.dtype().is(py::dtype::of<std::uint32_t>())) {
|
||||
return self.tensor(info.ptr,
|
||||
flatdata.size(),
|
||||
sizeof(uint32_t),
|
||||
kp::Tensor::TensorDataTypes::eUnsignedInt,
|
||||
tensor_type);
|
||||
} else if (flatdata.dtype().is(py::dtype::of<std::int32_t>())) {
|
||||
return self.tensor(info.ptr,
|
||||
flatdata.size(),
|
||||
sizeof(int32_t),
|
||||
kp::Tensor::TensorDataTypes::eInt,
|
||||
tensor_type);
|
||||
} else if (flatdata.dtype().is(py::dtype::of<std::double_t>())) {
|
||||
return self.tensor(info.ptr,
|
||||
flatdata.size(),
|
||||
sizeof(double),
|
||||
kp::Tensor::TensorDataTypes::eDouble,
|
||||
tensor_type);
|
||||
} else if (flatdata.dtype().is(py::dtype::of<bool>())) {
|
||||
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<std::shared_ptr<kp::Tensor>>& tensors,
|
||||
const py::bytes& spirv,
|
||||
const kp::Workgroup& workgroup,
|
||||
const std::vector<float>& spec_consts,
|
||||
const std::vector<float>& push_consts) {
|
||||
py::buffer_info info(py::buffer(spirv).request());
|
||||
const char* data = reinterpret_cast<const char*>(info.ptr);
|
||||
size_t length = static_cast<size_t>(info.size);
|
||||
std::vector<uint32_t> 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<float>(),
|
||||
py::arg("push_consts") = std::vector<float>())
|
||||
.def(
|
||||
"algorithm",
|
||||
[np](kp::Manager& self,
|
||||
const std::vector<std::shared_ptr<kp::Tensor>>& 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<const char*>(info.ptr);
|
||||
size_t length = static_cast<size_t>(info.size);
|
||||
std::vector<uint32_t> spirvVec((uint32_t*)data,
|
||||
(uint32_t*)(data + length));
|
||||
|
||||
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())));
|
||||
|
||||
// We have to iterate across a combination of parameters due to the
|
||||
// lack of support for templating
|
||||
if (spec_consts.dtype().is(py::dtype::of<std::float_t>())) {
|
||||
std::vector<float> specConstsVec(
|
||||
(float*)specInfo.ptr, ((float*)specInfo.ptr) + specInfo.size);
|
||||
if (spec_consts.dtype().is(py::dtype::of<std::float_t>())) {
|
||||
std::vector<float> pushConstsVec((float*)pushInfo.ptr,
|
||||
((float*)pushInfo.ptr) +
|
||||
pushInfo.size);
|
||||
return self.algorithm(tensors,
|
||||
spirvVec,
|
||||
workgroup,
|
||||
specConstsVec,
|
||||
pushConstsVec);
|
||||
} else if (spec_consts.dtype().is(
|
||||
py::dtype::of<std::int32_t>())) {
|
||||
std::vector<int32_t> pushConstsVec(
|
||||
(int32_t*)pushInfo.ptr,
|
||||
((int32_t*)pushInfo.ptr) + pushInfo.size);
|
||||
return self.algorithm(tensors,
|
||||
spirvVec,
|
||||
workgroup,
|
||||
specConstsVec,
|
||||
pushConstsVec);
|
||||
} else if (spec_consts.dtype().is(
|
||||
py::dtype::of<std::uint32_t>())) {
|
||||
std::vector<uint32_t> pushConstsVec(
|
||||
(uint32_t*)pushInfo.ptr,
|
||||
((uint32_t*)pushInfo.ptr) + pushInfo.size);
|
||||
return self.algorithm(tensors,
|
||||
spirvVec,
|
||||
workgroup,
|
||||
specConstsVec,
|
||||
pushConstsVec);
|
||||
} else if (spec_consts.dtype().is(
|
||||
py::dtype::of<std::double_t>())) {
|
||||
std::vector<double> pushConstsVec((double*)pushInfo.ptr,
|
||||
((double*)pushInfo.ptr) +
|
||||
pushInfo.size);
|
||||
return self.algorithm(tensors,
|
||||
spirvVec,
|
||||
workgroup,
|
||||
specConstsVec,
|
||||
pushConstsVec);
|
||||
}
|
||||
},
|
||||
DOC(kp, Manager, tensorT),
|
||||
py::arg("data"), py::arg("tensor_type") = kp::Tensor::TensorTypes::eDevice)
|
||||
.def("algorithm", [](kp::Manager& self,
|
||||
const std::vector<std::shared_ptr<kp::Tensor>>& tensors,
|
||||
const py::bytes& spirv,
|
||||
const kp::Workgroup& workgroup,
|
||||
const std::vector<float>& spec_consts,
|
||||
const std::vector<float>& push_consts) {
|
||||
py::buffer_info info(py::buffer(spirv).request());
|
||||
const char *data = reinterpret_cast<const char *>(info.ptr);
|
||||
size_t length = static_cast<size_t>(info.size);
|
||||
std::vector<uint32_t> 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<float>(),
|
||||
py::arg("push_consts") = std::vector<float>())
|
||||
.def("algorithm", [np](kp::Manager& self,
|
||||
const std::vector<std::shared_ptr<kp::Tensor>>& 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<const char *>(info.ptr);
|
||||
size_t length = static_cast<size_t>(info.size);
|
||||
std::vector<uint32_t> spirvVec((uint32_t*)data, (uint32_t*)(data + length));
|
||||
|
||||
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())));
|
||||
|
||||
// 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::float_t>()) {
|
||||
std::vector<float> specConstsVec((float*)specInfo.ptr, ((float*)specInfo.ptr) + specInfo.size);
|
||||
if (spec_consts.dtype() == py::dtype::of<std::float_t>()) {
|
||||
std::vector<float> 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::int32_t>()) {
|
||||
std::vector<int32_t> 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::uint32_t>()) {
|
||||
std::vector<uint32_t> 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::double_t>()) {
|
||||
std::vector<double> 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::int32_t>()) {
|
||||
std::vector<int32_t> specconstsvec((int32_t*)specInfo.ptr, ((int32_t*)specInfo.ptr) + specInfo.size);
|
||||
if (spec_consts.dtype() == py::dtype::of<std::float_t>()) {
|
||||
std::vector<float> 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::int32_t>()) {
|
||||
std::vector<int32_t> 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::uint32_t>()) {
|
||||
std::vector<uint32_t> 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::double_t>()) {
|
||||
std::vector<double> 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::uint32_t>()) {
|
||||
std::vector<uint32_t> specconstsvec((uint32_t*)specInfo.ptr, ((uint32_t*)specInfo.ptr) + specInfo.size);
|
||||
if (spec_consts.dtype() == py::dtype::of<std::float_t>()) {
|
||||
std::vector<float> 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::int32_t>()) {
|
||||
std::vector<int32_t> 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::uint32_t>()) {
|
||||
std::vector<uint32_t> 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::double_t>()) {
|
||||
std::vector<double> 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::double_t>()) {
|
||||
std::vector<double> specconstsvec((double*)specInfo.ptr, ((double*)specInfo.ptr) + specInfo.size);
|
||||
if (spec_consts.dtype() == py::dtype::of<std::float_t>()) {
|
||||
std::vector<float> 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::int32_t>()) {
|
||||
std::vector<float> 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::uint32_t>()) {
|
||||
std::vector<float> 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::double_t>()) {
|
||||
std::vector<float> 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");
|
||||
} else if (spec_consts.dtype().is(py::dtype::of<std::int32_t>())) {
|
||||
std::vector<int32_t> specconstsvec((int32_t*)specInfo.ptr,
|
||||
((int32_t*)specInfo.ptr) +
|
||||
specInfo.size);
|
||||
if (spec_consts.dtype().is(py::dtype::of<std::float_t>())) {
|
||||
std::vector<float> pushconstsvec((float*)pushInfo.ptr,
|
||||
((float*)pushInfo.ptr) +
|
||||
pushInfo.size);
|
||||
return self.algorithm(tensors,
|
||||
spirvVec,
|
||||
workgroup,
|
||||
specconstsvec,
|
||||
pushconstsvec);
|
||||
} else if (spec_consts.dtype().is(
|
||||
py::dtype::of<std::int32_t>())) {
|
||||
std::vector<int32_t> pushconstsvec(
|
||||
(int32_t*)pushInfo.ptr,
|
||||
((int32_t*)pushInfo.ptr) + pushInfo.size);
|
||||
return self.algorithm(tensors,
|
||||
spirvVec,
|
||||
workgroup,
|
||||
specconstsvec,
|
||||
pushconstsvec);
|
||||
} else if (spec_consts.dtype().is(
|
||||
py::dtype::of<std::uint32_t>())) {
|
||||
std::vector<uint32_t> pushconstsvec(
|
||||
(uint32_t*)pushInfo.ptr,
|
||||
((uint32_t*)pushInfo.ptr) + pushInfo.size);
|
||||
return self.algorithm(tensors,
|
||||
spirvVec,
|
||||
workgroup,
|
||||
specconstsvec,
|
||||
pushconstsvec);
|
||||
} else if (spec_consts.dtype().is(
|
||||
py::dtype::of<std::double_t>())) {
|
||||
std::vector<double> 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<float>(),
|
||||
py::arg("push_consts") = std::vector<float>())
|
||||
.def("list_devices", [](kp::Manager& self){
|
||||
} else if (spec_consts.dtype().is(py::dtype::of<std::uint32_t>())) {
|
||||
std::vector<uint32_t> specconstsvec((uint32_t*)specInfo.ptr,
|
||||
((uint32_t*)specInfo.ptr) +
|
||||
specInfo.size);
|
||||
if (spec_consts.dtype().is(py::dtype::of<std::float_t>())) {
|
||||
std::vector<float> pushconstsvec((float*)pushInfo.ptr,
|
||||
((float*)pushInfo.ptr) +
|
||||
pushInfo.size);
|
||||
return self.algorithm(tensors,
|
||||
spirvVec,
|
||||
workgroup,
|
||||
specconstsvec,
|
||||
pushconstsvec);
|
||||
} else if (spec_consts.dtype().is(
|
||||
py::dtype::of<std::int32_t>())) {
|
||||
std::vector<int32_t> pushconstsvec(
|
||||
(int32_t*)pushInfo.ptr,
|
||||
((int32_t*)pushInfo.ptr) + pushInfo.size);
|
||||
return self.algorithm(tensors,
|
||||
spirvVec,
|
||||
workgroup,
|
||||
specconstsvec,
|
||||
pushconstsvec);
|
||||
} else if (spec_consts.dtype().is(
|
||||
py::dtype::of<std::uint32_t>())) {
|
||||
std::vector<uint32_t> pushconstsvec(
|
||||
(uint32_t*)pushInfo.ptr,
|
||||
((uint32_t*)pushInfo.ptr) + pushInfo.size);
|
||||
return self.algorithm(tensors,
|
||||
spirvVec,
|
||||
workgroup,
|
||||
specconstsvec,
|
||||
pushconstsvec);
|
||||
} else if (spec_consts.dtype().is(
|
||||
py::dtype::of<std::double_t>())) {
|
||||
std::vector<double> pushconstsvec((double*)pushInfo.ptr,
|
||||
((double*)pushInfo.ptr) +
|
||||
pushInfo.size);
|
||||
return self.algorithm(tensors,
|
||||
spirvVec,
|
||||
workgroup,
|
||||
specconstsvec,
|
||||
pushconstsvec);
|
||||
}
|
||||
} else if (spec_consts.dtype().is(py::dtype::of<std::double_t>())) {
|
||||
std::vector<double> specconstsvec((double*)specInfo.ptr,
|
||||
((double*)specInfo.ptr) +
|
||||
specInfo.size);
|
||||
if (spec_consts.dtype().is(py::dtype::of<std::float_t>())) {
|
||||
std::vector<float> pushconstsvec((float*)pushInfo.ptr,
|
||||
((float*)pushInfo.ptr) +
|
||||
pushInfo.size);
|
||||
return self.algorithm(tensors,
|
||||
spirvVec,
|
||||
workgroup,
|
||||
specconstsvec,
|
||||
pushconstsvec);
|
||||
} else if (spec_consts.dtype().is(
|
||||
py::dtype::of<std::int32_t>())) {
|
||||
std::vector<float> pushconstsvec((int32_t*)pushInfo.ptr,
|
||||
((int32_t*)pushInfo.ptr) +
|
||||
pushInfo.size);
|
||||
return self.algorithm(tensors,
|
||||
spirvVec,
|
||||
workgroup,
|
||||
specconstsvec,
|
||||
pushconstsvec);
|
||||
} else if (spec_consts.dtype().is(
|
||||
py::dtype::of<std::uint32_t>())) {
|
||||
std::vector<float> pushconstsvec((uint32_t*)pushInfo.ptr,
|
||||
((uint32_t*)pushInfo.ptr) +
|
||||
pushInfo.size);
|
||||
return self.algorithm(tensors,
|
||||
spirvVec,
|
||||
workgroup,
|
||||
specconstsvec,
|
||||
pushconstsvec);
|
||||
} else if (spec_consts.dtype().is(
|
||||
py::dtype::of<std::double_t>())) {
|
||||
std::vector<float> pushconstsvec((double*)pushInfo.ptr,
|
||||
((double*)pushInfo.ptr) +
|
||||
pushInfo.size);
|
||||
return self.algorithm(tensors,
|
||||
spirvVec,
|
||||
workgroup,
|
||||
specconstsvec,
|
||||
pushconstsvec);
|
||||
}
|
||||
}
|
||||
// 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<float>(),
|
||||
py::arg("push_consts") = std::vector<float>())
|
||||
.def(
|
||||
"list_devices",
|
||||
[](kp::Manager& self) {
|
||||
const std::vector<vk::PhysicalDevice> 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_trace = py::none();
|
||||
kp_debug = py::none();
|
||||
kp_info = py::none();
|
||||
kp_warning = py::none();
|
||||
|
|
@ -340,4 +565,3 @@ PYBIND11_MODULE(kp, m) {
|
|||
m.attr("__version__") = "dev";
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,24 +1,30 @@
|
|||
|
||||
#include <kompute/Kompute.hpp>
|
||||
#include <pybind11/pybind11.h>
|
||||
#include <vulkan/vulkan.hpp>
|
||||
|
||||
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)
|
||||
{
|
||||
std::string deviceName = properties.deviceName;
|
||||
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 = deviceName,
|
||||
"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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
pyshader==0.7.0
|
||||
numpy==1.19.5
|
||||
pytest==6.2.1
|
||||
numpy==1.22.4
|
||||
pytest==7.1.2
|
||||
|
||||
|
|
|
|||
26
setup.py
26
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,9 +41,10 @@ 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_REPO_SUBMODULE_BUILD=1',
|
||||
'-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'),
|
||||
'-DPYTHON_LIBRARY=' + sysconfig.get_path('stdlib'),
|
||||
|
|
@ -52,20 +53,23 @@ 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']
|
||||
# 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']
|
||||
|
||||
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)
|
||||
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
|
|
@ -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"
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,169 +1,80 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
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
|
||||
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
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"
|
||||
)
|
||||
|
||||
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()
|
||||
|
||||
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
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/single_include>
|
||||
)
|
||||
|
||||
if(NOT KOMPUTE_OPT_ANDROID_BUILD)
|
||||
target_link_libraries(
|
||||
kompute
|
||||
Vulkan::Vulkan
|
||||
)
|
||||
else()
|
||||
target_link_libraries(
|
||||
kompute
|
||||
)
|
||||
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
|
||||
$<BUILD_INTERFACE:${VULKAN_HEADERS_INCLUDES}>)
|
||||
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 #######################
|
||||
#####################################################
|
||||
|
||||
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
|
||||
)
|
||||
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()
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
add_library(kompute Algorithm.cpp
|
||||
Manager.cpp
|
||||
OpAlgoDispatch.cpp
|
||||
OpMemoryBarrier.cpp
|
||||
OpTensorCopy.cpp
|
||||
OpTensorSyncDevice.cpp
|
||||
OpTensorSyncLocal.cpp
|
||||
Sequence.cpp
|
||||
Tensor.cpp
|
||||
Core.cpp)
|
||||
|
||||
add_library(kompute::kompute ALIAS kompute)
|
||||
|
||||
if(KOMPUTE_OPT_INSTALL)
|
||||
install(TARGETS kompute EXPORT KomputeTargets
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib
|
||||
INCLUDES DESTINATION include)
|
||||
# Set version for shared libraries.
|
||||
set_target_properties(kompute
|
||||
PROPERTIES
|
||||
VERSION ${${PROJECT_NAME}_VERSION}
|
||||
SOVERSION ${${PROJECT_NAME}_VERSION_MAJOR})
|
||||
|
||||
target_include_directories(kompute PUBLIC $<INSTALL_INTERFACE:include>)
|
||||
# Import GNU common install directory variables
|
||||
include(GNUInstallDirs)
|
||||
|
||||
install(DIRECTORY include/ DESTINATION include)
|
||||
install(TARGETS kompute
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
|
||||
install(DIRECTORY ${PROJECT_SOURCE_DIR}/single_include/
|
||||
DESTINATION include)
|
||||
# Include CMake helpers for package config files
|
||||
# Follow this installation guideline: https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
install(EXPORT KomputeTargets
|
||||
FILE komputeConfig.cmake
|
||||
NAMESPACE kompute::
|
||||
DESTINATION lib/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(FILES ${PROJECT_BINARY_DIR}/kompute/komputeConfig.cmake
|
||||
${PROJECT_BINARY_DIR}/kompute/komputeConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kompute)
|
||||
|
||||
# ####################################################
|
||||
# Linking
|
||||
# ####################################################
|
||||
if(KOMPUTE_OPT_ANDROID_BUILD)
|
||||
target_link_libraries(kompute PUBLIC vulkanAndroid
|
||||
android
|
||||
kp_logger
|
||||
kp_shader
|
||||
fmt::fmt)
|
||||
else()
|
||||
target_link_libraries(kompute PUBLIC Vulkan::Vulkan
|
||||
kp_logger
|
||||
kp_shader
|
||||
fmt::fmt)
|
||||
endif()
|
||||
|
||||
if(KOMPUTE_OPT_BUILD_PYTHON)
|
||||
include_directories(${PROJECT_SOURCE_DIR}/python/pybind11/include)
|
||||
find_package(PythonLibs REQUIRED)
|
||||
include_directories(${PYTHON_INCLUDE_DIRS})
|
||||
|
||||
target_link_libraries(kompute PRIVATE pybind11::headers ${PYTHON_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(KOMPUTE_OPT_USE_BUILT_IN_VULKAN_HEADER)
|
||||
target_link_libraries(kompute PUBLIC Vulkan-Headers)
|
||||
endif()
|
||||
|
||||
# ####################################################
|
||||
# Misc
|
||||
# ####################################################
|
||||
add_subdirectory(logger)
|
||||
add_subdirectory(shaders)
|
||||
add_subdirectory(include)
|
||||
|
|
|
|||
19
src/Core.cpp
Normal file
19
src/Core.cpp
Normal file
|
|
@ -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
|
||||
|
|
@ -1,33 +1,36 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#include "kompute/Manager.hpp"
|
||||
#include "fmt/format.h"
|
||||
#include "kompute/logger/Logger.hpp"
|
||||
#include <fmt/core.h>
|
||||
#include <iterator>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "kompute/Manager.hpp"
|
||||
|
||||
#include "fmt/ranges.h"
|
||||
|
||||
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*/,
|
||||
#if KOMPUTE_OPT_ACTIVE_LOG_LEVEL <= KOMPUTE_LOG_LEVEL_DEBUG
|
||||
const char* pLayerPrefix,
|
||||
const char* pMessage,
|
||||
void* pUserData)
|
||||
#else
|
||||
const char* /*pLayerPrefix*/,
|
||||
const char* /*pMessage*/,
|
||||
#endif
|
||||
void* /*pUserData*/)
|
||||
{
|
||||
KP_LOG_DEBUG("[VALIDATION]: {} - {}", pLayerPrefix, pMessage);
|
||||
return VK_FALSE;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Manager::Manager()
|
||||
: Manager(0)
|
||||
|
|
@ -40,6 +43,11 @@ Manager::Manager(uint32_t physicalDeviceIndex,
|
|||
{
|
||||
this->mManageResources = true;
|
||||
|
||||
// Make sure the logger is setup
|
||||
#if !KOMPUTE_OPT_LOG_LEVEL_DISABLED
|
||||
logger::setupLogger();
|
||||
#endif
|
||||
|
||||
this->createInstance();
|
||||
this->createDevice(
|
||||
familyQueueIndices, physicalDeviceIndex, desiredExtensions);
|
||||
|
|
@ -54,6 +62,11 @@ Manager::Manager(std::shared_ptr<vk::Instance> instance,
|
|||
this->mInstance = instance;
|
||||
this->mPhysicalDevice = physicalDevice;
|
||||
this->mDevice = device;
|
||||
|
||||
// Make sure the logger is setup
|
||||
#if !KOMPUTE_OPT_LOG_LEVEL_DISABLED
|
||||
logger::setupLogger();
|
||||
#endif
|
||||
}
|
||||
|
||||
Manager::~Manager()
|
||||
|
|
@ -120,14 +133,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) {
|
||||
|
|
@ -155,7 +166,7 @@ Manager::createInstance()
|
|||
|
||||
std::vector<const char*> applicationExtensions;
|
||||
|
||||
#if DEBUG
|
||||
#ifndef KOMPUTE_DISABLE_VK_DEBUG_LAYERS
|
||||
applicationExtensions.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
|
||||
#endif
|
||||
|
||||
|
|
@ -168,7 +179,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
|
||||
|
|
@ -180,16 +190,17 @@ Manager::createInstance()
|
|||
};
|
||||
std::vector<std::string> 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<std::string> beg(iss), end;
|
||||
std::istream_iterator<std::string> beg(iss);
|
||||
std::istream_iterator<std::string> end;
|
||||
envLayerNames = std::vector<std::string>(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
|
||||
|
|
@ -201,7 +212,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);
|
||||
|
|
@ -209,26 +220,36 @@ 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<uint32_t>(validLayerNames.size());
|
||||
computeInstanceCreateInfo.ppEnabledLayerNames = validLayerNames.data();
|
||||
} else {
|
||||
KP_LOG_WARN("Kompute Manager no valid layer names found from desired "
|
||||
"layer names");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if VK_USE_PLATFORM_ANDROID_KHR
|
||||
vk::DynamicLoader dl;
|
||||
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr =
|
||||
dl.getProcAddress<PFN_vkGetInstanceProcAddr>("vkGetInstanceProcAddr");
|
||||
VULKAN_HPP_DEFAULT_DISPATCHER.init(vkGetInstanceProcAddr);
|
||||
#endif // VK_USE_PLATFORM_ANDROID_KHR
|
||||
|
||||
this->mInstance = std::make_shared<vk::Instance>();
|
||||
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");
|
||||
|
||||
#if DEBUG
|
||||
#ifndef KOMPUTE_DISABLE_VK_DEBUG_LAYERS
|
||||
KP_LOG_DEBUG("Kompute Manager adding debug callbacks");
|
||||
if (validLayerNames.size() > 0) {
|
||||
|
|
@ -246,7 +267,6 @@ Manager::createInstance()
|
|||
debugCreateInfo, nullptr, this->mDebugDispatcher);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -311,8 +331,10 @@ Manager::createDevice(const std::vector<uint32_t>& familyQueueIndices,
|
|||
this->mPhysicalDevice =
|
||||
std::make_shared<vk::PhysicalDevice>(physicalDevice);
|
||||
|
||||
#if KOMPUTE_OPT_ACTIVE_LOG_LEVEL <= KOMPUTE_LOG_LEVEL_INFO
|
||||
vk::PhysicalDeviceProperties physicalDeviceProperties =
|
||||
physicalDevice.getProperties();
|
||||
#endif
|
||||
|
||||
KP_LOG_INFO("Using physical device index {} found {}",
|
||||
physicalDeviceIndex,
|
||||
|
|
@ -369,7 +391,7 @@ Manager::createDevice(const std::vector<uint32_t>& familyQueueIndices,
|
|||
}
|
||||
|
||||
KP_LOG_DEBUG("Kompute Manager desired extension layers {}",
|
||||
desiredExtensions);
|
||||
fmt::join(desiredExtensions, ", "));
|
||||
|
||||
std::vector<vk::ExtensionProperties> deviceExtensions =
|
||||
this->mPhysicalDevice->enumerateDeviceExtensionProperties();
|
||||
|
|
@ -379,7 +401,7 @@ Manager::createDevice(const std::vector<uint32_t>& familyQueueIndices,
|
|||
uniqueExtensionNames.insert(ext.extensionName);
|
||||
}
|
||||
KP_LOG_DEBUG("Kompute Manager available extensions {}",
|
||||
uniqueExtensionNames);
|
||||
fmt::join(uniqueExtensionNames, ", "));
|
||||
std::vector<const char*> validExtensions;
|
||||
for (const std::string& ext : desiredExtensions) {
|
||||
if (uniqueExtensionNames.count(ext) != 0) {
|
||||
|
|
@ -388,7 +410,7 @@ Manager::createDevice(const std::vector<uint32_t>& familyQueueIndices,
|
|||
}
|
||||
if (desiredExtensions.size() != validExtensions.size()) {
|
||||
KP_LOG_ERROR("Kompute Manager not all extensions were added: {}",
|
||||
validExtensions);
|
||||
fmt::join(validExtensions, ", "));
|
||||
}
|
||||
|
||||
vk::DeviceCreateInfo deviceCreateInfo(vk::DeviceCreateFlags(),
|
||||
|
|
|
|||
|
|
@ -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<std::shared_ptr<Tensor>>& 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(
|
||||
|
|
|
|||
|
|
@ -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<vk::PhysicalDevice> physicalDevice,
|
||||
std::shared_ptr<vk::Device> device,
|
||||
void* data,
|
||||
|
|
@ -14,7 +48,7 @@ Tensor::Tensor(std::shared_ptr<vk::PhysicalDevice> 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<vk::PhysicalDevice> physicalDevice,
|
|||
Tensor::~Tensor()
|
||||
{
|
||||
KP_LOG_DEBUG("Kompute Tensor destructor started. Type: {}",
|
||||
this->tensorType());
|
||||
Tensor::toString(this->tensorType()));
|
||||
|
||||
if (this->mDevice) {
|
||||
this->destroy();
|
||||
|
|
|
|||
44
src/include/CMakeLists.txt
Normal file
44
src/include/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# ####################################################
|
||||
# Kompute
|
||||
# ####################################################
|
||||
target_include_directories(kompute PUBLIC $<INSTALL_INTERFACE:include>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
|
||||
|
||||
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/logger/Logger.hpp
|
||||
)
|
||||
|
||||
install(DIRECTORY kompute DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
|
||||
# ####################################################
|
||||
# Logger
|
||||
# ####################################################
|
||||
target_include_directories(kp_logger PUBLIC $<INSTALL_INTERFACE:include>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
|
||||
|
||||
target_sources(kp_logger PRIVATE
|
||||
|
||||
# Header files (useful in IDEs)
|
||||
kompute/logger/Logger.hpp
|
||||
)
|
||||
|
||||
install(DIRECTORY logger DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
|
|
@ -3,7 +3,9 @@
|
|||
|
||||
#include "kompute/Core.hpp"
|
||||
|
||||
#include "fmt/format.h"
|
||||
#include "kompute/Tensor.hpp"
|
||||
#include "logger/Logger.hpp"
|
||||
|
||||
namespace kp {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,6 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
#pragma once
|
||||
|
||||
#if VK_USE_PLATFORM_ANDROID_KHR
|
||||
#include <android/log.h>
|
||||
#include <kompute_vk_ndk_wrapper.hpp>
|
||||
// VK_NO_PROTOTYPES required before vulkan import but after wrapper.hpp
|
||||
#undef VK_NO_PROTOTYPES
|
||||
static const char* KOMPUTE_LOG_TAG = "KomputeLog";
|
||||
#endif
|
||||
|
||||
#include <fmt/core.h>
|
||||
|
||||
#include <vulkan/vulkan.hpp>
|
||||
|
||||
// Typedefs to simplify interaction with core types
|
||||
|
|
@ -32,124 +22,9 @@ typedef std::vector<float> 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 <pybind11/pybind11.h>
|
||||
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
|
||||
|
||||
#ifndef KOMPUTE_LOG_OVERRIDE
|
||||
#if KOMPUTE_ENABLE_SPDLOG
|
||||
#include <spdlog/spdlog.h>
|
||||
#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 <iostream>
|
||||
#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
|
||||
|
|
|
|||
19
src/include/kompute/Kompute.hpp
Normal file
19
src/include/kompute/Kompute.hpp
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#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"
|
||||
|
||||
// Will be build by CMake and placed inside the build directory
|
||||
#include "ShaderLogisticRegression.hpp"
|
||||
#include "ShaderOpMult.hpp"
|
||||
|
|
@ -7,6 +7,7 @@
|
|||
#include "kompute/Core.hpp"
|
||||
|
||||
#include "kompute/Sequence.hpp"
|
||||
#include "logger/Logger.hpp"
|
||||
|
||||
#define KP_DEFAULT_SESSION "DEFAULT"
|
||||
|
||||
|
|
@ -240,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
|
||||
|
|
|
|||
|
|
@ -231,7 +231,7 @@ class Sequence : public std::enable_shared_from_this<Sequence>
|
|||
*
|
||||
* @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
|
||||
|
|
@ -239,7 +239,7 @@ class Sequence : public std::enable_shared_from_this<Sequence>
|
|||
*
|
||||
* @return Boolean stating if is initialized
|
||||
*/
|
||||
[[nodiscard]] bool isInit() const;
|
||||
bool isInit() const;
|
||||
|
||||
/**
|
||||
* Clears command buffer and triggers re-record of all the current
|
||||
|
|
@ -254,7 +254,7 @@ class Sequence : public std::enable_shared_from_this<Sequence>
|
|||
*
|
||||
* @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
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "kompute/Core.hpp"
|
||||
#include <fmt/format.h>
|
||||
#include "logger/Logger.hpp"
|
||||
#include <string>
|
||||
|
||||
namespace kp {
|
||||
|
|
@ -39,6 +39,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 +344,3 @@ class TensorT : public Tensor
|
|||
};
|
||||
|
||||
} // End namespace kp
|
||||
|
||||
/**
|
||||
* fmt fromater for kp::Tensor::TensorDataTypes.
|
||||
*/
|
||||
template<>
|
||||
struct fmt::formatter<kp::Tensor::TensorDataTypes> : formatter<std::string>
|
||||
{
|
||||
template<typename FormatContext>
|
||||
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<std::string>::format(name, ctx);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* fmt fromater for kp::Tensor::TensorTypes.
|
||||
*/
|
||||
template<>
|
||||
struct fmt::formatter<kp::Tensor::TensorTypes> : formatter<std::string>
|
||||
{
|
||||
template<typename FormatContext>
|
||||
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<std::string>::format(name, ctx);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
187
src/include/kompute/logger/Logger.hpp
Normal file
187
src/include/kompute/logger/Logger.hpp
Normal file
|
|
@ -0,0 +1,187 @@
|
|||
#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(...)
|
||||
#define KP_LOG_INFO(...)
|
||||
#define KP_LOG_WARN(...)
|
||||
#define KP_LOG_ERROR(...)
|
||||
#else
|
||||
|
||||
#if !KOMPUTE_OPT_USE_SPDLOG
|
||||
#if VK_USE_PLATFORM_ANDROID_KHR
|
||||
#include <android/log.h>
|
||||
#include <fmt/core.h>
|
||||
static const char* KOMPUTE_LOG_TAG = "KomputeLog";
|
||||
#else
|
||||
#if KOMPUTE_BUILD_PYTHON
|
||||
#include <pybind11/pybind11.h>
|
||||
namespace py = pybind11;
|
||||
// from python/src/main.cpp
|
||||
extern py::object kp_trace, kp_debug, kp_info, kp_warning, kp_error;
|
||||
#else
|
||||
#include <fmt/core.h>
|
||||
#endif // KOMPUTE_BUILD_PYTHON
|
||||
#endif // VK_USE_PLATFORM_ANDROID_KHR
|
||||
#else
|
||||
#include <spdlog/spdlog.h>
|
||||
#endif // !KOMPUTE_OPT_USE_SPDLOG
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
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_ACTIVE_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__, \
|
||||
__TIME__, \
|
||||
__FILE__, \
|
||||
__LINE__, \
|
||||
fmt::format(__VA_ARGS__))
|
||||
#endif // KOMPUTE_BUILD_PYTHON
|
||||
#endif // VK_USE_PLATFORM_ANDROID_KHR
|
||||
#else
|
||||
#define KP_LOG_TRACE(...)
|
||||
#endif
|
||||
#endif // !KP_LOG_TRACE
|
||||
|
||||
#ifndef KP_LOG_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( \
|
||||
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__, \
|
||||
__TIME__, \
|
||||
__FILE__, \
|
||||
__LINE__, \
|
||||
fmt::format(__VA_ARGS__))
|
||||
#endif // KOMPUTE_BUILD_PYTHON
|
||||
#endif // VK_USE_PLATFORM_ANDROID_KHR
|
||||
#else
|
||||
#define KP_LOG_DEBUG(...)
|
||||
#endif
|
||||
#endif // !KP_LOG_DEBUG
|
||||
|
||||
#ifndef KP_LOG_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( \
|
||||
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__, \
|
||||
__TIME__, \
|
||||
__FILE__, \
|
||||
__LINE__, \
|
||||
fmt::format(__VA_ARGS__))
|
||||
#endif // KOMPUTE_BUILD_PYTHON
|
||||
#endif // VK_USE_PLATFORM_ANDROID_KHR
|
||||
#else
|
||||
#define KP_LOG_INFO(...)
|
||||
#endif
|
||||
#endif // !KP_LOG_INFO
|
||||
|
||||
#ifndef KP_LOG_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( \
|
||||
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__, \
|
||||
__TIME__, \
|
||||
__FILE__, \
|
||||
__LINE__, \
|
||||
fmt::format(__VA_ARGS__))
|
||||
#endif // KOMPUTE_BUILD_PYTHON
|
||||
#endif // VK_USE_PLATFORM_ANDROID_KHR
|
||||
#else
|
||||
#define KP_LOG_WARN(...)
|
||||
#endif
|
||||
#endif // !KP_LOG_WARN
|
||||
|
||||
#ifndef KP_LOG_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( \
|
||||
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__, \
|
||||
__TIME__, \
|
||||
__FILE__, \
|
||||
__LINE__, \
|
||||
fmt::format(__VA_ARGS__))
|
||||
#endif // KOMPUTE_BUILD_PYTHON
|
||||
#endif // VK_USE_PLATFORM_ANDROID_KHR
|
||||
#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__)
|
||||
#define KP_LOG_INFO(...) SPDLOG_INFO(__VA_ARGS__)
|
||||
#define KP_LOG_WARN(...) SPDLOG_WARN(__VA_ARGS__)
|
||||
#define KP_LOG_ERROR(...) SPDLOG_ERROR(__VA_ARGS__)
|
||||
|
||||
void
|
||||
setLogLevel(spdlog::level::level_enum level);
|
||||
|
||||
spdlog::level::level_enum
|
||||
getLogLevel();
|
||||
|
||||
#endif // !KOMPUTE_OPT_USE_SPDLOG
|
||||
} // namespace logger
|
||||
|
||||
#endif // KOMPUTE_OPT_LOG_LEVEL_DISABLED
|
||||
|
|
@ -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<uint32_t> 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<uint32_t> spirv = std::vector<uint32_t>(
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
63
src/logger/CMakeLists.txt
Normal file
63
src/logger/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
set(LOGGER_SOURCES Logger.cpp)
|
||||
|
||||
add_library(kp_logger ${LOGGER_SOURCES})
|
||||
|
||||
# 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_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")
|
||||
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")
|
||||
elseif(${KOMPUTE_OPT_LOG_LEVEL} STREQUAL "Default")
|
||||
set(KOMPUTE_OPT_LOG_LEVEL $<IF:$<CONFIG:Debug>,DEBUG,INFO>)
|
||||
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()
|
||||
|
||||
# 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)
|
||||
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()
|
||||
98
src/logger/Logger.cpp
Normal file
98
src/logger/Logger.cpp
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
#include "kompute/logger/Logger.hpp"
|
||||
|
||||
#if !KOMPUTE_OPT_LOG_LEVEL_DISABLED
|
||||
#if !KOMPUTE_OPT_USE_SPDLOG
|
||||
#else
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <spdlog/async.h>
|
||||
#include <spdlog/common.h>
|
||||
#include <spdlog/logger.h>
|
||||
#include <spdlog/sinks/stdout_color_sinks.h>
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <string>
|
||||
#endif // !KOMPUTE_OPT_USE_SPDLOG
|
||||
|
||||
namespace logger {
|
||||
#if !KOMPUTE_OPT_USE_SPDLOG
|
||||
|
||||
void
|
||||
setupLogger()
|
||||
{
|
||||
}
|
||||
|
||||
#else
|
||||
constexpr int THREAD_QUEUE_LENGTH = 8192;
|
||||
|
||||
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();
|
||||
|
||||
spdlog::init_thread_pool(THREAD_QUEUE_LENGTH, 1);
|
||||
spdlog::sink_ptr console_sink =
|
||||
std::make_shared<spdlog::sinks::stdout_color_sink_mt>();
|
||||
console_sink->set_pattern("[%H:%M:%S %z] [%=8l] [thread %t] [%@]\t%v");
|
||||
std::vector<spdlog::sink_ptr> sinks{ console_sink };
|
||||
std::shared_ptr<spdlog::logger> logger =
|
||||
std::make_shared<spdlog::async_logger>(
|
||||
"",
|
||||
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);
|
||||
}
|
||||
#endif // !KOMPUTE_OPT_USE_SPDLOG
|
||||
} // namespace logger
|
||||
|
||||
#endif
|
||||
5
src/shaders/CMakeLists.txt
Normal file
5
src/shaders/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
# ######################
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
add_subdirectory(glsl)
|
||||
26
src/shaders/glsl/CMakeLists.txt
Normal file
26
src/shaders/glsl/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
# ######################
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# 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 $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>/ShaderOpMult.hpp COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/ShaderOpMult.hpp.in $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>/ShaderOpMult.hpp)
|
||||
add_custom_command(OUTPUT $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>/ShaderLogisticRegression.hpp COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/ShaderLogisticRegression.hpp.in $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>/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 $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
|
||||
|
||||
# Make sure we install shaders:
|
||||
install(FILES $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>/ShaderOpMult.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
install(FILES $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>/ShaderLogisticRegression.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
310
src/shaders/glsl/ShaderLogisticRegression.hpp.in
Normal file
310
src/shaders/glsl/ShaderLogisticRegression.hpp.in
Normal file
|
|
@ -0,0 +1,310 @@
|
|||
#pragma once
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
|
||||
namespace kp {
|
||||
const std::array<uint32_t, 1204> 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
|
||||
|
||||
|
||||
101
src/shaders/glsl/ShaderOpMult.hpp.in
Normal file
101
src/shaders/glsl/ShaderOpMult.hpp.in
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
#pragma once
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
|
||||
namespace kp {
|
||||
const std::array<uint32_t, 366> 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
|
||||
|
||||
|
||||
|
|
@ -1,100 +1,41 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
# ######################
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
#####################################################
|
||||
#################### GETEST #######################
|
||||
#####################################################
|
||||
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)
|
||||
# ####################################################
|
||||
# Shaders
|
||||
# ####################################################
|
||||
add_subdirectory(shaders)
|
||||
|
||||
# ####################################################
|
||||
# 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)
|
||||
|
||||
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)
|
||||
|
||||
# Group under the "tests" project folder in IDEs such as Visual Studio.
|
||||
set_property(TARGET kompute_tests PROPERTY FOLDER "tests")
|
||||
|
||||
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 $<TARGET_FILE:test_shaders> $<TARGET_FILE_DIR:kompute_tests>)
|
||||
add_custom_command(TARGET kompute_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:kompute::kompute> $<TARGET_FILE_DIR:kompute_tests>)
|
||||
add_custom_command(TARGET kompute_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:spdlog> $<TARGET_FILE_DIR:kompute_tests>)
|
||||
add_custom_command(TARGET kompute_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:kp_logger> $<TARGET_FILE_DIR:kompute_tests>)
|
||||
endif()
|
||||
|
||||
file(GLOB test_kompute_CPP
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
|
||||
)
|
||||
|
||||
add_executable(test_kompute ${test_kompute_CPP})
|
||||
|
||||
target_include_directories(
|
||||
test_kompute PUBLIC
|
||||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/single_include>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/compiled_shaders_include>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/utils>
|
||||
)
|
||||
|
||||
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)
|
||||
|
||||
add_test(NAME test_kompute COMMAND test_kompute)
|
||||
|
||||
|
||||
#####################################################
|
||||
#################### CODECOV #######################
|
||||
#####################################################
|
||||
|
||||
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()
|
||||
|
||||
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()
|
||||
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
#include <chrono>
|
||||
|
||||
#include "kompute/Kompute.hpp"
|
||||
|
||||
#include "kompute_test/Shader.hpp"
|
||||
#include "kompute/logger/Logger.hpp"
|
||||
#include "shaders/Utils.hpp"
|
||||
|
||||
TEST(TestAsyncOperations, TestManagerParallelExecution)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,8 +3,9 @@
|
|||
#include "gtest/gtest.h"
|
||||
|
||||
#include "kompute/Kompute.hpp"
|
||||
#include "kompute/logger/Logger.hpp"
|
||||
|
||||
#include "kompute_test/Shader.hpp"
|
||||
#include "shaders/Utils.hpp"
|
||||
|
||||
TEST(TestDestroy, TestDestroyTensorSingle)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,8 +3,9 @@
|
|||
#include "gtest/gtest.h"
|
||||
|
||||
#include "kompute/Kompute.hpp"
|
||||
#include "kompute/logger/Logger.hpp"
|
||||
|
||||
#include "kompute_test/shaders/shadertest_logistic_regression.hpp"
|
||||
#include "test_logistic_regression_shader.hpp"
|
||||
|
||||
TEST(TestLogisticRegression, TestMainLogisticRegression)
|
||||
{
|
||||
|
|
@ -39,13 +40,11 @@ TEST(TestLogisticRegression, TestMainLogisticRegression)
|
|||
|
||||
mgr.sequence()->eval<kp::OpTensorSyncDevice>(params);
|
||||
|
||||
std::vector<uint32_t> spirv = std::vector<uint32_t>(
|
||||
(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));
|
||||
std::vector<uint32_t> spirv2{ 0x1, 0x2 };
|
||||
|
||||
std::vector<uint32_t> spirv(
|
||||
kp::TEST_LOGISTIC_REGRESSION_SHADER_COMP_SPV.begin(),
|
||||
kp::TEST_LOGISTIC_REGRESSION_SHADER_COMP_SPV.end());
|
||||
|
||||
std::shared_ptr<kp::Algorithm> algorithm = mgr.algorithm(
|
||||
params, spirv, kp::Workgroup({ 5 }), std::vector<float>({ 5.0 }));
|
||||
|
|
@ -58,7 +57,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++) {
|
||||
|
|
@ -119,12 +117,9 @@ TEST(TestLogisticRegression, TestMainLogisticRegressionManualCopy)
|
|||
|
||||
mgr.sequence()->record<kp::OpTensorSyncDevice>(params)->eval();
|
||||
|
||||
std::vector<uint32_t> spirv = std::vector<uint32_t>(
|
||||
(uint32_t*)kp::shader_data::shaders_glsl_logisticregression_comp_spv,
|
||||
(uint32_t*)(kp::shader_data::
|
||||
shaders_glsl_logisticregression_comp_spv +
|
||||
kp::shader_data::
|
||||
shaders_glsl_logisticregression_comp_spv_len));
|
||||
std::vector<uint32_t> spirv(
|
||||
kp::TEST_LOGISTIC_REGRESSION_SHADER_COMP_SPV.begin(),
|
||||
kp::TEST_LOGISTIC_REGRESSION_SHADER_COMP_SPV.end());
|
||||
|
||||
std::shared_ptr<kp::Algorithm> algorithm = mgr.algorithm(
|
||||
params, spirv, kp::Workgroup(), std::vector<float>({ 5.0 }));
|
||||
|
|
|
|||
|
|
@ -1,18 +0,0 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <kompute/Kompute.hpp>
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
|
||||
#if KOMPUTE_ENABLE_SPDLOG
|
||||
spdlog::set_level(
|
||||
static_cast<spdlog::level::level_enum>(KOMPUTE_LOG_LEVEL));
|
||||
#endif
|
||||
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
#include "gtest/gtest.h"
|
||||
|
||||
#include "kompute/Kompute.hpp"
|
||||
#include "kompute/logger/Logger.hpp"
|
||||
|
||||
TEST(TestManager, EndToEndOpMultEvalFlow)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,8 +3,9 @@
|
|||
#include "gtest/gtest.h"
|
||||
|
||||
#include "kompute/Kompute.hpp"
|
||||
#include "kompute/logger/Logger.hpp"
|
||||
|
||||
#include "kompute_test/Shader.hpp"
|
||||
#include "shaders/Utils.hpp"
|
||||
|
||||
TEST(TestMultipleAlgoExecutions, TestEndToEndFunctionality)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,10 +3,37 @@
|
|||
#include "gtest/gtest.h"
|
||||
|
||||
#include "kompute/Kompute.hpp"
|
||||
#include "kompute/logger/Logger.hpp"
|
||||
|
||||
#include "kompute_test/shaders/shadertest_op_custom_shader.hpp"
|
||||
#include "shaders/Utils.hpp"
|
||||
#include "test_op_custom_shader.hpp"
|
||||
#include "test_shader.hpp"
|
||||
|
||||
#include "kompute_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<uint32_t> spirv = compileSource(shader);
|
||||
std::vector<uint32_t> 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)
|
||||
{
|
||||
|
|
@ -50,14 +77,8 @@ TEST(TestOpAlgoCreate, ShaderCompiledDataFromConstructor)
|
|||
std::shared_ptr<kp::TensorT<float>> tensorA = mgr.tensor({ 3, 4, 5 });
|
||||
std::shared_ptr<kp::TensorT<float>> tensorB = mgr.tensor({ 0, 0, 0 });
|
||||
|
||||
std::vector<uint32_t> spirv = std::vector<uint32_t>(
|
||||
(uint32_t*)
|
||||
kp::shader_data::test_shaders_glsl_test_op_custom_shader_comp_spv,
|
||||
(uint32_t*)(kp::shader_data::
|
||||
test_shaders_glsl_test_op_custom_shader_comp_spv +
|
||||
kp::shader_data::
|
||||
test_shaders_glsl_test_op_custom_shader_comp_spv_len));
|
||||
|
||||
std::vector<uint32_t> spirv(kp::TEST_OP_CUSTOM_SHADER_COMP_SPV.begin(),
|
||||
kp::TEST_OP_CUSTOM_SHADER_COMP_SPV.end());
|
||||
std::vector<std::shared_ptr<kp::Tensor>> params = { tensorA, tensorB };
|
||||
|
||||
mgr.sequence()
|
||||
|
|
|
|||
|
|
@ -3,8 +3,9 @@
|
|||
#include "gtest/gtest.h"
|
||||
|
||||
#include "kompute/Kompute.hpp"
|
||||
#include "kompute/logger/Logger.hpp"
|
||||
|
||||
#include "kompute_test/Shader.hpp"
|
||||
#include "shaders/Utils.hpp"
|
||||
|
||||
TEST(TestOpTensorCopy, CopyDeviceToDeviceTensor)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include "gtest/gtest.h"
|
||||
|
||||
#include "kompute/Kompute.hpp"
|
||||
#include "kompute/logger/Logger.hpp"
|
||||
|
||||
TEST(TestOpTensorCreate, CreateSingleTensorSingleOp)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include "gtest/gtest.h"
|
||||
|
||||
#include "kompute/Kompute.hpp"
|
||||
#include "kompute/logger/Logger.hpp"
|
||||
|
||||
TEST(TestOpTensorSync, SyncToDeviceMemorySingleTensor)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,10 +3,9 @@
|
|||
#include "gtest/gtest.h"
|
||||
|
||||
#include "kompute/Kompute.hpp"
|
||||
#include "kompute/logger/Logger.hpp"
|
||||
|
||||
#include "kompute_test/Shader.hpp"
|
||||
|
||||
#include "fmt/ranges.h"
|
||||
#include "shaders/Utils.hpp"
|
||||
|
||||
TEST(TestPushConstants, TestConstantsAlgoDispatchOverride)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,8 +3,9 @@
|
|||
#include "gtest/gtest.h"
|
||||
|
||||
#include "kompute/Kompute.hpp"
|
||||
#include "kompute/logger/Logger.hpp"
|
||||
|
||||
#include "kompute_test/Shader.hpp"
|
||||
#include "shaders/Utils.hpp"
|
||||
|
||||
TEST(TestSequence, SequenceDestructorViaManager)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,8 +3,9 @@
|
|||
#include "gtest/gtest.h"
|
||||
|
||||
#include "kompute/Kompute.hpp"
|
||||
#include "kompute/logger/Logger.hpp"
|
||||
|
||||
#include "kompute_test/Shader.hpp"
|
||||
#include "shaders/Utils.hpp"
|
||||
|
||||
TEST(TestSpecializationConstants, TestTwoConstants)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include "gtest/gtest.h"
|
||||
|
||||
#include "kompute/Kompute.hpp"
|
||||
#include "kompute/logger/Logger.hpp"
|
||||
|
||||
TEST(TestTensor, ConstructorData)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,8 +3,9 @@
|
|||
#include "gtest/gtest.h"
|
||||
|
||||
#include "kompute/Kompute.hpp"
|
||||
#include "kompute/logger/Logger.hpp"
|
||||
|
||||
#include "kompute_test/shaders/shadertest_workgroup.hpp"
|
||||
#include "test_workgroup_shader.hpp"
|
||||
|
||||
TEST(TestWorkgroup, TestSimpleWorkgroup)
|
||||
{
|
||||
|
|
@ -21,14 +22,9 @@ TEST(TestWorkgroup, TestSimpleWorkgroup)
|
|||
|
||||
std::vector<std::shared_ptr<kp::Tensor>> params = { tensorA,
|
||||
tensorB };
|
||||
|
||||
std::vector<uint32_t> spirv(
|
||||
(uint32_t*)
|
||||
kp::shader_data::test_shaders_glsl_test_workgroup_comp_spv,
|
||||
(uint32_t*)(kp::shader_data::
|
||||
test_shaders_glsl_test_workgroup_comp_spv +
|
||||
kp::shader_data::
|
||||
test_shaders_glsl_test_workgroup_comp_spv_len));
|
||||
kp::TEST_WORKGROUP_SHADER_COMP_SPV.begin(),
|
||||
kp::TEST_WORKGROUP_SHADER_COMP_SPV.end());
|
||||
|
||||
kp::Workgroup workgroup = { 16, 8, 1 };
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue