57 #ifndef AMESOS2_SUPERLUDIST_TYPEMAP_HPP
58 #define AMESOS2_SUPERLUDIST_TYPEMAP_HPP
65 #include <Teuchos_as.hpp>
66 #ifdef HAVE_TEUCHOS_COMPLEX
67 #include <Teuchos_SerializationTraits.hpp>
70 #include "Amesos2_TypeMap.hpp"
72 #ifdef KOKKOS_ENABLE_CUDA
73 #include <cublas_v2.h>
74 #include <cuda_runtime_api.h>
80 #if SUPERLU_DIST_MAJOR_VERSION > 4
82 #include "superlu_dist_config.h"
86 #define USER_FREE(addr) SLUD::superlu_free_dist(addr)
90 #undef __SUPERLU_SUPERMATRIX
91 #include "superlu_defs.h"
94 #if SUPERLU_DIST_MAJOR_VERSION > 4
95 typedef superlu_dist_options_t amesos2_superlu_dist_options_t;
96 typedef superlu_dist_mem_usage_t amesos2_superlu_dist_mem_usage_t;
97 #define AMESOS2_ENABLES_SUPERLUDIST_VERSION5_AND_HIGHER 1
99 typedef superlu_options_t amesos2_superlu_dist_options_t;
100 typedef mem_usage_t amesos2_superlu_dist_mem_usage_t;
105 #include "superlu_ddefs.h"
108 #if defined(HAVE_TEUCHOS_COMPLEX) && !defined(__clang__)
110 #include "superlu_zdefs.h"
112 #endif // HAVE_TEUCHOS_COMPLEX
115 template <
typename slu_scalar_t,
typename slu_mag_t>
116 struct slu_dist_mult {};
120 template <
typename T>
121 struct slu_dist_mult<T,T> : std::multiplies<T> {};
125 struct slu_dist_mult<double,double>
127 double operator()(
double a,
double b) {
132 #if defined(HAVE_TEUCHOS_COMPLEX) && !defined(__clang__)
135 struct slu_dist_mult<Z::doublecomplex,double>
137 Z::doublecomplex operator()(Z::doublecomplex amesos_z,
double amesos_d) {
138 Z::doublecomplex amesos_zr;
139 zd_mult(&amesos_zr, &amesos_z, amesos_d);
145 struct slu_dist_mult<Z::doublecomplex,Z::doublecomplex>
147 Z::doublecomplex operator()(Z::doublecomplex amesos_z1, Z::doublecomplex amesos_z2) {
148 Z::doublecomplex amesos_zr;
149 zz_mult(&amesos_zr, &amesos_z1, &amesos_z2);
153 #endif // HAVE_TEUCHOS_COMPLEX
155 #if defined(HAVE_TEUCHOS_COMPLEX) && !defined(__clang__)
171 template <
typename TypeFrom>
172 class ValueTypeConversionTraits<SLUD::Z::doublecomplex, TypeFrom>
175 static SLUD::Z::doublecomplex convert(
const TypeFrom t )
177 SLUD::Z::doublecomplex ret;
178 ret.r = Teuchos::as<double>(t.real());
179 ret.i = Teuchos::as<double>(t.imag());
183 static SLUD::Z::doublecomplex safeConvert(
const TypeFrom t )
185 SLUD::Z::doublecomplex ret;
186 ret.r = Teuchos::as<double>(t.real());
187 ret.i = Teuchos::as<double>(t.imag());
194 template <
typename TypeTo>
195 class ValueTypeConversionTraits<TypeTo, SLUD::Z::doublecomplex>
198 static TypeTo convert(
const SLUD::Z::doublecomplex t )
200 typedef typename TypeTo::value_type value_type;
201 value_type ret_r = Teuchos::as<value_type>( t.r );
202 value_type ret_i = Teuchos::as<value_type>( t.i );
203 return ( TypeTo( ret_r, ret_i ) );
207 static TypeTo safeConvert(
const SLUD::Z::doublecomplex t )
209 typedef typename TypeTo::value_type value_type;
210 value_type ret_r = Teuchos::as<value_type>( t.r );
211 value_type ret_i = Teuchos::as<value_type>( t.i );
212 return ( TypeTo( ret_r, ret_i ) );
216 template <
typename Ordinal>
217 class SerializationTraits<Ordinal,SLUD::Z::doublecomplex>
218 :
public DirectSerializationTraits<Ordinal,SLUD::Z::doublecomplex>
234 ostream& operator<<(ostream& out,
const SLUD::Z::doublecomplex z);
238 #endif // HAVE_TEUCHOS_COMPLEX
244 template <
class,
class>
class Superludist;
251 struct TypeMap<Superludist,double>
253 static const SLUD::Dtype_t dtype = SLUD::SLU_D;
255 typedef double magnitude_type;
256 #if SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
257 typedef SLUD::D::dLUstruct_t LUstruct_t;
258 typedef SLUD::D::dSOLVEstruct_t SOLVEstruct_t;
259 typedef SLUD::D::dScalePermstruct_t ScalePermstruct_t;
261 typedef SLUD::D::LUstruct_t LUstruct_t;
262 typedef SLUD::D::SOLVEstruct_t SOLVEstruct_t;
263 typedef SLUD::ScalePermstruct_t ScalePermstruct_t;
267 #if defined(HAVE_TEUCHOS_COMPLEX) && !defined(__clang__)
269 struct TypeMap<Superludist,std::complex<double> >
271 static const SLUD::Dtype_t dtype = SLUD::SLU_Z;
272 typedef SLUD::Z::doublecomplex type;
273 typedef double magnitude_type;
274 #if SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
275 typedef SLUD::Z::zLUstruct_t LUstruct_t;
276 typedef SLUD::Z::zSOLVEstruct_t SOLVEstruct_t;
277 typedef SLUD::Z::zScalePermstruct_t ScalePermstruct_t;
279 typedef SLUD::Z::LUstruct_t LUstruct_t;
280 typedef SLUD::Z::SOLVEstruct_t SOLVEstruct_t;
281 typedef SLUD::ScalePermstruct_t ScalePermstruct_t;
289 struct TypeMap<Superludist,SLUD::Z::doublecomplex>
291 static const SLUD::Dtype_t dtype = SLUD::SLU_Z;
292 typedef SLUD::Z::doublecomplex type;
293 typedef double magnitude_type;
294 #if SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
295 typedef SLUD::Z::zLUstruct_t LUstruct_t;
296 typedef SLUD::Z::zSOLVEstruct_t SOLVEstruct_t;
297 typedef SLUD::Z::zScalePermstruct_t ScalePermstruct_t;
299 typedef SLUD::Z::LUstruct_t LUstruct_t;
300 typedef SLUD::Z::SOLVEstruct_t SOLVEstruct_t;
301 typedef SLUD::ScalePermstruct_t ScalePermstruct_t;
305 #endif // HAVE_TEUCHOS_COMPLEX
312 #endif // AMESOS2_SUPERLUDIST_TYPEMAP_HPP