Skip to content

Commit 73bdd25

Browse files
authored
Fix build errors and improve CI config (#42)
* Fix -Wmissing-template-arg-list-after-template-kw compilation errors in nbody and fluid demos. * Fix sycl-ls regex in ConfigureSYCL.cmake following the removal of "ext_oneapi" from backend names. * Update ConfigureSYCL.cmake default CUDA and HIP arch to the oldest supported by oneAPI 2025.0. * Improve OpenMP CMake test in matrix_multiply_omp_compare sample. Previously it assumed all clang++ drivers support -fopenmp. This is only true in the oneAPI base toolkit version, but the open-source DPC++ nightly releases are built without libomp.so and linking with -fopenmp fails. Use try_compile to figure out if -fopenmp works. * Add a warning suppresion file to suppress CI build failures in external code from submodules. * Update the CI container with newer versions of CUDA and ROCm, and use a recent DPC++ open-source nightly instead of a oneAPI Toolkit release. * Restore CI workflow's permission to push containers to registry. * Do not push to registry in pull-request CI (not allowed in GitHub). Instead, push the image to a local registry and use that to build the code. Push to registry only in CI triggered by branch push.
1 parent def41b4 commit 73bdd25

File tree

8 files changed

+112
-90
lines changed

8 files changed

+112
-90
lines changed

.github/workflows/ci.yml

Lines changed: 34 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on: [push, pull_request]
44

55
permissions:
66
contents: read
7+
packages: write
78

89
env:
910
REGISTRY: ghcr.io
@@ -25,15 +26,20 @@ jobs:
2526
fallback-style: 'Google'
2627
include-regex: '^.*\.((((c|C)(c|pp|xx|\+\+)?$)|((h|H)h?(pp|xx|\+\+)?$))|(frag|vert))$'
2728

28-
build-container:
29+
build-dpcpp-nightly:
2930
runs-on: ubuntu-latest
3031

31-
outputs:
32-
image_tag: ${{ steps.set_image_tag.outputs.image_tag }}
32+
services:
33+
registry:
34+
image: registry:2.8.3@sha256:a3d8aaa63ed8681a604f1dea0aa03f100d5895b6a58ace528858a7b332415373
35+
ports:
36+
- 5000:5000
3337

3438
steps:
3539
- name: Checkout
3640
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
41+
with:
42+
submodules: 'recursive'
3743

3844
- name: Path filter
3945
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
@@ -46,75 +52,55 @@ jobs:
4652
- name: Set up Docker Buildx
4753
if: steps.changes.outputs.container == 'true'
4854
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0
55+
with:
56+
driver-opts: network=host
4957

5058
- name: Log in to the Container registry
51-
if: steps.changes.outputs.container == 'true'
59+
if: steps.changes.outputs.container == 'false' || github.event_name == 'push'
5260
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
5361
with:
5462
registry: ${{ env.REGISTRY }}
5563
username: ${{ github.actor }}
5664
password: ${{ secrets.GITHUB_TOKEN }}
5765

5866
- name: Extract metadata
67+
if: steps.changes.outputs.container == 'false' || github.event_name == 'push'
5968
id: meta
6069
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5.6.1
6170
with:
6271
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
6372
tags: |
64-
# set latest tag for the main branch
65-
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }},priority=5000
66-
# use ref_name in all other cases
67-
type=raw,value=${{github.ref_name}},priority=4000
68-
69-
- name: Build and push
70-
if: steps.changes.outputs.container == 'true'
73+
# push latest tag on main branch push
74+
type=raw,value=latest,enable=${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }},priority=5000
75+
# push branch name as the tag for every other branch push
76+
type=raw,value=${{github.ref_name}},enable=${{ github.event_name == 'push' && github.ref != 'refs/heads/main' }},priority=4000
77+
# pull latest in PRs
78+
type=raw,value=latest,enable=${{ github.event_name != 'push' }},priority=3000
79+
80+
- name: Build and push image
81+
if: steps.changes.outputs.container == 'true' && github.event_name == 'push'
7182
uses: docker/build-push-action@ca877d9245402d1537745e0e356eab47c3520991 # v6.13.0
7283
with:
7384
context: '{{defaultContext}}:ci'
7485
push: true
7586
tags: ${{ steps.meta.outputs.tags }}
7687
labels: ${{ steps.meta.outputs.labels }}
7788

