From ed090fb4c1a8025a91d8da9ed00b377e3685d4e1 Mon Sep 17 00:00:00 2001
From: Hashim Sharif <hsharif3@miranda.cs.illinois.edu>
Date: Tue, 26 Jan 2021 01:27:03 -0600
Subject: [PATCH] BugFix: Adding checks for global_knobs.txt existence

---
 .../tensor_runtime/src/approx_knobs_utils.cc       | 14 +++++++++++---
 .../hpvm-tensor-rt/tensor_runtime/src/debug.cc     |  3 ++-
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/hpvm/projects/hpvm-tensor-rt/tensor_runtime/src/approx_knobs_utils.cc b/hpvm/projects/hpvm-tensor-rt/tensor_runtime/src/approx_knobs_utils.cc
index 1c9abe0497..b272bbcab4 100644
--- a/hpvm/projects/hpvm-tensor-rt/tensor_runtime/src/approx_knobs_utils.cc
+++ b/hpvm/projects/hpvm-tensor-rt/tensor_runtime/src/approx_knobs_utils.cc
@@ -24,16 +24,20 @@ PerfParams::PerfParams(int row1, int col1, int skip_offset1) {
 
 PerfParamSet::PerfParamSet() {
 
-  //printf("- knobs_file_path = %s \n", GLOBAL_KNOBS_FILE);
+  printf("- knobs_file_path = %s \n", GLOBAL_KNOBS_FILE);
   std::ifstream file(GLOBAL_KNOBS_FILE);
 
+  if (!file){
+    ERROR(" Could NOT find global_knobs.txt \n");
+  }
+  
   std::string line;
   std::string partial;
   std::vector<std::string> tokens;
 
   while (std::getline(file, line)) { // Read each line
 
-    // printf ("***** line === %s ", line);
+    //printf ("***** line === %s ", line);
     std::istringstream iss(line);
     std::string token;
     while (std::getline(iss, token, '\t')) { // Read each token in the line
@@ -94,9 +98,13 @@ SampParams::SampParams(int skip_rate1, int skip_offset1,
 
 SampParamSet::SampParamSet() {
 
-  //printf("- knobs_file_path = %s \n", GLOBAL_KNOBS_FILE);
+  printf("- knobs_file_path = %s \n", GLOBAL_KNOBS_FILE);
   std::ifstream file(GLOBAL_KNOBS_FILE);
 
+  if (!file){
+    ERROR("Could NOT find global_knobs.txt \n");
+  }
+  
   std::string line;
   std::string partial;
   std::vector<std::string> tokens;
diff --git a/hpvm/projects/hpvm-tensor-rt/tensor_runtime/src/debug.cc b/hpvm/projects/hpvm-tensor-rt/tensor_runtime/src/debug.cc
index 04f22482bb..3e4aecb824 100644
--- a/hpvm/projects/hpvm-tensor-rt/tensor_runtime/src/debug.cc
+++ b/hpvm/projects/hpvm-tensor-rt/tensor_runtime/src/debug.cc
@@ -5,6 +5,7 @@
 
 #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"
@@ -35,7 +36,7 @@ void DEBUG(const char *format, ...) {
 }
 
 void ERROR(const char *format, ...) {
-  if (!LOG_DEBUG) // Don't print if logging info is disabled
+  if (!LOG_ERROR) // Don't print if logging info is disabled
     return;
   va_list args;
   va_start(args, format);
-- 
GitLab