Added active log level definitions for kompute
Signed-off-by: Alejandro Saucedo <axsauze@gmail.com>
This commit is contained in:
parent
8b08e7ccb5
commit
11b04510ea
5 changed files with 81 additions and 31 deletions
|
|
@ -17,7 +17,8 @@ option(KOMPUTE_OPT_BUILD_SINGLE_HEADER "Enable if you want to build the single h
|
|||
option(KOMPUTE_OPT_INSTALL "Enable if you want to enable installation" 0)
|
||||
# Build options
|
||||
option(KOMPUTE_OPT_BUILD_PYTHON "Enable if you want to build python bindings" 0)
|
||||
option(KOMPUTE_OPT_ENABLE_SPDLOG "Extra compile flags for Kompute, see docs for full list" 0)
|
||||
option(KOMPUTE_OPT_ENABLE_SPDLOG "Enable to compile with spdlog as the internal logging framework" 0)
|
||||
option(KOMPUTE_OPT_LOG_LEVEL "Provides configuration option for log level 0-7 (debug, info, warn, etc)" -1)
|
||||
option(KOMPUTE_OPT_REPO_SUBMODULE_BUILD "Use the submodule repos instead of external package manager" 0)
|
||||
option(KOMPUTE_OPT_ANDROID_BUILD "Enable android compilation flags required" 0)
|
||||
option(KOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS "Explicitly disable debug layers even on debug" 0)
|
||||
|
|
@ -26,6 +27,11 @@ option(KOMPUTE_OPT_BUILD_AS_SHARED_LIB "Whether to build kompute as shared libra
|
|||
# Build flags
|
||||
set(KOMPUTE_EXTRA_CXX_FLAGS "" CACHE STRING "Extra compile flags for Kompute, see docs for full list")
|
||||
|
||||
# If kompute log level greater or equal to 0 then set flag
|
||||
if(NOT (KOMPUTE_OPT_LOG_LEVEL LESS 0))
|
||||
set(KOMPUTE_EXTRA_CXX_FLAGS "${KOMPUTE_EXTRA_CXX_FLAGS} -DKOMPUTE_LOG_LEVEL=${KOMPUTE_OPT_LOG_LEVEL}")
|
||||
endif()
|
||||
|
||||
if(KOMPUTE_OPT_ENABLE_SPDLOG)
|
||||
set(KOMPUTE_EXTRA_CXX_FLAGS "${KOMPUTE_EXTRA_CXX_FLAGS} -DKOMPUTE_ENABLE_SPDLOG=1")
|
||||
set(SPDLOG_FMT_EXTERNAL ON CACHE BOOL "Enables external fmt as its current dep" FORCE)
|
||||
|
|
|
|||
|
|
@ -23,20 +23,34 @@ This by default configures without any of the extra build tasks (such as buildin
|
|||
- This is the path for your package manager if you use it such as vcpkg
|
||||
* - -DKOMPUTE_OPT_BUILD_TESTS=1
|
||||
- Enable if you wish to build and run the tests (must have deps installed.
|
||||
* - -DKOMPUTE_OPT_CODE_COVERAGE=1
|
||||
- Enable if you wish to build and run code coverage (must have deps installed which are limited to Windows platform)
|
||||
* - -DKOMPUTE_OPT_BUILD_DOCS=1
|
||||
- Enable if you wish to build the docs (must have docs deps installed)
|
||||
* - -DKOMPUTE_OPT_BUILD_SHADERS=1
|
||||
- Enable if you wish to build the shaders into header files (must have docs deps installed)
|
||||
* - -DKOMPUTE_OPT_BUILD_SINGLE_HEADER=1
|
||||
- Option to build the single header file using "quom" utility
|
||||
* - -DKOMPUTE_EXTRA_CXX_FLAGS="..."
|
||||
- Allows you to pass extra config flags to compiler
|
||||
* - -DKOMPUTE_OPT_INSTALL=0
|
||||
- Disables the install step in the cmake file (useful for android build)
|
||||
* - -DKOMPUTE_OPT_BUILD_PYTHON=1
|
||||
- Enable to build python bindings (used internally for python package)
|
||||
* - -DKOMPUTE_OPT_ENABLE_SPDLOG=1
|
||||
- Enable to compile with spdlog as the internal logging framework
|
||||
* - -DKOMPUTE_OPT_LOG_LEVEL=1
|
||||
- Provides configuration option for log level 0-7 (debug, info, warn, etc)
|
||||
* - -DKOMPUTE_OPT_REPO_SUBMODULE_BUILD=1
|
||||
- Use the submodule repos instead of external packages / manager
|
||||
* - -DKOMPUTE_OPT_ANDROID_BUILD=1
|
||||
- Enables android build which includes and excludes relevant libraries
|
||||
* - -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=1
|
||||
- Explicitly disables debug layers even when on debug mode
|
||||
* - -DKOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS=1
|
||||
- Ensures dependencies are referenced as shared libraries for kompute install
|
||||
* - -DKOMPUTE_OPT_BUILD_AS_SHARED_LIB=1
|
||||
- Whether to build Kompute as shared lib instead of static
|
||||
* - -DKOMPUTE_EXTRA_CXX_FLAGS="..."
|
||||
- Allows you to pass extra config flags to compiler
|
||||
|
||||
|
||||
Compile Flags
|
||||
|
|
@ -57,10 +71,10 @@ Compile Flags
|
|||
- Minor version to use for the Vulkan SDK
|
||||
* - -DKOMPUTE_ENABLE_SPDLOG=1
|
||||
- Enables the build with SPDLOG and FMT dependencies (must be installed)
|
||||
* - -DKOMPUTE_LOG_VERRIDE=1
|
||||
* - -DKOMPUTE_LOG_OVERRIDE=1
|
||||
- Does not define the SPDLOG_\ :raw-html-m2r:`<LEVEL>` macros if these are to be overridden
|
||||
* - -DSPDLOG_ACTIVE_LEVEL
|
||||
- The level for the log level on compile level (whether spdlog is enabled)
|
||||
* - -DKOMPUTE_LOG_LEVEL
|
||||
- The level for the log level on compile level (also sets spdlog level if enabled)
|
||||
* - -DVVK_USE_PLATFORM_ANDROID_KHR
|
||||
- Flag to enable android imports in kompute (enabled with -DKOMPUTE_OPT_ANDROID_BUILD)
|
||||
* - -DRELEASE=1
|
||||
|
|
|
|||
|
|
@ -620,13 +620,28 @@ typedef std::vector<float> Constants;
|
|||
KOMPUTE_VK_API_MAJOR_VERSION, KOMPUTE_VK_API_MINOR_VERSION, 0)
|
||||
#endif // KOMPUTE_VK_API_VERSION
|
||||
|
||||
// SPDLOG_ACTIVE_LEVEL must be defined before spdlog.h import
|
||||
#ifndef SPDLOG_ACTIVE_LEVEL
|
||||
// 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 SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_DEBUG
|
||||
#define KOMPUTE_LOG_LEVEL KOMPUTE_LOG_LEVEL_DEBUG
|
||||
#else
|
||||
#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_INFO
|
||||
#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)
|
||||
|
|
@ -645,7 +660,7 @@ extern py::object kp_debug, kp_info, kp_warning, kp_error;
|
|||
#define KP_LOG_ERROR(...) SPDLOG_ERROR(__VA_ARGS__)
|
||||
#else
|
||||
#include <iostream>
|
||||
#if SPDLOG_ACTIVE_LEVEL > 1
|
||||
#if KOMPUTE_LOG_LEVEL > 1
|
||||
#define KP_LOG_DEBUG(...)
|
||||
#else
|
||||
#if defined(VK_USE_PLATFORM_ANDROID_KHR)
|
||||
|
|
@ -663,9 +678,9 @@ extern py::object kp_debug, kp_info, kp_warning, kp_error;
|
|||
__LINE__, \
|
||||
fmt::format(__VA_ARGS__))
|
||||
#endif // VK_USE_PLATFORM_ANDROID_KHR
|
||||
#endif // SPDLOG_ACTIVE_LEVEL > 1
|
||||
#endif // KOMPUTE_LOG_LEVEL > 1
|
||||
|
||||
#if SPDLOG_ACTIVE_LEVEL > 2
|
||||
#if KOMPUTE_LOG_LEVEL > 2
|
||||
#define KP_LOG_INFO(...)
|
||||
#else
|
||||
#if defined(VK_USE_PLATFORM_ANDROID_KHR)
|
||||
|
|
@ -683,9 +698,9 @@ extern py::object kp_debug, kp_info, kp_warning, kp_error;
|
|||
__LINE__, \
|
||||
fmt::format(__VA_ARGS__))
|
||||
#endif // VK_USE_PLATFORM_ANDROID_KHR
|
||||
#endif // SPDLOG_ACTIVE_LEVEL > 2
|
||||
#endif // KOMPUTE_LOG_LEVEL > 2
|
||||
|
||||
#if SPDLOG_ACTIVE_LEVEL > 3
|
||||
#if KOMPUTE_LOG_LEVEL > 3
|
||||
#define KP_LOG_WARN(...)
|
||||
#else
|
||||
#if defined(VK_USE_PLATFORM_ANDROID_KHR)
|
||||
|
|
@ -703,9 +718,9 @@ extern py::object kp_debug, kp_info, kp_warning, kp_error;
|
|||
__LINE__, \
|
||||
fmt::format(__VA_ARGS__))
|
||||
#endif // VK_USE_PLATFORM_ANDROID_KHR
|
||||
#endif // SPDLOG_ACTIVE_LEVEL > 3
|
||||
#endif // KOMPUTE_LOG_LEVEL > 3
|
||||
|
||||
#if SPDLOG_ACTIVE_LEVEL > 4
|
||||
#if KOMPUTE_LOG_LEVEL > 4
|
||||
#define KP_LOG_ERROR(...)
|
||||
#else
|
||||
#if defined(VK_USE_PLATFORM_ANDROID_KHR)
|
||||
|
|
@ -723,7 +738,7 @@ extern py::object kp_debug, kp_info, kp_warning, kp_error;
|
|||
__LINE__, \
|
||||
fmt::format(__VA_ARGS__))
|
||||
#endif // VK_USE_PLATFORM_ANDROID_KHR
|
||||
#endif // SPDLOG_ACTIVE_LEVEL > 4
|
||||
#endif // KOMPUTE_LOG_LEVEL > 4
|
||||
#endif // KOMPUTE_SPDLOG_ENABLED
|
||||
#endif // KOMPUTE_LOG_OVERRIDE
|
||||
|
||||
|
|
|
|||
|
|
@ -32,13 +32,28 @@ typedef std::vector<float> Constants;
|
|||
KOMPUTE_VK_API_MAJOR_VERSION, KOMPUTE_VK_API_MINOR_VERSION, 0)
|
||||
#endif // KOMPUTE_VK_API_VERSION
|
||||
|
||||
// SPDLOG_ACTIVE_LEVEL must be defined before spdlog.h import
|
||||
#ifndef SPDLOG_ACTIVE_LEVEL
|
||||
// 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 SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_DEBUG
|
||||
#define KOMPUTE_LOG_LEVEL KOMPUTE_LOG_LEVEL_DEBUG
|
||||
#else
|
||||
#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_INFO
|
||||
#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)
|
||||
|
|
@ -57,7 +72,7 @@ extern py::object kp_debug, kp_info, kp_warning, kp_error;
|
|||
#define KP_LOG_ERROR(...) SPDLOG_ERROR(__VA_ARGS__)
|
||||
#else
|
||||
#include <iostream>
|
||||
#if SPDLOG_ACTIVE_LEVEL > 1
|
||||
#if KOMPUTE_LOG_LEVEL > 1
|
||||
#define KP_LOG_DEBUG(...)
|
||||
#else
|
||||
#if defined(VK_USE_PLATFORM_ANDROID_KHR)
|
||||
|
|
@ -75,9 +90,9 @@ extern py::object kp_debug, kp_info, kp_warning, kp_error;
|
|||
__LINE__, \
|
||||
fmt::format(__VA_ARGS__))
|
||||
#endif // VK_USE_PLATFORM_ANDROID_KHR
|
||||
#endif // SPDLOG_ACTIVE_LEVEL > 1
|
||||
#endif // KOMPUTE_LOG_LEVEL > 1
|
||||
|
||||
#if SPDLOG_ACTIVE_LEVEL > 2
|
||||
#if KOMPUTE_LOG_LEVEL > 2
|
||||
#define KP_LOG_INFO(...)
|
||||
#else
|
||||
#if defined(VK_USE_PLATFORM_ANDROID_KHR)
|
||||
|
|
@ -95,9 +110,9 @@ extern py::object kp_debug, kp_info, kp_warning, kp_error;
|
|||
__LINE__, \
|
||||
fmt::format(__VA_ARGS__))
|
||||
#endif // VK_USE_PLATFORM_ANDROID_KHR
|
||||
#endif // SPDLOG_ACTIVE_LEVEL > 2
|
||||
#endif // KOMPUTE_LOG_LEVEL > 2
|
||||
|
||||
#if SPDLOG_ACTIVE_LEVEL > 3
|
||||
#if KOMPUTE_LOG_LEVEL > 3
|
||||
#define KP_LOG_WARN(...)
|
||||
#else
|
||||
#if defined(VK_USE_PLATFORM_ANDROID_KHR)
|
||||
|
|
@ -115,9 +130,9 @@ extern py::object kp_debug, kp_info, kp_warning, kp_error;
|
|||
__LINE__, \
|
||||
fmt::format(__VA_ARGS__))
|
||||
#endif // VK_USE_PLATFORM_ANDROID_KHR
|
||||
#endif // SPDLOG_ACTIVE_LEVEL > 3
|
||||
#endif // KOMPUTE_LOG_LEVEL > 3
|
||||
|
||||
#if SPDLOG_ACTIVE_LEVEL > 4
|
||||
#if KOMPUTE_LOG_LEVEL > 4
|
||||
#define KP_LOG_ERROR(...)
|
||||
#else
|
||||
#if defined(VK_USE_PLATFORM_ANDROID_KHR)
|
||||
|
|
@ -135,6 +150,6 @@ extern py::object kp_debug, kp_info, kp_warning, kp_error;
|
|||
__LINE__, \
|
||||
fmt::format(__VA_ARGS__))
|
||||
#endif // VK_USE_PLATFORM_ANDROID_KHR
|
||||
#endif // SPDLOG_ACTIVE_LEVEL > 4
|
||||
#endif // KOMPUTE_LOG_LEVEL > 4
|
||||
#endif // KOMPUTE_SPDLOG_ENABLED
|
||||
#endif // KOMPUTE_LOG_OVERRIDE
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ main(int argc, char* argv[])
|
|||
|
||||
#if KOMPUTE_ENABLE_SPDLOG
|
||||
spdlog::set_level(
|
||||
static_cast<spdlog::level::level_enum>(SPDLOG_ACTIVE_LEVEL));
|
||||
static_cast<spdlog::level::level_enum>(KOMPUTE_LOG_LEVEL));
|
||||
#endif
|
||||
|
||||
return RUN_ALL_TESTS();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue