Skip to content
Snippets Groups Projects
Commit ebfd4e06 authored by hashimsharif's avatar hashimsharif
Browse files

Fixing global_knobs.txt path - make it relative to LLVM_SRC_ROOT

parent 88ed4913
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@
#include <fstream>
#include <map>
#include <vector>
#include <string.h>
#include "approx_knob_utils.h"
......@@ -24,8 +25,22 @@ PerfParams::PerfParams(int row1, int col1, int skip_offset1){
PerfParamSet::PerfParamSet(){
std::ifstream file("../autotuner/data/global_knobs.txt");
char llvm_src_root[100];
strcpy(llvm_src_root, getenv("LLVM_SRC_ROOT"));
if (llvm_src_root == NULL){
printf("ERROR: SET LLVM_SRC_ROOT \n");
abort();
}
printf ("*LLVM_SRC_ROOT = %s", llvm_src_root);
char* knobs_file_path = strcat(llvm_src_root, "/projects/hpvm-tensor-rt/autotuner/data/global_knobs.txt");
printf ("- knobs_file_path = %s \n", knobs_file_path);
std::ifstream file(knobs_file_path);
std::string line;
std::string partial;
......@@ -33,6 +48,8 @@ PerfParamSet::PerfParamSet(){
while(std::getline(file, line)) { // Read each line
printf ("***** line === ", line);
std::istringstream iss(line);
std::string token;
while(std::getline(iss, token, '\t')){ // Read each token in the line
......@@ -58,7 +75,8 @@ PerfParamSet::PerfParamSet(){
std::getline(token_stream, tok, ',');
int offset = atoi(tok.c_str());
printf ("**** knob = %d, row = %d, col = %d, offset = %d \n\n", knob, row, col, offset);
PerfParams params(row, col, offset);
perf_knob_map[knob] = params;
......@@ -66,11 +84,16 @@ PerfParamSet::PerfParamSet(){
}
}
file.close();
}
PerfParams PerfParamSet::getPerfParams(int swing){
if (swing >= 150){
swing = swing - 30;
}
return perf_knob_map[swing];
......@@ -94,58 +117,79 @@ SampParams::SampParams(int skip_rate1, int skip_offset1, float interpolation_id1
SampParamSet::SampParamSet(){
std::ifstream file("../autotuner/data/global_knobs.txt");
char llvm_src_root[100];
strcpy(llvm_src_root, getenv("LLVM_SRC_ROOT"));
if (llvm_src_root == NULL){
printf("ERROR: SET LLVM_SRC_ROOT \n");
abort();
}
printf ("* LLVM_SRC_ROOT = %s \n", llvm_src_root);
std::string line;
std::string partial;
std::vector<std::string> tokens;
char* knobs_file_path = strcat(llvm_src_root, "/projects/hpvm-tensor-rt/autotuner/data/global_knobs.txt");
printf ("- knobs_file_path = %s \n", knobs_file_path);
std::ifstream file(knobs_file_path);
while(std::getline(file, line)) { // Read each line
std::string line;
std::string partial;
std::vector<std::string> tokens;
while(std::getline(file, line)) { // Read each line
std::istringstream iss(line);
std::string token;
while(std::getline(iss, token, '\t')){ // Read each token in the line
tokens.push_back(token);
std::istringstream iss(line);
std::string token;
while(std::getline(iss, token, '\t')){ // Read each token in the line
tokens.push_back(token);
int index = token.find("samp");
int test_index = token.find("reduction");
int index = token.find("samp");
int test_index = token.find("reduction");
if (index != std::string::npos && test_index == std::string::npos){
if (index != std::string::npos && test_index == std::string::npos){
int index2 = token.find(",");
std::string knob_str = token.substr(index2 + 1);
int knob = atoi(knob_str.c_str());
printf ("knob = %d \n", knob);
int index2 = token.find(",");
std::string knob_str = token.substr(index2 + 1);
int knob = atoi(knob_str.c_str());
printf ("knob = %d \n", knob);
std::getline(iss, token, '\t');
std::istringstream token_stream(token);
std::getline(iss, token, '\t');
std::istringstream token_stream(token);
std::string tok;
std::string tok;
std::getline(token_stream, tok, ',');
int skip_every = atoi(tok.c_str());
std::getline(token_stream, tok, ',');
int skip_every = atoi(tok.c_str());
std::getline(token_stream, tok, ',');
int offset = atoi(tok.c_str());
std::getline(token_stream, tok, ',');
int offset = atoi(tok.c_str());
std::getline(token_stream, tok, ',');
float interpolation_id = atof(tok.c_str());
std::getline(token_stream, tok, ',');
float interpolation_id = atof(tok.c_str());
printf ("skip_every = %d, offset = %d \n", skip_every, offset);
SampParams params(skip_every, offset, interpolation_id);
samp_knob_map[knob] = params;
printf ("skip_every = %d, offset = %d \n", skip_every, offset);
SampParams params(skip_every, offset, interpolation_id);
samp_knob_map[knob] = params;
}
}
}
}
file.close();
}
SampParams SampParamSet::getSampParams(int swing){
if (swing >= 260){
swing = swing - 30;
}
return samp_knob_map[swing];
}
......
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