Skip to content
Snippets Groups Projects
Commit d1dcb220 authored by Markus Blatt's avatar Markus Blatt Committed by Christoph Grüninger
Browse files

Support various numeric types for SuperLU at once.

Previously, we only supported one numeric type (float, double, complex<float>,
or complex<double>) that the user could select via a cryptic preprocessor
define. This was done this way because when including SuperLU headers we
would otherwise have multiply defined structs in SuperLU. At least in 4.3
GlobalLU_t is defined in slu_sdefs.h, slu_ddefs.h, slu_cdefs.h, and
slu_zdefs.h

With this commit we do not include the problematic SuperLU headers anymore.
Instead why define the functions called by us with extern C within DUNE.
In addition we now provide all the numeric types for which SuperLU drivers are
found at the same time.

Hopefully this will also fix problems with multiply defined BLAS routines experienced
with arpack and SuperLU.
parent 2aed6a28
No related branches found
No related tags found
No related merge requests found
......@@ -125,8 +125,20 @@ int main(void)
}"
SUPERLU_MIN_VERSION_5)
if(SUPERLU_MIN_VERSION_4_3)
include(CheckIncludeFiles)
set(HAVE_SLU_DDEFS_H 1)
check_include_files(slu_sdefs.h HAVE_SLU_SDEFS_H)
check_include_files(slu_cdefs.h HAVE_SLU_CDEFS_H)
check_include_files(slu_zdefs.h HAVE_SLU_ZDEFS_H)
endif(SUPERLU_MIN_VERSION_4_3)
cmake_pop_check_state()
set(SUPERLU_INT_TYPE "int" CACHE STRING
"The integer version that SuperLU was compiled for (Default is int.
Should be the same as int_t define in e.g. slu_sdefs.h")
if(NOT SUPERLU_MIN_VERSION_4)
set(SUPERLU_WITH_VERSION "SuperLU < 4.0" CACHE STRING
"Human readable string containing SuperLU version information.")
......
......@@ -31,6 +31,22 @@
/* Define to ENABLE_SUPERLU if the SuperLU library is available */
#cmakedefine HAVE_SUPERLU ENABLE_SUPERLU
/* Define to the integer type that SuperLU was compiled for
See e.g. what int_t is defined to in slu_sdefs.h */
#cmakedefine SUPERLU_INT_TYPE @SUPERLU_INT_TYPE@
/* Define to 1 if header slu_sdefs.h is there. */
#cmakedefine01 HAVE_SLU_SDEFS_H
/* Define to 1 if header slu_ddefs.h is there. */
#cmakedefine01 HAVE_SLU_DDEFS_H
/* Define to 1 if header slu_cdefs.h is there. */
#cmakedefine01 HAVE_SLU_CDEFS_H
/* Define to 1 if header slu_zdefs.h is there. */
#cmakedefine01 HAVE_SLU_ZDEFS_H
/* Define to ENABLE_ARPACKPP if the ARPACK++ library is available */
#cmakedefine HAVE_ARPACKPP ENABLE_ARPACKPP
......
......@@ -4,32 +4,8 @@
#define DUNE_ISTL_SUPERLU_HH
#if HAVE_SUPERLU
#ifdef TRUE
#undef TRUE
#endif
#ifdef FALSE
#undef FALSE
#endif
#ifndef SUPERLU_NTYPE
#define SUPERLU_NTYPE 1
#endif
#if SUPERLU_NTYPE==0
#include "slu_sdefs.h"
#endif
#if SUPERLU_NTYPE==1
#include "slu_ddefs.h"
#endif
#if SUPERLU_NTYPE==2
#include "slu_cdefs.h"
#endif
#if SUPERLU_NTYPE>=3
#include "slu_zdefs.h"
#endif
#include "superlufunctions.hh"
#include "solvers.hh"
#include "supermatrix.hh"
#include <algorithm>
......@@ -81,7 +57,7 @@ namespace Dune
struct QuerySpaceChooser
{};
#if SUPERLU_NTYPE==0
#if HAVE_SLU_SDEFS_H
template<>
struct SuperLUDenseMatChooser<float>
{
......@@ -129,7 +105,7 @@ namespace Dune
#endif
#if SUPERLU_NTYPE==1
#if HAVE_SLU_DDEFS_H
template<>
struct SuperLUDenseMatChooser<double>
......@@ -176,7 +152,7 @@ namespace Dune
};
#endif
#if SUPERLU_NTYPE>=3
#if HAVE_SLU_ZDEFS_H
template<>
struct SuperLUDenseMatChooser<std::complex<double> >
{
......@@ -223,7 +199,7 @@ namespace Dune
};
#endif
#if SUPERLU_NTYPE==2
#if HAVE_SLU_CDEFS_H
template<>
struct SuperLUDenseMatChooser<std::complex<float> >
{
......
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_ISTL_SUPERLUFUNCTIONS_HH
#define DUNE_ISTL_SUPERLUFUNCTIONS_HH
#if HAVE_SUPERLU
#define int_t SUPERLU_INT_TYPE
#include "supermatrix.h"
#include "slu_util.h"
#undef int_t
#if HAVE_SLU_SDEFS_H
extern "C" {
extern void
sgssvx(superlu_options_t *, SuperMatrix *, int *, int *, int *,
char *, float *, float *, SuperMatrix *, SuperMatrix *,
void *, int, SuperMatrix *, SuperMatrix *,
float *, float *, float *, float *,
#if SUPERLU_MIN_VERSION_5
GlobalLU_t*,
#endif
mem_usage_t *, SuperLUStat_t *, int *);
extern void
sCreate_Dense_Matrix(SuperMatrix *, int, int, float *, int,
Stype_t, Dtype_t, Mtype_t);
extern void
sCreate_CompCol_Matrix(SuperMatrix *, int, int, int, float *,
int *, int *, Stype_t, Dtype_t, Mtype_t);
extern int sQuerySpace (SuperMatrix *, SuperMatrix *, mem_usage_t *);
extern void sPrint_CompCol_Matrix(char *, SuperMatrix *);
}
#endif
#if HAVE_SLU_DDEFS_H
extern "C" {
extern void
dgssvx(superlu_options_t *, SuperMatrix *, int *, int *, int *,
char *, double *, double *, SuperMatrix *, SuperMatrix *,
void *, int, SuperMatrix *, SuperMatrix *,
double *, double *, double *, double *,
#if SUPERLU_MIN_VERSION_5
GlobalLU_t*,
#endif
mem_usage_t *, SuperLUStat_t *, int *);
extern void
dCreate_CompCol_Matrix(SuperMatrix *, int, int, int, double *,
int *, int *, Stype_t, Dtype_t, Mtype_t);
extern void
dCreate_Dense_Matrix(SuperMatrix *, int, int, double *, int,
Stype_t, Dtype_t, Mtype_t);
extern int dQuerySpace (SuperMatrix *, SuperMatrix *, mem_usage_t *);
extern void dPrint_CompCol_Matrix(char *, SuperMatrix *);
}
#endif
#if HAVE_SLU_CDEFS_H
#include "slu_scomplex.h"
extern "C" {
extern void
cgssvx(superlu_options_t *, SuperMatrix *, int *, int *, int *,
char *, float *, float *, SuperMatrix *, SuperMatrix *,
void *, int, SuperMatrix *, SuperMatrix *,
float *, float *, float *, float *,
#if SUPERLU_MIN_VERSION_5
GlobalLU_t*,
#endif
mem_usage_t *, SuperLUStat_t *, int *);
extern void
cCreate_Dense_Matrix(SuperMatrix *, int, int, ::complex *, int,
Stype_t, Dtype_t, Mtype_t);
extern void
cCreate_CompCol_Matrix(SuperMatrix *, int, int, int, ::complex *,
int *, int *, Stype_t, Dtype_t, Mtype_t);
extern int cQuerySpace (SuperMatrix *, SuperMatrix *, mem_usage_t *);
extern void cPrint_CompCol_Matrix(char *, SuperMatrix *);
}
#endif
#if HAVE_SLU_ZDEFS_H
#include "slu_dcomplex.h"
extern "C" {
extern void
zgssvx(superlu_options_t *, SuperMatrix *, int *, int *, int *,
char *, double *, double *, SuperMatrix *, SuperMatrix *,
void *, int, SuperMatrix *, SuperMatrix *,
double *, double *, double *, double *,
#if SUPERLU_MIN_VERSION_5
GlobalLU_t*,
#endif
mem_usage_t *, SuperLUStat_t *, int *);
extern void
zCreate_CompCol_Matrix(SuperMatrix *, int, int, int, doublecomplex *,
int *, int *, Stype_t, Dtype_t, Mtype_t);
extern void
zCreate_Dense_Matrix(SuperMatrix *, int, int, doublecomplex *, int,
Stype_t, Dtype_t, Mtype_t);
extern int zQuerySpace (SuperMatrix *, SuperMatrix *, mem_usage_t *);
extern void zPrint_CompCol_Matrix(char *, SuperMatrix *);
}
#endif
#endif
#endif
......@@ -5,26 +5,6 @@
#if HAVE_SUPERLU
#ifndef SUPERLU_NTYPE
#define SUPERLU_NTYPE 1
#endif
#if SUPERLU_NTYPE==0
#include "slu_sdefs.h"
#endif
#if SUPERLU_NTYPE==1
#include "slu_ddefs.h"
#endif
#if SUPERLU_NTYPE==2
#include "slu_cdefs.h"
#endif
#if SUPERLU_NTYPE>=3
#include "slu_zdefs.h"
#endif
#include "bcrsmatrix.hh"
#include "bvector.hh"
#include <dune/common/fmatrix.hh>
......@@ -34,6 +14,8 @@
#include"colcompmatrix.hh"
#include "superlufunctions.hh"
namespace Dune
{
......@@ -45,7 +27,7 @@ namespace Dune
struct SuperMatrixPrinter
{};
#if SUPERLU_NTYPE==0
#if HAVE_SLU_SDEFS_H
template<>
struct SuperMatrixCreateSparseChooser<float>
{
......@@ -68,7 +50,7 @@ namespace Dune
};
#endif
#if SUPERLU_NTYPE==1
#if HAVE_SLU_DDEFS_H
template<>
struct SuperMatrixCreateSparseChooser<double>
{
......@@ -91,7 +73,7 @@ namespace Dune
};
#endif
#if SUPERLU_NTYPE==2
#if HAVE_SLU_CDEFS_H
template<>
struct SuperMatrixCreateSparseChooser<std::complex<float> >
{
......@@ -114,7 +96,7 @@ namespace Dune
};
#endif
#if SUPERLU_NTYPE>=3
#if HAVE_SLU_ZDEFS_H
template<>
struct SuperMatrixCreateSparseChooser<std::complex<double> >
{
......
......@@ -14,36 +14,11 @@
#include "laplacian.hh"
#ifndef SUPERLU_NTYPE
#define SUPERLU_NTYPE 1
#endif
#if SUPERLU_NTYPE==1
typedef double FIELD_TYPE;
#endif
#if SUPERLU_NTYPE==0
typedef float FIELD_TYPE;
#endif
#if SUPERLU_NTYPE==2
typedef std::complex<float> FIELD_TYPE;
#endif
#if SUPERLU_NTYPE>=3
typedef std::complex<double> FIELD_TYPE;
#endif
int main(int argc, char** argv)
try
{
#if HAVE_SUPERLU
template<typename FIELD_TYPE>
void runSuperLU(std::size_t N)
{
const int BS=1;
std::size_t N=100;
if(argc>1)
N = atoi(argv[1]);
std::cout<<"testing for N="<<N<<" BS="<<1<<std::endl;
typedef Dune::FieldMatrix<FIELD_TYPE,BS,BS> MatrixBlock;
......@@ -83,8 +58,34 @@ try
solver1.apply(x1,b1, res);
solver1.apply(reinterpret_cast<FIELD_TYPE*>(&x1[0]), reinterpret_cast<FIELD_TYPE*>(&b1[0]));
}
#endif
int main(int argc, char** argv)
try
{
std::size_t N=100;
if(argc>1)
N = atoi(argv[1]);
std::cout<<"testing for N="<<N<<" BS="<<1<<std::endl;
#if HAVE_SUPERLU
#if HAVE_SLU_SDEFS_H
runSuperLU<float>(N);
#endif
#if HAVE_SLU_DDEFS_H
runSuperLU<double>(N);
#endif
#if HAVE_SLU_CDEFS_H
runSuperLU<std::complex<float> >(N);
#endif
#if HAVE_SLU_ZDEFS_H
runSuperLU<std::complex<double> >(N);
#endif
return 0;
#else // HAVE_SUPERLU
std::cerr << "You need SuperLU to run this test." << std::endl;
return 77;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment