From 7b607dc5058d2f6a398cfac4d2eab65d415c3733 Mon Sep 17 00:00:00 2001 From: Anthony Barbier Date: Fri, 13 Jul 2018 15:55:24 +0100 Subject: COMPMID-1400: Add command line option to specify the tuner's config file Change-Id: Ib597e0dff4c8c01f7e6bd46d03824beef4bc1e9a Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/139923 Tested-by: Jenkins Reviewed-by: Georgios Pinitas --- tests/main.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'tests/main.cpp') diff --git a/tests/main.cpp b/tests/main.cpp index 2da6804c60..aaae99157a 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -61,6 +61,17 @@ std::unique_ptr library; } // namespace test } // namespace arm_compute +namespace +{ +#ifdef ARM_COMPUTE_CL +bool file_exists(const std::string &filename) +{ + std::ifstream file(filename); + return file.good(); +} +#endif /* ARM_COMPUTE_CL */ +} //namespace + int main(int argc, char **argv) { #ifdef ARM_COMPUTE_CL @@ -106,6 +117,8 @@ int main(int argc, char **argv) #ifdef ARM_COMPUTE_CL auto enable_tuner = parser.add_option("enable-tuner"); enable_tuner->set_help("Enable OpenCL dynamic tuner"); + auto tuner_file = parser.add_option>("tuner-file", ""); + tuner_file->set_help("File to load/save CLTuner values"); #endif /* ARM_COMPUTE_CL */ auto threads = parser.add_option>("threads", 1); threads->set_help("Number of threads to use"); @@ -127,6 +140,16 @@ int main(int argc, char **argv) if(enable_tuner->is_set()) { cl_tuner.set_tune_new_kernels(enable_tuner->value()); + // If that's the first run then the file won't exist yet + if(file_exists(tuner_file->value())) + { + cl_tuner.load_from_file(tuner_file->value()); + } + } + else if(!tuner_file->value().empty()) + { + //If we're not tuning and the file doesn't exist then we should raise an error: + cl_tuner.load_from_file(tuner_file->value()); } #endif /* ARM_COMPUTE_CL */ if(options.log_level->value() > framework::LogLevel::NONE) @@ -216,6 +239,10 @@ int main(int argc, char **argv) #ifdef ARM_COMPUTE_CL CLScheduler::get().sync(); + if(enable_tuner->is_set() && enable_tuner->value() && tuner_file->is_set()) + { + cl_tuner.save_to_file(tuner_file->value()); + } #endif /* ARM_COMPUTE_CL */ return (success ? 0 : 1); -- cgit v1.2.1