aboutsummaryrefslogtreecommitdiff
path: root/tests/main.cpp
diff options
context:
space:
mode:
authorAnthony Barbier <anthony.barbier@arm.com>2018-07-13 15:55:24 +0100
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:54:54 +0000
commit7b607dc5058d2f6a398cfac4d2eab65d415c3733 (patch)
tree8597679faf0fb1b389b7ffa7f3d424d527863a1c /tests/main.cpp
parent11a7e32230121e457252084f8b93357814fe57e5 (diff)
downloadComputeLibrary-7b607dc5058d2f6a398cfac4d2eab65d415c3733.tar.gz
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 <bsgcomp@arm.com> Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Diffstat (limited to 'tests/main.cpp')
-rw-r--r--tests/main.cpp27
1 files changed, 27 insertions, 0 deletions
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<AssetsLibrary> 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<utils::ToggleOption>("enable-tuner");
enable_tuner->set_help("Enable OpenCL dynamic tuner");
+ auto tuner_file = parser.add_option<utils::SimpleOption<std::string>>("tuner-file", "");
+ tuner_file->set_help("File to load/save CLTuner values");
#endif /* ARM_COMPUTE_CL */
auto threads = parser.add_option<utils::SimpleOption<int>>("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);