78-
- name: Set output image tag
79-
id: set_image_tag
80-
run: >
81-
tags="${{ steps.meta.outputs.tags }}"
82-
&& tags=${tags%% *}
83-
&& image=${tags%:*}
84-
&& tag="${{ steps.changes.outputs.container == 'true' && '${tags#*:}' || 'latest' }}"
85-
&& echo "image_tag=${image}:${tag}"
86-
&& echo "image_tag=${image}:${tag}" >> "$GITHUB_OUTPUT"
87-
88-
cmake-build:
89-
needs: build-container
90-
runs-on: ubuntu-latest
91-
container:
92-
image: ${{ needs.build-container.outputs.image_tag }}
93-
credentials:
94-
username: ${{ github.actor }}
95-
password: ${{ secrets.github_token }}
96-
steps:
97-
- name: Checkout
98-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
89+
- name: Build local image
90+
if: steps.changes.outputs.container == 'true' && github.event_name != 'push'
91+
uses: docker/build-push-action@ca877d9245402d1537745e0e356eab47c3520991 # v6.13.0
9992
with:
100-
submodules: "recursive"
101-
102-
- name: Configure CMake
103-
run: >
104-
cmake -B ${{github.workspace}}/build
105-
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
106-
-DCMAKE_CXX_COMPILER=clang++
107-
-DENABLE_GRAPHICS=ON
108-
-DENABLE_SPIR=ON
109-
-DENABLE_CUDA=ON -DCUDA_COMPUTE_CAPABILITY=80
110-
-DENABLE_HIP=ON -DHIP_GFX_ARCH=gfx90a
111-
-DCMAKE_CXX_FLAGS='-Wall -Wextra -Wpedantic -Werror'
112-
-G Ninja
93+
context: '{{defaultContext}}:ci'
94+
push: true
95+
tags: localhost:5000/sycl-samples:local
96+
labels: ${{ steps.meta.outputs.labels }}
11397

114-
- name: Build
115-
run: cmake --build ${{github.workspace}}/build -- -k 0
98+
- name: CMake configure and build
99+
run: |
100+
if [[ "${{steps.changes.outputs.container}}" == "false" || "${{github.event_name}}" == "push" ]]; then IMAGE_TAG=${{steps.meta.outputs.tags}}; else IMAGE_TAG=localhost:5000/sycl-samples:local; fi
101+
docker run -v${{github.workspace}}:/work ${IMAGE_TAG} ${{env.BUILD_TYPE}}
116102
117-
cmake-build-nographics:
103+
build-oneapi-basekit-nographics:
118104
runs-on: ubuntu-latest
119105
container:
120106
image: intel/oneapi-basekit:latest

ci/Dockerfile

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,39 @@
11
FROM ubuntu:24.04@sha256:3f85b7caad41a95462cf5b787d8a04604c8262cdcdf9a472b8c52ef83375fe15
22

33
# Get basic dependencies from Ubuntu repositories
4-
RUN apt update && apt -y install wget gpg git cmake ninja-build \
5-
gcc-12 libstdc++-12-dev libsdl2-dev \
4+
ARG DEBIAN_FRONTEND=noninteractive
5+
RUN apt update \
6+
&& apt -y install wget gpg git cmake ninja-build g++ libsdl2-dev \
67
&& apt clean
78

89
# Install nvcc (dependency for compiling for a CUDA target)
9-
ARG CUDA_VERSION=12-4
10+
ARG CUDA_VERSION=12-8
1011
RUN wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.0-1_all.deb \
1112
&& dpkg -i cuda-keyring_1.0-1_all.deb && rm cuda-keyring_1.0-1_all.deb \
1213
&& apt update && apt -y install cuda-nvcc-${CUDA_VERSION} && apt clean
1314

