Skip to content

Commit f2bc1f6

Browse files
committed
Add github CI workflow and multi-platform/config CMake
1 parent 3923046 commit f2bc1f6

File tree

7 files changed

+112
-31
lines changed

7 files changed

+112
-31
lines changed

.github/workflows/simsycl_ci.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: SimSYCL CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
build:
9+
runs-on: ${{ matrix.os }}
10+
11+
strategy:
12+
# 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.
13+
fail-fast: false
14+
15+
matrix:
16+
os: [ubuntu-latest, windows-latest]
17+
build_type: [Release, Debug]
18+
c_compiler: [gcc, clang, cl]
19+
include:
20+
- os: windows-latest
21+
c_compiler: cl
22+
cpp_compiler: cl
23+
- os: ubuntu-latest
24+
c_compiler: gcc
25+
cpp_compiler: g++
26+
- os: ubuntu-latest
27+
c_compiler: clang
28+
cpp_compiler: clang++
29+
exclude:
30+
- os: windows-latest
31+
c_compiler: gcc
32+
- os: windows-latest
33+
c_compiler: clang
34+
- os: ubuntu-latest
35+
c_compiler: cl
36+
37+
steps:
38+
- uses: actions/checkout@v3
39+
40+
- name: Set reusable strings
41+
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
42+
id: strings
43+
shell: bash
44+
run: |
45+
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
46+
47+
- name: Build Boost
48+
id: boost
49+
uses: egor-tensin/build-boost@v1
50+
with:
51+
version: 1.78.0
52+
libraries: context
53+
platform: x64
54+
configuration: Release
55+
static: true
56+
57+
- name: Check which boost libs were built
58+
run: ls ${{ steps.boost.outputs.librarydir }}
59+
60+
- name: Configure CMake
61+
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
62+
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
63+
run: >
64+
cmake
65+
-D "BOOST_ROOT=${{ steps.boost.outputs.root }}"
66+
-D "BOOST_LIBRARYDIR=${{ steps.boost.outputs.librarydir }}"
67+
-B ${{ steps.strings.outputs.build-output-dir }}
68+
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
69+
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
70+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
71+
-S ${{ github.workspace }}
72+
73+
- name: Build
74+
# 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).
75+
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
76+
77+
- name: Test
78+
working-directory: ${{ steps.strings.outputs.build-output-dir }}
79+
# 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).
80+
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
81+
run: ctest --build-config ${{ matrix.build_type }}

CMakeLists.txt

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,21 @@ project(SimSYCL VERSION 0.1 LANGUAGES CXX)
33

44
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
55

6-
find_package(Boost 1.60 COMPONENTS context REQUIRED)
6+
find_package(Boost 1.70 COMPONENTS context REQUIRED)
7+
8+
# Function to set properties, compile options, and link options for all simsycl targets
9+
function(set_simsycl_target_options target)
10+
set_target_properties(${target} PROPERTIES CXX_STANDARD 20)
11+
set_target_properties(${target} PROPERTIES CXX_STANDARD_REQUIRED ON)
12+
target_compile_options(${target} PRIVATE
13+
$<$<CXX_COMPILER_ID:MSVC>:/W4 $<$<CONFIG:Debug>:/fsanitize=address>>
14+
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -Wpedantic $<$<CONFIG:Debug>:-fsanitize=address>>
15+
)
16+
target_link_options(${target} PRIVATE
17+
$<$<CXX_COMPILER_ID:MSVC>:$<$<CONFIG:Debug>:/fsanitize=address>>
18+
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:$<$<CONFIG:Debug>:-fsanitize=address>>
19+
)
20+
endfunction()
721

