Skip to content

Commit

Permalink
Intel gpu (#53)
Browse files Browse the repository at this point in the history
This patch adds support for Intel GPUs. It uses OneAPI and SYCL. Therefore OneAPI needs to be installed. It includes github actions to test the build and mentions in the README. (Also changes actions somewhat)
  • Loading branch information
rschoene authored Dec 19, 2023
1 parent 1bff426 commit c08cefc
Show file tree
Hide file tree
Showing 10 changed files with 650 additions and 47 deletions.
154 changes: 122 additions & 32 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,39 @@ jobs:
os: [ubuntu-20.04]
compiler: [g++-7, g++-8, g++-9, g++-10, clang++-8, clang++-9, clang++-10]
CUDA: ['0', '8.0', '11.0', 'NVHPC-22.5']
ONEAPI: ['0', '2023.2.0', '2024.0']

runs-on: ${{ matrix.os }}

env:
CUDA_ROOT: '/usr/local/cuda'

steps:
- name: Install g++-7
- name: Install g++-7 (if needed)
if: matrix.compiler == 'g++-7'
run: |
sudo apt install g++-7
- name: Install g++-8
- name: Install g++-8 (if needed)
if: matrix.compiler == 'g++-8'
run: |
sudo apt install g++-8
- name: Install clang++-8
- name: Install clang++-8 (if needed)
if: matrix.compiler == 'clang++-8'
run: |
sudo apt install clang-8
- name: Install clang++-9
- name: Install clang++-9 (if needed)
if: matrix.compiler == 'clang++-9'
run: |
sudo apt install clang-9
- name: Install clang++-10 (if needed)
if: matrix.compiler == 'clang++-10'
run: |
sudo apt install clang-10
- uses: actions/checkout@v2
with:
fetch-depth: '0'
- name: Install CUDA runtime
if: matrix.CUDA != '0'
- name: Install CUDA runtime (if needed)
if: matrix.CUDA != '0' && matrix.ONEAPI == 0
run: |
case ${{ matrix.CUDA }} in
8.0)
Expand All @@ -56,18 +61,25 @@ jobs:
tar xpzf nvhpc_2022_225_Linux_x86_64_cuda_11.7.tar.gz
sudo NVHPC_SILENT="true" NVHPC_INSTALL_DIR="$CUDA_ROOT" NVHPC_INSTALL_TYPE="single" ./nvhpc_2022_225_Linux_x86_64_cuda_11.7/install
esac
- name: Install OneAPI Base-Toolkit (if needed)
if: matrix.ONEAPI != '0' && matrix.CUDA == '0'
run: |
wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | gpg --dearmor | sudo 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" | sudo tee /etc/apt/sources.list.d/oneAPI.list
sudo apt update
sudo apt install intel-basekit-${{ matrix.ONEAPI }}
- name: Create build directory
run: |
mkdir build
- name: Run CMake configure
if: matrix.CUDA == '0'
- name: Run CMake configure (default)
if: matrix.CUDA == '0' && matrix.ONEAPI == '0'
env:
CXX: ${{ matrix.compiler }}
run: |
cd build
cmake ..
- name: Run CMake configure
if: matrix.CUDA != '0' && matrix.CUDA != 'NVHPC-22.5'
- name: Run CMake configure (CUDA)
if: matrix.CUDA != '0' && matrix.CUDA != 'NVHPC-22.5' && matrix.ONEAPI == '0'
env:
CXX: ${{ matrix.compiler }}
run: |
Expand All @@ -82,8 +94,8 @@ jobs:
cd build
cmake -DFIRESTARTER_BUILD_TYPE="FIRESTARTER_CUDA" -DCMAKE_EXE_LINKER_FLAGS="-L${CUDA_ROOT}/lib64/stubs/" ..
- name: Run CMake configure
if: matrix.CUDA == 'NVHPC-22.5'
- name: Run CMake configure (CUDA with NVHPC)
if: matrix.CUDA == 'NVHPC-22.5' && matrix.ONEAPI == '0'
env:
CXX: ${{ matrix.compiler }}
run: |
Expand All @@ -95,41 +107,76 @@ jobs:
cd build
cmake -DFIRESTARTER_BUILD_TYPE="FIRESTARTER_CUDA" -DCMAKE_EXE_LINKER_FLAGS=-L"$CUDA_ROOT/$NVARCH/22.5/cuda/11.7/lib64/stubs" -LA ..
- name: Build
- name: Run CMake configure (OneAPI 2023.2.0)
if: matrix.CUDA == '0' && matrix.ONEAPI =='2023.2.0'
run: |
. /opt/intel/oneapi/setvars.sh
cd build
cmake -DFIRESTARTER_BUILD_TYPE="FIRESTARTER_ONEAPI" ..
- name: Run CMake configure (OneAPI 2024.0)
if: matrix.CUDA == '0' && matrix.ONEAPI =='2024.0'
run: |
. /opt/intel/oneapi/${{ matrix.ONEAPI }}/oneapi-vars.sh
cd build
cmake -DFIRESTARTER_BUILD_TYPE="FIRESTARTER_ONEAPI" ..
- name: Build (default, CUDA)
if: matrix.ONEAPI =='0'
run: |
cd build
make -j2
- name: Strip binary
if: matrix.CUDA == '0'
- name: Build (OneAPI 2023.2.0)
if: matrix.CUDA == '0' && matrix.ONEAPI =='2023.2.0'
run: |
. /opt/intel/oneapi/setvars.sh
cd build
make -j2
- name: Build (OneAPI 2024.0)
if: matrix.CUDA == '0' && matrix.ONEAPI =='2024.0'
run: |
. /opt/intel/oneapi/${{ matrix.ONEAPI }}/oneapi-vars.sh
cd build
make -j2
- name: Strip binary (default)
if: matrix.CUDA == '0' && matrix.ONEAPI == '0'
run: |
cd build
strip src/FIRESTARTER
- name: Strip binary
if: matrix.CUDA != '0'
- name: Strip binary (CUDA)
if: matrix.CUDA != '0' && matrix.ONEAPI == '0'
run: |
cd build
strip src/FIRESTARTER_CUDA
- name: Test FIRESTARTER
if: matrix.CUDA == '0'
- name: Strip binary (OneAPI)
if: matrix.ONEAPI != '0' && matrix.CUDA == '0'
run: |
cd build
strip src/FIRESTARTER_ONEAPI
- name: Test FIRESTARTER (default)
if: matrix.CUDA == '0' && matrix.ONEAPI == '0'
run: ./build/src/FIRESTARTER -t 1
- uses: actions/upload-artifact@v2
if: matrix.compiler == 'clang++-10' && matrix.CUDA == '0'
if: matrix.compiler == 'clang++-10' && matrix.CUDA == '0' && matrix.ONEAPI == '0'
with:
name: FIRESTARTER-linux
path: build/src/FIRESTARTER
- uses: actions/upload-artifact@v2
if: matrix.compiler == 'clang++-10' && matrix.CUDA != '0'
if: matrix.compiler == 'clang++-10' && matrix.CUDA != '0' && matrix.ONEAPI == '0'
with:
name: FIRESTARTER_CUDA_${{ matrix.CUDA }}-linux
path: build/src/FIRESTARTER_CUDA
- uses: actions/upload-artifact@v2
if: matrix.compiler == 'clang++-10' && matrix.CUDA == '0' && matrix.ONEAPI != '0'
with:
name: FIRESTARTER_ONEAPI_${{ matrix.ONEAPI }}-linux
path: build/src/FIRESTARTER_ONEAPI
build-windows:
strategy:
fail-fast: false
matrix:
os: [windows-2019]
cfg:
- { CUDA: '0', MSVC: true }
- { CUDA: '0', MSVC: false }
- { CUDA: '0', ONEAPI: '0', MSVC: true }
- { CUDA: '0', ONEAPI: '0', MSVC: false }

