From 9c4155c65ad2c2be94234ebfc5683fee646eb908 Mon Sep 17 00:00:00 2001
From: Hashim Sharif <hsharif3@tyler.cs.illinois.edu>
Date: Fri, 17 Jan 2020 22:28:44 -0600
Subject: [PATCH] Moving approx simulation source

---
 llvm/projects/hpvm-tensor-rt/CMakeLists.txt     |  2 +-
 .../tensor_runtime/include/approx_api.h         | 17 +++++++++++++++++
 .../tensor_runtime/include/debug.h              |  1 +
 .../tensor_runtime/include/profiling.h          |  1 +
 .../approx_simulation.cu}                       |  0
 .../hpvm-tensor-rt/tensor_runtime/src/debug.cc  |  3 ++-
 6 files changed, 22 insertions(+), 2 deletions(-)
 rename llvm/projects/hpvm-tensor-rt/tensor_runtime/{include/approx_simulation.h => src/approx_simulation.cu} (100%)

diff --git a/llvm/projects/hpvm-tensor-rt/CMakeLists.txt b/llvm/projects/hpvm-tensor-rt/CMakeLists.txt
index d7bffa6b90..832fbc25e2 100644
--- a/llvm/projects/hpvm-tensor-rt/CMakeLists.txt
+++ b/llvm/projects/hpvm-tensor-rt/CMakeLists.txt
@@ -36,7 +36,7 @@ link_directories($ENV{CUDNN_PATH} $ENV{CUDNN_PATH}/lib $ENV{CUDNN_PATH}/lib64)
 
 
 # Adding new rule for building a cuDNN runtime library
-cuda_add_library(tensor_runtime   tensor_runtime/src/tensor_runtime.cu  tensor_runtime/src/half_precision_api.cu  tensor_runtime/src/tensor_utils.cu  tensor_runtime/src/fp16_gemm.cu  tensor_runtime/src/debug.cc tensor_runtime/src/global_data.cc )
+cuda_add_library(tensor_runtime   tensor_runtime/src/tensor_runtime.cu  tensor_runtime/src/half_precision_api.cu  tensor_runtime/src/tensor_utils.cu  tensor_runtime/src/fp16_gemm.cu  tensor_runtime/src/debug.cc tensor_runtime/src/global_data.cc tensor_runtime/src/approx_simulation.cu)
 cuda_add_cublas_to_target(tensor_runtime)
 
 # Adding new rule for building a cuDNN runtime library
diff --git a/llvm/projects/hpvm-tensor-rt/tensor_runtime/include/approx_api.h b/llvm/projects/hpvm-tensor-rt/tensor_runtime/include/approx_api.h
index 50438eb22c..a785917607 100644
--- a/llvm/projects/hpvm-tensor-rt/tensor_runtime/include/approx_api.h
+++ b/llvm/projects/hpvm-tensor-rt/tensor_runtime/include/approx_api.h
@@ -74,4 +74,21 @@ extern "C"{
 			     int row, int col,
 			     int skip_every, int skip_offset);
 
+
+  void* PROMISE_Conv(void* input, float i_min, float i_max,
+		     void* filter, float w_min, float w_max,
+		     void* bias, float b_min, float b_max,
+		     int conv_pad_h, int conv_pad_w,
+		     int conv_stride_h, int conv_stride_w,
+		     int pool_id, int pool_size,
+		     int activation_id, // Relu, Tanh, ClipRelu
+		     float out_min, float out_max, int swing);
+
+
+  void* PROMISE_FC(void* input, float i_min, float i_max,
+		   void* weights, float w_min, float w_max,
+		   void* bias, float b_min, float b_max,
+		   int activation_id,
+		   float out_min, float out_max, int swing);
+  
 }
diff --git a/llvm/projects/hpvm-tensor-rt/tensor_runtime/include/debug.h b/llvm/projects/hpvm-tensor-rt/tensor_runtime/include/debug.h
index e3d4f43318..a847a827bf 100644
--- a/llvm/projects/hpvm-tensor-rt/tensor_runtime/include/debug.h
+++ b/llvm/projects/hpvm-tensor-rt/tensor_runtime/include/debug.h
@@ -8,6 +8,7 @@
 #define ASSERT_FLAG // Sets assertions to true (opposite of NDEBUG macro)
 
 #include "tensor.h"
+#include <sstream>
 
 
 #define FatalError(s) do {                                             \
diff --git a/llvm/projects/hpvm-tensor-rt/tensor_runtime/include/profiling.h b/llvm/projects/hpvm-tensor-rt/tensor_runtime/include/profiling.h
index 7075d51cd6..70ae14ca82 100644
--- a/llvm/projects/hpvm-tensor-rt/tensor_runtime/include/profiling.h
+++ b/llvm/projects/hpvm-tensor-rt/tensor_runtime/include/profiling.h
@@ -17,6 +17,7 @@
 #include <cuda_runtime.h>
 
 #include "global_data.h"
+#include "debug.h"
 
 
 /***** Profiling routines ***/
diff --git a/llvm/projects/hpvm-tensor-rt/tensor_runtime/include/approx_simulation.h b/llvm/projects/hpvm-tensor-rt/tensor_runtime/src/approx_simulation.cu
similarity index 100%
rename from llvm/projects/hpvm-tensor-rt/tensor_runtime/include/approx_simulation.h
rename to llvm/projects/hpvm-tensor-rt/tensor_runtime/src/approx_simulation.cu
diff --git a/llvm/projects/hpvm-tensor-rt/tensor_runtime/src/debug.cc b/llvm/projects/hpvm-tensor-rt/tensor_runtime/src/debug.cc
index d40e6e3dfb..1b36039f2f 100644
--- a/llvm/projects/hpvm-tensor-rt/tensor_runtime/src/debug.cc
+++ b/llvm/projects/hpvm-tensor-rt/tensor_runtime/src/debug.cc
@@ -8,10 +8,11 @@
 #define ASSERT_FLAG // Sets assertions to true (opposite of NDEBUG macro)
 
 #include "tensor.h"
-#include "../include/debug.h"
+#include "debug.h"
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <sstream>
 
 
 void INFO(const char* format, ...){
-- 
GitLab