[SYCL] Auto-detect presence of CL/sycl.hpp and ComputeCpp

This commit is contained in:
James Price 2016-05-11 22:00:04 +01:00
parent d4e74a88e9
commit 7cd14f480d

View File

@ -6,6 +6,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
project(gpu-stream) project(gpu-stream)
include(CheckIncludeFileCXX)
set(gpu-stream_VERSION_MAJOR 2) set(gpu-stream_VERSION_MAJOR 2)
set(gpu-stream_VERSION_MINOR 0) set(gpu-stream_VERSION_MINOR 0)
@ -108,20 +110,24 @@ endif ()
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# SYCL # SYCL
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# TODO: Find SYCL implementations somehow set(CMAKE_REQUIRED_FLAGS "-std=c++11")
if (true) check_include_file_cxx("CL/sycl.hpp" HAS_SYCL)
# ComputeCpp if (HAS_SYCL)
# TODO: Sort this out properly! find_program(COMPUTECPP "compute++")
add_custom_target(gpu-stream-sycl if (COMPUTECPP)
COMMAND compute++ ${CMAKE_CURRENT_SOURCE_DIR}/SYCLStream.cpp -sycl -no-serial-memop -O2 -emit-llvm -o SYCLStream.bc -c message(STATUS "Using ComputeCpp for SYCL compilation")
COMMAND /usr/bin/c++ ${CMAKE_CURRENT_SOURCE_DIR}/SYCLStream.cpp -O2 -std=c++11 -include SYCLStream.sycl -o SYCLStream.o -c add_custom_target(SYCLStream.sycl COMMAND ${COMPUTECPP} ${CMAKE_CURRENT_SOURCE_DIR}/SYCLStream.cpp -sycl -no-serial-memop -O2 -emit-llvm -c)
COMMAND /usr/bin/c++ ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp -O2 -std=c++11 SYCLStream.o -include SYCLStream.sycl -lSYCL -lOpenCL -o gpu-stream-sycl -DSYCL add_executable(gpu-stream-sycl main.cpp SYCLStream.cpp)
) add_dependencies(gpu-stream-sycl SYCLStream.sycl)
target_compile_definitions(gpu-stream-sycl PUBLIC SYCL)
# triSYCL target_compile_options(gpu-stream-sycl PUBLIC -include SYCLStream.sycl)
#add_executable(gpu-stream-sycl main.cpp SYCLStream.cpp) target_link_libraries(gpu-stream-sycl SYCL OpenCL)
#target_compile_definitions(gpu-stream-sycl PUBLIC SYCL) else()
#set_property(TARGET gpu-stream-sycl PROPERTY CXX_STANDARD 14) message(STATUS "Using header-only SYCL implementation")
add_executable(gpu-stream-sycl main.cpp SYCLStream.cpp)
target_compile_definitions(gpu-stream-sycl PUBLIC SYCL)
set_property(TARGET gpu-stream-sycl PROPERTY CXX_STANDARD 14)
endif(COMPUTECPP)
else () else ()
message("Skipping SYCL...") message("Skipping SYCL...")
endif () endif (HAS_SYCL)