From 23690e690630741d6a53fe01ba6c8d68faec60f0 Mon Sep 17 00:00:00 2001 From: Maria Kotsifakou <kotsifa2@illinois.edu> Date: Wed, 15 Apr 2020 18:03:54 -0500 Subject: [PATCH] Using new knob reading in hpvm controller and approxhpvm_runtime_utils --- .../include/approxhpvm_runtime_utils.h | 73 ++----------------- .../tensor_runtime/src/hpvm-rt-controller.cpp | 7 ++ 2 files changed, 13 insertions(+), 67 deletions(-) diff --git a/llvm/projects/hpvm-tensor-rt/tensor_runtime/include/approxhpvm_runtime_utils.h b/llvm/projects/hpvm-tensor-rt/tensor_runtime/include/approxhpvm_runtime_utils.h index 6577d3a9ae..1fc475ec05 100644 --- a/llvm/projects/hpvm-tensor-rt/tensor_runtime/include/approxhpvm_runtime_utils.h +++ b/llvm/projects/hpvm-tensor-rt/tensor_runtime/include/approxhpvm_runtime_utils.h @@ -8,6 +8,7 @@ #include "configuration.h" #include "hpvm-rt-controller.h" +#include "approx_knob_utils.h" // Utilities header for ApproxHPVM runtime API (wrapper runtime API) @@ -155,52 +156,15 @@ void* handleTensorConvApproximationTuples( } case GPUNodeConfiguration::APPROX::PERFORATION : { - int row = 0, col = 0, offset = 0; - switch (param) { - case 21: - row = 1; col = 2; offset = 0; - break; - case 22: - row = 1; col = 2; offset = 1; - break; - case 23: - row = 1; col = 3; offset = 0; - break; - case 24: - row = 1; col = 3; offset = 1; - break; - case 25: - row = 1; col = 3; offset = 2; - break; - case 26: - row = 2; col = 1; offset = 0; - break; - case 27: - row = 2; col = 1; offset = 1; - break; - case 28: - row = 3; col = 1; offset = 0; - break; - case 29: - row = 3; col = 1; offset = 1; - break; - case 30: - row = 3; col = 1; offset = 2; - break; - default: - DEBUG("Unsupported Option: Select default, 1-2-0.\n"); - row = 1; col = 2; offset = 0; - break; - } + PerfParams params = perfParamSet->getPerfParams(param); void* t_out; RC->resume_profiler(); t_out = tensorConvApproxHalf2(input, filter, conv_pad_h, conv_pad_w, conv_stride_h, conv_stride_w, 1, 1, - row, col, 1, offset); + params.row, params.col, 1, params.skip_offset); - RC->pause_profiler(); std::pair<double, double> pinfo = RC->get_time_energy(); RC->reset_profiler(); @@ -210,45 +174,20 @@ void* handleTensorConvApproximationTuples( } case GPUNodeConfiguration::APPROX::INPUT_SAMPLING : { - int skip_rate = 2, offset = 0; - switch (param) { - case 31: - skip_rate = 2; offset = 0; - break; - case 32: - skip_rate = 2; offset = 1; - break; - case 33: - skip_rate = 4; offset = 0; - break; - case 34: - skip_rate = 4; offset = 1; - break; - case 35: - skip_rate = 4; offset = 2; - break; - case 36: - skip_rate = 4; offset = 3; - break; - default: - DEBUG("Unsupported Option: Select default, 2-0.\n"); - skip_rate = 2; offset = 0; - break; - } + SampParams params = sampParamSet->getSampParams(param); void* t_out; RC->resume_profiler(); t_out = tensorConvApproxHalf2(input, filter, conv_pad_h, conv_pad_w, conv_stride_h, conv_stride_w, 1, 1, - 1, 1, skip_rate, skip_rate - 1/*offset*/); //FIXME + 1, 1, + params.skip_rate, params.skip_offset); RC->pause_profiler(); std::pair<double, double> pinfo = RC->get_time_energy(); RC->reset_profiler(); RC->addToCurrentIterationComputeTime("tensorConvApproxHalf(_samp)", pinfo.first); RC->addToCurrentIterationComputeEnergy("tensorConvApproxHalf(_samp)", pinfo.second); - - return t_out; } default : diff --git a/llvm/projects/hpvm-tensor-rt/tensor_runtime/src/hpvm-rt-controller.cpp b/llvm/projects/hpvm-tensor-rt/tensor_runtime/src/hpvm-rt-controller.cpp index fb116d5164..a754138a84 100644 --- a/llvm/projects/hpvm-tensor-rt/tensor_runtime/src/hpvm-rt-controller.cpp +++ b/llvm/projects/hpvm-tensor-rt/tensor_runtime/src/hpvm-rt-controller.cpp @@ -1,5 +1,6 @@ #include "hpvm-rt-controller.h" #include "img_tensor_utils.h" +#include "global_data.h" /* * Check if a file exists @@ -180,6 +181,7 @@ ProfileInfo::ProfileInfo() energy_compute_current_iteration(0.0), energy_control_current_iteration(0.0), energy_config_current_iteration(0.0), in_iteration(false) {} + Slowdowns::Slowdowns() { idx = 0; @@ -190,6 +192,7 @@ Slowdowns::Slowdowns() { slowdowns.push_back(1.0 + (rand() / (RAND_MAX / (5.0 - 1.0)))); } } else { + DEBUG("Found slowdowns file.\n"); for (std::string line; std::getline(s_in, line);) { float s = std::stof(line); slowdowns.push_back(s); @@ -273,6 +276,10 @@ void RuntimeController::init(const char *Cstr, const char *Qstr) { slowdowns = new Slowdowns(); pseudo_rd = 0.0; + // Initialize utility objects for knob reading + perfParamSet = new PerfParamSet(); + sampParamSet = new SampParamSet(); + // Start profiling thread in the background, ready to time start_profiler(); pause_profiler(); -- GitLab