1415
# Install ROCm device libs (dependency for compiling for a HIP target)
15-
ARG ROCM_VERSION=5.4.3
16+
ARG ROCM_VERSION=6.2.4
1617
RUN wget https://repo.radeon.com/rocm/rocm.gpg.key -O - \
1718
| gpg --dearmor | tee /etc/apt/keyrings/rocm.gpg > /dev/null \
1819
&& echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/rocm.gpg] https://repo.radeon.com/rocm/apt/${ROCM_VERSION} jammy main" \
1920
| tee /etc/apt/sources.list.d/rocm.list \
20-
&& apt update && apt -y install rocm-device-libs && apt clean
21+
&& apt update && apt -y install rocm-device-libs${ROCM_VERSION} && apt clean
2122

22-
# Install DPC++ and remove parts we don't need to reduce the container size
23-
ARG ONEAPI_VERSION=2024.1
24-
RUN wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \
25-
| gpg --dearmor | tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null \
26-
&& echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" \
27-
| tee /etc/apt/sources.list.d/oneAPI.list \
28-
&& apt update && apt -y install intel-oneapi-compiler-dpcpp-cpp-${ONEAPI_VERSION} \
29-
&& apt clean \
30-
&& cd /opt/intel/oneapi \
31-
&& rm -rf conda_channel debugger dev-utilities dpl compiler/latest/linux/lib/oclfpga
23+
# Download DPC++ nightly release
24+
ARG DPCPP_NIGHTLY=2025-03-06
25+
RUN mkdir /opt/dpcpp \
26+
&& wget -q -P /opt/dpcpp https://github.com/intel/llvm/releases/download/nightly-${DPCPP_NIGHTLY}/sycl_linux.tar.gz \
27+
&& tar -C /opt/dpcpp -xzf /opt/dpcpp/sycl_linux.tar.gz \
28+
&& rm /opt/dpcpp/sycl_linux.tar.gz
3229

3330
# Set up the environment
34-
ENV ONEAPI_ROOT=/opt/intel/oneapi
35-
ENV CMPLR_ROOT=${ONEAPI_ROOT}/compiler/latest
36-
ENV PATH=${CMPLR_ROOT}/bin:${CMPLR_ROOT}/bin/compiler:${PATH}
37-
ENV CPATH=${CMPLR_ROOT}/include:${CPATH}
38-
ENV LIBRARY_PATH=${CMPLR_ROOT}/lib:${LIBRARY_PATH}
39-
ENV LD_LIBRARY_PATH=${CMPLR_ROOT}/lib:${LD_LIBRARY_PATH}
40-
ENV HIP_DEVICE_LIB_PATH=/usr/lib/x86_64-linux-gnu/amdgcn/bitcode
31+
ENV DPCPP_ROOT=/opt/dpcpp
32+
ENV PATH=${DPCPP_ROOT}/bin:${PATH}
33+
ENV CPATH=${DPCPP_ROOT}/include:${CPATH}
34+
ENV LIBRARY_PATH=${DPCPP_ROOT}/lib:${LIBRARY_PATH}
35+
ENV LD_LIBRARY_PATH=${DPCPP_ROOT}/lib:${LD_LIBRARY_PATH}
36+
ENV HIP_DEVICE_LIB_PATH=/opt/rocm/amdgcn/bitcode
4137

42-
# Set up entry point
43-
ENTRYPOINT []
44-
CMD /bin/bash
38+
WORKDIR /work
39+
ENTRYPOINT ["/work/ci/build.sh"]

ci/build.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/bash
2+
3+
BUILD_TYPE=$1
4+
if [[ -z "$BUILD_TYPE" ]]; then
5+
BUILD_TYPE=Release
6+
fi
7+
8+
cmake -B build \
9+
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
10+
-DCMAKE_CXX_COMPILER=clang++ \
11+
-DENABLE_GRAPHICS=ON \
12+
-DENABLE_SPIR=ON \
13+
-DENABLE_CUDA=ON -DCUDA_COMPUTE_CAPABILITY=80 \
14+
-DENABLE_HIP=ON -DHIP_GFX_ARCH=gfx90a \
15+
-DCMAKE_CXX_FLAGS="-Wall -Wextra -Wpedantic -Werror --warning-suppression-mappings=${PWD}/ci/warning-suppresions.txt" \
16+
-G Ninja
17+
18+
cmake --build build -- -k 0

