Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial SYCL build system and examples #5081

Merged
merged 15 commits into from
May 22, 2022
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/ubuntu-sycl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Ubuntu SYCL

on:
push:
branches:
- master
pull_request:
types: [opened, reopened, synchronize]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
NPROC: 2
GCE_CLI_GHA_VERSION: "302.0.0"

jobs:
ubuntu-sycl:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
SHARED: [ON, OFF]
ssheorey marked this conversation as resolved.
Show resolved Hide resolved
steps:
- name: Checkout source code
uses: actions/checkout@v2
- name: Maximize build space
run: |
source util/ci_utils.sh
maximize_ubuntu_github_actions_build_space
- name: Docker build
run: |
if [ "${{ matrix.SHARED }}" = "ON" ]; then
docker/docker_build.sh sycl-shared
else
docker/docker_build.sh sycl-static
fi
- name: Docker test
run: |
if [ "${{ matrix.SHARED }}" = "ON" ]; then
docker/docker_test.sh sycl-shared
else
docker/docker_test.sh sycl-static
fi
- name: GCloud CLI setup
if: ${{ github.ref == 'refs/heads/master' }}
uses: google-github-actions/[email protected]
with:
version: ${{ env.GCE_CLI_GHA_VERSION }}
service_account_key: ${{ secrets.GCE_SA_KEY_DOCS_CI }}
project_id: ${{ secrets.GCE_DOCS_PROJECT }}
export_default_credentials: true
- name: Upload ccache to GCS
if: ${{ github.ref == 'refs/heads/master' }}
run: |
gsutil cp ${GITHUB_WORKSPACE}/open3d-ci-sycl.tar.gz gs://open3d-ci-cache/ || true
88 changes: 88 additions & 0 deletions 3rdparty/README_SYCL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Open3D SYCL

Note: this file will be moved to the `docs` folder once SYCL support is mature.

## Concepts

- **OpenCL**: Low-level programming interface for heterogeneous platforms.
- **SYCL**: High-level programming interface for heterogeneous platforms. SYCL
was originally based on OpenCL but now SYCL is an independent standard.
- **DPC++**: Intel's implementation of the SYCL standard.
- **oneAPI**: A collection of open standards, including DPC++, oneMKL, oneTBB, etc.

Open3D's SYCL support runs on DPC++ and requires oneAPI dependencies. For
convenience, in the source code, we use the term "SYCL" although we may be
referring to "DPC++".

## Setup

