Commit ab3bc98c authored by Mulas, Giacomo's avatar Mulas, Giacomo
Browse files

adapt to work also with mkl_lapacke.h, playing some gimmick with pointers

parent 0825677d
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -33,8 +33,12 @@
#endif

#ifdef USE_LAPACK
#ifdef USE_MKL
#include <mkl_lapacke.h>
#else
#include <lapacke.h>
#endif
#ifndef INCLUDE_LAPACK_CALLS_H_
#include "lapacke.h"
#include "../include/lapack_calls.h"
#endif
#endif
+7 −1
Original line number Diff line number Diff line
@@ -10,7 +10,13 @@
 * legacy serial function implementation is used as a fall-back.
 */

#ifndef lapack_int
#ifdef USE_LAPACK
#ifdef USE_MKL
#include <mkl_lapacke.h>
#else
#include <lapacke.h>
#endif
#else
#define lapack_int int64_t
#endif

+7 −1
Original line number Diff line number Diff line
@@ -9,10 +9,16 @@
#include "../include/algebraic.h"
#endif

#ifdef USE_LAPACK
#ifdef USE_MKL
#include <mkl_lapacke.h>
#else
#include <lapacke.h>
#endif
#ifndef INCLUDE_LAPACK_CALLS_H_
#include "lapacke.h"
#include "../include/lapack_calls.h"
#endif
#endif

// >>> FALL-BACK FUNCTIONS DECLARATION <<< //
extern void lucin(std::complex<double> **mat, int64_t max_size, int64_t size, int &ier);
+17 −3
Original line number Diff line number Diff line
#include <complex>
#include <complex.h>

#ifdef USE_LAPACK
#ifdef USE_MKL
#include <mkl_lapacke.h>
#else
#include <lapacke.h>
#endif
#ifndef INCLUDE_LAPACK_CALLS_H_
#include "lapacke.h"
#include "../include/lapack_calls.h"
#endif
#endif

#ifdef USE_LAPACK
void zinvert(std::complex<double> **mat, lapack_int n, int &jer) {
#ifdef USE_LAPACK
  jer = 0;
  __complex__ double *arr = new __complex__ double[n * n];
  const __complex__ double uim = 1.0*I;
#ifdef USE_MKL
  MKL_Complex16 *arr2 = (MKL_Complex16 *) arr;
#endif
  for (lapack_int i = 0; i < n; i++) {
    for (lapack_int j = 0; j < n; j++) {
      lapack_int idx = i + n * j;
@@ -20,8 +29,13 @@ void zinvert(std::complex<double> **mat, lapack_int n, int &jer) {
  
  lapack_int* IPIV = new lapack_int[n]();
  
#ifdef USE_MKL
  LAPACKE_zgetrf(LAPACK_ROW_MAJOR, n, n, arr2, n, IPIV);
  LAPACKE_zgetri(LAPACK_ROW_MAJOR, n, arr2, n, IPIV);
#else
  LAPACKE_zgetrf(LAPACK_ROW_MAJOR, n, n, arr, n, IPIV);
  LAPACKE_zgetri(LAPACK_ROW_MAJOR, n, arr, n, IPIV);
#endif
  for (lapack_int i = 0; i < n; i++) {
    for (lapack_int j = 0; j < n; j++) {
      lapack_int idx = i + n * j;
@@ -30,5 +44,5 @@ void zinvert(std::complex<double> **mat, lapack_int n, int &jer) {
  }
  delete[] IPIV;
  delete[] arr;
}
#endif
}
+1 −1
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ override CXXFLAGS=-O3 -ggdb -pg -coverage -I$(HDF5_INCLUDE)
ifdef USE_LAPACK
override CXXFLAGS+= -DUSE_LAPACK -DLAPACK_ILP64 
ifdef USE_MKL
override CXXFLAGS+= -DMKL_ILP64 -I$(MKLROOT)/include
override CXXFLAGS+= -DMKL_ILP64 -DUSE_MKL -I$(MKLROOT)/include
endif
endif
endif