diff --git a/CMakeLists.txt b/CMakeLists.txt index b018d369..e6ce10cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,51 +1,103 @@ # SPDX-License-Identifier: Apache-2.0 -cmake_minimum_required(VERSION 3.4.1) -project(kompute VERSION 0.8.1) +cmake_minimum_required(VERSION 3.15) +project(kompute VERSION 1.8.1 LANGUAGES CXX) set(CMAKE_CXX_STANDARD 14) -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -set(CMAKE_VERBOSE_MAKEFILE on) +# Only change the folder behaviour if kompute is not a subproject +if(${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME}) + set_property(GLOBAL PROPERTY USE_FOLDERS ON) + set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMake") + set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin) + set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib) +endif() + +# Avoid the dll boilerplate code for windows +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}") + +set(KOMPUTE_LIBRARIES kompute CACHE INTERNAL "") + +##################################################### +# Options +##################################################### + +macro(kompute_option OPTION_NAME OPTION_TEXT OPTION_DEFAULT) + option(${OPTION_NAME} ${OPTION_TEXT} ${OPTION_DEFAULT}) + if(DEFINED ENV{${OPTION_NAME}}) + # Allow overriding the option through an environment variable + set(${OPTION_NAME} $ENV{${OPTION_NAME}}) + endif() + if(${OPTION_NAME}) + add_definitions(-D${OPTION_NAME}) + endif() + message(STATUS " ${OPTION_NAME}: ${${OPTION_NAME}}") +endmacro() + +macro(kompute_log_level OPTION_NAME OPTION_TEXT OPTION_DEFAULT) + set(${OPTION_NAME} ${OPTION_DEFAULT} CACHE STRING ${OPTION_TEXT}) + set_property(CACHE ${OPTION_NAME} PROPERTY STRINGS "Trace" "Debug" "Info" "Warn" "Error" "Critical") + if(DEFINED ENV{${OPTION_NAME}}) + # Allow setting the option through an environment variable + set(${OPTION_NAME} $ENV{${OPTION_NAME}}) + endif() + if(${OPTION_NAME}) + add_definitions(-D${OPTION_NAME}) + endif() + message(STATUS " ${OPTION_NAME}: ${${OPTION_NAME}}") +endmacro() + +macro(kompute_option_string OPTION_NAME OPTION_TEXT OPTION_DEFAULT) + set(${OPTION_NAME} ${OPTION_DEFAULT} CACHE STRING ${OPTION_TEXT}) + if(DEFINED ENV{${OPTION_NAME}}) + # Allow setting the option through an environment variable + set(${OPTION_NAME} $ENV{${OPTION_NAME}}) + endif() + if(${OPTION_NAME}) + add_definitions(-D${OPTION_NAME}) + endif() + message(STATUS " ${OPTION_NAME}: ${${OPTION_NAME}}") +endmacro() +option(BUILD_SHARED_LIBS "Build libraries as shared libraries" ON) +message(STATUS "General purpose GPU compute framework built on Vulkan") +message(STATUS "=======================================================") # Enable or disable targets -option(KOMPUTE_OPT_BUILD_TESTS "Enable if you want to build tests" OFF) -option(KOMPUTE_OPT_CODE_COVERAGE "Enable if you want code coverage" OFF) -option(KOMPUTE_OPT_BUILD_DOCS "Enable if you want to build documentation" OFF) -option(KOMPUTE_OPT_BUILD_SHADERS "Enable if you want to re-build all shader files" OFF) -option(KOMPUTE_OPT_BUILD_SINGLE_HEADER "Enable if you want to build the single header file" OFF) -option(KOMPUTE_OPT_INSTALL "Enable if you want to enable installation" OFF) +kompute_option(KOMPUTE_OPT_BUILD_TESTS "Enable if you want to build tests" ON) +kompute_option(KOMPUTE_OPT_CODE_COVERAGE "Enable if you want code coverage" OFF) +kompute_option(KOMPUTE_OPT_BUILD_DOCS "Enable if you want to build documentation" OFF) +kompute_option(KOMPUTE_OPT_INSTALL "Enable if you want to enable installation" OFF) # Build options -option(KOMPUTE_OPT_BUILD_PYTHON "Enable if you want to build python bindings" OFF) -option(KOMPUTE_OPT_ENABLE_SPDLOG "Enable to compile with spdlog as the internal logging framework" OFF) -option(KOMPUTE_OPT_ANDROID_BUILD "Enable android compilation flags required" OFF) -option(KOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS "Explicitly disable debug layers even on debug" OFF) -option(KOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS "Whether to use shared libraries for dependencies for install" OFF) -option(KOMPUTE_OPT_BUILD_AS_SHARED_LIB "Whether to build kompute as shared library" OFF) -option(KOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK "Whether to check if your driver supports the Vulkan Header version you are linking against. This might be useful in case you build shared on a different system than you run later." OFF) - -# External komponents +kompute_option(KOMPUTE_OPT_BUILD_PYTHON "Enable if you want to build python bindings" OFF) +kompute_option(KOMPUTE_OPT_ENABLE_LOGGING "Internally we use spdlog for logging. The log output can be either enabled or disabled." OFF) +kompute_log_level(KOMPUTE_OPT_LOG_LEVEL "Internally we use spdlog for logging. The log level used can be changed here." "Debug") +kompute_option(KOMPUTE_OPT_ANDROID_BUILD "Enable android compilation flags required" OFF) +kompute_option(KOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS "Explicitly disable debug layers even on debug" OFF) +kompute_option(KOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK "Whether to check if your driver supports the Vulkan Header version you are linking against. This might be useful in case you build shared on a different system than you run later." OFF) + +# External components option(KOMPUTE_OPT_USE_BUILD_IN_SPDLOG "Use the build in version of Spdlog" ON) option(KOMPUTE_OPT_USE_BUILD_IN_FMT "Use the build in version of fmt" ON) option(KOMPUTE_OPT_USE_BUILD_IN_GOOGLE_TEST "Use the build in version of GoogleTest" ON) option(KOMPUTE_OPT_USE_BUILD_IN_PYBIND11 "Use the build in version of pybind11" ON) option(KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER "Use the build in version of Vulkan Headers. This could be helpful in case your system Vulkan Headers are to new for your driver. If you set this to false, please make sure your system Vulkan Header are supported by your driver." ON) -set(KOMPUTE_OPT_BUILD_IN_VULKAN_HEADER_TAG "v1.2.203" CACHE STRING "The git tag used for the build in Vulkan Headers when 'KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER' is enabled. A list of tags can be found here: https://github.com/KhronosGroup/Vulkan-Headers/tags") - -# Build flags -set(KOMPUTE_EXTRA_CXX_FLAGS "" CACHE STRING "Extra compile flags for Kompute, see docs for full list") +kompute_option_string(KOMPUTE_OPT_BUILD_IN_VULKAN_HEADER_TAG "The git tag used for the build in Vulkan Headers when 'KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER' is enabled. A list of tags can be found here: https://github.com/KhronosGroup/Vulkan-Headers/tags" "v1.2.203") +message(STATUS "=======================================================") ##################################################### -#################### Deprecated Options ############# +# Deprecated Options ##################################################### -if(KOMPUTE_OPT_REPO_SUBMODULE_BUILD) - message(FATAL_ERROR "'KOMPUTE_OPT_REPO_SUBMODULE_BUILD' got replaced by 'KOMPUTE_OPT_USE_BUILD_IN_SPDLOG', 'KOMPUTE_OPT_USE_BUILD_IN_FMT', 'KOMPUTE_OPT_USE_BUILD_IN_GOOGLE_TEST', 'KOMPUTE_OPT_USE_BUILD_IN_PYBIND11' and 'KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER'. Please use them instead.") -endif() +include(cmake/deprecation_warnings.cmake) ##################################################### -#################### Dependencies ################### +# Dependencies ##################################################### +include(cmake/vulkan_shader_compiler.cmake) include(FetchContent) include(cmake/check_vulkan_version.cmake) @@ -72,16 +124,18 @@ else() endif() # Spdlog -if(KOMPUTE_OPT_ENABLE_SPDLOG) - if(KOMPUTE_OPT_USE_BUILD_IN_SPDLOG) - set(SPDLOG_INSTALL ${KOMPUTE_OPT_INSTALL}) - set(SPDLOG_BUILD_SHARED ${KOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS}) - - FetchContent_Declare(spdlog GIT_REPOSITORY https://github.com/gabime/spdlog.git - GIT_TAG v1.10.0) # Source: https://github.com/gabime/spdlog/releases - FetchContent_MakeAvailable(spdlog) - else() - find_package(spdlog REQUIRED) +if(KOMPUTE_OPT_ENABLE_LOGGING) + if(KOMPUTE_OPT_ENABLE_SPDLOG) + if(KOMPUTE_OPT_USE_BUILD_IN_SPDLOG) + set(SPDLOG_INSTALL ${KOMPUTE_OPT_INSTALL}) + set(SPDLOG_BUILD_SHARED ${KOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS}) + + FetchContent_Declare(spdlog GIT_REPOSITORY https://github.com/gabime/spdlog.git + GIT_TAG v1.10.0) # Source: https://github.com/gabime/spdlog/releases + FetchContent_MakeAvailable(spdlog) + else() + find_package(spdlog REQUIRED) + endif() endif() endif() @@ -132,48 +186,43 @@ if(KOMPUTE_OPT_BUILD_PYTHON) endif() ##################################################### -#################### Other Options ################## +# Preprocessor Macros ##################################################### - if(KOMPUTE_OPT_ANDROID_BUILD) - set(KOMPUTE_EXTRA_CXX_FLAGS "${KOMPUTE_EXTRA_CXX_FLAGS} -DVK_USE_PLATFORM_ANDROID_KHR") + add_compile_definitions(VK_USE_PLATFORM_ANDROID_KHR=1) endif() if(KOMPUTE_OPT_BUILD_PYTHON) - set(KOMPUTE_EXTRA_CXX_FLAGS "${KOMPUTE_EXTRA_CXX_FLAGS} -DKOMPUTE_BUILD_PYTHON") + add_compile_definitions(KOMPUTE_BUILD_PYTHON=1) endif() if(KOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS) - set(KOMPUTE_EXTRA_CXX_FLAGS "${KOMPUTE_EXTRA_CXX_FLAGS} -DKOMPUTE_DISABLE_VK_DEBUG_LAYERS=1") + add_compile_definitions(KOMPUTE_DISABLE_VK_DEBUG_LAYERS=1) +endif() + +if(KOMPUTE_OPT_ENABLE_LOGGING) + add_compile_definitions(KOMPUTE_OPT_ENABLE_LOGGING=1) endif() +##################################################### +# Misc Options +##################################################### if(KOMPUTE_OPT_INSTALL) # Enable install parameters for glslang (overrides parameters passed) # When install is enabled the glslang libraries become shared set(ENABLE_GLSLANG_INSTALL ON CACHE BOOL "Enables install of glslang" FORCE) - - # By default we enable shared library based installation - if(KOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS) - set(BUILD_SHARED_LIBS ON CACHE BOOL "Enables build of shared libraries" FORCE) - endif() endif() -set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG=1 ${KOMPUTE_EXTRA_CXX_FLAGS} -DUSE_DEBUG_EXTENTIONS") -set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DRELEASE=1 ${KOMPUTE_EXTRA_CXX_FLAGS}") +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") +else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Werror") +endif() if(KOMPUTE_OPT_CODE_COVERAGE) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage --coverage") - - set(CODECOV_DIR - ${CMAKE_CURRENT_BINARY_DIR}/codecov/) - set(CODECOV_DIR_LCOV - ${CODECOV_DIR}lcov/) - set(CODECOV_FILENAME_LCOV_INFO - lcov.info) - set(CODECOV_FILENAME_LCOV_INFO_FULL - lcov_full.info) - set(CODECOV_DIR_HTML - ${CODECOV_DIR}html/) + if(NOT UNIX) + message(FATAL_ERROR "KOMPUTE_OPT_CODE_COVERAGE can only be enabled in unix based systems due to limitation on gcov.") + endif() + include(cmake/code_coverage.cmake) endif() # If glslang is cloned, then SPIRV/GlslangToSpv.h will be used instead of glslang/SPIRV/GlslangToSpv.h diff --git a/Makefile b/Makefile index f7093b59..3142ebc1 100644 --- a/Makefile +++ b/Makefile @@ -63,7 +63,6 @@ mk_cmake: -DKOMPUTE_OPT_BUILD_TESTS=1 \ -DKOMPUTE_OPT_BUILD_DOCS=1 \ -DKOMPUTE_OPT_BUILD_SHADERS=1 \ - -DKOMPUTE_OPT_BUILD_SINGLE_HEADER=1 \ -DKOMPUTE_OPT_ENABLE_SPDLOG=1 \ -DKOMPUTE_OPT_CODE_COVERAGE=1 \ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ @@ -116,7 +115,6 @@ vs_cmake: -DKOMPUTE_OPT_INSTALL=1 \ -DKOMPUTE_OPT_BUILD_TESTS=1 \ -DKOMPUTE_OPT_BUILD_SHADERS=1 \ - -DKOMPUTE_OPT_BUILD_SINGLE_HEADER=1 \ -DKOMPUTE_OPT_ENABLE_SPDLOG=1 \ -DKOMPUTE_OPT_CODE_COVERAGE=0 \ -DKOMPUTE_OPT_BUILD_DOCS=0 \ @@ -161,7 +159,7 @@ run_ci: generate_python_docstrings: python -m pybind11_mkdoc \ -o python/src/docstrings.hpp \ - single_include/kompute/Kompute.hpp \ + kompute/Kompute.hpp \ -Iexternal/fmt/include/ \ -Iexternal/spdlog/include/ \ -Iexternal/glslang/ \ diff --git a/cmake/bin2h.cmake b/cmake/bin2h.cmake new file mode 100644 index 00000000..4243ca0f --- /dev/null +++ b/cmake/bin2h.cmake @@ -0,0 +1,98 @@ +################################################################################## +# Based on: https://github.com/sivachandran/cmake-bin2h +# +# Copyright 2020 Sivachandran Paramasivam +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +################################################################################## + +include(CMakeParseArguments) + +# Function to wrap a given string into multiple lines at the given column position. +# Parameters: +# VARIABLE - The name of the CMake variable holding the string. +# AT_COLUMN - The column position at which string will be wrapped. +function(WRAP_STRING) + set(oneValueArgs VARIABLE AT_COLUMN) + cmake_parse_arguments(WRAP_STRING "${options}" "${oneValueArgs}" "" ${ARGN}) + + string(LENGTH ${${WRAP_STRING_VARIABLE}} stringLength) + math(EXPR offset "0") + + while(stringLength GREATER 0) + + if(stringLength GREATER ${WRAP_STRING_AT_COLUMN}) + math(EXPR length "${WRAP_STRING_AT_COLUMN}") + else() + math(EXPR length "${stringLength}") + endif() + + string(SUBSTRING ${${WRAP_STRING_VARIABLE}} ${offset} ${length} line) + set(lines "${lines}\n${line}") + + math(EXPR stringLength "${stringLength} - ${length}") + math(EXPR offset "${offset} + ${length}") + endwhile() + + set(${WRAP_STRING_VARIABLE} "${lines}" PARENT_SCOPE) +endfunction() + +# Function to embed contents of a file as byte array in C/C++ header file(.h). The header file +# will contain a byte array and integer variable holding the size of the array. +# Parameters +# SOURCE_FILE - The path of source file whose contents will be embedded in the header file. +# VARIABLE_NAME - The name of the variable for the byte array. The string "_SIZE" will be append +# to this name and will be used a variable name for size variable. +# HEADER_FILE - The path of header file. +# APPEND - If specified appends to the header file instead of overwriting it +# NULL_TERMINATE - If specified a null byte(zero) will be append to the byte array. This will be +# useful if the source file is a text file and we want to use the file contents +# as string. But the size variable holds size of the byte array without this +# null byte. +# HEADER_NAMESPACE - The namespace, where the array should be located in. +# Usage: +# bin2h(SOURCE_FILE "Logo.png" HEADER_FILE "Logo.h" VARIABLE_NAME "LOGO_PNG") +function(BIN2H) + set(options APPEND NULL_TERMINATE) + set(oneValueArgs SOURCE_FILE VARIABLE_NAME HEADER_FILE) + cmake_parse_arguments(BIN2H "${options}" "${oneValueArgs}" "" ${ARGN}) + + # reads source file contents as hex string + file(READ ${BIN2H_SOURCE_FILE} hexString HEX) + string(LENGTH ${hexString} hexStringLength) + + # appends null byte if asked + if(BIN2H_NULL_TERMINATE) + set(hexString "${hexString}00") + endif() + + # wraps the hex string into multiple lines at column 32(i.e. 16 bytes per line) + wrap_string(VARIABLE hexString AT_COLUMN 32) + math(EXPR arraySize "${hexStringLength} / 2") + + # adds '0x' prefix and comma suffix before and after every byte respectively + string(REGEX REPLACE "([0-9a-f][0-9a-f])" "0x\\1, " arrayValues ${hexString}) + # removes trailing comma + string(REGEX REPLACE ", $" "" arrayValues ${arrayValues}) + + # converts the variable name into proper C identifier + string(MAKE_C_IDENTIFIER "${BIN2H_VARIABLE_NAME}" BIN2H_VARIABLE_NAME) + string(TOUPPER "${BIN2H_VARIABLE_NAME}" BIN2H_VARIABLE_NAME) + + # declares byte array and the length variables + set(namespaceStart "namespace ${HEADER_NAMESPACE} {") + set(namespaceEnd "} // ${HEADER_NAMESPACE}") + set(arrayIncludes "#pragma once\n#include \n#include ") + set(arrayDefinition "const std::array ${BIN2H_VARIABLE_NAME} = { ${arrayValues} };") + + set(declarations "${arrayIncludes}\n\n${namespaceStart}\n${arrayDefinition}\n${namespaceEnd}\n\n") + if(BIN2H_APPEND) + file(APPEND ${BIN2H_HEADER_FILE} "${declarations}") + else() + file(WRITE ${BIN2H_HEADER_FILE} "${declarations}") + endif() +endfunction() \ No newline at end of file diff --git a/cmake/bin_file_to_header.cmake b/cmake/bin_file_to_header.cmake new file mode 100644 index 00000000..814aac90 --- /dev/null +++ b/cmake/bin_file_to_header.cmake @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.15) + +if(${INPUT_SHADER_FILE} STREQUAL "") + message(FATAL_ERROR "No input file path provided via 'INPUT_SHADER_FILE'.") +endif() + +if(${OUTPUT_HEADER_FILE} STREQUAL "") + message(FATAL_ERROR "No output file path provided via 'OUTPUT_HEADER_FILE'.") +endif() + +if(${HEADER_NAMESPACE} STREQUAL "") + message(FATAL_ERROR "No header namespace provided via 'HEADER_NAMESPACE'.") +endif() + +include(bin2h.cmake) + +get_filename_component(BINARY_FILE_CONTENT ${INPUT_SHADER_FILE} NAME) +bin2h(SOURCE_FILE ${INPUT_SHADER_FILE} HEADER_FILE ${OUTPUT_HEADER_FILE} VARIABLE_NAME ${BINARY_FILE_CONTENT} HEADER_NAMESPACE ${HEADER_NAMESPACE}) +file(APPEND ${OUTPUT_HEADER_FILE} "\n") \ No newline at end of file diff --git a/cmake/code_coverage.cmake b/cmake/code_coverage.cmake new file mode 100644 index 00000000..b1f74866 --- /dev/null +++ b/cmake/code_coverage.cmake @@ -0,0 +1,34 @@ +# Code coverage +set(CMAKE_BUILD_TYPE COVERAGE CACHE INTERNAL "Coverage build enabled") +message(STATUS "Enabling gcov support") +if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + set(COVERAGE_FLAG "--coverage") +endif() +set(CMAKE_CXX_FLAGS_COVERAGE + "-g -O0 ${COVERAGE_FLAG} -fprofile-arcs -ftest-coverage" + CACHE STRING "Flags used by the C++ compiler during coverage builds." + FORCE) +set(CMAKE_C_FLAGS_COVERAGE + "-g -O0 ${COVERAGE_FLAG} -fprofile-arcs -ftest-coverage" + CACHE STRING "Flags used by the C compiler during coverage builds." + FORCE) +set(CMAKE_EXE_LINKER_FLAGS_COVERAGE + "" + CACHE STRING "Flags used for linking binaries during coverage builds." + FORCE) +set(CMAKE_SHARED_LINKER_FLAGS_COVERAGE + "" + CACHE STRING "Flags used by the shared libraries linker during coverage builds." + FORCE) + +set(CODECOV_DIR ${CMAKE_CURRENT_BINARY_DIR}/codecov/) +set(CODECOV_DIR_LCOV ${CODECOV_DIR}lcov/) +set(CODECOV_FILENAME_LCOV_INFO lcov.info) +set(CODECOV_FILENAME_LCOV_INFO_FULL lcov_full.info) +set(CODECOV_DIR_HTML ${CODECOV_DIR}html/) + +mark_as_advanced(CMAKE_CXX_FLAGS_COVERAGE + CMAKE_C_FLAGS_COVERAGE + CMAKE_EXE_LINKER_FLAGS_COVERAGE + CMAKE_SHARED_LINKER_FLAGS_COVERAGE) +endif() diff --git a/cmake/deprecation_warnings.cmake b/cmake/deprecation_warnings.cmake new file mode 100644 index 00000000..95c81c28 --- /dev/null +++ b/cmake/deprecation_warnings.cmake @@ -0,0 +1,3 @@ +if(KOMPUTE_OPT_REPO_SUBMODULE_BUILD) + message(FATAL_ERROR "'KOMPUTE_OPT_REPO_SUBMODULE_BUILD' got replaced by 'KOMPUTE_OPT_USE_BUILD_IN_SPDLOG', 'KOMPUTE_OPT_USE_BUILD_IN_FMT', 'KOMPUTE_OPT_USE_BUILD_IN_GOOGLE_TEST', 'KOMPUTE_OPT_USE_BUILD_IN_PYBIND11' and 'KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER'. Please use them instead.") +endif() \ No newline at end of file diff --git a/cmake/komputeConfig.cmake.in b/cmake/komputeConfig.cmake.in new file mode 100644 index 00000000..87e8a99e --- /dev/null +++ b/cmake/komputeConfig.cmake.in @@ -0,0 +1,8 @@ +include(CMakeFindDependencyMacro) +@PACKAGE_INIT@ + +find_dependency(VULKAN REQUIRED) + +include(${CMAKE_CURRENT_LIST_DIR}/komputeTargets.cmake) + +check_required_components(kompute) \ No newline at end of file diff --git a/cmake/vulkan_shader_compiler.cmake b/cmake/vulkan_shader_compiler.cmake new file mode 100644 index 00000000..4526b796 --- /dev/null +++ b/cmake/vulkan_shader_compiler.cmake @@ -0,0 +1,36 @@ +function(vulkan_compile_shader) + find_program(GLS_LANG_VALIDATOR_PATH NAMES glslangValidator) + if(${GLS_LANG_VALIDATOR_PATH}) + message(FATAL_ERROR "glslangValidator not found.") + return() + endif() + + cmake_parse_arguments(SHADER_COMPILE "" "INFILE;OUTFILE;NAMESPACE" "" ${ARGN}) + set(SHADER_COMPILE_INFILE_FULL "${CMAKE_CURRENT_SOURCE_DIR}/${SHADER_COMPILE_INFILE}") + set(SHADER_COMPILE_SPV_FILE_FULL "${CMAKE_CURRENT_BINARY_DIR}/${SHADER_COMPILE_INFILE}.spv") + set(SHADER_COMPILE_HEADER_FILE_FULL "${CMAKE_CURRENT_BINARY_DIR}/${SHADER_COMPILE_OUTFILE}") + + # .comp -> .spv + add_custom_command(OUTPUT "${SHADER_COMPILE_SPV_FILE_FULL}" + COMMAND "${GLS_LANG_VALIDATOR_PATH}" + ARGS "-V" + "-o" + "${SHADER_COMPILE_SPV_FILE_FULL}" + "--target-env" + "vulkan1.2" + "${SHADER_COMPILE_INFILE_FULL}" + COMMENT "Compile vulkan compute shader from file '${SHADER_COMPILE_INFILE_FULL}' to '${SHADER_COMPILE_SPV_FILE_FULL}'." + MAIN_DEPENDENCY "${SHADER_COMPILE_INFILE_FULL}") + + # .spv -> .hpp + add_custom_command(OUTPUT "${SHADER_COMPILE_HEADER_FILE_FULL}" + COMMAND ${CMAKE_COMMAND} + ARGS "-DINPUT_SHADER_FILE=${SHADER_COMPILE_SPV_FILE_FULL}" + "-DOUTPUT_HEADER_FILE=${SHADER_COMPILE_HEADER_FILE_FULL}" + "-DHEADER_NAMESPACE=${SHADER_COMPILE_NAMESPACE}" + "-P" + "${CMAKE_SOURCE_DIR}/cmake/bin_file_to_header.cmake" + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/cmake" + COMMENT "Converting compiled shader '${SHADER_COMPILE_SPV_FILE_FULL}' to header file '${SHADER_COMPILE_HEADER_FILE_FULL}'." + MAIN_DEPENDENCY "${SHADER_COMPILE_SPV_FILE_FULL}") +endfunction() diff --git a/docs/overview/build-system.rst b/docs/overview/build-system.rst index d6c264d2..34b041f6 100644 --- a/docs/overview/build-system.rst +++ b/docs/overview/build-system.rst @@ -28,8 +28,6 @@ This by default configures without any of the extra build tasks (such as buildin * - -DKOMPUTE_OPT_BUILD_DOCS=ON - Enable if you wish to build the docs (must have docs deps installed) * - -DKOMPUTE_OPT_BUILD_SHADERS=ON - - Enable if you wish to build the shaders into header files (must have docs deps installed) - * - -DKOMPUTE_OPT_BUILD_SINGLE_HEADER=ON - Option to build the single header file using "quom" utility * - -DKOMPUTE_OPT_INSTALL=OFF - Disables the install step in the cmake file (useful for android build) diff --git a/examples/android/android-simple/app/build.gradle b/examples/android/android-simple/app/build.gradle index aef4b49b..a115ef77 100644 --- a/examples/android/android-simple/app/build.gradle +++ b/examples/android/android-simple/app/build.gradle @@ -20,7 +20,6 @@ android { '-DKOMPUTE_OPT_ANDROID_BUILD=1', '-DKOMPUTE_OPT_INSTALL=0', '-DKOMPUTE_OPT_ENABLE_SPDLOG=0', - '-DKOMPUTE_OPT_BUILD_SINGLE_HEADER=0', '-DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=1', '-DKOMPUTE_EXTRA_CXX_FLAGS=-DKOMPUTE_VK_API_MINOR_VERSION=0' } diff --git a/kompute-config.cmake b/kompute-config.cmake new file mode 100644 index 00000000..10425252 --- /dev/null +++ b/kompute-config.cmake @@ -0,0 +1,28 @@ +# General purpose GPU compute framework built on Vulkan to +# support 1000s of cross vendor graphics cards +# (AMD, Qualcomm, NVIDIA & friends). Blazing fast, mobile-enabled, +# asynchronous and optimized for advanced GPU data processing use cases. +# Backed by the Linux Foundation. +# +# Finding this module will define the following variables: +# KOMPUTE_FOUND - True if the core library has been found +# KOMPUTE_LIBRARIES - Path to the core library archive +# KOMPUTE_INCLUDE_DIRS - Path to the include directories. Gives access +# to kompute.h, as a single include which must be included in every +# file that uses this interface. Else it also points to the +# directory for individual includes. + +find_path(KOMPUTE_INCLUDE_DIR + NAMES kompute.h) + +find_library(KOMPUTE_LIBRARY + NAMES kompute + HINTS ${KOMPUTE_LIBRARY_ROOT}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(KOMPUTE REQUIRED_VARS KOMPUTE_LIBRARY KOMPUTE_INCLUDE_DIR) + +if(KOMPUTE_FOUND) + set(KOMPUTE_LIBRARIES ${KOMPUTE_LIBRARY}) + set(KOMPUTE_INCLUDE_DIRS ${KOMPUTE_INCLUDE_DIR}) +endif() diff --git a/single_include/AggregateHeaders.cpp b/single_include/AggregateHeaders.cpp deleted file mode 100644 index 0498fc01..00000000 --- a/single_include/AggregateHeaders.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once -#include "kompute/Algorithm.hpp" -#include "kompute/Core.hpp" -#include "kompute/Manager.hpp" -#include "kompute/Sequence.hpp" -#include "kompute/Tensor.hpp" -#include "kompute/operations/OpAlgoDispatch.hpp" -#include "kompute/operations/OpBase.hpp" -#include "kompute/operations/OpMemoryBarrier.hpp" -#include "kompute/operations/OpMult.hpp" -#include "kompute/operations/OpTensorCopy.hpp" -#include "kompute/operations/OpTensorSyncDevice.hpp" -#include "kompute/operations/OpTensorSyncLocal.hpp" -#include "kompute/shaders/shaderlogisticregression.hpp" -#include "kompute/shaders/shaderopmult.hpp" diff --git a/single_include/kompute/Kompute.hpp b/single_include/kompute/Kompute.hpp index e725b8bb..e69de29b 100644 --- a/single_include/kompute/Kompute.hpp +++ b/single_include/kompute/Kompute.hpp @@ -1,2432 +0,0 @@ -#pragma once -/* - THIS FILE HAS BEEN AUTOMATICALLY GENERATED - DO NOT EDIT - - --- - - Copyright 2020 The Institute for Ethical AI & Machine Learning - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#ifndef SHADEROP_SHADEROPMULT_HPP -#define SHADEROP_SHADEROPMULT_HPP - -namespace kp { -namespace shader_data { -static const unsigned char shaders_glsl_opmult_comp_spv[] = { - 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x0a, 0x00, 0x08, 0x00, - 0x2e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, - 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x06, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, - 0x0b, 0x00, 0x00, 0x00, 0x10, 0x00, 0x06, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x11, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x02, 0x00, 0x00, 0x00, - 0xc2, 0x01, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, - 0x08, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x08, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x47, - 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x49, 0x6e, 0x76, 0x6f, 0x63, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x49, 0x44, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, - 0x12, 0x00, 0x00, 0x00, 0x74, 0x65, 0x6e, 0x73, 0x6f, 0x72, 0x4f, 0x75, - 0x74, 0x70, 0x75, 0x74, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x07, 0x00, - 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x73, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x03, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x05, 0x00, 0x19, 0x00, 0x00, 0x00, 0x74, 0x65, 0x6e, 0x73, - 0x6f, 0x72, 0x4c, 0x68, 0x73, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, - 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x73, 0x4c, 0x68, 0x73, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, - 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, - 0x21, 0x00, 0x00, 0x00, 0x74, 0x65, 0x6e, 0x73, 0x6f, 0x72, 0x52, 0x68, - 0x73, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0x21, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x52, 0x68, - 0x73, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x23, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x29, 0x00, 0x00, 0x00, - 0x4c, 0x45, 0x4e, 0x5f, 0x4c, 0x48, 0x53, 0x00, 0x05, 0x00, 0x04, 0x00, - 0x2a, 0x00, 0x00, 0x00, 0x4c, 0x45, 0x4e, 0x5f, 0x52, 0x48, 0x53, 0x00, - 0x05, 0x00, 0x04, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x4c, 0x45, 0x4e, 0x5f, - 0x4f, 0x55, 0x54, 0x00, 0x47, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, - 0x0b, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x11, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x48, 0x00, 0x05, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, - 0x12, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x14, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x14, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x18, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, - 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x19, 0x00, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x1b, 0x00, 0x00, 0x00, - 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x1b, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x20, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x21, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x03, 0x00, 0x21, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x23, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x23, 0x00, 0x00, 0x00, - 0x21, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x29, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x2b, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x2d, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, - 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, - 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, - 0x0a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, - 0x0d, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x16, 0x00, 0x03, 0x00, 0x10, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, - 0x1d, 0x00, 0x03, 0x00, 0x11, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, - 0x1e, 0x00, 0x03, 0x00, 0x12, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x04, 0x00, 0x13, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x12, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x13, 0x00, 0x00, 0x00, - 0x14, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, - 0x15, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x2b, 0x00, 0x04, 0x00, 0x15, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x03, 0x00, 0x18, 0x00, 0x00, 0x00, - 0x10, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, 0x19, 0x00, 0x00, 0x00, - 0x18, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x1a, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x1a, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x04, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x10, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x03, 0x00, 0x20, 0x00, 0x00, 0x00, - 0x10, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, 0x21, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x22, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x22, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x32, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x06, 0x00, 0x09, 0x00, 0x00, 0x00, - 0x2d, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, - 0x2c, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x05, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, - 0x0b, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x08, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, - 0x08, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x1c, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, - 0x1d, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, - 0x16, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x10, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, - 0x08, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x1d, 0x00, 0x00, 0x00, - 0x25, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, - 0x24, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00, - 0x26, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, - 0x10, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, - 0x26, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x1d, 0x00, 0x00, 0x00, - 0x28, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, - 0x17, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x28, 0x00, 0x00, 0x00, - 0x27, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00 -}; -static const unsigned int shaders_glsl_opmult_comp_spv_len = 1464; -} -} -#endif // define SHADEROP_SHADEROPMULT_HPP - -/* - THIS FILE HAS BEEN AUTOMATICALLY GENERATED - DO NOT EDIT - - --- - - Copyright 2020 The Institute for Ethical AI & Machine Learning - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#ifndef SHADEROP_SHADERLOGISTICREGRESSION_HPP -#define SHADEROP_SHADERLOGISTICREGRESSION_HPP - -namespace kp { -namespace shader_data { -static const unsigned char shaders_glsl_logisticregression_comp_spv[] = { - 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x0a, 0x00, 0x08, 0x00, - 0xae, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, - 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x06, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x00, 0x00, 0x10, 0x00, 0x06, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x11, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x02, 0x00, 0x00, 0x00, - 0xc2, 0x01, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, - 0x0a, 0x00, 0x00, 0x00, 0x73, 0x69, 0x67, 0x6d, 0x6f, 0x69, 0x64, 0x28, - 0x66, 0x31, 0x3b, 0x00, 0x05, 0x00, 0x03, 0x00, 0x09, 0x00, 0x00, 0x00, - 0x7a, 0x00, 0x00, 0x00, 0x05, 0x00, 0x08, 0x00, 0x12, 0x00, 0x00, 0x00, - 0x69, 0x6e, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x28, 0x76, 0x66, - 0x32, 0x3b, 0x76, 0x66, 0x32, 0x3b, 0x66, 0x31, 0x3b, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x03, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x03, 0x00, 0x10, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x03, 0x00, 0x11, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x08, 0x00, 0x17, 0x00, 0x00, 0x00, 0x63, 0x61, 0x6c, 0x63, - 0x75, 0x6c, 0x61, 0x74, 0x65, 0x4c, 0x6f, 0x73, 0x73, 0x28, 0x66, 0x31, - 0x3b, 0x66, 0x31, 0x3b, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, - 0x15, 0x00, 0x00, 0x00, 0x79, 0x48, 0x61, 0x74, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x03, 0x00, 0x16, 0x00, 0x00, 0x00, 0x79, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x03, 0x00, 0x21, 0x00, 0x00, 0x00, 0x7a, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x04, 0x00, 0x27, 0x00, 0x00, 0x00, 0x79, 0x48, 0x61, 0x74, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x28, 0x00, 0x00, 0x00, - 0x70, 0x61, 0x72, 0x61, 0x6d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, - 0x3e, 0x00, 0x00, 0x00, 0x69, 0x64, 0x78, 0x00, 0x05, 0x00, 0x08, 0x00, - 0x41, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x47, 0x6c, 0x6f, 0x62, 0x61, - 0x6c, 0x49, 0x6e, 0x76, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, - 0x44, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x46, 0x00, 0x00, 0x00, - 0x77, 0x43, 0x75, 0x72, 0x72, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, - 0x48, 0x00, 0x00, 0x00, 0x62, 0x77, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x04, 0x00, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x77, 0x69, 0x6e, 0x00, 0x05, 0x00, 0x03, 0x00, 0x4a, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x54, 0x00, 0x00, 0x00, - 0x62, 0x43, 0x75, 0x72, 0x72, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, - 0x56, 0x00, 0x00, 0x00, 0x62, 0x62, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x04, 0x00, 0x56, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x62, 0x69, 0x6e, 0x00, 0x05, 0x00, 0x03, 0x00, 0x58, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x5b, 0x00, 0x00, 0x00, - 0x78, 0x43, 0x75, 0x72, 0x72, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, - 0x5d, 0x00, 0x00, 0x00, 0x62, 0x78, 0x69, 0x00, 0x06, 0x00, 0x04, 0x00, - 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x69, 0x00, 0x00, - 0x05, 0x00, 0x03, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x03, 0x00, 0x64, 0x00, 0x00, 0x00, 0x62, 0x78, 0x6a, 0x00, - 0x06, 0x00, 0x04, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x78, 0x6a, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x66, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x6b, 0x00, 0x00, 0x00, - 0x79, 0x43, 0x75, 0x72, 0x72, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, - 0x6d, 0x00, 0x00, 0x00, 0x62, 0x79, 0x00, 0x00, 0x06, 0x00, 0x04, 0x00, - 0x6d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x79, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x03, 0x00, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x04, 0x00, 0x73, 0x00, 0x00, 0x00, 0x79, 0x48, 0x61, 0x74, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x74, 0x00, 0x00, 0x00, - 0x70, 0x61, 0x72, 0x61, 0x6d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, - 0x76, 0x00, 0x00, 0x00, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x04, 0x00, 0x78, 0x00, 0x00, 0x00, 0x70, 0x61, 0x72, 0x61, - 0x6d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x7b, 0x00, 0x00, 0x00, - 0x64, 0x5a, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x00, 0x00, - 0x64, 0x57, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x6d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x86, 0x00, 0x00, 0x00, - 0x64, 0x42, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x8b, 0x00, 0x00, 0x00, - 0x62, 0x77, 0x6f, 0x75, 0x74, 0x69, 0x00, 0x00, 0x06, 0x00, 0x05, 0x00, - 0x8b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x6f, 0x75, 0x74, - 0x69, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x8d, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x93, 0x00, 0x00, 0x00, - 0x62, 0x77, 0x6f, 0x75, 0x74, 0x6a, 0x00, 0x00, 0x06, 0x00, 0x05, 0x00, - 0x93, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x6f, 0x75, 0x74, - 0x6a, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x95, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x9c, 0x00, 0x00, 0x00, - 0x62, 0x62, 0x6f, 0x75, 0x74, 0x00, 0x00, 0x00, 0x06, 0x00, 0x05, 0x00, - 0x9c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x6f, 0x75, 0x74, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x9e, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0xa3, 0x00, 0x00, 0x00, - 0x62, 0x6c, 0x6f, 0x75, 0x74, 0x00, 0x00, 0x00, 0x06, 0x00, 0x05, 0x00, - 0xa3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x6f, 0x75, 0x74, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0xa5, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0xa7, 0x00, 0x00, 0x00, - 0x70, 0x61, 0x72, 0x61, 0x6d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, - 0xa9, 0x00, 0x00, 0x00, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x41, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, - 0x1c, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x47, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, - 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x48, 0x00, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x4a, 0x00, 0x00, 0x00, - 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x4a, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x55, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x56, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x03, 0x00, 0x56, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x58, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x58, 0x00, 0x00, 0x00, - 0x21, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x5c, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x48, 0x00, 0x05, 0x00, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, - 0x5d, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x5f, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x63, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, - 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x64, 0x00, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x66, 0x00, 0x00, 0x00, - 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x66, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x6d, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x03, 0x00, 0x6d, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x6f, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x6f, 0x00, 0x00, 0x00, - 0x21, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x80, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x8b, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x03, 0x00, 0x8b, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x8d, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x8d, 0x00, 0x00, 0x00, - 0x21, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x92, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x48, 0x00, 0x05, 0x00, 0x93, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, - 0x93, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x95, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x95, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x9b, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, - 0x9c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x9c, 0x00, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x9e, 0x00, 0x00, 0x00, - 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x9e, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0xa2, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0xa3, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x03, 0x00, 0xa3, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0xa5, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0xa5, 0x00, 0x00, 0x00, - 0x21, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0xad, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, - 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, - 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x21, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, - 0x0d, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x21, 0x00, 0x06, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x0d, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x21, 0x00, 0x05, 0x00, 0x14, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, - 0x15, 0x00, 0x04, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x3d, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, - 0x3f, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x04, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x3f, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x40, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, - 0x3c, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x04, 0x00, 0x43, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x3c, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x03, 0x00, 0x47, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, 0x48, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x49, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x49, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x15, 0x00, 0x04, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x4b, 0x00, 0x00, 0x00, - 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, - 0x4d, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x2b, 0x00, 0x04, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x03, 0x00, 0x55, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, 0x56, 0x00, 0x00, 0x00, - 0x55, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x57, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x57, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x1d, 0x00, 0x03, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x1e, 0x00, 0x03, 0x00, 0x5d, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x04, 0x00, 0x5e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x5d, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x5e, 0x00, 0x00, 0x00, - 0x5f, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x03, 0x00, - 0x63, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, - 0x64, 0x00, 0x00, 0x00, 0x63, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, - 0x65, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x65, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x03, 0x00, 0x6c, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, 0x6d, 0x00, 0x00, 0x00, - 0x6c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x6e, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x6e, 0x00, 0x00, 0x00, 0x6f, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x32, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x03, 0x00, 0x8a, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, 0x8b, 0x00, 0x00, 0x00, - 0x8a, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x8c, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x8b, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x8c, 0x00, 0x00, 0x00, 0x8d, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x1d, 0x00, 0x03, 0x00, 0x92, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x1e, 0x00, 0x03, 0x00, 0x93, 0x00, 0x00, 0x00, 0x92, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x04, 0x00, 0x94, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x93, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x94, 0x00, 0x00, 0x00, - 0x95, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, - 0x3c, 0x00, 0x00, 0x00, 0x97, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x1d, 0x00, 0x03, 0x00, 0x9b, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x1e, 0x00, 0x03, 0x00, 0x9c, 0x00, 0x00, 0x00, 0x9b, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x04, 0x00, 0x9d, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x9c, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x9d, 0x00, 0x00, 0x00, - 0x9e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x03, 0x00, - 0xa2, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, - 0xa3, 0x00, 0x00, 0x00, 0xa2, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, - 0xa4, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa3, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0xa4, 0x00, 0x00, 0x00, 0xa5, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x06, 0x00, 0x3f, 0x00, 0x00, 0x00, - 0xad, 0x00, 0x00, 0x00, 0x97, 0x00, 0x00, 0x00, 0x97, 0x00, 0x00, 0x00, - 0x97, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x3d, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x54, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x0d, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x73, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x0d, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x76, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x78, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x86, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x07, 0x00, 0x00, 0x00, 0xa7, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0xa9, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x43, 0x00, 0x00, 0x00, - 0x44, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, - 0x44, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x3e, 0x00, 0x00, 0x00, - 0x45, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x4d, 0x00, 0x00, 0x00, - 0x4e, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, - 0x4c, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x4f, 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, - 0x4d, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, - 0x4c, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, - 0x50, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x53, 0x00, 0x00, 0x00, - 0x4f, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0x46, 0x00, 0x00, 0x00, 0x53, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, - 0x4d, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, - 0x4c, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x54, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x4d, 0x00, 0x00, 0x00, - 0x61, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, - 0x60, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x62, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x3c, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x06, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, - 0x66, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x69, 0x00, 0x00, 0x00, - 0x68, 0x00, 0x00, 0x00, 0x50, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x6a, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x69, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x6a, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x4d, 0x00, 0x00, 0x00, - 0x71, 0x00, 0x00, 0x00, 0x6f, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, - 0x70, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x72, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0x6b, 0x00, 0x00, 0x00, 0x72, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x74, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, - 0x46, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x76, 0x00, 0x00, 0x00, - 0x77, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x79, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0x78, 0x00, 0x00, 0x00, 0x79, 0x00, 0x00, 0x00, 0x39, 0x00, 0x07, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x7a, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, - 0x74, 0x00, 0x00, 0x00, 0x76, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x73, 0x00, 0x00, 0x00, 0x7a, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, - 0x73, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x7d, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x83, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, - 0x7d, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x7b, 0x00, 0x00, 0x00, - 0x7e, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x81, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, - 0x5b, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x83, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, - 0x7b, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x85, 0x00, 0x00, 0x00, 0x83, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, - 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, - 0x19, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x00, - 0x85, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x89, 0x00, 0x00, 0x00, - 0x87, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0x86, 0x00, 0x00, 0x00, 0x89, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x3c, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x8f, 0x00, 0x00, 0x00, - 0x7f, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x8f, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x06, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0x00, - 0x8d, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x91, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x96, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x98, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x97, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x99, 0x00, 0x00, 0x00, - 0x98, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x4d, 0x00, 0x00, 0x00, - 0x9a, 0x00, 0x00, 0x00, 0x95, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, - 0x96, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x9a, 0x00, 0x00, 0x00, - 0x99, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x3c, 0x00, 0x00, 0x00, - 0x9f, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x86, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x06, 0x00, 0x4d, 0x00, 0x00, 0x00, 0xa1, 0x00, 0x00, 0x00, - 0x9e, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x9f, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0xa1, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x3c, 0x00, 0x00, 0x00, 0xa6, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0xa8, 0x00, 0x00, 0x00, 0x73, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0xa7, 0x00, 0x00, 0x00, 0xa8, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0xaa, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0xa9, 0x00, 0x00, 0x00, 0xaa, 0x00, 0x00, 0x00, - 0x39, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, 0xab, 0x00, 0x00, 0x00, - 0x17, 0x00, 0x00, 0x00, 0xa7, 0x00, 0x00, 0x00, 0xa9, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x06, 0x00, 0x4d, 0x00, 0x00, 0x00, 0xac, 0x00, 0x00, 0x00, - 0xa5, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0xa6, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0xac, 0x00, 0x00, 0x00, 0xab, 0x00, 0x00, 0x00, - 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00, 0x36, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x08, 0x00, 0x00, 0x00, 0x37, 0x00, 0x03, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x0b, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x1b, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x1b, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, - 0x1c, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x1e, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, - 0xfe, 0x00, 0x02, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x38, 0x00, 0x01, 0x00, - 0x36, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x37, 0x00, 0x03, 0x00, - 0x0d, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x37, 0x00, 0x03, 0x00, - 0x0d, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x37, 0x00, 0x03, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, - 0x13, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x21, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x22, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, - 0x94, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, - 0x22, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, - 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, - 0x24, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0x21, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x28, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, - 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, - 0x0a, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0x27, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, - 0xfe, 0x00, 0x02, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x38, 0x00, 0x01, 0x00, - 0x36, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x37, 0x00, 0x03, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x37, 0x00, 0x03, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, - 0x18, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x2e, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, - 0x0c, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x00, - 0x85, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, - 0x2e, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, - 0x83, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, - 0x19, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, - 0x83, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, - 0x19, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x1c, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, - 0x36, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x38, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, - 0x7f, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00, - 0x38, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x02, 0x00, 0x39, 0x00, 0x00, 0x00, - 0x38, 0x00, 0x01, 0x00 -}; -static const unsigned int shaders_glsl_logisticregression_comp_spv_len = 4816; -} -} -#endif // define SHADEROP_SHADERLOGISTICREGRESSION_HPP - -// SPDX-License-Identifier: Apache-2.0 - -#if VK_USE_PLATFORM_ANDROID_KHR -#include -#include -// VK_NO_PROTOTYPES required before vulkan import but after wrapper.hpp -#undef VK_NO_PROTOTYPES -static const char* KOMPUTE_LOG_TAG = "KomputeLog"; -#endif - -#include -#include -#include - -#include - -// Typedefs to simplify interaction with core types -namespace kp { -typedef std::array Workgroup; -typedef std::vector Constants; -} - -// Must be after vulkan is included -#ifndef KOMPUTE_VK_API_VERSION -#ifndef KOMPUTE_VK_API_MAJOR_VERSION -#define KOMPUTE_VK_API_MAJOR_VERSION 1 -#endif // KOMPUTE_VK_API_MAJOR_VERSION -#ifndef KOMPUTE_VK_API_MINOR_VERSION -#define KOMPUTE_VK_API_MINOR_VERSION 1 -#endif // KOMPUTE_VK_API_MINOR_VERSION -#define KOMPUTE_VK_API_VERSION \ - VK_MAKE_VERSION( \ - KOMPUTE_VK_API_MAJOR_VERSION, KOMPUTE_VK_API_MINOR_VERSION, 0) -#endif // KOMPUTE_VK_API_VERSION - -// Defining kompute log levels analogous to spdlog log levels -#define KOMPUTE_LOG_LEVEL_TRACE 0 -#define KOMPUTE_LOG_LEVEL_DEBUG 1 -#define KOMPUTE_LOG_LEVEL_INFO 2 -#define KOMPUTE_LOG_LEVEL_WARN 3 -#define KOMPUTE_LOG_LEVEL_ERROR 4 -#define KOMPUTE_LOG_LEVEL_CRITICAL 5 -#define KOMPUTE_LOG_LEVEL_OFF 6 - -#ifndef KOMPUTE_LOG_LEVEL -#if DEBUG -#define KOMPUTE_LOG_LEVEL KOMPUTE_LOG_LEVEL_DEBUG -#else -#define KOMPUTE_LOG_LEVEL KOMPUTE_LOG_LEVEL_INFO -#endif -#endif // KOMPUTE_LOG_LEVEL - -// SPDLOG_ACTIVE_LEVEL must be defined before spdlog.h import -// It is recommended that it's set via KOMPUTE_LOG_LEVEL -// but if required it can be set directly as override -#ifndef SPDLOG_ACTIVE_LEVEL -#define SPDLOG_ACTIVE_LEVEL KOMPUTE_LOG_LEVEL -#endif - -#if defined(KOMPUTE_BUILD_PYTHON) -#include -namespace py = pybind11; -// from python/src/main.cpp -extern py::object kp_debug, kp_info, kp_warning, kp_error; -#endif - -#ifndef KOMPUTE_LOG_OVERRIDE -#if KOMPUTE_ENABLE_SPDLOG -#include -#define KP_LOG_DEBUG(...) SPDLOG_DEBUG(__VA_ARGS__) -#define KP_LOG_INFO(...) SPDLOG_INFO(__VA_ARGS__) -#define KP_LOG_WARN(...) SPDLOG_WARN(__VA_ARGS__) -#define KP_LOG_ERROR(...) SPDLOG_ERROR(__VA_ARGS__) -#else -#include -#if KOMPUTE_LOG_LEVEL > 1 -#define KP_LOG_DEBUG(...) -#else -#if defined(VK_USE_PLATFORM_ANDROID_KHR) -#define KP_LOG_DEBUG(...) \ - ((void)__android_log_write( \ - ANDROID_LOG_DEBUG, KOMPUTE_LOG_TAG, fmt::format(__VA_ARGS__).c_str())) -#elif defined(KOMPUTE_BUILD_PYTHON) -#define KP_LOG_DEBUG(...) kp_debug(fmt::format(__VA_ARGS__)) -#else -#define KP_LOG_DEBUG(...) \ - fmt::print("[{} {}] [debug] [{}:{}] {}\n", \ - __DATE__, \ - __TIME__, \ - __FILE__, \ - __LINE__, \ - fmt::format(__VA_ARGS__)) -#endif // VK_USE_PLATFORM_ANDROID_KHR -#endif // KOMPUTE_LOG_LEVEL > 1 - -#if KOMPUTE_LOG_LEVEL > 2 -#define KP_LOG_INFO(...) -#else -#if defined(VK_USE_PLATFORM_ANDROID_KHR) -#define KP_LOG_INFO(...) \ - ((void)__android_log_write( \ - ANDROID_LOG_INFO, KOMPUTE_LOG_TAG, fmt::format(__VA_ARGS__).c_str())) -#elif defined(KOMPUTE_BUILD_PYTHON) -#define KP_LOG_INFO(...) kp_info(fmt::format(__VA_ARGS__)) -#else -#define KP_LOG_INFO(...) \ - fmt::print("[{} {}] [debug] [{}:{}] {}\n", \ - __DATE__, \ - __TIME__, \ - __FILE__, \ - __LINE__, \ - fmt::format(__VA_ARGS__)) -#endif // VK_USE_PLATFORM_ANDROID_KHR -#endif // KOMPUTE_LOG_LEVEL > 2 - -#if KOMPUTE_LOG_LEVEL > 3 -#define KP_LOG_WARN(...) -#else -#if defined(VK_USE_PLATFORM_ANDROID_KHR) -#define KP_LOG_WARN(...) \ - ((void)__android_log_write( \ - ANDROID_LOG_WARN, KOMPUTE_LOG_TAG, fmt::format(__VA_ARGS__).c_str())) -#elif defined(KOMPUTE_BUILD_PYTHON) -#define KP_LOG_WARN(...) kp_warning(fmt::format(__VA_ARGS__)) -#else -#define KP_LOG_WARN(...) \ - fmt::print("[{} {}] [debug] [{}:{}] {}\n", \ - __DATE__, \ - __TIME__, \ - __FILE__, \ - __LINE__, \ - fmt::format(__VA_ARGS__)) -#endif // VK_USE_PLATFORM_ANDROID_KHR -#endif // KOMPUTE_LOG_LEVEL > 3 - -#if KOMPUTE_LOG_LEVEL > 4 -#define KP_LOG_ERROR(...) -#else -#if defined(VK_USE_PLATFORM_ANDROID_KHR) -#define KP_LOG_ERROR(...) \ - ((void)__android_log_write( \ - ANDROID_LOG_ERROR, KOMPUTE_LOG_TAG, fmt::format(__VA_ARGS__).c_str())) -#elif defined(KOMPUTE_BUILD_PYTHON) -#define KP_LOG_ERROR(...) kp_error(fmt::format(__VA_ARGS__)) -#else -#define KP_LOG_ERROR(...) \ - fmt::print("[{} {}] [debug] [{}:{}] {}\n", \ - __DATE__, \ - __TIME__, \ - __FILE__, \ - __LINE__, \ - fmt::format(__VA_ARGS__)) -#endif // VK_USE_PLATFORM_ANDROID_KHR -#endif // KOMPUTE_LOG_LEVEL > 4 -#endif // KOMPUTE_SPDLOG_ENABLED -#endif // KOMPUTE_LOG_OVERRIDE - -// SPDX-License-Identifier: Apache-2.0 - -namespace kp { - -/** - * Structured data used in GPU operations. - * - * Tensors are the base building block in Kompute to perform operations across - * GPUs. Each tensor would have a respective Vulkan memory and buffer, which - * would be used to store their respective data. The tensors can be used for GPU - * data storage or transfer. - */ -class Tensor -{ - public: - /** - * Type for tensors created: Device allows memory to be transferred from - * staging buffers. Staging are host memory visible. Storage are device - * visible but are not set up to transfer or receive data (only for shader - * storage). - */ - enum class TensorTypes - { - eDevice = 0, ///< Type is device memory, source and destination - eHost = 1, ///< Type is host memory, source and destination - eStorage = 2, ///< Type is Device memory (only) - }; - enum class TensorDataTypes - { - eBool = 0, - eInt = 1, - eUnsignedInt = 2, - eFloat = 3, - eDouble = 4, - }; - - /** - * Constructor with data provided which would be used to create the - * respective vulkan buffer and memory. - * - * @param physicalDevice The physical device to use to fetch properties - * @param device The device to use to create the buffer and memory from - * @param data Non-zero-sized vector of data that will be used by the - * tensor - * @param tensorTypes Type for the tensor which is of type TensorTypes - */ - Tensor(std::shared_ptr physicalDevice, - std::shared_ptr device, - void* data, - uint32_t elementTotalCount, - uint32_t elementMemorySize, - const TensorDataTypes& dataType, - const TensorTypes& tensorType = TensorTypes::eDevice); - - /** - * Destructor which is in charge of freeing vulkan resources unless they - * have been provided externally. - */ - virtual ~Tensor(); - - /** - * Function to trigger reinitialisation of the tensor buffer and memory with - * new data as well as new potential device type. - * - * @param data Vector of data to use to initialise vector from - * @param tensorType The type to use for the tensor - */ - void rebuild(void* data, - uint32_t elementTotalCount, - uint32_t elementMemorySize); - - /** - * Destroys and frees the GPU resources which include the buffer and memory. - */ - void destroy(); - - /** - * Check whether tensor is initialized based on the created gpu resources. - * - * @returns Boolean stating whether tensor is initialized - */ - bool isInit(); - - /** - * Retrieve the tensor type of the Tensor - * - * @return Tensor type of tensor - */ - TensorTypes tensorType(); - - /** - * Records a copy from the memory of the tensor provided to the current - * thensor. This is intended to pass memory into a processing, to perform - * a staging buffer transfer, or to gather output (between others). - * - * @param commandBuffer Vulkan Command Buffer to record the commands into - * @param copyFromTensor Tensor to copy the data from - */ - void recordCopyFrom(const vk::CommandBuffer& commandBuffer, - std::shared_ptr copyFromTensor); - - /** - * Records a copy from the internal staging memory to the device memory - * using an optional barrier to wait for the operation. This function would - * only be relevant for kp::Tensors of type eDevice. - * - * @param commandBuffer Vulkan Command Buffer to record the commands into - */ - void recordCopyFromStagingToDevice(const vk::CommandBuffer& commandBuffer); - - /** - * Records a copy from the internal device memory to the staging memory - * using an optional barrier to wait for the operation. This function would - * only be relevant for kp::Tensors of type eDevice. - * - * @param commandBuffer Vulkan Command Buffer to record the commands into - */ - void recordCopyFromDeviceToStaging(const vk::CommandBuffer& commandBuffer); - - /** - * Records the buffer memory barrier into the primary buffer and command - * buffer which ensures that relevant data transfers are carried out - * correctly. - * - * @param commandBuffer Vulkan Command Buffer to record the commands into - * @param srcAccessMask Access flags for source access mask - * @param dstAccessMask Access flags for destination access mask - * @param scrStageMask Pipeline stage flags for source stage mask - * @param dstStageMask Pipeline stage flags for destination stage mask - */ - void recordPrimaryBufferMemoryBarrier( - const vk::CommandBuffer& commandBuffer, - vk::AccessFlagBits srcAccessMask, - vk::AccessFlagBits dstAccessMask, - vk::PipelineStageFlagBits srcStageMask, - vk::PipelineStageFlagBits dstStageMask); - /** - * Records the buffer memory barrier into the staging buffer and command - * buffer which ensures that relevant data transfers are carried out - * correctly. - * - * @param commandBuffer Vulkan Command Buffer to record the commands into - * @param srcAccessMask Access flags for source access mask - * @param dstAccessMask Access flags for destination access mask - * @param scrStageMask Pipeline stage flags for source stage mask - * @param dstStageMask Pipeline stage flags for destination stage mask - */ - void recordStagingBufferMemoryBarrier( - const vk::CommandBuffer& commandBuffer, - vk::AccessFlagBits srcAccessMask, - vk::AccessFlagBits dstAccessMask, - vk::PipelineStageFlagBits srcStageMask, - vk::PipelineStageFlagBits dstStageMask); - - /** - * Constructs a vulkan descriptor buffer info which can be used to specify - * and reference the underlying buffer component of the tensor without - * exposing it. - * - * @return Descriptor buffer info with own buffer - */ - vk::DescriptorBufferInfo constructDescriptorBufferInfo(); - - /** - * Returns the size/magnitude of the Tensor, which will be the total number - * of elements across all dimensions - * - * @return Unsigned integer representing the total number of elements - */ - uint32_t size(); - - /** - * Returns the total size of a single element of the respective data type - * that this tensor holds. - * - * @return Unsigned integer representing the memory of a single element of - * the respective data type. - */ - uint32_t dataTypeMemorySize(); - - /** - * Returns the total memory size of the data contained by the Tensor object - * which would equate to (this->size() * this->dataTypeMemorySize()) - * - * @return Unsigned integer representing the memory of a single element of - * the respective data type. - */ - uint32_t memorySize(); - - /** - * Retrieve the data type of the tensor (host, device, storage) - * - * @return Data type of tensor of type kp::Tensor::TensorDataTypes - */ - TensorDataTypes dataType(); - - /** - * Retrieve the raw data via the pointer to the memory that contains the raw - * memory of this current tensor. This tensor gets changed to a nullptr when - * the Tensor is removed. - * - * @return Pointer to raw memory containing raw bytes data of Tensor. - */ - void* rawData(); - - /** - * Sets / resets the data of the tensor which is directly done on the GPU - * host visible memory available by the tensor. - */ - void setRawData(const void* data); - - /** - * Template to return the pointer data converted by specific type, which - * would be any of the supported types including float, double, int32, - * uint32 and bool. - * - * @return Pointer to raw memory containing raw bytes data of Tensor. - */ - template - T* data() - { - return (T*)this->mRawData; - } - - /** - * Template to get the data of the current tensor as a vector of specific - * type, which would be any of the supported types including float, double, - * int32, uint32 and bool. - * - * @return Vector of type provided by template. - */ - template - std::vector vector() - { - return { (T*)this->mRawData, ((T*)this->mRawData) + this->size() }; - } - - protected: - // -------------- ALWAYS OWNED RESOURCES - TensorTypes mTensorType; - TensorDataTypes mDataType; - uint32_t mSize; - uint32_t mDataTypeMemorySize; - void* mRawData; - - private: - // -------------- NEVER OWNED RESOURCES - std::shared_ptr mPhysicalDevice; - std::shared_ptr mDevice; - - // -------------- OPTIONALLY OWNED RESOURCES - std::shared_ptr mPrimaryBuffer; - bool mFreePrimaryBuffer = false; - std::shared_ptr mStagingBuffer; - bool mFreeStagingBuffer = false; - std::shared_ptr mPrimaryMemory; - bool mFreePrimaryMemory = false; - std::shared_ptr mStagingMemory; - bool mFreeStagingMemory = false; - - void allocateMemoryCreateGPUResources(); // Creates the vulkan buffer - void createBuffer(std::shared_ptr buffer, - vk::BufferUsageFlags bufferUsageFlags); - void allocateBindMemory(std::shared_ptr buffer, - std::shared_ptr memory, - vk::MemoryPropertyFlags memoryPropertyFlags); - void recordCopyBuffer(const vk::CommandBuffer& commandBuffer, - std::shared_ptr bufferFrom, - std::shared_ptr bufferTo, - vk::DeviceSize bufferSize, - vk::BufferCopy copyRegion); - void recordBufferMemoryBarrier(const vk::CommandBuffer& commandBuffer, - const vk::Buffer& buffer, - vk::AccessFlagBits srcAccessMask, - vk::AccessFlagBits dstAccessMask, - vk::PipelineStageFlagBits srcStageMask, - vk::PipelineStageFlagBits dstStageMask); - - // Private util functions - vk::BufferUsageFlags getPrimaryBufferUsageFlags(); - vk::MemoryPropertyFlags getPrimaryMemoryPropertyFlags(); - vk::BufferUsageFlags getStagingBufferUsageFlags(); - vk::MemoryPropertyFlags getStagingMemoryPropertyFlags(); - - void mapRawData(); - void unmapRawData(); -}; - -template -class TensorT : public Tensor -{ - - public: - TensorT(std::shared_ptr physicalDevice, - std::shared_ptr device, - const std::vector& data, - const TensorTypes& tensorType = TensorTypes::eDevice) - : Tensor(physicalDevice, - device, - (void*)data.data(), - data.size(), - sizeof(T), - this->dataType(), - tensorType) - { - KP_LOG_DEBUG("Kompute TensorT constructor with data size {}", - data.size()); - } - - ~TensorT() { KP_LOG_DEBUG("Kompute TensorT destructor"); } - - T* data() { return (T*)this->mRawData; } - - std::vector vector() - { - return { (T*)this->mRawData, ((T*)this->mRawData) + this->size() }; - } - - T& operator[](int index) { return *(((T*)this->mRawData) + index); } - - void setData(const std::vector& data) - { - - KP_LOG_DEBUG("Kompute TensorT setting data with data size {}", - data.size()); - - if (data.size() != this->mSize) { - throw std::runtime_error( - "Kompute TensorT Cannot set data of different sizes"); - } - - Tensor::setRawData(data.data()); - } - - TensorDataTypes dataType(); -}; - -} // End namespace kp - -// SPDX-License-Identifier: Apache-2.0 - -namespace kp { - -/** - Abstraction for compute shaders that are run on top of tensors grouped via - ParameterGroups (which group descriptorsets) -*/ -class Algorithm -{ - public: - /** - * Main constructor for algorithm with configuration parameters to create - * the underlying resources. - * - * @param device The Vulkan device to use for creating resources - * @param tensors (optional) The tensors to use to create the descriptor - * resources - * @param spirv (optional) The spirv code to use to create the algorithm - * @param workgroup (optional) The kp::Workgroup to use for the dispatch - * which defaults to kp::Workgroup(tensor[0].size(), 1, 1) if not set. - * @param specializationConstants (optional) The templatable param is to be - * used to initialize the specialization constants which cannot be changed - * once set. - * @param pushConstants (optional) This templatable param is to be used - * when initializing the pipeline, which set the size of the push constants - * - these can be modified but all new values must have the same data type - * and length as otherwise it will result in errors. - */ - template - Algorithm(std::shared_ptr device, - const std::vector>& tensors = {}, - const std::vector& spirv = {}, - const Workgroup& workgroup = {}, - const std::vector& specializationConstants = {}, - const std::vector

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

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

