Skip to content

Commit

Permalink
Format and minor CI update (KhronosGroup#2)
Browse files Browse the repository at this point in the history
* WIP

* Added error handling to context_properties

* Initial Utility and SDK lib docs

* Match definition to declaration

* Fix constraints lifetime

* Explicit narrowing conversion

* Fix lifetime

* Initial NBody sample

* Reduce NBody particle count

* NBody docs

* Add GLM as a dependency

* Don't draw after closing window

* Fix InteropWindow namespace

* Don't call CTOR explicitly

* Simplify includes

* Build SDK libs in correct place

* Hook SDK deps to the correct targerts

* Only install Util headers

* Check for TCLAP alongside other deps

* Only check for sample deps when building them

* Add TCLAP to SDK props

* Build SDK lib only with samples

* Inherit common deps from libSDK

* Modularize Stb detection for non-Vcpkg consumers

* Revamp dependency use

* Install layout overhaul

* Fix CI YAML

* Fix dynamic library dependence in install tree

* Update readme

* Don't test NBody using CTest

* Move image Dockerfiles to OpenCL-SDK

* Remove dead kernel code

* README typo fixes.

* Newline

* Update submodules to point GitHub

* Apply git-format

* CI bump

* Install deps.

* apt update

* Install stb

* Acknolwedge Linux stb install layout

* Fix build path

* Fix vcpkg paths

Co-authored-by: Ivan Siutsou <ivan@streamhpc.com>
  • Loading branch information
MathiasMagnus and Melirius authored Dec 14, 2021
1 parent 625a564 commit 37a3e6e
Show file tree
Hide file tree
Showing 85 changed files with 20,421 additions and 14,205 deletions.
25 changes: 17 additions & 8 deletions .github/workflows/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,25 @@ jobs:
submodules: recursive
- name: Build
run: |
mkdir build
cd build
if [[ "${{ matrix.os }}" == "ubuntu-20.04" ]]; then
sudo apt update
sudo apt install -y libtclap-dev libglm-dev libglew-dev libsfml-dev libstb-dev libidn11 libx11-dev libxrandr-dev libxi-dev mesa-common-dev libgl1-mesa-dev libglu1-mesa-dev libudev-dev
elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then
brew install tclap glm glew sfml mesa-glu
git clone https://github.com/Microsoft/vcpkg.git
./vcpkg/bootstrap-vcpkg.sh
./vcpkg/vcpkg install stb
TOOLCHAIN_ARG="-D CMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake"
fi
if [[ "${{ matrix.compiler }}" == "gcc" ]]; then
CC=gcc
CXX=g++
elif [[ "${{ matrix.compiler }}" == "clang" ]]; then
CC=clang
CXX=clang++
fi
cmake -DCMAKE_C_COMPILER=$CC -DCMAKE_CXX_COMPILER=$CXX ../
make -j2 VERBOSE=1
cmake -D CMAKE_C_COMPILER=$CC -D CMAKE_CXX_COMPILER=$CXX $TOOLCHAIN_ARG -S . -B build
cmake --build ./build --verbose --parallel 2
buildwin:
needs: format
name: Build Windows
Expand All @@ -50,10 +58,11 @@ jobs:
submodules: recursive
- name: Build
run: |
mkdir build
cd build
cmake ../
cmake --build .
git clone https://github.com/Microsoft/vcpkg.git
.\vcpkg\bootstrap-vcpkg.bat
.\vcpkg\vcpkg.exe --triplet=x64-windows install sfml tclap glm glew stb
cmake -D CMAKE_TOOLCHAIN_FILE=.\vcpkg\scripts\buildsystems\vcpkg.cmake -S . -B build
cmake --build ./build -- /verbosity:minimal /maxCpuCount /noLogo
python:
name: Exercise Python examples on ${{matrix.os}}
Expand Down
91 changes: 87 additions & 4 deletions .gitlab/stream-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,37 @@ variables:
image: streamhpc/opencl-sdk-base:ubuntu-18.04-20211119
parallel:
matrix:
# NOTE: Old CMake versions will likely not use cutting-edge compilers
# NOTE 1: Old CMake versions will likely not use cutting-edge compilers
# NOTE 2: To reduce CI time, we test a complete matrix only with the
# oldest supported GCC and LLVM compilers. Rest use defaults
- C_COMPILER: gcc-7
CXX_COMPILER: g++-7
BUILD_SAMPLES: ["ON", "OFF"]
BUILD_OPENGL: "ON"
- C_COMPILER: gcc-7
CXX_COMPILER: g++-7
BUILD_SAMPLES: "ON"
BUILD_OPENGL: "OFF"
- C_COMPILER: gcc-8
CXX_COMPILER: g++-8
BUILD_SAMPLES: "ON"
BUILD_OPENGL: "ON"
- C_COMPILER: clang-8
CXX_COMPILER: clang++-8
BUILD_SAMPLES: ["ON", "OFF"]
BUILD_OPENGL: "ON"
- C_COMPILER: clang-8
CXX_COMPILER: clang++-8
BUILD_SAMPLES: "ON"
BUILD_OPENGL: "OFF"
- C_COMPILER: clang-9
CXX_COMPILER: clang++-9
BUILD_SAMPLES: "ON"
BUILD_OPENGL: "ON"
- C_COMPILER: clang-10
CXX_COMPILER: clang++-10
BUILD_SAMPLES: "ON"
BUILD_OPENGL: "ON"
before_script:
- export PATH=/opt/Kitware/CMake/$CMAKE_MINIMUM/bin:$PATH
- git config --global url."https://gitlab-ci-token:${CI_JOB_TOKEN}@projects.streamhpc.com/".insteadOf "git@projects.streamhpc.com:"
Expand All @@ -46,14 +66,32 @@ variables:
# NOTE: Cutting edge CMake versions will likely not use old compilers
- C_COMPILER: gcc-9
CXX_COMPILER: g++-9
BUILD_SAMPLES: "ON"
BUILD_OPENGL: "ON"
- C_COMPILER: gcc-10
CXX_COMPILER: g++-10
BUILD_SAMPLES: ["ON", "OFF"]
BUILD_OPENGL: "ON"
- C_COMPILER: gcc-10
CXX_COMPILER: g++-10
BUILD_SAMPLES: "ON"
BUILD_OPENGL: "OFF"
- C_COMPILER: clang-11
CXX_COMPILER: clang++-11
BUILD_SAMPLES: "ON"
BUILD_OPENGL: "ON"
- C_COMPILER: clang-12
CXX_COMPILER: clang++-12
BUILD_SAMPLES: "ON"
BUILD_OPENGL: "ON"
- C_COMPILER: clang-13
CXX_COMPILER: clang++-13
BUILD_SAMPLES: ["ON", "OFF"]
BUILD_OPENGL: "ON"
- C_COMPILER: clang-13
CXX_COMPILER: clang++-13
BUILD_SAMPLES: "ON"
BUILD_OPENGL: "OFF"
before_script:
- export PATH=/opt/Kitware/CMake/$CMAKE_LATEST/bin:$PATH
- git config --global url."https://gitlab-ci-token:${CI_JOB_TOKEN}@projects.streamhpc.com/".insteadOf "git@projects.streamhpc.com:"
Expand All @@ -65,14 +103,32 @@ variables:
# NOTE: Old CMake versions will likely not use cutting-edge compilers
- C_COMPILER: gcc-7
CXX_COMPILER: g++-7
BUILD_SAMPLES: ["ON", "OFF"]
BUILD_OPENGL: "ON"
- C_COMPILER: gcc-7
CXX_COMPILER: g++-7
BUILD_SAMPLES: "ON"
BUILD_OPENGL: "OFF"
- C_COMPILER: gcc-8
CXX_COMPILER: g++-8
BUILD_SAMPLES: "ON"
BUILD_OPENGL: "ON"
- C_COMPILER: clang-8
CXX_COMPILER: clang++-8
BUILD_SAMPLES: ["ON", "OFF"]
BUILD_OPENGL: "ON"
- C_COMPILER: clang-8
CXX_COMPILER: clang++-8
BUILD_SAMPLES: "ON"
BUILD_OPENGL: "OFF"
- C_COMPILER: clang-9
CXX_COMPILER: clang++-9
BUILD_SAMPLES: "ON"
BUILD_OPENGL: "ON"
- C_COMPILER: clang-10
CXX_COMPILER: clang++-10
BUILD_SAMPLES: "ON"
BUILD_OPENGL: "ON"
before_script:
- export PATH=/opt/Kitware/CMake/$CMAKE_MINIMUM/bin:$PATH

Expand All @@ -82,14 +138,32 @@ variables:
# NOTE: Cutting edge CMake versions will likely not use old compilers
- C_COMPILER: gcc-9
CXX_COMPILER: g++-9
BUILD_SAMPLES: "ON"
BUILD_OPENGL: "ON"
- C_COMPILER: gcc-10
CXX_COMPILER: g++-10
BUILD_SAMPLES: ["ON", "OFF"]
BUILD_OPENGL: "ON"
- C_COMPILER: gcc-10
CXX_COMPILER: g++-10
BUILD_SAMPLES: "ON"
BUILD_OPENGL: "OFF"
- C_COMPILER: clang-11
CXX_COMPILER: clang++-11
BUILD_SAMPLES: "ON"
BUILD_OPENGL: "ON"
- C_COMPILER: clang-12
CXX_COMPILER: clang++-12
BUILD_SAMPLES: "ON"
BUILD_OPENGL: "ON"
- C_COMPILER: clang-13
CXX_COMPILER: clang++-13
BUILD_SAMPLES: ["ON", "OFF"]
BUILD_OPENGL: "ON"
- C_COMPILER: clang-13
CXX_COMPILER: clang++-13
BUILD_SAMPLES: "ON"
BUILD_OPENGL: "OFF"
before_script:
- export PATH=/opt/Kitware/CMake/$CMAKE_LATEST/bin:$PATH

Expand All @@ -106,6 +180,9 @@ build:cmake-minimum:
# NOTE 2: Lack of space in -H<folder> -B<folder> is important!
# https://stackoverflow.com/a/20611964/1476661
script:
# When not building OpenGL samples, delete OpenGL-related deps from image to make sure we
# don't accidentally include a header that otherwise need not be installed
- if [[ "$BUILD_OPENGL" == "OFF" ]]; then /opt/Microsoft/vcpkg/vcpkg remove sfml glm; fi;
# Clone, configure, build, install OpenCL-SDK
- cmake
-G Ninja
Expand All @@ -119,7 +196,8 @@ build:cmake-minimum:
-D BUILD_DOCS=OFF
-D BUILD_EXAMPLES=OFF
-D BUILD_TESTS=ON
-D OPENCL_SDK_BUILD_SAMPLES=ON
-D OPENCL_SDK_BUILD_SAMPLES=$BUILD_SAMPLES
-D OPENCL_SDK_BUILD_OPENGL_SAMPLES=$BUILD_OPENGL
-D OPENCL_SDK_TEST_SAMPLES=ON
-D CMAKE_INSTALL_PREFIX=$INSTALL_DIR
-B$BUILD_DIR
Expand All @@ -139,6 +217,9 @@ build:cmake-latest:
extends: .toolchain-matrix-latest
stage: build
script:
# When not building OpenGL samples, delete OpenGL-related deps from image to make sure we
# don't accidentally include a header that otherwise need not be installed
- if [[ "$BUILD_OPENGL" == "OFF" ]]; then /opt/Microsoft/vcpkg/vcpkg remove sfml glm; fi;
# Clone, configure, build, install OpenCL-SDK
- cmake
-G "Ninja Multi-Config"
Expand All @@ -151,8 +232,10 @@ build:cmake-latest:
-D BUILD_DOCS=OFF
-D BUILD_EXAMPLES=OFF
-D BUILD_TESTS=ON
-D OPENCL_SDK_BUILD_SAMPLES=ON
-D OPENCL_SDK_TEST_SAMPLES=ONINSTALL_DIR
-D OPENCL_SDK_BUILD_SAMPLES=$BUILD_SAMPLES
-D OPENCL_SDK_BUILD_OPENGL_SAMPLES=$BUILD_OPENGL
-D OPENCL_SDK_TEST_SAMPLES=ON
-D CMAKE_INSTALL_PREFIX=$INSTALL_DIR
-B $BUILD_DIR
-S $CI_PROJECT_DIR
- cmake
Expand Down
10 changes: 10 additions & 0 deletions .gitlab/ubuntu-18.04-rocm.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM streamhpc/opencl-sdk-base:ubuntu-18.04-20211119
RUN set -ex; \
export DEBIAN_FRONTEND=noninteractive ; \
# Register ROCm APT repo
wget --quiet --recursive --no-directories --no-parent "https://repo.radeon.com/amdgpu-install/latest/ubuntu/bionic/" --accept "amdgpu-install-*_all.deb" ; \
apt install -y -qq ./amdgpu-install-*_all.deb libnuma-dev initramfs-tools ; \
apt update -qq; \
rm ./amdgpu-install-*_all.deb ; \
# Install OpenCL package only (and dependency)
amdgpu-install -y --usecase=opencl
45 changes: 45 additions & 0 deletions .gitlab/ubuntu-18.04.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
FROM ubuntu:18.04 AS apt-installs
RUN set -ex; \
export DEBIAN_FRONTEND=noninteractive ; \
apt update -qq; \
# install wget to download repository keys and CMake tarballs
# install software-properties-common for the apt-add-repository command
apt install -y -qq wget software-properties-common ; \
# Canonical hosts recent GCC compilers in ubuntu-toolchain-r/test
apt-add-repository -y ppa:ubuntu-toolchain-r/test ; \
# LLVM hosts most toolchain in separate repos. We only register those absent from ubuntu-toolchain-r/test
wget -q -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - ; \
apt-add-repository -y 'deb [arch=amd64] https://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main' ; \
apt-add-repository -y 'deb [arch=amd64] https://apt.llvm.org/bionic/ llvm-toolchain-bionic-12 main' ; \
apt-add-repository -y 'deb [arch=amd64] https://apt.llvm.org/bionic/ llvm-toolchain-bionic-13 main' ; \
# install ninja, GCC 7-10, LLVM 8-13 and build-essential to get linkers, etc.
# install git to download dependencies
# install ruby to run CMock
# install libidn11 which CMake 3.1.3 only depends on
# install ca-certificates to `git clone` via HTTPS
# install SFML dependencies
# libx11-dev libxrandr-dev libxi-dev
# mesa-common-dev for gl.h
# libgl1-mesa-dev for libGL.so
# libglu1-mesa-dev for glu.h
# libudev-dev
# install Vcpkg dependencies
# curl zip unzip tar
apt install -y -qq build-essential g++-7 g++-8 g++-9 g++-10 clang-8 clang-9 clang-10 clang-11 clang-12 clang-13 ninja-build git ruby libidn11 ca-certificates libx11-dev libxrandr-dev libxi-dev mesa-common-dev libgl1-mesa-dev libglu1-mesa-dev libudev-dev curl zip unzip tar

# install CMake minimum (3.0.2 (Headers, ICD Loader), 3.1.3 (CLHPP), 3.10.3 (SDK)) and latest (3.21.2)
RUN mkdir -p /opt/Kitware/CMake ; \
wget -c https://github.com/Kitware/CMake/releases/download/v3.0.2/cmake-3.0.2-Linux-i386.tar.gz -O - | tar -xz --directory /opt/Kitware/CMake ; \
mv /opt/Kitware/CMake/cmake-3.0.2-Linux-i386 /opt/Kitware/CMake/3.0.2 ; \
wget -c https://github.com/Kitware/CMake/releases/download/v3.1.3/cmake-3.1.3-Linux-x86_64.tar.gz -O - | tar -xz --directory /opt/Kitware/CMake ; \
mv /opt/Kitware/CMake/cmake-3.1.3-Linux-x86_64 /opt/Kitware/CMake/3.1.3 ; \
wget -c https://github.com/Kitware/CMake/releases/download/v3.10.3/cmake-3.10.3-Linux-x86_64.tar.gz -O - | tar -xz --directory /opt/Kitware/CMake ; \
mv /opt/Kitware/CMake/cmake-3.10.3-Linux-x86_64 /opt/Kitware/CMake/3.10.3 ; \
wget -c https://github.com/Kitware/CMake/releases/download/v3.21.2/cmake-3.21.2-linux-x86_64.tar.gz -O - | tar -xz --directory /opt/Kitware/CMake ; \
mv /opt/Kitware/CMake/cmake-3.21.2-linux-x86_64 /opt/Kitware/CMake/3.21.2

# install Vcpkg
RUN git clone --depth 1 https://github.com/Microsoft/vcpkg.git /opt/Microsoft/vcpkg ; \
/opt/Microsoft/vcpkg/bootstrap-vcpkg.sh ; \
# install SFML, TCLAP, GLM
/opt/Microsoft/vcpkg/vcpkg install sfml tclap glm glew
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[submodule "loader"]
path = external/OpenCL-ICD-Loader
url = git@projects.streamhpc.com:Khronos/OpenCL-ICD-Loader.git
url = https://github.com/StreamHPC/OpenCL-ICD-Loader.git
branch = develop_stream
[submodule "headers"]
path = external/OpenCL-Headers
url = git@projects.streamhpc.com:Khronos/OpenCL-Headers.git
url = https://github.com/StreamHPC/OpenCL-Headers.git
branch = develop_stream
[submodule "headers-cpp"]
path = external/OpenCL-CLHPP
url = git@projects.streamhpc.com:Khronos/OpenCL-CLHPP.git
url = https://github.com/StreamHPC/OpenCL-CLHPP.git
branch = develop_stream
53 changes: 27 additions & 26 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,35 +42,36 @@ add_subdirectory(external/OpenCL-Headers)
add_subdirectory(external/OpenCL-ICD-Loader)
add_subdirectory(external/OpenCL-CLHPP)

add_subdirectory(third_party/cargs)
if(OPENCL_SDK_BUILD_OPENGL_SAMPLES)
cmake_minimum_required(VERSION 3.10) # SFML 2 won't find Freetype::Freetype under 3.10
if(OPENCL_SDK_BUILD_SAMPLES)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
add_subdirectory(third_party/cargs)
find_package(TCLAP REQUIRED)
find_package(Stb REQUIRED)
find_package(OpenGL REQUIRED)
if(CMAKE_SYSTEM_NAME MATCHES Linux) # TODO: Add EGL support
# OpenGL doesn't explicitly depend on X11 (as of CMake v3.2) but we'll need it
find_package(X11 REQUIRED)
endif()
find_package(GLEW REQUIRED)
if(NOT TARGET OpenGL::GLU)
# GLU is a dependency of GLEW but it's not advertized as an OpenGL COMPONENT
message(FATAL_ERROR "GLEW depends on GLU but was not found.")
endif()
find_package(SFML 2
REQUIRED
COMPONENTS window graphics
)
endif()
if(OPENCL_SDK_BUILD_OPENGL_SAMPLES)
cmake_minimum_required(VERSION 3.10) # SFML 2 won't find Freetype::Freetype under 3.10
find_package(OpenGL REQUIRED)
if(CMAKE_SYSTEM_NAME MATCHES Linux) # TODO: Add EGL support
# OpenGL doesn't explicitly depend on X11 (as of CMake v3.2) but we'll need it
find_package(X11 REQUIRED)
endif()
find_package(GLEW REQUIRED)
if(NOT TARGET OpenGL::GLU)
# GLU is a dependency of GLEW but it's not advertized as an OpenGL COMPONENT
message(FATAL_ERROR "GLEW depends on GLU but was not found.")
endif()
find_package(SFML 2
REQUIRED
COMPONENTS window graphics
)
find_package(GLEW REQUIRED)
find_package(glm CONFIG REQUIRED)
endif(OPENCL_SDK_BUILD_OPENGL_SAMPLES)
endif(OPENCL_SDK_BUILD_SAMPLES)

add_subdirectory(lib)
add_subdirectory(samples)

include (GNUInstallDirs)
set_target_properties(OpenCL OpenCLUtils OpenCLUtilsCpp
PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}
)
if(OPENCL_SDK_BUILD_SAMPLES)
add_subdirectory(samples)
endif()