runs-on: ${{ matrix.os }}

Expand Down Expand Up @@ -202,7 +249,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [macos-10.15]
os: [macos-11, macos-12, macos-13]
#os: [macos-11.0, macos-10.15]

runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -234,14 +281,14 @@ jobs:
cd build
./src/FIRESTARTER -t 1
- uses: actions/upload-artifact@v2
if: matrix.os == 'macos-10.15'
if: matrix.os == 'macos-12'
with:
name: FIRESTARTER-macOS_10.15
name: FIRESTARTER-macOS_12
path: build/src/FIRESTARTER
- uses: actions/upload-artifact@v2
if: matrix.os == 'macos-11.0'
if: matrix.os == 'macos-11'
with:
name: FIRESTARTER-macOS_11.0
name: FIRESTARTER-macOS_11
path: build/src/FIRESTARTER
create-download:
name: Create download for Website
Expand Down Expand Up @@ -292,6 +339,38 @@ jobs:
mv FIRESTARTER/FIRESTARTER_CUDA FIRESTARTER_CUDA_11.0
rm -rf FIRESTARTER
chmod +x FIRESTARTER_CUDA_11.0
# Linux CUDA HPC
- name: Retrieve FIRESTARTER_CUDA_NVHPC-22.5-linux
uses: actions/download-artifact@v2
with:
name: FIRESTARTER_CUDA_NVHPC-22.5-linux
path: FIRESTARTER
- name: Move binary to right directory
run: |
mv FIRESTARTER/FIRESTARTER_CUDA FIRESTARTER_CUDA_NVHPC-22.5
rm -rf FIRESTARTER
chmod +x FIRESTARTER_CUDA_NVHPC-22.5
# Linux OneAPI
- name: Retrieve FIRESTARTER_ONEAPI_2024.0-linux
uses: actions/download-artifact@v2
with:
name: FIRESTARTER_ONEAPI_2024.0-linux
path: FIRESTARTER
- name: Move binary to right directory
run: |
mv FIRESTARTER/FIRESTARTER_ONEAPI FIRESTARTER_ONEAPI_2024.0
rm -rf FIRESTARTER
chmod +x FIRESTARTER_ONEAPI_2024.0
- name: Retrieve FIRESTARTER_ONEAPI_2023.2.0-linux
uses: actions/download-artifact@v2
with:
name: FIRESTARTER_ONEAPI_2023.2.0-linux
path: FIRESTARTER
- name: Move binary to right directory
run: |
mv FIRESTARTER/FIRESTARTER_ONEAPI FIRESTARTER_ONEAPI_2023.2.0
rm -rf FIRESTARTER
chmod +x FIRESTARTER_ONEAPI_2023.2.0
# OSX 11.0
#- name: Retrieve FIRESTARTER-macOS_11.0
# uses: actions/download-artifact@v2
Expand All @@ -304,16 +383,26 @@ jobs:
# rm -rf FIRESTARTER
# chmod +x ../FIRESTARTER-macOS_11.0
# OSX 10.15
- name: Retrieve FIRESTARTER-macOS_10.15
- name: Retrieve FIRESTARTER-macOS_11
uses: actions/download-artifact@v2
with:
name: FIRESTARTER-macOS_11
path: FIRESTARTER
- name: Move binary to right directory
run: |
mv FIRESTARTER/FIRESTARTER FIRESTARTER-macOS_11
rm -rf FIRESTARTER
chmod +x FIRESTARTER-macOS_11
- name: Retrieve FIRESTARTER-macOS_12
uses: actions/download-artifact@v2
with:
name: FIRESTARTER-macOS_10.15
name: FIRESTARTER-macOS_12
path: FIRESTARTER
- name: Move binary to right directory
run: |
mv FIRESTARTER/FIRESTARTER FIRESTARTER-macOS_10.15
mv FIRESTARTER/FIRESTARTER FIRESTARTER-macOS_12
rm -rf FIRESTARTER
chmod +x FIRESTARTER-macOS_10.15
chmod +x FIRESTARTER-macOS_12
# Windows
- name: Retrieve FIRESTARTER-windows
uses: actions/download-artifact@v2
Expand Down Expand Up @@ -342,3 +431,4 @@ jobs:
with:
name: FIRESTARTER.tar.gz
path: FIRESTARTER.tar.gz

