From c2d84e77b12a3859b0ddfdf39bdab9d389dae7ba Mon Sep 17 00:00:00 2001 From: Yifan Zhao <yifanz16@illinois.edu> Date: Tue, 2 Feb 2021 03:03:08 -0600 Subject: [PATCH] Merged debug.cc and debug.cpp --- hpvm/projects/hpvm-tensor-rt/CMakeLists.txt | 2 +- .../tensor_runtime/include/debug.h | 1 + .../tensor_runtime/src/debug.cc | 76 ------------------- .../tensor_runtime/src/debug.cpp | 61 +++++++++++++++ 4 files changed, 63 insertions(+), 77 deletions(-) delete mode 100644 hpvm/projects/hpvm-tensor-rt/tensor_runtime/src/debug.cc diff --git a/hpvm/projects/hpvm-tensor-rt/CMakeLists.txt b/hpvm/projects/hpvm-tensor-rt/CMakeLists.txt index 492fdbacb4..24c200f5e8 100644 --- a/hpvm/projects/hpvm-tensor-rt/CMakeLists.txt +++ b/hpvm/projects/hpvm-tensor-rt/CMakeLists.txt @@ -50,7 +50,7 @@ set( RUNTIME_SRCS_FILENAME approx_knobs_utils.cc approx_simulation.cu approx_techniques.cu configuration.cpp - debug.cc debug.cpp device_math.cu + debug.cpp device_math.cu error.cu fp16_gemm.cu freq_utils.cc global_data.cc group_conv.cu diff --git a/hpvm/projects/hpvm-tensor-rt/tensor_runtime/include/debug.h b/hpvm/projects/hpvm-tensor-rt/tensor_runtime/include/debug.h index 7724a49edf..2c9f48203b 100644 --- a/hpvm/projects/hpvm-tensor-rt/tensor_runtime/include/debug.h +++ b/hpvm/projects/hpvm-tensor-rt/tensor_runtime/include/debug.h @@ -5,6 +5,7 @@ #define LOG_DEBUG 1 // Sets the debug logging to true #define LOG_INFO 1 // Sets the info logging to true +#define LOG_ERROR 1 // Print Errors #define ASSERT_FLAG // Sets assertions to true (opposite of NDEBUG macro) #include "tensor.h" diff --git a/hpvm/projects/hpvm-tensor-rt/tensor_runtime/src/debug.cc b/hpvm/projects/hpvm-tensor-rt/tensor_runtime/src/debug.cc deleted file mode 100644 index 1abf5432b9..0000000000 --- a/hpvm/projects/hpvm-tensor-rt/tensor_runtime/src/debug.cc +++ /dev/null @@ -1,76 +0,0 @@ - - -#ifndef RUNTIME_DEBUG -#define RUNTIME_DEBUG - -#define LOG_DEBUG 0 // Sets the debug logging to true -#define LOG_INFO 1 // Sets the info logging to true -#define LOG_ERROR 1 // Print Errors -#define ASSERT_FLAG // Sets assertions to true (opposite of NDEBUG macro) - -#include "debug.h" -#include "tensor.h" -#include <sstream> -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> - -void INFO(const char *format, ...) { - if (!LOG_INFO) // Don't print if logging info is disabled - return; - va_list args; - va_start(args, format); - printf("INFO: "); - vprintf(format, args); - va_end(args); -} - -void DEBUG(const char *format, ...) { - if (!LOG_DEBUG) // Don't print if logging info is disabled - return; - va_list args; - va_start(args, format); - printf("DEBUG: "); - vprintf(format, args); - va_end(args); -} - -void ERROR(const char *format, ...) { - if (!LOG_ERROR) // Don't print if logging info is disabled - return; - va_list args; - va_start(args, format); - printf("ERROR!: "); - vprintf(format, args); - va_end(args); - - abort(); -} - -void fillOnes(struct Tensor *tensor) { - // initialization is specific to the floating point type - if (tensor->data_type == CUDNN_DATA_FLOAT) { - float *data_arr = (float *)tensor->host_data; - for (unsigned int i = 0; i < tensor->num_elems; i++) { - data_arr[i] = 1.0; - } - } -} - -void printTensorDescInfo(struct Tensor *tensor) { - - cudnnDataType_t dType; - int nStride, cStride, hStride, wStride; - int size1, size2, size3, size4; - cudnnGetTensor4dDescriptor(tensor->tensor_desc, &dType, &size1, &size2, - &size3, &size4, &nStride, &cStride, &hStride, - &wStride); - - DEBUG("dType = %d, size1 = %d, size2 = %d, size3 = %d, size4 = %d \n", dType, - size1, size2, size3, size4); - - DEBUG("nStride = %d, cStride = %d, hStride = %d, wStride = %d \n", nStride, - cStride, hStride, wStride); -} - -#endif diff --git a/hpvm/projects/hpvm-tensor-rt/tensor_runtime/src/debug.cpp b/hpvm/projects/hpvm-tensor-rt/tensor_runtime/src/debug.cpp index 9bec84de77..8e5e1fe968 100644 --- a/hpvm/projects/hpvm-tensor-rt/tensor_runtime/src/debug.cpp +++ b/hpvm/projects/hpvm-tensor-rt/tensor_runtime/src/debug.cpp @@ -1,8 +1,69 @@ #include "debug.h" +#include "tensor.h" #include <cstdarg> #include <cstdio> #include <cuda_runtime_api.h> #include <stdexcept> +#include <sstream> +#include <cstdlib> + +void INFO(const char *format, ...) { + if (!LOG_INFO) // Don't print if logging info is disabled + return; + va_list args; + va_start(args, format); + printf("INFO: "); + vprintf(format, args); + va_end(args); +} + +void DEBUG(const char *format, ...) { + if (!LOG_DEBUG) // Don't print if logging info is disabled + return; + va_list args; + va_start(args, format); + printf("DEBUG: "); + vprintf(format, args); + va_end(args); +} + +void ERROR(const char *format, ...) { + if (!LOG_ERROR) // Don't print if logging info is disabled + return; + va_list args; + va_start(args, format); + printf("ERROR!: "); + vprintf(format, args); + va_end(args); + + abort(); +} + +void fillOnes(struct Tensor *tensor) { + // initialization is specific to the floating point type + if (tensor->data_type == CUDNN_DATA_FLOAT) { + float *data_arr = (float *)tensor->host_data; + for (unsigned int i = 0; i < tensor->num_elems; i++) { + data_arr[i] = 1.0; + } + } +} + +void printTensorDescInfo(struct Tensor *tensor) { + + cudnnDataType_t dType; + int nStride, cStride, hStride, wStride; + int size1, size2, size3, size4; + cudnnGetTensor4dDescriptor(tensor->tensor_desc, &dType, &size1, &size2, + &size3, &size4, &nStride, &cStride, &hStride, + &wStride); + + DEBUG("dType = %d, size1 = %d, size2 = %d, size3 = %d, size4 = %d \n", dType, + size1, size2, size3, size4); + + DEBUG("nStride = %d, cStride = %d, hStride = %d, wStride = %d \n", nStride, + cStride, hStride, wStride); +} void throwError(const char *file, int line, const char *fmt, ...) { char msg[2048]; -- GitLab