Skip to content

Commit

Permalink
Add github CI workflow and multi-platform/config CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterTh committed Dec 12, 2023
1 parent 3923046 commit f2bc1f6
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 31 deletions.
81 changes: 81 additions & 0 deletions .github/workflows/simsycl_ci.yml
Original file line number Diff line number Diff line change
@@ -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 }}
30 changes: 18 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
$<$<CXX_COMPILER_ID:MSVC>:/W4 $<$<CONFIG:Debug>:/fsanitize=address>>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -Wpedantic $<$<CONFIG:Debug>:-fsanitize=address>>
)
target_link_options(${target} PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:$<$<CONFIG:Debug>:/fsanitize=address>>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:$<$<CONFIG:Debug>:-fsanitize=address>>
)
endfunction()

add_library(simsycl
include/sycl/sycl.hpp
Expand Down Expand Up @@ -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)
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@

# Acknowlegments
- Fabian Knorr
- Peter Thoman
- Luigi Crisci
6 changes: 3 additions & 3 deletions include/simsycl/detail/group_operation_impl.hh
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ void default_group_op_function(T &per_group) {
}

template <GroupOpInitFunction InitF = decltype(default_group_op_init_function),
typename PerOpT = std::invoke_result_t<InitF>::element_type,
typename PerOpT = typename std::invoke_result_t<InitF>::element_type,
typename ReachedF = decltype(default_group_op_function<PerOpT>),
typename CompleteF = decltype(default_group_op_function<PerOpT>)>
struct group_operation_spec {
Expand Down Expand Up @@ -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<Spec::per_op_t &>(*op.per_op_data));
spec.reached(dynamic_cast<typename Spec::per_op_t &>(*op.per_op_data));
ops_reached++;

op.num_work_items_participating++;
Expand All @@ -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<Spec::per_op_t &>(*group_impl.operations[ops_reached - 1].per_op_data));
return spec.complete(dynamic_cast<typename Spec::per_op_t &>(*group_impl.operations[ops_reached - 1].per_op_data));
}

// more specific helper functions for group operations
Expand Down
6 changes: 0 additions & 6 deletions include/simsycl/sycl/accessor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,8 @@ class accessor {
template <access_mode A = AccessMode, std::enable_if_t<A != access_mode::atomic, int> = 0>
reference operator[](id<Dimensions> index) const;

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
template <access_mode A = AccessMode, std::enable_if_t<A == access_mode::atomic, int> = 0>
[[deprecated]] atomic<DataT, access::address_space::global_space> operator[](id<Dimensions> index) const;
#pragma GCC diagnostic pop

decltype(auto) operator[](size_t index) const { return detail::subscript(*this, index); }

Expand Down Expand Up @@ -221,11 +218,8 @@ class accessor<DataT, 0, AccessMode, AccessTarget, IsPlaceholder> {
template <access_mode A = AccessMode, std::enable_if_t<A != access_mode::atomic && A != access_mode::read, int> = 0>
const accessor &operator=(value_type &&other) const;

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
template <access_mode A = AccessMode, std::enable_if_t<A == access_mode::atomic, int> = 0>
[[deprecated]] operator atomic<DataT, access::address_space::global_space>() const;
#pragma GCC diagnostic pop

std::add_pointer_t<value_type> get_pointer() const noexcept;

Expand Down
6 changes: 3 additions & 3 deletions include/simsycl/sycl/group_algorithms.hh
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ T select_from_group(G g, T x, typename G::id_type remote_local_id) {
// reduce


template <Group G, Pointer Ptr, SyclFunctionObject Op, typename T = std::iterator_traits<Ptr>::value_type>
template <Group G, Pointer Ptr, SyclFunctionObject Op, typename T = typename std::iterator_traits<Ptr>::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); }
Expand Down Expand Up @@ -267,7 +267,7 @@ T reduce_over_group(G g, V x, T init, Op binary_op) {
// exclusive_scan

template <Group G, PointerToFundamental InPtr, PointerToFundamental OutPtr, SyclFunctionObject Op,
typename T = std::iterator_traits<InPtr>::value_type>
typename T = typename std::iterator_traits<InPtr>::value_type>
OutPtr joint_exclusive_scan(G g, InPtr first, InPtr last, OutPtr result, Op binary_op) {
std::vector<T> results(std::distance(first, last));
results[0] = known_identity_v<Op, T>;
Expand Down Expand Up @@ -303,7 +303,7 @@ T exclusive_scan_over_group(G g, V x, T init, Op binary_op) {
// inclusive_scan

template <Group G, PointerToFundamental InPtr, PointerToFundamental OutPtr, SyclFunctionObject Op,
typename T = std::iterator_traits<InPtr>::value_type>
typename T = typename std::iterator_traits<InPtr>::value_type>
OutPtr joint_inclusive_scan(G g, InPtr first, InPtr last, OutPtr result, Op binary_op) {
std::vector<T> results(std::distance(first, last));
results[0] = *first;
Expand Down
13 changes: 6 additions & 7 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit f2bc1f6

Please sign in to comment.