Tpetra parallel linear algebra Version of the Day
Loading...
Searching...
No Matches
Tpetra_Details_ExecutionSpacesSlot.hpp
1// @HEADER
2// *****************************************************************************
3// Tpetra: Templated Linear Algebra Services Package
4//
5// Copyright 2008 NTESS and the Tpetra contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef TPETRA_DETAILS_EXEUTIONSPACESSLOT_HPP
11#define TPETRA_DETAILS_EXEUTIONSPACESSLOT_HPP
12
13#include <iostream>
14#include <sstream>
15#include <vector>
16
17#include "Teuchos_RCP.hpp"
20#include <Kokkos_Core.hpp>
21
22namespace Tpetra {
23namespace Details {
24namespace Spaces {
25
31template <typename ExecSpace>
32class Slot {
33 public:
34 using execution_space = ExecSpace;
35
40 Slot() {
41 for (int i = 0; i < static_cast<int>(Spaces::Priority::NUM_LEVELS); ++i) {
42 // retrieve an RCP from the global instance manager
43 instances_[i] = Spaces::space_instance<execution_space>(
44 static_cast<Spaces::Priority>(i));
45 }
46 }
47
59 template <Spaces::Priority priority = Spaces::Priority::medium>
60 Teuchos::RCP<const execution_space> space_instance() const {
61 return instances_[static_cast<int>(priority)];
62 }
63
76 Teuchos::RCP<const execution_space>
78 switch (priority) {
79 case Spaces::Priority::high:
81 case Spaces::Priority::medium:
83 case Spaces::Priority::low:
85 default:
86 throw std::runtime_error("unexpected Tpetra Space priority");
87 }
88 }
89
90 private:
95 Teuchos::RCP<const execution_space>
96 instances_[static_cast<int>(Spaces::Priority::NUM_LEVELS)];
97}; // Slot
98
99} // namespace Spaces
100} // namespace Details
101} // namespace Tpetra
102
103#endif // TPETRA_DETAILS_EXEUTIONSPACESSLOT_HPP
Declaration of Tpetra::Details::Behavior, a class that describes Tpetra's behavior.
Priority
Priority interface for Tpetra's managed execution spaces.
Struct that holds views of the contents of a CrsMatrix.
Lazily acquires and stores Kokkos Execution Spaces.
Slot()
Default constructor that creates instances for each possible space priority level.
Teuchos::RCP< const execution_space > space_instance(const Spaces::Priority &priority) const
Get a specific execution space instance based on the given priority level.
Teuchos::RCP< const execution_space > space_instance() const
Get a specific execution space instance based on the given priority level.
Implementation details of Tpetra.
Namespace Tpetra contains the class and methods constituting the Tpetra library.