Skip to content

Commit

Permalink
Merge commit 'b12b606c35bb7469c1dfdf932e2917238635f02d' into merge-so…
Browse files Browse the repository at this point in the history
…me-main-changes-into-adapters-second-patch
  • Loading branch information
omarahmed1111 committed Nov 1, 2023
2 parents 2417fcf + b12b606 commit ec44de3
Show file tree
Hide file tree
Showing 144 changed files with 7,744 additions and 2,393 deletions.
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"
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,19 @@ 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:
- C++ compiler with C++17 support
- [CMake](https://cmake.org/) >= 3.14.0
- Python v3.6.6 or later

For development and contributions:
- clang-format-15.0 (can be installed with `python -m pip install clang-format==15.0.7`)

### Windows

Generating Visual Studio Project. EXE and binaries will be in **build/bin/{build_config}**
Expand Down Expand Up @@ -151,6 +154,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 Down
2 changes: 2 additions & 0 deletions 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 Down
6 changes: 3 additions & 3 deletions examples/codegen/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ constexpr unsigned PAGE_SIZE = 4096;

void ur_check(const ur_result_t r) {
if (r != UR_RESULT_SUCCESS) {
urTearDown(nullptr);
urLoaderTearDown();
throw std::runtime_error("Unified runtime error: " + std::to_string(r));
}
}
Expand Down Expand Up @@ -95,7 +95,7 @@ template <typename T, size_t N> struct alignas(PAGE_SIZE) AlignedArray {

int main() {
ur_loader_config_handle_t loader_config = nullptr;
ur_check(urInit(UR_DEVICE_INIT_FLAG_GPU, loader_config));
ur_check(urLoaderInit(UR_DEVICE_INIT_FLAG_GPU, loader_config));

auto adapters = get_adapters();
auto supported_adapters = get_supported_adapters(adapters);
Expand Down Expand Up @@ -172,5 +172,5 @@ int main() {
std::cout << "Results are incorrect." << std::endl;
}

return urTearDown(nullptr) == UR_RESULT_SUCCESS && expectedResult ? 0 : 1;
return urLoaderTearDown() == UR_RESULT_SUCCESS && expectedResult ? 0 : 1;
}
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 */
}
9 changes: 5 additions & 4 deletions examples/hello_world/hello_world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
#include "ur_api.h"

//////////////////////////////////////////////////////////////////////////
int main(int argc, char *argv[]) {
int main(int, char *[]) {
ur_result_t status;

// Initialize the platform
status = urInit(0, nullptr);
status = urLoaderInit(0, nullptr);
if (status != UR_RESULT_SUCCESS) {
std::cout << "urInit failed with return code: " << status << std::endl;
std::cout << "urLoaderInit failed with return code: " << status
<< std::endl;
return 1;
}
std::cout << "Platform initialized.\n";
Expand Down Expand Up @@ -119,6 +120,6 @@ int main(int argc, char *argv[]) {
for (auto adapter : adapters) {
urAdapterRelease(adapter);
}
urTearDown(nullptr);
urLoaderTearDown();
return status == UR_RESULT_SUCCESS ? 0 : 1;
}
Loading

0 comments on commit ec44de3

Please sign in to comment.