include(GNUInstallDirs)
file(
Expand Down
30 changes: 30 additions & 0 deletions cmake/Modules/FindStb.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# - Find Stb
# Find the Stb headers
#
# Stb_INCLUDE_DIR - where to find the TCLAP headers
# Stb_FOUND - True if TCLAP is found

if (Stb_INCLUDE_DIR)
# already in cache, be silent
set (Stb_FIND_QUIETLY TRUE)
endif (Stb_INCLUDE_DIR)

# find the headers
find_path (Stb_INCLUDE_PATH stb_image.h
PATHS
${Stb_DIR}
PATH_SUFFIXES
include
include/stb
)

# handle the QUIETLY and REQUIRED arguments and set Stb_FOUND to
# TRUE if all listed variables are TRUE
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (Stb "Stb (https://github.com/nothings/stb) could not be found. Set Stb_INCLUDE_PATH to point to the headers adding '-D Stb_INCLUDE_PATH=/path/to/stb' to the cmake command." Stb_INCLUDE_PATH)

if (Stb_FOUND)
set (Stb_INCLUDE_DIR ${Stb_INCLUDE_PATH})
endif (Stb_FOUND)

mark_as_advanced(Stb_INCLUDE_PATH)
Loading

0 comments on commit 37a3e6e

Please sign in to comment.