summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG1
-rw-r--r--CMakeLists.txt21
-rw-r--r--cmake/Modules/FindCBLAS.cmake2
-rw-r--r--cmake/Modules/FindMKL.cmake72
-rw-r--r--test/wrapper_cblas.hpp6
5 files changed, 95 insertions, 7 deletions
diff --git a/CHANGELOG b/CHANGELOG
index c86ab70b..70ebfd3a 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -9,6 +9,7 @@ Development (next version)
- The routine tuners now automatically pick up tuning results from disk from the kernel tuners
- Updated and reorganised the CLBlast documentation
- Added a 'canary' region to check for overflows in the tuner and tests (insipred by clARMOR)
+- Added an option to test against and compare performance with Intel's MKL
- Fixed an access violation when compiled with Visual Studio upon releasing the OpenCL program
- Fixed incorrect releasing of the OpenCL program resulting in segfaults / access violations
- Various minor fixes and enhancements
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ea306bc5..4216dea9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -170,16 +170,17 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL Android)
else()
# Locates the reference BLAS libraries in case the tests need to be compiled. The "FindclBLAS.cmake",
- # "FindCBLAS.cmake" and "FindcuBLAS.cmake" are included.
+ # "FindCBLAS.cmake", "FindMKL.cmake", and "FindcuBLAS.cmake" are included.
if(CLIENTS OR TESTS)
find_package(CBLAS)
+ find_package(MKL)
if(OPENCL)
find_package(clBLAS)
endif()
if(CUBLAS)
find_package(cuBLAS)
endif()
- if(NOT CLBLAS_FOUND AND NOT CBLAS_FOUND)
+ if(NOT CLBLAS_FOUND AND NOT CBLAS_FOUND AND NOT MKL_FOUND)
if(TESTS)
message(STATUS "Could NOT find clBLAS nor a CPU BLAS, disabling the compilation of the tests")
set(TESTS OFF)
@@ -468,9 +469,19 @@ if(CLIENTS OR TESTS)
add_definitions(" -DCLBLAST_REF_CLBLAS")
endif()
endif()
- if(CBLAS_FOUND)
- set(REF_INCLUDES ${REF_INCLUDES} ${CBLAS_INCLUDE_DIRS})
- set(REF_LIBRARIES ${REF_LIBRARIES} ${CBLAS_LIBRARIES})
+ if(CBLAS_FOUND OR MKL_FOUND)
+ if(MKL_FOUND) # prefers MKL over another CBLAS implementation
+ set(REF_INCLUDES ${REF_INCLUDES} ${MKL_INCLUDE_DIRS})
+ set(REF_LIBRARIES ${REF_LIBRARIES} ${MKL_LIBRARIES})
+ if(MSVC)
+ add_definitions(" /DCLBLAST_REF_CBLAS_MKL")
+ else()
+ add_definitions(" -DCLBLAST_REF_CBLAS_MKL")
+ endif()
+ else()
+ set(REF_INCLUDES ${REF_INCLUDES} ${CBLAS_INCLUDE_DIRS})
+ set(REF_LIBRARIES ${REF_LIBRARIES} ${CBLAS_LIBRARIES})
+ endif()
set(WRAPPERS ${WRAPPERS} test/wrapper_cblas.hpp)
if(MSVC)
add_definitions(" /DCLBLAST_REF_CBLAS")
diff --git a/cmake/Modules/FindCBLAS.cmake b/cmake/Modules/FindCBLAS.cmake
index 1439bfcb..fa97ce9f 100644
--- a/cmake/Modules/FindCBLAS.cmake
+++ b/cmake/Modules/FindCBLAS.cmake
@@ -48,7 +48,7 @@ mark_as_advanced(CBLAS_INCLUDE_DIRS)
# Finds the library
find_library(CBLAS_LIBRARIES
- NAMES cblas blas mkl blis openblas accelerate
+ NAMES cblas blas blis openblas accelerate
HINTS ${CBLAS_HINTS}
PATH_SUFFIXES
lib lib64 lib/x86_64 lib/x64 lib/x86 lib/Win32 lib/import lib64/import
diff --git a/cmake/Modules/FindMKL.cmake b/cmake/Modules/FindMKL.cmake
new file mode 100644
index 00000000..df481a4d
--- /dev/null
+++ b/cmake/Modules/FindMKL.cmake
@@ -0,0 +1,72 @@
+
+# ==================================================================================================
+# 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:
+# MKL_FOUND Boolean holding whether or not the Intel MKL BLAS library was found
+# MKL_INCLUDE_DIRS The Intel MKL BLAS include directory
+# MKL_LIBRARIES The Intel MKL BLAS library
+#
+# In case MKL is not installed in the default directory, set the MKL_ROOT variable to point to
+# the root of MKL, such that 'mkl_cblas.h' can be found in $MKL_ROOT/include. This can either be
+# done using an environmental variable (e.g. export MKL_ROOT=/path/to/MKL) or using a CMake
+# variable (e.g. cmake -DMKL_ROOT=/path/to/MKL ..).
+#
+# ==================================================================================================
+
+# Sets the possible install locations
+set(MKL_HINTS
+ ${MKL_ROOT}
+ $ENV{MKL_ROOT}
+)
+set(MKL_PATHS
+ /usr
+ /usr/local
+ /usr/local/opt
+ /usr/local/mkl
+ /opt/intel
+ /opt/intel/mkl
+)
+
+# Finds the include directories
+find_path(MKL_INCLUDE_DIRS
+ NAMES mkl_cblas.h
+ HINTS ${MKL_HINTS}
+ PATH_SUFFIXES
+ include inc include/x86_64 include/x64
+ PATHS ${MKL_PATHS}
+ DOC "Intel MKL CBLAS include header mkl_cblas.h"
+)
+mark_as_advanced(MKL_INCLUDE_DIRS)
+
+# Finds the libraries
+set(MKL_LIB_SUFFIXES lib lib64 lib/x86_64 lib/x64 lib/x86 lib/Win32 lib/import lib64/import lib/intel64)
+find_library(MKL_LIBRARIES_LP64 NAMES mkl_intel_lp64 HINTS ${MKL_HINTS} PATH_SUFFIXES ${MKL_LIB_SUFFIXES} PATHS ${MKL_PATHS} DOC "Intel MKL lp64 library")
+find_library(MKL_LIBRARIES_THREAD NAMES mkl_intel_thread HINTS ${MKL_HINTS} PATH_SUFFIXES ${MKL_LIB_SUFFIXES} PATHS ${MKL_PATHS} DOC "Intel MKL thread library")
+find_library(MKL_LIBRARIES_CORE NAMES mkl_core HINTS ${MKL_HINTS} PATH_SUFFIXES ${MKL_LIB_SUFFIXES} PATHS ${MKL_PATHS} DOC "Intel MKL core library")
+find_library(MKL_LIBRARIES_OMP NAMES iomp5 HINTS ${MKL_HINTS} PATH_SUFFIXES ${MKL_LIB_SUFFIXES} PATHS ${MKL_PATHS} DOC "Intel OpenMP library")
+set(MKL_LIBRARIES ${MKL_LIBRARIES_LP64} ${MKL_LIBRARIES_THREAD} ${MKL_LIBRARIES_CORE} ${MKL_LIBRARIES_OMP})
+mark_as_advanced(MKL_LIBRARIES)
+
+# ==================================================================================================
+
+# Notification messages
+if(NOT MKL_INCLUDE_DIRS)
+ message(STATUS "Could NOT find 'mkl_cblas.h', install MKL or set MKL_ROOT")
+endif()
+if(NOT MKL_LIBRARIES)
+ message(STATUS "Could NOT find the Intel MKL BLAS library, install it or set MKL_ROOT")
+endif()
+
+# Determines whether or not MKL was found
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(MKL DEFAULT_MSG MKL_INCLUDE_DIRS MKL_LIBRARIES)
+
+# ==================================================================================================
diff --git a/test/wrapper_cblas.hpp b/test/wrapper_cblas.hpp
index 408f084b..a47ff725 100644
--- a/test/wrapper_cblas.hpp
+++ b/test/wrapper_cblas.hpp
@@ -17,7 +17,11 @@
extern "C"
{
- #include <cblas.h>
+ #ifdef CLBLAST_REF_CBLAS_MKL
+ #include <mkl_cblas.h>
+ #else
+ #include <cblas.h>
+ #endif
}
#include "utilities/utilities.hpp"