Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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
......
......@@ -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);
......
#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
}
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment