CompPhysVienna / n2p2

n2p2 - A Neural Network Potential Package
https://compphysvienna.github.io/n2p2/
GNU General Public License v3.0
214 stars 81 forks source link

Issues in linking with the GSL CBLAS library #195

Open gkaf89 opened 9 months ago

gkaf89 commented 9 months ago

In the makefile configuration for GNU (src/makefile.gnu), the options to link with the BLAS library are the following:

PROJECT_LDFLAGS_BLAS=-lblas -lgsl -lgslcblas 

The GLS (-lgsl) library requires the CBLAS interface. The GSL CBLAS (-lgslcblas) library implements the CBLAS interface from scratch, and can be used to link with GSL when no other BLAS interface is required.

However, the program seems to require a library implementing the FORTRAN BLAS interface (-lblas). Typically, libraries such Netlib BLAS and OpenBLAS implement either the FORTRAN or C interface and provide a wrapper for the other language. In Netlib for instance, the CBLAS library simply forwards calls to the BLAS library functions.

The GLS library supports linking with external CBLAS implementations. In the case of Netlib BLAS the linking option will be,

PROJECT_LDFLAGS_BLAS=-lgsl -lcblas -lblas

and in the case of OpenBLAS

PROJECT_LDFLAGS_BLAS=-lgsl -lopenblas

since OpenBLAS implements all interfaces in one shared object.

Note that in the case of OpenBLAS, modifying the linking to options to something like

PROJECT_LDFLAGS_BLAS=-lopenblas -lgsl -lgslcblas 

which seems as the natural choice is particularly dangerous, since now 2 libraries provide the functions in CBLAS interface. In runtime either function can be loaded which can cause issues.

Is there any particular reason for linking with GSL CBLAS, or could it be removed and have a single library implementing BLAS (C and FORTRAN interfaces)?