Amended SPDLOG_X log functions to be KP_LOG_X

This commit is contained in:
Alejandro Saucedo
2021-02-21 11:51:34 +00:00
parent db6aa3e1e3
commit 29c50e5728
21 changed files with 304 additions and 296 deletions

View File

@@ -67,7 +67,7 @@ mk_cmake:
-DKOMPUTE_OPT_BUILD_DOCS=1 \
-DKOMPUTE_OPT_BUILD_SHADERS=1 \
-DKOMPUTE_OPT_BUILD_SINGLE_HEADER=1 \
-DKOMPUTE_OPT_ENABLE_SPDLOG=0 \
-DKOMPUTE_OPT_ENABLE_SPDLOG=1 \
-DKOMPUTE_OPT_CODE_COVERAGE=1 \
-G "Unix Makefiles"

View File

@@ -51,12 +51,12 @@ extern "C" {
JNIEXPORT jboolean JNICALL
Java_com_ethicalml_kompute_KomputeJni_initVulkan(JNIEnv *env, jobject thiz) {
SPDLOG_INFO("Initialising vulkan");
KP_LOG_INFO("Initialising vulkan");
uint32_t totalRetries = 0;
while (totalRetries < KOMPUTE_VK_INIT_RETRIES) {
SPDLOG_INFO("VULKAN LOAD TRY NUMBER: %u", totalRetries);
KP_LOG_INFO("VULKAN LOAD TRY NUMBER: %u", totalRetries);
if(InitVulkan()) {
break;
}
@@ -76,7 +76,7 @@ Java_com_ethicalml_kompute_KomputeJni_kompute(
jfloatArray xjJFloatArr,
jfloatArray yJFloatArr) {
SPDLOG_INFO("Creating manager");
KP_LOG_INFO("Creating manager");
std::vector<float> xiVector = jfloatArrayToVector(env, xiJFloatArr);
std::vector<float> xjVector = jfloatArrayToVector(env, xjJFloatArr);
@@ -98,7 +98,7 @@ Java_com_ethicalml_kompute_KomputeJni_komputeParams(
jfloatArray xjJFloatArr,
jfloatArray yJFloatArr) {
SPDLOG_INFO("Creating manager");
KP_LOG_INFO("Creating manager");
std::vector<float> xiVector = jfloatArrayToVector(env, xiJFloatArr);
std::vector<float> xjVector = jfloatArrayToVector(env, xjJFloatArr);

View File

@@ -92,10 +92,10 @@ void KomputeModelMLNode::train(Array yArr, Array xIArr, Array xJArr) {
}
}
SPDLOG_INFO("RESULT: <<<<<<<<<<<<<<<<<<<");
SPDLOG_INFO(wIn->data()[0]);
SPDLOG_INFO(wIn->data()[1]);
SPDLOG_INFO(bIn->data()[0]);
KP_LOG_INFO("RESULT: <<<<<<<<<<<<<<<<<<<");
KP_LOG_INFO(wIn->data()[0]);
KP_LOG_INFO(wIn->data()[1]);
KP_LOG_INFO(bIn->data()[0]);
this->mWeights = kp::Tensor(wIn->data());
this->mBias = kp::Tensor(bIn->data());
@@ -127,7 +127,7 @@ Array KomputeModelMLNode::predict(Array xI, Array xJ) {
Array KomputeModelMLNode::get_params() {
Array retArray;
SPDLOG_INFO(this->mWeights.size() + this->mBias.size());
KP_LOG_INFO(this->mWeights.size() + this->mBias.size());
if(this->mWeights.size() + this->mBias.size() == 0) {
return retArray;

View File

@@ -96,10 +96,10 @@ void KomputeModelML::train(Array yArr, Array xIArr, Array xJArr) {
}
}
SPDLOG_INFO("RESULT: <<<<<<<<<<<<<<<<<<<");
SPDLOG_INFO(wIn->data()[0]);
SPDLOG_INFO(wIn->data()[1]);
SPDLOG_INFO(bIn->data()[0]);
KP_LOG_INFO("RESULT: <<<<<<<<<<<<<<<<<<<");
KP_LOG_INFO(wIn->data()[0]);
KP_LOG_INFO(wIn->data()[1]);
KP_LOG_INFO(bIn->data()[0]);
this->mWeights = kp::Tensor(wIn->data());
this->mBias = kp::Tensor(bIn->data());
@@ -131,7 +131,7 @@ Array KomputeModelML::predict(Array xI, Array xJ) {
Array KomputeModelML::get_params() {
Array retArray;
SPDLOG_INFO(this->mWeights.size() + this->mBias.size());
KP_LOG_INFO(this->mWeights.size() + this->mBias.size());
if(this->mWeights.size() + this->mBias.size() == 0) {
return retArray;

View File

@@ -50,57 +50,61 @@ extern py::object kp_debug, kp_info, kp_warning, kp_error;
#ifndef KOMPUTE_LOG_OVERRIDE
#if KOMPUTE_ENABLE_SPDLOG
#include <spdlog/spdlog.h>
#define KP_LOG_DEBUG(...) SPDLOG_DEBUG(__VA_ARGS__)
#define KP_LOG_INFO(...) SPDLOG_INFO(__VA_ARGS__)
#define KP_LOG_WARN(...) SPDLOG_WARN(__VA_ARGS__)
#define KP_LOG_ERROR(...) SPDLOG_ERROR(__VA_ARGS__)
#else
#include <iostream>
#if SPDLOG_ACTIVE_LEVEL > 1
#define SPDLOG_DEBUG(...)
#define KP_LOG_DEBUG(...)
#else
#if defined(VK_USE_PLATFORM_ANDROID_KHR)
#define SPDLOG_DEBUG(...) \
#define KP_LOG_DEBUG(...) \
((void)__android_log_print(ANDROID_LOG_DEBUG, KOMPUTE_LOG_TAG, fmt::format(__VA_ARGS__)))
#elif defined(KOMPUTE_BUILD_PYTHON)
#define SPDLOG_DEBUG(...) kp_debug(fmt::format(__VA_ARGS__))
#define KP_LOG_DEBUG(...) kp_debug(fmt::format(__VA_ARGS__))
#else
#define SPDLOG_DEBUG(...) fmt::print("[{} {}] [debug] [{}:{}] {}\n", __DATE__, __TIME__, __FILE__, __LINE__, fmt::format(__VA_ARGS__))
#define KP_LOG_DEBUG(...) fmt::print("[{} {}] [debug] [{}:{}] {}\n", __DATE__, __TIME__, __FILE__, __LINE__, fmt::format(__VA_ARGS__))
#endif // VK_USE_PLATFORM_ANDROID_KHR
#endif // SPDLOG_ACTIVE_LEVEL > 1
#if SPDLOG_ACTIVE_LEVEL > 2
#define SPDLOG_INFO(...)
#define KP_LOG_INFO(...)
#else
#if defined(VK_USE_PLATFORM_ANDROID_KHR)
#define SPDLOG_INFO(...) \
#define KP_LOG_INFO(...) \
((void)__android_log_print(ANDROID_LOG_INFO, KOMPUTE_LOG_TAG, fmt::format(__VA_ARGS__)))
#elif defined(KOMPUTE_BUILD_PYTHON)
#define SPDLOG_INFO(...) kp_info(fmt::format(__VA_ARGS__))
#define KP_LOG_INFO(...) kp_info(fmt::format(__VA_ARGS__))
#else
#define SPDLOG_INFO(...) fmt::print("[{} {}] [debug] [{}:{}] {}\n", __DATE__, __TIME__, __FILE__, __LINE__, fmt::format(__VA_ARGS__))
#define KP_LOG_INFO(...) fmt::print("[{} {}] [debug] [{}:{}] {}\n", __DATE__, __TIME__, __FILE__, __LINE__, fmt::format(__VA_ARGS__))
#endif // VK_USE_PLATFORM_ANDROID_KHR
#endif // SPDLOG_ACTIVE_LEVEL > 2
#if SPDLOG_ACTIVE_LEVEL > 3
#define SPDLOG_WARN(...)
#define KP_LOG_WARN(...)
#else
#if defined(VK_USE_PLATFORM_ANDROID_KHR)
#define SPDLOG_WARN(...) \
#define KP_LOG_WARN(...) \
((void)__android_log_print(ANDROID_LOG_WARN, KOMPUTE_LOG_TAG, fmt::format(__VA_ARGS__)))
#elif defined(KOMPUTE_BUILD_PYTHON)
#define SPDLOG_WARN(...) kp_warning(fmt::format(__VA_ARGS__))
#define KP_LOG_WARN(...) kp_warning(fmt::format(__VA_ARGS__))
#else
#define SPDLOG_WARN(...) fmt::print("[{} {}] [debug] [{}:{}] {}\n", __DATE__, __TIME__, __FILE__, __LINE__, fmt::format(__VA_ARGS__))
#define KP_LOG_WARN(...) fmt::print("[{} {}] [debug] [{}:{}] {}\n", __DATE__, __TIME__, __FILE__, __LINE__, fmt::format(__VA_ARGS__))
#endif // VK_USE_PLATFORM_ANDROID_KHR
#endif // SPDLOG_ACTIVE_LEVEL > 3
#if SPDLOG_ACTIVE_LEVEL > 4
#define SPDLOG_ERROR(...)
#define KP_LOG_ERROR(...)
#else
#if defined(VK_USE_PLATFORM_ANDROID_KHR)
#define SPDLOG_ERROR(...) \
#define KP_LOG_ERROR(...) \
((void)__android_log_print(ANDROID_LOG_ERROR, KOMPUTE_LOG_TAG, fmt::format(__VA_ARGS__)))
#elif defined(KOMPUTE_BUILD_PYTHON)
#define SPDLOG_ERROR(...) kp_error(fmt::format(__VA_ARGS__))
#define KP_LOG_ERROR(...) kp_error(fmt::format(__VA_ARGS__))
#else
#define SPDLOG_ERROR(...) fmt::print("[{} {}] [debug] [{}:{}] {}\n", __DATE__, __TIME__, __FILE__, __LINE__, fmt::format(__VA_ARGS__))
#define KP_LOG_ERROR(...) fmt::print("[{} {}] [debug] [{}:{}] {}\n", __DATE__, __TIME__, __FILE__, __LINE__, fmt::format(__VA_ARGS__))
#endif // VK_USE_PLATFORM_ANDROID_KHR
#endif // SPDLOG_ACTIVE_LEVEL > 4
#endif // KOMPUTE_SPDLOG_ENABLED
@@ -1006,7 +1010,7 @@ class OpBase
/**
* Base constructor, should not be used unless explicitly intended.
*/
OpBase() { SPDLOG_DEBUG("Compute OpBase base constructor"); }
OpBase() { KP_LOG_DEBUG("Compute OpBase base constructor"); }
/**
* Default constructor with parameters that provides the bare minimum
@@ -1023,7 +1027,7 @@ class OpBase
std::shared_ptr<vk::CommandBuffer> commandBuffer,
std::vector<std::shared_ptr<Tensor>>& tensors)
{
SPDLOG_DEBUG("Compute OpBase constructor with params");
KP_LOG_DEBUG("Compute OpBase constructor with params");
this->mPhysicalDevice = physicalDevice;
this->mDevice = device;
@@ -1038,20 +1042,20 @@ class OpBase
*/
virtual ~OpBase()
{
SPDLOG_DEBUG("Kompute OpBase destructor started");
KP_LOG_DEBUG("Kompute OpBase destructor started");
if (!this->mDevice) {
SPDLOG_WARN("Kompute OpBase destructor called with empty device");
KP_LOG_WARN("Kompute OpBase destructor called with empty device");
return;
}
if (this->mFreeTensors) {
SPDLOG_DEBUG("Kompute OpBase freeing tensors");
KP_LOG_DEBUG("Kompute OpBase freeing tensors");
for (std::shared_ptr<Tensor> tensor : this->mTensors) {
if (tensor && tensor->isInit()) {
tensor->freeMemoryDestroyGPUResources();
} else {
SPDLOG_WARN("Kompute OpBase expected to free "
KP_LOG_WARN("Kompute OpBase expected to free "
"tensor but has already been freed.");
}
}
@@ -1234,15 +1238,15 @@ class Sequence
"Kompute Sequence record(...) template only valid with "
"OpBase derived classes");
SPDLOG_DEBUG("Kompute Sequence record function started");
KP_LOG_DEBUG("Kompute Sequence record function started");
if (!this->isRecording()) {
SPDLOG_ERROR(
KP_LOG_ERROR(
"Kompute sequence record attempted when not record BEGIN");
return false;
}
SPDLOG_DEBUG("Kompute Sequence creating OpBase derived class instance");
KP_LOG_DEBUG("Kompute Sequence creating OpBase derived class instance");
T* op = new T(this->mPhysicalDevice,
this->mDevice,
this->mCommandBuffer,
@@ -1253,11 +1257,11 @@ class Sequence
std::unique_ptr<OpBase> baseOpPtr{ baseOp };
SPDLOG_DEBUG(
KP_LOG_DEBUG(
"Kompute Sequence running init on OpBase derived class instance");
baseOpPtr->init();
SPDLOG_DEBUG(
KP_LOG_DEBUG(
"Kompute Sequence running record on OpBase derived class instance");
baseOpPtr->record();
@@ -1423,23 +1427,23 @@ class Manager
std::string sequenceName,
TArgs&&... params)
{
SPDLOG_DEBUG("Kompute Manager evalOp triggered");
KP_LOG_DEBUG("Kompute Manager evalOp triggered");
std::shared_ptr<kp::Sequence> sq =
this->sequence(sequenceName);
SPDLOG_DEBUG("Kompute Manager evalOp running sequence BEGIN");
KP_LOG_DEBUG("Kompute Manager evalOp running sequence BEGIN");
sq->begin();
SPDLOG_DEBUG("Kompute Manager evalOp running sequence RECORD");
KP_LOG_DEBUG("Kompute Manager evalOp running sequence RECORD");
sq->record<T>(tensors, std::forward<TArgs>(params)...);
SPDLOG_DEBUG("Kompute Manager evalOp running sequence END");
KP_LOG_DEBUG("Kompute Manager evalOp running sequence END");
sq->end();
SPDLOG_DEBUG("Kompute Manager evalOp running sequence EVAL");
KP_LOG_DEBUG("Kompute Manager evalOp running sequence EVAL");
sq->eval();
SPDLOG_DEBUG("Kompute Manager evalOp running sequence SUCCESS");
KP_LOG_DEBUG("Kompute Manager evalOp running sequence SUCCESS");
}
/**
@@ -1453,7 +1457,7 @@ class Manager
void evalOpDefault(std::vector<std::shared_ptr<Tensor>> tensors,
TArgs&&... params)
{
SPDLOG_DEBUG("Kompute Manager evalOp Default triggered");
KP_LOG_DEBUG("Kompute Manager evalOp Default triggered");
this->mCurrentSequenceIndex++;
this->evalOp<T>(
tensors, KP_DEFAULT_SESSION, std::forward<TArgs>(params)...);
@@ -1472,24 +1476,24 @@ class Manager
std::string sequenceName,
TArgs&&... params)
{
SPDLOG_DEBUG("Kompute Manager evalOpAsync triggered");
KP_LOG_DEBUG("Kompute Manager evalOpAsync triggered");
std::shared_ptr<kp::Sequence> sq =
this->sequence(sequenceName);
SPDLOG_DEBUG("Kompute Manager evalOpAsync running sequence BEGIN");
KP_LOG_DEBUG("Kompute Manager evalOpAsync running sequence BEGIN");
sq->begin();
SPDLOG_DEBUG("Kompute Manager evalOpAsync running sequence RECORD");
KP_LOG_DEBUG("Kompute Manager evalOpAsync running sequence RECORD");
sq->record<T>(tensors, std::forward<TArgs>(params)...);
SPDLOG_DEBUG("Kompute Manager evalOpAsync running sequence END");
KP_LOG_DEBUG("Kompute Manager evalOpAsync running sequence END");
sq->end();
SPDLOG_DEBUG("Kompute Manager evalOpAsync running sequence EVAL");
KP_LOG_DEBUG("Kompute Manager evalOpAsync running sequence EVAL");
sq->evalAsync();
SPDLOG_DEBUG("Kompute Manager evalOpAsync running sequence SUCCESS");
KP_LOG_DEBUG("Kompute Manager evalOpAsync running sequence SUCCESS");
}
/**
@@ -1504,7 +1508,7 @@ class Manager
void evalOpAsyncDefault(std::vector<std::shared_ptr<Tensor>> tensors,
TArgs&&... params)
{
SPDLOG_DEBUG("Kompute Manager evalOpAsyncDefault triggered");
KP_LOG_DEBUG("Kompute Manager evalOpAsyncDefault triggered");
this->mCurrentSequenceIndex++;
this->evalOpAsync<T>(
tensors, KP_DEFAULT_SESSION, std::forward<TArgs>(params)...);
@@ -1518,23 +1522,23 @@ class Manager
*/
void evalOpAwait(std::string sequenceName, uint64_t waitFor = UINT64_MAX)
{
SPDLOG_DEBUG("Kompute Manager evalOpAwait triggered with sequence {}",
KP_LOG_DEBUG("Kompute Manager evalOpAwait triggered with sequence {}",
sequenceName);
std::unordered_map<std::string, std::shared_ptr<Sequence>>::iterator
found = this->mManagedSequences.find(sequenceName);
if (found != this->mManagedSequences.end()) {
if (std::shared_ptr<kp::Sequence> sq = found->second) {
SPDLOG_DEBUG("Kompute Manager evalOpAwait running sequence "
KP_LOG_DEBUG("Kompute Manager evalOpAwait running sequence "
"Sequence EVAL AWAIT");
if (sq->isRunning()) {
sq->evalAwait(waitFor);
}
}
SPDLOG_DEBUG(
KP_LOG_DEBUG(
"Kompute Manager evalOpAwait running sequence SUCCESS");
} else {
SPDLOG_ERROR("Kompute Manager evalOpAwait Sequence not found");
KP_LOG_ERROR("Kompute Manager evalOpAwait Sequence not found");
}
}
@@ -1547,7 +1551,7 @@ class Manager
*/
void evalOpAwaitDefault(uint64_t waitFor = UINT64_MAX)
{
SPDLOG_DEBUG("Kompute Manager evalOpAwaitDefault triggered");
KP_LOG_DEBUG("Kompute Manager evalOpAwaitDefault triggered");
this->evalOpAwait(KP_DEFAULT_SESSION, waitFor);
}
@@ -2011,7 +2015,7 @@ class OpMult : public OpAlgoBase
const Workgroup& komputeWorkgroup = {})
: OpAlgoBase(physicalDevice, device, commandBuffer, tensors, "", komputeWorkgroup)
{
SPDLOG_DEBUG("Kompute OpMult constructor with params");
KP_LOG_DEBUG("Kompute OpMult constructor with params");
#ifndef RELEASE
this->mShaderFilePath = "shaders/glsl/opmult.comp.spv";
@@ -2025,7 +2029,7 @@ class OpMult : public OpAlgoBase
*/
std::vector<uint32_t> fetchSpirvBinaryData() override
{
SPDLOG_WARN(
KP_LOG_WARN(
"Kompute OpMult Running shaders directly from header");
return std::vector<uint32_t>(
@@ -2041,7 +2045,7 @@ class OpMult : public OpAlgoBase
* components but does not destroy the underlying tensors
*/
~OpMult() override {
SPDLOG_DEBUG("Kompute OpMult destructor started");
KP_LOG_DEBUG("Kompute OpMult destructor started");
}
};

View File

@@ -6,14 +6,14 @@ namespace kp {
Algorithm::Algorithm()
{
SPDLOG_DEBUG("Kompute Algorithm base constructor");
KP_LOG_DEBUG("Kompute Algorithm base constructor");
}
Algorithm::Algorithm(std::shared_ptr<vk::Device> device,
std::shared_ptr<vk::CommandBuffer> commandBuffer,
const Constants& specializationConstants)
{
SPDLOG_DEBUG("Kompute Algorithm Constructor with device");
KP_LOG_DEBUG("Kompute Algorithm Constructor with device");
this->mDevice = device;
this->mCommandBuffer = commandBuffer;
@@ -22,18 +22,18 @@ Algorithm::Algorithm(std::shared_ptr<vk::Device> device,
Algorithm::~Algorithm()
{
SPDLOG_DEBUG("Kompute Algorithm Destructor started");
KP_LOG_DEBUG("Kompute Algorithm Destructor started");
if (!this->mDevice) {
SPDLOG_ERROR(
KP_LOG_ERROR(
"Kompute Algorithm destructor reached with null Device pointer");
return;
}
if (this->mFreePipeline) {
SPDLOG_DEBUG("Kompute Algorithm Destroying pipeline");
KP_LOG_DEBUG("Kompute Algorithm Destroying pipeline");
if (!this->mPipeline) {
SPDLOG_ERROR("Kompute Algorithm Error requested to destroy "
KP_LOG_ERROR("Kompute Algorithm Error requested to destroy "
"pipeline but it is null");
}
this->mDevice->destroy(
@@ -42,9 +42,9 @@ Algorithm::~Algorithm()
}
if (this->mFreePipelineCache) {
SPDLOG_DEBUG("Kompute Algorithm Destroying pipeline cache");
KP_LOG_DEBUG("Kompute Algorithm Destroying pipeline cache");
if (!this->mPipelineCache) {
SPDLOG_ERROR("Kompute Algorithm Error requested to destroy "
KP_LOG_ERROR("Kompute Algorithm Error requested to destroy "
"pipeline cache but it is null");
}
this->mDevice->destroy(
@@ -53,9 +53,9 @@ Algorithm::~Algorithm()
}
if (this->mFreePipelineLayout) {
SPDLOG_DEBUG("Kompute Algorithm Destroying pipeline layout");
KP_LOG_DEBUG("Kompute Algorithm Destroying pipeline layout");
if (!this->mPipelineLayout) {
SPDLOG_ERROR("Kompute Algorithm Error requested to destroy "
KP_LOG_ERROR("Kompute Algorithm Error requested to destroy "
"pipeline layout but it is null");
}
this->mDevice->destroy(
@@ -64,9 +64,9 @@ Algorithm::~Algorithm()
}
if (this->mFreeShaderModule) {
SPDLOG_DEBUG("Kompute Algorithm Destroying shader module");
KP_LOG_DEBUG("Kompute Algorithm Destroying shader module");
if (!this->mShaderModule) {
SPDLOG_ERROR("Kompute Algorithm Error requested to destroy shader "
KP_LOG_ERROR("Kompute Algorithm Error requested to destroy shader "
"module but it is null");
}
this->mDevice->destroy(
@@ -75,9 +75,9 @@ Algorithm::~Algorithm()
}
if (this->mFreeDescriptorSet) {
SPDLOG_DEBUG("Kompute Algorithm Freeing Descriptor Set");
KP_LOG_DEBUG("Kompute Algorithm Freeing Descriptor Set");
if (!this->mDescriptorSet) {
SPDLOG_ERROR(
KP_LOG_ERROR(
"Kompute Algorithm Error requested to free descriptor set");
}
this->mDevice->freeDescriptorSets(
@@ -85,9 +85,9 @@ Algorithm::~Algorithm()
}
if (this->mFreeDescriptorSetLayout) {
SPDLOG_DEBUG("Kompute Algorithm Destroying Descriptor Set Layout");
KP_LOG_DEBUG("Kompute Algorithm Destroying Descriptor Set Layout");
if (!this->mDescriptorSetLayout) {
SPDLOG_ERROR("Kompute Algorithm Error requested to destroy "
KP_LOG_ERROR("Kompute Algorithm Error requested to destroy "
"descriptor set layout but it is null");
}
this->mDevice->destroy(
@@ -96,9 +96,9 @@ Algorithm::~Algorithm()
}
if (this->mFreeDescriptorPool) {
SPDLOG_DEBUG("Kompute Algorithm Destroying Descriptor Pool");
KP_LOG_DEBUG("Kompute Algorithm Destroying Descriptor Pool");
if (!this->mDescriptorPool) {
SPDLOG_ERROR("Kompute Algorithm Error requested to destroy "
KP_LOG_ERROR("Kompute Algorithm Error requested to destroy "
"descriptor pool but it is null");
}
this->mDevice->destroy(
@@ -111,7 +111,7 @@ void
Algorithm::init(const std::vector<uint32_t>& shaderFileData,
std::vector<std::shared_ptr<Tensor>> tensorParams)
{
SPDLOG_DEBUG("Kompute Algorithm init started");
KP_LOG_DEBUG("Kompute Algorithm init started");
this->createParameters(tensorParams);
this->createShaderModule(shaderFileData);
@@ -130,7 +130,7 @@ Algorithm::createDescriptorPool()
void
Algorithm::createParameters(std::vector<std::shared_ptr<Tensor>>& tensorParams)
{
SPDLOG_DEBUG("Kompute Algorithm createParameters started");
KP_LOG_DEBUG("Kompute Algorithm createParameters started");
std::vector<vk::DescriptorPoolSize> descriptorPoolSizes = {
vk::DescriptorPoolSize(
@@ -145,7 +145,7 @@ Algorithm::createParameters(std::vector<std::shared_ptr<Tensor>>& tensorParams)
static_cast<uint32_t>(descriptorPoolSizes.size()),
descriptorPoolSizes.data());
SPDLOG_DEBUG("Kompute Algorithm creating descriptor pool");
KP_LOG_DEBUG("Kompute Algorithm creating descriptor pool");
this->mDescriptorPool = std::make_shared<vk::DescriptorPool>();
this->mDevice->createDescriptorPool(
&descriptorPoolInfo, nullptr, this->mDescriptorPool.get());
@@ -166,7 +166,7 @@ Algorithm::createParameters(std::vector<std::shared_ptr<Tensor>>& tensorParams)
static_cast<uint32_t>(descriptorSetBindings.size()),
descriptorSetBindings.data());
SPDLOG_DEBUG("Kompute Algorithm creating descriptor set layout");
KP_LOG_DEBUG("Kompute Algorithm creating descriptor set layout");
this->mDescriptorSetLayout = std::make_shared<vk::DescriptorSetLayout>();
this->mDevice->createDescriptorSetLayout(
&descriptorSetLayoutInfo, nullptr, this->mDescriptorSetLayout.get());
@@ -177,13 +177,13 @@ Algorithm::createParameters(std::vector<std::shared_ptr<Tensor>>& tensorParams)
1, // Descriptor set layout count
this->mDescriptorSetLayout.get());
SPDLOG_DEBUG("Kompute Algorithm allocating descriptor sets");
KP_LOG_DEBUG("Kompute Algorithm allocating descriptor sets");
this->mDescriptorSet = std::make_shared<vk::DescriptorSet>();
this->mDevice->allocateDescriptorSets(&descriptorSetAllocateInfo,
this->mDescriptorSet.get());
this->mFreeDescriptorSet = true;
SPDLOG_DEBUG("Kompute Algorithm updating descriptor sets");
KP_LOG_DEBUG("Kompute Algorithm updating descriptor sets");
for (size_t i = 0; i < tensorParams.size(); i++) {
std::vector<vk::WriteDescriptorSet> computeWriteDescriptorSets;
@@ -203,20 +203,20 @@ Algorithm::createParameters(std::vector<std::shared_ptr<Tensor>>& tensorParams)
nullptr);
}
SPDLOG_DEBUG("Kompue Algorithm successfully run init");
KP_LOG_DEBUG("Kompue Algorithm successfully run init");
}
void
Algorithm::createShaderModule(const std::vector<uint32_t>& shaderFileData)
{
SPDLOG_DEBUG("Kompute Algorithm createShaderModule started");
KP_LOG_DEBUG("Kompute Algorithm createShaderModule started");
vk::ShaderModuleCreateInfo shaderModuleInfo(
vk::ShaderModuleCreateFlags(),
sizeof(uint32_t) * shaderFileData.size(),
shaderFileData.data());
SPDLOG_DEBUG("Kompute Algorithm Creating shader module. ShaderFileSize: {}",
KP_LOG_DEBUG("Kompute Algorithm Creating shader module. ShaderFileSize: {}",
shaderFileData.size());
this->mFreeShaderModule = true;
this->mShaderModule = std::make_shared<vk::ShaderModule>();
@@ -224,13 +224,13 @@ Algorithm::createShaderModule(const std::vector<uint32_t>& shaderFileData)
&shaderModuleInfo, nullptr, this->mShaderModule.get());
this->mFreeShaderModule = true;
SPDLOG_DEBUG("Kompute Algorithm create shader module success");
KP_LOG_DEBUG("Kompute Algorithm create shader module success");
}
void
Algorithm::createPipeline()
{
SPDLOG_DEBUG("Kompute Algorithm calling create Pipeline");
KP_LOG_DEBUG("Kompute Algorithm calling create Pipeline");
vk::PipelineLayoutCreateInfo pipelineLayoutInfo(
vk::PipelineLayoutCreateFlags(),
@@ -302,7 +302,7 @@ Algorithm::createPipeline()
void
Algorithm::recordDispatch(uint32_t x, uint32_t y, uint32_t z)
{
SPDLOG_DEBUG("Kompute Algorithm calling record dispatch");
KP_LOG_DEBUG("Kompute Algorithm calling record dispatch");
this->mCommandBuffer->bindPipeline(vk::PipelineBindPoint::eCompute,
*this->mPipeline);

View File

@@ -18,7 +18,7 @@ debugMessageCallback(VkDebugReportFlagsEXT flags,
const char* pMessage,
void* pUserData)
{
SPDLOG_DEBUG("[VALIDATION]: {} - {}", pLayerPrefix, pMessage);
KP_LOG_DEBUG("[VALIDATION]: {} - {}", pLayerPrefix, pMessage);
return VK_FALSE;
}
#endif
@@ -50,16 +50,16 @@ Manager::Manager(std::shared_ptr<vk::Instance> instance,
Manager::~Manager()
{
SPDLOG_DEBUG("Kompute Manager Destructor started");
KP_LOG_DEBUG("Kompute Manager Destructor started");
if (this->mDevice == nullptr) {
SPDLOG_ERROR(
KP_LOG_ERROR(
"Kompute Manager destructor reached with null Device pointer");
return;
}
if (this->mManagedSequences.size()) {
SPDLOG_DEBUG("Kompute Manager explicitly running destructor for "
KP_LOG_DEBUG("Kompute Manager explicitly running destructor for "
"managed sequences");
for (const std::pair<std::string, std::shared_ptr<Sequence>>& sqPair :
this->mManagedSequences) {
@@ -69,10 +69,10 @@ Manager::~Manager()
}
if (this->mManagedTensors.size()) {
SPDLOG_DEBUG("Kompute Manager explicitly freeing tensors");
KP_LOG_DEBUG("Kompute Manager explicitly freeing tensors");
for (const std::shared_ptr<Tensor>& tensor : this->mManagedTensors) {
if (!tensor->isInit()) {
SPDLOG_ERROR("Kompute Manager attempted to free managed tensor "
KP_LOG_ERROR("Kompute Manager attempted to free managed tensor "
"but not tensor is not initialised");
}
tensor->freeMemoryDestroyGPUResources();
@@ -81,14 +81,14 @@ Manager::~Manager()
}
if (this->mFreeDevice) {
SPDLOG_INFO("Destroying device");
KP_LOG_INFO("Destroying device");
this->mDevice->destroy(
(vk::Optional<const vk::AllocationCallbacks>)nullptr);
SPDLOG_DEBUG("Kompute Manager Destroyed Device");
KP_LOG_DEBUG("Kompute Manager Destroyed Device");
}
if (this->mInstance == nullptr) {
SPDLOG_ERROR(
KP_LOG_ERROR(
"Kompute Manager destructor reached with null Instance pointer");
return;
}
@@ -98,7 +98,7 @@ Manager::~Manager()
if (this->mDebugReportCallback) {
this->mInstance->destroyDebugReportCallbackEXT(
this->mDebugReportCallback, nullptr, this->mDebugDispatcher);
SPDLOG_DEBUG("Kompute Manager Destroyed Debug Report Callback");
KP_LOG_DEBUG("Kompute Manager Destroyed Debug Report Callback");
}
#endif
#endif
@@ -106,14 +106,14 @@ Manager::~Manager()
if (this->mFreeInstance) {
this->mInstance->destroy(
(vk::Optional<const vk::AllocationCallbacks>)nullptr);
SPDLOG_DEBUG("Kompute Manager Destroyed Instance");
KP_LOG_DEBUG("Kompute Manager Destroyed Instance");
}
}
std::shared_ptr<Sequence>
Manager::sequence(std::string sequenceName, uint32_t queueIndex)
{
SPDLOG_DEBUG("Kompute Manager sequence() with sequenceName: {} "
KP_LOG_DEBUG("Kompute Manager sequence() with sequenceName: {} "
"and queueIndex: {}",
sequenceName,
queueIndex);
@@ -143,7 +143,7 @@ void
Manager::createInstance()
{
SPDLOG_DEBUG("Kompute Manager creating instance");
KP_LOG_DEBUG("Kompute Manager creating instance");
this->mFreeInstance = true;
@@ -168,7 +168,7 @@ Manager::createInstance()
#if DEBUG
#ifndef KOMPUTE_DISABLE_VK_DEBUG_LAYERS
SPDLOG_DEBUG("Kompute Manager adding debug validation layers");
KP_LOG_DEBUG("Kompute Manager adding debug validation layers");
// We'll identify the layers that are supported
std::vector<const char*> validLayerNames;
std::vector<const char*> desiredLayerNames = {
@@ -201,11 +201,11 @@ Manager::createInstance()
this->mInstance = std::make_shared<vk::Instance>();
vk::createInstance(
&computeInstanceCreateInfo, nullptr, this->mInstance.get());
SPDLOG_DEBUG("Kompute Manager Instance Created");
KP_LOG_DEBUG("Kompute Manager Instance Created");
#if DEBUG
#ifndef KOMPUTE_DISABLE_VK_DEBUG_LAYERS
SPDLOG_DEBUG("Kompute Manager adding debug callbacks");
KP_LOG_DEBUG("Kompute Manager adding debug callbacks");
if (validLayerNames.size() > 0) {
vk::DebugReportFlagsEXT debugFlags =
vk::DebugReportFlagBitsEXT::eError |
@@ -228,7 +228,7 @@ void
Manager::createDevice(const std::vector<uint32_t>& familyQueueIndices)
{
SPDLOG_DEBUG("Kompute Manager creating Device");
KP_LOG_DEBUG("Kompute Manager creating Device");
if (this->mInstance == nullptr) {
throw std::runtime_error("Kompute Manager instance is null");
@@ -252,7 +252,7 @@ Manager::createDevice(const std::vector<uint32_t>& familyQueueIndices)
vk::PhysicalDeviceProperties physicalDeviceProperties =
physicalDevice.getProperties();
SPDLOG_INFO("Using physical device index {} found {}",
KP_LOG_INFO("Using physical device index {} found {}",
this->mPhysicalDeviceIndex,
physicalDeviceProperties.deviceName);
@@ -311,7 +311,7 @@ Manager::createDevice(const std::vector<uint32_t>& familyQueueIndices)
this->mDevice = std::make_shared<vk::Device>();
physicalDevice.createDevice(
&deviceCreateInfo, nullptr, this->mDevice.get());
SPDLOG_DEBUG("Kompute Manager device created");
KP_LOG_DEBUG("Kompute Manager device created");
for (const uint32_t& familyQueueIndex : this->mComputeQueueFamilyIndices) {
std::shared_ptr<vk::Queue> currQueue = std::make_shared<vk::Queue>();
@@ -325,7 +325,7 @@ Manager::createDevice(const std::vector<uint32_t>& familyQueueIndices)
this->mComputeQueues.push_back(currQueue);
}
SPDLOG_DEBUG("Kompute Manager compute queue obtained");
KP_LOG_DEBUG("Kompute Manager compute queue obtained");
}
std::shared_ptr<Tensor>
@@ -334,9 +334,9 @@ Manager::tensor(
Tensor::TensorTypes tensorType,
bool syncDataToGPU)
{
SPDLOG_DEBUG("Kompute Manager tensor triggered");
KP_LOG_DEBUG("Kompute Manager tensor triggered");
SPDLOG_DEBUG("Kompute Manager creating new tensor shared ptr");
KP_LOG_DEBUG("Kompute Manager creating new tensor shared ptr");
std::shared_ptr<Tensor> tensor =
std::make_shared<Tensor>(kp::Tensor(data, tensorType));
@@ -354,7 +354,7 @@ void
Manager::rebuild(std::vector<std::shared_ptr<kp::Tensor>> tensors,
bool syncDataToGPU)
{
SPDLOG_DEBUG("Kompute Manager rebuild triggered");
KP_LOG_DEBUG("Kompute Manager rebuild triggered");
for (std::shared_ptr<Tensor> tensor : tensors) {
// False syncData to run all tensors at once instead one by one
@@ -370,7 +370,7 @@ void
Manager::rebuild(std::shared_ptr<kp::Tensor> tensor,
bool syncDataToGPU)
{
SPDLOG_DEBUG("Kompute Manager rebuild Tensor triggered");
KP_LOG_DEBUG("Kompute Manager rebuild Tensor triggered");
if (tensor->isInit()) {
tensor->freeMemoryDestroyGPUResources();
@@ -392,7 +392,7 @@ Manager::rebuild(std::shared_ptr<kp::Tensor> tensor,
void
Manager::destroy(std::shared_ptr<kp::Tensor> tensor)
{
SPDLOG_DEBUG("Kompute Manager rebuild Tensor triggered");
KP_LOG_DEBUG("Kompute Manager rebuild Tensor triggered");
if (tensor->isInit()) {
tensor->freeMemoryDestroyGPUResources();
@@ -410,7 +410,7 @@ Manager::destroy(std::shared_ptr<kp::Tensor> tensor)
void
Manager::destroy(std::vector<std::shared_ptr<kp::Tensor>> tensors)
{
SPDLOG_DEBUG("Kompute Manager rebuild Tensor triggered");
KP_LOG_DEBUG("Kompute Manager rebuild Tensor triggered");
for (std::shared_ptr<Tensor> tensor : tensors) {
this->destroy(tensor);
@@ -420,7 +420,7 @@ Manager::destroy(std::vector<std::shared_ptr<kp::Tensor>> tensors)
void
Manager::destroy(std::vector<std::shared_ptr<kp::Sequence>> sequences)
{
SPDLOG_DEBUG("Kompute Manager rebuild Sequence triggered");
KP_LOG_DEBUG("Kompute Manager rebuild Sequence triggered");
for (std::shared_ptr<kp::Sequence> sequence : sequences) {
this->destroy(sequence);
@@ -430,7 +430,7 @@ Manager::destroy(std::vector<std::shared_ptr<kp::Sequence>> sequences)
void
Manager::destroy(std::shared_ptr<kp::Sequence> sequence)
{
SPDLOG_DEBUG("Kompute Manager rebuild Sequence triggered");
KP_LOG_DEBUG("Kompute Manager rebuild Sequence triggered");
// Inefficient but required to delete by value
// Depending on the amount of named sequences created may be worth creating
@@ -450,7 +450,7 @@ Manager::destroy(std::shared_ptr<kp::Sequence> sequence)
void
Manager::destroy(const std::string& sequenceName)
{
SPDLOG_DEBUG("Kompute Manager rebuild Sequence triggered");
KP_LOG_DEBUG("Kompute Manager rebuild Sequence triggered");
std::unordered_map<std::string, std::shared_ptr<Sequence>>::iterator
found = this->mManagedSequences.find(sequenceName);
@@ -467,7 +467,7 @@ Manager::destroy(const std::string& sequenceName)
void
Manager::destroy(const std::vector<std::string>& sequenceNames)
{
SPDLOG_DEBUG("Kompute Manager rebuild Sequence triggered");
KP_LOG_DEBUG("Kompute Manager rebuild Sequence triggered");
for (const std::string& sequenceName : sequenceNames) {
this->destroy(sequenceName);

View File

@@ -6,7 +6,7 @@ namespace kp {
OpAlgoBase::OpAlgoBase()
{
SPDLOG_DEBUG("Kompute OpAlgoBase constructor base");
KP_LOG_DEBUG("Kompute OpAlgoBase constructor base");
}
OpAlgoBase::OpAlgoBase(std::shared_ptr<vk::PhysicalDevice> physicalDevice,
@@ -17,7 +17,7 @@ OpAlgoBase::OpAlgoBase(std::shared_ptr<vk::PhysicalDevice> physicalDevice,
const Constants& specializationConstants)
: OpBase(physicalDevice, device, commandBuffer, tensors)
{
SPDLOG_DEBUG("Kompute OpAlgoBase constructor with params numTensors: {}",
KP_LOG_DEBUG("Kompute OpAlgoBase constructor with params numTensors: {}",
tensors.size());
// The dispatch size is set up based on either explicitly provided template
@@ -33,7 +33,7 @@ OpAlgoBase::OpAlgoBase(std::shared_ptr<vk::PhysicalDevice> physicalDevice,
} else {
this->mKomputeWorkgroup = { tensors[0]->size(), 1, 1 };
}
SPDLOG_INFO("Kompute OpAlgoBase dispatch size X: {}, Y: {}, Z: {}",
KP_LOG_INFO("Kompute OpAlgoBase dispatch size X: {}, Y: {}, Z: {}",
this->mKomputeWorkgroup[0],
this->mKomputeWorkgroup[1],
this->mKomputeWorkgroup[2]);
@@ -50,7 +50,7 @@ OpAlgoBase::OpAlgoBase(std::shared_ptr<vk::PhysicalDevice> physicalDevice,
const Constants& specializationConstants)
: OpAlgoBase(physicalDevice, device, commandBuffer, tensors, komputeWorkgroup, specializationConstants)
{
SPDLOG_DEBUG(
KP_LOG_DEBUG(
"Kompute OpAlgoBase shaderFilePath constructo with shaderfile path: {}",
shaderFilePath);
@@ -66,7 +66,7 @@ OpAlgoBase::OpAlgoBase(std::shared_ptr<vk::PhysicalDevice> physicalDevice,
const Constants& specializationConstants)
: OpAlgoBase(physicalDevice, device, commandBuffer, tensors, komputeWorkgroup, specializationConstants)
{
SPDLOG_DEBUG("Kompute OpAlgoBase shaderFilePath constructo with shader raw "
KP_LOG_DEBUG("Kompute OpAlgoBase shaderFilePath constructo with shader raw "
"data length: {}",
shaderDataRaw.size());
@@ -75,13 +75,13 @@ OpAlgoBase::OpAlgoBase(std::shared_ptr<vk::PhysicalDevice> physicalDevice,
OpAlgoBase::~OpAlgoBase()
{
SPDLOG_DEBUG("Kompute OpAlgoBase destructor started");
KP_LOG_DEBUG("Kompute OpAlgoBase destructor started");
}
void
OpAlgoBase::init()
{
SPDLOG_DEBUG("Kompute OpAlgoBase init called");
KP_LOG_DEBUG("Kompute OpAlgoBase init called");
if (this->mTensors.size() < 1) {
throw std::runtime_error(
@@ -96,11 +96,11 @@ OpAlgoBase::init()
}
}
SPDLOG_DEBUG("Kompute OpAlgoBase fetching spirv data");
KP_LOG_DEBUG("Kompute OpAlgoBase fetching spirv data");
std::vector<uint32_t> shaderFileData = this->fetchSpirvBinaryData();
SPDLOG_DEBUG("Kompute OpAlgoBase Initialising algorithm component");
KP_LOG_DEBUG("Kompute OpAlgoBase Initialising algorithm component");
this->mAlgorithm->init(shaderFileData, this->mTensors);
}
@@ -108,7 +108,7 @@ OpAlgoBase::init()
void
OpAlgoBase::record()
{
SPDLOG_DEBUG("Kompute OpAlgoBase record called");
KP_LOG_DEBUG("Kompute OpAlgoBase record called");
// Barrier to ensure the data is finished writing to buffer memory
for (std::shared_ptr<Tensor> tensor : this->mTensors) {
@@ -128,22 +128,22 @@ OpAlgoBase::record()
void
OpAlgoBase::preEval()
{
SPDLOG_DEBUG("Kompute OpAlgoBase preEval called");
KP_LOG_DEBUG("Kompute OpAlgoBase preEval called");
}
void
OpAlgoBase::postEval()
{
SPDLOG_DEBUG("Kompute OpAlgoBase postSubmit called");
KP_LOG_DEBUG("Kompute OpAlgoBase postSubmit called");
}
std::vector<uint32_t>
OpAlgoBase::fetchSpirvBinaryData()
{
SPDLOG_DEBUG("Kompute OpAlgoBase Running fetchSpirvBinaryData");
KP_LOG_DEBUG("Kompute OpAlgoBase Running fetchSpirvBinaryData");
if (this->mShaderFilePath.size()) {
SPDLOG_DEBUG("Kompute OpAlgoBase Reading data from file path");
KP_LOG_DEBUG("Kompute OpAlgoBase Reading data from file path");
std::ifstream fileStream(this->mShaderFilePath,
std::ios::binary | std::ios::in |
@@ -160,11 +160,11 @@ OpAlgoBase::fetchSpirvBinaryData()
fileStream.read(shaderDataRaw, shaderFileSize);
fileStream.close();
SPDLOG_WARN("Kompute OpAlgoBase fetched {} bytes", shaderFileSize);
KP_LOG_WARN("Kompute OpAlgoBase fetched {} bytes", shaderFileSize);
return std::vector<uint32_t>((uint32_t*)shaderDataRaw, (uint32_t*)(shaderDataRaw + shaderFileSize));
} else if (this->mShaderDataRaw.size()) {
SPDLOG_DEBUG("Kompute OpAlgoBase Reading data from data provided");
KP_LOG_DEBUG("Kompute OpAlgoBase Reading data from data provided");
return this->mShaderDataRaw;
} else {
throw std::runtime_error(

View File

@@ -6,7 +6,7 @@ namespace kp {
OpAlgoLhsRhsOut::OpAlgoLhsRhsOut()
{
SPDLOG_DEBUG("Kompute OpAlgoLhsRhsOut constructor base");
KP_LOG_DEBUG("Kompute OpAlgoLhsRhsOut constructor base");
}
OpAlgoLhsRhsOut::OpAlgoLhsRhsOut(
@@ -20,24 +20,24 @@ OpAlgoLhsRhsOut::OpAlgoLhsRhsOut(
// a granular way.
: OpAlgoBase(physicalDevice, device, commandBuffer, tensors, komputeWorkgroup)
{
SPDLOG_DEBUG("Kompute OpAlgoLhsRhsOut constructor with params");
KP_LOG_DEBUG("Kompute OpAlgoLhsRhsOut constructor with params");
}
OpAlgoLhsRhsOut::~OpAlgoLhsRhsOut()
{
SPDLOG_DEBUG("Kompute OpAlgoLhsRhsOut destructor started");
KP_LOG_DEBUG("Kompute OpAlgoLhsRhsOut destructor started");
}
void
OpAlgoLhsRhsOut::init()
{
SPDLOG_DEBUG("Kompute OpAlgoLhsRhsOut init called");
KP_LOG_DEBUG("Kompute OpAlgoLhsRhsOut init called");
if (this->mTensors.size() < 3) {
throw std::runtime_error(
"Kompute OpAlgoLhsRhsOut called with less than 1 tensor");
} else if (this->mTensors.size() > 3) {
SPDLOG_WARN(
KP_LOG_WARN(
"Kompute OpAlgoLhsRhsOut called with more than 3 this->mTensors");
}
@@ -65,11 +65,11 @@ OpAlgoLhsRhsOut::init()
" Output: " + std::to_string(this->mTensorOutput->size()));
}
SPDLOG_DEBUG("Kompute OpAlgoLhsRhsOut fetching spirv data");
KP_LOG_DEBUG("Kompute OpAlgoLhsRhsOut fetching spirv data");
std::vector<uint32_t> shaderFileData = this->fetchSpirvBinaryData();
SPDLOG_DEBUG("Kompute OpAlgoLhsRhsOut Initialising algorithm component");
KP_LOG_DEBUG("Kompute OpAlgoLhsRhsOut Initialising algorithm component");
this->mAlgorithm->init(shaderFileData, this->mTensors);
}
@@ -77,7 +77,7 @@ OpAlgoLhsRhsOut::init()
void
OpAlgoLhsRhsOut::record()
{
SPDLOG_DEBUG("Kompute OpAlgoLhsRhsOut record called");
KP_LOG_DEBUG("Kompute OpAlgoLhsRhsOut record called");
// Barrier to ensure the data is finished writing to buffer memory
this->mTensorLHS->recordBufferMemoryBarrier(
@@ -114,7 +114,7 @@ OpAlgoLhsRhsOut::record()
void
OpAlgoLhsRhsOut::postEval()
{
SPDLOG_DEBUG("Kompute OpAlgoLhsRhsOut postSubmit called");
KP_LOG_DEBUG("Kompute OpAlgoLhsRhsOut postSubmit called");
this->mTensorOutput->mapDataFromHostMemory();
}

View File

@@ -5,7 +5,7 @@ namespace kp {
OpTensorCopy::OpTensorCopy()
{
SPDLOG_DEBUG("Kompute OpTensorCopy constructor base");
KP_LOG_DEBUG("Kompute OpTensorCopy constructor base");
}
OpTensorCopy::OpTensorCopy(std::shared_ptr<vk::PhysicalDevice> physicalDevice,
@@ -14,18 +14,18 @@ OpTensorCopy::OpTensorCopy(std::shared_ptr<vk::PhysicalDevice> physicalDevice,
std::vector<std::shared_ptr<Tensor>> tensors)
: OpBase(physicalDevice, device, commandBuffer, tensors)
{
SPDLOG_DEBUG("Kompute OpTensorCopy constructor with params");
KP_LOG_DEBUG("Kompute OpTensorCopy constructor with params");
}
OpTensorCopy::~OpTensorCopy()
{
SPDLOG_DEBUG("Kompute OpTensorCopy destructor started");
KP_LOG_DEBUG("Kompute OpTensorCopy destructor started");
}
void
OpTensorCopy::init()
{
SPDLOG_DEBUG("Kompute OpTensorCopy init called");
KP_LOG_DEBUG("Kompute OpTensorCopy init called");
if (this->mTensors.size() < 2) {
throw std::runtime_error(
@@ -48,7 +48,7 @@ OpTensorCopy::init()
void
OpTensorCopy::record()
{
SPDLOG_DEBUG("Kompute OpTensorCopy record called");
KP_LOG_DEBUG("Kompute OpTensorCopy record called");
// We iterate from the second tensor onwards and record a copy to all
for (size_t i = 1; i < this->mTensors.size(); i++) {
@@ -60,13 +60,13 @@ OpTensorCopy::record()
void
OpTensorCopy::preEval()
{
SPDLOG_DEBUG("Kompute OpTensorCopy preEval called");
KP_LOG_DEBUG("Kompute OpTensorCopy preEval called");
}
void
OpTensorCopy::postEval()
{
SPDLOG_DEBUG("Kompute OpTensorCopy postEval called");
KP_LOG_DEBUG("Kompute OpTensorCopy postEval called");
// Copy the data from the first tensor into all the tensors
for (size_t i = 1; i < this->mTensors.size(); i++) {

View File

@@ -7,7 +7,7 @@ namespace kp {
OpTensorSyncDevice::OpTensorSyncDevice()
{
SPDLOG_DEBUG("Kompute OpTensorSyncDevice constructor base");
KP_LOG_DEBUG("Kompute OpTensorSyncDevice constructor base");
}
OpTensorSyncDevice::OpTensorSyncDevice(
@@ -17,18 +17,18 @@ OpTensorSyncDevice::OpTensorSyncDevice(
std::vector<std::shared_ptr<Tensor>> tensors)
: OpBase(physicalDevice, device, commandBuffer, tensors)
{
SPDLOG_DEBUG("Kompute OpTensorSyncDevice constructor with params");
KP_LOG_DEBUG("Kompute OpTensorSyncDevice constructor with params");
}
OpTensorSyncDevice::~OpTensorSyncDevice()
{
SPDLOG_DEBUG("Kompute OpTensorSyncDevice destructor started");
KP_LOG_DEBUG("Kompute OpTensorSyncDevice destructor started");
}
void
OpTensorSyncDevice::init()
{
SPDLOG_DEBUG("Kompute OpTensorSyncDevice init called");
KP_LOG_DEBUG("Kompute OpTensorSyncDevice init called");
if (this->mTensors.size() < 1) {
throw std::runtime_error(
@@ -41,7 +41,7 @@ OpTensorSyncDevice::init()
"has not been initialized");
}
if (tensor->tensorType() == Tensor::TensorTypes::eStorage) {
SPDLOG_WARN(
KP_LOG_WARN(
"Kompute OpTensorSyncLocal tensor parameter is of type "
"TensorTypes::eStorage and hence cannot be used to receive or "
"pass data.");
@@ -52,7 +52,7 @@ OpTensorSyncDevice::init()
void
OpTensorSyncDevice::record()
{
SPDLOG_DEBUG("Kompute OpTensorSyncDevice record called");
KP_LOG_DEBUG("Kompute OpTensorSyncDevice record called");
for (size_t i = 0; i < this->mTensors.size(); i++) {
if (this->mTensors[i]->tensorType() == Tensor::TensorTypes::eDevice) {
@@ -65,7 +65,7 @@ OpTensorSyncDevice::record()
void
OpTensorSyncDevice::preEval()
{
SPDLOG_DEBUG("Kompute OpTensorSyncDevice preEval called");
KP_LOG_DEBUG("Kompute OpTensorSyncDevice preEval called");
// Performing sync of data as eval can be called multiple times with same op
for (size_t i = 0; i < this->mTensors.size(); i++) {
@@ -78,7 +78,7 @@ OpTensorSyncDevice::preEval()
void
OpTensorSyncDevice::postEval()
{
SPDLOG_DEBUG("Kompute OpTensorSyncDevice postEval called");
KP_LOG_DEBUG("Kompute OpTensorSyncDevice postEval called");
}
}

View File

@@ -7,7 +7,7 @@ namespace kp {
OpTensorSyncLocal::OpTensorSyncLocal()
{
SPDLOG_DEBUG("Kompute OpTensorSyncLocal constructor base");
KP_LOG_DEBUG("Kompute OpTensorSyncLocal constructor base");
}
OpTensorSyncLocal::OpTensorSyncLocal(
@@ -17,18 +17,18 @@ OpTensorSyncLocal::OpTensorSyncLocal(
std::vector<std::shared_ptr<Tensor>> tensors)
: OpBase(physicalDevice, device, commandBuffer, tensors)
{
SPDLOG_DEBUG("Kompute OpTensorSyncLocal constructor with params");
KP_LOG_DEBUG("Kompute OpTensorSyncLocal constructor with params");
}
OpTensorSyncLocal::~OpTensorSyncLocal()
{
SPDLOG_DEBUG("Kompute OpTensorSyncLocal destructor started");
KP_LOG_DEBUG("Kompute OpTensorSyncLocal destructor started");
}
void
OpTensorSyncLocal::init()
{
SPDLOG_DEBUG("Kompute OpTensorSyncLocal init called");
KP_LOG_DEBUG("Kompute OpTensorSyncLocal init called");
if (this->mTensors.size() < 1) {
throw std::runtime_error(
@@ -41,7 +41,7 @@ OpTensorSyncLocal::init()
"Kompute OpTensorSyncLocal: Tensor has not been initialized");
}
if (tensor->tensorType() == Tensor::TensorTypes::eStorage) {
SPDLOG_WARN(
KP_LOG_WARN(
"Kompute OpTensorSyncLocal tensor parameter is of type "
"TensorTypes::eStorage and hence cannot be used to receive or "
"pass data.");
@@ -52,7 +52,7 @@ OpTensorSyncLocal::init()
void
OpTensorSyncLocal::record()
{
SPDLOG_DEBUG("Kompute OpTensorSyncLocal record called");
KP_LOG_DEBUG("Kompute OpTensorSyncLocal record called");
for (size_t i = 0; i < this->mTensors.size(); i++) {
if (this->mTensors[i]->tensorType() == Tensor::TensorTypes::eDevice) {
@@ -65,15 +65,15 @@ OpTensorSyncLocal::record()
void
OpTensorSyncLocal::preEval()
{
SPDLOG_DEBUG("Kompute OpTensorSyncLocal preEval called");
KP_LOG_DEBUG("Kompute OpTensorSyncLocal preEval called");
}
void
OpTensorSyncLocal::postEval()
{
SPDLOG_DEBUG("Kompute OpTensorSyncLocal postEval called");
KP_LOG_DEBUG("Kompute OpTensorSyncLocal postEval called");
SPDLOG_DEBUG("Kompute OpTensorSyncLocal mapping data into tensor local");
KP_LOG_DEBUG("Kompute OpTensorSyncLocal mapping data into tensor local");
for (size_t i = 0; i < this->mTensors.size(); i++) {
if (this->mTensors[i]->tensorType() != Tensor::TensorTypes::eStorage) {
this->mTensors[i]->mapDataFromHostMemory();

View File

@@ -5,7 +5,7 @@ namespace kp {
Sequence::Sequence()
{
SPDLOG_DEBUG("Kompute Sequence base constructor");
KP_LOG_DEBUG("Kompute Sequence base constructor");
this->mIsInit = false;
}
@@ -14,7 +14,7 @@ Sequence::Sequence(std::shared_ptr<vk::PhysicalDevice> physicalDevice,
std::shared_ptr<vk::Queue> computeQueue,
uint32_t queueIndex)
{
SPDLOG_DEBUG("Kompute Sequence Constructor with existing device & queue");
KP_LOG_DEBUG("Kompute Sequence Constructor with existing device & queue");
this->mPhysicalDevice = physicalDevice;
this->mDevice = device;
@@ -25,10 +25,10 @@ Sequence::Sequence(std::shared_ptr<vk::PhysicalDevice> physicalDevice,
Sequence::~Sequence()
{
SPDLOG_DEBUG("Kompute Sequence Destructor started");
KP_LOG_DEBUG("Kompute Sequence Destructor started");
if (!this->mIsInit) {
SPDLOG_INFO("Kompute Sequence destructor called but sequence is not "
KP_LOG_INFO("Kompute Sequence destructor called but sequence is not "
"initialized so no need to removing GPU resources.");
return;
} else {
@@ -47,15 +47,15 @@ Sequence::init()
bool
Sequence::begin()
{
SPDLOG_DEBUG("Kompute sequence called BEGIN");
KP_LOG_DEBUG("Kompute sequence called BEGIN");
if (this->isRecording()) {
SPDLOG_WARN("Kompute Sequence begin called when already recording");
KP_LOG_WARN("Kompute Sequence begin called when already recording");
return false;
}
if (this->isRunning()) {
SPDLOG_WARN(
KP_LOG_WARN(
"Kompute Sequence begin called when sequence still running");
return false;
}
@@ -65,16 +65,16 @@ Sequence::begin()
}
if (this->mOperations.size()) {
SPDLOG_INFO("Kompute Sequence clearing previous operations");
KP_LOG_INFO("Kompute Sequence clearing previous operations");
this->mOperations.clear();
}
if (!this->mRecording) {
SPDLOG_INFO("Kompute Sequence command recording BEGIN");
KP_LOG_INFO("Kompute Sequence command recording BEGIN");
this->mCommandBuffer->begin(vk::CommandBufferBeginInfo());
this->mRecording = true;
} else {
SPDLOG_WARN("Kompute Sequence attempted to start command recording "
KP_LOG_WARN("Kompute Sequence attempted to start command recording "
"but recording already started");
}
return true;
@@ -83,10 +83,10 @@ Sequence::begin()
bool
Sequence::end()
{
SPDLOG_DEBUG("Kompute Sequence calling END");
KP_LOG_DEBUG("Kompute Sequence calling END");
if (!this->isRecording()) {
SPDLOG_WARN("Kompute Sequence end called when not recording");
KP_LOG_WARN("Kompute Sequence end called when not recording");
return false;
}
@@ -95,11 +95,11 @@ Sequence::end()
}
if (this->mRecording) {
SPDLOG_INFO("Kompute Sequence command recording END");
KP_LOG_INFO("Kompute Sequence command recording END");
this->mCommandBuffer->end();
this->mRecording = false;
} else {
SPDLOG_WARN("Kompute Sequence attempted to end command recording but "
KP_LOG_WARN("Kompute Sequence attempted to end command recording but "
"recording not started");
}
return true;
@@ -108,17 +108,17 @@ Sequence::end()
bool
Sequence::eval()
{
SPDLOG_DEBUG("Kompute sequence EVAL BEGIN");
KP_LOG_DEBUG("Kompute sequence EVAL BEGIN");
bool evalResult = this->evalAsync();
if (!evalResult) {
SPDLOG_DEBUG("Kompute sequence EVAL FAILURE");
KP_LOG_DEBUG("Kompute sequence EVAL FAILURE");
return false;
}
evalResult = this->evalAwait();
SPDLOG_DEBUG("Kompute sequence EVAL SUCCESS");
KP_LOG_DEBUG("Kompute sequence EVAL SUCCESS");
return evalResult;
}
@@ -127,11 +127,11 @@ bool
Sequence::evalAsync()
{
if (this->isRecording()) {
SPDLOG_WARN("Kompute Sequence evalAsync called when still recording");
KP_LOG_WARN("Kompute Sequence evalAsync called when still recording");
return false;
}
if (this->mIsRunning) {
SPDLOG_WARN("Kompute Sequence evalAsync called when an eval async was "
KP_LOG_WARN("Kompute Sequence evalAsync called when an eval async was "
"called without successful wait");
return false;
}
@@ -147,7 +147,7 @@ Sequence::evalAsync()
this->mFence = this->mDevice->createFence(vk::FenceCreateInfo());
SPDLOG_DEBUG(
KP_LOG_DEBUG(
"Kompute sequence submitting command buffer into compute queue");
this->mComputeQueue->submit(1, &submitInfo, this->mFence);
@@ -159,7 +159,7 @@ bool
Sequence::evalAwait(uint64_t waitFor)
{
if (!this->mIsRunning) {
SPDLOG_WARN("Kompute Sequence evalAwait called without existing eval");
KP_LOG_WARN("Kompute Sequence evalAwait called without existing eval");
return false;
}
@@ -171,7 +171,7 @@ Sequence::evalAwait(uint64_t waitFor)
this->mIsRunning = false;
if (result == vk::Result::eTimeout) {
SPDLOG_WARN("Kompute Sequence evalAwait timed out");
KP_LOG_WARN("Kompute Sequence evalAwait timed out");
return false;
}
@@ -203,26 +203,26 @@ Sequence::isInit()
void
Sequence::freeMemoryDestroyGPUResources()
{
SPDLOG_DEBUG("Kompute Sequence freeMemoryDestroyGPUResources called");
KP_LOG_DEBUG("Kompute Sequence freeMemoryDestroyGPUResources called");
if (!this->mIsInit) {
SPDLOG_ERROR("Kompute Sequence freeMemoryDestroyGPUResources called "
KP_LOG_ERROR("Kompute Sequence freeMemoryDestroyGPUResources called "
"but Sequence is not initialized so there's no relevant "
"GPU resources.");
return;
}
if (!this->mDevice) {
SPDLOG_ERROR("Kompute Sequence freeMemoryDestroyGPUResources called "
KP_LOG_ERROR("Kompute Sequence freeMemoryDestroyGPUResources called "
"with null Device pointer");
this->mIsInit = false;
return;
}
if (this->mFreeCommandBuffer) {
SPDLOG_INFO("Freeing CommandBuffer");
KP_LOG_INFO("Freeing CommandBuffer");
if (!this->mCommandBuffer) {
SPDLOG_ERROR(
KP_LOG_ERROR(
"Kompute Sequence freeMemoryDestroyGPUResources called with null "
"CommandPool pointer");
this->mIsInit = false;
@@ -230,13 +230,13 @@ Sequence::freeMemoryDestroyGPUResources()
}
this->mDevice->freeCommandBuffers(
*this->mCommandPool, 1, this->mCommandBuffer.get());
SPDLOG_DEBUG("Kompute Sequence Freed CommandBuffer");
KP_LOG_DEBUG("Kompute Sequence Freed CommandBuffer");
}
if (this->mFreeCommandPool) {
SPDLOG_INFO("Destroying CommandPool");
KP_LOG_INFO("Destroying CommandPool");
if (this->mCommandPool == nullptr) {
SPDLOG_ERROR(
KP_LOG_ERROR(
"Kompute Sequence freeMemoryDestroyGPUResources called with null "
"CommandPool pointer");
this->mIsInit = false;
@@ -245,11 +245,11 @@ Sequence::freeMemoryDestroyGPUResources()
this->mDevice->destroy(
*this->mCommandPool,
(vk::Optional<const vk::AllocationCallbacks>)nullptr);
SPDLOG_DEBUG("Kompute Sequence Destroyed CommandPool");
KP_LOG_DEBUG("Kompute Sequence Destroyed CommandPool");
}
if (this->mOperations.size()) {
SPDLOG_INFO("Kompute Sequence clearing operations buffer");
KP_LOG_INFO("Kompute Sequence clearing operations buffer");
this->mOperations.clear();
}
@@ -259,7 +259,7 @@ Sequence::freeMemoryDestroyGPUResources()
void
Sequence::createCommandPool()
{
SPDLOG_DEBUG("Kompute Sequence creating command pool");
KP_LOG_DEBUG("Kompute Sequence creating command pool");
if (!this->mDevice) {
throw std::runtime_error("Kompute Sequence device is null");
@@ -275,13 +275,13 @@ Sequence::createCommandPool()
this->mCommandPool = std::make_shared<vk::CommandPool>();
this->mDevice->createCommandPool(
&commandPoolInfo, nullptr, this->mCommandPool.get());
SPDLOG_DEBUG("Kompute Sequence Command Pool Created");
KP_LOG_DEBUG("Kompute Sequence Command Pool Created");
}
void
Sequence::createCommandBuffer()
{
SPDLOG_DEBUG("Kompute Sequence creating command buffer");
KP_LOG_DEBUG("Kompute Sequence creating command buffer");
if (!this->mDevice) {
throw std::runtime_error("Kompute Sequence device is null");
}
@@ -297,7 +297,7 @@ Sequence::createCommandBuffer()
this->mCommandBuffer = std::make_shared<vk::CommandBuffer>();
this->mDevice->allocateCommandBuffers(&commandBufferAllocateInfo,
this->mCommandBuffer.get());
SPDLOG_DEBUG("Kompute Sequence Command Buffer Created");
KP_LOG_DEBUG("Kompute Sequence Command Buffer Created");
}
}

View File

@@ -38,7 +38,7 @@ Shader::compile_sources(const std::vector<std::string>& sources,
if (!shader.parse(&glslang::DefaultTBuiltInResource, 100, false, messages))
{
info_log = std::string(shader.getInfoLog()) + "\n" + std::string(shader.getInfoDebugLog());
SPDLOG_ERROR("Kompute Shader Error: {}", info_log);
KP_LOG_ERROR("Kompute Shader Error: {}", info_log);
throw std::runtime_error(info_log);
}
@@ -49,7 +49,7 @@ Shader::compile_sources(const std::vector<std::string>& sources,
if (!program.link(messages))
{
info_log = std::string(program.getInfoLog()) + "\n" + std::string(program.getInfoDebugLog());
SPDLOG_ERROR("Kompute Shader Error: {}", info_log);
KP_LOG_ERROR("Kompute Shader Error: {}", info_log);
throw std::runtime_error(info_log);
}
@@ -57,7 +57,7 @@ Shader::compile_sources(const std::vector<std::string>& sources,
if (shader.getInfoLog())
{
info_log += std::string(shader.getInfoLog()) + "\n" + std::string(shader.getInfoDebugLog()) + "\n";
SPDLOG_INFO("Kompute Shader Information: {}", info_log);
KP_LOG_INFO("Kompute Shader Information: {}", info_log);
}
glslang::TIntermediate *intermediate = program.getIntermediate(language);
@@ -65,7 +65,7 @@ Shader::compile_sources(const std::vector<std::string>& sources,
if (!intermediate)
{
info_log += "Failed to get shared intermediate code.\n";
SPDLOG_ERROR("Kompute Shader Error: {}", info_log);
KP_LOG_ERROR("Kompute Shader Error: {}", info_log);
throw std::runtime_error(info_log);
}
@@ -76,7 +76,7 @@ Shader::compile_sources(const std::vector<std::string>& sources,
if (shader.getInfoLog())
{
info_log += logger.getAllMessages() + "\n";
SPDLOG_DEBUG("Kompute Shader all result messages: {}", info_log);
KP_LOG_DEBUG("Kompute Shader all result messages: {}", info_log);
}
// Shutdown glslang library.

View File

@@ -5,14 +5,14 @@ namespace kp {
Tensor::Tensor()
{
SPDLOG_DEBUG("Kompute Tensor base constructor");
KP_LOG_DEBUG("Kompute Tensor base constructor");
this->mTensorType = TensorTypes::eDevice;
}
Tensor::Tensor(const std::vector<float>& data, TensorTypes tensorType)
{
#if DEBUG
SPDLOG_DEBUG("Kompute Tensor constructor data length: {}, and type: {}",
KP_LOG_DEBUG("Kompute Tensor constructor data length: {}, and type: {}",
data.size(),
tensorType);
#endif
@@ -24,21 +24,21 @@ Tensor::Tensor(const std::vector<float>& data, TensorTypes tensorType)
Tensor::~Tensor()
{
SPDLOG_DEBUG("Kompute Tensor destructor started. Type: {}",
KP_LOG_DEBUG("Kompute Tensor destructor started. Type: {}",
this->tensorType());
if (this->isInit()) {
this->freeMemoryDestroyGPUResources();
}
SPDLOG_DEBUG("Kompute Tensor destructor success");
KP_LOG_DEBUG("Kompute Tensor destructor success");
}
void
Tensor::init(std::shared_ptr<vk::PhysicalDevice> physicalDevice,
std::shared_ptr<vk::Device> device)
{
SPDLOG_DEBUG("Kompute Tensor running init with Vulkan params and num data "
KP_LOG_DEBUG("Kompute Tensor running init with Vulkan params and num data "
"elementS: {}",
this->mData.size());
@@ -111,7 +111,7 @@ Tensor::recordCopyFrom(std::shared_ptr<vk::CommandBuffer> commandBuffer,
vk::DeviceSize bufferSize(this->memorySize());
vk::BufferCopy copyRegion(0, 0, bufferSize);
SPDLOG_DEBUG("Kompute Tensor recordCopyFrom data size {}.", bufferSize);
KP_LOG_DEBUG("Kompute Tensor recordCopyFrom data size {}.", bufferSize);
this->copyBuffer(commandBuffer,
copyFromTensor->mPrimaryBuffer,
@@ -129,7 +129,7 @@ Tensor::recordCopyFromStagingToDevice(
vk::DeviceSize bufferSize(this->memorySize());
vk::BufferCopy copyRegion(0, 0, bufferSize);
SPDLOG_DEBUG("Kompute Tensor copying data size {}.", bufferSize);
KP_LOG_DEBUG("Kompute Tensor copying data size {}.", bufferSize);
this->copyBuffer(commandBuffer,
this->mStagingBuffer,
@@ -147,7 +147,7 @@ Tensor::recordCopyFromDeviceToStaging(
vk::DeviceSize bufferSize(this->memorySize());
vk::BufferCopy copyRegion(0, 0, bufferSize);
SPDLOG_DEBUG("Kompute Tensor copying data size {}.", bufferSize);
KP_LOG_DEBUG("Kompute Tensor copying data size {}.", bufferSize);
this->copyBuffer(commandBuffer,
this->mPrimaryBuffer,
@@ -191,7 +191,7 @@ Tensor::recordBufferMemoryBarrier(
vk::PipelineStageFlagBits srcStageMask,
vk::PipelineStageFlagBits dstStageMask)
{
SPDLOG_DEBUG("Kompute Tensor recording buffer memory barrier");
KP_LOG_DEBUG("Kompute Tensor recording buffer memory barrier");
vk::DeviceSize bufferSize = this->memorySize();
@@ -223,7 +223,7 @@ Tensor::constructDescriptorBufferInfo()
void
Tensor::mapDataFromHostMemory()
{
SPDLOG_DEBUG("Kompute Tensor mapping data from host buffer");
KP_LOG_DEBUG("Kompute Tensor mapping data from host buffer");
std::shared_ptr<vk::DeviceMemory> hostVisibleMemory = nullptr;
@@ -232,7 +232,7 @@ Tensor::mapDataFromHostMemory()
} else if (this->mTensorType == TensorTypes::eDevice) {
hostVisibleMemory = this->mStagingMemory;
} else {
SPDLOG_WARN(
KP_LOG_WARN(
"Kompute Tensor mapping data not supported on storage tensor");
return;
}
@@ -250,7 +250,7 @@ void
Tensor::mapDataIntoHostMemory()
{
SPDLOG_DEBUG("Kompute Tensor local mapping tensor data to host buffer");
KP_LOG_DEBUG("Kompute Tensor local mapping tensor data to host buffer");
std::shared_ptr<vk::DeviceMemory> hostVisibleMemory = nullptr;
@@ -259,7 +259,7 @@ Tensor::mapDataIntoHostMemory()
} else if (this->mTensorType == TensorTypes::eDevice) {
hostVisibleMemory = this->mStagingMemory;
} else {
SPDLOG_WARN(
KP_LOG_WARN(
"Kompute Tensor mapping data not supported on storage tensor");
return;
}
@@ -342,7 +342,7 @@ Tensor::getStagingMemoryPropertyFlags()
void
Tensor::allocateMemoryCreateGPUResources()
{
SPDLOG_DEBUG("Kompute Tensor creating buffer");
KP_LOG_DEBUG("Kompute Tensor creating buffer");
if (!this->mIsInit) {
throw std::runtime_error(
@@ -356,7 +356,7 @@ Tensor::allocateMemoryCreateGPUResources()
throw std::runtime_error("Kompute Tensor device is null");
}
SPDLOG_DEBUG("Kompute Tensor creating primary buffer and memory");
KP_LOG_DEBUG("Kompute Tensor creating primary buffer and memory");
this->mPrimaryBuffer = std::make_shared<vk::Buffer>();
this->createBuffer(this->mPrimaryBuffer,
@@ -369,7 +369,7 @@ Tensor::allocateMemoryCreateGPUResources()
this->mFreePrimaryMemory = true;
if (this->mTensorType == TensorTypes::eDevice) {
SPDLOG_DEBUG("Kompute Tensor creating staging buffer and memory");
KP_LOG_DEBUG("Kompute Tensor creating staging buffer and memory");
this->mStagingBuffer = std::make_shared<vk::Buffer>();
this->createBuffer(this->mStagingBuffer,
@@ -382,7 +382,7 @@ Tensor::allocateMemoryCreateGPUResources()
this->mFreeStagingMemory = true;
}
SPDLOG_DEBUG("Kompute Tensor buffer & memory creation successful");
KP_LOG_DEBUG("Kompute Tensor buffer & memory creation successful");
}
void
@@ -397,7 +397,7 @@ Tensor::createBuffer(std::shared_ptr<vk::Buffer> buffer,
"Kompute Tensor attempted to create a zero-sized buffer");
}
SPDLOG_DEBUG("Kompute Tensor creating buffer with memory size: {}, and "
KP_LOG_DEBUG("Kompute Tensor creating buffer with memory size: {}, and "
"usage flags: {}",
bufferSize,
vk::to_string(bufferUsageFlags));
@@ -417,7 +417,7 @@ Tensor::allocateBindMemory(std::shared_ptr<vk::Buffer> buffer,
vk::MemoryPropertyFlags memoryPropertyFlags)
{
SPDLOG_DEBUG("Kompute Tensor allocating and binding memory");
KP_LOG_DEBUG("Kompute Tensor allocating and binding memory");
vk::PhysicalDeviceMemoryProperties memoryProperties =
this->mPhysicalDevice->getMemoryProperties();
@@ -440,7 +440,7 @@ Tensor::allocateBindMemory(std::shared_ptr<vk::Buffer> buffer,
"Memory type index for buffer creation not found");
}
SPDLOG_DEBUG(
KP_LOG_DEBUG(
"Kompute Tensor allocating memory index: {}, size {}, flags: {}",
memoryTypeIndex,
memoryRequirements.size,
@@ -457,22 +457,22 @@ Tensor::allocateBindMemory(std::shared_ptr<vk::Buffer> buffer,
void
Tensor::freeMemoryDestroyGPUResources()
{
SPDLOG_DEBUG("Kompute Tensor started freeMemoryDestroyGPUResources");
KP_LOG_DEBUG("Kompute Tensor started freeMemoryDestroyGPUResources");
this->mIsInit = false;
if (!this->mDevice) {
SPDLOG_ERROR(
KP_LOG_ERROR(
"Kompute Tensor destructor reached with null Device pointer");
return;
}
if (this->mFreePrimaryBuffer) {
if (!this->mPrimaryBuffer) {
SPDLOG_ERROR("Kompose Tensor expected to destroy primary buffer "
KP_LOG_ERROR("Kompose Tensor expected to destroy primary buffer "
"but got null buffer");
} else {
SPDLOG_DEBUG("Kompose Tensor destroying primary buffer");
KP_LOG_DEBUG("Kompose Tensor destroying primary buffer");
this->mDevice->destroy(
*this->mPrimaryBuffer,
(vk::Optional<const vk::AllocationCallbacks>)nullptr);
@@ -482,10 +482,10 @@ Tensor::freeMemoryDestroyGPUResources()
if (this->mFreeStagingBuffer) {
if (!this->mStagingBuffer) {
SPDLOG_ERROR("Kompose Tensor expected to destroy staging buffer "
KP_LOG_ERROR("Kompose Tensor expected to destroy staging buffer "
"but got null buffer");
} else {
SPDLOG_DEBUG("Kompose Tensor destroying staging buffer");
KP_LOG_DEBUG("Kompose Tensor destroying staging buffer");
this->mDevice->destroy(
*this->mStagingBuffer,
(vk::Optional<const vk::AllocationCallbacks>)nullptr);
@@ -495,10 +495,10 @@ Tensor::freeMemoryDestroyGPUResources()
if (this->mFreePrimaryMemory) {
if (!this->mPrimaryMemory) {
SPDLOG_ERROR("Kompose Tensor expected to free primary memory but "
KP_LOG_ERROR("Kompose Tensor expected to free primary memory but "
"got null memory");
} else {
SPDLOG_DEBUG("Kompose Tensor freeing primary memory");
KP_LOG_DEBUG("Kompose Tensor freeing primary memory");
this->mDevice->freeMemory(
*this->mPrimaryMemory,
(vk::Optional<const vk::AllocationCallbacks>)nullptr);
@@ -508,10 +508,10 @@ Tensor::freeMemoryDestroyGPUResources()
if (this->mFreeStagingMemory) {
if (!this->mStagingMemory) {
SPDLOG_ERROR("Kompose Tensor expected to free staging memory but "
KP_LOG_ERROR("Kompose Tensor expected to free staging memory but "
"got null memory");
} else {
SPDLOG_DEBUG("Kompose Tensor freeing staging memory");
KP_LOG_DEBUG("Kompose Tensor freeing staging memory");
this->mDevice->freeMemory(
*this->mStagingMemory,
(vk::Optional<const vk::AllocationCallbacks>)nullptr);
@@ -519,7 +519,7 @@ Tensor::freeMemoryDestroyGPUResources()
}
}
SPDLOG_DEBUG("Kompute Tensor successful freeMemoryDestroyGPUResources");
KP_LOG_DEBUG("Kompute Tensor successful freeMemoryDestroyGPUResources");
}
}

View File

@@ -50,57 +50,61 @@ extern py::object kp_debug, kp_info, kp_warning, kp_error;
#ifndef KOMPUTE_LOG_OVERRIDE
#if KOMPUTE_ENABLE_SPDLOG
#include <spdlog/spdlog.h>
#define KP_LOG_DEBUG(...) SPDLOG_DEBUG(__VA_ARGS__)
#define KP_LOG_INFO(...) SPDLOG_INFO(__VA_ARGS__)
#define KP_LOG_WARN(...) SPDLOG_WARN(__VA_ARGS__)
#define KP_LOG_ERROR(...) SPDLOG_ERROR(__VA_ARGS__)
#else
#include <iostream>
#if SPDLOG_ACTIVE_LEVEL > 1
#define SPDLOG_DEBUG(...)
#define KP_LOG_DEBUG(...)
#else
#if defined(VK_USE_PLATFORM_ANDROID_KHR)
#define SPDLOG_DEBUG(...) \
#define KP_LOG_DEBUG(...) \
((void)__android_log_print(ANDROID_LOG_DEBUG, KOMPUTE_LOG_TAG, fmt::format(__VA_ARGS__)))
#elif defined(KOMPUTE_BUILD_PYTHON)
#define SPDLOG_DEBUG(...) kp_debug(fmt::format(__VA_ARGS__))
#define KP_LOG_DEBUG(...) kp_debug(fmt::format(__VA_ARGS__))
#else
#define SPDLOG_DEBUG(...) fmt::print("[{} {}] [debug] [{}:{}] {}\n", __DATE__, __TIME__, __FILE__, __LINE__, fmt::format(__VA_ARGS__))
#define KP_LOG_DEBUG(...) fmt::print("[{} {}] [debug] [{}:{}] {}\n", __DATE__, __TIME__, __FILE__, __LINE__, fmt::format(__VA_ARGS__))
#endif // VK_USE_PLATFORM_ANDROID_KHR
#endif // SPDLOG_ACTIVE_LEVEL > 1
#if SPDLOG_ACTIVE_LEVEL > 2
#define SPDLOG_INFO(...)
#define KP_LOG_INFO(...)
#else
#if defined(VK_USE_PLATFORM_ANDROID_KHR)
#define SPDLOG_INFO(...) \
#define KP_LOG_INFO(...) \
((void)__android_log_print(ANDROID_LOG_INFO, KOMPUTE_LOG_TAG, fmt::format(__VA_ARGS__)))
#elif defined(KOMPUTE_BUILD_PYTHON)
#define SPDLOG_INFO(...) kp_info(fmt::format(__VA_ARGS__))
#define KP_LOG_INFO(...) kp_info(fmt::format(__VA_ARGS__))
#else
#define SPDLOG_INFO(...) fmt::print("[{} {}] [debug] [{}:{}] {}\n", __DATE__, __TIME__, __FILE__, __LINE__, fmt::format(__VA_ARGS__))
#define KP_LOG_INFO(...) fmt::print("[{} {}] [debug] [{}:{}] {}\n", __DATE__, __TIME__, __FILE__, __LINE__, fmt::format(__VA_ARGS__))
#endif // VK_USE_PLATFORM_ANDROID_KHR
#endif // SPDLOG_ACTIVE_LEVEL > 2
#if SPDLOG_ACTIVE_LEVEL > 3
#define SPDLOG_WARN(...)
#define KP_LOG_WARN(...)
#else
#if defined(VK_USE_PLATFORM_ANDROID_KHR)
#define SPDLOG_WARN(...) \
#define KP_LOG_WARN(...) \
((void)__android_log_print(ANDROID_LOG_WARN, KOMPUTE_LOG_TAG, fmt::format(__VA_ARGS__)))
#elif defined(KOMPUTE_BUILD_PYTHON)
#define SPDLOG_WARN(...) kp_warning(fmt::format(__VA_ARGS__))
#define KP_LOG_WARN(...) kp_warning(fmt::format(__VA_ARGS__))
#else
#define SPDLOG_WARN(...) fmt::print("[{} {}] [debug] [{}:{}] {}\n", __DATE__, __TIME__, __FILE__, __LINE__, fmt::format(__VA_ARGS__))
#define KP_LOG_WARN(...) fmt::print("[{} {}] [debug] [{}:{}] {}\n", __DATE__, __TIME__, __FILE__, __LINE__, fmt::format(__VA_ARGS__))
#endif // VK_USE_PLATFORM_ANDROID_KHR
#endif // SPDLOG_ACTIVE_LEVEL > 3
#if SPDLOG_ACTIVE_LEVEL > 4
#define SPDLOG_ERROR(...)
#define KP_LOG_ERROR(...)
#else
#if defined(VK_USE_PLATFORM_ANDROID_KHR)
#define SPDLOG_ERROR(...) \
#define KP_LOG_ERROR(...) \
((void)__android_log_print(ANDROID_LOG_ERROR, KOMPUTE_LOG_TAG, fmt::format(__VA_ARGS__)))
#elif defined(KOMPUTE_BUILD_PYTHON)
#define SPDLOG_ERROR(...) kp_error(fmt::format(__VA_ARGS__))
#define KP_LOG_ERROR(...) kp_error(fmt::format(__VA_ARGS__))
#else
#define SPDLOG_ERROR(...) fmt::print("[{} {}] [debug] [{}:{}] {}\n", __DATE__, __TIME__, __FILE__, __LINE__, fmt::format(__VA_ARGS__))
#define KP_LOG_ERROR(...) fmt::print("[{} {}] [debug] [{}:{}] {}\n", __DATE__, __TIME__, __FILE__, __LINE__, fmt::format(__VA_ARGS__))
#endif // VK_USE_PLATFORM_ANDROID_KHR
#endif // SPDLOG_ACTIVE_LEVEL > 4
#endif // KOMPUTE_SPDLOG_ENABLED

View File

@@ -84,23 +84,23 @@ class Manager
std::string sequenceName,
TArgs&&... params)
{
SPDLOG_DEBUG("Kompute Manager evalOp triggered");
KP_LOG_DEBUG("Kompute Manager evalOp triggered");
std::shared_ptr<kp::Sequence> sq =
this->sequence(sequenceName);
SPDLOG_DEBUG("Kompute Manager evalOp running sequence BEGIN");
KP_LOG_DEBUG("Kompute Manager evalOp running sequence BEGIN");
sq->begin();
SPDLOG_DEBUG("Kompute Manager evalOp running sequence RECORD");
KP_LOG_DEBUG("Kompute Manager evalOp running sequence RECORD");
sq->record<T>(tensors, std::forward<TArgs>(params)...);
SPDLOG_DEBUG("Kompute Manager evalOp running sequence END");
KP_LOG_DEBUG("Kompute Manager evalOp running sequence END");
sq->end();
SPDLOG_DEBUG("Kompute Manager evalOp running sequence EVAL");
KP_LOG_DEBUG("Kompute Manager evalOp running sequence EVAL");
sq->eval();
SPDLOG_DEBUG("Kompute Manager evalOp running sequence SUCCESS");
KP_LOG_DEBUG("Kompute Manager evalOp running sequence SUCCESS");
}
/**
@@ -114,7 +114,7 @@ class Manager
void evalOpDefault(std::vector<std::shared_ptr<Tensor>> tensors,
TArgs&&... params)
{
SPDLOG_DEBUG("Kompute Manager evalOp Default triggered");
KP_LOG_DEBUG("Kompute Manager evalOp Default triggered");
this->mCurrentSequenceIndex++;
this->evalOp<T>(
tensors, KP_DEFAULT_SESSION, std::forward<TArgs>(params)...);
@@ -133,24 +133,24 @@ class Manager
std::string sequenceName,
TArgs&&... params)
{
SPDLOG_DEBUG("Kompute Manager evalOpAsync triggered");
KP_LOG_DEBUG("Kompute Manager evalOpAsync triggered");
std::shared_ptr<kp::Sequence> sq =
this->sequence(sequenceName);
SPDLOG_DEBUG("Kompute Manager evalOpAsync running sequence BEGIN");
KP_LOG_DEBUG("Kompute Manager evalOpAsync running sequence BEGIN");
sq->begin();
SPDLOG_DEBUG("Kompute Manager evalOpAsync running sequence RECORD");
KP_LOG_DEBUG("Kompute Manager evalOpAsync running sequence RECORD");
sq->record<T>(tensors, std::forward<TArgs>(params)...);
SPDLOG_DEBUG("Kompute Manager evalOpAsync running sequence END");
KP_LOG_DEBUG("Kompute Manager evalOpAsync running sequence END");
sq->end();
SPDLOG_DEBUG("Kompute Manager evalOpAsync running sequence EVAL");
KP_LOG_DEBUG("Kompute Manager evalOpAsync running sequence EVAL");
sq->evalAsync();
SPDLOG_DEBUG("Kompute Manager evalOpAsync running sequence SUCCESS");
KP_LOG_DEBUG("Kompute Manager evalOpAsync running sequence SUCCESS");
}
/**
@@ -165,7 +165,7 @@ class Manager
void evalOpAsyncDefault(std::vector<std::shared_ptr<Tensor>> tensors,
TArgs&&... params)
{
SPDLOG_DEBUG("Kompute Manager evalOpAsyncDefault triggered");
KP_LOG_DEBUG("Kompute Manager evalOpAsyncDefault triggered");
this->mCurrentSequenceIndex++;
this->evalOpAsync<T>(
tensors, KP_DEFAULT_SESSION, std::forward<TArgs>(params)...);
@@ -179,23 +179,23 @@ class Manager
*/
void evalOpAwait(std::string sequenceName, uint64_t waitFor = UINT64_MAX)
{
SPDLOG_DEBUG("Kompute Manager evalOpAwait triggered with sequence {}",
KP_LOG_DEBUG("Kompute Manager evalOpAwait triggered with sequence {}",
sequenceName);
std::unordered_map<std::string, std::shared_ptr<Sequence>>::iterator
found = this->mManagedSequences.find(sequenceName);
if (found != this->mManagedSequences.end()) {
if (std::shared_ptr<kp::Sequence> sq = found->second) {
SPDLOG_DEBUG("Kompute Manager evalOpAwait running sequence "
KP_LOG_DEBUG("Kompute Manager evalOpAwait running sequence "
"Sequence EVAL AWAIT");
if (sq->isRunning()) {
sq->evalAwait(waitFor);
}
}
SPDLOG_DEBUG(
KP_LOG_DEBUG(
"Kompute Manager evalOpAwait running sequence SUCCESS");
} else {
SPDLOG_ERROR("Kompute Manager evalOpAwait Sequence not found");
KP_LOG_ERROR("Kompute Manager evalOpAwait Sequence not found");
}
}
@@ -208,7 +208,7 @@ class Manager
*/
void evalOpAwaitDefault(uint64_t waitFor = UINT64_MAX)
{
SPDLOG_DEBUG("Kompute Manager evalOpAwaitDefault triggered");
KP_LOG_DEBUG("Kompute Manager evalOpAwaitDefault triggered");
this->evalOpAwait(KP_DEFAULT_SESSION, waitFor);
}

View File

@@ -129,15 +129,15 @@ class Sequence
"Kompute Sequence record(...) template only valid with "
"OpBase derived classes");
SPDLOG_DEBUG("Kompute Sequence record function started");
KP_LOG_DEBUG("Kompute Sequence record function started");
if (!this->isRecording()) {
SPDLOG_ERROR(
KP_LOG_ERROR(
"Kompute sequence record attempted when not record BEGIN");
return false;
}
SPDLOG_DEBUG("Kompute Sequence creating OpBase derived class instance");
KP_LOG_DEBUG("Kompute Sequence creating OpBase derived class instance");
T* op = new T(this->mPhysicalDevice,
this->mDevice,
this->mCommandBuffer,
@@ -148,11 +148,11 @@ class Sequence
std::unique_ptr<OpBase> baseOpPtr{ baseOp };
SPDLOG_DEBUG(
KP_LOG_DEBUG(
"Kompute Sequence running init on OpBase derived class instance");
baseOpPtr->init();
SPDLOG_DEBUG(
KP_LOG_DEBUG(
"Kompute Sequence running record on OpBase derived class instance");
baseOpPtr->record();

View File

@@ -20,7 +20,7 @@ class OpBase
/**
* Base constructor, should not be used unless explicitly intended.
*/
OpBase() { SPDLOG_DEBUG("Compute OpBase base constructor"); }
OpBase() { KP_LOG_DEBUG("Compute OpBase base constructor"); }
/**
* Default constructor with parameters that provides the bare minimum
@@ -37,7 +37,7 @@ class OpBase
std::shared_ptr<vk::CommandBuffer> commandBuffer,
std::vector<std::shared_ptr<Tensor>>& tensors)
{
SPDLOG_DEBUG("Compute OpBase constructor with params");
KP_LOG_DEBUG("Compute OpBase constructor with params");
this->mPhysicalDevice = physicalDevice;
this->mDevice = device;
@@ -52,20 +52,20 @@ class OpBase
*/
virtual ~OpBase()
{
SPDLOG_DEBUG("Kompute OpBase destructor started");
KP_LOG_DEBUG("Kompute OpBase destructor started");
if (!this->mDevice) {
SPDLOG_WARN("Kompute OpBase destructor called with empty device");
KP_LOG_WARN("Kompute OpBase destructor called with empty device");
return;
}
if (this->mFreeTensors) {
SPDLOG_DEBUG("Kompute OpBase freeing tensors");
KP_LOG_DEBUG("Kompute OpBase freeing tensors");
for (std::shared_ptr<Tensor> tensor : this->mTensors) {
if (tensor && tensor->isInit()) {
tensor->freeMemoryDestroyGPUResources();
} else {
SPDLOG_WARN("Kompute OpBase expected to free "
KP_LOG_WARN("Kompute OpBase expected to free "
"tensor but has already been freed.");
}
}

View File

@@ -47,7 +47,7 @@ class OpMult : public OpAlgoBase
const Workgroup& komputeWorkgroup = {})
: OpAlgoBase(physicalDevice, device, commandBuffer, tensors, "", komputeWorkgroup)
{
SPDLOG_DEBUG("Kompute OpMult constructor with params");
KP_LOG_DEBUG("Kompute OpMult constructor with params");
#ifndef RELEASE
this->mShaderFilePath = "shaders/glsl/opmult.comp.spv";
@@ -61,7 +61,7 @@ class OpMult : public OpAlgoBase
*/
std::vector<uint32_t> fetchSpirvBinaryData() override
{
SPDLOG_WARN(
KP_LOG_WARN(
"Kompute OpMult Running shaders directly from header");
return std::vector<uint32_t>(
@@ -77,7 +77,7 @@ class OpMult : public OpAlgoBase
* components but does not destroy the underlying tensors
*/
~OpMult() override {
SPDLOG_DEBUG("Kompute OpMult destructor started");
KP_LOG_DEBUG("Kompute OpMult destructor started");
}
};

View File

@@ -75,7 +75,7 @@ TEST(TestLogisticRegression, TestMainLogisticRegression)
EXPECT_GT(wIn->data()[1], 1.0);
EXPECT_LT(bIn->data()[0], 0.0);
SPDLOG_WARN("Result wIn i: {}, wIn j: {}, bIn: {}",
KP_LOG_WARN("Result wIn i: {}, wIn j: {}, bIn: {}",
wIn->data()[0],
wIn->data()[1],
bIn->data()[0]);
@@ -156,7 +156,7 @@ TEST(TestLogisticRegression, TestMainLogisticRegressionManualCopy)
EXPECT_GT(wIn->data()[1], 1.0);
EXPECT_LT(bIn->data()[0], 0.0);
SPDLOG_WARN("Result wIn i: {}, wIn j: {}, bIn: {}",
KP_LOG_WARN("Result wIn i: {}, wIn j: {}, bIn: {}",
wIn->data()[0],
wIn->data()[1],
bIn->data()[0]);