2015-05-30 12:30:43 +02:00
|
|
|
|
|
|
|
# ==================================================================================================
|
|
|
|
# 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>
|
|
|
|
#
|
|
|
|
# ==================================================================================================
|
|
|
|
|
2016-06-30 10:49:17 +02:00
|
|
|
cmake_minimum_required(VERSION 2.8.11)
|
2016-05-18 21:32:56 +02:00
|
|
|
|
|
|
|
# Overrides for MSVC static runtime
|
|
|
|
set(CMAKE_USER_MAKE_RULES_OVERRIDE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/c_flag_overrides.cmake)
|
|
|
|
set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cxx_flag_overrides.cmake)
|
|
|
|
|
|
|
|
# CMake project details
|
2015-08-13 13:46:13 +02:00
|
|
|
project("clblast" C CXX)
|
2015-05-30 12:30:43 +02:00
|
|
|
set(clblast_VERSION_MAJOR 0)
|
2016-11-27 13:34:18 +01:00
|
|
|
set(clblast_VERSION_MINOR 10)
|
2016-06-28 21:32:00 +02:00
|
|
|
set(clblast_VERSION_PATCH 0)
|
2015-05-30 12:30:43 +02:00
|
|
|
|
|
|
|
# Options and their default values
|
2016-10-15 17:11:08 +02:00
|
|
|
option(BUILD_SHARED_LIBS "Build a shared (ON) or static library (OFF)" ON)
|
2015-05-30 12:30:43 +02:00
|
|
|
option(SAMPLES "Enable compilation of the examples" OFF)
|
|
|
|
option(TUNERS "Enable compilation of the tuners" OFF)
|
2016-05-30 16:38:26 +02:00
|
|
|
option(CLIENTS "Enable compilation of the clients to test and compare performance" OFF)
|
|
|
|
option(TESTS "Enable compilation of the correctness tests" OFF)
|
2016-11-23 21:33:35 +01:00
|
|
|
option(NETLIB "Enable compilation of the CBLAS Netlib API" OFF)
|
2015-05-30 12:30:43 +02:00
|
|
|
|
2016-07-06 21:50:12 +02:00
|
|
|
# Compile in verbose mode with additional diagnostic messages
|
|
|
|
option(VERBOSE "Compile in verbose mode for additional diagnostic messages" OFF)
|
|
|
|
if(VERBOSE)
|
|
|
|
message("-- Building in verbose mode")
|
|
|
|
add_definitions(-DVERBOSE)
|
|
|
|
endif()
|
|
|
|
|
2015-05-30 12:30:43 +02:00
|
|
|
# ==================================================================================================
|
|
|
|
|
|
|
|
# RPATH settings
|
2016-06-06 13:40:52 +02:00
|
|
|
set(CMAKE_MACOSX_RPATH 1)
|
2015-05-30 12:30:43 +02:00
|
|
|
|
|
|
|
# ==================================================================================================
|
|
|
|
|
|
|
|
# Compiler-version check (requires at least CMake 2.8.10)
|
2016-05-18 21:32:56 +02:00
|
|
|
if(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
|
|
|
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
|
2015-05-30 12:30:43 +02:00
|
|
|
message(FATAL_ERROR "GCC version must be at least 4.7")
|
|
|
|
endif()
|
2016-05-18 21:32:56 +02:00
|
|
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang)
|
|
|
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.3)
|
2015-05-30 12:30:43 +02:00
|
|
|
message(FATAL_ERROR "Clang version must be at least 3.3")
|
|
|
|
endif()
|
2016-05-18 21:32:56 +02:00
|
|
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL AppleClang)
|
|
|
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
|
2015-05-30 12:30:43 +02:00
|
|
|
message(FATAL_ERROR "AppleClang version must be at least 5.0")
|
|
|
|
endif()
|
2016-05-18 21:32:56 +02:00
|
|
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL Intel)
|
|
|
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14.0)
|
2015-05-30 12:30:43 +02:00
|
|
|
message(FATAL_ERROR "ICC version must be at least 14.0")
|
|
|
|
endif()
|
2016-05-18 21:32:56 +02:00
|
|
|
elseif(MSVC)
|
|
|
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18.0)
|
2015-05-30 12:30:43 +02:00
|
|
|
message(FATAL_ERROR "MS Visual Studio version must be at least 18.0")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2016-10-15 00:45:34 +02:00
|
|
|
# DLL Settings
|
|
|
|
if(MSVC)
|
|
|
|
if(BUILD_SHARED_LIBS)
|
|
|
|
add_definitions(" /DCLBLAST_DLL")
|
2016-10-22 16:38:42 +02:00
|
|
|
endif()
|
2016-10-15 00:45:34 +02:00
|
|
|
endif(MSVC)
|
|
|
|
|
2015-05-30 12:30:43 +02:00
|
|
|
# C++ compiler settings
|
2016-05-18 21:32:56 +02:00
|
|
|
if(MSVC)
|
2016-01-30 11:54:29 +01:00
|
|
|
set(FLAGS "/Ox")
|
2016-01-30 14:57:49 +01:00
|
|
|
set(FLAGS "${FLAGS} /wd4715")
|
2016-05-18 21:32:56 +02:00
|
|
|
else()
|
2016-10-14 20:54:05 +02:00
|
|
|
set(FLAGS "-std=c++11")
|
|
|
|
if(VERBOSE)
|
|
|
|
set(FLAGS "${FLAGS} -O1 -g")
|
|
|
|
else()
|
|
|
|
set(FLAGS "${FLAGS} -O3")
|
|
|
|
endif()
|
2016-05-18 21:32:56 +02:00
|
|
|
if(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
|
2016-01-30 11:54:29 +01:00
|
|
|
set(FLAGS "${FLAGS} -Wall -Wno-comment -Wno-return-type -Wno-switch -Wno-missing-noreturn")
|
2016-05-18 21:32:56 +02:00
|
|
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9.0)
|
2016-01-30 11:54:29 +01:00
|
|
|
set(FLAGS "${FLAGS} -Wno-attributes -Wno-unused-variable")
|
|
|
|
endif()
|
2016-09-13 15:12:30 +02:00
|
|
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 6.0.0)
|
|
|
|
# GCC does not support attributes on template arguments
|
|
|
|
# in particular we hit this with the alignment attributes on cl_XXX types
|
|
|
|
# which are then used to instantiate various templates in CLBlast
|
|
|
|
set(FLAGS "${FLAGS} -Wno-ignored-attributes")
|
|
|
|
endif()
|
2016-05-18 21:32:56 +02:00
|
|
|
elseif(CMAKE_CXX_COMPILER_ID MATCHES Clang)
|
2016-04-04 17:39:13 +02:00
|
|
|
set(FLAGS "${FLAGS} -Wextra -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-padded")
|
2016-01-30 11:54:29 +01:00
|
|
|
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")
|
2016-04-04 17:39:13 +02:00
|
|
|
set(FLAGS "${FLAGS} -Wno-deprecated-declarations")
|
2015-05-30 12:30:43 +02:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAGS}")
|
|
|
|
|
2016-03-23 20:31:25 +01:00
|
|
|
# C compiler settings (for the sample)
|
2016-05-18 21:32:56 +02:00
|
|
|
if(MSVC)
|
2016-03-23 20:31:25 +01:00
|
|
|
set(CFLAGS "/Ox")
|
2016-05-18 21:32:56 +02:00
|
|
|
else()
|
2016-03-23 20:31:25 +01:00
|
|
|
set(CFLAGS "-O3 -std=c99")
|
|
|
|
endif()
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CFLAGS}")
|
|
|
|
|
2015-05-30 12:30:43 +02:00
|
|
|
# ==================================================================================================
|
|
|
|
|
|
|
|
# Package scripts location
|
2016-07-07 04:07:59 +02:00
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${clblast_SOURCE_DIR}/cmake/Modules/")
|
2015-05-30 12:30:43 +02:00
|
|
|
|
|
|
|
# Requires OpenCL. It is found through the included "FindOpenCL.cmake" in CMAKE_MODULE_PATH.
|
|
|
|
find_package(OpenCL REQUIRED)
|
|
|
|
|
|
|
|
# Locates the CLTune library in case the tuners need to be compiled. "FindCLTune.cmake" is included.
|
|
|
|
if(TUNERS)
|
|
|
|
find_package(CLTune)
|
|
|
|
if(NOT CLTUNE_FOUND)
|
|
|
|
message(STATUS "Could NOT find CLTune, disabling the compilation of the tuners")
|
|
|
|
set(TUNERS OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2016-04-01 07:22:29 +02:00
|
|
|
# Locates the reference BLAS libraries in case the tests need to be compiled. The "FindclBLAS.cmake"
|
|
|
|
# and "FindCBLAS.cmake" are included.
|
2016-05-30 16:38:26 +02:00
|
|
|
if(CLIENTS OR TESTS)
|
2015-07-31 11:06:07 +02:00
|
|
|
find_package(clBLAS)
|
2016-04-01 07:22:29 +02:00
|
|
|
find_package(CBLAS)
|
|
|
|
if(NOT CLBLAS_FOUND AND NOT CBLAS_FOUND)
|
2016-05-30 16:38:26 +02:00
|
|
|
if(TESTS)
|
|
|
|
message(STATUS "Could NOT find clBLAS nor a CPU BLAS, disabling the compilation of the tests")
|
|
|
|
set(TESTS OFF)
|
|
|
|
endif()
|
|
|
|
if(CLIENTS)
|
|
|
|
message(STATUS "Could NOT find clBLAS nor a CPU BLAS, head-to-head performance comparison not supported in the clients")
|
|
|
|
endif()
|
2015-07-31 11:06:07 +02:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2015-05-30 12:30:43 +02:00
|
|
|
# ==================================================================================================
|
|
|
|
|
|
|
|
# Sets the supported routines and the used kernels. New routines and kernels should be added here.
|
2016-09-25 14:48:34 +02:00
|
|
|
set(KERNELS copy_fast copy_pad transpose_fast transpose_pad xaxpy xdot xger
|
|
|
|
xgemm xgemm_direct xgemv)
|
2015-08-13 13:47:15 +02:00
|
|
|
set(SAMPLE_PROGRAMS_CPP sgemm)
|
2016-11-23 22:07:11 +01:00
|
|
|
set(SAMPLE_PROGRAMS_C sasum dgemv sgemm haxpy cache)
|
|
|
|
if(NETLIB)
|
|
|
|
set(SAMPLE_PROGRAMS_C ${SAMPLE_PROGRAMS_C} sgemm_netlib)
|
|
|
|
endif()
|
2016-04-21 06:12:51 +02:00
|
|
|
set(LEVEL1_ROUTINES xswap xscal xcopy xaxpy xdot xdotu xdotc xnrm2 xasum xamax)
|
2016-02-20 14:15:41 +01:00
|
|
|
set(LEVEL2_ROUTINES xgemv xgbmv xhemv xhbmv xhpmv xsymv xsbmv xspmv xtrmv xtbmv xtpmv
|
2016-03-06 15:48:11 +01:00
|
|
|
xger xgeru xgerc xher xhpr xher2 xhpr2 xsyr xspr xsyr2 xspr2)
|
2015-07-12 16:57:09 +02:00
|
|
|
set(LEVEL3_ROUTINES xgemm xsymm xhemm xsyrk xherk xsyr2k xher2k xtrmm)
|
2016-06-16 18:07:46 +02:00
|
|
|
set(LEVELX_ROUTINES xomatcopy)
|
|
|
|
set(ROUTINES ${LEVEL1_ROUTINES} ${LEVEL2_ROUTINES} ${LEVEL3_ROUTINES} ${LEVELX_ROUTINES})
|
2016-06-27 11:46:33 +02:00
|
|
|
set(PRECISIONS 32 64 3232 6464 16)
|
2015-05-30 12:30:43 +02:00
|
|
|
|
|
|
|
# ==================================================================================================
|
|
|
|
|
|
|
|
# Gathers all source-files
|
2016-06-18 20:20:13 +02:00
|
|
|
set(SOURCES
|
2016-06-19 13:55:49 +02:00
|
|
|
src/database/database.cpp
|
|
|
|
src/routines/common.cpp
|
2016-10-22 15:36:48 +02:00
|
|
|
src/utilities/clblast_exceptions.cpp
|
|
|
|
src/utilities/utilities.cpp
|
2016-06-19 13:55:49 +02:00
|
|
|
src/cache.cpp
|
|
|
|
src/clblast.cpp
|
|
|
|
src/clblast_c.cpp
|
|
|
|
src/routine.cpp
|
2016-06-18 20:20:13 +02:00
|
|
|
)
|
2016-11-23 21:33:35 +01:00
|
|
|
if(NETLIB)
|
|
|
|
set(SOURCES ${SOURCES} src/clblast_netlib_c.cpp)
|
|
|
|
endif()
|
2015-07-12 16:57:09 +02:00
|
|
|
foreach(ROUTINE ${LEVEL1_ROUTINES})
|
2016-06-19 13:55:49 +02:00
|
|
|
set(SOURCES ${SOURCES} src/routines/level1/${ROUTINE}.cpp)
|
2015-07-12 16:57:09 +02:00
|
|
|
endforeach()
|
|
|
|
foreach(ROUTINE ${LEVEL2_ROUTINES})
|
2016-06-19 13:55:49 +02:00
|
|
|
set(SOURCES ${SOURCES} src/routines/level2/${ROUTINE}.cpp)
|
2015-07-12 16:57:09 +02:00
|
|
|
endforeach()
|
|
|
|
foreach(ROUTINE ${LEVEL3_ROUTINES})
|
2016-06-19 13:55:49 +02:00
|
|
|
set(SOURCES ${SOURCES} src/routines/level3/${ROUTINE}.cpp)
|
2015-05-30 12:30:43 +02:00
|
|
|
endforeach()
|
2016-06-16 18:07:46 +02:00
|
|
|
foreach(ROUTINE ${LEVELX_ROUTINES})
|
2016-06-19 13:55:49 +02:00
|
|
|
set(SOURCES ${SOURCES} src/routines/levelx/${ROUTINE}.cpp)
|
2016-06-16 18:07:46 +02:00
|
|
|
endforeach()
|
2015-05-30 12:30:43 +02:00
|
|
|
|
|
|
|
# Creates and links the library
|
2016-10-13 18:03:44 +02:00
|
|
|
if(BUILD_SHARED_LIBS)
|
|
|
|
add_library(clblast SHARED ${SOURCES})
|
|
|
|
else(BUILD_SHARED_LIBS)
|
|
|
|
add_library(clblast STATIC ${SOURCES})
|
2016-10-22 16:38:42 +02:00
|
|
|
endif()
|
2016-10-13 18:03:44 +02:00
|
|
|
|
2015-05-30 12:30:43 +02:00
|
|
|
target_link_libraries(clblast ${OPENCL_LIBRARIES})
|
|
|
|
|
2016-07-24 18:10:39 +02:00
|
|
|
# Includes directories: CLBlast and OpenCL
|
|
|
|
target_include_directories(clblast PUBLIC
|
|
|
|
$<BUILD_INTERFACE:${clblast_SOURCE_DIR}/include>
|
|
|
|
$<BUILD_INTERFACE:${clblast_SOURCE_DIR}/src>
|
|
|
|
$<INSTALL_INTERFACE:include>
|
|
|
|
${OPENCL_INCLUDE_DIRS})
|
|
|
|
|
2016-06-30 10:49:17 +02:00
|
|
|
# Sets the proper __declspec(dllexport) keyword for Visual Studio when the library is built
|
|
|
|
if(MSVC)
|
2016-10-15 00:45:34 +02:00
|
|
|
if(BUILD_SHARED_LIBS)
|
|
|
|
target_compile_definitions(clblast PRIVATE COMPILING_DLL=1) # requires at least CMake 2.8.11
|
2016-10-22 16:38:42 +02:00
|
|
|
endif()
|
2016-06-30 10:49:17 +02:00
|
|
|
endif()
|
|
|
|
|
2015-05-30 12:30:43 +02:00
|
|
|
# Installs the library
|
2016-07-24 18:10:39 +02:00
|
|
|
install(TARGETS clblast EXPORT CLBlast DESTINATION lib)
|
2015-05-30 12:30:43 +02:00
|
|
|
install(FILES include/clblast.h DESTINATION include)
|
2015-08-13 13:46:13 +02:00
|
|
|
install(FILES include/clblast_c.h DESTINATION include)
|
2016-05-15 20:13:57 +02:00
|
|
|
install(FILES include/clblast_half.h DESTINATION include)
|
2016-11-23 21:33:35 +01:00
|
|
|
if(NETLIB)
|
|
|
|
install(FILES include/clblast_netlib_c.h DESTINATION include)
|
|
|
|
endif()
|
2015-05-30 12:30:43 +02:00
|
|
|
|
2016-07-24 18:10:39 +02:00
|
|
|
# Installs the config for find_package in dependent projects
|
|
|
|
install(EXPORT CLBlast DESTINATION lib/cmake/CLBLast FILE CLBlastConfig.cmake)
|
|
|
|
|
2016-10-21 09:38:25 +02:00
|
|
|
# Install pkg-config file on Linux
|
|
|
|
if(UNIX)
|
2016-10-22 15:36:48 +02:00
|
|
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/clblast.pc.in"
|
2016-10-21 09:38:25 +02:00
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/clblast.pc" @ONLY IMMEDIATE)
|
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/clblast.pc
|
|
|
|
DESTINATION lib/pkgconfig)
|
|
|
|
endif()
|
|
|
|
|
2015-05-30 12:30:43 +02:00
|
|
|
# ==================================================================================================
|
|
|
|
|
|
|
|
# This section contains all the code related to the examples
|
|
|
|
if(SAMPLES)
|
|
|
|
|
2016-03-31 01:24:38 +02:00
|
|
|
# Downloads the cl.hpp file from Khronos
|
2017-01-07 13:57:23 +01:00
|
|
|
file(DOWNLOAD https://www.khronos.org/registry/OpenCL/api/2.1/cl.hpp ${clblast_SOURCE_DIR}/samples/cl.hpp)
|
2016-03-31 01:24:38 +02:00
|
|
|
|
2015-08-13 13:47:15 +02:00
|
|
|
# Adds sample programs (C++)
|
|
|
|
foreach(SAMPLE ${SAMPLE_PROGRAMS_CPP})
|
2016-06-19 13:55:49 +02:00
|
|
|
add_executable(clblast_sample_${SAMPLE} samples/${SAMPLE}.cpp)
|
2015-08-21 07:36:19 +02:00
|
|
|
target_link_libraries(clblast_sample_${SAMPLE} clblast ${OPENCL_LIBRARIES})
|
|
|
|
install(TARGETS clblast_sample_${SAMPLE} DESTINATION bin)
|
2015-05-30 12:30:43 +02:00
|
|
|
endforeach()
|
|
|
|
|
2015-08-13 13:47:15 +02:00
|
|
|
# Adds sample programs (C)
|
|
|
|
foreach(SAMPLE ${SAMPLE_PROGRAMS_C})
|
2015-08-21 07:36:19 +02:00
|
|
|
add_executable(clblast_sample_${SAMPLE}_c samples/${SAMPLE}.c)
|
|
|
|
target_link_libraries(clblast_sample_${SAMPLE}_c clblast ${OPENCL_LIBRARIES})
|
|
|
|
install(TARGETS clblast_sample_${SAMPLE}_c DESTINATION bin)
|
2015-08-13 13:47:15 +02:00
|
|
|
endforeach()
|
|
|
|
|
2015-05-30 12:30:43 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# ==================================================================================================
|
|
|
|
|
|
|
|
# This section contains all the code related to the tuners. These tuners require the presence of
|
|
|
|
# the CLTune library (not included as part of the source).
|
|
|
|
if(TUNERS)
|
|
|
|
|
2016-07-04 19:46:14 +02:00
|
|
|
# Visual Studio requires the sources of non-exported objects/libraries
|
|
|
|
set(TUNERS_COMMON )
|
|
|
|
if(MSVC)
|
2016-10-23 14:34:46 +02:00
|
|
|
set(TUNERS_COMMON ${TUNERS_COMMON} src/utilities/utilities.cpp)
|
2016-07-04 19:46:14 +02:00
|
|
|
endif()
|
|
|
|
|
2015-05-30 12:30:43 +02:00
|
|
|
# Adds tuning executables
|
|
|
|
foreach(KERNEL ${KERNELS})
|
2016-07-04 19:46:14 +02:00
|
|
|
add_executable(clblast_tuner_${KERNEL} ${TUNERS_COMMON} src/tuning/kernels/${KERNEL}.cpp)
|
2015-08-21 07:36:19 +02:00
|
|
|
target_link_libraries(clblast_tuner_${KERNEL} clblast ${CLTUNE_LIBRARIES} ${OPENCL_LIBRARIES})
|
2016-07-28 16:53:54 +02:00
|
|
|
target_include_directories(clblast_tuner_${KERNEL} PUBLIC ${CLTUNE_INCLUDE_DIRS})
|
2015-08-21 07:36:19 +02:00
|
|
|
install(TARGETS clblast_tuner_${KERNEL} DESTINATION bin)
|
2015-05-30 12:30:43 +02:00
|
|
|
endforeach()
|
|
|
|
|
2015-08-19 19:35:56 +02:00
|
|
|
# Adds 'alltuners' target: runs all tuners for all precisions
|
|
|
|
set(ALLTUNERS )
|
|
|
|
set(ALLTUNERSDEPENDS )
|
|
|
|
foreach(KERNEL ${KERNELS})
|
|
|
|
foreach(PRECISION ${PRECISIONS})
|
2016-11-27 11:00:29 +01:00
|
|
|
set(ALLTUNERS ${ALLTUNERS} COMMAND clblast_tuner_${KERNEL} -precision ${PRECISION})
|
2015-08-19 19:35:56 +02:00
|
|
|
endforeach()
|
2015-08-21 07:36:19 +02:00
|
|
|
set(ALLTUNERSDEPENDS clblast_tuner_${KERNEL})
|
2015-08-19 19:35:56 +02:00
|
|
|
endforeach()
|
|
|
|
add_custom_target(alltuners ${ALLTUNERS} DEPENDS ${ALLTUNERSDEPENDS})
|
|
|
|
|
2015-05-30 12:30:43 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# ==================================================================================================
|
|
|
|
|
2016-05-30 16:38:26 +02:00
|
|
|
# Section for the tests: common part for both performance ('CLIENTS') and correctness ('TESTS')
|
|
|
|
if(CLIENTS OR TESTS)
|
2015-05-30 12:30:43 +02:00
|
|
|
|
2016-04-01 07:22:29 +02:00
|
|
|
# Sets the specifics for the reference BLAS libraries
|
|
|
|
set(REF_INCLUDES )
|
|
|
|
set(REF_LIBRARIES )
|
|
|
|
if(CLBLAS_FOUND)
|
2016-09-26 23:04:28 +02:00
|
|
|
find_package(Threads)
|
|
|
|
set(REF_LIBRARIES ${REF_LIBRARIES} ${CLBLAS_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
|
2016-04-01 07:22:29 +02:00
|
|
|
set(REF_INCLUDES ${REF_INCLUDES} ${CLBLAS_INCLUDE_DIRS})
|
2016-10-23 14:34:46 +02:00
|
|
|
if(MSVC)
|
2016-04-02 20:58:00 +02:00
|
|
|
add_definitions(" /DCLBLAST_REF_CLBLAS")
|
|
|
|
else()
|
|
|
|
add_definitions(" -DCLBLAST_REF_CLBLAS")
|
|
|
|
endif()
|
2016-04-01 07:22:29 +02:00
|
|
|
endif()
|
|
|
|
if(CBLAS_FOUND)
|
|
|
|
set(REF_INCLUDES ${REF_INCLUDES} ${CBLAS_INCLUDE_DIRS})
|
|
|
|
set(REF_LIBRARIES ${REF_LIBRARIES} ${CBLAS_LIBRARIES})
|
2016-10-23 14:34:46 +02:00
|
|
|
if(MSVC)
|
2016-04-02 20:58:00 +02:00
|
|
|
add_definitions(" /DCLBLAST_REF_CBLAS")
|
|
|
|
else()
|
|
|
|
add_definitions(" -DCLBLAST_REF_CBLAS")
|
|
|
|
endif()
|
2016-04-01 07:22:29 +02:00
|
|
|
endif()
|
|
|
|
|
2016-05-30 16:38:26 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# ==================================================================================================
|
|
|
|
|
|
|
|
# Section for the performance tests (i.e. the client). These compare against optionally a reference
|
|
|
|
# library, either clBLAS or a CPU BLAS.
|
|
|
|
if(CLIENTS)
|
|
|
|
|
2016-06-28 16:38:45 +02:00
|
|
|
# Visual Studio requires the sources of non-exported objects/libraries
|
|
|
|
set(CLIENTS_COMMON )
|
|
|
|
if(MSVC)
|
2016-10-23 14:34:46 +02:00
|
|
|
set(CLIENTS_COMMON ${CLIENTS_COMMON} src/utilities/utilities.cpp test/performance/client.cpp)
|
2016-06-28 16:38:45 +02:00
|
|
|
else()
|
|
|
|
# Creates the common performance-tests objects (requires CMake 2.8.8)
|
|
|
|
add_library(test_performance_common OBJECT test/performance/client.cpp)
|
2016-07-28 20:45:09 +02:00
|
|
|
|
|
|
|
# Adds CLBlast's interface include paths because we can't link to CLBlast here
|
2016-07-28 16:53:54 +02:00
|
|
|
target_include_directories(test_performance_common PRIVATE
|
|
|
|
$<TARGET_PROPERTY:clblast,INTERFACE_INCLUDE_DIRECTORIES>
|
2016-10-14 22:11:35 +02:00
|
|
|
${clblast_SOURCE_DIR} ${REF_INCLUDES})
|
2016-06-28 16:38:45 +02:00
|
|
|
set(CLIENTS_COMMON ${CLIENTS_COMMON} $<TARGET_OBJECTS:test_performance_common>)
|
|
|
|
endif()
|
2016-05-30 16:38:26 +02:00
|
|
|
|
|
|
|
# Compiles the performance-tests
|
|
|
|
foreach(ROUTINE ${LEVEL1_ROUTINES})
|
2016-06-28 16:38:45 +02:00
|
|
|
add_executable(clblast_client_${ROUTINE} ${CLIENTS_COMMON}
|
2016-06-19 13:55:49 +02:00
|
|
|
test/performance/routines/level1/${ROUTINE}.cpp)
|
2016-05-30 16:38:26 +02:00
|
|
|
endforeach()
|
|
|
|
foreach(ROUTINE ${LEVEL2_ROUTINES})
|
2016-06-28 16:38:45 +02:00
|
|
|
add_executable(clblast_client_${ROUTINE} ${CLIENTS_COMMON}
|
2016-06-19 13:55:49 +02:00
|
|
|
test/performance/routines/level2/${ROUTINE}.cpp)
|
2016-05-30 16:38:26 +02:00
|
|
|
endforeach()
|
|
|
|
foreach(ROUTINE ${LEVEL3_ROUTINES})
|
2016-06-28 16:38:45 +02:00
|
|
|
add_executable(clblast_client_${ROUTINE} ${CLIENTS_COMMON}
|
2016-06-19 13:55:49 +02:00
|
|
|
test/performance/routines/level3/${ROUTINE}.cpp)
|
2016-05-30 16:38:26 +02:00
|
|
|
endforeach()
|
2016-06-16 18:07:46 +02:00
|
|
|
foreach(ROUTINE ${LEVELX_ROUTINES})
|
2016-06-28 16:38:45 +02:00
|
|
|
add_executable(clblast_client_${ROUTINE} ${CLIENTS_COMMON}
|
2016-06-19 13:55:49 +02:00
|
|
|
test/performance/routines/levelx/${ROUTINE}.cpp)
|
2016-06-16 18:07:46 +02:00
|
|
|
endforeach()
|
2016-05-30 16:38:26 +02:00
|
|
|
foreach(ROUTINE ${ROUTINES})
|
|
|
|
target_link_libraries(clblast_client_${ROUTINE} clblast ${REF_LIBRARIES} ${OPENCL_LIBRARIES})
|
2016-07-28 16:53:54 +02:00
|
|
|
target_include_directories(clblast_client_${ROUTINE} PUBLIC ${clblast_SOURCE_DIR} ${REF_INCLUDES})
|
2016-05-30 16:38:26 +02:00
|
|
|
install(TARGETS clblast_client_${ROUTINE} DESTINATION bin)
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# ==================================================================================================
|
|
|
|
|
|
|
|
# Section for the correctness tests. Note that these tests require the presence of clBLAS and/or a
|
|
|
|
# CPU BLAS library to act as a reference.
|
|
|
|
if(TESTS)
|
2016-05-31 20:53:55 +02:00
|
|
|
enable_testing()
|
2016-05-30 16:38:26 +02:00
|
|
|
|
2016-06-28 16:38:45 +02:00
|
|
|
# Visual Studio requires the sources of non-exported objects/libraries
|
|
|
|
set(TESTS_COMMON )
|
|
|
|
if(MSVC)
|
2016-10-23 14:34:46 +02:00
|
|
|
set(TESTS_COMMON ${TESTS_COMMON} src/utilities/utilities.cpp
|
2016-06-28 16:38:45 +02:00
|
|
|
test/correctness/tester.cpp test/correctness/testblas.cpp)
|
|
|
|
else()
|
|
|
|
# Creates the common correctness-tests objects (requires CMake 2.8.8)
|
|
|
|
add_library(test_correctness_common OBJECT
|
|
|
|
test/correctness/tester.cpp test/correctness/testblas.cpp)
|
2016-07-28 16:53:54 +02:00
|
|
|
target_include_directories(test_correctness_common PUBLIC
|
|
|
|
$<TARGET_PROPERTY:clblast,INTERFACE_INCLUDE_DIRECTORIES>
|
2016-09-24 13:46:34 +02:00
|
|
|
${clblast_SOURCE_DIR} ${REF_INCLUDES})
|
2016-06-28 16:38:45 +02:00
|
|
|
set(TESTS_COMMON ${TESTS_COMMON} $<TARGET_OBJECTS:test_correctness_common>)
|
|
|
|
endif()
|
2015-05-30 12:30:43 +02:00
|
|
|
|
|
|
|
# Compiles the correctness-tests
|
2015-07-12 16:57:09 +02:00
|
|
|
foreach(ROUTINE ${LEVEL1_ROUTINES})
|
2016-06-28 16:38:45 +02:00
|
|
|
add_executable(clblast_test_${ROUTINE} ${TESTS_COMMON}
|
2016-06-19 13:55:49 +02:00
|
|
|
test/correctness/routines/level1/${ROUTINE}.cpp)
|
2015-07-12 16:57:09 +02:00
|
|
|
endforeach()
|
|
|
|
foreach(ROUTINE ${LEVEL2_ROUTINES})
|
2016-06-28 16:38:45 +02:00
|
|
|
add_executable(clblast_test_${ROUTINE} ${TESTS_COMMON}
|
2016-06-19 13:55:49 +02:00
|
|
|
test/correctness/routines/level2/${ROUTINE}.cpp)
|
2015-07-12 16:57:09 +02:00
|
|
|
endforeach()
|
|
|
|
foreach(ROUTINE ${LEVEL3_ROUTINES})
|
2016-06-28 16:38:45 +02:00
|
|
|
add_executable(clblast_test_${ROUTINE} ${TESTS_COMMON}
|
2016-06-19 13:55:49 +02:00
|
|
|
test/correctness/routines/level3/${ROUTINE}.cpp)
|
2015-07-12 16:57:09 +02:00
|
|
|
endforeach()
|
2016-06-16 18:07:46 +02:00
|
|
|
foreach(ROUTINE ${LEVELX_ROUTINES})
|
2016-06-28 16:38:45 +02:00
|
|
|
add_executable(clblast_test_${ROUTINE} ${TESTS_COMMON}
|
2016-06-19 13:55:49 +02:00
|
|
|
test/correctness/routines/levelx/${ROUTINE}.cpp)
|
2016-06-16 18:07:46 +02:00
|
|
|
endforeach()
|
2015-06-28 15:52:57 +02:00
|
|
|
foreach(ROUTINE ${ROUTINES})
|
2016-04-01 07:22:29 +02:00
|
|
|
target_link_libraries(clblast_test_${ROUTINE} clblast ${REF_LIBRARIES} ${OPENCL_LIBRARIES})
|
2015-08-21 07:36:19 +02:00
|
|
|
install(TARGETS clblast_test_${ROUTINE} DESTINATION bin)
|
2016-07-28 16:53:54 +02:00
|
|
|
target_include_directories(clblast_test_${ROUTINE} PUBLIC ${clblast_SOURCE_DIR} ${REF_INCLUDES})
|
2016-11-27 11:00:29 +01:00
|
|
|
add_test(clblast_test_${ROUTINE} clblast_test_${ROUTINE})
|
2015-05-30 12:30:43 +02:00
|
|
|
endforeach()
|
|
|
|
|
2017-02-14 21:09:00 +01:00
|
|
|
# Miscellaneous tests
|
|
|
|
set(MISC_TESTS override_parameters)
|
|
|
|
foreach(MISC_TEST ${MISC_TESTS})
|
|
|
|
add_executable(clblast_test_${MISC_TEST} ${TESTS_COMMON}
|
|
|
|
test/correctness/misc/${MISC_TEST}.cpp)
|
|
|
|
target_link_libraries(clblast_test_${MISC_TEST} clblast ${REF_LIBRARIES} ${OPENCL_LIBRARIES})
|
|
|
|
target_include_directories(clblast_test_${MISC_TEST} PUBLIC
|
|
|
|
$<TARGET_PROPERTY:clblast,INTERFACE_INCLUDE_DIRECTORIES>
|
|
|
|
${clblast_SOURCE_DIR} ${REF_INCLUDES})
|
|
|
|
add_test(clblast_test_${MISC_TEST} clblast_test_${MISC_TEST})
|
|
|
|
endforeach()
|
|
|
|
|
2015-08-21 07:36:19 +02:00
|
|
|
# Adds 'alltests' target: runs all tests
|
|
|
|
set(ALLTESTS )
|
|
|
|
set(ALLTESTSDEPENDS )
|
|
|
|
foreach(ROUTINE ${ROUTINES})
|
2016-11-27 11:00:29 +01:00
|
|
|
set(ALLTESTS ${ALLTESTS} COMMAND clblast_test_${ROUTINE})
|
2015-08-21 07:36:19 +02:00
|
|
|
set(ALLTESTSDEPENDS clblast_test_${ROUTINE})
|
|
|
|
endforeach()
|
|
|
|
add_custom_target(alltests ${ALLTESTS} DEPENDS ${ALLTESTSDEPENDS})
|
|
|
|
|
2015-05-30 12:30:43 +02:00
|
|
|
endif()
|
2016-05-30 16:38:26 +02:00
|
|
|
|
2015-05-30 12:30:43 +02:00
|
|
|
# ==================================================================================================
|