Skip to content

Commit

Permalink
Modifying search criteria for kokkos autotuning to be in seconds, not…
Browse files Browse the repository at this point in the history
… nanoseconds. This helps the math in the nelder mead search strategy, and doesn't hurt any other searches.
  • Loading branch information
khuck committed Sep 27, 2024
1 parent 4bc88dc commit 89e8962
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/apex/apex_kokkos_tuning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down Expand Up @@ -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)));
Expand Down
6 changes: 1 addition & 5 deletions src/apex/nelder_mead.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void NelderMead::start(void) {
init_simplex.push_back(tmp2);
}
searcher = new apex::internal::nelder_mead::Searcher<double>(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 {
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/apex/nelder_mead_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <sstream>
#include <stdexcept>
#include <vector>
#include "apex_options.hpp"

namespace apex {
namespace internal {
Expand Down Expand Up @@ -211,7 +212,7 @@ template <typename T = double> 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) {
Expand Down

0 comments on commit 89e8962

Please sign in to comment.