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;
69#if SUPERLU_DIST_MAJOR_VERSION > 9 || (SUPERLU_DIST_MAJOR_VERSION == 9 && SUPERLU_DIST_MINOR_VERSION > 1)
70 typedef int perm_int_t;
72 typedef int_t perm_int_t;
75#if SUPERLU_DIST_MAJOR_VERSION > 8
82#include "superlu_ddefs.h"
85#if defined(HAVE_TEUCHOS_COMPLEX) && !defined(__clang__)
87#include "superlu_zdefs.h"
94template <
typename slu_scalar_t,
typename slu_mag_t>
95struct slu_dist_mult {};
100struct slu_dist_mult<T,T> : std::multiplies<T> {};
104struct slu_dist_mult<double,double>
106 double operator()(
double a,
double b) {
111#if defined(HAVE_TEUCHOS_COMPLEX) && !defined(__clang__)
114 struct slu_dist_mult<Z::doublecomplex,double>
116 Z::doublecomplex operator()(Z::doublecomplex amesos_z,
double amesos_d) {
117 Z::doublecomplex amesos_zr;
118 zd_mult(&amesos_zr, &amesos_z, amesos_d);
124 struct slu_dist_mult<Z::doublecomplex,Z::doublecomplex>
126 Z::doublecomplex operator()(Z::doublecomplex amesos_z1, Z::doublecomplex amesos_z2) {
127 Z::doublecomplex amesos_zr;
128 zz_mult(&amesos_zr, &amesos_z1, &amesos_z2);
134#if defined(HAVE_TEUCHOS_COMPLEX) && !defined(__clang__)
150template <
typename TypeFrom>
151class ValueTypeConversionTraits<SLUD::Z::doublecomplex, TypeFrom>
154 static SLUD::Z::doublecomplex convert(
const TypeFrom t )
156 SLUD::Z::doublecomplex ret;
157 ret.r = Teuchos::as<double>(t.real());
158 ret.i = Teuchos::as<double>(t.imag());
162 static SLUD::Z::doublecomplex safeConvert(
const TypeFrom t )
164 SLUD::Z::doublecomplex ret;
165 ret.r = Teuchos::as<double>(t.real());
166 ret.i = Teuchos::as<double>(t.imag());
173template <
typename TypeTo>
174class ValueTypeConversionTraits<TypeTo, SLUD::Z::doublecomplex>
177 static TypeTo convert(
const SLUD::Z::doublecomplex t )
179 typedef typename TypeTo::value_type value_type;
180 value_type ret_r = Teuchos::as<value_type>( t.r );
181 value_type ret_i = Teuchos::as<value_type>( t.i );
182 return ( TypeTo( ret_r, ret_i ) );
186 static TypeTo safeConvert(
const SLUD::Z::doublecomplex t )
188 typedef typename TypeTo::value_type value_type;
189 value_type ret_r = Teuchos::as<value_type>( t.r );
190 value_type ret_i = Teuchos::as<value_type>( t.i );
191 return ( TypeTo( ret_r, ret_i ) );
195template <
typename Ordinal>
196class SerializationTraits<Ordinal,SLUD::Z::doublecomplex>
197 :
public DirectSerializationTraits<Ordinal,SLUD::Z::doublecomplex>
213 ostream& operator<<(ostream& out,
const SLUD::Z::doublecomplex z);
232 static const SLUD::Dtype_t dtype = SLUD::SLU_D;
234 typedef double magnitude_type;
235#if SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
236 typedef SLUD::D::dLUstruct_t LUstruct_t;
237 typedef SLUD::D::dSOLVEstruct_t SOLVEstruct_t;
238 typedef SLUD::D::dScalePermstruct_t ScalePermstruct_t;
240 typedef SLUD::D::LUstruct_t LUstruct_t;
241 typedef SLUD::D::SOLVEstruct_t SOLVEstruct_t;
242 typedef SLUD::ScalePermstruct_t ScalePermstruct_t;
246#if defined(HAVE_TEUCHOS_COMPLEX) && !defined(__clang__)
250 static const SLUD::Dtype_t dtype = SLUD::SLU_Z;
251 typedef SLUD::Z::doublecomplex type;
252 typedef double magnitude_type;
253#if SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
254 typedef SLUD::Z::zLUstruct_t LUstruct_t;
255 typedef SLUD::Z::zSOLVEstruct_t SOLVEstruct_t;
256 typedef SLUD::Z::zScalePermstruct_t ScalePermstruct_t;
258 typedef SLUD::Z::LUstruct_t LUstruct_t;
259 typedef SLUD::Z::SOLVEstruct_t SOLVEstruct_t;
260 typedef SLUD::ScalePermstruct_t ScalePermstruct_t;
270 static const SLUD::Dtype_t dtype = SLUD::SLU_Z;
271 typedef SLUD::Z::doublecomplex type;
272 typedef double magnitude_type;
273#if SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
274 typedef SLUD::Z::zLUstruct_t LUstruct_t;
275 typedef SLUD::Z::zSOLVEstruct_t SOLVEstruct_t;
276 typedef SLUD::Z::zScalePermstruct_t ScalePermstruct_t;
278 typedef SLUD::Z::LUstruct_t LUstruct_t;
279 typedef SLUD::Z::SOLVEstruct_t SOLVEstruct_t;
280 typedef SLUD::ScalePermstruct_t ScalePermstruct_t;
Amesos2 interface to the distributed memory version of SuperLU.
Definition Amesos2_Superludist_decl.hpp:57
Map types to solver-specific data-types and enums.
Definition Amesos2_TypeMap.hpp:48