Amesos2 - Direct Sparse Solver Interfaces  Version of the Day
Amesos2_Kokkos_Impl.hpp
Go to the documentation of this file.
1 // @HEADER
2 //
3 // ***********************************************************************
4 //
5 // Amesos2: Templated Direct Sparse Solver Package
6 // Copyright 2011 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
39 //
40 // ***********************************************************************
41 //
42 // @HEADER
43 
52 #ifndef AMESOS2_KOKKOS_IMPL_HPP
53 #define AMESOS2_KOKKOS_IMPL_HPP
54 
55 #include <type_traits>
57 #include <KokkosSparse_CrsMatrix.hpp>
58 
59 #define AMESOS2_KOKKOS_LOCAL_INSTANT_KOKKOS_ADAPTER(S,LO,EXEC_SPACE) \
60  template class Amesos2::AMESOS2_KOKKOS_IMPL_SOLVER_NAME<KokkosSparse::CrsMatrix<S, LO, \
61  typename EXEC_SPACE::device_type>, \
62  Kokkos::View<S**, Kokkos::LayoutLeft, typename EXEC_SPACE::device_type> >;
63 
64 #define AMESOS2_KOKKOS_LOCAL_INSTANT_KOKKOS_ADAPTER_UVM_OFF(S,LO) \
65  template class Amesos2::AMESOS2_KOKKOS_IMPL_SOLVER_NAME<KokkosSparse::CrsMatrix<S, LO, \
66  Kokkos::Device<Kokkos::Cuda,Kokkos::CudaSpace>>, \
67  Kokkos::View<S**, Kokkos::LayoutLeft, Kokkos::Device<Kokkos::Cuda,Kokkos::CudaSpace>> >;
68 
69 
70 #if defined(KOKKOS_ENABLE_SERIAL)
71 #ifdef HAVE_TPETRA_INST_FLOAT
72  AMESOS2_KOKKOS_LOCAL_INSTANT_KOKKOS_ADAPTER(float, int, Kokkos::Serial)
73 #endif
74 #ifdef HAVE_TPETRA_INST_DOUBLE
75  AMESOS2_KOKKOS_LOCAL_INSTANT_KOKKOS_ADAPTER(double, int, Kokkos::Serial)
76 #endif
77 #ifdef HAVE_TPETRA_INST_COMPLEX_FLOAT
78  AMESOS2_KOKKOS_LOCAL_INSTANT_KOKKOS_ADAPTER(Kokkos::complex<float>, int, Kokkos::Serial)
79 #endif
80 #ifdef HAVE_TPETRA_INST_COMPLEX_DOUBLE
81  AMESOS2_KOKKOS_LOCAL_INSTANT_KOKKOS_ADAPTER(Kokkos::complex<double>, int, Kokkos::Serial)
82 #endif
83 #endif
84 
85 #if defined(KOKKOS_ENABLE_THREADS)
86 #define EXEC_SPACE Kokkos::Threads
87 #ifdef HAVE_TPETRA_INST_FLOAT
88  AMESOS2_KOKKOS_LOCAL_INSTANT_KOKKOS_ADAPTER(float, int, Kokkos::Threads)
89 #endif
90 #ifdef HAVE_TPETRA_INST_DOUBLE
91  AMESOS2_KOKKOS_LOCAL_INSTANT_KOKKOS_ADAPTER(double, int, Kokkos::Threads)
92 #endif
93 #ifdef HAVE_TPETRA_INST_COMPLEX_FLOAT
94  AMESOS2_KOKKOS_LOCAL_INSTANT_KOKKOS_ADAPTER(Kokkos::complex<float>, int, Kokkos::Threads)
95 #endif
96 #ifdef HAVE_TPETRA_INST_COMPLEX_DOUBLE
97  AMESOS2_KOKKOS_LOCAL_INSTANT_KOKKOS_ADAPTER(Kokkos::complex<double>, int, Kokkos::Threads)
98 #endif
99 #endif // KOKKOS_ENABLE_THREADS
100 
101 #if defined(KOKKOS_ENABLE_OPENMP)
102 #ifdef HAVE_TPETRA_INST_FLOAT
103  AMESOS2_KOKKOS_LOCAL_INSTANT_KOKKOS_ADAPTER(float, int, Kokkos::OpenMP)
104 #endif
105 #ifdef HAVE_TPETRA_INST_DOUBLE
106  AMESOS2_KOKKOS_LOCAL_INSTANT_KOKKOS_ADAPTER(double, int, Kokkos::OpenMP)
107 #endif
108 #ifdef HAVE_TPETRA_INST_COMPLEX_FLOAT
109  AMESOS2_KOKKOS_LOCAL_INSTANT_KOKKOS_ADAPTER(Kokkos::complex<float>, int, Kokkos::OpenMP)
110 #endif
111 #ifdef HAVE_TPETRA_INST_COMPLEX_DOUBLE
112  AMESOS2_KOKKOS_LOCAL_INSTANT_KOKKOS_ADAPTER(Kokkos::complex<double>, int, Kokkos::OpenMP)
113 #endif
114 #endif // KOKKOS_ENABLE_OPENMP
115 
116 #if defined(KOKKOS_ENABLE_CUDA)
117 #ifdef HAVE_TPETRA_INST_FLOAT
118  AMESOS2_KOKKOS_LOCAL_INSTANT_KOKKOS_ADAPTER(float, int, Kokkos::Cuda)
119  AMESOS2_KOKKOS_LOCAL_INSTANT_KOKKOS_ADAPTER_UVM_OFF(float, int)
120 #endif
121 #ifdef HAVE_TPETRA_INST_DOUBLE
122  AMESOS2_KOKKOS_LOCAL_INSTANT_KOKKOS_ADAPTER(double, int, Kokkos::Cuda)
123  AMESOS2_KOKKOS_LOCAL_INSTANT_KOKKOS_ADAPTER_UVM_OFF(double, int)
124 #endif
125 #ifdef HAVE_TPETRA_INST_COMPLEX_FLOAT
126  AMESOS2_KOKKOS_LOCAL_INSTANT_KOKKOS_ADAPTER(Kokkos::complex<float>, int, Kokkos::Cuda)
127  AMESOS2_KOKKOS_LOCAL_INSTANT_KOKKOS_ADAPTER_UVM_OFF(Kokkos::complex<float>, int)
128 #endif
129 #ifdef HAVE_TPETRA_INST_COMPLEX_DOUBLE
130  AMESOS2_KOKKOS_LOCAL_INSTANT_KOKKOS_ADAPTER(Kokkos::complex<double>, int, Kokkos::Cuda)
131  AMESOS2_KOKKOS_LOCAL_INSTANT_KOKKOS_ADAPTER_UVM_OFF(Kokkos::complex<double>, int)
132 #endif
133 #endif // KOKKOS_ENABLE_CUDA
134 
135 #endif // AMESOS2_KOKKOS_IMPL_HPP
Amesos2::MultiVecAdapter specialization for the Kokkos::View class.