& pushConstants) - { - - KP_LOG_DEBUG("Kompute Manager algorithm creation triggered"); - - std::shared_ptr algorithm{ new kp::Algorithm( - this->mDevice, - tensors, - spirv, - workgroup, - specializationConstants, - pushConstants) }; - - if (this->mManageResources) { - this->mManagedAlgorithms.push_back(algorithm); - } - - return algorithm; - } - - /** - * Destroy the GPU resources and all managed resources by manager. - **/ - void destroy(); - /** - * Run a pseudo-garbage collection to release all the managed resources - * that have been already freed due to these reaching to zero ref count. - **/ - void clear(); - - /** - * Information about the current device. - * - * @return vk::PhysicalDeviceProperties containing information about the - *device - **/ - vk::PhysicalDeviceProperties getDeviceProperties() const; - - /** - * List the devices available in the current vulkan instance. - * - * @return vector of physical devices containing their respective properties - **/ - std::vector listDevices() const; - - private: - // -------------- OPTIONALLY OWNED RESOURCES - std::shared_ptr mInstance = nullptr; - bool mFreeInstance = false; - std::shared_ptr mPhysicalDevice = nullptr; - std::shared_ptr mDevice = nullptr; - bool mFreeDevice = false; - - // -------------- ALWAYS OWNED RESOURCES - std::vector> mManagedTensors; - std::vector> mManagedSequences; - std::vector> mManagedAlgorithms; - - std::vector mComputeQueueFamilyIndices; - std::vector> mComputeQueues; - - bool mManageResources = false; - -#if DEBUG -#ifndef KOMPUTE_DISABLE_VK_DEBUG_LAYERS - vk::DebugReportCallbackEXT mDebugReportCallback; - vk::DispatchLoaderDynamic mDebugDispatcher; -#endif -#endif - - // Create functions - void createInstance(); - void createDevice(const std::vector& familyQueueIndices = {}, - uint32_t hysicalDeviceIndex = 0, - const std::vector& desiredExtensions = {}); -}; - -} // End namespace kp - -/** - * fmt fromater for kp::Tensor::TensorDataTypes. - */ -template<> -struct fmt::formatter : formatter -{ - template - auto format(kp::Tensor::TensorDataTypes dt, FormatContext& ctx) - { - std::string name = "unknown"; - switch (dt) { - case kp::Tensor::TensorDataTypes::eBool: - name = "eBool"; - break; - case kp::Tensor::TensorDataTypes::eDouble: - name = "eDouble"; - break; - case kp::Tensor::TensorDataTypes::eFloat: - name = "eFloat"; - break; - case kp::Tensor::TensorDataTypes::eInt: - name = "eInt"; - break; - case kp::Tensor::TensorDataTypes::eUnsignedInt: - name = "eUnsignedInt"; - break; - } - return formatter::format(name, ctx); - } -}; - -/** - * fmt fromater for kp::Tensor::TensorTypes. - */ -template<> -struct fmt::formatter : formatter -{ - template - auto format(kp::Tensor::TensorTypes dt, FormatContext& ctx) - { - std::string name = "unknown"; - switch (dt) { - case kp::Tensor::TensorTypes::eDevice: - name = "eDevice"; - break; - case kp::Tensor::TensorTypes::eHost: - name = "eHost"; - break; - case kp::Tensor::TensorTypes::eStorage: - name = "eStorage"; - break; - } - return formatter::format(name, ctx); - } -}; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 44753cd4..ae472e62 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,124 +1,103 @@ # SPDX-License-Identifier: Apache-2.0 +cmake_minimum_required(VERSION 3.15) + if(KOMPUTE_OPT_ANDROID_BUILD) find_library(android android) endif() -if(KOMPUTE_OPT_BUILD_SHADERS) -# all shaders are compiled into cpp files - kompute_make(build_shaders - OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/include) -endif() +cmake_minimum_required(VERSION 3.15) + +add_library(kompute Algorithm.cpp + Manager.cpp + OpAlgoDispatch.cpp + OpMemoryBarrier.cpp + OpTensorCopy.cpp + OpTensorSyncDevice.cpp + OpTensorSyncLocal.cpp + Sequence.cpp + Tensor.cpp) + +add_library(kompute::kompute ALIAS kompute) -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) +# Set version for shared libraries. +set_target_properties(kompute + PROPERTIES + VERSION ${${PROJECT_NAME}_VERSION} + SOVERSION ${${PROJECT_NAME}_VERSION_MAJOR}) + +# Import GNU common install directory variables +include(GNUInstallDirs) + +if(CPR_FORCE_USE_SYSTEM_CURL) + install(TARGETS kompute + EXPORT komputeTargets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) + + # Include CMake helpers for package config files + # Follow this installation guideline: https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html + include(CMakePackageConfigHelpers) + + configure_package_config_file(${PROJECT_SOURCE_DIR}/cmake/komputeConfig.cmake.in + "${PROJECT_BINARY_DIR}/kompute/komputeConfig.cmake" + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kompute) + + install(EXPORT komputeTargets + FILE komputeTargets.cmake + NAMESPACE kompute:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kompute) + + install(FILES ${PROJECT_BINARY_DIR}/kompute/komputeConfig.cmake + ${PROJECT_BINARY_DIR}/kompute/komputeConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kompute) + +else() + install(TARGETS kompute + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() -file(GLOB kompute_CPP - "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp" -) +##################################################### +# Android +##################################################### if(KOMPUTE_OPT_ANDROID_BUILD) set(VK_ANDROID_COMMON_DIR ${ANDROID_NDK}/sources/third_party/vulkan/src/common) set(VK_ANDROID_PATCH_DIR ${PROJECT_SOURCE_DIR}/vk_ndk_wrapper_include/) set(VK_ANDROID_INCLUDE_DIR ${ANDROID_NDK}/sources/third_party/vulkan/src/include) - include_directories( - ${VK_ANDROID_COMMON_DIR} - ${VK_ANDROID_PATCH_DIR} - ${VK_ANDROID_INCLUDE_DIR}) + include_directories(${VK_ANDROID_COMMON_DIR} + ${VK_ANDROID_PATCH_DIR} + ${VK_ANDROID_INCLUDE_DIR}) - add_library(kompute_vk_ndk_wrapper STATIC - ${PROJECT_SOURCE_DIR}/vk_ndk_wrapper_include/kompute_vk_ndk_wrapper.cpp) + add_library(kompute_vk_ndk_wrapper STATIC ${PROJECT_SOURCE_DIR}/vk_ndk_wrapper_include/kompute_vk_ndk_wrapper.cpp) endif() -if(NOT KOMPUTE_OPT_BUILD_AS_SHARED_LIB) - add_library( - kompute STATIC - ${kompute_CPP}) -else() - add_library( - kompute SHARED - ${kompute_CPP}) -endif() - -target_include_directories( - kompute PUBLIC - $ - $ -) +##################################################### +# Linking +##################################################### if(KOMPUTE_OPT_ANDROID_BUILD) - target_link_libraries(kompute - fmt::fmt) + target_link_libraries(kompute PRIVATE fmt::fmt + kompute_vk_ndk_wrapper + log + android) else() - target_link_libraries(kompute - Vulkan::Vulkan - fmt::fmt) + target_link_libraries(kompute PRIVATE Vulkan::Vulkan + fmt::fmt) endif() if(KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER) - target_link_libraries(kompute - Vulkan-Headers) -endif() - -##################################################### -#################### SPDLOG ######################### -##################################################### - -if(KOMPUTE_OPT_ENABLE_SPDLOG) - target_link_libraries(kompute spdlog::spdlog) -endif() - -##################################################### -#################### Android ######################## -##################################################### - -if(KOMPUTE_OPT_ANDROID_BUILD) - target_link_libraries(kompute - kompute_vk_ndk_wrapper - log - android) + target_link_libraries(kompute PUBLIC Vulkan-Headers) endif() -##################################################### -########## Built C++ Header SHADERS ################# -##################################################### - -if(KOMPUTE_OPT_BUILD_SHADERS) - add_dependencies(kompute - build_shaders) +if(KOMPUTE_OPT_ENABLE_LOGGING) + target_link_libraries(kompute PRIVATE spdlog::spdlog) endif() ##################################################### -#################### Single Header ################## +# Misc ##################################################### - -if(KOMPUTE_OPT_BUILD_SINGLE_HEADER) - add_dependencies(kompute - build_single_header) -endif() - - -add_library(kompute::kompute ALIAS kompute) - -if(KOMPUTE_OPT_INSTALL) - install(TARGETS kompute EXPORT KomputeTargets - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - INCLUDES DESTINATION include) - - target_include_directories(kompute PUBLIC $) - - install(DIRECTORY include/ DESTINATION include) - - install(DIRECTORY ${PROJECT_SOURCE_DIR}/single_include/ - DESTINATION include) - - install(EXPORT KomputeTargets - FILE komputeConfig.cmake - NAMESPACE kompute:: - DESTINATION lib/cmake/kompute) -endif() +add_subdirectory(include) diff --git a/src/include/CMakeLists.txt b/src/include/CMakeLists.txt new file mode 100644 index 00000000..9f75d06a --- /dev/null +++ b/src/include/CMakeLists.txt @@ -0,0 +1,27 @@ +cmake_minimum_required(VERSION 3.15) + +target_include_directories(kompute PUBLIC $ + $) + +target_sources(kompute PRIVATE + # Header files (useful in IDEs) + kompute/Algorithm.hpp + kompute/Core.hpp + kompute/Kompute.hpp + kompute/Manager.hpp + kompute/Sequence.hpp + kompute/Tensor.hpp + + kompute/operations/OpAlgoDispatch.hpp + kompute/operations/OpBase.hpp + kompute/operations/OpMemoryBarrier.hpp + kompute/operations/OpMult.hpp + kompute/operations/OpTensorCopy.hpp + kompute/operations/OpTensorSyncDevice.hpp + kompute/operations/OpTensorSyncLocal.hpp + + kompute/shaders/shaderlogisticregression.hpp + kompute/shaders/shaderopmult.hpp +) + +install(DIRECTORY kompute DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) diff --git a/src/include/kompute/Kompute.hpp b/src/include/kompute/Kompute.hpp new file mode 100644 index 00000000..c5663ab7 --- /dev/null +++ b/src/include/kompute/Kompute.hpp @@ -0,0 +1,18 @@ +#pragma once + +#include "Algorithm.hpp" +#include "Core.hpp" +#include "Manager.hpp" +#include "Sequence.hpp" +#include "Tensor.hpp" + +#include "operations/OpAlgoDispatch.hpp" +#include "operations/OpBase.hpp" +#include "operations/OpMemoryBarrier.hpp" +#include "operations/OpMult.hpp" +#include "operations/OpTensorCopy.hpp" +#include "operations/OpTensorSyncDevice.hpp" +#include "operations/OpTensorSyncLocal.hpp" + +#include "shaders/shaderlogisticregression.hpp" +#include "shaders/shaderopmult.hpp" diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d1d949bd..8311253a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,81 +1,42 @@ # SPDX-License-Identifier: Apache-2.0 +####################### +cmake_minimum_required(VERSION 3.15) ##################################################### -#################### GOOGLETEST ##################### +# Shaders ##################################################### -enable_testing() - -file(GLOB test_kompute_CPP - "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp" -) - -add_executable(test_kompute ${test_kompute_CPP}) - -target_include_directories( - test_kompute PUBLIC - $ - $ - $ -) -target_link_libraries(test_kompute kompute GTest::GTest) - -add_test(NAME test_kompute COMMAND test_kompute) - +add_subdirectory(shaders) ##################################################### -#################### CODECOV ####################### +# Tests ##################################################### -if (KOMPUTE_OPT_CODE_COVERAGE) - if(NOT UNIX) - message( - FATAL_ERROR - "KOMPUTE_OPT_CODE_COVERAGE can only be enabled in unix based systems due to limitation on gcov") +macro(add_kompute_test _TEST_NAME) + add_executable("${_TEST_NAME}_tests" "Test${_TEST_NAME}.cpp" + ${ARGN}) + target_link_libraries("${_TEST_NAME}_tests" PRIVATE GTest::GTest + kompute::kompute + test_shaders + test_shaders_glsl) + add_test(NAME "kompute_${_TEST_NAME}_tests" COMMAND "${_TEST_NAME}_tests") + # Group under the "tests" project folder in IDEs such as Visual Studio. + set_property(TARGET ${_TEST_NAME}_tests PROPERTY FOLDER "tests") + if(WIN32 AND BUILD_SHARED_LIBS) + add_custom_command(TARGET ${_TEST_NAME}_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ $) + add_custom_command(TARGET ${_TEST_NAME}_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ $) endif() - - 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() - +endmacro() + +add_kompute_test(AsyncOperations) +add_kompute_test(Destroy) +add_kompute_test(LogisticRegression) +add_kompute_test(Main) +add_kompute_test(Manager) +add_kompute_test(MultipleAlgoExecutions) +add_kompute_test(OpShadersFromStringAndFile) +add_kompute_test(OpTensorCopy) +add_kompute_test(OpTensorCreate) +add_kompute_test(PushConstant) +add_kompute_test(Sequence) +add_kompute_test(SpecializationConstant) +add_kompute_test(Workgroup) diff --git a/test/TestAsyncOperations.cpp b/test/TestAsyncOperations.cpp index cacc41da..bd52ff39 100644 --- a/test/TestAsyncOperations.cpp +++ b/test/TestAsyncOperations.cpp @@ -6,8 +6,6 @@ #include "kompute/Kompute.hpp" -#include "kompute_test/Shader.hpp" - TEST(TestAsyncOperations, TestManagerParallelExecution) { // This test is built for NVIDIA 1650. It assumes: diff --git a/test/TestDestroy.cpp b/test/TestDestroy.cpp index 8ae82475..e81e3903 100644 --- a/test/TestDestroy.cpp +++ b/test/TestDestroy.cpp @@ -4,7 +4,7 @@ #include "kompute/Kompute.hpp" -#include "kompute_test/Shader.hpp" +#include "shaders/Utils.hpp" TEST(TestDestroy, TestDestroyTensorSingle) { diff --git a/test/TestLogisticRegression.cpp b/test/TestLogisticRegression.cpp index b1ffaef8..d149c477 100644 --- a/test/TestLogisticRegression.cpp +++ b/test/TestLogisticRegression.cpp @@ -4,7 +4,7 @@ #include "kompute/Kompute.hpp" -#include "kompute_test/shaders/shadertest_logistic_regression.hpp" +#include "test_logistic_regression.hpp" TEST(TestLogisticRegression, TestMainLogisticRegression) { @@ -40,12 +40,11 @@ TEST(TestLogisticRegression, TestMainLogisticRegression) mgr.sequence()->eval(params); std::vector spirv = std::vector( - (uint32_t*)kp::shader_data:: - test_shaders_glsl_test_logistic_regression_comp_spv, - (uint32_t*)(kp::shader_data:: - test_shaders_glsl_test_logistic_regression_comp_spv + - kp::shader_data:: - test_shaders_glsl_test_logistic_regression_comp_spv_len)); + (const uint32_t*)kp::TEST_LOGISTIC_REGRESSION_COMP_SPV.data(), + (const uint32_t*)(kp::shader_data:: + test_shaders_glsl_test_logistic_regression_comp_spv + + kp::shader_data:: + test_shaders_glsl_test_logistic_regression_comp_spv_len)); std::shared_ptr algorithm = mgr.algorithm( params, spirv, kp::Workgroup({ 5 }), std::vector({ 5.0 })); diff --git a/test/TestMultipleAlgoExecutions.cpp b/test/TestMultipleAlgoExecutions.cpp index f554f54f..40d15d6e 100644 --- a/test/TestMultipleAlgoExecutions.cpp +++ b/test/TestMultipleAlgoExecutions.cpp @@ -4,7 +4,7 @@ #include "kompute/Kompute.hpp" -#include "kompute_test/Shader.hpp" +#include "shaders/Utils.hpp" TEST(TestMultipleAlgoExecutions, TestEndToEndFunctionality) { diff --git a/test/TestOpShadersFromStringAndFile.cpp b/test/TestOpShadersFromStringAndFile.cpp index 7033816e..550f9e26 100644 --- a/test/TestOpShadersFromStringAndFile.cpp +++ b/test/TestOpShadersFromStringAndFile.cpp @@ -6,7 +6,7 @@ #include "kompute_test/shaders/shadertest_op_custom_shader.hpp" -#include "kompute_test/Shader.hpp" +#include "shaders/Utils.hpp" TEST(TestOpAlgoCreate, ShaderRawDataFromConstructor) { diff --git a/test/TestOpTensorCopy.cpp b/test/TestOpTensorCopy.cpp index c76db897..a272efbd 100644 --- a/test/TestOpTensorCopy.cpp +++ b/test/TestOpTensorCopy.cpp @@ -4,7 +4,7 @@ #include "kompute/Kompute.hpp" -#include "kompute_test/Shader.hpp" +#include "shaders/Utils.hpp" TEST(TestOpTensorCopy, CopyDeviceToDeviceTensor) { diff --git a/test/TestPushConstant.cpp b/test/TestPushConstant.cpp index c305f089..94f6afc4 100644 --- a/test/TestPushConstant.cpp +++ b/test/TestPushConstant.cpp @@ -4,7 +4,7 @@ #include "kompute/Kompute.hpp" -#include "kompute_test/Shader.hpp" +#include "shaders/Utils.hpp" #include "fmt/ranges.h" diff --git a/test/TestSequence.cpp b/test/TestSequence.cpp index 6e968756..7ab14a64 100644 --- a/test/TestSequence.cpp +++ b/test/TestSequence.cpp @@ -4,7 +4,7 @@ #include "kompute/Kompute.hpp" -#include "kompute_test/Shader.hpp" +#include "shaders/Utils.hpp" TEST(TestSequence, SequenceDestructorViaManager) { diff --git a/test/TestSpecializationConstant.cpp b/test/TestSpecializationConstant.cpp index e7bb3926..a1fc4bb3 100644 --- a/test/TestSpecializationConstant.cpp +++ b/test/TestSpecializationConstant.cpp @@ -4,7 +4,7 @@ #include "kompute/Kompute.hpp" -#include "kompute_test/Shader.hpp" +#include "shaders/Utils.hpp" TEST(TestSpecializationConstants, TestTwoConstants) { diff --git a/test/shaders/CMakeLists.txt b/test/shaders/CMakeLists.txt new file mode 100644 index 00000000..64fd07f5 --- /dev/null +++ b/test/shaders/CMakeLists.txt @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: Apache-2.0 +####################### +cmake_minimum_required(VERSION 3.15) + +add_library(test_shaders "Utils.cpp" + "Utils.hpp") + +add_subdirectory(glsl) \ No newline at end of file diff --git a/test/utils/kompute_test/Shader.hpp b/test/shaders/Utils.cpp similarity index 51% rename from test/utils/kompute_test/Shader.hpp rename to test/shaders/Utils.cpp index 33f81f12..85a38b56 100644 --- a/test/utils/kompute_test/Shader.hpp +++ b/test/shaders/Utils.cpp @@ -1,21 +1,13 @@ // SPDX-License-Identifier: Apache-2.0 -#pragma once - +#include "Utils.hpp" +#include #include #include +#include #include -/** - * Compile a single glslang source from string value. This is only meant - * to be used for testing as it's non threadsafe, and it had to be removed - * from the glslang dependency and now can only run the CLI directly due to - * license issues: see https://github.com/KomputeProject/kompute/pull/235 - * - * @param source An individual raw glsl shader in string format - * @return The compiled SPIR-V binary in unsigned int32 format - */ -static std::vector +std::vector compileSource(const std::string& source) { std::ofstream fileOut("tmp_kp_shader.comp"); @@ -24,12 +16,13 @@ compileSource(const std::string& source) if (system( std::string( "glslangValidator -V tmp_kp_shader.comp -o tmp_kp_shader.comp.spv") - .c_str())) + .c_str())) { throw std::runtime_error("Error running glslangValidator command"); + } std::ifstream fileStream("tmp_kp_shader.comp.spv", std::ios::binary); std::vector buffer; buffer.insert( buffer.begin(), std::istreambuf_iterator(fileStream), {}); - return { (uint32_t*)buffer.data(), - (uint32_t*)(buffer.data() + buffer.size()) }; + return { reinterpret_cast(buffer.data()), + reinterpret_cast(buffer.data() + buffer.size()) }; } diff --git a/test/shaders/Utils.hpp b/test/shaders/Utils.hpp new file mode 100644 index 00000000..fa8aa972 --- /dev/null +++ b/test/shaders/Utils.hpp @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include +#include +#include + +/** + * Compile a single glslang source from string value. This is only meant + * to be used for testing as it's non threadsafe, and it had to be removed + * from the glslang dependency and now can only run the CLI directly due to + * license issues: see https://github.com/KomputeProject/kompute/pull/235 + * + * @param source An individual raw glsl shader in string format + * @return The compiled SPIR-V binary in unsigned int32 format + */ +std::vector +compileSource(const std::string& source); diff --git a/test/shaders/glsl/CMakeLists.txt b/test/shaders/glsl/CMakeLists.txt new file mode 100644 index 00000000..41e20772 --- /dev/null +++ b/test/shaders/glsl/CMakeLists.txt @@ -0,0 +1,22 @@ +# SPDX-License-Identifier: Apache-2.0 +####################### +cmake_minimum_required(VERSION 3.15) + +vulkan_compile_shader(INFILE test_logistic_regression.comp + OUTFILE test_logistic_regression.hpp + NAMESPACE "kp") + +vulkan_compile_shader(INFILE test_op_custom_shader.comp + OUTFILE test_op_custom_shader.hpp + NAMESPACE "kp") + +vulkan_compile_shader(INFILE test_workgroup.comp + OUTFILE test_workgroup.hpp + NAMESPACE "kp") + +add_library(test_shaders_glsl "${CMAKE_CURRENT_BINARY_DIR}/test_logistic_regression.hpp" + "${CMAKE_CURRENT_BINARY_DIR}/test_op_custom_shader.hpp" + "${CMAKE_CURRENT_BINARY_DIR}/test_workgroup.hpp") + +set_target_properties(test_shaders_glsl PROPERTIES LINKER_LANGUAGE CXX) +target_include_directories(test_shaders_glsl PUBLIC $) diff --git a/test/shaders/glsl/test_logistic_regression.comp.spv b/test/shaders/glsl/test_logistic_regression.comp.spv deleted file mode 100755 index 2f6883da..00000000 Binary files a/test/shaders/glsl/test_logistic_regression.comp.spv and /dev/null differ diff --git a/test/shaders/glsl/test_op_custom_shader.comp.spv b/test/shaders/glsl/test_op_custom_shader.comp.spv deleted file mode 100755 index 1c1a83c3..00000000 Binary files a/test/shaders/glsl/test_op_custom_shader.comp.spv and /dev/null differ diff --git a/test/shaders/glsl/test_workgroup.comp.spv b/test/shaders/glsl/test_workgroup.comp.spv deleted file mode 100755 index 533d994f..00000000 Binary files a/test/shaders/glsl/test_workgroup.comp.spv and /dev/null differ