aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/CL/CLTuner.cpp
diff options
context:
space:
mode:
authorAnthony Barbier <anthony.barbier@arm.com>2018-03-01 10:11:22 +0000
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:48:33 +0000
commit317fa7f2a770c179692c20e10ebb9fe2dcb6c624 (patch)
treefb39bbc1cc15ef7c831a911e9ae209739657ad8f /src/runtime/CL/CLTuner.cpp
parentdd6693743b4da1048d2a5571edc01936f82709c3 (diff)
downloadComputeLibrary-317fa7f2a770c179692c20e10ebb9fe2dcb6c624.tar.gz
COMPID-978: Throw exception on missing tuning file
Change-Id: I09ad6f52cc32f5dcd38d2ba7c6143e7e9ab12b61 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/122767 Tested-by: Jenkins <bsgcomp@arm.com> Reviewed-by: Matthew Bentham <matthew.bentham@arm.com> Reviewed-by: Michalis Spyrou <michalis.spyrou@arm.com>
Diffstat (limited to 'src/runtime/CL/CLTuner.cpp')
-rw-r--r--src/runtime/CL/CLTuner.cpp46
1 files changed, 24 insertions, 22 deletions
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 <cerrno>
#include <fstream>
#include <iostream>
#include <limits>
@@ -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