Skip to content
Snippets Groups Projects
Commit 6c5dd7e5 authored by Hashim Sharif's avatar Hashim Sharif
Browse files

Disabling C++11 ABI for compatibilty across systems

parent 330f107e
No related branches found
No related tags found
No related merge requests found
......@@ -11,6 +11,7 @@
#include "../../tensor_runtime/include/tensor_cpu_runtime.h"
#include "types.h"
#include <cmath>
#include <stdint.h>
std::vector<float> run_accuracies;
......@@ -147,7 +148,6 @@ uint8_t* readLabelsBatch(const char* labels_file, int start, int end){
fclose(file);
// printf("--labels bytes_read = %lu \n", bytes_read);
return labels;
}
......@@ -169,7 +169,6 @@ void computeAccuracy(const char* labels_file, int num_labels, void* result_ptr){
if (data[i * channels + chosen] < data[i * channels + id]) chosen = id;
}
//printf("chosen = %d, label = %d \n", chosen, labels[i]);
if(chosen != labels[i])
num_errors++;
}
......@@ -180,12 +179,7 @@ void computeAccuracy(const char* labels_file, int num_labels, void* result_ptr){
FILE* fp = fopen("final_accuracy", "w+");
if(fp != NULL){
std::ostringstream ss;
ss << std::fixed << accuracy;
std::string print_str = ss.str();
fwrite(print_str.c_str(), 1, print_str.length(), fp);
fprintf(fp, "%f", accuracy);
fclose(fp);
}
......@@ -206,8 +200,7 @@ float computeAccuracy2(uint8_t* labels, int num_labels, void* result_ptr, unsign
printf("batch_dim = %lu, channels = %lu \n", batch_dim, channels);
for(int i = 0; i < num_labels; i++){
for(int i = 0; i < num_labels; i++){
int chosen = 0;
for (int id = 1; id < num_classes; ++id){
if (data[i * channels + chosen] < data[i * channels + id]) chosen = id;
......@@ -218,22 +211,14 @@ float computeAccuracy2(uint8_t* labels, int num_labels, void* result_ptr, unsign
if(chosen != labels[i])
num_errors++;
//printf("chosen = %d, label = %d \n", chosen, labels[i]);
}
float accuracy = ((batch_dim - num_errors) * 1.0 / batch_dim * 1.0) * 100.0;
printf("****** Accuracy = %f \n\n", accuracy);
//printf("****** Zero class labels %d \n", num_zeros);
FILE* fp = fopen("final_accuracy", "w+");
if(fp != NULL){
std::ostringstream ss;
ss << std::fixed << accuracy;
std::string print_str = ss.str();
fwrite(print_str.c_str(), 1, print_str.length(), fp);
fprintf(fp, "%f", accuracy);
}
fclose(fp);
......@@ -292,12 +277,7 @@ float computeTop5Accuracy(uint8_t* labels, int num_labels, void* result_ptr, uns
FILE* fp = fopen("final_accuracy", "w+");
if(fp != NULL){
std::ostringstream ss;
ss << std::fixed << accuracy;
std::string print_str = ss.str();
fwrite(print_str.c_str(), 1, print_str.length(), fp);
fprintf(fp, "%f", accuracy);
}
fclose(fp);
......@@ -314,11 +294,7 @@ void dumpFinalAccuracy(float accuracy){
FILE* fp = fopen("final_accuracy", "w+");
if(fp != NULL){
std::ostringstream ss;
ss << std::fixed << accuracy;
std::string print_str = ss.str();
fwrite(print_str.c_str(), 1, print_str.length(), fp);
fprintf(fp, "%f", accuracy);
}
fclose(fp);
......@@ -328,7 +304,7 @@ void dumpFinalAccuracy(float accuracy){
void dumpAvgPSNR(float avg_psnr){
/*void dumpAvgPSNR(float avg_psnr){
FILE* fp = fopen("avg_psnr", "w+");
if(fp != NULL){
......@@ -340,9 +316,9 @@ void dumpAvgPSNR(float avg_psnr){
fclose(fp);
}
*/
void dumpPSNRStd(float psnr_std){
/*void dumpPSNRStd(float psnr_std){
FILE* fp = fopen("psnr_std.txt", "w+");
if(fp != NULL){
......@@ -353,12 +329,12 @@ void dumpPSNRStd(float psnr_std){
}
fclose(fp);
}
}*/
/*
void dumpExecutionAccuracies(){
FILE* fp = fopen("run_accuracies.txt", "w+");
......@@ -376,7 +352,7 @@ void dumpExecutionAccuracies(){
fclose(fp);
}
*/
float readPSNRFromFile(const char* file_name){
......@@ -393,7 +369,7 @@ float readPSNRFromFile(const char* file_name){
}
float computePSNRViolation(void* gold_ptr, void* approx_ptr, float PSNR_threshold){
/*float computePSNRViolation(void* gold_ptr, void* approx_ptr, float PSNR_threshold){
PSNR_threshold = readPSNRFromFile("psnr.txt");
......@@ -468,10 +444,10 @@ float computePSNRViolation(void* gold_ptr, void* approx_ptr, float PSNR_threshol
var /= batch_dim;
float std = sqrt(var);
dumpPSNRStd(std);
//dumpPSNRStd(std);
return violation_rate;
}
}*/
void dumpOutput(void* output_ptr, const char* file_name){
......
......@@ -22,8 +22,9 @@ DNN_INCLUDE_DIR = $(LLVM_SRC_ROOT)/projects/hpvm-tensor-rt/dnn_sources/include
TENSOR_RT_INCLUDE_DIR = $(LLVM_SRC_ROOT)/projects/hpvm-tensor-rt/tensor_runtime/include
TENSOR_RT_SRC_DIR = $(LLVM_SRC_ROOT)/projects/hpvm-tensor-rt/tensor_runtime/src
# -std=c++11
# -I $(TENSOR_INCLUDE_DIR)
CC_FLAGS = -I $(LLVM_INCLUDE_DIR) -I $(DNN_INCLUDE_DIR) -I $(COMMON_INCLUDE_DIR) -I $(TENSOR_RT_INCLUDE_DIR) -I $(CUDA_INCLUDE_PATH) -fno-exceptions -ffast-math -std=c++11 -O3
CC_FLAGS = -I $(LLVM_INCLUDE_DIR) -I $(DNN_INCLUDE_DIR) -I $(COMMON_INCLUDE_DIR) -I $(TENSOR_RT_INCLUDE_DIR) -I $(CUDA_INCLUDE_PATH) -fno-exceptions -ffast-math -D_GLIBCXX_USE_CXX11_ABI=0 -O3
LINKER_FLAGS = -lpthread -lOpenCL
HPVM_LIB_DIR = $(HPVM_BUILD_DIR)/lib
......@@ -35,7 +36,9 @@ OPTFLAGS2 = -load $(HPVM_LIB_DIR)/InlineTensorCalls.so -inline-tensor-calls
TARGET = $(BUILD_DIR)/$(APP).opt.bc
SOURCES = $(SRC_DIR)/$(APP).cpp
VISC_RT_PATH = $(LLVM_SRC_ROOT)/../build/projects/visc-rt/visc-rt.ll
#VISC_RT_PATH = $(LLVM_SRC_ROOT)/../build/projects/visc-rt/visc-rt.ll
VISC_RT_PATH = $(HPVM_BUILD_DIR)/projects/visc-rt/visc-rt.ll
.PRECIOUS: $(BUILD_DIR)/$(APP).ll $(BUILD_DIR)/$(APP).visc.ll
default: $(BUILD_DIR) $(TARGET)
......@@ -55,7 +58,8 @@ $(BUILD_DIR)/%.opt.bc: $(BUILD_DIR)/%.visc.ll
$(OPT) $(OPTFLAGS1) $< -o $@
$(CC) -emit-llvm -c $(TENSOR_RT_SRC_DIR)/tensor_cpu_runtime.cc -o $(BUILD_DIR)/tensor_cpu_runtime.bc
$(OPT) -always-inline $(BUILD_DIR)/tensor_cpu_runtime.bc -o $(BUILD_DIR)/tensor_cpu_runtime.bc
$(LLVM_LINK) $@ $(wildcard *module.ll) $(BUILD_DIR)/tensor_cpu_runtime.bc $(VISC_RT_PATH) -o $(BUILD_DIR)/lenet_tensor_rt.bc
$(LLVM_LINK) $@ $(BUILD_DIR)/$(wildcard *module.ll) $(BUILD_DIR)/tensor_cpu_runtime.bc $(VISC_RT_PATH) -o $(BUILD_DIR)/lenet_tensor_rt.bc
$(OPT) $(OPTFLAGS2) $(BUILD_DIR)/lenet_tensor_rt.bc -o $(BUILD_DIR)/lenet_inline.bc
$(CC) $(BUILD_DIR)/lenet_tensor_rt.bc -o $(BUILD_DIR)/lenet_final $(LINKER_FLAGS)
$(foreach module, $(expanded_modules), $(LLVM_LINK) $(module) $(BUILD_DIR)/tensor_cpu_runtime.bc -o $(module)_linked ${\n} $(OPT) $(OPTFLAGS2) $(module)_linked -o $(module)_inline ${\n} )
......
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