forked from triSYCL/triSYCL
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request triSYCL#29 from MathiasMagnus/cmake
Cmake build and test automation
- Loading branch information
Showing
28 changed files
with
664 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
cmake_minimum_required (VERSION 3.5) # The minimum version of CMake necessary to build this project | ||
project(triSYCL C CXX) # The name of the project (forward declare language ) | ||
|
||
# | ||
# Behavioural options for the solution | ||
# | ||
option(TRISYCL_OPENMP "triSYCL multi-threading with OpenMP" ON) | ||
option(TRISYCL_NO_ASYNC "triSYCL use synchronous kernel execution" OFF) | ||
option(BUILD_OPENCL "triSYCL build OpenCL tests" ON) | ||
option(BUILD_XILINX "triSYCL build Xilinx-specific tests" OFF) | ||
option(TRISYCL_DEBUG "triSCYL use debug mode" OFF) | ||
option(TRISYCL_DEBUG_STRUCTORS "triSYCL trace of object lifetimes" OFF) | ||
|
||
set(CL_SYCL_LANGUAGE_VERSION 220 CACHE VERSION "Host language version to be used by trisYCL (default is: 220)") | ||
set(TRISYCL_CL_LANGUAGE_VERSION 220 CACHE VERSION "Device language version to be used by trisYCL (default is: 220) (not used yet)") | ||
|
||
# | ||
# Platform/compiler-independant setup | ||
# | ||
set_property(GLOBAL PROPERTY USE_FOLDERS ON) # Use solution folders in IDEs | ||
|
||
# Find dependencies | ||
if(TRISYCL_OPENMP) | ||
find_package(OpenMP REQUIRED) | ||
endif(TRISYCL_OPENMP) | ||
|
||
if(BUILD_OPENCL) | ||
find_package(OpenCL REQUIRED) | ||
endif(BUILD_OPENCL) | ||
|
||
find_package(Boost 1.58 REQUIRED COMPONENTS chrono log) | ||
|
||
# Enable CTest | ||
include(CTest) | ||
enable_testing() | ||
|
||
include_directories(${PROJECT_SOURCE_DIR}/include) # All targets inherit SYCL include dir | ||
include_directories(${PROJECT_SOURCE_DIR}/tests/common) # All targets inherit SYCL include dir | ||
|
||
# | ||
# Platform-specific setup | ||
# | ||
if(UNIX) # If compiling under Linux | ||
set(BOOST_COMPUTE_INCPATH /usr/include/compute CACHE PATH "Path to Boost.Compute headers (default is: /usr/include/compute)") | ||
find_package(Threads REQUIRED) | ||
endif(UNIX) | ||
|
||
if(APPLE) # If compiling under OSX | ||
find_package(Threads REQUIRED) | ||
endif(APPLE) | ||
|
||
# | ||
# Set compiler-specific variables | ||
# | ||
# If compiling with MSVC++ | ||
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") | ||
add_compile_options("/std:c++14") # Change to /std:c++latest once Boost::funtional is fixed (1.63.0 with toolset v141 not working) | ||
string(REGEX REPLACE "/W[0-9]" "/W4" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # Replace default Warning Level 3 with 4 (/Wall is pretty-much useless on MSVC, system headers are plagued with warnings) | ||
|
||
# Disabling (default) Warning Level 3 output | ||
add_compile_options("/wd4996") # warning C4996: Call to '<algorithm name>' with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. | ||
add_compile_options("/wd4267") # warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data | ||
add_compile_options("/wd4244") # warning C4244: '=': conversion from 'size_t' to 'double', possible loss of data | ||
add_compile_options("/wd4305") # warning C4305: '<op>': truncation from 'double' to 'float' | ||
add_compile_options("/wd4101") # warning C4101: '<id>': unreferenced local variable | ||
add_compile_options("/wd4700") # warning C4700: uninitialized local variable '<id>' used | ||
add_compile_options("/wd4189") # warning C4189: '<id>': local variable is initialized but not referenced | ||
|
||
# Disabling Warning Level 4 output | ||
add_compile_options("/wd4100") # warning C4100: '<param>': unreferenced formal parameter | ||
add_compile_options("/wd4459") # warning C4459: declaration of '<id>' hides global declaration | ||
add_compile_options("/wd4127") # warning C4127: conditional expression is constant | ||
add_compile_options("/wd4456") # warning C4456: declaration of '<id>' hides previous local declaration | ||
endif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") | ||
|
||
# If compiling with g++ | ||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU") | ||
add_compile_options("-std=c++1z") # Use latest available C++ standard | ||
add_compile_options("-Wall") # Turn on all warnings | ||
add_compile_options("-Wextra") # Turn on all warnings | ||
|
||
# Disabling specific warnings | ||
add_compile_options("-Wno-ignored-attributes") # warning: ignoring attributes on template argument | ||
add_compile_options("-Wno-sign-compare") # warning: comparison between signed and unsigned integer expressions | ||
add_compile_options("-Wno-deprecated-declarations") # warning: ‘<OpenCL func>’ is deprecated | ||
add_compile_options("-Wno-ignored-qualifiers") # warning: type qualifiers ignored on function return type | ||
add_compile_options("-Wno-unused-parameter") # warning: unused parameter ‘<id>’ | ||
endif (CMAKE_CXX_COMPILER_ID MATCHES "GNU") | ||
|
||
# If compiling with clang | ||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
add_compile_options("-std=c++1z") # Use latest available C++ standard | ||
add_compile_options("-Wall") # Turn on all warnings | ||
add_compile_options("-Wextra") # Turn on all warnings | ||
|
||
# Disabling specific warnings | ||
add_compile_options("-Wno-ignored-qualifiers") # warning: 'const' type qualifier on return type has no effect | ||
add_compile_options("-Wno-sign-compare") # warning: comparison between signed and unsigned integer expressions | ||
add_compile_options("-Wno-deprecated-declarations") # warning: ‘<OpenCL func>’ is deprecated | ||
add_compile_options("-Wno-unused-parameter") # warning: unused parameter ‘<id>’ | ||
add_compile_options("-Wno-missing-braces") # warning: suggest braces around initialization of subobject | ||
add_compile_options("-Wno-unused-variable") # warning: unused variable '<id>' | ||
add_compile_options("-Wno-undefined-var-template") # warning: instantiation of variable '<templated id>' required here, but no definition is available | ||
endif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
|
||
# Recurse into tests dir to pick up unit tests | ||
add_subdirectory(tests) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
cmake_minimum_required (VERSION 3.0) # The minimum version of CMake necessary to build this project | ||
project (2014-04-21-HPC-GPU_Meetup) # The name of our project | ||
|
||
declare_trisycl_test(TARGET slide_7 TEST_REGEX "1234") | ||
declare_trisycl_test(TARGET slide_9-20 TEST_REGEX "1234") | ||
declare_trisycl_test(TARGET slide_13 TEST_REGEX "= 3") | ||
declare_trisycl_test(TARGET slide_14 TEST_REGEX "= 3") | ||
declare_trisycl_test(TARGET slide_17-18 TEST_REGEX "1234") | ||
declare_trisycl_test(TARGET slide_21 TEST_REGEX "1234") | ||
declare_trisycl_test(TARGET slide_22 TEST_REGEX "= 10") | ||
declare_trisycl_test(TARGET slide_23 TEST_REGEX "1234") | ||
declare_trisycl_test(TARGET slide_26 TEST_REGEX "= 42") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
include(CMakeParseArguments) # Helper macro to define new functions | ||
|
||
function(declare_trisycl_test) | ||
|
||
# Setup argument parsing | ||
set(options USES_OPENCL FORCE_SYNCRONOUS_EXEC XILINX_SPECIFIC) | ||
set(oneValueArgs TARGET TEST_REGEX) | ||
set(multiValueArgs HEADERS SOURCES KERNELS) | ||
|
||
# Parse function arguments | ||
cmake_parse_arguments(declare_trisycl_test "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) | ||
|
||
# Declare source code files | ||
set (Files_HDRS ${declare_trisycl_test_HEADERS}) | ||
|
||
# If sources are defined, use them; otherwise default to TARGET.cpp | ||
if("${declare_trisycl_test_SOURCES}" STREQUAL "") | ||
set (Files_SRCS "${PROJECT_SOURCE_DIR}/${declare_trisycl_test_TARGET}.cpp") | ||
else("${declare_trisycl_test_SOURCES}" STREQUAL "") | ||
set (Files_SRCS ${declare_trisycl_test_SOURCES}) | ||
endif("${declare_trisycl_test_SOURCES}" STREQUAL "") | ||
|
||
set_source_files_properties(${Files_SRCS} PROPERTIES LANGUAGE CXX ) # Needed because of sloppy file naming in multiple_compilation_units test | ||
|
||
# Variable to hold ALL files to build and be visible in IDE | ||
set (Files_BUILD ${Files_HDRS} ${Files_SRCS}) | ||
|
||
# Create filters for IDEs | ||
source_group ("Headers" FILES ${Files_HDRS}) | ||
source_group ("Sources" FILES ${Files_SRCS}) | ||
|
||
set(TARGET_NAME "${PROJECT_NAME}_${declare_trisycl_test_TARGET}") # Disambiguates sources with identical names from different directories | ||
set(TEST_NAME "${PROJECT_NAME}/${declare_trisycl_test_TARGET}") # Save for multiple uses later | ||
|
||
# Specify executable sources | ||
add_executable (${TARGET_NAME} ${Files_BUILD}) | ||
|
||
# Add include directories to the "#include <>" paths | ||
target_include_directories (${TARGET_NAME} PUBLIC #$<$<BOOL:${declare_trisycl_test_USES_OPENCL}>:${OpenCL_INCLUDE_DIRS}> # include OpenCL headers if example uses it | ||
${OpenCL_INCLUDE_DIRS} | ||
$<$<BOOL:${UNIX}>:${BOOST_COMPUTE_INCPATH}> | ||
${Boost_INCLUDE_DIRS}) | ||
|
||
# Link dependencies | ||
target_link_libraries (${TARGET_NAME} PUBLIC #$<$<BOOL:${declare_trisycl_test_USES_OPENCL}>:${OpenCL_LIBRARIES}> # Link to OpenCL if example requires | ||
${OpenCL_LIBRARIES} | ||
$<$<NOT:$<BOOL:${WIN32}>>:Threads::Threads> # If not on Windows, use some threading model | ||
$<$<BOOL:${WIN32}>:Boost::disable_autolinking> # Boost can auto-link when used with MSVC, but relies on relative paths which CMake does not really like | ||
$<$<OR:$<BOOL:${TRISYCL_DEBUG}>,$<BOOL:${TRISYCL_DEBUG_STRUCTORS}>>:Boost::log> # Link to Boost.log when triSYCL in debug mode | ||
Boost::chrono) | ||
|
||
# Compile definitions | ||
target_compile_definitions(${TARGET_NAME} PUBLIC $<$<BOOL:${TRISYCL_NO_ASYNC}>:TRISYCL_NO_ASYNC> # If opting for synchronous task exec | ||
$<$<BOOL:${declare_trisycl_test_USES_OPENCL}>:TRISYCL_OPENCL> # If the test uses OpenCL | ||
$<$<BOOL:${TRISYCL_DEBUG}>:TRISYCL_DEBUG> | ||
$<$<BOOL:${TRISYCL_DEBUG_STRUCTORS}>:TRISYCL_DEBUG_STRUCTORS>) | ||
|
||
# OpenMP requirements | ||
target_compile_options(${TARGET_NAME} PUBLIC $<$<BOOL:${TRISYCL_OPENMP}>:${OpenMP_CXX_FLAGS}>) | ||
|
||
if(${TRISYCL_OPENMP} AND (NOT WIN32)) | ||
set_target_properties(${TARGET_NAME} PROPERTIES LINK_FLAGS ${OpenMP_CXX_FLAGS}) # Does not support generator expressions | ||
endif(${TRISYCL_OPENMP} AND (NOT WIN32)) | ||
|
||
# Add unit test | ||
add_test(NAME ${TEST_NAME} | ||
COMMAND ${TARGET_NAME} | ||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}) | ||
|
||
# If test uses regular expression | ||
if(NOT ${declare_trisycl_test_TEST_REGEX} STREQUAL "") | ||
set_tests_properties (${TEST_NAME} PROPERTIES PASS_REGULAR_EXPRESSION ${declare_trisycl_test_TEST_REGEX}) | ||
endif(NOT ${declare_trisycl_test_TEST_REGEX} STREQUAL "") | ||
|
||
endfunction(declare_trisycl_test) | ||
|
||
# Recurse into tests dir to pick up unit tests | ||
add_subdirectory(2014-04-21-HPC-GPU_Meetup) | ||
add_subdirectory(accessor) | ||
add_subdirectory(address_spaces) | ||
add_subdirectory(buffer) | ||
add_subdirectory(detail) | ||
add_subdirectory(device) | ||
add_subdirectory(device_selector) | ||
add_subdirectory(examples) | ||
add_subdirectory(group) | ||
add_subdirectory(id) | ||
add_subdirectory(item) | ||
add_subdirectory(jacobi) | ||
add_subdirectory(kernel) | ||
add_subdirectory(math) | ||
add_subdirectory(multiple_compilation_units) | ||
add_subdirectory(nd_item) | ||
add_subdirectory(nd_range) | ||
add_subdirectory(parallel_for) | ||
add_subdirectory(pipe) | ||
add_subdirectory(platform) | ||
add_subdirectory(queue) | ||
add_subdirectory(range) | ||
add_subdirectory(single_task) | ||
#add_subdirectory(SDAccel) | ||
add_subdirectory(vector) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cmake_minimum_required (VERSION 3.0) # The minimum version of CMake necessary to build this project | ||
project (accessor) # The name of our project | ||
|
||
declare_trisycl_test(TARGET accessor) | ||
declare_trisycl_test(TARGET accessor_sizes) | ||
declare_trisycl_test(TARGET demo_parallel_matrix_add) | ||
declare_trisycl_test(TARGET iterators) | ||
declare_trisycl_test(TARGET local_accessor_hierarchical_convolution) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
cmake_minimum_required (VERSION 3.0) # The minimum version of CMake necessary to build this project | ||
project (address_space) # The name of our project | ||
|
||
declare_trisycl_test(TARGET address_spaces TEST_REGEX | ||
"i = 3 | ||
f\\[0\\] = 2 | ||
f\\[0\\] = 2 | ||
f\\[1\\] = 3 | ||
f\\[1\\] = 3 | ||
f\\[0\\] = 2 | ||
\\*c_p = s | ||
global_float = 6 | ||
Range = {2,3} | ||
Range2 = {2,3} | ||
s = yo man Size = 6 | ||
ps = yo manyo man Size = 12 | ||
e-salut | ||
e-= Mont a ra mat\\? | ||
3") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
cmake_minimum_required (VERSION 3.0) # The minimum version of CMake necessary to build this project | ||
project (buffer) # The name of our project | ||
|
||
declare_trisycl_test(TARGET associative_containers) | ||
declare_trisycl_test(TARGET buffer_get_count) | ||
declare_trisycl_test(TARGET buffer_map_allocator) | ||
declare_trisycl_test(TARGET buffer_set_final_data_1) | ||
declare_trisycl_test(TARGET buffer_set_final_data) | ||
declare_trisycl_test(TARGET buffer_shared_ptr) | ||
declare_trisycl_test(TARGET buffer_sizes) | ||
declare_trisycl_test(TARGET buffer_unique_ptr) | ||
declare_trisycl_test(TARGET global_buffer_host_access TEST_REGEX "1 2 3 4 5 6") | ||
declare_trisycl_test(TARGET global_buffer_set_final_data) | ||
declare_trisycl_test(TARGET global_buffer TEST_REGEX "3 5 7 9 11 13") | ||
declare_trisycl_test(TARGET read_write_buffer TEST_REGEX | ||
"buffer \"a\" is read_only: 0 | ||
buffer \"b\" is read_only: 0 | ||
buffer \"c\" is read_only: 0 | ||
buffer \"cc\" is read_only: 1 | ||
buffer \"vb\" is read_only: 0") | ||
declare_trisycl_test(TARGET shared_buffer TEST_REGEX | ||
"buffer \"a\" use_count\\(\\) is: 20 | ||
buffer \"a\" is read_only: 0 | ||
buffer \"a\" use_count\\(\\) is: 20 | ||
buffer \"b\" use_count\\(\\) is: 20 | ||
buffer \"b\" is read_only: 0 | ||
buffer \"a\" use_count\\(\\) is: 20 | ||
buffer \"b\" use_count\\(\\) is: 20 | ||
buffer \"c\" use_count\\(\\) is: 20 | ||
buffer \"a\" use_count\\(\\) is: 20 | ||
buffer \"b\" use_count\\(\\) is: 20 | ||
buffer \"c\" use_count\\(\\) is: 20 | ||
buffer \"c\" is read_only: 0 | ||
buffer \"a\" use_count\\(\\) is: 20 | ||
buffer \"b\" use_count\\(\\) is: 20 | ||
buffer \"c\" use_count\\(\\) is: 20 | ||
buffer \"a\" use_count\\(\\) is: 20 | ||
buffer \"z\" use_count\\(\\) is: 20 | ||
buffer \"z\" is read_only: 0") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
cmake_minimum_required (VERSION 3.0) # The minimum version of CMake necessary to build this project | ||
project (detail) # The name of our project | ||
|
||
declare_trisycl_test(TARGET small_array) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
cmake_minimum_required (VERSION 3.0) # The minimum version of CMake necessary to build this project | ||
project (device) # The name of our project | ||
|
||
declare_trisycl_test(TARGET default_device) | ||
declare_trisycl_test(TARGET get_info) | ||
declare_trisycl_test(TARGET type) | ||
if(${BUILD_OPENCL}) | ||
declare_trisycl_test(TARGET opencl_device USES_OPENCL) | ||
endif(${BUILD_OPENCL}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cmake_minimum_required (VERSION 3.0) # The minimum version of CMake necessary to build this project | ||
project (device_selector) # The name of our project | ||
|
||
declare_trisycl_test(TARGET explicit_selector) | ||
declare_trisycl_test(TARGET selector) | ||
if(${BUILD_OPENCL}) | ||
declare_trisycl_test(TARGET opencl_selector USES_OPENCL) | ||
endif(${BUILD_OPENCL}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
cmake_minimum_required (VERSION 3.0) # The minimum version of CMake necessary to build this project | ||
project (examples) # The name of our project | ||
|
||
declare_trisycl_test(TARGET demo_parallel_matrices_add) | ||
declare_trisycl_test(TARGET demo_parallel_matrix_add) | ||
declare_trisycl_test(TARGET parallel_matrix_add TEST_REGEX "3 5 7 9 11 13") | ||
declare_trisycl_test(TARGET parallel_vector_add TEST_REGEX "6 8 11") | ||
declare_trisycl_test(TARGET simpler_parallel_matrix_add TEST_REGEX "= 7") | ||
declare_trisycl_test(TARGET vector_add TEST_REGEX "6 8 11") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
cmake_minimum_required (VERSION 3.0) # The minimum version of CMake necessary to build this project | ||
project (group) # The name of our project | ||
|
||
declare_trisycl_test(TARGET group TEST_REGEX | ||
" 10 | ||
2 | ||
0 | ||
5 | ||
5 | ||
10 | ||
10 | ||
2 | ||
2 | ||
0 | ||
0 | ||
3 | ||
3 | ||
3 | ||
100 10 | ||
2 5 | ||
0 0 | ||
50 2 | ||
50 2 | ||
100 10 | ||
100 10 | ||
2 5 | ||
2 5 | ||
0 0 | ||
0 0 | ||
49 1 | ||
49 1 | ||
99 | ||
10 9 12 | ||
2 3 6 | ||
1 2 3 | ||
5 3 2 | ||
5 3 2 | ||
10 9 12 | ||
10 9 12 | ||
2 3 6 | ||
2 3 6 | ||
1 2 3 | ||
1 2 3 | ||
4 2 1 | ||
4 2 1 | ||
29") |
Oops, something went wrong.