Skip to content

Commit 55dd596

Browse files
committed
Adjust overprov impl. Add value check
1 parent 3a261dc commit 55dd596

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/kokkos/ekat_team_policy_utils.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ class TeamUtils<ValueType,EkatGpuSpace> : public TeamUtilsCommonBase<ValueType,E
258258
_open_ws_slots("open_ws_slots", _need_ws_sharing ? _num_ws_slots : 0),
259259
_rand_pool()
260260
{
261+
EKAT_REQUIRE_MSG(overprov_factor >= 1.0, "Makes no sense to have an overprov < 1");
261262
if (_need_ws_sharing) {
262263
_rand_pool = RandomGenerator(std::chrono::high_resolution_clock::now().time_since_epoch().count());
263264
}

src/kokkos/ekat_workspace.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ class WorkspaceManager
7272
//
7373

7474
// Default overprov factor for large GPU problems, testing has shown 1.25 is optimal
75-
// Some linkers were having trouble with the code below, so just define it
75+
// Some linkers were having trouble with the code below, so use a function
7676
//static inline constexpr double GPU_DEFAULT_OVERPROVISION_FACTOR = 1.25;
77-
#define WSM_GPU_DEFAULT_OVERPROVISION_FACTOR 1.25
77+
static constexpr double GPU_DEFAULT_OVERPROVISION_FACTOR() { return 1.25; }
7878

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

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

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

111111
// call from host.
112112
//
@@ -118,14 +118,14 @@ class WorkspaceManager
118118
//
119119
// Setup routine for the WSM if the user used the empty constructor
120120
void setup(int size, int max_used, TeamPolicy policy,
121-
const double& overprov_factor=WSM_GPU_DEFAULT_OVERPROVISION_FACTOR);
121+
const double& overprov_factor=GPU_DEFAULT_OVERPROVISION_FACTOR());
122122

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

130130
// call from host.
131131
//

0 commit comments

Comments
 (0)