Tpetra parallel linear algebra Version of the Day
Loading...
Searching...
No Matches
Tpetra_Details_ExecutionSpaces.cpp
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
11
12#include <sstream>
13#include <vector>
14
15namespace Tpetra {
16namespace Details {
17namespace Spaces {
18
19#if defined(KOKKOS_ENABLE_CUDA)
20// cuda has default stream priority 0
21CudaInfo::CudaInfo() : initialized_(false), mediumPrio_(0) {}
22#endif
23
24void lazy_init() {
25#if defined(KOKKOS_ENABLE_CUDA)
26 if (!cudaInfo.initialized_) {
27 cudaInfo.initialized_ = true;
28 TPETRA_DETAILS_SPACES_CUDA_RUNTIME(cudaEventCreateWithFlags(
29 &cudaInfo.execSpaceWaitEvent_, cudaEventDisableTiming));
30 TPETRA_DETAILS_SPACES_CUDA_RUNTIME(cudaDeviceGetStreamPriorityRange(
31 &cudaInfo.lowPrio_, &cudaInfo.highPrio_));
32
33 // We expect
34 // medium priority should be 0
35 // lower numbers to be higher priorities
36 // low is at least as good as medium
37 // medium is at least as good as high
38 if (!(cudaInfo.lowPrio_ >= cudaInfo.mediumPrio_ &&
39 cudaInfo.mediumPrio_ >= cudaInfo.highPrio_)) {
40 std::stringstream ss;
41 ss << "CUDA stream priority does not follow assumptions."
42 << " low=" << cudaInfo.lowPrio_ << " medium=" << cudaInfo.mediumPrio_
43 << " high=" << cudaInfo.highPrio_
44 << " Please report this to the Tpetra developers.";
45 throw std::runtime_error(ss.str());
46 }
47 }
48#endif
49}
50
51/* -----------------------------
52 Space Management Singletons
53 -----------------------------*/
54
55#if defined(KOKKOS_ENABLE_CUDA)
56/*extern*/ InstanceLifetimeManager<Kokkos::Cuda> cudaSpaces;
57/*extern*/ CudaInfo cudaInfo;
58#endif
59#ifdef KOKKOS_ENABLE_SERIAL
60/*extern*/ InstanceLifetimeManager<Kokkos::Serial> serialSpaces;
61#endif
62#ifdef KOKKOS_ENABLE_OPENMP
63/*extern*/ InstanceLifetimeManager<Kokkos::OpenMP> openMPSpaces;
64#endif
65#ifdef KOKKOS_ENABLE_HIP
66/*extern*/ InstanceLifetimeManager<Kokkos::HIP> HIPSpaces;
67#endif
68#ifdef KOKKOS_ENABLE_SYCL
69/*extern*/ InstanceLifetimeManager<Kokkos::Experimental::SYCL> SYCLSpaces;
70#endif
71
72} // namespace Spaces
73} // namespace Details
74} // namespace Tpetra
Nonmember function that computes a residual Computes R = B - A * X.
Namespace Tpetra contains the class and methods constituting the Tpetra library.