From 89e896214c3074dc71a65028b5038903b4575420 Mon Sep 17 00:00:00 2001 From: Kevin Huck Date: Fri, 27 Sep 2024 09:25:05 -0700 Subject: [PATCH] Modifying search criteria for kokkos autotuning to be in seconds, not nanoseconds. This helps the math in the nelder mead search strategy, and doesn't hurt any other searches. --- src/apex/apex_kokkos_tuning.cpp | 5 +++-- src/apex/nelder_mead.cpp | 6 +----- src/apex/nelder_mead_internal.h | 3 ++- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/apex/apex_kokkos_tuning.cpp b/src/apex/apex_kokkos_tuning.cpp index 66014ba2..5b034dfa 100644 --- a/src/apex/apex_kokkos_tuning.cpp +++ b/src/apex/apex_kokkos_tuning.cpp @@ -990,9 +990,10 @@ bool handle_start(const std::string & name, const size_t vars, } double result = profile->minimum; if (result == 0.0) result = profile->accumulated/profile->calls; + result = result * 1.0e-9; // convert to seconds to help search math if(verbose) { std::cout << std::string(getDepth(), ' '); - std::cout << "querying time per call: " << (double)(result)/1000000000.0 << "s" << std::endl; + std::cout << "querying time per call: " << result << "s" << std::endl; } return result; }; @@ -1314,7 +1315,7 @@ void kokkosp_end_context(const size_t contextId) { start != session.context_starts.end()) { if (session.verbose) { std::cout << std::string(getDepth(), ' '); - std::cout << name->second << "\t" << (end-(start->second)) << std::endl; + std::cout << name->second << "\t" << (end-(start->second)) << " sec." << std::endl; } if (session.used_history.count(contextId) == 0) { apex::sample_value(name->second, (double)(end-(start->second))); diff --git a/src/apex/nelder_mead.cpp b/src/apex/nelder_mead.cpp index cc1a7222..8f3a3c70 100644 --- a/src/apex/nelder_mead.cpp +++ b/src/apex/nelder_mead.cpp @@ -56,7 +56,7 @@ void NelderMead::start(void) { init_simplex.push_back(tmp2); } searcher = new apex::internal::nelder_mead::Searcher(init_point, init_simplex, lower_limit, upper_limit, false); - searcher->function_tolerance(10000); + searcher->function_tolerance(1.0e-4); if (hasDiscrete) { searcher->point_tolerance(1.0); } else { @@ -110,10 +110,6 @@ void NelderMead::evaluate(double new_cost) { std::cout << std::endl; } cost = new_cost; - // if the function evaluation takes a long time (in nanoseconds, remember), increase our tolerance. - auto tmp = std::max((new_cost / 50.0), 1000.0); - //std::cout << "new function tolerance: " << tmp << std::endl; - searcher->function_tolerance(tmp); } k++; return; diff --git a/src/apex/nelder_mead_internal.h b/src/apex/nelder_mead_internal.h index b34115a7..0c658959 100644 --- a/src/apex/nelder_mead_internal.h +++ b/src/apex/nelder_mead_internal.h @@ -5,6 +5,7 @@ #include #include #include +#include "apex_options.hpp" namespace apex { namespace internal { @@ -211,7 +212,7 @@ template class Searcher { : adaptive(_adaptive), tol_fun(1e-8), tol_x(1e-8), max_iter(1000), max_fun_evals(2000), current_simplex_index(0), minimum_limits(_minimum_limits), maximum_limits(_maximum_limits), - _converged(false), verbose(false) { + _converged(false), verbose(apex_options::use_verbose()) { initialize(initial_point, initial_simplex); } void function_tolerance(T tol) {