From 80a79af1c1bd58df99178a9f8559ab0e89897196 Mon Sep 17 00:00:00 2001 From: Giovanni La Mura <giovanni.lamura@inaf.it> Date: Tue, 5 Mar 2024 12:28:05 +0100 Subject: [PATCH] Compile with 64-bit LAPACK headers --- src/cluster/Makefile | 2 +- src/cluster/cluster.cpp | 3 ++- src/include/lapack_calls.h | 2 +- src/libnptm/lapack_calls.cpp | 18 +++++++++--------- src/make.inc | 4 ++-- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/cluster/Makefile b/src/cluster/Makefile index 3fc31183..8a117426 100644 --- a/src/cluster/Makefile +++ b/src/cluster/Makefile @@ -46,7 +46,7 @@ $(BUILDDIR_CLU)/edfb_clu: $(OBJDIR) $(OBJDIR)/edfb_clu.o $(BUILDDIR_CLU) # We put $(LIBNPTM) as an object to link in directly, so that it will be found at runtime even if it is a shared object library. May change in the future when we have an install: target $(BUILDDIR_CLU)/np_cluster: $(OBJDIR) $(CXX_CLU_OBJS) $(BUILDDIR_CLU) $(LIBNPTM) - $(CXX) $(CXXFLAGS) -o $(BUILDDIR_CLU)/np_cluster $(CXX_CLU_OBJS) $(LIBNPTM) $(CXXLDFLAGS) -llapacke + $(CXX) $(CXXFLAGS) -o $(BUILDDIR_CLU)/np_cluster $(CXX_CLU_OBJS) $(LIBNPTM) $(CXXLDFLAGS) clean: rm -f $(F_CLU_OBJS) $(CXX_CLU_OBJS) $(CXX_CLU_DEBUG) diff --git a/src/cluster/cluster.cpp b/src/cluster/cluster.cpp index ea86b739..a31b2b71 100644 --- a/src/cluster/cluster.cpp +++ b/src/cluster/cluster.cpp @@ -33,6 +33,7 @@ #endif #ifndef INCLUDE_LAPACK_CALLS_H_ +#include "lapacke.h" #include "../include/lapack_calls.h" #endif @@ -340,7 +341,7 @@ void cluster(string config_file, string data_file, string output_path) { } // i132 loop cms(am, c1, c1ao, c4, c6); //cms(tam, c1, c1ao, c4, c6); - int ndit = 2 * nsph * c4->nlim; + lapack_int ndit = 2 * nsph * c4->nlim; //lucin(am, mxndm, ndit, jer); zinvert(am, ndit, jer); if (jer != 0) break; // jxi488 loop: goes to memory clean diff --git a/src/include/lapack_calls.h b/src/include/lapack_calls.h index 52996a53..9c363e74 100644 --- a/src/include/lapack_calls.h +++ b/src/include/lapack_calls.h @@ -16,6 +16,6 @@ * \param n: `int` The number of rows and columns of the [n x n] matrix. * \param jer: `int &` Reference to an integer return flag. */ -void zinvert(std::complex<double> **mat, int n, int &jer); +void zinvert(std::complex<double> **mat, lapack_int n, int &jer); #endif diff --git a/src/libnptm/lapack_calls.cpp b/src/libnptm/lapack_calls.cpp index f57e31da..e22c5a84 100644 --- a/src/libnptm/lapack_calls.cpp +++ b/src/libnptm/lapack_calls.cpp @@ -1,31 +1,31 @@ #include <complex> #include <cstdlib> -#include "lapacke.h" #ifndef INCLUDE_LAPACK_CALLS_H_ +#include "lapacke.h" #include "../include/lapack_calls.h" #endif using namespace std; -void zinvert(std::complex<double> **mat, int n, int &jer) { +void zinvert(std::complex<double> **mat, lapack_int n, int &jer) { jer = 0; __complex__ double *arr = new __complex__ double[n * n]; const __complex__ double uim = 1.0di; - for (int i = 0; i < n; i++) { - for (int j = 0; j < n; j++) { - int idx = i + n * j; + for (lapack_int i = 0; i < n; i++) { + for (lapack_int j = 0; j < n; j++) { + lapack_int idx = i + n * j; arr[idx] = mat[j][i].real() + uim * mat[j][i].imag(); } } - int* IPIV = new int[n]; + int* IPIV = new int[n](); LAPACKE_zgetrf(LAPACK_ROW_MAJOR, n, n, arr, n, IPIV); LAPACKE_zgetri(LAPACK_ROW_MAJOR, n, arr, n, IPIV); - for (int i = 0; i < n; i++) { - for (int j = 0; j < n; j++) { - int idx = i + n * j; + for (lapack_int i = 0; i < n; i++) { + for (lapack_int j = 0; j < n; j++) { + lapack_int idx = i + n * j; mat[j][i] = complex<double>(__real__ arr[idx], __imag__ arr[idx]); } } diff --git a/src/make.inc b/src/make.inc index dcdd896f..3779c034 100644 --- a/src/make.inc +++ b/src/make.inc @@ -40,7 +40,7 @@ endif # CXXFLAGS defines the default compilation options for the C++ compiler ifndef CXXFLAGS -override CXXFLAGS=-O3 -ggdb -pg -coverage -I$(HDF5_INCLUDE) +override CXXFLAGS=-O3 -ggdb -pg -coverage -I$(HDF5_INCLUDE) -DLAPACK_ILP64 #override CXXFLAGS=-O3 -I$(HDF5_INCLUDE) endif @@ -50,7 +50,7 @@ ifndef CXXLDFLAGS ifndef HDF5_LIB override HDF5_LIB=/usr/lib/x86_64-linux-gnu/hdf5/serial endif -override CXXLDFLAGS=-L/usr/lib64 -L$(HDF5_LIB) -lhdf5 $(LDFLAGS) +override CXXLDFLAGS=-L/usr/lib64 -L$(HDF5_LIB) -lhdf5 -llapacke $(LDFLAGS) #else #override CXXLDFLAGS=-L/usr/lib64 -L$(HDF5_LIB) -lhdf5 $(CXXLDFLAGS) endif -- GitLab