Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/kokkos/ekat_team_policy_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ class TeamUtils<ValueType,EkatGpuSpace> : public TeamUtilsCommonBase<ValueType,E
_open_ws_slots("open_ws_slots", _need_ws_sharing ? _num_ws_slots : 0),
_rand_pool()
{
EKAT_REQUIRE_MSG(overprov_factor >= 1.0, "Makes no sense to have an overprov < 1");
if (_need_ws_sharing) {
_rand_pool = RandomGenerator(std::chrono::high_resolution_clock::now().time_since_epoch().count());
}
Expand Down
17 changes: 8 additions & 9 deletions src/kokkos/ekat_workspace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ class WorkspaceManager
//

// Default overprov factor for large GPU problems, testing has shown 1.25 is optimal
static constexpr double GPU_DEFAULT_OVERPROVISION_FACTOR = 1.25;
// Some linkers were having trouble with the code below, so use a function
//static inline constexpr double GPU_DEFAULT_OVERPROVISION_FACTOR = 1.25;
static constexpr double GPU_DEFAULT_OVERPROVISION_FACTOR() { return 1.25; }

//
// ------- public API ---------
Expand All @@ -87,7 +89,7 @@ class WorkspaceManager
// policy: The team policy for Kokkos kernels using this WorkspaceManager
// overprov_factor: How many workspace slots to overprovision (only applies to GPU for large problems)
WorkspaceManager(int size, int max_used, TeamPolicy policy,
const double& overprov_factor=GPU_DEFAULT_OVERPROVISION_FACTOR);
const double& overprov_factor=GPU_DEFAULT_OVERPROVISION_FACTOR());

// Constructor, call from host
// Same as above, but here the user initializes the data.
Expand All @@ -97,14 +99,14 @@ class WorkspaceManager
// data is available, for which the get_total_slots_to_be_used()
// function can be helpful.
WorkspaceManager(T* data, int size, int max_used, TeamPolicy policy,
const double& overprov_factor=GPU_DEFAULT_OVERPROVISION_FACTOR);
const double& overprov_factor=GPU_DEFAULT_OVERPROVISION_FACTOR());

// Helper functions which return the number of bytes that will be reserved for a given
// set of constructor inputs. Note, this does not actually create an instance of the WSM,
// but is useful for when memory needs to be reserved in a different scope than the
// WSM is created.
static int get_total_bytes_needed(int size, int max_used, TeamPolicy policy,
const double& overprov_factor=GPU_DEFAULT_OVERPROVISION_FACTOR);
const double& overprov_factor=GPU_DEFAULT_OVERPROVISION_FACTOR());

// call from host.
//
Expand All @@ -116,14 +118,14 @@ class WorkspaceManager
//
// Setup routine for the WSM if the user used the empty constructor
void setup(int size, int max_used, TeamPolicy policy,
const double& overprov_factor=GPU_DEFAULT_OVERPROVISION_FACTOR);
const double& overprov_factor=GPU_DEFAULT_OVERPROVISION_FACTOR());

// call from host.
//
// Setup routine for the WSM if the user used the empty constructor.
// Same as above, but here the user initializes the data.
void setup(T* data, int size, int max_used, TeamPolicy policy,
const double& overprov_factor=GPU_DEFAULT_OVERPROVISION_FACTOR);
const double& overprov_factor=GPU_DEFAULT_OVERPROVISION_FACTOR());

// call from host.
//
Expand Down Expand Up @@ -377,9 +379,6 @@ class WorkspaceManager
void operator() (const MemberType& team) const;
}; // class WorkspaceManager

template <typename T, typename D>
constexpr double WorkspaceManager<T, D>::GPU_DEFAULT_OVERPROVISION_FACTOR;

} // namespace ekat

#include "ekat_workspace_impl.hpp"
Expand Down
2 changes: 1 addition & 1 deletion tests/kokkos/workspace_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static void unittest_workspace_overprovision()
TeamUtils<double,ExeSpace> tu_temp(temp_policy);
const int num_conc = tu_temp.get_max_concurrent_threads() / temp_policy.team_size();

constexpr double op_fact = WSM::GPU_DEFAULT_OVERPROVISION_FACTOR;
constexpr double op_fact = WSM::GPU_DEFAULT_OVERPROVISION_FACTOR();
constexpr double explicit_op_fact = op_fact * 2.0;

const int ni_under = (num_conc / 2) + 1;
Expand Down