Skip to content

Commit 2e3e08d

Browse files
authored
Merge pull request #386 from E3SM-Project/jgfouca/wsm_link_fix
WorkspaceManager: Make constant a CPP define to make it easier to link
2 parents 7c82fc7 + 9b89187 commit 2e3e08d

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
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: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ class WorkspaceManager
7272
//
7373

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

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

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

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

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

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

128130
// call from host.
129131
//
@@ -377,9 +379,6 @@ class WorkspaceManager
377379
void operator() (const MemberType& team) const;
378380
}; // class WorkspaceManager
379381

380-
template <typename T, typename D>
381-
constexpr double WorkspaceManager<T, D>::GPU_DEFAULT_OVERPROVISION_FACTOR;
382-
383382
} // namespace ekat
384383

385384
#include "ekat_workspace_impl.hpp"

tests/kokkos/workspace_mgr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static void unittest_workspace_overprovision()
3939
TeamUtils<double,ExeSpace> tu_temp(temp_policy);
4040
const int num_conc = tu_temp.get_max_concurrent_threads() / temp_policy.team_size();
4141

42-
constexpr double op_fact = WSM::GPU_DEFAULT_OVERPROVISION_FACTOR;
42+
constexpr double op_fact = WSM::GPU_DEFAULT_OVERPROVISION_FACTOR();
4343
constexpr double explicit_op_fact = op_fact * 2.0;
4444

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

0 commit comments

Comments
 (0)