Updated SPDLOG as an optional dependency
This commit is contained in:
parent
0410ae0db6
commit
36a60922ba
19 changed files with 151 additions and 77 deletions
|
|
@ -23,7 +23,7 @@ Algorithm::~Algorithm()
|
|||
SPDLOG_DEBUG("Kompute Algorithm Destructor started");
|
||||
|
||||
if (!this->mDevice) {
|
||||
spdlog::error(
|
||||
SPDLOG_ERROR(
|
||||
"Kompute Algorithm destructor reached with null Device pointer");
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
find_package(fmt REQUIRED)
|
||||
find_package(spdlog REQUIRED)
|
||||
find_package(Vulkan REQUIRED)
|
||||
|
||||
|
|
@ -25,11 +24,16 @@ target_include_directories(
|
|||
|
||||
target_link_libraries(
|
||||
kompute
|
||||
fmt::fmt
|
||||
spdlog::spdlog
|
||||
Vulkan::Vulkan
|
||||
)
|
||||
|
||||
if(KOMPUTE_OPT_ENABLE_SPDLOG)
|
||||
target_link_libraries(
|
||||
kompute
|
||||
spdlog::spdlog
|
||||
)
|
||||
endif()
|
||||
|
||||
add_dependencies(kompute
|
||||
build_shaders
|
||||
build_single_header)
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ Manager::~Manager()
|
|||
SPDLOG_DEBUG("Kompute Manager Destructor started");
|
||||
|
||||
if (this->mDevice == nullptr) {
|
||||
spdlog::error(
|
||||
SPDLOG_ERROR(
|
||||
"Kompute Manager destructor reached with null Device pointer");
|
||||
return;
|
||||
}
|
||||
|
|
@ -61,13 +61,13 @@ Manager::~Manager()
|
|||
}
|
||||
|
||||
if (this->mFreeDevice) {
|
||||
spdlog::info("Destroying device");
|
||||
SPDLOG_INFO("Destroying device");
|
||||
this->mDevice->destroy();
|
||||
SPDLOG_DEBUG("Kompute Manager Destroyed Device");
|
||||
}
|
||||
|
||||
if (this->mInstance == nullptr) {
|
||||
spdlog::error(
|
||||
SPDLOG_ERROR(
|
||||
"Kompute Manager destructor reached with null Instance pointer");
|
||||
return;
|
||||
}
|
||||
|
|
@ -214,7 +214,7 @@ Manager::createDevice()
|
|||
vk::PhysicalDeviceProperties physicalDeviceProperties =
|
||||
physicalDevice.getProperties();
|
||||
|
||||
spdlog::info("Using physical device index {} found {}",
|
||||
SPDLOG_INFO("Using physical device index {} found {}",
|
||||
this->mPhysicalDeviceIndex,
|
||||
physicalDeviceProperties.deviceName);
|
||||
|
||||
|
|
@ -234,7 +234,7 @@ Manager::createDevice()
|
|||
}
|
||||
|
||||
if (this->mComputeQueueFamilyIndex < 0) {
|
||||
spdlog::critical("Compute queue is not supported");
|
||||
throw std::runtime_error("Compute queue is not supported");
|
||||
}
|
||||
|
||||
const float defaultQueuePriority(0.0f);
|
||||
|
|
|
|||
|
|
@ -28,15 +28,15 @@ Sequence::~Sequence()
|
|||
SPDLOG_DEBUG("Kompute Sequence Destructor started");
|
||||
|
||||
if (!this->mDevice) {
|
||||
spdlog::error(
|
||||
SPDLOG_ERROR(
|
||||
"Kompute Sequence destructor reached with null Device pointer");
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->mFreeCommandBuffer) {
|
||||
spdlog::info("Freeing CommandBuffer");
|
||||
SPDLOG_INFO("Freeing CommandBuffer");
|
||||
if (!this->mCommandBuffer) {
|
||||
spdlog::error("Kompute Sequence destructor reached with null "
|
||||
SPDLOG_ERROR("Kompute Sequence destructor reached with null "
|
||||
"CommandPool pointer");
|
||||
return;
|
||||
}
|
||||
|
|
@ -46,9 +46,9 @@ Sequence::~Sequence()
|
|||
}
|
||||
|
||||
if (this->mFreeCommandPool) {
|
||||
spdlog::info("Destroying CommandPool");
|
||||
SPDLOG_INFO("Destroying CommandPool");
|
||||
if (this->mCommandPool == nullptr) {
|
||||
spdlog::error("Kompute Sequence destructor reached with null "
|
||||
SPDLOG_ERROR("Kompute Sequence destructor reached with null "
|
||||
"CommandPool pointer");
|
||||
return;
|
||||
}
|
||||
|
|
@ -71,7 +71,7 @@ Sequence::begin()
|
|||
SPDLOG_DEBUG("Kompute sequence called BEGIN");
|
||||
|
||||
if (this->isRecording()) {
|
||||
spdlog::warn("Kompute Sequence begin called when already recording");
|
||||
SPDLOG_WARN("Kompute Sequence begin called when already recording");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -80,11 +80,11 @@ Sequence::begin()
|
|||
}
|
||||
|
||||
if (!this->mRecording) {
|
||||
spdlog::info("Kompute Sequence command recording BEGIN");
|
||||
SPDLOG_INFO("Kompute Sequence command recording BEGIN");
|
||||
this->mCommandBuffer->begin(vk::CommandBufferBeginInfo());
|
||||
this->mRecording = true;
|
||||
} else {
|
||||
spdlog::warn("Kompute Sequence attempted to start command recording "
|
||||
SPDLOG_WARN("Kompute Sequence attempted to start command recording "
|
||||
"but recording already started");
|
||||
}
|
||||
return true;
|
||||
|
|
@ -96,7 +96,7 @@ Sequence::end()
|
|||
SPDLOG_DEBUG("Kompute Sequence calling END");
|
||||
|
||||
if (!this->isRecording()) {
|
||||
spdlog::warn("Kompute Sequence end called when not recording");
|
||||
SPDLOG_WARN("Kompute Sequence end called when not recording");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -105,11 +105,11 @@ Sequence::end()
|
|||
}
|
||||
|
||||
if (this->mRecording) {
|
||||
spdlog::info("Kompute Sequence command recording END");
|
||||
SPDLOG_INFO("Kompute Sequence command recording END");
|
||||
this->mCommandBuffer->end();
|
||||
this->mRecording = false;
|
||||
} else {
|
||||
spdlog::warn("Kompute Sequence attempted to end command recording but "
|
||||
SPDLOG_WARN("Kompute Sequence attempted to end command recording but "
|
||||
"recording not started");
|
||||
}
|
||||
return true;
|
||||
|
|
@ -121,7 +121,7 @@ Sequence::eval()
|
|||
SPDLOG_DEBUG("Kompute sequence compute recording EVAL");
|
||||
|
||||
if (this->isRecording()) {
|
||||
spdlog::warn("Kompute Sequence eval called when still recording");
|
||||
SPDLOG_WARN("Kompute Sequence eval called when still recording");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
|
||||
#if DEBUG
|
||||
#include <fmt/ranges.h>
|
||||
#if KOMPUTE_SPDLOG_ENABLED
|
||||
// Only enabled if spdlog is enabled
|
||||
#include <spdlog/fmt/ranges.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "kompute/Tensor.hpp"
|
||||
|
|
@ -169,7 +172,7 @@ Tensor::mapDataFromHostMemory()
|
|||
SPDLOG_DEBUG("Kompute Tensor mapping data from host buffer");
|
||||
|
||||
if (this->mTensorType != TensorTypes::eStaging) {
|
||||
spdlog::error(
|
||||
SPDLOG_ERROR(
|
||||
"Mapping tensor data manually from DEVICE buffer instead of "
|
||||
"using record GPU command with staging buffer");
|
||||
return;
|
||||
|
|
@ -191,7 +194,7 @@ Tensor::mapDataIntoHostMemory()
|
|||
SPDLOG_DEBUG("Kompute Tensor local mapping tensor data to host buffer");
|
||||
|
||||
if (this->mTensorType != TensorTypes::eStaging) {
|
||||
spdlog::error(
|
||||
SPDLOG_ERROR(
|
||||
"Mapping tensor data manually to DEVICE memory instead of "
|
||||
"using record GPU command with staging buffer");
|
||||
return;
|
||||
|
|
@ -335,14 +338,14 @@ Tensor::freeMemoryDestroyGPUResources()
|
|||
this->mIsInit = false;
|
||||
|
||||
if (!this->mDevice) {
|
||||
spdlog::error(
|
||||
SPDLOG_ERROR(
|
||||
"Kompute Tensor destructor reached with null Device pointer");
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->mFreeBuffer) {
|
||||
if (!this->mBuffer) {
|
||||
spdlog::error(
|
||||
SPDLOG_ERROR(
|
||||
"Kompose Tensor expected to free buffer but got null buffer");
|
||||
} else {
|
||||
SPDLOG_DEBUG("Kompose Tensor destroying buffer");
|
||||
|
|
@ -353,7 +356,7 @@ Tensor::freeMemoryDestroyGPUResources()
|
|||
|
||||
if (this->mFreeMemory) {
|
||||
if (!this->mMemory) {
|
||||
spdlog::error(
|
||||
SPDLOG_ERROR(
|
||||
"Kompose Tensor expected to free buffer but got null memory");
|
||||
} else {
|
||||
SPDLOG_DEBUG("Kompose Tensor freeing memory");
|
||||
|
|
|
|||
|
|
@ -4,7 +4,36 @@
|
|||
|
||||
// SPDLOG_ACTIVE_LEVEL must be defined before spdlog.h import
|
||||
#if DEBUG
|
||||
#ifndef SPDLOG_ACTIVE_LEVEL
|
||||
#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_DEBUG
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef KOMPUTE_LOG_OVERRIDE
|
||||
#if KOMPUTE_ENABLE_SPDLOG
|
||||
#include <spdlog/spdlog.h>
|
||||
#else
|
||||
#include <iostream>
|
||||
#if SPDLOG_ACTIVE_LEVEL > 1
|
||||
#define SPDLOG_DEBUG(message, ...)
|
||||
#else
|
||||
#define SPDLOG_DEBUG(message, ...) std::cout << "DEBUG: " << message << std::endl
|
||||
#endif // SPDLOG_ACTIVE_LEVEL > 1
|
||||
#if SPDLOG_ACTIVE_LEVEL > 2
|
||||
#define SPDLOG_INFO(message, ...)
|
||||
#else
|
||||
#define SPDLOG_INFO(message, ...) std::cout << "INFO: " << message << std::endl
|
||||
#endif // SPDLOG_ACTIVE_LEVEL > 2
|
||||
#if SPDLOG_ACTIVE_LEVEL > 3
|
||||
#define SPDLOG_WARN(message, ...)
|
||||
#else
|
||||
#define SPDLOG_WARN(message, ...) std::cout << "WARNING: " << message << std::endl
|
||||
#endif // SPDLOG_ACTIVE_LEVEL > 3
|
||||
#if SPDLOG_ACTIVE_LEVEL > 4
|
||||
#define SPDLOG_ERROR(message, ...)
|
||||
#else
|
||||
#define SPDLOG_ERROR(message, ...) std::cout << "ERROR: " << message << std::endl
|
||||
#endif // SPDLOG_ACTIVE_LEVEL > 4
|
||||
#endif //KOMPUTE_SPDLOG_ENABLED
|
||||
#endif // KOMPUTE_LOG_OVERRIDE
|
||||
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ class Sequence
|
|||
SPDLOG_DEBUG("Kompute Sequence record function started");
|
||||
|
||||
if (!this->isRecording()) {
|
||||
spdlog::error(
|
||||
SPDLOG_ERROR(
|
||||
"Kompute sequence record attempted when not record BEGIN");
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ OpAlgoBase<tX, tY, tZ>::OpAlgoBase(std::shared_ptr<vk::PhysicalDevice> physicalD
|
|||
this->mY = 1;
|
||||
this->mZ = 1;
|
||||
}
|
||||
spdlog::info("Kompute OpAlgoBase dispatch size X: {}, Y: {}, Z: {}",
|
||||
SPDLOG_INFO("Kompute OpAlgoBase dispatch size X: {}, Y: {}, Z: {}",
|
||||
this->mX,
|
||||
this->mY,
|
||||
this->mZ);
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class OpBase
|
|||
SPDLOG_DEBUG("Kompute OpBase destructor started");
|
||||
|
||||
if (!this->mDevice) {
|
||||
spdlog::warn("Kompute OpBase destructor called with empty device");
|
||||
SPDLOG_WARN("Kompute OpBase destructor called with empty device");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -69,7 +69,7 @@ class OpBase
|
|||
if (tensor && tensor->isInit()) {
|
||||
tensor->freeMemoryDestroyGPUResources();
|
||||
} else {
|
||||
spdlog::error("Kompute OpBase expected to free "
|
||||
SPDLOG_ERROR("Kompute OpBase expected to free "
|
||||
"tensor but has already been freed.");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue