Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add github CI workflow and multi-platform/config CMake #4

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions .github/workflows/simsycl_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
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: Install boost
uses: MarkusJx/[email protected]
id: install-boost
with:
boost_version: 1.78.0

- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v1
if: matrix.cpp_compiler == 'clang++'
with:
version: "17"

- 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.install-boost.outputs.BOOST_ROOT }}"
-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 }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.cache/
.vscode/
/build
/build*
/compile_commands.json
29 changes: 17 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,20 @@ 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>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -Wpedantic $<$<CONFIG:Debug>:-fsanitize=address>>
)
target_link_options(${target} PRIVATE
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:$<$<CONFIG:Debug>:-fsanitize=address>>
)
endfunction()

add_library(simsycl
include/sycl/sycl.hpp
Expand Down Expand Up @@ -46,20 +59,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)
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
![simSYCL](resources/logo.png)
### The SYCL implementation you did (not) know you wanted

# Requirements
SimSYCL requires the Boost `context` libary.

# Supported Platforms
The following platform and compiler combinations are currently tested in CI:

* Linux with GCC 11
* Linux with Clang 17
* Windows with MSVC

Other platforms and compilers should also work, as long as they have sufficient C++20 support.
Note that clang versions prior to 17 do not currently work in SimSYCL due to their CTAD limitations.

# 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
12 changes: 4 additions & 8 deletions include/simsycl/sycl/accessor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,13 @@ class accessor {

id<Dimensions> get_offset() const;

template <access_mode A = AccessMode, std::enable_if_t<A != access_mode::atomic, int> = 0>
template <access_mode A = AccessMode>
requires(A != access_mode::atomic)
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>
template <access_mode A = AccessMode>
requires(A == access_mode::atomic)
[[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 +220,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
2 changes: 1 addition & 1 deletion include/simsycl/sycl/forward.hh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ template <typename DataT, int Dimensions = 1,
class accessor;

template <typename T, access::address_space AddressSpace = access::address_space::global_space>
class [[deprecated("Deprecated in SYCL 2020")]] atomic;
class atomic;

template <typename T, int Dimensions = 1, typename AllocatorT = buffer_allocator<std::remove_const_t<T>>>
class buffer;
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)
Loading