From 3c8531df63f86fb8c44a5e5cdc30985b73aacc07 Mon Sep 17 00:00:00 2001 From: Denis Davydov Date: Thu, 6 Dec 2018 22:43:09 +0100 Subject: [PATCH] move new blas extension template functions into a separate header --- .../deal.II/lac/blas_extension_templates.h | 174 ++++++++++++++++++ include/deal.II/lac/lapack_templates.h | 141 -------------- source/lac/lapack_full_matrix.cc | 3 +- 3 files changed, 176 insertions(+), 142 deletions(-) create mode 100644 include/deal.II/lac/blas_extension_templates.h diff --git a/include/deal.II/lac/blas_extension_templates.h b/include/deal.II/lac/blas_extension_templates.h new file mode 100644 index 0000000000..a6b19cc428 --- /dev/null +++ b/include/deal.II/lac/blas_extension_templates.h @@ -0,0 +1,174 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2018 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + + +#ifndef dealii_blas_extension_templates_h +#define dealii_blas_extension_templates_h + +#include + +#include + +#ifdef DEAL_II_HAVE_FP_EXCEPTIONS +# include +#endif + +// Intel-MKL specific functions +#ifdef DEAL_II_LAPACK_WITH_MKL +// see +// https://software.intel.com/en-us/mkl-windows-developer-guide-using-complex-types-in-c-c +# define MKL_Complex8 std::complex +# define MKL_Complex16 std::complex +# include +#endif + + +DEAL_II_NAMESPACE_OPEN + + +template +inline void +omatcopy(char, + char, + dealii::types::blas_int, + dealii::types::blas_int, + const number1, + const number2 *, + dealii::types::blas_int, + number3 *, + dealii::types::blas_int) +{ + Assert(false, ExcNotImplemented()); +} + + + +inline void +omatcopy(char ordering, + char trans, + dealii::types::blas_int rows, + dealii::types::blas_int cols, + const float alpha, + const float * A, + dealii::types::blas_int lda, + float * B, + dealii::types::blas_int ldb) +{ +#ifdef DEAL_II_LAPACK_WITH_MKL + mkl_somatcopy(ordering, trans, rows, cols, alpha, A, lda, B, ldb); +#else + (void)ordering; + (void)trans; + (void)rows; + (void)cols; + (void)alpha; + (void)A; + (void)lda; + (void)B; + (void)ldb; + Assert(false, LAPACKSupport::ExcMissing("mkl_somatcopy")); +#endif // DEAL_II_LAPACK_WITH_MKL +} + + + +inline void +omatcopy(char ordering, + char trans, + dealii::types::blas_int rows, + dealii::types::blas_int cols, + const double alpha, + const double * A, + dealii::types::blas_int lda, + double * B, + dealii::types::blas_int ldb) +{ +#ifdef DEAL_II_LAPACK_WITH_MKL + mkl_domatcopy(ordering, trans, rows, cols, alpha, A, lda, B, ldb); +#else + (void)ordering; + (void)trans; + (void)rows; + (void)cols; + (void)alpha; + (void)A; + (void)lda; + (void)B; + (void)ldb; + Assert(false, LAPACKSupport::ExcMissing("mkl_domatcopy")); +#endif // DEAL_II_LAPACK_WITH_MKL +} + + + +inline void +omatcopy(char ordering, + char trans, + dealii::types::blas_int rows, + dealii::types::blas_int cols, + const std::complex alpha, + const std::complex *A, + dealii::types::blas_int lda, + std::complex * B, + dealii::types::blas_int ldb) +{ +#ifdef DEAL_II_LAPACK_WITH_MKL + mkl_comatcopy(ordering, trans, rows, cols, alpha, A, lda, B, ldb); +#else + (void)ordering; + (void)trans; + (void)rows; + (void)cols; + (void)alpha; + (void)A; + (void)lda; + (void)B; + (void)ldb; + Assert(false, LAPACKSupport::ExcMissing("mkl_comatcopy")); +#endif // DEAL_II_LAPACK_WITH_MKL +} + + + +inline void +omatcopy(char ordering, + char trans, + dealii::types::blas_int rows, + dealii::types::blas_int cols, + const std::complex alpha, + const std::complex *A, + dealii::types::blas_int lda, + std::complex * B, + dealii::types::blas_int ldb) +{ +#ifdef DEAL_II_LAPACK_WITH_MKL + mkl_zomatcopy(ordering, trans, rows, cols, alpha, A, lda, B, ldb); +#else + (void)ordering; + (void)trans; + (void)rows; + (void)cols; + (void)alpha; + (void)A; + (void)lda; + (void)B; + (void)ldb; + Assert(false, LAPACKSupport::ExcMissing("mkl_zomatcopy")); +#endif // DEAL_II_LAPACK_WITH_MKL +} + +DEAL_II_NAMESPACE_CLOSE + +#endif diff --git a/include/deal.II/lac/lapack_templates.h b/include/deal.II/lac/lapack_templates.h index 62d5ebd86c..fde6c6ed31 100644 --- a/include/deal.II/lac/lapack_templates.h +++ b/include/deal.II/lac/lapack_templates.h @@ -25,15 +25,6 @@ # include #endif -// Intel-MKL specific functions -#ifdef DEAL_II_LAPACK_WITH_MKL -// see -// https://software.intel.com/en-us/mkl-windows-developer-guide-using-complex-types-in-c-c -# define MKL_Complex8 std::complex -# define MKL_Complex16 std::complex -# include "mkl_trans.h" -#endif - extern "C" { void @@ -1418,138 +1409,6 @@ extern "C" DEAL_II_NAMESPACE_OPEN -template -inline void -mkl_omatcopy(char, - char, - dealii::types::blas_int, - dealii::types::blas_int, - const number1, - const number2 *, - dealii::types::blas_int, - number3 *, - dealii::types::blas_int) -{ - Assert(false, ExcNotImplemented()); -} - - - -inline void -mkl_omatcopy(char ordering, - char trans, - dealii::types::blas_int rows, - dealii::types::blas_int cols, - const float alpha, - const float * A, - dealii::types::blas_int lda, - float * B, - dealii::types::blas_int ldb) -{ -#ifdef DEAL_II_LAPACK_WITH_MKL - mkl_somatcopy(ordering, trans, rows, cols, alpha, A, lda, B, ldb); -#else - (void)ordering; - (void)trans; - (void)rows; - (void)cols; - (void)alpha; - (void)A; - (void)lda; - (void)B; - (void)ldb; - Assert(false, LAPACKSupport::ExcMissing("mkl_somatcopy")); -#endif // DEAL_II_LAPACK_WITH_MKL -} - - - -inline void -mkl_omatcopy(char ordering, - char trans, - dealii::types::blas_int rows, - dealii::types::blas_int cols, - const double alpha, - const double * A, - dealii::types::blas_int lda, - double * B, - dealii::types::blas_int ldb) -{ -#ifdef DEAL_II_LAPACK_WITH_MKL - mkl_domatcopy(ordering, trans, rows, cols, alpha, A, lda, B, ldb); -#else - (void)ordering; - (void)trans; - (void)rows; - (void)cols; - (void)alpha; - (void)A; - (void)lda; - (void)B; - (void)ldb; - Assert(false, LAPACKSupport::ExcMissing("mkl_domatcopy")); -#endif // DEAL_II_LAPACK_WITH_MKL -} - - - -inline void -mkl_omatcopy(char ordering, - char trans, - dealii::types::blas_int rows, - dealii::types::blas_int cols, - const std::complex alpha, - const std::complex *A, - dealii::types::blas_int lda, - std::complex * B, - dealii::types::blas_int ldb) -{ -#ifdef DEAL_II_LAPACK_WITH_MKL - mkl_comatcopy(ordering, trans, rows, cols, alpha, A, lda, B, ldb); -#else - (void)ordering; - (void)trans; - (void)rows; - (void)cols; - (void)alpha; - (void)A; - (void)lda; - (void)B; - (void)ldb; - Assert(false, LAPACKSupport::ExcMissing("mkl_comatcopy")); -#endif // DEAL_II_LAPACK_WITH_MKL -} - - - -inline void -mkl_omatcopy(char ordering, - char trans, - dealii::types::blas_int rows, - dealii::types::blas_int cols, - const std::complex alpha, - const std::complex *A, - dealii::types::blas_int lda, - std::complex * B, - dealii::types::blas_int ldb) -{ -#ifdef DEAL_II_LAPACK_WITH_MKL - mkl_zomatcopy(ordering, trans, rows, cols, alpha, A, lda, B, ldb); -#else - (void)ordering; - (void)trans; - (void)rows; - (void)cols; - (void)alpha; - (void)A; - (void)lda; - (void)B; - (void)ldb; - Assert(false, LAPACKSupport::ExcMissing("mkl_zomatcopy")); -#endif // DEAL_II_LAPACK_WITH_MKL -} - - template inline void diff --git a/source/lac/lapack_full_matrix.cc b/source/lac/lapack_full_matrix.cc index 837191d34d..90c303a12b 100644 --- a/source/lac/lapack_full_matrix.cc +++ b/source/lac/lapack_full_matrix.cc @@ -15,6 +15,7 @@ #include +#include #include #include #include @@ -1042,7 +1043,7 @@ LAPACKFullMatrix::transpose(LAPACKFullMatrix &B) const const types::blas_int n = B.n(); #ifdef DEAL_II_LAPACK_WITH_MKL const number one = 1.; - mkl_omatcopy('C', 'C', n, m, one, &A.values[0], n, &B.values[0], m); + omatcopy('C', 'C', n, m, one, &A.values[0], n, &B.values[0], m); #else for (types::blas_int i = 0; i < m; ++i) for (types::blas_int j = 0; j < n; ++j) -- 2.39.5