Skip to content

Commit

Permalink
Merge branch 'main' into new-adapters
Browse files Browse the repository at this point in the history
  • Loading branch information
omarahmed1111 committed Oct 24, 2023
1 parent 614e6d0 commit 3303968
Show file tree
Hide file tree
Showing 170 changed files with 9,729 additions and 2,699 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,13 @@ jobs:
- name: Install prerequisites
run: python3 -m pip install -r third_party/requirements.txt

- name: Install doxygen
run: |
$WorkingDir = $PWD.Path
Invoke-WebRequest -Uri https://github.com/doxygen/doxygen/releases/download/Release_1_9_8/doxygen-1.9.8.windows.x64.bin.zip -OutFile "$WorkingDir\doxygen.zip"
Expand-Archive -Path "$WorkingDir\doxygen.zip"
Add-Content $env:GITHUB_PATH "$WorkingDir\doxygen"
- name: Configure CMake
run: >
cmake
Expand Down
115 changes: 115 additions & 0 deletions .github/workflows/e2e_nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: E2E Nightly

on:
schedule:
# Run every day at 23:00 UTC
- cron: '0 23 * * *'

jobs:
e2e-build-hw:
name: Build SYCL, UR, run E2E
strategy:
matrix:
adapter: [
{name: CUDA}
]
build_type: [Release]
compiler: [{c: clang, cxx: clang++}]

runs-on: ${{matrix.adapter.name}}

