Skip to content

Commit

Permalink
Add NVIDIA and AMD targets in CI builds (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafbiels authored Apr 30, 2024
1 parent f811144 commit 79142ca
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 16 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ jobs:
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
-DCMAKE_CXX_COMPILER=clang++
-DENABLE_GRAPHICS=ON
-DENABLE_SPIR=ON -DENABLE_CUDA=OFF -DENABLE_HIP=OFF
-DENABLE_SPIR=ON
-DENABLE_CUDA=ON -DCUDA_COMPUTE_CAPABILITY=80
-DENABLE_HIP=ON -DHIP_GFX_ARCH=gfx90a
-DCMAKE_CXX_FLAGS='-Wall -Wextra -Wpedantic -Werror'
-G Ninja
Expand Down
24 changes: 19 additions & 5 deletions ci/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,27 @@ RUN apt update && apt -y install wget gpg git cmake ninja-build \
gcc-12 libstdc++-12-dev libsdl2-dev \
&& apt clean

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

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

# Install DPC++ and remove parts we don't need to reduce the container size
ARG ONEAPI_VERSION=2024.1
RUN wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \
| gpg --dearmor | tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null \
&& echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" \
| tee /etc/apt/sources.list.d/oneAPI.list

# Install DPC++ and remove parts we don't need to reduce the container size
RUN apt update && apt -y install intel-oneapi-compiler-dpcpp-cpp-2024.0 \
| tee /etc/apt/sources.list.d/oneAPI.list \
&& apt update && apt -y install intel-oneapi-compiler-dpcpp-cpp-${ONEAPI_VERSION} \
&& apt clean \
&& cd /opt/intel/oneapi \
&& rm -rf conda_channel debugger dev-utilities dpl compiler/latest/linux/lib/oclfpga
Expand All @@ -24,6 +37,7 @@ ENV PATH=${CMPLR_ROOT}/bin:${CMPLR_ROOT}/bin/compiler:${PATH}
ENV CPATH=${CMPLR_ROOT}/include:${CPATH}
ENV LIBRARY_PATH=${CMPLR_ROOT}/lib:${LIBRARY_PATH}
ENV LD_LIBRARY_PATH=${CMPLR_ROOT}/lib:${LD_LIBRARY_PATH}
ENV HIP_DEVICE_LIB_PATH=/usr/lib/x86_64-linux-gnu/amdgcn/bitcode

# Set up entry point
ENTRYPOINT []
Expand Down
32 changes: 22 additions & 10 deletions cmake/ConfigureSYCL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,18 @@ set(SYCL_TARGETS "")
if(${ENABLE_CUDA})
string(JOIN "," SYCL_TARGETS "${SYCL_TARGETS}" "nvptx64-nvidia-cuda")
set(DEFAULT_CUDA_COMPUTE_CAPABILITY "50")
execute_process(
COMMAND bash -c "which nvidia-smi >/dev/null && nvidia-smi --query-gpu=compute_cap --format=csv,noheader | head -n 1 | tr -d '.'"
OUTPUT_VARIABLE CUDA_COMPUTE_CAPABILITY
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(CUDA_COMPUTE_CAPABILITY "" CACHE BOOL
"CUDA architecture (compute capability), e.g. sm_80. Default value is auto-configured using nvidia-smi.")
# Auto-configure if not specified by user
if ("${CUDA_COMPUTE_CAPABILITY}" STREQUAL "")
message(WARNING "Failed to autoconfigure CUDA Compute Capability using nvidia-smi. Will default to sm_${DEFAULT_CUDA_COMPUTE_CAPABILITY}")
execute_process(
COMMAND bash -c "which nvidia-smi >/dev/null && nvidia-smi --query-gpu=compute_cap --format=csv,noheader | head -n 1 | tr -d '.'"
OUTPUT_VARIABLE CUDA_COMPUTE_CAPABILITY
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
# Warn if not specified and failed to auto-configure
if ("${CUDA_COMPUTE_CAPABILITY}" STREQUAL "")
message(WARNING "Failed to autoconfigure CUDA_COMPUTE_CAPABILITY using nvidia-smi. Will default to sm_${DEFAULT_CUDA_COMPUTE_CAPABILITY}")
set(CUDA_COMPUTE_CAPABILITY ${DEFAULT_CUDA_COMPUTE_CAPABILITY} CACHE STRING "CUDA Compute Capability")
else()
message(STATUS "Enabled SYCL target CUDA with Compute Capability sm_${CUDA_COMPUTE_CAPABILITY}")
Expand All @@ -60,12 +66,18 @@ endif()
if(${ENABLE_HIP})
string(JOIN "," SYCL_TARGETS "${SYCL_TARGETS}" "amdgcn-amd-amdhsa")
set(DEFAULT_HIP_GFX_ARCH "gfx906")
execute_process(
COMMAND bash -c "which rocminfo >/dev/null && rocminfo | grep -o 'gfx[0-9]*' | head -n 1"
OUTPUT_VARIABLE HIP_GFX_ARCH
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(HIP_GFX_ARCH "" CACHE BOOL
"HIP architecture tag, e.g. gfx90a. Default value is auto-configured using rocminfo.")
# Auto-configure if not specified by user
if ("${CUDA_COMPUTE_CAPABILITY}" STREQUAL "")
execute_process(
COMMAND bash -c "which rocminfo >/dev/null && rocminfo | grep -o 'gfx[0-9]*' | head -n 1"
OUTPUT_VARIABLE HIP_GFX_ARCH
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
# Warn if not specified and failed to auto-configure
if ("${HIP_GFX_ARCH}" STREQUAL "")
message(WARNING "Failed to autoconfigure HIP gfx arch using rocminfo. Will default to ${DEFAULT_HIP_GFX_ARCH}")
message(WARNING "Failed to autoconfigure HIP_GFX_ARCH using rocminfo. Will default to ${DEFAULT_HIP_GFX_ARCH}")
set(HIP_GFX_ARCH ${DEFAULT_HIP_GFX_ARCH} CACHE STRING "HIP gfx arch")
else()
message(STATUS "Enabled SYCL target HIP with gfx arch ${HIP_GFX_ARCH}")
Expand Down

0 comments on commit 79142ca

Please sign in to comment.