Skip to content

Commit 8a4fd68

Browse files
committed
Add SYCL coverage upload
1 parent 750e0df commit 8a4fd68

3 files changed

Lines changed: 87 additions & 5 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ name: CI
22

33
on:
44
push:
5-
branches:
6-
- main
75
pull_request:
86
schedule:
97
- cron: '0 8 * * *'
@@ -228,6 +226,8 @@ jobs:
228226
- name: Upload coverage reports to Codecov
229227
uses: codecov/codecov-action@v4.0.1
230228
with:
229+
files: coverage.xml
230+
fail_ci_if_error: true
231231
token: ${{ secrets.CODECOV_TOKEN }}
232232
slug: embedded-dev-research/ITLabAI
233233

.github/workflows/sycl-ci.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,74 @@ jobs:
147147

148148
- name: Test
149149
run: ctest --test-dir "build/${{ matrix.build_type }}" --output-on-failure -R '^(UnitTests|SYCL\.Example)$'
150+
151+
codecov-sycl:
152+
name: codecov sycl
153+
needs: prepare-sycl-toolchain
154+
runs-on: ubuntu-latest
155+
timeout-minutes: 180
156+
steps:
157+
- uses: actions/checkout@v4
158+
with:
159+
submodules: true
160+
161+
- name: Setup ccache
162+
uses: hendrikmuhs/ccache-action@v1.2
163+
with:
164+
key: ccache-${{ github.job }}-linux-x86_64
165+
max-size: 4G
166+
167+
- name: Restore AdaptiveCpp toolchain cache
168+
uses: actions/cache/restore@v4
169+
with:
170+
path: |
171+
${{ runner.temp }}/AdaptiveCpp
172+
${{ runner.temp }}/AdaptiveCpp-build
173+
${{ runner.temp }}/adaptivecpp-install
174+
${{ runner.temp }}/archives
175+
key: sycl-toolchain-linux-x86_64-${{ env.ADAPTIVECPP_TAG }}-${{ env.ADAPTIVECPP_CACHE_VERSION }}
176+
fail-on-cache-miss: true
177+
178+
- name: Setup SYCL toolchain
179+
uses: ./.github/actions/setup-sycl-toolchain
180+
with:
181+
phase: build
182+
183+
- name: Install coverage tools
184+
shell: bash
185+
run: sudo apt-get update && sudo apt-get install -y gcovr
186+
187+
- name: Configure
188+
shell: bash
189+
run: |
190+
cmake -S . -B build/sycl-coverage -G Ninja \
191+
-DCMAKE_BUILD_TYPE=Debug \
192+
-DCMAKE_C_COMPILER="${ITLABAI_CC}" \
193+
-DCMAKE_CXX_COMPILER="${ITLABAI_CXX}" \
194+
-DCMAKE_PREFIX_PATH="${ITLABAI_CMAKE_PREFIX_PATH}" \
195+
-DOpenMP_ROOT="${ITLABAI_OPENMP_ROOT}" \
196+
-DACPP_TARGETS="${ACPP_TARGETS}" \
197+
-DCMAKE_C_FLAGS="--coverage" \
198+
-DCMAKE_CXX_FLAGS="--coverage" \
199+
-DCMAKE_EXE_LINKER_FLAGS="--coverage" \
200+
-DCMAKE_SHARED_LINKER_FLAGS="--coverage" \
201+
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
202+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
203+
204+
- name: Build
205+
run: cmake --build build/sycl-coverage --target SYCL_Example run_test --parallel
206+
207+
- name: Test
208+
run: ctest --test-dir build/sycl-coverage --output-on-failure -R '^(UnitTests|SYCL\.Example)$'
209+
210+
- name: Generate SYCL coverage data
211+
run: gcovr -r . --xml -o sycl-coverage.xml --gcov-executable "llvm-cov-18 gcov" --gcov-ignore-parse-errors
212+
213+
- name: Upload SYCL coverage report to Codecov
214+
uses: codecov/codecov-action@v4.0.1
215+
with:
216+
files: sycl-coverage.xml
217+
flags: sycl
218+
fail_ci_if_error: true
219+
token: ${{ secrets.CODECOV_TOKEN }}
220+
slug: embedded-dev-research/ITLabAI

test/parallel/test_sycl_parallel.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1+
#include <stdexcept>
2+
13
#include "gtest/gtest.h"
24
#include "parallel/parallel.hpp"
35

46
#ifdef ITLABAI_HAS_SYCL
5-
67
# include <vector>
8+
#endif
79

810
namespace it_lab_ai {
911
namespace {
1012

13+
#ifdef ITLABAI_HAS_SYCL
1114
TEST(sycl_parallel, parallel_for_writes_expected_values) {
1215
constexpr std::size_t kSize = 1024;
1316
std::vector<int> values(kSize, 0);
@@ -25,7 +28,15 @@ TEST(sycl_parallel, reports_selected_device) {
2528
EXPECT_FALSE(parallel::sycl_device_name().empty());
2629
}
2730

28-
} // namespace
29-
} // namespace it_lab_ai
31+
#else
32+
33+
TEST(sycl_parallel, throws_when_backend_is_unavailable) {
34+
EXPECT_THROW(parallel::parallel_for(1024, [](std::size_t) {},
35+
parallel::Backend::kSycl),
36+
std::runtime_error);
37+
}
3038

3139
#endif
40+
41+
} // namespace
42+
} // namespace it_lab_ai

0 commit comments

Comments
 (0)