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