8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,17 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
endif()
endif()

set(FIRESTARTER_BUILD_TYPE "FIRESTARTER" CACHE STRING "FIRESTARTER_BUILD_TYPE can be any of FIRESTARTER or FIRESTARTER_CUDA.")
set_property(CACHE FIRESTARTER_BUILD_TYPE PROPERTY STRINGS FIRESTARTER FIRESTARTER_CUDA)
set(FIRESTARTER_BUILD_TYPE "FIRESTARTER" CACHE STRING "FIRESTARTER_BUILD_TYPE can be any of FIRESTARTER, FIRESTARTER_CUDA, or FIRESTARTER_ONEAPI.")
set_property(CACHE FIRESTARTER_BUILD_TYPE PROPERTY STRINGS FIRESTARTER FIRESTARTER_CUDA FIRESTARTER_ONEAPI)
if (${FIRESTARTER_BUILD_TYPE} STREQUAL "FIRESTARTER")
option(FIRESTARTER_LINK_STATIC "Link FIRESTARTER as a static binary. Note, dlopen is not supported in static binaries. This option is not available on macOS or with CUDA enabled." ON)
option(FIRESTARTER_LINK_STATIC "Link FIRESTARTER as a static binary. Note, dlopen is not supported in static binaries. This option is not available on macOS or with CUDA or OneAPI enabled." ON)
endif()
if (${FIRESTARTER_BUILD_TYPE} STREQUAL "FIRESTARTER")
option(FIRESTARTER_BUILD_HWLOC "Build hwloc dependency." ON)
elseif(${FIRESTARTER_BUILD_TYPE} STREQUAL "FIRESTARTER_CUDA")
option(FIRESTARTER_BUILD_HWLOC "Build hwloc dependency." ON)
elseif(${FIRESTARTER_BUILD_TYPE} STREQUAL "FIRESTARTER_ONEAPI")
option(FIRESTARTER_BUILD_HWLOC "Build hwloc dependency." ON)
endif()
option(FIRESTARTER_THREAD_AFFINITY "Enable FIRESTARTER to set affinity to hardware threads." ON)

