Skip to content

Commit c80c9e1

Browse files
committed
Make flush extension optional; add CI for options mechanism
1 parent b5e2ea3 commit c80c9e1

9 files changed

Lines changed: 122 additions & 4 deletions

File tree

.github/workflows/extension_ci.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: SimSYCL Extension CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v3
13+
14+
- name: Set reusable strings
15+
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
16+
id: strings
17+
shell: bash
18+
run: |
19+
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
20+
echo "install-dir=${{ github.workspace }}/install" >> "$GITHUB_OUTPUT"
21+
echo "build-ext-dir=${{ github.workspace }}/build-ext" >> "$GITHUB_OUTPUT"
22+
23+
- name: Install boost
24+
uses: MarkusJx/install-boost@v2.4.5
25+
id: install-boost
26+
with:
27+
boost_version: 1.81.0
28+
29+
- name: Configure CMake for SimSYCL (no extensions)
30+
run: >
31+
cmake
32+
-D "BOOST_ROOT=${{ steps.install-boost.outputs.BOOST_ROOT }}"
33+
-B ${{ steps.strings.outputs.build-output-dir }}
34+
-DCMAKE_BUILD_TYPE=Debug
35+
-DCMAKE_POLICY_DEFAULT_CMP0144=NEW
36+
-S ${{ github.workspace }}
37+
-DCMAKE_INSTALL_PREFIX=${{ steps.strings.outputs.install-dir }}
38+
-DSIMSYCL_ENABLE_SYCL_KHR_QUEUE_FLUSH=OFF
39+
40+
- name: Build SimSYCL (no extensions)
41+
run: >
42+
cmake --build ${{ steps.strings.outputs.build-output-dir }} --parallel --target install
43+
44+
- name: Configure CMake for extension check program (no extensions)
45+
run: >
46+
cmake
47+
-D "BOOST_ROOT=${{ steps.install-boost.outputs.BOOST_ROOT }}"
48+
-B ${{ steps.strings.outputs.build-ext-dir }}
49+
-DCMAKE_BUILD_TYPE=Debug
50+
-DCMAKE_POLICY_DEFAULT_CMP0144=NEW
51+
-S ${{ github.workspace }}/test/extensions
52+
-DCMAKE_INSTALL_PREFIX=${{ steps.strings.outputs.install-dir }}
53+
54+
- name: Verify that extensions are not available
55+
run: |
56+
set +e
57+
cmake --build ${{ steps.strings.outputs.build-ext-dir }} --target extensions_test
58+
if [ $? -eq 0 ]; then
59+
echo "Extensions should not be enabled, but are available."
60+
exit 1
61+
fi
62+
exit 0
63+
64+
- name: Configure CMake for SimSYCL (with extensions)
65+
run: >
66+
cmake
67+
-D "BOOST_ROOT=${{ steps.install-boost.outputs.BOOST_ROOT }}"
68+
-B ${{ steps.strings.outputs.build-output-dir }}
69+
-DCMAKE_BUILD_TYPE=Debug
70+
-DCMAKE_POLICY_DEFAULT_CMP0144=NEW
71+
-S ${{ github.workspace }}
72+
-DCMAKE_INSTALL_PREFIX=${{ steps.strings.outputs.install-dir }}
73+
-DSIMSYCL_ENABLE_SYCL_KHR_QUEUE_FLUSH=ON
74+
75+
- name: Build SimSYCL (with extensions)
76+
run: >
77+
cmake --build ${{ steps.strings.outputs.build-output-dir }} --parallel --target install
78+
79+
- name: Verify that extensions are available
80+
run: |
81+
cmake --build ${{ steps.strings.outputs.build-ext-dir }} --target extensions_test
82+
if [ $? -ne 0 ]; then
83+
echo "Extensions should be enabled, but are not available."
84+
exit 1
85+
fi
86+
exit 0

.github/workflows/simsycl_ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ jobs:
8686
8787
- name: Build and install SimSYCL
8888
# 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).
89-
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} --target install
89+
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} --parallel --target install
9090

