GPRidge v1.0.0
GPR-accelerated saddle point searches on potential energy surfaces
☾
Toggle main menu visibility
Loading...
Searching...
No Matches
LocalExecutor.cpp
Go to the documentation of this file.
1
// SPDX-License-Identifier: MIT
2
// Copyright (c) gpridge developers
3
4
#include "
LocalExecutor.h
"
5
6
#include <algorithm>
7
#include <atomic>
8
#include <stdexcept>
9
10
#include "
LinalgThreads.h
"
11
12
namespace
gpr::linalg
{
13
namespace
{
14
std::atomic<int> requested_kernel_threads{1};
15
std::atomic<int> default_concurrency{1};
16
}
// namespace
17
18
void
configureKernelThreads
(
int
threads)
19
{
20
const
LocalExecutor
validated(threads);
21
requested_kernel_threads.store(validated.
concurrency
(),
22
std::memory_order_relaxed);
23
refreshKernelTeam
();
24
}
25
26
void
refreshKernelTeam
()
27
{
28
// The linalg count is the assembly team; --kernel-threads can widen it
29
// but its default of one must not shrink it.
30
int
team = requested_kernel_threads.load(std::memory_order_relaxed);
31
if
(
LocalExecutor::parallelAvailable
())
32
team = std::max(team,
configuredLinalgThreads
());
33
default_concurrency.store(team, std::memory_order_relaxed);
34
}
35
36
LocalExecutor::LocalExecutor
()
37
:
LocalExecutor
(default_concurrency.load(
std
::memory_order_relaxed))
38
{
39
}
40
41
LocalExecutor::LocalExecutor
(
int
concurrency
) : concurrency_(
concurrency
)
42
{
43
if
(
concurrency
< 1 || (
concurrency
> 1 && !
parallelAvailable
()))
44
throw
std::invalid_argument(
45
"kernel threads require a positive count and parallel STL support"
);
46
}
47
48
bool
LocalExecutor::parallelAvailable
() noexcept
49
{
50
#if defined(GPR_USE_STDPAR) || defined(USE_OPENMP)
51
return
true
;
52
#else
53
return
false
;
54
#endif
55
}
56
57
}
// namespace gpr::linalg
LinalgThreads.h
LocalExecutor.h
gpr::linalg::LocalExecutor
Definition
LocalExecutor.h:42
gpr::linalg::LocalExecutor::concurrency
int concurrency() const noexcept
Definition
LocalExecutor.h:46
gpr::linalg::LocalExecutor::LocalExecutor
LocalExecutor()
Definition
LocalExecutor.cpp:36
gpr::linalg::LocalExecutor::parallelAvailable
static bool parallelAvailable() noexcept
Definition
LocalExecutor.cpp:48
gpr::linalg
Dense and structured linear algebra behind the GP: Cholesky and eigen solvers, linear operators,...
Definition
ConditionedKernel.h:14
gpr::linalg::refreshKernelTeam
void refreshKernelTeam()
Definition
LocalExecutor.cpp:26
gpr::linalg::configureKernelThreads
void configureKernelThreads(int threads)
Definition
LocalExecutor.cpp:18
gpr::linalg::configuredLinalgThreads
int configuredLinalgThreads() noexcept
Requested dense numerical budget, independent of nested BLAS controls.
Definition
LinalgThreads.cpp:119
std
STL namespace.
gpr
linalg
LocalExecutor.cpp
Generated by
1.17.0
Generated by
Doxygen 1.17.0
Analytics by
Antics
provided by
TurtleTech ehf