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
|
2017-10-14 16:26:35 +02:00
|
|
|
option(OVERRIDE_MSVC_FLAGS_TO_MT "Override compiler flags for MSVC to build with a static runtime (/MT instead of /MD)" ON)
|
|
|
|
if(OVERRIDE_MSVC_FLAGS_TO_MT)
|
|
|
|
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)
|
|
|
|
endif()
|
2016-05-18 21:32:56 +02:00
|
|
|
|
|
|
|
# CMake project details
|
2015-08-13 13:46:13 +02:00
|
|
|
project("clblast" C CXX)
|
2017-07-30 20:54:21 +02:00
|
|
|
set(clblast_VERSION_MAJOR 1)
|
2018-01-29 20:45:21 +01:00
|
|
|
set(clblast_VERSION_MINOR 3)
|
2017-09-30 17:19:17 +02:00
|
|
|
set(clblast_VERSION_PATCH 0)
|
2018-02-11 15:31:21 +01:00
|
|
|
set(clblast_VERSION "${clblast_VERSION_MAJOR}.${clblast_VERSION_MINOR}.${clblast_VERSION_PATCH}")
|
|
|
|
set(clblast_SOVERSION ${clblast_VERSION_MAJOR})
|
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)
|
2017-11-19 14:33:25 +01:00
|
|
|
option(TUNERS "Enable compilation of the tuners" ON)
|
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)
|
2017-04-16 17:53:51 +02:00
|
|
|
option(CUBLAS "Enables performance comparison against cuBLAS on NVIDIA GPUs" OFF)
|
2015-05-30 12:30:43 +02:00
|
|
|
|
2017-10-11 23:16:57 +02:00
|
|
|
# Select between an OpenCL API (default) or a CUDA API (beta)
|
|
|
|
option(OPENCL "Build CLBlast with an OpenCL API (default)" ON)
|
|
|
|
option(CUDA "Build CLBlast with a CUDA API (beta)" OFF)
|
|
|
|
if(NOT OPENCL AND NOT CUDA)
|
|
|
|
message(FATAL_ERROR "No API selected, choose from OpenCL (-DOPENCL=ON) or CUDA (-DCUDA=ON)")
|
|
|
|
endif()
|
2017-10-14 10:50:28 +02:00
|
|
|
if(OPENCL AND CUDA)
|
2017-10-11 23:16:57 +02:00
|
|
|
message(FATAL_ERROR "Multiple APIs selected, choose either OpenCL (-DOPENCL=ON -DCUDA=OFF) or CUDA (-DCUDA=ON -DOPENCL=OFF)")
|
|
|
|
endif()
|
|
|
|
if(OPENCL)
|
|
|
|
message("-- Building CLBlast with OpenCL API (default)")
|
|
|
|
add_definitions(-DOPENCL_API)
|
|
|
|
elseif(CUDA)
|
|
|
|
message("-- Building CLBlast with CUDA API (beta)")
|
|
|
|
add_definitions(-DCUDA_API)
|
|
|
|
endif()
|
|
|
|
|
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)
|
2017-06-26 21:36:56 +02:00
|
|
|
set(FLAGS "/Ot")
|
2017-06-26 21:38:04 +02:00
|
|
|
set(FLAGS "${FLAGS} /wd4715 /D_CRT_SECURE_NO_WARNINGS")
|
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()
|
2017-06-26 21:36:56 +02:00
|
|
|
set(FLAGS "${FLAGS} -O2")
|
2016-10-14 20:54:05 +02:00
|
|
|
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")
|
2017-07-30 18:52:20 +02:00
|
|
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 3.9.0) # clang 4.0 or higher
|
|
|
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0.0) # but not for AppleClang
|
2017-07-30 18:34:39 +02:00
|
|
|
set(FLAGS "${FLAGS} -Wno-undefined-var-template")
|
|
|
|
endif()
|
2017-07-12 20:58:31 +02:00
|
|
|
endif()
|
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)
|
2017-06-26 21:36:56 +02:00
|
|
|
set(CFLAGS "/Ot")
|
2016-05-18 21:32:56 +02:00
|
|
|
else()
|
2017-06-26 21:36:56 +02:00
|
|
|
set(CFLAGS "-O2 -std=c99")
|
2016-03-23 20:31:25 +01:00
|
|
|
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
|
|
|
|
2017-10-11 23:16:57 +02:00
|
|
|
if(OPENCL)
|
|
|
|
# Requires OpenCL. It is found through the included "FindOpenCL.cmake" in CMAKE_MODULE_PATH.
|
|
|
|
find_package(OpenCL REQUIRED)
|
|
|
|
set(API_LIBRARIES ${OPENCL_LIBRARIES})
|
|
|
|
set(API_INCLUDE_DIRS ${OPENCL_INCLUDE_DIRS})
|
|
|
|
elseif(CUDA)
|
|
|
|
# For CUDA, the "FindCUDA.cmake" is part of CMake
|
|
|
|
find_package(CUDA REQUIRED)
|
|
|
|
set(API_LIBRARIES cuda nvrtc)
|
|
|
|
set(API_INCLUDE_DIRS ${CUDA_INCLUDE_DIRS})
|
|
|
|
link_directories(${CUDA_TOOLKIT_ROOT_DIR}/lib64)
|
|
|
|
endif()
|
2015-05-30 12:30:43 +02:00
|
|
|
|
2017-10-29 13:02:14 +01:00
|
|
|
# Don't search for system libraries when cross-compiling
|
|
|
|
if(${CMAKE_SYSTEM_NAME} STREQUAL Android)
|
|
|
|
if(TESTS)
|
|
|
|
message(STATUS "Compilation of the tests disabled for the Android target")
|
|
|
|
set(TESTS OFF)
|
2017-10-15 13:56:19 +02:00
|
|
|
endif()
|
2017-10-29 13:02:14 +01:00
|
|
|
if(CLIENTS)
|
|
|
|
message(STATUS "Head-to-head performance comparison not supported in the clients for the Android target")
|
2017-04-16 17:53:51 +02:00
|
|
|
endif()
|
2017-10-29 13:02:14 +01:00
|
|
|
else()
|
|
|
|
|
|
|
|
# Locates the reference BLAS libraries in case the tests need to be compiled. The "FindclBLAS.cmake",
|
|
|
|
# "FindCBLAS.cmake" and "FindcuBLAS.cmake" are included.
|
|
|
|
if(CLIENTS OR TESTS)
|
|
|
|
find_package(CBLAS)
|
|
|
|
if(OPENCL)
|
|
|
|
find_package(clBLAS)
|
|
|
|
endif()
|
|
|
|
if(CUBLAS)
|
|
|
|
find_package(cuBLAS)
|
2016-05-30 16:38:26 +02:00
|
|
|
endif()
|
2017-10-29 13:02:14 +01:00
|
|
|
if(NOT CLBLAS_FOUND AND NOT CBLAS_FOUND)
|
|
|
|
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()
|
2016-05-30 16:38:26 +02:00
|
|
|
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
|
2017-12-19 21:10:48 +01:00
|
|
|
xgemm xgemm_direct xgemv invert)
|
2017-09-06 21:50:42 +02:00
|
|
|
set(DATABASES copy pad padtranspose transpose xaxpy xdot
|
2017-12-23 13:55:22 +01:00
|
|
|
xgemm xgemm_direct xgemv xgemv_fast xgemv_fast_rot xger invert
|
2017-12-23 13:34:57 +01:00
|
|
|
gemm_routine trsv_routine)
|
|
|
|
set(ROUTINE_TUNERS xgemm xtrsv)
|
2016-04-21 06:12:51 +02:00
|
|
|
set(LEVEL1_ROUTINES xswap xscal xcopy xaxpy xdot xdotu xdotc xnrm2 xasum xamax)
|
2017-01-20 11:30:32 +01:00
|
|
|
set(LEVEL2_ROUTINES xgemv xgbmv xhemv xhbmv xhpmv xsymv xsbmv xspmv xtrmv xtbmv xtpmv xtrsv
|
2016-03-06 15:48:11 +01:00
|
|
|
xger xgeru xgerc xher xhpr xher2 xhpr2 xsyr xspr xsyr2 xspr2)
|
2016-12-18 12:30:16 +01:00
|
|
|
set(LEVEL3_ROUTINES xgemm xsymm xhemm xsyrk xherk xsyr2k xher2k xtrmm xtrsm)
|
2018-01-31 20:41:02 +01:00
|
|
|
set(LEVELX_ROUTINES xhad xomatcopy xim2col xaxpybatched xgemmbatched xgemmstridedbatched)
|
2016-06-16 18:07:46 +02:00
|
|
|
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
|
|
|
|
2017-10-15 13:56:19 +02:00
|
|
|
# Sample programs
|
2017-10-11 23:16:57 +02:00
|
|
|
if(OPENCL)
|
2018-03-06 20:52:12 +01:00
|
|
|
set(SAMPLE_PROGRAMS_CPP sgemm sgemm_batched dtrsm tuning_api)
|
2017-10-11 23:16:57 +02:00
|
|
|
set(SAMPLE_PROGRAMS_C sasum dgemv sgemm haxpy cache)
|
|
|
|
if(NETLIB)
|
|
|
|
set(SAMPLE_PROGRAMS_C ${SAMPLE_PROGRAMS_C} sgemm_netlib)
|
|
|
|
endif()
|
|
|
|
elseif(CUDA)
|
2017-10-14 12:23:35 +02:00
|
|
|
set(SAMPLE_PROGRAMS_CPP daxpy_cuda sgemm_cuda)
|
2017-10-11 23:16:57 +02:00
|
|
|
set(SAMPLE_PROGRAMS_C )
|
|
|
|
endif()
|
2015-05-30 12:30:43 +02:00
|
|
|
|
|
|
|
# ==================================================================================================
|
|
|
|
|
2017-08-11 21:20:40 +02:00
|
|
|
# Gathers all source-files (required for the compiler) and header-files (for IDEs only)
|
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
|
2017-11-17 20:57:46 +01:00
|
|
|
src/utilities/compile.cpp
|
2016-10-22 15:36:48 +02:00
|
|
|
src/utilities/clblast_exceptions.cpp
|
2017-11-15 22:47:06 +01:00
|
|
|
src/utilities/timing.cpp
|
2016-10-22 15:36:48 +02:00
|
|
|
src/utilities/utilities.cpp
|
2017-10-08 21:52:02 +02:00
|
|
|
src/api_common.cpp
|
2016-06-19 13:55:49 +02:00
|
|
|
src/cache.cpp
|
2017-11-25 10:24:05 +01:00
|
|
|
src/kernel_preprocessor.cpp
|
2016-06-19 13:55:49 +02:00
|
|
|
src/routine.cpp
|
2017-02-25 12:28:13 +01:00
|
|
|
src/routines/levelx/xinvert.cpp # only source, don't include it as a test
|
2018-03-06 20:52:12 +01:00
|
|
|
src/tuning/configurations.cpp
|
|
|
|
src/tuning/tuning_api.cpp
|
2016-06-18 20:20:13 +02:00
|
|
|
)
|
2017-08-11 21:20:40 +02:00
|
|
|
set(HEADERS # such that they can be discovered by IDEs such as CLion and Visual Studio
|
|
|
|
include/clblast_half.h
|
|
|
|
src/database/apple_cpu_fallback.hpp
|
|
|
|
src/database/database.hpp
|
2017-09-08 21:09:05 +02:00
|
|
|
src/database/database_structure.hpp
|
2017-08-11 21:20:40 +02:00
|
|
|
src/routines/level1/xamin.hpp
|
|
|
|
src/routines/level1/xmax.hpp
|
|
|
|
src/routines/level1/xmin.hpp
|
|
|
|
src/routines/level1/xsum.hpp
|
|
|
|
src/routines/common.hpp
|
2017-10-08 21:52:02 +02:00
|
|
|
src/routines/routines.hpp
|
2017-08-11 21:20:40 +02:00
|
|
|
src/utilities/buffer_test.hpp
|
2017-11-17 20:57:46 +01:00
|
|
|
src/utilities/compile.hpp
|
2017-08-11 21:20:40 +02:00
|
|
|
src/utilities/clblast_exceptions.hpp
|
2017-09-10 16:34:54 +02:00
|
|
|
src/utilities/device_mapping.hpp
|
2017-08-11 21:20:40 +02:00
|
|
|
src/utilities/msvc.hpp
|
2017-10-28 14:12:05 +02:00
|
|
|
src/utilities/timing.hpp
|
2017-08-11 21:20:40 +02:00
|
|
|
src/utilities/utilities.hpp
|
|
|
|
src/cache.hpp
|
2017-11-25 10:24:05 +01:00
|
|
|
src/kernel_preprocessor.hpp
|
2017-08-11 21:20:40 +02:00
|
|
|
src/cxpp11_common.hpp
|
|
|
|
src/routine.hpp
|
2018-03-06 20:52:12 +01:00
|
|
|
src/tuning/configurations.hpp
|
|
|
|
src/tuning/tuning.hpp
|
|
|
|
src/tuning/routines/routine_tuner.hpp
|
2017-08-11 21:20:40 +02:00
|
|
|
)
|
2017-10-11 23:16:57 +02:00
|
|
|
if(OPENCL)
|
|
|
|
set(SOURCES ${SOURCES} src/clblast.cpp src/clblast_c.cpp)
|
|
|
|
set(HEADERS ${HEADERS} include/clblast.h include/clblast_c.h src/clpp11.hpp)
|
|
|
|
if(NETLIB)
|
|
|
|
set(SOURCES ${SOURCES} src/clblast_netlib_c.cpp)
|
|
|
|
set(HEADERS ${HEADERS} include/clblast_netlib_c.h)
|
|
|
|
endif()
|
|
|
|
elseif(CUDA)
|
|
|
|
set(SOURCES ${SOURCES} src/clblast_cuda.cpp)
|
|
|
|
set(HEADERS ${HEADERS} include/clblast_cuda.h src/cupp11.hpp)
|
2016-11-23 21:33:35 +01:00
|
|
|
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)
|
2017-08-11 21:20:40 +02:00
|
|
|
set(HEADERS ${HEADERS} src/routines/level1/${ROUTINE}.hpp)
|
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)
|
2017-08-11 21:20:40 +02:00
|
|
|
set(HEADERS ${HEADERS} src/routines/level2/${ROUTINE}.hpp)
|
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)
|
2017-08-11 21:20:40 +02:00
|
|
|
set(HEADERS ${HEADERS} src/routines/level3/${ROUTINE}.hpp)
|
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)
|
2017-08-11 21:20:40 +02:00
|
|
|
set(HEADERS ${HEADERS} src/routines/levelx/${ROUTINE}.hpp)
|
|
|
|
endforeach()
|
|
|
|
foreach(DATABASE ${DATABASES})
|
2017-12-27 12:04:22 +01:00
|
|
|
set(SOURCES ${SOURCES} src/database/kernels/${DATABASE}/${DATABASE}.cpp)
|
2017-09-06 21:50:42 +02:00
|
|
|
set(HEADERS ${HEADERS} src/database/kernels/${DATABASE}/${DATABASE}.hpp)
|
|
|
|
set(HEADERS ${HEADERS} src/database/kernels/${DATABASE}/${DATABASE}_16.hpp)
|
|
|
|
set(HEADERS ${HEADERS} src/database/kernels/${DATABASE}/${DATABASE}_32.hpp)
|
|
|
|
set(HEADERS ${HEADERS} src/database/kernels/${DATABASE}/${DATABASE}_64.hpp)
|
|
|
|
set(HEADERS ${HEADERS} src/database/kernels/${DATABASE}/${DATABASE}_3232.hpp)
|
|
|
|
set(HEADERS ${HEADERS} src/database/kernels/${DATABASE}/${DATABASE}_6464.hpp)
|
2016-06-16 18:07:46 +02:00
|
|
|
endforeach()
|
2018-03-06 20:52:12 +01:00
|
|
|
foreach(KERNEL ${KERNELS})
|
|
|
|
set(HEADERS ${HEADERS} src/tuning/kernels/${KERNEL}.hpp)
|
|
|
|
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)
|
2017-08-11 21:20:40 +02:00
|
|
|
add_library(clblast SHARED ${SOURCES} ${HEADERS})
|
2016-10-13 18:03:44 +02:00
|
|
|
else(BUILD_SHARED_LIBS)
|
2017-08-11 21:20:40 +02:00
|
|
|
add_library(clblast STATIC ${SOURCES} ${HEADERS})
|
2016-10-22 16:38:42 +02:00
|
|
|
endif()
|
2018-02-11 15:31:21 +01:00
|
|
|
set_target_properties(clblast PROPERTIES VERSION ${clblast_VERSION} SOVERSION ${clblast_SOVERSION})
|
2016-10-13 18:03:44 +02:00
|
|
|
|
2017-10-11 23:16:57 +02:00
|
|
|
target_link_libraries(clblast ${API_LIBRARIES})
|
2015-05-30 12:30:43 +02:00
|
|
|
|
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>
|
2017-10-11 23:16:57 +02:00
|
|
|
${API_INCLUDE_DIRS})
|
2016-07-24 18:10:39 +02:00
|
|
|
|
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
|
2017-10-23 15:54:55 +02:00
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
|
|
|
install(TARGETS clblast EXPORT CLBlast DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
|
|
|
install(FILES include/clblast_half.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
2017-10-11 23:16:57 +02:00
|
|
|
if(OPENCL)
|
2017-10-23 15:54:55 +02:00
|
|
|
install(FILES include/clblast.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
|
|
|
install(FILES include/clblast_c.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
2017-10-11 23:16:57 +02:00
|
|
|
if(NETLIB)
|
2017-10-23 15:54:55 +02:00
|
|
|
install(FILES include/clblast_netlib_c.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
2017-10-11 23:16:57 +02:00
|
|
|
endif()
|
|
|
|
elseif(CUDA)
|
2017-10-23 15:54:55 +02:00
|
|
|
install(FILES include/clblast_cuda.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
2016-11-23 21:33:35 +01:00
|
|
|
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
|
2017-10-23 15:54:55 +02:00
|
|
|
install(EXPORT CLBlast DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/CLBLast FILE CLBlastConfig.cmake)
|
2016-07-24 18:10:39 +02:00
|
|
|
|
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)
|
2017-10-23 15:54:55 +02:00
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/clblast.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
2016-10-21 09:38:25 +02:00
|
|
|
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-10-11 23:16:57 +02:00
|
|
|
if(OPENCL)
|
|
|
|
file(DOWNLOAD https://www.khronos.org/registry/OpenCL/api/2.1/cl.hpp ${clblast_SOURCE_DIR}/samples/cl.hpp)
|
|
|
|
endif()
|
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)
|
2017-10-11 23:16:57 +02:00
|
|
|
target_link_libraries(clblast_sample_${SAMPLE} clblast ${API_LIBRARIES})
|
2015-08-21 07:36:19 +02:00
|
|
|
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)
|
2017-10-11 23:16:57 +02:00
|
|
|
target_link_libraries(clblast_sample_${SAMPLE}_c clblast ${API_LIBRARIES})
|
2015-08-21 07:36:19 +02:00
|
|
|
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()
|
|
|
|
|
|
|
|
# ==================================================================================================
|
|
|
|
|
2017-11-16 21:28:36 +01:00
|
|
|
# This section contains all the code related to the tuners
|
2015-05-30 12:30:43 +02:00
|
|
|
if(TUNERS)
|
|
|
|
|
2017-11-15 22:49:35 +01:00
|
|
|
set(TUNERS_COMMON
|
2017-11-17 20:57:46 +01:00
|
|
|
src/utilities/compile.cpp
|
|
|
|
src/utilities/clblast_exceptions.cpp
|
|
|
|
src/utilities/timing.cpp
|
|
|
|
src/utilities/utilities.cpp
|
2017-11-15 22:49:35 +01:00
|
|
|
src/tuning/configurations.cpp
|
2017-11-25 10:24:05 +01:00
|
|
|
src/tuning/tuning.cpp
|
|
|
|
src/kernel_preprocessor.cpp)
|
2017-11-17 20:57:46 +01:00
|
|
|
set(TUNERS_HEADERS # such that they can be discovered by IDEs such as CLion and Visual Studio
|
|
|
|
src/utilities/compile.hpp
|
|
|
|
src/utilities/clblast_exceptions.hpp
|
|
|
|
src/utilities/timing.hpp
|
|
|
|
src/utilities/utilities.hpp
|
2017-11-15 22:49:35 +01:00
|
|
|
src/tuning/configurations.hpp
|
2017-11-25 10:24:05 +01:00
|
|
|
src/tuning/tuning.hpp
|
2018-01-15 21:32:51 +01:00
|
|
|
src/tuning/routines/routine_tuner.hpp
|
2017-11-25 10:24:05 +01:00
|
|
|
src/kernel_preprocessor.hpp)
|
2017-11-19 12:59:28 +01:00
|
|
|
set(TUNERS_COMMON ${TUNERS_COMMON} ${TUNERS_HEADERS})
|
|
|
|
|
|
|
|
# Creates a library with common sources for all tuners
|
|
|
|
if(MSVC)
|
|
|
|
# Visual Studio requires the sources of non-exported objects/libraries
|
|
|
|
else()
|
|
|
|
# Creates the common performance-tests objects (requires CMake 2.8.8)
|
|
|
|
add_library(tuners_common_library OBJECT ${TUNERS_COMMON})
|
|
|
|
|
|
|
|
# Adds CLBlast's interface include paths because we can't link to CLBlast here
|
|
|
|
target_include_directories(tuners_common_library PRIVATE
|
|
|
|
$<TARGET_PROPERTY:clblast,INTERFACE_INCLUDE_DIRECTORIES>
|
|
|
|
${clblast_SOURCE_DIR} ${API_INCLUDE_DIRS})
|
|
|
|
set(TUNERS_COMMON $<TARGET_OBJECTS:tuners_common_library>)
|
|
|
|
endif()
|
2017-11-15 22:49:35 +01:00
|
|
|
|
2015-05-30 12:30:43 +02:00
|
|
|
# Adds tuning executables
|
|
|
|
foreach(KERNEL ${KERNELS})
|
2017-11-19 12:59:28 +01:00
|
|
|
add_executable(clblast_tuner_${KERNEL} ${TUNERS_COMMON} src/tuning/kernels/${KERNEL}.cpp)
|
2017-11-17 20:57:46 +01:00
|
|
|
target_link_libraries(clblast_tuner_${KERNEL} ${API_LIBRARIES})
|
2017-11-19 12:59:28 +01:00
|
|
|
target_include_directories(clblast_tuner_${KERNEL} PUBLIC $<TARGET_PROPERTY:clblast,INTERFACE_INCLUDE_DIRECTORIES> ${API_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()
|
2017-10-28 17:30:29 +02:00
|
|
|
foreach(ROUTINE_TUNER ${ROUTINE_TUNERS})
|
2017-11-19 12:59:28 +01:00
|
|
|
add_executable(clblast_tuner_routine_${ROUTINE_TUNER} ${TUNERS_COMMON} src/tuning/routines/${ROUTINE_TUNER}.cpp)
|
|
|
|
target_link_libraries(clblast_tuner_routine_${ROUTINE_TUNER} clblast)
|
|
|
|
target_include_directories(clblast_tuner_routine_${ROUTINE_TUNER} PUBLIC $<TARGET_PROPERTY:clblast,INTERFACE_INCLUDE_DIRECTORIES> ${API_INCLUDE_DIRS})
|
2017-10-28 17:30:29 +02:00
|
|
|
install(TARGETS clblast_tuner_routine_${ROUTINE_TUNER} DESTINATION bin)
|
|
|
|
endforeach()
|
2015-05-30 12:30:43 +02:00
|
|
|
|
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})
|
2017-08-11 21:20:40 +02:00
|
|
|
set(WRAPPERS ${WRAPPERS} test/wrapper_clblas.hpp)
|
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})
|
2017-08-11 21:20:40 +02:00
|
|
|
set(WRAPPERS ${WRAPPERS} test/wrapper_cblas.hpp)
|
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()
|
2017-04-03 21:45:18 +02:00
|
|
|
if(CUBLAS_FOUND)
|
2017-04-02 18:06:15 +02:00
|
|
|
set(REF_INCLUDES ${REF_INCLUDES} ${CUDA_INCLUDE_DIRS})
|
2017-04-03 21:45:18 +02:00
|
|
|
set(REF_LIBRARIES ${REF_LIBRARIES} ${CUDA_LIBRARIES} ${CUBLAS_LIBRARIES})
|
2017-08-11 21:20:40 +02:00
|
|
|
set(WRAPPERS ${WRAPPERS} test/wrapper_cuda.hpp test/wrapper_cublas.hpp)
|
2017-04-02 18:06:15 +02:00
|
|
|
if(MSVC)
|
|
|
|
add_definitions(" /DCLBLAST_REF_CUBLAS")
|
|
|
|
else()
|
|
|
|
add_definitions(" -DCLBLAST_REF_CUBLAS")
|
|
|
|
endif()
|
|
|
|
endif()
|
2016-04-01 07:22:29 +02:00
|
|
|
|
2016-05-30 16:38:26 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# ==================================================================================================
|
|
|
|
|
|
|
|
# Section for the performance tests (i.e. the client). These compare against optionally a reference
|
2017-04-02 18:06:15 +02:00
|
|
|
# library, either clBLAS, a CPU BLAS, or CUDA's cuBLAS.
|
2016-05-30 16:38:26 +02:00
|
|
|
if(CLIENTS)
|
2017-08-12 16:07:28 +02:00
|
|
|
set(CLIENTS_COMMON ${WRAPPERS} test/test_utilities.hpp
|
2017-08-12 15:38:17 +02:00
|
|
|
test/performance/client.hpp test/routines/common.hpp)
|
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
|
|
|
|
if(MSVC)
|
2017-08-12 16:07:28 +02:00
|
|
|
set(CLIENTS_COMMON ${CLIENTS_COMMON} src/utilities/utilities.cpp test/test_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)
|
2017-08-12 16:07:28 +02:00
|
|
|
add_library(test_performance_common OBJECT test/test_utilities.cpp 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}
|
2017-08-11 21:20:40 +02:00
|
|
|
test/performance/routines/level1/${ROUTINE}.cpp
|
|
|
|
test/routines/level1/${ROUTINE}.hpp)
|
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}
|
2017-08-11 21:20:40 +02:00
|
|
|
test/performance/routines/level2/${ROUTINE}.cpp
|
|
|
|
test/routines/level2/${ROUTINE}.hpp)
|
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}
|
2017-08-11 21:20:40 +02:00
|
|
|
test/performance/routines/level3/${ROUTINE}.cpp
|
|
|
|
test/routines/level3/${ROUTINE}.hpp)
|
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}
|
2017-08-11 21:20:40 +02:00
|
|
|
test/performance/routines/levelx/${ROUTINE}.cpp
|
|
|
|
test/routines/levelx/${ROUTINE}.hpp)
|
2016-06-16 18:07:46 +02:00
|
|
|
endforeach()
|
2016-05-30 16:38:26 +02:00
|
|
|
foreach(ROUTINE ${ROUTINES})
|
2017-10-11 23:16:57 +02:00
|
|
|
target_link_libraries(clblast_client_${ROUTINE} clblast ${REF_LIBRARIES} ${API_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
|
2017-04-02 18:06:15 +02:00
|
|
|
# CPU BLAS library, and/or cuBLAS to act as a reference.
|
2016-05-30 16:38:26 +02:00
|
|
|
if(TESTS)
|
2016-05-31 20:53:55 +02:00
|
|
|
enable_testing()
|
2017-08-12 16:07:28 +02:00
|
|
|
set(TESTS_COMMON ${WRAPPERS} test/test_utilities.hpp test/correctness/testblas.hpp
|
|
|
|
test/correctness/tester.hpp test/routines/common.hpp)
|
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
|
|
|
|
if(MSVC)
|
2017-08-12 16:07:28 +02:00
|
|
|
set(TESTS_COMMON ${TESTS_COMMON} src/utilities/utilities.cpp test/test_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
|
2017-08-12 16:07:28 +02:00
|
|
|
test/test_utilities.cpp 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}
|
2017-08-11 21:20:40 +02:00
|
|
|
test/correctness/routines/level1/${ROUTINE}.cpp
|
|
|
|
test/routines/level1/${ROUTINE}.hpp)
|
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}
|
2017-08-11 21:20:40 +02:00
|
|
|
test/correctness/routines/level2/${ROUTINE}.cpp
|
|
|
|
test/routines/level2/${ROUTINE}.hpp)
|
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}
|
2017-08-11 21:20:40 +02:00
|
|
|
test/correctness/routines/level3/${ROUTINE}.cpp
|
|
|
|
test/routines/level3/${ROUTINE}.hpp)
|
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}
|
2017-08-11 21:20:40 +02:00
|
|
|
test/correctness/routines/levelx/${ROUTINE}.cpp
|
|
|
|
test/routines/levelx/${ROUTINE}.hpp)
|
2016-06-16 18:07:46 +02:00
|
|
|
endforeach()
|
2015-06-28 15:52:57 +02:00
|
|
|
foreach(ROUTINE ${ROUTINES})
|
2017-10-11 23:16:57 +02:00
|
|
|
target_link_libraries(clblast_test_${ROUTINE} clblast ${REF_LIBRARIES} ${API_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
|
2018-01-11 20:34:09 +01:00
|
|
|
set(MISC_TESTS override_parameters retrieve_parameters)
|
2017-12-24 12:10:55 +01:00
|
|
|
if(NOT CUDA)
|
|
|
|
set(MISC_TESTS ${MISC_TESTS} preprocessor)
|
|
|
|
endif()
|
2017-12-24 11:33:47 +01:00
|
|
|
if(MSVC)
|
2018-01-29 20:26:25 +01:00
|
|
|
set(TESTS_COMMON ${TESTS_COMMON} src/kernel_preprocessor.cpp src/utilities/compile.cpp)
|
2017-12-24 11:33:47 +01:00
|
|
|
endif()
|
2017-02-14 21:09:00 +01:00
|
|
|
foreach(MISC_TEST ${MISC_TESTS})
|
|
|
|
add_executable(clblast_test_${MISC_TEST} ${TESTS_COMMON}
|
|
|
|
test/correctness/misc/${MISC_TEST}.cpp)
|
2017-10-11 23:16:57 +02:00
|
|
|
target_link_libraries(clblast_test_${MISC_TEST} clblast ${REF_LIBRARIES} ${API_LIBRARIES})
|
2017-12-24 11:33:47 +01:00
|
|
|
target_include_directories(clblast_test_${MISC_TEST} PUBLIC ${clblast_SOURCE_DIR} ${REF_INCLUDES})
|
2017-02-14 21:09:00 +01:00
|
|
|
add_test(clblast_test_${MISC_TEST} clblast_test_${MISC_TEST})
|
|
|
|
endforeach()
|
|
|
|
|
2017-09-19 21:43:35 +02:00
|
|
|
# CLBlast diagnostics
|
|
|
|
add_executable(clblast_test_diagnostics ${TESTS_COMMON} test/diagnostics.cpp)
|
2017-10-11 23:16:57 +02:00
|
|
|
target_link_libraries(clblast_test_diagnostics clblast ${REF_LIBRARIES} ${API_LIBRARIES})
|
2017-09-19 21:43:35 +02:00
|
|
|
target_include_directories(clblast_test_diagnostics PUBLIC
|
|
|
|
$<TARGET_PROPERTY:clblast,INTERFACE_INCLUDE_DIRECTORIES>
|
|
|
|
${clblast_SOURCE_DIR} ${REF_INCLUDES})
|
|
|
|
|
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
|
|
|
# ==================================================================================================
|