diff options
-rw-r--r-- | CMakeLists.txt | 32 | ||||
-rw-r--r-- | cmake/Modules/FindCBLAS.cmake | 70 |
2 files changed, 93 insertions, 9 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 8316a49a..48aaefe9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,7 +66,7 @@ else () set(FLAGS "${FLAGS} -Wno-attributes -Wno-unused-variable") endif() elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") - set(FLAGS "${FLAGS} -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-padded") + set(FLAGS "${FLAGS} -Wall -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-padded") set(FLAGS "${FLAGS} -Wno-missing-prototypes -Wno-float-equal -Wno-switch-enum -Wno-switch") set(FLAGS "${FLAGS} -Wno-exit-time-destructors -Wno-global-constructors -Wno-missing-noreturn") endif() @@ -98,11 +98,13 @@ if(TUNERS) endif() endif() -# Locates the clBLAS library in case the tests need to be compiled. "FindclBLAS.cmake" is included. +# Locates the reference BLAS libraries in case the tests need to be compiled. The "FindclBLAS.cmake" +# and "FindCBLAS.cmake" are included. if(TESTS) find_package(clBLAS) - if(NOT CLBLAS_FOUND) - message(STATUS "Could NOT find clBLAS, disabling the compilation of the tests") + find_package(CBLAS) + if(NOT CLBLAS_FOUND AND NOT CBLAS_FOUND) + message(STATUS "Could NOT find clBLAS nor a CPU BLAS, disabling the compilation of the tests") set(TESTS OFF) endif() endif() @@ -215,11 +217,23 @@ endif() # ================================================================================================== # Down from here is all test (performance and correctness) related. Note that these tests require -# the presence of the clBLAS library to act as a reference. +# the presence of clBLAS and/or a BLAS library to act as a reference. if(TESTS) - # Adds new include directories for the reference clBLAS - include_directories(${clblast_SOURCE_DIR}/test ${CLBLAS_INCLUDE_DIRS}) + # Sets the specifics for the reference BLAS libraries + set(REF_INCLUDES ) + set(REF_LIBRARIES ) + if(CLBLAS_FOUND) + set(REF_INCLUDES ${REF_INCLUDES} ${CLBLAS_INCLUDE_DIRS}) + set(REF_LIBRARIES ${REF_LIBRARIES} ${CLBLAS_LIBRARIES}) + endif() + if(CBLAS_FOUND) + set(REF_INCLUDES ${REF_INCLUDES} ${CBLAS_INCLUDE_DIRS}) + set(REF_LIBRARIES ${REF_LIBRARIES} ${CBLAS_LIBRARIES}) + endif() + + # Sets the include directories + include_directories(${clblast_SOURCE_DIR}/test ${REF_INCLUDES}) # Creates the common correctness-tests objects (requires CMake 2.8.8) add_library(test_correctness_common OBJECT @@ -239,7 +253,7 @@ if(TESTS) test/correctness/routines/level3/${ROUTINE}.cc) endforeach() foreach(ROUTINE ${ROUTINES}) - target_link_libraries(clblast_test_${ROUTINE} clblast ${CLBLAS_LIBRARIES} ${OPENCL_LIBRARIES}) + target_link_libraries(clblast_test_${ROUTINE} clblast ${REF_LIBRARIES} ${OPENCL_LIBRARIES}) install(TARGETS clblast_test_${ROUTINE} DESTINATION bin) endforeach() @@ -269,7 +283,7 @@ if(TESTS) test/performance/routines/level3/${ROUTINE}.cc) endforeach() foreach(ROUTINE ${ROUTINES}) - target_link_libraries(clblast_client_${ROUTINE} clblast ${CLBLAS_LIBRARIES} ${OPENCL_LIBRARIES}) + target_link_libraries(clblast_client_${ROUTINE} clblast ${REF_LIBRARIES} ${OPENCL_LIBRARIES}) install(TARGETS clblast_client_${ROUTINE} DESTINATION bin) endforeach() diff --git a/cmake/Modules/FindCBLAS.cmake b/cmake/Modules/FindCBLAS.cmake new file mode 100644 index 00000000..16dce243 --- /dev/null +++ b/cmake/Modules/FindCBLAS.cmake @@ -0,0 +1,70 @@ + +# ================================================================================================== +# This file is part of the CLBlast project. The project is licensed under Apache Version 2.0. This +# project loosely follows the Google C++ styleguide and uses a tab-size of two spaces and a max- +# width of 100 characters per line. +# +# Author(s): +# Cedric Nugteren <www.cedricnugteren.nl> +# +# ================================================================================================== +# +# Defines the following variables: +# CBLAS_FOUND Boolean holding whether or not the Netlib BLAS library was found +# CBLAS_INCLUDE_DIRS The Netlib BLAS include directory +# CBLAS_LIBRARIES The Netlib BLAS library +# +# In case BLAS is not installed in the default directory, set the CBLAS_ROOT variable to point to +# the root of BLAS, such that 'cblas.h' can be found in $CBLAS_ROOT/include. This can either be +# done using an environmental variable (e.g. export CBLAS_ROOT=/path/to/BLAS) or using a CMake +# variable (e.g. cmake -DCBLAS_ROOT=/path/to/BLAS ..). +# +# ================================================================================================== + +# Sets the possible install locations +set(CBLAS_HINTS + ${CBLAS_ROOT} + $ENV{CBLAS_ROOT} +) +set(CBLAS_PATHS + /usr + /usr/local + /usr/local/opt + /System/Library/Frameworks +) + +# Finds the include directories +find_path(CBLAS_INCLUDE_DIRS + NAMES cblas.h + HINTS ${CBLAS_HINTS} + PATH_SUFFIXES include inc include/x86_64 include/x64 openblas/include + PATHS ${CBLAS_PATHS} + DOC "Netlib BLAS include header cblas.h" +) +mark_as_advanced(CBLAS_INCLUDE_DIRS) + +# Finds the library +find_library(CBLAS_LIBRARIES + NAMES blas openblas atlas mkl accelerate + HINTS ${CBLAS_HINTS} + PATH_SUFFIXES lib lib64 lib/x86_64 lib/x64 lib/x86 lib/Win32 lib/import lib64/import openblas/lib + PATHS ${CBLAS_PATHS} + DOC "Netlib BLAS library" +) +mark_as_advanced(CBLAS_LIBRARIES) + +# ================================================================================================== + +# Notification messages +if(NOT CBLAS_INCLUDE_DIRS) + message(STATUS "Could NOT find 'cblas.h', install a CPU Netlib BLAS or set CBLAS_ROOT") +endif() +if(NOT CBLAS_LIBRARIES) + message(STATUS "Could NOT find a CPU Netlib BLAS library, install it or set CBLAS_ROOT") +endif() + +# Determines whether or not BLAS was found +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(CBLAS DEFAULT_MSG CBLAS_INCLUDE_DIRS CBLAS_LIBRARIES) + +# ================================================================================================== |