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

Adding dir_path cmd argument to InsertApproxInfo pass

parent 8374b345
No related branches found
No related tags found
No related merge requests found
......@@ -21,6 +21,9 @@
#include "llvm/Support/SourceMgr.h"
#include "llvm/InPlaceDFG/InPlaceDFGAnalysis.h"
#include "llvm/SupportVISC/DFG2LLVM.h"
#include <unordered_map>
#include <dirent.h>
#include <stdio.h>
using namespace llvm;
......@@ -31,10 +34,26 @@ using namespace inplacedfg;
namespace {
static cl::opt<std::string> dir_name("results-dir", cl::desc(" Name of directory with Autotuner results "));
struct ApproxMetrics{
// Relative L-norm metrics
double relative_l0;
double relative_l1;
double relative_l2;
// Mean L-norm metrics
double mean_l0;
double mean_l1;
double mean_l2;
};
struct InsertApproxInfoWrapperPass : public ModulePass {
static char ID; // Pass identification, replacement for typeid
InsertApproxInfoWrapperPass() : ModulePass(ID) {}
public:
// Functions
bool runOnModule(Module &M);
......@@ -51,6 +70,10 @@ private:
void initRuntimeAPI() {}
void codeGen(DFInternalNode* N);
void codeGen(DFLeafNode* N);
void loadTrainedApproxMetrics(std::string dir_path);
// private data
std::unordered_map<std::string, std::vector<ApproxMetrics*>> operation_metrics;
public:
// Constructor
......@@ -59,7 +82,7 @@ public:
}
//void run(Module &M, BuildDFG &DFG);
void run();
void run(std::string dir_path);
};
......@@ -70,20 +93,43 @@ void InsertApproxInfoWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
AU.addPreserved<BuildDFG>();
}
bool InsertApproxInfoWrapperPass::runOnModule(Module &M) {
std::string dir_path = dir_name.getValue();
// Get the BuildDFG Analysis Results:
// - Dataflow graph
BuildDFG &DFG = getAnalysis<BuildDFG>();
InsertApproxInfo IApprox(M, DFG);
IApprox.run();
IApprox.run(dir_path);
return false;
}
void InsertApproxInfo::loadTrainedApproxMetrics(std::string dir_path){
struct dirent* entry;
DIR* dir = opendir(dir_path.c_str());
if(dir == NULL){
printf("Directory %s not found . Aborting ... \n\n ", dir_path.c_str());
abort();
}
while((entry = readdir(dir)) != NULL){
printf("%s \n", entry->d_name);
}
}
/*** Methods of InPlaceDFGAnalysis ***/
void InsertApproxInfo::run() {
void InsertApproxInfo::run(std::string dir_path) {
loadTrainedApproxMetrics(dir_path);
errs() << "\n NOTE: ApproxInfo INSERTION TRANSFORM \n";
std::vector<DFInternalNode*> Roots = DFG.getRoots();
......@@ -116,5 +162,9 @@ static RegisterPass<InsertApproxInfoWrapperPass> X("insert-approxinfo",
false /* does not modify the CFG */,
false /* not transformation, just analysis */);
} // End of namespace
......@@ -4,12 +4,11 @@
module load cuda-toolkit/9.1
export CUDA_INCLUDE_PATH=/software/cuda-9.1/include
export CUDNN_PATH=/software/cuda-9.1/lib64/
module load cuda-toolkit/9.1
export LIBRARY_PATH=/software/cuda-9.1/lib64/:$LIBRARY_PATH
export LD_LIBRARY_PATH=/software/cuda-9.1/lib64/$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/software/cuda-9.1/lib64/:$LD_LIBRARY_PATH
# HPVM Path setup
export CPATH=$CPATH:/home/hsharif3/anaconda2/include/
export PATH=/home/hsharif3/Gitlab/llvm/llvm/build/bin/:$PATH
export PATH=/home/hsharif3/Gitlab/hpvm/build/bin/:$PATH
export LLVM_BUILD_ROOT=/home/hsharif3/Gitlab/hpvm/build/
export LLVM_SRC_ROOT=/home/hsharif3/Gitlab/hpvm/llvm/
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