9191
- name: Configure CMake for examples
9292
run: >

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ option(SIMSYCL_ANNOTATE_SYCL_DEPRECATIONS "Wether to annotate deprecated SYCL AP
6767
option(SIMSYCL_ENABLE_ASAN "Whether to enable address sanitizer" OFF)
6868
set(SIMSYCL_CHECK_MODE "ABORT" CACHE STRING "Runtime assertion handling NONE|LOG|THROW|ABORT")
6969

70+
# Extension options
71+
option(SIMSYCL_ENABLE_SYCL_KHR_QUEUE_FLUSH "Enable the SYCL_KHR_QUEUE_FLUSH extension" ON)
72+
7073
set(CONFIG_PATH "${CMAKE_CURRENT_BINARY_DIR}/include/simsycl/config.hh")
7174
configure_file(
7275
"${PROJECT_SOURCE_DIR}/include/simsycl/config.hh.in"

cmake/simsycl-config.cmake.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,6 @@ set(SIMSYCL_FEATURE_HALF_TYPE "@SIMSYCL_FEATURE_HALF_TYPE@")
2727
set(SIMSYCL_CHECK_MODE "@SIMSYCL_CHECK_MODE@")
2828
set(SIMSYCL_ENABLE_ASAN "@SIMSYCL_ENABLE_ASAN@")
2929

30+
set(SIMSYCL_ENABLE_SYCL_KHR_QUEUE_FLUSH "@SIMSYCL_ENABLE_SYCL_KHR_QUEUE_FLUSH@")
31+
3032
include("${CMAKE_CURRENT_LIST_DIR}/AddToTarget.cmake")

include/simsycl/config.hh.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#cmakedefine01 SIMSYCL_ANNOTATE_SYCL_DEPRECATIONS
99
#cmakedefine01 SIMSYCL_FEATURE_HALF_TYPE
1010

11+
#cmakedefine01 SIMSYCL_ENABLE_SYCL_KHR_QUEUE_FLUSH
12+
1113
#ifndef SIMSYCL_CHECK_MODE
1214
#define SIMSYCL_CHECK_MODE SIMSYCL_CHECK_@SIMSYCL_CHECK_MODE@
1315
#endif

include/simsycl/sycl/queue.hh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#pragma once
22

3+
#include <simsycl/config.hh>
4+
35
#include "async_handler.hh"
46
#include "event.hh"
57
#include "handler.hh"
@@ -8,7 +10,9 @@
810
#include "../detail/lock.hh"
911
#include "../detail/reference_type.hh"
1012

13+
#if SIMSYCL_ENABLE_SYCL_KHR_QUEUE_FLUSH
1114
#define SYCL_KHR_QUEUE_FLUSH 1
15+
#endif // SIMSYCL_ENABLE_SYCL_KHR_QUEUE_FLUSH
1216

1317
namespace simsycl::sycl::property::queue {
1418

@@ -90,7 +94,9 @@ class queue final : public detail::reference_type<queue, detail::queue_state>,
9094

9195
device get_device() const;
9296

93-
void khr_flush() const;
97+
#if SIMSYCL_ENABLE_SYCL_KHR_QUEUE_FLUSH
98+
void khr_flush() const { /* This is a no-op in SimSYCL due to its synchronous nature */ }
99+
#endif // SIMSYCL_ENABLE_SYCL_KHR_QUEUE_FLUSH
94100

95101
bool is_in_order() const { return has_property<property::queue::in_order>(); }
96102

src/simsycl/queue.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,4 @@ context queue::get_context() const { return state().context; }
6969

7070
device queue::get_device() const { return state().device; }
7171

72-
void queue::khr_flush() const {}
73-
7472
} // namespace simsycl::sycl

test/extensions/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
cmake_minimum_required(VERSION 3.13)
2+
project(extensions_test LANGUAGES CXX)
3+
4+
find_package(SimSYCL)
5+
6+
add_executable(extensions_test extensions_test.cc)
7+
add_sycl_to_target(TARGET extensions_test SIMSYCL_ALL_WARNINGS)

test/extensions/extensions_test.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// This program simply checks if extensions are available in the current configuration.
2+
// It attempts no validation of the extension semantics, this can be done in normal tests guarded by feature macros.
3+
4+
// The intention of this is to CI the extension options, by failing to compile when they are disabled and compiling when
5+
// they are enabled.
6+
7+
#include <sycl/sycl.hpp>
8+
9+
int main() {
10+
sycl::queue queue;
11+
12+
// SIMSYCL_ENABLE_SYCL_KHR_QUEUE_FLUSH
13+
queue.khr_flush();
14+
}

0 commit comments

Comments
 (0)