Skip to content

Commit 8f3a426

Browse files
committed
added option to use only openblas, rather than both openblas and lapacke
1 parent db9cd7a commit 8f3a426

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

framework/CMakeLists.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,27 @@ elseif( ${SAF_PERFORMANCE_LIB} MATCHES "SAF_USE_OPEN_BLAS_AND_LAPACKE")
160160

161161
message(STATUS "Using OpenBLAS. Linking against: ${OPENBLAS_LIBRARY}; ${LAPACKE_LIBRARY}")
162162

163+
elseif( ${SAF_PERFORMANCE_LIB} MATCHES "SAF_USE_OPEN_BLAS")
164+
target_compile_definitions(${PROJECT_NAME} PUBLIC SAF_USE_OPEN_BLAS=1)
165+
166+
# find and link libraries
167+
if (NOT DEFINED OPENBLAS_LIBRARY)
168+
find_library(OPENBLAS_LIBRARY openblas HINTS /usr/lib/x86_64-linux-gnu /usr/lib/arm-linux-gnueabihf)
169+
endif()
170+
target_link_libraries(${PROJECT_NAME} PUBLIC ${OPENBLAS_LIBRARY})
171+
172+
# Add header search paths if they are defined
173+
if(DEFINED OPENBLAS_HEADER_PATH)
174+
target_include_directories(${PROJECT_NAME} PUBLIC ${OPENBLAS_HEADER_PATH})
175+
endif()
176+
177+
# Disable this particular warning... We know, but it's OK.
178+
if(UNIX)
179+
target_compile_options(${PROJECT_NAME} PRIVATE -Wno-incompatible-pointer-types)
180+
endif()
181+
182+
message(STATUS "Using OpenBLAS. Linking against: ${OPENBLAS_LIBRARY}")
183+
163184
elseif( ${SAF_PERFORMANCE_LIB} MATCHES "SAF_USE_ATLAS")
164185
message(STATUS "Using ATLAS...")
165186
message(SEND_ERROR "Not yet supported! Please contribute if you use this library.")

framework/include/saf_externals.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ extern "C" {
7878
#if (defined(SAF_USE_INTEL_MKL_LP64) + \
7979
defined(SAF_USE_INTEL_MKL_ILP64) + \
8080
defined(SAF_USE_OPEN_BLAS_AND_LAPACKE) + \
81+
defined(SAF_USE_OPEN_BLAS) + \
8182
defined(SAF_USE_ATLAS) + \
8283
defined(SAF_USE_GSL) + \
8384
defined(SAF_USE_APPLE_ACCELERATE)) != 1
@@ -144,6 +145,28 @@ extern "C" {
144145
# include "cblas.h"
145146
# include "lapacke.h"
146147

148+
#elif defined(SAF_USE_OPEN_BLAS)
149+
/*
150+
* Using OpenBLAS and the included LAPACK interface
151+
* (A decent option for both x86 and ARM based architectures)
152+
*
153+
* This option provides implementations of the CBLAS/LAPACK functions which have
154+
* decent performance. However, unlike Intel MKL or Apple Accelerate, it does
155+
* not offer an optimised DFT/FFT or any other linear algebra functions outside
156+
* of these standards. Therefore, consider also using Intel's IPP library or
157+
* FFTW for the DFT/FFT with: "SAF_USE_INTEL_IPP" or "SAF_USE_FFTW"
158+
*
159+
* Note that "SAF_USE_INTEL_IPP" also offers support for certain linear algebra
160+
* operations not covered by the CBLAS/LAPACK standards, which SAF can leverage.
161+
*
162+
* Alternatively, SSE/AVX/AVX-512 fallback implementations for certain linear
163+
* algebra operations may be enabled with: "SAF_ENABLE_SIMD"
164+
*
165+
* More information regarding these additional options can be found below.
166+
*/
167+
# include "cblas.h"
168+
# include "lapack.h"
169+
147170
#elif defined(SAF_USE_ATLAS)
148171
/*
149172
* Using the Automatically Tuned Linear Algebra Software (ATLAS) library
@@ -311,6 +334,8 @@ extern "C" {
311334
# define SAF_CURRENT_PERFORMANCE_LIBRARY_STRING "Intel MKL (ILP64)"
312335
#elif defined(SAF_USE_OPEN_BLAS_AND_LAPACKE)
313336
# define SAF_CURRENT_PERFORMANCE_LIBRARY_STRING "OpenBLAS with LAPACKE"
337+
#elif defined(SAF_USE_OPEN_BLAS)
338+
# define SAF_CURRENT_PERFORMANCE_LIBRARY_STRING "OpenBLAS"
314339
#elif defined(SAF_USE_ATLAS)
315340
# define SAF_CURRENT_PERFORMANCE_LIBRARY_STRING "ATLAS"
316341
#elif defined(__APPLE__) && defined(SAF_USE_APPLE_ACCELERATE)

framework/modules/saf_utilities/saf_utility_veclib.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
# define SAF_VECLIB_USE_LAPACKE_INTERFACE /**< LAPACK interface */
5858
#elif defined(SAF_USE_OPEN_BLAS_AND_LAPACKE)
5959
# define SAF_VECLIB_USE_LAPACKE_INTERFACE /**< LAPACK interface */
60+
#elif defined(SAF_USE_OPEN_BLAS)
61+
# define SAF_VECLIB_USE_LAPACK_FORTRAN_INTERFACE /**< LAPACK interface */
6062
#elif defined(SAF_USE_ATLAS)
6163
# define SAF_VECLIB_USE_CLAPACK_INTERFACE /**< LAPACK interface */
6264
#elif defined(__APPLE__) && defined(SAF_USE_APPLE_ACCELERATE)

0 commit comments

Comments
 (0)