1. Install oneAPI for Linux: [install via apt-get](https://www.intel.com/content/www/us/en/develop/documentation/installation-guide-for-intel-oneapi-toolkits-linux/top/installation/install-using-package-managers/apt.html)
2. Prepare environment
```bash
# Source environments
source /opt/intel/oneapi/setvars.sh

# We'll be using oneAPI's distribution of conda and Python
# Python 3.6+ will work
conda create -n sycl python=3.8
conda activate sycl
```
3. Check your environment
```bash
which icx # /opt/intel/oneapi/compiler/<version>/linux/bin/icx
which icpx # /opt/intel/oneapi/compiler/<version>/linux/bin/icpx
which python # ${HOME}/.conda/envs/sycl/bin/python
python --version # Python 3.8.12 :: Intel Corporation
```
4. Config and build
```bash
cmake -DBUILD_SYCL_MODULE=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx ..
make -j$(nproc)
```
5. Run demos
We provide several ways to run SYCL demos. This ensures the linking are
correct and all run-time dependencies are satisfied.
```bash
# C++ test
make tests -j$(nproc)
./bin/tests --gtest_filter="*SYCLDemo*"

# C++ example
make SYCLDemo -j$(nproc)
./bin/examples/SYCLDemo

# Python
make install-pip-package -j$(nproc)
pytest ../python/test/core/test_sycl_utils.py -s
```

## Known limitations/requirement

- Limitations (not implemented yet)
- Only supports Linux
- Only supports `BUILD_CUDA_MODULE=OFF`
- ML ops not supported (C++17 cannot be enabled for TF)
- Requirements (required by DPC++)
- Only supports `GLIBCXX_USE_CXX11_ABI=ON`
- Only supports `set(CMAKE_CXX_STANDARD 17)`


## List of oneAPI Python packages

To make `pip install open3d` works out-of-the box on SYCL-enabled platforms,
we can utilize runtime libraries released via PyPI. This feature needs to be
implemented.

User:
- https://pypi.org/user/IntelAutomationEngineering/

Libraries:
- dpcpp-cpp-rt https://pypi.org/project/dpcpp-cpp-rt/#history
- mkl https://pypi.org/project/mkl/#history
- mkl-static https://pypi.org/project/mkl-static/#history
- mkl-include https://pypi.org/project/mkl-include/#history
- mkl-dpcpp https://pypi.org/project/mkl-dpcpp/#history
- mkl-devel-dpcpp https://pypi.org/project/mkl-devel-dpcpp/#history
- ipp https://pypi.org/project/ipp/#history
- ipp-static https://pypi.org/project/ipp-static/#history
- tbb https://pypi.org/project/tbb/#history
11 changes: 10 additions & 1 deletion 3rdparty/assimp/assimp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ else()
set(lib_name assimp)
endif()

# IntelLLVM (SYCL) compiler defaults to fast math, causing NaN comparison code
# compilation error.
if(CMAKE_CXX_COMPILER_ID MATCHES "IntelLLVM")
set(assimp_cmake_cxx_flags "${CMAKE_CXX_FLAGS} -ffp-contract=on -fno-fast-math")
else()
set(assimp_cmake_cxx_flags "${CMAKE_CXX_FLAGS}")
endif()

ExternalProject_Add(
ext_assimp
PREFIX assimp
Expand All @@ -14,6 +22,8 @@ ExternalProject_Add(
DOWNLOAD_DIR "${OPEN3D_THIRD_PARTY_DOWNLOAD_DIR}/assimp"
UPDATE_COMMAND ""
CMAKE_ARGS
${ExternalProject_CMAKE_ARGS_hidden}
-DCMAKE_CXX_FLAGS:STRING=${assimp_cmake_cxx_flags}
-DBUILD_SHARED_LIBS=OFF
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DASSIMP_NO_EXPORT=ON
Expand All @@ -23,7 +33,6 @@ ExternalProject_Add(
-DASSIMP_BUILD_ZLIB=ON
-DHUNTER_ENABLED=OFF # Renamed to "ASSIMP_HUNTER_ENABLED" in newer assimp.
-DCMAKE_DEBUG_POSTFIX=
${ExternalProject_CMAKE_ARGS_hidden}
BUILD_BYPRODUCTS
<INSTALL_DIR>/${Open3D_INSTALL_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}${lib_name}${CMAKE_STATIC_LIBRARY_SUFFIX}
<INSTALL_DIR>/${Open3D_INSTALL_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}IrrXML${CMAKE_STATIC_LIBRARY_SUFFIX}
Expand Down
5 changes: 5 additions & 0 deletions 3rdparty/benchmark/MakeAvailable/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ else()
add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=0)
endif()

# IntelLLVM (SYCL) compiler defaults to fast math, causing NaN comparison
# code compilation error.
add_compile_options($<$<CXX_COMPILER_ID:IntelLLVM>:-ffp-contract=on>)
add_compile_options($<$<CXX_COMPILER_ID:IntelLLVM>:-fno-fast-math>)

yxlao marked this conversation as resolved.
Show resolved Hide resolved
FetchContent_MakeAvailable(ext_benchmark)

# Set the cache vars introduced by the benchmark lib as advanced to not
Expand Down
6 changes: 3 additions & 3 deletions 3rdparty/embree/embree.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,12 @@ endif()
ExternalProject_Add(
ext_embree
PREFIX embree
URL https://github.com/embree/embree/archive/refs/tags/v3.13.0.tar.gz
URL_HASH SHA256=4d86a69508a7e2eb8710d571096ad024b5174834b84454a8020d3a910af46f4f
URL https://github.com/embree/embree/archive/refs/tags/v3.13.3.tar.gz
URL_HASH SHA256=74ec785afb8f14d28ea5e0773544572c8df2e899caccdfc88509f1bfff58716f
DOWNLOAD_DIR "${OPEN3D_THIRD_PARTY_DOWNLOAD_DIR}/embree"
UPDATE_COMMAND ""
CMAKE_ARGS
${ExternalProject_CMAKE_ARGS_hidden}
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
${ISA_ARGS}
-DEMBREE_ISPC_SUPPORT=OFF
Expand All @@ -85,7 +86,6 @@ ExternalProject_Add(
-DEMBREE_GEOMETRY_QUAD=OFF
-DEMBREE_GEOMETRY_SUBDIVISION=OFF
-DEMBREE_TASKING_SYSTEM=INTERNAL
${ExternalProject_CMAKE_ARGS_hidden}
${WIN_CMAKE_ARGS}
BUILD_BYPRODUCTS
<INSTALL_DIR>/${Open3D_INSTALL_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}embree3${CMAKE_STATIC_LIBRARY_SUFFIX}
Expand Down
Loading