Skip to content
Snippets Groups Projects
Commit c2d84e77 authored by Yifan Zhao's avatar Yifan Zhao
Browse files

Merged debug.cc and debug.cpp

parent caaf0792
No related branches found
No related tags found
No related merge requests found
...@@ -50,7 +50,7 @@ set( ...@@ -50,7 +50,7 @@ set(
RUNTIME_SRCS_FILENAME RUNTIME_SRCS_FILENAME
approx_knobs_utils.cc approx_simulation.cu approx_techniques.cu approx_knobs_utils.cc approx_simulation.cu approx_techniques.cu
configuration.cpp configuration.cpp
debug.cc debug.cpp device_math.cu debug.cpp device_math.cu
error.cu error.cu
fp16_gemm.cu freq_utils.cc fp16_gemm.cu freq_utils.cc
global_data.cc group_conv.cu global_data.cc group_conv.cu
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#define LOG_DEBUG 1 // Sets the debug logging to true #define LOG_DEBUG 1 // Sets the debug logging to true
#define LOG_INFO 1 // Sets the info 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) #define ASSERT_FLAG // Sets assertions to true (opposite of NDEBUG macro)
#include "tensor.h" #include "tensor.h"
......
#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
#include "debug.h" #include "debug.h"
#include "tensor.h"
#include <cstdarg> #include <cstdarg>
#include <cstdio> #include <cstdio>
#include <cuda_runtime_api.h> #include <cuda_runtime_api.h>
#include <stdexcept> #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, ...) { void throwError(const char *file, int line, const char *fmt, ...) {
char msg[2048]; char msg[2048];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment