This repository has been archived by the owner on Apr 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Kokkos::ScopeGuard
Jeff Miles edited this page May 1, 2020
·
1 revision
Header File: Kokkos_Core.hpp
Usage:
Kokkos::ScopeGuard(narg, arg);
Kokkos::ScopeGuard(args);
ScopeGuard
is a class which ensure that Kokkos::initialize
and
Kokkos::finalize
are called correctly even in the presence of unhandled
exceptions and multiple libraries trying to "own" Kokkos initialization.
ScopeGuard
calls Kokkos::initialize
in its constructor only if
Kokkos::is_initialized()
is false, and calls Kokkos::finalize
in its
destructor only if it called Kokkos::initialize
in its constructor.
Kokkos::ScopeGuard(int& narg, char* arg[]);
Kokkos::ScopeGuard(const InitArguments& args);
~ScopeGuard();
- narg: number of command line arguments
- arg: array of command line arguments, valid arguments are listed below.
- args: structure of valid Kokkos arguments
Note that all of the parameters above are passed to the Kokkos::initialize
called internally. See Kokkos::initialize for more details.
-
Kokkos::ScopeGuard
object should be constructed before user initiated Kokkos objects
- Calls
Kokkos::initialize
only ifKokkos::is_initialized()
is false. - Arguments are passed directly to
Kokkos::initialize
if it is called. - Kokkos::ScopeGuard::~ScopeGuard calls
Kokkos::finalize
only if the constructor of this object calledKokkos::initialize
.
int main(int argc, char** argv) {
Kokkos::ScopeGuard kokkos(argc, argv);
Kokkos::View<double*> my_view("my_view", 10);
// my_view destructor called before Kokkos::finalize
// ScopeGuard destructor called, calls Kokkos::finalize
}
Home:
- Introduction
- Machine Model
- Programming Model
- Compiling
- Initialization
- View
- Parallel Dispatch
- Hierarchical Parallelism
- Custom Reductions
- Atomic Operations
- Subviews
- Interoperability
- Kokkos and Virtual Functions
- Initialization and Finalization
- View
- Data Parallelism
- Execution Policies
- Spaces
- Task Parallelism
- Utilities
- STL Compatibility
- Numerics
- Detection Idiom