steps:
# Workspace on self-hosted runners is not cleaned automatically.
# We have to delete the files created outside of using actions.
- name: Cleanup self-hosted workspace
if: always()
run: |
ls -la ./
rm -rf ./* || true
- name: Checkout UR
uses: actions/checkout@v4
with:
ref: adapters
path: ur-repo

- name: Checkout SYCL
uses: actions/checkout@v4
with:
repository: intel/llvm
ref: sycl
path: sycl-repo

- name: Install pip packages
working-directory: ${{github.workspace}}/ur-repo
run: pip install -r third_party/requirements.txt

- name: Configure CMake UR
working-directory: ${{github.workspace}}/ur-repo
run: >
cmake
-B build
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
-DCMAKE_BUILD_TYPE=${{matrix.build_type}}
-DUR_ENABLE_TRACING=ON
-DUR_DEVELOPER_MODE=ON
-DUR_BUILD_ADAPTER_${{matrix.adapter.name}}=ON
- name: Build UR
run: LD_LIBRARY_PATH=${{github.workspace}}/dpcpp_compiler/lib
cmake --build ${{github.workspace}}/ur-repo/build -j $(nproc)

- name: Set env vars & pre setup
run: |
echo "SYCL_PREFER_UR=1" >> $GITHUB_ENV
echo "CUDA_LIB_PATH=/usr/local/cuda/lib64/stubs" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=/usr/local/cuda/compat/:/usr/local/cuda/lib64:$LD_LIBRARY_PATH" >> $GITHUB_ENV
source /opt/intel/oneapi/setvars.sh
sycl-ls
- name: Configure SYCL
run: >
python3 sycl-repo/buildbot/configure.py
-t ${{matrix.build_type}}
-o ${{github.workspace}}/sycl_build
--cmake-gen "Unix Makefiles"
--ci-defaults --cuda --hip
--cmake-opt="-DLLVM_INSTALL_UTILS=ON"
--cmake-opt="-DSYCL_PI_TESTS=OFF"
--cmake-opt=-DCMAKE_C_COMPILER_LAUNCHER=ccache
--cmake-opt=-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
- name: Build SYCL
run: cmake --build ${{github.workspace}}/sycl_build

- name: Run check-sycl
# Remove after fixing SYCL test :: abi/layout_handler.cpp
# This issue does not affect further execution of e2e with UR.
continue-on-error: true
run: cmake --build ${{github.workspace}}/sycl_build --target check-sycl

- name: Swap UR loader and adapters
run: |
cp ${{github.workspace}}/ur-repo/build/lib/libur_loader.so* ${{github.workspace}}/sycl_build/lib/
cp ${{github.workspace}}/ur-repo/build/lib/libur_adapter_cuda.so* ${{github.workspace}}/sycl_build/lib/
- name: Setup SYCL
run: |
echo "${{github.workspace}}/sycl_build/bin" >> $GITHUB_PATH
echo "LD_LIBRARY_PATH=${{github.workspace}}/sycl_build/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
which clang++ sycl-ls
SYCL_PI_TRACE=-1 sycl-ls
- name: Build e2e tests
run: >
cmake
-GNinja
-B ${{github.workspace}}/build-e2e/
-S ${{github.workspace}}/sycl-repo/sycl/test-e2e/
-DSYCL_TEST_E2E_TARGETS="ext_oneapi_cuda:gpu"
-DCMAKE_CXX_COMPILER="$(which clang++)"
-DLLVM_LIT="${{github.workspace}}/sycl-repo/llvm/utils/lit/lit.py"
- name: Run e2e tests
run: ninja -C build-e2e check-sycl-e2e
53 changes: 53 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Nightly

on:
schedule:
# Run every day at 23:00 UTC
- cron: '0 23 * * *'

jobs:
long-fuzz-test:
name: Run long fuzz tests
strategy:
matrix:
build_type: [Debug, Release]
compiler: [{c: clang, cxx: clang++}]

runs-on: 'ubuntu-22.04'

steps:
- uses: actions/checkout@v3
# with-ref part to be removed after merging 'adapters' branch with 'main'
with:
ref: adapters

- name: Install pip packages
run: pip install -r third_party/requirements.txt

- name: Download DPC++
run: |
wget -O ${{github.workspace}}/dpcpp_compiler.tar.gz https://github.com/intel/llvm/releases/download/nightly-2023-08-31/sycl_linux.tar.gz
mkdir dpcpp_compiler
tar -xvf ${{github.workspace}}/dpcpp_compiler.tar.gz -C dpcpp_compiler
- name: Configure CMake
run: >
cmake
-B${{github.workspace}}/build
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
-DUR_ENABLE_TRACING=ON
-DCMAKE_BUILD_TYPE=${{matrix.build_type}}
-DUR_BUILD_TESTS=ON
-DUR_USE_ASAN=ON
-DUR_USE_UBSAN=ON
-DUR_DPCXX=${{github.workspace}}/dpcpp_compiler/bin/clang++
- name: Build
run: >
LD_LIBRARY_PATH=${{github.workspace}}/dpcpp_compiler/lib
cmake --build ${{github.workspace}}/build -j $(nproc)
- name: Fuzz long test
working-directory: ${{github.workspace}}/build
run: ctest -C ${{matrix.build_type}} --output-on-failure -L "fuzz-long"
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

cmake_minimum_required(VERSION 3.14.0 FATAL_ERROR)
project(unified-runtime VERSION 0.7.0)
project(unified-runtime VERSION 0.8.0)

include(GNUInstallDirs)
include(CheckCXXSourceCompiles)
Expand All @@ -15,7 +15,8 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(helpers)

if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
set(CMAKE_FIND_FRAMEWORK NEVER)
set(Python3_FIND_FRAMEWORK NEVER)
set(Python3_FIND_STRATEGY LOCATION)
endif()

find_package(Python3 COMPONENTS Interpreter REQUIRED)
Expand Down
39 changes: 36 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ see cmake options for details.
- [Contents of the repo](#contents-of-the-repo)
- [Integration](#integration)
- [Weekly tags](#weekly-tags)
- [Third-Party tools](#third-party-tools)
- [Building](#building)
3. [Third-Party tools](#third-party-tools)
4. [Building](#building)
- [Requirements](#requirements)
- [Windows](#windows)
- [Linux](#linux)
Expand All @@ -31,7 +31,7 @@ see cmake options for details.
- [Adapter naming convention](#adapter-naming-convention)
- [Source code generation](#source-code-generation)
- [Documentation](#documentation)

6. [Release Process](#release-process)

## Contents of the repo

Expand Down Expand Up @@ -80,6 +80,12 @@ Tools can be acquired via instructions in [third_party](/third_party/README.md).

## Building

The requirements and instructions below are for building the project from source
without any modifications. To make modifications to the specification, please
see the
[Contribution Guide](https://oneapi-src.github.io/unified-runtime/core/CONTRIB.html)
for more detailed instructions on the correct setup.

### Requirements

Required packages:
Expand Down Expand Up @@ -150,6 +156,10 @@ It will generate the source code **and** run automated code formatting:
$ make generate
```

This target has additional dependencies which are described in the *Build
Environment* section of the
[Contribution Guide](https://oneapi-src.github.io/unified-runtime/core/CONTRIB.html).

## Contributions

For those who intend to make a contribution to the project please read our
Expand All @@ -172,3 +182,26 @@ Code is generated using included [Python scripts](/scripts/README.md).

Documentation is generated from source code using Sphinx -
see [scripts dir](/scripts/README.md) for details.

## Release Process

Unified Runtime releases are aligned with oneAPI releases. Once all changes
planned for a release have been accepted, the release process is defined as:

1. Create a new release branch based on the [main][main-branch] branch taking
the form `v<major>.<minor>.x` where `x` is a placeholder for the patch
version. This branch will always contain the latest patch version for a given
release.
2. Create a PR to increment the CMake project version on the [main][main-branch]
and merge before accepting any other changes.
3. Create a new tag based on the latest commit on the release branch taking the
form `v<major>.<minor>.<patch>`.
4. Create a [new GitHub release][new-github-release] using the tag created in
the previous step.
* Prior to version 1.0, check the *Set as a pre-release* tick box.
5. Update downstream projects to utilize the release tag. If any issues arise
from integration, apply any necessary hot fixes to `v<major>.<minor>.x`
branch and go back to step 3.

[main-branch]: https://github.com/oneapi-src/unified-runtime/tree/main
[new-github-release]: https://github.com/oneapi-src/unified-runtime/releases/new
4 changes: 3 additions & 1 deletion cmake/helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ function(add_ur_target_compile_options name)
-fPIC
-Wall
-Wpedantic
-Wempty-body
-Wunused-parameter
$<$<CXX_COMPILER_ID:GNU>:-fdiagnostics-color=always>
$<$<CXX_COMPILER_ID:Clang,AppleClang>:-fcolor-diagnostics>
)
Expand All @@ -78,7 +80,7 @@ function(add_ur_target_compile_options name)
endif()
elseif(MSVC)
target_compile_options(${name} PRIVATE
/MP
$<$<CXX_COMPILER_ID:MSVC>:/MP> # clang-cl.exe does not support /MP
/W3
/MD$<$<CONFIG:Debug>:d>
/GS
Expand Down
2 changes: 1 addition & 1 deletion examples/collector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $ mkdir build
$ cd build
$ cmake .. -DUR_ENABLE_TRACING=ON
$ make
$ UR_ADAPTERS_FORCE_LOAD=./lib/libur_adapter_null.so XPTI_TRACE_ENABLE=1 XPTI_FRAMEWORK_DISPATCHER=./lib/libxptifw.so XPTI_SUBSCRIBERS=./lib/libcollector.so ./bin/hello_world
$ UR_ADAPTERS_FORCE_LOAD=./lib/libur_adapter_null.so UR_ENABLE_LAYERS=UR_LAYER_TRACING XPTI_TRACE_ENABLE=1 XPTI_FRAMEWORK_DISPATCHER=./lib/libxptifw.so XPTI_SUBSCRIBERS=./lib/libcollector.so ./bin/hello_world
```

See [XPTI framework documentation](https://github.com/intel/llvm/blob/sycl/xptifw/doc/XPTI_Framework.md) for more information.
45 changes: 26 additions & 19 deletions examples/collector/collector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,32 +34,41 @@ constexpr uint16_t TRACE_FN_END =
constexpr std::string_view UR_STREAM_NAME = "ur";

/**
* @brief Formats the function parameters and arguments for urInit
* @brief Formats the function parameters and arguments for urAdapterGet
*/
std::ostream &operator<<(std::ostream &os,
const struct ur_init_params_t *params) {
os << ".device_flags = ";
if (*params->pdevice_flags & UR_DEVICE_INIT_FLAG_GPU) {
os << "UR_DEVICE_INIT_FLAG_GPU";
} else {
os << "0";
const struct ur_adapter_get_params_t *params) {
os << ".NumEntries = ";
os << *params->pNumEntries;
os << ", ";
os << ".phAdapters = ";
os << *params->pphAdapters;
if (*params->pphAdapters) {
os << " (" << **params->pphAdapters << ")";
}
os << ", ";
os << ".pNumAdapters = ";
os << *params->ppNumAdapters;
if (*params->ppNumAdapters) {
os << " (" << **params->ppNumAdapters << ")";
}
os << "";
return os;
}

/**
* A map of functions that format the parameters and arguments for each UR function.
* This example only implements a handler for one function, `urInit`, but it's
* This example only implements a handler for one function, `urAdapterGet`, but it's
* trivial to expand it to support more.
*/
static std::unordered_map<
std::string_view,
std::function<void(const xpti::function_with_args_t *, std::ostream &)>>
handlers = {{"urInit", [](const xpti::function_with_args_t *fn_args,
std::ostream &os) {
auto params = static_cast<const struct ur_init_params_t *>(
fn_args->args_data);
handlers = {{"urAdapterGet", [](const xpti::function_with_args_t *fn_args,
std::ostream &os) {
auto params =
static_cast<const struct ur_adapter_get_params_t *>(
fn_args->args_data);
os << params;
}}};

Expand All @@ -73,10 +82,9 @@ static std::unordered_map<
* On begin, it prints the function declaration with the call arguments specified,
* and on end it prints the function name with the result of the call.
*/
XPTI_CALLBACK_API void trace_cb(uint16_t trace_type,
xpti::trace_event_data_t *parent,
xpti::trace_event_data_t *event,
uint64_t instance, const void *user_data) {
XPTI_CALLBACK_API void trace_cb(uint16_t trace_type, xpti::trace_event_data_t *,
xpti::trace_event_data_t *, uint64_t instance,
const void *user_data) {
auto *args = static_cast<const xpti::function_with_args_t *>(user_data);
std::ostringstream out;
if (trace_type == TRACE_FN_BEGIN) {
Expand Down Expand Up @@ -110,8 +118,7 @@ XPTI_CALLBACK_API void trace_cb(uint16_t trace_type,
* selected trace types.
*/
XPTI_CALLBACK_API void xptiTraceInit(unsigned int major_version,
unsigned int minor_version,
const char *version_str,
unsigned int minor_version, const char *,
const char *stream_name) {
if (stream_name == nullptr) {
std::cout << "Stream name not provided. Aborting." << std::endl;
Expand Down Expand Up @@ -149,5 +156,5 @@ XPTI_CALLBACK_API void xptiTraceInit(unsigned int major_version,
*
* Can be used to cleanup state or resources.
*/
XPTI_CALLBACK_API void xptiTraceFinish(const char *stream_name) { /* noop */
XPTI_CALLBACK_API void xptiTraceFinish(const char *) { /* noop */
}
Loading

0 comments on commit 3303968

Please sign in to comment.