From 317fa7f2a770c179692c20e10ebb9fe2dcb6c624 Mon Sep 17 00:00:00 2001 From: Anthony Barbier Date: Thu, 1 Mar 2018 10:11:22 +0000 Subject: COMPID-978: Throw exception on missing tuning file Change-Id: I09ad6f52cc32f5dcd38d2ba7c6143e7e9ab12b61 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/122767 Tested-by: Jenkins Reviewed-by: Matthew Bentham Reviewed-by: Michalis Spyrou --- src/runtime/CL/CLTuner.cpp | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) (limited to 'src/runtime/CL/CLTuner.cpp') diff --git a/src/runtime/CL/CLTuner.cpp b/src/runtime/CL/CLTuner.cpp index 07c24a85c7..df8e255356 100644 --- a/src/runtime/CL/CLTuner.cpp +++ b/src/runtime/CL/CLTuner.cpp @@ -27,6 +27,7 @@ #include "arm_compute/core/Error.h" #include "arm_compute/runtime/CL/CLScheduler.h" +#include #include #include #include @@ -264,37 +265,38 @@ void CLTuner::load_from_file(const std::string &filename) std::ifstream fs; fs.exceptions(std::ifstream::badbit); fs.open(filename, std::ios::in); - if(fs.is_open()) + if(!fs.is_open()) { - std::string line; - while(!std::getline(fs, line).fail()) + ARM_COMPUTE_ERROR("Failed to open '%s' (%s [%d])", filename.c_str(), strerror(errno), errno); + } + std::string line; + while(!std::getline(fs, line).fail()) + { + std::istringstream ss(line); + std::string token; + if(std::getline(ss, token, ';').fail()) + { + ARM_COMPUTE_ERROR("Malformed row '%s' in %s (Should be of the form 'kernel_id;lws[0];lws[1];lws[2]')", ss.str().c_str(), filename.c_str()); + } + std::string kernel_id = token; + cl::NDRange lws(1, 1, 1); + for(int i = 0; i < 3; i++) { - std::istringstream ss(line); - std::string token; if(std::getline(ss, token, ';').fail()) { ARM_COMPUTE_ERROR("Malformed row '%s' in %s (Should be of the form 'kernel_id;lws[0];lws[1];lws[2]')", ss.str().c_str(), filename.c_str()); } - std::string kernel_id = token; - cl::NDRange lws(1, 1, 1); - for(int i = 0; i < 3; i++) - { - if(std::getline(ss, token, ';').fail()) - { - ARM_COMPUTE_ERROR("Malformed row '%s' in %s (Should be of the form 'kernel_id;lws[0];lws[1];lws[2]')", ss.str().c_str(), filename.c_str()); - } - lws.get()[i] = support::cpp11::stoi(token); - } + lws.get()[i] = support::cpp11::stoi(token); + } - // If all dimensions are 0: reset to NullRange (i.e nullptr) - if(lws[0] == 0 && lws[1] == 0 && lws[2] == 0) - { - lws = cl::NullRange; - } - add_lws_to_table(kernel_id, lws); + // If all dimensions are 0: reset to NullRange (i.e nullptr) + if(lws[0] == 0 && lws[1] == 0 && lws[2] == 0) + { + lws = cl::NullRange; } - fs.close(); + add_lws_to_table(kernel_id, lws); } + fs.close(); } void CLTuner::save_to_file(const std::string &filename) const -- cgit v1.2.1