ci/warning-suppresions.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Suppress warnings in external code from submodules
2+
3+
[nontrivial-memcall]
4+
src:*/modules/imgui/*
5+
6+
[deprecated-literal-operator]
7+
src:*/modules/corrade/*
8+
src:*/modules/magnum/*

cmake/ConfigureSYCL.cmake

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
# Detect available backends
2323
# ------------------------------------------------
2424
execute_process(
25-
COMMAND bash -c "! sycl-ls | grep -q ext_oneapi_cuda"
25+
COMMAND bash -c "! sycl-ls | grep -q cuda"
2626
RESULT_VARIABLE CUDA_BACKEND_AVAILABLE)
2727
execute_process(
28-
COMMAND bash -c "! sycl-ls | grep -q ext_oneapi_hip"
28+
COMMAND bash -c "! sycl-ls | grep -q hip"
2929
RESULT_VARIABLE HIP_BACKEND_AVAILABLE)
3030
execute_process(
3131
COMMAND bash -c "! sycl-ls | grep -q 'opencl\\|level_zero'"
@@ -41,7 +41,7 @@ set(SYCL_TARGETS "")
4141
# ------------------------------------------------
4242
if(${ENABLE_CUDA})
4343
string(JOIN "," SYCL_TARGETS "${SYCL_TARGETS}" "nvptx64-nvidia-cuda")
44-
set(DEFAULT_CUDA_COMPUTE_CAPABILITY "50")
44+
set(DEFAULT_CUDA_COMPUTE_CAPABILITY "60")
4545
set(CUDA_COMPUTE_CAPABILITY "" CACHE BOOL
4646
"CUDA architecture (compute capability), e.g. sm_80. Default value is auto-configured using nvidia-smi.")
4747
# Auto-configure if not specified by user
@@ -65,7 +65,7 @@ endif()
6565
# ------------------------------------------------
6666
if(${ENABLE_HIP})
6767
string(JOIN "," SYCL_TARGETS "${SYCL_TARGETS}" "amdgcn-amd-amdhsa")
68-
set(DEFAULT_HIP_GFX_ARCH "gfx906")
68+
set(DEFAULT_HIP_GFX_ARCH "gfx908")
6969
set(HIP_GFX_ARCH "" CACHE BOOL
7070
"HIP architecture tag, e.g. gfx90a. Default value is auto-configured using rocminfo.")
7171
# Auto-configure if not specified by user

src/fluid/fluid.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class SYCLFluidContainer {
8080
// Returns a pointer to the pixel data buffer.
8181
template <typename Func>
8282
void WithData(Func&& func) {
83-
auto acc{img.template get_host_access(sycl::read_only)};
83+
auto acc{img.template get_host_access<>(sycl::read_only)};
8484
func(acc.get_pointer());
8585
}
8686

@@ -207,8 +207,8 @@ class SYCLFluidContainer {
207207
// Update the image pixel data with the appropriate color for a given
208208
// density.
209209
queue.submit([&](sycl::handler& cgh) {
210-
auto img_acc{img.template get_access(cgh, sycl::write_only)};
211-
auto density_a{density_b.template get_access(cgh, sycl::read_write)};
210+
auto img_acc{img.template get_access<>(cgh, sycl::write_only)};
211+
auto density_a{density_b.template get_access<>(cgh, sycl::read_write)};
212212
cgh.parallel_for<image_kernal>(
213213
sycl::range<1>(size * size), [=](sycl::item<1> item) {
214214
auto index{item.get_id(0)};
@@ -240,7 +240,7 @@ class SYCLFluidContainer {
240240
// Creates read_write accessors from a buffer.
241241
template <typename T>
242242
static read_write_accessor CreateAccessor(sycl::handler& cgh, T buffer) {
243-
return buffer.template get_access(cgh, sycl::read_write);
243+
return buffer.template get_access<>(cgh, sycl::read_write);
244244
}
245245

246246
// Get clamped index based off of coordinates.

src/matrix_multiply_omp_compare/CMakeLists.txt

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,25 @@ set(MATRIX_MULTIPLY_FLAGS ${SYCL_FLAGS})
44
find_package(OpenMP QUIET)
55
if(OpenMP_CXX_FOUND)
66
target_link_libraries(matrix_multiply_omp_compare PUBLIC OpenMP::OpenMP_CXX)
7+
message(STATUS "Found OpenMP: ${OpenMP_omp_LIBRARY}")
78
elseif(CMAKE_CXX_COMPILER MATCHES "clang")
8-
# CMake's FindOpenMP doesn't recognise LLVM internal implementation, but
9-
# it's still possible to parallelise OpenMP loops with clang++ -fopenmp
10-
list(APPEND MATRIX_MULTIPLY_FLAGS -fopenmp)
9+
# CMake's FindOpenMP doesn't recognise that oneAPI Base Toolkit clang++
10+
# compiler driver supports the -fopenmp flag. However, other clang++ builds
11+
# may not support it. Test whether clang++ -fopenmp works to determine if we
12+
# can use it.
13+
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/omp-test.cpp "int main(){}")
14+
try_compile(CLANG_SUPPORTS_FOPENMP
15+
${CMAKE_CURRENT_BINARY_DIR}
16+
${CMAKE_CURRENT_BINARY_DIR}/omp-test.cpp
17+
COMPILE_DEFINITIONS -fopenmp
18+
LINK_OPTIONS -fopenmp)
19+
file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/omp-test.cpp)
20+
if (CLANG_SUPPORTS_FOPENMP)
21+
message(STATUS "Found OpenMP: supported with clang++ -fopenmp flag")
22+
list(APPEND MATRIX_MULTIPLY_FLAGS -fopenmp)
23+
else()
24+
message(STATUS "OpenMP not found, matrix_multiply_omp_compare will compare SYCL to serial CPU execution")
25+
endif()
1126
else()
1227
message(STATUS "OpenMP not found, matrix_multiply_omp_compare will compare SYCL to serial CPU execution")
1328
endif()

src/nbody/sycl_bufs.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ struct BufToReadAccFunc {
3131
template <typename In>
3232
AUTO_FUNC(
3333
// pair of (buffer, handler)
34-
operator()(In && in), std::forward<In>(in).first.template get_access(
34+
operator()(In && in), std::forward<In>(in).first.template get_access<>(
3535
*std::forward<In>(in).second, sycl::read_only))
3636
};
3737

@@ -40,27 +40,27 @@ struct BufToDcdWriteAccFunc {
4040
// pair of (buffer, handler)
4141
template <typename In>
4242
AUTO_FUNC(operator()(In && in),
43-
std::forward<In>(in).first.template get_access(
43+
std::forward<In>(in).first.template get_access<>(
4444
*std::forward<In>(in).second, sycl::write_only))
4545
};
4646

4747
// Template function object which transforms buffers to host read accessors
4848
struct BufToHostReadAccFunc {
4949
template <typename In>
5050
auto operator()(In&& in)
51-
-> decltype(std::forward<In>(in).template get_host_access(
51+
-> decltype(std::forward<In>(in).template get_host_access<>(
5252
sycl::read_only)) {
53-
return std::forward<In>(in).template get_host_access(sycl::read_only);
53+
return std::forward<In>(in).template get_host_access<>(sycl::read_only);
5454
}
5555
};
5656

5757
// Template function object which transforms buffers to host write accessors
5858
struct BufToHostDcdWriteAccFunc {
5959
template <typename In>
6060
auto operator()(In&& in)
61-
-> decltype(std::forward<In>(in).template get_host_access(
61+
-> decltype(std::forward<In>(in).template get_host_access<>(
6262
sycl::write_only)) {
63-
return std::forward<In>(in).template get_host_access(sycl::write_only);
63+
return std::forward<In>(in).template get_host_access<>(sycl::write_only);
6464
}
6565
};
6666

0 commit comments

Comments
 (0)