Expand Down
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![Build Status](https://github.com/tud-zih-energy/FIRESTARTER/workflows/Build/badge.svg?branch=master)
![Build Status](https://github.com/tud-zih-energy/FIRESTARTER/actions/workflows/cmake.yml/badge.svg?branch=intel_gpu)

# FIRESTARTER - A Processor Stress Test Utility

Expand Down Expand Up @@ -147,11 +147,13 @@ GCC (>=7) or Clang (>=9) is supported.

CMake option | Description
:---------------------------- | :----------------------------
`FIRESTARTER_BUILD_TYPE` | Can be any of `FIRESTARTER` or `FIRESTARTER_CUDA`. Default `FIRESTARTER`
`FIRESTARTER_LINK_STATIC` | Link FIRESTARTER as a static binary. Note, dlopen is not supported in static binaries. This option is not available on macOS or with CUDA enabled. Default `ON`
`FIRESTARTER_BUILD_TYPE` | Can be any of `FIRESTARTER`, `FIRESTARTER_CUDA`, or `FIRESTARTER_ONEAPI`,. Default `FIRESTARTER`
`FIRESTARTER_LINK_STATIC` | Link FIRESTARTER as a static binary. Note, dlopen is not supported in static binaries. This option is not available on macOS or with CUDA or OneAPI enabled. Default `ON`
`FIRESTARTER_BUILD_HWLOC` | Build hwloc dependency. Default `ON`
`FIRESTARTER_THREAD_AFFINITY` | Enable FIRESTARTER to set affinity to hardware threads. Default `ON`

When building `FIRESTARTER_ONEAPI` make sure that the Intel Math Kernel Library (MKL) and the complier `icx` can be found. These will be used to build `FIRESTARTER`, while dependencies will be build with `$CC` and `$CXX` respectively.

## Metrics

The Linux version of FIRESTARTER supports to collect metrics during runtime.
Expand Down Expand Up @@ -245,6 +247,13 @@ If `perf-ipc` is not available use `ipc-estimate`
FIRESTARTER -t 20 --optimize=NSGA2 --optimization-metric sysfs-powercap-rapl,ipc-estimate
```

## OneAPI
`FIRESTARTER_ONEAPI` needs to find certain libraries, which are installed with
the Intel OneAPI toolkits, since some of these libraries cannot be linked statically.
Make sure that they are installed and `$LD_LIBRARY_PATH` is set-up correctly.
Make also sure that you have the correct drivers for your GPU installed so that
OneAPI can apply work to it.

## Reference

A detailed description can be found in the following paper. Please cite this if
Expand Down
13 changes: 10 additions & 3 deletions include/firestarter/Firestarter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
#include <firestarter/Cuda/Cuda.hpp>
#endif

#ifdef FIRESTARTER_BUILD_ONEAPI
#include <firestarter/OneAPI/OneAPI.hpp>
#endif



#include <firestarter/Constants.hpp>

#if defined(linux) || defined(__linux__)
Expand Down Expand Up @@ -132,6 +138,10 @@ class Firestarter {
std::unique_ptr<cuda::Cuda> _cuda;
#endif

#ifdef FIRESTARTER_BUILD_ONEAPI
std::unique_ptr<oneapi::OneAPI> _oneapi;
#endif

#if defined(linux) || defined(__linux__)
inline static std::unique_ptr<optimizer::OptimizerWorker> _optimizer;
std::shared_ptr<measurement::MeasurementWorker> _measurementWorker;
Expand Down Expand Up @@ -163,9 +173,6 @@ class Firestarter {
void signalLoadWorkers(int comm);
static void loadThreadWorker(std::shared_ptr<LoadWorkerData> td);

// CudaWorker.cpp
static void *cudaWorker(void *cudaData);

#ifdef FIRESTARTER_DEBUG_FEATURES
// DumpRegisterWorker.cpp
static void dumpRegisterWorker(std::unique_ptr<DumpRegisterWorkerData> data);
Expand Down
Loading

0 comments on commit c08cefc

Please sign in to comment.