From b2912d3a984826285edfa53a880f81be1ec21a06 Mon Sep 17 00:00:00 2001 From: Adel Ejjeh <aejjeh@tyler.cs.illinois.edu> Date: Wed, 22 Jan 2020 21:37:28 -0600 Subject: [PATCH] fixed policy and unsused code in X86 pass and visc-rt --- .../Transforms/DFG2LLVM_X86/DFG2LLVM_X86.cpp | 196 ++++-------------- .../visc-rt/deviceStatusSwitchIntervals.txt | 2 - hpvm/projects/visc-rt/device_abstraction.h | 80 ------- hpvm/projects/visc-rt/makefile | 29 --- hpvm/projects/visc-rt/policy.h | 108 ---------- hpvm/projects/visc-rt/visc-rt.cpp | 50 ----- hpvm/projects/visc-rt/visc-rt.h | 13 -- hpvm/test/hpvm-cava/Makefile | 12 +- hpvm/test/hpvm-cava/Makefile.config | 22 +- hpvm/test/hpvm-cava/Makefile.config.example | 28 ++- hpvm/test/parboil/common/mk/visc.mk | 13 +- hpvm/test/pipeline/Makefile | 7 +- hpvm/test/pipeline/Makefile.config | 22 +- hpvm/test/pipeline/Makefile.config.example | 28 ++- 14 files changed, 97 insertions(+), 513 deletions(-) delete mode 100644 hpvm/projects/visc-rt/deviceStatusSwitchIntervals.txt delete mode 100644 hpvm/projects/visc-rt/device_abstraction.h delete mode 100644 hpvm/projects/visc-rt/makefile delete mode 100644 hpvm/projects/visc-rt/policy.h diff --git a/hpvm/lib/Transforms/DFG2LLVM_X86/DFG2LLVM_X86.cpp b/hpvm/lib/Transforms/DFG2LLVM_X86/DFG2LLVM_X86.cpp index 09198e26b3..6498b46cd9 100644 --- a/hpvm/lib/Transforms/DFG2LLVM_X86/DFG2LLVM_X86.cpp +++ b/hpvm/lib/Transforms/DFG2LLVM_X86/DFG2LLVM_X86.cpp @@ -160,12 +160,14 @@ void CGT_X86::initRuntimeAPI() { assert(LLVM_SRC_ROOT != NULL && "Define LLVM_SRC_ROOT environment variable!"); Twine llvmSrcRoot = LLVM_SRC_ROOT; - Twine runtimeAPI = llvmSrcRoot + "/tools/hpvm/projects/visc-rt/visc-rt.ll"; + Twine runtimeAPI = llvmSrcRoot + "/../build/tools/hpvm/projects/visc-rt/visc-rt.bc"; runtimeModule = parseIRFile(runtimeAPI.str(), Err, M.getContext()); - if(runtimeModule == NULL) - DEBUG(errs() << Err.getMessage()); + if(runtimeModule == nullptr) { + DEBUG(errs() << Err.getMessage() << " " << runtimeAPI << "\n"); + assert(false && "couldn't parse runtime"); + } else DEBUG(errs() << "Successfully loaded visc-rt API module\n"); @@ -1005,7 +1007,7 @@ Function* CGT_X86::createFunctionFilter(DFNode* C) { CF->getLinkage(), CF->getName()+"_Pipeline", &M); - DEBUG(errs() << "Generating Pipline Function\n"); + DEBUG(errs() << "Generating Pipeline Function\n"); // Give a name to the argument which is used pass data to this thread Value* data = &*CF_Pipeline->arg_begin(); data->setName("data.addr"); @@ -1054,7 +1056,7 @@ Function* CGT_X86::createFunctionFilter(DFNode* C) { TyList.push_back(i8Ty->getPointerTo()); names.push_back("isLastInput_buffer"); - // Extract the inputs, outputs and + // Extract the inputs, outputs Args = extractElements(data, TyList, names, RI); for(unsigned i=0; i<Args.size(); i++) { DEBUG(errs() << *Args[i] << "\n"); @@ -1168,8 +1170,6 @@ Function* CGT_X86::createFunctionFilter(DFNode* C) { EntryBB = CondStartI->getParent(); addWhileLoop(CondStartI, BodyStartI, RI, Cond); - CondBB = CondStartI->getParent(); - BodyBB = CI->getParent(); // Return the Function pointer DEBUG(errs() << "Pipeline Version of " << CF->getName() << ":\n"); @@ -1347,12 +1347,13 @@ void CGT_X86::codeGen(DFInternalNode* N) { bool CFx86 = N->hasX86GenFuncForTarget(visc::CPU_TARGET); bool GFx86 = N->hasX86GenFuncForTarget(visc::GPU_TARGET); - errs() << "Node: " << N->getFuncPointer()->getName() - << " with tag " << N->getTag() << "\n"; - errs() << "CPU Fun: " << (CF ? CF->getName() : "null" ) << "\n"; - errs() << "hasx86GenFuncForCPU : " << CFx86 << "\n"; - errs() << "GPU Fun: " << (GF ? GF->getName() : "null" ) << "\n"; - errs() << "hasx86GenFuncForGPU : " << GFx86 << "\n"; + DEBUG(errs() << "Before editing\n"); + DEBUG(errs() << "Node: " << N->getFuncPointer()->getName() + << " with tag " << N->getTag() << "\n"); + DEBUG(errs() << "CPU Fun: " << (CF ? CF->getName() : "null" ) << "\n"); + DEBUG(errs() << "hasx86GenFuncForCPU : " << CFx86 << "\n"); + DEBUG(errs() << "GPU Fun: " << (GF ? GF->getName() : "null" ) << "\n"); + DEBUG(errs() << "hasx86GenFuncForGPU : " << GFx86 << "\n"); if (N->getTag() == visc::None) { @@ -1362,8 +1363,8 @@ void CGT_X86::codeGen(DFInternalNode* N) { // node, and thus they have not produced a genFunc // - a child node had no CPU hint, thus no code gen for CPU could // take place - errs() << "No GenFunc - Skipping CPU code generation for node " - << N->getFuncPointer()->getName() << "\n"; + DEBUG(errs() << "No GenFunc - Skipping CPU code generation for node " + << N->getFuncPointer()->getName() << "\n"); } else if (viscUtils::isSingleTargetTag(N->getTag())) { // There is a single version for this node according to code gen hints. // Therefore, we do not need to check the policy, we simply use the @@ -1387,133 +1388,33 @@ void CGT_X86::codeGen(DFInternalNode* N) { assert(false && "Unreachable: we checked that tag was single target!\n"); break; } + + N->addGenFunc(N->getGenFuncForTarget(N->getTag()), + visc::CPU_TARGET, + true); + N->removeGenFuncForTarget(visc::GPU_TARGET); + N->setTag(visc::CPU_TARGET); + + // Sanity checks - to be removed TODO + CF = N->getGenFuncForTarget(visc::CPU_TARGET); + GF = N->getGenFuncForTarget(visc::GPU_TARGET); + + CFx86 = N->hasX86GenFuncForTarget(visc::CPU_TARGET); + GFx86 = N->hasX86GenFuncForTarget(visc::GPU_TARGET); + + DEBUG(errs() << "After editing\n"); + DEBUG(errs() << "Node: " << N->getFuncPointer()->getName() + << " with tag " << N->getTag() << "\n"); + DEBUG(errs() << "CPU Fun: " << (CF ? CF->getName() : "null" ) << "\n"); + DEBUG(errs() << "hasx86GenFuncForCPU : " << CFx86 << "\n"); + DEBUG(errs() << "GPU Fun: " << (GF ? GF->getName() : "null" ) << "\n"); + DEBUG(errs() << "hasx86GenFuncForGPU : " << GFx86 << "\n"); + + } + else { + assert(false && "Multiple tags unsupported!"); } - Function *Ftmp = N->getGenFuncForTarget(N->getTag()); - N->removeGenFuncForTarget(visc::GPU_TARGET); - N->setTag(visc::None); - N->addGenFunc(Ftmp, visc::CPU_TARGET, true); - N->setTag(visc::CPU_TARGET); - - // Sanity checks - to be removed TODO - CF = N->getGenFuncForTarget(visc::CPU_TARGET); - GF = N->getGenFuncForTarget(visc::GPU_TARGET); - - CFx86 = N->hasX86GenFuncForTarget(visc::CPU_TARGET); - GFx86 = N->hasX86GenFuncForTarget(visc::GPU_TARGET); - - errs() << "After editing\n"; - errs() << "Node: " << N->getFuncPointer()->getName() - << " with tag " << N->getTag() << "\n"; - errs() << "CPU Fun: " << (CF ? CF->getName() : "null" ) << "\n"; - errs() << "hasx86GenFuncForCPU : " << CFx86 << "\n"; - errs() << "GPU Fun: " << (GF ? GF->getName() : "null" ) << "\n"; - errs() << "hasx86GenFuncForGPU : " << GFx86 << "\n"; - - errs() << "Node Name (for policy) : " - << N->getFuncPointer()->getName() << "\n"; - - Function *CF = N->getGenFuncForTarget(visc::CPU_TARGET); - Function *GF = N->getGenFuncForTarget(visc::GPU_TARGET); - - bool CFx86 = N->hasX86GenFuncForTarget(visc::CPU_TARGET); - bool GFx86 = N->hasX86GenFuncForTarget(visc::GPU_TARGET); - - // These assertions express what we can support with the current runtime. - // Code generation works the same way even for other target combinations. - // For now, we want either CPU and GPU, or CPU and SPIR - assert((CF && (GF || !GF)) && "Invalid target selection\n"); - assert((CFx86 && (GFx86 || !GFx86)) && - "Generated functions without appropriate x86 wrapper\n"); - - FunctionType *FT = CF->getFunctionType(); - if (GF) - assert(FT == GF->getFunctionType() && - "Type mismatch between generated functions for GPU and CPU targets.\n"); - - // Code generation of wrapper function - Function *F_wrapper; - ValueToValueMapTy VMap; - F_wrapper = Function::Create(FT, CF->getLinkage(), CF->getName()+"_wrapper", &M); - - // Copy argument names over - Function::arg_iterator dest_iterator = F_wrapper->arg_begin(); - for (Function::arg_iterator i = CF->arg_begin(), e = CF->arg_end(); - i != e; ++i) { - dest_iterator->setName(i->getName()); - VMap[&*i] = &*dest_iterator; - ++dest_iterator; - } - // Gather all arguments of wrapper in a vector, to prepare the call to - // the individual gen functions - std::vector<Value *> GenFuncCallArgs; - for (Function::arg_iterator i = F_wrapper->arg_begin(), e = F_wrapper->arg_end(); - i != e; ++i) { - GenFuncCallArgs.push_back(&*i); - } - - BasicBlock *BBcurrent, *BBtrue, *BBfalse; - - BBcurrent = BasicBlock::Create(M.getContext(), "entry", F_wrapper); - - StringRef FName = N->getFuncPointer()->getName(); - size_t nameSize = FName.size()+1; - std::vector<Constant *> NameV; - for (char c: FName) { - NameV.push_back(ConstantInt::get(Type::getInt8Ty(M.getContext()), c)); - } - NameV.push_back(ConstantInt::get(Type::getInt8Ty(M.getContext()), '\0')); - ArrayType *NameType = - ArrayType::get(IntegerType::get(M.getContext(), 8), nameSize); - AllocaInst *AI = new AllocaInst(NameType, 0, nullptr, "", BBcurrent); - Constant *NameConst = ConstantArray::get(NameType, NameV); - StoreInst *StI = new StoreInst(NameConst, AI, BBcurrent); - CastInst *BI = BitCastInst::CreatePointerCast(AI, - Type::getInt8PtrTy(M.getContext()), "", BBcurrent); - - ConstantInt *CmpConst = - ConstantInt::get(Type::getInt32Ty(M.getContext()), 0, true); - CmpInst *CmpI = CmpInst::Create(Instruction::ICmp, - CmpInst::ICMP_EQ, - RTFInst, CmpConst, - "", BBcurrent); - - BBtrue = BasicBlock::Create(M.getContext(), "version_cpu", F_wrapper); - BBfalse = BasicBlock::Create(M.getContext(), "not_cpu", F_wrapper); - BranchInst *BrI = BranchInst::Create(BBtrue, BBfalse, CmpI, BBcurrent); - - CallInst *GenFuncCI = CallInst::Create(CF, GenFuncCallArgs, "", BBtrue); - ReturnInst *RI = ReturnInst::Create(M.getContext(), GenFuncCI, BBtrue); - - // Switch basic block pointers - BBcurrent = BBfalse; - if (GF) { - // We have a GPU version. Generate policy check and call - CmpConst = - ConstantInt::get(Type::getInt32Ty(M.getContext()), 1, true); - CmpI = CmpInst::Create(Instruction::ICmp, CmpInst::ICMP_EQ, - RTFInst, CmpConst, "", BBcurrent); - BBtrue = BasicBlock::Create(M.getContext(), "version_gpu", F_wrapper); - BBfalse = BasicBlock::Create(M.getContext(), "not_gpu", F_wrapper); - BrI = BranchInst::Create(BBtrue, BBfalse, CmpI, BBcurrent); - - GenFuncCI = CallInst::Create(GF, GenFuncCallArgs, "", BBtrue); - RI = ReturnInst::Create(M.getContext(), GenFuncCI, BBtrue); - - // Switch basic block pointers - BBcurrent = BBfalse; - RI = ReturnInst::Create(M.getContext(), - UndefValue::get(FT->getReturnType()), BBfalse); - - // Now, make the node cpu gen func to be this one - // Remove all other versions and update the tag - N->addGenFunc(F_wrapper, visc::CPU_TARGET, true); - N->removeGenFuncForTarget(visc::GPU_TARGET); - N->setTag(visc::CPU_TARGET); - - // assert(false && "got to the point where we have to combine\n"); - } - } // Code generation for leaf nodes @@ -1543,14 +1444,11 @@ void CGT_X86::codeGen(DFLeafNode* N) { errs() << "No CPU hint for node " << N->getFuncPointer()->getName() << " : skipping it\n"; - errs() << "Check for cudnn or promise hint for node " - << N->getFuncPointer()->getName() << "\n"; - switch (N->getTag()) { case visc::GPU_TARGET: // A leaf node should not have an x86 function for GPU // by design of DFG2LLVM_NVPTX backend - assert(!(N->hasX86GenFuncForTarget(visc::GPU_TARGET)) && ""); + assert(!(N->hasX86GenFuncForTarget(visc::GPU_TARGET)) && "Leaf node not expected to have GPU GenFunc"); break; default: break; @@ -1793,21 +1691,13 @@ void CGT_X86::codeGen(DFLeafNode* N) { } } else { - //TODO: how to handle address space qualifiers in load/store } } - //TODO: - // When to replace the uses? - // In which order is it safe to replace the instructions in - // IItoReplace? - // Probably in the reverse order in the vectors - // It is a good idea to have them in one vector and chech the type - // using dyn_cast in order to determine if we replace with inst or value - //TODO: maybe leave these instructions to be removed by a later DCE pass + // Remove them in reverse order for (std::vector<IntrinsicInst *>::iterator i = IItoRemove.begin(); i != IItoRemove.end(); ++i) { (*i)->replaceAllUsesWith(UndefValue::get((*i)->getType())); diff --git a/hpvm/projects/visc-rt/deviceStatusSwitchIntervals.txt b/hpvm/projects/visc-rt/deviceStatusSwitchIntervals.txt deleted file mode 100644 index 7069470a1a..0000000000 --- a/hpvm/projects/visc-rt/deviceStatusSwitchIntervals.txt +++ /dev/null @@ -1,2 +0,0 @@ -10 -10 15 10 16 15 30 15 25 20 15 diff --git a/hpvm/projects/visc-rt/device_abstraction.h b/hpvm/projects/visc-rt/device_abstraction.h deleted file mode 100644 index 7e77d100de..0000000000 --- a/hpvm/projects/visc-rt/device_abstraction.h +++ /dev/null @@ -1,80 +0,0 @@ -#ifndef __DEVICE_ABSTRACTION__ -#define __DEVICE_ABSTRACTION__ - -#include <fstream> -#include <iostream> -#include <stdio.h> -#include <stdlib.h> -#include <thread> -#include <time.h> -#include <vector> - -#define MIN_INTERVAL 2 -#define MAX_INTERVAL 8 -#define NUM_INTERVALS 10 - -// Device status variable: true if the device is available for use -volatile bool deviceStatus = true; -// Intervals at which to change the device status -std::vector<unsigned> Intervals; - -// Set to true when program execution ends and so we can end the device -// simulation -volatile bool executionEnd = false; - -void initializeDeviceStatusIntervals() { - - unsigned sz = 0; - unsigned tmp = 0; - - const char *fn = "/home/kotsifa2/HPVM/hpvm/build/projects/visc-rt/" - "deviceStatusSwitchIntervals.txt"; - std::ifstream infile; - infile.open(fn); - if (!infile.is_open()) { - std::cout << "Failed to open " << fn << " for reading\n"; - return; - } - infile >> sz; - - if (sz) { - // We have data. Read them into the vector - for (unsigned i = 0; i < sz; i++) { - infile >> tmp; - Intervals.push_back(tmp); - } - infile.close(); - } else { - // We have no data. Create random data and write them into the file - infile.close(); - std::ofstream outfile; - outfile.open(fn); - if (!outfile.is_open()) { - std::cout << "Failed to open " << fn << " for writing\n"; - return; - } - sz = 1 + rand() % NUM_INTERVALS; - outfile << sz; - for (unsigned i = 0; i < sz; i++) { - Intervals.push_back(MIN_INTERVAL + - rand() % (MAX_INTERVAL - MIN_INTERVAL)); - outfile << Intervals[i]; - } - outfile.close(); - } - - return; -} - -void updateDeviceStatus() { - - unsigned i = 0; - while (!executionEnd) { - std::this_thread::sleep_for(std::chrono::seconds(Intervals[i])); - deviceStatus = !deviceStatus; - std::cout << "Changed device status to " << deviceStatus << "\n"; - i = (i + 1) % Intervals.size(); - } -} - -#endif // __DEVICE_ABSTRACTION__ diff --git a/hpvm/projects/visc-rt/makefile b/hpvm/projects/visc-rt/makefile deleted file mode 100644 index adcc632335..0000000000 --- a/hpvm/projects/visc-rt/makefile +++ /dev/null @@ -1,29 +0,0 @@ -#LLVM_SRC_ROOT = -LLVM_BUILD_ROOT = ${LLVM_SRC_ROOT}/../build/ - -CUDA_INC_PATH = /software/cuda-9.1/include/CL/ - - -ifeq ($(NUM_CORES),) - NUM_CORES=1 -endif - -CPP_FLAGS = -I$(LLVM_SRC_ROOT)/include -I$(LLVM_BUILD_ROOT)/include -I$(CUDA_INC_PATH) -std=c++11 -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -TARGET:=visc-rt - -LLVM_CC:=$(LLVM_BUILD_ROOT)/bin/clang -LLVM_CXX:=$(LLVM_BUILD_ROOT)/bin/clang++ - -OPTS = - -ifeq ($(DEBUG),1) - OPTS+=-DDEBUG_BUILD -endif - -all: $(TARGET:%=%.ll) - -$(TARGET:%=%.ll):%.ll:%.cpp %.h - $(LLVM_CXX) -DNUM_CORES=$(NUM_CORES) -O3 -S -emit-llvm $(CPP_FLAGS) $(OPTS) $< -o $@ - -clean : - rm -f $(TARGET).ll diff --git a/hpvm/projects/visc-rt/policy.h b/hpvm/projects/visc-rt/policy.h deleted file mode 100644 index d50e65868b..0000000000 --- a/hpvm/projects/visc-rt/policy.h +++ /dev/null @@ -1,108 +0,0 @@ -#ifndef __POLICY__ -#define __POLICY__ - -#include "device_abstraction.h" -#include <string> - -/************************* Policies *************************************/ -class Policy { -public: - virtual int getVersion(const char *, int64_t) = 0; - virtual ~Policy(){}; -}; - -class ConstPolicy : public Policy { -public: - ConstPolicy(int deviceID) : deviceID(deviceID) {} - - int getVersion(const char *, int64_t) override { return deviceID; } - -private: - int deviceID; -}; - -class NodePolicy : public Policy { - virtual int getVersion(const char *name, int64_t it) override { - std::string s(name); - // std::string NodeNames[1] = { - // "_Z9mysgemmNTPfiS_iS_iiff_clonedInternal_level2_cloned" }; - std::string NodeNames[] = { - "WrapperGaussianSmoothing_cloned", - "WrapperlaplacianEstimate_cloned", - "WrapperComputeZeroCrossings_cloned", - "WrapperComputeGradient_cloned", - "WrapperComputeMaxGradient_cloned", - "WrapperRejectZeroCrossings_cloned", - }; - // if (!s.compare(NodeNames[4])) { - // std::cout << s << ": CPU" << "\n"; - // return 0; - //} - return 2; - } -}; - -class IterationPolicy : public Policy { - virtual int getVersion(const char *name, int64_t it) override { - if ((it % 10 == 0) || (it % 10 == 1)) - return 0; - else - return 2; - } -}; - -class DeviceStatusPolicy : public Policy { - virtual int getVersion(const char *name, int64_t it) override { - if (deviceStatus) { - // std::cout << "Returning GPU\n"; - return 2; - } else { - // std::cout << "Returning CPU\n"; - return 0; - } - } -}; - -/* ------------------------------------------------------------------------- */ -// Added for the CFAR interactive policy demo. - -class InteractivePolicy : public Policy { -private: - // 0 :for CPU, 1 for GPU, 2 for Vector - unsigned int userTargetDeviceChoice; - // Used to end thread execution - bool end; - // Thread that will update userTargetDeviceChoice - std::thread userTargetDeviceChoiceThread; - // Thread function - void updateUserTargetChoice() { - while (!end) { - std::cout << "Select target device (0 for CPU, 1 fpr GPU): "; - std::cin >> userTargetDeviceChoice; - if (userTargetDeviceChoice > 1) { - std::cout << "Invalid target device. Selecting GPU instead.\n"; - userTargetDeviceChoice = 1; - } - } - } - -public: - // Inherited method, erquired for every policy object - virtual int getVersion(const char *name, int64_t it) { - return userTargetDeviceChoice; - } - - InteractivePolicy() { - userTargetDeviceChoice = 1; - end = false; - userTargetDeviceChoiceThread = - std::thread(&InteractivePolicy::updateUserTargetChoice, this); - } - - ~InteractivePolicy() { - end = true; - userTargetDeviceChoiceThread.join(); - } -}; - -#endif // __POLICY__ diff --git a/hpvm/projects/visc-rt/visc-rt.cpp b/hpvm/projects/visc-rt/visc-rt.cpp index 53d3b516f2..df5b1b80f7 100644 --- a/hpvm/projects/visc-rt/visc-rt.cpp +++ b/hpvm/projects/visc-rt/visc-rt.cpp @@ -52,7 +52,6 @@ cl_context globalOCLContext; cl_device_id *clDevices; cl_command_queue globalCommandQue; -Policy *policy = NULL; MemTracker MTracker; vector<DFGDepth> DStack; // Mutex to prevent concurrent access by multiple thereads in pipeline @@ -69,55 +68,6 @@ static inline void checkErr(cl_int err, cl_int success, const char *name) { } } -/************************* Policies *************************************/ -void llvm_visc_policy_init() { - cout << "Initializing policy object ...\n"; - // policy = new NodePolicy(); - // policy = new IterationPolicy(); - // policy = new DeviceStatusPolicy(); - // policy = new InteractivePolicy(); - policy = new ConstPolicy(0); - cout << "DONE: Initializing policy object.\n"; -} - -void llvm_visc_policy_clear() { - if (policy) - free(policy); -} - -int llvm_visc_policy_getVersion(const char *name, int64_t i) { - return policy->getVersion(name, i); -} - -/******************** Device Abstraction ********************************/ -std::thread deviceStatusThread; - -void llvm_visc_deviceAbstraction_start() { - cout << "Starting device status simulation ...\n"; - // Initialize vector with points where ti switch device status - initializeDeviceStatusIntervals(); - // Create a thread that performs the changes - deviceStatusThread = std::thread(updateDeviceStatus); - cout << "Started device status simulation thread ...\n"; - return; -} - -void llvm_visc_deviceAbstraction_end() { - cout << "Ending device status simulation thread ...\n"; - // Set the variable that allows the thread to know that execution has ended - executionEnd = true; - // Wait for the thread that manages device status to terminate - deviceStatusThread.join(); - cout << "Ended device status simulation.\n"; - return; -} - -void llvm_visc_deviceAbstraction_waitOnDeviceStatus() { - while (!deviceStatus) { - }; - return; -} - /************************* Depth Stack Routines ***************************/ void llvm_visc_x86_dstack_push(unsigned n, uint64_t limitX, uint64_t iX, diff --git a/hpvm/projects/visc-rt/visc-rt.h b/hpvm/projects/visc-rt/visc-rt.h index 3ad315768b..d9d946f1da 100644 --- a/hpvm/projects/visc-rt/visc-rt.h +++ b/hpvm/projects/visc-rt/visc-rt.h @@ -15,8 +15,6 @@ #include "../../include/SupportVISC/VISCHint.h" #include "../../include/SupportVISC/VISCTimer.h" -#include "device_abstraction.h" -#include "policy.h" #ifndef DEBUG_BUILD #define DEBUG(s) \ @@ -29,17 +27,6 @@ using namespace std; extern "C" { -/************************* Policies *************************************/ - -void llvm_visc_policy_init(); -void llvm_visc_policy_clear(); -int llvm_visc_policy_getVersion(const char *, int64_t); - -/******************** Device Abstraction ********************************/ -void llvm_visc_deviceAbstraction_start(); -void llvm_visc_deviceAbstraction_end(); -void llvm_visc_deviceAbstraction_waitOnDeviceStatus(); - /********************* DFG Depth Stack **********************************/ class DFGDepth { private: diff --git a/hpvm/test/hpvm-cava/Makefile b/hpvm/test/hpvm-cava/Makefile index 24027cb1a9..0054af8c4d 100644 --- a/hpvm/test/hpvm-cava/Makefile +++ b/hpvm/test/hpvm-cava/Makefile @@ -52,7 +52,7 @@ OBJS_CFLAGS = -O1 $(APP_CFLAGS) $(PLATFORM_CFLAGS) CXXFLAGS = $(APP_CXXFLAGS) $(PLATFORM_CXXFLAGS) LDFLAGS= $(APP_LDFLAGS) $(PLATFORM_LDFLAGS) -VISC_RT_PATH = $(VISC_BUILD_DIR)/tools/hpvm/projects/visc-rt +VISC_RT_PATH = $(LLVM_BUILD_DIR)/tools/hpvm/projects/visc-rt VISC_RT_LIB = $(VISC_RT_PATH)/visc-rt.bc @@ -82,9 +82,7 @@ OBJS = $(call INBUILDDIR,$(SRCDIR_OBJS)) TEST_OBJS = $(call INBUILDDIR,$(VISC_OBJS)) KERNEL = $(TEST_OBJS).kernels.ll -ifeq ($(TARGET),seq) -else - KERNEL_LINKED = $(BUILD_DIR)/$(APP).kernels.linked.ll +ifeq ($(TARGET),gpu) KERNEL_OCL = $(TEST_OBJS).kernels.cl endif @@ -102,7 +100,7 @@ default: $(FAILSAFE) $(BUILD_DIR) $(KERNEL_OCL) $(EXE) #default: $(FAILSAFE) $(BUILD_DIR) $(KERNEL_OCL) $(SPIR_ASSEMBLY) $(AOC_CL) $(AOCL_ASSEMBLY) $(EXE) $(KERNEL_OCL) : $(KERNEL) - $(OCLBE) --debug $< -o $@ + $(OCLBE) $< -o $@ $(EXE) : $(HOST_LINKED) $(CXX) -O3 $(LDFLAGS) $< -o $@ @@ -111,7 +109,7 @@ $(HOST_LINKED) : $(HOST) $(OBJS) $(VISC_RT_LIB) $(LLVM_LINK) $^ -S -o $@ $(HOST) $(KERNEL): $(BUILD_DIR)/$(VISC_OBJS) - $(OPT) -debug $(VISC_OPTFLAGS) -S $< -o $(HOST) + $(OPT) $(VISC_OPTFLAGS) -S $< -o $(HOST) $(BUILD_DIR): mkdir -p $(BUILD_DIR) @@ -123,6 +121,6 @@ $(BUILD_DIR)/main.ll : $(SRC_DIR)/main.c $(CC) $(CFLAGS) -emit-llvm -S -o $@ $< $(BUILD_DIR)/main.visc.ll : $(BUILD_DIR)/main.ll - $(OPT) -debug-only=genvisc $(TESTGEN_OPTFLAGS) $< -S -o $@ + $(OPT) $(TESTGEN_OPTFLAGS) $< -S -o $@ ## END HPVM MAKEFILE diff --git a/hpvm/test/hpvm-cava/Makefile.config b/hpvm/test/hpvm-cava/Makefile.config index ffb2942911..1bdb62dec4 100644 --- a/hpvm/test/hpvm-cava/Makefile.config +++ b/hpvm/test/hpvm-cava/Makefile.config @@ -3,23 +3,21 @@ CUDA_LIB_PATH=$(CUDA_PATH)/lib64 OPENCL_PATH=/software/cuda-9.1 OPENCL_LIB_PATH=$(OPENCL_PATH)/lib64 -LLVM_SRC_ROOT=/home/aejjeh/work_dir/hpvm-release/hpvm/llvm/ -# NOTE: You may need to configure this based on your root path. -VISC_SRC_ROOT=$(LLVM_SRC_ROOT) +LLVM_SRC_ROOT=/home/aejjeh/work_dir/hpvm-reorg-9-temp/hpvm/llvm/ -VISC_BUILD_DIR =$(VISC_SRC_ROOT)/../build -CC = $(VISC_BUILD_DIR)/bin/clang -PLATFORM_CFLAGS = -I$(LLVM_SRC_ROOT)/include -I../include -I$(VISC_BUILD_DIR)/include -OCLBE = $(VISC_BUILD_DIR)/bin/llvm-cbe +LLVM_BUILD_DIR =$(LLVM_SRC_ROOT)/../build +CC = $(LLVM_BUILD_DIR)/bin/clang +PLATFORM_CFLAGS = -I$(LLVM_SRC_ROOT)/include -I$(OPENCL_PATH)/include/CL/ -I../include -I$(LLVM_BUILD_DIR)/include +OCLBE = $(LLVM_BUILD_DIR)/bin/llvm-cbe -CXX = $(VISC_BUILD_DIR)/bin/clang++ -PLATFORM_CXXFLAGS = -I$(LLVM_SRC_ROOT)/include -I../include -I$(VISC_BUILD_DIR)/include +CXX = $(LLVM_BUILD_DIR)/bin/clang++ +PLATFORM_CXXFLAGS = -I$(LLVM_SRC_ROOT)/include -I$(OPENCL_PATH)/include/CL/ -I../include -I$(LLVM_BUILD_DIR)/include -LINKER = $(VISC_BUILD_DIR)/bin/clang++ +LINKER = $(LLVM_BUILD_DIR)/bin/clang++ PLATFORM_LDFLAGS = -lm -lpthread -lrt -lOpenCL -L$(OPENCL_LIB_PATH) -LLVM_LIB_PATH = $(VISC_BUILD_DIR)/lib -LLVM_BIN_PATH = $(VISC_BUILD_DIR)/bin +LLVM_LIB_PATH = $(LLVM_BUILD_DIR)/lib +LLVM_BIN_PATH = $(LLVM_BUILD_DIR)/bin OPT = $(LLVM_BIN_PATH)/opt LLVM_LINK = $(LLVM_BIN_PATH)/llvm-link diff --git a/hpvm/test/hpvm-cava/Makefile.config.example b/hpvm/test/hpvm-cava/Makefile.config.example index 269f0b7df2..2627ca508f 100644 --- a/hpvm/test/hpvm-cava/Makefile.config.example +++ b/hpvm/test/hpvm-cava/Makefile.config.example @@ -1,23 +1,21 @@ -CUDA_PATH=/usr/local/cuda -CUDA_LIB_PATH=/usr/local/cuda/lib64 -OPENCL_PATH=/opt/intelFPGA_pro/18.0/hld/host/linux64 -OPENCL_LIB_PATH=$(OPENCL_PATH)/lib +CUDA_PATH=/software/cuda-9.1 +CUDA_LIB_PATH=$(CUDA_PATH)/lib64 +OPENCL_PATH=/software/cuda-9.1 +OPENCL_LIB_PATH=$(OPENCL_PATH)/lib64 -# NOTE: You may need to configure this based on your root path. -VISC_SRC_ROOT=$(LLVM_SRC_ROOT) +LLVM_BUILD_DIR =$(LLVM_SRC_ROOT)/../build +CC = $(LLVM_BUILD_DIR)/bin/clang +PLATFORM_CFLAGS = -I$(LLVM_SRC_ROOT)/include -I$(OPENCL_PATH)/include/CL/ -I../include -I$(LLVM_BUILD_DIR)/include +OCLBE = $(LLVM_BUILD_DIR)/bin/llvm-cbe -VISC_BUILD_DIR =$(VISC_SRC_ROOT)/build -CC = $(VISC_BUILD_DIR)/bin/clang -PLATFORM_CFLAGS = -I$(LLVM_SRC_ROOT)/include -I$(VISC_BUILD_DIR)/include +CXX = $(LLVM_BUILD_DIR)/bin/clang++ +PLATFORM_CXXFLAGS = -I$(LLVM_SRC_ROOT)/include -I$(OPENCL_PATH)/include/CL/ -I../include -I$(LLVM_BUILD_DIR)/include -CXX = $(VISC_BUILD_DIR)/bin/clang++ -PLATFORM_CXXFLAGS = -I$(LLVM_SRC_ROOT)/include -I$(VISC_BUILD_DIR)/include - -LINKER = $(VISC_BUILD_DIR)/bin/clang++ +LINKER = $(LLVM_BUILD_DIR)/bin/clang++ PLATFORM_LDFLAGS = -lm -lpthread -lrt -lOpenCL -L$(OPENCL_LIB_PATH) -LLVM_LIB_PATH = $(VISC_BUILD_DIR)/lib -LLVM_BIN_PATH = $(VISC_BUILD_DIR)/bin +LLVM_LIB_PATH = $(LLVM_BUILD_DIR)/lib +LLVM_BIN_PATH = $(LLVM_BUILD_DIR)/bin OPT = $(LLVM_BIN_PATH)/opt LLVM_LINK = $(LLVM_BIN_PATH)/llvm-link diff --git a/hpvm/test/parboil/common/mk/visc.mk b/hpvm/test/parboil/common/mk/visc.mk index 7ef5b017f0..0a8984deea 100755 --- a/hpvm/test/parboil/common/mk/visc.mk +++ b/hpvm/test/parboil/common/mk/visc.mk @@ -172,17 +172,9 @@ clean : if [ -d $(BUILDDIR) ]; then rm -rf $(BUILDDIR); fi if [ -d $(RUNDIR) ]; then rm -rf $(RUNDIR); fi -#$(APP_BINS) : $(KERNEL_OCL) $(BIN) - #echo Generating $(APP_BINS) ... - -#TODO: Fix this. Remove echo to actually compile kernel to ptx $(KERNEL_OCL) : $(KERNEL_OPT) $(OCLBE) $< -o $@ -$(SPIR_ASSEMBLY) : $(KERNEL_OPT) - python $(PYTHON_LLVM_40_34) $< $(BUILDDIR)/kernel_34.ll - $(LLVM_34_AS) $(BUILDDIR)/kernel_34.ll -o $@ - $(KERNEL_OPT) : $(KERNEL) $(OPT) $(APP_OPTFLAGS) -S $< -o $@ @@ -193,7 +185,7 @@ $(HOST_LINKED) : $(HOST) $(OBJS) $(BUILDDIR)/parboil.ll $(VISC_RT_LIB) $(LLVM_LINK) $^ -S -o $@ $(HOST) $(KERNEL): $(BUILDDIR)/$(VISC_OBJS) - $(OPT) --debug $(VISC_OPTFLAGS) -S $< -o $(HOST) + $(OPT) $(VISC_OPTFLAGS) -S $< -o $(HOST) $(RUNDIR) : mkdir -p $(RUNDIR) @@ -212,9 +204,6 @@ $(BUILDDIR)/%.ll : $(SRCDIR)/%.cpp $(BUILDDIR)/%.visc.ll: $(BUILDDIR)/%.ll $(OPT) $(TESTGEN_OPTFLAGS) $< -S -o $@ - cat $(LLVM_SRC_ROOT)/tools/hpvm/test/parboil/RUN.parboil.script $@ > $@.tmp - mv $@.tmp $(BUILDDIR)/$(APP).visc.ll - #@cp $(VISC_OBJS) $(BUILDDIR)/$(VISC_OBJS) $(BUILDDIR)/%.o : $(SRCDIR)/%.c $(CC) $(CFLAGS) -c $< -o $@ diff --git a/hpvm/test/pipeline/Makefile b/hpvm/test/pipeline/Makefile index 52ac5a9b7e..e3572ecdfc 100644 --- a/hpvm/test/pipeline/Makefile +++ b/hpvm/test/pipeline/Makefile @@ -39,8 +39,8 @@ OBJS_CFLAGS = $(APP_CFLAGS) $(PLATFORM_CFLAGS) CXXFLAGS = $(APP_CXXFLAGS) $(PLATFORM_CXXFLAGS) LDFLAGS= $(APP_LDFLAGS) $(PLATFORM_LDFLAGS) -VISC_RT_PATH = $(LLVM_SRC_ROOT)/tools/hpvm/projects/visc-rt -VISC_RT_LIB = $(VISC_RT_PATH)/visc-rt.ll +VISC_RT_PATH = $(LLVM_BUILD_DIR)/tools/hpvm/projects/visc-rt +VISC_RT_LIB = $(VISC_RT_PATH)/visc-rt.bc TESTGEN_OPTFLAGS = -load LLVMGenVISC.so -genvisc -globaldce @@ -94,9 +94,6 @@ $(EXE) : $(HOST_LINKED) $(HOST_LINKED) : $(HOST) $(OBJS) $(VISC_RT_LIB) $(LLVM_LINK) $^ -S -o $@ -$(VISC_RT_LIB) : $(VISC_RT_PATH)/visc-rt.cpp - make -C $(LLVM_LIB_PATH) - $(HOST) $(KERNEL): $(BUILD_DIR)/$(VISC_OBJS) $(OPT) -debug $(VISC_OPTFLAGS) -S $< -o $(HOST) diff --git a/hpvm/test/pipeline/Makefile.config b/hpvm/test/pipeline/Makefile.config index ffb2942911..1bdb62dec4 100644 --- a/hpvm/test/pipeline/Makefile.config +++ b/hpvm/test/pipeline/Makefile.config @@ -3,23 +3,21 @@ CUDA_LIB_PATH=$(CUDA_PATH)/lib64 OPENCL_PATH=/software/cuda-9.1 OPENCL_LIB_PATH=$(OPENCL_PATH)/lib64 -LLVM_SRC_ROOT=/home/aejjeh/work_dir/hpvm-release/hpvm/llvm/ -# NOTE: You may need to configure this based on your root path. -VISC_SRC_ROOT=$(LLVM_SRC_ROOT) +LLVM_SRC_ROOT=/home/aejjeh/work_dir/hpvm-reorg-9-temp/hpvm/llvm/ -VISC_BUILD_DIR =$(VISC_SRC_ROOT)/../build -CC = $(VISC_BUILD_DIR)/bin/clang -PLATFORM_CFLAGS = -I$(LLVM_SRC_ROOT)/include -I../include -I$(VISC_BUILD_DIR)/include -OCLBE = $(VISC_BUILD_DIR)/bin/llvm-cbe +LLVM_BUILD_DIR =$(LLVM_SRC_ROOT)/../build +CC = $(LLVM_BUILD_DIR)/bin/clang +PLATFORM_CFLAGS = -I$(LLVM_SRC_ROOT)/include -I$(OPENCL_PATH)/include/CL/ -I../include -I$(LLVM_BUILD_DIR)/include +OCLBE = $(LLVM_BUILD_DIR)/bin/llvm-cbe -CXX = $(VISC_BUILD_DIR)/bin/clang++ -PLATFORM_CXXFLAGS = -I$(LLVM_SRC_ROOT)/include -I../include -I$(VISC_BUILD_DIR)/include +CXX = $(LLVM_BUILD_DIR)/bin/clang++ +PLATFORM_CXXFLAGS = -I$(LLVM_SRC_ROOT)/include -I$(OPENCL_PATH)/include/CL/ -I../include -I$(LLVM_BUILD_DIR)/include -LINKER = $(VISC_BUILD_DIR)/bin/clang++ +LINKER = $(LLVM_BUILD_DIR)/bin/clang++ PLATFORM_LDFLAGS = -lm -lpthread -lrt -lOpenCL -L$(OPENCL_LIB_PATH) -LLVM_LIB_PATH = $(VISC_BUILD_DIR)/lib -LLVM_BIN_PATH = $(VISC_BUILD_DIR)/bin +LLVM_LIB_PATH = $(LLVM_BUILD_DIR)/lib +LLVM_BIN_PATH = $(LLVM_BUILD_DIR)/bin OPT = $(LLVM_BIN_PATH)/opt LLVM_LINK = $(LLVM_BIN_PATH)/llvm-link diff --git a/hpvm/test/pipeline/Makefile.config.example b/hpvm/test/pipeline/Makefile.config.example index 269f0b7df2..2627ca508f 100644 --- a/hpvm/test/pipeline/Makefile.config.example +++ b/hpvm/test/pipeline/Makefile.config.example @@ -1,23 +1,21 @@ -CUDA_PATH=/usr/local/cuda -CUDA_LIB_PATH=/usr/local/cuda/lib64 -OPENCL_PATH=/opt/intelFPGA_pro/18.0/hld/host/linux64 -OPENCL_LIB_PATH=$(OPENCL_PATH)/lib +CUDA_PATH=/software/cuda-9.1 +CUDA_LIB_PATH=$(CUDA_PATH)/lib64 +OPENCL_PATH=/software/cuda-9.1 +OPENCL_LIB_PATH=$(OPENCL_PATH)/lib64 -# NOTE: You may need to configure this based on your root path. -VISC_SRC_ROOT=$(LLVM_SRC_ROOT) +LLVM_BUILD_DIR =$(LLVM_SRC_ROOT)/../build +CC = $(LLVM_BUILD_DIR)/bin/clang +PLATFORM_CFLAGS = -I$(LLVM_SRC_ROOT)/include -I$(OPENCL_PATH)/include/CL/ -I../include -I$(LLVM_BUILD_DIR)/include +OCLBE = $(LLVM_BUILD_DIR)/bin/llvm-cbe -VISC_BUILD_DIR =$(VISC_SRC_ROOT)/build -CC = $(VISC_BUILD_DIR)/bin/clang -PLATFORM_CFLAGS = -I$(LLVM_SRC_ROOT)/include -I$(VISC_BUILD_DIR)/include +CXX = $(LLVM_BUILD_DIR)/bin/clang++ +PLATFORM_CXXFLAGS = -I$(LLVM_SRC_ROOT)/include -I$(OPENCL_PATH)/include/CL/ -I../include -I$(LLVM_BUILD_DIR)/include -CXX = $(VISC_BUILD_DIR)/bin/clang++ -PLATFORM_CXXFLAGS = -I$(LLVM_SRC_ROOT)/include -I$(VISC_BUILD_DIR)/include - -LINKER = $(VISC_BUILD_DIR)/bin/clang++ +LINKER = $(LLVM_BUILD_DIR)/bin/clang++ PLATFORM_LDFLAGS = -lm -lpthread -lrt -lOpenCL -L$(OPENCL_LIB_PATH) -LLVM_LIB_PATH = $(VISC_BUILD_DIR)/lib -LLVM_BIN_PATH = $(VISC_BUILD_DIR)/bin +LLVM_LIB_PATH = $(LLVM_BUILD_DIR)/lib +LLVM_BIN_PATH = $(LLVM_BUILD_DIR)/bin OPT = $(LLVM_BIN_PATH)/opt LLVM_LINK = $(LLVM_BIN_PATH)/llvm-link -- GitLab