diff --git a/.github/workflows/simsycl_ci.yml b/.github/workflows/simsycl_ci.yml new file mode 100644 index 0000000..4e41a20 --- /dev/null +++ b/.github/workflows/simsycl_ci.yml @@ -0,0 +1,81 @@ +name: SimSYCL CI + +on: + push: + pull_request: + +jobs: + build: + runs-on: ${{ matrix.os }} + + strategy: + # Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable. + fail-fast: false + + matrix: + os: [ubuntu-latest, windows-latest] + build_type: [Release, Debug] + c_compiler: [gcc, clang, cl] + include: + - os: windows-latest + c_compiler: cl + cpp_compiler: cl + - os: ubuntu-latest + c_compiler: gcc + cpp_compiler: g++ + - os: ubuntu-latest + c_compiler: clang + cpp_compiler: clang++ + exclude: + - os: windows-latest + c_compiler: gcc + - os: windows-latest + c_compiler: clang + - os: ubuntu-latest + c_compiler: cl + + steps: + - uses: actions/checkout@v3 + + - name: Set reusable strings + # Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file. + id: strings + shell: bash + run: | + echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" + + - name: Build Boost + id: boost + uses: egor-tensin/build-boost@v1 + with: + version: 1.78.0 + libraries: context + platform: x64 + configuration: Release + static: true + + - name: Check which boost libs were built + run: ls ${{ steps.boost.outputs.librarydir }} + + - name: Configure CMake + # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + run: > + cmake + -D "BOOST_ROOT=${{ steps.boost.outputs.root }}" + -D "BOOST_LIBRARYDIR=${{ steps.boost.outputs.librarydir }}" + -B ${{ steps.strings.outputs.build-output-dir }} + -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} + -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + -S ${{ github.workspace }} + + - name: Build + # Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). + run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} + + - name: Test + working-directory: ${{ steps.strings.outputs.build-output-dir }} + # Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). + # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail + run: ctest --build-config ${{ matrix.build_type }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d7de21..b145a9b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,21 @@ project(SimSYCL VERSION 0.1 LANGUAGES CXX) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -find_package(Boost 1.60 COMPONENTS context REQUIRED) +find_package(Boost 1.70 COMPONENTS context REQUIRED) + +# Function to set properties, compile options, and link options for all simsycl targets +function(set_simsycl_target_options target) + set_target_properties(${target} PROPERTIES CXX_STANDARD 20) + set_target_properties(${target} PROPERTIES CXX_STANDARD_REQUIRED ON) + target_compile_options(${target} PRIVATE + $<$:/W4 $<$:/fsanitize=address>> + $<$>:-Wall -Wextra -Wpedantic $<$:-fsanitize=address>> + ) + target_link_options(${target} PRIVATE + $<$:$<$:/fsanitize=address>> + $<$>:$<$:-fsanitize=address>> + ) +endfunction() add_library(simsycl include/sycl/sycl.hpp @@ -46,20 +60,12 @@ add_library(simsycl src/simsycl/dummy.cc ) target_link_libraries(simsycl Boost::context) - target_include_directories(simsycl PUBLIC include) -set_target_properties(simsycl PROPERTIES CXX_STANDARD 20) -set_target_properties(simsycl PROPERTIES CXX_STANDARD_REQUIRED ON) -target_compile_options(simsycl PRIVATE -Wall -Wextra -Wpedantic) -target_compile_options(simsycl PRIVATE -fsanitize=address) -target_link_options(simsycl PRIVATE -fsanitize=address) +set_simsycl_target_options(simsycl) add_executable(main src/test/main.cc) target_link_libraries(main simsycl) -set_target_properties(main PROPERTIES CXX_STANDARD 20) -set_target_properties(main PROPERTIES CXX_STANDARD_REQUIRED ON) -target_compile_options(main PRIVATE -Wall -Wextra -Wpedantic) -target_compile_options(main PRIVATE -fsanitize=address) -target_link_options(main PRIVATE -fsanitize=address) +set_simsycl_target_options(main) +enable_testing() add_subdirectory(test) diff --git a/README.md b/README.md index 6bfd900..db209ed 100644 --- a/README.md +++ b/README.md @@ -3,4 +3,5 @@ # Acknowlegments - Fabian Knorr +- Peter Thoman - Luigi Crisci \ No newline at end of file diff --git a/include/simsycl/detail/group_operation_impl.hh b/include/simsycl/detail/group_operation_impl.hh index 9ff61a3..116582d 100644 --- a/include/simsycl/detail/group_operation_impl.hh +++ b/include/simsycl/detail/group_operation_impl.hh @@ -152,7 +152,7 @@ void default_group_op_function(T &per_group) { } template ::element_type, + typename PerOpT = typename std::invoke_result_t::element_type, typename ReachedF = decltype(default_group_op_function), typename CompleteF = decltype(default_group_op_function)> struct group_operation_spec { @@ -188,7 +188,7 @@ auto perform_group_operation(G g, group_operation_id id, const Spec &spec) { SIMSYCL_CHECK(op.id == new_op.id); SIMSYCL_CHECK(op.expected_num_work_items == new_op.expected_num_work_items); SIMSYCL_CHECK(op.num_work_items_participating < op.expected_num_work_items); - spec.reached(dynamic_cast(*op.per_op_data)); + spec.reached(dynamic_cast(*op.per_op_data)); ops_reached++; op.num_work_items_participating++; @@ -200,7 +200,7 @@ auto perform_group_operation(G g, group_operation_id id, const Spec &spec) { } this_nd_item_impl.barrier(); - return spec.complete(dynamic_cast(*group_impl.operations[ops_reached - 1].per_op_data)); + return spec.complete(dynamic_cast(*group_impl.operations[ops_reached - 1].per_op_data)); } // more specific helper functions for group operations diff --git a/include/simsycl/sycl/accessor.hh b/include/simsycl/sycl/accessor.hh index 85634c4..99b000f 100644 --- a/include/simsycl/sycl/accessor.hh +++ b/include/simsycl/sycl/accessor.hh @@ -137,11 +137,8 @@ class accessor { template = 0> reference operator[](id index) const; - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated-declarations" template = 0> [[deprecated]] atomic operator[](id index) const; - #pragma GCC diagnostic pop decltype(auto) operator[](size_t index) const { return detail::subscript(*this, index); } @@ -221,11 +218,8 @@ class accessor { template = 0> const accessor &operator=(value_type &&other) const; - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated-declarations" template = 0> [[deprecated]] operator atomic() const; - #pragma GCC diagnostic pop std::add_pointer_t get_pointer() const noexcept; diff --git a/include/simsycl/sycl/group_algorithms.hh b/include/simsycl/sycl/group_algorithms.hh index 217a45a..34d9ce5 100644 --- a/include/simsycl/sycl/group_algorithms.hh +++ b/include/simsycl/sycl/group_algorithms.hh @@ -238,7 +238,7 @@ T select_from_group(G g, T x, typename G::id_type remote_local_id) { // reduce -template ::value_type> +template ::value_type> T joint_reduce(G g, Ptr first, Ptr last, Op binary_op) { T result = *first; for(auto i = first + 1; first != last && i != last; ++i) { result = binary_op(result, *i); } @@ -267,7 +267,7 @@ T reduce_over_group(G g, V x, T init, Op binary_op) { // exclusive_scan template ::value_type> + typename T = typename std::iterator_traits::value_type> OutPtr joint_exclusive_scan(G g, InPtr first, InPtr last, OutPtr result, Op binary_op) { std::vector results(std::distance(first, last)); results[0] = known_identity_v; @@ -303,7 +303,7 @@ T exclusive_scan_over_group(G g, V x, T init, Op binary_op) { // inclusive_scan template ::value_type> + typename T = typename std::iterator_traits::value_type> OutPtr joint_inclusive_scan(G g, InPtr first, InPtr last, OutPtr result, Op binary_op) { std::vector results(std::distance(first, last)); results[0] = *first; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3cbf22d..9fc9b3b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -9,11 +9,10 @@ FetchContent_Declare( FetchContent_MakeAvailable(Catch2) add_executable(tests group_op_tests.cc) - -set_target_properties(tests PROPERTIES CXX_STANDARD 20) -set_target_properties(tests PROPERTIES CXX_STANDARD_REQUIRED ON) -target_compile_options(tests PRIVATE -Wall -Wextra -Wpedantic) -target_compile_options(tests PRIVATE -fsanitize=address) - target_link_libraries(tests PRIVATE Catch2::Catch2WithMain simsycl) -target_link_options(tests PRIVATE -fsanitize=address) +set_simsycl_target_options(tests) + +list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras) +include(CTest) +include(Catch) +catch_discover_tests(tests)