23 #ifndef AMESOS2_SUPERLUDIST_TYPEMAP_HPP
24 #define AMESOS2_SUPERLUDIST_TYPEMAP_HPP
31 #include <Teuchos_as.hpp>
32 #ifdef HAVE_TEUCHOS_COMPLEX
33 #include <Teuchos_SerializationTraits.hpp>
36 #include "Amesos2_TypeMap.hpp"
38 #ifdef KOKKOS_ENABLE_CUDA
39 #include <cublas_v2.h>
40 #include <cuda_runtime_api.h>
46 #if SUPERLU_DIST_MAJOR_VERSION > 4
48 #include "superlu_dist_config.h"
52 #define USER_FREE(addr) SLUD::superlu_free_dist(addr)
56 #undef __SUPERLU_SUPERMATRIX
57 #include "superlu_defs.h"
60 #if SUPERLU_DIST_MAJOR_VERSION > 4
61 typedef superlu_dist_options_t amesos2_superlu_dist_options_t;
62 typedef superlu_dist_mem_usage_t amesos2_superlu_dist_mem_usage_t;
63 #define AMESOS2_ENABLES_SUPERLUDIST_VERSION5_AND_HIGHER 1
65 typedef superlu_options_t amesos2_superlu_dist_options_t;
66 typedef mem_usage_t amesos2_superlu_dist_mem_usage_t;
71 #include "superlu_ddefs.h"
74 #if defined(HAVE_TEUCHOS_COMPLEX) && !defined(__clang__)
76 #include "superlu_zdefs.h"
78 #endif // HAVE_TEUCHOS_COMPLEX
83 template <
typename slu_scalar_t,
typename slu_mag_t>
84 struct slu_dist_mult {};
89 struct slu_dist_mult<T,T> : std::multiplies<T> {};
93 struct slu_dist_mult<double,double>
95 double operator()(
double a,
double b) {
100 #if defined(HAVE_TEUCHOS_COMPLEX) && !defined(__clang__)
103 struct slu_dist_mult<Z::doublecomplex,double>
105 Z::doublecomplex operator()(Z::doublecomplex amesos_z,
double amesos_d) {
106 Z::doublecomplex amesos_zr;
107 zd_mult(&amesos_zr, &amesos_z, amesos_d);
113 struct slu_dist_mult<Z::doublecomplex,Z::doublecomplex>
115 Z::doublecomplex operator()(Z::doublecomplex amesos_z1, Z::doublecomplex amesos_z2) {
116 Z::doublecomplex amesos_zr;
117 zz_mult(&amesos_zr, &amesos_z1, &amesos_z2);
121 #endif // HAVE_TEUCHOS_COMPLEX
123 #if defined(HAVE_TEUCHOS_COMPLEX) && !defined(__clang__)
139 template <
typename TypeFrom>
140 class ValueTypeConversionTraits<SLUD::Z::doublecomplex, TypeFrom>
143 static SLUD::Z::doublecomplex convert(
const TypeFrom t )
145 SLUD::Z::doublecomplex ret;
146 ret.r = Teuchos::as<double>(t.real());
147 ret.i = Teuchos::as<double>(t.imag());
151 static SLUD::Z::doublecomplex safeConvert(
const TypeFrom t )
153 SLUD::Z::doublecomplex ret;
154 ret.r = Teuchos::as<double>(t.real());
155 ret.i = Teuchos::as<double>(t.imag());
162 template <
typename TypeTo>
163 class ValueTypeConversionTraits<TypeTo, SLUD::Z::doublecomplex>
166 static TypeTo convert(
const SLUD::Z::doublecomplex t )
168 typedef typename TypeTo::value_type value_type;
169 value_type ret_r = Teuchos::as<value_type>( t.r );
170 value_type ret_i = Teuchos::as<value_type>( t.i );
171 return ( TypeTo( ret_r, ret_i ) );
175 static TypeTo safeConvert(
const SLUD::Z::doublecomplex t )
177 typedef typename TypeTo::value_type value_type;
178 value_type ret_r = Teuchos::as<value_type>( t.r );
179 value_type ret_i = Teuchos::as<value_type>( t.i );
180 return ( TypeTo( ret_r, ret_i ) );
184 template <
typename Ordinal>
185 class SerializationTraits<Ordinal,SLUD::Z::doublecomplex>
186 :
public DirectSerializationTraits<Ordinal,SLUD::Z::doublecomplex>
202 ostream& operator<<(ostream& out,
const SLUD::Z::doublecomplex z);
206 #endif // HAVE_TEUCHOS_COMPLEX
212 template <
class,
class>
class Superludist;
219 struct TypeMap<Superludist,double>
221 static const SLUD::Dtype_t dtype = SLUD::SLU_D;
223 typedef double magnitude_type;
224 #if SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
225 typedef SLUD::D::dLUstruct_t LUstruct_t;
226 typedef SLUD::D::dSOLVEstruct_t SOLVEstruct_t;
227 typedef SLUD::D::dScalePermstruct_t ScalePermstruct_t;
229 typedef SLUD::D::LUstruct_t LUstruct_t;
230 typedef SLUD::D::SOLVEstruct_t SOLVEstruct_t;
231 typedef SLUD::ScalePermstruct_t ScalePermstruct_t;
235 #if defined(HAVE_TEUCHOS_COMPLEX) && !defined(__clang__)
237 struct TypeMap<Superludist,std::complex<double> >
239 static const SLUD::Dtype_t dtype = SLUD::SLU_Z;
240 typedef SLUD::Z::doublecomplex type;
241 typedef double magnitude_type;
242 #if SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
243 typedef SLUD::Z::zLUstruct_t LUstruct_t;
244 typedef SLUD::Z::zSOLVEstruct_t SOLVEstruct_t;
245 typedef SLUD::Z::zScalePermstruct_t ScalePermstruct_t;
247 typedef SLUD::Z::LUstruct_t LUstruct_t;
248 typedef SLUD::Z::SOLVEstruct_t SOLVEstruct_t;
249 typedef SLUD::ScalePermstruct_t ScalePermstruct_t;
257 struct TypeMap<Superludist,SLUD::Z::doublecomplex>
259 static const SLUD::Dtype_t dtype = SLUD::SLU_Z;
260 typedef SLUD::Z::doublecomplex type;
261 typedef double magnitude_type;
262 #if SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
263 typedef SLUD::Z::zLUstruct_t LUstruct_t;
264 typedef SLUD::Z::zSOLVEstruct_t SOLVEstruct_t;
265 typedef SLUD::Z::zScalePermstruct_t ScalePermstruct_t;
267 typedef SLUD::Z::LUstruct_t LUstruct_t;
268 typedef SLUD::Z::SOLVEstruct_t SOLVEstruct_t;
269 typedef SLUD::ScalePermstruct_t ScalePermstruct_t;
273 #endif // HAVE_TEUCHOS_COMPLEX
280 #endif // AMESOS2_SUPERLUDIST_TYPEMAP_HPP