diff --git a/CMakeLists.txt b/CMakeLists.txt index dfdba1b..d92fa8b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,34 +7,42 @@ option(PARALLEL_STL_BENCHMARKS "Build the internal benchmarks" OFF) option(USE_COMPUTECPP "Use ComputeCPP" ON) message(STATUS " Path to CMAKE source directory: ${CMAKE_SOURCE_DIR} ") -set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules/) + +list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules) find_package(Threads REQUIRED) +set(CMAKE_CXX_STANDARD 14) + if (USE_COMPUTECPP) message(STATUS " Using ComputeCpp CMake") - message(STATUS " Path to ComputeCpp implementation: ${COMPUTECPP_PACKAGE_ROOT_DIR} ") - - set(CMAKE_CXX_STANDARD 11) - include(FindOpenCL) include(FindComputeCpp) add_definitions(-DSYCL_PSTL_USE_OLD_ALGO) - set(COMPUTECPP_DEVICE_COMPILER_FLAGS "${COMPUTECPP_DEVICE_COMPILER_FLAGS} -DSYCL_PSTL_USE_OLD_ALGO") - - include_directories("${COMPUTECPP_INCLUDE_DIRECTORY}") - - + set(SYCL_LIBRARY ${COMPUTECPP_RUNTIME_LIBRARY}) + set(SYCL_INCLUDE_DIRS ${ComputeCpp_INCLUDE_DIRS}) else() message(STATUS " Using triSYCL CMake") include(FindTriSYCL) + set(SYCL_INCLUDE_DIRS ${TRISYCL_INCLUDE_DIR}) + set(SYCL_LIBRARY) # Not needed for TriSYCL endif() # PSTL specific include_directories("include") +# Function to build a file +function(build_file file) + get_filename_component(SOURCE_NAME ${file} NAME_WE) + message(STATUS " Adding ${SOURCE_NAME} ") + + add_executable(${SOURCE_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/${file} ) + + add_sycl_to_target(TARGET ${SOURCE_NAME} SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/${file}) +endfunction() + add_subdirectory (src) add_subdirectory (examples) add_subdirectory (tests) diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index 16d3ab7..ec57199 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -1,19 +1,22 @@ -file(GLOB EXAMPLE_FILES ./*.cpp) - -foreach(file ${EXAMPLE_FILES}) - - get_filename_component(SOURCE_NAME ${file} NAME_WE) - message(STATUS " Adding ${SOURCE_NAME} ") - - include_directories(${COMPUTECPP_INCLUDE_DIRECTORY}) - - add_executable(${SOURCE_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE_NAME}.cpp ) - target_compile_options(${SOURCE_NAME} PUBLIC ${HOST_COMPILER_OPTIONS}) - - target_link_libraries(${SOURCE_NAME} PUBLIC ${CMAKE_THREAD_LIBS_INIT}) - - add_sycl_to_target(${SOURCE_NAME} ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE_NAME}.cpp) - - +set(BENCHMARK_FILES + "basic.cpp" + "montecarloPI.cpp" + "nbody.cpp" + "std_foreach_saxpy.cpp" + "std_sort.cpp" + "std_transform_saxpy.cpp" + "sycl_exclusive_scan.cpp" + "sycl_foreach_saxpy.cpp" + "sycl_inclusive_scan.cpp" + "sycl_reduce.cpp" + "sycl_sort.cpp" + "sycl_transform_het_saxpy.cpp" + "sycl_transform_reduce_saxpy.cpp" + "sycl_transform_saxpy.cpp" + "word_count.cpp" +) + + +foreach(file ${BENCHMARK_FILES}) + build_file(${file}) endforeach() diff --git a/benchmarks/amd_cpu_selector.hpp b/benchmarks/amd_cpu_selector.hpp deleted file mode 100644 index 8ec2315..0000000 --- a/benchmarks/amd_cpu_selector.hpp +++ /dev/null @@ -1,63 +0,0 @@ -/* Copyright (c) 2015-2018 The Khronos Group Inc. - - Permission is hereby granted, free of charge, to any person obtaining a - copy of this software and/or associated documentation files (the - "Materials"), to deal in the Materials without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Materials, and to - permit persons to whom the Materials are furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Materials. - - MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS - KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS - SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT - https://www.khronos.org/registry/ - - THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. - -*/ - -#ifndef __AMD_CPU_SELECTOR__ -#define __AMD_CPU_SELECTOR__ - -#include -#include -#include - -/** class amd_cpu_selector. -* @brief Looks for an AMD cpu among the available CPUs. -* if it finds an AMD CPU it will return an 1, otherwise it returns a -1. -*/ -class amd_cpu_selector : public cl::sycl::device_selector { - public: - amd_cpu_selector() : cl::sycl::device_selector() {} - - int operator()(const cl::sycl::device &device) const { - int res = -1; - if (device.is_host()) { - res = -1; - } else { - cl::sycl::info::device_type type = - device.get_info(); - if (type == cl::sycl::info::device_type::cpu) { - cl::sycl::platform plat = device.get_platform(); - std::string name = plat.get_info(); - if (name.find("AMD") != std::string::npos) { - res = 1; - } - } - } - return res; - } -}; - -#endif // __AMD_CPU_SELECTOR__ diff --git a/benchmarks/sycl_transform_het_saxpy.cpp b/benchmarks/sycl_transform_het_saxpy.cpp index 54cb085..fd548fa 100644 --- a/benchmarks/sycl_transform_het_saxpy.cpp +++ b/benchmarks/sycl_transform_het_saxpy.cpp @@ -35,7 +35,6 @@ #include #include -#include "amd_cpu_selector.hpp" #include "benchmark.h" @@ -56,7 +55,7 @@ benchmark<>::time_units_t benchmark_transform_heterogeneous( res.push_back(i); } cl::sycl::queue q; - amd_cpu_selector cpu_sel; + cl::sycl::cpu_selector cpu_sel; cl::sycl::queue q2(cpu_sel); sycl::sycl_heterogeneous_execution_policy snp( q, q2, ratio); diff --git a/build.sh b/build.sh index 79f3464..a4defe3 100755 --- a/build.sh +++ b/build.sh @@ -49,31 +49,15 @@ then CMAKE_ARGS="$CMAKE_ARGS -DUSE_COMPUTECPP=OFF $@" else echo "build.sh entering mode: ComputeCpp" - CMAKE_ARGS="$CMAKE_ARGS -DCOMPUTECPP_PACKAGE_ROOT_DIR=$(readlink -f $1)" + CMAKE_ARGS="$CMAKE_ARGS -DComputeCpp_DIR=$(readlink -f $1)" shift fi NPROC=$(nproc) -function install_gmock {( - REPO="https://github.com/google/googletest.git" - mkdir -p external - cd external - if [ -d googletest ] - then - cd googletest - $NO_DOWNLOAD git pull - else - $NO_DOWNLOAD git clone $REPO - cd googletest - fi - cd googlemock/make - make -j$NPROC -)} - function configure { mkdir -p build && pushd build - cmake .. $CMAKE_ARGS -DPARALLEL_STL_BENCHMARKS=ON + cmake .. $CMAKE_ARGS -DCMAKE_BUILD_TYPE=RelWithDebInfo -DPARALLEL_STL_BENCHMARKS=ON popd } @@ -89,7 +73,6 @@ function tst { } function main { - install_gmock configure mak tst diff --git a/cmake/Modules/FindComputeCpp.cmake b/cmake/Modules/FindComputeCpp.cmake index 9447bc0..e265b55 100644 --- a/cmake/Modules/FindComputeCpp.cmake +++ b/cmake/Modules/FindComputeCpp.cmake @@ -2,7 +2,7 @@ # FindComputeCpp #--------------- # -# Copyright 2016 Codeplay Software Ltd. +# Copyright 2016-2018 Codeplay Software Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use these files except in compliance with the License. @@ -23,172 +23,210 @@ # # Tools for finding and building with ComputeCpp. # -# User must define COMPUTECPP_PACKAGE_ROOT_DIR pointing to the ComputeCpp -# installation. +# User must define ComputeCpp_DIR pointing to the ComputeCpp +# installation. # # Latest version of this file can be found at: # https://github.com/codeplaysoftware/computecpp-sdk -# Require CMake version 3.2.2 or higher -cmake_minimum_required(VERSION 3.2.2) +cmake_minimum_required(VERSION 3.4.3) +include(FindPackageHandleStandardArgs) # Check that a supported host compiler can be found if(CMAKE_COMPILER_IS_GNUCXX) # Require at least gcc 4.8 if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) message(FATAL_ERROR - "host compiler - Not found! (gcc version must be at least 4.8)") - else() - message(STATUS "host compiler - gcc ${CMAKE_CXX_COMPILER_VERSION}") + "host compiler - gcc version must be at least 4.8") endif() elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") # Require at least clang 3.6 if (${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 3.6) message(FATAL_ERROR - "host compiler - Not found! (clang version must be at least 3.6)") - else() - message(STATUS "host compiler - clang ${CMAKE_CXX_COMPILER_VERSION}") + "host compiler - clang version must be at least 3.6") endif() endif() -set(COMPUTECPP_64_BIT_DEFAULT ON) -option(COMPUTECPP_64_BIT_CODE "Compile device code in 64 bit mode" - ${COMPUTECPP_64_BIT_DEFAULT}) -mark_as_advanced(COMPUTECPP_64_BIT_CODE) - -option(COMPUTECPP_DISABLE_GCC_DUAL_ABI "Compile with pre-5.1 ABI" OFF) -mark_as_advanced(COMPUTECPP_DISABLE_GCC_DUAL_ABI) - set(COMPUTECPP_USER_FLAGS "" CACHE STRING "User flags for compute++") mark_as_advanced(COMPUTECPP_USER_FLAGS) -# Platform-specific arguments -if(MSVC) - # Workaround to an unfixed Clang bug, rationale: - # https://github.com/codeplaysoftware/computecpp-sdk/pull/51#discussion_r139399093 - set (COMPUTECPP_PLATFORM_SPECIFIC_ARGS "-fno-ms-compatibility") -endif() +set(COMPUTECPP_BITCODE "spir64" CACHE STRING + "Bitcode type to use as SYCL target in compute++") +mark_as_advanced(COMPUTECPP_BITCODE) -# Find OpenCL package find_package(OpenCL REQUIRED) # Find ComputeCpp package -if(NOT COMPUTECPP_PACKAGE_ROOT_DIR) - message(FATAL_ERROR - "ComputeCpp package - Not found! (please set COMPUTECPP_PACKAGE_ROOT_DIR)") -else() - message(STATUS "ComputeCpp package - Found") -endif() -# Obtain the path to compute++ -find_program(COMPUTECPP_DEVICE_COMPILER compute++ PATHS - ${COMPUTECPP_PACKAGE_ROOT_DIR} PATH_SUFFIXES bin) -if (EXISTS ${COMPUTECPP_DEVICE_COMPILER}) - mark_as_advanced(COMPUTECPP_DEVICE_COMPILER) - message(STATUS "compute++ - Found") -else() - message(FATAL_ERROR "compute++ - Not found! (${COMPUTECPP_DEVICE_COMPILER})") +if(DEFINED ComputeCpp_DIR) + set(computecpp_find_hint ${ComputeCpp_DIR}) +elseif(DEFINED ENV{COMPUTECPP_DIR}) + set(computecpp_find_hint $ENV{COMPUTECPP_DIR}) endif() -# Obtain the path to computecpp_info -find_program(COMPUTECPP_INFO_TOOL computecpp_info PATHS - ${COMPUTECPP_PACKAGE_ROOT_DIR} PATH_SUFFIXES bin) -if (EXISTS ${COMPUTECPP_INFO_TOOL}) - mark_as_advanced(${COMPUTECPP_INFO_TOOL}) - message(STATUS "computecpp_info - Found") -else() - message(FATAL_ERROR "computecpp_info - Not found! (${COMPUTECPP_INFO_TOOL})") +# Used for running executables on the host +set(computecpp_host_find_hint ${computecpp_find_hint}) + +if(CMAKE_CROSSCOMPILING) + # ComputeCpp_HOST_DIR is used to find executables that are run on the host + if(DEFINED ComputeCpp_HOST_DIR) + set(computecpp_host_find_hint ${ComputeCpp_HOST_DIR}) + elseif(DEFINED ENV{COMPUTECPP_HOST_DIR}) + set(computecpp_host_find_hint $ENV{COMPUTECPP_HOST_DIR}) + endif() endif() -# Obtain the path to the ComputeCpp runtime library +find_program(ComputeCpp_DEVICE_COMPILER_EXECUTABLE compute++ + HINTS ${computecpp_host_find_hint} + PATH_SUFFIXES bin) + +find_program(ComputeCpp_INFO_EXECUTABLE computecpp_info + HINTS ${computecpp_host_find_hint} + PATH_SUFFIXES bin) + find_library(COMPUTECPP_RUNTIME_LIBRARY NAMES ComputeCpp ComputeCpp_vs2015 - PATHS ${COMPUTECPP_PACKAGE_ROOT_DIR} - HINTS ${COMPUTECPP_PACKAGE_ROOT_DIR}/lib PATH_SUFFIXES lib - DOC "ComputeCpp Runtime Library" NO_DEFAULT_PATH) - -if (EXISTS ${COMPUTECPP_RUNTIME_LIBRARY}) - mark_as_advanced(COMPUTECPP_RUNTIME_LIBRARY) -else() - message(FATAL_ERROR "ComputeCpp Runtime Library - Not found!") -endif() + HINTS ${computecpp_find_hint} + PATH_SUFFIXES lib + DOC "ComputeCpp Runtime Library") find_library(COMPUTECPP_RUNTIME_LIBRARY_DEBUG NAMES ComputeCpp ComputeCpp_vs2015_d - PATHS ${COMPUTECPP_PACKAGE_ROOT_DIR} - HINTS ${COMPUTECPP_PACKAGE_ROOT_DIR}/lib PATH_SUFFIXES lib - DOC "ComputeCpp Debug Runtime Library" NO_DEFAULT_PATH) - -if (EXISTS ${COMPUTECPP_RUNTIME_LIBRARY_DEBUG}) - mark_as_advanced(COMPUTECPP_RUNTIME_LIBRARY_DEBUG) -else() - message(FATAL_ERROR "ComputeCpp Debug Runtime Library - Not found!") + HINTS ${computecpp_find_hint} + PATH_SUFFIXES lib + DOC "ComputeCpp Debug Runtime Library") + +find_path(ComputeCpp_INCLUDE_DIRS + NAMES "CL/sycl.hpp" + HINTS ${computecpp_find_hint}/include + DOC "The ComputeCpp include directory") +get_filename_component(ComputeCpp_INCLUDE_DIRS ${ComputeCpp_INCLUDE_DIRS} ABSOLUTE) + +get_filename_component(computecpp_canonical_root_dir "${ComputeCpp_INCLUDE_DIRS}/.." ABSOLUTE) +set(ComputeCpp_ROOT_DIR "${computecpp_canonical_root_dir}" CACHE PATH + "The root of the ComputeCpp install") + +execute_process(COMMAND ${ComputeCpp_INFO_EXECUTABLE} "--dump-version" + OUTPUT_VARIABLE ComputeCpp_VERSION + RESULT_VARIABLE ComputeCpp_INFO_EXECUTABLE_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE) +if(NOT ComputeCpp_INFO_EXECUTABLE_RESULT EQUAL "0") + message(FATAL_ERROR "Package version - Error obtaining version!") endif() -# NOTE: Having two sets of libraries is Windows specific, not MSVC specific. -# Compiling with Clang on Windows would still require linking to both of them. -if (${CMAKE_SYSTEM_NAME} MATCHES "Windows") - message(STATUS "ComputeCpp runtime (Release): ${COMPUTECPP_RUNTIME_LIBRARY} - Found") - message(STATUS "ComputeCpp runtime (Debug) : ${COMPUTECPP_RUNTIME_LIBRARY_DEBUG} - Found") +execute_process(COMMAND ${ComputeCpp_INFO_EXECUTABLE} "--dump-is-supported" + OUTPUT_VARIABLE COMPUTECPP_PLATFORM_IS_SUPPORTED + RESULT_VARIABLE ComputeCpp_INFO_EXECUTABLE_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE) +if(NOT ComputeCpp_INFO_EXECUTABLE_RESULT EQUAL "0") + message(FATAL_ERROR "platform - Error checking platform support!") else() - message(STATUS "ComputeCpp runtime: ${COMPUTECPP_RUNTIME_LIBRARY} - Found") + mark_as_advanced(COMPUTECPP_PLATFORM_IS_SUPPORTED) + if (COMPUTECPP_PLATFORM_IS_SUPPORTED) + message(STATUS "platform - your system can support ComputeCpp") + else() + message(WARNING "platform - your system CANNOT support ComputeCpp") + endif() endif() -# Obtain the ComputeCpp include directory -set(COMPUTECPP_INCLUDE_DIRECTORY ${COMPUTECPP_PACKAGE_ROOT_DIR}/include/) -if (NOT EXISTS ${COMPUTECPP_INCLUDE_DIRECTORY}) - message(FATAL_ERROR "ComputeCpp includes - Not found!") -else() - message(STATUS "ComputeCpp includes - Found") -endif() +execute_process(COMMAND ${ComputeCpp_INFO_EXECUTABLE} + "--dump-device-compiler-flags" + OUTPUT_VARIABLE COMPUTECPP_DEVICE_COMPILER_FLAGS + RESULT_VARIABLE ComputeCpp_INFO_EXECUTABLE_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE) -# Obtain the package version -execute_process(COMMAND ${COMPUTECPP_INFO_TOOL} "--dump-version" - OUTPUT_VARIABLE COMPUTECPP_PACKAGE_VERSION - RESULT_VARIABLE COMPUTECPP_INFO_TOOL_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE) -if(NOT COMPUTECPP_INFO_TOOL_RESULT EQUAL "0") - message(FATAL_ERROR "Package version - Error obtaining version!") -else() - mark_as_advanced(COMPUTECPP_PACKAGE_VERSION) - message(STATUS "Package version - ${COMPUTECPP_PACKAGE_VERSION}") +if(NOT ComputeCpp_INFO_EXECUTABLE_RESULT EQUAL "0") + message(FATAL_ERROR "compute++ flags - Error obtaining compute++ flags!") endif() +mark_as_advanced(COMPUTECPP_DEVICE_COMPILER_FLAGS) +separate_arguments(COMPUTECPP_DEVICE_COMPILER_FLAGS) -# Obtain the device compiler flags -set(USE_SPIRV "") -if (COMPUTECPP_USE_SPIRV) - set(USE_SPIRV "--use-spirv") +# Check if the hosted STL of MSVC is compatible with ComputeCpp +if(MSVC) + set(ComputeCpp_STL_CHECK_SRC __STL_check) + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${ComputeCpp_STL_CHECK_SRC}.cpp + "#include \n" + "int main() { return 0; }\n") + execute_process( + COMMAND ${ComputeCpp_DEVICE_COMPILER_EXECUTABLE} + ${COMPUTECPP_DEVICE_COMPILER_FLAGS} + -isystem ${ComputeCpp_INCLUDE_DIRS} + -o ${ComputeCpp_STL_CHECK_SRC}.sycl + -c ${ComputeCpp_STL_CHECK_SRC}.cpp + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + RESULT_VARIABLE ComputeCpp_STL_CHECK_RESULT + ERROR_QUIET + OUTPUT_QUIET) + if(NOT ${ComputeCpp_STL_CHECK_RESULT} EQUAL 0) + # Try disabling compiler version checks + execute_process( + COMMAND ${ComputeCpp_DEVICE_COMPILER_EXECUTABLE} + ${COMPUTECPP_DEVICE_COMPILER_FLAGS} + -D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH + -isystem ${ComputeCpp_INCLUDE_DIRS} + -o ${ComputeCpp_STL_CHECK_SRC}.cpp.sycl + -c ${ComputeCpp_STL_CHECK_SRC}.cpp + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + RESULT_VARIABLE ComputeCpp_STL_CHECK_RESULT + ERROR_QUIET + OUTPUT_QUIET) + if(NOT ${ComputeCpp_STL_CHECK_RESULT} EQUAL 0) + message(STATUS "Device compiler cannot consume hosted STL headers. Using any parts of the STL will likely result in device compiler errors.") + else() + message(STATUS "Device compiler does not meet certain STL version requirements. Disabling version checks and hoping for the best.") + list(APPEND COMPUTECPP_DEVICE_COMPILER_FLAGS -D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH) + endif() + endif() + file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/${ComputeCpp_STL_CHECK_SRC}.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${ComputeCpp_STL_CHECK_SRC}.cpp.sycl) +endif(MSVC) + +find_package_handle_standard_args(ComputeCpp + REQUIRED_VARS ComputeCpp_ROOT_DIR + ComputeCpp_DEVICE_COMPILER_EXECUTABLE + ComputeCpp_INFO_EXECUTABLE + COMPUTECPP_RUNTIME_LIBRARY + COMPUTECPP_RUNTIME_LIBRARY_DEBUG + ComputeCpp_INCLUDE_DIRS + VERSION_VAR ComputeCpp_VERSION) +mark_as_advanced(ComputeCpp_ROOT_DIR + ComputeCpp_DEVICE_COMPILER_EXECUTABLE + ComputeCpp_INFO_EXECUTABLE + COMPUTECPP_RUNTIME_LIBRARY + COMPUTECPP_RUNTIME_LIBRARY_DEBUG + ComputeCpp_INCLUDE_DIRS + ComputeCpp_VERSION) + +if(NOT ComputeCpp_FOUND) + return() endif() -set(USE_PTX "") -if (COMPUTECPP_USE_PTX) - set(USE_PTX "--use-ptx") +if(CMAKE_CROSSCOMPILING) + if(NOT SDK_DONT_USE_TOOLCHAIN) + list(APPEND COMPUTECPP_DEVICE_COMPILER_FLAGS --gcc-toolchain=${SDK_TOOLCHAIN_DIR}) + endif() + list(APPEND COMPUTECPP_DEVICE_COMPILER_FLAGS --sysroot=${SDK_SYSROOT_DIR}) + list(APPEND COMPUTECPP_DEVICE_COMPILER_FLAGS -target ${SDK_TARGET_TRIPLE}) endif() -execute_process(COMMAND ${COMPUTECPP_INFO_TOOL} - ${USE_SPIRV} ${USE_PTX} "--dump-device-compiler-flags" - OUTPUT_VARIABLE COMPUTECPP_DEVICE_COMPILER_FLAGS - RESULT_VARIABLE COMPUTECPP_INFO_TOOL_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE) +list(APPEND COMPUTECPP_DEVICE_COMPILER_FLAGS -sycl-target ${COMPUTECPP_BITCODE}) +list(REMOVE_ITEM COMPUTECPP_DEVICE_COMPILER_FLAGS -emit-llvm) +message(STATUS "compute++ flags - ${COMPUTECPP_DEVICE_COMPILER_FLAGS}") -if(NOT COMPUTECPP_INFO_TOOL_RESULT EQUAL "0") - message(FATAL_ERROR "compute++ flags - Error obtaining compute++ flags!") -else() - mark_as_advanced(COMPUTECPP_COMPILER_FLAGS) - message(STATUS "compute++ flags - ${COMPUTECPP_DEVICE_COMPILER_FLAGS}") +if(NOT TARGET OpenCL::OpenCL) + add_library(OpenCL::OpenCL UNKNOWN IMPORTED) + set_target_properties(OpenCL::OpenCL PROPERTIES + IMPORTED_LOCATION "${OpenCL_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${OpenCL_INCLUDE_DIRS}" + ) endif() -# Check if the platform is supported -execute_process(COMMAND ${COMPUTECPP_INFO_TOOL} "--dump-is-supported" - OUTPUT_VARIABLE COMPUTECPP_PLATFORM_IS_SUPPORTED - RESULT_VARIABLE COMPUTECPP_INFO_TOOL_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE) -if(NOT COMPUTECPP_INFO_TOOL_RESULT EQUAL "0") - message(FATAL_ERROR "platform - Error checking platform support!") -else() - mark_as_advanced(COMPUTECPP_PLATFORM_IS_SUPPORTED) - if (COMPUTECPP_PLATFORM_IS_SUPPORTED) - message(STATUS "platform - your system can support ComputeCpp") - else() - message(STATUS "platform - your system CANNOT support ComputeCpp") - endif() +if(NOT TARGET ComputeCpp::ComputeCpp) + add_library(ComputeCpp::ComputeCpp UNKNOWN IMPORTED) + set_target_properties(ComputeCpp::ComputeCpp PROPERTIES + IMPORTED_LOCATION_DEBUG "${COMPUTECPP_RUNTIME_LIBRARY_DEBUG}" + IMPORTED_LOCATION_RELWITHDEBINFO "${COMPUTECPP_RUNTIME_LIBRARY_DEBUG}" + IMPORTED_LOCATION "${COMPUTECPP_RUNTIME_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${ComputeCpp_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "OpenCL::OpenCL" + ) endif() # This property allows targets to specify that their sources should be @@ -203,50 +241,63 @@ define_property( the command line so that it is seen by the compiler first. Enables non-standards-conformant SYCL code to compile with ComputeCpp." ) +define_property( + TARGET PROPERTY INTERFACE_COMPUTECPP_FLAGS + BRIEF_DOCS "Interface compile flags to provide compute++" + FULL_DOCS "Set additional compile flags to pass to compute++ when compiling + any target which links to this one." +) +define_property( + SOURCE PROPERTY COMPUTECPP_SOURCE_FLAGS + BRIEF_DOCS "Source file compile flags for compute++" + FULL_DOCS "Set additional compile flags for compiling the SYCL integration + header for the given source file." +) #################### -# __build_sycl +# __build_ir #################### # # Adds a custom target for running compute++ and adding a dependency for the # resulting integration header. # -# targetName : Name of the target. -# sourceFile : Source file to be compiled. -# binaryDir : Intermediate directory to output the integration header. -# fileCounter : Counter included in name of custom target. Different counter -# values prevent duplicated names of custom target when source files with the same name, -# but located in different directories, are used for the same target. +# TARGET : Name of the target. +# SOURCE : Source file to be compiled. +# COUNTER : Counter included in name of custom target. Different counter +# values prevent duplicated names of custom target when source files with +# the same name, but located in different directories, are used for the +# same target. # -function(__build_spir targetName sourceFile binaryDir fileCounter) - - # Retrieve source file name. - get_filename_component(sourceFileName ${sourceFile} NAME) +function(__build_ir) + set(options) + set(one_value_args + TARGET + SOURCE + COUNTER + ) + set(multi_value_args) + cmake_parse_arguments(SDK_BUILD_IR + "${options}" + "${one_value_args}" + "${multi_value_args}" + ${ARGN} + ) + get_filename_component(sourceFileName ${SDK_BUILD_IR_SOURCE} NAME) - # Set the path to the Sycl file. - set(outputSyclFile ${binaryDir}/${sourceFileName}.sycl) + # Set the path to the integration header. + set(outputSyclFile ${CMAKE_CURRENT_BINARY_DIR}/${sourceFileName}.sycl) + set(depFileName ${CMAKE_CURRENT_BINARY_DIR}/${sourceFileName}.sycl.d) - # Add any user-defined include to the device compiler - set(device_compiler_includes "") - get_property(includeDirectories DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY - INCLUDE_DIRECTORIES) - foreach(directory ${includeDirectories}) - set(device_compiler_includes "-I${directory}" ${device_compiler_includes}) - endforeach() - get_target_property(targetIncludeDirectories ${targetName} INCLUDE_DIRECTORIES) - foreach(directory ${targetIncludeDirectories}) - set(device_compiler_includes "-I${directory}" ${device_compiler_includes}) - endforeach() - if (CMAKE_INCLUDE_PATH) - foreach(directory ${CMAKE_INCLUDE_PATH}) - set(device_compiler_includes "-I${directory}" - ${device_compiler_includes}) - endforeach() - endif() + set(include_directories "$") + set(compile_definitions "$") + set(generated_include_directories + $<$:-I\"$\">) + set(generated_compile_definitions + $<$:-D$>) # Obtain language standard of the file set(device_compiler_cxx_standard) - get_target_property(targetCxxStandard ${targetName} CXX_STANDARD) + get_target_property(targetCxxStandard ${SDK_BUILD_IR_TARGET} CXX_STANDARD) if (targetCxxStandard MATCHES 17) set(device_compiler_cxx_standard "-std=c++1z") elseif (targetCxxStandard MATCHES 14) @@ -254,78 +305,124 @@ function(__build_spir targetName sourceFile binaryDir fileCounter) elseif (targetCxxStandard MATCHES 11) set(device_compiler_cxx_standard "-std=c++11") elseif (targetCxxStandard MATCHES 98) - message(FATAL_ERROR "SYCL implementations cannot be compiled using C++98") + message(FATAL_ERROR "SYCL applications cannot be compiled using C++98") else () set(device_compiler_cxx_standard "") endif() - set(COMPUTECPP_DEVICE_COMPILER_FLAGS + get_property(source_compile_flags + SOURCE ${SDK_BUILD_IR_SOURCE} + PROPERTY COMPUTECPP_SOURCE_FLAGS + ) + if(source_compile_flags) + list(APPEND target_compile_flags ${source_compile_flags}) + endif() + + list(APPEND COMPUTECPP_DEVICE_COMPILER_FLAGS ${device_compiler_cxx_standard} - ${COMPUTECPP_DEVICE_COMPILER_FLAGS} - ${COMPUTECPP_USER_FLAGS}) - # Convert argument list format - separate_arguments(COMPUTECPP_DEVICE_COMPILER_FLAGS) + ${COMPUTECPP_USER_FLAGS} + ${target_compile_flags} + ) + + set(ir_dependencies ${SDK_BUILD_IR_SOURCE}) + get_target_property(target_libraries ${SDK_BUILD_IR_TARGET} LINK_LIBRARIES) + if(target_libraries) + foreach(library ${target_libraries}) + list(APPEND ir_dependencies ${library}) + endforeach() + endif() + + # Depfile support was only added in CMake 3.7 + # CMake throws an error if it is unsupported by the generator (i. e. not ninja) + if((NOT CMAKE_VERSION VERSION_LESS 3.7.0) AND + CMAKE_GENERATOR MATCHES "Ninja") + file(RELATIVE_PATH relOutputFile ${CMAKE_BINARY_DIR} ${outputSyclFile}) + set(generate_depfile -MMD -MF ${depFileName} -MT ${relOutputFile}) + set(enable_depfile DEPFILE ${depFileName}) + endif() # Add custom command for running compute++ add_custom_command( OUTPUT ${outputSyclFile} - COMMAND ${COMPUTECPP_DEVICE_COMPILER} + COMMAND ${ComputeCpp_DEVICE_COMPILER_EXECUTABLE} ${COMPUTECPP_DEVICE_COMPILER_FLAGS} - -isystem ${COMPUTECPP_INCLUDE_DIRECTORY} - ${COMPUTECPP_PLATFORM_SPECIFIC_ARGS} ${device_compiler_includes} + ${generated_include_directories} + ${generated_compile_definitions} -o ${outputSyclFile} - -c ${sourceFile} - DEPENDS ${sourceFile} - IMPLICIT_DEPENDS CXX ${sourceFile} - WORKING_DIRECTORY ${binaryDir} + -c ${SDK_BUILD_IR_SOURCE} + ${generate_depfile} + DEPENDS ${ir_dependencies} + IMPLICIT_DEPENDS CXX ${SDK_BUILD_IR_SOURCE} + ${enable_depfile} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Building ComputeCpp integration header file ${outputSyclFile}") - # Name: - # (user-defined name)_(source file)_(counter)_ih + # Name: (user-defined name)_(source file)_(counter)_ih set(headerTargetName - ${targetName}_${sourceFileName}_${fileCounter}_ih) - - # Add a custom target for the generated integration header - add_custom_target(${headerTargetName} DEPENDS ${outputSyclFile}) + ${SDK_BUILD_IR_TARGET}_${sourceFileName}_${SDK_BUILD_IR_COUNTER}_ih) - # Add a dependency on the integration header - add_dependencies(${targetName} ${headerTargetName}) + if(NOT MSVC) + # Add a custom target for the generated integration header + add_custom_target(${headerTargetName} DEPENDS ${outputSyclFile}) + add_dependencies(${SDK_BUILD_IR_TARGET} ${headerTargetName}) + endif() + + # This property can be set on a per-target basis to indicate that the + # integration header should appear after the main source listing + get_property(includeAfter TARGET ${SDK_BUILD_IR_TARGET} + PROPERTY COMPUTECPP_INCLUDE_AFTER) + + if(includeAfter) + # Change the source file to the integration header - e.g. + # g++ -c source_file_name.cpp.sycl + get_target_property(current_sources ${SDK_BUILD_IR_TARGET} SOURCES) + # Remove absolute path to source file + list(REMOVE_ITEM current_sources ${SDK_BUILD_IR_SOURCE}) + # Remove relative path to source file + string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" + rel_source_file ${SDK_BUILD_IR_SOURCE} + ) + list(REMOVE_ITEM current_sources ${rel_source_file}) + # Add SYCL header to source list + list(APPEND current_sources ${outputSyclFile}) + set_property(TARGET ${SDK_BUILD_IR_TARGET} + PROPERTY SOURCES ${current_sources}) + # CMake/gcc don't know what language a .sycl file is, so tell them + set_property(SOURCE ${outputSyclFile} PROPERTY LANGUAGE CXX) + set(includedFile ${SDK_BUILD_IR_SOURCE}) + set(cppFile ${outputSyclFile}) + else() + set_property(SOURCE ${outputSyclFile} PROPERTY HEADER_FILE_ONLY ON) + set(includedFile ${outputSyclFile}) + set(cppFile ${SDK_BUILD_IR_SOURCE}) + endif() # Force inclusion of the integration header for the host compiler if(MSVC) - # NOTE: The Visual Studio generators parse compile flags differently, - # hence the different argument syntax - if(CMAKE_GENERATOR MATCHES "Visual Studio") - set(forceIncludeFlags "/FI\"${outputSyclFile}\"") - else() - set(forceIncludeFlags /FI ${outputSyclFile}) - endif() - else() - # This property can be set on a per-target basis to indicate that the - # integration header should appear after the main source listing - get_property(includeAfter TARGET ${targetName} - PROPERTY COMPUTECPP_INCLUDE_AFTER) + # Group SYCL files inside Visual Studio + source_group("SYCL" FILES ${outputSyclFile}) + if(includeAfter) - # Change the source file to the integration header - i.e. - # g++ -c source_file_name.cpp.sycl - set_property(TARGET ${targetName} PROPERTY SOURCES ${outputSyclFile}) - # CMake/gcc don't know what language a .sycl file is, so tell them - set_property(SOURCE ${outputSyclFile} PROPERTY LANGUAGE CXX) - set(forceIncludeFlags -include ${sourceFile} -x c++) - else() - set(forceIncludeFlags -include ${outputSyclFile}) + # Allow the source file to be edited using Visual Studio. + # It will be added as a header file so it won't be compiled. + set_property(SOURCE ${SDK_BUILD_IR_SOURCE} PROPERTY HEADER_FILE_ONLY true) endif() + + # Add both source and the sycl files to the VS solution. + target_sources(${SDK_BUILD_IR_TARGET} PUBLIC ${SDK_BUILD_IR_SOURCE} ${outputSyclFile}) + + set(forceIncludeFlags "/FI ${includedFile} /TP") + else() + set(forceIncludeFlags "-include ${includedFile} -x c++") endif() - target_compile_options(${targetName} PUBLIC ${forceIncludeFlags}) - - # Disable GCC dual ABI on GCC 5.1 and higher - if(COMPUTECPP_DISABLE_GCC_DUAL_ABI) - set_property(TARGET ${targetName} APPEND PROPERTY COMPILE_DEFINITIONS - "_GLIBCXX_USE_CXX11_ABI=0") - endif() -endfunction() + set_property( + SOURCE ${cppFile} + APPEND_STRING PROPERTY COMPILE_FLAGS "${forceIncludeFlags}" + ) + +endfunction(__build_ir) ####################### # add_sycl_to_target @@ -334,28 +431,38 @@ endfunction() # Adds a SYCL compilation custom command associated with an existing # target and sets a dependancy on that new command. # -# targetName : Name of the target to add a SYCL to. -# binaryDir : Intermediate directory to output the integration header. -# sourceFiles : Source files to be compiled for SYCL. +# TARGET : Name of the target to add SYCL to. +# SOURCES : Source files to be compiled for SYCL. # -function(add_sycl_to_target targetName binaryDir sourceFiles) - - set(sourceFiles ${sourceFiles} ${ARGN}) - set(fileCounter 0) - target_include_directories( - ${targetName} SYSTEM - PRIVATE ${OpenCL_INCLUDE_DIR} - PRIVATE ${COMPUTECPP_INCLUDE_DIRECTORY} +function(add_sycl_to_target) + set(options) + set(one_value_args + TARGET + ) + set(multi_value_args + SOURCES ) + cmake_parse_arguments(SDK_ADD_SYCL + "${options}" + "${one_value_args}" + "${multi_value_args}" + ${ARGN} + ) + set(fileCounter 0) # Add custom target to run compute++ and generate the integration header - foreach(sourceFile ${sourceFiles}) - __build_spir(${targetName} ${sourceFile} ${binaryDir} ${fileCounter}) + foreach(sourceFile ${SDK_ADD_SYCL_SOURCES}) + if(NOT IS_ABSOLUTE ${sourceFile}) + set(sourceFile "${CMAKE_CURRENT_SOURCE_DIR}/${sourceFile}") + endif() + __build_ir( + TARGET ${SDK_ADD_SYCL_TARGET} + SOURCE ${sourceFile} + COUNTER ${fileCounter} + ) MATH(EXPR fileCounter "${fileCounter} + 1") endforeach() - - # Link with the ComputeCpp runtime library - target_link_libraries(${targetName} PUBLIC $<$,$>:${COMPUTECPP_RUNTIME_LIBRARY_DEBUG}> - $<$,$>>:${COMPUTECPP_RUNTIME_LIBRARY}> - ${OpenCL_LIBRARIES}) - + set_property(TARGET ${SDK_ADD_SYCL_TARGET} + APPEND PROPERTY LINK_LIBRARIES ComputeCpp::ComputeCpp) + set_property(TARGET ${SDK_ADD_SYCL_TARGET} + APPEND PROPERTY INTERFACE_LINK_LIBRARIES ComputeCpp::ComputeCpp) endfunction(add_sycl_to_target) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 9e73aa2..27bd0d3 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,19 +1,11 @@ -file(GLOB BENCHMARK_FILES ./*.cpp) - -foreach(file ${BENCHMARK_FILES}) - - message(STATUS " Getting ${file} ") - - get_filename_component(SOURCE_NAME ${file} NAME_WE) - message(STATUS " Adding ${SOURCE_NAME} ") - - include_directories(${COMPUTECPP_INCLUDE_DIRECTORY}) - - add_executable(${SOURCE_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE_NAME}.cpp ) - target_compile_options(${SOURCE_NAME} PUBLIC ${HOST_COMPILER_OPTIONS}) - target_link_libraries(${SOURCE_NAME} PUBLIC ${CMAKE_THREAD_LIBS_INIT}) +set(EXAMPLE_FILES + "parallel_execpol_general.cpp" + "sycl_sample_00.cpp" + "sycl_sample_01.cpp" + ) + +foreach(file ${EXAMPLE_FILES}) + build_file(${file}) +endforeach() - add_sycl_to_target(${SOURCE_NAME} ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE_NAME}.cpp ) -endforeach() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b2d7368..5d78524 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,11 +1,10 @@ add_library(SyclSTL policies.cpp) -# This is only supported in CMake 1.1 and above -set_property(TARGET SyclSTL PROPERTY CXX_STANDARD "11") +set_property(TARGET SyclSTL PROPERTY CXX_STANDARD "14") set_property(TARGET SyclSTL PROPERTY CXX_STANDARD_REQUIRED True) -set_property(TARGET SyclSTL APPEND PROPERTY COMPILE_FLAGS "-std=c++11") +set_property(TARGET SyclSTL APPEND PROPERTY COMPILE_FLAGS "-std=c++14") -target_link_libraries(SyclSTL ${SYCL_LIBRARY} ${OPENCL_LIBRARY}) +target_link_libraries(SyclSTL ${SYCL_LIBRARY} ${OPENCL_LIBRARY}) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 0314a5f..1dca946 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,21 +1,62 @@ +include(ExternalProject) + +set(SYCLBLAS_TEST ${CMAKE_CURRENT_SOURCE_DIR}) +set(SYCLBLAS_TEST_INCLUDE "${SYCLBLAS_TEST}/include") + +if(CMAKE_CROSSCOMPILING) + set(cmake_toolchain + "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}" + ) + message(STATUS "Crossing : ${cmake_toolchain}") +endif() + # Download and unpack googletest at configure time -configure_file(CMakeLists.txt.in -"${CMAKE_BINARY_DIR}/googletest-download/CMakeLists.txt") +configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt) execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . -WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/googletest-download" ) + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download ) +if(result) + message(FATAL_ERROR "CMake step for googletest failed: ${result}") +endif() execute_process(COMMAND ${CMAKE_COMMAND} --build . -WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/googletest-download" ) + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download ) +if(result) + message(FATAL_ERROR "Build step for googletest failed: ${result}") +endif() -# Prevent GoogleTest from overriding our compiler/linker options -# when building with Visual Studio +# Prevent overriding the parent project's compiler/linker +# settings on Windows set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) -# Add googletest directly to our build. This adds -# the following targets: gtest, gtest_main, gmock -# and gmock_main -add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src - ${CMAKE_BINARY_DIR}/googletest-build) -include_directories(${gtest_SOURCE_DIR}/include) -include_directories(${gmock_SOURCE_DIR}/include) +# Add googletest directly to our build. This defines +# the gtest and gtest_main targets. +add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src + ${CMAKE_CURRENT_BINARY_DIR}/googletest-build + EXCLUDE_FROM_ALL) + +# The gtest/gtest_main targets carry header search path +# dependencies automatically when using CMake 2.8.11 or +# later. Otherwise we have to add them here ourselves. +if (CMAKE_VERSION VERSION_LESS 2.8.11) + include_directories("${gtest_SOURCE_DIR}/include") +endif() + +add_library(libgtest IMPORTED STATIC GLOBAL) +add_dependencies(libgtest gtest) + +if(VERBOSE) + add_definitions(-DVERBOSE=VERBOSE) +endif(VERBOSE) + +if(SYCL_DEVICE) + add_definitions(-DSYCL_DEVICE=${SYCL_DEVICE}) +endif(SYCL_DEVICE) + +include_directories( + ${GTEST_LIB} + ${SYCL_INCLUDE_DIRS} +) + add_subdirectory(pstl-tests) diff --git a/tests/CMakeLists.txt.in b/tests/CMakeLists.txt.in index 8f0f70c..080611e 100644 --- a/tests/CMakeLists.txt.in +++ b/tests/CMakeLists.txt.in @@ -1,12 +1,13 @@ +project(googletest-download NONE) + cmake_minimum_required(VERSION 3.2.2) -find_package(Threads) include(ExternalProject) ExternalProject_Add(googletest GIT_REPOSITORY https://github.com/google/googletest.git GIT_TAG release-1.8.0 - SOURCE_DIR "${CMAKE_BINARY_DIR}/googletest-src" - BINARY_DIR "${CMAKE_BINARY_DIR}/googletest-build" + SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-src" + BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-build" CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" diff --git a/tests/pstl-tests/CMakeLists.txt b/tests/pstl-tests/CMakeLists.txt index a02392f..0feb1db 100644 --- a/tests/pstl-tests/CMakeLists.txt +++ b/tests/pstl-tests/CMakeLists.txt @@ -1,21 +1,41 @@ -find_package(Threads) -function(compile_test source) - set(test_name "pstl.${source}") - set(source "${source}.cpp") - add_executable(${test_name} ${source}) - target_link_libraries(${test_name} PUBLIC "${gtest_BINARY_DIR}/libgtest.a" - PUBLIC "${gtest_BINARY_DIR}/libgtest_main.a" - PUBLIC "${CMAKE_THREAD_LIBS_INIT}") - add_dependencies(${test_name} gtest_main) - add_dependencies(${test_name} gtest) - add_sycl_to_target(${test_name} ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/${source}) - add_test(test.${test_name} ${test_name}) -endfunction() -file(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp") +set(files + "all_of.cpp" + "any_of.cpp" + "buffer_unique_ptr.cpp" + "count.cpp" + "count_if.cpp" + "equal.cpp" + "exclusive_scan.cpp" + "fill.cpp" + "fill_n.cpp" + "find.cpp" + "for_each.cpp" + "for_each_n.cpp" + "generate.cpp" + "generate_n.cpp" + "inclusive_scan.cpp" + "inner_product.cpp" + "invalid_vector_iterators.cpp" + "mismatch.cpp" + "none_of.cpp" + "reduce.cpp" + "replace_copy.cpp" + "replace_copy_if.cpp" + "replace.cpp" + "replace_if.cpp" + "reverse_copy.cpp" + "reverse.cpp" + "sort.cpp" + "transform.cpp" + "transform_reduce.cpp" + "vector.cpp" + ) + foreach (file ${files}) - get_filename_component(file ${file} NAME_WE) - compile_test(${file}) + build_file(${file}) + get_filename_component(SOURCE_NAME ${file} NAME_WE) + target_link_libraries(${SOURCE_NAME} PUBLIC gtest_main) + add_test(${SOURCE_NAME} ${CMAKE_CURRENT_BINARY_DIR}/${SOURCE_NAME}) endforeach() diff --git a/tests/pstl-tests/all_of.cpp b/tests/pstl-tests/all_of.cpp index 6d011a2..987d864 100644 --- a/tests/pstl-tests/all_of.cpp +++ b/tests/pstl-tests/all_of.cpp @@ -25,7 +25,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ -#include "gmock/gmock.h" +#include "gtest/gtest.h" #include #include diff --git a/tests/pstl-tests/any_of.cpp b/tests/pstl-tests/any_of.cpp index 66ce4af..0e23f08 100644 --- a/tests/pstl-tests/any_of.cpp +++ b/tests/pstl-tests/any_of.cpp @@ -25,7 +25,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ -#include "gmock/gmock.h" +#include "gtest/gtest.h" #include #include diff --git a/tests/pstl-tests/buffer_unique_ptr.cpp b/tests/pstl-tests/buffer_unique_ptr.cpp index 59bda59..4e8cce7 100644 --- a/tests/pstl-tests/buffer_unique_ptr.cpp +++ b/tests/pstl-tests/buffer_unique_ptr.cpp @@ -26,7 +26,7 @@ */ #include -#include "gmock/gmock.h" +#include "gtest/gtest.h" #include #include diff --git a/tests/pstl-tests/count.cpp b/tests/pstl-tests/count.cpp index bb97ad1..3af3370 100644 --- a/tests/pstl-tests/count.cpp +++ b/tests/pstl-tests/count.cpp @@ -24,7 +24,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ -#include "gmock/gmock.h" +#include "gtest/gtest.h" #include #include diff --git a/tests/pstl-tests/count_if.cpp b/tests/pstl-tests/count_if.cpp index 822075e..72cb97f 100644 --- a/tests/pstl-tests/count_if.cpp +++ b/tests/pstl-tests/count_if.cpp @@ -24,7 +24,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ -#include "gmock/gmock.h" +#include "gtest/gtest.h" #include #include diff --git a/tests/pstl-tests/equal.cpp b/tests/pstl-tests/equal.cpp index 8415338..52ba6a8 100644 --- a/tests/pstl-tests/equal.cpp +++ b/tests/pstl-tests/equal.cpp @@ -25,7 +25,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ -#include "gmock/gmock.h" +#include "gtest/gtest.h" #include #include diff --git a/tests/pstl-tests/exclusive_scan.cpp b/tests/pstl-tests/exclusive_scan.cpp index 8f13f34..5d9d5e4 100644 --- a/tests/pstl-tests/exclusive_scan.cpp +++ b/tests/pstl-tests/exclusive_scan.cpp @@ -24,7 +24,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ -#include "gmock/gmock.h" +#include "gtest/gtest.h" #include #include diff --git a/tests/pstl-tests/fill.cpp b/tests/pstl-tests/fill.cpp index f944593..129f068 100644 --- a/tests/pstl-tests/fill.cpp +++ b/tests/pstl-tests/fill.cpp @@ -24,7 +24,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ -#include "gmock/gmock.h" +#include "gtest/gtest.h" #include #include diff --git a/tests/pstl-tests/fill_n.cpp b/tests/pstl-tests/fill_n.cpp index 7e1a260..2df941e 100644 --- a/tests/pstl-tests/fill_n.cpp +++ b/tests/pstl-tests/fill_n.cpp @@ -24,7 +24,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ -#include "gmock/gmock.h" +#include "gtest/gtest.h" #include #include diff --git a/tests/pstl-tests/find.cpp b/tests/pstl-tests/find.cpp index fc70274..e7617e4 100644 --- a/tests/pstl-tests/find.cpp +++ b/tests/pstl-tests/find.cpp @@ -24,7 +24,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ -#include "gmock/gmock.h" +#include "gtest/gtest.h" #include #include diff --git a/tests/pstl-tests/for_each.cpp b/tests/pstl-tests/for_each.cpp index 219135f..ec9bab0 100644 --- a/tests/pstl-tests/for_each.cpp +++ b/tests/pstl-tests/for_each.cpp @@ -24,7 +24,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ -#include "gmock/gmock.h" +#include "gtest/gtest.h" #include #include diff --git a/tests/pstl-tests/for_each_n.cpp b/tests/pstl-tests/for_each_n.cpp index 490162c..bf00568 100644 --- a/tests/pstl-tests/for_each_n.cpp +++ b/tests/pstl-tests/for_each_n.cpp @@ -24,7 +24,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ -#include "gmock/gmock.h" +#include "gtest/gtest.h" #include #include diff --git a/tests/pstl-tests/generate.cpp b/tests/pstl-tests/generate.cpp index 702eaf6..8d45b54 100644 --- a/tests/pstl-tests/generate.cpp +++ b/tests/pstl-tests/generate.cpp @@ -24,7 +24,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ -#include "gmock/gmock.h" +#include "gtest/gtest.h" #include #include diff --git a/tests/pstl-tests/generate_n.cpp b/tests/pstl-tests/generate_n.cpp index 87f04f9..30d5a71 100644 --- a/tests/pstl-tests/generate_n.cpp +++ b/tests/pstl-tests/generate_n.cpp @@ -24,7 +24,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ -#include "gmock/gmock.h" +#include "gtest/gtest.h" #include #include diff --git a/tests/pstl-tests/inclusive_scan.cpp b/tests/pstl-tests/inclusive_scan.cpp index d71ea80..23aa9b8 100644 --- a/tests/pstl-tests/inclusive_scan.cpp +++ b/tests/pstl-tests/inclusive_scan.cpp @@ -24,7 +24,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ -#include "gmock/gmock.h" +#include "gtest/gtest.h" #include #include diff --git a/tests/pstl-tests/inner_product.cpp b/tests/pstl-tests/inner_product.cpp index 66d3bac..e7dcd98 100644 --- a/tests/pstl-tests/inner_product.cpp +++ b/tests/pstl-tests/inner_product.cpp @@ -25,7 +25,7 @@ MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ -#include "gmock/gmock.h" +#include "gtest/gtest.h" #include #include diff --git a/tests/pstl-tests/invalid_vector_iterators.cpp b/tests/pstl-tests/invalid_vector_iterators.cpp index 32d5d4b..c578771 100644 --- a/tests/pstl-tests/invalid_vector_iterators.cpp +++ b/tests/pstl-tests/invalid_vector_iterators.cpp @@ -28,7 +28,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ -#include "gmock/gmock.h" +#include "gtest/gtest.h" #include #include diff --git a/tests/pstl-tests/mismatch.cpp b/tests/pstl-tests/mismatch.cpp index 7a28ac4..f0505f3 100644 --- a/tests/pstl-tests/mismatch.cpp +++ b/tests/pstl-tests/mismatch.cpp @@ -24,7 +24,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ -#include "gmock/gmock.h" +#include "gtest/gtest.h" #include #include diff --git a/tests/pstl-tests/none_of.cpp b/tests/pstl-tests/none_of.cpp index 3c4b26d..c7c66f2 100644 --- a/tests/pstl-tests/none_of.cpp +++ b/tests/pstl-tests/none_of.cpp @@ -25,7 +25,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ -#include "gmock/gmock.h" +#include "gtest/gtest.h" #include #include diff --git a/tests/pstl-tests/reduce.cpp b/tests/pstl-tests/reduce.cpp index 4ee4a8d..cc48fd5 100644 --- a/tests/pstl-tests/reduce.cpp +++ b/tests/pstl-tests/reduce.cpp @@ -24,7 +24,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ -#include "gmock/gmock.h" +#include "gtest/gtest.h" #include #include diff --git a/tests/pstl-tests/replace.cpp b/tests/pstl-tests/replace.cpp index 2d01131..13ae559 100644 --- a/tests/pstl-tests/replace.cpp +++ b/tests/pstl-tests/replace.cpp @@ -24,7 +24,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ -#include "gmock/gmock.h" +#include "gtest/gtest.h" #include #include diff --git a/tests/pstl-tests/replace_copy.cpp b/tests/pstl-tests/replace_copy.cpp index 43e079a..710e4d8 100644 --- a/tests/pstl-tests/replace_copy.cpp +++ b/tests/pstl-tests/replace_copy.cpp @@ -24,7 +24,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ -#include "gmock/gmock.h" +#include "gtest/gtest.h" #include #include diff --git a/tests/pstl-tests/replace_copy_if.cpp b/tests/pstl-tests/replace_copy_if.cpp index d7f9381..25a9310 100644 --- a/tests/pstl-tests/replace_copy_if.cpp +++ b/tests/pstl-tests/replace_copy_if.cpp @@ -24,7 +24,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ -#include "gmock/gmock.h" +#include "gtest/gtest.h" #include #include diff --git a/tests/pstl-tests/replace_if.cpp b/tests/pstl-tests/replace_if.cpp index d72e435..d38181f 100644 --- a/tests/pstl-tests/replace_if.cpp +++ b/tests/pstl-tests/replace_if.cpp @@ -24,7 +24,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ -#include "gmock/gmock.h" +#include "gtest/gtest.h" #include #include diff --git a/tests/pstl-tests/reverse.cpp b/tests/pstl-tests/reverse.cpp index 77dcac2..7e8d2a7 100644 --- a/tests/pstl-tests/reverse.cpp +++ b/tests/pstl-tests/reverse.cpp @@ -24,7 +24,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ -#include "gmock/gmock.h" +#include "gtest/gtest.h" #include #include diff --git a/tests/pstl-tests/reverse_copy.cpp b/tests/pstl-tests/reverse_copy.cpp index 744b009..2944632 100644 --- a/tests/pstl-tests/reverse_copy.cpp +++ b/tests/pstl-tests/reverse_copy.cpp @@ -24,7 +24,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ -#include "gmock/gmock.h" +#include "gtest/gtest.h" #include #include diff --git a/tests/pstl-tests/sort.cpp b/tests/pstl-tests/sort.cpp index 4f15ee7..999b5e6 100644 --- a/tests/pstl-tests/sort.cpp +++ b/tests/pstl-tests/sort.cpp @@ -24,7 +24,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ -#include "gmock/gmock.h" +#include "gtest/gtest.h" #include #include diff --git a/tests/pstl-tests/transform.cpp b/tests/pstl-tests/transform.cpp index 6ba41b3..dd8117f 100644 --- a/tests/pstl-tests/transform.cpp +++ b/tests/pstl-tests/transform.cpp @@ -24,7 +24,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ -#include "gmock/gmock.h" +#include "gtest/gtest.h" #include #include diff --git a/tests/pstl-tests/transform_reduce.cpp b/tests/pstl-tests/transform_reduce.cpp index 5cc0983..32e44ea 100644 --- a/tests/pstl-tests/transform_reduce.cpp +++ b/tests/pstl-tests/transform_reduce.cpp @@ -24,7 +24,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ -#include "gmock/gmock.h" +#include "gtest/gtest.h" #include #include diff --git a/tests/pstl-tests/vector.cpp b/tests/pstl-tests/vector.cpp index d6db91a..c974240 100644 --- a/tests/pstl-tests/vector.cpp +++ b/tests/pstl-tests/vector.cpp @@ -24,7 +24,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ -#include "gmock/gmock.h" +#include "gtest/gtest.h" #include #include