diff --git a/hpvm/projects/hpvm-rt/deviceStatusSwitchIntervals.txt b/hpvm/projects/hpvm-rt/deviceStatusSwitchIntervals.txt deleted file mode 100644 index 7069470a1a6f8b1a49eea2824f27204ebdf3fb26..0000000000000000000000000000000000000000 --- a/hpvm/projects/hpvm-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/hpvm-rt/device_abstraction.h b/hpvm/projects/hpvm-rt/device_abstraction.h deleted file mode 100644 index 4948502ce8ae47cbb7e37c1372fcd81813486e15..0000000000000000000000000000000000000000 --- a/hpvm/projects/hpvm-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/hpvm-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/hpvm-rt/makefile b/hpvm/projects/hpvm-rt/makefile deleted file mode 100644 index 927e26e254a2b2f980fed8efd8858935e9f3cbdf..0000000000000000000000000000000000000000 --- a/hpvm/projects/hpvm-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:=hpvm-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/hpvm-rt/policy.h b/hpvm/projects/hpvm-rt/policy.h deleted file mode 100644 index 78aacfc94a87c4855e67997fbdadbf10621cbd30..0000000000000000000000000000000000000000 --- a/hpvm/projects/hpvm-rt/policy.h +++ /dev/null @@ -1,99 +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[] = { - "WrapperGaussianSmoothing_cloned", - "WrapperlaplacianEstimate_cloned", - "WrapperComputeZeroCrossings_cloned", - "WrapperComputeGradient_cloned", - "WrapperComputeMaxGradient_cloned", - "WrapperRejectZeroCrossings_cloned", - }; - 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) { - return 2; - } else { - return 0; - } - } -}; - -/* ------------------------------------------------------------------------- */ - -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__