822
add_library(simsycl
923
include/sycl/sycl.hpp
@@ -46,20 +60,12 @@ add_library(simsycl
4660
src/simsycl/dummy.cc
4761
)
4862
target_link_libraries(simsycl Boost::context)
49-
5063
target_include_directories(simsycl PUBLIC include)
51-
set_target_properties(simsycl PROPERTIES CXX_STANDARD 20)
52-
set_target_properties(simsycl PROPERTIES CXX_STANDARD_REQUIRED ON)
53-
target_compile_options(simsycl PRIVATE -Wall -Wextra -Wpedantic)
54-
target_compile_options(simsycl PRIVATE -fsanitize=address)
55-
target_link_options(simsycl PRIVATE -fsanitize=address)
64+
set_simsycl_target_options(simsycl)
5665

5766
add_executable(main src/test/main.cc)
5867
target_link_libraries(main simsycl)
59-
set_target_properties(main PROPERTIES CXX_STANDARD 20)
60-
set_target_properties(main PROPERTIES CXX_STANDARD_REQUIRED ON)
61-
target_compile_options(main PRIVATE -Wall -Wextra -Wpedantic)
62-
target_compile_options(main PRIVATE -fsanitize=address)
63-
target_link_options(main PRIVATE -fsanitize=address)
68+
set_simsycl_target_options(main)
6469

70+
enable_testing()
6571
add_subdirectory(test)

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33

44
# Acknowlegments
55
- Fabian Knorr
6+
- Peter Thoman
67
- Luigi Crisci

include/simsycl/detail/group_operation_impl.hh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ void default_group_op_function(T &per_group) {
152152
}
153153

154154
template <GroupOpInitFunction InitF = decltype(default_group_op_init_function),
155-
typename PerOpT = std::invoke_result_t<InitF>::element_type,
155+
typename PerOpT = typename std::invoke_result_t<InitF>::element_type,
156156
typename ReachedF = decltype(default_group_op_function<PerOpT>),
157157
typename CompleteF = decltype(default_group_op_function<PerOpT>)>
158158
struct group_operation_spec {
@@ -188,7 +188,7 @@ auto perform_group_operation(G g, group_operation_id id, const Spec &spec) {
188188
SIMSYCL_CHECK(op.id == new_op.id);
189189
SIMSYCL_CHECK(op.expected_num_work_items == new_op.expected_num_work_items);
190190
SIMSYCL_CHECK(op.num_work_items_participating < op.expected_num_work_items);
191-
spec.reached(dynamic_cast<Spec::per_op_t &>(*op.per_op_data));
191+
spec.reached(dynamic_cast<typename Spec::per_op_t &>(*op.per_op_data));
192192
ops_reached++;
193193

194194
op.num_work_items_participating++;
@@ -200,7 +200,7 @@ auto perform_group_operation(G g, group_operation_id id, const Spec &spec) {
200200
}
201201
this_nd_item_impl.barrier();
202202

203-
return spec.complete(dynamic_cast<Spec::per_op_t &>(*group_impl.operations[ops_reached - 1].per_op_data));
203+
return spec.complete(dynamic_cast<typename Spec::per_op_t &>(*group_impl.operations[ops_reached - 1].per_op_data));
204204
}
205205

206206
// more specific helper functions for group operations

include/simsycl/sycl/accessor.hh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,8 @@ class accessor {
137137
template <access_mode A = AccessMode, std::enable_if_t<A != access_mode::atomic, int> = 0>
138138
reference operator[](id<Dimensions> index) const;
139139

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

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

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

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

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

include/simsycl/sycl/group_algorithms.hh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ T select_from_group(G g, T x, typename G::id_type remote_local_id) {
238238
// reduce
239239

240240

241-
template <Group G, Pointer Ptr, SyclFunctionObject Op, typename T = std::iterator_traits<Ptr>::value_type>
241+
template <Group G, Pointer Ptr, SyclFunctionObject Op, typename T = typename std::iterator_traits<Ptr>::value_type>
242242
T joint_reduce(G g, Ptr first, Ptr last, Op binary_op) {
243243
T result = *first;
244244
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) {
267267
// exclusive_scan
268268

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

305305
template <Group G, PointerToFundamental InPtr, PointerToFundamental OutPtr, SyclFunctionObject Op,
306-
typename T = std::iterator_traits<InPtr>::value_type>
306+
typename T = typename std::iterator_traits<InPtr>::value_type>
307307
OutPtr joint_inclusive_scan(G g, InPtr first, InPtr last, OutPtr result, Op binary_op) {
308308
std::vector<T> results(std::distance(first, last));
309309
results[0] = *first;

test/CMakeLists.txt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ FetchContent_Declare(
99
FetchContent_MakeAvailable(Catch2)
1010

1111
add_executable(tests group_op_tests.cc)
12-
13-
set_target_properties(tests PROPERTIES CXX_STANDARD 20)
14-
set_target_properties(tests PROPERTIES CXX_STANDARD_REQUIRED ON)
15-
target_compile_options(tests PRIVATE -Wall -Wextra -Wpedantic)
16-
target_compile_options(tests PRIVATE -fsanitize=address)
17-
1812
target_link_libraries(tests PRIVATE Catch2::Catch2WithMain simsycl)
19-
target_link_options(tests PRIVATE -fsanitize=address)
13+
set_simsycl_target_options(tests)
14+
15+
list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras)
16+
include(CTest)
17+
include(Catch)
18+
catch_discover_tests(tests)

0 commit comments

Comments
 (0)