diff --git a/.github/docker/README.md b/.github/docker/README.md new file mode 100644 index 0000000000..782dce372e --- /dev/null +++ b/.github/docker/README.md @@ -0,0 +1,42 @@ +# Content + +Dockerfiles and scripts placed in this directory are intended to be used as +development process vehicles and part of continuous integration process. + +Images built out of those recipes may be used with Docker or podman as +development environment. + +# How to build docker image + +To build docker image on local machine execute: + +```sh +docker build -t ur:ubuntu-22.04 -f ./ubuntu-22.04.Dockerfile . +``` + +To set any build time variable (e.g., an optional ARG from docker recipe), add to the command (after `build`), e.g.: + +```sh + --build-arg SKIP_DPCPP_BUILD=1 +``` + +One other example of using these extra build arguments are proxy settings. They are required for accessing network +(e.g., to download dependencies within docker), if a host is using a proxy server. Example usage: + +```sh + --build-arg https_proxy=http://proxy.com:port --build-arg http_proxy=http://proxy.com:port +``` + +# How to use docker image + +To run docker container (using the previously built image) execute: + +```sh +docker run --shm-size=4G -v /your/workspace/path/:/opt/workspace:z -w /opt/workspace/ -it ur:ubuntu-22.04 /bin/bash +``` + +To set (or override) any docker environment variable, add to the command (after `run`): + +```sh + -e ENV_VARIABLE=VALUE +``` diff --git a/.github/docker/install_dpcpp.sh b/.github/docker/install_dpcpp.sh new file mode 100755 index 0000000000..0aac93eee4 --- /dev/null +++ b/.github/docker/install_dpcpp.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +# Copyright (C) 2023 Intel Corporation +# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +# See LICENSE.TXT +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +# +# install_dpcpp.sh - unpacks DPC++ in ${DPCPP_PATH}, to be used while building UR +# + +set -e + +if [ "${SKIP_DPCPP_BUILD}" ]; then + echo "Variable 'SKIP_DPCPP_BUILD' is set; skipping building DPC++" + exit +fi + +apt-get install -y --no-install-recommends \ + libncurses5 + +mkdir -p ${DPCPP_PATH} +wget -O ${DPCPP_PATH}/dpcpp_compiler.tar.gz https://github.com/intel/llvm/releases/download/sycl-nightly%2F20230626/dpcpp-compiler.tar.gz +tar -xvf ${DPCPP_PATH}/dpcpp_compiler.tar.gz -C ${DPCPP_PATH}/ diff --git a/.github/docker/install_libbacktrace.sh b/.github/docker/install_libbacktrace.sh new file mode 100755 index 0000000000..ae364ddb13 --- /dev/null +++ b/.github/docker/install_libbacktrace.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +# Copyright (C) 2023 Intel Corporation +# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +# See LICENSE.TXT +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +# +# install_libbacktrace.sh - builds and installs tracing library +# + +set -e + +if [ "${SKIP_LIBBACKTRACE_BUILD}" ]; then + echo "Variable 'SKIP_LIBBACKTRACE_BUILD' is set; skipping building libbacktrace" + exit +fi + +git clone https://github.com/ianlancetaylor/libbacktrace.git +pushd libbacktrace +./configure +make -j$(nproc) +make install -j$(nproc) +popd diff --git a/.github/docker/ubuntu-22.04.Dockerfile b/.github/docker/ubuntu-22.04.Dockerfile new file mode 100644 index 0000000000..38161f5b6e --- /dev/null +++ b/.github/docker/ubuntu-22.04.Dockerfile @@ -0,0 +1,70 @@ +# Copyright (C) 2023 Intel Corporation +# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +# See LICENSE.TXT +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +# +# Dockerfile - image with all Unified Runtime dependencies. +# + +# Pull base image +FROM registry.hub.docker.com/library/ubuntu:22.04 + +# Set environment variables +ENV OS ubuntu +ENV OS_VER 22.04 +ENV NOTTY 1 +ENV DEBIAN_FRONTEND noninteractive + +# Additional parameters to build docker without building components. +# These ARGs can be set in docker building phase and are used +# within bash scripts (executed within docker). +ARG SKIP_DPCPP_BUILD +ARG SKIP_LIBBACKTRACE_BUILD + +# Base development packages +ARG BASE_DEPS="\ + build-essential \ + cmake \ + git" + +# Unified Runtime's dependencies +ARG UR_DEPS="\ + doxygen \ + python3 \ + python3-pip" + +# Unified Runtime's dependencies (installed via pip) +ARG UR_PYTHON_DEPS="\ + clang-format==15.0.7" + +# Miscellaneous for our builds/CI (optional) +ARG MISC_DEPS="\ + clang \ + sudo \ + wget \ + whois" + +# Update and install required packages +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + ${BASE_DEPS} \ + ${UR_DEPS} \ + ${MISC_DEPS} \ + && apt-get clean all + +RUN pip3 install ${UR_PYTHON_DEPS} + +# Install DPC++ +COPY install_dpcpp.sh install_dpcpp.sh +ENV DPCPP_PATH=/opt/dpcpp +RUN ./install_dpcpp.sh + +# Install libbacktrace +COPY install_libbacktrace.sh install_libbacktrace.sh +RUN ./install_libbacktrace.sh + +# Add a new (non-root) 'user' +ENV USER user +ENV USERPASS pass +RUN useradd -m $USER -g sudo -p `mkpasswd $USERPASS` diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index e9f4ba2594..306552a110 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -11,6 +11,7 @@ jobs: build_type: [Debug, Release] compiler: [{c: gcc, cxx: g++}] libbacktrace: ['-DVAL_USE_LIBBACKTRACE_BACKTRACE=OFF'] + pool_tracking: ['-DUMF_ENABLE_POOL_TRACKING=ON', '-DUMF_ENABLE_POOL_TRACKING=OFF'] include: - os: 'ubuntu-22.04' build_type: Release @@ -53,9 +54,15 @@ jobs: cd libbacktrace ./configure make - sudo make install + sudo make install cd .. + - name: Download DPC++ + run: | + sudo apt install libncurses5 + wget -O ${{github.workspace}}/dpcpp_compiler.tar.gz https://github.com/intel/llvm/releases/download/sycl-nightly%2F20230626/dpcpp-compiler.tar.gz + tar -xvf ${{github.workspace}}/dpcpp_compiler.tar.gz + - name: Configure CMake run: > cmake @@ -66,7 +73,9 @@ jobs: -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DUR_BUILD_TESTS=ON -DUR_FORMAT_CPP_STYLE=ON + -DUR_DPCXX=${{github.workspace}}/dpcpp_compiler/bin/clang++ ${{matrix.libbacktrace}} + ${{matrix.pool_tracking}} - name: Generate source from spec, check for uncommitted diff if: matrix.os == 'ubuntu-22.04' @@ -77,7 +86,7 @@ jobs: - name: Test working-directory: ${{github.workspace}}/build - run: ctest -C ${{matrix.build_type}} --output-on-failure -L "python|uma|loader|validation|tracing|unit|urtrace" + run: ctest -C ${{matrix.build_type}} --output-on-failure -L "python|umf|loader|validation|tracing|unit|urtrace" adapter-build: name: Build - Adapters on Ubuntu @@ -165,4 +174,35 @@ jobs: - name: Test working-directory: ${{github.workspace}}/build - run: ctest -C ${{matrix.build_type}} --output-on-failure -L "python|uma|loader|validation|tracing|unit|urtrace" + run: ctest -C ${{matrix.build_type}} --output-on-failure -L "python|umf|loader|validation|tracing|unit|urtrace" + + + macos-build: + name: Build - MacOS + strategy: + matrix: + os: ['macos-12', 'macos-13'] + runs-on: ${{matrix.os}} + + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-python@v4 + with: + python-version: 3.9 + + - name: Install prerequisites + run: python3 -m pip install -r third_party/requirements.txt + + - name: Configure CMake + run: > + cmake + -B${{github.workspace}}/build + -DUR_ENABLE_TRACING=ON + -DUR_DEVELOPER_MODE=ON + -DCMAKE_BUILD_TYPE=Release + -DUR_BUILD_TESTS=ON + -DUR_FORMAT_CPP_STYLE=ON + -DUMF_ENABLE_POOL_TRACKING=ON + - name: Build + run: cmake --build ${{github.workspace}}/build -j $(nproc) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 31bf8d2515..701a3be4a2 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -27,7 +27,7 @@ jobs: run: pip install -r third_party/requirements.txt - name: Configure CMake - run: cmake -B ${{github.workspace}}/build -DUR_DEVELOPER_MODE=ON -DUR_BUILD_TESTS=ON -DUR_ENABLE_TRACING=ON -DUR_BUILD_TOOLS=ON + run: cmake -B ${{github.workspace}}/build -DUR_DEVELOPER_MODE=ON -DUR_BUILD_TESTS=ON -DUR_ENABLE_TRACING=ON -DUR_BUILD_TOOLS=ON -DUMF_ENABLE_POOL_TRACKING=ON - name: Build run: cmake --build ${{github.workspace}}/build -j $(nproc) @@ -61,7 +61,7 @@ jobs: run: python3 -m pip install -r third_party/requirements.txt - name: Configure CMake - run: cmake -B ${{github.workspace}}/build -DCMAKE_POLICY_DEFAULT_CMP0094=NEW -DUR_DEVELOPER_MODE=ON -DUR_BUILD_TESTS=ON -DUR_ENABLE_TRACING=ON -DUR_BUILD_TOOLS=ON + run: cmake -B ${{github.workspace}}/build -DCMAKE_POLICY_DEFAULT_CMP0094=NEW -DUR_DEVELOPER_MODE=ON -DUR_BUILD_TESTS=ON -DUR_ENABLE_TRACING=ON -DUR_BUILD_TOOLS=ON -DUMF_ENABLE_POOL_TRACKING=ON - name: Build run: cmake --build ${{github.workspace}}/build -j $(nproc) --config Release diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml index 7d825e92a7..ed6cd31ca9 100644 --- a/.github/workflows/coverity.yml +++ b/.github/workflows/coverity.yml @@ -26,7 +26,7 @@ jobs: linux: name: Coverity runs-on: ubuntu-latest - + steps: - name: Clone the git repo uses: actions/checkout@v3 @@ -35,12 +35,12 @@ jobs: run: | sudo apt-get update sudo apt-get install -y doxygen - + - name: Install pip packages run: pip install -r third_party/requirements.txt - name: Configure CMake - run: cmake -B $WORKDIR/build -DUR_ENABLE_TRACING=ON -DUR_DEVELOPER_MODE=ON -DUR_BUILD_TESTS=ON -DUR_FORMAT_CPP_STYLE=ON + run: cmake -B $WORKDIR/build -DUR_ENABLE_TRACING=ON -DUR_DEVELOPER_MODE=ON -DUR_BUILD_TESTS=ON -DUR_FORMAT_CPP_STYLE=ON -DUMF_ENABLE_POOL_TRACKING=ON - name: Generate source from spec, check for uncommitted diff run: | diff --git a/CMakeLists.txt b/CMakeLists.txt index 42f42642a8..9971d3f40d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,10 @@ include(CTest) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") include(helpers) +if(CMAKE_SYSTEM_NAME STREQUAL Darwin) + set(CMAKE_FIND_FRAMEWORK NEVER) +endif() + find_package(Python3 COMPONENTS Interpreter) set(CMAKE_CXX_STANDARD 17) @@ -26,10 +30,12 @@ option(UR_FORMAT_CPP_STYLE "format code style of C++ sources" OFF) option(UR_USE_ASAN "enable AddressSanitizer" OFF) option(UR_USE_UBSAN "enable UndefinedBehaviorSanitizer" OFF) option(UR_USE_MSAN "enable MemorySanitizer" OFF) -option(UMA_BUILD_SHARED_LIBRARY "Build UMA as shared library" OFF) +option(UR_USE_TSAN "enable ThreadSanitizer" OFF) +option(UMF_BUILD_SHARED_LIBRARY "Build UMF as shared library" OFF) option(UR_ENABLE_TRACING "enable api tracing through xpti" OFF) option(VAL_USE_LIBBACKTRACE_BACKTRACE "enable libbacktrace validation backtrace for linux" OFF) option(UR_BUILD_TOOLS "build ur tools" ON) +option(UMF_ENABLE_POOL_TRACKING "Build UMF with pool tracking" OFF) option(UR_BUILD_ADAPTER_L0 "build level 0 adapter from SYCL" OFF) option(UR_BUILD_ADAPTER_CUDA "build cuda adapter from SYCL" OFF) option(UR_BUILD_ADAPTER_HIP "build hip adapter from SYCL" OFF) @@ -51,14 +57,7 @@ if(MSVC) set(CUSTOM_COMMAND_BINARY_DIR ${CUSTOM_COMMAND_BINARY_DIR}/$) endif() -# CXX flags setup if(NOT MSVC) - add_compile_options(-fPIC -Wall -Wpedantic - $<$:-fdiagnostics-color=always> - $<$:-fcolor-diagnostics>) - if(UR_DEVELOPER_MODE) - add_compile_options(-Werror -fno-omit-frame-pointer) - endif() # Determine if libstdc++ is being used. check_cxx_source_compiles(" #include @@ -74,21 +73,13 @@ if(NOT MSVC) # is available we still need to link this library. link_libraries(stdc++fs) endif() -elseif(MSVC) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") - add_compile_options(/MP /W3 /MD$<$:d>) - - if(UR_DEVELOPER_MODE) - add_compile_options(/WX) - endif() endif() if(UR_ENABLE_TRACING) add_compile_definitions(UR_ENABLE_TRACING) # fetch xpti proxy library for the tracing layer - FetchContentSparse_Declare(xpti https://github.com/intel/llvm.git "sycl-nightly/20230304" "xpti") + FetchContentSparse_Declare(xpti https://github.com/intel/llvm.git "sycl-nightly/20230703" "xpti") FetchContent_MakeAvailable(xpti) # set -fPIC for xpti since we are linking it with a shared library @@ -100,7 +91,7 @@ if(UR_ENABLE_TRACING) set(XPTI_DIR ${xpti_SOURCE_DIR}) set(XPTI_ENABLE_TESTS OFF CACHE INTERNAL "Turn off xptifw tests") - FetchContentSparse_Declare(xptifw https://github.com/intel/llvm.git "sycl-nightly/20230304" "xptifw") + FetchContentSparse_Declare(xptifw https://github.com/intel/llvm.git "sycl-nightly/20230703" "xptifw") FetchContent_MakeAvailable(xptifw) @@ -130,6 +121,10 @@ if(UR_USE_UBSAN) add_sanitizer_flag(undefined) endif() +if(UR_USE_TSAN) + add_sanitizer_flag(thread) +endif() + if(UR_USE_MSAN) message(WARNING "MemorySanitizer requires that all code is built with its instrumentation, otherwise false positives are possible. diff --git a/README.md b/README.md index a9a1e0cabb..3ef600f341 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,38 @@ # Unified Runtime -[![GHA build status](https://github.com/oneapi-src/unified-runtime/actions/workflows/cmake.yml/badge.svg?branch=main)](https://github.com/oneapi-src/unified-runtime/actions) +[![Build and test](https://github.com/oneapi-src/unified-runtime/actions/workflows/cmake.yml/badge.svg)](https://github.com/oneapi-src/unified-runtime/actions/workflows/cmake.yml) +[![CodeQL](https://github.com/oneapi-src/unified-runtime/actions/workflows/codeql.yml/badge.svg)](https://github.com/oneapi-src/unified-runtime/actions/workflows/codeql.yml) +[![Bandit](https://github.com/oneapi-src/unified-runtime/actions/workflows/bandit.yml/badge.svg)](https://github.com/oneapi-src/unified-runtime/actions/workflows/bandit.yml) +[![Coverity](https://scan.coverity.com/projects/28213/badge.svg)](https://scan.coverity.com/projects/oneapi-src-unified-runtime) ## Adapters Adapter implementations for Unified Runtime currently reside in the [SYCL repository](https://github.com/intel/llvm/tree/sycl/sycl/plugins/unified_runtime/ur). This branch contains scripts to automatically fetch and build them directly in the UR tree. The adapters are disabled by default, see cmake options for details. -> **Note** -> -> For those who intend to make a contribution to the project please read our -> [Contribution Guide](https://oneapi-src.github.io/unified-runtime/core/CONTRIB.html) -> for more information. + -## Contents +## Table of contents + +- [Unified Runtime](#unified-runtime) + - [Adapters](#adapters) + - [Table of contents](#table-of-contents) + - [Contents of the repo](#contents-of-the-repo) + - [Integration](#integration) + - [Weekly tags](#weekly-tags) + - [Third-Party tools](#third-party-tools) + - [Building](#building) + - [Windows](#windows) + - [Linux](#linux) + - [CMake standard options](#cmake-standard-options) + - [Additional make targets](#additional-make-targets) + - [Contributions](#contributions) + - [Adapter naming convention](#adapter-naming-convention) + - [Source code generation](#source-code-generation) + - [Documentation](#documentation) + + +## Contents of the repo This repo contains the following: @@ -46,7 +65,7 @@ add_executable(example example.cpp) target_link_libraries(example PUBLIC unified-runtime::headers) ``` -### Weekly Tags +### Weekly tags Each Friday at 23:00 UTC time a [prerelease tag](https://github.com/oneapi-src/unified-runtime/releases) is created which @@ -54,15 +73,7 @@ takes the form `weekly-YYYY-MM-DD`. These tags should be used by downstream projects which intend to track development closely but maintain a fixed point in history to avoid pulling potentially breaking changes from the `main` branch. -## Source Code Generation - -Code is generated using included [Python scripts](/scripts/README.md). - -## Documentation - -Documentation is generated from source code using Sphinx. - -## Third-Party Tools +## Third-Party tools Tools can be acquired via instructions in [third_party](/third_party/README.md). @@ -70,31 +81,29 @@ Tools can be acquired via instructions in [third_party](/third_party/README.md). Requirements: - C++ compiler with C++17 support -- cmake >= 3.14.0 +- [CMake](https://cmake.org/) >= 3.14.0 - clang-format-15.0 (can be installed with `python -m pip install clang-format==15.0.7`) -Project is defined using [CMake](https://cmake.org/). - -**Windows**: +### Windows -Generating Visual Studio Project. EXE and binaries will be in **build/bin/{build_config}** +Generating Visual Studio Project. EXE and binaries will be in **build/bin/{build_config}** -~~~~ +```bash $ mkdir build $ cd build $ cmake {path_to_source_dir} -G "Visual Studio 15 2017 Win64" -~~~~ +``` -**Linux**: +### Linux Executable and binaries will be in **build/bin** -~~~~ +```bash $ mkdir build $ cd build $ cmake {path_to_source_dir} $ make -~~~~ +``` ### CMake standard options @@ -103,36 +112,41 @@ List of options provided by CMake: | Name | Description | Values | Default | | - | - | - | - | | UR_BUILD_TESTS | Build the tests | ON/OFF | ON | +| UR_BUILD_TOOLS | Build tools | ON/OFF | ON | | UR_FORMAT_CPP_STYLE | Format code style | ON/OFF | OFF | | UR_DEVELOPER_MODE | Treat warnings as errors and enables additional checks | ON/OFF | OFF | | UR_USE_ASAN | Enable AddressSanitizer | ON/OFF | OFF | +| UR_USE_TSAN | Enable ThreadSanitizer | ON/OFF | OFF | | UR_USE_UBSAN | Enable UndefinedBehavior Sanitizer | ON/OFF | OFF | | UR_USE_MSAN | Enable MemorySanitizer (clang only) | ON/OFF | OFF | | UR_ENABLE_TRACING | Enable XPTI-based tracing layer | ON/OFF | OFF | -| UR_BUILD_TOOLS | Build tools | ON/OFF | ON | | UR_BUILD_ADAPTER_L0 | Fetch and use level-zero adapter from SYCL | ON/OFF | OFF | | UR_BUILD_ADAPTER_CUDA | Fetch and use cuda adapter from SYCL | ON/OFF | OFF | | UR_BUILD_ADAPTER_HIP | Fetch and use hip adapter from SYCL | ON/OFF | OFF | | UR_HIP_PLATFORM | Build hip adapter for AMD or NVIDIA platform | AMD/NVIDIA | AMD | -**General**: +### Additional make targets + +To run automated code formatting, configure CMake with `UR_FORMAT_CPP_STYLE` option +and then run a custom `cppformat` target: -To run automated code formatting build with option `UR_FORMAT_CPP_STYLE` and then run a custom `cppformat` target: -~~~~ +```bash $ make cppformat -~~~~ +``` -If you've made modifications to the specification, you can also run a custom `generate-code` or `generate` target prior to building. -This call will generate the source code: -~~~~ -$ make generate-code -~~~~ +If you've made modifications to the specification, you can also run +a custom `generate` target prior to building. +It will generate the source code **and** run automated code formatting: -This call will generate the source code and run automated code formatting: -~~~~ +```bash $ make generate -~~~~ -Note: `generate` target requires `UR_FORMAT_CPP_STYLE` to bet set. +``` + +## Contributions + +For those who intend to make a contribution to the project please read our +[Contribution Guide](https://oneapi-src.github.io/unified-runtime/core/CONTRIB.html) +for more information. ### Adapter naming convention @@ -141,3 +155,12 @@ to use the following naming convention: * On Linux platforms, use `libur_adapter_[name].so`. * On Windows platforms, use `ur_adapter_[name].dll`. + +### Source code generation + +Code is generated using included [Python scripts](/scripts/README.md). + +### Documentation + +Documentation is generated from source code using Sphinx - +see [scripts dir](/scripts/README.md) for details. diff --git a/REQUIREMENTS.md b/REQUIREMENTS.md index f9014ec79a..0dcacc9948 100644 --- a/REQUIREMENTS.md +++ b/REQUIREMENTS.md @@ -28,9 +28,9 @@ ### Library Language Binding Requirements * DPC++ Language binding requirements - + Performance Libraries that execute on multiple Intel IP’s shall support the DPCP++ language binding as the primary mechanism for programing on multiple Intel Hardware IP’s + + Performance Libraries that execute on multiple Intel IP’s shall support the DPCP++ language binding as the primary mechanism for programming on multiple Intel Hardware IP’s + If the library supports DPC++ for a only a subset of functions for offload to an accelerator (e.g. ATS), all CPU functions should all support DPC++ Language bindings so that application developers can write their entire application in DPC++ - + If a Library only supports only the CPU, but is likey to be used with another library the supports DPC++ on CPU and ATS, the library shall also support DPC++ + + If a Library only supports only the CPU, but is likely to be used with another library the supports DPC++ on CPU and ATS, the library shall also support DPC++ * Libraries may support other language bindings (C/C++/FORTRAN/JAVA/PYTHON, etc.) to support existing user base and use cases required by the developer domain ### Library API Deprecation Management diff --git a/ci/pyenv.cmd b/ci/pyenv.cmd index 2540657150..a90a33509f 100644 --- a/ci/pyenv.cmd +++ b/ci/pyenv.cmd @@ -112,7 +112,7 @@ goto :eof ::=============================================================== :: Deletes existing python virtual env. :reset_python -echo Reseting python... +echo Resetting python... set VDIR_ACTIVE= if exist "%VDIR%" ( call "%VDIR%\Scripts\deactivate.bat" diff --git a/cmake/helpers.cmake b/cmake/helpers.cmake index 0892fecdb4..cd3497fc0e 100644 --- a/cmake/helpers.cmake +++ b/cmake/helpers.cmake @@ -57,6 +57,56 @@ macro(add_sanitizer_flag flag) set(CMAKE_REQUIRED_LIBRARIES ${SAVED_CMAKE_REQUIRED_LIBRARIES}) endmacro() +function(add_ur_target_compile_options name) + if(NOT MSVC) + target_compile_options(${name} PRIVATE + -fPIC + -Wall + -Wpedantic + $<$:-fdiagnostics-color=always> + $<$:-fcolor-diagnostics> + ) + + if (CMAKE_BUILD_TYPE STREQUAL "Release") + target_compile_definitions(${name} PRIVATE -D_FORTIFY_SOURCE=2) + endif() + if(UR_DEVELOPER_MODE) + target_compile_options(${name} PRIVATE + -Werror + -fno-omit-frame-pointer + -fstack-protector-strong + ) + endif() + elseif(MSVC) + target_compile_options(${name} PRIVATE + /MP + /W3 + /MD$<$:d> + /GS + ) + add_link_options( + /DYNAMICBASE + /HIGHENTROPYVA + /ALLOWISOLATION + /NXCOMPAT + ) + + if(UR_DEVELOPER_MODE) + target_compile_options(${name} PRIVATE /WX /GS) + endif() + endif() +endfunction() + +function(add_ur_executable name) + add_executable(${name} ${ARGN}) + add_ur_target_compile_options(${name}) +endfunction() + +function(add_ur_library name) + add_library(${name} ${ARGN}) + add_ur_target_compile_options(${name}) +endfunction() + include(FetchContent) function(FetchSource GIT_REPOSITORY GIT_TAG GIT_DIR DEST) diff --git a/examples/collector/CMakeLists.txt b/examples/collector/CMakeLists.txt index e9ce42c14e..5fe484d0b8 100644 --- a/examples/collector/CMakeLists.txt +++ b/examples/collector/CMakeLists.txt @@ -5,7 +5,7 @@ set(TARGET_NAME collector) -add_library(${TARGET_NAME} SHARED +add_ur_library(${TARGET_NAME} SHARED ${CMAKE_CURRENT_SOURCE_DIR}/collector.cpp ) diff --git a/examples/hello_world/CMakeLists.txt b/examples/hello_world/CMakeLists.txt index b1723ae605..8fd9bda19d 100644 --- a/examples/hello_world/CMakeLists.txt +++ b/examples/hello_world/CMakeLists.txt @@ -5,14 +5,10 @@ set(TARGET_NAME hello_world) -add_executable(${TARGET_NAME} +add_ur_executable(${TARGET_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/hello_world.cpp ) -target_include_directories(${TARGET_NAME} PRIVATE - ${CMAKE_SOURCE_DIR}/include -) - if(MSVC) set_target_properties(${TARGET_NAME} PROPERTIES @@ -24,4 +20,5 @@ endif() target_link_libraries(${TARGET_NAME} PRIVATE ${PROJECT_NAME}::loader ${CMAKE_DL_LIBS} + ${PROJECT_NAME}::headers ) diff --git a/examples/hello_world/hello_world.cpp b/examples/hello_world/hello_world.cpp index 454aeea540..4d903da65a 100644 --- a/examples/hello_world/hello_world.cpp +++ b/examples/hello_world/hello_world.cpp @@ -19,17 +19,34 @@ int main(int argc, char *argv[]) { ur_result_t status; // Initialize the platform - status = urInit(0); + status = urInit(0, nullptr); if (status != UR_RESULT_SUCCESS) { std::cout << "urInit failed with return code: " << status << std::endl; return 1; } std::cout << "Platform initialized.\n"; + uint32_t adapterCount = 0; + std::vector adapters; uint32_t platformCount = 0; std::vector platforms; - status = urPlatformGet(1, nullptr, &platformCount); + status = urAdapterGet(0, nullptr, &adapterCount); + if (status != UR_RESULT_SUCCESS) { + std::cout << "urAdapterGet failed with return code: " << status + << std::endl; + return 1; + } + adapters.resize(adapterCount); + status = urAdapterGet(adapterCount, adapters.data(), nullptr); + if (status != UR_RESULT_SUCCESS) { + std::cout << "urAdapterGet failed with return code: " << status + << std::endl; + return 1; + } + + status = urPlatformGet(adapters.data(), adapterCount, 1, nullptr, + &platformCount); if (status != UR_RESULT_SUCCESS) { std::cout << "urPlatformGet failed with return code: " << status << std::endl; @@ -37,7 +54,8 @@ int main(int argc, char *argv[]) { } platforms.resize(platformCount); - status = urPlatformGet(platformCount, platforms.data(), nullptr); + status = urPlatformGet(adapters.data(), adapterCount, platformCount, + platforms.data(), nullptr); if (status != UR_RESULT_SUCCESS) { std::cout << "urPlatformGet failed with return code: " << status << std::endl; @@ -98,6 +116,9 @@ int main(int argc, char *argv[]) { } out: + for (auto adapter : adapters) { + urAdapterRelease(adapter); + } urTearDown(nullptr); return status == UR_RESULT_SUCCESS ? 0 : 1; } diff --git a/include/ur.py b/include/ur.py index f70649998b..f48acbd21b 100644 --- a/include/ur.py +++ b/include/ur.py @@ -19,6 +19,238 @@ ############################################################################### __version__ = "1.0" +############################################################################### +## @brief Defines unique stable identifiers for all functions +class ur_function_v(IntEnum): + CONTEXT_CREATE = 1 ## Enumerator for ::urContextCreate + CONTEXT_RETAIN = 2 ## Enumerator for ::urContextRetain + CONTEXT_RELEASE = 3 ## Enumerator for ::urContextRelease + CONTEXT_GET_INFO = 4 ## Enumerator for ::urContextGetInfo + CONTEXT_GET_NATIVE_HANDLE = 5 ## Enumerator for ::urContextGetNativeHandle + CONTEXT_CREATE_WITH_NATIVE_HANDLE = 6 ## Enumerator for ::urContextCreateWithNativeHandle + CONTEXT_SET_EXTENDED_DELETER = 7 ## Enumerator for ::urContextSetExtendedDeleter + DEVICE_GET = 8 ## Enumerator for ::urDeviceGet + DEVICE_GET_INFO = 9 ## Enumerator for ::urDeviceGetInfo + DEVICE_RETAIN = 10 ## Enumerator for ::urDeviceRetain + DEVICE_RELEASE = 11 ## Enumerator for ::urDeviceRelease + DEVICE_PARTITION = 12 ## Enumerator for ::urDevicePartition + DEVICE_SELECT_BINARY = 13 ## Enumerator for ::urDeviceSelectBinary + DEVICE_GET_NATIVE_HANDLE = 14 ## Enumerator for ::urDeviceGetNativeHandle + DEVICE_CREATE_WITH_NATIVE_HANDLE = 15 ## Enumerator for ::urDeviceCreateWithNativeHandle + DEVICE_GET_GLOBAL_TIMESTAMPS = 16 ## Enumerator for ::urDeviceGetGlobalTimestamps + ENQUEUE_KERNEL_LAUNCH = 17 ## Enumerator for ::urEnqueueKernelLaunch + ENQUEUE_EVENTS_WAIT = 18 ## Enumerator for ::urEnqueueEventsWait + ENQUEUE_EVENTS_WAIT_WITH_BARRIER = 19 ## Enumerator for ::urEnqueueEventsWaitWithBarrier + ENQUEUE_MEM_BUFFER_READ = 20 ## Enumerator for ::urEnqueueMemBufferRead + ENQUEUE_MEM_BUFFER_WRITE = 21 ## Enumerator for ::urEnqueueMemBufferWrite + ENQUEUE_MEM_BUFFER_READ_RECT = 22 ## Enumerator for ::urEnqueueMemBufferReadRect + ENQUEUE_MEM_BUFFER_WRITE_RECT = 23 ## Enumerator for ::urEnqueueMemBufferWriteRect + ENQUEUE_MEM_BUFFER_COPY = 24 ## Enumerator for ::urEnqueueMemBufferCopy + ENQUEUE_MEM_BUFFER_COPY_RECT = 25 ## Enumerator for ::urEnqueueMemBufferCopyRect + ENQUEUE_MEM_BUFFER_FILL = 26 ## Enumerator for ::urEnqueueMemBufferFill + ENQUEUE_MEM_IMAGE_READ = 27 ## Enumerator for ::urEnqueueMemImageRead + ENQUEUE_MEM_IMAGE_WRITE = 28 ## Enumerator for ::urEnqueueMemImageWrite + ENQUEUE_MEM_IMAGE_COPY = 29 ## Enumerator for ::urEnqueueMemImageCopy + ENQUEUE_MEM_BUFFER_MAP = 30 ## Enumerator for ::urEnqueueMemBufferMap + ENQUEUE_MEM_UNMAP = 31 ## Enumerator for ::urEnqueueMemUnmap + ENQUEUE_USM_FILL = 32 ## Enumerator for ::urEnqueueUSMFill + ENQUEUE_USM_MEMCPY = 33 ## Enumerator for ::urEnqueueUSMMemcpy + ENQUEUE_USM_PREFETCH = 34 ## Enumerator for ::urEnqueueUSMPrefetch + ENQUEUE_USM_ADVISE = 35 ## Enumerator for ::urEnqueueUSMAdvise + ENQUEUE_DEVICE_GLOBAL_VARIABLE_WRITE = 38 ## Enumerator for ::urEnqueueDeviceGlobalVariableWrite + ENQUEUE_DEVICE_GLOBAL_VARIABLE_READ = 39 ## Enumerator for ::urEnqueueDeviceGlobalVariableRead + EVENT_GET_INFO = 40 ## Enumerator for ::urEventGetInfo + EVENT_GET_PROFILING_INFO = 41 ## Enumerator for ::urEventGetProfilingInfo + EVENT_WAIT = 42 ## Enumerator for ::urEventWait + EVENT_RETAIN = 43 ## Enumerator for ::urEventRetain + EVENT_RELEASE = 44 ## Enumerator for ::urEventRelease + EVENT_GET_NATIVE_HANDLE = 45 ## Enumerator for ::urEventGetNativeHandle + EVENT_CREATE_WITH_NATIVE_HANDLE = 46 ## Enumerator for ::urEventCreateWithNativeHandle + EVENT_SET_CALLBACK = 47 ## Enumerator for ::urEventSetCallback + KERNEL_CREATE = 48 ## Enumerator for ::urKernelCreate + KERNEL_SET_ARG_VALUE = 49 ## Enumerator for ::urKernelSetArgValue + KERNEL_SET_ARG_LOCAL = 50 ## Enumerator for ::urKernelSetArgLocal + KERNEL_GET_INFO = 51 ## Enumerator for ::urKernelGetInfo + KERNEL_GET_GROUP_INFO = 52 ## Enumerator for ::urKernelGetGroupInfo + KERNEL_GET_SUB_GROUP_INFO = 53 ## Enumerator for ::urKernelGetSubGroupInfo + KERNEL_RETAIN = 54 ## Enumerator for ::urKernelRetain + KERNEL_RELEASE = 55 ## Enumerator for ::urKernelRelease + KERNEL_SET_ARG_POINTER = 56 ## Enumerator for ::urKernelSetArgPointer + KERNEL_SET_EXEC_INFO = 57 ## Enumerator for ::urKernelSetExecInfo + KERNEL_SET_ARG_SAMPLER = 58 ## Enumerator for ::urKernelSetArgSampler + KERNEL_SET_ARG_MEM_OBJ = 59 ## Enumerator for ::urKernelSetArgMemObj + KERNEL_SET_SPECIALIZATION_CONSTANTS = 60 ## Enumerator for ::urKernelSetSpecializationConstants + KERNEL_GET_NATIVE_HANDLE = 61 ## Enumerator for ::urKernelGetNativeHandle + KERNEL_CREATE_WITH_NATIVE_HANDLE = 62 ## Enumerator for ::urKernelCreateWithNativeHandle + MEM_IMAGE_CREATE = 63 ## Enumerator for ::urMemImageCreate + MEM_BUFFER_CREATE = 64 ## Enumerator for ::urMemBufferCreate + MEM_RETAIN = 65 ## Enumerator for ::urMemRetain + MEM_RELEASE = 66 ## Enumerator for ::urMemRelease + MEM_BUFFER_PARTITION = 67 ## Enumerator for ::urMemBufferPartition + MEM_GET_NATIVE_HANDLE = 68 ## Enumerator for ::urMemGetNativeHandle + ENQUEUE_READ_HOST_PIPE = 69 ## Enumerator for ::urEnqueueReadHostPipe + MEM_GET_INFO = 70 ## Enumerator for ::urMemGetInfo + MEM_IMAGE_GET_INFO = 71 ## Enumerator for ::urMemImageGetInfo + PLATFORM_GET = 72 ## Enumerator for ::urPlatformGet + PLATFORM_GET_INFO = 73 ## Enumerator for ::urPlatformGetInfo + PLATFORM_GET_API_VERSION = 74 ## Enumerator for ::urPlatformGetApiVersion + PLATFORM_GET_NATIVE_HANDLE = 75 ## Enumerator for ::urPlatformGetNativeHandle + PLATFORM_CREATE_WITH_NATIVE_HANDLE = 76 ## Enumerator for ::urPlatformCreateWithNativeHandle + PROGRAM_CREATE_WITH_IL = 78 ## Enumerator for ::urProgramCreateWithIL + PROGRAM_CREATE_WITH_BINARY = 79 ## Enumerator for ::urProgramCreateWithBinary + PROGRAM_BUILD = 80 ## Enumerator for ::urProgramBuild + PROGRAM_COMPILE = 81 ## Enumerator for ::urProgramCompile + PROGRAM_LINK = 82 ## Enumerator for ::urProgramLink + PROGRAM_RETAIN = 83 ## Enumerator for ::urProgramRetain + PROGRAM_RELEASE = 84 ## Enumerator for ::urProgramRelease + PROGRAM_GET_FUNCTION_POINTER = 85 ## Enumerator for ::urProgramGetFunctionPointer + PROGRAM_GET_INFO = 86 ## Enumerator for ::urProgramGetInfo + PROGRAM_GET_BUILD_INFO = 87 ## Enumerator for ::urProgramGetBuildInfo + PROGRAM_SET_SPECIALIZATION_CONSTANTS = 88 ## Enumerator for ::urProgramSetSpecializationConstants + PROGRAM_GET_NATIVE_HANDLE = 89 ## Enumerator for ::urProgramGetNativeHandle + PROGRAM_CREATE_WITH_NATIVE_HANDLE = 90 ## Enumerator for ::urProgramCreateWithNativeHandle + QUEUE_GET_INFO = 91 ## Enumerator for ::urQueueGetInfo + QUEUE_CREATE = 92 ## Enumerator for ::urQueueCreate + QUEUE_RETAIN = 93 ## Enumerator for ::urQueueRetain + QUEUE_RELEASE = 94 ## Enumerator for ::urQueueRelease + QUEUE_GET_NATIVE_HANDLE = 95 ## Enumerator for ::urQueueGetNativeHandle + QUEUE_CREATE_WITH_NATIVE_HANDLE = 96 ## Enumerator for ::urQueueCreateWithNativeHandle + QUEUE_FINISH = 97 ## Enumerator for ::urQueueFinish + QUEUE_FLUSH = 98 ## Enumerator for ::urQueueFlush + INIT = 99 ## Enumerator for ::urInit + TEAR_DOWN = 100 ## Enumerator for ::urTearDown + SAMPLER_CREATE = 101 ## Enumerator for ::urSamplerCreate + SAMPLER_RETAIN = 102 ## Enumerator for ::urSamplerRetain + SAMPLER_RELEASE = 103 ## Enumerator for ::urSamplerRelease + SAMPLER_GET_INFO = 104 ## Enumerator for ::urSamplerGetInfo + SAMPLER_GET_NATIVE_HANDLE = 105 ## Enumerator for ::urSamplerGetNativeHandle + SAMPLER_CREATE_WITH_NATIVE_HANDLE = 106 ## Enumerator for ::urSamplerCreateWithNativeHandle + USM_HOST_ALLOC = 107 ## Enumerator for ::urUSMHostAlloc + USM_DEVICE_ALLOC = 108 ## Enumerator for ::urUSMDeviceAlloc + USM_SHARED_ALLOC = 109 ## Enumerator for ::urUSMSharedAlloc + USM_FREE = 110 ## Enumerator for ::urUSMFree + USM_GET_MEM_ALLOC_INFO = 111 ## Enumerator for ::urUSMGetMemAllocInfo + USM_POOL_CREATE = 112 ## Enumerator for ::urUSMPoolCreate + COMMAND_BUFFER_CREATE_EXP = 113 ## Enumerator for ::urCommandBufferCreateExp + PLATFORM_GET_BACKEND_OPTION = 114 ## Enumerator for ::urPlatformGetBackendOption + MEM_BUFFER_CREATE_WITH_NATIVE_HANDLE = 115 ## Enumerator for ::urMemBufferCreateWithNativeHandle + MEM_IMAGE_CREATE_WITH_NATIVE_HANDLE = 116 ## Enumerator for ::urMemImageCreateWithNativeHandle + ENQUEUE_WRITE_HOST_PIPE = 117 ## Enumerator for ::urEnqueueWriteHostPipe + USM_POOL_RETAIN = 118 ## Enumerator for ::urUSMPoolRetain + USM_POOL_RELEASE = 119 ## Enumerator for ::urUSMPoolRelease + USM_POOL_GET_INFO = 120 ## Enumerator for ::urUSMPoolGetInfo + COMMAND_BUFFER_RETAIN_EXP = 121 ## Enumerator for ::urCommandBufferRetainExp + COMMAND_BUFFER_RELEASE_EXP = 122 ## Enumerator for ::urCommandBufferReleaseExp + COMMAND_BUFFER_FINALIZE_EXP = 123 ## Enumerator for ::urCommandBufferFinalizeExp + COMMAND_BUFFER_APPEND_KERNEL_LAUNCH_EXP = 125 ## Enumerator for ::urCommandBufferAppendKernelLaunchExp + COMMAND_BUFFER_ENQUEUE_EXP = 128 ## Enumerator for ::urCommandBufferEnqueueExp + COMMAND_BUFFER_APPEND_MEMCPY_USM_EXP = 129 ## Enumerator for ::urCommandBufferAppendMemcpyUSMExp + COMMAND_BUFFER_APPEND_MEMBUFFER_COPY_EXP = 130 ## Enumerator for ::urCommandBufferAppendMembufferCopyExp + COMMAND_BUFFER_APPEND_MEMBUFFER_COPY_RECT_EXP = 131 ## Enumerator for ::urCommandBufferAppendMembufferCopyRectExp + USM_PITCHED_ALLOC_EXP = 132 ## Enumerator for ::urUSMPitchedAllocExp + BINDLESS_IMAGES_UNSAMPLED_IMAGE_HANDLE_DESTROY_EXP = 133## Enumerator for ::urBindlessImagesUnsampledImageHandleDestroyExp + BINDLESS_IMAGES_SAMPLED_IMAGE_HANDLE_DESTROY_EXP = 134 ## Enumerator for ::urBindlessImagesSampledImageHandleDestroyExp + BINDLESS_IMAGES_IMAGE_ALLOCATE_EXP = 135 ## Enumerator for ::urBindlessImagesImageAllocateExp + BINDLESS_IMAGES_IMAGE_FREE_EXP = 136 ## Enumerator for ::urBindlessImagesImageFreeExp + BINDLESS_IMAGES_UNSAMPLED_IMAGE_CREATE_EXP = 137## Enumerator for ::urBindlessImagesUnsampledImageCreateExp + BINDLESS_IMAGES_SAMPLED_IMAGE_CREATE_EXP = 138 ## Enumerator for ::urBindlessImagesSampledImageCreateExp + BINDLESS_IMAGES_IMAGE_COPY_EXP = 139 ## Enumerator for ::urBindlessImagesImageCopyExp + BINDLESS_IMAGES_IMAGE_GET_INFO_EXP = 140 ## Enumerator for ::urBindlessImagesImageGetInfoExp + BINDLESS_IMAGES_MIPMAP_GET_LEVEL_EXP = 141 ## Enumerator for ::urBindlessImagesMipmapGetLevelExp + BINDLESS_IMAGES_MIPMAP_FREE_EXP = 142 ## Enumerator for ::urBindlessImagesMipmapFreeExp + BINDLESS_IMAGES_IMPORT_OPAQUE_FD_EXP = 143 ## Enumerator for ::urBindlessImagesImportOpaqueFDExp + BINDLESS_IMAGES_MAP_EXTERNAL_ARRAY_EXP = 144 ## Enumerator for ::urBindlessImagesMapExternalArrayExp + BINDLESS_IMAGES_RELEASE_INTEROP_EXP = 145 ## Enumerator for ::urBindlessImagesReleaseInteropExp + BINDLESS_IMAGES_IMPORT_EXTERNAL_SEMAPHORE_OPAQUE_FD_EXP = 146 ## Enumerator for ::urBindlessImagesImportExternalSemaphoreOpaqueFDExp + BINDLESS_IMAGES_DESTROY_EXTERNAL_SEMAPHORE_EXP = 147## Enumerator for ::urBindlessImagesDestroyExternalSemaphoreExp + BINDLESS_IMAGES_WAIT_EXTERNAL_SEMAPHORE_EXP = 148 ## Enumerator for ::urBindlessImagesWaitExternalSemaphoreExp + BINDLESS_IMAGES_SIGNAL_EXTERNAL_SEMAPHORE_EXP = 149 ## Enumerator for ::urBindlessImagesSignalExternalSemaphoreExp + ENQUEUE_USM_FILL_2D = 151 ## Enumerator for ::urEnqueueUSMFill2D + ENQUEUE_USM_MEMCPY_2D = 152 ## Enumerator for ::urEnqueueUSMMemcpy2D + VIRTUAL_MEM_GRANULARITY_GET_INFO = 153 ## Enumerator for ::urVirtualMemGranularityGetInfo + VIRTUAL_MEM_RESERVE = 154 ## Enumerator for ::urVirtualMemReserve + VIRTUAL_MEM_FREE = 155 ## Enumerator for ::urVirtualMemFree + VIRTUAL_MEM_MAP = 156 ## Enumerator for ::urVirtualMemMap + VIRTUAL_MEM_UNMAP = 157 ## Enumerator for ::urVirtualMemUnmap + VIRTUAL_MEM_SET_ACCESS = 158 ## Enumerator for ::urVirtualMemSetAccess + VIRTUAL_MEM_GET_INFO = 159 ## Enumerator for ::urVirtualMemGetInfo + PHYSICAL_MEM_CREATE = 160 ## Enumerator for ::urPhysicalMemCreate + PHYSICAL_MEM_RETAIN = 161 ## Enumerator for ::urPhysicalMemRetain + PHYSICAL_MEM_RELEASE = 162 ## Enumerator for ::urPhysicalMemRelease + USM_IMPORT_EXP = 163 ## Enumerator for ::urUSMImportExp + USM_RELEASE_EXP = 164 ## Enumerator for ::urUSMReleaseExp + USM_P2P_ENABLE_PEER_ACCESS_EXP = 165 ## Enumerator for ::urUsmP2PEnablePeerAccessExp + USM_P2P_DISABLE_PEER_ACCESS_EXP = 166 ## Enumerator for ::urUsmP2PDisablePeerAccessExp + USM_P2P_PEER_ACCESS_GET_INFO_EXP = 167 ## Enumerator for ::urUsmP2PPeerAccessGetInfoExp + COMMAND_BUFFER_APPEND_MEMBUFFER_WRITE_EXP = 168 ## Enumerator for ::urCommandBufferAppendMembufferWriteExp + COMMAND_BUFFER_APPEND_MEMBUFFER_READ_EXP = 169 ## Enumerator for ::urCommandBufferAppendMembufferReadExp + COMMAND_BUFFER_APPEND_MEMBUFFER_WRITE_RECT_EXP = 170## Enumerator for ::urCommandBufferAppendMembufferWriteRectExp + COMMAND_BUFFER_APPEND_MEMBUFFER_READ_RECT_EXP = 171 ## Enumerator for ::urCommandBufferAppendMembufferReadRectExp + LOADER_CONFIG_CREATE = 172 ## Enumerator for ::urLoaderConfigCreate + LOADER_CONFIG_RELEASE = 173 ## Enumerator for ::urLoaderConfigRelease + LOADER_CONFIG_RETAIN = 174 ## Enumerator for ::urLoaderConfigRetain + LOADER_CONFIG_GET_INFO = 175 ## Enumerator for ::urLoaderConfigGetInfo + LOADER_CONFIG_ENABLE_LAYER = 176 ## Enumerator for ::urLoaderConfigEnableLayer + ADAPTER_RELEASE = 177 ## Enumerator for ::urAdapterRelease + ADAPTER_GET = 178 ## Enumerator for ::urAdapterGet + ADAPTER_RETAIN = 179 ## Enumerator for ::urAdapterRetain + ADAPTER_GET_LAST_ERROR = 180 ## Enumerator for ::urAdapterGetLastError + ADAPTER_GET_INFO = 181 ## Enumerator for ::urAdapterGetInfo + +class ur_function_t(c_int): + def __str__(self): + return str(ur_function_v(self.value)) + + +############################################################################### +## @brief Defines structure types +class ur_structure_type_v(IntEnum): + CONTEXT_PROPERTIES = 0 ## ::ur_context_properties_t + IMAGE_DESC = 1 ## ::ur_image_desc_t + BUFFER_PROPERTIES = 2 ## ::ur_buffer_properties_t + BUFFER_REGION = 3 ## ::ur_buffer_region_t + BUFFER_CHANNEL_PROPERTIES = 4 ## ::ur_buffer_channel_properties_t + BUFFER_ALLOC_LOCATION_PROPERTIES = 5 ## ::ur_buffer_alloc_location_properties_t + PROGRAM_PROPERTIES = 6 ## ::ur_program_properties_t + USM_DESC = 7 ## ::ur_usm_desc_t + USM_HOST_DESC = 8 ## ::ur_usm_host_desc_t + USM_DEVICE_DESC = 9 ## ::ur_usm_device_desc_t + USM_POOL_DESC = 10 ## ::ur_usm_pool_desc_t + USM_POOL_LIMITS_DESC = 11 ## ::ur_usm_pool_limits_desc_t + DEVICE_BINARY = 12 ## ::ur_device_binary_t + SAMPLER_DESC = 13 ## ::ur_sampler_desc_t + QUEUE_PROPERTIES = 14 ## ::ur_queue_properties_t + QUEUE_INDEX_PROPERTIES = 15 ## ::ur_queue_index_properties_t + CONTEXT_NATIVE_PROPERTIES = 16 ## ::ur_context_native_properties_t + KERNEL_NATIVE_PROPERTIES = 17 ## ::ur_kernel_native_properties_t + QUEUE_NATIVE_PROPERTIES = 18 ## ::ur_queue_native_properties_t + MEM_NATIVE_PROPERTIES = 19 ## ::ur_mem_native_properties_t + EVENT_NATIVE_PROPERTIES = 20 ## ::ur_event_native_properties_t + PLATFORM_NATIVE_PROPERTIES = 21 ## ::ur_platform_native_properties_t + DEVICE_NATIVE_PROPERTIES = 22 ## ::ur_device_native_properties_t + PROGRAM_NATIVE_PROPERTIES = 23 ## ::ur_program_native_properties_t + SAMPLER_NATIVE_PROPERTIES = 24 ## ::ur_sampler_native_properties_t + QUEUE_NATIVE_DESC = 25 ## ::ur_queue_native_desc_t + DEVICE_PARTITION_PROPERTIES = 26 ## ::ur_device_partition_properties_t + KERNEL_ARG_MEM_OBJ_PROPERTIES = 27 ## ::ur_kernel_arg_mem_obj_properties_t + PHYSICAL_MEM_PROPERTIES = 28 ## ::ur_physical_mem_properties_t + KERNEL_ARG_POINTER_PROPERTIES = 29 ## ::ur_kernel_arg_pointer_properties_t + KERNEL_ARG_SAMPLER_PROPERTIES = 30 ## ::ur_kernel_arg_sampler_properties_t + KERNEL_EXEC_INFO_PROPERTIES = 31 ## ::ur_kernel_exec_info_properties_t + KERNEL_ARG_VALUE_PROPERTIES = 32 ## ::ur_kernel_arg_value_properties_t + KERNEL_ARG_LOCAL_PROPERTIES = 33 ## ::ur_kernel_arg_local_properties_t + EXP_COMMAND_BUFFER_DESC = 0x1000 ## ::ur_exp_command_buffer_desc_t + EXP_SAMPLER_MIP_PROPERTIES = 0x2000 ## ::ur_exp_sampler_mip_properties_t + EXP_INTEROP_MEM_DESC = 0x2001 ## ::ur_exp_interop_mem_desc_t + EXP_INTEROP_SEMAPHORE_DESC = 0x2002 ## ::ur_exp_interop_semaphore_desc_t + EXP_FILE_DESCRIPTOR = 0x2003 ## ::ur_exp_file_descriptor_t + EXP_WIN32_HANDLE = 0x2004 ## ::ur_exp_win32_handle_t + +class ur_structure_type_t(c_int): + def __str__(self): + return str(ur_structure_type_v(self.value)) + + ############################################################################### ## @brief Generates generic 'oneAPI' API versions def UR_MAKE_VERSION( _major, _minor ): @@ -55,6 +287,16 @@ def UR_MINOR_VERSION( _ver ): class ur_bool_t(c_ubyte): pass +############################################################################### +## @brief Handle of a loader config object +class ur_loader_config_handle_t(c_void_p): + pass + +############################################################################### +## @brief Handle of an adapter instance +class ur_adapter_handle_t(c_void_p): + pass + ############################################################################### ## @brief Handle of a platform instance class ur_platform_handle_t(c_void_p): @@ -142,7 +384,7 @@ class ur_result_v(IntEnum): ERROR_DEVICE_LOST = 20 ## Device hung, reset, was removed, or adapter update occurred ERROR_DEVICE_REQUIRES_RESET = 21 ## Device requires a reset ERROR_DEVICE_IN_LOW_POWER_STATE = 22 ## Device currently in low power state - ERROR_DEVICE_PARTITION_FAILED = 23 ## Device paritioning failed + ERROR_DEVICE_PARTITION_FAILED = 23 ## Device partitioning failed ERROR_INVALID_DEVICE_PARTITION_COUNT = 24 ## Invalid counts provided with ::UR_DEVICE_PARTITION_BY_COUNTS ERROR_INVALID_WORK_ITEM_SIZE = 25 ## Invalid work item size ERROR_INVALID_WORK_DIMENSION = 26 ## Invalid work dimension @@ -158,7 +400,8 @@ class ur_result_v(IntEnum): ERROR_IMAGE_FORMAT_NOT_SUPPORTED = 35 ## Image format not supported ERROR_MEM_OBJECT_ALLOCATION_FAILURE = 36 ## Memory object allocation failure ERROR_INVALID_PROGRAM_EXECUTABLE = 37 ## Program object parameter is invalid. - ERROR_UNINITIALIZED = 38 ## [Validation] adapter is not initialized + ERROR_UNINITIALIZED = 38 ## [Validation] adapter is not initialized or specific entry-point is not + ## implemented ERROR_OUT_OF_HOST_MEMORY = 39 ## Insufficient host memory to satisfy call ERROR_OUT_OF_DEVICE_MEMORY = 40 ## Insufficient device memory to satisfy call ERROR_OUT_OF_RESOURCES = 41 ## Out of resources @@ -196,6 +439,7 @@ class ur_result_v(IntEnum): ERROR_OBJECT_ALLOCATION_FAILURE = 66 ## Objection allocation failure ERROR_ADAPTER_SPECIFIC = 67 ## An adapter specific warning/error has been reported and can be ## retrieved via the urPlatformGetLastError entry point. + ERROR_LAYER_NOT_PRESENT = 68 ## A requested layer was not found by the loader. ERROR_INVALID_COMMAND_BUFFER_EXP = 0x1000 ## Invalid Command-Buffer ERROR_INVALID_COMMAND_BUFFER_SYNC_POINT_EXP = 0x1001## Sync point is not valid for the command-buffer ERROR_INVALID_COMMAND_BUFFER_SYNC_POINT_WAIT_LIST_EXP = 0x1002 ## Sync point wait list is invalid @@ -206,51 +450,6 @@ def __str__(self): return str(ur_result_v(self.value)) -############################################################################### -## @brief Defines structure types -class ur_structure_type_v(IntEnum): - CONTEXT_PROPERTIES = 0 ## ::ur_context_properties_t - IMAGE_DESC = 1 ## ::ur_image_desc_t - BUFFER_PROPERTIES = 2 ## ::ur_buffer_properties_t - BUFFER_REGION = 3 ## ::ur_buffer_region_t - BUFFER_CHANNEL_PROPERTIES = 4 ## ::ur_buffer_channel_properties_t - BUFFER_ALLOC_LOCATION_PROPERTIES = 5 ## ::ur_buffer_alloc_location_properties_t - PROGRAM_PROPERTIES = 6 ## ::ur_program_properties_t - USM_DESC = 7 ## ::ur_usm_desc_t - USM_HOST_DESC = 8 ## ::ur_usm_host_desc_t - USM_DEVICE_DESC = 9 ## ::ur_usm_device_desc_t - USM_POOL_DESC = 10 ## ::ur_usm_pool_desc_t - USM_POOL_LIMITS_DESC = 11 ## ::ur_usm_pool_limits_desc_t - DEVICE_BINARY = 12 ## ::ur_device_binary_t - SAMPLER_DESC = 13 ## ::ur_sampler_desc_t - QUEUE_PROPERTIES = 14 ## ::ur_queue_properties_t - QUEUE_INDEX_PROPERTIES = 15 ## ::ur_queue_properties_t - CONTEXT_NATIVE_PROPERTIES = 16 ## ::ur_context_native_properties_t - KERNEL_NATIVE_PROPERTIES = 17 ## ::ur_kernel_native_properties_t - QUEUE_NATIVE_PROPERTIES = 18 ## ::ur_queue_native_properties_t - MEM_NATIVE_PROPERTIES = 19 ## ::ur_mem_native_properties_t - EVENT_NATIVE_PROPERTIES = 20 ## ::ur_event_native_properties_t - PLATFORM_NATIVE_PROPERTIES = 21 ## ::ur_platform_native_properties_t - DEVICE_NATIVE_PROPERTIES = 22 ## ::ur_device_native_properties_t - PROGRAM_NATIVE_PROPERTIES = 23 ## ::ur_program_native_properties_t - SAMPLER_NATIVE_PROPERTIES = 24 ## ::ur_sampler_native_properties_t - QUEUE_NATIVE_DESC = 25 ## ::ur_queue_native_desc_t - DEVICE_PARTITION_PROPERTIES = 26 ## ::ur_device_partition_properties_t - KERNEL_ARG_MEM_OBJ_PROPERTIES = 27 ## ::ur_kernel_arg_mem_obj_properties_t - PHYSICAL_MEM_PROPERTIES = 28 ## ::ur_physical_mem_properties_t - KERNEL_ARG_POINTER_PROPERTIES = 29 ## ::ur_kernel_arg_pointer_properties_t - KERNEL_ARG_SAMPLER_PROPERTIES = 30 ## ::ur_kernel_arg_sampler_properties_t - KERNEL_EXEC_INFO_PROPERTIES = 31 ## ::ur_kernel_exec_info_properties_t - KERNEL_ARG_VALUE_PROPERTIES = 32 ## ::ur_kernel_arg_value_properties_t - KERNEL_ARG_LOCAL_PROPERTIES = 33 ## ::ur_kernel_arg_local_properties_t - EXP_COMMAND_BUFFER_DESC = 0x1000 ## ::ur_exp_command_buffer_desc_t - EXP_SAMPLER_MIP_PROPERTIES = 0x2000 ## ::ur_exp_sampler_mip_properties_t - -class ur_structure_type_t(c_int): - def __str__(self): - return str(ur_structure_type_v(self.value)) - - ############################################################################### ## @brief Base for all properties types class ur_base_properties_t(Structure): @@ -294,9 +493,51 @@ class ur_device_init_flags_v(IntEnum): MCA = UR_BIT(3) ## initialize MCA device adapters. VPU = UR_BIT(4) ## initialize VPU device adapters. -class ur_device_init_flags_t(c_int): +class ur_device_init_flags_t(c_int): + def __str__(self): + return hex(self.value) + + +############################################################################### +## @brief Supported loader info +class ur_loader_config_info_v(IntEnum): + AVAILABLE_LAYERS = 0 ## [char[]] Null-terminated, semi-colon separated list of available + ## layers. + REFERENCE_COUNT = 1 ## [uint32_t] Reference count of the loader config object. + +class ur_loader_config_info_t(c_int): + def __str__(self): + return str(ur_loader_config_info_v(self.value)) + + +############################################################################### +## @brief Supported adapter info +class ur_adapter_info_v(IntEnum): + BACKEND = 0 ## [::ur_adapter_backend_t] Identifies the native backend supported by + ## the adapter. + REFERENCE_COUNT = 1 ## [uint32_t] Reference count of the adapter. + ## The reference count returned should be considered immediately stale. + ## It is unsuitable for general use in applications. This feature is + ## provided for identifying memory leaks. + +class ur_adapter_info_t(c_int): + def __str__(self): + return str(ur_adapter_info_v(self.value)) + + +############################################################################### +## @brief Identifies backend of the adapter +class ur_adapter_backend_v(IntEnum): + UNKNOWN = 0 ## The backend is not a recognized one + LEVEL_ZERO = 1 ## The backend is Level Zero + OPENCL = 2 ## The backend is OpenCL + CUDA = 3 ## The backend is CUDA + HIP = 4 ## The backend is HIP + NATIVE_CPU = 5 ## The backend is Native CPU + +class ur_adapter_backend_t(c_int): def __str__(self): - return hex(self.value) + return str(ur_adapter_backend_v(self.value)) ############################################################################### @@ -355,6 +596,7 @@ class ur_platform_backend_v(IntEnum): OPENCL = 2 ## The backend is OpenCL CUDA = 3 ## The backend is CUDA HIP = 4 ## The backend is HIP + NATIVE_CPU = 5 ## The backend is Native CPU class ur_platform_backend_t(c_int): def __str__(self): @@ -475,7 +717,7 @@ class ur_device_info_v(IntEnum): MAX_READ_WRITE_IMAGE_ARGS = 32 ## [uint32_t] max number of image objects arguments of a kernel declared ## with the read_write qualifier IMAGE2D_MAX_WIDTH = 33 ## [size_t] max width of Image2D object - IMAGE2D_MAX_HEIGHT = 34 ## [size_t] max heigh of Image2D object + IMAGE2D_MAX_HEIGHT = 34 ## [size_t] max height of Image2D object IMAGE3D_MAX_WIDTH = 35 ## [size_t] max width of Image3D object IMAGE3D_MAX_HEIGHT = 36 ## [size_t] max height of Image3D object IMAGE3D_MAX_DEPTH = 37 ## [size_t] max depth of Image3D object @@ -584,13 +826,14 @@ class ur_device_info_v(IntEnum): IP_VERSION = 113 ## [uint32_t] The device IP version. The meaning of the device IP version ## is implementation-defined, but newer devices should have a higher ## version than older devices. + VIRTUAL_MEMORY_SUPPORT = 114 ## [::ur_bool_t] return true if the device supports virtual memory. BINDLESS_IMAGES_SUPPORT_EXP = 0x2000 ## [::ur_bool_t] returns true if the device supports the creation of ## bindless images - BINDLESS_IMAGES_1D_USM_SUPPORT_EXP = 0x2001 ## [::ur_bool_t] returns true if the device supports the creation of 1D - ## bindless images backed by USM - BINDLESS_IMAGES_2D_USM_SUPPORT_EXP = 0x2002 ## [::ur_bool_t] returns true if the device supports the creation of 2D + BINDLESS_IMAGES_SHARED_USM_SUPPORT_EXP = 0x2001 ## [::ur_bool_t] returns true if the device supports the creation of + ## bindless images backed by shared USM + BINDLESS_IMAGES_1D_USM_SUPPORT_EXP = 0x2002 ## [::ur_bool_t] returns true if the device supports the creation of 1D ## bindless images backed by USM - BINDLESS_IMAGES_3D_USM_SUPPORT_EXP = 0x2003 ## [::ur_bool_t] returns true if the device supports the creation of 3D + BINDLESS_IMAGES_2D_USM_SUPPORT_EXP = 0x2003 ## [::ur_bool_t] returns true if the device supports the creation of 2D ## bindless images backed by USM IMAGE_PITCH_ALIGN_EXP = 0x2004 ## [uint32_t] returns the required alignment of the pitch between two ## rows of an image in bytes @@ -673,7 +916,7 @@ class ur_device_partition_value_t(Structure): ("count", c_ulong), ## [in] Number of compute units in a sub-device when partitioning with ## ::UR_DEVICE_PARTITION_BY_COUNTS. ("affinity_domain", ur_device_affinity_domain_flags_t) ## [in] The affinity domain to partition for when partitioning with - ## $UR_DEVICE_PARTITION_BY_AFFINITY_DOMAIN. + ## ::UR_DEVICE_PARTITION_BY_AFFINITY_DOMAIN. ] ############################################################################### @@ -681,7 +924,7 @@ class ur_device_partition_value_t(Structure): class ur_device_partition_property_t(Structure): _fields_ = [ ("type", ur_device_partition_t), ## [in] The partitioning type to be used. - ("value", ur_device_partition_value_t) ## [in] The paritioning value. + ("value", ur_device_partition_value_t) ## [in][tagged_by(type)] The partitioning value. ] ############################################################################### @@ -1404,7 +1647,7 @@ class ur_program_metadata_t(Structure): ("type", ur_program_metadata_type_t), ## [in] the type of metadata value. ("size", c_size_t), ## [in] size in bytes of the data pointed to by value.pData, or 0 when ## value size is less than 64-bits and is stored directly in value.data. - ("value", ur_program_metadata_value_t) ## [in] the metadata value storage. + ("value", ur_program_metadata_value_t) ## [in][tagged_by(type)] the metadata value storage. ] ############################################################################### @@ -1573,7 +1816,7 @@ def __str__(self): ############################################################################### -## @brief Kernel Cache Configuartion. +## @brief Kernel Cache Configuration. class ur_kernel_cache_config_v(IntEnum): DEFAULT = 0 ## No preference for SLM or data cache. LARGE_SLM = 1 ## Large Shared Local Memory (SLM) size. @@ -1867,180 +2110,6 @@ def ur_event_callback_t_wrapper(hEvent, execStatus, pUserData): return user_defined_callback(hEvent, execStatus, pUserData) return ur_event_callback_t_wrapper -############################################################################### -## @brief Defines unique stable identifiers for all functions -class ur_function_v(IntEnum): - CONTEXT_CREATE = 1 ## Enumerator for ::urContextCreate - CONTEXT_RETAIN = 2 ## Enumerator for ::urContextRetain - CONTEXT_RELEASE = 3 ## Enumerator for ::urContextRelease - CONTEXT_GET_INFO = 4 ## Enumerator for ::urContextGetInfo - CONTEXT_GET_NATIVE_HANDLE = 5 ## Enumerator for ::urContextGetNativeHandle - CONTEXT_CREATE_WITH_NATIVE_HANDLE = 6 ## Enumerator for ::urContextCreateWithNativeHandle - CONTEXT_SET_EXTENDED_DELETER = 7 ## Enumerator for ::urContextSetExtendedDeleter - DEVICE_GET = 8 ## Enumerator for ::urDeviceGet - DEVICE_GET_INFO = 9 ## Enumerator for ::urDeviceGetInfo - DEVICE_RETAIN = 10 ## Enumerator for ::urDeviceRetain - DEVICE_RELEASE = 11 ## Enumerator for ::urDeviceRelease - DEVICE_PARTITION = 12 ## Enumerator for ::urDevicePartition - DEVICE_SELECT_BINARY = 13 ## Enumerator for ::urDeviceSelectBinary - DEVICE_GET_NATIVE_HANDLE = 14 ## Enumerator for ::urDeviceGetNativeHandle - DEVICE_CREATE_WITH_NATIVE_HANDLE = 15 ## Enumerator for ::urDeviceCreateWithNativeHandle - DEVICE_GET_GLOBAL_TIMESTAMPS = 16 ## Enumerator for ::urDeviceGetGlobalTimestamps - ENQUEUE_KERNEL_LAUNCH = 17 ## Enumerator for ::urEnqueueKernelLaunch - ENQUEUE_EVENTS_WAIT = 18 ## Enumerator for ::urEnqueueEventsWait - ENQUEUE_EVENTS_WAIT_WITH_BARRIER = 19 ## Enumerator for ::urEnqueueEventsWaitWithBarrier - ENQUEUE_MEM_BUFFER_READ = 20 ## Enumerator for ::urEnqueueMemBufferRead - ENQUEUE_MEM_BUFFER_WRITE = 21 ## Enumerator for ::urEnqueueMemBufferWrite - ENQUEUE_MEM_BUFFER_READ_RECT = 22 ## Enumerator for ::urEnqueueMemBufferReadRect - ENQUEUE_MEM_BUFFER_WRITE_RECT = 23 ## Enumerator for ::urEnqueueMemBufferWriteRect - ENQUEUE_MEM_BUFFER_COPY = 24 ## Enumerator for ::urEnqueueMemBufferCopy - ENQUEUE_MEM_BUFFER_COPY_RECT = 25 ## Enumerator for ::urEnqueueMemBufferCopyRect - ENQUEUE_MEM_BUFFER_FILL = 26 ## Enumerator for ::urEnqueueMemBufferFill - ENQUEUE_MEM_IMAGE_READ = 27 ## Enumerator for ::urEnqueueMemImageRead - ENQUEUE_MEM_IMAGE_WRITE = 28 ## Enumerator for ::urEnqueueMemImageWrite - ENQUEUE_MEM_IMAGE_COPY = 29 ## Enumerator for ::urEnqueueMemImageCopy - ENQUEUE_MEM_BUFFER_MAP = 30 ## Enumerator for ::urEnqueueMemBufferMap - ENQUEUE_MEM_UNMAP = 31 ## Enumerator for ::urEnqueueMemUnmap - ENQUEUE_USM_FILL = 32 ## Enumerator for ::urEnqueueUSMFill - ENQUEUE_USM_MEMCPY = 33 ## Enumerator for ::urEnqueueUSMMemcpy - ENQUEUE_USM_PREFETCH = 34 ## Enumerator for ::urEnqueueUSMPrefetch - ENQUEUE_USM_ADVISE = 35 ## Enumerator for ::urEnqueueUSMAdvise - ENQUEUE_DEVICE_GLOBAL_VARIABLE_WRITE = 38 ## Enumerator for ::urEnqueueDeviceGlobalVariableWrite - ENQUEUE_DEVICE_GLOBAL_VARIABLE_READ = 39 ## Enumerator for ::urEnqueueDeviceGlobalVariableRead - EVENT_GET_INFO = 40 ## Enumerator for ::urEventGetInfo - EVENT_GET_PROFILING_INFO = 41 ## Enumerator for ::urEventGetProfilingInfo - EVENT_WAIT = 42 ## Enumerator for ::urEventWait - EVENT_RETAIN = 43 ## Enumerator for ::urEventRetain - EVENT_RELEASE = 44 ## Enumerator for ::urEventRelease - EVENT_GET_NATIVE_HANDLE = 45 ## Enumerator for ::urEventGetNativeHandle - EVENT_CREATE_WITH_NATIVE_HANDLE = 46 ## Enumerator for ::urEventCreateWithNativeHandle - EVENT_SET_CALLBACK = 47 ## Enumerator for ::urEventSetCallback - KERNEL_CREATE = 48 ## Enumerator for ::urKernelCreate - KERNEL_SET_ARG_VALUE = 49 ## Enumerator for ::urKernelSetArgValue - KERNEL_SET_ARG_LOCAL = 50 ## Enumerator for ::urKernelSetArgLocal - KERNEL_GET_INFO = 51 ## Enumerator for ::urKernelGetInfo - KERNEL_GET_GROUP_INFO = 52 ## Enumerator for ::urKernelGetGroupInfo - KERNEL_GET_SUB_GROUP_INFO = 53 ## Enumerator for ::urKernelGetSubGroupInfo - KERNEL_RETAIN = 54 ## Enumerator for ::urKernelRetain - KERNEL_RELEASE = 55 ## Enumerator for ::urKernelRelease - KERNEL_SET_ARG_POINTER = 56 ## Enumerator for ::urKernelSetArgPointer - KERNEL_SET_EXEC_INFO = 57 ## Enumerator for ::urKernelSetExecInfo - KERNEL_SET_ARG_SAMPLER = 58 ## Enumerator for ::urKernelSetArgSampler - KERNEL_SET_ARG_MEM_OBJ = 59 ## Enumerator for ::urKernelSetArgMemObj - KERNEL_SET_SPECIALIZATION_CONSTANTS = 60 ## Enumerator for ::urKernelSetSpecializationConstants - KERNEL_GET_NATIVE_HANDLE = 61 ## Enumerator for ::urKernelGetNativeHandle - KERNEL_CREATE_WITH_NATIVE_HANDLE = 62 ## Enumerator for ::urKernelCreateWithNativeHandle - MEM_IMAGE_CREATE = 63 ## Enumerator for ::urMemImageCreate - MEM_BUFFER_CREATE = 64 ## Enumerator for ::urMemBufferCreate - MEM_RETAIN = 65 ## Enumerator for ::urMemRetain - MEM_RELEASE = 66 ## Enumerator for ::urMemRelease - MEM_BUFFER_PARTITION = 67 ## Enumerator for ::urMemBufferPartition - MEM_GET_NATIVE_HANDLE = 68 ## Enumerator for ::urMemGetNativeHandle - ENQUEUE_READ_HOST_PIPE = 69 ## Enumerator for ::urEnqueueReadHostPipe - MEM_GET_INFO = 70 ## Enumerator for ::urMemGetInfo - MEM_IMAGE_GET_INFO = 71 ## Enumerator for ::urMemImageGetInfo - PLATFORM_GET = 72 ## Enumerator for ::urPlatformGet - PLATFORM_GET_INFO = 73 ## Enumerator for ::urPlatformGetInfo - PLATFORM_GET_API_VERSION = 74 ## Enumerator for ::urPlatformGetApiVersion - PLATFORM_GET_NATIVE_HANDLE = 75 ## Enumerator for ::urPlatformGetNativeHandle - PLATFORM_CREATE_WITH_NATIVE_HANDLE = 76 ## Enumerator for ::urPlatformCreateWithNativeHandle - PROGRAM_CREATE_WITH_IL = 78 ## Enumerator for ::urProgramCreateWithIL - PROGRAM_CREATE_WITH_BINARY = 79 ## Enumerator for ::urProgramCreateWithBinary - PROGRAM_BUILD = 80 ## Enumerator for ::urProgramBuild - PROGRAM_COMPILE = 81 ## Enumerator for ::urProgramCompile - PROGRAM_LINK = 82 ## Enumerator for ::urProgramLink - PROGRAM_RETAIN = 83 ## Enumerator for ::urProgramRetain - PROGRAM_RELEASE = 84 ## Enumerator for ::urProgramRelease - PROGRAM_GET_FUNCTION_POINTER = 85 ## Enumerator for ::urProgramGetFunctionPointer - PROGRAM_GET_INFO = 86 ## Enumerator for ::urProgramGetInfo - PROGRAM_GET_BUILD_INFO = 87 ## Enumerator for ::urProgramGetBuildInfo - PROGRAM_SET_SPECIALIZATION_CONSTANTS = 88 ## Enumerator for ::urProgramSetSpecializationConstants - PROGRAM_GET_NATIVE_HANDLE = 89 ## Enumerator for ::urProgramGetNativeHandle - PROGRAM_CREATE_WITH_NATIVE_HANDLE = 90 ## Enumerator for ::urProgramCreateWithNativeHandle - QUEUE_GET_INFO = 91 ## Enumerator for ::urQueueGetInfo - QUEUE_CREATE = 92 ## Enumerator for ::urQueueCreate - QUEUE_RETAIN = 93 ## Enumerator for ::urQueueRetain - QUEUE_RELEASE = 94 ## Enumerator for ::urQueueRelease - QUEUE_GET_NATIVE_HANDLE = 95 ## Enumerator for ::urQueueGetNativeHandle - QUEUE_CREATE_WITH_NATIVE_HANDLE = 96 ## Enumerator for ::urQueueCreateWithNativeHandle - QUEUE_FINISH = 97 ## Enumerator for ::urQueueFinish - QUEUE_FLUSH = 98 ## Enumerator for ::urQueueFlush - INIT = 99 ## Enumerator for ::urInit - TEAR_DOWN = 100 ## Enumerator for ::urTearDown - SAMPLER_CREATE = 101 ## Enumerator for ::urSamplerCreate - SAMPLER_RETAIN = 102 ## Enumerator for ::urSamplerRetain - SAMPLER_RELEASE = 103 ## Enumerator for ::urSamplerRelease - SAMPLER_GET_INFO = 104 ## Enumerator for ::urSamplerGetInfo - SAMPLER_GET_NATIVE_HANDLE = 105 ## Enumerator for ::urSamplerGetNativeHandle - SAMPLER_CREATE_WITH_NATIVE_HANDLE = 106 ## Enumerator for ::urSamplerCreateWithNativeHandle - USM_HOST_ALLOC = 107 ## Enumerator for ::urUSMHostAlloc - USM_DEVICE_ALLOC = 108 ## Enumerator for ::urUSMDeviceAlloc - USM_SHARED_ALLOC = 109 ## Enumerator for ::urUSMSharedAlloc - USM_FREE = 110 ## Enumerator for ::urUSMFree - USM_GET_MEM_ALLOC_INFO = 111 ## Enumerator for ::urUSMGetMemAllocInfo - USM_POOL_CREATE = 112 ## Enumerator for ::urUSMPoolCreate - COMMAND_BUFFER_CREATE_EXP = 113 ## Enumerator for ::urCommandBufferCreateExp - PLATFORM_GET_BACKEND_OPTION = 114 ## Enumerator for ::urPlatformGetBackendOption - MEM_BUFFER_CREATE_WITH_NATIVE_HANDLE = 115 ## Enumerator for ::urMemBufferCreateWithNativeHandle - MEM_IMAGE_CREATE_WITH_NATIVE_HANDLE = 116 ## Enumerator for ::urMemImageCreateWithNativeHandle - ENQUEUE_WRITE_HOST_PIPE = 117 ## Enumerator for ::urEnqueueWriteHostPipe - USM_POOL_RETAIN = 118 ## Enumerator for ::urUSMPoolRetain - USM_POOL_RELEASE = 119 ## Enumerator for ::urUSMPoolRelease - USM_POOL_GET_INFO = 120 ## Enumerator for ::urUSMPoolGetInfo - COMMAND_BUFFER_RETAIN_EXP = 121 ## Enumerator for ::urCommandBufferRetainExp - COMMAND_BUFFER_RELEASE_EXP = 122 ## Enumerator for ::urCommandBufferReleaseExp - COMMAND_BUFFER_FINALIZE_EXP = 123 ## Enumerator for ::urCommandBufferFinalizeExp - COMMAND_BUFFER_APPEND_KERNEL_LAUNCH_EXP = 125 ## Enumerator for ::urCommandBufferAppendKernelLaunchExp - COMMAND_BUFFER_ENQUEUE_EXP = 128 ## Enumerator for ::urCommandBufferEnqueueExp - COMMAND_BUFFER_APPEND_MEMCPY_USM_EXP = 129 ## Enumerator for ::urCommandBufferAppendMemcpyUSMExp - COMMAND_BUFFER_APPEND_MEMBUFFER_COPY_EXP = 130 ## Enumerator for ::urCommandBufferAppendMembufferCopyExp - COMMAND_BUFFER_APPEND_MEMBUFFER_COPY_RECT_EXP = 131 ## Enumerator for ::urCommandBufferAppendMembufferCopyRectExp - USM_PITCHED_ALLOC_EXP = 132 ## Enumerator for ::urUSMPitchedAllocExp - BINDLESS_IMAGES_UNSAMPLED_IMAGE_HANDLE_DESTROY_EXP = 133## Enumerator for ::urBindlessImagesUnsampledImageHandleDestroyExp - BINDLESS_IMAGES_SAMPLED_IMAGE_HANDLE_DESTROY_EXP = 134 ## Enumerator for ::urBindlessImagesSampledImageHandleDestroyExp - BINDLESS_IMAGES_IMAGE_ALLOCATE_EXP = 135 ## Enumerator for ::urBindlessImagesImageAllocateExp - BINDLESS_IMAGES_IMAGE_FREE_EXP = 136 ## Enumerator for ::urBindlessImagesImageFreeExp - BINDLESS_IMAGES_UNSAMPLED_IMAGE_CREATE_EXP = 137## Enumerator for ::urBindlessImagesUnsampledImageCreateExp - BINDLESS_IMAGES_SAMPLED_IMAGE_CREATE_EXP = 138 ## Enumerator for ::urBindlessImagesSampledImageCreateExp - BINDLESS_IMAGES_IMAGE_COPY_EXP = 139 ## Enumerator for ::urBindlessImagesImageCopyExp - BINDLESS_IMAGES_IMAGE_GET_INFO_EXP = 140 ## Enumerator for ::urBindlessImagesImageGetInfoExp - BINDLESS_IMAGES_MIPMAP_GET_LEVEL_EXP = 141 ## Enumerator for ::urBindlessImagesMipmapGetLevelExp - BINDLESS_IMAGES_MIPMAP_FREE_EXP = 142 ## Enumerator for ::urBindlessImagesMipmapFreeExp - BINDLESS_IMAGES_IMPORT_OPAQUE_FD_EXP = 143 ## Enumerator for ::urBindlessImagesImportOpaqueFDExp - BINDLESS_IMAGES_MAP_EXTERNAL_ARRAY_EXP = 144 ## Enumerator for ::urBindlessImagesMapExternalArrayExp - BINDLESS_IMAGES_RELEASE_INTEROP_EXP = 145 ## Enumerator for ::urBindlessImagesReleaseInteropExp - BINDLESS_IMAGES_IMPORT_EXTERNAL_SEMAPHORE_OPAQUE_FD_EXP = 146 ## Enumerator for ::urBindlessImagesImportExternalSemaphoreOpaqueFDExp - BINDLESS_IMAGES_DESTROY_EXTERNAL_SEMAPHORE_EXP = 147## Enumerator for ::urBindlessImagesDestroyExternalSemaphoreExp - BINDLESS_IMAGES_WAIT_EXTERNAL_SEMAPHORE_EXP = 148 ## Enumerator for ::urBindlessImagesWaitExternalSemaphoreExp - BINDLESS_IMAGES_SIGNAL_EXTERNAL_SEMAPHORE_EXP = 149 ## Enumerator for ::urBindlessImagesSignalExternalSemaphoreExp - PLATFORM_GET_LAST_ERROR = 150 ## Enumerator for ::urPlatformGetLastError - ENQUEUE_USM_FILL_2D = 151 ## Enumerator for ::urEnqueueUSMFill2D - ENQUEUE_USM_MEMCPY_2D = 152 ## Enumerator for ::urEnqueueUSMMemcpy2D - VIRTUAL_MEM_GRANULARITY_GET_INFO = 153 ## Enumerator for ::urVirtualMemGranularityGetInfo - VIRTUAL_MEM_RESERVE = 154 ## Enumerator for ::urVirtualMemReserve - VIRTUAL_MEM_FREE = 155 ## Enumerator for ::urVirtualMemFree - VIRTUAL_MEM_MAP = 156 ## Enumerator for ::urVirtualMemMap - VIRTUAL_MEM_UNMAP = 157 ## Enumerator for ::urVirtualMemUnmap - VIRTUAL_MEM_SET_ACCESS = 158 ## Enumerator for ::urVirtualMemSetAccess - VIRTUAL_MEM_GET_INFO = 159 ## Enumerator for ::urVirtualMemGetInfo - PHYSICAL_MEM_CREATE = 160 ## Enumerator for ::urPhysicalMemCreate - PHYSICAL_MEM_RETAIN = 161 ## Enumerator for ::urPhysicalMemRetain - PHYSICAL_MEM_RELEASE = 162 ## Enumerator for ::urPhysicalMemRelease - USM_IMPORT_EXP = 163 ## Enumerator for ::urUSMImportExp - USM_RELEASE_EXP = 164 ## Enumerator for ::urUSMReleaseExp - USM_P2P_ENABLE_PEER_ACCESS_EXP = 165 ## Enumerator for ::urUsmP2PEnablePeerAccessExp - USM_P2P_DISABLE_PEER_ACCESS_EXP = 166 ## Enumerator for ::urUsmP2PDisablePeerAccessExp - USM_P2P_PEER_ACCESS_GET_INFO_EXP = 167 ## Enumerator for ::urUsmP2PPeerAccessGetInfoExp - COMMAND_BUFFER_APPEND_MEMBUFFER_WRITE_EXP = 168 ## Enumerator for ::urCommandBufferAppendMembufferWriteExp - COMMAND_BUFFER_APPEND_MEMBUFFER_READ_EXP = 169 ## Enumerator for ::urCommandBufferAppendMembufferReadExp - COMMAND_BUFFER_APPEND_MEMBUFFER_WRITE_RECT_EXP = 170## Enumerator for ::urCommandBufferAppendMembufferWriteRectExp - COMMAND_BUFFER_APPEND_MEMBUFFER_READ_RECT_EXP = 171 ## Enumerator for ::urCommandBufferAppendMembufferReadRectExp - -class ur_function_t(c_int): - def __str__(self): - return str(ur_function_v(self.value)) - - ############################################################################### ## @brief Map flags class ur_map_flags_v(IntEnum): @@ -2086,7 +2155,7 @@ class ur_exp_interop_semaphore_handle_t(c_void_p): ############################################################################### ## @brief Dictates the type of memory copy. class ur_exp_image_copy_flags_v(IntEnum): - HOST_TO_DEVICE = UR_BIT(0) ## Host to device. + HOST_TO_DEVICE = UR_BIT(0) ## Host to device DEVICE_TO_HOST = UR_BIT(1) ## Device to host DEVICE_TO_DEVICE = UR_BIT(2) ## Device to device @@ -2095,6 +2164,26 @@ def __str__(self): return hex(self.value) +############################################################################### +## @brief File descriptor +class ur_exp_file_descriptor_t(Structure): + _fields_ = [ + ("stype", ur_structure_type_t), ## [in] type of this structure, must be + ## ::UR_STRUCTURE_TYPE_EXP_FILE_DESCRIPTOR + ("pNext", c_void_p), ## [in][optional] pointer to extension-specific structure + ("fd", c_int) ## [in] A file descriptor used for Linux and & MacOS operating systems. + ] + +############################################################################### +## @brief Windows specific file handle +class ur_exp_win32_handle_t(Structure): + _fields_ = [ + ("stype", ur_structure_type_t), ## [in] type of this structure, must be + ## ::UR_STRUCTURE_TYPE_EXP_WIN32_HANDLE + ("pNext", c_void_p), ## [in][optional] pointer to extension-specific structure + ("handle", c_void_p) ## [in] A win32 file handle. + ] + ############################################################################### ## @brief Describes mipmap sampler properties ## @@ -2110,8 +2199,27 @@ class ur_exp_sampler_mip_properties_t(Structure): ## being 0 ("maxMipmapLevelClamp", c_float), ## [in] maximum mipmap level from which we can sample, maximum value ## being the number of levels - ("maxAnistropy", c_float) ## [in] anisotropic ratio used when samplling the mipmap with anisotropic + ("maxAnisotropy", c_float), ## [in] anisotropic ratio used when samplling the mipmap with anisotropic ## filtering + ("mipFilterMode", ur_sampler_filter_mode_t) ## [in] mipmap filter mode used for filtering between mipmap levels + ] + +############################################################################### +## @brief Describes an interop memory resource descriptor +class ur_exp_interop_mem_desc_t(Structure): + _fields_ = [ + ("stype", ur_structure_type_t), ## [in] type of this structure, must be + ## ::UR_STRUCTURE_TYPE_EXP_INTEROP_MEM_DESC + ("pNext", c_void_p) ## [in][optional] pointer to extension-specific structure + ] + +############################################################################### +## @brief Describes an interop semaphore resource descriptor +class ur_exp_interop_semaphore_desc_t(Structure): + _fields_ = [ + ("stype", ur_structure_type_t), ## [in] type of this structure, must be + ## ::UR_STRUCTURE_TYPE_EXP_INTEROP_SEMAPHORE_DESC + ("pNext", c_void_p) ## [in][optional] pointer to extension-specific structure ] ############################################################################### @@ -2155,12 +2263,59 @@ def __str__(self): ############################################################################### __use_win_types = "Windows" == platform.uname()[0] +############################################################################### +## @brief Function-pointer for urLoaderConfigCreate +if __use_win_types: + _urLoaderConfigCreate_t = WINFUNCTYPE( ur_result_t, POINTER(ur_loader_config_handle_t) ) +else: + _urLoaderConfigCreate_t = CFUNCTYPE( ur_result_t, POINTER(ur_loader_config_handle_t) ) + +############################################################################### +## @brief Function-pointer for urLoaderConfigRetain +if __use_win_types: + _urLoaderConfigRetain_t = WINFUNCTYPE( ur_result_t, ur_loader_config_handle_t ) +else: + _urLoaderConfigRetain_t = CFUNCTYPE( ur_result_t, ur_loader_config_handle_t ) + +############################################################################### +## @brief Function-pointer for urLoaderConfigRelease +if __use_win_types: + _urLoaderConfigRelease_t = WINFUNCTYPE( ur_result_t, ur_loader_config_handle_t ) +else: + _urLoaderConfigRelease_t = CFUNCTYPE( ur_result_t, ur_loader_config_handle_t ) + +############################################################################### +## @brief Function-pointer for urLoaderConfigGetInfo +if __use_win_types: + _urLoaderConfigGetInfo_t = WINFUNCTYPE( ur_result_t, ur_loader_config_handle_t, ur_loader_config_info_t, c_size_t, c_void_p, POINTER(c_size_t) ) +else: + _urLoaderConfigGetInfo_t = CFUNCTYPE( ur_result_t, ur_loader_config_handle_t, ur_loader_config_info_t, c_size_t, c_void_p, POINTER(c_size_t) ) + +############################################################################### +## @brief Function-pointer for urLoaderConfigEnableLayer +if __use_win_types: + _urLoaderConfigEnableLayer_t = WINFUNCTYPE( ur_result_t, ur_loader_config_handle_t, c_char_p ) +else: + _urLoaderConfigEnableLayer_t = CFUNCTYPE( ur_result_t, ur_loader_config_handle_t, c_char_p ) + + +############################################################################### +## @brief Table of LoaderConfig functions pointers +class ur_loader_config_dditable_t(Structure): + _fields_ = [ + ("pfnCreate", c_void_p), ## _urLoaderConfigCreate_t + ("pfnRetain", c_void_p), ## _urLoaderConfigRetain_t + ("pfnRelease", c_void_p), ## _urLoaderConfigRelease_t + ("pfnGetInfo", c_void_p), ## _urLoaderConfigGetInfo_t + ("pfnEnableLayer", c_void_p) ## _urLoaderConfigEnableLayer_t + ] + ############################################################################### ## @brief Function-pointer for urPlatformGet if __use_win_types: - _urPlatformGet_t = WINFUNCTYPE( ur_result_t, c_ulong, POINTER(ur_platform_handle_t), POINTER(c_ulong) ) + _urPlatformGet_t = WINFUNCTYPE( ur_result_t, POINTER(ur_adapter_handle_t), c_ulong, c_ulong, POINTER(ur_platform_handle_t), POINTER(c_ulong) ) else: - _urPlatformGet_t = CFUNCTYPE( ur_result_t, c_ulong, POINTER(ur_platform_handle_t), POINTER(c_ulong) ) + _urPlatformGet_t = CFUNCTYPE( ur_result_t, POINTER(ur_adapter_handle_t), c_ulong, c_ulong, POINTER(ur_platform_handle_t), POINTER(c_ulong) ) ############################################################################### ## @brief Function-pointer for urPlatformGetInfo @@ -2183,13 +2338,6 @@ def __str__(self): else: _urPlatformCreateWithNativeHandle_t = CFUNCTYPE( ur_result_t, ur_native_handle_t, POINTER(ur_platform_native_properties_t), POINTER(ur_platform_handle_t) ) -############################################################################### -## @brief Function-pointer for urPlatformGetLastError -if __use_win_types: - _urPlatformGetLastError_t = WINFUNCTYPE( ur_result_t, ur_platform_handle_t, POINTER(c_char_p), POINTER(c_long) ) -else: - _urPlatformGetLastError_t = CFUNCTYPE( ur_result_t, ur_platform_handle_t, POINTER(c_char_p), POINTER(c_long) ) - ############################################################################### ## @brief Function-pointer for urPlatformGetApiVersion if __use_win_types: @@ -2213,7 +2361,6 @@ class ur_platform_dditable_t(Structure): ("pfnGetInfo", c_void_p), ## _urPlatformGetInfo_t ("pfnGetNativeHandle", c_void_p), ## _urPlatformGetNativeHandle_t ("pfnCreateWithNativeHandle", c_void_p), ## _urPlatformCreateWithNativeHandle_t - ("pfnGetLastError", c_void_p), ## _urPlatformGetLastError_t ("pfnGetApiVersion", c_void_p), ## _urPlatformGetApiVersion_t ("pfnGetBackendOption", c_void_p) ## _urPlatformGetBackendOption_t ] @@ -3044,51 +3191,51 @@ class ur_queue_dditable_t(Structure): ############################################################################### ## @brief Function-pointer for urBindlessImagesUnsampledImageHandleDestroyExp if __use_win_types: - _urBindlessImagesUnsampledImageHandleDestroyExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_exp_image_handle_t ) + _urBindlessImagesUnsampledImageHandleDestroyExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, ur_exp_image_handle_t ) else: - _urBindlessImagesUnsampledImageHandleDestroyExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_exp_image_handle_t ) + _urBindlessImagesUnsampledImageHandleDestroyExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, ur_exp_image_handle_t ) ############################################################################### ## @brief Function-pointer for urBindlessImagesSampledImageHandleDestroyExp if __use_win_types: - _urBindlessImagesSampledImageHandleDestroyExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_exp_image_handle_t ) + _urBindlessImagesSampledImageHandleDestroyExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, ur_exp_image_handle_t ) else: - _urBindlessImagesSampledImageHandleDestroyExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_exp_image_handle_t ) + _urBindlessImagesSampledImageHandleDestroyExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, ur_exp_image_handle_t ) ############################################################################### ## @brief Function-pointer for urBindlessImagesImageAllocateExp if __use_win_types: - _urBindlessImagesImageAllocateExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), POINTER(ur_exp_image_mem_handle_t) ) + _urBindlessImagesImageAllocateExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), POINTER(ur_exp_image_mem_handle_t) ) else: - _urBindlessImagesImageAllocateExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), POINTER(ur_exp_image_mem_handle_t) ) + _urBindlessImagesImageAllocateExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), POINTER(ur_exp_image_mem_handle_t) ) ############################################################################### ## @brief Function-pointer for urBindlessImagesImageFreeExp if __use_win_types: - _urBindlessImagesImageFreeExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_exp_image_mem_handle_t ) + _urBindlessImagesImageFreeExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, ur_exp_image_mem_handle_t ) else: - _urBindlessImagesImageFreeExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_exp_image_mem_handle_t ) + _urBindlessImagesImageFreeExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, ur_exp_image_mem_handle_t ) ############################################################################### ## @brief Function-pointer for urBindlessImagesUnsampledImageCreateExp if __use_win_types: - _urBindlessImagesUnsampledImageCreateExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_exp_image_mem_handle_t, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), POINTER(ur_mem_handle_t), POINTER(ur_exp_image_handle_t) ) + _urBindlessImagesUnsampledImageCreateExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, ur_exp_image_mem_handle_t, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), POINTER(ur_mem_handle_t), POINTER(ur_exp_image_handle_t) ) else: - _urBindlessImagesUnsampledImageCreateExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_exp_image_mem_handle_t, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), POINTER(ur_mem_handle_t), POINTER(ur_exp_image_handle_t) ) + _urBindlessImagesUnsampledImageCreateExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, ur_exp_image_mem_handle_t, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), POINTER(ur_mem_handle_t), POINTER(ur_exp_image_handle_t) ) ############################################################################### ## @brief Function-pointer for urBindlessImagesSampledImageCreateExp if __use_win_types: - _urBindlessImagesSampledImageCreateExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_exp_image_mem_handle_t, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), ur_sampler_handle_t, POINTER(ur_mem_handle_t), POINTER(ur_exp_image_handle_t) ) + _urBindlessImagesSampledImageCreateExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, ur_exp_image_mem_handle_t, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), ur_sampler_handle_t, POINTER(ur_mem_handle_t), POINTER(ur_exp_image_handle_t) ) else: - _urBindlessImagesSampledImageCreateExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_exp_image_mem_handle_t, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), ur_sampler_handle_t, POINTER(ur_mem_handle_t), POINTER(ur_exp_image_handle_t) ) + _urBindlessImagesSampledImageCreateExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, ur_exp_image_mem_handle_t, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), ur_sampler_handle_t, POINTER(ur_mem_handle_t), POINTER(ur_exp_image_handle_t) ) ############################################################################### ## @brief Function-pointer for urBindlessImagesImageCopyExp if __use_win_types: - _urBindlessImagesImageCopyExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, c_void_p, c_void_p, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), ur_exp_image_copy_flags_t, c_ulong, POINTER(ur_event_handle_t), POINTER(ur_event_handle_t) ) + _urBindlessImagesImageCopyExp_t = WINFUNCTYPE( ur_result_t, ur_queue_handle_t, c_void_p, c_void_p, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), ur_exp_image_copy_flags_t, ur_rect_offset_t, ur_rect_offset_t, ur_rect_region_t, ur_rect_region_t, c_ulong, POINTER(ur_event_handle_t), POINTER(ur_event_handle_t) ) else: - _urBindlessImagesImageCopyExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, c_void_p, c_void_p, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), ur_exp_image_copy_flags_t, c_ulong, POINTER(ur_event_handle_t), POINTER(ur_event_handle_t) ) + _urBindlessImagesImageCopyExp_t = CFUNCTYPE( ur_result_t, ur_queue_handle_t, c_void_p, c_void_p, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), ur_exp_image_copy_flags_t, ur_rect_offset_t, ur_rect_offset_t, ur_rect_region_t, ur_rect_region_t, c_ulong, POINTER(ur_event_handle_t), POINTER(ur_event_handle_t) ) ############################################################################### ## @brief Function-pointer for urBindlessImagesImageGetInfoExp @@ -3100,51 +3247,51 @@ class ur_queue_dditable_t(Structure): ############################################################################### ## @brief Function-pointer for urBindlessImagesMipmapGetLevelExp if __use_win_types: - _urBindlessImagesMipmapGetLevelExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_exp_image_mem_handle_t, c_ulong, POINTER(ur_exp_image_mem_handle_t) ) + _urBindlessImagesMipmapGetLevelExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, ur_exp_image_mem_handle_t, c_ulong, POINTER(ur_exp_image_mem_handle_t) ) else: - _urBindlessImagesMipmapGetLevelExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_exp_image_mem_handle_t, c_ulong, POINTER(ur_exp_image_mem_handle_t) ) + _urBindlessImagesMipmapGetLevelExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, ur_exp_image_mem_handle_t, c_ulong, POINTER(ur_exp_image_mem_handle_t) ) ############################################################################### ## @brief Function-pointer for urBindlessImagesMipmapFreeExp if __use_win_types: - _urBindlessImagesMipmapFreeExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_exp_image_mem_handle_t ) + _urBindlessImagesMipmapFreeExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, ur_exp_image_mem_handle_t ) else: - _urBindlessImagesMipmapFreeExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_exp_image_mem_handle_t ) + _urBindlessImagesMipmapFreeExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, ur_exp_image_mem_handle_t ) ############################################################################### ## @brief Function-pointer for urBindlessImagesImportOpaqueFDExp if __use_win_types: - _urBindlessImagesImportOpaqueFDExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, c_size_t, c_ulong, POINTER(ur_exp_interop_mem_handle_t) ) + _urBindlessImagesImportOpaqueFDExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, c_size_t, POINTER(ur_exp_interop_mem_desc_t), POINTER(ur_exp_interop_mem_handle_t) ) else: - _urBindlessImagesImportOpaqueFDExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, c_size_t, c_ulong, POINTER(ur_exp_interop_mem_handle_t) ) + _urBindlessImagesImportOpaqueFDExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, c_size_t, POINTER(ur_exp_interop_mem_desc_t), POINTER(ur_exp_interop_mem_handle_t) ) ############################################################################### ## @brief Function-pointer for urBindlessImagesMapExternalArrayExp if __use_win_types: - _urBindlessImagesMapExternalArrayExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), ur_exp_interop_mem_handle_t, POINTER(ur_exp_image_handle_t) ) + _urBindlessImagesMapExternalArrayExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), ur_exp_interop_mem_handle_t, POINTER(ur_exp_image_mem_handle_t) ) else: - _urBindlessImagesMapExternalArrayExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), ur_exp_interop_mem_handle_t, POINTER(ur_exp_image_handle_t) ) + _urBindlessImagesMapExternalArrayExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, POINTER(ur_image_format_t), POINTER(ur_image_desc_t), ur_exp_interop_mem_handle_t, POINTER(ur_exp_image_mem_handle_t) ) ############################################################################### ## @brief Function-pointer for urBindlessImagesReleaseInteropExp if __use_win_types: - _urBindlessImagesReleaseInteropExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_exp_interop_mem_handle_t ) + _urBindlessImagesReleaseInteropExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, ur_exp_interop_mem_handle_t ) else: - _urBindlessImagesReleaseInteropExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_exp_interop_mem_handle_t ) + _urBindlessImagesReleaseInteropExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, ur_exp_interop_mem_handle_t ) ############################################################################### ## @brief Function-pointer for urBindlessImagesImportExternalSemaphoreOpaqueFDExp if __use_win_types: - _urBindlessImagesImportExternalSemaphoreOpaqueFDExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, c_ulong, POINTER(ur_exp_interop_semaphore_handle_t) ) + _urBindlessImagesImportExternalSemaphoreOpaqueFDExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, POINTER(ur_exp_interop_semaphore_desc_t), POINTER(ur_exp_interop_semaphore_handle_t) ) else: - _urBindlessImagesImportExternalSemaphoreOpaqueFDExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, c_ulong, POINTER(ur_exp_interop_semaphore_handle_t) ) + _urBindlessImagesImportExternalSemaphoreOpaqueFDExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, POINTER(ur_exp_interop_semaphore_desc_t), POINTER(ur_exp_interop_semaphore_handle_t) ) ############################################################################### ## @brief Function-pointer for urBindlessImagesDestroyExternalSemaphoreExp if __use_win_types: - _urBindlessImagesDestroyExternalSemaphoreExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_exp_interop_semaphore_handle_t ) + _urBindlessImagesDestroyExternalSemaphoreExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, ur_exp_interop_semaphore_handle_t ) else: - _urBindlessImagesDestroyExternalSemaphoreExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_exp_interop_semaphore_handle_t ) + _urBindlessImagesDestroyExternalSemaphoreExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_device_handle_t, ur_exp_interop_semaphore_handle_t ) ############################################################################### ## @brief Function-pointer for urBindlessImagesWaitExternalSemaphoreExp @@ -3439,9 +3586,9 @@ class ur_usm_p2p_exp_dditable_t(Structure): ############################################################################### ## @brief Function-pointer for urInit if __use_win_types: - _urInit_t = WINFUNCTYPE( ur_result_t, ur_device_init_flags_t ) + _urInit_t = WINFUNCTYPE( ur_result_t, ur_device_init_flags_t, ur_loader_config_handle_t ) else: - _urInit_t = CFUNCTYPE( ur_result_t, ur_device_init_flags_t ) + _urInit_t = CFUNCTYPE( ur_result_t, ur_device_init_flags_t, ur_loader_config_handle_t ) ############################################################################### ## @brief Function-pointer for urTearDown @@ -3450,13 +3597,53 @@ class ur_usm_p2p_exp_dditable_t(Structure): else: _urTearDown_t = CFUNCTYPE( ur_result_t, c_void_p ) +############################################################################### +## @brief Function-pointer for urAdapterGet +if __use_win_types: + _urAdapterGet_t = WINFUNCTYPE( ur_result_t, c_ulong, POINTER(ur_adapter_handle_t), POINTER(c_ulong) ) +else: + _urAdapterGet_t = CFUNCTYPE( ur_result_t, c_ulong, POINTER(ur_adapter_handle_t), POINTER(c_ulong) ) + +############################################################################### +## @brief Function-pointer for urAdapterRelease +if __use_win_types: + _urAdapterRelease_t = WINFUNCTYPE( ur_result_t, ur_adapter_handle_t ) +else: + _urAdapterRelease_t = CFUNCTYPE( ur_result_t, ur_adapter_handle_t ) + +############################################################################### +## @brief Function-pointer for urAdapterRetain +if __use_win_types: + _urAdapterRetain_t = WINFUNCTYPE( ur_result_t, ur_adapter_handle_t ) +else: + _urAdapterRetain_t = CFUNCTYPE( ur_result_t, ur_adapter_handle_t ) + +############################################################################### +## @brief Function-pointer for urAdapterGetLastError +if __use_win_types: + _urAdapterGetLastError_t = WINFUNCTYPE( ur_result_t, ur_adapter_handle_t, POINTER(c_char_p), POINTER(c_long) ) +else: + _urAdapterGetLastError_t = CFUNCTYPE( ur_result_t, ur_adapter_handle_t, POINTER(c_char_p), POINTER(c_long) ) + +############################################################################### +## @brief Function-pointer for urAdapterGetInfo +if __use_win_types: + _urAdapterGetInfo_t = WINFUNCTYPE( ur_result_t, ur_adapter_handle_t, ur_adapter_info_t, c_size_t, c_void_p, POINTER(c_size_t) ) +else: + _urAdapterGetInfo_t = CFUNCTYPE( ur_result_t, ur_adapter_handle_t, ur_adapter_info_t, c_size_t, c_void_p, POINTER(c_size_t) ) + ############################################################################### ## @brief Table of Global functions pointers class ur_global_dditable_t(Structure): _fields_ = [ ("pfnInit", c_void_p), ## _urInit_t - ("pfnTearDown", c_void_p) ## _urTearDown_t + ("pfnTearDown", c_void_p), ## _urTearDown_t + ("pfnAdapterGet", c_void_p), ## _urAdapterGet_t + ("pfnAdapterRelease", c_void_p), ## _urAdapterRelease_t + ("pfnAdapterRetain", c_void_p), ## _urAdapterRetain_t + ("pfnAdapterGetLastError", c_void_p), ## _urAdapterGetLastError_t + ("pfnAdapterGetInfo", c_void_p) ## _urAdapterGetInfo_t ] ############################################################################### @@ -3604,6 +3791,7 @@ class ur_device_dditable_t(Structure): ############################################################################### class ur_dditable_t(Structure): _fields_ = [ + ("LoaderConfig", ur_loader_config_dditable_t), ("Platform", ur_platform_dditable_t), ("Context", ur_context_dditable_t), ("Event", ur_event_dditable_t), @@ -3652,7 +3840,6 @@ def __init__(self, version : ur_api_version_t): self.urPlatformGetInfo = _urPlatformGetInfo_t(self.__dditable.Platform.pfnGetInfo) self.urPlatformGetNativeHandle = _urPlatformGetNativeHandle_t(self.__dditable.Platform.pfnGetNativeHandle) self.urPlatformCreateWithNativeHandle = _urPlatformCreateWithNativeHandle_t(self.__dditable.Platform.pfnCreateWithNativeHandle) - self.urPlatformGetLastError = _urPlatformGetLastError_t(self.__dditable.Platform.pfnGetLastError) self.urPlatformGetApiVersion = _urPlatformGetApiVersion_t(self.__dditable.Platform.pfnGetApiVersion) self.urPlatformGetBackendOption = _urPlatformGetBackendOption_t(self.__dditable.Platform.pfnGetBackendOption) @@ -3932,6 +4119,11 @@ def __init__(self, version : ur_api_version_t): # attach function interface to function address self.urInit = _urInit_t(self.__dditable.Global.pfnInit) self.urTearDown = _urTearDown_t(self.__dditable.Global.pfnTearDown) + self.urAdapterGet = _urAdapterGet_t(self.__dditable.Global.pfnAdapterGet) + self.urAdapterRelease = _urAdapterRelease_t(self.__dditable.Global.pfnAdapterRelease) + self.urAdapterRetain = _urAdapterRetain_t(self.__dditable.Global.pfnAdapterRetain) + self.urAdapterGetLastError = _urAdapterGetLastError_t(self.__dditable.Global.pfnAdapterGetLastError) + self.urAdapterGetInfo = _urAdapterGetInfo_t(self.__dditable.Global.pfnAdapterGetInfo) # call driver to get function pointers VirtualMem = ur_virtual_mem_dditable_t() diff --git a/include/ur_api.h b/include/ur_api.h index 2f15f4e1d1..1ff0ba0905 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -24,6 +24,245 @@ extern "C" { #endif +// Intel 'oneAPI' Unified Runtime function registry +#if !defined(__GNUC__) +#pragma region registry +#endif +/////////////////////////////////////////////////////////////////////////////// +/// @brief Defines unique stable identifiers for all functions +typedef enum ur_function_t { + UR_FUNCTION_CONTEXT_CREATE = 1, ///< Enumerator for ::urContextCreate + UR_FUNCTION_CONTEXT_RETAIN = 2, ///< Enumerator for ::urContextRetain + UR_FUNCTION_CONTEXT_RELEASE = 3, ///< Enumerator for ::urContextRelease + UR_FUNCTION_CONTEXT_GET_INFO = 4, ///< Enumerator for ::urContextGetInfo + UR_FUNCTION_CONTEXT_GET_NATIVE_HANDLE = 5, ///< Enumerator for ::urContextGetNativeHandle + UR_FUNCTION_CONTEXT_CREATE_WITH_NATIVE_HANDLE = 6, ///< Enumerator for ::urContextCreateWithNativeHandle + UR_FUNCTION_CONTEXT_SET_EXTENDED_DELETER = 7, ///< Enumerator for ::urContextSetExtendedDeleter + UR_FUNCTION_DEVICE_GET = 8, ///< Enumerator for ::urDeviceGet + UR_FUNCTION_DEVICE_GET_INFO = 9, ///< Enumerator for ::urDeviceGetInfo + UR_FUNCTION_DEVICE_RETAIN = 10, ///< Enumerator for ::urDeviceRetain + UR_FUNCTION_DEVICE_RELEASE = 11, ///< Enumerator for ::urDeviceRelease + UR_FUNCTION_DEVICE_PARTITION = 12, ///< Enumerator for ::urDevicePartition + UR_FUNCTION_DEVICE_SELECT_BINARY = 13, ///< Enumerator for ::urDeviceSelectBinary + UR_FUNCTION_DEVICE_GET_NATIVE_HANDLE = 14, ///< Enumerator for ::urDeviceGetNativeHandle + UR_FUNCTION_DEVICE_CREATE_WITH_NATIVE_HANDLE = 15, ///< Enumerator for ::urDeviceCreateWithNativeHandle + UR_FUNCTION_DEVICE_GET_GLOBAL_TIMESTAMPS = 16, ///< Enumerator for ::urDeviceGetGlobalTimestamps + UR_FUNCTION_ENQUEUE_KERNEL_LAUNCH = 17, ///< Enumerator for ::urEnqueueKernelLaunch + UR_FUNCTION_ENQUEUE_EVENTS_WAIT = 18, ///< Enumerator for ::urEnqueueEventsWait + UR_FUNCTION_ENQUEUE_EVENTS_WAIT_WITH_BARRIER = 19, ///< Enumerator for ::urEnqueueEventsWaitWithBarrier + UR_FUNCTION_ENQUEUE_MEM_BUFFER_READ = 20, ///< Enumerator for ::urEnqueueMemBufferRead + UR_FUNCTION_ENQUEUE_MEM_BUFFER_WRITE = 21, ///< Enumerator for ::urEnqueueMemBufferWrite + UR_FUNCTION_ENQUEUE_MEM_BUFFER_READ_RECT = 22, ///< Enumerator for ::urEnqueueMemBufferReadRect + UR_FUNCTION_ENQUEUE_MEM_BUFFER_WRITE_RECT = 23, ///< Enumerator for ::urEnqueueMemBufferWriteRect + UR_FUNCTION_ENQUEUE_MEM_BUFFER_COPY = 24, ///< Enumerator for ::urEnqueueMemBufferCopy + UR_FUNCTION_ENQUEUE_MEM_BUFFER_COPY_RECT = 25, ///< Enumerator for ::urEnqueueMemBufferCopyRect + UR_FUNCTION_ENQUEUE_MEM_BUFFER_FILL = 26, ///< Enumerator for ::urEnqueueMemBufferFill + UR_FUNCTION_ENQUEUE_MEM_IMAGE_READ = 27, ///< Enumerator for ::urEnqueueMemImageRead + UR_FUNCTION_ENQUEUE_MEM_IMAGE_WRITE = 28, ///< Enumerator for ::urEnqueueMemImageWrite + UR_FUNCTION_ENQUEUE_MEM_IMAGE_COPY = 29, ///< Enumerator for ::urEnqueueMemImageCopy + UR_FUNCTION_ENQUEUE_MEM_BUFFER_MAP = 30, ///< Enumerator for ::urEnqueueMemBufferMap + UR_FUNCTION_ENQUEUE_MEM_UNMAP = 31, ///< Enumerator for ::urEnqueueMemUnmap + UR_FUNCTION_ENQUEUE_USM_FILL = 32, ///< Enumerator for ::urEnqueueUSMFill + UR_FUNCTION_ENQUEUE_USM_MEMCPY = 33, ///< Enumerator for ::urEnqueueUSMMemcpy + UR_FUNCTION_ENQUEUE_USM_PREFETCH = 34, ///< Enumerator for ::urEnqueueUSMPrefetch + UR_FUNCTION_ENQUEUE_USM_ADVISE = 35, ///< Enumerator for ::urEnqueueUSMAdvise + UR_FUNCTION_ENQUEUE_DEVICE_GLOBAL_VARIABLE_WRITE = 38, ///< Enumerator for ::urEnqueueDeviceGlobalVariableWrite + UR_FUNCTION_ENQUEUE_DEVICE_GLOBAL_VARIABLE_READ = 39, ///< Enumerator for ::urEnqueueDeviceGlobalVariableRead + UR_FUNCTION_EVENT_GET_INFO = 40, ///< Enumerator for ::urEventGetInfo + UR_FUNCTION_EVENT_GET_PROFILING_INFO = 41, ///< Enumerator for ::urEventGetProfilingInfo + UR_FUNCTION_EVENT_WAIT = 42, ///< Enumerator for ::urEventWait + UR_FUNCTION_EVENT_RETAIN = 43, ///< Enumerator for ::urEventRetain + UR_FUNCTION_EVENT_RELEASE = 44, ///< Enumerator for ::urEventRelease + UR_FUNCTION_EVENT_GET_NATIVE_HANDLE = 45, ///< Enumerator for ::urEventGetNativeHandle + UR_FUNCTION_EVENT_CREATE_WITH_NATIVE_HANDLE = 46, ///< Enumerator for ::urEventCreateWithNativeHandle + UR_FUNCTION_EVENT_SET_CALLBACK = 47, ///< Enumerator for ::urEventSetCallback + UR_FUNCTION_KERNEL_CREATE = 48, ///< Enumerator for ::urKernelCreate + UR_FUNCTION_KERNEL_SET_ARG_VALUE = 49, ///< Enumerator for ::urKernelSetArgValue + UR_FUNCTION_KERNEL_SET_ARG_LOCAL = 50, ///< Enumerator for ::urKernelSetArgLocal + UR_FUNCTION_KERNEL_GET_INFO = 51, ///< Enumerator for ::urKernelGetInfo + UR_FUNCTION_KERNEL_GET_GROUP_INFO = 52, ///< Enumerator for ::urKernelGetGroupInfo + UR_FUNCTION_KERNEL_GET_SUB_GROUP_INFO = 53, ///< Enumerator for ::urKernelGetSubGroupInfo + UR_FUNCTION_KERNEL_RETAIN = 54, ///< Enumerator for ::urKernelRetain + UR_FUNCTION_KERNEL_RELEASE = 55, ///< Enumerator for ::urKernelRelease + UR_FUNCTION_KERNEL_SET_ARG_POINTER = 56, ///< Enumerator for ::urKernelSetArgPointer + UR_FUNCTION_KERNEL_SET_EXEC_INFO = 57, ///< Enumerator for ::urKernelSetExecInfo + UR_FUNCTION_KERNEL_SET_ARG_SAMPLER = 58, ///< Enumerator for ::urKernelSetArgSampler + UR_FUNCTION_KERNEL_SET_ARG_MEM_OBJ = 59, ///< Enumerator for ::urKernelSetArgMemObj + UR_FUNCTION_KERNEL_SET_SPECIALIZATION_CONSTANTS = 60, ///< Enumerator for ::urKernelSetSpecializationConstants + UR_FUNCTION_KERNEL_GET_NATIVE_HANDLE = 61, ///< Enumerator for ::urKernelGetNativeHandle + UR_FUNCTION_KERNEL_CREATE_WITH_NATIVE_HANDLE = 62, ///< Enumerator for ::urKernelCreateWithNativeHandle + UR_FUNCTION_MEM_IMAGE_CREATE = 63, ///< Enumerator for ::urMemImageCreate + UR_FUNCTION_MEM_BUFFER_CREATE = 64, ///< Enumerator for ::urMemBufferCreate + UR_FUNCTION_MEM_RETAIN = 65, ///< Enumerator for ::urMemRetain + UR_FUNCTION_MEM_RELEASE = 66, ///< Enumerator for ::urMemRelease + UR_FUNCTION_MEM_BUFFER_PARTITION = 67, ///< Enumerator for ::urMemBufferPartition + UR_FUNCTION_MEM_GET_NATIVE_HANDLE = 68, ///< Enumerator for ::urMemGetNativeHandle + UR_FUNCTION_ENQUEUE_READ_HOST_PIPE = 69, ///< Enumerator for ::urEnqueueReadHostPipe + UR_FUNCTION_MEM_GET_INFO = 70, ///< Enumerator for ::urMemGetInfo + UR_FUNCTION_MEM_IMAGE_GET_INFO = 71, ///< Enumerator for ::urMemImageGetInfo + UR_FUNCTION_PLATFORM_GET = 72, ///< Enumerator for ::urPlatformGet + UR_FUNCTION_PLATFORM_GET_INFO = 73, ///< Enumerator for ::urPlatformGetInfo + UR_FUNCTION_PLATFORM_GET_API_VERSION = 74, ///< Enumerator for ::urPlatformGetApiVersion + UR_FUNCTION_PLATFORM_GET_NATIVE_HANDLE = 75, ///< Enumerator for ::urPlatformGetNativeHandle + UR_FUNCTION_PLATFORM_CREATE_WITH_NATIVE_HANDLE = 76, ///< Enumerator for ::urPlatformCreateWithNativeHandle + UR_FUNCTION_PROGRAM_CREATE_WITH_IL = 78, ///< Enumerator for ::urProgramCreateWithIL + UR_FUNCTION_PROGRAM_CREATE_WITH_BINARY = 79, ///< Enumerator for ::urProgramCreateWithBinary + UR_FUNCTION_PROGRAM_BUILD = 80, ///< Enumerator for ::urProgramBuild + UR_FUNCTION_PROGRAM_COMPILE = 81, ///< Enumerator for ::urProgramCompile + UR_FUNCTION_PROGRAM_LINK = 82, ///< Enumerator for ::urProgramLink + UR_FUNCTION_PROGRAM_RETAIN = 83, ///< Enumerator for ::urProgramRetain + UR_FUNCTION_PROGRAM_RELEASE = 84, ///< Enumerator for ::urProgramRelease + UR_FUNCTION_PROGRAM_GET_FUNCTION_POINTER = 85, ///< Enumerator for ::urProgramGetFunctionPointer + UR_FUNCTION_PROGRAM_GET_INFO = 86, ///< Enumerator for ::urProgramGetInfo + UR_FUNCTION_PROGRAM_GET_BUILD_INFO = 87, ///< Enumerator for ::urProgramGetBuildInfo + UR_FUNCTION_PROGRAM_SET_SPECIALIZATION_CONSTANTS = 88, ///< Enumerator for ::urProgramSetSpecializationConstants + UR_FUNCTION_PROGRAM_GET_NATIVE_HANDLE = 89, ///< Enumerator for ::urProgramGetNativeHandle + UR_FUNCTION_PROGRAM_CREATE_WITH_NATIVE_HANDLE = 90, ///< Enumerator for ::urProgramCreateWithNativeHandle + UR_FUNCTION_QUEUE_GET_INFO = 91, ///< Enumerator for ::urQueueGetInfo + UR_FUNCTION_QUEUE_CREATE = 92, ///< Enumerator for ::urQueueCreate + UR_FUNCTION_QUEUE_RETAIN = 93, ///< Enumerator for ::urQueueRetain + UR_FUNCTION_QUEUE_RELEASE = 94, ///< Enumerator for ::urQueueRelease + UR_FUNCTION_QUEUE_GET_NATIVE_HANDLE = 95, ///< Enumerator for ::urQueueGetNativeHandle + UR_FUNCTION_QUEUE_CREATE_WITH_NATIVE_HANDLE = 96, ///< Enumerator for ::urQueueCreateWithNativeHandle + UR_FUNCTION_QUEUE_FINISH = 97, ///< Enumerator for ::urQueueFinish + UR_FUNCTION_QUEUE_FLUSH = 98, ///< Enumerator for ::urQueueFlush + UR_FUNCTION_INIT = 99, ///< Enumerator for ::urInit + UR_FUNCTION_TEAR_DOWN = 100, ///< Enumerator for ::urTearDown + UR_FUNCTION_SAMPLER_CREATE = 101, ///< Enumerator for ::urSamplerCreate + UR_FUNCTION_SAMPLER_RETAIN = 102, ///< Enumerator for ::urSamplerRetain + UR_FUNCTION_SAMPLER_RELEASE = 103, ///< Enumerator for ::urSamplerRelease + UR_FUNCTION_SAMPLER_GET_INFO = 104, ///< Enumerator for ::urSamplerGetInfo + UR_FUNCTION_SAMPLER_GET_NATIVE_HANDLE = 105, ///< Enumerator for ::urSamplerGetNativeHandle + UR_FUNCTION_SAMPLER_CREATE_WITH_NATIVE_HANDLE = 106, ///< Enumerator for ::urSamplerCreateWithNativeHandle + UR_FUNCTION_USM_HOST_ALLOC = 107, ///< Enumerator for ::urUSMHostAlloc + UR_FUNCTION_USM_DEVICE_ALLOC = 108, ///< Enumerator for ::urUSMDeviceAlloc + UR_FUNCTION_USM_SHARED_ALLOC = 109, ///< Enumerator for ::urUSMSharedAlloc + UR_FUNCTION_USM_FREE = 110, ///< Enumerator for ::urUSMFree + UR_FUNCTION_USM_GET_MEM_ALLOC_INFO = 111, ///< Enumerator for ::urUSMGetMemAllocInfo + UR_FUNCTION_USM_POOL_CREATE = 112, ///< Enumerator for ::urUSMPoolCreate + UR_FUNCTION_COMMAND_BUFFER_CREATE_EXP = 113, ///< Enumerator for ::urCommandBufferCreateExp + UR_FUNCTION_PLATFORM_GET_BACKEND_OPTION = 114, ///< Enumerator for ::urPlatformGetBackendOption + UR_FUNCTION_MEM_BUFFER_CREATE_WITH_NATIVE_HANDLE = 115, ///< Enumerator for ::urMemBufferCreateWithNativeHandle + UR_FUNCTION_MEM_IMAGE_CREATE_WITH_NATIVE_HANDLE = 116, ///< Enumerator for ::urMemImageCreateWithNativeHandle + UR_FUNCTION_ENQUEUE_WRITE_HOST_PIPE = 117, ///< Enumerator for ::urEnqueueWriteHostPipe + UR_FUNCTION_USM_POOL_RETAIN = 118, ///< Enumerator for ::urUSMPoolRetain + UR_FUNCTION_USM_POOL_RELEASE = 119, ///< Enumerator for ::urUSMPoolRelease + UR_FUNCTION_USM_POOL_GET_INFO = 120, ///< Enumerator for ::urUSMPoolGetInfo + UR_FUNCTION_COMMAND_BUFFER_RETAIN_EXP = 121, ///< Enumerator for ::urCommandBufferRetainExp + UR_FUNCTION_COMMAND_BUFFER_RELEASE_EXP = 122, ///< Enumerator for ::urCommandBufferReleaseExp + UR_FUNCTION_COMMAND_BUFFER_FINALIZE_EXP = 123, ///< Enumerator for ::urCommandBufferFinalizeExp + UR_FUNCTION_COMMAND_BUFFER_APPEND_KERNEL_LAUNCH_EXP = 125, ///< Enumerator for ::urCommandBufferAppendKernelLaunchExp + UR_FUNCTION_COMMAND_BUFFER_ENQUEUE_EXP = 128, ///< Enumerator for ::urCommandBufferEnqueueExp + UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMCPY_USM_EXP = 129, ///< Enumerator for ::urCommandBufferAppendMemcpyUSMExp + UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_COPY_EXP = 130, ///< Enumerator for ::urCommandBufferAppendMembufferCopyExp + UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_COPY_RECT_EXP = 131, ///< Enumerator for ::urCommandBufferAppendMembufferCopyRectExp + UR_FUNCTION_USM_PITCHED_ALLOC_EXP = 132, ///< Enumerator for ::urUSMPitchedAllocExp + UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_HANDLE_DESTROY_EXP = 133, ///< Enumerator for ::urBindlessImagesUnsampledImageHandleDestroyExp + UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_HANDLE_DESTROY_EXP = 134, ///< Enumerator for ::urBindlessImagesSampledImageHandleDestroyExp + UR_FUNCTION_BINDLESS_IMAGES_IMAGE_ALLOCATE_EXP = 135, ///< Enumerator for ::urBindlessImagesImageAllocateExp + UR_FUNCTION_BINDLESS_IMAGES_IMAGE_FREE_EXP = 136, ///< Enumerator for ::urBindlessImagesImageFreeExp + UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_CREATE_EXP = 137, ///< Enumerator for ::urBindlessImagesUnsampledImageCreateExp + UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_CREATE_EXP = 138, ///< Enumerator for ::urBindlessImagesSampledImageCreateExp + UR_FUNCTION_BINDLESS_IMAGES_IMAGE_COPY_EXP = 139, ///< Enumerator for ::urBindlessImagesImageCopyExp + UR_FUNCTION_BINDLESS_IMAGES_IMAGE_GET_INFO_EXP = 140, ///< Enumerator for ::urBindlessImagesImageGetInfoExp + UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_GET_LEVEL_EXP = 141, ///< Enumerator for ::urBindlessImagesMipmapGetLevelExp + UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_FREE_EXP = 142, ///< Enumerator for ::urBindlessImagesMipmapFreeExp + UR_FUNCTION_BINDLESS_IMAGES_IMPORT_OPAQUE_FD_EXP = 143, ///< Enumerator for ::urBindlessImagesImportOpaqueFDExp + UR_FUNCTION_BINDLESS_IMAGES_MAP_EXTERNAL_ARRAY_EXP = 144, ///< Enumerator for ::urBindlessImagesMapExternalArrayExp + UR_FUNCTION_BINDLESS_IMAGES_RELEASE_INTEROP_EXP = 145, ///< Enumerator for ::urBindlessImagesReleaseInteropExp + UR_FUNCTION_BINDLESS_IMAGES_IMPORT_EXTERNAL_SEMAPHORE_OPAQUE_FD_EXP = 146, ///< Enumerator for ::urBindlessImagesImportExternalSemaphoreOpaqueFDExp + UR_FUNCTION_BINDLESS_IMAGES_DESTROY_EXTERNAL_SEMAPHORE_EXP = 147, ///< Enumerator for ::urBindlessImagesDestroyExternalSemaphoreExp + UR_FUNCTION_BINDLESS_IMAGES_WAIT_EXTERNAL_SEMAPHORE_EXP = 148, ///< Enumerator for ::urBindlessImagesWaitExternalSemaphoreExp + UR_FUNCTION_BINDLESS_IMAGES_SIGNAL_EXTERNAL_SEMAPHORE_EXP = 149, ///< Enumerator for ::urBindlessImagesSignalExternalSemaphoreExp + UR_FUNCTION_ENQUEUE_USM_FILL_2D = 151, ///< Enumerator for ::urEnqueueUSMFill2D + UR_FUNCTION_ENQUEUE_USM_MEMCPY_2D = 152, ///< Enumerator for ::urEnqueueUSMMemcpy2D + UR_FUNCTION_VIRTUAL_MEM_GRANULARITY_GET_INFO = 153, ///< Enumerator for ::urVirtualMemGranularityGetInfo + UR_FUNCTION_VIRTUAL_MEM_RESERVE = 154, ///< Enumerator for ::urVirtualMemReserve + UR_FUNCTION_VIRTUAL_MEM_FREE = 155, ///< Enumerator for ::urVirtualMemFree + UR_FUNCTION_VIRTUAL_MEM_MAP = 156, ///< Enumerator for ::urVirtualMemMap + UR_FUNCTION_VIRTUAL_MEM_UNMAP = 157, ///< Enumerator for ::urVirtualMemUnmap + UR_FUNCTION_VIRTUAL_MEM_SET_ACCESS = 158, ///< Enumerator for ::urVirtualMemSetAccess + UR_FUNCTION_VIRTUAL_MEM_GET_INFO = 159, ///< Enumerator for ::urVirtualMemGetInfo + UR_FUNCTION_PHYSICAL_MEM_CREATE = 160, ///< Enumerator for ::urPhysicalMemCreate + UR_FUNCTION_PHYSICAL_MEM_RETAIN = 161, ///< Enumerator for ::urPhysicalMemRetain + UR_FUNCTION_PHYSICAL_MEM_RELEASE = 162, ///< Enumerator for ::urPhysicalMemRelease + UR_FUNCTION_USM_IMPORT_EXP = 163, ///< Enumerator for ::urUSMImportExp + UR_FUNCTION_USM_RELEASE_EXP = 164, ///< Enumerator for ::urUSMReleaseExp + UR_FUNCTION_USM_P2P_ENABLE_PEER_ACCESS_EXP = 165, ///< Enumerator for ::urUsmP2PEnablePeerAccessExp + UR_FUNCTION_USM_P2P_DISABLE_PEER_ACCESS_EXP = 166, ///< Enumerator for ::urUsmP2PDisablePeerAccessExp + UR_FUNCTION_USM_P2P_PEER_ACCESS_GET_INFO_EXP = 167, ///< Enumerator for ::urUsmP2PPeerAccessGetInfoExp + UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_WRITE_EXP = 168, ///< Enumerator for ::urCommandBufferAppendMembufferWriteExp + UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_READ_EXP = 169, ///< Enumerator for ::urCommandBufferAppendMembufferReadExp + UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_WRITE_RECT_EXP = 170, ///< Enumerator for ::urCommandBufferAppendMembufferWriteRectExp + UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_READ_RECT_EXP = 171, ///< Enumerator for ::urCommandBufferAppendMembufferReadRectExp + UR_FUNCTION_LOADER_CONFIG_CREATE = 172, ///< Enumerator for ::urLoaderConfigCreate + UR_FUNCTION_LOADER_CONFIG_RELEASE = 173, ///< Enumerator for ::urLoaderConfigRelease + UR_FUNCTION_LOADER_CONFIG_RETAIN = 174, ///< Enumerator for ::urLoaderConfigRetain + UR_FUNCTION_LOADER_CONFIG_GET_INFO = 175, ///< Enumerator for ::urLoaderConfigGetInfo + UR_FUNCTION_LOADER_CONFIG_ENABLE_LAYER = 176, ///< Enumerator for ::urLoaderConfigEnableLayer + UR_FUNCTION_ADAPTER_RELEASE = 177, ///< Enumerator for ::urAdapterRelease + UR_FUNCTION_ADAPTER_GET = 178, ///< Enumerator for ::urAdapterGet + UR_FUNCTION_ADAPTER_RETAIN = 179, ///< Enumerator for ::urAdapterRetain + UR_FUNCTION_ADAPTER_GET_LAST_ERROR = 180, ///< Enumerator for ::urAdapterGetLastError + UR_FUNCTION_ADAPTER_GET_INFO = 181, ///< Enumerator for ::urAdapterGetInfo + /// @cond + UR_FUNCTION_FORCE_UINT32 = 0x7fffffff + /// @endcond + +} ur_function_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Defines structure types +typedef enum ur_structure_type_t { + UR_STRUCTURE_TYPE_CONTEXT_PROPERTIES = 0, ///< ::ur_context_properties_t + UR_STRUCTURE_TYPE_IMAGE_DESC = 1, ///< ::ur_image_desc_t + UR_STRUCTURE_TYPE_BUFFER_PROPERTIES = 2, ///< ::ur_buffer_properties_t + UR_STRUCTURE_TYPE_BUFFER_REGION = 3, ///< ::ur_buffer_region_t + UR_STRUCTURE_TYPE_BUFFER_CHANNEL_PROPERTIES = 4, ///< ::ur_buffer_channel_properties_t + UR_STRUCTURE_TYPE_BUFFER_ALLOC_LOCATION_PROPERTIES = 5, ///< ::ur_buffer_alloc_location_properties_t + UR_STRUCTURE_TYPE_PROGRAM_PROPERTIES = 6, ///< ::ur_program_properties_t + UR_STRUCTURE_TYPE_USM_DESC = 7, ///< ::ur_usm_desc_t + UR_STRUCTURE_TYPE_USM_HOST_DESC = 8, ///< ::ur_usm_host_desc_t + UR_STRUCTURE_TYPE_USM_DEVICE_DESC = 9, ///< ::ur_usm_device_desc_t + UR_STRUCTURE_TYPE_USM_POOL_DESC = 10, ///< ::ur_usm_pool_desc_t + UR_STRUCTURE_TYPE_USM_POOL_LIMITS_DESC = 11, ///< ::ur_usm_pool_limits_desc_t + UR_STRUCTURE_TYPE_DEVICE_BINARY = 12, ///< ::ur_device_binary_t + UR_STRUCTURE_TYPE_SAMPLER_DESC = 13, ///< ::ur_sampler_desc_t + UR_STRUCTURE_TYPE_QUEUE_PROPERTIES = 14, ///< ::ur_queue_properties_t + UR_STRUCTURE_TYPE_QUEUE_INDEX_PROPERTIES = 15, ///< ::ur_queue_index_properties_t + UR_STRUCTURE_TYPE_CONTEXT_NATIVE_PROPERTIES = 16, ///< ::ur_context_native_properties_t + UR_STRUCTURE_TYPE_KERNEL_NATIVE_PROPERTIES = 17, ///< ::ur_kernel_native_properties_t + UR_STRUCTURE_TYPE_QUEUE_NATIVE_PROPERTIES = 18, ///< ::ur_queue_native_properties_t + UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES = 19, ///< ::ur_mem_native_properties_t + UR_STRUCTURE_TYPE_EVENT_NATIVE_PROPERTIES = 20, ///< ::ur_event_native_properties_t + UR_STRUCTURE_TYPE_PLATFORM_NATIVE_PROPERTIES = 21, ///< ::ur_platform_native_properties_t + UR_STRUCTURE_TYPE_DEVICE_NATIVE_PROPERTIES = 22, ///< ::ur_device_native_properties_t + UR_STRUCTURE_TYPE_PROGRAM_NATIVE_PROPERTIES = 23, ///< ::ur_program_native_properties_t + UR_STRUCTURE_TYPE_SAMPLER_NATIVE_PROPERTIES = 24, ///< ::ur_sampler_native_properties_t + UR_STRUCTURE_TYPE_QUEUE_NATIVE_DESC = 25, ///< ::ur_queue_native_desc_t + UR_STRUCTURE_TYPE_DEVICE_PARTITION_PROPERTIES = 26, ///< ::ur_device_partition_properties_t + UR_STRUCTURE_TYPE_KERNEL_ARG_MEM_OBJ_PROPERTIES = 27, ///< ::ur_kernel_arg_mem_obj_properties_t + UR_STRUCTURE_TYPE_PHYSICAL_MEM_PROPERTIES = 28, ///< ::ur_physical_mem_properties_t + UR_STRUCTURE_TYPE_KERNEL_ARG_POINTER_PROPERTIES = 29, ///< ::ur_kernel_arg_pointer_properties_t + UR_STRUCTURE_TYPE_KERNEL_ARG_SAMPLER_PROPERTIES = 30, ///< ::ur_kernel_arg_sampler_properties_t + UR_STRUCTURE_TYPE_KERNEL_EXEC_INFO_PROPERTIES = 31, ///< ::ur_kernel_exec_info_properties_t + UR_STRUCTURE_TYPE_KERNEL_ARG_VALUE_PROPERTIES = 32, ///< ::ur_kernel_arg_value_properties_t + UR_STRUCTURE_TYPE_KERNEL_ARG_LOCAL_PROPERTIES = 33, ///< ::ur_kernel_arg_local_properties_t + UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC = 0x1000, ///< ::ur_exp_command_buffer_desc_t + UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES = 0x2000, ///< ::ur_exp_sampler_mip_properties_t + UR_STRUCTURE_TYPE_EXP_INTEROP_MEM_DESC = 0x2001, ///< ::ur_exp_interop_mem_desc_t + UR_STRUCTURE_TYPE_EXP_INTEROP_SEMAPHORE_DESC = 0x2002, ///< ::ur_exp_interop_semaphore_desc_t + UR_STRUCTURE_TYPE_EXP_FILE_DESCRIPTOR = 0x2003, ///< ::ur_exp_file_descriptor_t + UR_STRUCTURE_TYPE_EXP_WIN32_HANDLE = 0x2004, ///< ::ur_exp_win32_handle_t + /// @cond + UR_STRUCTURE_TYPE_FORCE_UINT32 = 0x7fffffff + /// @endcond + +} ur_structure_type_t; + +#if !defined(__GNUC__) +#pragma endregion +#endif // Intel 'oneAPI' Unified Runtime API common types #if !defined(__GNUC__) #pragma region common @@ -88,6 +327,14 @@ extern "C" { /// @brief compiler-independent type typedef uint8_t ur_bool_t; +/////////////////////////////////////////////////////////////////////////////// +/// @brief Handle of a loader config object +typedef struct ur_loader_config_handle_t_ *ur_loader_config_handle_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Handle of an adapter instance +typedef struct ur_adapter_handle_t_ *ur_adapter_handle_t; + /////////////////////////////////////////////////////////////////////////////// /// @brief Handle of a platform instance typedef struct ur_platform_handle_t_ *ur_platform_handle_t; @@ -165,7 +412,7 @@ typedef enum ur_result_t { UR_RESULT_ERROR_DEVICE_LOST = 20, ///< Device hung, reset, was removed, or adapter update occurred UR_RESULT_ERROR_DEVICE_REQUIRES_RESET = 21, ///< Device requires a reset UR_RESULT_ERROR_DEVICE_IN_LOW_POWER_STATE = 22, ///< Device currently in low power state - UR_RESULT_ERROR_DEVICE_PARTITION_FAILED = 23, ///< Device paritioning failed + UR_RESULT_ERROR_DEVICE_PARTITION_FAILED = 23, ///< Device partitioning failed UR_RESULT_ERROR_INVALID_DEVICE_PARTITION_COUNT = 24, ///< Invalid counts provided with ::UR_DEVICE_PARTITION_BY_COUNTS UR_RESULT_ERROR_INVALID_WORK_ITEM_SIZE = 25, ///< Invalid work item size UR_RESULT_ERROR_INVALID_WORK_DIMENSION = 26, ///< Invalid work dimension @@ -181,7 +428,8 @@ typedef enum ur_result_t { UR_RESULT_ERROR_IMAGE_FORMAT_NOT_SUPPORTED = 35, ///< Image format not supported UR_RESULT_ERROR_MEM_OBJECT_ALLOCATION_FAILURE = 36, ///< Memory object allocation failure UR_RESULT_ERROR_INVALID_PROGRAM_EXECUTABLE = 37, ///< Program object parameter is invalid. - UR_RESULT_ERROR_UNINITIALIZED = 38, ///< [Validation] adapter is not initialized + UR_RESULT_ERROR_UNINITIALIZED = 38, ///< [Validation] adapter is not initialized or specific entry-point is not + ///< implemented UR_RESULT_ERROR_OUT_OF_HOST_MEMORY = 39, ///< Insufficient host memory to satisfy call UR_RESULT_ERROR_OUT_OF_DEVICE_MEMORY = 40, ///< Insufficient device memory to satisfy call UR_RESULT_ERROR_OUT_OF_RESOURCES = 41, ///< Out of resources @@ -219,6 +467,7 @@ typedef enum ur_result_t { UR_RESULT_ERROR_OBJECT_ALLOCATION_FAILURE = 66, ///< Objection allocation failure UR_RESULT_ERROR_ADAPTER_SPECIFIC = 67, ///< An adapter specific warning/error has been reported and can be ///< retrieved via the urPlatformGetLastError entry point. + UR_RESULT_ERROR_LAYER_NOT_PRESENT = 68, ///< A requested layer was not found by the loader. UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_EXP = 0x1000, ///< Invalid Command-Buffer UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_SYNC_POINT_EXP = 0x1001, ///< Sync point is not valid for the command-buffer UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_SYNC_POINT_WAIT_LIST_EXP = 0x1002, ///< Sync point wait list is invalid @@ -229,51 +478,6 @@ typedef enum ur_result_t { } ur_result_t; -/////////////////////////////////////////////////////////////////////////////// -/// @brief Defines structure types -typedef enum ur_structure_type_t { - UR_STRUCTURE_TYPE_CONTEXT_PROPERTIES = 0, ///< ::ur_context_properties_t - UR_STRUCTURE_TYPE_IMAGE_DESC = 1, ///< ::ur_image_desc_t - UR_STRUCTURE_TYPE_BUFFER_PROPERTIES = 2, ///< ::ur_buffer_properties_t - UR_STRUCTURE_TYPE_BUFFER_REGION = 3, ///< ::ur_buffer_region_t - UR_STRUCTURE_TYPE_BUFFER_CHANNEL_PROPERTIES = 4, ///< ::ur_buffer_channel_properties_t - UR_STRUCTURE_TYPE_BUFFER_ALLOC_LOCATION_PROPERTIES = 5, ///< ::ur_buffer_alloc_location_properties_t - UR_STRUCTURE_TYPE_PROGRAM_PROPERTIES = 6, ///< ::ur_program_properties_t - UR_STRUCTURE_TYPE_USM_DESC = 7, ///< ::ur_usm_desc_t - UR_STRUCTURE_TYPE_USM_HOST_DESC = 8, ///< ::ur_usm_host_desc_t - UR_STRUCTURE_TYPE_USM_DEVICE_DESC = 9, ///< ::ur_usm_device_desc_t - UR_STRUCTURE_TYPE_USM_POOL_DESC = 10, ///< ::ur_usm_pool_desc_t - UR_STRUCTURE_TYPE_USM_POOL_LIMITS_DESC = 11, ///< ::ur_usm_pool_limits_desc_t - UR_STRUCTURE_TYPE_DEVICE_BINARY = 12, ///< ::ur_device_binary_t - UR_STRUCTURE_TYPE_SAMPLER_DESC = 13, ///< ::ur_sampler_desc_t - UR_STRUCTURE_TYPE_QUEUE_PROPERTIES = 14, ///< ::ur_queue_properties_t - UR_STRUCTURE_TYPE_QUEUE_INDEX_PROPERTIES = 15, ///< ::ur_queue_properties_t - UR_STRUCTURE_TYPE_CONTEXT_NATIVE_PROPERTIES = 16, ///< ::ur_context_native_properties_t - UR_STRUCTURE_TYPE_KERNEL_NATIVE_PROPERTIES = 17, ///< ::ur_kernel_native_properties_t - UR_STRUCTURE_TYPE_QUEUE_NATIVE_PROPERTIES = 18, ///< ::ur_queue_native_properties_t - UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES = 19, ///< ::ur_mem_native_properties_t - UR_STRUCTURE_TYPE_EVENT_NATIVE_PROPERTIES = 20, ///< ::ur_event_native_properties_t - UR_STRUCTURE_TYPE_PLATFORM_NATIVE_PROPERTIES = 21, ///< ::ur_platform_native_properties_t - UR_STRUCTURE_TYPE_DEVICE_NATIVE_PROPERTIES = 22, ///< ::ur_device_native_properties_t - UR_STRUCTURE_TYPE_PROGRAM_NATIVE_PROPERTIES = 23, ///< ::ur_program_native_properties_t - UR_STRUCTURE_TYPE_SAMPLER_NATIVE_PROPERTIES = 24, ///< ::ur_sampler_native_properties_t - UR_STRUCTURE_TYPE_QUEUE_NATIVE_DESC = 25, ///< ::ur_queue_native_desc_t - UR_STRUCTURE_TYPE_DEVICE_PARTITION_PROPERTIES = 26, ///< ::ur_device_partition_properties_t - UR_STRUCTURE_TYPE_KERNEL_ARG_MEM_OBJ_PROPERTIES = 27, ///< ::ur_kernel_arg_mem_obj_properties_t - UR_STRUCTURE_TYPE_PHYSICAL_MEM_PROPERTIES = 28, ///< ::ur_physical_mem_properties_t - UR_STRUCTURE_TYPE_KERNEL_ARG_POINTER_PROPERTIES = 29, ///< ::ur_kernel_arg_pointer_properties_t - UR_STRUCTURE_TYPE_KERNEL_ARG_SAMPLER_PROPERTIES = 30, ///< ::ur_kernel_arg_sampler_properties_t - UR_STRUCTURE_TYPE_KERNEL_EXEC_INFO_PROPERTIES = 31, ///< ::ur_kernel_exec_info_properties_t - UR_STRUCTURE_TYPE_KERNEL_ARG_VALUE_PROPERTIES = 32, ///< ::ur_kernel_arg_value_properties_t - UR_STRUCTURE_TYPE_KERNEL_ARG_LOCAL_PROPERTIES = 33, ///< ::ur_kernel_arg_local_properties_t - UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC = 0x1000, ///< ::ur_exp_command_buffer_desc_t - UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES = 0x2000, ///< ::ur_exp_sampler_mip_properties_t - /// @cond - UR_STRUCTURE_TYPE_FORCE_UINT32 = 0x7fffffff - /// @endcond - -} ur_structure_type_t; - /////////////////////////////////////////////////////////////////////////////// /// @brief Base for all properties types typedef struct ur_base_properties_t { @@ -332,6 +536,137 @@ typedef enum ur_device_init_flag_t { /// @brief Bit Mask for validating ur_device_init_flags_t #define UR_DEVICE_INIT_FLAGS_MASK 0xffffffe0 +/////////////////////////////////////////////////////////////////////////////// +/// @brief Create a loader config object. +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == phLoaderConfig` +UR_APIEXPORT ur_result_t UR_APICALL +urLoaderConfigCreate( + ur_loader_config_handle_t *phLoaderConfig ///< [out] Pointer to handle of loader config object created. +); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Get a reference to the loader config object. +/// +/// @details +/// - Get a reference to the loader config handle. Increment its reference +/// count +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hLoaderConfig` +UR_APIEXPORT ur_result_t UR_APICALL +urLoaderConfigRetain( + ur_loader_config_handle_t hLoaderConfig ///< [in] loader config handle to retain +); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Release config handle. +/// +/// @details +/// - Decrement reference count and destroy the config handle if reference +/// count becomes zero. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hLoaderConfig` +UR_APIEXPORT ur_result_t UR_APICALL +urLoaderConfigRelease( + ur_loader_config_handle_t hLoaderConfig ///< [in] config handle to release +); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Supported loader info +typedef enum ur_loader_config_info_t { + UR_LOADER_CONFIG_INFO_AVAILABLE_LAYERS = 0, ///< [char[]] Null-terminated, semi-colon separated list of available + ///< layers. + UR_LOADER_CONFIG_INFO_REFERENCE_COUNT = 1, ///< [uint32_t] Reference count of the loader config object. + /// @cond + UR_LOADER_CONFIG_INFO_FORCE_UINT32 = 0x7fffffff + /// @endcond + +} ur_loader_config_info_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Retrieves various information about the loader. +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hLoaderConfig` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `::UR_LOADER_CONFIG_INFO_REFERENCE_COUNT < propName` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION +/// + If `propName` is not supported by the loader. +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `propSize == 0 && pPropValue != NULL` +/// + If `propSize` is less than the real number of bytes needed to return the info. +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `propSize != 0 && pPropValue == NULL` +/// + `pPropValue == NULL && pPropSizeRet == NULL` +/// - ::UR_RESULT_ERROR_INVALID_DEVICE +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY +UR_APIEXPORT ur_result_t UR_APICALL +urLoaderConfigGetInfo( + ur_loader_config_handle_t hLoaderConfig, ///< [in] handle of the loader config object + ur_loader_config_info_t propName, ///< [in] type of the info to retrieve + size_t propSize, ///< [in] the number of bytes pointed to by pPropValue. + void *pPropValue, ///< [out][optional][typename(propName, propSize)] array of bytes holding + ///< the info. + ///< If propSize is not equal to or greater than the real number of bytes + ///< needed to return the info + ///< then the ::UR_RESULT_ERROR_INVALID_SIZE error is returned and + ///< pPropValue is not used. + size_t *pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of the queried propName. +); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Enable a layer for the specified loader config. +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hLoaderConfig` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == pLayerName` +/// - ::UR_RESULT_ERROR_LAYER_NOT_PRESENT +/// + If layer specified with `pLayerName` can't be found by the loader. +UR_APIEXPORT ur_result_t UR_APICALL +urLoaderConfigEnableLayer( + ur_loader_config_handle_t hLoaderConfig, ///< [in] Handle to config object the layer will be enabled for. + const char *pLayerName ///< [in] Null terminated string containing the name of the layer to + ///< enable. +); + /////////////////////////////////////////////////////////////////////////////// /// @brief Initialize the 'oneAPI' adapter(s) /// @@ -359,8 +694,9 @@ typedef enum ur_device_init_flag_t { /// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY UR_APIEXPORT ur_result_t UR_APICALL urInit( - ur_device_init_flags_t device_flags ///< [in] device initialization flags. - ///< must be 0 (default) or a combination of ::ur_device_init_flag_t. + ur_device_init_flags_t device_flags, ///< [in] device initialization flags. + ///< must be 0 (default) or a combination of ::ur_device_init_flag_t. + ur_loader_config_handle_t hLoaderConfig ///< [in][optional] Handle of loader config handle. ); /////////////////////////////////////////////////////////////////////////////// @@ -379,6 +715,197 @@ urTearDown( void *pParams ///< [in] pointer to tear down parameters ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Retrieves all available adapters +/// +/// @details +/// - Adapter implementations must return exactly one adapter handle from +/// this entry point. +/// - The loader may return more than one adapter handle when there are +/// multiple available. +/// - Each returned adapter has its reference count incremented and should +/// be released with a subsequent call to ::urAdapterRelease. +/// - Adapters may perform adapter-specific state initialization when the +/// first reference to them is taken. +/// - An application may call this entry point multiple times to acquire +/// multiple references to the adapter handle(s). +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_SIZE +UR_APIEXPORT ur_result_t UR_APICALL +urAdapterGet( + uint32_t NumEntries, ///< [in] the number of adapters to be added to phAdapters. + ///< If phAdapters is not NULL, then NumEntries should be greater than + ///< zero, otherwise ::UR_RESULT_ERROR_INVALID_SIZE, + ///< will be returned. + ur_adapter_handle_t *phAdapters, ///< [out][optional][range(0, NumEntries)] array of handle of adapters. + ///< If NumEntries is less than the number of adapters available, then + ///< ::urAdapterGet shall only retrieve that number of platforms. + uint32_t *pNumAdapters ///< [out][optional] returns the total number of adapters available. +); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Releases the adapter handle reference indicating end of its usage +/// +/// @details +/// - When the reference count of the adapter reaches zero, the adapter may +/// perform adapter-specififc resource teardown +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hAdapter` +UR_APIEXPORT ur_result_t UR_APICALL +urAdapterRelease( + ur_adapter_handle_t hAdapter ///< [in] Adapter handle to release +); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Get a reference to the adapter handle. +/// +/// @details +/// - Get a reference to the adapter handle. Increment its reference count +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hAdapter` +UR_APIEXPORT ur_result_t UR_APICALL +urAdapterRetain( + ur_adapter_handle_t hAdapter ///< [in] Adapter handle to retain +); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Get the last adapter specific error. +/// +/// @details +/// To be used after another entry-point has returned +/// ::UR_RESULT_ERROR_ADAPTER_SPECIFIC in order to retrieve a message describing +/// the circumstances of the underlying driver error and the error code +/// returned by the failed driver entry-point. +/// +/// * Implementations *must* store the message and error code in thread-local +/// storage prior to returning ::UR_RESULT_ERROR_ADAPTER_SPECIFIC. +/// +/// * The message and error code storage is will only be valid if a previously +/// called entry-point returned ::UR_RESULT_ERROR_ADAPTER_SPECIFIC. +/// +/// * The memory pointed to by the C string returned in `ppMessage` is owned by +/// the adapter and *must* be null terminated. +/// +/// * The application *may* call this function from simultaneous threads. +/// +/// * The implementation of this function *should* be lock-free. +/// +/// Example usage: +/// +/// ```cpp +/// if (::urQueueCreate(hContext, hDevice, nullptr, &hQueue) == +/// ::UR_RESULT_ERROR_ADAPTER_SPECIFIC) { +/// const char* pMessage; +/// int32_t error; +/// ::urAdapterGetLastError(hAdapter, &pMessage, &error); +/// } +/// ``` +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hAdapter` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == ppMessage` +/// + `NULL == pError` +UR_APIEXPORT ur_result_t UR_APICALL +urAdapterGetLastError( + ur_adapter_handle_t hAdapter, ///< [in] handle of the adapter instance + const char **ppMessage, ///< [out] pointer to a C string where the adapter specific error message + ///< will be stored. + int32_t *pError ///< [out] pointer to an integer where the adapter specific error code will + ///< be stored. +); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Supported adapter info +typedef enum ur_adapter_info_t { + UR_ADAPTER_INFO_BACKEND = 0, ///< [::ur_adapter_backend_t] Identifies the native backend supported by + ///< the adapter. + UR_ADAPTER_INFO_REFERENCE_COUNT = 1, ///< [uint32_t] Reference count of the adapter. + ///< The reference count returned should be considered immediately stale. + ///< It is unsuitable for general use in applications. This feature is + ///< provided for identifying memory leaks. + /// @cond + UR_ADAPTER_INFO_FORCE_UINT32 = 0x7fffffff + /// @endcond + +} ur_adapter_info_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Retrieves information about the adapter +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hAdapter` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `::UR_ADAPTER_INFO_REFERENCE_COUNT < propName` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION +/// + If `propName` is not supported by the adapter. +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `propSize == 0 && pPropValue != NULL` +/// + If `propSize` is less than the real number of bytes needed to return the info. +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `propSize != 0 && pPropValue == NULL` +/// + `pPropValue == NULL && pPropSizeRet == NULL` +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY +UR_APIEXPORT ur_result_t UR_APICALL +urAdapterGetInfo( + ur_adapter_handle_t hAdapter, ///< [in] handle of the adapter + ur_adapter_info_t propName, ///< [in] type of the info to retrieve + size_t propSize, ///< [in] the number of bytes pointed to by pPropValue. + void *pPropValue, ///< [out][optional][typename(propName, propSize)] array of bytes holding + ///< the info. + ///< If Size is not equal to or greater to the real number of bytes needed + ///< to return the info then the ::UR_RESULT_ERROR_INVALID_SIZE error is + ///< returned and pPropValue is not used. + size_t *pPropSizeRet ///< [out][optional] pointer to the actual number of bytes being queried by pPropValue. +); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Identifies backend of the adapter +typedef enum ur_adapter_backend_t { + UR_ADAPTER_BACKEND_UNKNOWN = 0, ///< The backend is not a recognized one + UR_ADAPTER_BACKEND_LEVEL_ZERO = 1, ///< The backend is Level Zero + UR_ADAPTER_BACKEND_OPENCL = 2, ///< The backend is OpenCL + UR_ADAPTER_BACKEND_CUDA = 3, ///< The backend is CUDA + UR_ADAPTER_BACKEND_HIP = 4, ///< The backend is HIP + UR_ADAPTER_BACKEND_NATIVE_CPU = 5, ///< The backend is Native CPU + /// @cond + UR_ADAPTER_BACKEND_FORCE_UINT32 = 0x7fffffff + /// @endcond + +} ur_adapter_backend_t; + #if !defined(__GNUC__) #pragma endregion #endif @@ -387,7 +914,7 @@ urTearDown( #pragma region platform #endif /////////////////////////////////////////////////////////////////////////////// -/// @brief Retrieves all available platforms +/// @brief Retrieves all available platforms for the given adapters /// /// @details /// - Multiple calls to this function will return identical platforms @@ -404,9 +931,13 @@ urTearDown( /// - ::UR_RESULT_ERROR_UNINITIALIZED /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == phAdapters` /// - ::UR_RESULT_ERROR_INVALID_SIZE UR_APIEXPORT ur_result_t UR_APICALL urPlatformGet( + ur_adapter_handle_t *phAdapters, ///< [in][range(0, NumAdapters)] array of adapters to query for platforms. + uint32_t NumAdapters, ///< [in] number of adapters pointed to by phAdapters uint32_t NumEntries, ///< [in] the number of platforms to be added to phPlatforms. ///< If phPlatforms is not NULL, then NumEntries should be greater than ///< zero, otherwise ::UR_RESULT_ERROR_INVALID_SIZE, @@ -540,6 +1071,8 @@ urPlatformGetApiVersion( /// + `NULL == hPlatform` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativePlatform` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. UR_APIEXPORT ur_result_t UR_APICALL urPlatformGetNativeHandle( ur_platform_handle_t hPlatform, ///< [in] handle of the platform. @@ -572,13 +1105,13 @@ typedef struct ur_platform_native_properties_t { /// - ::UR_RESULT_ERROR_UNINITIALIZED /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC -/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativePlatform` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phPlatform` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. UR_APIEXPORT ur_result_t UR_APICALL urPlatformCreateWithNativeHandle( - ur_native_handle_t hNativePlatform, ///< [in] the native handle of the platform. + ur_native_handle_t hNativePlatform, ///< [in][nocheck] the native handle of the platform. const ur_platform_native_properties_t *pProperties, ///< [in][optional] pointer to native platform properties struct. ur_platform_handle_t *phPlatform ///< [out] pointer to the handle of the platform object created. ); @@ -616,58 +1149,6 @@ urPlatformGetBackendOption( ///< the frontend option. ); -/////////////////////////////////////////////////////////////////////////////// -/// @brief Get the last adapter specific error. -/// -/// @details -/// To be used after another entry-point has returned -/// ::UR_RESULT_ERROR_ADAPTER_SPECIFIC in order to retrieve a message describing -/// the circumstances of the underlying driver error and the error code -/// returned by the failed driver entry-point. -/// -/// * Implementations *must* store the message and error code in thread-local -/// storage prior to returning ::UR_RESULT_ERROR_ADAPTER_SPECIFIC. -/// -/// * The message and error code storage is will only be valid if a previously -/// called entry-point returned ::UR_RESULT_ERROR_ADAPTER_SPECIFIC. -/// -/// * The memory pointed to by the C string returned in `ppMessage` is owned by -/// the adapter and *must* be null terminated. -/// -/// * The application *may* call this function from simultaneous threads. -/// -/// * The implementation of this function *should* be lock-free. -/// -/// Example usage: -/// -/// ```cpp -/// if (::urQueueCreate(hContext, hDevice, nullptr, &hQueue) == -/// ::UR_RESULT_ERROR_ADAPTER_SPECIFIC) { -/// const char* pMessage; -/// int32_t error; -/// ::urPlatformGetLastError(hPlatform, &pMessage, &error); -/// } -/// ``` -/// -/// @returns -/// - ::UR_RESULT_SUCCESS -/// - ::UR_RESULT_ERROR_UNINITIALIZED -/// - ::UR_RESULT_ERROR_DEVICE_LOST -/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC -/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hPlatform` -/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER -/// + `NULL == ppMessage` -/// + `NULL == pError` -UR_APIEXPORT ur_result_t UR_APICALL -urPlatformGetLastError( - ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance - const char **ppMessage, ///< [out] pointer to a C string where the adapter specific error message - ///< will be stored. - int32_t *pError ///< [out] pointer to an integer where the adapter specific error code will - ///< be stored. -); - /////////////////////////////////////////////////////////////////////////////// /// @brief Identifies native backend adapters typedef enum ur_platform_backend_t { @@ -676,6 +1157,7 @@ typedef enum ur_platform_backend_t { UR_PLATFORM_BACKEND_OPENCL = 2, ///< The backend is OpenCL UR_PLATFORM_BACKEND_CUDA = 3, ///< The backend is CUDA UR_PLATFORM_BACKEND_HIP = 4, ///< The backend is HIP + UR_PLATFORM_BACKEND_NATIVE_CPU = 5, ///< The backend is Native CPU /// @cond UR_PLATFORM_BACKEND_FORCE_UINT32 = 0x7fffffff /// @endcond @@ -822,187 +1304,188 @@ urDeviceGet( /////////////////////////////////////////////////////////////////////////////// /// @brief Supported device info typedef enum ur_device_info_t { - UR_DEVICE_INFO_TYPE = 0, ///< [::ur_device_type_t] type of the device - UR_DEVICE_INFO_VENDOR_ID = 1, ///< [uint32_t] vendor Id of the device - UR_DEVICE_INFO_DEVICE_ID = 2, ///< [uint32_t] Id of the device - UR_DEVICE_INFO_MAX_COMPUTE_UNITS = 3, ///< [uint32_t] the number of compute units - UR_DEVICE_INFO_MAX_WORK_ITEM_DIMENSIONS = 4, ///< [uint32_t] max work item dimensions - UR_DEVICE_INFO_MAX_WORK_ITEM_SIZES = 5, ///< [size_t[]] return an array of max work item sizes - UR_DEVICE_INFO_MAX_WORK_GROUP_SIZE = 6, ///< [size_t] max work group size - UR_DEVICE_INFO_SINGLE_FP_CONFIG = 7, ///< [::ur_device_fp_capability_flags_t] single precision floating point - ///< capability - UR_DEVICE_INFO_HALF_FP_CONFIG = 8, ///< [::ur_device_fp_capability_flags_t] half precision floating point - ///< capability - UR_DEVICE_INFO_DOUBLE_FP_CONFIG = 9, ///< [::ur_device_fp_capability_flags_t] double precision floating point - ///< capability - UR_DEVICE_INFO_QUEUE_PROPERTIES = 10, ///< [::ur_queue_flags_t] command queue properties supported by the device - UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_CHAR = 11, ///< [uint32_t] preferred vector width for char - UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_SHORT = 12, ///< [uint32_t] preferred vector width for short - UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_INT = 13, ///< [uint32_t] preferred vector width for int - UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_LONG = 14, ///< [uint32_t] preferred vector width for long - UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_FLOAT = 15, ///< [uint32_t] preferred vector width for float - UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_DOUBLE = 16, ///< [uint32_t] preferred vector width for double - UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_HALF = 17, ///< [uint32_t] preferred vector width for half float - UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_CHAR = 18, ///< [uint32_t] native vector width for char - UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_SHORT = 19, ///< [uint32_t] native vector width for short - UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_INT = 20, ///< [uint32_t] native vector width for int - UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_LONG = 21, ///< [uint32_t] native vector width for long - UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_FLOAT = 22, ///< [uint32_t] native vector width for float - UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_DOUBLE = 23, ///< [uint32_t] native vector width for double - UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_HALF = 24, ///< [uint32_t] native vector width for half float - UR_DEVICE_INFO_MAX_CLOCK_FREQUENCY = 25, ///< [uint32_t] max clock frequency in MHz - UR_DEVICE_INFO_MEMORY_CLOCK_RATE = 26, ///< [uint32_t] memory clock frequency in MHz - UR_DEVICE_INFO_ADDRESS_BITS = 27, ///< [uint32_t] address bits - UR_DEVICE_INFO_MAX_MEM_ALLOC_SIZE = 28, ///< [uint64_t] max memory allocation size - UR_DEVICE_INFO_IMAGE_SUPPORTED = 29, ///< [::ur_bool_t] images are supported - UR_DEVICE_INFO_MAX_READ_IMAGE_ARGS = 30, ///< [uint32_t] max number of image objects arguments of a kernel declared - ///< with the read_only qualifier - UR_DEVICE_INFO_MAX_WRITE_IMAGE_ARGS = 31, ///< [uint32_t] max number of image objects arguments of a kernel declared - ///< with the write_only qualifier - UR_DEVICE_INFO_MAX_READ_WRITE_IMAGE_ARGS = 32, ///< [uint32_t] max number of image objects arguments of a kernel declared - ///< with the read_write qualifier - UR_DEVICE_INFO_IMAGE2D_MAX_WIDTH = 33, ///< [size_t] max width of Image2D object - UR_DEVICE_INFO_IMAGE2D_MAX_HEIGHT = 34, ///< [size_t] max heigh of Image2D object - UR_DEVICE_INFO_IMAGE3D_MAX_WIDTH = 35, ///< [size_t] max width of Image3D object - UR_DEVICE_INFO_IMAGE3D_MAX_HEIGHT = 36, ///< [size_t] max height of Image3D object - UR_DEVICE_INFO_IMAGE3D_MAX_DEPTH = 37, ///< [size_t] max depth of Image3D object - UR_DEVICE_INFO_IMAGE_MAX_BUFFER_SIZE = 38, ///< [size_t] max image buffer size - UR_DEVICE_INFO_IMAGE_MAX_ARRAY_SIZE = 39, ///< [size_t] max image array size - UR_DEVICE_INFO_MAX_SAMPLERS = 40, ///< [uint32_t] max number of samplers that can be used in a kernel - UR_DEVICE_INFO_MAX_PARAMETER_SIZE = 41, ///< [size_t] max size in bytes of all arguments passed to a kernel - UR_DEVICE_INFO_MEM_BASE_ADDR_ALIGN = 42, ///< [uint32_t] memory base address alignment - UR_DEVICE_INFO_GLOBAL_MEM_CACHE_TYPE = 43, ///< [::ur_device_mem_cache_type_t] global memory cache type - UR_DEVICE_INFO_GLOBAL_MEM_CACHELINE_SIZE = 44, ///< [uint32_t] global memory cache line size in bytes - UR_DEVICE_INFO_GLOBAL_MEM_CACHE_SIZE = 45, ///< [uint64_t] size of global memory cache in bytes - UR_DEVICE_INFO_GLOBAL_MEM_SIZE = 46, ///< [uint64_t] size of global memory in bytes - UR_DEVICE_INFO_GLOBAL_MEM_FREE = 47, ///< [uint64_t] size of global memory which is free in bytes - UR_DEVICE_INFO_MAX_CONSTANT_BUFFER_SIZE = 48, ///< [uint64_t] max constant buffer size in bytes - UR_DEVICE_INFO_MAX_CONSTANT_ARGS = 49, ///< [uint32_t] max number of __const declared arguments in a kernel - UR_DEVICE_INFO_LOCAL_MEM_TYPE = 50, ///< [::ur_device_local_mem_type_t] local memory type - UR_DEVICE_INFO_LOCAL_MEM_SIZE = 51, ///< [uint64_t] local memory size in bytes - UR_DEVICE_INFO_ERROR_CORRECTION_SUPPORT = 52, ///< [::ur_bool_t] support error correction to global and local memory - UR_DEVICE_INFO_HOST_UNIFIED_MEMORY = 53, ///< [::ur_bool_t] unified host device memory - UR_DEVICE_INFO_PROFILING_TIMER_RESOLUTION = 54, ///< [size_t] profiling timer resolution in nanoseconds - UR_DEVICE_INFO_ENDIAN_LITTLE = 55, ///< [::ur_bool_t] little endian byte order - UR_DEVICE_INFO_AVAILABLE = 56, ///< [::ur_bool_t] device is available - UR_DEVICE_INFO_COMPILER_AVAILABLE = 57, ///< [::ur_bool_t] device compiler is available - UR_DEVICE_INFO_LINKER_AVAILABLE = 58, ///< [::ur_bool_t] device linker is available - UR_DEVICE_INFO_EXECUTION_CAPABILITIES = 59, ///< [::ur_device_exec_capability_flags_t] device kernel execution - ///< capability bit-field - UR_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES = 60, ///< [::ur_queue_flags_t] device command queue property bit-field - UR_DEVICE_INFO_QUEUE_ON_HOST_PROPERTIES = 61, ///< [::ur_queue_flags_t] host queue property bit-field - UR_DEVICE_INFO_BUILT_IN_KERNELS = 62, ///< [char[]] a semi-colon separated list of built-in kernels - UR_DEVICE_INFO_PLATFORM = 63, ///< [::ur_platform_handle_t] the platform associated with the device - UR_DEVICE_INFO_REFERENCE_COUNT = 64, ///< [uint32_t] Reference count of the device object. - ///< The reference count returned should be considered immediately stale. - ///< It is unsuitable for general use in applications. This feature is - ///< provided for identifying memory leaks. - UR_DEVICE_INFO_IL_VERSION = 65, ///< [char[]] IL version - UR_DEVICE_INFO_NAME = 66, ///< [char[]] Device name - UR_DEVICE_INFO_VENDOR = 67, ///< [char[]] Device vendor - UR_DEVICE_INFO_DRIVER_VERSION = 68, ///< [char[]] Driver version - UR_DEVICE_INFO_PROFILE = 69, ///< [char[]] Device profile - UR_DEVICE_INFO_VERSION = 70, ///< [char[]] Device version - UR_DEVICE_INFO_BACKEND_RUNTIME_VERSION = 71, ///< [char[]] Version of backend runtime - UR_DEVICE_INFO_EXTENSIONS = 72, ///< [char[]] Return a space separated list of extension names - UR_DEVICE_INFO_PRINTF_BUFFER_SIZE = 73, ///< [size_t] Maximum size in bytes of internal printf buffer - UR_DEVICE_INFO_PREFERRED_INTEROP_USER_SYNC = 74, ///< [::ur_bool_t] prefer user synchronization when sharing object with - ///< other API - UR_DEVICE_INFO_PARENT_DEVICE = 75, ///< [::ur_device_handle_t] return parent device handle - UR_DEVICE_INFO_SUPPORTED_PARTITIONS = 76, ///< [::ur_device_partition_t[]] Returns an array of partition types - ///< supported by the device - UR_DEVICE_INFO_PARTITION_MAX_SUB_DEVICES = 77, ///< [uint32_t] maximum number of sub-devices when the device is - ///< partitioned - UR_DEVICE_INFO_PARTITION_AFFINITY_DOMAIN = 78, ///< [::ur_device_affinity_domain_flags_t] Returns a bit-field of the - ///< supported affinity domains for partitioning. - ///< If the device does not support any affinity domains, then 0 will be returned. - UR_DEVICE_INFO_PARTITION_TYPE = 79, ///< [::ur_device_partition_property_t[]] return an array of - ///< ::ur_device_partition_property_t for properties specified in - ///< ::urDevicePartition - UR_DEVICE_INFO_MAX_NUM_SUB_GROUPS = 80, ///< [uint32_t] max number of sub groups - UR_DEVICE_INFO_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS = 81, ///< [::ur_bool_t] support sub group independent forward progress - UR_DEVICE_INFO_SUB_GROUP_SIZES_INTEL = 82, ///< [uint32_t[]] return an array of sub group sizes supported on Intel - ///< device - UR_DEVICE_INFO_USM_HOST_SUPPORT = 83, ///< [::ur_device_usm_access_capability_flags_t] support USM host memory - ///< access - UR_DEVICE_INFO_USM_DEVICE_SUPPORT = 84, ///< [::ur_device_usm_access_capability_flags_t] support USM device memory - ///< access - UR_DEVICE_INFO_USM_SINGLE_SHARED_SUPPORT = 85, ///< [::ur_device_usm_access_capability_flags_t] support USM single device - ///< shared memory access - UR_DEVICE_INFO_USM_CROSS_SHARED_SUPPORT = 86, ///< [::ur_device_usm_access_capability_flags_t] support USM cross device - ///< shared memory access - UR_DEVICE_INFO_USM_SYSTEM_SHARED_SUPPORT = 87, ///< [::ur_device_usm_access_capability_flags_t] support USM system wide - ///< shared memory access - UR_DEVICE_INFO_UUID = 88, ///< [char[]] return device UUID - UR_DEVICE_INFO_PCI_ADDRESS = 89, ///< [char[]] return device PCI address - UR_DEVICE_INFO_GPU_EU_COUNT = 90, ///< [uint32_t] return Intel GPU EU count - UR_DEVICE_INFO_GPU_EU_SIMD_WIDTH = 91, ///< [uint32_t] return Intel GPU EU SIMD width - UR_DEVICE_INFO_GPU_EU_SLICES = 92, ///< [uint32_t] return Intel GPU number of slices - UR_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE = 93, ///< [uint32_t] return Intel GPU EU count per subslice - UR_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE = 94, ///< [uint32_t] return Intel GPU number of subslices per slice - UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU = 95, ///< [uint32_t] return Intel GPU number of threads per EU - UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH = 96, ///< [uint32_t] return max memory bandwidth in Mb/s - UR_DEVICE_INFO_IMAGE_SRGB = 97, ///< [::ur_bool_t] device supports sRGB images - UR_DEVICE_INFO_BUILD_ON_SUBDEVICE = 98, ///< [::ur_bool_t] Return true if sub-device should do its own program - ///< build - UR_DEVICE_INFO_ATOMIC_64 = 99, ///< [::ur_bool_t] support 64 bit atomics - UR_DEVICE_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES = 100, ///< [::ur_memory_order_capability_flags_t] return a bit-field of atomic - ///< memory order capabilities - UR_DEVICE_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES = 101, ///< [::ur_memory_scope_capability_flags_t] return a bit-field of atomic - ///< memory scope capabilities - UR_DEVICE_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES = 102, ///< [::ur_memory_order_capability_flags_t] return a bit-field of atomic - ///< memory fence order capabilities - UR_DEVICE_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES = 103, ///< [::ur_memory_scope_capability_flags_t] return a bit-field of atomic - ///< memory fence scope capabilities - UR_DEVICE_INFO_BFLOAT16 = 104, ///< [::ur_bool_t] support for bfloat16 - UR_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES = 105, ///< [uint32_t] Returns 1 if the device doesn't have a notion of a - ///< queue index. Otherwise, returns the number of queue indices that are - ///< available for this device. - UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS = 106, ///< [::ur_bool_t] support the ::urKernelSetSpecializationConstants entry - ///< point - UR_DEVICE_INFO_MEMORY_BUS_WIDTH = 107, ///< [uint32_t] return the width in bits of the memory bus interface of the - ///< device. - UR_DEVICE_INFO_MAX_WORK_GROUPS_3D = 108, ///< [size_t[3]] return max 3D work groups - UR_DEVICE_INFO_ASYNC_BARRIER = 109, ///< [::ur_bool_t] return true if Async Barrier is supported - UR_DEVICE_INFO_MEM_CHANNEL_SUPPORT = 110, ///< [::ur_bool_t] return true if specifying memory channels is supported - UR_DEVICE_INFO_HOST_PIPE_READ_WRITE_SUPPORTED = 111, ///< [::ur_bool_t] Return true if the device supports enqueueing commands - ///< to read and write pipes from the host. - UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP = 112, ///< [uint32_t] The maximum number of registers available per block. - UR_DEVICE_INFO_IP_VERSION = 113, ///< [uint32_t] The device IP version. The meaning of the device IP version - ///< is implementation-defined, but newer devices should have a higher - ///< version than older devices. - UR_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP = 0x2000, ///< [::ur_bool_t] returns true if the device supports the creation of - ///< bindless images - UR_DEVICE_INFO_BINDLESS_IMAGES_1D_USM_SUPPORT_EXP = 0x2001, ///< [::ur_bool_t] returns true if the device supports the creation of 1D - ///< bindless images backed by USM - UR_DEVICE_INFO_BINDLESS_IMAGES_2D_USM_SUPPORT_EXP = 0x2002, ///< [::ur_bool_t] returns true if the device supports the creation of 2D - ///< bindless images backed by USM - UR_DEVICE_INFO_BINDLESS_IMAGES_3D_USM_SUPPORT_EXP = 0x2003, ///< [::ur_bool_t] returns true if the device supports the creation of 3D - ///< bindless images backed by USM - UR_DEVICE_INFO_IMAGE_PITCH_ALIGN_EXP = 0x2004, ///< [uint32_t] returns the required alignment of the pitch between two - ///< rows of an image in bytes - UR_DEVICE_INFO_MAX_IMAGE_LINEAR_WIDTH_EXP = 0x2005, ///< [size_t] returns the maximum linear width allowed for images allocated - ///< using USM - UR_DEVICE_INFO_MAX_IMAGE_LINEAR_HEIGHT_EXP = 0x2006, ///< [size_t] returns the maximum linear height allowed for images - ///< allocated using USM - UR_DEVICE_INFO_MAX_IMAGE_LINEAR_PITCH_EXP = 0x2007, ///< [size_t] returns the maximum linear pitch allowed for images allocated - ///< using USM - UR_DEVICE_INFO_MIPMAP_SUPPORT_EXP = 0x2008, ///< [::ur_bool_t] returns true if the device supports allocating mipmap - ///< resources - UR_DEVICE_INFO_MIPMAP_ANISOTROPY_SUPPORT_EXP = 0x2009, ///< [::ur_bool_t] returns true if the device supports sampling mipmap - ///< images with anisotropic filtering - UR_DEVICE_INFO_MIPMAP_MAX_ANISOTROPY_EXP = 0x200A, ///< [uint32_t] returns the maximum anisotropic ratio supported by the - ///< device - UR_DEVICE_INFO_MIPMAP_LEVEL_REFERENCE_SUPPORT_EXP = 0x200B, ///< [::ur_bool_t] returns true if the device supports using images created - ///< from individual mipmap levels - UR_DEVICE_INFO_INTEROP_MEMORY_IMPORT_SUPPORT_EXP = 0x200C, ///< [::ur_bool_t] returns true if the device supports importing external - ///< memory resources - UR_DEVICE_INFO_INTEROP_MEMORY_EXPORT_SUPPORT_EXP = 0x200D, ///< [::ur_bool_t] returns true if the device supports exporting internal - ///< memory resources - UR_DEVICE_INFO_INTEROP_SEMAPHORE_IMPORT_SUPPORT_EXP = 0x200E, ///< [::ur_bool_t] returns true if the device supports importing external - ///< semaphore resources - UR_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP = 0x200F, ///< [::ur_bool_t] returns true if the device supports exporting internal - ///< event resources + UR_DEVICE_INFO_TYPE = 0, ///< [::ur_device_type_t] type of the device + UR_DEVICE_INFO_VENDOR_ID = 1, ///< [uint32_t] vendor Id of the device + UR_DEVICE_INFO_DEVICE_ID = 2, ///< [uint32_t] Id of the device + UR_DEVICE_INFO_MAX_COMPUTE_UNITS = 3, ///< [uint32_t] the number of compute units + UR_DEVICE_INFO_MAX_WORK_ITEM_DIMENSIONS = 4, ///< [uint32_t] max work item dimensions + UR_DEVICE_INFO_MAX_WORK_ITEM_SIZES = 5, ///< [size_t[]] return an array of max work item sizes + UR_DEVICE_INFO_MAX_WORK_GROUP_SIZE = 6, ///< [size_t] max work group size + UR_DEVICE_INFO_SINGLE_FP_CONFIG = 7, ///< [::ur_device_fp_capability_flags_t] single precision floating point + ///< capability + UR_DEVICE_INFO_HALF_FP_CONFIG = 8, ///< [::ur_device_fp_capability_flags_t] half precision floating point + ///< capability + UR_DEVICE_INFO_DOUBLE_FP_CONFIG = 9, ///< [::ur_device_fp_capability_flags_t] double precision floating point + ///< capability + UR_DEVICE_INFO_QUEUE_PROPERTIES = 10, ///< [::ur_queue_flags_t] command queue properties supported by the device + UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_CHAR = 11, ///< [uint32_t] preferred vector width for char + UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_SHORT = 12, ///< [uint32_t] preferred vector width for short + UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_INT = 13, ///< [uint32_t] preferred vector width for int + UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_LONG = 14, ///< [uint32_t] preferred vector width for long + UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_FLOAT = 15, ///< [uint32_t] preferred vector width for float + UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_DOUBLE = 16, ///< [uint32_t] preferred vector width for double + UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_HALF = 17, ///< [uint32_t] preferred vector width for half float + UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_CHAR = 18, ///< [uint32_t] native vector width for char + UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_SHORT = 19, ///< [uint32_t] native vector width for short + UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_INT = 20, ///< [uint32_t] native vector width for int + UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_LONG = 21, ///< [uint32_t] native vector width for long + UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_FLOAT = 22, ///< [uint32_t] native vector width for float + UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_DOUBLE = 23, ///< [uint32_t] native vector width for double + UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_HALF = 24, ///< [uint32_t] native vector width for half float + UR_DEVICE_INFO_MAX_CLOCK_FREQUENCY = 25, ///< [uint32_t] max clock frequency in MHz + UR_DEVICE_INFO_MEMORY_CLOCK_RATE = 26, ///< [uint32_t] memory clock frequency in MHz + UR_DEVICE_INFO_ADDRESS_BITS = 27, ///< [uint32_t] address bits + UR_DEVICE_INFO_MAX_MEM_ALLOC_SIZE = 28, ///< [uint64_t] max memory allocation size + UR_DEVICE_INFO_IMAGE_SUPPORTED = 29, ///< [::ur_bool_t] images are supported + UR_DEVICE_INFO_MAX_READ_IMAGE_ARGS = 30, ///< [uint32_t] max number of image objects arguments of a kernel declared + ///< with the read_only qualifier + UR_DEVICE_INFO_MAX_WRITE_IMAGE_ARGS = 31, ///< [uint32_t] max number of image objects arguments of a kernel declared + ///< with the write_only qualifier + UR_DEVICE_INFO_MAX_READ_WRITE_IMAGE_ARGS = 32, ///< [uint32_t] max number of image objects arguments of a kernel declared + ///< with the read_write qualifier + UR_DEVICE_INFO_IMAGE2D_MAX_WIDTH = 33, ///< [size_t] max width of Image2D object + UR_DEVICE_INFO_IMAGE2D_MAX_HEIGHT = 34, ///< [size_t] max height of Image2D object + UR_DEVICE_INFO_IMAGE3D_MAX_WIDTH = 35, ///< [size_t] max width of Image3D object + UR_DEVICE_INFO_IMAGE3D_MAX_HEIGHT = 36, ///< [size_t] max height of Image3D object + UR_DEVICE_INFO_IMAGE3D_MAX_DEPTH = 37, ///< [size_t] max depth of Image3D object + UR_DEVICE_INFO_IMAGE_MAX_BUFFER_SIZE = 38, ///< [size_t] max image buffer size + UR_DEVICE_INFO_IMAGE_MAX_ARRAY_SIZE = 39, ///< [size_t] max image array size + UR_DEVICE_INFO_MAX_SAMPLERS = 40, ///< [uint32_t] max number of samplers that can be used in a kernel + UR_DEVICE_INFO_MAX_PARAMETER_SIZE = 41, ///< [size_t] max size in bytes of all arguments passed to a kernel + UR_DEVICE_INFO_MEM_BASE_ADDR_ALIGN = 42, ///< [uint32_t] memory base address alignment + UR_DEVICE_INFO_GLOBAL_MEM_CACHE_TYPE = 43, ///< [::ur_device_mem_cache_type_t] global memory cache type + UR_DEVICE_INFO_GLOBAL_MEM_CACHELINE_SIZE = 44, ///< [uint32_t] global memory cache line size in bytes + UR_DEVICE_INFO_GLOBAL_MEM_CACHE_SIZE = 45, ///< [uint64_t] size of global memory cache in bytes + UR_DEVICE_INFO_GLOBAL_MEM_SIZE = 46, ///< [uint64_t] size of global memory in bytes + UR_DEVICE_INFO_GLOBAL_MEM_FREE = 47, ///< [uint64_t] size of global memory which is free in bytes + UR_DEVICE_INFO_MAX_CONSTANT_BUFFER_SIZE = 48, ///< [uint64_t] max constant buffer size in bytes + UR_DEVICE_INFO_MAX_CONSTANT_ARGS = 49, ///< [uint32_t] max number of __const declared arguments in a kernel + UR_DEVICE_INFO_LOCAL_MEM_TYPE = 50, ///< [::ur_device_local_mem_type_t] local memory type + UR_DEVICE_INFO_LOCAL_MEM_SIZE = 51, ///< [uint64_t] local memory size in bytes + UR_DEVICE_INFO_ERROR_CORRECTION_SUPPORT = 52, ///< [::ur_bool_t] support error correction to global and local memory + UR_DEVICE_INFO_HOST_UNIFIED_MEMORY = 53, ///< [::ur_bool_t] unified host device memory + UR_DEVICE_INFO_PROFILING_TIMER_RESOLUTION = 54, ///< [size_t] profiling timer resolution in nanoseconds + UR_DEVICE_INFO_ENDIAN_LITTLE = 55, ///< [::ur_bool_t] little endian byte order + UR_DEVICE_INFO_AVAILABLE = 56, ///< [::ur_bool_t] device is available + UR_DEVICE_INFO_COMPILER_AVAILABLE = 57, ///< [::ur_bool_t] device compiler is available + UR_DEVICE_INFO_LINKER_AVAILABLE = 58, ///< [::ur_bool_t] device linker is available + UR_DEVICE_INFO_EXECUTION_CAPABILITIES = 59, ///< [::ur_device_exec_capability_flags_t] device kernel execution + ///< capability bit-field + UR_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES = 60, ///< [::ur_queue_flags_t] device command queue property bit-field + UR_DEVICE_INFO_QUEUE_ON_HOST_PROPERTIES = 61, ///< [::ur_queue_flags_t] host queue property bit-field + UR_DEVICE_INFO_BUILT_IN_KERNELS = 62, ///< [char[]] a semi-colon separated list of built-in kernels + UR_DEVICE_INFO_PLATFORM = 63, ///< [::ur_platform_handle_t] the platform associated with the device + UR_DEVICE_INFO_REFERENCE_COUNT = 64, ///< [uint32_t] Reference count of the device object. + ///< The reference count returned should be considered immediately stale. + ///< It is unsuitable for general use in applications. This feature is + ///< provided for identifying memory leaks. + UR_DEVICE_INFO_IL_VERSION = 65, ///< [char[]] IL version + UR_DEVICE_INFO_NAME = 66, ///< [char[]] Device name + UR_DEVICE_INFO_VENDOR = 67, ///< [char[]] Device vendor + UR_DEVICE_INFO_DRIVER_VERSION = 68, ///< [char[]] Driver version + UR_DEVICE_INFO_PROFILE = 69, ///< [char[]] Device profile + UR_DEVICE_INFO_VERSION = 70, ///< [char[]] Device version + UR_DEVICE_INFO_BACKEND_RUNTIME_VERSION = 71, ///< [char[]] Version of backend runtime + UR_DEVICE_INFO_EXTENSIONS = 72, ///< [char[]] Return a space separated list of extension names + UR_DEVICE_INFO_PRINTF_BUFFER_SIZE = 73, ///< [size_t] Maximum size in bytes of internal printf buffer + UR_DEVICE_INFO_PREFERRED_INTEROP_USER_SYNC = 74, ///< [::ur_bool_t] prefer user synchronization when sharing object with + ///< other API + UR_DEVICE_INFO_PARENT_DEVICE = 75, ///< [::ur_device_handle_t] return parent device handle + UR_DEVICE_INFO_SUPPORTED_PARTITIONS = 76, ///< [::ur_device_partition_t[]] Returns an array of partition types + ///< supported by the device + UR_DEVICE_INFO_PARTITION_MAX_SUB_DEVICES = 77, ///< [uint32_t] maximum number of sub-devices when the device is + ///< partitioned + UR_DEVICE_INFO_PARTITION_AFFINITY_DOMAIN = 78, ///< [::ur_device_affinity_domain_flags_t] Returns a bit-field of the + ///< supported affinity domains for partitioning. + ///< If the device does not support any affinity domains, then 0 will be returned. + UR_DEVICE_INFO_PARTITION_TYPE = 79, ///< [::ur_device_partition_property_t[]] return an array of + ///< ::ur_device_partition_property_t for properties specified in + ///< ::urDevicePartition + UR_DEVICE_INFO_MAX_NUM_SUB_GROUPS = 80, ///< [uint32_t] max number of sub groups + UR_DEVICE_INFO_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS = 81, ///< [::ur_bool_t] support sub group independent forward progress + UR_DEVICE_INFO_SUB_GROUP_SIZES_INTEL = 82, ///< [uint32_t[]] return an array of sub group sizes supported on Intel + ///< device + UR_DEVICE_INFO_USM_HOST_SUPPORT = 83, ///< [::ur_device_usm_access_capability_flags_t] support USM host memory + ///< access + UR_DEVICE_INFO_USM_DEVICE_SUPPORT = 84, ///< [::ur_device_usm_access_capability_flags_t] support USM device memory + ///< access + UR_DEVICE_INFO_USM_SINGLE_SHARED_SUPPORT = 85, ///< [::ur_device_usm_access_capability_flags_t] support USM single device + ///< shared memory access + UR_DEVICE_INFO_USM_CROSS_SHARED_SUPPORT = 86, ///< [::ur_device_usm_access_capability_flags_t] support USM cross device + ///< shared memory access + UR_DEVICE_INFO_USM_SYSTEM_SHARED_SUPPORT = 87, ///< [::ur_device_usm_access_capability_flags_t] support USM system wide + ///< shared memory access + UR_DEVICE_INFO_UUID = 88, ///< [char[]] return device UUID + UR_DEVICE_INFO_PCI_ADDRESS = 89, ///< [char[]] return device PCI address + UR_DEVICE_INFO_GPU_EU_COUNT = 90, ///< [uint32_t] return Intel GPU EU count + UR_DEVICE_INFO_GPU_EU_SIMD_WIDTH = 91, ///< [uint32_t] return Intel GPU EU SIMD width + UR_DEVICE_INFO_GPU_EU_SLICES = 92, ///< [uint32_t] return Intel GPU number of slices + UR_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE = 93, ///< [uint32_t] return Intel GPU EU count per subslice + UR_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE = 94, ///< [uint32_t] return Intel GPU number of subslices per slice + UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU = 95, ///< [uint32_t] return Intel GPU number of threads per EU + UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH = 96, ///< [uint32_t] return max memory bandwidth in Mb/s + UR_DEVICE_INFO_IMAGE_SRGB = 97, ///< [::ur_bool_t] device supports sRGB images + UR_DEVICE_INFO_BUILD_ON_SUBDEVICE = 98, ///< [::ur_bool_t] Return true if sub-device should do its own program + ///< build + UR_DEVICE_INFO_ATOMIC_64 = 99, ///< [::ur_bool_t] support 64 bit atomics + UR_DEVICE_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES = 100, ///< [::ur_memory_order_capability_flags_t] return a bit-field of atomic + ///< memory order capabilities + UR_DEVICE_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES = 101, ///< [::ur_memory_scope_capability_flags_t] return a bit-field of atomic + ///< memory scope capabilities + UR_DEVICE_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES = 102, ///< [::ur_memory_order_capability_flags_t] return a bit-field of atomic + ///< memory fence order capabilities + UR_DEVICE_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES = 103, ///< [::ur_memory_scope_capability_flags_t] return a bit-field of atomic + ///< memory fence scope capabilities + UR_DEVICE_INFO_BFLOAT16 = 104, ///< [::ur_bool_t] support for bfloat16 + UR_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES = 105, ///< [uint32_t] Returns 1 if the device doesn't have a notion of a + ///< queue index. Otherwise, returns the number of queue indices that are + ///< available for this device. + UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS = 106, ///< [::ur_bool_t] support the ::urKernelSetSpecializationConstants entry + ///< point + UR_DEVICE_INFO_MEMORY_BUS_WIDTH = 107, ///< [uint32_t] return the width in bits of the memory bus interface of the + ///< device. + UR_DEVICE_INFO_MAX_WORK_GROUPS_3D = 108, ///< [size_t[3]] return max 3D work groups + UR_DEVICE_INFO_ASYNC_BARRIER = 109, ///< [::ur_bool_t] return true if Async Barrier is supported + UR_DEVICE_INFO_MEM_CHANNEL_SUPPORT = 110, ///< [::ur_bool_t] return true if specifying memory channels is supported + UR_DEVICE_INFO_HOST_PIPE_READ_WRITE_SUPPORTED = 111, ///< [::ur_bool_t] Return true if the device supports enqueueing commands + ///< to read and write pipes from the host. + UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP = 112, ///< [uint32_t] The maximum number of registers available per block. + UR_DEVICE_INFO_IP_VERSION = 113, ///< [uint32_t] The device IP version. The meaning of the device IP version + ///< is implementation-defined, but newer devices should have a higher + ///< version than older devices. + UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT = 114, ///< [::ur_bool_t] return true if the device supports virtual memory. + UR_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP = 0x2000, ///< [::ur_bool_t] returns true if the device supports the creation of + ///< bindless images + UR_DEVICE_INFO_BINDLESS_IMAGES_SHARED_USM_SUPPORT_EXP = 0x2001, ///< [::ur_bool_t] returns true if the device supports the creation of + ///< bindless images backed by shared USM + UR_DEVICE_INFO_BINDLESS_IMAGES_1D_USM_SUPPORT_EXP = 0x2002, ///< [::ur_bool_t] returns true if the device supports the creation of 1D + ///< bindless images backed by USM + UR_DEVICE_INFO_BINDLESS_IMAGES_2D_USM_SUPPORT_EXP = 0x2003, ///< [::ur_bool_t] returns true if the device supports the creation of 2D + ///< bindless images backed by USM + UR_DEVICE_INFO_IMAGE_PITCH_ALIGN_EXP = 0x2004, ///< [uint32_t] returns the required alignment of the pitch between two + ///< rows of an image in bytes + UR_DEVICE_INFO_MAX_IMAGE_LINEAR_WIDTH_EXP = 0x2005, ///< [size_t] returns the maximum linear width allowed for images allocated + ///< using USM + UR_DEVICE_INFO_MAX_IMAGE_LINEAR_HEIGHT_EXP = 0x2006, ///< [size_t] returns the maximum linear height allowed for images + ///< allocated using USM + UR_DEVICE_INFO_MAX_IMAGE_LINEAR_PITCH_EXP = 0x2007, ///< [size_t] returns the maximum linear pitch allowed for images allocated + ///< using USM + UR_DEVICE_INFO_MIPMAP_SUPPORT_EXP = 0x2008, ///< [::ur_bool_t] returns true if the device supports allocating mipmap + ///< resources + UR_DEVICE_INFO_MIPMAP_ANISOTROPY_SUPPORT_EXP = 0x2009, ///< [::ur_bool_t] returns true if the device supports sampling mipmap + ///< images with anisotropic filtering + UR_DEVICE_INFO_MIPMAP_MAX_ANISOTROPY_EXP = 0x200A, ///< [uint32_t] returns the maximum anisotropic ratio supported by the + ///< device + UR_DEVICE_INFO_MIPMAP_LEVEL_REFERENCE_SUPPORT_EXP = 0x200B, ///< [::ur_bool_t] returns true if the device supports using images created + ///< from individual mipmap levels + UR_DEVICE_INFO_INTEROP_MEMORY_IMPORT_SUPPORT_EXP = 0x200C, ///< [::ur_bool_t] returns true if the device supports importing external + ///< memory resources + UR_DEVICE_INFO_INTEROP_MEMORY_EXPORT_SUPPORT_EXP = 0x200D, ///< [::ur_bool_t] returns true if the device supports exporting internal + ///< memory resources + UR_DEVICE_INFO_INTEROP_SEMAPHORE_IMPORT_SUPPORT_EXP = 0x200E, ///< [::ur_bool_t] returns true if the device supports importing external + ///< semaphore resources + UR_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP = 0x200F, ///< [::ur_bool_t] returns true if the device supports exporting internal + ///< event resources /// @cond UR_DEVICE_INFO_FORCE_UINT32 = 0x7fffffff /// @endcond @@ -1166,7 +1649,7 @@ typedef union ur_device_partition_value_t { uint32_t count; ///< [in] Number of compute units in a sub-device when partitioning with ///< ::UR_DEVICE_PARTITION_BY_COUNTS. ur_device_affinity_domain_flags_t affinity_domain; ///< [in] The affinity domain to partition for when partitioning with - ///< $UR_DEVICE_PARTITION_BY_AFFINITY_DOMAIN. + ///< ::UR_DEVICE_PARTITION_BY_AFFINITY_DOMAIN. } ur_device_partition_value_t; @@ -1174,7 +1657,7 @@ typedef union ur_device_partition_value_t { /// @brief Device partition property typedef struct ur_device_partition_property_t { ur_device_partition_t type; ///< [in] The partitioning type to be used. - ur_device_partition_value_t value; ///< [in] The paritioning value. + ur_device_partition_value_t value; ///< [in][tagged_by(type)] The partitioning value. } ur_device_partition_property_t; @@ -1344,6 +1827,8 @@ typedef enum ur_device_exec_capability_flag_t { /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeDevice` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetNativeHandle( ur_device_handle_t hDevice, ///< [in] handle of the device. @@ -1377,13 +1862,14 @@ typedef struct ur_device_native_properties_t { /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeDevice` /// + `NULL == hPlatform` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phDevice` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. UR_APIEXPORT ur_result_t UR_APICALL urDeviceCreateWithNativeHandle( - ur_native_handle_t hNativeDevice, ///< [in] the native handle of the device. + ur_native_handle_t hNativeDevice, ///< [in][nocheck] the native handle of the device. ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance const ur_device_native_properties_t *pProperties, ///< [in][optional] pointer to native device properties struct. ur_device_handle_t *phDevice ///< [out] pointer to the handle of the device object created. @@ -1680,6 +2166,8 @@ urContextGetInfo( /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeContext` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. UR_APIEXPORT ur_result_t UR_APICALL urContextGetNativeHandle( ur_context_handle_t hContext, ///< [in] handle of the context. @@ -1712,14 +2200,14 @@ typedef struct ur_context_native_properties_t { /// - ::UR_RESULT_ERROR_UNINITIALIZED /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC -/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phDevices` /// + `NULL == phContext` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. UR_APIEXPORT ur_result_t UR_APICALL urContextCreateWithNativeHandle( - ur_native_handle_t hNativeContext, ///< [in] the native handle of the context. + ur_native_handle_t hNativeContext, ///< [in][nocheck] the native handle of the context. uint32_t numDevices, ///< [in] number of devices associated with the context const ur_device_handle_t *phDevices, ///< [in][range(0, numDevices)] list of devices associated with the context const ur_context_native_properties_t *pProperties, ///< [in][optional] pointer to native context properties struct @@ -2158,6 +2646,8 @@ urMemBufferPartition( /// + `NULL == hMem` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeMem` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. UR_APIEXPORT ur_result_t UR_APICALL urMemGetNativeHandle( ur_mem_handle_t hMem, ///< [in] handle of the mem. @@ -2190,13 +2680,14 @@ typedef struct ur_mem_native_properties_t { /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeMem` /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phMem` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. UR_APIEXPORT ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( - ur_native_handle_t hNativeMem, ///< [in] the native handle to the memory. + ur_native_handle_t hNativeMem, ///< [in][nocheck] the native handle to the memory. ur_context_handle_t hContext, ///< [in] handle of the context object. const ur_mem_native_properties_t *pProperties, ///< [in][optional] pointer to native memory creation properties. ur_mem_handle_t *phMem ///< [out] pointer to handle of buffer memory object created. @@ -2216,15 +2707,16 @@ urMemBufferCreateWithNativeHandle( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeMem` /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == pImageFormat` /// + `NULL == pImageDesc` /// + `NULL == phMem` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. UR_APIEXPORT ur_result_t UR_APICALL urMemImageCreateWithNativeHandle( - ur_native_handle_t hNativeMem, ///< [in] the native handle to the memory. + ur_native_handle_t hNativeMem, ///< [in][nocheck] the native handle to the memory. ur_context_handle_t hContext, ///< [in] handle of the context object. const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification. const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description. @@ -2294,6 +2786,17 @@ urMemGetInfo( /// + `NULL == hMemory` /// - ::UR_RESULT_ERROR_INVALID_ENUMERATION /// + `::UR_IMAGE_INFO_DEPTH < propName` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION +/// + If `propName` is not supported by the adapter. +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `propSize == 0 && pPropValue != NULL` +/// + If `propSize` is less than the real number of bytes needed to return the info. +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `propSize != 0 && pPropValue == NULL` +/// + `pPropValue == NULL && pPropSizeRet == NULL` +/// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY UR_APIEXPORT ur_result_t UR_APICALL urMemImageGetInfo( ur_mem_handle_t hMemory, ///< [in] handle to the image object being queried. @@ -2509,6 +3012,8 @@ urSamplerGetInfo( /// + `NULL == hSampler` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeSampler` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. UR_APIEXPORT ur_result_t UR_APICALL urSamplerGetNativeHandle( ur_sampler_handle_t hSampler, ///< [in] handle of the sampler. @@ -2542,13 +3047,14 @@ typedef struct ur_sampler_native_properties_t { /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeSampler` /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phSampler` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. UR_APIEXPORT ur_result_t UR_APICALL urSamplerCreateWithNativeHandle( - ur_native_handle_t hNativeSampler, ///< [in] the native handle of the sampler. + ur_native_handle_t hNativeSampler, ///< [in][nocheck] the native handle of the sampler. ur_context_handle_t hContext, ///< [in] handle of the context object const ur_sampler_native_properties_t *pProperties, ///< [in][optional] pointer to native sampler properties struct. ur_sampler_handle_t *phSampler ///< [out] pointer to the handle of the sampler object created. @@ -3053,6 +3559,18 @@ typedef enum ur_virtual_mem_granularity_info_t { /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_ENUMERATION /// + `::UR_VIRTUAL_MEM_GRANULARITY_INFO_RECOMMENDED < propName` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION +/// + If `propName` is not supported by the adapter. +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `propSize == 0 && pPropValue != NULL` +/// + If `propSize` is less than the real number of bytes needed to return the info. +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `propSize != 0 && pPropValue == NULL` +/// + `pPropValue == NULL && pPropSizeRet == NULL` +/// - ::UR_RESULT_ERROR_INVALID_DEVICE +/// - ::UR_RESULT_ERROR_INVALID_CONTEXT +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY UR_APIEXPORT ur_result_t UR_APICALL urVirtualMemGranularityGetInfo( ur_context_handle_t hContext, ///< [in] handle of the context object. @@ -3190,7 +3708,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urVirtualMemSetAccess( ur_context_handle_t hContext, ///< [in] handle to the context object. const void *pStart, ///< [in] pointer to the start of the virtual memory range. - size_t size, ///< [in] size in bytes of the virutal memory range. + size_t size, ///< [in] size in bytes of the virtual memory range. ur_virtual_mem_access_flags_t flags ///< [in] access flags to set for the mapped virtual memory range. ); @@ -3269,11 +3787,13 @@ typedef struct ur_physical_mem_properties_t { /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phPhysicalMem` +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + If size is not a multiple of ::UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM. UR_APIEXPORT ur_result_t UR_APICALL urPhysicalMemCreate( ur_context_handle_t hContext, ///< [in] handle of the context object. ur_device_handle_t hDevice, ///< [in] handle of the device object. - size_t size, ///< [in] size in bytes of phyisical memory to allocate, must be a multiple + size_t size, ///< [in] size in bytes of physical memory to allocate, must be a multiple ///< of ::UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM. const ur_physical_mem_properties_t *pProperties, ///< [in][optional] pointer to physical memory creation properties. ur_physical_mem_handle_t *phPhysicalMem ///< [out] pointer to handle of physical memory object created. @@ -3346,11 +3866,11 @@ typedef union ur_program_metadata_value_t { /////////////////////////////////////////////////////////////////////////////// /// @brief Program metadata property. typedef struct ur_program_metadata_t { - char *pName; ///< [in] null-terminated metadata name. + const char *pName; ///< [in] null-terminated metadata name. ur_program_metadata_type_t type; ///< [in] the type of metadata value. size_t size; ///< [in] size in bytes of the data pointed to by value.pData, or 0 when ///< value size is less than 64-bits and is stored directly in value.data. - ur_program_metadata_value_t value; ///< [in] the metadata value storage. + ur_program_metadata_value_t value; ///< [in][tagged_by(type)] the metadata value storage. } ur_program_metadata_t; @@ -3445,7 +3965,7 @@ urProgramCreateWithBinary( /// /// @details /// - The application may call this function from simultaneous threads. -/// - Following a succesful call to this entry point, the program passed +/// - Following a successful call to this entry point, the program passed /// will contain a binary of the ::UR_PROGRAM_BINARY_TYPE_EXECUTABLE type /// for each device in `hContext`. /// @@ -3477,9 +3997,9 @@ urProgramBuild( /// /// @details /// - The application may call this function from simultaneous threads. -/// - Following a succesful call to this entry point `hProgram` will contain -/// a binary of the ::UR_PROGRAM_BINARY_TYPE_COMPILED_OBJECT type for each -/// device in `hContext`. +/// - Following a successful call to this entry point `hProgram` will +/// contain a binary of the ::UR_PROGRAM_BINARY_TYPE_COMPILED_OBJECT type +/// for each device in `hContext`. /// /// @remarks /// _Analogues_ @@ -3509,8 +4029,8 @@ urProgramCompile( /// /// @details /// - The application may call this function from simultaneous threads. -/// - Following a succesful call to this entry point the program returned in -/// `phProgram` will contain a binary of the +/// - Following a successful call to this entry point the program returned +/// in `phProgram` will contain a binary of the /// ::UR_PROGRAM_BINARY_TYPE_EXECUTABLE type for each device in /// `hContext`. /// @@ -3828,6 +4348,8 @@ urProgramSetSpecializationConstants( /// + `NULL == hProgram` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeProgram` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. UR_APIEXPORT ur_result_t UR_APICALL urProgramGetNativeHandle( ur_program_handle_t hProgram, ///< [in] handle of the program. @@ -3861,13 +4383,14 @@ typedef struct ur_program_native_properties_t { /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeProgram` /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phProgram` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. UR_APIEXPORT ur_result_t UR_APICALL urProgramCreateWithNativeHandle( - ur_native_handle_t hNativeProgram, ///< [in] the native handle of the program. + ur_native_handle_t hNativeProgram, ///< [in][nocheck] the native handle of the program. ur_context_handle_t hContext, ///< [in] handle of the context instance const ur_program_native_properties_t *pProperties, ///< [in][optional] pointer to native program properties struct. ur_program_handle_t *phProgram ///< [out] pointer to the handle of the program object created. @@ -4030,7 +4553,7 @@ typedef enum ur_kernel_sub_group_info_t { } ur_kernel_sub_group_info_t; /////////////////////////////////////////////////////////////////////////////// -/// @brief Kernel Cache Configuartion. +/// @brief Kernel Cache Configuration. typedef enum ur_kernel_cache_config_t { UR_KERNEL_CACHE_CONFIG_DEFAULT = 0, ///< No preference for SLM or data cache. UR_KERNEL_CACHE_CONFIG_LARGE_SLM = 1, ///< Large Shared Local Memory (SLM) size. @@ -4408,6 +4931,8 @@ urKernelSetSpecializationConstants( /// + `NULL == hKernel` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeKernel` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. UR_APIEXPORT ur_result_t UR_APICALL urKernelGetNativeHandle( ur_kernel_handle_t hKernel, ///< [in] handle of the kernel. @@ -4441,14 +4966,15 @@ typedef struct ur_kernel_native_properties_t { /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeKernel` /// + `NULL == hContext` /// + `NULL == hProgram` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phKernel` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. UR_APIEXPORT ur_result_t UR_APICALL urKernelCreateWithNativeHandle( - ur_native_handle_t hNativeKernel, ///< [in] the native handle of the kernel. + ur_native_handle_t hNativeKernel, ///< [in][nocheck] the native handle of the kernel. ur_context_handle_t hContext, ///< [in] handle of the context object ur_program_handle_t hProgram, ///< [in] handle of the program associated with the kernel const ur_kernel_native_properties_t *pProperties, ///< [in][optional] pointer to native kernel properties struct @@ -4700,6 +5226,8 @@ typedef struct ur_queue_native_desc_t { /// + `NULL == hQueue` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeQueue` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. UR_APIEXPORT ur_result_t UR_APICALL urQueueGetNativeHandle( ur_queue_handle_t hQueue, ///< [in] handle of the queue. @@ -4734,14 +5262,15 @@ typedef struct ur_queue_native_properties_t { /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeQueue` /// + `NULL == hContext` /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phQueue` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. UR_APIEXPORT ur_result_t UR_APICALL urQueueCreateWithNativeHandle( - ur_native_handle_t hNativeQueue, ///< [in] the native handle of the queue. + ur_native_handle_t hNativeQueue, ///< [in][nocheck] the native handle of the queue. ur_context_handle_t hContext, ///< [in] handle of the context object ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_queue_native_properties_t *pProperties, ///< [in][optional] pointer to native queue properties struct @@ -5022,325 +5551,147 @@ urEventRetain( /////////////////////////////////////////////////////////////////////////////// /// @brief Decrement the event object's reference count and delete the event /// object if the reference count becomes zero. -/// -/// @remarks -/// _Analogues_ -/// - **clReleaseEvent** -/// -/// @returns -/// - ::UR_RESULT_SUCCESS -/// - ::UR_RESULT_ERROR_UNINITIALIZED -/// - ::UR_RESULT_ERROR_DEVICE_LOST -/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC -/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hEvent` -/// - ::UR_RESULT_ERROR_INVALID_EVENT -/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES -/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY -UR_APIEXPORT ur_result_t UR_APICALL -urEventRelease( - ur_event_handle_t hEvent ///< [in] handle of the event object -); - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Return platform native event handle. -/// -/// @details -/// - Retrieved native handle can be used for direct interaction with the -/// native platform driver. -/// - Use interoperability platform extensions to convert native handle to -/// native type. -/// - The application may call this function from simultaneous threads for -/// the same context. -/// - The implementation of this function should be thread-safe. -/// -/// @returns -/// - ::UR_RESULT_SUCCESS -/// - ::UR_RESULT_ERROR_UNINITIALIZED -/// - ::UR_RESULT_ERROR_DEVICE_LOST -/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC -/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hEvent` -/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER -/// + `NULL == phNativeEvent` -UR_APIEXPORT ur_result_t UR_APICALL -urEventGetNativeHandle( - ur_event_handle_t hEvent, ///< [in] handle of the event. - ur_native_handle_t *phNativeEvent ///< [out] a pointer to the native handle of the event. -); - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Properties for for ::urEventCreateWithNativeHandle. -typedef struct ur_event_native_properties_t { - ur_structure_type_t stype; ///< [in] type of this structure, must be - ///< ::UR_STRUCTURE_TYPE_EVENT_NATIVE_PROPERTIES - void *pNext; ///< [in,out][optional] pointer to extension-specific structure - bool isNativeHandleOwned; ///< [in] Indicates UR owns the native handle or if it came from an interoperability - ///< operation in the application that asked to not transfer the ownership to - ///< the unified-runtime. - -} ur_event_native_properties_t; - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Create runtime event object from native event handle. -/// -/// @details -/// - Creates runtime event handle from native driver event handle. -/// - The application may call this function from simultaneous threads for -/// the same context. -/// - The implementation of this function should be thread-safe. -/// -/// @returns -/// - ::UR_RESULT_SUCCESS -/// - ::UR_RESULT_ERROR_UNINITIALIZED -/// - ::UR_RESULT_ERROR_DEVICE_LOST -/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC -/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeEvent` -/// + `NULL == hContext` -/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER -/// + `NULL == phEvent` -UR_APIEXPORT ur_result_t UR_APICALL -urEventCreateWithNativeHandle( - ur_native_handle_t hNativeEvent, ///< [in] the native handle of the event. - ur_context_handle_t hContext, ///< [in] handle of the context object - const ur_event_native_properties_t *pProperties, ///< [in][optional] pointer to native event properties struct - ur_event_handle_t *phEvent ///< [out] pointer to the handle of the event object created. -); - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Event states for all events. -typedef enum ur_execution_info_t { - UR_EXECUTION_INFO_EXECUTION_INFO_COMPLETE = 0, ///< Indicates that the event has completed. - UR_EXECUTION_INFO_EXECUTION_INFO_RUNNING = 1, ///< Indicates that the device has started processing this event. - UR_EXECUTION_INFO_EXECUTION_INFO_SUBMITTED = 2, ///< Indicates that the event has been submitted by the host to the device. - UR_EXECUTION_INFO_EXECUTION_INFO_QUEUED = 3, ///< Indicates that the event has been queued, this is the initial state of - ///< events. - /// @cond - UR_EXECUTION_INFO_FORCE_UINT32 = 0x7fffffff - /// @endcond - -} ur_execution_info_t; - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Event callback function that can be registered by the application. -typedef void (*ur_event_callback_t)( - ur_event_handle_t hEvent, ///< [in] handle to event - ur_execution_info_t execStatus, ///< [in] execution status of the event - void *pUserData ///< [in][out] pointer to data to be passed to callback -); - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Register a user callback function for a specific command execution -/// status. -/// -/// @details -/// - The registered callback function will be called when the execution -/// status of command associated with event changes to an execution status -/// equal to or past the status specified by command_exec_status. -/// - The application may call this function from simultaneous threads for -/// the same context. -/// - The implementation of this function should be thread-safe. -/// -/// @returns -/// - ::UR_RESULT_SUCCESS -/// - ::UR_RESULT_ERROR_UNINITIALIZED -/// - ::UR_RESULT_ERROR_DEVICE_LOST -/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC -/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hEvent` -/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION -/// + `::UR_EXECUTION_INFO_EXECUTION_INFO_QUEUED < execStatus` -/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER -/// + `NULL == pfnNotify` -UR_APIEXPORT ur_result_t UR_APICALL -urEventSetCallback( - ur_event_handle_t hEvent, ///< [in] handle of the event object - ur_execution_info_t execStatus, ///< [in] execution status of the event - ur_event_callback_t pfnNotify, ///< [in] execution status of the event - void *pUserData ///< [in][out][optional] pointer to data to be passed to callback. -); - -#if !defined(__GNUC__) -#pragma endregion -#endif -// Intel 'oneAPI' Unified Runtime function registry -#if !defined(__GNUC__) -#pragma region registry -#endif -/////////////////////////////////////////////////////////////////////////////// -/// @brief Defines unique stable identifiers for all functions -typedef enum ur_function_t { - UR_FUNCTION_CONTEXT_CREATE = 1, ///< Enumerator for ::urContextCreate - UR_FUNCTION_CONTEXT_RETAIN = 2, ///< Enumerator for ::urContextRetain - UR_FUNCTION_CONTEXT_RELEASE = 3, ///< Enumerator for ::urContextRelease - UR_FUNCTION_CONTEXT_GET_INFO = 4, ///< Enumerator for ::urContextGetInfo - UR_FUNCTION_CONTEXT_GET_NATIVE_HANDLE = 5, ///< Enumerator for ::urContextGetNativeHandle - UR_FUNCTION_CONTEXT_CREATE_WITH_NATIVE_HANDLE = 6, ///< Enumerator for ::urContextCreateWithNativeHandle - UR_FUNCTION_CONTEXT_SET_EXTENDED_DELETER = 7, ///< Enumerator for ::urContextSetExtendedDeleter - UR_FUNCTION_DEVICE_GET = 8, ///< Enumerator for ::urDeviceGet - UR_FUNCTION_DEVICE_GET_INFO = 9, ///< Enumerator for ::urDeviceGetInfo - UR_FUNCTION_DEVICE_RETAIN = 10, ///< Enumerator for ::urDeviceRetain - UR_FUNCTION_DEVICE_RELEASE = 11, ///< Enumerator for ::urDeviceRelease - UR_FUNCTION_DEVICE_PARTITION = 12, ///< Enumerator for ::urDevicePartition - UR_FUNCTION_DEVICE_SELECT_BINARY = 13, ///< Enumerator for ::urDeviceSelectBinary - UR_FUNCTION_DEVICE_GET_NATIVE_HANDLE = 14, ///< Enumerator for ::urDeviceGetNativeHandle - UR_FUNCTION_DEVICE_CREATE_WITH_NATIVE_HANDLE = 15, ///< Enumerator for ::urDeviceCreateWithNativeHandle - UR_FUNCTION_DEVICE_GET_GLOBAL_TIMESTAMPS = 16, ///< Enumerator for ::urDeviceGetGlobalTimestamps - UR_FUNCTION_ENQUEUE_KERNEL_LAUNCH = 17, ///< Enumerator for ::urEnqueueKernelLaunch - UR_FUNCTION_ENQUEUE_EVENTS_WAIT = 18, ///< Enumerator for ::urEnqueueEventsWait - UR_FUNCTION_ENQUEUE_EVENTS_WAIT_WITH_BARRIER = 19, ///< Enumerator for ::urEnqueueEventsWaitWithBarrier - UR_FUNCTION_ENQUEUE_MEM_BUFFER_READ = 20, ///< Enumerator for ::urEnqueueMemBufferRead - UR_FUNCTION_ENQUEUE_MEM_BUFFER_WRITE = 21, ///< Enumerator for ::urEnqueueMemBufferWrite - UR_FUNCTION_ENQUEUE_MEM_BUFFER_READ_RECT = 22, ///< Enumerator for ::urEnqueueMemBufferReadRect - UR_FUNCTION_ENQUEUE_MEM_BUFFER_WRITE_RECT = 23, ///< Enumerator for ::urEnqueueMemBufferWriteRect - UR_FUNCTION_ENQUEUE_MEM_BUFFER_COPY = 24, ///< Enumerator for ::urEnqueueMemBufferCopy - UR_FUNCTION_ENQUEUE_MEM_BUFFER_COPY_RECT = 25, ///< Enumerator for ::urEnqueueMemBufferCopyRect - UR_FUNCTION_ENQUEUE_MEM_BUFFER_FILL = 26, ///< Enumerator for ::urEnqueueMemBufferFill - UR_FUNCTION_ENQUEUE_MEM_IMAGE_READ = 27, ///< Enumerator for ::urEnqueueMemImageRead - UR_FUNCTION_ENQUEUE_MEM_IMAGE_WRITE = 28, ///< Enumerator for ::urEnqueueMemImageWrite - UR_FUNCTION_ENQUEUE_MEM_IMAGE_COPY = 29, ///< Enumerator for ::urEnqueueMemImageCopy - UR_FUNCTION_ENQUEUE_MEM_BUFFER_MAP = 30, ///< Enumerator for ::urEnqueueMemBufferMap - UR_FUNCTION_ENQUEUE_MEM_UNMAP = 31, ///< Enumerator for ::urEnqueueMemUnmap - UR_FUNCTION_ENQUEUE_USM_FILL = 32, ///< Enumerator for ::urEnqueueUSMFill - UR_FUNCTION_ENQUEUE_USM_MEMCPY = 33, ///< Enumerator for ::urEnqueueUSMMemcpy - UR_FUNCTION_ENQUEUE_USM_PREFETCH = 34, ///< Enumerator for ::urEnqueueUSMPrefetch - UR_FUNCTION_ENQUEUE_USM_ADVISE = 35, ///< Enumerator for ::urEnqueueUSMAdvise - UR_FUNCTION_ENQUEUE_DEVICE_GLOBAL_VARIABLE_WRITE = 38, ///< Enumerator for ::urEnqueueDeviceGlobalVariableWrite - UR_FUNCTION_ENQUEUE_DEVICE_GLOBAL_VARIABLE_READ = 39, ///< Enumerator for ::urEnqueueDeviceGlobalVariableRead - UR_FUNCTION_EVENT_GET_INFO = 40, ///< Enumerator for ::urEventGetInfo - UR_FUNCTION_EVENT_GET_PROFILING_INFO = 41, ///< Enumerator for ::urEventGetProfilingInfo - UR_FUNCTION_EVENT_WAIT = 42, ///< Enumerator for ::urEventWait - UR_FUNCTION_EVENT_RETAIN = 43, ///< Enumerator for ::urEventRetain - UR_FUNCTION_EVENT_RELEASE = 44, ///< Enumerator for ::urEventRelease - UR_FUNCTION_EVENT_GET_NATIVE_HANDLE = 45, ///< Enumerator for ::urEventGetNativeHandle - UR_FUNCTION_EVENT_CREATE_WITH_NATIVE_HANDLE = 46, ///< Enumerator for ::urEventCreateWithNativeHandle - UR_FUNCTION_EVENT_SET_CALLBACK = 47, ///< Enumerator for ::urEventSetCallback - UR_FUNCTION_KERNEL_CREATE = 48, ///< Enumerator for ::urKernelCreate - UR_FUNCTION_KERNEL_SET_ARG_VALUE = 49, ///< Enumerator for ::urKernelSetArgValue - UR_FUNCTION_KERNEL_SET_ARG_LOCAL = 50, ///< Enumerator for ::urKernelSetArgLocal - UR_FUNCTION_KERNEL_GET_INFO = 51, ///< Enumerator for ::urKernelGetInfo - UR_FUNCTION_KERNEL_GET_GROUP_INFO = 52, ///< Enumerator for ::urKernelGetGroupInfo - UR_FUNCTION_KERNEL_GET_SUB_GROUP_INFO = 53, ///< Enumerator for ::urKernelGetSubGroupInfo - UR_FUNCTION_KERNEL_RETAIN = 54, ///< Enumerator for ::urKernelRetain - UR_FUNCTION_KERNEL_RELEASE = 55, ///< Enumerator for ::urKernelRelease - UR_FUNCTION_KERNEL_SET_ARG_POINTER = 56, ///< Enumerator for ::urKernelSetArgPointer - UR_FUNCTION_KERNEL_SET_EXEC_INFO = 57, ///< Enumerator for ::urKernelSetExecInfo - UR_FUNCTION_KERNEL_SET_ARG_SAMPLER = 58, ///< Enumerator for ::urKernelSetArgSampler - UR_FUNCTION_KERNEL_SET_ARG_MEM_OBJ = 59, ///< Enumerator for ::urKernelSetArgMemObj - UR_FUNCTION_KERNEL_SET_SPECIALIZATION_CONSTANTS = 60, ///< Enumerator for ::urKernelSetSpecializationConstants - UR_FUNCTION_KERNEL_GET_NATIVE_HANDLE = 61, ///< Enumerator for ::urKernelGetNativeHandle - UR_FUNCTION_KERNEL_CREATE_WITH_NATIVE_HANDLE = 62, ///< Enumerator for ::urKernelCreateWithNativeHandle - UR_FUNCTION_MEM_IMAGE_CREATE = 63, ///< Enumerator for ::urMemImageCreate - UR_FUNCTION_MEM_BUFFER_CREATE = 64, ///< Enumerator for ::urMemBufferCreate - UR_FUNCTION_MEM_RETAIN = 65, ///< Enumerator for ::urMemRetain - UR_FUNCTION_MEM_RELEASE = 66, ///< Enumerator for ::urMemRelease - UR_FUNCTION_MEM_BUFFER_PARTITION = 67, ///< Enumerator for ::urMemBufferPartition - UR_FUNCTION_MEM_GET_NATIVE_HANDLE = 68, ///< Enumerator for ::urMemGetNativeHandle - UR_FUNCTION_ENQUEUE_READ_HOST_PIPE = 69, ///< Enumerator for ::urEnqueueReadHostPipe - UR_FUNCTION_MEM_GET_INFO = 70, ///< Enumerator for ::urMemGetInfo - UR_FUNCTION_MEM_IMAGE_GET_INFO = 71, ///< Enumerator for ::urMemImageGetInfo - UR_FUNCTION_PLATFORM_GET = 72, ///< Enumerator for ::urPlatformGet - UR_FUNCTION_PLATFORM_GET_INFO = 73, ///< Enumerator for ::urPlatformGetInfo - UR_FUNCTION_PLATFORM_GET_API_VERSION = 74, ///< Enumerator for ::urPlatformGetApiVersion - UR_FUNCTION_PLATFORM_GET_NATIVE_HANDLE = 75, ///< Enumerator for ::urPlatformGetNativeHandle - UR_FUNCTION_PLATFORM_CREATE_WITH_NATIVE_HANDLE = 76, ///< Enumerator for ::urPlatformCreateWithNativeHandle - UR_FUNCTION_PROGRAM_CREATE_WITH_IL = 78, ///< Enumerator for ::urProgramCreateWithIL - UR_FUNCTION_PROGRAM_CREATE_WITH_BINARY = 79, ///< Enumerator for ::urProgramCreateWithBinary - UR_FUNCTION_PROGRAM_BUILD = 80, ///< Enumerator for ::urProgramBuild - UR_FUNCTION_PROGRAM_COMPILE = 81, ///< Enumerator for ::urProgramCompile - UR_FUNCTION_PROGRAM_LINK = 82, ///< Enumerator for ::urProgramLink - UR_FUNCTION_PROGRAM_RETAIN = 83, ///< Enumerator for ::urProgramRetain - UR_FUNCTION_PROGRAM_RELEASE = 84, ///< Enumerator for ::urProgramRelease - UR_FUNCTION_PROGRAM_GET_FUNCTION_POINTER = 85, ///< Enumerator for ::urProgramGetFunctionPointer - UR_FUNCTION_PROGRAM_GET_INFO = 86, ///< Enumerator for ::urProgramGetInfo - UR_FUNCTION_PROGRAM_GET_BUILD_INFO = 87, ///< Enumerator for ::urProgramGetBuildInfo - UR_FUNCTION_PROGRAM_SET_SPECIALIZATION_CONSTANTS = 88, ///< Enumerator for ::urProgramSetSpecializationConstants - UR_FUNCTION_PROGRAM_GET_NATIVE_HANDLE = 89, ///< Enumerator for ::urProgramGetNativeHandle - UR_FUNCTION_PROGRAM_CREATE_WITH_NATIVE_HANDLE = 90, ///< Enumerator for ::urProgramCreateWithNativeHandle - UR_FUNCTION_QUEUE_GET_INFO = 91, ///< Enumerator for ::urQueueGetInfo - UR_FUNCTION_QUEUE_CREATE = 92, ///< Enumerator for ::urQueueCreate - UR_FUNCTION_QUEUE_RETAIN = 93, ///< Enumerator for ::urQueueRetain - UR_FUNCTION_QUEUE_RELEASE = 94, ///< Enumerator for ::urQueueRelease - UR_FUNCTION_QUEUE_GET_NATIVE_HANDLE = 95, ///< Enumerator for ::urQueueGetNativeHandle - UR_FUNCTION_QUEUE_CREATE_WITH_NATIVE_HANDLE = 96, ///< Enumerator for ::urQueueCreateWithNativeHandle - UR_FUNCTION_QUEUE_FINISH = 97, ///< Enumerator for ::urQueueFinish - UR_FUNCTION_QUEUE_FLUSH = 98, ///< Enumerator for ::urQueueFlush - UR_FUNCTION_INIT = 99, ///< Enumerator for ::urInit - UR_FUNCTION_TEAR_DOWN = 100, ///< Enumerator for ::urTearDown - UR_FUNCTION_SAMPLER_CREATE = 101, ///< Enumerator for ::urSamplerCreate - UR_FUNCTION_SAMPLER_RETAIN = 102, ///< Enumerator for ::urSamplerRetain - UR_FUNCTION_SAMPLER_RELEASE = 103, ///< Enumerator for ::urSamplerRelease - UR_FUNCTION_SAMPLER_GET_INFO = 104, ///< Enumerator for ::urSamplerGetInfo - UR_FUNCTION_SAMPLER_GET_NATIVE_HANDLE = 105, ///< Enumerator for ::urSamplerGetNativeHandle - UR_FUNCTION_SAMPLER_CREATE_WITH_NATIVE_HANDLE = 106, ///< Enumerator for ::urSamplerCreateWithNativeHandle - UR_FUNCTION_USM_HOST_ALLOC = 107, ///< Enumerator for ::urUSMHostAlloc - UR_FUNCTION_USM_DEVICE_ALLOC = 108, ///< Enumerator for ::urUSMDeviceAlloc - UR_FUNCTION_USM_SHARED_ALLOC = 109, ///< Enumerator for ::urUSMSharedAlloc - UR_FUNCTION_USM_FREE = 110, ///< Enumerator for ::urUSMFree - UR_FUNCTION_USM_GET_MEM_ALLOC_INFO = 111, ///< Enumerator for ::urUSMGetMemAllocInfo - UR_FUNCTION_USM_POOL_CREATE = 112, ///< Enumerator for ::urUSMPoolCreate - UR_FUNCTION_COMMAND_BUFFER_CREATE_EXP = 113, ///< Enumerator for ::urCommandBufferCreateExp - UR_FUNCTION_PLATFORM_GET_BACKEND_OPTION = 114, ///< Enumerator for ::urPlatformGetBackendOption - UR_FUNCTION_MEM_BUFFER_CREATE_WITH_NATIVE_HANDLE = 115, ///< Enumerator for ::urMemBufferCreateWithNativeHandle - UR_FUNCTION_MEM_IMAGE_CREATE_WITH_NATIVE_HANDLE = 116, ///< Enumerator for ::urMemImageCreateWithNativeHandle - UR_FUNCTION_ENQUEUE_WRITE_HOST_PIPE = 117, ///< Enumerator for ::urEnqueueWriteHostPipe - UR_FUNCTION_USM_POOL_RETAIN = 118, ///< Enumerator for ::urUSMPoolRetain - UR_FUNCTION_USM_POOL_RELEASE = 119, ///< Enumerator for ::urUSMPoolRelease - UR_FUNCTION_USM_POOL_GET_INFO = 120, ///< Enumerator for ::urUSMPoolGetInfo - UR_FUNCTION_COMMAND_BUFFER_RETAIN_EXP = 121, ///< Enumerator for ::urCommandBufferRetainExp - UR_FUNCTION_COMMAND_BUFFER_RELEASE_EXP = 122, ///< Enumerator for ::urCommandBufferReleaseExp - UR_FUNCTION_COMMAND_BUFFER_FINALIZE_EXP = 123, ///< Enumerator for ::urCommandBufferFinalizeExp - UR_FUNCTION_COMMAND_BUFFER_APPEND_KERNEL_LAUNCH_EXP = 125, ///< Enumerator for ::urCommandBufferAppendKernelLaunchExp - UR_FUNCTION_COMMAND_BUFFER_ENQUEUE_EXP = 128, ///< Enumerator for ::urCommandBufferEnqueueExp - UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMCPY_USM_EXP = 129, ///< Enumerator for ::urCommandBufferAppendMemcpyUSMExp - UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_COPY_EXP = 130, ///< Enumerator for ::urCommandBufferAppendMembufferCopyExp - UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_COPY_RECT_EXP = 131, ///< Enumerator for ::urCommandBufferAppendMembufferCopyRectExp - UR_FUNCTION_USM_PITCHED_ALLOC_EXP = 132, ///< Enumerator for ::urUSMPitchedAllocExp - UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_HANDLE_DESTROY_EXP = 133, ///< Enumerator for ::urBindlessImagesUnsampledImageHandleDestroyExp - UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_HANDLE_DESTROY_EXP = 134, ///< Enumerator for ::urBindlessImagesSampledImageHandleDestroyExp - UR_FUNCTION_BINDLESS_IMAGES_IMAGE_ALLOCATE_EXP = 135, ///< Enumerator for ::urBindlessImagesImageAllocateExp - UR_FUNCTION_BINDLESS_IMAGES_IMAGE_FREE_EXP = 136, ///< Enumerator for ::urBindlessImagesImageFreeExp - UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_CREATE_EXP = 137, ///< Enumerator for ::urBindlessImagesUnsampledImageCreateExp - UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_CREATE_EXP = 138, ///< Enumerator for ::urBindlessImagesSampledImageCreateExp - UR_FUNCTION_BINDLESS_IMAGES_IMAGE_COPY_EXP = 139, ///< Enumerator for ::urBindlessImagesImageCopyExp - UR_FUNCTION_BINDLESS_IMAGES_IMAGE_GET_INFO_EXP = 140, ///< Enumerator for ::urBindlessImagesImageGetInfoExp - UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_GET_LEVEL_EXP = 141, ///< Enumerator for ::urBindlessImagesMipmapGetLevelExp - UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_FREE_EXP = 142, ///< Enumerator for ::urBindlessImagesMipmapFreeExp - UR_FUNCTION_BINDLESS_IMAGES_IMPORT_OPAQUE_FD_EXP = 143, ///< Enumerator for ::urBindlessImagesImportOpaqueFDExp - UR_FUNCTION_BINDLESS_IMAGES_MAP_EXTERNAL_ARRAY_EXP = 144, ///< Enumerator for ::urBindlessImagesMapExternalArrayExp - UR_FUNCTION_BINDLESS_IMAGES_RELEASE_INTEROP_EXP = 145, ///< Enumerator for ::urBindlessImagesReleaseInteropExp - UR_FUNCTION_BINDLESS_IMAGES_IMPORT_EXTERNAL_SEMAPHORE_OPAQUE_FD_EXP = 146, ///< Enumerator for ::urBindlessImagesImportExternalSemaphoreOpaqueFDExp - UR_FUNCTION_BINDLESS_IMAGES_DESTROY_EXTERNAL_SEMAPHORE_EXP = 147, ///< Enumerator for ::urBindlessImagesDestroyExternalSemaphoreExp - UR_FUNCTION_BINDLESS_IMAGES_WAIT_EXTERNAL_SEMAPHORE_EXP = 148, ///< Enumerator for ::urBindlessImagesWaitExternalSemaphoreExp - UR_FUNCTION_BINDLESS_IMAGES_SIGNAL_EXTERNAL_SEMAPHORE_EXP = 149, ///< Enumerator for ::urBindlessImagesSignalExternalSemaphoreExp - UR_FUNCTION_PLATFORM_GET_LAST_ERROR = 150, ///< Enumerator for ::urPlatformGetLastError - UR_FUNCTION_ENQUEUE_USM_FILL_2D = 151, ///< Enumerator for ::urEnqueueUSMFill2D - UR_FUNCTION_ENQUEUE_USM_MEMCPY_2D = 152, ///< Enumerator for ::urEnqueueUSMMemcpy2D - UR_FUNCTION_VIRTUAL_MEM_GRANULARITY_GET_INFO = 153, ///< Enumerator for ::urVirtualMemGranularityGetInfo - UR_FUNCTION_VIRTUAL_MEM_RESERVE = 154, ///< Enumerator for ::urVirtualMemReserve - UR_FUNCTION_VIRTUAL_MEM_FREE = 155, ///< Enumerator for ::urVirtualMemFree - UR_FUNCTION_VIRTUAL_MEM_MAP = 156, ///< Enumerator for ::urVirtualMemMap - UR_FUNCTION_VIRTUAL_MEM_UNMAP = 157, ///< Enumerator for ::urVirtualMemUnmap - UR_FUNCTION_VIRTUAL_MEM_SET_ACCESS = 158, ///< Enumerator for ::urVirtualMemSetAccess - UR_FUNCTION_VIRTUAL_MEM_GET_INFO = 159, ///< Enumerator for ::urVirtualMemGetInfo - UR_FUNCTION_PHYSICAL_MEM_CREATE = 160, ///< Enumerator for ::urPhysicalMemCreate - UR_FUNCTION_PHYSICAL_MEM_RETAIN = 161, ///< Enumerator for ::urPhysicalMemRetain - UR_FUNCTION_PHYSICAL_MEM_RELEASE = 162, ///< Enumerator for ::urPhysicalMemRelease - UR_FUNCTION_USM_IMPORT_EXP = 163, ///< Enumerator for ::urUSMImportExp - UR_FUNCTION_USM_RELEASE_EXP = 164, ///< Enumerator for ::urUSMReleaseExp - UR_FUNCTION_USM_P2P_ENABLE_PEER_ACCESS_EXP = 165, ///< Enumerator for ::urUsmP2PEnablePeerAccessExp - UR_FUNCTION_USM_P2P_DISABLE_PEER_ACCESS_EXP = 166, ///< Enumerator for ::urUsmP2PDisablePeerAccessExp - UR_FUNCTION_USM_P2P_PEER_ACCESS_GET_INFO_EXP = 167, ///< Enumerator for ::urUsmP2PPeerAccessGetInfoExp - UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_WRITE_EXP = 168, ///< Enumerator for ::urCommandBufferAppendMembufferWriteExp - UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_READ_EXP = 169, ///< Enumerator for ::urCommandBufferAppendMembufferReadExp - UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_WRITE_RECT_EXP = 170, ///< Enumerator for ::urCommandBufferAppendMembufferWriteRectExp - UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_READ_RECT_EXP = 171, ///< Enumerator for ::urCommandBufferAppendMembufferReadRectExp +/// +/// @remarks +/// _Analogues_ +/// - **clReleaseEvent** +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hEvent` +/// - ::UR_RESULT_ERROR_INVALID_EVENT +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY +UR_APIEXPORT ur_result_t UR_APICALL +urEventRelease( + ur_event_handle_t hEvent ///< [in] handle of the event object +); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Return platform native event handle. +/// +/// @details +/// - Retrieved native handle can be used for direct interaction with the +/// native platform driver. +/// - Use interoperability platform extensions to convert native handle to +/// native type. +/// - The application may call this function from simultaneous threads for +/// the same context. +/// - The implementation of this function should be thread-safe. +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hEvent` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == phNativeEvent` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. +UR_APIEXPORT ur_result_t UR_APICALL +urEventGetNativeHandle( + ur_event_handle_t hEvent, ///< [in] handle of the event. + ur_native_handle_t *phNativeEvent ///< [out] a pointer to the native handle of the event. +); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Properties for for ::urEventCreateWithNativeHandle. +typedef struct ur_event_native_properties_t { + ur_structure_type_t stype; ///< [in] type of this structure, must be + ///< ::UR_STRUCTURE_TYPE_EVENT_NATIVE_PROPERTIES + void *pNext; ///< [in,out][optional] pointer to extension-specific structure + bool isNativeHandleOwned; ///< [in] Indicates UR owns the native handle or if it came from an interoperability + ///< operation in the application that asked to not transfer the ownership to + ///< the unified-runtime. + +} ur_event_native_properties_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Create runtime event object from native event handle. +/// +/// @details +/// - Creates runtime event handle from native driver event handle. +/// - The application may call this function from simultaneous threads for +/// the same context. +/// - The implementation of this function should be thread-safe. +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hContext` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == phEvent` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. +UR_APIEXPORT ur_result_t UR_APICALL +urEventCreateWithNativeHandle( + ur_native_handle_t hNativeEvent, ///< [in][nocheck] the native handle of the event. + ur_context_handle_t hContext, ///< [in] handle of the context object + const ur_event_native_properties_t *pProperties, ///< [in][optional] pointer to native event properties struct + ur_event_handle_t *phEvent ///< [out] pointer to the handle of the event object created. +); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Event states for all events. +typedef enum ur_execution_info_t { + UR_EXECUTION_INFO_EXECUTION_INFO_COMPLETE = 0, ///< Indicates that the event has completed. + UR_EXECUTION_INFO_EXECUTION_INFO_RUNNING = 1, ///< Indicates that the device has started processing this event. + UR_EXECUTION_INFO_EXECUTION_INFO_SUBMITTED = 2, ///< Indicates that the event has been submitted by the host to the device. + UR_EXECUTION_INFO_EXECUTION_INFO_QUEUED = 3, ///< Indicates that the event has been queued, this is the initial state of + ///< events. /// @cond - UR_FUNCTION_FORCE_UINT32 = 0x7fffffff + UR_EXECUTION_INFO_FORCE_UINT32 = 0x7fffffff /// @endcond -} ur_function_t; +} ur_execution_info_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Event callback function that can be registered by the application. +typedef void (*ur_event_callback_t)( + ur_event_handle_t hEvent, ///< [in] handle to event + ur_execution_info_t execStatus, ///< [in] execution status of the event + void *pUserData ///< [in][out] pointer to data to be passed to callback +); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Register a user callback function for a specific command execution +/// status. +/// +/// @details +/// - The registered callback function will be called when the execution +/// status of command associated with event changes to an execution status +/// equal to or past the status specified by command_exec_status. +/// - The application may call this function from simultaneous threads for +/// the same context. +/// - The implementation of this function should be thread-safe. +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hEvent` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `::UR_EXECUTION_INFO_EXECUTION_INFO_QUEUED < execStatus` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == pfnNotify` +UR_APIEXPORT ur_result_t UR_APICALL +urEventSetCallback( + ur_event_handle_t hEvent, ///< [in] handle of the event object + ur_execution_info_t execStatus, ///< [in] execution status of the event + ur_event_callback_t pfnNotify, ///< [in] execution status of the event + void *pUserData ///< [in][out][optional] pointer to data to be passed to callback. +); #if !defined(__GNUC__) #pragma endregion @@ -6578,7 +6929,7 @@ typedef struct ur_exp_interop_semaphore_handle_t_ *ur_exp_interop_semaphore_hand /// @brief Dictates the type of memory copy. typedef uint32_t ur_exp_image_copy_flags_t; typedef enum ur_exp_image_copy_flag_t { - UR_EXP_IMAGE_COPY_FLAG_HOST_TO_DEVICE = UR_BIT(0), ///< Host to device. + UR_EXP_IMAGE_COPY_FLAG_HOST_TO_DEVICE = UR_BIT(0), ///< Host to device UR_EXP_IMAGE_COPY_FLAG_DEVICE_TO_HOST = UR_BIT(1), ///< Device to host UR_EXP_IMAGE_COPY_FLAG_DEVICE_TO_DEVICE = UR_BIT(2), ///< Device to device /// @cond @@ -6589,6 +6940,26 @@ typedef enum ur_exp_image_copy_flag_t { /// @brief Bit Mask for validating ur_exp_image_copy_flags_t #define UR_EXP_IMAGE_COPY_FLAGS_MASK 0xfffffff8 +/////////////////////////////////////////////////////////////////////////////// +/// @brief File descriptor +typedef struct ur_exp_file_descriptor_t { + ur_structure_type_t stype; ///< [in] type of this structure, must be + ///< ::UR_STRUCTURE_TYPE_EXP_FILE_DESCRIPTOR + const void *pNext; ///< [in][optional] pointer to extension-specific structure + int fd; ///< [in] A file descriptor used for Linux and & MacOS operating systems. + +} ur_exp_file_descriptor_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Windows specific file handle +typedef struct ur_exp_win32_handle_t { + ur_structure_type_t stype; ///< [in] type of this structure, must be + ///< ::UR_STRUCTURE_TYPE_EXP_WIN32_HANDLE + const void *pNext; ///< [in][optional] pointer to extension-specific structure + void *handle; ///< [in] A win32 file handle. + +} ur_exp_win32_handle_t; + /////////////////////////////////////////////////////////////////////////////// /// @brief Describes mipmap sampler properties /// @@ -6596,18 +6967,37 @@ typedef enum ur_exp_image_copy_flag_t { /// - Specify these properties in ::urSamplerCreate via ::ur_sampler_desc_t /// as part of a `pNext` chain. typedef struct ur_exp_sampler_mip_properties_t { - ur_structure_type_t stype; ///< [in] type of this structure, must be - ///< ::UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES - void *pNext; ///< [in,out][optional] pointer to extension-specific structure - float minMipmapLevelClamp; ///< [in] minimum mipmap level from which we can sample, minimum value - ///< being 0 - float maxMipmapLevelClamp; ///< [in] maximum mipmap level from which we can sample, maximum value - ///< being the number of levels - float maxAnistropy; ///< [in] anisotropic ratio used when samplling the mipmap with anisotropic - ///< filtering + ur_structure_type_t stype; ///< [in] type of this structure, must be + ///< ::UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES + void *pNext; ///< [in,out][optional] pointer to extension-specific structure + float minMipmapLevelClamp; ///< [in] minimum mipmap level from which we can sample, minimum value + ///< being 0 + float maxMipmapLevelClamp; ///< [in] maximum mipmap level from which we can sample, maximum value + ///< being the number of levels + float maxAnisotropy; ///< [in] anisotropic ratio used when samplling the mipmap with anisotropic + ///< filtering + ur_sampler_filter_mode_t mipFilterMode; ///< [in] mipmap filter mode used for filtering between mipmap levels } ur_exp_sampler_mip_properties_t; +/////////////////////////////////////////////////////////////////////////////// +/// @brief Describes an interop memory resource descriptor +typedef struct ur_exp_interop_mem_desc_t { + ur_structure_type_t stype; ///< [in] type of this structure, must be + ///< ::UR_STRUCTURE_TYPE_EXP_INTEROP_MEM_DESC + const void *pNext; ///< [in][optional] pointer to extension-specific structure + +} ur_exp_interop_mem_desc_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Describes an interop semaphore resource descriptor +typedef struct ur_exp_interop_semaphore_desc_t { + ur_structure_type_t stype; ///< [in] type of this structure, must be + ///< ::UR_STRUCTURE_TYPE_EXP_INTEROP_SEMAPHORE_DESC + const void *pNext; ///< [in][optional] pointer to extension-specific structure + +} ur_exp_interop_semaphore_desc_t; + /////////////////////////////////////////////////////////////////////////////// /// @brief USM allocate pitched memory /// @@ -6676,12 +7066,14 @@ urUSMPitchedAllocExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hImage` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesUnsampledImageHandleDestroyExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_handle_t hImage ///< [in] pointer to handle of image object to destroy ); @@ -6699,12 +7091,14 @@ urBindlessImagesUnsampledImageHandleDestroyExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hImage` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesSampledImageHandleDestroyExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_handle_t hImage ///< [in] pointer to handle of image object to destroy ); @@ -6723,6 +7117,7 @@ urBindlessImagesSampledImageHandleDestroyExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == pImageFormat` /// + `NULL == pImageDesc` @@ -6736,6 +7131,7 @@ urBindlessImagesSampledImageHandleDestroyExp( UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description ur_exp_image_mem_handle_t *phImageMem ///< [out] pointer to handle of image memory allocated @@ -6755,12 +7151,14 @@ urBindlessImagesImageAllocateExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hImageMem` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageFreeExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem ///< [in] handle of image memory to be freed ); @@ -6778,6 +7176,7 @@ urBindlessImagesImageFreeExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hImageMem` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == pImageFormat` @@ -6793,6 +7192,7 @@ urBindlessImagesImageFreeExp( UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] handle to memory from which to create the image const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description @@ -6814,6 +7214,7 @@ urBindlessImagesUnsampledImageCreateExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hImageMem` /// + `NULL == hSampler` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER @@ -6831,6 +7232,7 @@ urBindlessImagesUnsampledImageCreateExp( UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] handle to memory from which to create the image const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description @@ -6855,7 +7257,7 @@ urBindlessImagesSampledImageCreateExp( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hContext` +/// + `NULL == hQueue` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == pDst` /// + `NULL == pSrc` @@ -6863,7 +7265,7 @@ urBindlessImagesSampledImageCreateExp( /// + `NULL == pImageDesc` /// - ::UR_RESULT_ERROR_INVALID_ENUMERATION /// + `::UR_EXP_IMAGE_COPY_FLAGS_MASK & imageCopyFlags` -/// - ::UR_RESULT_ERROR_INVALID_CONTEXT +/// - ::UR_RESULT_ERROR_INVALID_QUEUE /// - ::UR_RESULT_ERROR_INVALID_VALUE /// - ::UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR /// + `pImageDesc && UR_MEM_TYPE_IMAGE1D_BUFFER < pImageDesc->type` @@ -6871,12 +7273,20 @@ urBindlessImagesSampledImageCreateExp( /// - ::UR_RESULT_ERROR_INVALID_OPERATION UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp( - ur_context_handle_t hContext, ///< [in] handle of the context object + ur_queue_handle_t hQueue, ///< [in] handle of the queue object void *pDst, ///< [in] location the data will be copied to void *pSrc, ///< [in] location the data will be copied from const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description ur_exp_image_copy_flags_t imageCopyFlags, ///< [in] flags describing copy direction e.g. H2D or D2H + ur_rect_offset_t srcOffset, ///< [in] defines the (x,y,z) source offset in pixels in the 1D, 2D, or 3D + ///< image + ur_rect_offset_t dstOffset, ///< [in] defines the (x,y,z) destination offset in pixels in the 1D, 2D, + ///< or 3D image + ur_rect_region_t copyExtent, ///< [in] defines the (width, height, depth) in pixels of the 1D, 2D, or 3D + ///< region to copy + ur_rect_region_t hostExtent, ///< [in] defines the (width, height, depth) in pixels of the 1D, 2D, or 3D + ///< region on the host uint32_t numEventsInWaitList, ///< [in] size of the event wait list const ur_event_handle_t *phEventWaitList, ///< [in][optional][range(0, numEventsInWaitList)] pointer to a list of ///< events that must be complete before this command can be executed. @@ -6930,6 +7340,7 @@ urBindlessImagesImageGetInfoExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hImageMem` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phImageMem` @@ -6938,6 +7349,7 @@ urBindlessImagesImageGetInfoExp( UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] memory handle to the mipmap image uint32_t mipmapLevel, ///< [in] requested level of the mipmap ur_exp_image_mem_handle_t *phImageMem ///< [out] returning memory handle to the individual image @@ -6957,12 +7369,14 @@ urBindlessImagesMipmapGetLevelExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hMem` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hMem ///< [in] handle of image memory to be freed ); @@ -6980,17 +7394,20 @@ urBindlessImagesMipmapFreeExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == pInteropMemDesc` /// + `NULL == phInteropMem` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE /// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( - ur_context_handle_t hContext, ///< [in] handle of the context object - size_t size, ///< [in] size of the external memory - uint32_t fileDescriptor, ///< [in] the file descriptor - ur_exp_interop_mem_handle_t *phInteropMem ///< [out] interop memory handle to the external memory + ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object + size_t size, ///< [in] size of the external memory + ur_exp_interop_mem_desc_t *pInteropMemDesc, ///< [in] the interop memory descriptor + ur_exp_interop_mem_handle_t *phInteropMem ///< [out] interop memory handle to the external memory ); /////////////////////////////////////////////////////////////////////////////// @@ -7003,6 +7420,7 @@ urBindlessImagesImportOpaqueFDExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hInteropMem` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == pImageFormat` @@ -7018,10 +7436,11 @@ urBindlessImagesImportOpaqueFDExp( UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description ur_exp_interop_mem_handle_t hInteropMem, ///< [in] interop memory handle to the external memory - ur_exp_image_handle_t *phImageMem ///< [out] image memory handle to the externally allocated memory + ur_exp_image_mem_handle_t *phImageMem ///< [out] image memory handle to the externally allocated memory ); /////////////////////////////////////////////////////////////////////////////// @@ -7038,12 +7457,14 @@ urBindlessImagesMapExternalArrayExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hInteropMem` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_interop_mem_handle_t hInteropMem ///< [in] handle of interop memory to be freed ); @@ -7061,15 +7482,18 @@ urBindlessImagesReleaseInteropExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER -/// + `NULL == phInteropSemaphoreHandle` +/// + `NULL == pInteropSemaphoreDesc` +/// + `NULL == phInteropSemaphore` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreOpaqueFDExp( - ur_context_handle_t hContext, ///< [in] handle of the context object - uint32_t fileDescriptor, ///< [in] the file descriptor - ur_exp_interop_semaphore_handle_t *phInteropSemaphoreHandle ///< [out] interop semaphore handle to the external semaphore + ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object + ur_exp_interop_semaphore_desc_t *pInteropSemaphoreDesc, ///< [in] the interop semaphore descriptor + ur_exp_interop_semaphore_handle_t *phInteropSemaphore ///< [out] interop semaphore handle to the external semaphore ); /////////////////////////////////////////////////////////////////////////////// @@ -7086,12 +7510,14 @@ urBindlessImagesImportExternalSemaphoreOpaqueFDExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hInteropSemaphore` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesDestroyExternalSemaphoreExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_interop_semaphore_handle_t hInteropSemaphore ///< [in] handle of interop semaphore to be destroyed ); @@ -7807,11 +8233,58 @@ urUsmP2PPeerAccessGetInfoExp( #if !defined(__GNUC__) #pragma region callbacks #endif +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urLoaderConfigCreate +/// @details Each entry is a pointer to the parameter passed to the function; +/// allowing the callback the ability to modify the parameter's value +typedef struct ur_loader_config_create_params_t { + ur_loader_config_handle_t **pphLoaderConfig; +} ur_loader_config_create_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urLoaderConfigRetain +/// @details Each entry is a pointer to the parameter passed to the function; +/// allowing the callback the ability to modify the parameter's value +typedef struct ur_loader_config_retain_params_t { + ur_loader_config_handle_t *phLoaderConfig; +} ur_loader_config_retain_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urLoaderConfigRelease +/// @details Each entry is a pointer to the parameter passed to the function; +/// allowing the callback the ability to modify the parameter's value +typedef struct ur_loader_config_release_params_t { + ur_loader_config_handle_t *phLoaderConfig; +} ur_loader_config_release_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urLoaderConfigGetInfo +/// @details Each entry is a pointer to the parameter passed to the function; +/// allowing the callback the ability to modify the parameter's value +typedef struct ur_loader_config_get_info_params_t { + ur_loader_config_handle_t *phLoaderConfig; + ur_loader_config_info_t *ppropName; + size_t *ppropSize; + void **ppPropValue; + size_t **ppPropSizeRet; +} ur_loader_config_get_info_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urLoaderConfigEnableLayer +/// @details Each entry is a pointer to the parameter passed to the function; +/// allowing the callback the ability to modify the parameter's value +typedef struct ur_loader_config_enable_layer_params_t { + ur_loader_config_handle_t *phLoaderConfig; + const char **ppLayerName; +} ur_loader_config_enable_layer_params_t; + /////////////////////////////////////////////////////////////////////////////// /// @brief Function parameters for urPlatformGet /// @details Each entry is a pointer to the parameter passed to the function; /// allowing the callback the ability to modify the parameter's value typedef struct ur_platform_get_params_t { + ur_adapter_handle_t **pphAdapters; + uint32_t *pNumAdapters; uint32_t *pNumEntries; ur_platform_handle_t **pphPlatforms; uint32_t **ppNumPlatforms; @@ -7848,16 +8321,6 @@ typedef struct ur_platform_create_with_native_handle_params_t { ur_platform_handle_t **pphPlatform; } ur_platform_create_with_native_handle_params_t; -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function parameters for urPlatformGetLastError -/// @details Each entry is a pointer to the parameter passed to the function; -/// allowing the callback the ability to modify the parameter's value -typedef struct ur_platform_get_last_error_params_t { - ur_platform_handle_t *phPlatform; - const char ***pppMessage; - int32_t **ppError; -} ur_platform_get_last_error_params_t; - /////////////////////////////////////////////////////////////////////////////// /// @brief Function parameters for urPlatformGetApiVersion /// @details Each entry is a pointer to the parameter passed to the function; @@ -9011,6 +9474,7 @@ typedef struct ur_queue_flush_params_t { /// allowing the callback the ability to modify the parameter's value typedef struct ur_bindless_images_unsampled_image_handle_destroy_exp_params_t { ur_context_handle_t *phContext; + ur_device_handle_t *phDevice; ur_exp_image_handle_t *phImage; } ur_bindless_images_unsampled_image_handle_destroy_exp_params_t; @@ -9020,6 +9484,7 @@ typedef struct ur_bindless_images_unsampled_image_handle_destroy_exp_params_t { /// allowing the callback the ability to modify the parameter's value typedef struct ur_bindless_images_sampled_image_handle_destroy_exp_params_t { ur_context_handle_t *phContext; + ur_device_handle_t *phDevice; ur_exp_image_handle_t *phImage; } ur_bindless_images_sampled_image_handle_destroy_exp_params_t; @@ -9029,6 +9494,7 @@ typedef struct ur_bindless_images_sampled_image_handle_destroy_exp_params_t { /// allowing the callback the ability to modify the parameter's value typedef struct ur_bindless_images_image_allocate_exp_params_t { ur_context_handle_t *phContext; + ur_device_handle_t *phDevice; const ur_image_format_t **ppImageFormat; const ur_image_desc_t **ppImageDesc; ur_exp_image_mem_handle_t **pphImageMem; @@ -9040,6 +9506,7 @@ typedef struct ur_bindless_images_image_allocate_exp_params_t { /// allowing the callback the ability to modify the parameter's value typedef struct ur_bindless_images_image_free_exp_params_t { ur_context_handle_t *phContext; + ur_device_handle_t *phDevice; ur_exp_image_mem_handle_t *phImageMem; } ur_bindless_images_image_free_exp_params_t; @@ -9049,6 +9516,7 @@ typedef struct ur_bindless_images_image_free_exp_params_t { /// allowing the callback the ability to modify the parameter's value typedef struct ur_bindless_images_unsampled_image_create_exp_params_t { ur_context_handle_t *phContext; + ur_device_handle_t *phDevice; ur_exp_image_mem_handle_t *phImageMem; const ur_image_format_t **ppImageFormat; const ur_image_desc_t **ppImageDesc; @@ -9062,6 +9530,7 @@ typedef struct ur_bindless_images_unsampled_image_create_exp_params_t { /// allowing the callback the ability to modify the parameter's value typedef struct ur_bindless_images_sampled_image_create_exp_params_t { ur_context_handle_t *phContext; + ur_device_handle_t *phDevice; ur_exp_image_mem_handle_t *phImageMem; const ur_image_format_t **ppImageFormat; const ur_image_desc_t **ppImageDesc; @@ -9075,12 +9544,16 @@ typedef struct ur_bindless_images_sampled_image_create_exp_params_t { /// @details Each entry is a pointer to the parameter passed to the function; /// allowing the callback the ability to modify the parameter's value typedef struct ur_bindless_images_image_copy_exp_params_t { - ur_context_handle_t *phContext; + ur_queue_handle_t *phQueue; void **ppDst; void **ppSrc; const ur_image_format_t **ppImageFormat; const ur_image_desc_t **ppImageDesc; ur_exp_image_copy_flags_t *pimageCopyFlags; + ur_rect_offset_t *psrcOffset; + ur_rect_offset_t *pdstOffset; + ur_rect_region_t *pcopyExtent; + ur_rect_region_t *phostExtent; uint32_t *pnumEventsInWaitList; const ur_event_handle_t **pphEventWaitList; ur_event_handle_t **pphEvent; @@ -9103,6 +9576,7 @@ typedef struct ur_bindless_images_image_get_info_exp_params_t { /// allowing the callback the ability to modify the parameter's value typedef struct ur_bindless_images_mipmap_get_level_exp_params_t { ur_context_handle_t *phContext; + ur_device_handle_t *phDevice; ur_exp_image_mem_handle_t *phImageMem; uint32_t *pmipmapLevel; ur_exp_image_mem_handle_t **pphImageMem; @@ -9114,6 +9588,7 @@ typedef struct ur_bindless_images_mipmap_get_level_exp_params_t { /// allowing the callback the ability to modify the parameter's value typedef struct ur_bindless_images_mipmap_free_exp_params_t { ur_context_handle_t *phContext; + ur_device_handle_t *phDevice; ur_exp_image_mem_handle_t *phMem; } ur_bindless_images_mipmap_free_exp_params_t; @@ -9123,8 +9598,9 @@ typedef struct ur_bindless_images_mipmap_free_exp_params_t { /// allowing the callback the ability to modify the parameter's value typedef struct ur_bindless_images_import_opaque_fd_exp_params_t { ur_context_handle_t *phContext; + ur_device_handle_t *phDevice; size_t *psize; - uint32_t *pfileDescriptor; + ur_exp_interop_mem_desc_t **ppInteropMemDesc; ur_exp_interop_mem_handle_t **pphInteropMem; } ur_bindless_images_import_opaque_fd_exp_params_t; @@ -9134,10 +9610,11 @@ typedef struct ur_bindless_images_import_opaque_fd_exp_params_t { /// allowing the callback the ability to modify the parameter's value typedef struct ur_bindless_images_map_external_array_exp_params_t { ur_context_handle_t *phContext; + ur_device_handle_t *phDevice; const ur_image_format_t **ppImageFormat; const ur_image_desc_t **ppImageDesc; ur_exp_interop_mem_handle_t *phInteropMem; - ur_exp_image_handle_t **pphImageMem; + ur_exp_image_mem_handle_t **pphImageMem; } ur_bindless_images_map_external_array_exp_params_t; /////////////////////////////////////////////////////////////////////////////// @@ -9146,6 +9623,7 @@ typedef struct ur_bindless_images_map_external_array_exp_params_t { /// allowing the callback the ability to modify the parameter's value typedef struct ur_bindless_images_release_interop_exp_params_t { ur_context_handle_t *phContext; + ur_device_handle_t *phDevice; ur_exp_interop_mem_handle_t *phInteropMem; } ur_bindless_images_release_interop_exp_params_t; @@ -9155,8 +9633,9 @@ typedef struct ur_bindless_images_release_interop_exp_params_t { /// allowing the callback the ability to modify the parameter's value typedef struct ur_bindless_images_import_external_semaphore_opaque_fd_exp_params_t { ur_context_handle_t *phContext; - uint32_t *pfileDescriptor; - ur_exp_interop_semaphore_handle_t **pphInteropSemaphoreHandle; + ur_device_handle_t *phDevice; + ur_exp_interop_semaphore_desc_t **ppInteropSemaphoreDesc; + ur_exp_interop_semaphore_handle_t **pphInteropSemaphore; } ur_bindless_images_import_external_semaphore_opaque_fd_exp_params_t; /////////////////////////////////////////////////////////////////////////////// @@ -9165,6 +9644,7 @@ typedef struct ur_bindless_images_import_external_semaphore_opaque_fd_exp_params /// allowing the callback the ability to modify the parameter's value typedef struct ur_bindless_images_destroy_external_semaphore_exp_params_t { ur_context_handle_t *phContext; + ur_device_handle_t *phDevice; ur_exp_interop_semaphore_handle_t *phInteropSemaphore; } ur_bindless_images_destroy_external_semaphore_exp_params_t; @@ -9545,6 +10025,7 @@ typedef struct ur_usm_p2p_peer_access_get_info_exp_params_t { /// allowing the callback the ability to modify the parameter's value typedef struct ur_init_params_t { ur_device_init_flags_t *pdevice_flags; + ur_loader_config_handle_t *phLoaderConfig; } ur_init_params_t; /////////////////////////////////////////////////////////////////////////////// @@ -9555,6 +10036,54 @@ typedef struct ur_tear_down_params_t { void **ppParams; } ur_tear_down_params_t; +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urAdapterGet +/// @details Each entry is a pointer to the parameter passed to the function; +/// allowing the callback the ability to modify the parameter's value +typedef struct ur_adapter_get_params_t { + uint32_t *pNumEntries; + ur_adapter_handle_t **pphAdapters; + uint32_t **ppNumAdapters; +} ur_adapter_get_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urAdapterRelease +/// @details Each entry is a pointer to the parameter passed to the function; +/// allowing the callback the ability to modify the parameter's value +typedef struct ur_adapter_release_params_t { + ur_adapter_handle_t *phAdapter; +} ur_adapter_release_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urAdapterRetain +/// @details Each entry is a pointer to the parameter passed to the function; +/// allowing the callback the ability to modify the parameter's value +typedef struct ur_adapter_retain_params_t { + ur_adapter_handle_t *phAdapter; +} ur_adapter_retain_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urAdapterGetLastError +/// @details Each entry is a pointer to the parameter passed to the function; +/// allowing the callback the ability to modify the parameter's value +typedef struct ur_adapter_get_last_error_params_t { + ur_adapter_handle_t *phAdapter; + const char ***pppMessage; + int32_t **ppError; +} ur_adapter_get_last_error_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urAdapterGetInfo +/// @details Each entry is a pointer to the parameter passed to the function; +/// allowing the callback the ability to modify the parameter's value +typedef struct ur_adapter_get_info_params_t { + ur_adapter_handle_t *phAdapter; + ur_adapter_info_t *ppropName; + size_t *ppropSize; + void **ppPropValue; + size_t **ppPropSizeRet; +} ur_adapter_get_info_params_t; + /////////////////////////////////////////////////////////////////////////////// /// @brief Function parameters for urVirtualMemGranularityGetInfo /// @details Each entry is a pointer to the parameter passed to the function; diff --git a/include/ur_ddi.h b/include/ur_ddi.h index d99302ea94..958f5ca29b 100644 --- a/include/ur_ddi.h +++ b/include/ur_ddi.h @@ -24,6 +24,8 @@ extern "C" { /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urPlatformGet typedef ur_result_t(UR_APICALL *ur_pfnPlatformGet_t)( + ur_adapter_handle_t *, + uint32_t, uint32_t, ur_platform_handle_t *, uint32_t *); @@ -50,13 +52,6 @@ typedef ur_result_t(UR_APICALL *ur_pfnPlatformCreateWithNativeHandle_t)( const ur_platform_native_properties_t *, ur_platform_handle_t *); -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function-pointer for urPlatformGetLastError -typedef ur_result_t(UR_APICALL *ur_pfnPlatformGetLastError_t)( - ur_platform_handle_t, - const char **, - int32_t *); - /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urPlatformGetApiVersion typedef ur_result_t(UR_APICALL *ur_pfnPlatformGetApiVersion_t)( @@ -77,7 +72,6 @@ typedef struct ur_platform_dditable_t { ur_pfnPlatformGetInfo_t pfnGetInfo; ur_pfnPlatformGetNativeHandle_t pfnGetNativeHandle; ur_pfnPlatformCreateWithNativeHandle_t pfnCreateWithNativeHandle; - ur_pfnPlatformGetLastError_t pfnGetLastError; ur_pfnPlatformGetApiVersion_t pfnGetApiVersion; ur_pfnPlatformGetBackendOption_t pfnGetBackendOption; } ur_platform_dditable_t; @@ -1279,18 +1273,21 @@ typedef ur_result_t(UR_APICALL *ur_pfnGetQueueProcAddrTable_t)( /// @brief Function-pointer for urBindlessImagesUnsampledImageHandleDestroyExp typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesUnsampledImageHandleDestroyExp_t)( ur_context_handle_t, + ur_device_handle_t, ur_exp_image_handle_t); /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urBindlessImagesSampledImageHandleDestroyExp typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesSampledImageHandleDestroyExp_t)( ur_context_handle_t, + ur_device_handle_t, ur_exp_image_handle_t); /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urBindlessImagesImageAllocateExp typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesImageAllocateExp_t)( ur_context_handle_t, + ur_device_handle_t, const ur_image_format_t *, const ur_image_desc_t *, ur_exp_image_mem_handle_t *); @@ -1299,12 +1296,14 @@ typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesImageAllocateExp_t)( /// @brief Function-pointer for urBindlessImagesImageFreeExp typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesImageFreeExp_t)( ur_context_handle_t, + ur_device_handle_t, ur_exp_image_mem_handle_t); /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urBindlessImagesUnsampledImageCreateExp typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesUnsampledImageCreateExp_t)( ur_context_handle_t, + ur_device_handle_t, ur_exp_image_mem_handle_t, const ur_image_format_t *, const ur_image_desc_t *, @@ -1315,6 +1314,7 @@ typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesUnsampledImageCreateExp_t)( /// @brief Function-pointer for urBindlessImagesSampledImageCreateExp typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesSampledImageCreateExp_t)( ur_context_handle_t, + ur_device_handle_t, ur_exp_image_mem_handle_t, const ur_image_format_t *, const ur_image_desc_t *, @@ -1325,12 +1325,16 @@ typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesSampledImageCreateExp_t)( /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urBindlessImagesImageCopyExp typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesImageCopyExp_t)( - ur_context_handle_t, + ur_queue_handle_t, void *, void *, const ur_image_format_t *, const ur_image_desc_t *, ur_exp_image_copy_flags_t, + ur_rect_offset_t, + ur_rect_offset_t, + ur_rect_region_t, + ur_rect_region_t, uint32_t, const ur_event_handle_t *, ur_event_handle_t *); @@ -1347,6 +1351,7 @@ typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesImageGetInfoExp_t)( /// @brief Function-pointer for urBindlessImagesMipmapGetLevelExp typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesMipmapGetLevelExp_t)( ur_context_handle_t, + ur_device_handle_t, ur_exp_image_mem_handle_t, uint32_t, ur_exp_image_mem_handle_t *); @@ -1355,42 +1360,48 @@ typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesMipmapGetLevelExp_t)( /// @brief Function-pointer for urBindlessImagesMipmapFreeExp typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesMipmapFreeExp_t)( ur_context_handle_t, + ur_device_handle_t, ur_exp_image_mem_handle_t); /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urBindlessImagesImportOpaqueFDExp typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesImportOpaqueFDExp_t)( ur_context_handle_t, + ur_device_handle_t, size_t, - uint32_t, + ur_exp_interop_mem_desc_t *, ur_exp_interop_mem_handle_t *); /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urBindlessImagesMapExternalArrayExp typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesMapExternalArrayExp_t)( ur_context_handle_t, + ur_device_handle_t, const ur_image_format_t *, const ur_image_desc_t *, ur_exp_interop_mem_handle_t, - ur_exp_image_handle_t *); + ur_exp_image_mem_handle_t *); /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urBindlessImagesReleaseInteropExp typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesReleaseInteropExp_t)( ur_context_handle_t, + ur_device_handle_t, ur_exp_interop_mem_handle_t); /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urBindlessImagesImportExternalSemaphoreOpaqueFDExp typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesImportExternalSemaphoreOpaqueFDExp_t)( ur_context_handle_t, - uint32_t, + ur_device_handle_t, + ur_exp_interop_semaphore_desc_t *, ur_exp_interop_semaphore_handle_t *); /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urBindlessImagesDestroyExternalSemaphoreExp typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesDestroyExternalSemaphoreExp_t)( ur_context_handle_t, + ur_device_handle_t, ur_exp_interop_semaphore_handle_t); /////////////////////////////////////////////////////////////////////////////// @@ -1852,18 +1863,57 @@ typedef ur_result_t(UR_APICALL *ur_pfnGetUsmP2PExpProcAddrTable_t)( /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urInit typedef ur_result_t(UR_APICALL *ur_pfnInit_t)( - ur_device_init_flags_t); + ur_device_init_flags_t, + ur_loader_config_handle_t); /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urTearDown typedef ur_result_t(UR_APICALL *ur_pfnTearDown_t)( void *); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urAdapterGet +typedef ur_result_t(UR_APICALL *ur_pfnAdapterGet_t)( + uint32_t, + ur_adapter_handle_t *, + uint32_t *); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urAdapterRelease +typedef ur_result_t(UR_APICALL *ur_pfnAdapterRelease_t)( + ur_adapter_handle_t); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urAdapterRetain +typedef ur_result_t(UR_APICALL *ur_pfnAdapterRetain_t)( + ur_adapter_handle_t); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urAdapterGetLastError +typedef ur_result_t(UR_APICALL *ur_pfnAdapterGetLastError_t)( + ur_adapter_handle_t, + const char **, + int32_t *); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urAdapterGetInfo +typedef ur_result_t(UR_APICALL *ur_pfnAdapterGetInfo_t)( + ur_adapter_handle_t, + ur_adapter_info_t, + size_t, + void *, + size_t *); + /////////////////////////////////////////////////////////////////////////////// /// @brief Table of Global functions pointers typedef struct ur_global_dditable_t { ur_pfnInit_t pfnInit; ur_pfnTearDown_t pfnTearDown; + ur_pfnAdapterGet_t pfnAdapterGet; + ur_pfnAdapterRelease_t pfnAdapterRelease; + ur_pfnAdapterRetain_t pfnAdapterRetain; + ur_pfnAdapterGetLastError_t pfnAdapterGetLastError; + ur_pfnAdapterGetInfo_t pfnAdapterGetInfo; } ur_global_dditable_t; /////////////////////////////////////////////////////////////////////////////// diff --git a/scripts/README.md b/scripts/README.md index f7c41b445a..c51008a120 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -4,12 +4,10 @@ Python dependencies: * [PyYAML](https://pyyaml.org/) v3.13 * [Sphinx](https://www.sphinx-doc.org/en/master/) v2.2.2 -Installing Python dependencies: - ~~~~ - * Install all python requirements. - ~~~~ - python -m pip install -r ../third_party/requirements.txt - ~~~~ +To install all Python dependencies, execute: +```bash +$ python -m pip install -r ../third_party/requirements.txt +``` Documentation is generated from source code using Doxygen. * [Doxygen](http://www.doxygen.nl/) v1.8.15 diff --git a/scripts/YaML.md b/scripts/YaML.md index bbd1e76e0d..a735a7f7a4 100644 --- a/scripts/YaML.md +++ b/scripts/YaML.md @@ -20,7 +20,7 @@ This document describes the YaML format used by the scripts for the API specific * A header requires the following scalar fields: {`desc`} - `desc` will be used as the region description comment * A header may take the following optional scalar fields: {`ordinal`, `version`} - - `ordinal` will be used to override the default order (alphebetical) in which regions appear in the specification; `default="1000"`. Multiple regions with the same ordinal will be ordered alphebetically. + - `ordinal` will be used to override the default order (alphabetical) in which regions appear in the specification; `default="1000"`. Multiple regions with the same ordinal will be ordered alphabetically. - `version` can be used to define the minimum API version for all documents in the yml file; `default="1.0"` @@ -325,7 +325,7 @@ class ur_name_handle_t(c_void_p): - `version` will be used to define the minimum API version in which the enum will appear; `default="1.0"` This will also affect the order in which the enum appears within its section and class. - `extend` will be used to extend an existing enum with additional `etors`, usually used to implement experimental features. `type` *must* refer to an - exiting enum and each `etor` must include a unique `value`. + existing enum and each `etor` must include a unique `value`. - `typed_etors` boolean value that will be used to determine whether the enum's values have associated types. * An enum requires the following sequence of mappings: {`etors`} - An etor requires the following scalar fields: {`name`, `desc`} @@ -454,6 +454,8 @@ class ur_name_flags_v(IntEnum): - `name` must be a unique ISO-C standard identifier, start with `$` tag, be snake_case and end with `_t` + The special-case descriptor struct should always end with `_desc_t` + The special-case property struct should always end with `_properties_t` +* A union requires the following + - `tag` is a reference to an enum type that will be used to describe which field of the union to access. * A struct|union may take the following optional scalar fields: {`class`, `base`, `condition`, `ordinal`, `version`} - `class` will be used to scope the struct|union declaration within the specified C++ class - `base` will be used as the base type of the structure @@ -468,6 +470,8 @@ class ur_name_flags_v(IntEnum): - `out` is used for members that are write-only; if the member is a pointer, then the memory being pointed to is also write-only - `in,out` is used for members that are both read and write; typically this is used for pointers to other data structures that contain both read and write members - `nocheck` is used to specify that no additional validation checks will be generated. + + `desc` must also include the following annotation when describing a union: {`"tagged_by(param)"`} + - `tagged_by` is used to specify which parameter will be used as the tag for accessing the union. + `desc` may include one the following annotations: {`"[optional]"`, `"[typename(typeVarName, sizeVarName)]"`} - `optional` is used for members that are pointers where it is legal for the value to be `nullptr` - `typename` is used to denote the type enum for params that are opaque pointers to values of tagged data types. @@ -477,6 +481,7 @@ class ur_name_flags_v(IntEnum): + `init` will be used to initialize the C++ struct|union member's value + `init` must be an ISO-C standard identifier or literal + `version` will be used to define the minimum API version in which the member will appear; `default="1.0"` This will also affect the order in which the member appears within the struct|union. + + `tag` applies only to unions and refers to a value for when this member can be accessed. * A struct|union may take the following optional field which can be a scalar, a sequence of scalars or scalars to sequences: {`details`} - `details` will be used as the struct|union's detailed comment diff --git a/scripts/core/EXP-BINDLESS-IMAGES.rst b/scripts/core/EXP-BINDLESS-IMAGES.rst index c6ecbb7c69..071fe799fd 100644 --- a/scripts/core/EXP-BINDLESS-IMAGES.rst +++ b/scripts/core/EXP-BINDLESS-IMAGES.rst @@ -64,12 +64,16 @@ Enums ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * ${x}_structure_type_t ${X}_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES + ${X}_STRUCTURE_TYPE_EXP_INTEROP_MEM_DESC + ${X}_STRUCTURE_TYPE_EXP_INTEROP_SEMAPHORE_DESC + ${X}_STRUCTURE_TYPE_EXP_FILE_DESCRIPTOR + ${X}_STRUCTURE_TYPE_EXP_WIN32_HANDLE * ${x}_device_info_t * ${X}_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP + * ${X}_DEVICE_INFO_BINDLESS_IMAGES_SHARED_USM_SUPPORT_EXP * ${X}_DEVICE_INFO_BINDLESS_IMAGES_1D_USM_SUPPORT_EXP * ${X}_DEVICE_INFO_BINDLESS_IMAGES_2D_USM_SUPPORT_EXP - * ${X}_DEVICE_INFO_BINDLESS_IMAGES_3D_USM_SUPPORT_EXP * ${X}_DEVICE_INFO_IMAGE_PITCH_ALIGN_EXP * ${X}_DEVICE_INFO_MAX_IMAGE_LINEAR_WIDTH_EXP * ${X}_DEVICE_INFO_MAX_IMAGE_LINEAR_HEIGHT_EXP @@ -119,6 +123,10 @@ Types * ${x}_exp_image_mem_handle_t * ${x}_exp_interop_mem_handle_t * ${x}_exp_interop_semaphore_handle_t +* ${x}_exp_interop_mem_desc_t +* ${x}_exp_interop_semaphore_desc_t +* ${x}_exp_file_descriptor_t +* ${x}_exp_win32_handle_t Functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -149,11 +157,25 @@ Functions Changelog -------------------------------------------------------------------------------- -+-----------+------------------------+ -| Revision | Changes | -+===========+========================+ -| 1.0 | Initial Draft | -+-----------+------------------------+ ++----------+----------------------------------------------------------+ +| Revision | Changes | ++==========+==========================================================+ +| 1.0 | Initial Draft | ++----------+----------------------------------------------------------+ +| 2.0 || Added device parameters to UR functions. | +| || Added sub-region copy parameters to image copy function.| +| || Removed 3D USM capabilities. | +| || Added mip filter mode. | ++----------+----------------------------------------------------------+ +| 3.0 | Added device query for bindless images on shared USM | ++----------+-------------------------------------------------------------+ +| 4.0 || Added platform specific interop resource handles. | +| || Added and updated to use new interop resource descriptors. | ++----------+-------------------------------------------------------------+ +| 5.0 | Update interop struct and func param names to adhere to convention. | ++----------+-------------------------------------------------------------+ +| 6.0 | Fix semaphore import function parameter name. | ++----------+-------------------------------------------------------------+ Contributors -------------------------------------------------------------------------------- diff --git a/scripts/core/EXP-COMMAND-BUFFER.rst b/scripts/core/EXP-COMMAND-BUFFER.rst index 46aa160630..8a83c8a024 100644 --- a/scripts/core/EXP-COMMAND-BUFFER.rst +++ b/scripts/core/EXP-COMMAND-BUFFER.rst @@ -59,7 +59,8 @@ returned list of supported extensions. // Retrieve extension string std::unique_ptr returnedExtensions(new char[returnedSize]); - ${x}DeviceGetInfo(hDevice, ${X}_DEVICE_INFO_EXTENSIONS, returnedSize, returnedExtensions.get(), nullptr); + ${x}DeviceGetInfo(hDevice, ${X}_DEVICE_INFO_EXTENSIONS, returnedSize, + returnedExtensions.get(), nullptr); std::string_view ExtensionsString(returnedExtensions.get()); bool CmdBufferSupport = @@ -117,11 +118,15 @@ were obtained from. // Append a memcpy with no sync-point dependencies ${x}_exp_command_buffer_sync_point_t syncPoint; - ${x}CommandBufferAppendMemcpyUSMExp(hCommandBuffer, pDst, pSrc, size, 0, nullptr, &syncPoint); + ${x}CommandBufferAppendMemcpyUSMExp(hCommandBuffer, pDst, pSrc, size, 0, + nullptr, &syncPoint); // Append a kernel launch with syncPoint as a dependency, ignore returned // sync-point - ${x}CommandBufferAppendKernelLaunchExp(hCommandBuffer, hKernel, workDim, pGlobalWorkOffset, pGlobalWorkSize, pLocalWorkSize, 1, &syncPoint, nullptr); + ${x}CommandBufferAppendKernelLaunchExp(hCommandBuffer, hKernel, workDim, + pGlobalWorkOffset, pGlobalWorkSize, + pLocalWorkSize, 1, &syncPoint, + nullptr); Enqueueing Command-Buffers -------------------------------------------------------------------------------- diff --git a/scripts/core/INTRO.rst b/scripts/core/INTRO.rst index 6517cea1fc..4c3a1a9d2d 100644 --- a/scripts/core/INTRO.rst +++ b/scripts/core/INTRO.rst @@ -234,6 +234,25 @@ Currently, UR looks for these adapter libraries: For more information about the usage of mentioned environment variables see `Environment Variables`_ section. +Layers +--------------------- +UR comes with a mechanism that allows various API intercept layers to be enabled, either through the API or with an environment variable (see `Environment Variables`_). +Layers currently included with the runtime are as follows: + +.. list-table:: + :header-rows: 1 + + * - Layer Name + - Description + * - UR_LAYER_PARAMETER_VALIDATION + - Enables non-adapter-specific parameter validation (e.g. checking for null values). + * - UR_LAYER_LEAK_CHECKING + - Performs some leak checking for API calls involving object creation/destruction. + * - UR_LAYER_FULL_VALIDATION + - Enables UR_LAYER_PARAMETER_VALIDATION and UR_LAYER_LEAK_CHECKING. + * - UR_LAYER_TRACING + - Enables the XPTI tracing layer, see Tracing_ for more detail. + Environment Variables --------------------- @@ -277,30 +296,13 @@ Specific environment variables can be set to control the behavior of unified run This environment variable is ignored when :envvar:`UR_ADAPTERS_FORCE_LOAD` environment variable is used. -.. envvar:: UR_ENABLE_VALIDATION_LAYER +.. envvar:: UR_ENABLE_LAYERS - Holds the value ``0`` or ``1``. By setting it to ``1`` you enable validation layer. - - .. note:: - - This environment variable should be used for development and debugging only. + Holds a comma-separated list of layers to enable in addition to any specified via ``urInit``. -.. envvar:: UR_ENABLE_PARAMETER_VALIDATION - - Holds the value ``0`` or ``1``. By setting it to ``1`` you enable parameter validation for Unified Runtime API calls. - - .. note:: - - This environment variable should be used together with :envvar:`UR_ENABLE_VALIDATION_LAYER`. - -.. envvar:: UR_ENABLE_LEAK_CHECKING - - Holds the value ``0`` or ``1``. By setting it to ``1`` you enable leak checking for Unified Runtime API calls involving - object creation/destruction. Leak checking depends on the logging mechanism. - - .. note:: + .. note:: - This environment variable should be used together with :envvar:`UR_ENABLE_VALIDATION_LAYER` and :envvar:`UR_LOG_VALIDATION`. + See the Layers_ section for details of the layers currently included in the runtime. Service identifiers --------------------- diff --git a/scripts/core/PROG.rst b/scripts/core/PROG.rst index 280144adcd..e7bf24986b 100644 --- a/scripts/core/PROG.rst +++ b/scripts/core/PROG.rst @@ -51,20 +51,28 @@ Initialization and Discovery .. parsed-literal:: + // Discover all available adapters + uint32_t adapterCount = 0; + ${x}AdapterGet(0, nullptr, &adapterCount); + std::vector<${x}_adapter_handle_t> adapters(adapterCount); + ${x}AdapterGet(adapterCount, adapters.data(), nullptr); + // Discover all the platform instances uint32_t platformCount = 0; - ${x}PlatformGet(0, nullptr, &platformCount); + ${x}PlatformGet(adapters.data(), adapterCount, 0, nullptr, &platformCount); std::vector<${x}_platform_handle_t> platforms(platformCount); - ${x}PlatformGet(platform.size(), platforms.data(), &platformCount); + ${x}PlatformGet(adapters.data(), adapterCount, platform.size(), platforms.data(), &platformCount); // Get number of total GPU devices in the platform uint32_t deviceCount = 0; - ${x}DeviceGet(platforms[0], ${X}_DEVICE_TYPE_GPU, &deviceCount, nullptr, nullptr); + ${x}DeviceGet(platforms[0], ${X}_DEVICE_TYPE_GPU, &deviceCount, nullptr, + nullptr); // Get handles of all GPU devices in the platform std::vector<${x}_device_handle_t> devices(deviceCount); - ${x}DeviceGet(platforms[0], ${X}_DEVICE_TYPE_GPU, &deviceCount, devices.data(), devices.size()); + ${x}DeviceGet(platforms[0], ${X}_DEVICE_TYPE_GPU, &deviceCount, + devices.data(), devices.size()); Device handle lifetime ---------------------- @@ -97,7 +105,8 @@ In case where the info size is only known at runtime then two calls are needed, // Size is known beforehand ${x}_device_type_t deviceType; - ${x}DeviceGetInfo(hDevice, ${X}_DEVICE_INFO_TYPE, sizeof(${x}_device_type_t), &deviceType, nullptr); + ${x}DeviceGetInfo(hDevice, ${X}_DEVICE_INFO_TYPE, + sizeof(${x}_device_type_t), &deviceType, nullptr); // Size is only known at runtime size_t infoSize; @@ -105,7 +114,8 @@ In case where the info size is only known at runtime then two calls are needed, std::string deviceName; DeviceName.resize(infoSize); - ${x}DeviceGetInfo(hDevice, ${X}_DEVICE_INFO_NAME, infoSize, deviceName.data(), nullptr); + ${x}DeviceGetInfo(hDevice, ${X}_DEVICE_INFO_NAME, infoSize, + deviceName.data(), nullptr); Device partitioning into sub-devices ------------------------------------ @@ -133,7 +143,8 @@ fixed part of the parent device, which can explicitly be programmed individually if (count > 0) { subDevices.resize(count); - ${x}DevicePartition(Device, &properties, count, &subDevices.data(), nullptr); + ${x}DevicePartition(Device, &properties, count, &subDevices.data(), + nullptr); } The returned sub-devices may be requested for further partitioning into sub-sub-devices, and so on. @@ -158,7 +169,8 @@ events, and programs are explicitly created against a context. A trivial work wi uint32_t deviceCount = 1; ${x}_device_handle_t hDevice; - ${x}DeviceGet(hPlatform, ${X}_DEVICE_TYPE_GPU, &deviceCount, &hDevice, nullptr); + ${x}DeviceGet(hPlatform, ${X}_DEVICE_TYPE_GPU, &deviceCount, &hDevice, + nullptr); // Create a context ${x}_context_handle_t hContext; @@ -234,14 +246,16 @@ queue is created. // Create an out of order queue for hDevice in hContext ${x}_queue_handle_t hQueue; - ${x}QueueCreate(hContext, hDevice, ${X}_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE, &hQueue); + ${x}QueueCreate(hContext, hDevice, + ${X}_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE, &hQueue); - // Lanuch a kernel with 3D workspace partitioning + // Launch a kernel with 3D workspace partitioning const uint32_t nDim = 3; const size_t gWorkOffset = {0, 0, 0}; const size_t gWorkSize = {128, 128, 128}; const size_t lWorkSize = {1, 8, 8}; - ${x}EnqueueKernelLaunch(hQueue, hKernel, nDim, gWorkOffset, gWorkSize, lWorkSize, 0, nullptr, nullptr); + ${x}EnqueueKernelLaunch(hQueue, hKernel, nDim, gWorkOffset, gWorkSize, + lWorkSize, 0, nullptr, nullptr); Queue object lifetime --------------------- diff --git a/scripts/core/common.yml b/scripts/core/common.yml index 02bffd0751..7a522ada35 100644 --- a/scripts/core/common.yml +++ b/scripts/core/common.yml @@ -60,6 +60,16 @@ name: $x_bool_t value: uint8_t --- #-------------------------------------------------------------------------- type: handle +desc: "Handle of a loader config object" +class: $xLoaderConfig +name: "$x_loader_config_handle_t" +--- #-------------------------------------------------------------------------- +type: handle +desc: "Handle of an adapter instance" +class: $xAdapter +name: "$x_adapter_handle_t" +--- #-------------------------------------------------------------------------- +type: handle desc: "Handle of a platform instance" class: $xPlatform name: "$x_platform_handle_t" @@ -171,7 +181,7 @@ etors: - name: ERROR_DEVICE_IN_LOW_POWER_STATE desc: "Device currently in low power state" - name: ERROR_DEVICE_PARTITION_FAILED - desc: "Device paritioning failed" + desc: "Device partitioning failed" - name: ERROR_INVALID_DEVICE_PARTITION_COUNT desc: "Invalid counts provided with $X_DEVICE_PARTITION_BY_COUNTS" - name: ERROR_INVALID_WORK_ITEM_SIZE @@ -201,7 +211,7 @@ etors: - name: ERROR_INVALID_PROGRAM_EXECUTABLE desc: "Program object parameter is invalid." - name: ERROR_UNINITIALIZED - desc: "[Validation] adapter is not initialized" + desc: "[Validation] adapter is not initialized or specific entry-point is not implemented" - name: ERROR_OUT_OF_HOST_MEMORY desc: "Insufficient host memory to satisfy call" - name: ERROR_OUT_OF_DEVICE_MEMORY @@ -261,83 +271,12 @@ etors: - name: ERROR_ADAPTER_SPECIFIC desc: "An adapter specific warning/error has been reported and can be retrieved via the urPlatformGetLastError entry point." + - name: ERROR_LAYER_NOT_PRESENT + desc: "A requested layer was not found by the loader." - name: ERROR_UNKNOWN value: "0x7ffffffe" desc: "Unknown or internal error" --- #-------------------------------------------------------------------------- -type: enum -desc: "Defines structure types" -name: $x_structure_type_t -etors: - - name: CONTEXT_PROPERTIES - desc: $x_context_properties_t - - name: IMAGE_DESC - desc: $x_image_desc_t - - name: BUFFER_PROPERTIES - desc: $x_buffer_properties_t - - name: BUFFER_REGION - desc: $x_buffer_region_t - - name: BUFFER_CHANNEL_PROPERTIES - desc: $x_buffer_channel_properties_t - - name: BUFFER_ALLOC_LOCATION_PROPERTIES - desc: $x_buffer_alloc_location_properties_t - - name: PROGRAM_PROPERTIES - desc: $x_program_properties_t - - name: USM_DESC - desc: $x_usm_desc_t - - name: USM_HOST_DESC - desc: $x_usm_host_desc_t - - name: USM_DEVICE_DESC - desc: $x_usm_device_desc_t - - name: USM_POOL_DESC - desc: $x_usm_pool_desc_t - - name: USM_POOL_LIMITS_DESC - desc: $x_usm_pool_limits_desc_t - - name: DEVICE_BINARY - desc: $x_device_binary_t - - name: SAMPLER_DESC - desc: $x_sampler_desc_t - - name: QUEUE_PROPERTIES - desc: $x_queue_properties_t - - name: QUEUE_INDEX_PROPERTIES - desc: $x_queue_properties_t - - name: CONTEXT_NATIVE_PROPERTIES - desc: $x_context_native_properties_t - - name: KERNEL_NATIVE_PROPERTIES - desc: $x_kernel_native_properties_t - - name: QUEUE_NATIVE_PROPERTIES - desc: $x_queue_native_properties_t - - name: MEM_NATIVE_PROPERTIES - desc: $x_mem_native_properties_t - - name: EVENT_NATIVE_PROPERTIES - desc: $x_event_native_properties_t - - name: PLATFORM_NATIVE_PROPERTIES - desc: $x_platform_native_properties_t - - name: DEVICE_NATIVE_PROPERTIES - desc: $x_device_native_properties_t - - name: PROGRAM_NATIVE_PROPERTIES - desc: $x_program_native_properties_t - - name: SAMPLER_NATIVE_PROPERTIES - desc: $x_sampler_native_properties_t - - name: QUEUE_NATIVE_DESC - desc: $x_queue_native_desc_t - - name: DEVICE_PARTITION_PROPERTIES - desc: $x_device_partition_properties_t - - name: KERNEL_ARG_MEM_OBJ_PROPERTIES - desc: $x_kernel_arg_mem_obj_properties_t - - name: PHYSICAL_MEM_PROPERTIES - desc: $x_physical_mem_properties_t - - name: KERNEL_ARG_POINTER_PROPERTIES - desc: $x_kernel_arg_pointer_properties_t - - name: KERNEL_ARG_SAMPLER_PROPERTIES - desc: $x_kernel_arg_sampler_properties_t - - name: KERNEL_EXEC_INFO_PROPERTIES - desc: $x_kernel_exec_info_properties_t - - name: KERNEL_ARG_VALUE_PROPERTIES - desc: $x_kernel_arg_value_properties_t - - name: KERNEL_ARG_LOCAL_PROPERTIES - desc: $x_kernel_arg_local_properties_t ---- #-------------------------------------------------------------------------- type: struct desc: "Base for all properties types" name: $x_base_properties_t diff --git a/scripts/core/context.yml b/scripts/core/context.yml index 345798a043..fef1161fca 100644 --- a/scripts/core/context.yml +++ b/scripts/core/context.yml @@ -196,6 +196,9 @@ params: name: phNativeContext desc: | [out] a pointer to the native handle of the context. +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." --- #-------------------------------------------------------------------------- type: struct desc: "Properties for for $xContextCreateWithNativeHandle." @@ -224,7 +227,7 @@ params: - type: $x_native_handle_t name: hNativeContext desc: | - [in] the native handle of the context. + [in][nocheck] the native handle of the context. - type: uint32_t name: numDevices desc: "[in] number of devices associated with the context" @@ -238,6 +241,9 @@ params: name: phContext desc: | [out] pointer to the handle of the context object created. +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." --- #-------------------------------------------------------------------------- type: fptr_typedef desc: "Context's extended deleter callback function with user data." diff --git a/scripts/core/device.yml b/scripts/core/device.yml index 5e8fa6e727..4fd4b09d93 100644 --- a/scripts/core/device.yml +++ b/scripts/core/device.yml @@ -1,5 +1,5 @@ # -# Copyright (C) 2022 Intel Corporation +# Copyright (C) 2022-2023 Intel Corporation # # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. # See LICENSE.TXT @@ -216,7 +216,7 @@ etors: - name: IMAGE2D_MAX_WIDTH desc: "[size_t] max width of Image2D object" - name: IMAGE2D_MAX_HEIGHT - desc: "[size_t] max heigh of Image2D object" + desc: "[size_t] max height of Image2D object" - name: IMAGE3D_MAX_WIDTH desc: "[size_t] max width of Image3D object" - name: IMAGE3D_MAX_HEIGHT @@ -383,6 +383,8 @@ etors: desc: "[uint32_t] The maximum number of registers available per block." - name: IP_VERSION desc: "[uint32_t] The device IP version. The meaning of the device IP version is implementation-defined, but newer devices should have a higher version than older devices." + - name: VIRTUAL_MEMORY_SUPPORT + desc: "[$x_bool_t] return true if the device supports virtual memory." --- #-------------------------------------------------------------------------- type: function desc: "Retrieves various information about device" @@ -518,16 +520,20 @@ type: union desc: "Device partition value." name: $x_device_partition_value_t class: $xDevice +tag: $x_device_partition_t members: - type: uint32_t name: equally desc: "[in] Number of compute units per sub-device when partitioning with $X_DEVICE_PARTITION_EQUALLY." + tag: $X_DEVICE_PARTITION_EQUALLY - type: uint32_t name: count desc: "[in] Number of compute units in a sub-device when partitioning with $X_DEVICE_PARTITION_BY_COUNTS." + tag: $X_DEVICE_PARTITION_BY_COUNTS - type: $x_device_affinity_domain_flags_t name: affinity_domain - desc: "[in] The affinity domain to partition for when partitioning with $UR_DEVICE_PARTITION_BY_AFFINITY_DOMAIN." + desc: "[in] The affinity domain to partition for when partitioning with $X_DEVICE_PARTITION_BY_AFFINITY_DOMAIN." + tag: $X_DEVICE_PARTITION_BY_AFFINITY_DOMAIN --- #-------------------------------------------------------------------------- type: struct desc: "Device partition property" @@ -539,7 +545,7 @@ members: desc: "[in] The partitioning type to be used." - type: $x_device_partition_value_t name: value - desc: "[in] The paritioning value." + desc: "[in][tagged_by(type)] The partitioning value." --- #-------------------------------------------------------------------------- type: struct desc: "Device Partition Properties" @@ -727,6 +733,9 @@ params: name: phNativeDevice desc: | [out] a pointer to the native handle of the device. +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." --- #-------------------------------------------------------------------------- type: struct desc: "Native device creation properties" @@ -754,7 +763,7 @@ details: params: - type: $x_native_handle_t name: hNativeDevice - desc: "[in] the native handle of the device." + desc: "[in][nocheck] the native handle of the device." - type: $x_platform_handle_t name: hPlatform desc: "[in] handle of the platform instance" @@ -764,6 +773,9 @@ params: - type: "$x_device_handle_t*" name: phDevice desc: "[out] pointer to the handle of the device object created." +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." --- #-------------------------------------------------------------------------- type: function desc: "Returns synchronized Host and Device global timestamps." diff --git a/scripts/core/event.yml b/scripts/core/event.yml index f38d68b779..c20a8e04c9 100644 --- a/scripts/core/event.yml +++ b/scripts/core/event.yml @@ -266,6 +266,9 @@ params: name: phNativeEvent desc: | [out] a pointer to the native handle of the event. +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." --- #-------------------------------------------------------------------------- type: struct desc: "Properties for for $xEventCreateWithNativeHandle." @@ -294,7 +297,7 @@ params: - type: $x_native_handle_t name: hNativeEvent desc: | - [in] the native handle of the event. + [in][nocheck] the native handle of the event. - type: $x_context_handle_t name: hContext desc: "[in] handle of the context object" @@ -305,6 +308,9 @@ params: name: phEvent desc: | [out] pointer to the handle of the event object created. +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." --- #-------------------------------------------------------------------------- type: enum desc: "Event states for all events." diff --git a/scripts/core/exp-bindless-images.yml b/scripts/core/exp-bindless-images.yml index 1b4d408379..cbb194849f 100644 --- a/scripts/core/exp-bindless-images.yml +++ b/scripts/core/exp-bindless-images.yml @@ -32,15 +32,15 @@ etors: - name: BINDLESS_IMAGES_SUPPORT_EXP value: "0x2000" desc: "[$x_bool_t] returns true if the device supports the creation of bindless images" - - name: BINDLESS_IMAGES_1D_USM_SUPPORT_EXP + - name: BINDLESS_IMAGES_SHARED_USM_SUPPORT_EXP value: "0x2001" + desc: "[$x_bool_t] returns true if the device supports the creation of bindless images backed by shared USM" + - name: BINDLESS_IMAGES_1D_USM_SUPPORT_EXP + value: "0x2002" desc: "[$x_bool_t] returns true if the device supports the creation of 1D bindless images backed by USM" - name: BINDLESS_IMAGES_2D_USM_SUPPORT_EXP - value: "0x2002" - desc: "[$x_bool_t] returns true if the device supports the creation of 2D bindless images backed by USM" - - name: BINDLESS_IMAGES_3D_USM_SUPPORT_EXP value: "0x2003" - desc: "[$x_bool_t] returns true if the device supports the creation of 3D bindless images backed by USM" + desc: "[$x_bool_t] returns true if the device supports the creation of 2D bindless images backed by USM" - name: IMAGE_PITCH_ALIGN_EXP value: "0x2004" desc: "[uint32_t] returns the required alignment of the pitch between two rows of an image in bytes" @@ -86,6 +86,18 @@ etors: - name: EXP_SAMPLER_MIP_PROPERTIES desc: $x_exp_sampler_mip_properties_t value: "0x2000" + - name: EXP_INTEROP_MEM_DESC + desc: $x_exp_interop_mem_desc_t + value: "0x2001" + - name: EXP_INTEROP_SEMAPHORE_DESC + desc: $x_exp_interop_semaphore_desc_t + value: "0x2002" + - name: EXP_FILE_DESCRIPTOR + desc: $x_exp_file_descriptor_t + value: "0x2003" + - name: EXP_WIN32_HANDLE + desc: $x_exp_win32_handle_t + value: "0x2004" --- #-------------------------------------------------------------------------- type: enum extend: true @@ -105,13 +117,31 @@ class: $xBindlessImages name: $x_exp_image_copy_flags_t etors: - name: HOST_TO_DEVICE - desc: "Host to device." + desc: "Host to device" - name: DEVICE_TO_HOST desc: "Device to host" - name: DEVICE_TO_DEVICE desc: "Device to device" --- #-------------------------------------------------------------------------- type: struct +desc: "File descriptor" +name: $x_exp_file_descriptor_t +base: $x_base_desc_t +members: + - type: int + name: fd + desc: "[in] A file descriptor used for Linux and & MacOS operating systems." +--- #-------------------------------------------------------------------------- +type: struct +desc: "Windows specific file handle" +name: $x_exp_win32_handle_t +base: $x_base_desc_t +members: + - type: void* + name: handle + desc: "[in] A win32 file handle." +--- #-------------------------------------------------------------------------- +type: struct desc: "Describes mipmap sampler properties" details: - Specify these properties in $xSamplerCreate via $x_sampler_desc_t as part @@ -127,8 +157,25 @@ members: name: maxMipmapLevelClamp desc: "[in] maximum mipmap level from which we can sample, maximum value being the number of levels" - type: float - name: maxAnistropy + name: maxAnisotropy desc: "[in] anisotropic ratio used when samplling the mipmap with anisotropic filtering" + - type: $x_sampler_filter_mode_t + name: mipFilterMode + desc: "[in] mipmap filter mode used for filtering between mipmap levels" +--- #-------------------------------------------------------------------------- +type: struct +desc: "Describes an interop memory resource descriptor" +class: $xBindlessImages +name: $x_exp_interop_mem_desc_t +base: $x_base_desc_t +members: [] +--- #-------------------------------------------------------------------------- +type: struct +desc: "Describes an interop semaphore resource descriptor" +class: $xBindlessImages +name: $x_exp_interop_semaphore_desc_t +base: $x_base_desc_t +members: [] --- #-------------------------------------------------------------------------- type: function desc: "USM allocate pitched memory" @@ -197,6 +244,9 @@ params: - type: $x_context_handle_t name: hContext desc: "[in] handle of the context object" + - type: $x_device_handle_t + name: hDevice + desc: "[in] handle of the device object" - type: $x_exp_image_handle_t name: hImage desc: "[in] pointer to handle of image object to destroy" @@ -215,6 +265,9 @@ params: - type: $x_context_handle_t name: hContext desc: "[in] handle of the context object" + - type: $x_device_handle_t + name: hDevice + desc: "[in] handle of the device object" - type: $x_exp_image_handle_t name: hImage desc: "[in] pointer to handle of image object to destroy" @@ -234,6 +287,9 @@ params: - type: $x_context_handle_t name: hContext desc: "[in] handle of the context object" + - type: $x_device_handle_t + name: hDevice + desc: "[in] handle of the device object" - type: "const $x_image_format_t*" name: pImageFormat desc: "[in] pointer to image format specification" @@ -262,6 +318,9 @@ params: - type: $x_context_handle_t name: hContext desc: "[in] handle of the context object" + - type: $x_device_handle_t + name: hDevice + desc: "[in] handle of the device object" - type: $x_exp_image_mem_handle_t name: hImageMem desc: "[in] handle of image memory to be freed" @@ -280,6 +339,9 @@ params: - type: $x_context_handle_t name: hContext desc: "[in] handle of the context object" + - type: $x_device_handle_t + name: hDevice + desc: "[in] handle of the device object" - type: $x_exp_image_mem_handle_t name: hImageMem desc: "[in] handle to memory from which to create the image" @@ -314,6 +376,9 @@ params: - type: $x_context_handle_t name: hContext desc: "[in] handle of the context object" + - type: $x_device_handle_t + name: hDevice + desc: "[in] handle of the device object" - type: $x_exp_image_mem_handle_t name: hImageMem desc: "[in] handle to memory from which to create the image" @@ -352,9 +417,9 @@ analogue: - "**cuMemcpy2DAsync**" - "**cuMemcpy3DAsync**" params: - - type: $x_context_handle_t - name: hContext - desc: "[in] handle of the context object" + - type: $x_queue_handle_t + name: hQueue + desc: "[in] handle of the queue object" - type: void* name: pDst desc: "[in] location the data will be copied to" @@ -370,6 +435,18 @@ params: - type: $x_exp_image_copy_flags_t name: imageCopyFlags desc: "[in] flags describing copy direction e.g. H2D or D2H" + - type: $x_rect_offset_t + name: srcOffset + desc: "[in] defines the (x,y,z) source offset in pixels in the 1D, 2D, or 3D image" + - type: $x_rect_offset_t + name: dstOffset + desc: "[in] defines the (x,y,z) destination offset in pixels in the 1D, 2D, or 3D image" + - type: $x_rect_region_t + name: copyExtent + desc: "[in] defines the (width, height, depth) in pixels of the 1D, 2D, or 3D region to copy" + - type: $x_rect_region_t + name: hostExtent + desc: "[in] defines the (width, height, depth) in pixels of the 1D, 2D, or 3D region on the host" - type: uint32_t name: numEventsInWaitList desc: "[in] size of the event wait list" @@ -384,7 +461,7 @@ params: desc: | [out][optional] return an event object that identifies this particular command instance. returns: - - $X_RESULT_ERROR_INVALID_CONTEXT + - $X_RESULT_ERROR_INVALID_QUEUE - $X_RESULT_ERROR_INVALID_VALUE - $X_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR: - "`pImageDesc && UR_MEM_TYPE_IMAGE1D_BUFFER < pImageDesc->type`" @@ -431,6 +508,9 @@ params: - type: $x_context_handle_t name: hContext desc: "[in] handle of the context object" + - type: $x_device_handle_t + name: hDevice + desc: "[in] handle of the device object" - type: $x_exp_image_mem_handle_t name: hImageMem desc: "[in] memory handle to the mipmap image" @@ -455,6 +535,9 @@ params: - type: $x_context_handle_t name: hContext desc: "[in] handle of the context object" + - type: $x_device_handle_t + name: hDevice + desc: "[in] handle of the device object" - type: $x_exp_image_mem_handle_t name: hMem desc: "[in] handle of image memory to be freed" @@ -473,12 +556,15 @@ params: - type: $x_context_handle_t name: hContext desc: "[in] handle of the context object" + - type: $x_device_handle_t + name: hDevice + desc: "[in] handle of the device object" - type: size_t name: size desc: "[in] size of the external memory" - - type: uint32_t - name: fileDescriptor - desc: "[in] the file descriptor" + - type: $x_exp_interop_mem_desc_t* + name: pInteropMemDesc + desc: "[in] the interop memory descriptor" - type: $x_exp_interop_mem_handle_t* name: phInteropMem desc: "[out] interop memory handle to the external memory" @@ -496,6 +582,9 @@ params: - type: $x_context_handle_t name: hContext desc: "[in] handle of the context object" + - type: $x_device_handle_t + name: hDevice + desc: "[in] handle of the device object" - type: "const $x_image_format_t*" name: pImageFormat desc: "[in] pointer to image format specification" @@ -505,7 +594,7 @@ params: - type: $x_exp_interop_mem_handle_t name: hInteropMem desc: "[in] interop memory handle to the external memory" - - type: $x_exp_image_handle_t* + - type: $x_exp_image_mem_handle_t* name: phImageMem desc: "[out] image memory handle to the externally allocated memory" returns: @@ -528,6 +617,9 @@ params: - type: $x_context_handle_t name: hContext desc: "[in] handle of the context object" + - type: $x_device_handle_t + name: hDevice + desc: "[in] handle of the device object" - type: $x_exp_interop_mem_handle_t name: hInteropMem desc: "[in] handle of interop memory to be freed" @@ -546,11 +638,14 @@ params: - type: $x_context_handle_t name: hContext desc: "[in] handle of the context object" - - type: uint32_t - name: fileDescriptor - desc: "[in] the file descriptor" + - type: $x_device_handle_t + name: hDevice + desc: "[in] handle of the device object" + - type: $x_exp_interop_semaphore_desc_t* + name: pInteropSemaphoreDesc + desc: "[in] the interop semaphore descriptor" - type: $x_exp_interop_semaphore_handle_t* - name: phInteropSemaphoreHandle + name: phInteropSemaphore desc: "[out] interop semaphore handle to the external semaphore" returns: - $X_RESULT_ERROR_INVALID_CONTEXT @@ -567,6 +662,9 @@ params: - type: $x_context_handle_t name: hContext desc: "[in] handle of the context object" + - type: $x_device_handle_t + name: hDevice + desc: "[in] handle of the device object" - type: $x_exp_interop_semaphore_handle_t name: hInteropSemaphore desc: "[in] handle of interop semaphore to be destroyed" diff --git a/scripts/core/kernel.yml b/scripts/core/kernel.yml index cc659a2c1d..27481f810f 100644 --- a/scripts/core/kernel.yml +++ b/scripts/core/kernel.yml @@ -160,7 +160,7 @@ etors: desc: "[uint32_t] Return SubGroup size required by Intel" --- #-------------------------------------------------------------------------- type: enum -desc: "Kernel Cache Configuartion." +desc: "Kernel Cache Configuration." class: $xKernel name: $x_kernel_cache_config_t etors: @@ -487,6 +487,9 @@ params: name: phNativeKernel desc: | [out] a pointer to the native handle of the kernel. +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." --- #-------------------------------------------------------------------------- type: struct desc: "Properties for for $xKernelCreateWithNativeHandle." @@ -515,7 +518,7 @@ params: - type: $x_native_handle_t name: hNativeKernel desc: | - [in] the native handle of the kernel. + [in][nocheck] the native handle of the kernel. - type: $x_context_handle_t name: hContext desc: "[in] handle of the context object" @@ -529,3 +532,6 @@ params: name: phKernel desc: | [out] pointer to the handle of the kernel object created. +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." diff --git a/scripts/core/memory.yml b/scripts/core/memory.yml index b9c3ef1792..ede16a1913 100644 --- a/scripts/core/memory.yml +++ b/scripts/core/memory.yml @@ -436,6 +436,9 @@ params: name: phNativeMem desc: | [out] a pointer to the native handle of the mem. +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." --- #-------------------------------------------------------------------------- type: struct desc: "Native memory object creation properties" @@ -463,7 +466,7 @@ details: params: - type: $x_native_handle_t name: hNativeMem - desc: "[in] the native handle to the memory." + desc: "[in][nocheck] the native handle to the memory." - type: $x_context_handle_t name: hContext desc: "[in] handle of the context object." @@ -473,6 +476,9 @@ params: - type: $x_mem_handle_t* name: phMem desc: "[out] pointer to handle of buffer memory object created." +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." --- #-------------------------------------------------------------------------- type: function desc: "Create runtime image memory object from native memory handle." @@ -487,7 +493,7 @@ details: params: - type: $x_native_handle_t name: hNativeMem - desc: "[in] the native handle to the memory." + desc: "[in][nocheck] the native handle to the memory." - type: $x_context_handle_t name: hContext desc: "[in] handle of the context object." @@ -503,6 +509,9 @@ params: - type: $x_mem_handle_t* name: phMem desc: "[out] pointer to handle of image memory object created." +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." --- #-------------------------------------------------------------------------- type: function desc: "Retrieve information about a memory object." @@ -577,3 +586,15 @@ params: name: pPropSizeRet desc: | [out][optional] pointer to the actual size in bytes of the queried propName. +returns: + - $X_RESULT_ERROR_UNSUPPORTED_ENUMERATION: + - "If `propName` is not supported by the adapter." + - $X_RESULT_ERROR_INVALID_SIZE: + - "`propSize == 0 && pPropValue != NULL`" + - "If `propSize` is less than the real number of bytes needed to return the info." + - $X_RESULT_ERROR_INVALID_NULL_POINTER: + - "`propSize != 0 && pPropValue == NULL`" + - "`pPropValue == NULL && pPropSizeRet == NULL`" + - $X_RESULT_ERROR_INVALID_MEM_OBJECT + - $X_RESULT_ERROR_OUT_OF_RESOURCES + - $X_RESULT_ERROR_OUT_OF_HOST_MEMORY diff --git a/scripts/core/platform.yml b/scripts/core/platform.yml index 9dab95a68a..6a0d350703 100644 --- a/scripts/core/platform.yml +++ b/scripts/core/platform.yml @@ -13,7 +13,7 @@ desc: "Intel $OneApi Unified Runtime APIs for Platform" ordinal: "1" --- #-------------------------------------------------------------------------- type: function -desc: "Retrieves all available platforms" +desc: "Retrieves all available platforms for the given adapters" class: $xPlatform name: Get decl: static @@ -24,6 +24,12 @@ details: - "Multiple calls to this function will return identical platforms handles, in the same order." - "The application may call this function from simultaneous threads, the implementation must be thread-safe" params: + - type: "$x_adapter_handle_t*" + name: "phAdapters" + desc: "[in][range(0, NumAdapters)] array of adapters to query for platforms." + - type: "uint32_t" + name: "NumAdapters" + desc: "[in] number of adapters pointed to by phAdapters" - type: "uint32_t" name: NumEntries desc: | @@ -161,6 +167,9 @@ params: name: phNativePlatform desc: | [out] a pointer to the native handle of the platform. +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." --- #-------------------------------------------------------------------------- type: struct desc: "Native platform creation properties" @@ -188,13 +197,16 @@ details: params: - type: $x_native_handle_t name: hNativePlatform - desc: "[in] the native handle of the platform." + desc: "[in][nocheck] the native handle of the platform." - type: const $x_platform_native_properties_t* name: pProperties desc: "[in][optional] pointer to native platform properties struct." - type: "$x_platform_handle_t*" name: phPlatform desc: "[out] pointer to the handle of the platform object created." +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." --- #-------------------------------------------------------------------------- type: function desc: "Get the platform specific compiler backend option from a generic frontend option." @@ -221,56 +233,6 @@ returns: - $X_RESULT_ERROR_INVALID_VALUE: - "If `pFrontendOption` is not a valid frontend option." --- #-------------------------------------------------------------------------- -type: function -desc: "Get the last adapter specific error." -details: | - To be used after another entry-point has returned - $X_RESULT_ERROR_ADAPTER_SPECIFIC in order to retrieve a message describing - the circumstances of the underlying driver error and the error code - returned by the failed driver entry-point. - - * Implementations *must* store the message and error code in thread-local - storage prior to returning $X_RESULT_ERROR_ADAPTER_SPECIFIC. - - * The message and error code storage is will only be valid if a previously - called entry-point returned $X_RESULT_ERROR_ADAPTER_SPECIFIC. - - * The memory pointed to by the C string returned in `ppMessage` is owned by - the adapter and *must* be null terminated. - - * The application *may* call this function from simultaneous threads. - - * The implementation of this function *should* be lock-free. - - Example usage: - - ```cpp - if ($xQueueCreate(hContext, hDevice, nullptr, &hQueue) == - $X_RESULT_ERROR_ADAPTER_SPECIFIC) { - const char* pMessage; - int32_t error; - $xPlatformGetLastError(hPlatform, &pMessage, &error); - } - ``` -class: $xPlatform -name: GetLastError -decl: static -ordinal: "0" -params: - - type: $x_platform_handle_t - name: hPlatform - desc: "[in] handle of the platform instance" - - type: const char** - name: ppMessage - desc: > - [out] pointer to a C string where the adapter specific error message - will be stored. - - type: int32_t* - name: pError - desc: > - [out] pointer to an integer where the adapter specific error code - will be stored. ---- #-------------------------------------------------------------------------- type: enum desc: "Identifies native backend adapters" class: $xPlatform @@ -291,3 +253,6 @@ etors: - name: HIP value: "4" desc: "The backend is HIP" + - name: NATIVE_CPU + value: "5" + desc: "The backend is Native CPU" diff --git a/scripts/core/program.yml b/scripts/core/program.yml index ef548ded22..acab24c3bd 100644 --- a/scripts/core/program.yml +++ b/scripts/core/program.yml @@ -29,26 +29,31 @@ type: union desc: "Program metadata value union." class: $xProgram name: $x_program_metadata_value_t +tag: $x_program_metadata_type_t members: - type: uint32_t name: data32 desc: "[in] inline storage for the 32-bit data, type $X_PROGRAM_METADATA_TYPE_UINT32." + tag: $X_PROGRAM_METADATA_TYPE_UINT32 - type: uint64_t name: data64 desc: "[in] inline storage for the 64-bit data, type $X_PROGRAM_METADATA_TYPE_UINT64." + tag: $X_PROGRAM_METADATA_TYPE_UINT64 - type: char* name: pString desc: "[in] pointer to null-terminated string data, type $X_PROGRAM_METADATA_TYPE_STRING." + tag: $X_PROGRAM_METADATA_TYPE_STRING - type: void* name: pData desc: "[in] pointer to binary data, type $X_PROGRAM_METADATA_TYPE_BYTE_ARRAY." + tag: $X_PROGRAM_METADATA_TYPE_BYTE_ARRAY --- #-------------------------------------------------------------------------- type: struct desc: "Program metadata property." class: $xProgram name: $x_program_metadata_t members: - - type: char* + - type: const char* name: pName desc: "[in] null-terminated metadata name." - type: $x_program_metadata_type_t @@ -59,7 +64,7 @@ members: desc: "[in] size in bytes of the data pointed to by value.pData, or 0 when value size is less than 64-bits and is stored directly in value.data." - type: $x_program_metadata_value_t name: value - desc: "[in] the metadata value storage." + desc: "[in][tagged_by(type)] the metadata value storage." --- #-------------------------------------------------------------------------- type: struct desc: "Program creation properties." @@ -159,7 +164,7 @@ analogue: - "**clBuildProgram**" details: - "The application may call this function from simultaneous threads." - - "Following a succesful call to this entry point, the program passed will contain a binary of the $X_PROGRAM_BINARY_TYPE_EXECUTABLE type for each device in `hContext`." + - "Following a successful call to this entry point, the program passed will contain a binary of the $X_PROGRAM_BINARY_TYPE_EXECUTABLE type for each device in `hContext`." params: - type: $x_context_handle_t name: hContext @@ -186,7 +191,7 @@ analogue: - "**clCompileProgram**" details: - "The application may call this function from simultaneous threads." - - "Following a succesful call to this entry point `hProgram` will contain a binary of the $X_PROGRAM_BINARY_TYPE_COMPILED_OBJECT type for each device in `hContext`." + - "Following a successful call to this entry point `hProgram` will contain a binary of the $X_PROGRAM_BINARY_TYPE_COMPILED_OBJECT type for each device in `hContext`." params: - type: $x_context_handle_t name: hContext @@ -213,7 +218,7 @@ analogue: - "**clLinkProgram**" details: - "The application may call this function from simultaneous threads." - - "Following a succesful call to this entry point the program returned in `phProgram` will contain a binary of the $X_PROGRAM_BINARY_TYPE_EXECUTABLE type for each device in `hContext`." + - "Following a successful call to this entry point the program returned in `phProgram` will contain a binary of the $X_PROGRAM_BINARY_TYPE_EXECUTABLE type for each device in `hContext`." params: - type: $x_context_handle_t name: hContext @@ -509,6 +514,9 @@ params: name: phNativeProgram desc: | [out] a pointer to the native handle of the program. +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." --- #-------------------------------------------------------------------------- type: struct desc: "Native program creation properties" @@ -536,7 +544,7 @@ details: params: - type: $x_native_handle_t name: hNativeProgram - desc: "[in] the native handle of the program." + desc: "[in][nocheck] the native handle of the program." - type: $x_context_handle_t name: hContext desc: "[in] handle of the context instance" @@ -546,3 +554,6 @@ params: - type: "$x_program_handle_t*" name: phProgram desc: "[out] pointer to the handle of the program object created." +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." diff --git a/scripts/core/queue.yml b/scripts/core/queue.yml index 86d167b7b9..88fe153165 100644 --- a/scripts/core/queue.yml +++ b/scripts/core/queue.yml @@ -244,6 +244,9 @@ params: name: phNativeQueue desc: | [out] a pointer to the native handle of the queue. +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." --- #-------------------------------------------------------------------------- type: struct desc: "Properties for for $xQueueCreateWithNativeHandle." @@ -272,7 +275,7 @@ params: - type: $x_native_handle_t name: hNativeQueue desc: | - [in] the native handle of the queue. + [in][nocheck] the native handle of the queue. - type: $x_context_handle_t name: hContext desc: "[in] handle of the context object" @@ -286,6 +289,9 @@ params: name: phQueue desc: | [out] pointer to the handle of the queue object created. +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." --- #-------------------------------------------------------------------------- type: function desc: "Blocks until all previously issued commands to the command queue are finished." diff --git a/scripts/core/registry.yml b/scripts/core/registry.yml index e29203afdc..30596ec14e 100644 --- a/scripts/core/registry.yml +++ b/scripts/core/registry.yml @@ -1,7 +1,7 @@ --- type: header desc: "Intel $OneApi Unified Runtime function registry" -ordinal: "9" +ordinal: "-1" --- name: $x_function_t type: enum @@ -436,9 +436,6 @@ etors: - name: BINDLESS_IMAGES_SIGNAL_EXTERNAL_SEMAPHORE_EXP desc: Enumerator for $xBindlessImagesSignalExternalSemaphoreExp value: '149' -- name: PLATFORM_GET_LAST_ERROR - desc: Enumerator for $xPlatformGetLastError - value: '150' - name: ENQUEUE_USM_FILL_2D desc: Enumerator for $xEnqueueUSMFill2D value: '151' @@ -502,3 +499,140 @@ etors: - name: COMMAND_BUFFER_APPEND_MEMBUFFER_READ_RECT_EXP desc: Enumerator for $xCommandBufferAppendMembufferReadRectExp value: '171' +- name: LOADER_CONFIG_CREATE + desc: Enumerator for $xLoaderConfigCreate + value: '172' +- name: LOADER_CONFIG_RELEASE + desc: Enumerator for $xLoaderConfigRelease + value: '173' +- name: LOADER_CONFIG_RETAIN + desc: Enumerator for $xLoaderConfigRetain + value: '174' +- name: LOADER_CONFIG_GET_INFO + desc: Enumerator for $xLoaderConfigGetInfo + value: '175' +- name: LOADER_CONFIG_ENABLE_LAYER + desc: Enumerator for $xLoaderConfigEnableLayer + value: '176' +- name: ADAPTER_RELEASE + desc: Enumerator for $xAdapterRelease + value: '177' +- name: ADAPTER_GET + desc: Enumerator for $xAdapterGet + value: '178' +- name: ADAPTER_RETAIN + desc: Enumerator for $xAdapterRetain + value: '179' +- name: ADAPTER_GET_LAST_ERROR + desc: Enumerator for $xAdapterGetLastError + value: '180' +- name: ADAPTER_GET_INFO + desc: Enumerator for $xAdapterGetInfo + value: '181' +--- +type: enum +desc: Defines structure types +name: $x_structure_type_t +etors: +- name: CONTEXT_PROPERTIES + desc: $x_context_properties_t + value: '0' +- name: IMAGE_DESC + desc: $x_image_desc_t + value: '1' +- name: BUFFER_PROPERTIES + desc: $x_buffer_properties_t + value: '2' +- name: BUFFER_REGION + desc: $x_buffer_region_t + value: '3' +- name: BUFFER_CHANNEL_PROPERTIES + desc: $x_buffer_channel_properties_t + value: '4' +- name: BUFFER_ALLOC_LOCATION_PROPERTIES + desc: $x_buffer_alloc_location_properties_t + value: '5' +- name: PROGRAM_PROPERTIES + desc: $x_program_properties_t + value: '6' +- name: USM_DESC + desc: $x_usm_desc_t + value: '7' +- name: USM_HOST_DESC + desc: $x_usm_host_desc_t + value: '8' +- name: USM_DEVICE_DESC + desc: $x_usm_device_desc_t + value: '9' +- name: USM_POOL_DESC + desc: $x_usm_pool_desc_t + value: '10' +- name: USM_POOL_LIMITS_DESC + desc: $x_usm_pool_limits_desc_t + value: '11' +- name: DEVICE_BINARY + desc: $x_device_binary_t + value: '12' +- name: SAMPLER_DESC + desc: $x_sampler_desc_t + value: '13' +- name: QUEUE_PROPERTIES + desc: $x_queue_properties_t + value: '14' +- name: QUEUE_INDEX_PROPERTIES + desc: $x_queue_index_properties_t + value: '15' +- name: CONTEXT_NATIVE_PROPERTIES + desc: $x_context_native_properties_t + value: '16' +- name: KERNEL_NATIVE_PROPERTIES + desc: $x_kernel_native_properties_t + value: '17' +- name: QUEUE_NATIVE_PROPERTIES + desc: $x_queue_native_properties_t + value: '18' +- name: MEM_NATIVE_PROPERTIES + desc: $x_mem_native_properties_t + value: '19' +- name: EVENT_NATIVE_PROPERTIES + desc: $x_event_native_properties_t + value: '20' +- name: PLATFORM_NATIVE_PROPERTIES + desc: $x_platform_native_properties_t + value: '21' +- name: DEVICE_NATIVE_PROPERTIES + desc: $x_device_native_properties_t + value: '22' +- name: PROGRAM_NATIVE_PROPERTIES + desc: $x_program_native_properties_t + value: '23' +- name: SAMPLER_NATIVE_PROPERTIES + desc: $x_sampler_native_properties_t + value: '24' +- name: QUEUE_NATIVE_DESC + desc: $x_queue_native_desc_t + value: '25' +- name: DEVICE_PARTITION_PROPERTIES + desc: $x_device_partition_properties_t + value: '26' +- name: KERNEL_ARG_MEM_OBJ_PROPERTIES + desc: $x_kernel_arg_mem_obj_properties_t + value: '27' +- name: PHYSICAL_MEM_PROPERTIES + desc: $x_physical_mem_properties_t + value: '28' +- name: KERNEL_ARG_POINTER_PROPERTIES + desc: $x_kernel_arg_pointer_properties_t + value: '29' +- name: KERNEL_ARG_SAMPLER_PROPERTIES + desc: $x_kernel_arg_sampler_properties_t + value: '30' +- name: KERNEL_EXEC_INFO_PROPERTIES + desc: $x_kernel_exec_info_properties_t + value: '31' +- name: KERNEL_ARG_VALUE_PROPERTIES + desc: $x_kernel_arg_value_properties_t + value: '32' +- name: KERNEL_ARG_LOCAL_PROPERTIES + desc: $x_kernel_arg_local_properties_t + value: '33' diff --git a/scripts/core/runtime.yml b/scripts/core/runtime.yml index c0bd7a12c7..06010a643c 100644 --- a/scripts/core/runtime.yml +++ b/scripts/core/runtime.yml @@ -29,6 +29,113 @@ etors: desc: "initialize VPU device adapters." --- #-------------------------------------------------------------------------- type: function +desc: "Create a loader config object." +class: $xLoaderConfig +name: Create +decl: static +params: + - type: $x_loader_config_handle_t* + name: phLoaderConfig + desc: "[out] Pointer to handle of loader config object created." +--- #-------------------------------------------------------------------------- +type: function +desc: "Get a reference to the loader config object." +class: $xLoaderConfig +name: Retain +decl: static +details: + - "Get a reference to the loader config handle. Increment its reference count" + - "The application may call this function from simultaneous threads." + - "The implementation of this function should be lock-free." +params: + - type: $x_loader_config_handle_t + name: hLoaderConfig + desc: "[in] loader config handle to retain" +--- #-------------------------------------------------------------------------- +type: function +desc: "Release config handle." +class: $xLoaderConfig +name: Release +decl: static +details: + - "Decrement reference count and destroy the config handle if reference count becomes zero." + - "The application may call this function from simultaneous threads." + - "The implementation of this function should be lock-free." +params: + - type: $x_loader_config_handle_t + name: hLoaderConfig + desc: "[in] config handle to release" +--- #-------------------------------------------------------------------------- +type: enum +desc: "Supported loader info" +class: $xLoaderConfig +name: $x_loader_config_info_t +typed_etors: True +etors: + - name: AVAILABLE_LAYERS + desc: "[char[]] Null-terminated, semi-colon separated list of available layers." + - name: REFERENCE_COUNT + desc: "[uint32_t] Reference count of the loader config object." +--- #-------------------------------------------------------------------------- +type: function +desc: "Retrieves various information about the loader." +class: $xLoaderConfig +name: GetInfo +decl: static +details: + - "The application may call this function from simultaneous threads." + - "The implementation of this function should be lock-free." +params: + - type: $x_loader_config_handle_t + name: hLoaderConfig + desc: "[in] handle of the loader config object" + - type: $x_loader_config_info_t + name: propName + desc: "[in] type of the info to retrieve" + - type: "size_t" + name: propSize + desc: | + [in] the number of bytes pointed to by pPropValue. + - type: "void*" + name: pPropValue + desc: | + [out][optional][typename(propName, propSize)] array of bytes holding the info. + If propSize is not equal to or greater than the real number of bytes needed to return the info + then the $X_RESULT_ERROR_INVALID_SIZE error is returned and pPropValue is not used. + - type: "size_t*" + name: pPropSizeRet + desc: | + [out][optional] pointer to the actual size in bytes of the queried propName. +returns: + - $X_RESULT_ERROR_UNSUPPORTED_ENUMERATION: + - "If `propName` is not supported by the loader." + - $X_RESULT_ERROR_INVALID_SIZE: + - "`propSize == 0 && pPropValue != NULL`" + - "If `propSize` is less than the real number of bytes needed to return the info." + - $X_RESULT_ERROR_INVALID_NULL_POINTER: + - "`propSize != 0 && pPropValue == NULL`" + - "`pPropValue == NULL && pPropSizeRet == NULL`" + - $X_RESULT_ERROR_INVALID_DEVICE + - $X_RESULT_ERROR_OUT_OF_RESOURCES + - $X_RESULT_ERROR_OUT_OF_HOST_MEMORY +--- #-------------------------------------------------------------------------- +type: function +desc: "Enable a layer for the specified loader config." +class: $xLoaderConfig +name: EnableLayer +decl: static +params: + - type: $x_loader_config_handle_t + name: hLoaderConfig + desc: "[in] Handle to config object the layer will be enabled for." + - type: const char* + name: pLayerName + desc: "[in] Null terminated string containing the name of the layer to enable." +returns: + - $X_RESULT_ERROR_LAYER_NOT_PRESENT: + - "If layer specified with `pLayerName` can't be found by the loader." +--- #-------------------------------------------------------------------------- +type: function desc: "Initialize the $OneApi adapter(s)" class: $x name: Init @@ -49,6 +156,9 @@ params: [in] device initialization flags. must be 0 (default) or a combination of $x_device_init_flag_t. init: "0" + - type: $x_loader_config_handle_t + name: hLoaderConfig + desc: "[in][optional] Handle of loader config handle." returns: - $X_RESULT_ERROR_OUT_OF_HOST_MEMORY --- #-------------------------------------------------------------------------- @@ -64,3 +174,191 @@ params: desc: "[in] pointer to tear down parameters" returns: - $X_RESULT_ERROR_OUT_OF_HOST_MEMORY +--- #-------------------------------------------------------------------------- +type: function +desc: "Retrieves all available adapters" +class: $x +name: AdapterGet +decl: static +ordinal: "2" +details: + - "Adapter implementations must return exactly one adapter handle from this entry point." + - "The loader may return more than one adapter handle when there are multiple available." + - "Each returned adapter has its reference count incremented and should be released with a subsequent call to $xAdapterRelease." + - "Adapters may perform adapter-specific state initialization when the first reference to them is taken." + - "An application may call this entry point multiple times to acquire multiple references to the adapter handle(s)." +params: + - type: "uint32_t" + name: NumEntries + desc: | + [in] the number of adapters to be added to phAdapters. + If phAdapters is not NULL, then NumEntries should be greater than zero, otherwise $X_RESULT_ERROR_INVALID_SIZE, + will be returned. + - type: "$x_adapter_handle_t*" + name: phAdapters + desc: | + [out][optional][range(0, NumEntries)] array of handle of adapters. + If NumEntries is less than the number of adapters available, then $xAdapterGet shall only retrieve that number of platforms. + - type: "uint32_t*" + name: "pNumAdapters" + desc: | + [out][optional] returns the total number of adapters available. +returns: + - $X_RESULT_ERROR_INVALID_SIZE +--- #-------------------------------------------------------------------------- +type: function +desc: "Releases the adapter handle reference indicating end of its usage" +class: $x +name: AdapterRelease +decl: static +ordinal: "3" +details: + - "When the reference count of the adapter reaches zero, the adapter may perform adapter-specififc resource teardown" +params: + - type: "$x_adapter_handle_t" + name: hAdapter + desc: | + [in] Adapter handle to release +--- #-------------------------------------------------------------------------- +type: function +desc: "Get a reference to the adapter handle." +class: $x +name: AdapterRetain +decl: static +ordinal: "4" +details: + - "Get a reference to the adapter handle. Increment its reference count" +params: + - type: "$x_adapter_handle_t" + name: hAdapter + desc: | + [in] Adapter handle to retain +--- #-------------------------------------------------------------------------- +type: function +desc: "Get the last adapter specific error." +details: | + To be used after another entry-point has returned + $X_RESULT_ERROR_ADAPTER_SPECIFIC in order to retrieve a message describing + the circumstances of the underlying driver error and the error code + returned by the failed driver entry-point. + + * Implementations *must* store the message and error code in thread-local + storage prior to returning $X_RESULT_ERROR_ADAPTER_SPECIFIC. + + * The message and error code storage is will only be valid if a previously + called entry-point returned $X_RESULT_ERROR_ADAPTER_SPECIFIC. + + * The memory pointed to by the C string returned in `ppMessage` is owned by + the adapter and *must* be null terminated. + + * The application *may* call this function from simultaneous threads. + + * The implementation of this function *should* be lock-free. + + Example usage: + + ```cpp + if ($xQueueCreate(hContext, hDevice, nullptr, &hQueue) == + $X_RESULT_ERROR_ADAPTER_SPECIFIC) { + const char* pMessage; + int32_t error; + $xAdapterGetLastError(hAdapter, &pMessage, &error); + } + ``` +class: $x +name: AdapterGetLastError +decl: static +ordinal: "5" +params: + - type: $x_adapter_handle_t + name: hAdapter + desc: "[in] handle of the adapter instance" + - type: const char** + name: ppMessage + desc: > + [out] pointer to a C string where the adapter specific error message + will be stored. + - type: int32_t* + name: pError + desc: > + [out] pointer to an integer where the adapter specific error code + will be stored. +--- #-------------------------------------------------------------------------- +type: enum +desc: "Supported adapter info" +class: $xAdapter +name: $x_adapter_info_t +typed_etors: True +etors: + - name: BACKEND + desc: "[$x_adapter_backend_t] Identifies the native backend supported by the adapter." + - name: REFERENCE_COUNT + desc: | + [uint32_t] Reference count of the adapter. + The reference count returned should be considered immediately stale. + It is unsuitable for general use in applications. This feature is provided for identifying memory leaks. +--- #-------------------------------------------------------------------------- +type: function +desc: "Retrieves information about the adapter" +class: $x +name: AdapterGetInfo +decl: static +ordinal: "6" +details: + - "The application may call this function from simultaneous threads." + - "The implementation of this function should be lock-free." +params: + - type: $x_adapter_handle_t + name: hAdapter + desc: "[in] handle of the adapter" + - type: $x_adapter_info_t + name: propName + desc: "[in] type of the info to retrieve" + - type: "size_t" + name: propSize + desc: | + [in] the number of bytes pointed to by pPropValue. + - type: "void*" + name: pPropValue + desc: | + [out][optional][typename(propName, propSize)] array of bytes holding the info. + If Size is not equal to or greater to the real number of bytes needed to return the info then the $X_RESULT_ERROR_INVALID_SIZE error is returned and pPropValue is not used. + - type: "size_t*" + name: pPropSizeRet + desc: | + [out][optional] pointer to the actual number of bytes being queried by pPropValue. +returns: + - $X_RESULT_ERROR_UNSUPPORTED_ENUMERATION: + - "If `propName` is not supported by the adapter." + - $X_RESULT_ERROR_INVALID_SIZE: + - "`propSize == 0 && pPropValue != NULL`" + - "If `propSize` is less than the real number of bytes needed to return the info." + - $X_RESULT_ERROR_INVALID_NULL_POINTER: + - "`propSize != 0 && pPropValue == NULL`" + - "`pPropValue == NULL && pPropSizeRet == NULL`" + - $X_RESULT_ERROR_OUT_OF_RESOURCES + - $X_RESULT_ERROR_OUT_OF_HOST_MEMORY +--- #-------------------------------------------------------------------------- +type: enum +desc: "Identifies backend of the adapter" +class: $x +name: $x_adapter_backend_t +etors: + - name: UNKNOWN + value: "0" + desc: "The backend is not a recognized one" + - name: LEVEL_ZERO + value: "1" + desc: "The backend is Level Zero" + - name: OPENCL + value: "2" + desc: "The backend is OpenCL" + - name: CUDA + value: "3" + desc: "The backend is CUDA" + - name: HIP + value: "4" + desc: "The backend is HIP" + - name: NATIVE_CPU + value: "5" + desc: "The backend is Native CPU" diff --git a/scripts/core/sampler.yml b/scripts/core/sampler.yml index 17719f6c3b..7bb33b357e 100644 --- a/scripts/core/sampler.yml +++ b/scripts/core/sampler.yml @@ -194,6 +194,9 @@ params: name: phNativeSampler desc: | [out] a pointer to the native handle of the sampler. +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." --- #-------------------------------------------------------------------------- type: struct desc: "Native sampler creation properties" @@ -221,7 +224,7 @@ details: params: - type: $x_native_handle_t name: hNativeSampler - desc: "[in] the native handle of the sampler." + desc: "[in][nocheck] the native handle of the sampler." - type: $x_context_handle_t name: hContext desc: "[in] handle of the context object" @@ -231,3 +234,6 @@ params: - type: "$x_sampler_handle_t*" name: phSampler desc: "[out] pointer to the handle of the sampler object created." +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." diff --git a/scripts/core/virtual_memory.yml b/scripts/core/virtual_memory.yml index 774890d8f5..ba88d4be2e 100644 --- a/scripts/core/virtual_memory.yml +++ b/scripts/core/virtual_memory.yml @@ -59,6 +59,19 @@ params: desc: > [out][optional] pointer to the actual size in bytes of the queried propName." +returns: + - $X_RESULT_ERROR_UNSUPPORTED_ENUMERATION: + - "If `propName` is not supported by the adapter." + - $X_RESULT_ERROR_INVALID_SIZE: + - "`propSize == 0 && pPropValue != NULL`" + - "If `propSize` is less than the real number of bytes needed to return the info." + - $X_RESULT_ERROR_INVALID_NULL_POINTER: + - "`propSize != 0 && pPropValue == NULL`" + - "`pPropValue == NULL && pPropSizeRet == NULL`" + - $X_RESULT_ERROR_INVALID_DEVICE + - $X_RESULT_ERROR_INVALID_CONTEXT + - $X_RESULT_ERROR_OUT_OF_RESOURCES + - $X_RESULT_ERROR_OUT_OF_HOST_MEMORY --- #-------------------------------------------------------------------------- type: function @@ -174,7 +187,7 @@ params: desc: "[in] pointer to the start of the virtual memory range." - type: size_t name: size - desc: "[in] size in bytes of the virutal memory range." + desc: "[in] size in bytes of the virtual memory range." - type: $x_virtual_mem_access_flags_t name: flags desc: "[in] access flags to set for the mapped virtual memory range." @@ -260,7 +273,7 @@ params: - type: size_t name: size desc: > - [in] size in bytes of phyisical memory to allocate, must be a + [in] size in bytes of physical memory to allocate, must be a multiple of $X_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM. - type: const $x_physical_mem_properties_t* name: pProperties @@ -268,7 +281,9 @@ params: - type: $x_physical_mem_handle_t* name: phPhysicalMem desc: "[out] pointer to handle of physical memory object created." - +returns: + - $X_RESULT_ERROR_INVALID_SIZE: + - "If size is not a multiple of $X_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM." --- #-------------------------------------------------------------------------- type: function desc: "Retain a physical memory handle, increment its reference count." diff --git a/scripts/generate_docs.py b/scripts/generate_docs.py index 4b2ca891d3..3f28e1b75e 100644 --- a/scripts/generate_docs.py +++ b/scripts/generate_docs.py @@ -96,7 +96,8 @@ def _generate_valid_rst(fin, fout, namespace, tags, ver, rev, meta): error = False outlines = [] - for iline, line in enumerate(util.textRead(fin)): + iter = enumerate(util.textRead(fin)) + for iline, line in iter: if re.match(RE_ENABLE, line) or re.match(RE_PYCODE_BLOCK_END, line): enable = True @@ -136,6 +137,18 @@ def _generate_valid_rst(fin, fout, namespace, tags, ver, rev, meta): continue if code_block and 'function' == symbol_type: + # If function is split across multiple lines + # then join lines until a ';' is encountered. + try: + line = line.rstrip() + while not line.endswith(';'): + _, n_line = next(iter) + line = line + n_line.strip() + line += '\n' + except StopIteration: + print(f"Function {line[:100]} was not terminated by a ';' character.") + error = True + words = re.sub(RE_EXTRACT_PARAMS, r"\1", line) words = line.split(",") if len(words) != len(meta['function'][symbol]['params']): diff --git a/scripts/generate_ids.py b/scripts/generate_ids.py index 26dfd89fb7..0b26b8407d 100644 --- a/scripts/generate_ids.py +++ b/scripts/generate_ids.py @@ -9,6 +9,8 @@ from fileinput import FileInput import util import yaml +import re +import copy ENUM_NAME = '$x_function_t' @@ -18,29 +20,100 @@ class quoted(str): def quoted_presenter(dumper, data): return dumper.represent_scalar('tag:yaml.org,2002:str', data, style='"') -def generate_registry(path, specs): +def get_registry_header(): + return {'type': 'header', 'desc': quoted('Intel $OneApi Unified Runtime function registry'), 'ordinal': quoted(-1)} + +def write_registry(data, path): + with open(path, 'w') as fout: + yaml.add_representer(quoted, quoted_presenter) + yaml.dump_all(data, fout, + default_flow_style=False, + sort_keys=False, + explicit_start=True) + +def find_type_in_specs(specs, type): + return [obj for s in specs for obj in s['objects'] if obj['name'] == type][0] + +def get_max_enum(enum): + return int(max(enum['etors'], key=lambda x : int(x['value']))['value']) + +def copy_and_strip_prefix_from_enums(enum, prefix): + cpy = copy.deepcopy(enum) + for etor in cpy['etors']: + etor['name'] = etor['name'][len(prefix):] + return cpy + + +def generate_function_type(specs, meta, update_fn) -> dict: + existing_function_type = find_type_in_specs(specs, '$x_function_t') + existing_etors = {etor['name'] : etor['value'] for etor in existing_function_type['etors']} + max_etor = get_max_enum(existing_function_type) + functions = [obj['class'][len('$x'):] + obj['name'] for s in specs for obj in s['objects'] if obj['type'] == 'function'] + registry = list() + for fname in functions: + etor_name = "$X_FUNCTION_" + util.to_snake_case(fname).upper() + id = existing_etors.get(etor_name) + if id is None: + max_etor += 1 + id = max_etor + registry.append({ + 'name': etor_name, + 'desc': f'Enumerator for $x{fname}', + 'value': str(id)} + ) + registry = sorted(registry, key=lambda x : int(x['value'])) + existing_function_type['etors'] = registry + update_fn(existing_function_type, meta) + + ## create a copy to write back to registry.yml + return copy_and_strip_prefix_from_enums(existing_function_type, '$X_FUNCTION_') + + +def generate_structure_type(specs, meta, refresh_fn) -> dict: + structure_type = find_type_in_specs(specs, '$x_structure_type_t') + extended_structs = [obj for s in specs for obj in s['objects'] if re.match(r"struct|union", obj['type']) and 'base' in obj] + max_enum = get_max_enum(structure_type) + + structure_type_etors = list() + for struct in extended_structs: + # skip experimental enumerations + if struct['name'].startswith('$x_exp_'): + continue + + etor = [mem for mem in struct['members'] if mem['name'] == 'stype'][0]['init'] + + # try and match the etor + matched_etor = [e for e in structure_type['etors'] if e['name'] == etor] + + out_etor = { + 'name': etor, + 'desc': struct['name'] + } + + # if no match exists we assign it a new value + if len(matched_etor) == 0: + max_enum += 1 + out_etor['value'] = str(max_enum) + else: + out_etor['value'] = matched_etor[0]['value'] + + structure_type_etors.append(out_etor) + + structure_type_etors = sorted(structure_type_etors, key = lambda x : int(x['value'])) + structure_type['etors'] = structure_type_etors + refresh_fn(structure_type, meta) + + ## create a copy to write back to registry.yml + return copy_and_strip_prefix_from_enums(structure_type, '$X_STRUCTURE_TYPE_') + +def generate_registry(path, specs, meta, update_fn): try: - existing_registry = list(util.yamlRead(path))[1]['etors'] - existing_etors = {etor["name"]: etor["value"] for etor in existing_registry} - max_etor = int(max(existing_registry, key = lambda x : int(x["value"]))["value"]) - functions = [obj['class'][len('$x'):] + obj['name'] for s in specs for obj in s['objects'] if obj['type'] == 'function'] - registry = list() - for fname in functions: - etor_name = util.to_snake_case(fname).upper() - id = existing_etors.get(etor_name) - if id is None: - max_etor += 1 - id = max_etor - registry.append({'name': util.to_snake_case(fname).upper(), 'desc': 'Enumerator for $x'+fname, 'value': str(id)}) - registry = sorted(registry, key=lambda x: int(x['value'])) - wrapper = { 'name': ENUM_NAME, 'type': 'enum', 'desc': 'Defines unique stable identifiers for all functions' , 'etors': registry} - header = {'type': 'header', 'desc': quoted('Intel $OneApi Unified Runtime function registry'), 'ordinal': quoted(9)} - with open(path, 'w') as fout: - yaml.add_representer(quoted, quoted_presenter) - yaml.dump_all([header, wrapper], fout, - default_flow_style=False, - sort_keys=False, - explicit_start=True) + write_registry([ + get_registry_header(), + generate_function_type(specs, meta, update_fn), + generate_structure_type(specs, meta, update_fn) + ], path) + except BaseException as e: print("Failed to generate registry.yml... %s", e) raise e diff --git a/scripts/json2src.py b/scripts/json2src.py index 0a5c52e38a..10ad00a2fc 100755 --- a/scripts/json2src.py +++ b/scripts/json2src.py @@ -23,6 +23,33 @@ def add_argument(parser, name, help, default=False): group.add_argument("--skip-" + name, dest=name, help="Skip "+help, action="store_false") parser.set_defaults(**{name:default}) +""" + helpers to strip loader only api constructs from the json +""" +def strip_specs_class(specs, strip_class): + for spec in specs: + remove_obj = [] + for obj in spec["objects"]: + if "class" in obj and strip_class in obj["class"]: + remove_obj.append(obj) + for obj in remove_obj: + spec["objects"].remove(obj) + +def strip_meta_entry(meta, entry_name, pattern): + loader_entries = [] + for entry in meta[entry_name]: + if pattern in entry: + loader_entries.append(entry) + + for entry in loader_entries: + del meta[entry_name][entry] + +def strip_loader_meta(meta): + strip_meta_entry(meta, "class", "Loader") + strip_meta_entry(meta, "function", "Loader") + strip_meta_entry(meta, "enum", "loader") + strip_meta_entry(meta, "handle", "loader") + if __name__ == '__main__': parser = argparse.ArgumentParser() add_argument(parser, "lib", "generation of lib files.", True) @@ -48,6 +75,9 @@ def add_argument(parser, name, help, default=False): if args.sections == None or config['name'] in args.sections: if args.lib: generate_code.generate_lib(srcpath, config['name'], config['namespace'], config['tags'], args.ver, specs, input['meta']) + # From here only generate code for functions adapters can implement. + strip_specs_class(specs, "Loader") + strip_loader_meta(input['meta']) if args.loader: generate_code.generate_loader(srcpath, config['name'], config['namespace'], config['tags'], args.ver, specs, input['meta']) if args.layers: diff --git a/scripts/parse_specs.py b/scripts/parse_specs.py index 63cce5769d..d0094f958c 100644 --- a/scripts/parse_specs.py +++ b/scripts/parse_specs.py @@ -1,5 +1,5 @@ """ - Copyright (C) 2022 Intel Corporation + Copyright (C) 2022-2023 Intel Corporation Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT @@ -231,7 +231,7 @@ def __validate_etors(d, tags): raise Exception(prefix+"typed etor " + item['name'] + " must begin with a type identifier: [type]") type_name = _subt(type, tags) if not is_iso(type_name): - raise Exception(prefix+"type " + str(type) + " in a typed etor " + item['name'] + " must be a valid ISO C identifer") + raise Exception(prefix+"type " + str(type) + " in a typed etor " + item['name'] + " must be a valid ISO C identifier") __validate_name(item, 'name', tags, case='upper', prefix=prefix) @@ -292,6 +292,9 @@ def __validate_members(d, tags): if item['type'].endswith("flag_t"): raise Exception(prefix+"'type' must not be '*_flag_t': %s"%item['type']) + if d['type'] == 'union'and item.get('tag') is None: + raise Exception(prefix + f"union member {item['name']} must include a 'tag' annotation") + ver = __validate_version(item, prefix=prefix, base_version=d_ver) if ver < max_ver: raise Exception(prefix+"'version' must be increasing: %s"%item['version']) @@ -339,7 +342,11 @@ def __validate_params(d, tags): if ver < max_ver: raise Exception(prefix+"'version' must be increasing: %s"%item['version']) max_ver = ver - + + def __validate_union_tag(d): + if d.get('tag') is None: + raise Exception(f"{d['name']} must include a 'tag' part of the union.") + try: if 'type' not in d: raise Exception("every document must have 'type'") @@ -401,6 +408,8 @@ def __validate_params(d, tags): if ('desc' not in d) or ('name' not in d): raise Exception("'%s' requires the following scalar fields: {`desc`, `name`}"%d['type']) + if d['type'] == 'union': + __validate_union_tag(d) __validate_type(d, 'name', tags) __validate_base(d) __validate_members(d, tags) @@ -763,6 +772,13 @@ def _append(lst, key, val): obj['returns'] = rets return obj + +def _inline_extended_structs(specs, meta): + for s in specs: + for i, obj in enumerate(s['objects']): + obj = _inline_base(obj, meta) + s['objects'][i] = obj + """ generates extra content """ @@ -770,7 +786,6 @@ def _generate_extra(specs, meta): for s in specs: for i, obj in enumerate(s['objects']): obj = _generate_hash(obj) - obj = _inline_base(obj, meta) obj = _generate_returns(obj, meta) s['objects'][i] = obj @@ -809,7 +824,8 @@ def _refresh_enum_meta(obj, meta): if obj.get('class'): meta['class'][obj['class']]['enum'].remove(obj['name']) - del meta['enum'][obj['name']] + if meta['enum'].get(obj['name']): + del meta['enum'][obj['name']] ## re-generate meta meta = _generate_meta(obj, None, meta) @@ -856,13 +872,10 @@ def parse(section, version, tags, meta, ref): specs = [] files = util.findFiles(path, "*.yml") - # make sure registry is last, because it's autogenerated based on the rest of the spec - files = sorted(files, key=lambda f: 1 if f.endswith('registry.yml') else 0) + registry = [f for f in files if f.endswith('registry.yml')][0] enum_extensions = [] for f in files: - if f.endswith('registry.yml'): - generate_ids.generate_registry(f, specs) print("Parsing %s..."%f) docs = util.yamlRead(f) @@ -914,6 +927,8 @@ def parse(section, version, tags, meta, ref): }) specs = sorted(specs, key=lambda s: s['header']['ordinal']) + _inline_extended_structs(specs, meta) + generate_ids.generate_registry(registry, specs, meta, _refresh_enum_meta) _extend_enums(enum_extensions, specs, meta) _generate_extra(specs, meta) diff --git a/scripts/templates/api.py.mako b/scripts/templates/api.py.mako index 35a2fd6d27..0399bf1ba8 100644 --- a/scripts/templates/api.py.mako +++ b/scripts/templates/api.py.mako @@ -178,6 +178,9 @@ class ${N}_DDI: self.__dll.${x}Init(0, 0) %for tbl in tables: + %if 'Loader' in tbl['name']: +<% continue %> + %endif # call driver to get function pointers ${tbl['name']} = ${tbl['type']}() r = ${x}_result_v(self.__dll.${tbl['export']['name']}(version, byref(${tbl['name']}))) diff --git a/scripts/templates/api_listing.mako b/scripts/templates/api_listing.mako index 8a2f3c9833..722a803915 100644 --- a/scripts/templates/api_listing.mako +++ b/scripts/templates/api_listing.mako @@ -82,6 +82,54 @@ ${title} %endif %endfor # obj in objects +################################################################# +## ------------------------- +## Macros +## ------------------------- + <%isempty = True%> + <%seen = list() %> +%for obj in objects: +%if re.match(r"macro", obj['type']): +%if obj['name'] in seen: + <% continue %> +%else: + <% seen.append(obj['name'])%> +%endif +%if isempty: # only display section title if there is content. +%if needstitle: +<%needstitle = False%> +${title} +============================================================ +%endif +* Macros + +<%isempty = False%> +%endif + * :ref:`${th.make_type_name(n, tags, obj).replace("_", "-")}` +%endif +%endfor # obj in objects + +################################################################# +## ------------------------- +## Typedefs +## ------------------------- + <%isempty = True%> +%for obj in objects: +%if re.match(r"typedef", obj['type']): +%if isempty: # only display section title if there is content. +%if needstitle: +<%needstitle = False%> +${title} +============================================================ +%endif +* Typedefs + +<%isempty = False%> +%endif + * :ref:`${th.make_type_name(n, tags, obj).replace("_", "-")}` +%endif +%endfor # obj in objects + ################################################################# ## Generate API documentation ################################################################# @@ -159,6 +207,59 @@ ${th.make_type_name(n, tags, obj)} :project: UnifiedRuntime %endif +%endif +%endfor # obj in objects + +################################################################# +## ------------------------- +## Macros +## ------------------------- + <%isempty = True%> + <%seen = list() %> +%for obj in objects: +%if not re.match(r"macro", obj['type']): +<% continue %> +%endif # macro +%if obj['name'] in seen: + <% continue %> +%else: + <% seen.append(obj['name']) %> +%endif +%if isempty: +${title} Macros +-------------------------------------------------------------------------------- +<%isempty = False%> +%endif # isempty +.. _${th.make_type_name(n, tags, obj).replace("_", "-")}: + +${th.make_type_name(n, tags, obj)} +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. doxygendefine:: ${th.make_type_name(n, tags, obj)} + :project: UnifiedRuntime +%endfor # obj in objects + +################################################################# +## ------------------------- +## Typedefs +## ------------------------- + <%isempty = True%> +%for obj in objects: +%if re.match(r"typedef", obj['type']): +%if isempty: # only display section title if there is content. +${title} Typedefs +-------------------------------------------------------------------------------- +<%isempty = False%> +%endif +.. _${th.make_type_name(n, tags, obj).replace("_", "-")}: + +${th.make_type_name(n, tags, obj)} +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. doxygentypedef:: ${th.make_type_name(n, tags, obj)} + :project: UnifiedRuntime + + %endif %endfor # obj in objects diff --git a/scripts/templates/ddi.h.mako b/scripts/templates/ddi.h.mako index 3a0e0c1af2..26d7f3f93d 100644 --- a/scripts/templates/ddi.h.mako +++ b/scripts/templates/ddi.h.mako @@ -31,6 +31,9 @@ extern "C" { #endif %for tbl in th.get_pfntables(specs, meta, n, tags): +%if 'Loader' in tbl['export']['name']: + <% continue %> +%endif %for obj in tbl['functions']: /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for ${th.make_func_name(n, tags, obj)} @@ -94,6 +97,9 @@ typedef ${x}_result_t (${X}_APICALL *${tbl['pfn']})( typedef struct ${n}_dditable_t { %for tbl in th.get_pfntables(specs, meta, n, tags): +%if 'loader' in tbl['type']: + <% continue %> +%endif ${th.append_ws(tbl['type'], 35)} ${tbl['name']}; %endfor } ${n}_dditable_t; diff --git a/scripts/templates/exp-features.rst.mako b/scripts/templates/exp-features.rst.mako index 8358298047..5e90f9fa79 100644 --- a/scripts/templates/exp-features.rst.mako +++ b/scripts/templates/exp-features.rst.mako @@ -5,7 +5,7 @@ import glob expdocs = [] for section in sections: foundDocs = glob.glob(section + "/EXP-*.rst") - for found in foundDocs: + for found in sorted(foundDocs): expdocs.append(found) %> ===================== diff --git a/scripts/templates/exp_feat.rst.mako b/scripts/templates/exp_feat.rst.mako index cfa124fd1b..8c8de46e6a 100644 --- a/scripts/templates/exp_feat.rst.mako +++ b/scripts/templates/exp_feat.rst.mako @@ -70,6 +70,16 @@ Changelog | 1.0 | Initial Draft | +-----------+------------------------+ +Support +-------------------------------------------------------------------------------- + +Adapters which support this experimental feature *must* return the valid string +defined in ``${"${X}"}_${"_".join(name.split("-")).upper()}_EXTENSION_STRING_EXP`` +as one of the options from ${"${x}"}DeviceGetInfo when querying for +${"${X}"}_DEVICE_INFO_EXTENSIONS. Conversely, before using any of the +functionality defined in this experimental feature the user *must* use the +device query to determine if the adapter supports this feature. + Contributors -------------------------------------------------------------------------------- .. comment: diff --git a/scripts/templates/exp_feat.yml.mako b/scripts/templates/exp_feat.yml.mako index c23eab3f2b..84819697ed 100644 --- a/scripts/templates/exp_feat.yml.mako +++ b/scripts/templates/exp_feat.yml.mako @@ -17,3 +17,10 @@ import datetime type: header desc: "Intel $OneApi Unified Runtime Experimental APIs for ${" ".join(name.split("-")).title()}" ordinal: "99" +--- #-------------------------------------------------------------------------- +type: macro +desc: | + The extension string which defines support for ${name} + which is returned when querying device extensions. +name: $X_${"_".join(name.split("-")).upper()}_EXTENSION_STRING_EXP +value: "\"$x_exp_${"_".join(name.split("-"))}\"" diff --git a/scripts/templates/helper.py b/scripts/templates/helper.py index cbb612e29b..1e738dbc09 100644 --- a/scripts/templates/helper.py +++ b/scripts/templates/helper.py @@ -1,5 +1,5 @@ """ - Copyright (C) 2022 Intel Corporation + Copyright (C) 2022-2023 Intel Corporation Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT @@ -319,6 +319,7 @@ class param_traits: RE_RANGE = r".*\[range\((.+),\s*(.+)\)\][\S\s]*" RE_RELEASE = r".*\[release\].*" RE_TYPENAME = r".*\[typename\((.+),\s(.+)\)\].*" + RE_TAGGED = r".*\[tagged_by\((.+)\)].*" @classmethod def is_mbz(cls, item): @@ -369,6 +370,20 @@ def is_range(cls, item): except: return False + @classmethod + def is_tagged(cls, item): + try: + return True if re.match(cls.RE_TAGGED, item['desc']) else False + except: + return False + + @classmethod + def tagged_member(cls, item): + try: + return re.sub(cls.RE_TAGGED, r"\1", item['desc']) + except: + return None + @classmethod def range_start(cls, item): try: @@ -427,7 +442,7 @@ def is_global(item, tags): """ Public: - substitues each tag['key'] with tag['value'] + substitutes each tag['key'] with tag['value'] if comment, then insert doxygen '::' notation at beginning (for autogen links) """ def subt(namespace, tags, string, comment=False, remove_namespace=False): diff --git a/scripts/templates/ldrddi.cpp.mako b/scripts/templates/ldrddi.cpp.mako index 76ba506b64..bb15dc97c7 100644 --- a/scripts/templates/ldrddi.cpp.mako +++ b/scripts/templates/ldrddi.cpp.mako @@ -66,36 +66,65 @@ namespace ur_loader platform.dditable.${n}.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)}( ${", ".join(th.make_param_lines(n, tags, obj, format=["name"]))} ); } + %elif re.match(r"\w+AdapterGet$", th.make_func_name(n, tags, obj)): + + size_t adapterIndex = 0; + if( nullptr != ${obj['params'][1]['name']} && ${obj['params'][0]['name']} !=0) + { + for( auto& platform : context->platforms ) + { + platform.dditable.${n}.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)}( 1, &${obj['params'][1]['name']}[adapterIndex], nullptr ); + try + { + ${obj['params'][1]['name']}[adapterIndex] = reinterpret_cast<${n}_adapter_handle_t>(${n}_adapter_factory.getInstance( + ${obj['params'][1]['name']}[adapterIndex], &platform.dditable + )); + } + catch( std::bad_alloc &) + { + result = ${X}_RESULT_ERROR_OUT_OF_HOST_MEMORY; + break; + } + adapterIndex++; + } + } + + if( ${obj['params'][2]['name']} != nullptr ) + { + *${obj['params'][2]['name']} = static_cast(context->platforms.size()); + } + %elif re.match(r"\w+PlatformGet$", th.make_func_name(n, tags, obj)): uint32_t total_platform_handle_count = 0; - for( auto& platform : context->platforms ) + for( uint32_t adapter_index = 0; adapter_index < ${obj['params'][1]['name']}; adapter_index++) { - if(platform.initStatus != ${X}_RESULT_SUCCESS) - continue; + // extract adapter's function pointer table + auto dditable = + reinterpret_cast<${n}_platform_object_t *>( ${obj['params'][0]['name']}[adapter_index])->dditable; - if( ( 0 < ${obj['params'][0]['name']} ) && ( ${obj['params'][0]['name']} == total_platform_handle_count)) + if( ( 0 < ${obj['params'][2]['name']} ) && ( ${obj['params'][2]['name']} == total_platform_handle_count)) break; uint32_t library_platform_handle_count = 0; - result = platform.dditable.${n}.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)}( 0, nullptr, &library_platform_handle_count ); + result = dditable->${n}.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)}( &${obj['params'][0]['name']}[adapter_index], 1, 0, nullptr, &library_platform_handle_count ); if( ${X}_RESULT_SUCCESS != result ) break; - if( nullptr != ${obj['params'][1]['name']} && ${obj['params'][0]['name']} !=0) + if( nullptr != ${obj['params'][3]['name']} && ${obj['params'][2]['name']} !=0) { - if( total_platform_handle_count + library_platform_handle_count > ${obj['params'][0]['name']}) { - library_platform_handle_count = ${obj['params'][0]['name']} - total_platform_handle_count; + if( total_platform_handle_count + library_platform_handle_count > ${obj['params'][2]['name']}) { + library_platform_handle_count = ${obj['params'][2]['name']} - total_platform_handle_count; } - result = platform.dditable.${n}.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)}( library_platform_handle_count, &${obj['params'][1]['name']}[ total_platform_handle_count ], nullptr ); + result = dditable->${n}.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)}( &${obj['params'][0]['name']}[adapter_index], 1, library_platform_handle_count, &${obj['params'][3]['name']}[ total_platform_handle_count ], nullptr ); if( ${X}_RESULT_SUCCESS != result ) break; try { for( uint32_t i = 0; i < library_platform_handle_count; ++i ) { uint32_t platform_index = total_platform_handle_count + i; - ${obj['params'][1]['name']}[ platform_index ] = reinterpret_cast<${n}_platform_handle_t>( - ${n}_platform_factory.getInstance( ${obj['params'][1]['name']}[ platform_index ], &platform.dditable ) ); + ${obj['params'][3]['name']}[ platform_index ] = reinterpret_cast<${n}_platform_handle_t>( + ${n}_platform_factory.getInstance( ${obj['params'][3]['name']}[ platform_index ], dditable ) ); } } catch( std::bad_alloc& ) @@ -107,8 +136,8 @@ namespace ur_loader total_platform_handle_count += library_platform_handle_count; } - if( ${X}_RESULT_SUCCESS == result && ${obj['params'][2]['name']} != nullptr ) - *${obj['params'][2]['name']} = total_platform_handle_count; + if( ${X}_RESULT_SUCCESS == result && ${obj['params'][4]['name']} != nullptr ) + *${obj['params'][4]['name']} = total_platform_handle_count; %else: <%param_replacements={}%> diff --git a/scripts/templates/libapi.cpp.mako b/scripts/templates/libapi.cpp.mako index b054180fb6..c2fb67808e 100644 --- a/scripts/templates/libapi.cpp.mako +++ b/scripts/templates/libapi.cpp.mako @@ -56,10 +56,13 @@ ${th.make_func_name(n, tags, obj)}( %endfor ) try { +%if 'Loader' in obj['class']: + return ur_lib::${th.make_func_name(n, tags, obj)}(${", ".join(th.make_param_lines(n, tags, obj, format=["name"]))} ); +%else: %if re.match("Init", obj['name']): static ${x}_result_t result = ${X}_RESULT_SUCCESS; - std::call_once(${x}_lib::context->initOnce, [device_flags]() { - result = ${x}_lib::context->Init(device_flags); + std::call_once(${x}_lib::context->initOnce, [device_flags, hLoaderConfig]() { + result = ${x}_lib::context->Init(device_flags, hLoaderConfig); }); if( ${X}_RESULT_SUCCESS != result ) @@ -71,6 +74,7 @@ try { return ${X}_RESULT_ERROR_UNINITIALIZED; return ${th.make_pfn_name(n, tags, obj)}( ${", ".join(th.make_param_lines(n, tags, obj, format=["name"]))} ); +%endif } catch(...) { return exceptionToResult(std::current_exception()); } %if 'condition' in obj: #endif // ${th.subt(n, tags, obj['condition'])} diff --git a/scripts/templates/libddi.cpp.mako b/scripts/templates/libddi.cpp.mako index de73cc2fc7..fc04c20ff8 100644 --- a/scripts/templates/libddi.cpp.mako +++ b/scripts/templates/libddi.cpp.mako @@ -33,6 +33,9 @@ namespace ${x}_lib ${x}_result_t result = ${X}_RESULT_SUCCESS; %for tbl in th.get_pfntables(specs, meta, n, tags): + %if 'Loader' in tbl['export']['name']: + <% continue %> + %endif if( ${X}_RESULT_SUCCESS == result ) { result = ${tbl['export']['name']}( ${X}_API_VERSION_CURRENT, &${n}DdiTable.${tbl['name']} ); diff --git a/scripts/templates/params.hpp.mako b/scripts/templates/params.hpp.mako index c48d020ec8..78966d66ff 100644 --- a/scripts/templates/params.hpp.mako +++ b/scripts/templates/params.hpp.mako @@ -41,6 +41,16 @@ from templates import helper as th %endif +<% +def findUnionTag(_union): + tag = [_obj for _s in specs for _obj in _s['objects'] if _obj['name'] == _union['tag']] + return tag[0] if len(tag) > 0 else None + +def findMemberType(_item): + query = [_o for _s in specs for _o in _s['objects'] if _o['name'] == _item['type']] + return query[0] if len(query) > 0 else None +%> + <%def name="line(item, n, params, params_dict)"> <% iname = th._get_param_name(n, tags, item) @@ -57,7 +67,7 @@ from templates import helper as th %if n != 0: os << ", "; %endif - ## can't iterate over 'void *'... +## can't iterate over 'void *'... %if th.param_traits.is_range(item) and "void*" not in itype: os << ".${iname} = {"; for (size_t i = ${th.param_traits.range_start(item)}; ${deref}(params${access}${pname}) != NULL && i < ${deref}params${access}${prefix + th.param_traits.range_end(item)}; ++i) { @@ -69,6 +79,9 @@ from templates import helper as th } os << "}"; + %elif findMemberType(item) is not None and findMemberType(item)['type'] == "union": + os << ".${iname} = "; + ${x}_params::serializeUnion(os, ${deref}(params${access}${item['name']}), params${access}${th.param_traits.tagged_member(item)}); %elif typename is not None: os << ".${iname} = "; ${x}_params::serializeTagged(os, ${deref}(params${access}${pname}), ${deref}(params${access}${prefix}${typename}), ${deref}(params${access}${prefix}${typename_size})); @@ -96,6 +109,15 @@ template inline void serializeTagged(std::ostream &os, const void * %endif %endif +%if re.match(r"union", obj['type']) and obj['name']: + <% tag = [_obj for _s in specs for _obj in _s['objects'] if _obj['name'] == obj['tag']][0] %> + inline void serializeUnion( + std::ostream &os, + const ${obj['type']} ${th.make_type_name(n, tags, obj)} params, + const ${tag['type']} ${th.make_type_name(n, tags, tag)} tag + ); +%endif + %if th.type_traits.is_flags(obj['name']): template<> inline void serializeFlag<${th.make_enum_name(n, tags, obj)}>(std::ostream &os, uint32_t flag); @@ -109,7 +131,7 @@ template inline void serializeTagged(std::ostream &os, const void * ## ENUM ####################################################################### %if re.match(r"enum", obj['type']): inline std::ostream &operator<<(std::ostream &os, enum ${th.make_enum_name(n, tags, obj)} value); -%elif re.match(r"struct|union", obj['type']): +%elif re.match(r"struct", obj['type']): inline std::ostream &operator<<(std::ostream &os, const ${obj['type']} ${th.make_type_name(n, tags, obj)} params); %endif %endfor # obj in spec['objects'] @@ -260,7 +282,7 @@ inline void serializeFlag<${th.make_enum_name(n, tags, obj)}>(std::ostream &os, } // namespace ${x}_params %endif ## STRUCT/UNION ############################################################### -%elif re.match(r"struct|union", obj['type']): +%elif re.match(r"struct", obj['type']): inline std::ostream &operator<<(std::ostream &os, const ${obj['type']} ${th.make_type_name(n, tags, obj)} params) { os << "(${obj['type']} ${th.make_type_name(n, tags, obj)}){"; <% @@ -277,6 +299,33 @@ inline std::ostream &operator<<(std::ostream &os, const ${obj['type']} ${th.make os << "}"; return os; } +%elif re.match(r"union", obj['type']) and obj['name']: +<% tag = findUnionTag(obj) %> +inline void ${x}_params::serializeUnion( + std::ostream &os, + const ${obj['type']} ${th.make_type_name(n, tags, obj)} params, + const ${tag['type']} ${th.make_type_name(n, tags, tag)} tag +){ + os << "(${obj['type']} ${th.make_type_name(n, tags, obj)}){"; +<% +params_dict = dict() +for item in obj['members']: + iname = th._get_param_name(n, tags, item) + itype = th._get_type_name(n, tags, obj, item) + params_dict[iname] = itype +%> + switch(tag){ +%for mem in obj['members']: + case ${th.subt(n, tags, mem['tag'])}: + ${line(mem, 0, False, params_dict)} + break; +%endfor + default: + os << ""; + break; + } + os << "}"; +} %endif %endfor # obj in spec['objects'] %endfor diff --git a/scripts/templates/trcddi.cpp.mako b/scripts/templates/trcddi.cpp.mako index f8b506240a..6160b0072e 100644 --- a/scripts/templates/trcddi.cpp.mako +++ b/scripts/templates/trcddi.cpp.mako @@ -102,9 +102,14 @@ namespace ur_tracing_layer } %endfor - ${x}_result_t context_t::init(ur_dditable_t *dditable) - { + ${x}_result_t + context_t::init(ur_dditable_t *dditable, + const std::set &enabledLayerNames) { ${x}_result_t result = ${X}_RESULT_SUCCESS; + + if(!enabledLayerNames.count(name)) { + return result; + } %for tbl in th.get_pfntables(specs, meta, n, tags): if( ${X}_RESULT_SUCCESS == result ) diff --git a/scripts/templates/valddi.cpp.mako b/scripts/templates/valddi.cpp.mako index bd8b11d5a2..ee931f66f9 100644 --- a/scripts/templates/valddi.cpp.mako +++ b/scripts/templates/valddi.cpp.mako @@ -47,8 +47,9 @@ namespace ur_validation_layer { auto ${th.make_pfn_name(n, tags, obj)} = context.${n}DdiTable.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)}; - if( nullptr == ${th.make_pfn_name(n, tags, obj)} ) - return ${X}_RESULT_ERROR_UNSUPPORTED_FEATURE; + if( nullptr == ${th.make_pfn_name(n, tags, obj)} ) { + return ${X}_RESULT_ERROR_UNINITIALIZED; + } if( context.enableParameterValidation ) { @@ -138,11 +139,26 @@ namespace ur_validation_layer } %endfor - ${x}_result_t context_t::init( - ${x}_dditable_t *dditable - ) - { + ${x}_result_t + context_t::init(ur_dditable_t *dditable, + const std::set &enabledLayerNames) { ${x}_result_t result = ${X}_RESULT_SUCCESS; + + if (enabledLayerNames.count(nameFullValidation)) { + enableParameterValidation = true; + enableLeakChecking = true; + } else { + if (enabledLayerNames.count(nameParameterValidation)) { + enableParameterValidation = true; + } + if (enabledLayerNames.count(nameLeakChecking)) { + enableLeakChecking = true; + } + } + + if(!enableParameterValidation && !enableLeakChecking) { + return result; + } %for tbl in th.get_pfntables(specs, meta, n, tags): if ( ${X}_RESULT_SUCCESS == result ) diff --git a/source/adapters/CMakeLists.txt b/source/adapters/CMakeLists.txt index c003671e0c..8de581ac68 100644 --- a/source/adapters/CMakeLists.txt +++ b/source/adapters/CMakeLists.txt @@ -4,7 +4,7 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception function(add_ur_adapter name) - add_library(${name} ${ARGN}) + add_ur_library(${name} ${ARGN}) if(MSVC) set(TARGET_LIBNAME ${name}) string(TOUPPER ${TARGET_LIBNAME} TARGET_LIBNAME) @@ -15,6 +15,8 @@ function(add_ur_adapter name) set_target_properties(${name} PROPERTIES LINK_FLAGS "/DEF:${ADAPTER_VERSION_SCRIPT}" ) + elseif(APPLE) + target_compile_options(${name} PRIVATE "-fvisibility=hidden") else() set(TARGET_LIBNAME lib${name}_${PROJECT_VERSION_MAJOR}.0) string(TOUPPER ${TARGET_LIBNAME} TARGET_LIBNAME) @@ -31,7 +33,7 @@ add_subdirectory(null) if(UR_BUILD_ADAPTER_L0 OR UR_BUILD_ADAPTER_CUDA OR UR_BUILD_ADAPTER_HIP) # fetch adapter sources from SYCL set(SYCL_ADAPTER_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external") - FetchSource(https://github.com/intel/llvm.git sycl-nightly/20230717 "sycl/plugins/unified_runtime/ur" ${SYCL_ADAPTER_DIR}) + FetchSource(https://github.com/intel/llvm.git nightly-2023-08-01 "sycl/plugins/unified_runtime/ur" ${SYCL_ADAPTER_DIR}) endif() if(UR_BUILD_ADAPTER_L0) diff --git a/source/adapters/cuda/CMakeLists.txt b/source/adapters/cuda/CMakeLists.txt index 29bdc87152..f85d759c09 100644 --- a/source/adapters/cuda/CMakeLists.txt +++ b/source/adapters/cuda/CMakeLists.txt @@ -10,6 +10,10 @@ set(TARGET_NAME ur_adapter_cuda) add_ur_adapter(${TARGET_NAME} SHARED ${CUDA_DIR}/ur_interface_loader.cpp + ${CUDA_DIR}/adapter.hpp + ${CUDA_DIR}/adapter.cpp + ${CUDA_DIR}/command_buffer.hpp + ${CUDA_DIR}/command_buffer.cpp ${CUDA_DIR}/common.hpp ${CUDA_DIR}/common.cpp ${CUDA_DIR}/context.hpp @@ -33,12 +37,9 @@ add_ur_adapter(${TARGET_NAME} ${CUDA_DIR}/sampler.cpp ${CUDA_DIR}/tracing.cpp ${CUDA_DIR}/usm.cpp + ${CUDA_DIR}/usm_p2p.cpp ${CUDA_DIR}/../../ur.cpp ${CUDA_DIR}/../../ur.hpp - ${CUDA_DIR}/../../usm_allocator.cpp - ${CUDA_DIR}/../../usm_allocator.hpp - ${CUDA_DIR}/../../usm_allocator_config.cpp - ${CUDA_DIR}/../../usm_allocator_config.hpp ) set_target_properties(${TARGET_NAME} PROPERTIES @@ -69,6 +70,7 @@ endif() target_link_libraries(${TARGET_NAME} PRIVATE ${PROJECT_NAME}::headers ${PROJECT_NAME}::common + ${PROJECT_NAME}::unified_malloc_framework Threads::Threads cudadrv ) diff --git a/source/adapters/hip/CMakeLists.txt b/source/adapters/hip/CMakeLists.txt index a014725268..2f205d84e6 100644 --- a/source/adapters/hip/CMakeLists.txt +++ b/source/adapters/hip/CMakeLists.txt @@ -45,6 +45,10 @@ set(HIP_HEADERS "${UR_HIP_INCLUDE_DIR};${UR_HIP_HSA_INCLUDE_DIR}") add_ur_adapter(${TARGET_NAME} SHARED ${HIP_DIR}/ur_interface_loader.cpp + ${HIP_DIR}/adapter.hpp + ${HIP_DIR}/adapter.cpp + ${HIP_DIR}/command_buffer.hpp + ${HIP_DIR}/command_buffer.cpp ${HIP_DIR}/common.hpp ${HIP_DIR}/common.cpp ${HIP_DIR}/context.hpp @@ -67,12 +71,9 @@ add_ur_adapter(${TARGET_NAME} ${HIP_DIR}/sampler.hpp ${HIP_DIR}/sampler.cpp ${HIP_DIR}/usm.cpp + ${HIP_DIR}/usm_p2p.cpp ${HIP_DIR}/../../ur.cpp ${HIP_DIR}/../../ur.hpp - ${HIP_DIR}/../../usm_allocator.cpp - ${HIP_DIR}/../../usm_allocator.hpp - ${HIP_DIR}/../../usm_allocator_config.cpp - ${HIP_DIR}/../../usm_allocator_config.hpp ) if(NOT MSVC) @@ -100,6 +101,7 @@ if("${UR_HIP_PLATFORM}" STREQUAL "AMD") target_link_libraries(${TARGET_NAME} PRIVATE ${PROJECT_NAME}::headers ${PROJECT_NAME}::common + ${PROJECT_NAME}::unified_malloc_framework rocmdrv ) diff --git a/source/adapters/level_zero/CMakeLists.txt b/source/adapters/level_zero/CMakeLists.txt index fa089c4b9a..c361c230d3 100644 --- a/source/adapters/level_zero/CMakeLists.txt +++ b/source/adapters/level_zero/CMakeLists.txt @@ -74,6 +74,10 @@ target_include_directories(LevelZeroLoader-Headers add_ur_adapter(${TARGET_NAME} SHARED ${L0_DIR}/ur_interface_loader.cpp + ${L0_DIR}/adapter.hpp + ${L0_DIR}/adapter.cpp + ${L0_DIR}/command_buffer.hpp + ${L0_DIR}/command_buffer.cpp ${L0_DIR}/common.hpp ${L0_DIR}/context.hpp ${L0_DIR}/device.hpp @@ -91,6 +95,7 @@ add_ur_adapter(${TARGET_NAME} ${L0_DIR}/device.cpp ${L0_DIR}/event.cpp ${L0_DIR}/usm.cpp + ${L0_DIR}/usm_p2p.cpp ${L0_DIR}/memory.cpp ${L0_DIR}/kernel.cpp ${L0_DIR}/platform.cpp @@ -98,10 +103,6 @@ add_ur_adapter(${TARGET_NAME} ${L0_DIR}/queue.cpp ${L0_DIR}/sampler.cpp ${L0_DIR}/../../ur.cpp - ${L0_DIR}/../../usm_allocator.cpp - ${L0_DIR}/../../usm_allocator.hpp - ${L0_DIR}/../../usm_allocator_config.cpp - ${L0_DIR}/../../usm_allocator_config.hpp ) set_target_properties(${TARGET_NAME} PROPERTIES @@ -112,6 +113,7 @@ set_target_properties(${TARGET_NAME} PROPERTIES target_link_libraries(${TARGET_NAME} PRIVATE ${PROJECT_NAME}::headers ${PROJECT_NAME}::common + ${PROJECT_NAME}::unified_malloc_framework LevelZeroLoader LevelZeroLoader-Headers ) diff --git a/source/adapters/null/ur_null.cpp b/source/adapters/null/ur_null.cpp index 5653ca57db..18c8d89ef5 100644 --- a/source/adapters/null/ur_null.cpp +++ b/source/adapters/null/ur_null.cpp @@ -18,7 +18,28 @@ context_t d_context; ////////////////////////////////////////////////////////////////////////// context_t::context_t() { ////////////////////////////////////////////////////////////////////////// - urDdiTable.Platform.pfnGet = [](uint32_t NumEntries, + urDdiTable.Global.pfnAdapterGet = [](uint32_t NumAdapters, + ur_adapter_handle_t *phAdapters, + uint32_t *pNumAdapters) { + if (phAdapters != nullptr && NumAdapters != 1) { + return UR_RESULT_ERROR_INVALID_SIZE; + } + if (pNumAdapters != nullptr) { + *pNumAdapters = 1; + } + if (nullptr != phAdapters) { + *reinterpret_cast(phAdapters) = d_context.get(); + } + + return UR_RESULT_SUCCESS; + }; + ////////////////////////////////////////////////////////////////////////// + urDdiTable.Global.pfnAdapterRelease = [](ur_adapter_handle_t) { + return UR_RESULT_SUCCESS; + }; + ////////////////////////////////////////////////////////////////////////// + urDdiTable.Platform.pfnGet = [](ur_adapter_handle_t *phAdapters, + uint32_t NumAdapters, uint32_t NumEntries, ur_platform_handle_t *phPlatforms, uint32_t *pNumPlatforms) { if (phPlatforms != nullptr && NumEntries != 1) { diff --git a/source/adapters/null/ur_nullddi.cpp b/source/adapters/null/ur_nullddi.cpp index 2e19884b23..f9b8fb4d11 100644 --- a/source/adapters/null/ur_nullddi.cpp +++ b/source/adapters/null/ur_nullddi.cpp @@ -15,15 +15,17 @@ namespace driver { /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urInit __urdlllocal ur_result_t UR_APICALL urInit( - ur_device_init_flags_t device_flags ///< [in] device initialization flags. + ur_device_init_flags_t device_flags, ///< [in] device initialization flags. ///< must be 0 (default) or a combination of ::ur_device_init_flag_t. + ur_loader_config_handle_t + hLoaderConfig ///< [in][optional] Handle of loader config handle. ) try { ur_result_t result = UR_RESULT_SUCCESS; // if the driver has created a custom function, then call it instead of using the generic path auto pfnInit = d_context.urDdiTable.Global.pfnInit; if (nullptr != pfnInit) { - result = pfnInit(device_flags); + result = pfnInit(device_flags, hLoaderConfig); } else { // generic implementation } @@ -53,9 +55,144 @@ __urdlllocal ur_result_t UR_APICALL urTearDown( return exceptionToResult(std::current_exception()); } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterGet +__urdlllocal ur_result_t UR_APICALL urAdapterGet( + uint32_t + NumEntries, ///< [in] the number of adapters to be added to phAdapters. + ///< If phAdapters is not NULL, then NumEntries should be greater than + ///< zero, otherwise ::UR_RESULT_ERROR_INVALID_SIZE, + ///< will be returned. + ur_adapter_handle_t * + phAdapters, ///< [out][optional][range(0, NumEntries)] array of handle of adapters. + ///< If NumEntries is less than the number of adapters available, then + ///< ::urAdapterGet shall only retrieve that number of platforms. + uint32_t * + pNumAdapters ///< [out][optional] returns the total number of adapters available. + ) try { + ur_result_t result = UR_RESULT_SUCCESS; + + // if the driver has created a custom function, then call it instead of using the generic path + auto pfnAdapterGet = d_context.urDdiTable.Global.pfnAdapterGet; + if (nullptr != pfnAdapterGet) { + result = pfnAdapterGet(NumEntries, phAdapters, pNumAdapters); + } else { + // generic implementation + for (size_t i = 0; (nullptr != phAdapters) && (i < NumEntries); ++i) { + phAdapters[i] = + reinterpret_cast(d_context.get()); + } + } + + return result; +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterRelease +__urdlllocal ur_result_t UR_APICALL urAdapterRelease( + ur_adapter_handle_t hAdapter ///< [in] Adapter handle to release + ) try { + ur_result_t result = UR_RESULT_SUCCESS; + + // if the driver has created a custom function, then call it instead of using the generic path + auto pfnAdapterRelease = d_context.urDdiTable.Global.pfnAdapterRelease; + if (nullptr != pfnAdapterRelease) { + result = pfnAdapterRelease(hAdapter); + } else { + // generic implementation + } + + return result; +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterRetain +__urdlllocal ur_result_t UR_APICALL urAdapterRetain( + ur_adapter_handle_t hAdapter ///< [in] Adapter handle to retain + ) try { + ur_result_t result = UR_RESULT_SUCCESS; + + // if the driver has created a custom function, then call it instead of using the generic path + auto pfnAdapterRetain = d_context.urDdiTable.Global.pfnAdapterRetain; + if (nullptr != pfnAdapterRetain) { + result = pfnAdapterRetain(hAdapter); + } else { + // generic implementation + } + + return result; +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterGetLastError +__urdlllocal ur_result_t UR_APICALL urAdapterGetLastError( + ur_adapter_handle_t hAdapter, ///< [in] handle of the adapter instance + const char ** + ppMessage, ///< [out] pointer to a C string where the adapter specific error message + ///< will be stored. + int32_t * + pError ///< [out] pointer to an integer where the adapter specific error code will + ///< be stored. + ) try { + ur_result_t result = UR_RESULT_SUCCESS; + + // if the driver has created a custom function, then call it instead of using the generic path + auto pfnAdapterGetLastError = + d_context.urDdiTable.Global.pfnAdapterGetLastError; + if (nullptr != pfnAdapterGetLastError) { + result = pfnAdapterGetLastError(hAdapter, ppMessage, pError); + } else { + // generic implementation + } + + return result; +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterGetInfo +__urdlllocal ur_result_t UR_APICALL urAdapterGetInfo( + ur_adapter_handle_t hAdapter, ///< [in] handle of the adapter + ur_adapter_info_t propName, ///< [in] type of the info to retrieve + size_t propSize, ///< [in] the number of bytes pointed to by pPropValue. + void * + pPropValue, ///< [out][optional][typename(propName, propSize)] array of bytes holding + ///< the info. + ///< If Size is not equal to or greater to the real number of bytes needed + ///< to return the info then the ::UR_RESULT_ERROR_INVALID_SIZE error is + ///< returned and pPropValue is not used. + size_t * + pPropSizeRet ///< [out][optional] pointer to the actual number of bytes being queried by pPropValue. + ) try { + ur_result_t result = UR_RESULT_SUCCESS; + + // if the driver has created a custom function, then call it instead of using the generic path + auto pfnAdapterGetInfo = d_context.urDdiTable.Global.pfnAdapterGetInfo; + if (nullptr != pfnAdapterGetInfo) { + result = pfnAdapterGetInfo(hAdapter, propName, propSize, pPropValue, + pPropSizeRet); + } else { + // generic implementation + } + + return result; +} catch (...) { + return exceptionToResult(std::current_exception()); +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urPlatformGet __urdlllocal ur_result_t UR_APICALL urPlatformGet( + ur_adapter_handle_t * + phAdapters, ///< [in][range(0, NumAdapters)] array of adapters to query for platforms. + uint32_t NumAdapters, ///< [in] number of adapters pointed to by phAdapters uint32_t NumEntries, ///< [in] the number of platforms to be added to phPlatforms. ///< If phPlatforms is not NULL, then NumEntries should be greater than @@ -73,7 +210,8 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGet( // if the driver has created a custom function, then call it instead of using the generic path auto pfnGet = d_context.urDdiTable.Platform.pfnGet; if (nullptr != pfnGet) { - result = pfnGet(NumEntries, phPlatforms, pNumPlatforms); + result = pfnGet(phAdapters, NumAdapters, NumEntries, phPlatforms, + pNumPlatforms); } else { // generic implementation for (size_t i = 0; (nullptr != phPlatforms) && (i < NumEntries); ++i) { @@ -167,7 +305,7 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetNativeHandle( /// @brief Intercept function for urPlatformCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urPlatformCreateWithNativeHandle( ur_native_handle_t - hNativePlatform, ///< [in] the native handle of the platform. + hNativePlatform, ///< [in][nocheck] the native handle of the platform. const ur_platform_native_properties_t * pProperties, ///< [in][optional] pointer to native platform properties struct. ur_platform_handle_t * @@ -218,32 +356,6 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetBackendOption( return exceptionToResult(std::current_exception()); } -/////////////////////////////////////////////////////////////////////////////// -/// @brief Intercept function for urPlatformGetLastError -__urdlllocal ur_result_t UR_APICALL urPlatformGetLastError( - ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance - const char ** - ppMessage, ///< [out] pointer to a C string where the adapter specific error message - ///< will be stored. - int32_t * - pError ///< [out] pointer to an integer where the adapter specific error code will - ///< be stored. - ) try { - ur_result_t result = UR_RESULT_SUCCESS; - - // if the driver has created a custom function, then call it instead of using the generic path - auto pfnGetLastError = d_context.urDdiTable.Platform.pfnGetLastError; - if (nullptr != pfnGetLastError) { - result = pfnGetLastError(hPlatform, ppMessage, pError); - } else { - // generic implementation - } - - return result; -} catch (...) { - return exceptionToResult(std::current_exception()); -} - /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urDeviceGet __urdlllocal ur_result_t UR_APICALL urDeviceGet( @@ -445,8 +557,9 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urDeviceCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urDeviceCreateWithNativeHandle( - ur_native_handle_t hNativeDevice, ///< [in] the native handle of the device. - ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance + ur_native_handle_t + hNativeDevice, ///< [in][nocheck] the native handle of the device. + ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance const ur_device_native_properties_t * pProperties, ///< [in][optional] pointer to native device properties struct. ur_device_handle_t @@ -627,7 +740,7 @@ __urdlllocal ur_result_t UR_APICALL urContextGetNativeHandle( /// @brief Intercept function for urContextCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( ur_native_handle_t - hNativeContext, ///< [in] the native handle of the context. + hNativeContext, ///< [in][nocheck] the native handle of the context. uint32_t numDevices, ///< [in] number of devices associated with the context const ur_device_handle_t * phDevices, ///< [in][range(0, numDevices)] list of devices associated with the context @@ -829,8 +942,9 @@ __urdlllocal ur_result_t UR_APICALL urMemGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urMemBufferCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( - ur_native_handle_t hNativeMem, ///< [in] the native handle to the memory. - ur_context_handle_t hContext, ///< [in] handle of the context object. + ur_native_handle_t + hNativeMem, ///< [in][nocheck] the native handle to the memory. + ur_context_handle_t hContext, ///< [in] handle of the context object. const ur_mem_native_properties_t * pProperties, ///< [in][optional] pointer to native memory creation properties. ur_mem_handle_t @@ -857,8 +971,9 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urMemImageCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urMemImageCreateWithNativeHandle( - ur_native_handle_t hNativeMem, ///< [in] the native handle to the memory. - ur_context_handle_t hContext, ///< [in] handle of the context object. + ur_native_handle_t + hNativeMem, ///< [in][nocheck] the native handle to the memory. + ur_context_handle_t hContext, ///< [in] handle of the context object. const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification. const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description. @@ -1073,7 +1188,7 @@ __urdlllocal ur_result_t UR_APICALL urSamplerGetNativeHandle( /// @brief Intercept function for urSamplerCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urSamplerCreateWithNativeHandle( ur_native_handle_t - hNativeSampler, ///< [in] the native handle of the sampler. + hNativeSampler, ///< [in][nocheck] the native handle of the sampler. ur_context_handle_t hContext, ///< [in] handle of the context object const ur_sampler_native_properties_t * pProperties, ///< [in][optional] pointer to native sampler properties struct. @@ -1472,7 +1587,7 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemSetAccess( ur_context_handle_t hContext, ///< [in] handle to the context object. const void *pStart, ///< [in] pointer to the start of the virtual memory range. - size_t size, ///< [in] size in bytes of the virutal memory range. + size_t size, ///< [in] size in bytes of the virtual memory range. ur_virtual_mem_access_flags_t flags ///< [in] access flags to set for the mapped virtual memory range. ) try { @@ -1531,7 +1646,7 @@ __urdlllocal ur_result_t UR_APICALL urPhysicalMemCreate( ur_context_handle_t hContext, ///< [in] handle of the context object. ur_device_handle_t hDevice, ///< [in] handle of the device object. size_t - size, ///< [in] size in bytes of phyisical memory to allocate, must be a multiple + size, ///< [in] size in bytes of physical memory to allocate, must be a multiple ///< of ::UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM. const ur_physical_mem_properties_t * pProperties, ///< [in][optional] pointer to physical memory creation properties. @@ -1919,7 +2034,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetNativeHandle( /// @brief Intercept function for urProgramCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urProgramCreateWithNativeHandle( ur_native_handle_t - hNativeProgram, ///< [in] the native handle of the program. + hNativeProgram, ///< [in][nocheck] the native handle of the program. ur_context_handle_t hContext, ///< [in] handle of the context instance const ur_program_native_properties_t * pProperties, ///< [in][optional] pointer to native program properties struct. @@ -2307,8 +2422,9 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urKernelCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urKernelCreateWithNativeHandle( - ur_native_handle_t hNativeKernel, ///< [in] the native handle of the kernel. - ur_context_handle_t hContext, ///< [in] handle of the context object + ur_native_handle_t + hNativeKernel, ///< [in][nocheck] the native handle of the kernel. + ur_context_handle_t hContext, ///< [in] handle of the context object ur_program_handle_t hProgram, ///< [in] handle of the program associated with the kernel const ur_kernel_native_properties_t * @@ -2457,9 +2573,10 @@ __urdlllocal ur_result_t UR_APICALL urQueueGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urQueueCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urQueueCreateWithNativeHandle( - ur_native_handle_t hNativeQueue, ///< [in] the native handle of the queue. - ur_context_handle_t hContext, ///< [in] handle of the context object - ur_device_handle_t hDevice, ///< [in] handle of the device object + ur_native_handle_t + hNativeQueue, ///< [in][nocheck] the native handle of the queue. + ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_queue_native_properties_t * pProperties, ///< [in][optional] pointer to native queue properties struct ur_queue_handle_t @@ -2669,8 +2786,9 @@ __urdlllocal ur_result_t UR_APICALL urEventGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urEventCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urEventCreateWithNativeHandle( - ur_native_handle_t hNativeEvent, ///< [in] the native handle of the event. - ur_context_handle_t hContext, ///< [in] handle of the context object + ur_native_handle_t + hNativeEvent, ///< [in][nocheck] the native handle of the event. + ur_context_handle_t hContext, ///< [in] handle of the context object const ur_event_native_properties_t * pProperties, ///< [in][optional] pointer to native event properties struct ur_event_handle_t @@ -3817,6 +3935,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMPitchedAllocExp( __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageHandleDestroyExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_handle_t hImage ///< [in] pointer to handle of image object to destroy ) try { @@ -3827,7 +3946,7 @@ urBindlessImagesUnsampledImageHandleDestroyExp( d_context.urDdiTable.BindlessImagesExp .pfnUnsampledImageHandleDestroyExp; if (nullptr != pfnUnsampledImageHandleDestroyExp) { - result = pfnUnsampledImageHandleDestroyExp(hContext, hImage); + result = pfnUnsampledImageHandleDestroyExp(hContext, hDevice, hImage); } else { // generic implementation } @@ -3842,6 +3961,7 @@ urBindlessImagesUnsampledImageHandleDestroyExp( __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageHandleDestroyExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_handle_t hImage ///< [in] pointer to handle of image object to destroy ) try { @@ -3851,7 +3971,7 @@ urBindlessImagesSampledImageHandleDestroyExp( auto pfnSampledImageHandleDestroyExp = d_context.urDdiTable.BindlessImagesExp.pfnSampledImageHandleDestroyExp; if (nullptr != pfnSampledImageHandleDestroyExp) { - result = pfnSampledImageHandleDestroyExp(hContext, hImage); + result = pfnSampledImageHandleDestroyExp(hContext, hDevice, hImage); } else { // generic implementation } @@ -3865,6 +3985,7 @@ urBindlessImagesSampledImageHandleDestroyExp( /// @brief Intercept function for urBindlessImagesImageAllocateExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description @@ -3877,8 +3998,8 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( auto pfnImageAllocateExp = d_context.urDdiTable.BindlessImagesExp.pfnImageAllocateExp; if (nullptr != pfnImageAllocateExp) { - result = - pfnImageAllocateExp(hContext, pImageFormat, pImageDesc, phImageMem); + result = pfnImageAllocateExp(hContext, hDevice, pImageFormat, + pImageDesc, phImageMem); } else { // generic implementation *phImageMem = @@ -3894,6 +4015,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( /// @brief Intercept function for urBindlessImagesImageFreeExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageFreeExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem ///< [in] handle of image memory to be freed ) try { @@ -3903,7 +4025,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageFreeExp( auto pfnImageFreeExp = d_context.urDdiTable.BindlessImagesExp.pfnImageFreeExp; if (nullptr != pfnImageFreeExp) { - result = pfnImageFreeExp(hContext, hImageMem); + result = pfnImageFreeExp(hContext, hDevice, hImageMem); } else { // generic implementation } @@ -3917,6 +4039,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageFreeExp( /// @brief Intercept function for urBindlessImagesUnsampledImageCreateExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] handle to memory from which to create the image const ur_image_format_t @@ -3932,8 +4055,9 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( auto pfnUnsampledImageCreateExp = d_context.urDdiTable.BindlessImagesExp.pfnUnsampledImageCreateExp; if (nullptr != pfnUnsampledImageCreateExp) { - result = pfnUnsampledImageCreateExp(hContext, hImageMem, pImageFormat, - pImageDesc, phMem, phImage); + result = pfnUnsampledImageCreateExp(hContext, hDevice, hImageMem, + pImageFormat, pImageDesc, phMem, + phImage); } else { // generic implementation *phMem = reinterpret_cast(d_context.get()); @@ -3950,6 +4074,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( /// @brief Intercept function for urBindlessImagesSampledImageCreateExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] handle to memory from which to create the image const ur_image_format_t @@ -3966,8 +4091,9 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( auto pfnSampledImageCreateExp = d_context.urDdiTable.BindlessImagesExp.pfnSampledImageCreateExp; if (nullptr != pfnSampledImageCreateExp) { - result = pfnSampledImageCreateExp(hContext, hImageMem, pImageFormat, - pImageDesc, hSampler, phMem, phImage); + result = + pfnSampledImageCreateExp(hContext, hDevice, hImageMem, pImageFormat, + pImageDesc, hSampler, phMem, phImage); } else { // generic implementation *phMem = reinterpret_cast(d_context.get()); @@ -3983,14 +4109,26 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urBindlessImagesImageCopyExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageCopyExp( - ur_context_handle_t hContext, ///< [in] handle of the context object - void *pDst, ///< [in] location the data will be copied to - void *pSrc, ///< [in] location the data will be copied from + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + void *pDst, ///< [in] location the data will be copied to + void *pSrc, ///< [in] location the data will be copied from const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description ur_exp_image_copy_flags_t imageCopyFlags, ///< [in] flags describing copy direction e.g. H2D or D2H + ur_rect_offset_t + srcOffset, ///< [in] defines the (x,y,z) source offset in pixels in the 1D, 2D, or 3D + ///< image + ur_rect_offset_t + dstOffset, ///< [in] defines the (x,y,z) destination offset in pixels in the 1D, 2D, + ///< or 3D image + ur_rect_region_t + copyExtent, ///< [in] defines the (width, height, depth) in pixels of the 1D, 2D, or 3D + ///< region to copy + ur_rect_region_t + hostExtent, ///< [in] defines the (width, height, depth) in pixels of the 1D, 2D, or 3D + ///< region on the host uint32_t numEventsInWaitList, ///< [in] size of the event wait list const ur_event_handle_t * phEventWaitList, ///< [in][optional][range(0, numEventsInWaitList)] pointer to a list of @@ -4008,8 +4146,9 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageCopyExp( auto pfnImageCopyExp = d_context.urDdiTable.BindlessImagesExp.pfnImageCopyExp; if (nullptr != pfnImageCopyExp) { - result = pfnImageCopyExp(hContext, pDst, pSrc, pImageFormat, pImageDesc, - imageCopyFlags, numEventsInWaitList, + result = pfnImageCopyExp(hQueue, pDst, pSrc, pImageFormat, pImageDesc, + imageCopyFlags, srcOffset, dstOffset, + copyExtent, hostExtent, numEventsInWaitList, phEventWaitList, phEvent); } else { // generic implementation @@ -4052,6 +4191,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( /// @brief Intercept function for urBindlessImagesMipmapGetLevelExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] memory handle to the mipmap image uint32_t mipmapLevel, ///< [in] requested level of the mipmap @@ -4064,8 +4204,8 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( auto pfnMipmapGetLevelExp = d_context.urDdiTable.BindlessImagesExp.pfnMipmapGetLevelExp; if (nullptr != pfnMipmapGetLevelExp) { - result = - pfnMipmapGetLevelExp(hContext, hImageMem, mipmapLevel, phImageMem); + result = pfnMipmapGetLevelExp(hContext, hDevice, hImageMem, mipmapLevel, + phImageMem); } else { // generic implementation *phImageMem = @@ -4081,6 +4221,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( /// @brief Intercept function for urBindlessImagesMipmapFreeExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hMem ///< [in] handle of image memory to be freed ) try { ur_result_t result = UR_RESULT_SUCCESS; @@ -4089,7 +4230,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( auto pfnMipmapFreeExp = d_context.urDdiTable.BindlessImagesExp.pfnMipmapFreeExp; if (nullptr != pfnMipmapFreeExp) { - result = pfnMipmapFreeExp(hContext, hMem); + result = pfnMipmapFreeExp(hContext, hDevice, hMem); } else { // generic implementation } @@ -4103,8 +4244,10 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( /// @brief Intercept function for urBindlessImagesImportOpaqueFDExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object size_t size, ///< [in] size of the external memory - uint32_t fileDescriptor, ///< [in] the file descriptor + ur_exp_interop_mem_desc_t + *pInteropMemDesc, ///< [in] the interop memory descriptor ur_exp_interop_mem_handle_t *phInteropMem ///< [out] interop memory handle to the external memory ) try { @@ -4114,8 +4257,8 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( auto pfnImportOpaqueFDExp = d_context.urDdiTable.BindlessImagesExp.pfnImportOpaqueFDExp; if (nullptr != pfnImportOpaqueFDExp) { - result = - pfnImportOpaqueFDExp(hContext, size, fileDescriptor, phInteropMem); + result = pfnImportOpaqueFDExp(hContext, hDevice, size, pInteropMemDesc, + phInteropMem); } else { // generic implementation *phInteropMem = @@ -4131,12 +4274,13 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( /// @brief Intercept function for urBindlessImagesMapExternalArrayExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description ur_exp_interop_mem_handle_t hInteropMem, ///< [in] interop memory handle to the external memory - ur_exp_image_handle_t * + ur_exp_image_mem_handle_t * phImageMem ///< [out] image memory handle to the externally allocated memory ) try { ur_result_t result = UR_RESULT_SUCCESS; @@ -4145,11 +4289,12 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( auto pfnMapExternalArrayExp = d_context.urDdiTable.BindlessImagesExp.pfnMapExternalArrayExp; if (nullptr != pfnMapExternalArrayExp) { - result = pfnMapExternalArrayExp(hContext, pImageFormat, pImageDesc, - hInteropMem, phImageMem); + result = pfnMapExternalArrayExp(hContext, hDevice, pImageFormat, + pImageDesc, hInteropMem, phImageMem); } else { // generic implementation - *phImageMem = reinterpret_cast(d_context.get()); + *phImageMem = + reinterpret_cast(d_context.get()); } return result; @@ -4161,6 +4306,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( /// @brief Intercept function for urBindlessImagesReleaseInteropExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_interop_mem_handle_t hInteropMem ///< [in] handle of interop memory to be freed ) try { @@ -4170,7 +4316,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( auto pfnReleaseInteropExp = d_context.urDdiTable.BindlessImagesExp.pfnReleaseInteropExp; if (nullptr != pfnReleaseInteropExp) { - result = pfnReleaseInteropExp(hContext, hInteropMem); + result = pfnReleaseInteropExp(hContext, hDevice, hInteropMem); } else { // generic implementation } @@ -4185,9 +4331,11 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object - uint32_t fileDescriptor, ///< [in] the file descriptor + ur_device_handle_t hDevice, ///< [in] handle of the device object + ur_exp_interop_semaphore_desc_t + *pInteropSemaphoreDesc, ///< [in] the interop semaphore descriptor ur_exp_interop_semaphore_handle_t * - phInteropSemaphoreHandle ///< [out] interop semaphore handle to the external semaphore + phInteropSemaphore ///< [out] interop semaphore handle to the external semaphore ) try { ur_result_t result = UR_RESULT_SUCCESS; @@ -4197,10 +4345,10 @@ urBindlessImagesImportExternalSemaphoreOpaqueFDExp( .pfnImportExternalSemaphoreOpaqueFDExp; if (nullptr != pfnImportExternalSemaphoreOpaqueFDExp) { result = pfnImportExternalSemaphoreOpaqueFDExp( - hContext, fileDescriptor, phInteropSemaphoreHandle); + hContext, hDevice, pInteropSemaphoreDesc, phInteropSemaphore); } else { // generic implementation - *phInteropSemaphoreHandle = + *phInteropSemaphore = reinterpret_cast( d_context.get()); } @@ -4214,6 +4362,7 @@ urBindlessImagesImportExternalSemaphoreOpaqueFDExp( /// @brief Intercept function for urBindlessImagesDestroyExternalSemaphoreExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesDestroyExternalSemaphoreExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_interop_semaphore_handle_t hInteropSemaphore ///< [in] handle of interop semaphore to be destroyed ) try { @@ -4223,7 +4372,8 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesDestroyExternalSemaphoreExp( auto pfnDestroyExternalSemaphoreExp = d_context.urDdiTable.BindlessImagesExp.pfnDestroyExternalSemaphoreExp; if (nullptr != pfnDestroyExternalSemaphoreExp) { - result = pfnDestroyExternalSemaphoreExp(hContext, hInteropSemaphore); + result = pfnDestroyExternalSemaphoreExp(hContext, hDevice, + hInteropSemaphore); } else { // generic implementation } @@ -4906,6 +5056,16 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetGlobalProcAddrTable( pDdiTable->pfnTearDown = driver::urTearDown; + pDdiTable->pfnAdapterGet = driver::urAdapterGet; + + pDdiTable->pfnAdapterRelease = driver::urAdapterRelease; + + pDdiTable->pfnAdapterRetain = driver::urAdapterRetain; + + pDdiTable->pfnAdapterGetLastError = driver::urAdapterGetLastError; + + pDdiTable->pfnAdapterGetInfo = driver::urAdapterGetInfo; + return result; } catch (...) { return exceptionToResult(std::current_exception()); @@ -5389,8 +5549,6 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetPlatformProcAddrTable( pDdiTable->pfnCreateWithNativeHandle = driver::urPlatformCreateWithNativeHandle; - pDdiTable->pfnGetLastError = driver::urPlatformGetLastError; - pDdiTable->pfnGetApiVersion = driver::urPlatformGetApiVersion; pDdiTable->pfnGetBackendOption = driver::urPlatformGetBackendOption; diff --git a/source/common/CMakeLists.txt b/source/common/CMakeLists.txt index aefc0c6195..f240f9908b 100644 --- a/source/common/CMakeLists.txt +++ b/source/common/CMakeLists.txt @@ -11,20 +11,20 @@ target_include_directories(ur_common INTERFACE ${CMAKE_SOURCE_DIR}/include ) -add_subdirectory(unified_memory_allocation) -add_subdirectory(uma_pools) -target_link_libraries(ur_common INTERFACE unified_memory_allocation disjoint_pool ${CMAKE_DL_LIBS} ${PROJECT_NAME}::headers) +add_subdirectory(unified_malloc_framework) +add_subdirectory(umf_pools) +target_link_libraries(ur_common INTERFACE unified_malloc_framework disjoint_pool ${CMAKE_DL_LIBS} ${PROJECT_NAME}::headers) if(WIN32) target_sources(ur_common INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/windows/ur_lib_loader.cpp - uma_helpers.hpp ur_pool_manager.hpp + umf_helpers.hpp ur_pool_manager.hpp ) else() target_sources(ur_common INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/linux/ur_lib_loader.cpp - uma_helpers.hpp ur_pool_manager.hpp + umf_helpers.hpp ur_pool_manager.hpp ) endif() diff --git a/source/common/linux/ur_lib_loader.cpp b/source/common/linux/ur_lib_loader.cpp index 445de6f2eb..1c5e0af89b 100644 --- a/source/common/linux/ur_lib_loader.cpp +++ b/source/common/linux/ur_lib_loader.cpp @@ -12,7 +12,7 @@ #include "logger/ur_logger.hpp" #include "ur_lib_loader.hpp" -#if defined(SANITIZER_ANY) +#if defined(SANITIZER_ANY) || defined(__APPLE__) #define LOAD_DRIVER_LIBRARY(NAME) dlopen(NAME, RTLD_LAZY | RTLD_LOCAL) #else #define LOAD_DRIVER_LIBRARY(NAME) \ diff --git a/source/common/logger/ur_sinks.hpp b/source/common/logger/ur_sinks.hpp index e9baac0a89..66322e98a6 100644 --- a/source/common/logger/ur_sinks.hpp +++ b/source/common/logger/ur_sinks.hpp @@ -28,7 +28,7 @@ class Sink { format(buffer, fmt, std::forward(args)...); - std::scoped_lock lock(output_mutex); + std::scoped_lock lock(output_mutex); *ostream << buffer.str(); if (level >= flush_level) { ostream->flush(); diff --git a/source/common/uma_helpers.hpp b/source/common/uma_helpers.hpp deleted file mode 100644 index 67eddd6811..0000000000 --- a/source/common/uma_helpers.hpp +++ /dev/null @@ -1,159 +0,0 @@ -/* - * - * Copyright (C) 2023 Intel Corporation - * - * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. - * See LICENSE.TXT - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - * - */ - -#ifndef UMA_HELPERS_H -#define UMA_HELPERS_H 1 - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -namespace uma { - -using pool_unique_handle_t = - std::unique_ptr>; -using provider_unique_handle_t = - std::unique_ptr>; - -#define UMA_ASSIGN_OP(ops, type, func, default_return) \ - ops.func = [](void *obj, auto... args) { \ - try { \ - return reinterpret_cast(obj)->func(args...); \ - } catch (...) { \ - return default_return; \ - } \ - } - -#define UMA_ASSIGN_OP_NORETURN(ops, type, func) \ - ops.func = [](void *obj, auto... args) { \ - try { \ - return reinterpret_cast(obj)->func(args...); \ - } catch (...) { \ - } \ - } - -/// @brief creates UMA memory provider based on given T type. -/// T should implement all functions defined by -/// uma_memory_provider_ops_t, except for finalize (it is -/// replaced by dtor). All arguments passed to this function are -/// forwarded to T::initialize(). -template -auto memoryProviderMakeUnique(Args &&...args) { - uma_memory_provider_ops_t ops; - auto argsTuple = std::make_tuple(std::forward(args)...); - - ops.version = UMA_VERSION_CURRENT; - ops.initialize = [](void *params, void **obj) { - auto *tuple = reinterpret_cast(params); - T *provider; - try { - provider = new T; - } catch (...) { - return UMA_RESULT_ERROR_OUT_OF_HOST_MEMORY; - } - - *obj = provider; - - try { - auto ret = - std::apply(&T::initialize, - std::tuple_cat(std::make_tuple(provider), *tuple)); - if (ret != UMA_RESULT_SUCCESS) { - delete provider; - } - return ret; - } catch (...) { - delete provider; - return UMA_RESULT_ERROR_UNKNOWN; - } - }; - ops.finalize = [](void *obj) { delete reinterpret_cast(obj); }; - - UMA_ASSIGN_OP(ops, T, alloc, UMA_RESULT_ERROR_UNKNOWN); - UMA_ASSIGN_OP(ops, T, free, UMA_RESULT_ERROR_UNKNOWN); - UMA_ASSIGN_OP(ops, T, get_last_result, UMA_RESULT_ERROR_UNKNOWN); - UMA_ASSIGN_OP(ops, T, get_recommended_page_size, UMA_RESULT_ERROR_UNKNOWN); - UMA_ASSIGN_OP(ops, T, get_min_page_size, UMA_RESULT_ERROR_UNKNOWN); - UMA_ASSIGN_OP(ops, T, purge_lazy, UMA_RESULT_ERROR_UNKNOWN); - UMA_ASSIGN_OP(ops, T, purge_force, UMA_RESULT_ERROR_UNKNOWN); - UMA_ASSIGN_OP_NORETURN(ops, T, get_name); - - uma_memory_provider_handle_t hProvider = nullptr; - auto ret = umaMemoryProviderCreate(&ops, &argsTuple, &hProvider); - return std::pair{ - ret, provider_unique_handle_t(hProvider, &umaMemoryProviderDestroy)}; -} - -/// @brief creates UMA memory pool based on given T type. -/// T should implement all functions defined by -/// uma_memory_provider_ops_t, except for finalize (it is -/// replaced by dtor). All arguments passed to this function are -/// forwarded to T::initialize(). -template -auto poolMakeUnique(uma_memory_provider_handle_t *providers, - size_t numProviders, Args &&...args) { - uma_memory_pool_ops_t ops; - auto argsTuple = std::make_tuple(std::forward(args)...); - - ops.version = UMA_VERSION_CURRENT; - ops.initialize = [](uma_memory_provider_handle_t *providers, - size_t numProviders, void *params, void **obj) { - auto *tuple = reinterpret_cast(params); - T *pool; - - try { - pool = new T; - } catch (...) { - return UMA_RESULT_ERROR_OUT_OF_HOST_MEMORY; - } - - *obj = pool; - - try { - auto ret = std::apply( - &T::initialize, - std::tuple_cat(std::make_tuple(pool, providers, numProviders), - *tuple)); - if (ret != UMA_RESULT_SUCCESS) { - delete pool; - } - return ret; - } catch (...) { - delete pool; - return UMA_RESULT_ERROR_UNKNOWN; - } - }; - ops.finalize = [](void *obj) { delete reinterpret_cast(obj); }; - - UMA_ASSIGN_OP(ops, T, malloc, ((void *)nullptr)); - UMA_ASSIGN_OP(ops, T, calloc, ((void *)nullptr)); - UMA_ASSIGN_OP(ops, T, aligned_malloc, ((void *)nullptr)); - UMA_ASSIGN_OP(ops, T, realloc, ((void *)nullptr)); - UMA_ASSIGN_OP(ops, T, malloc_usable_size, ((size_t)0)); - UMA_ASSIGN_OP_NORETURN(ops, T, free); - UMA_ASSIGN_OP(ops, T, get_last_result, UMA_RESULT_ERROR_UNKNOWN); - - uma_memory_pool_handle_t hPool = nullptr; - auto ret = umaPoolCreate(&ops, providers, numProviders, &argsTuple, &hPool); - return std::pair{ - ret, pool_unique_handle_t(hPool, &umaPoolDestroy)}; -} -} // namespace uma - -#endif /* UMA_HELPERS_H */ diff --git a/source/common/umf_helpers.hpp b/source/common/umf_helpers.hpp new file mode 100644 index 0000000000..4f2113f3d6 --- /dev/null +++ b/source/common/umf_helpers.hpp @@ -0,0 +1,225 @@ +/* + * + * Copyright (C) 2023 Intel Corporation + * + * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. + * See LICENSE.TXT + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + */ + +#ifndef UMF_HELPERS_H +#define UMF_HELPERS_H 1 + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +namespace umf { + +using pool_unique_handle_t = + std::unique_ptr>; +using provider_unique_handle_t = + std::unique_ptr>; + +#define UMF_ASSIGN_OP(ops, type, func, default_return) \ + ops.func = [](void *obj, auto... args) { \ + try { \ + return reinterpret_cast(obj)->func(args...); \ + } catch (...) { \ + return default_return; \ + } \ + } + +#define UMF_ASSIGN_OP_NORETURN(ops, type, func) \ + ops.func = [](void *obj, auto... args) { \ + try { \ + return reinterpret_cast(obj)->func(args...); \ + } catch (...) { \ + } \ + } + +namespace detail { +template +umf_result_t initialize(T *obj, ArgsTuple &&args) { + try { + auto ret = std::apply(&T::initialize, + std::tuple_cat(std::make_tuple(obj), + std::forward(args))); + if (ret != UMF_RESULT_SUCCESS) { + delete obj; + } + return ret; + } catch (...) { + delete obj; + return UMF_RESULT_ERROR_UNKNOWN; + } +} + +template +umf_memory_pool_ops_t poolMakeUniqueOps() { + umf_memory_pool_ops_t ops; + + ops.version = UMF_VERSION_CURRENT; + ops.initialize = [](umf_memory_provider_handle_t *providers, + size_t numProviders, void *params, void **obj) { + try { + *obj = new T; + } catch (...) { + return UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY; + } + + return detail::initialize( + reinterpret_cast(*obj), + std::tuple_cat(std::make_tuple(providers, numProviders), + *reinterpret_cast(params))); + }; + ops.finalize = [](void *obj) { delete reinterpret_cast(obj); }; + + UMF_ASSIGN_OP(ops, T, malloc, ((void *)nullptr)); + UMF_ASSIGN_OP(ops, T, calloc, ((void *)nullptr)); + UMF_ASSIGN_OP(ops, T, aligned_malloc, ((void *)nullptr)); + UMF_ASSIGN_OP(ops, T, realloc, ((void *)nullptr)); + UMF_ASSIGN_OP(ops, T, malloc_usable_size, ((size_t)0)); + UMF_ASSIGN_OP(ops, T, free, UMF_RESULT_SUCCESS); + UMF_ASSIGN_OP(ops, T, get_last_allocation_error, UMF_RESULT_ERROR_UNKNOWN); + + return ops; +} +} // namespace detail + +/// @brief creates UMF memory provider based on given T type. +/// T should implement all functions defined by +/// umf_memory_provider_ops_t, except for finalize (it is +/// replaced by dtor). All arguments passed to this function are +/// forwarded to T::initialize(). +template +auto memoryProviderMakeUnique(Args &&...args) { + umf_memory_provider_ops_t ops; + auto argsTuple = std::make_tuple(std::forward(args)...); + + ops.version = UMF_VERSION_CURRENT; + ops.initialize = [](void *params, void **obj) { + try { + *obj = new T; + } catch (...) { + return UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY; + } + + return detail::initialize( + reinterpret_cast(*obj), + *reinterpret_cast(params)); + }; + ops.finalize = [](void *obj) { delete reinterpret_cast(obj); }; + + UMF_ASSIGN_OP(ops, T, alloc, UMF_RESULT_ERROR_UNKNOWN); + UMF_ASSIGN_OP(ops, T, free, UMF_RESULT_ERROR_UNKNOWN); + UMF_ASSIGN_OP_NORETURN(ops, T, get_last_native_error); + UMF_ASSIGN_OP(ops, T, get_recommended_page_size, UMF_RESULT_ERROR_UNKNOWN); + UMF_ASSIGN_OP(ops, T, get_min_page_size, UMF_RESULT_ERROR_UNKNOWN); + UMF_ASSIGN_OP(ops, T, purge_lazy, UMF_RESULT_ERROR_UNKNOWN); + UMF_ASSIGN_OP(ops, T, purge_force, UMF_RESULT_ERROR_UNKNOWN); + UMF_ASSIGN_OP(ops, T, get_name, ""); + + umf_memory_provider_handle_t hProvider = nullptr; + auto ret = umfMemoryProviderCreate(&ops, &argsTuple, &hProvider); + return std::pair{ + ret, provider_unique_handle_t(hProvider, &umfMemoryProviderDestroy)}; +} + +/// @brief creates UMF memory pool based on given T type. +/// T should implement all functions defined by +/// umf_memory_provider_ops_t, except for finalize (it is +/// replaced by dtor). All arguments passed to this function are +/// forwarded to T::initialize(). +template +auto poolMakeUnique(umf_memory_provider_handle_t *providers, + size_t numProviders, Args &&...args) { + auto argsTuple = std::make_tuple(std::forward(args)...); + auto ops = detail::poolMakeUniqueOps(); + + umf_memory_pool_handle_t hPool = nullptr; + auto ret = umfPoolCreate(&ops, providers, numProviders, &argsTuple, &hPool); + return std::pair{ + ret, pool_unique_handle_t(hPool, &umfPoolDestroy)}; +} + +/// @brief creates UMF memory pool based on given T type. +/// This overload takes ownership of memory providers and destroys +/// them after memory pool is destroyed. +template +auto poolMakeUnique(std::array providers, + Args &&...args) { + auto argsTuple = std::make_tuple(std::forward(args)...); + auto ops = detail::poolMakeUniqueOps(); + + std::array provider_handles; + for (size_t i = 0; i < N; i++) { + provider_handles[i] = providers[i].release(); + } + + // capture providers and destroy them after the pool is destroyed + auto poolDestructor = [provider_handles](umf_memory_pool_handle_t hPool) { + umfPoolDestroy(hPool); + for (auto &provider : provider_handles) { + umfMemoryProviderDestroy(provider); + } + }; + + umf_memory_pool_handle_t hPool = nullptr; + auto ret = umfPoolCreate(&ops, provider_handles.data(), + provider_handles.size(), &argsTuple, &hPool); + return std::pair{ + ret, pool_unique_handle_t(hPool, std::move(poolDestructor))}; +} + +template umf_result_t &getPoolLastStatusRef() { + static thread_local umf_result_t last_status = UMF_RESULT_SUCCESS; + return last_status; +} + +/// @brief translates UMF return values to UR. +/// This function assumes that the native error of +/// the last failed memory provider is ur_result_t. +inline ur_result_t umf2urResult(umf_result_t umfResult) { + switch (umfResult) { + case UMF_RESULT_SUCCESS: + return UR_RESULT_SUCCESS; + case UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY: + return UR_RESULT_ERROR_OUT_OF_HOST_MEMORY; + case UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC: { + auto hProvider = umfGetLastFailedMemoryProvider(); + if (hProvider == nullptr) { + return UR_RESULT_ERROR_UNKNOWN; + } + + ur_result_t Err = UR_RESULT_ERROR_UNKNOWN; + umfMemoryProviderGetLastNativeError(hProvider, nullptr, + reinterpret_cast(&Err)); + return Err; + } + case UMF_RESULT_ERROR_INVALID_ARGUMENT: + return UR_RESULT_ERROR_INVALID_ARGUMENT; + case UMF_RESULT_ERROR_INVALID_ALIGNMENT: + return UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT; + case UMF_RESULT_ERROR_NOT_SUPPORTED: + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + default: + return UR_RESULT_ERROR_UNKNOWN; + }; +} + +} // namespace umf + +#endif /* UMF_HELPERS_H */ diff --git a/source/common/uma_pools/CMakeLists.txt b/source/common/umf_pools/CMakeLists.txt similarity index 91% rename from source/common/uma_pools/CMakeLists.txt rename to source/common/umf_pools/CMakeLists.txt index cd93cad0a9..d9bc3deaaf 100644 --- a/source/common/uma_pools/CMakeLists.txt +++ b/source/common/umf_pools/CMakeLists.txt @@ -3,7 +3,7 @@ # See LICENSE.TXT # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -add_library(disjoint_pool STATIC +add_ur_library(disjoint_pool STATIC disjoint_pool.cpp disjoint_pool_config_parser.cpp ) @@ -11,7 +11,7 @@ add_library(disjoint_pool STATIC add_library(${PROJECT_NAME}::disjoint_pool ALIAS disjoint_pool) target_link_libraries(disjoint_pool PRIVATE - unified_memory_allocation + unified_malloc_framework ${PROJECT_NAME}::headers) if (UNIX) diff --git a/source/common/uma_pools/disjoint_pool.cpp b/source/common/umf_pools/disjoint_pool.cpp similarity index 94% rename from source/common/uma_pools/disjoint_pool.cpp rename to source/common/umf_pools/disjoint_pool.cpp index 562d8f1d7c..7efd243f63 100644 --- a/source/common/uma_pools/disjoint_pool.cpp +++ b/source/common/umf_pools/disjoint_pool.cpp @@ -74,6 +74,10 @@ static size_t AlignUp(size_t Val, size_t Alignment) { return (Val + Alignment - 1) & (~(Alignment - 1)); } +struct MemoryProviderError { + umf_result_t code; +}; + DisjointPoolConfig::DisjointPoolConfig() : limits(std::make_shared()) {} @@ -109,7 +113,7 @@ class Slab { // Hints where to start search for free chunk in a slab size_t FirstFreeChunkIdx = 0; - // Return the index of the first available chunk, SIZE_MAX otherwize + // Return the index of the first available chunk, SIZE_MAX otherwise size_t FindFirstAvailableChunkIdx() const; // Register/Unregister the slab in the global slab address map. @@ -216,7 +220,7 @@ class Bucket { // Free an allocation that is a full slab in this bucket. void freeSlab(Slab &Slab, bool &ToPool); - uma_memory_provider_handle_t getMemHandle(); + umf_memory_provider_handle_t getMemHandle(); DisjointPool::AllocImpl &getAllocCtx() { return OwnAllocCtx; } @@ -271,7 +275,7 @@ class DisjointPool::AllocImpl { std::shared_timed_mutex KnownSlabsMapLock; // Handle to the memory provider - uma_memory_provider_handle_t MemHandle; + umf_memory_provider_handle_t MemHandle; // Store as unique_ptrs since Bucket is not Movable(because of std::mutex) std::vector> Buckets; @@ -283,7 +287,7 @@ class DisjointPool::AllocImpl { size_t ProviderMinPageSize; public: - AllocImpl(uma_memory_provider_handle_t hProvider, DisjointPoolConfig params) + AllocImpl(umf_memory_provider_handle_t hProvider, DisjointPoolConfig params) : MemHandle{hProvider}, params(params) { // Generate buckets sized such as: 64, 96, 128, 192, ..., CutOff. @@ -296,9 +300,9 @@ class DisjointPool::AllocImpl { } Buckets.push_back(std::make_unique(CutOff, *this)); - auto ret = umaMemoryProviderGetMinPageSize(hProvider, nullptr, + auto ret = umfMemoryProviderGetMinPageSize(hProvider, nullptr, &ProviderMinPageSize); - if (ret != UMA_RESULT_SUCCESS) { + if (ret != UMF_RESULT_SUCCESS) { ProviderMinPageSize = 0; } } @@ -307,7 +311,7 @@ class DisjointPool::AllocImpl { void *allocate(size_t Size, bool &FromPool); void deallocate(void *Ptr, bool &ToPool); - uma_memory_provider_handle_t getMemHandle() { return MemHandle; } + umf_memory_provider_handle_t getMemHandle() { return MemHandle; } std::shared_timed_mutex &getKnownSlabsMapLock() { return KnownSlabsMapLock; @@ -327,23 +331,21 @@ class DisjointPool::AllocImpl { Bucket &findBucket(size_t Size); }; -static void *memoryProviderAlloc(uma_memory_provider_handle_t hProvider, +static void *memoryProviderAlloc(umf_memory_provider_handle_t hProvider, size_t size, size_t alignment = 0) { void *ptr; - auto ret = umaMemoryProviderAlloc(hProvider, size, alignment, &ptr); - if (ret != UMA_RESULT_SUCCESS) { - // TODO: Set last error appropriately - throw std::runtime_error("umaMemoryProviderAlloc"); + auto ret = umfMemoryProviderAlloc(hProvider, size, alignment, &ptr); + if (ret != UMF_RESULT_SUCCESS) { + throw MemoryProviderError{ret}; } return ptr; } -static void memoryProviderFree(uma_memory_provider_handle_t hProvider, +static void memoryProviderFree(umf_memory_provider_handle_t hProvider, void *ptr) { - auto ret = umaMemoryProviderFree(hProvider, ptr, 0); - if (ret != UMA_RESULT_SUCCESS) { - // TODO: introduce custom exceptions? PI L0 relies on those - throw std::runtime_error("memoryProviderFree"); + auto ret = umfMemoryProviderFree(hProvider, ptr, 0); + if (ret != UMF_RESULT_SUCCESS) { + throw MemoryProviderError{ret}; } } @@ -373,7 +375,13 @@ Slab::~Slab() { } catch (std::exception &e) { std::cout << "DisjointPool: unexpected error: " << e.what() << "\n"; } - memoryProviderFree(bucket.getMemHandle(), MemPtr); + + try { + memoryProviderFree(bucket.getMemHandle(), MemPtr); + } catch (MemoryProviderError &e) { + std::cout << "DisjointPool: error from memory provider: " << e.code + << "\n"; + } } // Return the index of the first available chunk, SIZE_MAX otherwise @@ -655,7 +663,7 @@ bool Bucket::CanPool(bool &ToPool) { return false; } -uma_memory_provider_handle_t Bucket::getMemHandle() { +umf_memory_provider_handle_t Bucket::getMemHandle() { return OwnAllocCtx.getMemHandle(); } @@ -719,7 +727,7 @@ void Bucket::printStats(bool &TitlePrinted, const std::string &Label) { } } -void *DisjointPool::AllocImpl::allocate(size_t Size, bool &FromPool) { +void *DisjointPool::AllocImpl::allocate(size_t Size, bool &FromPool) try { void *Ptr; if (Size == 0) { @@ -744,10 +752,13 @@ void *DisjointPool::AllocImpl::allocate(size_t Size, bool &FromPool) { } return Ptr; +} catch (MemoryProviderError &e) { + umf::getPoolLastStatusRef() = e.code; + return nullptr; } void *DisjointPool::AllocImpl::allocate(size_t Size, size_t Alignment, - bool &FromPool) { + bool &FromPool) try { void *Ptr; if (Size == 0) { @@ -791,6 +802,9 @@ void *DisjointPool::AllocImpl::allocate(size_t Size, size_t Alignment, } return AlignPtrUp(Ptr, Alignment); +} catch (MemoryProviderError &e) { + umf::getPoolLastStatusRef() = e.code; + return nullptr; } Bucket &DisjointPool::AllocImpl::findBucket(size_t Size) { @@ -865,15 +879,15 @@ void DisjointPool::AllocImpl::printStats(bool &TitlePrinted, } } -uma_result_t DisjointPool::initialize(uma_memory_provider_handle_t *providers, +umf_result_t DisjointPool::initialize(umf_memory_provider_handle_t *providers, size_t numProviders, DisjointPoolConfig parameters) { if (numProviders != 1 || !providers[0]) { - return UMA_RESULT_ERROR_INVALID_ARGUMENT; + return UMF_RESULT_ERROR_INVALID_ARGUMENT; } impl = std::make_unique(providers[0], parameters); - return UMA_RESULT_SUCCESS; + return UMF_RESULT_SUCCESS; } void *DisjointPool::malloc(size_t size) { // For full-slab allocations indicates @@ -892,13 +906,13 @@ void *DisjointPool::malloc(size_t size) { // For full-slab allocations indicates void *DisjointPool::calloc(size_t, size_t) { // Not supported - assert(false); + umf::getPoolLastStatusRef() = UMF_RESULT_ERROR_NOT_SUPPORTED; return NULL; } void *DisjointPool::realloc(void *, size_t) { // Not supported - assert(false); + umf::getPoolLastStatusRef() = UMF_RESULT_ERROR_NOT_SUPPORTED; return NULL; } @@ -918,12 +932,10 @@ void *DisjointPool::aligned_malloc(size_t size, size_t alignment) { size_t DisjointPool::malloc_usable_size(void *) { // Not supported - assert(false); - return 0; } -void DisjointPool::free(void *ptr) { +enum umf_result_t DisjointPool::free(void *ptr) try { bool ToPool; impl->deallocate(ptr, ToPool); @@ -936,13 +948,13 @@ void DisjointPool::free(void *ptr) { << ", Current pool size for " << MT << " " << impl->getParams().CurPoolSize << "\n"; } - return; + return UMF_RESULT_SUCCESS; +} catch (MemoryProviderError &e) { + return e.code; } -enum uma_result_t DisjointPool::get_last_result(const char **ppMessage) { - // TODO: implement and return last error, we probably need something like - // https://github.com/oneapi-src/unified-runtime/issues/500 in UMA - return UMA_RESULT_ERROR_UNKNOWN; +enum umf_result_t DisjointPool::get_last_allocation_error() { + return umf::getPoolLastStatusRef(); } DisjointPool::DisjointPool() {} diff --git a/source/common/uma_pools/disjoint_pool.hpp b/source/common/umf_pools/disjoint_pool.hpp similarity index 90% rename from source/common/uma_pools/disjoint_pool.hpp rename to source/common/umf_pools/disjoint_pool.hpp index c991fa07bb..a8c9487ef2 100644 --- a/source/common/uma_pools/disjoint_pool.hpp +++ b/source/common/umf_pools/disjoint_pool.hpp @@ -11,8 +11,9 @@ #include #include +#include -#include "../uma_helpers.hpp" +#include "../umf_helpers.hpp" namespace usm { @@ -60,15 +61,15 @@ class DisjointPool { class AllocImpl; using Config = DisjointPoolConfig; - uma_result_t initialize(uma_memory_provider_handle_t *providers, + umf_result_t initialize(umf_memory_provider_handle_t *providers, size_t numProviders, DisjointPoolConfig parameters); void *malloc(size_t size); void *calloc(size_t, size_t); void *realloc(void *, size_t); void *aligned_malloc(size_t size, size_t alignment); size_t malloc_usable_size(void *); - void free(void *ptr); - enum uma_result_t get_last_result(const char **ppMessage); + enum umf_result_t free(void *ptr); + enum umf_result_t get_last_allocation_error(); DisjointPool(); ~DisjointPool(); diff --git a/source/common/uma_pools/disjoint_pool_config_parser.cpp b/source/common/umf_pools/disjoint_pool_config_parser.cpp similarity index 100% rename from source/common/uma_pools/disjoint_pool_config_parser.cpp rename to source/common/umf_pools/disjoint_pool_config_parser.cpp diff --git a/source/common/uma_pools/disjoint_pool_config_parser.hpp b/source/common/umf_pools/disjoint_pool_config_parser.hpp similarity index 100% rename from source/common/uma_pools/disjoint_pool_config_parser.hpp rename to source/common/umf_pools/disjoint_pool_config_parser.hpp diff --git a/source/common/unified_malloc_framework/CMakeLists.txt b/source/common/unified_malloc_framework/CMakeLists.txt new file mode 100644 index 0000000000..15744605ec --- /dev/null +++ b/source/common/unified_malloc_framework/CMakeLists.txt @@ -0,0 +1,33 @@ +# Copyright (C) 2023 Intel Corporation +# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +# See LICENSE.TXT +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +set(UMF_SOURCES + src/memory_pool.c + src/memory_provider.c + src/memory_tracker.cpp + src/memory_provider_get_last_failed.cpp +) + +if(UMF_BUILD_SHARED_LIBRARY) + message(WARNING "Unified Malloc Framework is still an early work in progress." + "There are no API/ABI backward compatibility guarantees. There will be breakages." + "Do not use the shared library in production software.") + add_ur_library(unified_malloc_framework SHARED + ${UMF_SOURCES}) + target_compile_definitions(unified_malloc_framework PUBLIC UMF_SHARED_LIBRARY) +else() + add_ur_library(unified_malloc_framework STATIC + ${UMF_SOURCES}) +endif() + +if (UMF_ENABLE_POOL_TRACKING) + target_sources(unified_malloc_framework PRIVATE src/memory_pool_tracking.c) +else() + target_sources(unified_malloc_framework PRIVATE src/memory_pool_default.c) +endif() + +add_library(${PROJECT_NAME}::unified_malloc_framework ALIAS unified_malloc_framework) + +target_include_directories(unified_malloc_framework PUBLIC include) diff --git a/source/common/unified_memory_allocation/include/uma.h b/source/common/unified_malloc_framework/include/umf.h similarity index 54% rename from source/common/unified_memory_allocation/include/uma.h rename to source/common/unified_malloc_framework/include/umf.h index 9b6eb1a435..c46eaa3e1f 100644 --- a/source/common/unified_memory_allocation/include/uma.h +++ b/source/common/unified_malloc_framework/include/umf.h @@ -8,10 +8,10 @@ * */ -#ifndef UMA_UNIFIED_MEMORY_ALLOCATION_H -#define UMA_UNIFIED_MEMORY_ALLOCATION_H 1 +#ifndef UMF_UNIFIED_MEMORY_ALLOCATION_H +#define UMF_UNIFIED_MEMORY_ALLOCATION_H 1 -#include -#include +#include +#include -#endif /* UMA_UNIFIED_MEMORY_ALLOCATION_H */ +#endif /* UMF_UNIFIED_MEMORY_ALLOCATION_H */ diff --git a/source/common/unified_malloc_framework/include/umf/base.h b/source/common/unified_malloc_framework/include/umf/base.h new file mode 100644 index 0000000000..6971bc0cab --- /dev/null +++ b/source/common/unified_malloc_framework/include/umf/base.h @@ -0,0 +1,54 @@ +/* + * + * Copyright (C) 2023 Intel Corporation + * + * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. + * See LICENSE.TXT + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + */ + +#ifndef UMF_BASE_H +#define UMF_BASE_H 1 + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/// \brief Generates generic 'UMF' API versions +#define UMF_MAKE_VERSION(_major, _minor) \ + ((_major << 16) | (_minor & 0x0000ffff)) + +/// \brief Extracts 'UMF' API major version +#define UMF_MAJOR_VERSION(_ver) (_ver >> 16) + +/// \brief Extracts 'UMF' API minor version +#define UMF_MINOR_VERSION(_ver) (_ver & 0x0000ffff) + +/// \brief Current version of the UMF headers +#define UMF_VERSION_CURRENT UMF_MAKE_VERSION(0, 9) + +/// \brief Operation results +enum umf_result_t { + UMF_RESULT_SUCCESS = 0, ///< Success + UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY = + 1, ///< Insufficient host memory to satisfy call, + UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC = + 2, ///< A provider specific warning/error has been reported and can be + ///< Retrieved via the umfMemoryProviderGetLastNativeError entry point. + UMF_RESULT_ERROR_INVALID_ARGUMENT = + 3, ///< Generic error code for invalid arguments + UMF_RESULT_ERROR_INVALID_ALIGNMENT = 4, /// Invalid alignment of an argument + UMF_RESULT_ERROR_NOT_SUPPORTED = 5, /// Operation not supported + + UMF_RESULT_ERROR_UNKNOWN = 0x7ffffffe ///< Unknown or internal error +}; + +#ifdef __cplusplus +} +#endif + +#endif /* UMF_BASE_H */ diff --git a/source/common/unified_memory_allocation/include/uma/memory_pool.h b/source/common/unified_malloc_framework/include/umf/memory_pool.h similarity index 53% rename from source/common/unified_memory_allocation/include/uma/memory_pool.h rename to source/common/unified_malloc_framework/include/umf/memory_pool.h index d2cc044a58..f8049ab75f 100644 --- a/source/common/unified_memory_allocation/include/uma/memory_pool.h +++ b/source/common/unified_malloc_framework/include/umf/memory_pool.h @@ -8,40 +8,40 @@ * */ -#ifndef UMA_MEMORY_POOL_H -#define UMA_MEMORY_POOL_H 1 +#ifndef UMF_MEMORY_POOL_H +#define UMF_MEMORY_POOL_H 1 -#include -#include +#include +#include #ifdef __cplusplus extern "C" { #endif -typedef struct uma_memory_pool_t *uma_memory_pool_handle_t; +typedef struct umf_memory_pool_t *umf_memory_pool_handle_t; -struct uma_memory_pool_ops_t; +struct umf_memory_pool_ops_t; /// /// \brief Creates new memory pool. -/// \param ops instance of uma_memory_pool_ops_t +/// \param ops instance of umf_memory_pool_ops_t /// \param providers array of memory providers that will be used for coarse-grain allocations. /// Should contain at least one memory provider. /// \param numProvider number of elements in the providers array /// \param params pointer to pool-specific parameters /// \param hPool [out] handle to the newly created memory pool -/// \return UMA_RESULT_SUCCESS on success or appropriate error code on failure. +/// \return UMF_RESULT_SUCCESS on success or appropriate error code on failure. /// -enum uma_result_t umaPoolCreate(struct uma_memory_pool_ops_t *ops, - uma_memory_provider_handle_t *providers, +enum umf_result_t umfPoolCreate(const struct umf_memory_pool_ops_t *ops, + umf_memory_provider_handle_t *providers, size_t numProviders, void *params, - uma_memory_pool_handle_t *hPool); + umf_memory_pool_handle_t *hPool); /// /// \brief Destroys memory pool. /// \param hPool handle to the pool /// -void umaPoolDestroy(uma_memory_pool_handle_t hPool); +void umfPoolDestroy(umf_memory_pool_handle_t hPool); /// /// \brief Allocates size bytes of uninitialized storage of the specified hPool. @@ -49,7 +49,7 @@ void umaPoolDestroy(uma_memory_pool_handle_t hPool); /// \param size number of bytes to allocate /// \return Pointer to the allocated memory. /// -void *umaPoolMalloc(uma_memory_pool_handle_t hPool, size_t size); +void *umfPoolMalloc(umf_memory_pool_handle_t hPool, size_t size); /// /// \brief Allocates size bytes of uninitialized storage of the specified hPool. @@ -59,7 +59,7 @@ void *umaPoolMalloc(uma_memory_pool_handle_t hPool, size_t size); /// \param alignment alignment of the allocation /// \return Pointer to the allocated memory. /// -void *umaPoolAlignedMalloc(uma_memory_pool_handle_t hPool, size_t size, +void *umfPoolAlignedMalloc(umf_memory_pool_handle_t hPool, size_t size, size_t alignment); /// @@ -71,7 +71,7 @@ void *umaPoolAlignedMalloc(uma_memory_pool_handle_t hPool, size_t size, /// \param size specified size of each element /// \return Pointer to the allocated memory. /// -void *umaPoolCalloc(uma_memory_pool_handle_t hPool, size_t num, size_t size); +void *umfPoolCalloc(umf_memory_pool_handle_t hPool, size_t num, size_t size); /// /// \brief Reallocates memory of the specified hPool. @@ -80,7 +80,7 @@ void *umaPoolCalloc(uma_memory_pool_handle_t hPool, size_t num, size_t size); /// \param size new size for the memory block in bytes /// \return Pointer to the allocated memory. /// -void *umaPoolRealloc(uma_memory_pool_handle_t hPool, void *ptr, size_t size); +void *umfPoolRealloc(umf_memory_pool_handle_t hPool, void *ptr, size_t size); /// /// \brief Obtains size of block of memory allocated from the pool. @@ -88,66 +88,68 @@ void *umaPoolRealloc(uma_memory_pool_handle_t hPool, void *ptr, size_t size); /// \param ptr pointer to the allocated memory /// \return Number of bytes. /// -size_t umaPoolMallocUsableSize(uma_memory_pool_handle_t hPool, void *ptr); +size_t umfPoolMallocUsableSize(umf_memory_pool_handle_t hPool, void *ptr); /// /// \brief Frees the memory space of the specified hPool pointed by ptr. /// \param hPool specified memory hPool /// \param ptr pointer to the allocated memory +/// \return UMF_RESULT_SUCCESS on success or appropriate error code on failure. +/// Whether any status other than UMF_RESULT_SUCCESS can be returned +/// depends on the memory provider used by the pool. /// -void umaPoolFree(uma_memory_pool_handle_t hPool, void *ptr); +enum umf_result_t umfPoolFree(umf_memory_pool_handle_t hPool, void *ptr); /// -/// \brief Frees the memory space pointed by ptr if it belongs to UMA pool, does nothing otherwise. +/// \brief Frees the memory space pointed by ptr if it belongs to UMF pool, does nothing otherwise. /// \param ptr pointer to the allocated memory +/// \return UMF_RESULT_SUCCESS on success or appropriate error code on failure. +/// Whether any status other than UMF_RESULT_SUCCESS can be returned +/// depends on the memory provider used by the pool. /// -void umaFree(void *ptr); +enum umf_result_t umfFree(void *ptr); /// -/// \brief Retrieve string representation of the underlying pool specific -/// result reported by the last API that returned -/// UMA_RESULT_ERROR_POOL_SPECIFIC or NULL ptr (in case of allocation -/// functions). Allows for a pool independent way to -/// return a pool specific result. +/// \brief Retrieve umf_result_t representing the error of the last failed allocation +/// operation in this thread (malloc, calloc, realloc, aligned_malloc). /// /// \details -/// - The string returned via the ppMessage is a NULL terminated C style -/// string. -/// - The string returned via the ppMessage is thread local. -/// - The memory in the string returned via the ppMessage is owned by the -/// adapter. -/// - The application may call this function from simultaneous threads. -/// - The implementation of this function should be lock-free. +/// * Implementations *must* store the error code in thread-local +/// storage prior to returning NULL from the allocation functions. +/// +/// * If the last allocation/de-allocation operation succeeded, the value returned by +/// this function is unspecified. +/// +/// * The application *may* call this function from simultaneous threads. +/// +/// * The implementation of this function *should* be lock-free. /// \param hPool specified memory hPool -/// \param ppMessage [out] pointer to a string containing provider specific -/// result in string representation. -/// \return UMA_RESULT_SUCCESS if the result being -/// reported is to be considered a warning. Any other result code -/// returned indicates that the adapter specific result is an error. -enum uma_result_t umaPoolGetLastResult(uma_memory_pool_handle_t hPool, - const char **ppMessage); +/// \return Error code desciribng the failure of the last failed allocation operation. +/// The value is undefined if the previous allocation was successful. +enum umf_result_t umfPoolGetLastAllocationError(umf_memory_pool_handle_t hPool); /// -/// \brief Retrieve memory pool associated with a given ptr. +/// \brief Retrieve memory pool associated with a given ptr. Only memory allocated +/// with the usage of a memory provider is being tracked. /// \param ptr pointer to memory belonging to a memory pool -/// \return Handle to a memory pool that contains ptr or NULL if pointer does not belong to any UMA pool. -uma_memory_pool_handle_t umaPoolByPtr(const void *ptr); +/// \return Handle to a memory pool that contains ptr or NULL if pointer does not belong to any UMF pool. +umf_memory_pool_handle_t umfPoolByPtr(const void *ptr); /// /// \brief Retrieve memory providers associated with a given pool. /// \param hPool specified memory pool /// \param hProviders [out] pointer to an array of memory providers. If numProviders is not equal to or -/// greater than the real number of providers, UMA_RESULT_ERROR_INVALID_ARGUMENT is returned. +/// greater than the real number of providers, UMF_RESULT_ERROR_INVALID_ARGUMENT is returned. /// \param numProviders [in] number of memory providers to return /// \param numProvidersRet pointer to the actual number of memory providers -/// \return UMA_RESULT_SUCCESS on success or appropriate error code on failure. -enum uma_result_t -umaPoolGetMemoryProviders(uma_memory_pool_handle_t hPool, size_t numProviders, - uma_memory_provider_handle_t *hProviders, +/// \return UMF_RESULT_SUCCESS on success or appropriate error code on failure. +enum umf_result_t +umfPoolGetMemoryProviders(umf_memory_pool_handle_t hPool, size_t numProviders, + umf_memory_provider_handle_t *hProviders, size_t *numProvidersRet); #ifdef __cplusplus } #endif -#endif /* UMA_MEMORY_POOL_H */ +#endif /* UMF_MEMORY_POOL_H */ diff --git a/source/common/unified_memory_allocation/include/uma/memory_pool_ops.h b/source/common/unified_malloc_framework/include/umf/memory_pool_ops.h similarity index 73% rename from source/common/unified_memory_allocation/include/uma/memory_pool_ops.h rename to source/common/unified_malloc_framework/include/umf/memory_pool_ops.h index 31a15ca02f..b858e5fc04 100644 --- a/source/common/unified_memory_allocation/include/uma/memory_pool_ops.h +++ b/source/common/unified_malloc_framework/include/umf/memory_pool_ops.h @@ -8,32 +8,33 @@ * */ -#ifndef UMA_MEMORY_POOL_OPS_H -#define UMA_MEMORY_POOL_OPS_H 1 +#ifndef UMF_MEMORY_POOL_OPS_H +#define UMF_MEMORY_POOL_OPS_H 1 -#include +#include +#include #ifdef __cplusplus extern "C" { #endif -/// \brief This structure comprises function pointers used by corresponding umaPool* +/// \brief This structure comprises function pointers used by corresponding umfPool* /// calls. Each memory pool implementation should initialize all function /// pointers. -struct uma_memory_pool_ops_t { +struct umf_memory_pool_ops_t { /// Version of the ops structure. - /// Should be initialized using UMA_VERSION_CURRENT + /// Should be initialized using UMF_VERSION_CURRENT uint32_t version; /// - /// \brief Intializes memory pool. + /// \brief Initializes memory pool. /// \param providers array of memory providers that will be used for coarse-grain allocations. /// Should contain at least one memory provider. /// \param numProvider number of elements in the providers array /// \param params pool-specific params /// \param pool [out] returns pointer to the pool - /// \return UMA_RESULT_SUCCESS on success or appropriate error code on failure. - enum uma_result_t (*initialize)(uma_memory_provider_handle_t *providers, + /// \return UMF_RESULT_SUCCESS on success or appropriate error code on failure. + enum umf_result_t (*initialize)(umf_memory_provider_handle_t *providers, size_t numProviders, void *params, void **pool); @@ -48,12 +49,12 @@ struct uma_memory_pool_ops_t { void *(*realloc)(void *pool, void *ptr, size_t size); void *(*aligned_malloc)(void *pool, size_t size, size_t alignment); size_t (*malloc_usable_size)(void *pool, void *ptr); - void (*free)(void *pool, void *); - enum uma_result_t (*get_last_result)(void *pool, const char **ppMessage); + enum umf_result_t (*free)(void *pool, void *); + enum umf_result_t (*get_last_allocation_error)(void *pool); }; #ifdef __cplusplus } #endif -#endif /* UMA_MEMORY_POOL_OPS_H */ +#endif /* UMF_MEMORY_POOL_OPS_H */ diff --git a/source/common/unified_memory_allocation/include/uma/memory_provider.h b/source/common/unified_malloc_framework/include/umf/memory_provider.h similarity index 50% rename from source/common/unified_memory_allocation/include/uma/memory_provider.h rename to source/common/unified_malloc_framework/include/umf/memory_provider.h index d3c2df3ac4..2e50238238 100644 --- a/source/common/unified_memory_allocation/include/uma/memory_provider.h +++ b/source/common/unified_malloc_framework/include/umf/memory_provider.h @@ -8,34 +8,34 @@ * */ -#ifndef UMA_MEMORY_PROVIDER_H -#define UMA_MEMORY_PROVIDER_H 1 +#ifndef UMF_MEMORY_PROVIDER_H +#define UMF_MEMORY_PROVIDER_H 1 -#include -#include +#include +#include #ifdef __cplusplus extern "C" { #endif -typedef struct uma_memory_provider_t *uma_memory_provider_handle_t; +typedef struct umf_memory_provider_t *umf_memory_provider_handle_t; /// /// \brief Creates new memory provider. -/// \param ops instance of uma_memory_provider_ops_t +/// \param ops instance of umf_memory_provider_ops_t /// \param params pointer to provider-specific parameters /// \param hProvider [out] pointer to the newly created memory provider -/// \return UMA_RESULT_SUCCESS on success or appropriate error code on failure. +/// \return UMF_RESULT_SUCCESS on success or appropriate error code on failure. /// -enum uma_result_t -umaMemoryProviderCreate(struct uma_memory_provider_ops_t *ops, void *params, - uma_memory_provider_handle_t *hProvider); +enum umf_result_t +umfMemoryProviderCreate(const struct umf_memory_provider_ops_t *ops, + void *params, umf_memory_provider_handle_t *hProvider); /// /// \brief Destroys memory provider. /// \param hPool handle to the memory provider /// -void umaMemoryProviderDestroy(uma_memory_provider_handle_t hProvider); +void umfMemoryProviderDestroy(umf_memory_provider_handle_t hProvider); /// /// \brief Allocates size bytes of uninitialized storage from memory provider @@ -44,9 +44,9 @@ void umaMemoryProviderDestroy(uma_memory_provider_handle_t hProvider); /// \param size number of bytes to allocate /// \param alignment alignment of the allocation /// \param ptr [out] pointer to the allocated memory -/// \return UMA_RESULT_SUCCESS on success or appropriate error code on failure. +/// \return UMF_RESULT_SUCCESS on success or appropriate error code on failure. /// -enum uma_result_t umaMemoryProviderAlloc(uma_memory_provider_handle_t hProvider, +enum umf_result_t umfMemoryProviderAlloc(umf_memory_provider_handle_t hProvider, size_t size, size_t alignment, void **ptr); @@ -55,44 +55,46 @@ enum uma_result_t umaMemoryProviderAlloc(uma_memory_provider_handle_t hProvider, /// \param hProvider handle to the memory provider /// \param ptr pointer to the allocated memory /// \param size size of the allocation -/// \return UMA_RESULT_SUCCESS on success or appropriate error code on failure. +/// \return UMF_RESULT_SUCCESS on success or appropriate error code on failure. /// -enum uma_result_t umaMemoryProviderFree(uma_memory_provider_handle_t hProvider, +enum umf_result_t umfMemoryProviderFree(umf_memory_provider_handle_t hProvider, void *ptr, size_t size); /// /// \brief Retrieve string representation of the underlying provider specific /// result reported by the last API that returned -/// UMA_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC. Allows for a provider +/// UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC. Allows for a provider /// independent way to return a provider specific result. /// /// \details -/// - The string returned via the ppMessage is a NULL terminated C style -/// string. -/// - The string returned via the ppMessage is thread local. -/// - The memory in the string returned via the ppMessage is owned by the -/// adapter. -/// - The application may call this function from simultaneous threads. -/// - The implementation of this function should be lock-free. +/// * Implementations *must* store the message and error code in thread-local +/// storage prior to returning UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC. /// +/// * The message and error code will only be valid if a previously +/// called entry-point returned UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC. +/// +/// * The memory pointed to by the C string returned in `ppMessage` is owned by +/// the adapter and *must* be null terminated. +/// +/// * The application *may* call this function from simultaneous threads. +/// +/// * The implementation of this function *should* be lock-free. /// \param hProvider handle to the memory provider /// \param ppMessage [out] pointer to a string containing provider specific /// result in string representation -/// \return UMA_RESULT_SUCCESS if the result being reported is to be considered -/// a warning. Any other result code returned indicates that the -/// adapter specific result is an error. -enum uma_result_t -umaMemoryProviderGetLastResult(uma_memory_provider_handle_t hProvider, - const char **ppMessage); +/// \param pError [out] pointer to an integer where the adapter specific error code will be stored +void umfMemoryProviderGetLastNativeError(umf_memory_provider_handle_t hProvider, + const char **ppMessage, + int32_t *pError); /// /// \brief Retrieve recommended page size for a given allocation size. /// \param hProvider handle to the memory provider /// \param size allocation size /// \param pageSize [out] will be updated with recommended page size -/// \return UMA_RESULT_SUCCESS on success or appropriate error code on failure. -enum uma_result_t -umaMemoryProviderGetRecommendedPageSize(uma_memory_provider_handle_t hProvider, +/// \return UMF_RESULT_SUCCESS on success or appropriate error code on failure. +enum umf_result_t +umfMemoryProviderGetRecommendedPageSize(umf_memory_provider_handle_t hProvider, size_t size, size_t *pageSize); /// @@ -101,46 +103,55 @@ umaMemoryProviderGetRecommendedPageSize(uma_memory_provider_handle_t hProvider, /// \param hProvider handle to the memory provider /// \param ptr [optional] pointer to memory allocated by this memory provider /// \param pageSize [out] will be updated with page size value. -/// \return UMA_RESULT_SUCCESS on success or appropriate error code on failure. -enum uma_result_t -umaMemoryProviderGetMinPageSize(uma_memory_provider_handle_t hProvider, +/// \return UMF_RESULT_SUCCESS on success or appropriate error code on failure. +enum umf_result_t +umfMemoryProviderGetMinPageSize(umf_memory_provider_handle_t hProvider, void *ptr, size_t *pageSize); /// /// \brief Discard physical pages within the virtual memory mapping associated at given addr and size. -/// This call is asynchronous and may delay puring the pages indefinitely. +/// This call is asynchronous and may delay purging the pages indefinitely. /// \param hProvider handle to the memory provider /// \param ptr beginning of the virtual memory range /// \param size size of the virtual memory range -/// \return UMA_RESULT_SUCCESS on success or appropriate error code on failure. -/// UMA_RESULT_ERROR_INVALID_ALIGNMENT if ptr or size is not page-aligned. -/// UMA_RESULT_ERROR_NOT_SUPPORTED if operation is not supported by this provider. -enum uma_result_t -umaMemoryProviderPurgeLazy(uma_memory_provider_handle_t hProvider, void *ptr, +/// \return UMF_RESULT_SUCCESS on success or appropriate error code on failure. +/// UMF_RESULT_ERROR_INVALID_ALIGNMENT if ptr or size is not page-aligned. +/// UMF_RESULT_ERROR_NOT_SUPPORTED if operation is not supported by this provider. +enum umf_result_t +umfMemoryProviderPurgeLazy(umf_memory_provider_handle_t hProvider, void *ptr, size_t size); /// /// \brief Discard physical pages within the virtual memory mapping associated at given addr and size. -/// This call is synchronous and if it suceeds, pages are guaranteed to be zero-filled on the next access. +/// This call is synchronous and if it succeeds, pages are guaranteed to be zero-filled on the next access. /// \param hProvider handle to the memory provider /// \param ptr beginning of the virtual memory range /// \param size size of the virtual memory range -/// \return UMA_RESULT_SUCCESS on success or appropriate error code on failure -/// UMA_RESULT_ERROR_INVALID_ALIGNMENT if ptr or size is not page-aligned. -/// UMA_RESULT_ERROR_NOT_SUPPORTED if operation is not supported by this provider. -enum uma_result_t -umaMemoryProviderPurgeForce(uma_memory_provider_handle_t hProvider, void *ptr, +/// \return UMF_RESULT_SUCCESS on success or appropriate error code on failure +/// UMF_RESULT_ERROR_INVALID_ALIGNMENT if ptr or size is not page-aligned. +/// UMF_RESULT_ERROR_NOT_SUPPORTED if operation is not supported by this provider. +enum umf_result_t +umfMemoryProviderPurgeForce(umf_memory_provider_handle_t hProvider, void *ptr, size_t size); /// -/// \brief Retrive name of a given memory provider. +/// \brief Retrieve name of a given memory provider. /// \param hProvider handle to the memory provider /// \param ppName [out] pointer to a string containing name of the provider -void umaMemoryProviderGetName(uma_memory_provider_handle_t hProvider, - const char **ppName); +const char *umfMemoryProviderGetName(umf_memory_provider_handle_t hProvider); + +/// \brief Retrieve handle to the last memory provider that returned status other +/// than UMF_RESULT_SUCCESS on the calling thread. +/// +/// \details Handle to the memory provider is stored in the thread local +/// storage. The handle is updated every time a memory provider +/// returns status other than UMF_RESULT_SUCCESS. +/// +/// \return Handle to the memory provider +umf_memory_provider_handle_t umfGetLastFailedMemoryProvider(void); #ifdef __cplusplus } #endif -#endif /* UMA_MEMORY_PROVIDER_H */ +#endif /* UMF_MEMORY_PROVIDER_H */ diff --git a/source/common/unified_malloc_framework/include/umf/memory_provider_ops.h b/source/common/unified_malloc_framework/include/umf/memory_provider_ops.h new file mode 100644 index 0000000000..216be5437b --- /dev/null +++ b/source/common/unified_malloc_framework/include/umf/memory_provider_ops.h @@ -0,0 +1,59 @@ +/* + * + * Copyright (C) 2023 Intel Corporation + * + * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. + * See LICENSE.TXT + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + */ + +#ifndef UMF_MEMORY_PROVIDER_OPS_H +#define UMF_MEMORY_PROVIDER_OPS_H 1 + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/// This structure comprises function pointers used by corresponding +/// umfMemoryProvider* calls. Each memory provider implementation should +/// initialize all function pointers. +struct umf_memory_provider_ops_t { + /// Version of the ops structure. + /// Should be initialized using UMF_VERSION_CURRENT + uint32_t version; + + /// + /// \brief Initializes memory provider. + /// \param params provider-specific params + /// \param provider returns pointer to the provider + /// \return UMF_RESULT_SUCCESS on success or appropriate error code on failure. + enum umf_result_t (*initialize)(void *params, void **provider); + + /// + /// \brief Finalizes memory provider. + /// \param provider provider to finalize + void (*finalize)(void *provider); + + /// Refer to memory_provider.h for description of those functions + enum umf_result_t (*alloc)(void *provider, size_t size, size_t alignment, + void **ptr); + enum umf_result_t (*free)(void *provider, void *ptr, size_t size); + void (*get_last_native_error)(void *provider, const char **ppMessage, + int32_t *pError); + enum umf_result_t (*get_recommended_page_size)(void *provider, size_t size, + size_t *pageSize); + enum umf_result_t (*get_min_page_size)(void *provider, void *ptr, + size_t *pageSize); + enum umf_result_t (*purge_lazy)(void *provider, void *ptr, size_t size); + enum umf_result_t (*purge_force)(void *provider, void *ptr, size_t size); + const char *(*get_name)(void *provider); +}; + +#ifdef __cplusplus +} +#endif + +#endif /* #ifndef UMF_MEMORY_PROVIDER_OPS_H */ diff --git a/source/common/unified_malloc_framework/src/memory_pool.c b/source/common/unified_malloc_framework/src/memory_pool.c new file mode 100644 index 0000000000..7b88b2f7d6 --- /dev/null +++ b/source/common/unified_malloc_framework/src/memory_pool.c @@ -0,0 +1,47 @@ +/* + * + * Copyright (C) 2023 Intel Corporation + * + * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. + * See LICENSE.TXT + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + */ + +#include "memory_pool_internal.h" + +#include +#include + +#include +#include + +void *umfPoolMalloc(umf_memory_pool_handle_t hPool, size_t size) { + return hPool->ops.malloc(hPool->pool_priv, size); +} + +void *umfPoolAlignedMalloc(umf_memory_pool_handle_t hPool, size_t size, + size_t alignment) { + return hPool->ops.aligned_malloc(hPool->pool_priv, size, alignment); +} + +void *umfPoolCalloc(umf_memory_pool_handle_t hPool, size_t num, size_t size) { + return hPool->ops.calloc(hPool->pool_priv, num, size); +} + +void *umfPoolRealloc(umf_memory_pool_handle_t hPool, void *ptr, size_t size) { + return hPool->ops.realloc(hPool->pool_priv, ptr, size); +} + +size_t umfPoolMallocUsableSize(umf_memory_pool_handle_t hPool, void *ptr) { + return hPool->ops.malloc_usable_size(hPool->pool_priv, ptr); +} + +enum umf_result_t umfPoolFree(umf_memory_pool_handle_t hPool, void *ptr) { + return hPool->ops.free(hPool->pool_priv, ptr); +} + +enum umf_result_t +umfPoolGetLastAllocationError(umf_memory_pool_handle_t hPool) { + return hPool->ops.get_last_allocation_error(hPool->pool_priv); +} diff --git a/source/common/unified_malloc_framework/src/memory_pool_default.c b/source/common/unified_malloc_framework/src/memory_pool_default.c new file mode 100644 index 0000000000..be7c4c9c57 --- /dev/null +++ b/source/common/unified_malloc_framework/src/memory_pool_default.c @@ -0,0 +1,95 @@ +/* + * + * Copyright (C) 2023 Intel Corporation + * + * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. + * See LICENSE.TXT + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + */ + +#include "memory_pool_internal.h" + +#include + +#include +#include + +enum umf_result_t umfPoolCreate(const struct umf_memory_pool_ops_t *ops, + umf_memory_provider_handle_t *providers, + size_t numProviders, void *params, + umf_memory_pool_handle_t *hPool) { + if (!numProviders || !providers) { + return UMF_RESULT_ERROR_INVALID_ARGUMENT; + } + + enum umf_result_t ret = UMF_RESULT_SUCCESS; + umf_memory_pool_handle_t pool = malloc(sizeof(struct umf_memory_pool_t)); + if (!pool) { + return UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY; + } + + assert(ops->version == UMF_VERSION_CURRENT); + + pool->providers = + calloc(numProviders, sizeof(umf_memory_provider_handle_t)); + if (!pool->providers) { + ret = UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY; + goto err_providers_alloc; + } + + size_t providerInd = 0; + pool->numProviders = numProviders; + + for (providerInd = 0; providerInd < numProviders; providerInd++) { + pool->providers[providerInd] = providers[providerInd]; + } + + pool->ops = *ops; + ret = ops->initialize(pool->providers, pool->numProviders, params, + &pool->pool_priv); + if (ret != UMF_RESULT_SUCCESS) { + goto err_pool_init; + } + + *hPool = pool; + return UMF_RESULT_SUCCESS; + +err_pool_init: + free(pool->providers); +err_providers_alloc: + free(pool); + + return ret; +} + +void umfPoolDestroy(umf_memory_pool_handle_t hPool) { + hPool->ops.finalize(hPool->pool_priv); + free(hPool->providers); + free(hPool); +} + +enum umf_result_t umfFree(void *ptr) { return UMF_RESULT_ERROR_NOT_SUPPORTED; } + +umf_memory_pool_handle_t umfPoolByPtr(const void *ptr) { return NULL; } + +enum umf_result_t +umfPoolGetMemoryProviders(umf_memory_pool_handle_t hPool, size_t numProviders, + umf_memory_provider_handle_t *hProviders, + size_t *numProvidersRet) { + if (hProviders && numProviders < hPool->numProviders) { + return UMF_RESULT_ERROR_INVALID_ARGUMENT; + } + + if (numProvidersRet) { + *numProvidersRet = hPool->numProviders; + } + + if (hProviders) { + for (size_t i = 0; i < hPool->numProviders; i++) { + hProviders[i] = hPool->providers[i]; + } + } + + return UMF_RESULT_SUCCESS; +} diff --git a/source/common/unified_malloc_framework/src/memory_pool_internal.h b/source/common/unified_malloc_framework/src/memory_pool_internal.h new file mode 100644 index 0000000000..37424fd3bf --- /dev/null +++ b/source/common/unified_malloc_framework/src/memory_pool_internal.h @@ -0,0 +1,37 @@ +/* + * + * Copyright (C) 2023 Intel Corporation + * + * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. + * See LICENSE.TXT + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + */ + +#ifndef UMF_MEMORY_POOL_INTERNAL_H +#define UMF_MEMORY_POOL_INTERNAL_H 1 + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct umf_memory_pool_t { + void *pool_priv; + struct umf_memory_pool_ops_t ops; + + // Holds array of memory providers. All providers are wrapped + // by memory tracking providers (owned and released by UMF). + umf_memory_provider_handle_t *providers; + + size_t numProviders; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* UMF_MEMORY_POOL_INTERNAL_H */ diff --git a/source/common/unified_malloc_framework/src/memory_pool_tracking.c b/source/common/unified_malloc_framework/src/memory_pool_tracking.c new file mode 100644 index 0000000000..033a390fcb --- /dev/null +++ b/source/common/unified_malloc_framework/src/memory_pool_tracking.c @@ -0,0 +1,122 @@ +/* + * + * Copyright (C) 2023 Intel Corporation + * + * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. + * See LICENSE.TXT + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + */ + +#include "memory_pool_internal.h" +#include "memory_provider_internal.h" +#include "memory_tracker.h" + +#include + +#include +#include + +static void +destroyMemoryProviderWrappers(umf_memory_provider_handle_t *providers, + size_t numProviders) { + for (size_t i = 0; i < numProviders; i++) { + umfMemoryProviderDestroy(providers[i]); + } + + free(providers); +} + +enum umf_result_t umfPoolCreate(const struct umf_memory_pool_ops_t *ops, + umf_memory_provider_handle_t *providers, + size_t numProviders, void *params, + umf_memory_pool_handle_t *hPool) { + if (!numProviders || !providers) { + return UMF_RESULT_ERROR_INVALID_ARGUMENT; + } + + enum umf_result_t ret = UMF_RESULT_SUCCESS; + umf_memory_pool_handle_t pool = malloc(sizeof(struct umf_memory_pool_t)); + if (!pool) { + return UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY; + } + + assert(ops->version == UMF_VERSION_CURRENT); + + pool->providers = + calloc(numProviders, sizeof(umf_memory_provider_handle_t)); + if (!pool->providers) { + ret = UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY; + goto err_providers_alloc; + } + + size_t providerInd = 0; + pool->numProviders = numProviders; + + // Wrap each provider with memory tracking provider. + for (providerInd = 0; providerInd < numProviders; providerInd++) { + ret = umfTrackingMemoryProviderCreate(providers[providerInd], pool, + &pool->providers[providerInd]); + if (ret != UMF_RESULT_SUCCESS) { + goto err_providers_init; + } + } + + pool->ops = *ops; + ret = ops->initialize(pool->providers, pool->numProviders, params, + &pool->pool_priv); + if (ret != UMF_RESULT_SUCCESS) { + goto err_pool_init; + } + + *hPool = pool; + return UMF_RESULT_SUCCESS; + +err_pool_init: +err_providers_init: + destroyMemoryProviderWrappers(pool->providers, providerInd); +err_providers_alloc: + free(pool); + + return ret; +} + +void umfPoolDestroy(umf_memory_pool_handle_t hPool) { + hPool->ops.finalize(hPool->pool_priv); + destroyMemoryProviderWrappers(hPool->providers, hPool->numProviders); + free(hPool); +} + +enum umf_result_t umfFree(void *ptr) { + umf_memory_pool_handle_t hPool = umfPoolByPtr(ptr); + if (hPool) { + return umfPoolFree(hPool, ptr); + } + return UMF_RESULT_SUCCESS; +} + +umf_memory_pool_handle_t umfPoolByPtr(const void *ptr) { + return umfMemoryTrackerGetPool(umfMemoryTrackerGet(), ptr); +} + +enum umf_result_t +umfPoolGetMemoryProviders(umf_memory_pool_handle_t hPool, size_t numProviders, + umf_memory_provider_handle_t *hProviders, + size_t *numProvidersRet) { + if (hProviders && numProviders < hPool->numProviders) { + return UMF_RESULT_ERROR_INVALID_ARGUMENT; + } + + if (numProvidersRet) { + *numProvidersRet = hPool->numProviders; + } + + if (hProviders) { + for (size_t i = 0; i < hPool->numProviders; i++) { + umfTrackingMemoryProviderGetUpstreamProvider( + umfMemoryProviderGetPriv(hPool->providers[i]), hProviders + i); + } + } + + return UMF_RESULT_SUCCESS; +} diff --git a/source/common/unified_malloc_framework/src/memory_provider.c b/source/common/unified_malloc_framework/src/memory_provider.c new file mode 100644 index 0000000000..8a977e37c5 --- /dev/null +++ b/source/common/unified_malloc_framework/src/memory_provider.c @@ -0,0 +1,132 @@ +/* + * + * Copyright (C) 2023 Intel Corporation + * + * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. + * See LICENSE.TXT + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + */ + +#include "memory_provider_internal.h" +#include + +#include +#include + +struct umf_memory_provider_t { + struct umf_memory_provider_ops_t ops; + void *provider_priv; +}; + +enum umf_result_t +umfMemoryProviderCreate(const struct umf_memory_provider_ops_t *ops, + void *params, umf_memory_provider_handle_t *hProvider) { + umf_memory_provider_handle_t provider = + malloc(sizeof(struct umf_memory_provider_t)); + if (!provider) { + return UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY; + } + + assert(ops->version == UMF_VERSION_CURRENT); + + provider->ops = *ops; + + void *provider_priv; + enum umf_result_t ret = ops->initialize(params, &provider_priv); + if (ret != UMF_RESULT_SUCCESS) { + free(provider); + return ret; + } + + provider->provider_priv = provider_priv; + + *hProvider = provider; + + return UMF_RESULT_SUCCESS; +} + +void umfMemoryProviderDestroy(umf_memory_provider_handle_t hProvider) { + hProvider->ops.finalize(hProvider->provider_priv); + free(hProvider); +} + +static void +checkErrorAndSetLastProvider(enum umf_result_t result, + umf_memory_provider_handle_t hProvider) { + if (result != UMF_RESULT_SUCCESS) { + *umfGetLastFailedMemoryProviderPtr() = hProvider; + } +} + +enum umf_result_t umfMemoryProviderAlloc(umf_memory_provider_handle_t hProvider, + size_t size, size_t alignment, + void **ptr) { + enum umf_result_t res = + hProvider->ops.alloc(hProvider->provider_priv, size, alignment, ptr); + checkErrorAndSetLastProvider(res, hProvider); + return res; +} + +enum umf_result_t umfMemoryProviderFree(umf_memory_provider_handle_t hProvider, + void *ptr, size_t size) { + enum umf_result_t res = + hProvider->ops.free(hProvider->provider_priv, ptr, size); + checkErrorAndSetLastProvider(res, hProvider); + return res; +} + +void umfMemoryProviderGetLastNativeError(umf_memory_provider_handle_t hProvider, + const char **ppMessage, + int32_t *pError) { + hProvider->ops.get_last_native_error(hProvider->provider_priv, ppMessage, + pError); +} + +void *umfMemoryProviderGetPriv(umf_memory_provider_handle_t hProvider) { + return hProvider->provider_priv; +} + +enum umf_result_t +umfMemoryProviderGetRecommendedPageSize(umf_memory_provider_handle_t hProvider, + size_t size, size_t *pageSize) { + enum umf_result_t res = hProvider->ops.get_recommended_page_size( + hProvider->provider_priv, size, pageSize); + checkErrorAndSetLastProvider(res, hProvider); + return res; +} + +enum umf_result_t +umfMemoryProviderGetMinPageSize(umf_memory_provider_handle_t hProvider, + void *ptr, size_t *pageSize) { + enum umf_result_t res = hProvider->ops.get_min_page_size( + hProvider->provider_priv, ptr, pageSize); + checkErrorAndSetLastProvider(res, hProvider); + return res; +} + +enum umf_result_t +umfMemoryProviderPurgeLazy(umf_memory_provider_handle_t hProvider, void *ptr, + size_t size) { + enum umf_result_t res = + hProvider->ops.purge_lazy(hProvider->provider_priv, ptr, size); + checkErrorAndSetLastProvider(res, hProvider); + return res; +} + +enum umf_result_t +umfMemoryProviderPurgeForce(umf_memory_provider_handle_t hProvider, void *ptr, + size_t size) { + enum umf_result_t res = + hProvider->ops.purge_force(hProvider->provider_priv, ptr, size); + checkErrorAndSetLastProvider(res, hProvider); + return res; +} + +const char *umfMemoryProviderGetName(umf_memory_provider_handle_t hProvider) { + return hProvider->ops.get_name(hProvider->provider_priv); +} + +umf_memory_provider_handle_t umfGetLastFailedMemoryProvider(void) { + return *umfGetLastFailedMemoryProviderPtr(); +} diff --git a/source/common/unified_malloc_framework/src/memory_provider_get_last_failed.cpp b/source/common/unified_malloc_framework/src/memory_provider_get_last_failed.cpp new file mode 100644 index 0000000000..f9af93206a --- /dev/null +++ b/source/common/unified_malloc_framework/src/memory_provider_get_last_failed.cpp @@ -0,0 +1,20 @@ +/* + * + * Copyright (C) 2023 Intel Corporation + * + * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. + * See LICENSE.TXT + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + */ + +#include "memory_provider_internal.h" + +extern "C" { + +static thread_local umf_memory_provider_handle_t lastFailedProvider = nullptr; + +umf_memory_provider_handle_t *umfGetLastFailedMemoryProviderPtr(void) { + return &lastFailedProvider; +} +} diff --git a/source/common/unified_memory_allocation/src/memory_provider_internal.h b/source/common/unified_malloc_framework/src/memory_provider_internal.h similarity index 51% rename from source/common/unified_memory_allocation/src/memory_provider_internal.h rename to source/common/unified_malloc_framework/src/memory_provider_internal.h index dce77cb6d6..2bad161706 100644 --- a/source/common/unified_memory_allocation/src/memory_provider_internal.h +++ b/source/common/unified_malloc_framework/src/memory_provider_internal.h @@ -8,19 +8,20 @@ * */ -#ifndef UMA_MEMORY_PROVIDER_INTERNAL_H -#define UMA_MEMORY_PROVIDER_INTERNAL_H 1 +#ifndef UMF_MEMORY_PROVIDER_INTERNAL_H +#define UMF_MEMORY_PROVIDER_INTERNAL_H 1 -#include +#include #ifdef __cplusplus extern "C" { #endif -void *umaMemoryProviderGetPriv(uma_memory_provider_handle_t hProvider); +void *umfMemoryProviderGetPriv(umf_memory_provider_handle_t hProvider); +umf_memory_provider_handle_t *umfGetLastFailedMemoryProviderPtr(void); #ifdef __cplusplus } #endif -#endif /* UMA_MEMORY_PROVIDER_INTERNAL_H */ +#endif /* UMF_MEMORY_PROVIDER_INTERNAL_H */ diff --git a/source/common/unified_malloc_framework/src/memory_tracker.cpp b/source/common/unified_malloc_framework/src/memory_tracker.cpp new file mode 100644 index 0000000000..adbe2aa5e9 --- /dev/null +++ b/source/common/unified_malloc_framework/src/memory_tracker.cpp @@ -0,0 +1,270 @@ +/* + * + * Copyright (C) 2023 Intel Corporation + * + * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. + * See LICENSE.TXT + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + */ + +#include "memory_tracker.h" +#include +#include + +#include +#include +#include +#include +#include + +#ifdef _WIN32 +#include +#endif + +// TODO: reimplement in C and optimize... +struct umf_memory_tracker_t { + enum umf_result_t add(void *pool, const void *ptr, size_t size) { + std::unique_lock lock(mtx); + + if (size == 0) { + return UMF_RESULT_SUCCESS; + } + + auto ret = + map.try_emplace(reinterpret_cast(ptr), size, pool); + return ret.second ? UMF_RESULT_SUCCESS : UMF_RESULT_ERROR_UNKNOWN; + } + + enum umf_result_t remove(const void *ptr, size_t size) { + std::unique_lock lock(mtx); + + map.erase(reinterpret_cast(ptr)); + + // TODO: handle removing part of the range + (void)size; + + return UMF_RESULT_SUCCESS; + } + + void *find(const void *ptr) { + std::shared_lock lock(mtx); + + auto intptr = reinterpret_cast(ptr); + auto it = map.upper_bound(intptr); + if (it == map.begin()) { + return nullptr; + } + + --it; + + auto address = it->first; + auto size = it->second.first; + auto pool = it->second.second; + + if (intptr >= address && intptr < address + size) { + return pool; + } + + return nullptr; + } + + private: + std::shared_mutex mtx; + std::map> map; +}; + +static enum umf_result_t +umfMemoryTrackerAdd(umf_memory_tracker_handle_t hTracker, void *pool, + const void *ptr, size_t size) { + return hTracker->add(pool, ptr, size); +} + +static enum umf_result_t +umfMemoryTrackerRemove(umf_memory_tracker_handle_t hTracker, const void *ptr, + size_t size) { + return hTracker->remove(ptr, size); +} + +extern "C" { + +#if defined(_WIN32) && defined(UMF_SHARED_LIBRARY) +umf_memory_tracker_t *tracker = nullptr; +BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { + if (fdwReason == DLL_PROCESS_DETACH) { + delete tracker; + } else if (fdwReason == DLL_PROCESS_ATTACH) { + tracker = new umf_memory_tracker_t; + } + return TRUE; +} +#elif defined(_WIN32) +umf_memory_tracker_t trackerInstance; +umf_memory_tracker_t *tracker = &trackerInstance; +#else +umf_memory_tracker_t *tracker = nullptr; +void __attribute__((constructor)) createLibTracker() { + tracker = new umf_memory_tracker_t; +} + +void __attribute__((destructor)) deleteLibTracker() { delete tracker; } +#endif + +umf_memory_tracker_handle_t umfMemoryTrackerGet(void) { return tracker; } + +void *umfMemoryTrackerGetPool(umf_memory_tracker_handle_t hTracker, + const void *ptr) { + return hTracker->find(ptr); +} + +struct umf_tracking_memory_provider_t { + umf_memory_provider_handle_t hUpstream; + umf_memory_tracker_handle_t hTracker; + umf_memory_pool_handle_t pool; +}; + +typedef struct umf_tracking_memory_provider_t umf_tracking_memory_provider_t; + +static enum umf_result_t trackingAlloc(void *hProvider, size_t size, + size_t alignment, void **ptr) { + umf_tracking_memory_provider_t *p = + (umf_tracking_memory_provider_t *)hProvider; + enum umf_result_t ret = UMF_RESULT_SUCCESS; + + if (!p->hUpstream) { + return UMF_RESULT_ERROR_INVALID_ARGUMENT; + } + + ret = umfMemoryProviderAlloc(p->hUpstream, size, alignment, ptr); + if (ret != UMF_RESULT_SUCCESS) { + return ret; + } + + ret = umfMemoryTrackerAdd(p->hTracker, p->pool, *ptr, size); + if (ret != UMF_RESULT_SUCCESS && p->hUpstream) { + if (umfMemoryProviderFree(p->hUpstream, *ptr, size)) { + // TODO: LOG + } + } + + return ret; +} + +static enum umf_result_t trackingFree(void *hProvider, void *ptr, size_t size) { + enum umf_result_t ret; + umf_tracking_memory_provider_t *p = + (umf_tracking_memory_provider_t *)hProvider; + + // umfMemoryTrackerRemove should be called before umfMemoryProviderFree + // to avoid a race condition. If the order would be different, other thread + // could allocate the memory at address `ptr` before a call to umfMemoryTrackerRemove + // resulting in inconsistent state. + ret = umfMemoryTrackerRemove(p->hTracker, ptr, size); + if (ret != UMF_RESULT_SUCCESS) { + return ret; + } + + ret = umfMemoryProviderFree(p->hUpstream, ptr, size); + if (ret != UMF_RESULT_SUCCESS) { + if (umfMemoryTrackerAdd(p->hTracker, p->pool, ptr, size) != + UMF_RESULT_SUCCESS) { + // TODO: LOG + } + return ret; + } + + return ret; +} + +static enum umf_result_t trackingInitialize(void *params, void **ret) { + umf_tracking_memory_provider_t *provider = + (umf_tracking_memory_provider_t *)malloc( + sizeof(umf_tracking_memory_provider_t)); + if (!provider) { + return UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY; + } + + *provider = *((umf_tracking_memory_provider_t *)params); + *ret = provider; + return UMF_RESULT_SUCCESS; +} + +static void trackingFinalize(void *provider) { free(provider); } + +static void trackingGetLastError(void *provider, const char **msg, + int32_t *pError) { + umf_tracking_memory_provider_t *p = + (umf_tracking_memory_provider_t *)provider; + umfMemoryProviderGetLastNativeError(p->hUpstream, msg, pError); +} + +static enum umf_result_t +trackingGetRecommendedPageSize(void *provider, size_t size, size_t *pageSize) { + umf_tracking_memory_provider_t *p = + (umf_tracking_memory_provider_t *)provider; + return umfMemoryProviderGetRecommendedPageSize(p->hUpstream, size, + pageSize); +} + +static enum umf_result_t trackingGetMinPageSize(void *provider, void *ptr, + size_t *pageSize) { + umf_tracking_memory_provider_t *p = + (umf_tracking_memory_provider_t *)provider; + return umfMemoryProviderGetMinPageSize(p->hUpstream, ptr, pageSize); +} + +static enum umf_result_t trackingPurgeLazy(void *provider, void *ptr, + size_t size) { + umf_tracking_memory_provider_t *p = + (umf_tracking_memory_provider_t *)provider; + return umfMemoryProviderPurgeLazy(p->hUpstream, ptr, size); +} + +static enum umf_result_t trackingPurgeForce(void *provider, void *ptr, + size_t size) { + umf_tracking_memory_provider_t *p = + (umf_tracking_memory_provider_t *)provider; + return umfMemoryProviderPurgeForce(p->hUpstream, ptr, size); +} + +static const char *trackingName(void *provider) { + umf_tracking_memory_provider_t *p = + (umf_tracking_memory_provider_t *)provider; + return umfMemoryProviderGetName(p->hUpstream); +} + +enum umf_result_t umfTrackingMemoryProviderCreate( + umf_memory_provider_handle_t hUpstream, umf_memory_pool_handle_t hPool, + umf_memory_provider_handle_t *hTrackingProvider) { + umf_tracking_memory_provider_t params; + params.hUpstream = hUpstream; + params.hTracker = umfMemoryTrackerGet(); + params.pool = hPool; + + struct umf_memory_provider_ops_t trackingMemoryProviderOps; + trackingMemoryProviderOps.version = UMF_VERSION_CURRENT; + trackingMemoryProviderOps.initialize = trackingInitialize; + trackingMemoryProviderOps.finalize = trackingFinalize; + trackingMemoryProviderOps.alloc = trackingAlloc; + trackingMemoryProviderOps.free = trackingFree; + trackingMemoryProviderOps.get_last_native_error = trackingGetLastError; + trackingMemoryProviderOps.get_min_page_size = trackingGetMinPageSize; + trackingMemoryProviderOps.get_recommended_page_size = + trackingGetRecommendedPageSize; + trackingMemoryProviderOps.purge_force = trackingPurgeForce; + trackingMemoryProviderOps.purge_lazy = trackingPurgeLazy; + trackingMemoryProviderOps.get_name = trackingName; + + return umfMemoryProviderCreate(&trackingMemoryProviderOps, ¶ms, + hTrackingProvider); +} + +void umfTrackingMemoryProviderGetUpstreamProvider( + umf_memory_provider_handle_t hTrackingProvider, + umf_memory_provider_handle_t *hUpstream) { + assert(hUpstream); + umf_tracking_memory_provider_t *p = + (umf_tracking_memory_provider_t *)hTrackingProvider; + *hUpstream = p->hUpstream; +} +} diff --git a/source/common/unified_malloc_framework/src/memory_tracker.h b/source/common/unified_malloc_framework/src/memory_tracker.h new file mode 100644 index 0000000000..43a95cf0cd --- /dev/null +++ b/source/common/unified_malloc_framework/src/memory_tracker.h @@ -0,0 +1,42 @@ +/* + * + * Copyright (C) 2023 Intel Corporation + * + * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. + * See LICENSE.TXT + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + */ + +#ifndef UMF_MEMORY_TRACKER_INTERNAL_H +#define UMF_MEMORY_TRACKER_INTERNAL_H 1 + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct umf_memory_tracker_t *umf_memory_tracker_handle_t; + +umf_memory_tracker_handle_t umfMemoryTrackerGet(void); +void *umfMemoryTrackerGetPool(umf_memory_tracker_handle_t hTracker, + const void *ptr); + +// Creates a memory provider that tracks each allocation/deallocation through umf_memory_tracker_handle_t and +// forwards all requests to hUpstream memory Provider. hUpstream lifetime should be managed by the user of this function. +enum umf_result_t umfTrackingMemoryProviderCreate( + umf_memory_provider_handle_t hUpstream, umf_memory_pool_handle_t hPool, + umf_memory_provider_handle_t *hTrackingProvider); + +void umfTrackingMemoryProviderGetUpstreamProvider( + umf_memory_provider_handle_t hTrackingProvider, + umf_memory_provider_handle_t *hUpstream); + +#ifdef __cplusplus +} +#endif + +#endif /* UMF_MEMORY_TRACKER_INTERNAL_H */ diff --git a/source/common/unified_memory_allocation/CMakeLists.txt b/source/common/unified_memory_allocation/CMakeLists.txt deleted file mode 100644 index 81eb655692..0000000000 --- a/source/common/unified_memory_allocation/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright (C) 2023 Intel Corporation -# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. -# See LICENSE.TXT -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -set(UMA_SOURCES - src/memory_pool.c - src/memory_provider.c - src/memory_tracker.cpp -) - -if(UMA_BUILD_SHARED_LIBRARY) - message(WARNING "Unified Memory Allocation is still an early work in progress." - "There are no API/ABI backward compatibility guarantees. There will be breakages." - "Do not use the shared library in production software.") - add_library(unified_memory_allocation SHARED - ${UMA_SOURCES}) -else() - add_library(unified_memory_allocation STATIC - ${UMA_SOURCES}) -endif() - -add_library(${PROJECT_NAME}::unified_memory_allocation ALIAS unified_memory_allocation) - -target_include_directories(unified_memory_allocation PUBLIC include) diff --git a/source/common/unified_memory_allocation/include/uma/base.h b/source/common/unified_memory_allocation/include/uma/base.h deleted file mode 100644 index 7d5d34f987..0000000000 --- a/source/common/unified_memory_allocation/include/uma/base.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * - * Copyright (C) 2023 Intel Corporation - * - * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. - * See LICENSE.TXT - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - * - */ - -#ifndef UMA_BASE_H -#define UMA_BASE_H 1 - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/// \brief Generates generic 'UMA' API versions -#define UMA_MAKE_VERSION(_major, _minor) \ - ((_major << 16) | (_minor & 0x0000ffff)) - -/// \brief Extracts 'UMA' API major version -#define UMA_MAJOR_VERSION(_ver) (_ver >> 16) - -/// \brief Extracts 'UMA' API minor version -#define UMA_MINOR_VERSION(_ver) (_ver & 0x0000ffff) - -/// \brief Current version of the UMA headers -#define UMA_VERSION_CURRENT UMA_MAKE_VERSION(0, 9) - -/// \brief Operation results -enum uma_result_t { - UMA_RESULT_SUCCESS = 0, ///< Success - UMA_RESULT_ERROR_OUT_OF_HOST_MEMORY = - 1, ///< Insufficient host memory to satisfy call, - UMA_RESULT_ERROR_POOL_SPECIFIC = - 2, ///< A pool specific warning/error has been reported and can be - ///< Retrieved via the umaPoolGetLastResult entry point. - UMA_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC = - 3, ///< A provider specific warning/error has been reported and can be - ///< Retrieved via the umaMemoryProviderGetLastResult entry point. - UMA_RESULT_ERROR_INVALID_ARGUMENT = - 4, ///< Generic error code for invalid arguments - UMA_RESULT_ERROR_INVALID_ALIGNMENT = 5, /// Invalid alignment of an argument - UMA_RESULT_ERROR_NOT_SUPPORTED = 6, /// Operation not supported - - UMA_RESULT_ERROR_UNKNOWN = 0x7ffffffe ///< Unknown or internal error -}; - -#ifdef __cplusplus -} -#endif - -#endif /* UMA_BASE_H */ diff --git a/source/common/unified_memory_allocation/include/uma/memory_provider_ops.h b/source/common/unified_memory_allocation/include/uma/memory_provider_ops.h deleted file mode 100644 index 40c2ac8a0f..0000000000 --- a/source/common/unified_memory_allocation/include/uma/memory_provider_ops.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * - * Copyright (C) 2023 Intel Corporation - * - * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. - * See LICENSE.TXT - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - * - */ - -#ifndef UMA_MEMORY_PROVIDER_OPS_H -#define UMA_MEMORY_PROVIDER_OPS_H 1 - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/// This structure comprises function pointers used by corresponding -/// umaMemoryProvider* calls. Each memory provider implementation should -/// initialize all function pointers. -struct uma_memory_provider_ops_t { - /// Version of the ops structure. - /// Should be initialized using UMA_VERSION_CURRENT - uint32_t version; - - /// - /// \brief Intializes memory pool. - /// \param params pool-specific params - /// \param pool returns pointer to the pool - /// \return UMA_RESULT_SUCCESS on success or appropriate error code on failure. - enum uma_result_t (*initialize)(void *params, void **pool); - - /// - /// \brief Finalizes memory pool. - /// \param pool pool to finalize - void (*finalize)(void *pool); - - /// Refer to memory_provider.h for description of those functions - enum uma_result_t (*alloc)(void *provider, size_t size, size_t alignment, - void **ptr); - enum uma_result_t (*free)(void *provider, void *ptr, size_t size); - enum uma_result_t (*get_last_result)(void *provider, - const char **ppMessage); - enum uma_result_t (*get_recommended_page_size)(void *provider, size_t size, - size_t *pageSize); - enum uma_result_t (*get_min_page_size)(void *provider, void *ptr, - size_t *pageSize); - enum uma_result_t (*purge_lazy)(void *provider, void *ptr, size_t size); - enum uma_result_t (*purge_force)(void *provider, void *ptr, size_t size); - void (*get_name)(void *provider, const char **ppName); -}; - -#ifdef __cplusplus -} -#endif - -#endif /* #ifndef UMA_MEMORY_PROVIDER_OPS_H */ diff --git a/source/common/unified_memory_allocation/src/memory_pool.c b/source/common/unified_memory_allocation/src/memory_pool.c deleted file mode 100644 index 754e4697bd..0000000000 --- a/source/common/unified_memory_allocation/src/memory_pool.c +++ /dev/null @@ -1,162 +0,0 @@ -/* - * - * Copyright (C) 2023 Intel Corporation - * - * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. - * See LICENSE.TXT - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - * - */ - -#include "memory_provider_internal.h" -#include "memory_tracker.h" - -#include -#include - -#include -#include - -struct uma_memory_pool_t { - void *pool_priv; - struct uma_memory_pool_ops_t ops; - - // Holds array of memory providers. All providers are wrapped - // by memory tracking providers (owned and released by UMA). - uma_memory_provider_handle_t *providers; - - size_t numProviders; -}; - -static void -destroyMemoryProviderWrappers(uma_memory_provider_handle_t *providers, - size_t numProviders) { - for (size_t i = 0; i < numProviders; i++) { - umaMemoryProviderDestroy(providers[i]); - } - - free(providers); -} - -enum uma_result_t umaPoolCreate(struct uma_memory_pool_ops_t *ops, - uma_memory_provider_handle_t *providers, - size_t numProviders, void *params, - uma_memory_pool_handle_t *hPool) { - if (!numProviders || !providers) { - return UMA_RESULT_ERROR_INVALID_ARGUMENT; - } - - enum uma_result_t ret = UMA_RESULT_SUCCESS; - uma_memory_pool_handle_t pool = malloc(sizeof(struct uma_memory_pool_t)); - if (!pool) { - return UMA_RESULT_ERROR_OUT_OF_HOST_MEMORY; - } - - assert(ops->version == UMA_VERSION_CURRENT); - - pool->providers = - calloc(numProviders, sizeof(uma_memory_provider_handle_t)); - if (!pool->providers) { - ret = UMA_RESULT_ERROR_OUT_OF_HOST_MEMORY; - goto err_providers_alloc; - } - - size_t providerInd = 0; - pool->numProviders = numProviders; - - // Wrap each provider with memory tracking provider. - for (providerInd = 0; providerInd < numProviders; providerInd++) { - ret = umaTrackingMemoryProviderCreate(providers[providerInd], pool, - &pool->providers[providerInd]); - if (ret != UMA_RESULT_SUCCESS) { - goto err_providers_init; - } - } - - pool->ops = *ops; - ret = ops->initialize(pool->providers, pool->numProviders, params, - &pool->pool_priv); - if (ret != UMA_RESULT_SUCCESS) { - goto err_pool_init; - } - - *hPool = pool; - return UMA_RESULT_SUCCESS; - -err_pool_init: -err_providers_init: - destroyMemoryProviderWrappers(pool->providers, providerInd); -err_providers_alloc: - free(pool); - - return ret; -} - -void umaPoolDestroy(uma_memory_pool_handle_t hPool) { - hPool->ops.finalize(hPool->pool_priv); - destroyMemoryProviderWrappers(hPool->providers, hPool->numProviders); - free(hPool); -} - -void *umaPoolMalloc(uma_memory_pool_handle_t hPool, size_t size) { - return hPool->ops.malloc(hPool->pool_priv, size); -} - -void *umaPoolAlignedMalloc(uma_memory_pool_handle_t hPool, size_t size, - size_t alignment) { - return hPool->ops.aligned_malloc(hPool->pool_priv, size, alignment); -} - -void *umaPoolCalloc(uma_memory_pool_handle_t hPool, size_t num, size_t size) { - return hPool->ops.calloc(hPool->pool_priv, num, size); -} - -void *umaPoolRealloc(uma_memory_pool_handle_t hPool, void *ptr, size_t size) { - return hPool->ops.realloc(hPool->pool_priv, ptr, size); -} - -size_t umaPoolMallocUsableSize(uma_memory_pool_handle_t hPool, void *ptr) { - return hPool->ops.malloc_usable_size(hPool->pool_priv, ptr); -} - -void umaPoolFree(uma_memory_pool_handle_t hPool, void *ptr) { - hPool->ops.free(hPool->pool_priv, ptr); -} - -void umaFree(void *ptr) { - uma_memory_pool_handle_t hPool = umaPoolByPtr(ptr); - if (hPool) { - umaPoolFree(hPool, ptr); - } -} - -enum uma_result_t umaPoolGetLastResult(uma_memory_pool_handle_t hPool, - const char **ppMessage) { - return hPool->ops.get_last_result(hPool->pool_priv, ppMessage); -} - -uma_memory_pool_handle_t umaPoolByPtr(const void *ptr) { - return umaMemoryTrackerGetPool(umaMemoryTrackerGet(), ptr); -} - -enum uma_result_t -umaPoolGetMemoryProviders(uma_memory_pool_handle_t hPool, size_t numProviders, - uma_memory_provider_handle_t *hProviders, - size_t *numProvidersRet) { - if (hProviders && numProviders < hPool->numProviders) { - return UMA_RESULT_ERROR_INVALID_ARGUMENT; - } - - if (numProvidersRet) { - *numProvidersRet = hPool->numProviders; - } - - if (hProviders) { - for (size_t i = 0; i < hPool->numProviders; i++) { - umaTrackingMemoryProviderGetUpstreamProvider( - umaMemoryProviderGetPriv(hPool->providers[i]), hProviders + i); - } - } - - return UMA_RESULT_SUCCESS; -} diff --git a/source/common/unified_memory_allocation/src/memory_provider.c b/source/common/unified_memory_allocation/src/memory_provider.c deleted file mode 100644 index 23b05cd4d4..0000000000 --- a/source/common/unified_memory_allocation/src/memory_provider.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - * - * Copyright (C) 2023 Intel Corporation - * - * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. - * See LICENSE.TXT - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - * - */ - -#include "memory_provider_internal.h" -#include - -#include -#include - -struct uma_memory_provider_t { - struct uma_memory_provider_ops_t ops; - void *provider_priv; -}; - -enum uma_result_t -umaMemoryProviderCreate(struct uma_memory_provider_ops_t *ops, void *params, - uma_memory_provider_handle_t *hProvider) { - uma_memory_provider_handle_t provider = - malloc(sizeof(struct uma_memory_provider_t)); - if (!provider) { - return UMA_RESULT_ERROR_OUT_OF_HOST_MEMORY; - } - - assert(ops->version == UMA_VERSION_CURRENT); - - provider->ops = *ops; - - void *provider_priv; - enum uma_result_t ret = ops->initialize(params, &provider_priv); - if (ret != UMA_RESULT_SUCCESS) { - free(provider); - return ret; - } - - provider->provider_priv = provider_priv; - - *hProvider = provider; - - return UMA_RESULT_SUCCESS; -} - -void umaMemoryProviderDestroy(uma_memory_provider_handle_t hProvider) { - hProvider->ops.finalize(hProvider->provider_priv); - free(hProvider); -} - -enum uma_result_t umaMemoryProviderAlloc(uma_memory_provider_handle_t hProvider, - size_t size, size_t alignment, - void **ptr) { - return hProvider->ops.alloc(hProvider->provider_priv, size, alignment, ptr); -} - -enum uma_result_t umaMemoryProviderFree(uma_memory_provider_handle_t hProvider, - void *ptr, size_t size) { - return hProvider->ops.free(hProvider->provider_priv, ptr, size); -} - -enum uma_result_t -umaMemoryProviderGetLastResult(uma_memory_provider_handle_t hProvider, - const char **ppMessage) { - return hProvider->ops.get_last_result(hProvider->provider_priv, ppMessage); -} - -void *umaMemoryProviderGetPriv(uma_memory_provider_handle_t hProvider) { - return hProvider->provider_priv; -} - -enum uma_result_t -umaMemoryProviderGetRecommendedPageSize(uma_memory_provider_handle_t hProvider, - size_t size, size_t *pageSize) { - return hProvider->ops.get_recommended_page_size(hProvider->provider_priv, - size, pageSize); -} - -enum uma_result_t -umaMemoryProviderGetMinPageSize(uma_memory_provider_handle_t hProvider, - void *ptr, size_t *pageSize) { - return hProvider->ops.get_min_page_size(hProvider->provider_priv, ptr, - pageSize); -} - -enum uma_result_t -umaMemoryProviderPurgeLazy(uma_memory_provider_handle_t hProvider, void *ptr, - size_t size) { - return hProvider->ops.purge_lazy(hProvider->provider_priv, ptr, size); -} - -enum uma_result_t -umaMemoryProviderPurgeForce(uma_memory_provider_handle_t hProvider, void *ptr, - size_t size) { - return hProvider->ops.purge_force(hProvider->provider_priv, ptr, size); -} - -void umaMemoryProviderGetName(uma_memory_provider_handle_t hProvider, - const char **ppName) { - hProvider->ops.get_name(hProvider->provider_priv, ppName); -} diff --git a/source/common/unified_memory_allocation/src/memory_tracker.cpp b/source/common/unified_memory_allocation/src/memory_tracker.cpp deleted file mode 100644 index 6f56134db2..0000000000 --- a/source/common/unified_memory_allocation/src/memory_tracker.cpp +++ /dev/null @@ -1,247 +0,0 @@ -/* - * - * Copyright (C) 2023 Intel Corporation - * - * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. - * See LICENSE.TXT - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - * - */ - -#include "memory_tracker.h" -#include -#include - -#include -#include -#include -#include -#include - -// TODO: reimplement in C and optimize... -struct uma_memory_tracker_t { - enum uma_result_t add(void *pool, const void *ptr, size_t size) { - std::unique_lock lock(mtx); - - if (size == 0) { - return UMA_RESULT_SUCCESS; - } - - auto ret = - map.try_emplace(reinterpret_cast(ptr), size, pool); - return ret.second ? UMA_RESULT_SUCCESS : UMA_RESULT_ERROR_UNKNOWN; - } - - enum uma_result_t remove(const void *ptr, size_t size) { - std::unique_lock lock(mtx); - - map.erase(reinterpret_cast(ptr)); - - // TODO: handle removing part of the range - (void)size; - - return UMA_RESULT_SUCCESS; - } - - void *find(const void *ptr) { - std::shared_lock lock(mtx); - - auto intptr = reinterpret_cast(ptr); - auto it = map.upper_bound(intptr); - if (it == map.begin()) { - return nullptr; - } - - --it; - - auto address = it->first; - auto size = it->second.first; - auto pool = it->second.second; - - if (intptr >= address && intptr < address + size) { - return pool; - } - - return nullptr; - } - - private: - std::shared_mutex mtx; - std::map> map; -}; - -static enum uma_result_t -umaMemoryTrackerAdd(uma_memory_tracker_handle_t hTracker, void *pool, - const void *ptr, size_t size) { - return hTracker->add(pool, ptr, size); -} - -static enum uma_result_t -umaMemoryTrackerRemove(uma_memory_tracker_handle_t hTracker, const void *ptr, - size_t size) { - return hTracker->remove(ptr, size); -} - -extern "C" { - -uma_memory_tracker_handle_t umaMemoryTrackerGet(void) { - static uma_memory_tracker_t tracker; - return &tracker; -} - -void *umaMemoryTrackerGetPool(uma_memory_tracker_handle_t hTracker, - const void *ptr) { - return hTracker->find(ptr); -} - -struct uma_tracking_memory_provider_t { - uma_memory_provider_handle_t hUpstream; - uma_memory_tracker_handle_t hTracker; - uma_memory_pool_handle_t pool; -}; - -typedef struct uma_tracking_memory_provider_t uma_tracking_memory_provider_t; - -static enum uma_result_t trackingAlloc(void *hProvider, size_t size, - size_t alignment, void **ptr) { - uma_tracking_memory_provider_t *p = - (uma_tracking_memory_provider_t *)hProvider; - enum uma_result_t ret = UMA_RESULT_SUCCESS; - - if (!p->hUpstream) { - return UMA_RESULT_ERROR_INVALID_ARGUMENT; - } - - ret = umaMemoryProviderAlloc(p->hUpstream, size, alignment, ptr); - if (ret != UMA_RESULT_SUCCESS) { - return ret; - } - - ret = umaMemoryTrackerAdd(p->hTracker, p->pool, *ptr, size); - if (ret != UMA_RESULT_SUCCESS && p->hUpstream) { - if (umaMemoryProviderFree(p->hUpstream, *ptr, size)) { - // TODO: LOG - } - } - - return ret; -} - -static enum uma_result_t trackingFree(void *hProvider, void *ptr, size_t size) { - enum uma_result_t ret; - uma_tracking_memory_provider_t *p = - (uma_tracking_memory_provider_t *)hProvider; - - // umaMemoryTrackerRemove should be called before umaMemoryProviderFree - // to avoid a race condition. If the order would be different, other thread - // could allocate the memory at address `ptr` before a call to umaMemoryTrackerRemove - // resulting in inconsistent state. - ret = umaMemoryTrackerRemove(p->hTracker, ptr, size); - if (ret != UMA_RESULT_SUCCESS) { - return ret; - } - - ret = umaMemoryProviderFree(p->hUpstream, ptr, size); - if (ret != UMA_RESULT_SUCCESS) { - if (umaMemoryTrackerAdd(p->hTracker, p->pool, ptr, size) != - UMA_RESULT_SUCCESS) { - // TODO: LOG - } - return ret; - } - - return ret; -} - -static enum uma_result_t trackingInitialize(void *params, void **ret) { - uma_tracking_memory_provider_t *provider = - (uma_tracking_memory_provider_t *)malloc( - sizeof(uma_tracking_memory_provider_t)); - if (!provider) { - return UMA_RESULT_ERROR_OUT_OF_HOST_MEMORY; - } - - *provider = *((uma_tracking_memory_provider_t *)params); - *ret = provider; - return UMA_RESULT_SUCCESS; -} - -static void trackingFinalize(void *provider) { free(provider); } - -static enum uma_result_t trackingGetLastResult(void *provider, - const char **msg) { - uma_tracking_memory_provider_t *p = - (uma_tracking_memory_provider_t *)provider; - return umaMemoryProviderGetLastResult(p->hUpstream, msg); -} - -static enum uma_result_t -trackingGetRecommendedPageSize(void *provider, size_t size, size_t *pageSize) { - uma_tracking_memory_provider_t *p = - (uma_tracking_memory_provider_t *)provider; - return umaMemoryProviderGetRecommendedPageSize(p->hUpstream, size, - pageSize); -} - -static enum uma_result_t trackingGetMinPageSize(void *provider, void *ptr, - size_t *pageSize) { - uma_tracking_memory_provider_t *p = - (uma_tracking_memory_provider_t *)provider; - return umaMemoryProviderGetMinPageSize(p->hUpstream, ptr, pageSize); -} - -static enum uma_result_t trackingPurgeLazy(void *provider, void *ptr, - size_t size) { - uma_tracking_memory_provider_t *p = - (uma_tracking_memory_provider_t *)provider; - return umaMemoryProviderPurgeLazy(p->hUpstream, ptr, size); -} - -static enum uma_result_t trackingPurgeForce(void *provider, void *ptr, - size_t size) { - uma_tracking_memory_provider_t *p = - (uma_tracking_memory_provider_t *)provider; - return umaMemoryProviderPurgeForce(p->hUpstream, ptr, size); -} - -static void trackingName(void *provider, const char **ppName) { - uma_tracking_memory_provider_t *p = - (uma_tracking_memory_provider_t *)provider; - return umaMemoryProviderGetName(p->hUpstream, ppName); -} - -enum uma_result_t umaTrackingMemoryProviderCreate( - uma_memory_provider_handle_t hUpstream, uma_memory_pool_handle_t hPool, - uma_memory_provider_handle_t *hTrackingProvider) { - uma_tracking_memory_provider_t params; - params.hUpstream = hUpstream; - params.hTracker = umaMemoryTrackerGet(); - params.pool = hPool; - - struct uma_memory_provider_ops_t trackingMemoryProviderOps; - trackingMemoryProviderOps.version = UMA_VERSION_CURRENT; - trackingMemoryProviderOps.initialize = trackingInitialize; - trackingMemoryProviderOps.finalize = trackingFinalize; - trackingMemoryProviderOps.alloc = trackingAlloc; - trackingMemoryProviderOps.free = trackingFree; - trackingMemoryProviderOps.get_last_result = trackingGetLastResult; - trackingMemoryProviderOps.get_min_page_size = trackingGetMinPageSize; - trackingMemoryProviderOps.get_recommended_page_size = - trackingGetRecommendedPageSize; - trackingMemoryProviderOps.purge_force = trackingPurgeForce; - trackingMemoryProviderOps.purge_lazy = trackingPurgeLazy; - trackingMemoryProviderOps.get_name = trackingName; - - return umaMemoryProviderCreate(&trackingMemoryProviderOps, ¶ms, - hTrackingProvider); -} - -void umaTrackingMemoryProviderGetUpstreamProvider( - uma_memory_provider_handle_t hTrackingProvider, - uma_memory_provider_handle_t *hUpstream) { - assert(hUpstream); - uma_tracking_memory_provider_t *p = - (uma_tracking_memory_provider_t *)hTrackingProvider; - *hUpstream = p->hUpstream; -} -} diff --git a/source/common/unified_memory_allocation/src/memory_tracker.h b/source/common/unified_memory_allocation/src/memory_tracker.h deleted file mode 100644 index 055942174f..0000000000 --- a/source/common/unified_memory_allocation/src/memory_tracker.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * - * Copyright (C) 2023 Intel Corporation - * - * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. - * See LICENSE.TXT - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - * - */ - -#ifndef UMA_MEMORY_TRACKER_INTERNAL_H -#define UMA_MEMORY_TRACKER_INTERNAL_H 1 - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct uma_memory_tracker_t *uma_memory_tracker_handle_t; - -uma_memory_tracker_handle_t umaMemoryTrackerGet(void); -void *umaMemoryTrackerGetPool(uma_memory_tracker_handle_t hTracker, - const void *ptr); - -// Creates a memory provider that tracks each allocation/deallocation through uma_memory_tracker_handle_t and -// forwards all requests to hUpstream memory Provider. hUpstream liftime should be managed by the user of this function. -enum uma_result_t umaTrackingMemoryProviderCreate( - uma_memory_provider_handle_t hUpstream, uma_memory_pool_handle_t hPool, - uma_memory_provider_handle_t *hTrackingProvider); - -void umaTrackingMemoryProviderGetUpstreamProvider( - uma_memory_provider_handle_t hTrackingProvider, - uma_memory_provider_handle_t *hUpstream); - -#ifdef __cplusplus -} -#endif - -#endif /* UMA_MEMORY_TRACKER_INTERNAL_H */ diff --git a/source/common/ur_params.hpp b/source/common/ur_params.hpp index deab11b7af..2f9789506e 100644 --- a/source/common/ur_params.hpp +++ b/source/common/ur_params.hpp @@ -30,6 +30,10 @@ template <> inline void serializeFlag(std::ostream &os, uint32_t flag); +template <> +inline void serializeTagged(std::ostream &os, const void *ptr, + ur_adapter_info_t value, size_t size); + template <> inline void serializeTagged(std::ostream &os, const void *ptr, ur_platform_info_t value, size_t size); @@ -42,6 +46,10 @@ template <> inline void serializeFlag(std::ostream &os, uint32_t flag); +inline void serializeUnion(std::ostream &os, + const union ur_device_partition_value_t params, + const enum ur_device_partition_t tag); + template <> inline void serializeFlag(std::ostream &os, uint32_t flag); @@ -125,6 +133,10 @@ template <> inline void serializeFlag(std::ostream &os, uint32_t flag); +inline void serializeUnion(std::ostream &os, + const union ur_program_metadata_value_t params, + const enum ur_program_metadata_type_t tag); + template <> inline void serializeTagged(std::ostream &os, const void *ptr, ur_program_info_t value, size_t size); @@ -181,9 +193,10 @@ inline void serializeTagged(std::ostream &os, const void *ptr, } // namespace ur_params -inline std::ostream &operator<<(std::ostream &os, enum ur_result_t value); +inline std::ostream &operator<<(std::ostream &os, enum ur_function_t value); inline std::ostream &operator<<(std::ostream &os, enum ur_structure_type_t value); +inline std::ostream &operator<<(std::ostream &os, enum ur_result_t value); inline std::ostream &operator<<(std::ostream &os, const struct ur_base_properties_t params); inline std::ostream &operator<<(std::ostream &os, @@ -194,6 +207,9 @@ inline std::ostream &operator<<(std::ostream &os, const struct ur_rect_region_t params); inline std::ostream &operator<<(std::ostream &os, enum ur_device_init_flag_t value); +inline std::ostream &operator<<(std::ostream &os, enum ur_adapter_info_t value); +inline std::ostream &operator<<(std::ostream &os, + enum ur_adapter_backend_t value); inline std::ostream &operator<<(std::ostream &os, enum ur_platform_info_t value); inline std::ostream &operator<<(std::ostream &os, enum ur_api_version_t value); @@ -210,8 +226,6 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_device_affinity_domain_flag_t value); inline std::ostream &operator<<(std::ostream &os, enum ur_device_partition_t value); -inline std::ostream &operator<<(std::ostream &os, - const union ur_device_partition_value_t params); inline std::ostream & operator<<(std::ostream &os, const struct ur_device_partition_property_t params); @@ -312,8 +326,6 @@ inline std::ostream & operator<<(std::ostream &os, const struct ur_physical_mem_properties_t params); inline std::ostream &operator<<(std::ostream &os, enum ur_program_metadata_type_t value); -inline std::ostream &operator<<(std::ostream &os, - const union ur_program_metadata_value_t params); inline std::ostream &operator<<(std::ostream &os, const struct ur_program_metadata_t params); inline std::ostream &operator<<(std::ostream &os, @@ -379,502 +391,935 @@ inline std::ostream & operator<<(std::ostream &os, const struct ur_event_native_properties_t params); inline std::ostream &operator<<(std::ostream &os, enum ur_execution_info_t value); -inline std::ostream &operator<<(std::ostream &os, enum ur_function_t value); inline std::ostream &operator<<(std::ostream &os, enum ur_map_flag_t value); inline std::ostream &operator<<(std::ostream &os, enum ur_usm_migration_flag_t value); inline std::ostream &operator<<(std::ostream &os, enum ur_exp_image_copy_flag_t value); +inline std::ostream &operator<<(std::ostream &os, + const struct ur_exp_file_descriptor_t params); +inline std::ostream &operator<<(std::ostream &os, + const struct ur_exp_win32_handle_t params); inline std::ostream & operator<<(std::ostream &os, const struct ur_exp_sampler_mip_properties_t params); +inline std::ostream &operator<<(std::ostream &os, + const struct ur_exp_interop_mem_desc_t params); +inline std::ostream & +operator<<(std::ostream &os, + const struct ur_exp_interop_semaphore_desc_t params); inline std::ostream & operator<<(std::ostream &os, const struct ur_exp_command_buffer_desc_t params); inline std::ostream &operator<<(std::ostream &os, enum ur_exp_peer_info_t value); -inline std::ostream &operator<<(std::ostream &os, enum ur_result_t value) { +inline std::ostream &operator<<(std::ostream &os, enum ur_function_t value) { switch (value) { - case UR_RESULT_SUCCESS: - os << "UR_RESULT_SUCCESS"; + case UR_FUNCTION_CONTEXT_CREATE: + os << "UR_FUNCTION_CONTEXT_CREATE"; break; - case UR_RESULT_ERROR_INVALID_OPERATION: - os << "UR_RESULT_ERROR_INVALID_OPERATION"; + case UR_FUNCTION_CONTEXT_RETAIN: + os << "UR_FUNCTION_CONTEXT_RETAIN"; break; - case UR_RESULT_ERROR_INVALID_QUEUE_PROPERTIES: - os << "UR_RESULT_ERROR_INVALID_QUEUE_PROPERTIES"; + case UR_FUNCTION_CONTEXT_RELEASE: + os << "UR_FUNCTION_CONTEXT_RELEASE"; break; - case UR_RESULT_ERROR_INVALID_QUEUE: - os << "UR_RESULT_ERROR_INVALID_QUEUE"; + case UR_FUNCTION_CONTEXT_GET_INFO: + os << "UR_FUNCTION_CONTEXT_GET_INFO"; break; - case UR_RESULT_ERROR_INVALID_VALUE: - os << "UR_RESULT_ERROR_INVALID_VALUE"; + case UR_FUNCTION_CONTEXT_GET_NATIVE_HANDLE: + os << "UR_FUNCTION_CONTEXT_GET_NATIVE_HANDLE"; break; - case UR_RESULT_ERROR_INVALID_CONTEXT: - os << "UR_RESULT_ERROR_INVALID_CONTEXT"; + case UR_FUNCTION_CONTEXT_CREATE_WITH_NATIVE_HANDLE: + os << "UR_FUNCTION_CONTEXT_CREATE_WITH_NATIVE_HANDLE"; break; - case UR_RESULT_ERROR_INVALID_PLATFORM: - os << "UR_RESULT_ERROR_INVALID_PLATFORM"; + case UR_FUNCTION_CONTEXT_SET_EXTENDED_DELETER: + os << "UR_FUNCTION_CONTEXT_SET_EXTENDED_DELETER"; break; - case UR_RESULT_ERROR_INVALID_BINARY: - os << "UR_RESULT_ERROR_INVALID_BINARY"; + case UR_FUNCTION_DEVICE_GET: + os << "UR_FUNCTION_DEVICE_GET"; break; - case UR_RESULT_ERROR_INVALID_PROGRAM: - os << "UR_RESULT_ERROR_INVALID_PROGRAM"; + case UR_FUNCTION_DEVICE_GET_INFO: + os << "UR_FUNCTION_DEVICE_GET_INFO"; break; - case UR_RESULT_ERROR_INVALID_SAMPLER: - os << "UR_RESULT_ERROR_INVALID_SAMPLER"; + case UR_FUNCTION_DEVICE_RETAIN: + os << "UR_FUNCTION_DEVICE_RETAIN"; break; - case UR_RESULT_ERROR_INVALID_BUFFER_SIZE: - os << "UR_RESULT_ERROR_INVALID_BUFFER_SIZE"; + case UR_FUNCTION_DEVICE_RELEASE: + os << "UR_FUNCTION_DEVICE_RELEASE"; break; - case UR_RESULT_ERROR_INVALID_MEM_OBJECT: - os << "UR_RESULT_ERROR_INVALID_MEM_OBJECT"; + case UR_FUNCTION_DEVICE_PARTITION: + os << "UR_FUNCTION_DEVICE_PARTITION"; break; - case UR_RESULT_ERROR_INVALID_EVENT: - os << "UR_RESULT_ERROR_INVALID_EVENT"; + case UR_FUNCTION_DEVICE_SELECT_BINARY: + os << "UR_FUNCTION_DEVICE_SELECT_BINARY"; break; - case UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST: - os << "UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST"; + case UR_FUNCTION_DEVICE_GET_NATIVE_HANDLE: + os << "UR_FUNCTION_DEVICE_GET_NATIVE_HANDLE"; break; - case UR_RESULT_ERROR_MISALIGNED_SUB_BUFFER_OFFSET: - os << "UR_RESULT_ERROR_MISALIGNED_SUB_BUFFER_OFFSET"; + case UR_FUNCTION_DEVICE_CREATE_WITH_NATIVE_HANDLE: + os << "UR_FUNCTION_DEVICE_CREATE_WITH_NATIVE_HANDLE"; break; - case UR_RESULT_ERROR_INVALID_WORK_GROUP_SIZE: - os << "UR_RESULT_ERROR_INVALID_WORK_GROUP_SIZE"; + case UR_FUNCTION_DEVICE_GET_GLOBAL_TIMESTAMPS: + os << "UR_FUNCTION_DEVICE_GET_GLOBAL_TIMESTAMPS"; break; - case UR_RESULT_ERROR_COMPILER_NOT_AVAILABLE: - os << "UR_RESULT_ERROR_COMPILER_NOT_AVAILABLE"; + case UR_FUNCTION_ENQUEUE_KERNEL_LAUNCH: + os << "UR_FUNCTION_ENQUEUE_KERNEL_LAUNCH"; break; - case UR_RESULT_ERROR_PROFILING_INFO_NOT_AVAILABLE: - os << "UR_RESULT_ERROR_PROFILING_INFO_NOT_AVAILABLE"; + case UR_FUNCTION_ENQUEUE_EVENTS_WAIT: + os << "UR_FUNCTION_ENQUEUE_EVENTS_WAIT"; break; - case UR_RESULT_ERROR_DEVICE_NOT_FOUND: - os << "UR_RESULT_ERROR_DEVICE_NOT_FOUND"; + case UR_FUNCTION_ENQUEUE_EVENTS_WAIT_WITH_BARRIER: + os << "UR_FUNCTION_ENQUEUE_EVENTS_WAIT_WITH_BARRIER"; break; - case UR_RESULT_ERROR_INVALID_DEVICE: - os << "UR_RESULT_ERROR_INVALID_DEVICE"; + case UR_FUNCTION_ENQUEUE_MEM_BUFFER_READ: + os << "UR_FUNCTION_ENQUEUE_MEM_BUFFER_READ"; break; - case UR_RESULT_ERROR_DEVICE_LOST: - os << "UR_RESULT_ERROR_DEVICE_LOST"; + case UR_FUNCTION_ENQUEUE_MEM_BUFFER_WRITE: + os << "UR_FUNCTION_ENQUEUE_MEM_BUFFER_WRITE"; break; - case UR_RESULT_ERROR_DEVICE_REQUIRES_RESET: - os << "UR_RESULT_ERROR_DEVICE_REQUIRES_RESET"; + case UR_FUNCTION_ENQUEUE_MEM_BUFFER_READ_RECT: + os << "UR_FUNCTION_ENQUEUE_MEM_BUFFER_READ_RECT"; break; - case UR_RESULT_ERROR_DEVICE_IN_LOW_POWER_STATE: - os << "UR_RESULT_ERROR_DEVICE_IN_LOW_POWER_STATE"; + case UR_FUNCTION_ENQUEUE_MEM_BUFFER_WRITE_RECT: + os << "UR_FUNCTION_ENQUEUE_MEM_BUFFER_WRITE_RECT"; break; - case UR_RESULT_ERROR_DEVICE_PARTITION_FAILED: - os << "UR_RESULT_ERROR_DEVICE_PARTITION_FAILED"; + case UR_FUNCTION_ENQUEUE_MEM_BUFFER_COPY: + os << "UR_FUNCTION_ENQUEUE_MEM_BUFFER_COPY"; break; - case UR_RESULT_ERROR_INVALID_DEVICE_PARTITION_COUNT: - os << "UR_RESULT_ERROR_INVALID_DEVICE_PARTITION_COUNT"; + case UR_FUNCTION_ENQUEUE_MEM_BUFFER_COPY_RECT: + os << "UR_FUNCTION_ENQUEUE_MEM_BUFFER_COPY_RECT"; break; - case UR_RESULT_ERROR_INVALID_WORK_ITEM_SIZE: - os << "UR_RESULT_ERROR_INVALID_WORK_ITEM_SIZE"; + case UR_FUNCTION_ENQUEUE_MEM_BUFFER_FILL: + os << "UR_FUNCTION_ENQUEUE_MEM_BUFFER_FILL"; break; - case UR_RESULT_ERROR_INVALID_WORK_DIMENSION: - os << "UR_RESULT_ERROR_INVALID_WORK_DIMENSION"; + case UR_FUNCTION_ENQUEUE_MEM_IMAGE_READ: + os << "UR_FUNCTION_ENQUEUE_MEM_IMAGE_READ"; break; - case UR_RESULT_ERROR_INVALID_KERNEL_ARGS: - os << "UR_RESULT_ERROR_INVALID_KERNEL_ARGS"; + case UR_FUNCTION_ENQUEUE_MEM_IMAGE_WRITE: + os << "UR_FUNCTION_ENQUEUE_MEM_IMAGE_WRITE"; break; - case UR_RESULT_ERROR_INVALID_KERNEL: - os << "UR_RESULT_ERROR_INVALID_KERNEL"; + case UR_FUNCTION_ENQUEUE_MEM_IMAGE_COPY: + os << "UR_FUNCTION_ENQUEUE_MEM_IMAGE_COPY"; break; - case UR_RESULT_ERROR_INVALID_KERNEL_NAME: - os << "UR_RESULT_ERROR_INVALID_KERNEL_NAME"; + case UR_FUNCTION_ENQUEUE_MEM_BUFFER_MAP: + os << "UR_FUNCTION_ENQUEUE_MEM_BUFFER_MAP"; break; - case UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_INDEX: - os << "UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_INDEX"; + case UR_FUNCTION_ENQUEUE_MEM_UNMAP: + os << "UR_FUNCTION_ENQUEUE_MEM_UNMAP"; break; - case UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_SIZE: - os << "UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_SIZE"; + case UR_FUNCTION_ENQUEUE_USM_FILL: + os << "UR_FUNCTION_ENQUEUE_USM_FILL"; break; - case UR_RESULT_ERROR_INVALID_KERNEL_ATTRIBUTE_VALUE: - os << "UR_RESULT_ERROR_INVALID_KERNEL_ATTRIBUTE_VALUE"; + case UR_FUNCTION_ENQUEUE_USM_MEMCPY: + os << "UR_FUNCTION_ENQUEUE_USM_MEMCPY"; break; - case UR_RESULT_ERROR_INVALID_IMAGE_SIZE: - os << "UR_RESULT_ERROR_INVALID_IMAGE_SIZE"; + case UR_FUNCTION_ENQUEUE_USM_PREFETCH: + os << "UR_FUNCTION_ENQUEUE_USM_PREFETCH"; break; - case UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR: - os << "UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR"; + case UR_FUNCTION_ENQUEUE_USM_ADVISE: + os << "UR_FUNCTION_ENQUEUE_USM_ADVISE"; break; - case UR_RESULT_ERROR_IMAGE_FORMAT_NOT_SUPPORTED: - os << "UR_RESULT_ERROR_IMAGE_FORMAT_NOT_SUPPORTED"; + case UR_FUNCTION_ENQUEUE_DEVICE_GLOBAL_VARIABLE_WRITE: + os << "UR_FUNCTION_ENQUEUE_DEVICE_GLOBAL_VARIABLE_WRITE"; break; - case UR_RESULT_ERROR_MEM_OBJECT_ALLOCATION_FAILURE: - os << "UR_RESULT_ERROR_MEM_OBJECT_ALLOCATION_FAILURE"; + case UR_FUNCTION_ENQUEUE_DEVICE_GLOBAL_VARIABLE_READ: + os << "UR_FUNCTION_ENQUEUE_DEVICE_GLOBAL_VARIABLE_READ"; break; - case UR_RESULT_ERROR_INVALID_PROGRAM_EXECUTABLE: - os << "UR_RESULT_ERROR_INVALID_PROGRAM_EXECUTABLE"; + case UR_FUNCTION_EVENT_GET_INFO: + os << "UR_FUNCTION_EVENT_GET_INFO"; break; - case UR_RESULT_ERROR_UNINITIALIZED: - os << "UR_RESULT_ERROR_UNINITIALIZED"; + case UR_FUNCTION_EVENT_GET_PROFILING_INFO: + os << "UR_FUNCTION_EVENT_GET_PROFILING_INFO"; break; - case UR_RESULT_ERROR_OUT_OF_HOST_MEMORY: - os << "UR_RESULT_ERROR_OUT_OF_HOST_MEMORY"; + case UR_FUNCTION_EVENT_WAIT: + os << "UR_FUNCTION_EVENT_WAIT"; break; - case UR_RESULT_ERROR_OUT_OF_DEVICE_MEMORY: - os << "UR_RESULT_ERROR_OUT_OF_DEVICE_MEMORY"; + case UR_FUNCTION_EVENT_RETAIN: + os << "UR_FUNCTION_EVENT_RETAIN"; break; - case UR_RESULT_ERROR_OUT_OF_RESOURCES: - os << "UR_RESULT_ERROR_OUT_OF_RESOURCES"; + case UR_FUNCTION_EVENT_RELEASE: + os << "UR_FUNCTION_EVENT_RELEASE"; break; - case UR_RESULT_ERROR_PROGRAM_BUILD_FAILURE: - os << "UR_RESULT_ERROR_PROGRAM_BUILD_FAILURE"; + case UR_FUNCTION_EVENT_GET_NATIVE_HANDLE: + os << "UR_FUNCTION_EVENT_GET_NATIVE_HANDLE"; break; - case UR_RESULT_ERROR_PROGRAM_LINK_FAILURE: - os << "UR_RESULT_ERROR_PROGRAM_LINK_FAILURE"; + case UR_FUNCTION_EVENT_CREATE_WITH_NATIVE_HANDLE: + os << "UR_FUNCTION_EVENT_CREATE_WITH_NATIVE_HANDLE"; break; - case UR_RESULT_ERROR_UNSUPPORTED_VERSION: - os << "UR_RESULT_ERROR_UNSUPPORTED_VERSION"; + case UR_FUNCTION_EVENT_SET_CALLBACK: + os << "UR_FUNCTION_EVENT_SET_CALLBACK"; break; - case UR_RESULT_ERROR_UNSUPPORTED_FEATURE: - os << "UR_RESULT_ERROR_UNSUPPORTED_FEATURE"; + case UR_FUNCTION_KERNEL_CREATE: + os << "UR_FUNCTION_KERNEL_CREATE"; break; - case UR_RESULT_ERROR_INVALID_ARGUMENT: - os << "UR_RESULT_ERROR_INVALID_ARGUMENT"; + case UR_FUNCTION_KERNEL_SET_ARG_VALUE: + os << "UR_FUNCTION_KERNEL_SET_ARG_VALUE"; break; - case UR_RESULT_ERROR_INVALID_NULL_HANDLE: - os << "UR_RESULT_ERROR_INVALID_NULL_HANDLE"; + case UR_FUNCTION_KERNEL_SET_ARG_LOCAL: + os << "UR_FUNCTION_KERNEL_SET_ARG_LOCAL"; break; - case UR_RESULT_ERROR_HANDLE_OBJECT_IN_USE: - os << "UR_RESULT_ERROR_HANDLE_OBJECT_IN_USE"; + case UR_FUNCTION_KERNEL_GET_INFO: + os << "UR_FUNCTION_KERNEL_GET_INFO"; break; - case UR_RESULT_ERROR_INVALID_NULL_POINTER: - os << "UR_RESULT_ERROR_INVALID_NULL_POINTER"; + case UR_FUNCTION_KERNEL_GET_GROUP_INFO: + os << "UR_FUNCTION_KERNEL_GET_GROUP_INFO"; break; - case UR_RESULT_ERROR_INVALID_SIZE: - os << "UR_RESULT_ERROR_INVALID_SIZE"; + case UR_FUNCTION_KERNEL_GET_SUB_GROUP_INFO: + os << "UR_FUNCTION_KERNEL_GET_SUB_GROUP_INFO"; break; - case UR_RESULT_ERROR_UNSUPPORTED_SIZE: - os << "UR_RESULT_ERROR_UNSUPPORTED_SIZE"; + case UR_FUNCTION_KERNEL_RETAIN: + os << "UR_FUNCTION_KERNEL_RETAIN"; break; - case UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT: - os << "UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT"; + case UR_FUNCTION_KERNEL_RELEASE: + os << "UR_FUNCTION_KERNEL_RELEASE"; break; - case UR_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT: - os << "UR_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT"; + case UR_FUNCTION_KERNEL_SET_ARG_POINTER: + os << "UR_FUNCTION_KERNEL_SET_ARG_POINTER"; break; - case UR_RESULT_ERROR_INVALID_ENUMERATION: - os << "UR_RESULT_ERROR_INVALID_ENUMERATION"; + case UR_FUNCTION_KERNEL_SET_EXEC_INFO: + os << "UR_FUNCTION_KERNEL_SET_EXEC_INFO"; break; - case UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION: - os << "UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION"; + case UR_FUNCTION_KERNEL_SET_ARG_SAMPLER: + os << "UR_FUNCTION_KERNEL_SET_ARG_SAMPLER"; break; - case UR_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT: - os << "UR_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT"; + case UR_FUNCTION_KERNEL_SET_ARG_MEM_OBJ: + os << "UR_FUNCTION_KERNEL_SET_ARG_MEM_OBJ"; break; - case UR_RESULT_ERROR_INVALID_NATIVE_BINARY: - os << "UR_RESULT_ERROR_INVALID_NATIVE_BINARY"; + case UR_FUNCTION_KERNEL_SET_SPECIALIZATION_CONSTANTS: + os << "UR_FUNCTION_KERNEL_SET_SPECIALIZATION_CONSTANTS"; break; - case UR_RESULT_ERROR_INVALID_GLOBAL_NAME: - os << "UR_RESULT_ERROR_INVALID_GLOBAL_NAME"; + case UR_FUNCTION_KERNEL_GET_NATIVE_HANDLE: + os << "UR_FUNCTION_KERNEL_GET_NATIVE_HANDLE"; break; - case UR_RESULT_ERROR_INVALID_FUNCTION_NAME: - os << "UR_RESULT_ERROR_INVALID_FUNCTION_NAME"; + case UR_FUNCTION_KERNEL_CREATE_WITH_NATIVE_HANDLE: + os << "UR_FUNCTION_KERNEL_CREATE_WITH_NATIVE_HANDLE"; break; - case UR_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION: - os << "UR_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION"; + case UR_FUNCTION_MEM_IMAGE_CREATE: + os << "UR_FUNCTION_MEM_IMAGE_CREATE"; break; - case UR_RESULT_ERROR_INVALID_GLOBAL_WIDTH_DIMENSION: - os << "UR_RESULT_ERROR_INVALID_GLOBAL_WIDTH_DIMENSION"; + case UR_FUNCTION_MEM_BUFFER_CREATE: + os << "UR_FUNCTION_MEM_BUFFER_CREATE"; break; - case UR_RESULT_ERROR_PROGRAM_UNLINKED: - os << "UR_RESULT_ERROR_PROGRAM_UNLINKED"; + case UR_FUNCTION_MEM_RETAIN: + os << "UR_FUNCTION_MEM_RETAIN"; break; - case UR_RESULT_ERROR_OVERLAPPING_REGIONS: - os << "UR_RESULT_ERROR_OVERLAPPING_REGIONS"; + case UR_FUNCTION_MEM_RELEASE: + os << "UR_FUNCTION_MEM_RELEASE"; break; - case UR_RESULT_ERROR_INVALID_HOST_PTR: - os << "UR_RESULT_ERROR_INVALID_HOST_PTR"; + case UR_FUNCTION_MEM_BUFFER_PARTITION: + os << "UR_FUNCTION_MEM_BUFFER_PARTITION"; break; - case UR_RESULT_ERROR_INVALID_USM_SIZE: - os << "UR_RESULT_ERROR_INVALID_USM_SIZE"; + case UR_FUNCTION_MEM_GET_NATIVE_HANDLE: + os << "UR_FUNCTION_MEM_GET_NATIVE_HANDLE"; break; - case UR_RESULT_ERROR_OBJECT_ALLOCATION_FAILURE: - os << "UR_RESULT_ERROR_OBJECT_ALLOCATION_FAILURE"; + case UR_FUNCTION_ENQUEUE_READ_HOST_PIPE: + os << "UR_FUNCTION_ENQUEUE_READ_HOST_PIPE"; break; - case UR_RESULT_ERROR_ADAPTER_SPECIFIC: - os << "UR_RESULT_ERROR_ADAPTER_SPECIFIC"; + case UR_FUNCTION_MEM_GET_INFO: + os << "UR_FUNCTION_MEM_GET_INFO"; break; - case UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_EXP: - os << "UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_EXP"; + case UR_FUNCTION_MEM_IMAGE_GET_INFO: + os << "UR_FUNCTION_MEM_IMAGE_GET_INFO"; break; - case UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_SYNC_POINT_EXP: - os << "UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_SYNC_POINT_EXP"; + case UR_FUNCTION_PLATFORM_GET: + os << "UR_FUNCTION_PLATFORM_GET"; break; - case UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_SYNC_POINT_WAIT_LIST_EXP: - os << "UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_SYNC_POINT_WAIT_LIST_EXP"; + case UR_FUNCTION_PLATFORM_GET_INFO: + os << "UR_FUNCTION_PLATFORM_GET_INFO"; break; - case UR_RESULT_ERROR_UNKNOWN: - os << "UR_RESULT_ERROR_UNKNOWN"; + case UR_FUNCTION_PLATFORM_GET_API_VERSION: + os << "UR_FUNCTION_PLATFORM_GET_API_VERSION"; break; - default: - os << "unknown enumerator"; + + case UR_FUNCTION_PLATFORM_GET_NATIVE_HANDLE: + os << "UR_FUNCTION_PLATFORM_GET_NATIVE_HANDLE"; break; - } - return os; -} -inline std::ostream &operator<<(std::ostream &os, - enum ur_structure_type_t value) { - switch (value) { - case UR_STRUCTURE_TYPE_CONTEXT_PROPERTIES: - os << "UR_STRUCTURE_TYPE_CONTEXT_PROPERTIES"; + case UR_FUNCTION_PLATFORM_CREATE_WITH_NATIVE_HANDLE: + os << "UR_FUNCTION_PLATFORM_CREATE_WITH_NATIVE_HANDLE"; break; - case UR_STRUCTURE_TYPE_IMAGE_DESC: - os << "UR_STRUCTURE_TYPE_IMAGE_DESC"; + case UR_FUNCTION_PROGRAM_CREATE_WITH_IL: + os << "UR_FUNCTION_PROGRAM_CREATE_WITH_IL"; break; - case UR_STRUCTURE_TYPE_BUFFER_PROPERTIES: - os << "UR_STRUCTURE_TYPE_BUFFER_PROPERTIES"; + case UR_FUNCTION_PROGRAM_CREATE_WITH_BINARY: + os << "UR_FUNCTION_PROGRAM_CREATE_WITH_BINARY"; break; - case UR_STRUCTURE_TYPE_BUFFER_REGION: - os << "UR_STRUCTURE_TYPE_BUFFER_REGION"; + case UR_FUNCTION_PROGRAM_BUILD: + os << "UR_FUNCTION_PROGRAM_BUILD"; break; - case UR_STRUCTURE_TYPE_BUFFER_CHANNEL_PROPERTIES: - os << "UR_STRUCTURE_TYPE_BUFFER_CHANNEL_PROPERTIES"; + case UR_FUNCTION_PROGRAM_COMPILE: + os << "UR_FUNCTION_PROGRAM_COMPILE"; break; - case UR_STRUCTURE_TYPE_BUFFER_ALLOC_LOCATION_PROPERTIES: - os << "UR_STRUCTURE_TYPE_BUFFER_ALLOC_LOCATION_PROPERTIES"; + case UR_FUNCTION_PROGRAM_LINK: + os << "UR_FUNCTION_PROGRAM_LINK"; break; - case UR_STRUCTURE_TYPE_PROGRAM_PROPERTIES: - os << "UR_STRUCTURE_TYPE_PROGRAM_PROPERTIES"; + case UR_FUNCTION_PROGRAM_RETAIN: + os << "UR_FUNCTION_PROGRAM_RETAIN"; break; - case UR_STRUCTURE_TYPE_USM_DESC: - os << "UR_STRUCTURE_TYPE_USM_DESC"; + case UR_FUNCTION_PROGRAM_RELEASE: + os << "UR_FUNCTION_PROGRAM_RELEASE"; break; - case UR_STRUCTURE_TYPE_USM_HOST_DESC: - os << "UR_STRUCTURE_TYPE_USM_HOST_DESC"; + case UR_FUNCTION_PROGRAM_GET_FUNCTION_POINTER: + os << "UR_FUNCTION_PROGRAM_GET_FUNCTION_POINTER"; break; - case UR_STRUCTURE_TYPE_USM_DEVICE_DESC: - os << "UR_STRUCTURE_TYPE_USM_DEVICE_DESC"; + case UR_FUNCTION_PROGRAM_GET_INFO: + os << "UR_FUNCTION_PROGRAM_GET_INFO"; break; - case UR_STRUCTURE_TYPE_USM_POOL_DESC: - os << "UR_STRUCTURE_TYPE_USM_POOL_DESC"; + case UR_FUNCTION_PROGRAM_GET_BUILD_INFO: + os << "UR_FUNCTION_PROGRAM_GET_BUILD_INFO"; break; - case UR_STRUCTURE_TYPE_USM_POOL_LIMITS_DESC: - os << "UR_STRUCTURE_TYPE_USM_POOL_LIMITS_DESC"; + case UR_FUNCTION_PROGRAM_SET_SPECIALIZATION_CONSTANTS: + os << "UR_FUNCTION_PROGRAM_SET_SPECIALIZATION_CONSTANTS"; break; - case UR_STRUCTURE_TYPE_DEVICE_BINARY: - os << "UR_STRUCTURE_TYPE_DEVICE_BINARY"; + case UR_FUNCTION_PROGRAM_GET_NATIVE_HANDLE: + os << "UR_FUNCTION_PROGRAM_GET_NATIVE_HANDLE"; break; - case UR_STRUCTURE_TYPE_SAMPLER_DESC: - os << "UR_STRUCTURE_TYPE_SAMPLER_DESC"; + case UR_FUNCTION_PROGRAM_CREATE_WITH_NATIVE_HANDLE: + os << "UR_FUNCTION_PROGRAM_CREATE_WITH_NATIVE_HANDLE"; break; - case UR_STRUCTURE_TYPE_QUEUE_PROPERTIES: - os << "UR_STRUCTURE_TYPE_QUEUE_PROPERTIES"; + case UR_FUNCTION_QUEUE_GET_INFO: + os << "UR_FUNCTION_QUEUE_GET_INFO"; break; - case UR_STRUCTURE_TYPE_QUEUE_INDEX_PROPERTIES: - os << "UR_STRUCTURE_TYPE_QUEUE_INDEX_PROPERTIES"; + case UR_FUNCTION_QUEUE_CREATE: + os << "UR_FUNCTION_QUEUE_CREATE"; break; - case UR_STRUCTURE_TYPE_CONTEXT_NATIVE_PROPERTIES: - os << "UR_STRUCTURE_TYPE_CONTEXT_NATIVE_PROPERTIES"; + case UR_FUNCTION_QUEUE_RETAIN: + os << "UR_FUNCTION_QUEUE_RETAIN"; break; - case UR_STRUCTURE_TYPE_KERNEL_NATIVE_PROPERTIES: - os << "UR_STRUCTURE_TYPE_KERNEL_NATIVE_PROPERTIES"; + case UR_FUNCTION_QUEUE_RELEASE: + os << "UR_FUNCTION_QUEUE_RELEASE"; break; - case UR_STRUCTURE_TYPE_QUEUE_NATIVE_PROPERTIES: - os << "UR_STRUCTURE_TYPE_QUEUE_NATIVE_PROPERTIES"; + case UR_FUNCTION_QUEUE_GET_NATIVE_HANDLE: + os << "UR_FUNCTION_QUEUE_GET_NATIVE_HANDLE"; break; - case UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES: - os << "UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES"; + case UR_FUNCTION_QUEUE_CREATE_WITH_NATIVE_HANDLE: + os << "UR_FUNCTION_QUEUE_CREATE_WITH_NATIVE_HANDLE"; break; - case UR_STRUCTURE_TYPE_EVENT_NATIVE_PROPERTIES: - os << "UR_STRUCTURE_TYPE_EVENT_NATIVE_PROPERTIES"; + case UR_FUNCTION_QUEUE_FINISH: + os << "UR_FUNCTION_QUEUE_FINISH"; break; - case UR_STRUCTURE_TYPE_PLATFORM_NATIVE_PROPERTIES: - os << "UR_STRUCTURE_TYPE_PLATFORM_NATIVE_PROPERTIES"; + case UR_FUNCTION_QUEUE_FLUSH: + os << "UR_FUNCTION_QUEUE_FLUSH"; break; - case UR_STRUCTURE_TYPE_DEVICE_NATIVE_PROPERTIES: - os << "UR_STRUCTURE_TYPE_DEVICE_NATIVE_PROPERTIES"; + case UR_FUNCTION_INIT: + os << "UR_FUNCTION_INIT"; break; - case UR_STRUCTURE_TYPE_PROGRAM_NATIVE_PROPERTIES: - os << "UR_STRUCTURE_TYPE_PROGRAM_NATIVE_PROPERTIES"; + case UR_FUNCTION_TEAR_DOWN: + os << "UR_FUNCTION_TEAR_DOWN"; break; - case UR_STRUCTURE_TYPE_SAMPLER_NATIVE_PROPERTIES: - os << "UR_STRUCTURE_TYPE_SAMPLER_NATIVE_PROPERTIES"; + case UR_FUNCTION_SAMPLER_CREATE: + os << "UR_FUNCTION_SAMPLER_CREATE"; break; - case UR_STRUCTURE_TYPE_QUEUE_NATIVE_DESC: - os << "UR_STRUCTURE_TYPE_QUEUE_NATIVE_DESC"; + case UR_FUNCTION_SAMPLER_RETAIN: + os << "UR_FUNCTION_SAMPLER_RETAIN"; break; - case UR_STRUCTURE_TYPE_DEVICE_PARTITION_PROPERTIES: - os << "UR_STRUCTURE_TYPE_DEVICE_PARTITION_PROPERTIES"; + case UR_FUNCTION_SAMPLER_RELEASE: + os << "UR_FUNCTION_SAMPLER_RELEASE"; break; - case UR_STRUCTURE_TYPE_KERNEL_ARG_MEM_OBJ_PROPERTIES: - os << "UR_STRUCTURE_TYPE_KERNEL_ARG_MEM_OBJ_PROPERTIES"; + case UR_FUNCTION_SAMPLER_GET_INFO: + os << "UR_FUNCTION_SAMPLER_GET_INFO"; break; - case UR_STRUCTURE_TYPE_PHYSICAL_MEM_PROPERTIES: - os << "UR_STRUCTURE_TYPE_PHYSICAL_MEM_PROPERTIES"; + case UR_FUNCTION_SAMPLER_GET_NATIVE_HANDLE: + os << "UR_FUNCTION_SAMPLER_GET_NATIVE_HANDLE"; break; - case UR_STRUCTURE_TYPE_KERNEL_ARG_POINTER_PROPERTIES: - os << "UR_STRUCTURE_TYPE_KERNEL_ARG_POINTER_PROPERTIES"; + case UR_FUNCTION_SAMPLER_CREATE_WITH_NATIVE_HANDLE: + os << "UR_FUNCTION_SAMPLER_CREATE_WITH_NATIVE_HANDLE"; break; - case UR_STRUCTURE_TYPE_KERNEL_ARG_SAMPLER_PROPERTIES: - os << "UR_STRUCTURE_TYPE_KERNEL_ARG_SAMPLER_PROPERTIES"; + case UR_FUNCTION_USM_HOST_ALLOC: + os << "UR_FUNCTION_USM_HOST_ALLOC"; break; - case UR_STRUCTURE_TYPE_KERNEL_EXEC_INFO_PROPERTIES: - os << "UR_STRUCTURE_TYPE_KERNEL_EXEC_INFO_PROPERTIES"; + case UR_FUNCTION_USM_DEVICE_ALLOC: + os << "UR_FUNCTION_USM_DEVICE_ALLOC"; break; - case UR_STRUCTURE_TYPE_KERNEL_ARG_VALUE_PROPERTIES: - os << "UR_STRUCTURE_TYPE_KERNEL_ARG_VALUE_PROPERTIES"; + case UR_FUNCTION_USM_SHARED_ALLOC: + os << "UR_FUNCTION_USM_SHARED_ALLOC"; break; - case UR_STRUCTURE_TYPE_KERNEL_ARG_LOCAL_PROPERTIES: - os << "UR_STRUCTURE_TYPE_KERNEL_ARG_LOCAL_PROPERTIES"; + case UR_FUNCTION_USM_FREE: + os << "UR_FUNCTION_USM_FREE"; break; - case UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC: - os << "UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC"; + case UR_FUNCTION_USM_GET_MEM_ALLOC_INFO: + os << "UR_FUNCTION_USM_GET_MEM_ALLOC_INFO"; break; - case UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES: - os << "UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES"; + case UR_FUNCTION_USM_POOL_CREATE: + os << "UR_FUNCTION_USM_POOL_CREATE"; break; - default: - os << "unknown enumerator"; + + case UR_FUNCTION_COMMAND_BUFFER_CREATE_EXP: + os << "UR_FUNCTION_COMMAND_BUFFER_CREATE_EXP"; break; - } - return os; -} -namespace ur_params { -inline void serializeStruct(std::ostream &os, const void *ptr) { - if (ptr == NULL) { - ur_params::serializePtr(os, ptr); - return; - } - enum ur_structure_type_t *value = (enum ur_structure_type_t *)ptr; - switch (*value) { + case UR_FUNCTION_PLATFORM_GET_BACKEND_OPTION: + os << "UR_FUNCTION_PLATFORM_GET_BACKEND_OPTION"; + break; - case UR_STRUCTURE_TYPE_CONTEXT_PROPERTIES: { - const ur_context_properties_t *pstruct = - (const ur_context_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_FUNCTION_MEM_BUFFER_CREATE_WITH_NATIVE_HANDLE: + os << "UR_FUNCTION_MEM_BUFFER_CREATE_WITH_NATIVE_HANDLE"; + break; - case UR_STRUCTURE_TYPE_IMAGE_DESC: { - const ur_image_desc_t *pstruct = (const ur_image_desc_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_FUNCTION_MEM_IMAGE_CREATE_WITH_NATIVE_HANDLE: + os << "UR_FUNCTION_MEM_IMAGE_CREATE_WITH_NATIVE_HANDLE"; + break; - case UR_STRUCTURE_TYPE_BUFFER_PROPERTIES: { - const ur_buffer_properties_t *pstruct = - (const ur_buffer_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_FUNCTION_ENQUEUE_WRITE_HOST_PIPE: + os << "UR_FUNCTION_ENQUEUE_WRITE_HOST_PIPE"; + break; - case UR_STRUCTURE_TYPE_BUFFER_REGION: { - const ur_buffer_region_t *pstruct = (const ur_buffer_region_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_FUNCTION_USM_POOL_RETAIN: + os << "UR_FUNCTION_USM_POOL_RETAIN"; + break; - case UR_STRUCTURE_TYPE_BUFFER_CHANNEL_PROPERTIES: { + case UR_FUNCTION_USM_POOL_RELEASE: + os << "UR_FUNCTION_USM_POOL_RELEASE"; + break; + + case UR_FUNCTION_USM_POOL_GET_INFO: + os << "UR_FUNCTION_USM_POOL_GET_INFO"; + break; + + case UR_FUNCTION_COMMAND_BUFFER_RETAIN_EXP: + os << "UR_FUNCTION_COMMAND_BUFFER_RETAIN_EXP"; + break; + + case UR_FUNCTION_COMMAND_BUFFER_RELEASE_EXP: + os << "UR_FUNCTION_COMMAND_BUFFER_RELEASE_EXP"; + break; + + case UR_FUNCTION_COMMAND_BUFFER_FINALIZE_EXP: + os << "UR_FUNCTION_COMMAND_BUFFER_FINALIZE_EXP"; + break; + + case UR_FUNCTION_COMMAND_BUFFER_APPEND_KERNEL_LAUNCH_EXP: + os << "UR_FUNCTION_COMMAND_BUFFER_APPEND_KERNEL_LAUNCH_EXP"; + break; + + case UR_FUNCTION_COMMAND_BUFFER_ENQUEUE_EXP: + os << "UR_FUNCTION_COMMAND_BUFFER_ENQUEUE_EXP"; + break; + + case UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMCPY_USM_EXP: + os << "UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMCPY_USM_EXP"; + break; + + case UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_COPY_EXP: + os << "UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_COPY_EXP"; + break; + + case UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_COPY_RECT_EXP: + os << "UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_COPY_RECT_EXP"; + break; + + case UR_FUNCTION_USM_PITCHED_ALLOC_EXP: + os << "UR_FUNCTION_USM_PITCHED_ALLOC_EXP"; + break; + + case UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_HANDLE_DESTROY_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_HANDLE_DESTROY_EXP"; + break; + + case UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_HANDLE_DESTROY_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_HANDLE_DESTROY_EXP"; + break; + + case UR_FUNCTION_BINDLESS_IMAGES_IMAGE_ALLOCATE_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_IMAGE_ALLOCATE_EXP"; + break; + + case UR_FUNCTION_BINDLESS_IMAGES_IMAGE_FREE_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_IMAGE_FREE_EXP"; + break; + + case UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_CREATE_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_CREATE_EXP"; + break; + + case UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_CREATE_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_CREATE_EXP"; + break; + + case UR_FUNCTION_BINDLESS_IMAGES_IMAGE_COPY_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_IMAGE_COPY_EXP"; + break; + + case UR_FUNCTION_BINDLESS_IMAGES_IMAGE_GET_INFO_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_IMAGE_GET_INFO_EXP"; + break; + + case UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_GET_LEVEL_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_GET_LEVEL_EXP"; + break; + + case UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_FREE_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_FREE_EXP"; + break; + + case UR_FUNCTION_BINDLESS_IMAGES_IMPORT_OPAQUE_FD_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_IMPORT_OPAQUE_FD_EXP"; + break; + + case UR_FUNCTION_BINDLESS_IMAGES_MAP_EXTERNAL_ARRAY_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_MAP_EXTERNAL_ARRAY_EXP"; + break; + + case UR_FUNCTION_BINDLESS_IMAGES_RELEASE_INTEROP_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_RELEASE_INTEROP_EXP"; + break; + + case UR_FUNCTION_BINDLESS_IMAGES_IMPORT_EXTERNAL_SEMAPHORE_OPAQUE_FD_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_IMPORT_EXTERNAL_SEMAPHORE_OPAQUE_FD_" + "EXP"; + break; + + case UR_FUNCTION_BINDLESS_IMAGES_DESTROY_EXTERNAL_SEMAPHORE_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_DESTROY_EXTERNAL_SEMAPHORE_EXP"; + break; + + case UR_FUNCTION_BINDLESS_IMAGES_WAIT_EXTERNAL_SEMAPHORE_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_WAIT_EXTERNAL_SEMAPHORE_EXP"; + break; + + case UR_FUNCTION_BINDLESS_IMAGES_SIGNAL_EXTERNAL_SEMAPHORE_EXP: + os << "UR_FUNCTION_BINDLESS_IMAGES_SIGNAL_EXTERNAL_SEMAPHORE_EXP"; + break; + + case UR_FUNCTION_ENQUEUE_USM_FILL_2D: + os << "UR_FUNCTION_ENQUEUE_USM_FILL_2D"; + break; + + case UR_FUNCTION_ENQUEUE_USM_MEMCPY_2D: + os << "UR_FUNCTION_ENQUEUE_USM_MEMCPY_2D"; + break; + + case UR_FUNCTION_VIRTUAL_MEM_GRANULARITY_GET_INFO: + os << "UR_FUNCTION_VIRTUAL_MEM_GRANULARITY_GET_INFO"; + break; + + case UR_FUNCTION_VIRTUAL_MEM_RESERVE: + os << "UR_FUNCTION_VIRTUAL_MEM_RESERVE"; + break; + + case UR_FUNCTION_VIRTUAL_MEM_FREE: + os << "UR_FUNCTION_VIRTUAL_MEM_FREE"; + break; + + case UR_FUNCTION_VIRTUAL_MEM_MAP: + os << "UR_FUNCTION_VIRTUAL_MEM_MAP"; + break; + + case UR_FUNCTION_VIRTUAL_MEM_UNMAP: + os << "UR_FUNCTION_VIRTUAL_MEM_UNMAP"; + break; + + case UR_FUNCTION_VIRTUAL_MEM_SET_ACCESS: + os << "UR_FUNCTION_VIRTUAL_MEM_SET_ACCESS"; + break; + + case UR_FUNCTION_VIRTUAL_MEM_GET_INFO: + os << "UR_FUNCTION_VIRTUAL_MEM_GET_INFO"; + break; + + case UR_FUNCTION_PHYSICAL_MEM_CREATE: + os << "UR_FUNCTION_PHYSICAL_MEM_CREATE"; + break; + + case UR_FUNCTION_PHYSICAL_MEM_RETAIN: + os << "UR_FUNCTION_PHYSICAL_MEM_RETAIN"; + break; + + case UR_FUNCTION_PHYSICAL_MEM_RELEASE: + os << "UR_FUNCTION_PHYSICAL_MEM_RELEASE"; + break; + + case UR_FUNCTION_USM_IMPORT_EXP: + os << "UR_FUNCTION_USM_IMPORT_EXP"; + break; + + case UR_FUNCTION_USM_RELEASE_EXP: + os << "UR_FUNCTION_USM_RELEASE_EXP"; + break; + + case UR_FUNCTION_USM_P2P_ENABLE_PEER_ACCESS_EXP: + os << "UR_FUNCTION_USM_P2P_ENABLE_PEER_ACCESS_EXP"; + break; + + case UR_FUNCTION_USM_P2P_DISABLE_PEER_ACCESS_EXP: + os << "UR_FUNCTION_USM_P2P_DISABLE_PEER_ACCESS_EXP"; + break; + + case UR_FUNCTION_USM_P2P_PEER_ACCESS_GET_INFO_EXP: + os << "UR_FUNCTION_USM_P2P_PEER_ACCESS_GET_INFO_EXP"; + break; + + case UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_WRITE_EXP: + os << "UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_WRITE_EXP"; + break; + + case UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_READ_EXP: + os << "UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_READ_EXP"; + break; + + case UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_WRITE_RECT_EXP: + os << "UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_WRITE_RECT_EXP"; + break; + + case UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_READ_RECT_EXP: + os << "UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_READ_RECT_EXP"; + break; + + case UR_FUNCTION_LOADER_CONFIG_CREATE: + os << "UR_FUNCTION_LOADER_CONFIG_CREATE"; + break; + + case UR_FUNCTION_LOADER_CONFIG_RELEASE: + os << "UR_FUNCTION_LOADER_CONFIG_RELEASE"; + break; + + case UR_FUNCTION_LOADER_CONFIG_RETAIN: + os << "UR_FUNCTION_LOADER_CONFIG_RETAIN"; + break; + + case UR_FUNCTION_LOADER_CONFIG_GET_INFO: + os << "UR_FUNCTION_LOADER_CONFIG_GET_INFO"; + break; + + case UR_FUNCTION_LOADER_CONFIG_ENABLE_LAYER: + os << "UR_FUNCTION_LOADER_CONFIG_ENABLE_LAYER"; + break; + + case UR_FUNCTION_ADAPTER_RELEASE: + os << "UR_FUNCTION_ADAPTER_RELEASE"; + break; + + case UR_FUNCTION_ADAPTER_GET: + os << "UR_FUNCTION_ADAPTER_GET"; + break; + + case UR_FUNCTION_ADAPTER_RETAIN: + os << "UR_FUNCTION_ADAPTER_RETAIN"; + break; + + case UR_FUNCTION_ADAPTER_GET_LAST_ERROR: + os << "UR_FUNCTION_ADAPTER_GET_LAST_ERROR"; + break; + + case UR_FUNCTION_ADAPTER_GET_INFO: + os << "UR_FUNCTION_ADAPTER_GET_INFO"; + break; + default: + os << "unknown enumerator"; + break; + } + return os; +} +inline std::ostream &operator<<(std::ostream &os, + enum ur_structure_type_t value) { + switch (value) { + + case UR_STRUCTURE_TYPE_CONTEXT_PROPERTIES: + os << "UR_STRUCTURE_TYPE_CONTEXT_PROPERTIES"; + break; + + case UR_STRUCTURE_TYPE_IMAGE_DESC: + os << "UR_STRUCTURE_TYPE_IMAGE_DESC"; + break; + + case UR_STRUCTURE_TYPE_BUFFER_PROPERTIES: + os << "UR_STRUCTURE_TYPE_BUFFER_PROPERTIES"; + break; + + case UR_STRUCTURE_TYPE_BUFFER_REGION: + os << "UR_STRUCTURE_TYPE_BUFFER_REGION"; + break; + + case UR_STRUCTURE_TYPE_BUFFER_CHANNEL_PROPERTIES: + os << "UR_STRUCTURE_TYPE_BUFFER_CHANNEL_PROPERTIES"; + break; + + case UR_STRUCTURE_TYPE_BUFFER_ALLOC_LOCATION_PROPERTIES: + os << "UR_STRUCTURE_TYPE_BUFFER_ALLOC_LOCATION_PROPERTIES"; + break; + + case UR_STRUCTURE_TYPE_PROGRAM_PROPERTIES: + os << "UR_STRUCTURE_TYPE_PROGRAM_PROPERTIES"; + break; + + case UR_STRUCTURE_TYPE_USM_DESC: + os << "UR_STRUCTURE_TYPE_USM_DESC"; + break; + + case UR_STRUCTURE_TYPE_USM_HOST_DESC: + os << "UR_STRUCTURE_TYPE_USM_HOST_DESC"; + break; + + case UR_STRUCTURE_TYPE_USM_DEVICE_DESC: + os << "UR_STRUCTURE_TYPE_USM_DEVICE_DESC"; + break; + + case UR_STRUCTURE_TYPE_USM_POOL_DESC: + os << "UR_STRUCTURE_TYPE_USM_POOL_DESC"; + break; + + case UR_STRUCTURE_TYPE_USM_POOL_LIMITS_DESC: + os << "UR_STRUCTURE_TYPE_USM_POOL_LIMITS_DESC"; + break; + + case UR_STRUCTURE_TYPE_DEVICE_BINARY: + os << "UR_STRUCTURE_TYPE_DEVICE_BINARY"; + break; + + case UR_STRUCTURE_TYPE_SAMPLER_DESC: + os << "UR_STRUCTURE_TYPE_SAMPLER_DESC"; + break; + + case UR_STRUCTURE_TYPE_QUEUE_PROPERTIES: + os << "UR_STRUCTURE_TYPE_QUEUE_PROPERTIES"; + break; + + case UR_STRUCTURE_TYPE_QUEUE_INDEX_PROPERTIES: + os << "UR_STRUCTURE_TYPE_QUEUE_INDEX_PROPERTIES"; + break; + + case UR_STRUCTURE_TYPE_CONTEXT_NATIVE_PROPERTIES: + os << "UR_STRUCTURE_TYPE_CONTEXT_NATIVE_PROPERTIES"; + break; + + case UR_STRUCTURE_TYPE_KERNEL_NATIVE_PROPERTIES: + os << "UR_STRUCTURE_TYPE_KERNEL_NATIVE_PROPERTIES"; + break; + + case UR_STRUCTURE_TYPE_QUEUE_NATIVE_PROPERTIES: + os << "UR_STRUCTURE_TYPE_QUEUE_NATIVE_PROPERTIES"; + break; + + case UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES: + os << "UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES"; + break; + + case UR_STRUCTURE_TYPE_EVENT_NATIVE_PROPERTIES: + os << "UR_STRUCTURE_TYPE_EVENT_NATIVE_PROPERTIES"; + break; + + case UR_STRUCTURE_TYPE_PLATFORM_NATIVE_PROPERTIES: + os << "UR_STRUCTURE_TYPE_PLATFORM_NATIVE_PROPERTIES"; + break; + + case UR_STRUCTURE_TYPE_DEVICE_NATIVE_PROPERTIES: + os << "UR_STRUCTURE_TYPE_DEVICE_NATIVE_PROPERTIES"; + break; + + case UR_STRUCTURE_TYPE_PROGRAM_NATIVE_PROPERTIES: + os << "UR_STRUCTURE_TYPE_PROGRAM_NATIVE_PROPERTIES"; + break; + + case UR_STRUCTURE_TYPE_SAMPLER_NATIVE_PROPERTIES: + os << "UR_STRUCTURE_TYPE_SAMPLER_NATIVE_PROPERTIES"; + break; + + case UR_STRUCTURE_TYPE_QUEUE_NATIVE_DESC: + os << "UR_STRUCTURE_TYPE_QUEUE_NATIVE_DESC"; + break; + + case UR_STRUCTURE_TYPE_DEVICE_PARTITION_PROPERTIES: + os << "UR_STRUCTURE_TYPE_DEVICE_PARTITION_PROPERTIES"; + break; + + case UR_STRUCTURE_TYPE_KERNEL_ARG_MEM_OBJ_PROPERTIES: + os << "UR_STRUCTURE_TYPE_KERNEL_ARG_MEM_OBJ_PROPERTIES"; + break; + + case UR_STRUCTURE_TYPE_PHYSICAL_MEM_PROPERTIES: + os << "UR_STRUCTURE_TYPE_PHYSICAL_MEM_PROPERTIES"; + break; + + case UR_STRUCTURE_TYPE_KERNEL_ARG_POINTER_PROPERTIES: + os << "UR_STRUCTURE_TYPE_KERNEL_ARG_POINTER_PROPERTIES"; + break; + + case UR_STRUCTURE_TYPE_KERNEL_ARG_SAMPLER_PROPERTIES: + os << "UR_STRUCTURE_TYPE_KERNEL_ARG_SAMPLER_PROPERTIES"; + break; + + case UR_STRUCTURE_TYPE_KERNEL_EXEC_INFO_PROPERTIES: + os << "UR_STRUCTURE_TYPE_KERNEL_EXEC_INFO_PROPERTIES"; + break; + + case UR_STRUCTURE_TYPE_KERNEL_ARG_VALUE_PROPERTIES: + os << "UR_STRUCTURE_TYPE_KERNEL_ARG_VALUE_PROPERTIES"; + break; + + case UR_STRUCTURE_TYPE_KERNEL_ARG_LOCAL_PROPERTIES: + os << "UR_STRUCTURE_TYPE_KERNEL_ARG_LOCAL_PROPERTIES"; + break; + + case UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC: + os << "UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC"; + break; + + case UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES: + os << "UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES"; + break; + + case UR_STRUCTURE_TYPE_EXP_INTEROP_MEM_DESC: + os << "UR_STRUCTURE_TYPE_EXP_INTEROP_MEM_DESC"; + break; + + case UR_STRUCTURE_TYPE_EXP_INTEROP_SEMAPHORE_DESC: + os << "UR_STRUCTURE_TYPE_EXP_INTEROP_SEMAPHORE_DESC"; + break; + + case UR_STRUCTURE_TYPE_EXP_FILE_DESCRIPTOR: + os << "UR_STRUCTURE_TYPE_EXP_FILE_DESCRIPTOR"; + break; + + case UR_STRUCTURE_TYPE_EXP_WIN32_HANDLE: + os << "UR_STRUCTURE_TYPE_EXP_WIN32_HANDLE"; + break; + default: + os << "unknown enumerator"; + break; + } + return os; +} +namespace ur_params { +inline void serializeStruct(std::ostream &os, const void *ptr) { + if (ptr == NULL) { + ur_params::serializePtr(os, ptr); + return; + } + + enum ur_structure_type_t *value = (enum ur_structure_type_t *)ptr; + switch (*value) { + + case UR_STRUCTURE_TYPE_CONTEXT_PROPERTIES: { + const ur_context_properties_t *pstruct = + (const ur_context_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + + case UR_STRUCTURE_TYPE_IMAGE_DESC: { + const ur_image_desc_t *pstruct = (const ur_image_desc_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + + case UR_STRUCTURE_TYPE_BUFFER_PROPERTIES: { + const ur_buffer_properties_t *pstruct = + (const ur_buffer_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + + case UR_STRUCTURE_TYPE_BUFFER_REGION: { + const ur_buffer_region_t *pstruct = (const ur_buffer_region_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + + case UR_STRUCTURE_TYPE_BUFFER_CHANNEL_PROPERTIES: { const ur_buffer_channel_properties_t *pstruct = (const ur_buffer_channel_properties_t *)ptr; ur_params::serializePtr(os, pstruct); @@ -886,185 +1331,509 @@ inline void serializeStruct(std::ostream &os, const void *ptr) { ur_params::serializePtr(os, pstruct); } break; - case UR_STRUCTURE_TYPE_PROGRAM_PROPERTIES: { - const ur_program_properties_t *pstruct = - (const ur_program_properties_t *)ptr; + case UR_STRUCTURE_TYPE_PROGRAM_PROPERTIES: { + const ur_program_properties_t *pstruct = + (const ur_program_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + + case UR_STRUCTURE_TYPE_USM_DESC: { + const ur_usm_desc_t *pstruct = (const ur_usm_desc_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + + case UR_STRUCTURE_TYPE_USM_HOST_DESC: { + const ur_usm_host_desc_t *pstruct = (const ur_usm_host_desc_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + + case UR_STRUCTURE_TYPE_USM_DEVICE_DESC: { + const ur_usm_device_desc_t *pstruct = (const ur_usm_device_desc_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + + case UR_STRUCTURE_TYPE_USM_POOL_DESC: { + const ur_usm_pool_desc_t *pstruct = (const ur_usm_pool_desc_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + + case UR_STRUCTURE_TYPE_USM_POOL_LIMITS_DESC: { + const ur_usm_pool_limits_desc_t *pstruct = + (const ur_usm_pool_limits_desc_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + + case UR_STRUCTURE_TYPE_DEVICE_BINARY: { + const ur_device_binary_t *pstruct = (const ur_device_binary_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + + case UR_STRUCTURE_TYPE_SAMPLER_DESC: { + const ur_sampler_desc_t *pstruct = (const ur_sampler_desc_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + + case UR_STRUCTURE_TYPE_QUEUE_PROPERTIES: { + const ur_queue_properties_t *pstruct = + (const ur_queue_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + + case UR_STRUCTURE_TYPE_QUEUE_INDEX_PROPERTIES: { + const ur_queue_index_properties_t *pstruct = + (const ur_queue_index_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + + case UR_STRUCTURE_TYPE_CONTEXT_NATIVE_PROPERTIES: { + const ur_context_native_properties_t *pstruct = + (const ur_context_native_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + + case UR_STRUCTURE_TYPE_KERNEL_NATIVE_PROPERTIES: { + const ur_kernel_native_properties_t *pstruct = + (const ur_kernel_native_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + + case UR_STRUCTURE_TYPE_QUEUE_NATIVE_PROPERTIES: { + const ur_queue_native_properties_t *pstruct = + (const ur_queue_native_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + + case UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES: { + const ur_mem_native_properties_t *pstruct = + (const ur_mem_native_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + + case UR_STRUCTURE_TYPE_EVENT_NATIVE_PROPERTIES: { + const ur_event_native_properties_t *pstruct = + (const ur_event_native_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + + case UR_STRUCTURE_TYPE_PLATFORM_NATIVE_PROPERTIES: { + const ur_platform_native_properties_t *pstruct = + (const ur_platform_native_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + + case UR_STRUCTURE_TYPE_DEVICE_NATIVE_PROPERTIES: { + const ur_device_native_properties_t *pstruct = + (const ur_device_native_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + + case UR_STRUCTURE_TYPE_PROGRAM_NATIVE_PROPERTIES: { + const ur_program_native_properties_t *pstruct = + (const ur_program_native_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + + case UR_STRUCTURE_TYPE_SAMPLER_NATIVE_PROPERTIES: { + const ur_sampler_native_properties_t *pstruct = + (const ur_sampler_native_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + + case UR_STRUCTURE_TYPE_QUEUE_NATIVE_DESC: { + const ur_queue_native_desc_t *pstruct = + (const ur_queue_native_desc_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + + case UR_STRUCTURE_TYPE_DEVICE_PARTITION_PROPERTIES: { + const ur_device_partition_properties_t *pstruct = + (const ur_device_partition_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + + case UR_STRUCTURE_TYPE_KERNEL_ARG_MEM_OBJ_PROPERTIES: { + const ur_kernel_arg_mem_obj_properties_t *pstruct = + (const ur_kernel_arg_mem_obj_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + + case UR_STRUCTURE_TYPE_PHYSICAL_MEM_PROPERTIES: { + const ur_physical_mem_properties_t *pstruct = + (const ur_physical_mem_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + + case UR_STRUCTURE_TYPE_KERNEL_ARG_POINTER_PROPERTIES: { + const ur_kernel_arg_pointer_properties_t *pstruct = + (const ur_kernel_arg_pointer_properties_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; + + case UR_STRUCTURE_TYPE_KERNEL_ARG_SAMPLER_PROPERTIES: { + const ur_kernel_arg_sampler_properties_t *pstruct = + (const ur_kernel_arg_sampler_properties_t *)ptr; ur_params::serializePtr(os, pstruct); } break; - case UR_STRUCTURE_TYPE_USM_DESC: { - const ur_usm_desc_t *pstruct = (const ur_usm_desc_t *)ptr; + case UR_STRUCTURE_TYPE_KERNEL_EXEC_INFO_PROPERTIES: { + const ur_kernel_exec_info_properties_t *pstruct = + (const ur_kernel_exec_info_properties_t *)ptr; ur_params::serializePtr(os, pstruct); } break; - case UR_STRUCTURE_TYPE_USM_HOST_DESC: { - const ur_usm_host_desc_t *pstruct = (const ur_usm_host_desc_t *)ptr; + case UR_STRUCTURE_TYPE_KERNEL_ARG_VALUE_PROPERTIES: { + const ur_kernel_arg_value_properties_t *pstruct = + (const ur_kernel_arg_value_properties_t *)ptr; ur_params::serializePtr(os, pstruct); } break; - case UR_STRUCTURE_TYPE_USM_DEVICE_DESC: { - const ur_usm_device_desc_t *pstruct = (const ur_usm_device_desc_t *)ptr; + case UR_STRUCTURE_TYPE_KERNEL_ARG_LOCAL_PROPERTIES: { + const ur_kernel_arg_local_properties_t *pstruct = + (const ur_kernel_arg_local_properties_t *)ptr; ur_params::serializePtr(os, pstruct); } break; - case UR_STRUCTURE_TYPE_USM_POOL_DESC: { - const ur_usm_pool_desc_t *pstruct = (const ur_usm_pool_desc_t *)ptr; + case UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC: { + const ur_exp_command_buffer_desc_t *pstruct = + (const ur_exp_command_buffer_desc_t *)ptr; ur_params::serializePtr(os, pstruct); } break; - case UR_STRUCTURE_TYPE_USM_POOL_LIMITS_DESC: { - const ur_usm_pool_limits_desc_t *pstruct = - (const ur_usm_pool_limits_desc_t *)ptr; + case UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES: { + const ur_exp_sampler_mip_properties_t *pstruct = + (const ur_exp_sampler_mip_properties_t *)ptr; ur_params::serializePtr(os, pstruct); } break; - case UR_STRUCTURE_TYPE_DEVICE_BINARY: { - const ur_device_binary_t *pstruct = (const ur_device_binary_t *)ptr; + case UR_STRUCTURE_TYPE_EXP_INTEROP_MEM_DESC: { + const ur_exp_interop_mem_desc_t *pstruct = + (const ur_exp_interop_mem_desc_t *)ptr; ur_params::serializePtr(os, pstruct); } break; - case UR_STRUCTURE_TYPE_SAMPLER_DESC: { - const ur_sampler_desc_t *pstruct = (const ur_sampler_desc_t *)ptr; + case UR_STRUCTURE_TYPE_EXP_INTEROP_SEMAPHORE_DESC: { + const ur_exp_interop_semaphore_desc_t *pstruct = + (const ur_exp_interop_semaphore_desc_t *)ptr; ur_params::serializePtr(os, pstruct); } break; - case UR_STRUCTURE_TYPE_QUEUE_PROPERTIES: { - const ur_queue_properties_t *pstruct = - (const ur_queue_properties_t *)ptr; + case UR_STRUCTURE_TYPE_EXP_FILE_DESCRIPTOR: { + const ur_exp_file_descriptor_t *pstruct = + (const ur_exp_file_descriptor_t *)ptr; ur_params::serializePtr(os, pstruct); } break; - case UR_STRUCTURE_TYPE_QUEUE_INDEX_PROPERTIES: { - const ur_queue_properties_t *pstruct = - (const ur_queue_properties_t *)ptr; + case UR_STRUCTURE_TYPE_EXP_WIN32_HANDLE: { + const ur_exp_win32_handle_t *pstruct = + (const ur_exp_win32_handle_t *)ptr; ur_params::serializePtr(os, pstruct); } break; + default: + os << "unknown enumerator"; + break; + } +} +} // namespace ur_params +inline std::ostream &operator<<(std::ostream &os, enum ur_result_t value) { + switch (value) { + + case UR_RESULT_SUCCESS: + os << "UR_RESULT_SUCCESS"; + break; + + case UR_RESULT_ERROR_INVALID_OPERATION: + os << "UR_RESULT_ERROR_INVALID_OPERATION"; + break; + + case UR_RESULT_ERROR_INVALID_QUEUE_PROPERTIES: + os << "UR_RESULT_ERROR_INVALID_QUEUE_PROPERTIES"; + break; + + case UR_RESULT_ERROR_INVALID_QUEUE: + os << "UR_RESULT_ERROR_INVALID_QUEUE"; + break; + + case UR_RESULT_ERROR_INVALID_VALUE: + os << "UR_RESULT_ERROR_INVALID_VALUE"; + break; + + case UR_RESULT_ERROR_INVALID_CONTEXT: + os << "UR_RESULT_ERROR_INVALID_CONTEXT"; + break; + + case UR_RESULT_ERROR_INVALID_PLATFORM: + os << "UR_RESULT_ERROR_INVALID_PLATFORM"; + break; + + case UR_RESULT_ERROR_INVALID_BINARY: + os << "UR_RESULT_ERROR_INVALID_BINARY"; + break; + + case UR_RESULT_ERROR_INVALID_PROGRAM: + os << "UR_RESULT_ERROR_INVALID_PROGRAM"; + break; + + case UR_RESULT_ERROR_INVALID_SAMPLER: + os << "UR_RESULT_ERROR_INVALID_SAMPLER"; + break; + + case UR_RESULT_ERROR_INVALID_BUFFER_SIZE: + os << "UR_RESULT_ERROR_INVALID_BUFFER_SIZE"; + break; + + case UR_RESULT_ERROR_INVALID_MEM_OBJECT: + os << "UR_RESULT_ERROR_INVALID_MEM_OBJECT"; + break; + + case UR_RESULT_ERROR_INVALID_EVENT: + os << "UR_RESULT_ERROR_INVALID_EVENT"; + break; + + case UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST: + os << "UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST"; + break; + + case UR_RESULT_ERROR_MISALIGNED_SUB_BUFFER_OFFSET: + os << "UR_RESULT_ERROR_MISALIGNED_SUB_BUFFER_OFFSET"; + break; + + case UR_RESULT_ERROR_INVALID_WORK_GROUP_SIZE: + os << "UR_RESULT_ERROR_INVALID_WORK_GROUP_SIZE"; + break; + + case UR_RESULT_ERROR_COMPILER_NOT_AVAILABLE: + os << "UR_RESULT_ERROR_COMPILER_NOT_AVAILABLE"; + break; + + case UR_RESULT_ERROR_PROFILING_INFO_NOT_AVAILABLE: + os << "UR_RESULT_ERROR_PROFILING_INFO_NOT_AVAILABLE"; + break; + + case UR_RESULT_ERROR_DEVICE_NOT_FOUND: + os << "UR_RESULT_ERROR_DEVICE_NOT_FOUND"; + break; + + case UR_RESULT_ERROR_INVALID_DEVICE: + os << "UR_RESULT_ERROR_INVALID_DEVICE"; + break; + + case UR_RESULT_ERROR_DEVICE_LOST: + os << "UR_RESULT_ERROR_DEVICE_LOST"; + break; + + case UR_RESULT_ERROR_DEVICE_REQUIRES_RESET: + os << "UR_RESULT_ERROR_DEVICE_REQUIRES_RESET"; + break; + + case UR_RESULT_ERROR_DEVICE_IN_LOW_POWER_STATE: + os << "UR_RESULT_ERROR_DEVICE_IN_LOW_POWER_STATE"; + break; + + case UR_RESULT_ERROR_DEVICE_PARTITION_FAILED: + os << "UR_RESULT_ERROR_DEVICE_PARTITION_FAILED"; + break; + + case UR_RESULT_ERROR_INVALID_DEVICE_PARTITION_COUNT: + os << "UR_RESULT_ERROR_INVALID_DEVICE_PARTITION_COUNT"; + break; + + case UR_RESULT_ERROR_INVALID_WORK_ITEM_SIZE: + os << "UR_RESULT_ERROR_INVALID_WORK_ITEM_SIZE"; + break; + + case UR_RESULT_ERROR_INVALID_WORK_DIMENSION: + os << "UR_RESULT_ERROR_INVALID_WORK_DIMENSION"; + break; + + case UR_RESULT_ERROR_INVALID_KERNEL_ARGS: + os << "UR_RESULT_ERROR_INVALID_KERNEL_ARGS"; + break; + + case UR_RESULT_ERROR_INVALID_KERNEL: + os << "UR_RESULT_ERROR_INVALID_KERNEL"; + break; + + case UR_RESULT_ERROR_INVALID_KERNEL_NAME: + os << "UR_RESULT_ERROR_INVALID_KERNEL_NAME"; + break; + + case UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_INDEX: + os << "UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_INDEX"; + break; + + case UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_SIZE: + os << "UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_SIZE"; + break; + + case UR_RESULT_ERROR_INVALID_KERNEL_ATTRIBUTE_VALUE: + os << "UR_RESULT_ERROR_INVALID_KERNEL_ATTRIBUTE_VALUE"; + break; + + case UR_RESULT_ERROR_INVALID_IMAGE_SIZE: + os << "UR_RESULT_ERROR_INVALID_IMAGE_SIZE"; + break; + + case UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR: + os << "UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR"; + break; + + case UR_RESULT_ERROR_IMAGE_FORMAT_NOT_SUPPORTED: + os << "UR_RESULT_ERROR_IMAGE_FORMAT_NOT_SUPPORTED"; + break; + + case UR_RESULT_ERROR_MEM_OBJECT_ALLOCATION_FAILURE: + os << "UR_RESULT_ERROR_MEM_OBJECT_ALLOCATION_FAILURE"; + break; + + case UR_RESULT_ERROR_INVALID_PROGRAM_EXECUTABLE: + os << "UR_RESULT_ERROR_INVALID_PROGRAM_EXECUTABLE"; + break; + + case UR_RESULT_ERROR_UNINITIALIZED: + os << "UR_RESULT_ERROR_UNINITIALIZED"; + break; + + case UR_RESULT_ERROR_OUT_OF_HOST_MEMORY: + os << "UR_RESULT_ERROR_OUT_OF_HOST_MEMORY"; + break; + + case UR_RESULT_ERROR_OUT_OF_DEVICE_MEMORY: + os << "UR_RESULT_ERROR_OUT_OF_DEVICE_MEMORY"; + break; + + case UR_RESULT_ERROR_OUT_OF_RESOURCES: + os << "UR_RESULT_ERROR_OUT_OF_RESOURCES"; + break; + + case UR_RESULT_ERROR_PROGRAM_BUILD_FAILURE: + os << "UR_RESULT_ERROR_PROGRAM_BUILD_FAILURE"; + break; + + case UR_RESULT_ERROR_PROGRAM_LINK_FAILURE: + os << "UR_RESULT_ERROR_PROGRAM_LINK_FAILURE"; + break; + + case UR_RESULT_ERROR_UNSUPPORTED_VERSION: + os << "UR_RESULT_ERROR_UNSUPPORTED_VERSION"; + break; + + case UR_RESULT_ERROR_UNSUPPORTED_FEATURE: + os << "UR_RESULT_ERROR_UNSUPPORTED_FEATURE"; + break; + + case UR_RESULT_ERROR_INVALID_ARGUMENT: + os << "UR_RESULT_ERROR_INVALID_ARGUMENT"; + break; + + case UR_RESULT_ERROR_INVALID_NULL_HANDLE: + os << "UR_RESULT_ERROR_INVALID_NULL_HANDLE"; + break; + + case UR_RESULT_ERROR_HANDLE_OBJECT_IN_USE: + os << "UR_RESULT_ERROR_HANDLE_OBJECT_IN_USE"; + break; + + case UR_RESULT_ERROR_INVALID_NULL_POINTER: + os << "UR_RESULT_ERROR_INVALID_NULL_POINTER"; + break; + + case UR_RESULT_ERROR_INVALID_SIZE: + os << "UR_RESULT_ERROR_INVALID_SIZE"; + break; + + case UR_RESULT_ERROR_UNSUPPORTED_SIZE: + os << "UR_RESULT_ERROR_UNSUPPORTED_SIZE"; + break; - case UR_STRUCTURE_TYPE_CONTEXT_NATIVE_PROPERTIES: { - const ur_context_native_properties_t *pstruct = - (const ur_context_native_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT: + os << "UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT"; + break; - case UR_STRUCTURE_TYPE_KERNEL_NATIVE_PROPERTIES: { - const ur_kernel_native_properties_t *pstruct = - (const ur_kernel_native_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT: + os << "UR_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT"; + break; - case UR_STRUCTURE_TYPE_QUEUE_NATIVE_PROPERTIES: { - const ur_queue_native_properties_t *pstruct = - (const ur_queue_native_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_RESULT_ERROR_INVALID_ENUMERATION: + os << "UR_RESULT_ERROR_INVALID_ENUMERATION"; + break; - case UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES: { - const ur_mem_native_properties_t *pstruct = - (const ur_mem_native_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION: + os << "UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION"; + break; - case UR_STRUCTURE_TYPE_EVENT_NATIVE_PROPERTIES: { - const ur_event_native_properties_t *pstruct = - (const ur_event_native_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT: + os << "UR_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT"; + break; - case UR_STRUCTURE_TYPE_PLATFORM_NATIVE_PROPERTIES: { - const ur_platform_native_properties_t *pstruct = - (const ur_platform_native_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_RESULT_ERROR_INVALID_NATIVE_BINARY: + os << "UR_RESULT_ERROR_INVALID_NATIVE_BINARY"; + break; - case UR_STRUCTURE_TYPE_DEVICE_NATIVE_PROPERTIES: { - const ur_device_native_properties_t *pstruct = - (const ur_device_native_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_RESULT_ERROR_INVALID_GLOBAL_NAME: + os << "UR_RESULT_ERROR_INVALID_GLOBAL_NAME"; + break; - case UR_STRUCTURE_TYPE_PROGRAM_NATIVE_PROPERTIES: { - const ur_program_native_properties_t *pstruct = - (const ur_program_native_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_RESULT_ERROR_INVALID_FUNCTION_NAME: + os << "UR_RESULT_ERROR_INVALID_FUNCTION_NAME"; + break; - case UR_STRUCTURE_TYPE_SAMPLER_NATIVE_PROPERTIES: { - const ur_sampler_native_properties_t *pstruct = - (const ur_sampler_native_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION: + os << "UR_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION"; + break; - case UR_STRUCTURE_TYPE_QUEUE_NATIVE_DESC: { - const ur_queue_native_desc_t *pstruct = - (const ur_queue_native_desc_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_RESULT_ERROR_INVALID_GLOBAL_WIDTH_DIMENSION: + os << "UR_RESULT_ERROR_INVALID_GLOBAL_WIDTH_DIMENSION"; + break; - case UR_STRUCTURE_TYPE_DEVICE_PARTITION_PROPERTIES: { - const ur_device_partition_properties_t *pstruct = - (const ur_device_partition_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_RESULT_ERROR_PROGRAM_UNLINKED: + os << "UR_RESULT_ERROR_PROGRAM_UNLINKED"; + break; - case UR_STRUCTURE_TYPE_KERNEL_ARG_MEM_OBJ_PROPERTIES: { - const ur_kernel_arg_mem_obj_properties_t *pstruct = - (const ur_kernel_arg_mem_obj_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_RESULT_ERROR_OVERLAPPING_REGIONS: + os << "UR_RESULT_ERROR_OVERLAPPING_REGIONS"; + break; - case UR_STRUCTURE_TYPE_PHYSICAL_MEM_PROPERTIES: { - const ur_physical_mem_properties_t *pstruct = - (const ur_physical_mem_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_RESULT_ERROR_INVALID_HOST_PTR: + os << "UR_RESULT_ERROR_INVALID_HOST_PTR"; + break; - case UR_STRUCTURE_TYPE_KERNEL_ARG_POINTER_PROPERTIES: { - const ur_kernel_arg_pointer_properties_t *pstruct = - (const ur_kernel_arg_pointer_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_RESULT_ERROR_INVALID_USM_SIZE: + os << "UR_RESULT_ERROR_INVALID_USM_SIZE"; + break; - case UR_STRUCTURE_TYPE_KERNEL_ARG_SAMPLER_PROPERTIES: { - const ur_kernel_arg_sampler_properties_t *pstruct = - (const ur_kernel_arg_sampler_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_RESULT_ERROR_OBJECT_ALLOCATION_FAILURE: + os << "UR_RESULT_ERROR_OBJECT_ALLOCATION_FAILURE"; + break; - case UR_STRUCTURE_TYPE_KERNEL_EXEC_INFO_PROPERTIES: { - const ur_kernel_exec_info_properties_t *pstruct = - (const ur_kernel_exec_info_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_RESULT_ERROR_ADAPTER_SPECIFIC: + os << "UR_RESULT_ERROR_ADAPTER_SPECIFIC"; + break; - case UR_STRUCTURE_TYPE_KERNEL_ARG_VALUE_PROPERTIES: { - const ur_kernel_arg_value_properties_t *pstruct = - (const ur_kernel_arg_value_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_RESULT_ERROR_LAYER_NOT_PRESENT: + os << "UR_RESULT_ERROR_LAYER_NOT_PRESENT"; + break; - case UR_STRUCTURE_TYPE_KERNEL_ARG_LOCAL_PROPERTIES: { - const ur_kernel_arg_local_properties_t *pstruct = - (const ur_kernel_arg_local_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_EXP: + os << "UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_EXP"; + break; - case UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC: { - const ur_exp_command_buffer_desc_t *pstruct = - (const ur_exp_command_buffer_desc_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_SYNC_POINT_EXP: + os << "UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_SYNC_POINT_EXP"; + break; - case UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES: { - const ur_exp_sampler_mip_properties_t *pstruct = - (const ur_exp_sampler_mip_properties_t *)ptr; - ur_params::serializePtr(os, pstruct); - } break; + case UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_SYNC_POINT_WAIT_LIST_EXP: + os << "UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_SYNC_POINT_WAIT_LIST_EXP"; + break; + + case UR_RESULT_ERROR_UNKNOWN: + os << "UR_RESULT_ERROR_UNKNOWN"; + break; default: os << "unknown enumerator"; break; } + return os; } -} // namespace ur_params inline std::ostream &operator<<(std::ostream &os, const struct ur_base_properties_t params) { os << "(struct ur_base_properties_t){"; @@ -1237,6 +2006,100 @@ inline void serializeFlag(std::ostream &os, } } } // namespace ur_params +inline std::ostream &operator<<(std::ostream &os, + enum ur_adapter_info_t value) { + switch (value) { + + case UR_ADAPTER_INFO_BACKEND: + os << "UR_ADAPTER_INFO_BACKEND"; + break; + + case UR_ADAPTER_INFO_REFERENCE_COUNT: + os << "UR_ADAPTER_INFO_REFERENCE_COUNT"; + break; + default: + os << "unknown enumerator"; + break; + } + return os; +} +namespace ur_params { +template <> +inline void serializeTagged(std::ostream &os, const void *ptr, + ur_adapter_info_t value, size_t size) { + if (ptr == NULL) { + serializePtr(os, ptr); + return; + } + + switch (value) { + + case UR_ADAPTER_INFO_BACKEND: { + const ur_adapter_backend_t *tptr = (const ur_adapter_backend_t *)ptr; + if (sizeof(ur_adapter_backend_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_adapter_backend_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + + case UR_ADAPTER_INFO_REFERENCE_COUNT: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint32_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + default: + os << "unknown enumerator"; + break; + } +} +} // namespace ur_params +inline std::ostream &operator<<(std::ostream &os, + enum ur_adapter_backend_t value) { + switch (value) { + + case UR_ADAPTER_BACKEND_UNKNOWN: + os << "UR_ADAPTER_BACKEND_UNKNOWN"; + break; + + case UR_ADAPTER_BACKEND_LEVEL_ZERO: + os << "UR_ADAPTER_BACKEND_LEVEL_ZERO"; + break; + + case UR_ADAPTER_BACKEND_OPENCL: + os << "UR_ADAPTER_BACKEND_OPENCL"; + break; + + case UR_ADAPTER_BACKEND_CUDA: + os << "UR_ADAPTER_BACKEND_CUDA"; + break; + + case UR_ADAPTER_BACKEND_HIP: + os << "UR_ADAPTER_BACKEND_HIP"; + break; + + case UR_ADAPTER_BACKEND_NATIVE_CPU: + os << "UR_ADAPTER_BACKEND_NATIVE_CPU"; + break; + default: + os << "unknown enumerator"; + break; + } + return os; +} inline std::ostream &operator<<(std::ostream &os, enum ur_platform_info_t value) { switch (value) { @@ -1379,6 +2242,10 @@ inline std::ostream &operator<<(std::ostream &os, case UR_PLATFORM_BACKEND_HIP: os << "UR_PLATFORM_BACKEND_HIP"; break; + + case UR_PLATFORM_BACKEND_NATIVE_CPU: + os << "UR_PLATFORM_BACKEND_NATIVE_CPU"; + break; default: os << "unknown enumerator"; break; @@ -1901,10 +2768,18 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_device_info_t value) { os << "UR_DEVICE_INFO_IP_VERSION"; break; + case UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT: + os << "UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT"; + break; + case UR_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP: os << "UR_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP"; break; + case UR_DEVICE_INFO_BINDLESS_IMAGES_SHARED_USM_SUPPORT_EXP: + os << "UR_DEVICE_INFO_BINDLESS_IMAGES_SHARED_USM_SUPPORT_EXP"; + break; + case UR_DEVICE_INFO_BINDLESS_IMAGES_1D_USM_SUPPORT_EXP: os << "UR_DEVICE_INFO_BINDLESS_IMAGES_1D_USM_SUPPORT_EXP"; break; @@ -1913,10 +2788,6 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_device_info_t value) { os << "UR_DEVICE_INFO_BINDLESS_IMAGES_2D_USM_SUPPORT_EXP"; break; - case UR_DEVICE_INFO_BINDLESS_IMAGES_3D_USM_SUPPORT_EXP: - os << "UR_DEVICE_INFO_BINDLESS_IMAGES_3D_USM_SUPPORT_EXP"; - break; - case UR_DEVICE_INFO_IMAGE_PITCH_ALIGN_EXP: os << "UR_DEVICE_INFO_IMAGE_PITCH_ALIGN_EXP"; break; @@ -3515,7 +4386,21 @@ inline void serializeTagged(std::ostream &os, const void *ptr, const uint32_t *tptr = (const uint32_t *)ptr; if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; + << ", expected: >=" << sizeof(uint32_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + + case UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT: { + const ur_bool_t *tptr = (const ur_bool_t *)ptr; + if (sizeof(ur_bool_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_bool_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -3539,7 +4424,7 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_BINDLESS_IMAGES_1D_USM_SUPPORT_EXP: { + case UR_DEVICE_INFO_BINDLESS_IMAGES_SHARED_USM_SUPPORT_EXP: { const ur_bool_t *tptr = (const ur_bool_t *)ptr; if (sizeof(ur_bool_t) > size) { os << "invalid size (is: " << size @@ -3553,7 +4438,7 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_BINDLESS_IMAGES_2D_USM_SUPPORT_EXP: { + case UR_DEVICE_INFO_BINDLESS_IMAGES_1D_USM_SUPPORT_EXP: { const ur_bool_t *tptr = (const ur_bool_t *)ptr; if (sizeof(ur_bool_t) > size) { os << "invalid size (is: " << size @@ -3567,7 +4452,7 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_DEVICE_INFO_BINDLESS_IMAGES_3D_USM_SUPPORT_EXP: { + case UR_DEVICE_INFO_BINDLESS_IMAGES_2D_USM_SUPPORT_EXP: { const ur_bool_t *tptr = (const ur_bool_t *)ptr; if (sizeof(ur_bool_t) > size) { os << "invalid size (is: " << size @@ -3896,27 +4781,41 @@ inline std::ostream &operator<<(std::ostream &os, } return os; } -inline std::ostream & -operator<<(std::ostream &os, const union ur_device_partition_value_t params) { + +inline void +ur_params::serializeUnion(std::ostream &os, + const union ur_device_partition_value_t params, + const enum ur_device_partition_t tag) { os << "(union ur_device_partition_value_t){"; - os << ".equally = "; + switch (tag) { + case UR_DEVICE_PARTITION_EQUALLY: - os << (params.equally); + os << ".equally = "; - os << ", "; - os << ".count = "; + os << (params.equally); - os << (params.count); + break; + case UR_DEVICE_PARTITION_BY_COUNTS: - os << ", "; - os << ".affinity_domain = "; + os << ".count = "; + + os << (params.count); + + break; + case UR_DEVICE_PARTITION_BY_AFFINITY_DOMAIN: - ur_params::serializeFlag( - os, (params.affinity_domain)); + os << ".affinity_domain = "; + ur_params::serializeFlag( + os, (params.affinity_domain)); + + break; + default: + os << ""; + break; + } os << "}"; - return os; } inline std::ostream & operator<<(std::ostream &os, @@ -3929,8 +4828,7 @@ operator<<(std::ostream &os, os << ", "; os << ".value = "; - - os << (params.value); + ur_params::serializeUnion(os, (params.value), params.type); os << "}"; return os; @@ -4926,260 +5824,42 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_mem_type_t value) { case UR_MEM_TYPE_IMAGE2D: os << "UR_MEM_TYPE_IMAGE2D"; - break; - - case UR_MEM_TYPE_IMAGE3D: - os << "UR_MEM_TYPE_IMAGE3D"; - break; - - case UR_MEM_TYPE_IMAGE2D_ARRAY: - os << "UR_MEM_TYPE_IMAGE2D_ARRAY"; - break; - - case UR_MEM_TYPE_IMAGE1D: - os << "UR_MEM_TYPE_IMAGE1D"; - break; - - case UR_MEM_TYPE_IMAGE1D_ARRAY: - os << "UR_MEM_TYPE_IMAGE1D_ARRAY"; - break; - - case UR_MEM_TYPE_IMAGE1D_BUFFER: - os << "UR_MEM_TYPE_IMAGE1D_BUFFER"; - break; - default: - os << "unknown enumerator"; - break; - } - return os; -} -inline std::ostream &operator<<(std::ostream &os, enum ur_mem_info_t value) { - switch (value) { - - case UR_MEM_INFO_SIZE: - os << "UR_MEM_INFO_SIZE"; - break; - - case UR_MEM_INFO_CONTEXT: - os << "UR_MEM_INFO_CONTEXT"; - break; - default: - os << "unknown enumerator"; - break; - } - return os; -} -namespace ur_params { -template <> -inline void serializeTagged(std::ostream &os, const void *ptr, - ur_mem_info_t value, size_t size) { - if (ptr == NULL) { - serializePtr(os, ptr); - return; - } - - switch (value) { - - case UR_MEM_INFO_SIZE: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; - - os << ")"; - } break; - - case UR_MEM_INFO_CONTEXT: { - const ur_context_handle_t *tptr = (const ur_context_handle_t *)ptr; - if (sizeof(ur_context_handle_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_context_handle_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - ur_params::serializePtr(os, *tptr); - - os << ")"; - } break; - default: - os << "unknown enumerator"; - break; - } -} -} // namespace ur_params -inline std::ostream &operator<<(std::ostream &os, - enum ur_image_channel_order_t value) { - switch (value) { - - case UR_IMAGE_CHANNEL_ORDER_A: - os << "UR_IMAGE_CHANNEL_ORDER_A"; - break; - - case UR_IMAGE_CHANNEL_ORDER_R: - os << "UR_IMAGE_CHANNEL_ORDER_R"; - break; - - case UR_IMAGE_CHANNEL_ORDER_RG: - os << "UR_IMAGE_CHANNEL_ORDER_RG"; - break; - - case UR_IMAGE_CHANNEL_ORDER_RA: - os << "UR_IMAGE_CHANNEL_ORDER_RA"; - break; - - case UR_IMAGE_CHANNEL_ORDER_RGB: - os << "UR_IMAGE_CHANNEL_ORDER_RGB"; - break; - - case UR_IMAGE_CHANNEL_ORDER_RGBA: - os << "UR_IMAGE_CHANNEL_ORDER_RGBA"; - break; - - case UR_IMAGE_CHANNEL_ORDER_BGRA: - os << "UR_IMAGE_CHANNEL_ORDER_BGRA"; - break; - - case UR_IMAGE_CHANNEL_ORDER_ARGB: - os << "UR_IMAGE_CHANNEL_ORDER_ARGB"; - break; - - case UR_IMAGE_CHANNEL_ORDER_ABGR: - os << "UR_IMAGE_CHANNEL_ORDER_ABGR"; - break; - - case UR_IMAGE_CHANNEL_ORDER_INTENSITY: - os << "UR_IMAGE_CHANNEL_ORDER_INTENSITY"; - break; - - case UR_IMAGE_CHANNEL_ORDER_LUMINANCE: - os << "UR_IMAGE_CHANNEL_ORDER_LUMINANCE"; - break; - - case UR_IMAGE_CHANNEL_ORDER_RX: - os << "UR_IMAGE_CHANNEL_ORDER_RX"; - break; - - case UR_IMAGE_CHANNEL_ORDER_RGX: - os << "UR_IMAGE_CHANNEL_ORDER_RGX"; - break; - - case UR_IMAGE_CHANNEL_ORDER_RGBX: - os << "UR_IMAGE_CHANNEL_ORDER_RGBX"; - break; - - case UR_IMAGE_CHANNEL_ORDER_SRGBA: - os << "UR_IMAGE_CHANNEL_ORDER_SRGBA"; - break; - default: - os << "unknown enumerator"; - break; - } - return os; -} -inline std::ostream &operator<<(std::ostream &os, - enum ur_image_channel_type_t value) { - switch (value) { - - case UR_IMAGE_CHANNEL_TYPE_SNORM_INT8: - os << "UR_IMAGE_CHANNEL_TYPE_SNORM_INT8"; - break; - - case UR_IMAGE_CHANNEL_TYPE_SNORM_INT16: - os << "UR_IMAGE_CHANNEL_TYPE_SNORM_INT16"; - break; - - case UR_IMAGE_CHANNEL_TYPE_UNORM_INT8: - os << "UR_IMAGE_CHANNEL_TYPE_UNORM_INT8"; - break; - - case UR_IMAGE_CHANNEL_TYPE_UNORM_INT16: - os << "UR_IMAGE_CHANNEL_TYPE_UNORM_INT16"; - break; - - case UR_IMAGE_CHANNEL_TYPE_UNORM_SHORT_565: - os << "UR_IMAGE_CHANNEL_TYPE_UNORM_SHORT_565"; - break; - - case UR_IMAGE_CHANNEL_TYPE_UNORM_SHORT_555: - os << "UR_IMAGE_CHANNEL_TYPE_UNORM_SHORT_555"; - break; - - case UR_IMAGE_CHANNEL_TYPE_INT_101010: - os << "UR_IMAGE_CHANNEL_TYPE_INT_101010"; - break; - - case UR_IMAGE_CHANNEL_TYPE_SIGNED_INT8: - os << "UR_IMAGE_CHANNEL_TYPE_SIGNED_INT8"; - break; - - case UR_IMAGE_CHANNEL_TYPE_SIGNED_INT16: - os << "UR_IMAGE_CHANNEL_TYPE_SIGNED_INT16"; - break; - - case UR_IMAGE_CHANNEL_TYPE_SIGNED_INT32: - os << "UR_IMAGE_CHANNEL_TYPE_SIGNED_INT32"; - break; - - case UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT8: - os << "UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT8"; - break; - - case UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT16: - os << "UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT16"; - break; - - case UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT32: - os << "UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT32"; - break; - - case UR_IMAGE_CHANNEL_TYPE_HALF_FLOAT: - os << "UR_IMAGE_CHANNEL_TYPE_HALF_FLOAT"; - break; - - case UR_IMAGE_CHANNEL_TYPE_FLOAT: - os << "UR_IMAGE_CHANNEL_TYPE_FLOAT"; - break; - default: - os << "unknown enumerator"; - break; - } - return os; -} -inline std::ostream &operator<<(std::ostream &os, enum ur_image_info_t value) { - switch (value) { + break; - case UR_IMAGE_INFO_FORMAT: - os << "UR_IMAGE_INFO_FORMAT"; + case UR_MEM_TYPE_IMAGE3D: + os << "UR_MEM_TYPE_IMAGE3D"; break; - case UR_IMAGE_INFO_ELEMENT_SIZE: - os << "UR_IMAGE_INFO_ELEMENT_SIZE"; + case UR_MEM_TYPE_IMAGE2D_ARRAY: + os << "UR_MEM_TYPE_IMAGE2D_ARRAY"; break; - case UR_IMAGE_INFO_ROW_PITCH: - os << "UR_IMAGE_INFO_ROW_PITCH"; + case UR_MEM_TYPE_IMAGE1D: + os << "UR_MEM_TYPE_IMAGE1D"; break; - case UR_IMAGE_INFO_SLICE_PITCH: - os << "UR_IMAGE_INFO_SLICE_PITCH"; + case UR_MEM_TYPE_IMAGE1D_ARRAY: + os << "UR_MEM_TYPE_IMAGE1D_ARRAY"; break; - case UR_IMAGE_INFO_WIDTH: - os << "UR_IMAGE_INFO_WIDTH"; + case UR_MEM_TYPE_IMAGE1D_BUFFER: + os << "UR_MEM_TYPE_IMAGE1D_BUFFER"; + break; + default: + os << "unknown enumerator"; break; + } + return os; +} +inline std::ostream &operator<<(std::ostream &os, enum ur_mem_info_t value) { + switch (value) { - case UR_IMAGE_INFO_HEIGHT: - os << "UR_IMAGE_INFO_HEIGHT"; + case UR_MEM_INFO_SIZE: + os << "UR_MEM_INFO_SIZE"; break; - case UR_IMAGE_INFO_DEPTH: - os << "UR_IMAGE_INFO_DEPTH"; + case UR_MEM_INFO_CONTEXT: + os << "UR_MEM_INFO_CONTEXT"; break; default: os << "unknown enumerator"; @@ -5190,7 +5870,7 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_image_info_t value) { namespace ur_params { template <> inline void serializeTagged(std::ostream &os, const void *ptr, - ur_image_info_t value, size_t size) { + ur_mem_info_t value, size_t size) { if (ptr == NULL) { serializePtr(os, ptr); return; @@ -5198,77 +5878,7 @@ inline void serializeTagged(std::ostream &os, const void *ptr, switch (value) { - case UR_IMAGE_INFO_FORMAT: { - const ur_image_format_t *tptr = (const ur_image_format_t *)ptr; - if (sizeof(ur_image_format_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_image_format_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; - - os << ")"; - } break; - - case UR_IMAGE_INFO_ELEMENT_SIZE: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; - - os << ")"; - } break; - - case UR_IMAGE_INFO_ROW_PITCH: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; - - os << ")"; - } break; - - case UR_IMAGE_INFO_SLICE_PITCH: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; - - os << ")"; - } break; - - case UR_IMAGE_INFO_WIDTH: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; - - os << ")"; - } break; - - case UR_IMAGE_INFO_HEIGHT: { + case UR_MEM_INFO_SIZE: { const size_t *tptr = (const size_t *)ptr; if (sizeof(size_t) > size) { os << "invalid size (is: " << size @@ -5282,199 +5892,87 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_IMAGE_INFO_DEPTH: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { + case UR_MEM_INFO_CONTEXT: { + const ur_context_handle_t *tptr = (const ur_context_handle_t *)ptr; + if (sizeof(ur_context_handle_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; + << ", expected: >=" << sizeof(ur_context_handle_t) << ")"; return; } os << (void *)(tptr) << " ("; - os << *tptr; - - os << ")"; - } break; - default: - os << "unknown enumerator"; - break; - } -} -} // namespace ur_params -inline std::ostream &operator<<(std::ostream &os, - const struct ur_image_format_t params) { - os << "(struct ur_image_format_t){"; - - os << ".channelOrder = "; - - os << (params.channelOrder); - - os << ", "; - os << ".channelType = "; - - os << (params.channelType); - - os << "}"; - return os; -} -inline std::ostream &operator<<(std::ostream &os, - const struct ur_image_desc_t params) { - os << "(struct ur_image_desc_t){"; - - os << ".stype = "; - - os << (params.stype); - - os << ", "; - os << ".pNext = "; - - ur_params::serializeStruct(os, (params.pNext)); - - os << ", "; - os << ".type = "; - - os << (params.type); - - os << ", "; - os << ".width = "; - - os << (params.width); - - os << ", "; - os << ".height = "; - - os << (params.height); - - os << ", "; - os << ".depth = "; - - os << (params.depth); - - os << ", "; - os << ".arraySize = "; - - os << (params.arraySize); - - os << ", "; - os << ".rowPitch = "; - - os << (params.rowPitch); - - os << ", "; - os << ".slicePitch = "; - - os << (params.slicePitch); - - os << ", "; - os << ".numMipLevel = "; - - os << (params.numMipLevel); - - os << ", "; - os << ".numSamples = "; - - os << (params.numSamples); - - os << "}"; - return os; -} -inline std::ostream &operator<<(std::ostream &os, - const struct ur_buffer_properties_t params) { - os << "(struct ur_buffer_properties_t){"; - - os << ".stype = "; - - os << (params.stype); - - os << ", "; - os << ".pNext = "; - - ur_params::serializeStruct(os, (params.pNext)); - - os << ", "; - os << ".pHost = "; - - ur_params::serializePtr(os, (params.pHost)); - - os << "}"; - return os; -} -inline std::ostream & -operator<<(std::ostream &os, - const struct ur_buffer_channel_properties_t params) { - os << "(struct ur_buffer_channel_properties_t){"; - - os << ".stype = "; - - os << (params.stype); - - os << ", "; - os << ".pNext = "; - - ur_params::serializeStruct(os, (params.pNext)); - - os << ", "; - os << ".channel = "; - - os << (params.channel); - - os << "}"; - return os; -} -inline std::ostream & -operator<<(std::ostream &os, - const struct ur_buffer_alloc_location_properties_t params) { - os << "(struct ur_buffer_alloc_location_properties_t){"; - - os << ".stype = "; + ur_params::serializePtr(os, *tptr); - os << (params.stype); + os << ")"; + } break; + default: + os << "unknown enumerator"; + break; + } +} +} // namespace ur_params +inline std::ostream &operator<<(std::ostream &os, + enum ur_image_channel_order_t value) { + switch (value) { - os << ", "; - os << ".pNext = "; + case UR_IMAGE_CHANNEL_ORDER_A: + os << "UR_IMAGE_CHANNEL_ORDER_A"; + break; - ur_params::serializeStruct(os, (params.pNext)); + case UR_IMAGE_CHANNEL_ORDER_R: + os << "UR_IMAGE_CHANNEL_ORDER_R"; + break; - os << ", "; - os << ".location = "; + case UR_IMAGE_CHANNEL_ORDER_RG: + os << "UR_IMAGE_CHANNEL_ORDER_RG"; + break; - os << (params.location); + case UR_IMAGE_CHANNEL_ORDER_RA: + os << "UR_IMAGE_CHANNEL_ORDER_RA"; + break; - os << "}"; - return os; -} -inline std::ostream &operator<<(std::ostream &os, - const struct ur_buffer_region_t params) { - os << "(struct ur_buffer_region_t){"; + case UR_IMAGE_CHANNEL_ORDER_RGB: + os << "UR_IMAGE_CHANNEL_ORDER_RGB"; + break; - os << ".stype = "; + case UR_IMAGE_CHANNEL_ORDER_RGBA: + os << "UR_IMAGE_CHANNEL_ORDER_RGBA"; + break; - os << (params.stype); + case UR_IMAGE_CHANNEL_ORDER_BGRA: + os << "UR_IMAGE_CHANNEL_ORDER_BGRA"; + break; - os << ", "; - os << ".pNext = "; + case UR_IMAGE_CHANNEL_ORDER_ARGB: + os << "UR_IMAGE_CHANNEL_ORDER_ARGB"; + break; - ur_params::serializeStruct(os, (params.pNext)); + case UR_IMAGE_CHANNEL_ORDER_ABGR: + os << "UR_IMAGE_CHANNEL_ORDER_ABGR"; + break; - os << ", "; - os << ".origin = "; + case UR_IMAGE_CHANNEL_ORDER_INTENSITY: + os << "UR_IMAGE_CHANNEL_ORDER_INTENSITY"; + break; - os << (params.origin); + case UR_IMAGE_CHANNEL_ORDER_LUMINANCE: + os << "UR_IMAGE_CHANNEL_ORDER_LUMINANCE"; + break; - os << ", "; - os << ".size = "; + case UR_IMAGE_CHANNEL_ORDER_RX: + os << "UR_IMAGE_CHANNEL_ORDER_RX"; + break; - os << (params.size); + case UR_IMAGE_CHANNEL_ORDER_RGX: + os << "UR_IMAGE_CHANNEL_ORDER_RGX"; + break; - os << "}"; - return os; -} -inline std::ostream &operator<<(std::ostream &os, - enum ur_buffer_create_type_t value) { - switch (value) { + case UR_IMAGE_CHANNEL_ORDER_RGBX: + os << "UR_IMAGE_CHANNEL_ORDER_RGBX"; + break; - case UR_BUFFER_CREATE_TYPE_REGION: - os << "UR_BUFFER_CREATE_TYPE_REGION"; + case UR_IMAGE_CHANNEL_ORDER_SRGBA: + os << "UR_IMAGE_CHANNEL_ORDER_SRGBA"; break; default: os << "unknown enumerator"; @@ -5482,66 +5980,68 @@ inline std::ostream &operator<<(std::ostream &os, } return os; } -inline std::ostream & -operator<<(std::ostream &os, const struct ur_mem_native_properties_t params) { - os << "(struct ur_mem_native_properties_t){"; +inline std::ostream &operator<<(std::ostream &os, + enum ur_image_channel_type_t value) { + switch (value) { - os << ".stype = "; + case UR_IMAGE_CHANNEL_TYPE_SNORM_INT8: + os << "UR_IMAGE_CHANNEL_TYPE_SNORM_INT8"; + break; - os << (params.stype); + case UR_IMAGE_CHANNEL_TYPE_SNORM_INT16: + os << "UR_IMAGE_CHANNEL_TYPE_SNORM_INT16"; + break; - os << ", "; - os << ".pNext = "; + case UR_IMAGE_CHANNEL_TYPE_UNORM_INT8: + os << "UR_IMAGE_CHANNEL_TYPE_UNORM_INT8"; + break; - ur_params::serializeStruct(os, (params.pNext)); + case UR_IMAGE_CHANNEL_TYPE_UNORM_INT16: + os << "UR_IMAGE_CHANNEL_TYPE_UNORM_INT16"; + break; - os << ", "; - os << ".isNativeHandleOwned = "; + case UR_IMAGE_CHANNEL_TYPE_UNORM_SHORT_565: + os << "UR_IMAGE_CHANNEL_TYPE_UNORM_SHORT_565"; + break; - os << (params.isNativeHandleOwned); + case UR_IMAGE_CHANNEL_TYPE_UNORM_SHORT_555: + os << "UR_IMAGE_CHANNEL_TYPE_UNORM_SHORT_555"; + break; - os << "}"; - return os; -} -inline std::ostream &operator<<(std::ostream &os, - enum ur_sampler_filter_mode_t value) { - switch (value) { + case UR_IMAGE_CHANNEL_TYPE_INT_101010: + os << "UR_IMAGE_CHANNEL_TYPE_INT_101010"; + break; - case UR_SAMPLER_FILTER_MODE_NEAREST: - os << "UR_SAMPLER_FILTER_MODE_NEAREST"; + case UR_IMAGE_CHANNEL_TYPE_SIGNED_INT8: + os << "UR_IMAGE_CHANNEL_TYPE_SIGNED_INT8"; break; - case UR_SAMPLER_FILTER_MODE_LINEAR: - os << "UR_SAMPLER_FILTER_MODE_LINEAR"; + case UR_IMAGE_CHANNEL_TYPE_SIGNED_INT16: + os << "UR_IMAGE_CHANNEL_TYPE_SIGNED_INT16"; break; - default: - os << "unknown enumerator"; + + case UR_IMAGE_CHANNEL_TYPE_SIGNED_INT32: + os << "UR_IMAGE_CHANNEL_TYPE_SIGNED_INT32"; break; - } - return os; -} -inline std::ostream &operator<<(std::ostream &os, - enum ur_sampler_addressing_mode_t value) { - switch (value) { - case UR_SAMPLER_ADDRESSING_MODE_NONE: - os << "UR_SAMPLER_ADDRESSING_MODE_NONE"; + case UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT8: + os << "UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT8"; break; - case UR_SAMPLER_ADDRESSING_MODE_CLAMP_TO_EDGE: - os << "UR_SAMPLER_ADDRESSING_MODE_CLAMP_TO_EDGE"; + case UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT16: + os << "UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT16"; break; - case UR_SAMPLER_ADDRESSING_MODE_CLAMP: - os << "UR_SAMPLER_ADDRESSING_MODE_CLAMP"; + case UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT32: + os << "UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT32"; break; - case UR_SAMPLER_ADDRESSING_MODE_REPEAT: - os << "UR_SAMPLER_ADDRESSING_MODE_REPEAT"; + case UR_IMAGE_CHANNEL_TYPE_HALF_FLOAT: + os << "UR_IMAGE_CHANNEL_TYPE_HALF_FLOAT"; break; - case UR_SAMPLER_ADDRESSING_MODE_MIRRORED_REPEAT: - os << "UR_SAMPLER_ADDRESSING_MODE_MIRRORED_REPEAT"; + case UR_IMAGE_CHANNEL_TYPE_FLOAT: + os << "UR_IMAGE_CHANNEL_TYPE_FLOAT"; break; default: os << "unknown enumerator"; @@ -5549,28 +6049,35 @@ inline std::ostream &operator<<(std::ostream &os, } return os; } -inline std::ostream &operator<<(std::ostream &os, - enum ur_sampler_info_t value) { +inline std::ostream &operator<<(std::ostream &os, enum ur_image_info_t value) { switch (value) { - case UR_SAMPLER_INFO_REFERENCE_COUNT: - os << "UR_SAMPLER_INFO_REFERENCE_COUNT"; + case UR_IMAGE_INFO_FORMAT: + os << "UR_IMAGE_INFO_FORMAT"; break; - case UR_SAMPLER_INFO_CONTEXT: - os << "UR_SAMPLER_INFO_CONTEXT"; + case UR_IMAGE_INFO_ELEMENT_SIZE: + os << "UR_IMAGE_INFO_ELEMENT_SIZE"; break; - case UR_SAMPLER_INFO_NORMALIZED_COORDS: - os << "UR_SAMPLER_INFO_NORMALIZED_COORDS"; + case UR_IMAGE_INFO_ROW_PITCH: + os << "UR_IMAGE_INFO_ROW_PITCH"; break; - case UR_SAMPLER_INFO_ADDRESSING_MODE: - os << "UR_SAMPLER_INFO_ADDRESSING_MODE"; + case UR_IMAGE_INFO_SLICE_PITCH: + os << "UR_IMAGE_INFO_SLICE_PITCH"; break; - case UR_SAMPLER_INFO_FILTER_MODE: - os << "UR_SAMPLER_INFO_FILTER_MODE"; + case UR_IMAGE_INFO_WIDTH: + os << "UR_IMAGE_INFO_WIDTH"; + break; + + case UR_IMAGE_INFO_HEIGHT: + os << "UR_IMAGE_INFO_HEIGHT"; + break; + + case UR_IMAGE_INFO_DEPTH: + os << "UR_IMAGE_INFO_DEPTH"; break; default: os << "unknown enumerator"; @@ -5581,7 +6088,7 @@ inline std::ostream &operator<<(std::ostream &os, namespace ur_params { template <> inline void serializeTagged(std::ostream &os, const void *ptr, - ur_sampler_info_t value, size_t size) { + ur_image_info_t value, size_t size) { if (ptr == NULL) { serializePtr(os, ptr); return; @@ -5589,11 +6096,11 @@ inline void serializeTagged(std::ostream &os, const void *ptr, switch (value) { - case UR_SAMPLER_INFO_REFERENCE_COUNT: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { + case UR_IMAGE_INFO_FORMAT: { + const ur_image_format_t *tptr = (const ur_image_format_t *)ptr; + if (sizeof(ur_image_format_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; + << ", expected: >=" << sizeof(ur_image_format_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -5603,25 +6110,25 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_SAMPLER_INFO_CONTEXT: { - const ur_context_handle_t *tptr = (const ur_context_handle_t *)ptr; - if (sizeof(ur_context_handle_t) > size) { + case UR_IMAGE_INFO_ELEMENT_SIZE: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_context_handle_t) << ")"; + << ", expected: >=" << sizeof(size_t) << ")"; return; } os << (void *)(tptr) << " ("; - ur_params::serializePtr(os, *tptr); + os << *tptr; os << ")"; } break; - case UR_SAMPLER_INFO_NORMALIZED_COORDS: { - const ur_bool_t *tptr = (const ur_bool_t *)ptr; - if (sizeof(ur_bool_t) > size) { + case UR_IMAGE_INFO_ROW_PITCH: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_bool_t) << ")"; + << ", expected: >=" << sizeof(size_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -5631,13 +6138,39 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_SAMPLER_INFO_ADDRESSING_MODE: { - const ur_sampler_addressing_mode_t *tptr = - (const ur_sampler_addressing_mode_t *)ptr; - if (sizeof(ur_sampler_addressing_mode_t) > size) { + case UR_IMAGE_INFO_SLICE_PITCH: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(size_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + + case UR_IMAGE_INFO_WIDTH: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(size_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + + case UR_IMAGE_INFO_HEIGHT: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_sampler_addressing_mode_t) - << ")"; + << ", expected: >=" << sizeof(size_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -5647,12 +6180,11 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_SAMPLER_INFO_FILTER_MODE: { - const ur_sampler_filter_mode_t *tptr = - (const ur_sampler_filter_mode_t *)ptr; - if (sizeof(ur_sampler_filter_mode_t) > size) { + case UR_IMAGE_INFO_DEPTH: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_sampler_filter_mode_t) << ")"; + << ", expected: >=" << sizeof(size_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -5668,8 +6200,24 @@ inline void serializeTagged(std::ostream &os, const void *ptr, } } // namespace ur_params inline std::ostream &operator<<(std::ostream &os, - const struct ur_sampler_desc_t params) { - os << "(struct ur_sampler_desc_t){"; + const struct ur_image_format_t params) { + os << "(struct ur_image_format_t){"; + + os << ".channelOrder = "; + + os << (params.channelOrder); + + os << ", "; + os << ".channelType = "; + + os << (params.channelType); + + os << "}"; + return os; +} +inline std::ostream &operator<<(std::ostream &os, + const struct ur_image_desc_t params) { + os << "(struct ur_image_desc_t){"; os << ".stype = "; @@ -5681,27 +6229,78 @@ inline std::ostream &operator<<(std::ostream &os, ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".normalizedCoords = "; + os << ".type = "; - os << (params.normalizedCoords); + os << (params.type); os << ", "; - os << ".addressingMode = "; + os << ".width = "; - os << (params.addressingMode); + os << (params.width); os << ", "; - os << ".filterMode = "; + os << ".height = "; - os << (params.filterMode); + os << (params.height); + + os << ", "; + os << ".depth = "; + + os << (params.depth); + + os << ", "; + os << ".arraySize = "; + + os << (params.arraySize); + + os << ", "; + os << ".rowPitch = "; + + os << (params.rowPitch); + + os << ", "; + os << ".slicePitch = "; + + os << (params.slicePitch); + + os << ", "; + os << ".numMipLevel = "; + + os << (params.numMipLevel); + + os << ", "; + os << ".numSamples = "; + + os << (params.numSamples); + + os << "}"; + return os; +} +inline std::ostream &operator<<(std::ostream &os, + const struct ur_buffer_properties_t params) { + os << "(struct ur_buffer_properties_t){"; + + os << ".stype = "; + + os << (params.stype); + + os << ", "; + os << ".pNext = "; + + ur_params::serializeStruct(os, (params.pNext)); + + os << ", "; + os << ".pHost = "; + + ur_params::serializePtr(os, (params.pHost)); os << "}"; return os; } inline std::ostream & operator<<(std::ostream &os, - const struct ur_sampler_native_properties_t params) { - os << "(struct ur_sampler_native_properties_t){"; + const struct ur_buffer_channel_properties_t params) { + os << "(struct ur_buffer_channel_properties_t){"; os << ".stype = "; @@ -5713,69 +6312,67 @@ operator<<(std::ostream &os, ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".isNativeHandleOwned = "; + os << ".channel = "; - os << (params.isNativeHandleOwned); + os << (params.channel); os << "}"; return os; } -inline std::ostream &operator<<(std::ostream &os, - enum ur_usm_host_mem_flag_t value) { - switch (value) { +inline std::ostream & +operator<<(std::ostream &os, + const struct ur_buffer_alloc_location_properties_t params) { + os << "(struct ur_buffer_alloc_location_properties_t){"; - case UR_USM_HOST_MEM_FLAG_INITIAL_PLACEMENT: - os << "UR_USM_HOST_MEM_FLAG_INITIAL_PLACEMENT"; - break; - default: - os << "unknown enumerator"; - break; - } + os << ".stype = "; + + os << (params.stype); + + os << ", "; + os << ".pNext = "; + + ur_params::serializeStruct(os, (params.pNext)); + + os << ", "; + os << ".location = "; + + os << (params.location); + + os << "}"; return os; } -namespace ur_params { +inline std::ostream &operator<<(std::ostream &os, + const struct ur_buffer_region_t params) { + os << "(struct ur_buffer_region_t){"; -template <> -inline void serializeFlag(std::ostream &os, - uint32_t flag) { - uint32_t val = flag; - bool first = true; + os << ".stype = "; - if ((val & UR_USM_HOST_MEM_FLAG_INITIAL_PLACEMENT) == - (uint32_t)UR_USM_HOST_MEM_FLAG_INITIAL_PLACEMENT) { - val ^= (uint32_t)UR_USM_HOST_MEM_FLAG_INITIAL_PLACEMENT; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_USM_HOST_MEM_FLAG_INITIAL_PLACEMENT; - } - if (val != 0) { - std::bitset<32> bits(val); - if (!first) { - os << " | "; - } - os << "unknown bit flags " << bits; - } else if (first) { - os << "0"; - } + os << (params.stype); + + os << ", "; + os << ".pNext = "; + + ur_params::serializeStruct(os, (params.pNext)); + + os << ", "; + os << ".origin = "; + + os << (params.origin); + + os << ", "; + os << ".size = "; + + os << (params.size); + + os << "}"; + return os; } -} // namespace ur_params inline std::ostream &operator<<(std::ostream &os, - enum ur_usm_device_mem_flag_t value) { + enum ur_buffer_create_type_t value) { switch (value) { - case UR_USM_DEVICE_MEM_FLAG_WRITE_COMBINED: - os << "UR_USM_DEVICE_MEM_FLAG_WRITE_COMBINED"; - break; - - case UR_USM_DEVICE_MEM_FLAG_INITIAL_PLACEMENT: - os << "UR_USM_DEVICE_MEM_FLAG_INITIAL_PLACEMENT"; - break; - - case UR_USM_DEVICE_MEM_FLAG_DEVICE_READ_ONLY: - os << "UR_USM_DEVICE_MEM_FLAG_DEVICE_READ_ONLY"; + case UR_BUFFER_CREATE_TYPE_REGION: + os << "UR_BUFFER_CREATE_TYPE_REGION"; break; default: os << "unknown enumerator"; @@ -5783,63 +6380,37 @@ inline std::ostream &operator<<(std::ostream &os, } return os; } -namespace ur_params { +inline std::ostream & +operator<<(std::ostream &os, const struct ur_mem_native_properties_t params) { + os << "(struct ur_mem_native_properties_t){"; -template <> -inline void serializeFlag(std::ostream &os, - uint32_t flag) { - uint32_t val = flag; - bool first = true; + os << ".stype = "; - if ((val & UR_USM_DEVICE_MEM_FLAG_WRITE_COMBINED) == - (uint32_t)UR_USM_DEVICE_MEM_FLAG_WRITE_COMBINED) { - val ^= (uint32_t)UR_USM_DEVICE_MEM_FLAG_WRITE_COMBINED; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_USM_DEVICE_MEM_FLAG_WRITE_COMBINED; - } + os << (params.stype); - if ((val & UR_USM_DEVICE_MEM_FLAG_INITIAL_PLACEMENT) == - (uint32_t)UR_USM_DEVICE_MEM_FLAG_INITIAL_PLACEMENT) { - val ^= (uint32_t)UR_USM_DEVICE_MEM_FLAG_INITIAL_PLACEMENT; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_USM_DEVICE_MEM_FLAG_INITIAL_PLACEMENT; - } + os << ", "; + os << ".pNext = "; - if ((val & UR_USM_DEVICE_MEM_FLAG_DEVICE_READ_ONLY) == - (uint32_t)UR_USM_DEVICE_MEM_FLAG_DEVICE_READ_ONLY) { - val ^= (uint32_t)UR_USM_DEVICE_MEM_FLAG_DEVICE_READ_ONLY; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_USM_DEVICE_MEM_FLAG_DEVICE_READ_ONLY; - } - if (val != 0) { - std::bitset<32> bits(val); - if (!first) { - os << " | "; - } - os << "unknown bit flags " << bits; - } else if (first) { - os << "0"; - } + ur_params::serializeStruct(os, (params.pNext)); + + os << ", "; + os << ".isNativeHandleOwned = "; + + os << (params.isNativeHandleOwned); + + os << "}"; + return os; } -} // namespace ur_params inline std::ostream &operator<<(std::ostream &os, - enum ur_usm_pool_flag_t value) { + enum ur_sampler_filter_mode_t value) { switch (value) { - case UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK: - os << "UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK"; + case UR_SAMPLER_FILTER_MODE_NEAREST: + os << "UR_SAMPLER_FILTER_MODE_NEAREST"; + break; + + case UR_SAMPLER_FILTER_MODE_LINEAR: + os << "UR_SAMPLER_FILTER_MODE_LINEAR"; break; default: os << "unknown enumerator"; @@ -5847,51 +6418,28 @@ inline std::ostream &operator<<(std::ostream &os, } return os; } -namespace ur_params { - -template <> -inline void serializeFlag(std::ostream &os, uint32_t flag) { - uint32_t val = flag; - bool first = true; - - if ((val & UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK) == - (uint32_t)UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK) { - val ^= (uint32_t)UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK; - } - if (val != 0) { - std::bitset<32> bits(val); - if (!first) { - os << " | "; - } - os << "unknown bit flags " << bits; - } else if (first) { - os << "0"; - } -} -} // namespace ur_params -inline std::ostream &operator<<(std::ostream &os, enum ur_usm_type_t value) { +inline std::ostream &operator<<(std::ostream &os, + enum ur_sampler_addressing_mode_t value) { switch (value) { - case UR_USM_TYPE_UNKNOWN: - os << "UR_USM_TYPE_UNKNOWN"; + case UR_SAMPLER_ADDRESSING_MODE_NONE: + os << "UR_SAMPLER_ADDRESSING_MODE_NONE"; break; - case UR_USM_TYPE_HOST: - os << "UR_USM_TYPE_HOST"; + case UR_SAMPLER_ADDRESSING_MODE_CLAMP_TO_EDGE: + os << "UR_SAMPLER_ADDRESSING_MODE_CLAMP_TO_EDGE"; break; - case UR_USM_TYPE_DEVICE: - os << "UR_USM_TYPE_DEVICE"; + case UR_SAMPLER_ADDRESSING_MODE_CLAMP: + os << "UR_SAMPLER_ADDRESSING_MODE_CLAMP"; break; - case UR_USM_TYPE_SHARED: - os << "UR_USM_TYPE_SHARED"; + case UR_SAMPLER_ADDRESSING_MODE_REPEAT: + os << "UR_SAMPLER_ADDRESSING_MODE_REPEAT"; + break; + + case UR_SAMPLER_ADDRESSING_MODE_MIRRORED_REPEAT: + os << "UR_SAMPLER_ADDRESSING_MODE_MIRRORED_REPEAT"; break; default: os << "unknown enumerator"; @@ -5900,27 +6448,27 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_usm_type_t value) { return os; } inline std::ostream &operator<<(std::ostream &os, - enum ur_usm_alloc_info_t value) { + enum ur_sampler_info_t value) { switch (value) { - case UR_USM_ALLOC_INFO_TYPE: - os << "UR_USM_ALLOC_INFO_TYPE"; + case UR_SAMPLER_INFO_REFERENCE_COUNT: + os << "UR_SAMPLER_INFO_REFERENCE_COUNT"; break; - case UR_USM_ALLOC_INFO_BASE_PTR: - os << "UR_USM_ALLOC_INFO_BASE_PTR"; + case UR_SAMPLER_INFO_CONTEXT: + os << "UR_SAMPLER_INFO_CONTEXT"; break; - case UR_USM_ALLOC_INFO_SIZE: - os << "UR_USM_ALLOC_INFO_SIZE"; + case UR_SAMPLER_INFO_NORMALIZED_COORDS: + os << "UR_SAMPLER_INFO_NORMALIZED_COORDS"; break; - case UR_USM_ALLOC_INFO_DEVICE: - os << "UR_USM_ALLOC_INFO_DEVICE"; + case UR_SAMPLER_INFO_ADDRESSING_MODE: + os << "UR_SAMPLER_INFO_ADDRESSING_MODE"; break; - case UR_USM_ALLOC_INFO_POOL: - os << "UR_USM_ALLOC_INFO_POOL"; + case UR_SAMPLER_INFO_FILTER_MODE: + os << "UR_SAMPLER_INFO_FILTER_MODE"; break; default: os << "unknown enumerator"; @@ -5931,7 +6479,7 @@ inline std::ostream &operator<<(std::ostream &os, namespace ur_params { template <> inline void serializeTagged(std::ostream &os, const void *ptr, - ur_usm_alloc_info_t value, size_t size) { + ur_sampler_info_t value, size_t size) { if (ptr == NULL) { serializePtr(os, ptr); return; @@ -5939,11 +6487,11 @@ inline void serializeTagged(std::ostream &os, const void *ptr, switch (value) { - case UR_USM_ALLOC_INFO_TYPE: { - const ur_usm_type_t *tptr = (const ur_usm_type_t *)ptr; - if (sizeof(ur_usm_type_t) > size) { + case UR_SAMPLER_INFO_REFERENCE_COUNT: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_usm_type_t) << ")"; + << ", expected: >=" << sizeof(uint32_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -5953,25 +6501,25 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_USM_ALLOC_INFO_BASE_PTR: { - const void **tptr = (const void **)ptr; - if (sizeof(void *) > size) { + case UR_SAMPLER_INFO_CONTEXT: { + const ur_context_handle_t *tptr = (const ur_context_handle_t *)ptr; + if (sizeof(ur_context_handle_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(void *) << ")"; + << ", expected: >=" << sizeof(ur_context_handle_t) << ")"; return; } os << (void *)(tptr) << " ("; - os << *tptr; + ur_params::serializePtr(os, *tptr); os << ")"; } break; - case UR_USM_ALLOC_INFO_SIZE: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { + case UR_SAMPLER_INFO_NORMALIZED_COORDS: { + const ur_bool_t *tptr = (const ur_bool_t *)ptr; + if (sizeof(ur_bool_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; + << ", expected: >=" << sizeof(ur_bool_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -5981,30 +6529,33 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_USM_ALLOC_INFO_DEVICE: { - const ur_device_handle_t *tptr = (const ur_device_handle_t *)ptr; - if (sizeof(ur_device_handle_t) > size) { + case UR_SAMPLER_INFO_ADDRESSING_MODE: { + const ur_sampler_addressing_mode_t *tptr = + (const ur_sampler_addressing_mode_t *)ptr; + if (sizeof(ur_sampler_addressing_mode_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_device_handle_t) << ")"; + << ", expected: >=" << sizeof(ur_sampler_addressing_mode_t) + << ")"; return; } os << (void *)(tptr) << " ("; - ur_params::serializePtr(os, *tptr); + os << *tptr; os << ")"; } break; - case UR_USM_ALLOC_INFO_POOL: { - const ur_usm_pool_handle_t *tptr = (const ur_usm_pool_handle_t *)ptr; - if (sizeof(ur_usm_pool_handle_t) > size) { + case UR_SAMPLER_INFO_FILTER_MODE: { + const ur_sampler_filter_mode_t *tptr = + (const ur_sampler_filter_mode_t *)ptr; + if (sizeof(ur_sampler_filter_mode_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_usm_pool_handle_t) << ")"; + << ", expected: >=" << sizeof(ur_sampler_filter_mode_t) << ")"; return; } os << (void *)(tptr) << " ("; - ur_params::serializePtr(os, *tptr); + os << *tptr; os << ")"; } break; @@ -6015,245 +6566,160 @@ inline void serializeTagged(std::ostream &os, const void *ptr, } } // namespace ur_params inline std::ostream &operator<<(std::ostream &os, - enum ur_usm_advice_flag_t value) { - switch (value) { - - case UR_USM_ADVICE_FLAG_DEFAULT: - os << "UR_USM_ADVICE_FLAG_DEFAULT"; - break; - - case UR_USM_ADVICE_FLAG_SET_READ_MOSTLY: - os << "UR_USM_ADVICE_FLAG_SET_READ_MOSTLY"; - break; - - case UR_USM_ADVICE_FLAG_CLEAR_READ_MOSTLY: - os << "UR_USM_ADVICE_FLAG_CLEAR_READ_MOSTLY"; - break; - - case UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION: - os << "UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION"; - break; + const struct ur_sampler_desc_t params) { + os << "(struct ur_sampler_desc_t){"; - case UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION: - os << "UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION"; - break; + os << ".stype = "; - case UR_USM_ADVICE_FLAG_SET_NON_ATOMIC_MOSTLY: - os << "UR_USM_ADVICE_FLAG_SET_NON_ATOMIC_MOSTLY"; - break; + os << (params.stype); - case UR_USM_ADVICE_FLAG_CLEAR_NON_ATOMIC_MOSTLY: - os << "UR_USM_ADVICE_FLAG_CLEAR_NON_ATOMIC_MOSTLY"; - break; + os << ", "; + os << ".pNext = "; - case UR_USM_ADVICE_FLAG_BIAS_CACHED: - os << "UR_USM_ADVICE_FLAG_BIAS_CACHED"; - break; + ur_params::serializeStruct(os, (params.pNext)); - case UR_USM_ADVICE_FLAG_BIAS_UNCACHED: - os << "UR_USM_ADVICE_FLAG_BIAS_UNCACHED"; - break; + os << ", "; + os << ".normalizedCoords = "; - case UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_DEVICE: - os << "UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_DEVICE"; - break; + os << (params.normalizedCoords); - case UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_DEVICE: - os << "UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_DEVICE"; - break; + os << ", "; + os << ".addressingMode = "; - case UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_HOST: - os << "UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_HOST"; - break; + os << (params.addressingMode); - case UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_HOST: - os << "UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_HOST"; - break; + os << ", "; + os << ".filterMode = "; - case UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION_HOST: - os << "UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION_HOST"; - break; + os << (params.filterMode); - case UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION_HOST: - os << "UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION_HOST"; - break; - default: - os << "unknown enumerator"; - break; - } + os << "}"; return os; } -namespace ur_params { - -template <> -inline void serializeFlag(std::ostream &os, - uint32_t flag) { - uint32_t val = flag; - bool first = true; - - if ((val & UR_USM_ADVICE_FLAG_DEFAULT) == - (uint32_t)UR_USM_ADVICE_FLAG_DEFAULT) { - val ^= (uint32_t)UR_USM_ADVICE_FLAG_DEFAULT; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_USM_ADVICE_FLAG_DEFAULT; - } +inline std::ostream & +operator<<(std::ostream &os, + const struct ur_sampler_native_properties_t params) { + os << "(struct ur_sampler_native_properties_t){"; - if ((val & UR_USM_ADVICE_FLAG_SET_READ_MOSTLY) == - (uint32_t)UR_USM_ADVICE_FLAG_SET_READ_MOSTLY) { - val ^= (uint32_t)UR_USM_ADVICE_FLAG_SET_READ_MOSTLY; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_USM_ADVICE_FLAG_SET_READ_MOSTLY; - } + os << ".stype = "; - if ((val & UR_USM_ADVICE_FLAG_CLEAR_READ_MOSTLY) == - (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_READ_MOSTLY) { - val ^= (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_READ_MOSTLY; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_USM_ADVICE_FLAG_CLEAR_READ_MOSTLY; - } + os << (params.stype); - if ((val & UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION) == - (uint32_t)UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION) { - val ^= (uint32_t)UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION; - } + os << ", "; + os << ".pNext = "; - if ((val & UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION) == - (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION) { - val ^= (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION; - } + ur_params::serializeStruct(os, (params.pNext)); - if ((val & UR_USM_ADVICE_FLAG_SET_NON_ATOMIC_MOSTLY) == - (uint32_t)UR_USM_ADVICE_FLAG_SET_NON_ATOMIC_MOSTLY) { - val ^= (uint32_t)UR_USM_ADVICE_FLAG_SET_NON_ATOMIC_MOSTLY; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_USM_ADVICE_FLAG_SET_NON_ATOMIC_MOSTLY; - } + os << ", "; + os << ".isNativeHandleOwned = "; - if ((val & UR_USM_ADVICE_FLAG_CLEAR_NON_ATOMIC_MOSTLY) == - (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_NON_ATOMIC_MOSTLY) { - val ^= (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_NON_ATOMIC_MOSTLY; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_USM_ADVICE_FLAG_CLEAR_NON_ATOMIC_MOSTLY; - } + os << (params.isNativeHandleOwned); - if ((val & UR_USM_ADVICE_FLAG_BIAS_CACHED) == - (uint32_t)UR_USM_ADVICE_FLAG_BIAS_CACHED) { - val ^= (uint32_t)UR_USM_ADVICE_FLAG_BIAS_CACHED; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_USM_ADVICE_FLAG_BIAS_CACHED; - } + os << "}"; + return os; +} +inline std::ostream &operator<<(std::ostream &os, + enum ur_usm_host_mem_flag_t value) { + switch (value) { - if ((val & UR_USM_ADVICE_FLAG_BIAS_UNCACHED) == - (uint32_t)UR_USM_ADVICE_FLAG_BIAS_UNCACHED) { - val ^= (uint32_t)UR_USM_ADVICE_FLAG_BIAS_UNCACHED; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_USM_ADVICE_FLAG_BIAS_UNCACHED; + case UR_USM_HOST_MEM_FLAG_INITIAL_PLACEMENT: + os << "UR_USM_HOST_MEM_FLAG_INITIAL_PLACEMENT"; + break; + default: + os << "unknown enumerator"; + break; } + return os; +} +namespace ur_params { - if ((val & UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_DEVICE) == - (uint32_t)UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_DEVICE) { - val ^= (uint32_t)UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_DEVICE; +template <> +inline void serializeFlag(std::ostream &os, + uint32_t flag) { + uint32_t val = flag; + bool first = true; + + if ((val & UR_USM_HOST_MEM_FLAG_INITIAL_PLACEMENT) == + (uint32_t)UR_USM_HOST_MEM_FLAG_INITIAL_PLACEMENT) { + val ^= (uint32_t)UR_USM_HOST_MEM_FLAG_INITIAL_PLACEMENT; if (!first) { os << " | "; } else { first = false; } - os << UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_DEVICE; + os << UR_USM_HOST_MEM_FLAG_INITIAL_PLACEMENT; } - - if ((val & UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_DEVICE) == - (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_DEVICE) { - val ^= (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_DEVICE; + if (val != 0) { + std::bitset<32> bits(val); if (!first) { os << " | "; - } else { - first = false; } - os << UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_DEVICE; + os << "unknown bit flags " << bits; + } else if (first) { + os << "0"; } +} +} // namespace ur_params +inline std::ostream &operator<<(std::ostream &os, + enum ur_usm_device_mem_flag_t value) { + switch (value) { - if ((val & UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_HOST) == - (uint32_t)UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_HOST) { - val ^= (uint32_t)UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_HOST; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_HOST; + case UR_USM_DEVICE_MEM_FLAG_WRITE_COMBINED: + os << "UR_USM_DEVICE_MEM_FLAG_WRITE_COMBINED"; + break; + + case UR_USM_DEVICE_MEM_FLAG_INITIAL_PLACEMENT: + os << "UR_USM_DEVICE_MEM_FLAG_INITIAL_PLACEMENT"; + break; + + case UR_USM_DEVICE_MEM_FLAG_DEVICE_READ_ONLY: + os << "UR_USM_DEVICE_MEM_FLAG_DEVICE_READ_ONLY"; + break; + default: + os << "unknown enumerator"; + break; } + return os; +} +namespace ur_params { - if ((val & UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_HOST) == - (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_HOST) { - val ^= (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_HOST; +template <> +inline void serializeFlag(std::ostream &os, + uint32_t flag) { + uint32_t val = flag; + bool first = true; + + if ((val & UR_USM_DEVICE_MEM_FLAG_WRITE_COMBINED) == + (uint32_t)UR_USM_DEVICE_MEM_FLAG_WRITE_COMBINED) { + val ^= (uint32_t)UR_USM_DEVICE_MEM_FLAG_WRITE_COMBINED; if (!first) { os << " | "; } else { first = false; } - os << UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_HOST; + os << UR_USM_DEVICE_MEM_FLAG_WRITE_COMBINED; } - if ((val & UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION_HOST) == - (uint32_t)UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION_HOST) { - val ^= (uint32_t)UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION_HOST; + if ((val & UR_USM_DEVICE_MEM_FLAG_INITIAL_PLACEMENT) == + (uint32_t)UR_USM_DEVICE_MEM_FLAG_INITIAL_PLACEMENT) { + val ^= (uint32_t)UR_USM_DEVICE_MEM_FLAG_INITIAL_PLACEMENT; if (!first) { os << " | "; } else { first = false; } - os << UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION_HOST; + os << UR_USM_DEVICE_MEM_FLAG_INITIAL_PLACEMENT; } - if ((val & UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION_HOST) == - (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION_HOST) { - val ^= (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION_HOST; + if ((val & UR_USM_DEVICE_MEM_FLAG_DEVICE_READ_ONLY) == + (uint32_t)UR_USM_DEVICE_MEM_FLAG_DEVICE_READ_ONLY) { + val ^= (uint32_t)UR_USM_DEVICE_MEM_FLAG_DEVICE_READ_ONLY; if (!first) { os << " | "; } else { first = false; } - os << UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION_HOST; + os << UR_USM_DEVICE_MEM_FLAG_DEVICE_READ_ONLY; } if (val != 0) { std::bitset<32> bits(val); @@ -6267,130 +6733,92 @@ inline void serializeFlag(std::ostream &os, } } // namespace ur_params inline std::ostream &operator<<(std::ostream &os, - const struct ur_usm_desc_t params) { - os << "(struct ur_usm_desc_t){"; - - os << ".stype = "; - - os << (params.stype); - - os << ", "; - os << ".pNext = "; - - ur_params::serializeStruct(os, (params.pNext)); - - os << ", "; - os << ".hints = "; - - ur_params::serializeFlag(os, (params.hints)); - - os << ", "; - os << ".align = "; - - os << (params.align); - - os << "}"; - return os; -} -inline std::ostream &operator<<(std::ostream &os, - const struct ur_usm_host_desc_t params) { - os << "(struct ur_usm_host_desc_t){"; - - os << ".stype = "; - - os << (params.stype); - - os << ", "; - os << ".pNext = "; - - ur_params::serializeStruct(os, (params.pNext)); - - os << ", "; - os << ".flags = "; - - ur_params::serializeFlag(os, (params.flags)); + enum ur_usm_pool_flag_t value) { + switch (value) { - os << "}"; + case UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK: + os << "UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK"; + break; + default: + os << "unknown enumerator"; + break; + } return os; } -inline std::ostream &operator<<(std::ostream &os, - const struct ur_usm_device_desc_t params) { - os << "(struct ur_usm_device_desc_t){"; - - os << ".stype = "; - - os << (params.stype); - - os << ", "; - os << ".pNext = "; - - ur_params::serializeStruct(os, (params.pNext)); - - os << ", "; - os << ".flags = "; +namespace ur_params { - ur_params::serializeFlag(os, (params.flags)); +template <> +inline void serializeFlag(std::ostream &os, uint32_t flag) { + uint32_t val = flag; + bool first = true; - os << "}"; - return os; + if ((val & UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK) == + (uint32_t)UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK) { + val ^= (uint32_t)UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK; + } + if (val != 0) { + std::bitset<32> bits(val); + if (!first) { + os << " | "; + } + os << "unknown bit flags " << bits; + } else if (first) { + os << "0"; + } } -inline std::ostream &operator<<(std::ostream &os, - const struct ur_usm_pool_desc_t params) { - os << "(struct ur_usm_pool_desc_t){"; - - os << ".stype = "; - - os << (params.stype); - - os << ", "; - os << ".pNext = "; +} // namespace ur_params +inline std::ostream &operator<<(std::ostream &os, enum ur_usm_type_t value) { + switch (value) { - ur_params::serializeStruct(os, (params.pNext)); + case UR_USM_TYPE_UNKNOWN: + os << "UR_USM_TYPE_UNKNOWN"; + break; - os << ", "; - os << ".flags = "; + case UR_USM_TYPE_HOST: + os << "UR_USM_TYPE_HOST"; + break; - ur_params::serializeFlag(os, (params.flags)); + case UR_USM_TYPE_DEVICE: + os << "UR_USM_TYPE_DEVICE"; + break; - os << "}"; + case UR_USM_TYPE_SHARED: + os << "UR_USM_TYPE_SHARED"; + break; + default: + os << "unknown enumerator"; + break; + } return os; } inline std::ostream &operator<<(std::ostream &os, - const struct ur_usm_pool_limits_desc_t params) { - os << "(struct ur_usm_pool_limits_desc_t){"; - - os << ".stype = "; - - os << (params.stype); - - os << ", "; - os << ".pNext = "; - - ur_params::serializeStruct(os, (params.pNext)); - - os << ", "; - os << ".maxPoolableSize = "; - - os << (params.maxPoolableSize); + enum ur_usm_alloc_info_t value) { + switch (value) { - os << ", "; - os << ".minDriverAllocSize = "; + case UR_USM_ALLOC_INFO_TYPE: + os << "UR_USM_ALLOC_INFO_TYPE"; + break; - os << (params.minDriverAllocSize); + case UR_USM_ALLOC_INFO_BASE_PTR: + os << "UR_USM_ALLOC_INFO_BASE_PTR"; + break; - os << "}"; - return os; -} -inline std::ostream &operator<<(std::ostream &os, - enum ur_usm_pool_info_t value) { - switch (value) { + case UR_USM_ALLOC_INFO_SIZE: + os << "UR_USM_ALLOC_INFO_SIZE"; + break; - case UR_USM_POOL_INFO_REFERENCE_COUNT: - os << "UR_USM_POOL_INFO_REFERENCE_COUNT"; + case UR_USM_ALLOC_INFO_DEVICE: + os << "UR_USM_ALLOC_INFO_DEVICE"; break; - case UR_USM_POOL_INFO_CONTEXT: - os << "UR_USM_POOL_INFO_CONTEXT"; + case UR_USM_ALLOC_INFO_POOL: + os << "UR_USM_ALLOC_INFO_POOL"; break; default: os << "unknown enumerator"; @@ -6401,7 +6829,7 @@ inline std::ostream &operator<<(std::ostream &os, namespace ur_params { template <> inline void serializeTagged(std::ostream &os, const void *ptr, - ur_usm_pool_info_t value, size_t size) { + ur_usm_alloc_info_t value, size_t size) { if (ptr == NULL) { serializePtr(os, ptr); return; @@ -6409,11 +6837,11 @@ inline void serializeTagged(std::ostream &os, const void *ptr, switch (value) { - case UR_USM_POOL_INFO_REFERENCE_COUNT: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { + case UR_USM_ALLOC_INFO_TYPE: { + const ur_usm_type_t *tptr = (const ur_usm_type_t *)ptr; + if (sizeof(ur_usm_type_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; + << ", expected: >=" << sizeof(ur_usm_type_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -6423,55 +6851,21 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_USM_POOL_INFO_CONTEXT: { - const ur_context_handle_t *tptr = (const ur_context_handle_t *)ptr; - if (sizeof(ur_context_handle_t) > size) { + case UR_USM_ALLOC_INFO_BASE_PTR: { + const void **tptr = (const void **)ptr; + if (sizeof(void *) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_context_handle_t) << ")"; + << ", expected: >=" << sizeof(void *) << ")"; return; } os << (void *)(tptr) << " ("; - ur_params::serializePtr(os, *tptr); + os << *tptr; os << ")"; } break; - default: - os << "unknown enumerator"; - break; - } -} -} // namespace ur_params -inline std::ostream &operator<<(std::ostream &os, - enum ur_virtual_mem_granularity_info_t value) { - switch (value) { - - case UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM: - os << "UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM"; - break; - - case UR_VIRTUAL_MEM_GRANULARITY_INFO_RECOMMENDED: - os << "UR_VIRTUAL_MEM_GRANULARITY_INFO_RECOMMENDED"; - break; - default: - os << "unknown enumerator"; - break; - } - return os; -} -namespace ur_params { -template <> -inline void serializeTagged(std::ostream &os, const void *ptr, - ur_virtual_mem_granularity_info_t value, - size_t size) { - if (ptr == NULL) { - serializePtr(os, ptr); - return; - } - - switch (value) { - case UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM: { + case UR_USM_ALLOC_INFO_SIZE: { const size_t *tptr = (const size_t *)ptr; if (sizeof(size_t) > size) { os << "invalid size (is: " << size @@ -6485,16 +6879,30 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_VIRTUAL_MEM_GRANULARITY_INFO_RECOMMENDED: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { + case UR_USM_ALLOC_INFO_DEVICE: { + const ur_device_handle_t *tptr = (const ur_device_handle_t *)ptr; + if (sizeof(ur_device_handle_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; + << ", expected: >=" << sizeof(ur_device_handle_t) << ")"; return; } os << (void *)(tptr) << " ("; - os << *tptr; + ur_params::serializePtr(os, *tptr); + + os << ")"; + } break; + + case UR_USM_ALLOC_INFO_POOL: { + const ur_usm_pool_handle_t *tptr = (const ur_usm_pool_handle_t *)ptr; + if (sizeof(ur_usm_pool_handle_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_usm_pool_handle_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + ur_params::serializePtr(os, *tptr); os << ")"; } break; @@ -6505,19 +6913,67 @@ inline void serializeTagged(std::ostream &os, const void *ptr, } } // namespace ur_params inline std::ostream &operator<<(std::ostream &os, - enum ur_virtual_mem_access_flag_t value) { + enum ur_usm_advice_flag_t value) { switch (value) { - case UR_VIRTUAL_MEM_ACCESS_FLAG_NONE: - os << "UR_VIRTUAL_MEM_ACCESS_FLAG_NONE"; + case UR_USM_ADVICE_FLAG_DEFAULT: + os << "UR_USM_ADVICE_FLAG_DEFAULT"; break; - case UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE: - os << "UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE"; + case UR_USM_ADVICE_FLAG_SET_READ_MOSTLY: + os << "UR_USM_ADVICE_FLAG_SET_READ_MOSTLY"; break; - case UR_VIRTUAL_MEM_ACCESS_FLAG_READ_ONLY: - os << "UR_VIRTUAL_MEM_ACCESS_FLAG_READ_ONLY"; + case UR_USM_ADVICE_FLAG_CLEAR_READ_MOSTLY: + os << "UR_USM_ADVICE_FLAG_CLEAR_READ_MOSTLY"; + break; + + case UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION: + os << "UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION"; + break; + + case UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION: + os << "UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION"; + break; + + case UR_USM_ADVICE_FLAG_SET_NON_ATOMIC_MOSTLY: + os << "UR_USM_ADVICE_FLAG_SET_NON_ATOMIC_MOSTLY"; + break; + + case UR_USM_ADVICE_FLAG_CLEAR_NON_ATOMIC_MOSTLY: + os << "UR_USM_ADVICE_FLAG_CLEAR_NON_ATOMIC_MOSTLY"; + break; + + case UR_USM_ADVICE_FLAG_BIAS_CACHED: + os << "UR_USM_ADVICE_FLAG_BIAS_CACHED"; + break; + + case UR_USM_ADVICE_FLAG_BIAS_UNCACHED: + os << "UR_USM_ADVICE_FLAG_BIAS_UNCACHED"; + break; + + case UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_DEVICE: + os << "UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_DEVICE"; + break; + + case UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_DEVICE: + os << "UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_DEVICE"; + break; + + case UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_HOST: + os << "UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_HOST"; + break; + + case UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_HOST: + os << "UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_HOST"; + break; + + case UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION_HOST: + os << "UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION_HOST"; + break; + + case UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION_HOST: + os << "UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION_HOST"; break; default: os << "unknown enumerator"; @@ -6528,129 +6984,174 @@ inline std::ostream &operator<<(std::ostream &os, namespace ur_params { template <> -inline void serializeFlag(std::ostream &os, - uint32_t flag) { +inline void serializeFlag(std::ostream &os, + uint32_t flag) { uint32_t val = flag; bool first = true; - if ((val & UR_VIRTUAL_MEM_ACCESS_FLAG_NONE) == - (uint32_t)UR_VIRTUAL_MEM_ACCESS_FLAG_NONE) { - val ^= (uint32_t)UR_VIRTUAL_MEM_ACCESS_FLAG_NONE; + if ((val & UR_USM_ADVICE_FLAG_DEFAULT) == + (uint32_t)UR_USM_ADVICE_FLAG_DEFAULT) { + val ^= (uint32_t)UR_USM_ADVICE_FLAG_DEFAULT; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_USM_ADVICE_FLAG_DEFAULT; + } + + if ((val & UR_USM_ADVICE_FLAG_SET_READ_MOSTLY) == + (uint32_t)UR_USM_ADVICE_FLAG_SET_READ_MOSTLY) { + val ^= (uint32_t)UR_USM_ADVICE_FLAG_SET_READ_MOSTLY; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_USM_ADVICE_FLAG_SET_READ_MOSTLY; + } + + if ((val & UR_USM_ADVICE_FLAG_CLEAR_READ_MOSTLY) == + (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_READ_MOSTLY) { + val ^= (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_READ_MOSTLY; if (!first) { os << " | "; } else { first = false; } - os << UR_VIRTUAL_MEM_ACCESS_FLAG_NONE; + os << UR_USM_ADVICE_FLAG_CLEAR_READ_MOSTLY; } - if ((val & UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE) == - (uint32_t)UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE) { - val ^= (uint32_t)UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE; + if ((val & UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION) == + (uint32_t)UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION) { + val ^= (uint32_t)UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION; if (!first) { os << " | "; } else { first = false; } - os << UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE; + os << UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION; } - if ((val & UR_VIRTUAL_MEM_ACCESS_FLAG_READ_ONLY) == - (uint32_t)UR_VIRTUAL_MEM_ACCESS_FLAG_READ_ONLY) { - val ^= (uint32_t)UR_VIRTUAL_MEM_ACCESS_FLAG_READ_ONLY; + if ((val & UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION) == + (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION) { + val ^= (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION; if (!first) { os << " | "; } else { first = false; } - os << UR_VIRTUAL_MEM_ACCESS_FLAG_READ_ONLY; + os << UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION; } - if (val != 0) { - std::bitset<32> bits(val); + + if ((val & UR_USM_ADVICE_FLAG_SET_NON_ATOMIC_MOSTLY) == + (uint32_t)UR_USM_ADVICE_FLAG_SET_NON_ATOMIC_MOSTLY) { + val ^= (uint32_t)UR_USM_ADVICE_FLAG_SET_NON_ATOMIC_MOSTLY; if (!first) { os << " | "; + } else { + first = false; } - os << "unknown bit flags " << bits; - } else if (first) { - os << "0"; + os << UR_USM_ADVICE_FLAG_SET_NON_ATOMIC_MOSTLY; } -} -} // namespace ur_params -inline std::ostream &operator<<(std::ostream &os, - enum ur_virtual_mem_info_t value) { - switch (value) { - case UR_VIRTUAL_MEM_INFO_ACCESS_MODE: - os << "UR_VIRTUAL_MEM_INFO_ACCESS_MODE"; - break; - default: - os << "unknown enumerator"; - break; + if ((val & UR_USM_ADVICE_FLAG_CLEAR_NON_ATOMIC_MOSTLY) == + (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_NON_ATOMIC_MOSTLY) { + val ^= (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_NON_ATOMIC_MOSTLY; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_USM_ADVICE_FLAG_CLEAR_NON_ATOMIC_MOSTLY; } - return os; -} -namespace ur_params { -template <> -inline void serializeTagged(std::ostream &os, const void *ptr, - ur_virtual_mem_info_t value, size_t size) { - if (ptr == NULL) { - serializePtr(os, ptr); - return; + + if ((val & UR_USM_ADVICE_FLAG_BIAS_CACHED) == + (uint32_t)UR_USM_ADVICE_FLAG_BIAS_CACHED) { + val ^= (uint32_t)UR_USM_ADVICE_FLAG_BIAS_CACHED; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_USM_ADVICE_FLAG_BIAS_CACHED; } - switch (value) { + if ((val & UR_USM_ADVICE_FLAG_BIAS_UNCACHED) == + (uint32_t)UR_USM_ADVICE_FLAG_BIAS_UNCACHED) { + val ^= (uint32_t)UR_USM_ADVICE_FLAG_BIAS_UNCACHED; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_USM_ADVICE_FLAG_BIAS_UNCACHED; + } - case UR_VIRTUAL_MEM_INFO_ACCESS_MODE: { - const ur_virtual_mem_access_flags_t *tptr = - (const ur_virtual_mem_access_flags_t *)ptr; - if (sizeof(ur_virtual_mem_access_flags_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_virtual_mem_access_flags_t) - << ")"; - return; + if ((val & UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_DEVICE) == + (uint32_t)UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_DEVICE) { + val ^= (uint32_t)UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_DEVICE; + if (!first) { + os << " | "; + } else { + first = false; } - os << (void *)(tptr) << " ("; + os << UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_DEVICE; + } - ur_params::serializeFlag(os, *tptr); + if ((val & UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_DEVICE) == + (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_DEVICE) { + val ^= (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_DEVICE; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_DEVICE; + } - os << ")"; - } break; - default: - os << "unknown enumerator"; - break; + if ((val & UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_HOST) == + (uint32_t)UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_HOST) { + val ^= (uint32_t)UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_HOST; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_HOST; } -} -} // namespace ur_params -inline std::ostream &operator<<(std::ostream &os, - enum ur_physical_mem_flag_t value) { - switch (value) { - case UR_PHYSICAL_MEM_FLAG_TBD: - os << "UR_PHYSICAL_MEM_FLAG_TBD"; - break; - default: - os << "unknown enumerator"; - break; + if ((val & UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_HOST) == + (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_HOST) { + val ^= (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_HOST; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_HOST; } - return os; -} -namespace ur_params { -template <> -inline void serializeFlag(std::ostream &os, - uint32_t flag) { - uint32_t val = flag; - bool first = true; + if ((val & UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION_HOST) == + (uint32_t)UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION_HOST) { + val ^= (uint32_t)UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION_HOST; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION_HOST; + } - if ((val & UR_PHYSICAL_MEM_FLAG_TBD) == - (uint32_t)UR_PHYSICAL_MEM_FLAG_TBD) { - val ^= (uint32_t)UR_PHYSICAL_MEM_FLAG_TBD; + if ((val & UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION_HOST) == + (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION_HOST) { + val ^= (uint32_t)UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION_HOST; if (!first) { os << " | "; } else { first = false; } - os << UR_PHYSICAL_MEM_FLAG_TBD; + os << UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION_HOST; } if (val != 0) { std::bitset<32> bits(val); @@ -6663,9 +7164,9 @@ inline void serializeFlag(std::ostream &os, } } } // namespace ur_params -inline std::ostream & -operator<<(std::ostream &os, const struct ur_physical_mem_properties_t params) { - os << "(struct ur_physical_mem_properties_t){"; +inline std::ostream &operator<<(std::ostream &os, + const struct ur_usm_desc_t params) { + os << "(struct ur_usm_desc_t){"; os << ".stype = "; @@ -6677,93 +7178,84 @@ operator<<(std::ostream &os, const struct ur_physical_mem_properties_t params) { ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".flags = "; + os << ".hints = "; - ur_params::serializeFlag(os, (params.flags)); + ur_params::serializeFlag(os, (params.hints)); + + os << ", "; + os << ".align = "; + + os << (params.align); os << "}"; return os; } inline std::ostream &operator<<(std::ostream &os, - enum ur_program_metadata_type_t value) { - switch (value) { + const struct ur_usm_host_desc_t params) { + os << "(struct ur_usm_host_desc_t){"; - case UR_PROGRAM_METADATA_TYPE_UINT32: - os << "UR_PROGRAM_METADATA_TYPE_UINT32"; - break; + os << ".stype = "; - case UR_PROGRAM_METADATA_TYPE_UINT64: - os << "UR_PROGRAM_METADATA_TYPE_UINT64"; - break; + os << (params.stype); - case UR_PROGRAM_METADATA_TYPE_BYTE_ARRAY: - os << "UR_PROGRAM_METADATA_TYPE_BYTE_ARRAY"; - break; + os << ", "; + os << ".pNext = "; - case UR_PROGRAM_METADATA_TYPE_STRING: - os << "UR_PROGRAM_METADATA_TYPE_STRING"; - break; - default: - os << "unknown enumerator"; - break; - } - return os; -} -inline std::ostream & -operator<<(std::ostream &os, const union ur_program_metadata_value_t params) { - os << "(union ur_program_metadata_value_t){"; + ur_params::serializeStruct(os, (params.pNext)); - os << ".data32 = "; + os << ", "; + os << ".flags = "; - os << (params.data32); + ur_params::serializeFlag(os, (params.flags)); - os << ", "; - os << ".data64 = "; + os << "}"; + return os; +} +inline std::ostream &operator<<(std::ostream &os, + const struct ur_usm_device_desc_t params) { + os << "(struct ur_usm_device_desc_t){"; - os << (params.data64); + os << ".stype = "; + + os << (params.stype); os << ", "; - os << ".pString = "; + os << ".pNext = "; - ur_params::serializePtr(os, (params.pString)); + ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".pData = "; + os << ".flags = "; - ur_params::serializePtr(os, (params.pData)); + ur_params::serializeFlag(os, (params.flags)); os << "}"; return os; } inline std::ostream &operator<<(std::ostream &os, - const struct ur_program_metadata_t params) { - os << "(struct ur_program_metadata_t){"; - - os << ".pName = "; - - ur_params::serializePtr(os, (params.pName)); + const struct ur_usm_pool_desc_t params) { + os << "(struct ur_usm_pool_desc_t){"; - os << ", "; - os << ".type = "; + os << ".stype = "; - os << (params.type); + os << (params.stype); os << ", "; - os << ".size = "; + os << ".pNext = "; - os << (params.size); + ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".value = "; + os << ".flags = "; - os << (params.value); + ur_params::serializeFlag(os, (params.flags)); os << "}"; return os; } inline std::ostream &operator<<(std::ostream &os, - const struct ur_program_properties_t params) { - os << "(struct ur_program_properties_t){"; + const struct ur_usm_pool_limits_desc_t params) { + os << "(struct ur_usm_pool_limits_desc_t){"; os << ".stype = "; @@ -6775,62 +7267,28 @@ inline std::ostream &operator<<(std::ostream &os, ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".count = "; + os << ".maxPoolableSize = "; - os << (params.count); + os << (params.maxPoolableSize); os << ", "; - os << ".pMetadatas = {"; - for (size_t i = 0; (params.pMetadatas) != NULL && i < params.count; ++i) { - if (i != 0) { - os << ", "; - } + os << ".minDriverAllocSize = "; - os << ((params.pMetadatas))[i]; - } - os << "}"; + os << (params.minDriverAllocSize); os << "}"; return os; } inline std::ostream &operator<<(std::ostream &os, - enum ur_program_info_t value) { + enum ur_usm_pool_info_t value) { switch (value) { - case UR_PROGRAM_INFO_REFERENCE_COUNT: - os << "UR_PROGRAM_INFO_REFERENCE_COUNT"; - break; - - case UR_PROGRAM_INFO_CONTEXT: - os << "UR_PROGRAM_INFO_CONTEXT"; - break; - - case UR_PROGRAM_INFO_NUM_DEVICES: - os << "UR_PROGRAM_INFO_NUM_DEVICES"; - break; - - case UR_PROGRAM_INFO_DEVICES: - os << "UR_PROGRAM_INFO_DEVICES"; - break; - - case UR_PROGRAM_INFO_SOURCE: - os << "UR_PROGRAM_INFO_SOURCE"; - break; - - case UR_PROGRAM_INFO_BINARY_SIZES: - os << "UR_PROGRAM_INFO_BINARY_SIZES"; - break; - - case UR_PROGRAM_INFO_BINARIES: - os << "UR_PROGRAM_INFO_BINARIES"; - break; - - case UR_PROGRAM_INFO_NUM_KERNELS: - os << "UR_PROGRAM_INFO_NUM_KERNELS"; + case UR_USM_POOL_INFO_REFERENCE_COUNT: + os << "UR_USM_POOL_INFO_REFERENCE_COUNT"; break; - case UR_PROGRAM_INFO_KERNEL_NAMES: - os << "UR_PROGRAM_INFO_KERNEL_NAMES"; + case UR_USM_POOL_INFO_CONTEXT: + os << "UR_USM_POOL_INFO_CONTEXT"; break; default: os << "unknown enumerator"; @@ -6841,7 +7299,7 @@ inline std::ostream &operator<<(std::ostream &os, namespace ur_params { template <> inline void serializeTagged(std::ostream &os, const void *ptr, - ur_program_info_t value, size_t size) { + ur_usm_pool_info_t value, size_t size) { if (ptr == NULL) { serializePtr(os, ptr); return; @@ -6849,7 +7307,7 @@ inline void serializeTagged(std::ostream &os, const void *ptr, switch (value) { - case UR_PROGRAM_INFO_REFERENCE_COUNT: { + case UR_USM_POOL_INFO_REFERENCE_COUNT: { const uint32_t *tptr = (const uint32_t *)ptr; if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size @@ -6863,7 +7321,7 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_PROGRAM_INFO_CONTEXT: { + case UR_USM_POOL_INFO_CONTEXT: { const ur_context_handle_t *tptr = (const ur_context_handle_t *)ptr; if (sizeof(ur_context_handle_t) > size) { os << "invalid size (is: " << size @@ -6876,12 +7334,46 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; + default: + os << "unknown enumerator"; + break; + } +} +} // namespace ur_params +inline std::ostream &operator<<(std::ostream &os, + enum ur_virtual_mem_granularity_info_t value) { + switch (value) { - case UR_PROGRAM_INFO_NUM_DEVICES: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { + case UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM: + os << "UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM"; + break; + + case UR_VIRTUAL_MEM_GRANULARITY_INFO_RECOMMENDED: + os << "UR_VIRTUAL_MEM_GRANULARITY_INFO_RECOMMENDED"; + break; + default: + os << "unknown enumerator"; + break; + } + return os; +} +namespace ur_params { +template <> +inline void serializeTagged(std::ostream &os, const void *ptr, + ur_virtual_mem_granularity_info_t value, + size_t size) { + if (ptr == NULL) { + serializePtr(os, ptr); + return; + } + + switch (value) { + + case UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; + << ", expected: >=" << sizeof(size_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -6891,49 +7383,7 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_PROGRAM_INFO_DEVICES: { - - const ur_device_handle_t *tptr = (const ur_device_handle_t *)ptr; - os << "{"; - size_t nelems = size / sizeof(ur_device_handle_t); - for (size_t i = 0; i < nelems; ++i) { - if (i != 0) { - os << ", "; - } - - ur_params::serializePtr(os, tptr[i]); - } - os << "}"; - } break; - - case UR_PROGRAM_INFO_SOURCE: { - - const char *tptr = (const char *)ptr; - serializePtr(os, tptr); - } break; - - case UR_PROGRAM_INFO_BINARY_SIZES: { - - const size_t *tptr = (const size_t *)ptr; - os << "{"; - size_t nelems = size / sizeof(size_t); - for (size_t i = 0; i < nelems; ++i) { - if (i != 0) { - os << ", "; - } - - os << tptr[i]; - } - os << "}"; - } break; - - case UR_PROGRAM_INFO_BINARIES: { - - const unsigned char *tptr = (const unsigned char *)ptr; - serializePtr(os, tptr); - } break; - - case UR_PROGRAM_INFO_NUM_KERNELS: { + case UR_VIRTUAL_MEM_GRANULARITY_INFO_RECOMMENDED: { const size_t *tptr = (const size_t *)ptr; if (sizeof(size_t) > size) { os << "invalid size (is: " << size @@ -6946,12 +7396,6 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - - case UR_PROGRAM_INFO_KERNEL_NAMES: { - - const char *tptr = (const char *)ptr; - serializePtr(os, tptr); - } break; default: os << "unknown enumerator"; break; @@ -6959,48 +7403,128 @@ inline void serializeTagged(std::ostream &os, const void *ptr, } } // namespace ur_params inline std::ostream &operator<<(std::ostream &os, - enum ur_program_build_status_t value) { + enum ur_virtual_mem_access_flag_t value) { switch (value) { - case UR_PROGRAM_BUILD_STATUS_NONE: - os << "UR_PROGRAM_BUILD_STATUS_NONE"; + case UR_VIRTUAL_MEM_ACCESS_FLAG_NONE: + os << "UR_VIRTUAL_MEM_ACCESS_FLAG_NONE"; break; - case UR_PROGRAM_BUILD_STATUS_ERROR: - os << "UR_PROGRAM_BUILD_STATUS_ERROR"; + case UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE: + os << "UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE"; break; - case UR_PROGRAM_BUILD_STATUS_SUCCESS: - os << "UR_PROGRAM_BUILD_STATUS_SUCCESS"; + case UR_VIRTUAL_MEM_ACCESS_FLAG_READ_ONLY: + os << "UR_VIRTUAL_MEM_ACCESS_FLAG_READ_ONLY"; + break; + default: + os << "unknown enumerator"; + break; + } + return os; +} +namespace ur_params { + +template <> +inline void serializeFlag(std::ostream &os, + uint32_t flag) { + uint32_t val = flag; + bool first = true; + + if ((val & UR_VIRTUAL_MEM_ACCESS_FLAG_NONE) == + (uint32_t)UR_VIRTUAL_MEM_ACCESS_FLAG_NONE) { + val ^= (uint32_t)UR_VIRTUAL_MEM_ACCESS_FLAG_NONE; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_VIRTUAL_MEM_ACCESS_FLAG_NONE; + } + + if ((val & UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE) == + (uint32_t)UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE) { + val ^= (uint32_t)UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE; + } + + if ((val & UR_VIRTUAL_MEM_ACCESS_FLAG_READ_ONLY) == + (uint32_t)UR_VIRTUAL_MEM_ACCESS_FLAG_READ_ONLY) { + val ^= (uint32_t)UR_VIRTUAL_MEM_ACCESS_FLAG_READ_ONLY; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_VIRTUAL_MEM_ACCESS_FLAG_READ_ONLY; + } + if (val != 0) { + std::bitset<32> bits(val); + if (!first) { + os << " | "; + } + os << "unknown bit flags " << bits; + } else if (first) { + os << "0"; + } +} +} // namespace ur_params +inline std::ostream &operator<<(std::ostream &os, + enum ur_virtual_mem_info_t value) { + switch (value) { + + case UR_VIRTUAL_MEM_INFO_ACCESS_MODE: + os << "UR_VIRTUAL_MEM_INFO_ACCESS_MODE"; + break; + default: + os << "unknown enumerator"; break; + } + return os; +} +namespace ur_params { +template <> +inline void serializeTagged(std::ostream &os, const void *ptr, + ur_virtual_mem_info_t value, size_t size) { + if (ptr == NULL) { + serializePtr(os, ptr); + return; + } + + switch (value) { + + case UR_VIRTUAL_MEM_INFO_ACCESS_MODE: { + const ur_virtual_mem_access_flags_t *tptr = + (const ur_virtual_mem_access_flags_t *)ptr; + if (sizeof(ur_virtual_mem_access_flags_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_virtual_mem_access_flags_t) + << ")"; + return; + } + os << (void *)(tptr) << " ("; + + ur_params::serializeFlag(os, *tptr); - case UR_PROGRAM_BUILD_STATUS_IN_PROGRESS: - os << "UR_PROGRAM_BUILD_STATUS_IN_PROGRESS"; - break; + os << ")"; + } break; default: os << "unknown enumerator"; break; } - return os; } +} // namespace ur_params inline std::ostream &operator<<(std::ostream &os, - enum ur_program_binary_type_t value) { + enum ur_physical_mem_flag_t value) { switch (value) { - case UR_PROGRAM_BINARY_TYPE_NONE: - os << "UR_PROGRAM_BINARY_TYPE_NONE"; - break; - - case UR_PROGRAM_BINARY_TYPE_COMPILED_OBJECT: - os << "UR_PROGRAM_BINARY_TYPE_COMPILED_OBJECT"; - break; - - case UR_PROGRAM_BINARY_TYPE_LIBRARY: - os << "UR_PROGRAM_BINARY_TYPE_LIBRARY"; - break; - - case UR_PROGRAM_BINARY_TYPE_EXECUTABLE: - os << "UR_PROGRAM_BINARY_TYPE_EXECUTABLE"; + case UR_PHYSICAL_MEM_FLAG_TBD: + os << "UR_PHYSICAL_MEM_FLAG_TBD"; break; default: os << "unknown enumerator"; @@ -7008,24 +7532,74 @@ inline std::ostream &operator<<(std::ostream &os, } return os; } +namespace ur_params { + +template <> +inline void serializeFlag(std::ostream &os, + uint32_t flag) { + uint32_t val = flag; + bool first = true; + + if ((val & UR_PHYSICAL_MEM_FLAG_TBD) == + (uint32_t)UR_PHYSICAL_MEM_FLAG_TBD) { + val ^= (uint32_t)UR_PHYSICAL_MEM_FLAG_TBD; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_PHYSICAL_MEM_FLAG_TBD; + } + if (val != 0) { + std::bitset<32> bits(val); + if (!first) { + os << " | "; + } + os << "unknown bit flags " << bits; + } else if (first) { + os << "0"; + } +} +} // namespace ur_params +inline std::ostream & +operator<<(std::ostream &os, const struct ur_physical_mem_properties_t params) { + os << "(struct ur_physical_mem_properties_t){"; + + os << ".stype = "; + + os << (params.stype); + + os << ", "; + os << ".pNext = "; + + ur_params::serializeStruct(os, (params.pNext)); + + os << ", "; + os << ".flags = "; + + ur_params::serializeFlag(os, (params.flags)); + + os << "}"; + return os; +} inline std::ostream &operator<<(std::ostream &os, - enum ur_program_build_info_t value) { + enum ur_program_metadata_type_t value) { switch (value) { - case UR_PROGRAM_BUILD_INFO_STATUS: - os << "UR_PROGRAM_BUILD_INFO_STATUS"; + case UR_PROGRAM_METADATA_TYPE_UINT32: + os << "UR_PROGRAM_METADATA_TYPE_UINT32"; break; - case UR_PROGRAM_BUILD_INFO_OPTIONS: - os << "UR_PROGRAM_BUILD_INFO_OPTIONS"; + case UR_PROGRAM_METADATA_TYPE_UINT64: + os << "UR_PROGRAM_METADATA_TYPE_UINT64"; break; - case UR_PROGRAM_BUILD_INFO_LOG: - os << "UR_PROGRAM_BUILD_INFO_LOG"; + case UR_PROGRAM_METADATA_TYPE_BYTE_ARRAY: + os << "UR_PROGRAM_METADATA_TYPE_BYTE_ARRAY"; break; - case UR_PROGRAM_BUILD_INFO_BINARY_TYPE: - os << "UR_PROGRAM_BUILD_INFO_BINARY_TYPE"; + case UR_PROGRAM_METADATA_TYPE_STRING: + os << "UR_PROGRAM_METADATA_TYPE_STRING"; break; default: os << "unknown enumerator"; @@ -7033,72 +7607,60 @@ inline std::ostream &operator<<(std::ostream &os, } return os; } -namespace ur_params { -template <> -inline void serializeTagged(std::ostream &os, const void *ptr, - ur_program_build_info_t value, size_t size) { - if (ptr == NULL) { - serializePtr(os, ptr); - return; - } - switch (value) { +inline void +ur_params::serializeUnion(std::ostream &os, + const union ur_program_metadata_value_t params, + const enum ur_program_metadata_type_t tag) { + os << "(union ur_program_metadata_value_t){"; - case UR_PROGRAM_BUILD_INFO_STATUS: { - const ur_program_build_status_t *tptr = - (const ur_program_build_status_t *)ptr; - if (sizeof(ur_program_build_status_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_program_build_status_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + switch (tag) { + case UR_PROGRAM_METADATA_TYPE_UINT32: - os << *tptr; + os << ".data32 = "; - os << ")"; - } break; + os << (params.data32); - case UR_PROGRAM_BUILD_INFO_OPTIONS: { + break; + case UR_PROGRAM_METADATA_TYPE_UINT64: - const char *tptr = (const char *)ptr; - serializePtr(os, tptr); - } break; + os << ".data64 = "; - case UR_PROGRAM_BUILD_INFO_LOG: { + os << (params.data64); - const char *tptr = (const char *)ptr; - serializePtr(os, tptr); - } break; + break; + case UR_PROGRAM_METADATA_TYPE_STRING: - case UR_PROGRAM_BUILD_INFO_BINARY_TYPE: { - const ur_program_binary_type_t *tptr = - (const ur_program_binary_type_t *)ptr; - if (sizeof(ur_program_binary_type_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_program_binary_type_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + os << ".pString = "; - os << *tptr; + ur_params::serializePtr(os, (params.pString)); - os << ")"; - } break; + break; + case UR_PROGRAM_METADATA_TYPE_BYTE_ARRAY: + + os << ".pData = "; + + ur_params::serializePtr(os, (params.pData)); + + break; default: - os << "unknown enumerator"; + os << ""; break; } + os << "}"; } -} // namespace ur_params -inline std::ostream & -operator<<(std::ostream &os, - const struct ur_specialization_constant_info_t params) { - os << "(struct ur_specialization_constant_info_t){"; +inline std::ostream &operator<<(std::ostream &os, + const struct ur_program_metadata_t params) { + os << "(struct ur_program_metadata_t){"; - os << ".id = "; + os << ".pName = "; - os << (params.id); + ur_params::serializePtr(os, (params.pName)); + + os << ", "; + os << ".type = "; + + os << (params.type); os << ", "; os << ".size = "; @@ -7106,17 +7668,15 @@ operator<<(std::ostream &os, os << (params.size); os << ", "; - os << ".pValue = "; - - ur_params::serializePtr(os, (params.pValue)); + os << ".value = "; + ur_params::serializeUnion(os, (params.value), params.type); os << "}"; return os; } -inline std::ostream & -operator<<(std::ostream &os, - const struct ur_program_native_properties_t params) { - os << "(struct ur_program_native_properties_t){"; +inline std::ostream &operator<<(std::ostream &os, + const struct ur_program_properties_t params) { + os << "(struct ur_program_properties_t){"; os << ".stype = "; @@ -7128,76 +7688,62 @@ operator<<(std::ostream &os, ur_params::serializeStruct(os, (params.pNext)); os << ", "; - os << ".isNativeHandleOwned = "; - - os << (params.isNativeHandleOwned); - - os << "}"; - return os; -} -inline std::ostream & -operator<<(std::ostream &os, - const struct ur_kernel_arg_value_properties_t params) { - os << "(struct ur_kernel_arg_value_properties_t){"; - - os << ".stype = "; + os << ".count = "; - os << (params.stype); + os << (params.count); os << ", "; - os << ".pNext = "; - - ur_params::serializeStruct(os, (params.pNext)); + os << ".pMetadatas = {"; + for (size_t i = 0; (params.pMetadatas) != NULL && i < params.count; ++i) { + if (i != 0) { + os << ", "; + } + os << ((params.pMetadatas))[i]; + } os << "}"; - return os; -} -inline std::ostream & -operator<<(std::ostream &os, - const struct ur_kernel_arg_local_properties_t params) { - os << "(struct ur_kernel_arg_local_properties_t){"; - - os << ".stype = "; - - os << (params.stype); - - os << ", "; - os << ".pNext = "; - - ur_params::serializeStruct(os, (params.pNext)); os << "}"; return os; } -inline std::ostream &operator<<(std::ostream &os, enum ur_kernel_info_t value) { +inline std::ostream &operator<<(std::ostream &os, + enum ur_program_info_t value) { switch (value) { - case UR_KERNEL_INFO_FUNCTION_NAME: - os << "UR_KERNEL_INFO_FUNCTION_NAME"; + case UR_PROGRAM_INFO_REFERENCE_COUNT: + os << "UR_PROGRAM_INFO_REFERENCE_COUNT"; break; - case UR_KERNEL_INFO_NUM_ARGS: - os << "UR_KERNEL_INFO_NUM_ARGS"; + case UR_PROGRAM_INFO_CONTEXT: + os << "UR_PROGRAM_INFO_CONTEXT"; break; - case UR_KERNEL_INFO_REFERENCE_COUNT: - os << "UR_KERNEL_INFO_REFERENCE_COUNT"; + case UR_PROGRAM_INFO_NUM_DEVICES: + os << "UR_PROGRAM_INFO_NUM_DEVICES"; break; - case UR_KERNEL_INFO_CONTEXT: - os << "UR_KERNEL_INFO_CONTEXT"; + case UR_PROGRAM_INFO_DEVICES: + os << "UR_PROGRAM_INFO_DEVICES"; break; - case UR_KERNEL_INFO_PROGRAM: - os << "UR_KERNEL_INFO_PROGRAM"; + case UR_PROGRAM_INFO_SOURCE: + os << "UR_PROGRAM_INFO_SOURCE"; break; - case UR_KERNEL_INFO_ATTRIBUTES: - os << "UR_KERNEL_INFO_ATTRIBUTES"; + case UR_PROGRAM_INFO_BINARY_SIZES: + os << "UR_PROGRAM_INFO_BINARY_SIZES"; break; - case UR_KERNEL_INFO_NUM_REGS: - os << "UR_KERNEL_INFO_NUM_REGS"; + case UR_PROGRAM_INFO_BINARIES: + os << "UR_PROGRAM_INFO_BINARIES"; + break; + + case UR_PROGRAM_INFO_NUM_KERNELS: + os << "UR_PROGRAM_INFO_NUM_KERNELS"; + break; + + case UR_PROGRAM_INFO_KERNEL_NAMES: + os << "UR_PROGRAM_INFO_KERNEL_NAMES"; break; default: os << "unknown enumerator"; @@ -7208,7 +7754,7 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_kernel_info_t value) { namespace ur_params { template <> inline void serializeTagged(std::ostream &os, const void *ptr, - ur_kernel_info_t value, size_t size) { + ur_program_info_t value, size_t size) { if (ptr == NULL) { serializePtr(os, ptr); return; @@ -7216,27 +7762,7 @@ inline void serializeTagged(std::ostream &os, const void *ptr, switch (value) { - case UR_KERNEL_INFO_FUNCTION_NAME: { - - const char *tptr = (const char *)ptr; - serializePtr(os, tptr); - } break; - - case UR_KERNEL_INFO_NUM_ARGS: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; - - os << ")"; - } break; - - case UR_KERNEL_INFO_REFERENCE_COUNT: { + case UR_PROGRAM_INFO_REFERENCE_COUNT: { const uint32_t *tptr = (const uint32_t *)ptr; if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size @@ -7250,7 +7776,7 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_KERNEL_INFO_CONTEXT: { + case UR_PROGRAM_INFO_CONTEXT: { const ur_context_handle_t *tptr = (const ur_context_handle_t *)ptr; if (sizeof(ur_context_handle_t) > size) { os << "invalid size (is: " << size @@ -7264,27 +7790,7 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_KERNEL_INFO_PROGRAM: { - const ur_program_handle_t *tptr = (const ur_program_handle_t *)ptr; - if (sizeof(ur_program_handle_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_program_handle_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - ur_params::serializePtr(os, *tptr); - - os << ")"; - } break; - - case UR_KERNEL_INFO_ATTRIBUTES: { - - const char *tptr = (const char *)ptr; - serializePtr(os, tptr); - } break; - - case UR_KERNEL_INFO_NUM_REGS: { + case UR_PROGRAM_INFO_NUM_DEVICES: { const uint32_t *tptr = (const uint32_t *)ptr; if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size @@ -7297,86 +7803,29 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - default: - os << "unknown enumerator"; - break; - } -} -} // namespace ur_params -inline std::ostream &operator<<(std::ostream &os, - enum ur_kernel_group_info_t value) { - switch (value) { - - case UR_KERNEL_GROUP_INFO_GLOBAL_WORK_SIZE: - os << "UR_KERNEL_GROUP_INFO_GLOBAL_WORK_SIZE"; - break; - - case UR_KERNEL_GROUP_INFO_WORK_GROUP_SIZE: - os << "UR_KERNEL_GROUP_INFO_WORK_GROUP_SIZE"; - break; - - case UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE: - os << "UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE"; - break; - - case UR_KERNEL_GROUP_INFO_LOCAL_MEM_SIZE: - os << "UR_KERNEL_GROUP_INFO_LOCAL_MEM_SIZE"; - break; - - case UR_KERNEL_GROUP_INFO_PREFERRED_WORK_GROUP_SIZE_MULTIPLE: - os << "UR_KERNEL_GROUP_INFO_PREFERRED_WORK_GROUP_SIZE_MULTIPLE"; - break; - - case UR_KERNEL_GROUP_INFO_PRIVATE_MEM_SIZE: - os << "UR_KERNEL_GROUP_INFO_PRIVATE_MEM_SIZE"; - break; - default: - os << "unknown enumerator"; - break; - } - return os; -} -namespace ur_params { -template <> -inline void serializeTagged(std::ostream &os, const void *ptr, - ur_kernel_group_info_t value, size_t size) { - if (ptr == NULL) { - serializePtr(os, ptr); - return; - } - switch (value) { - - case UR_KERNEL_GROUP_INFO_GLOBAL_WORK_SIZE: { + case UR_PROGRAM_INFO_DEVICES: { - const size_t *tptr = (const size_t *)ptr; + const ur_device_handle_t *tptr = (const ur_device_handle_t *)ptr; os << "{"; - size_t nelems = size / sizeof(size_t); + size_t nelems = size / sizeof(ur_device_handle_t); for (size_t i = 0; i < nelems; ++i) { if (i != 0) { os << ", "; } - os << tptr[i]; + ur_params::serializePtr(os, tptr[i]); } os << "}"; } break; - case UR_KERNEL_GROUP_INFO_WORK_GROUP_SIZE: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; + case UR_PROGRAM_INFO_SOURCE: { - os << ")"; + const char *tptr = (const char *)ptr; + serializePtr(os, tptr); } break; - case UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE: { + case UR_PROGRAM_INFO_BINARY_SIZES: { const size_t *tptr = (const size_t *)ptr; os << "{"; @@ -7391,21 +7840,13 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << "}"; } break; - case UR_KERNEL_GROUP_INFO_LOCAL_MEM_SIZE: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; + case UR_PROGRAM_INFO_BINARIES: { - os << ")"; + const unsigned char *tptr = (const unsigned char *)ptr; + serializePtr(os, tptr); } break; - case UR_KERNEL_GROUP_INFO_PREFERRED_WORK_GROUP_SIZE_MULTIPLE: { + case UR_PROGRAM_INFO_NUM_KERNELS: { const size_t *tptr = (const size_t *)ptr; if (sizeof(size_t) > size) { os << "invalid size (is: " << size @@ -7419,18 +7860,10 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_KERNEL_GROUP_INFO_PRIVATE_MEM_SIZE: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(size_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; + case UR_PROGRAM_INFO_KERNEL_NAMES: { - os << ")"; + const char *tptr = (const char *)ptr; + serializePtr(os, tptr); } break; default: os << "unknown enumerator"; @@ -7439,23 +7872,23 @@ inline void serializeTagged(std::ostream &os, const void *ptr, } } // namespace ur_params inline std::ostream &operator<<(std::ostream &os, - enum ur_kernel_sub_group_info_t value) { + enum ur_program_build_status_t value) { switch (value) { - case UR_KERNEL_SUB_GROUP_INFO_MAX_SUB_GROUP_SIZE: - os << "UR_KERNEL_SUB_GROUP_INFO_MAX_SUB_GROUP_SIZE"; + case UR_PROGRAM_BUILD_STATUS_NONE: + os << "UR_PROGRAM_BUILD_STATUS_NONE"; break; - case UR_KERNEL_SUB_GROUP_INFO_MAX_NUM_SUB_GROUPS: - os << "UR_KERNEL_SUB_GROUP_INFO_MAX_NUM_SUB_GROUPS"; + case UR_PROGRAM_BUILD_STATUS_ERROR: + os << "UR_PROGRAM_BUILD_STATUS_ERROR"; break; - case UR_KERNEL_SUB_GROUP_INFO_COMPILE_NUM_SUB_GROUPS: - os << "UR_KERNEL_SUB_GROUP_INFO_COMPILE_NUM_SUB_GROUPS"; + case UR_PROGRAM_BUILD_STATUS_SUCCESS: + os << "UR_PROGRAM_BUILD_STATUS_SUCCESS"; break; - case UR_KERNEL_SUB_GROUP_INFO_SUB_GROUP_SIZE_INTEL: - os << "UR_KERNEL_SUB_GROUP_INFO_SUB_GROUP_SIZE_INTEL"; + case UR_PROGRAM_BUILD_STATUS_IN_PROGRESS: + os << "UR_PROGRAM_BUILD_STATUS_IN_PROGRESS"; break; default: os << "unknown enumerator"; @@ -7463,92 +7896,24 @@ inline std::ostream &operator<<(std::ostream &os, } return os; } -namespace ur_params { -template <> -inline void serializeTagged(std::ostream &os, const void *ptr, - ur_kernel_sub_group_info_t value, size_t size) { - if (ptr == NULL) { - serializePtr(os, ptr); - return; - } - +inline std::ostream &operator<<(std::ostream &os, + enum ur_program_binary_type_t value) { switch (value) { - case UR_KERNEL_SUB_GROUP_INFO_MAX_SUB_GROUP_SIZE: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; - - os << ")"; - } break; - - case UR_KERNEL_SUB_GROUP_INFO_MAX_NUM_SUB_GROUPS: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; - - os << ")"; - } break; - - case UR_KERNEL_SUB_GROUP_INFO_COMPILE_NUM_SUB_GROUPS: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; - - os << ")"; - } break; - - case UR_KERNEL_SUB_GROUP_INFO_SUB_GROUP_SIZE_INTEL: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; - - os << ")"; - } break; - default: - os << "unknown enumerator"; + case UR_PROGRAM_BINARY_TYPE_NONE: + os << "UR_PROGRAM_BINARY_TYPE_NONE"; break; - } -} -} // namespace ur_params -inline std::ostream &operator<<(std::ostream &os, - enum ur_kernel_cache_config_t value) { - switch (value) { - case UR_KERNEL_CACHE_CONFIG_DEFAULT: - os << "UR_KERNEL_CACHE_CONFIG_DEFAULT"; + case UR_PROGRAM_BINARY_TYPE_COMPILED_OBJECT: + os << "UR_PROGRAM_BINARY_TYPE_COMPILED_OBJECT"; break; - case UR_KERNEL_CACHE_CONFIG_LARGE_SLM: - os << "UR_KERNEL_CACHE_CONFIG_LARGE_SLM"; + case UR_PROGRAM_BINARY_TYPE_LIBRARY: + os << "UR_PROGRAM_BINARY_TYPE_LIBRARY"; break; - case UR_KERNEL_CACHE_CONFIG_LARGE_DATA: - os << "UR_KERNEL_CACHE_CONFIG_LARGE_DATA"; + case UR_PROGRAM_BINARY_TYPE_EXECUTABLE: + os << "UR_PROGRAM_BINARY_TYPE_EXECUTABLE"; break; default: os << "unknown enumerator"; @@ -7557,19 +7922,23 @@ inline std::ostream &operator<<(std::ostream &os, return os; } inline std::ostream &operator<<(std::ostream &os, - enum ur_kernel_exec_info_t value) { + enum ur_program_build_info_t value) { switch (value) { - case UR_KERNEL_EXEC_INFO_USM_INDIRECT_ACCESS: - os << "UR_KERNEL_EXEC_INFO_USM_INDIRECT_ACCESS"; + case UR_PROGRAM_BUILD_INFO_STATUS: + os << "UR_PROGRAM_BUILD_INFO_STATUS"; break; - case UR_KERNEL_EXEC_INFO_USM_PTRS: - os << "UR_KERNEL_EXEC_INFO_USM_PTRS"; + case UR_PROGRAM_BUILD_INFO_OPTIONS: + os << "UR_PROGRAM_BUILD_INFO_OPTIONS"; break; - case UR_KERNEL_EXEC_INFO_CACHE_CONFIG: - os << "UR_KERNEL_EXEC_INFO_CACHE_CONFIG"; + case UR_PROGRAM_BUILD_INFO_LOG: + os << "UR_PROGRAM_BUILD_INFO_LOG"; + break; + + case UR_PROGRAM_BUILD_INFO_BINARY_TYPE: + os << "UR_PROGRAM_BUILD_INFO_BINARY_TYPE"; break; default: os << "unknown enumerator"; @@ -7580,7 +7949,7 @@ inline std::ostream &operator<<(std::ostream &os, namespace ur_params { template <> inline void serializeTagged(std::ostream &os, const void *ptr, - ur_kernel_exec_info_t value, size_t size) { + ur_program_build_info_t value, size_t size) { if (ptr == NULL) { serializePtr(os, ptr); return; @@ -7588,11 +7957,12 @@ inline void serializeTagged(std::ostream &os, const void *ptr, switch (value) { - case UR_KERNEL_EXEC_INFO_USM_INDIRECT_ACCESS: { - const ur_bool_t *tptr = (const ur_bool_t *)ptr; - if (sizeof(ur_bool_t) > size) { + case UR_PROGRAM_BUILD_INFO_STATUS: { + const ur_program_build_status_t *tptr = + (const ur_program_build_status_t *)ptr; + if (sizeof(ur_program_build_status_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_bool_t) << ")"; + << ", expected: >=" << sizeof(ur_program_build_status_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -7602,27 +7972,24 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_KERNEL_EXEC_INFO_USM_PTRS: { + case UR_PROGRAM_BUILD_INFO_OPTIONS: { - const void **tptr = (const void **)ptr; - os << "{"; - size_t nelems = size / sizeof(void *); - for (size_t i = 0; i < nelems; ++i) { - if (i != 0) { - os << ", "; - } + const char *tptr = (const char *)ptr; + serializePtr(os, tptr); + } break; - os << tptr[i]; - } - os << "}"; + case UR_PROGRAM_BUILD_INFO_LOG: { + + const char *tptr = (const char *)ptr; + serializePtr(os, tptr); } break; - case UR_KERNEL_EXEC_INFO_CACHE_CONFIG: { - const ur_kernel_cache_config_t *tptr = - (const ur_kernel_cache_config_t *)ptr; - if (sizeof(ur_kernel_cache_config_t) > size) { + case UR_PROGRAM_BUILD_INFO_BINARY_TYPE: { + const ur_program_binary_type_t *tptr = + (const ur_program_binary_type_t *)ptr; + if (sizeof(ur_program_binary_type_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_kernel_cache_config_t) << ")"; + << ", expected: >=" << sizeof(ur_program_binary_type_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -7639,25 +8006,30 @@ inline void serializeTagged(std::ostream &os, const void *ptr, } // namespace ur_params inline std::ostream & operator<<(std::ostream &os, - const struct ur_kernel_arg_pointer_properties_t params) { - os << "(struct ur_kernel_arg_pointer_properties_t){"; + const struct ur_specialization_constant_info_t params) { + os << "(struct ur_specialization_constant_info_t){"; - os << ".stype = "; + os << ".id = "; - os << (params.stype); + os << (params.id); os << ", "; - os << ".pNext = "; + os << ".size = "; - ur_params::serializeStruct(os, (params.pNext)); + os << (params.size); + + os << ", "; + os << ".pValue = "; + + ur_params::serializePtr(os, (params.pValue)); os << "}"; return os; } inline std::ostream & operator<<(std::ostream &os, - const struct ur_kernel_exec_info_properties_t params) { - os << "(struct ur_kernel_exec_info_properties_t){"; + const struct ur_program_native_properties_t params) { + os << "(struct ur_program_native_properties_t){"; os << ".stype = "; @@ -7668,13 +8040,18 @@ operator<<(std::ostream &os, ur_params::serializeStruct(os, (params.pNext)); + os << ", "; + os << ".isNativeHandleOwned = "; + + os << (params.isNativeHandleOwned); + os << "}"; return os; } inline std::ostream & operator<<(std::ostream &os, - const struct ur_kernel_arg_sampler_properties_t params) { - os << "(struct ur_kernel_arg_sampler_properties_t){"; + const struct ur_kernel_arg_value_properties_t params) { + os << "(struct ur_kernel_arg_value_properties_t){"; os << ".stype = "; @@ -7690,8 +8067,8 @@ operator<<(std::ostream &os, } inline std::ostream & operator<<(std::ostream &os, - const struct ur_kernel_arg_mem_obj_properties_t params) { - os << "(struct ur_kernel_arg_mem_obj_properties_t){"; + const struct ur_kernel_arg_local_properties_t params) { + os << "(struct ur_kernel_arg_local_properties_t){"; os << ".stype = "; @@ -7702,65 +8079,169 @@ operator<<(std::ostream &os, ur_params::serializeStruct(os, (params.pNext)); - os << ", "; - os << ".memoryAccess = "; - - ur_params::serializeFlag(os, (params.memoryAccess)); - os << "}"; return os; } -inline std::ostream & -operator<<(std::ostream &os, - const struct ur_kernel_native_properties_t params) { - os << "(struct ur_kernel_native_properties_t){"; +inline std::ostream &operator<<(std::ostream &os, enum ur_kernel_info_t value) { + switch (value) { - os << ".stype = "; + case UR_KERNEL_INFO_FUNCTION_NAME: + os << "UR_KERNEL_INFO_FUNCTION_NAME"; + break; - os << (params.stype); + case UR_KERNEL_INFO_NUM_ARGS: + os << "UR_KERNEL_INFO_NUM_ARGS"; + break; - os << ", "; - os << ".pNext = "; + case UR_KERNEL_INFO_REFERENCE_COUNT: + os << "UR_KERNEL_INFO_REFERENCE_COUNT"; + break; - ur_params::serializeStruct(os, (params.pNext)); + case UR_KERNEL_INFO_CONTEXT: + os << "UR_KERNEL_INFO_CONTEXT"; + break; - os << ", "; - os << ".isNativeHandleOwned = "; + case UR_KERNEL_INFO_PROGRAM: + os << "UR_KERNEL_INFO_PROGRAM"; + break; - os << (params.isNativeHandleOwned); + case UR_KERNEL_INFO_ATTRIBUTES: + os << "UR_KERNEL_INFO_ATTRIBUTES"; + break; - os << "}"; + case UR_KERNEL_INFO_NUM_REGS: + os << "UR_KERNEL_INFO_NUM_REGS"; + break; + default: + os << "unknown enumerator"; + break; + } return os; } -inline std::ostream &operator<<(std::ostream &os, enum ur_queue_info_t value) { +namespace ur_params { +template <> +inline void serializeTagged(std::ostream &os, const void *ptr, + ur_kernel_info_t value, size_t size) { + if (ptr == NULL) { + serializePtr(os, ptr); + return; + } + switch (value) { - case UR_QUEUE_INFO_CONTEXT: - os << "UR_QUEUE_INFO_CONTEXT"; + case UR_KERNEL_INFO_FUNCTION_NAME: { + + const char *tptr = (const char *)ptr; + serializePtr(os, tptr); + } break; + + case UR_KERNEL_INFO_NUM_ARGS: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(size_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + + case UR_KERNEL_INFO_REFERENCE_COUNT: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint32_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + + case UR_KERNEL_INFO_CONTEXT: { + const ur_context_handle_t *tptr = (const ur_context_handle_t *)ptr; + if (sizeof(ur_context_handle_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_context_handle_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + ur_params::serializePtr(os, *tptr); + + os << ")"; + } break; + + case UR_KERNEL_INFO_PROGRAM: { + const ur_program_handle_t *tptr = (const ur_program_handle_t *)ptr; + if (sizeof(ur_program_handle_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_program_handle_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + ur_params::serializePtr(os, *tptr); + + os << ")"; + } break; + + case UR_KERNEL_INFO_ATTRIBUTES: { + + const char *tptr = (const char *)ptr; + serializePtr(os, tptr); + } break; + + case UR_KERNEL_INFO_NUM_REGS: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint32_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + default: + os << "unknown enumerator"; break; + } +} +} // namespace ur_params +inline std::ostream &operator<<(std::ostream &os, + enum ur_kernel_group_info_t value) { + switch (value) { - case UR_QUEUE_INFO_DEVICE: - os << "UR_QUEUE_INFO_DEVICE"; + case UR_KERNEL_GROUP_INFO_GLOBAL_WORK_SIZE: + os << "UR_KERNEL_GROUP_INFO_GLOBAL_WORK_SIZE"; break; - case UR_QUEUE_INFO_DEVICE_DEFAULT: - os << "UR_QUEUE_INFO_DEVICE_DEFAULT"; + case UR_KERNEL_GROUP_INFO_WORK_GROUP_SIZE: + os << "UR_KERNEL_GROUP_INFO_WORK_GROUP_SIZE"; break; - case UR_QUEUE_INFO_FLAGS: - os << "UR_QUEUE_INFO_FLAGS"; + case UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE: + os << "UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE"; break; - case UR_QUEUE_INFO_REFERENCE_COUNT: - os << "UR_QUEUE_INFO_REFERENCE_COUNT"; + case UR_KERNEL_GROUP_INFO_LOCAL_MEM_SIZE: + os << "UR_KERNEL_GROUP_INFO_LOCAL_MEM_SIZE"; break; - case UR_QUEUE_INFO_SIZE: - os << "UR_QUEUE_INFO_SIZE"; + case UR_KERNEL_GROUP_INFO_PREFERRED_WORK_GROUP_SIZE_MULTIPLE: + os << "UR_KERNEL_GROUP_INFO_PREFERRED_WORK_GROUP_SIZE_MULTIPLE"; break; - case UR_QUEUE_INFO_EMPTY: - os << "UR_QUEUE_INFO_EMPTY"; + case UR_KERNEL_GROUP_INFO_PRIVATE_MEM_SIZE: + os << "UR_KERNEL_GROUP_INFO_PRIVATE_MEM_SIZE"; break; default: os << "unknown enumerator"; @@ -7771,7 +8252,7 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_queue_info_t value) { namespace ur_params { template <> inline void serializeTagged(std::ostream &os, const void *ptr, - ur_queue_info_t value, size_t size) { + ur_kernel_group_info_t value, size_t size) { if (ptr == NULL) { serializePtr(os, ptr); return; @@ -7779,67 +8260,55 @@ inline void serializeTagged(std::ostream &os, const void *ptr, switch (value) { - case UR_QUEUE_INFO_CONTEXT: { - const ur_queue_handle_t *tptr = (const ur_queue_handle_t *)ptr; - if (sizeof(ur_queue_handle_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_queue_handle_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - ur_params::serializePtr(os, *tptr); + case UR_KERNEL_GROUP_INFO_GLOBAL_WORK_SIZE: { - os << ")"; - } break; + const size_t *tptr = (const size_t *)ptr; + os << "{"; + size_t nelems = size / sizeof(size_t); + for (size_t i = 0; i < nelems; ++i) { + if (i != 0) { + os << ", "; + } - case UR_QUEUE_INFO_DEVICE: { - const ur_device_handle_t *tptr = (const ur_device_handle_t *)ptr; - if (sizeof(ur_device_handle_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_device_handle_t) << ")"; - return; + os << tptr[i]; } - os << (void *)(tptr) << " ("; - - ur_params::serializePtr(os, *tptr); - - os << ")"; + os << "}"; } break; - case UR_QUEUE_INFO_DEVICE_DEFAULT: { - const ur_queue_handle_t *tptr = (const ur_queue_handle_t *)ptr; - if (sizeof(ur_queue_handle_t) > size) { + case UR_KERNEL_GROUP_INFO_WORK_GROUP_SIZE: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_queue_handle_t) << ")"; + << ", expected: >=" << sizeof(size_t) << ")"; return; } os << (void *)(tptr) << " ("; - ur_params::serializePtr(os, *tptr); + os << *tptr; os << ")"; } break; - case UR_QUEUE_INFO_FLAGS: { - const ur_queue_flags_t *tptr = (const ur_queue_flags_t *)ptr; - if (sizeof(ur_queue_flags_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_queue_flags_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; + case UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE: { - ur_params::serializeFlag(os, *tptr); + const size_t *tptr = (const size_t *)ptr; + os << "{"; + size_t nelems = size / sizeof(size_t); + for (size_t i = 0; i < nelems; ++i) { + if (i != 0) { + os << ", "; + } - os << ")"; + os << tptr[i]; + } + os << "}"; } break; - case UR_QUEUE_INFO_REFERENCE_COUNT: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { + case UR_KERNEL_GROUP_INFO_LOCAL_MEM_SIZE: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; + << ", expected: >=" << sizeof(size_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -7849,11 +8318,11 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_QUEUE_INFO_SIZE: { - const uint32_t *tptr = (const uint32_t *)ptr; - if (sizeof(uint32_t) > size) { + case UR_KERNEL_GROUP_INFO_PREFERRED_WORK_GROUP_SIZE_MULTIPLE: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint32_t) << ")"; + << ", expected: >=" << sizeof(size_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -7863,11 +8332,11 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_QUEUE_INFO_EMPTY: { - const ur_bool_t *tptr = (const ur_bool_t *)ptr; - if (sizeof(ur_bool_t) > size) { + case UR_KERNEL_GROUP_INFO_PRIVATE_MEM_SIZE: { + const size_t *tptr = (const size_t *)ptr; + if (sizeof(size_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_bool_t) << ")"; + << ", expected: >=" << sizeof(size_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -7882,51 +8351,24 @@ inline void serializeTagged(std::ostream &os, const void *ptr, } } } // namespace ur_params -inline std::ostream &operator<<(std::ostream &os, enum ur_queue_flag_t value) { +inline std::ostream &operator<<(std::ostream &os, + enum ur_kernel_sub_group_info_t value) { switch (value) { - case UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE: - os << "UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE"; - break; - - case UR_QUEUE_FLAG_PROFILING_ENABLE: - os << "UR_QUEUE_FLAG_PROFILING_ENABLE"; - break; - - case UR_QUEUE_FLAG_ON_DEVICE: - os << "UR_QUEUE_FLAG_ON_DEVICE"; - break; - - case UR_QUEUE_FLAG_ON_DEVICE_DEFAULT: - os << "UR_QUEUE_FLAG_ON_DEVICE_DEFAULT"; - break; - - case UR_QUEUE_FLAG_DISCARD_EVENTS: - os << "UR_QUEUE_FLAG_DISCARD_EVENTS"; - break; - - case UR_QUEUE_FLAG_PRIORITY_LOW: - os << "UR_QUEUE_FLAG_PRIORITY_LOW"; - break; - - case UR_QUEUE_FLAG_PRIORITY_HIGH: - os << "UR_QUEUE_FLAG_PRIORITY_HIGH"; - break; - - case UR_QUEUE_FLAG_SUBMISSION_BATCHED: - os << "UR_QUEUE_FLAG_SUBMISSION_BATCHED"; + case UR_KERNEL_SUB_GROUP_INFO_MAX_SUB_GROUP_SIZE: + os << "UR_KERNEL_SUB_GROUP_INFO_MAX_SUB_GROUP_SIZE"; break; - case UR_QUEUE_FLAG_SUBMISSION_IMMEDIATE: - os << "UR_QUEUE_FLAG_SUBMISSION_IMMEDIATE"; + case UR_KERNEL_SUB_GROUP_INFO_MAX_NUM_SUB_GROUPS: + os << "UR_KERNEL_SUB_GROUP_INFO_MAX_NUM_SUB_GROUPS"; break; - case UR_QUEUE_FLAG_USE_DEFAULT_STREAM: - os << "UR_QUEUE_FLAG_USE_DEFAULT_STREAM"; + case UR_KERNEL_SUB_GROUP_INFO_COMPILE_NUM_SUB_GROUPS: + os << "UR_KERNEL_SUB_GROUP_INFO_COMPILE_NUM_SUB_GROUPS"; break; - case UR_QUEUE_FLAG_SYNC_WITH_DEFAULT_STREAM: - os << "UR_QUEUE_FLAG_SYNC_WITH_DEFAULT_STREAM"; + case UR_KERNEL_SUB_GROUP_INFO_SUB_GROUP_SIZE_INTEL: + os << "UR_KERNEL_SUB_GROUP_INFO_SUB_GROUP_SIZE_INTEL"; break; default: os << "unknown enumerator"; @@ -7935,187 +8377,183 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_queue_flag_t value) { return os; } namespace ur_params { - template <> -inline void serializeFlag(std::ostream &os, uint32_t flag) { - uint32_t val = flag; - bool first = true; - - if ((val & UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE) == - (uint32_t)UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE) { - val ^= (uint32_t)UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE; - } - - if ((val & UR_QUEUE_FLAG_PROFILING_ENABLE) == - (uint32_t)UR_QUEUE_FLAG_PROFILING_ENABLE) { - val ^= (uint32_t)UR_QUEUE_FLAG_PROFILING_ENABLE; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_QUEUE_FLAG_PROFILING_ENABLE; - } - - if ((val & UR_QUEUE_FLAG_ON_DEVICE) == (uint32_t)UR_QUEUE_FLAG_ON_DEVICE) { - val ^= (uint32_t)UR_QUEUE_FLAG_ON_DEVICE; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_QUEUE_FLAG_ON_DEVICE; - } - - if ((val & UR_QUEUE_FLAG_ON_DEVICE_DEFAULT) == - (uint32_t)UR_QUEUE_FLAG_ON_DEVICE_DEFAULT) { - val ^= (uint32_t)UR_QUEUE_FLAG_ON_DEVICE_DEFAULT; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_QUEUE_FLAG_ON_DEVICE_DEFAULT; - } - - if ((val & UR_QUEUE_FLAG_DISCARD_EVENTS) == - (uint32_t)UR_QUEUE_FLAG_DISCARD_EVENTS) { - val ^= (uint32_t)UR_QUEUE_FLAG_DISCARD_EVENTS; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_QUEUE_FLAG_DISCARD_EVENTS; +inline void serializeTagged(std::ostream &os, const void *ptr, + ur_kernel_sub_group_info_t value, size_t size) { + if (ptr == NULL) { + serializePtr(os, ptr); + return; } - if ((val & UR_QUEUE_FLAG_PRIORITY_LOW) == - (uint32_t)UR_QUEUE_FLAG_PRIORITY_LOW) { - val ^= (uint32_t)UR_QUEUE_FLAG_PRIORITY_LOW; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_QUEUE_FLAG_PRIORITY_LOW; - } + switch (value) { - if ((val & UR_QUEUE_FLAG_PRIORITY_HIGH) == - (uint32_t)UR_QUEUE_FLAG_PRIORITY_HIGH) { - val ^= (uint32_t)UR_QUEUE_FLAG_PRIORITY_HIGH; - if (!first) { - os << " | "; - } else { - first = false; + case UR_KERNEL_SUB_GROUP_INFO_MAX_SUB_GROUP_SIZE: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint32_t) << ")"; + return; } - os << UR_QUEUE_FLAG_PRIORITY_HIGH; - } + os << (void *)(tptr) << " ("; - if ((val & UR_QUEUE_FLAG_SUBMISSION_BATCHED) == - (uint32_t)UR_QUEUE_FLAG_SUBMISSION_BATCHED) { - val ^= (uint32_t)UR_QUEUE_FLAG_SUBMISSION_BATCHED; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_QUEUE_FLAG_SUBMISSION_BATCHED; - } + os << *tptr; - if ((val & UR_QUEUE_FLAG_SUBMISSION_IMMEDIATE) == - (uint32_t)UR_QUEUE_FLAG_SUBMISSION_IMMEDIATE) { - val ^= (uint32_t)UR_QUEUE_FLAG_SUBMISSION_IMMEDIATE; - if (!first) { - os << " | "; - } else { - first = false; - } - os << UR_QUEUE_FLAG_SUBMISSION_IMMEDIATE; - } + os << ")"; + } break; - if ((val & UR_QUEUE_FLAG_USE_DEFAULT_STREAM) == - (uint32_t)UR_QUEUE_FLAG_USE_DEFAULT_STREAM) { - val ^= (uint32_t)UR_QUEUE_FLAG_USE_DEFAULT_STREAM; - if (!first) { - os << " | "; - } else { - first = false; + case UR_KERNEL_SUB_GROUP_INFO_MAX_NUM_SUB_GROUPS: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint32_t) << ")"; + return; } - os << UR_QUEUE_FLAG_USE_DEFAULT_STREAM; - } + os << (void *)(tptr) << " ("; - if ((val & UR_QUEUE_FLAG_SYNC_WITH_DEFAULT_STREAM) == - (uint32_t)UR_QUEUE_FLAG_SYNC_WITH_DEFAULT_STREAM) { - val ^= (uint32_t)UR_QUEUE_FLAG_SYNC_WITH_DEFAULT_STREAM; - if (!first) { - os << " | "; - } else { - first = false; + os << *tptr; + + os << ")"; + } break; + + case UR_KERNEL_SUB_GROUP_INFO_COMPILE_NUM_SUB_GROUPS: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint32_t) << ")"; + return; } - os << UR_QUEUE_FLAG_SYNC_WITH_DEFAULT_STREAM; - } - if (val != 0) { - std::bitset<32> bits(val); - if (!first) { - os << " | "; + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + + case UR_KERNEL_SUB_GROUP_INFO_SUB_GROUP_SIZE_INTEL: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint32_t) << ")"; + return; } - os << "unknown bit flags " << bits; - } else if (first) { - os << "0"; + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + default: + os << "unknown enumerator"; + break; } } } // namespace ur_params inline std::ostream &operator<<(std::ostream &os, - const struct ur_queue_properties_t params) { - os << "(struct ur_queue_properties_t){"; - - os << ".stype = "; + enum ur_kernel_cache_config_t value) { + switch (value) { - os << (params.stype); + case UR_KERNEL_CACHE_CONFIG_DEFAULT: + os << "UR_KERNEL_CACHE_CONFIG_DEFAULT"; + break; - os << ", "; - os << ".pNext = "; + case UR_KERNEL_CACHE_CONFIG_LARGE_SLM: + os << "UR_KERNEL_CACHE_CONFIG_LARGE_SLM"; + break; - ur_params::serializeStruct(os, (params.pNext)); + case UR_KERNEL_CACHE_CONFIG_LARGE_DATA: + os << "UR_KERNEL_CACHE_CONFIG_LARGE_DATA"; + break; + default: + os << "unknown enumerator"; + break; + } + return os; +} +inline std::ostream &operator<<(std::ostream &os, + enum ur_kernel_exec_info_t value) { + switch (value) { - os << ", "; - os << ".flags = "; + case UR_KERNEL_EXEC_INFO_USM_INDIRECT_ACCESS: + os << "UR_KERNEL_EXEC_INFO_USM_INDIRECT_ACCESS"; + break; - ur_params::serializeFlag(os, (params.flags)); + case UR_KERNEL_EXEC_INFO_USM_PTRS: + os << "UR_KERNEL_EXEC_INFO_USM_PTRS"; + break; - os << "}"; + case UR_KERNEL_EXEC_INFO_CACHE_CONFIG: + os << "UR_KERNEL_EXEC_INFO_CACHE_CONFIG"; + break; + default: + os << "unknown enumerator"; + break; + } return os; } -inline std::ostream & -operator<<(std::ostream &os, const struct ur_queue_index_properties_t params) { - os << "(struct ur_queue_index_properties_t){"; +namespace ur_params { +template <> +inline void serializeTagged(std::ostream &os, const void *ptr, + ur_kernel_exec_info_t value, size_t size) { + if (ptr == NULL) { + serializePtr(os, ptr); + return; + } - os << ".stype = "; + switch (value) { - os << (params.stype); + case UR_KERNEL_EXEC_INFO_USM_INDIRECT_ACCESS: { + const ur_bool_t *tptr = (const ur_bool_t *)ptr; + if (sizeof(ur_bool_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_bool_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - os << ", "; - os << ".pNext = "; + os << *tptr; - ur_params::serializeStruct(os, (params.pNext)); + os << ")"; + } break; - os << ", "; - os << ".computeIndex = "; + case UR_KERNEL_EXEC_INFO_USM_PTRS: { - os << (params.computeIndex); + const void **tptr = (const void **)ptr; + os << "{"; + size_t nelems = size / sizeof(void *); + for (size_t i = 0; i < nelems; ++i) { + if (i != 0) { + os << ", "; + } - os << "}"; - return os; + os << tptr[i]; + } + os << "}"; + } break; + + case UR_KERNEL_EXEC_INFO_CACHE_CONFIG: { + const ur_kernel_cache_config_t *tptr = + (const ur_kernel_cache_config_t *)ptr; + if (sizeof(ur_kernel_cache_config_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_kernel_cache_config_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + default: + os << "unknown enumerator"; + break; + } } -inline std::ostream &operator<<(std::ostream &os, - const struct ur_queue_native_desc_t params) { - os << "(struct ur_queue_native_desc_t){"; +} // namespace ur_params +inline std::ostream & +operator<<(std::ostream &os, + const struct ur_kernel_arg_pointer_properties_t params) { + os << "(struct ur_kernel_arg_pointer_properties_t){"; os << ".stype = "; @@ -8126,17 +8564,13 @@ inline std::ostream &operator<<(std::ostream &os, ur_params::serializeStruct(os, (params.pNext)); - os << ", "; - os << ".pNativeData = "; - - ur_params::serializePtr(os, (params.pNativeData)); - os << "}"; return os; } inline std::ostream & -operator<<(std::ostream &os, const struct ur_queue_native_properties_t params) { - os << "(struct ur_queue_native_properties_t){"; +operator<<(std::ostream &os, + const struct ur_kernel_exec_info_properties_t params) { + os << "(struct ur_kernel_exec_info_properties_t){"; os << ".stype = "; @@ -8147,180 +8581,99 @@ operator<<(std::ostream &os, const struct ur_queue_native_properties_t params) { ur_params::serializeStruct(os, (params.pNext)); - os << ", "; - os << ".isNativeHandleOwned = "; - - os << (params.isNativeHandleOwned); - os << "}"; return os; } -inline std::ostream &operator<<(std::ostream &os, enum ur_command_t value) { - switch (value) { - - case UR_COMMAND_KERNEL_LAUNCH: - os << "UR_COMMAND_KERNEL_LAUNCH"; - break; - - case UR_COMMAND_EVENTS_WAIT: - os << "UR_COMMAND_EVENTS_WAIT"; - break; - - case UR_COMMAND_EVENTS_WAIT_WITH_BARRIER: - os << "UR_COMMAND_EVENTS_WAIT_WITH_BARRIER"; - break; - - case UR_COMMAND_MEM_BUFFER_READ: - os << "UR_COMMAND_MEM_BUFFER_READ"; - break; - - case UR_COMMAND_MEM_BUFFER_WRITE: - os << "UR_COMMAND_MEM_BUFFER_WRITE"; - break; - - case UR_COMMAND_MEM_BUFFER_READ_RECT: - os << "UR_COMMAND_MEM_BUFFER_READ_RECT"; - break; - - case UR_COMMAND_MEM_BUFFER_WRITE_RECT: - os << "UR_COMMAND_MEM_BUFFER_WRITE_RECT"; - break; - - case UR_COMMAND_MEM_BUFFER_COPY: - os << "UR_COMMAND_MEM_BUFFER_COPY"; - break; - - case UR_COMMAND_MEM_BUFFER_COPY_RECT: - os << "UR_COMMAND_MEM_BUFFER_COPY_RECT"; - break; - - case UR_COMMAND_MEM_BUFFER_FILL: - os << "UR_COMMAND_MEM_BUFFER_FILL"; - break; +inline std::ostream & +operator<<(std::ostream &os, + const struct ur_kernel_arg_sampler_properties_t params) { + os << "(struct ur_kernel_arg_sampler_properties_t){"; - case UR_COMMAND_MEM_IMAGE_READ: - os << "UR_COMMAND_MEM_IMAGE_READ"; - break; + os << ".stype = "; - case UR_COMMAND_MEM_IMAGE_WRITE: - os << "UR_COMMAND_MEM_IMAGE_WRITE"; - break; + os << (params.stype); - case UR_COMMAND_MEM_IMAGE_COPY: - os << "UR_COMMAND_MEM_IMAGE_COPY"; - break; + os << ", "; + os << ".pNext = "; - case UR_COMMAND_MEM_BUFFER_MAP: - os << "UR_COMMAND_MEM_BUFFER_MAP"; - break; + ur_params::serializeStruct(os, (params.pNext)); - case UR_COMMAND_MEM_UNMAP: - os << "UR_COMMAND_MEM_UNMAP"; - break; + os << "}"; + return os; +} +inline std::ostream & +operator<<(std::ostream &os, + const struct ur_kernel_arg_mem_obj_properties_t params) { + os << "(struct ur_kernel_arg_mem_obj_properties_t){"; - case UR_COMMAND_USM_FILL: - os << "UR_COMMAND_USM_FILL"; - break; + os << ".stype = "; - case UR_COMMAND_USM_MEMCPY: - os << "UR_COMMAND_USM_MEMCPY"; - break; + os << (params.stype); - case UR_COMMAND_USM_PREFETCH: - os << "UR_COMMAND_USM_PREFETCH"; - break; + os << ", "; + os << ".pNext = "; - case UR_COMMAND_USM_ADVISE: - os << "UR_COMMAND_USM_ADVISE"; - break; + ur_params::serializeStruct(os, (params.pNext)); - case UR_COMMAND_USM_FILL_2D: - os << "UR_COMMAND_USM_FILL_2D"; - break; + os << ", "; + os << ".memoryAccess = "; - case UR_COMMAND_USM_MEMCPY_2D: - os << "UR_COMMAND_USM_MEMCPY_2D"; - break; + ur_params::serializeFlag(os, (params.memoryAccess)); - case UR_COMMAND_DEVICE_GLOBAL_VARIABLE_WRITE: - os << "UR_COMMAND_DEVICE_GLOBAL_VARIABLE_WRITE"; - break; + os << "}"; + return os; +} +inline std::ostream & +operator<<(std::ostream &os, + const struct ur_kernel_native_properties_t params) { + os << "(struct ur_kernel_native_properties_t){"; - case UR_COMMAND_DEVICE_GLOBAL_VARIABLE_READ: - os << "UR_COMMAND_DEVICE_GLOBAL_VARIABLE_READ"; - break; + os << ".stype = "; - case UR_COMMAND_READ_HOST_PIPE: - os << "UR_COMMAND_READ_HOST_PIPE"; - break; + os << (params.stype); - case UR_COMMAND_WRITE_HOST_PIPE: - os << "UR_COMMAND_WRITE_HOST_PIPE"; - break; + os << ", "; + os << ".pNext = "; - case UR_COMMAND_COMMAND_BUFFER_ENQUEUE_EXP: - os << "UR_COMMAND_COMMAND_BUFFER_ENQUEUE_EXP"; - break; + ur_params::serializeStruct(os, (params.pNext)); - case UR_COMMAND_INTEROP_SEMAPHORE_WAIT_EXP: - os << "UR_COMMAND_INTEROP_SEMAPHORE_WAIT_EXP"; - break; + os << ", "; + os << ".isNativeHandleOwned = "; - case UR_COMMAND_INTEROP_SEMAPHORE_SIGNAL_EXP: - os << "UR_COMMAND_INTEROP_SEMAPHORE_SIGNAL_EXP"; - break; - default: - os << "unknown enumerator"; - break; - } + os << (params.isNativeHandleOwned); + + os << "}"; return os; } -inline std::ostream &operator<<(std::ostream &os, - enum ur_event_status_t value) { +inline std::ostream &operator<<(std::ostream &os, enum ur_queue_info_t value) { switch (value) { - case UR_EVENT_STATUS_COMPLETE: - os << "UR_EVENT_STATUS_COMPLETE"; - break; - - case UR_EVENT_STATUS_RUNNING: - os << "UR_EVENT_STATUS_RUNNING"; - break; - - case UR_EVENT_STATUS_SUBMITTED: - os << "UR_EVENT_STATUS_SUBMITTED"; + case UR_QUEUE_INFO_CONTEXT: + os << "UR_QUEUE_INFO_CONTEXT"; break; - case UR_EVENT_STATUS_QUEUED: - os << "UR_EVENT_STATUS_QUEUED"; - break; - default: - os << "unknown enumerator"; + case UR_QUEUE_INFO_DEVICE: + os << "UR_QUEUE_INFO_DEVICE"; break; - } - return os; -} -inline std::ostream &operator<<(std::ostream &os, enum ur_event_info_t value) { - switch (value) { - case UR_EVENT_INFO_COMMAND_QUEUE: - os << "UR_EVENT_INFO_COMMAND_QUEUE"; + case UR_QUEUE_INFO_DEVICE_DEFAULT: + os << "UR_QUEUE_INFO_DEVICE_DEFAULT"; break; - case UR_EVENT_INFO_CONTEXT: - os << "UR_EVENT_INFO_CONTEXT"; + case UR_QUEUE_INFO_FLAGS: + os << "UR_QUEUE_INFO_FLAGS"; break; - case UR_EVENT_INFO_COMMAND_TYPE: - os << "UR_EVENT_INFO_COMMAND_TYPE"; + case UR_QUEUE_INFO_REFERENCE_COUNT: + os << "UR_QUEUE_INFO_REFERENCE_COUNT"; break; - case UR_EVENT_INFO_COMMAND_EXECUTION_STATUS: - os << "UR_EVENT_INFO_COMMAND_EXECUTION_STATUS"; + case UR_QUEUE_INFO_SIZE: + os << "UR_QUEUE_INFO_SIZE"; break; - case UR_EVENT_INFO_REFERENCE_COUNT: - os << "UR_EVENT_INFO_REFERENCE_COUNT"; + case UR_QUEUE_INFO_EMPTY: + os << "UR_QUEUE_INFO_EMPTY"; break; default: os << "unknown enumerator"; @@ -8331,7 +8684,7 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_event_info_t value) { namespace ur_params { template <> inline void serializeTagged(std::ostream &os, const void *ptr, - ur_event_info_t value, size_t size) { + ur_queue_info_t value, size_t size) { if (ptr == NULL) { serializePtr(os, ptr); return; @@ -8339,7 +8692,7 @@ inline void serializeTagged(std::ostream &os, const void *ptr, switch (value) { - case UR_EVENT_INFO_COMMAND_QUEUE: { + case UR_QUEUE_INFO_CONTEXT: { const ur_queue_handle_t *tptr = (const ur_queue_handle_t *)ptr; if (sizeof(ur_queue_handle_t) > size) { os << "invalid size (is: " << size @@ -8353,11 +8706,11 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_EVENT_INFO_CONTEXT: { - const ur_context_handle_t *tptr = (const ur_context_handle_t *)ptr; - if (sizeof(ur_context_handle_t) > size) { + case UR_QUEUE_INFO_DEVICE: { + const ur_device_handle_t *tptr = (const ur_device_handle_t *)ptr; + if (sizeof(ur_device_handle_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_context_handle_t) << ")"; + << ", expected: >=" << sizeof(ur_device_handle_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -8367,35 +8720,35 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_EVENT_INFO_COMMAND_TYPE: { - const ur_command_t *tptr = (const ur_command_t *)ptr; - if (sizeof(ur_command_t) > size) { + case UR_QUEUE_INFO_DEVICE_DEFAULT: { + const ur_queue_handle_t *tptr = (const ur_queue_handle_t *)ptr; + if (sizeof(ur_queue_handle_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_command_t) << ")"; + << ", expected: >=" << sizeof(ur_queue_handle_t) << ")"; return; } os << (void *)(tptr) << " ("; - os << *tptr; + ur_params::serializePtr(os, *tptr); os << ")"; } break; - case UR_EVENT_INFO_COMMAND_EXECUTION_STATUS: { - const ur_event_status_t *tptr = (const ur_event_status_t *)ptr; - if (sizeof(ur_event_status_t) > size) { + case UR_QUEUE_INFO_FLAGS: { + const ur_queue_flags_t *tptr = (const ur_queue_flags_t *)ptr; + if (sizeof(ur_queue_flags_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(ur_event_status_t) << ")"; + << ", expected: >=" << sizeof(ur_queue_flags_t) << ")"; return; } os << (void *)(tptr) << " ("; - os << *tptr; + ur_params::serializeFlag(os, *tptr); os << ")"; } break; - case UR_EVENT_INFO_REFERENCE_COUNT: { + case UR_QUEUE_INFO_REFERENCE_COUNT: { const uint32_t *tptr = (const uint32_t *)ptr; if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size @@ -8408,99 +8761,12 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - default: - os << "unknown enumerator"; - break; - } -} -} // namespace ur_params -inline std::ostream &operator<<(std::ostream &os, - enum ur_profiling_info_t value) { - switch (value) { - - case UR_PROFILING_INFO_COMMAND_QUEUED: - os << "UR_PROFILING_INFO_COMMAND_QUEUED"; - break; - - case UR_PROFILING_INFO_COMMAND_SUBMIT: - os << "UR_PROFILING_INFO_COMMAND_SUBMIT"; - break; - - case UR_PROFILING_INFO_COMMAND_START: - os << "UR_PROFILING_INFO_COMMAND_START"; - break; - - case UR_PROFILING_INFO_COMMAND_END: - os << "UR_PROFILING_INFO_COMMAND_END"; - break; - - case UR_PROFILING_INFO_COMMAND_COMPLETE: - os << "UR_PROFILING_INFO_COMMAND_COMPLETE"; - break; - default: - os << "unknown enumerator"; - break; - } - return os; -} -namespace ur_params { -template <> -inline void serializeTagged(std::ostream &os, const void *ptr, - ur_profiling_info_t value, size_t size) { - if (ptr == NULL) { - serializePtr(os, ptr); - return; - } - - switch (value) { - - case UR_PROFILING_INFO_COMMAND_QUEUED: { - const uint64_t *tptr = (const uint64_t *)ptr; - if (sizeof(uint64_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint64_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; - - os << ")"; - } break; - - case UR_PROFILING_INFO_COMMAND_SUBMIT: { - const uint64_t *tptr = (const uint64_t *)ptr; - if (sizeof(uint64_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint64_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; - - os << ")"; - } break; - - case UR_PROFILING_INFO_COMMAND_START: { - const uint64_t *tptr = (const uint64_t *)ptr; - if (sizeof(uint64_t) > size) { - os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint64_t) << ")"; - return; - } - os << (void *)(tptr) << " ("; - - os << *tptr; - - os << ")"; - } break; - case UR_PROFILING_INFO_COMMAND_END: { - const uint64_t *tptr = (const uint64_t *)ptr; - if (sizeof(uint64_t) > size) { + case UR_QUEUE_INFO_SIZE: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint64_t) << ")"; + << ", expected: >=" << sizeof(uint32_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -8510,11 +8776,11 @@ inline void serializeTagged(std::ostream &os, const void *ptr, os << ")"; } break; - case UR_PROFILING_INFO_COMMAND_COMPLETE: { - const uint64_t *tptr = (const uint64_t *)ptr; - if (sizeof(uint64_t) > size) { + case UR_QUEUE_INFO_EMPTY: { + const ur_bool_t *tptr = (const ur_bool_t *)ptr; + if (sizeof(ur_bool_t) > size) { os << "invalid size (is: " << size - << ", expected: >=" << sizeof(uint64_t) << ")"; + << ", expected: >=" << sizeof(ur_bool_t) << ")"; return; } os << (void *)(tptr) << " ("; @@ -8529,714 +8795,692 @@ inline void serializeTagged(std::ostream &os, const void *ptr, } } } // namespace ur_params -inline std::ostream & -operator<<(std::ostream &os, const struct ur_event_native_properties_t params) { - os << "(struct ur_event_native_properties_t){"; - - os << ".stype = "; - - os << (params.stype); - - os << ", "; - os << ".pNext = "; - - ur_params::serializeStruct(os, (params.pNext)); - - os << ", "; - os << ".isNativeHandleOwned = "; - - os << (params.isNativeHandleOwned); - - os << "}"; - return os; -} -inline std::ostream &operator<<(std::ostream &os, - enum ur_execution_info_t value) { - switch (value) { - - case UR_EXECUTION_INFO_EXECUTION_INFO_COMPLETE: - os << "UR_EXECUTION_INFO_EXECUTION_INFO_COMPLETE"; - break; - - case UR_EXECUTION_INFO_EXECUTION_INFO_RUNNING: - os << "UR_EXECUTION_INFO_EXECUTION_INFO_RUNNING"; - break; - - case UR_EXECUTION_INFO_EXECUTION_INFO_SUBMITTED: - os << "UR_EXECUTION_INFO_EXECUTION_INFO_SUBMITTED"; - break; - - case UR_EXECUTION_INFO_EXECUTION_INFO_QUEUED: - os << "UR_EXECUTION_INFO_EXECUTION_INFO_QUEUED"; - break; - default: - os << "unknown enumerator"; - break; - } - return os; -} -inline std::ostream &operator<<(std::ostream &os, enum ur_function_t value) { +inline std::ostream &operator<<(std::ostream &os, enum ur_queue_flag_t value) { switch (value) { - case UR_FUNCTION_CONTEXT_CREATE: - os << "UR_FUNCTION_CONTEXT_CREATE"; - break; - - case UR_FUNCTION_CONTEXT_RETAIN: - os << "UR_FUNCTION_CONTEXT_RETAIN"; - break; - - case UR_FUNCTION_CONTEXT_RELEASE: - os << "UR_FUNCTION_CONTEXT_RELEASE"; - break; - - case UR_FUNCTION_CONTEXT_GET_INFO: - os << "UR_FUNCTION_CONTEXT_GET_INFO"; - break; - - case UR_FUNCTION_CONTEXT_GET_NATIVE_HANDLE: - os << "UR_FUNCTION_CONTEXT_GET_NATIVE_HANDLE"; - break; - - case UR_FUNCTION_CONTEXT_CREATE_WITH_NATIVE_HANDLE: - os << "UR_FUNCTION_CONTEXT_CREATE_WITH_NATIVE_HANDLE"; - break; - - case UR_FUNCTION_CONTEXT_SET_EXTENDED_DELETER: - os << "UR_FUNCTION_CONTEXT_SET_EXTENDED_DELETER"; - break; - - case UR_FUNCTION_DEVICE_GET: - os << "UR_FUNCTION_DEVICE_GET"; - break; - - case UR_FUNCTION_DEVICE_GET_INFO: - os << "UR_FUNCTION_DEVICE_GET_INFO"; - break; - - case UR_FUNCTION_DEVICE_RETAIN: - os << "UR_FUNCTION_DEVICE_RETAIN"; - break; - - case UR_FUNCTION_DEVICE_RELEASE: - os << "UR_FUNCTION_DEVICE_RELEASE"; - break; - - case UR_FUNCTION_DEVICE_PARTITION: - os << "UR_FUNCTION_DEVICE_PARTITION"; - break; - - case UR_FUNCTION_DEVICE_SELECT_BINARY: - os << "UR_FUNCTION_DEVICE_SELECT_BINARY"; - break; - - case UR_FUNCTION_DEVICE_GET_NATIVE_HANDLE: - os << "UR_FUNCTION_DEVICE_GET_NATIVE_HANDLE"; - break; - - case UR_FUNCTION_DEVICE_CREATE_WITH_NATIVE_HANDLE: - os << "UR_FUNCTION_DEVICE_CREATE_WITH_NATIVE_HANDLE"; - break; - - case UR_FUNCTION_DEVICE_GET_GLOBAL_TIMESTAMPS: - os << "UR_FUNCTION_DEVICE_GET_GLOBAL_TIMESTAMPS"; - break; - - case UR_FUNCTION_ENQUEUE_KERNEL_LAUNCH: - os << "UR_FUNCTION_ENQUEUE_KERNEL_LAUNCH"; - break; - - case UR_FUNCTION_ENQUEUE_EVENTS_WAIT: - os << "UR_FUNCTION_ENQUEUE_EVENTS_WAIT"; - break; - - case UR_FUNCTION_ENQUEUE_EVENTS_WAIT_WITH_BARRIER: - os << "UR_FUNCTION_ENQUEUE_EVENTS_WAIT_WITH_BARRIER"; - break; - - case UR_FUNCTION_ENQUEUE_MEM_BUFFER_READ: - os << "UR_FUNCTION_ENQUEUE_MEM_BUFFER_READ"; - break; - - case UR_FUNCTION_ENQUEUE_MEM_BUFFER_WRITE: - os << "UR_FUNCTION_ENQUEUE_MEM_BUFFER_WRITE"; - break; - - case UR_FUNCTION_ENQUEUE_MEM_BUFFER_READ_RECT: - os << "UR_FUNCTION_ENQUEUE_MEM_BUFFER_READ_RECT"; - break; - - case UR_FUNCTION_ENQUEUE_MEM_BUFFER_WRITE_RECT: - os << "UR_FUNCTION_ENQUEUE_MEM_BUFFER_WRITE_RECT"; - break; - - case UR_FUNCTION_ENQUEUE_MEM_BUFFER_COPY: - os << "UR_FUNCTION_ENQUEUE_MEM_BUFFER_COPY"; - break; - - case UR_FUNCTION_ENQUEUE_MEM_BUFFER_COPY_RECT: - os << "UR_FUNCTION_ENQUEUE_MEM_BUFFER_COPY_RECT"; - break; - - case UR_FUNCTION_ENQUEUE_MEM_BUFFER_FILL: - os << "UR_FUNCTION_ENQUEUE_MEM_BUFFER_FILL"; + case UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE: + os << "UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE"; break; - case UR_FUNCTION_ENQUEUE_MEM_IMAGE_READ: - os << "UR_FUNCTION_ENQUEUE_MEM_IMAGE_READ"; + case UR_QUEUE_FLAG_PROFILING_ENABLE: + os << "UR_QUEUE_FLAG_PROFILING_ENABLE"; break; - case UR_FUNCTION_ENQUEUE_MEM_IMAGE_WRITE: - os << "UR_FUNCTION_ENQUEUE_MEM_IMAGE_WRITE"; + case UR_QUEUE_FLAG_ON_DEVICE: + os << "UR_QUEUE_FLAG_ON_DEVICE"; break; - case UR_FUNCTION_ENQUEUE_MEM_IMAGE_COPY: - os << "UR_FUNCTION_ENQUEUE_MEM_IMAGE_COPY"; + case UR_QUEUE_FLAG_ON_DEVICE_DEFAULT: + os << "UR_QUEUE_FLAG_ON_DEVICE_DEFAULT"; break; - case UR_FUNCTION_ENQUEUE_MEM_BUFFER_MAP: - os << "UR_FUNCTION_ENQUEUE_MEM_BUFFER_MAP"; + case UR_QUEUE_FLAG_DISCARD_EVENTS: + os << "UR_QUEUE_FLAG_DISCARD_EVENTS"; break; - case UR_FUNCTION_ENQUEUE_MEM_UNMAP: - os << "UR_FUNCTION_ENQUEUE_MEM_UNMAP"; + case UR_QUEUE_FLAG_PRIORITY_LOW: + os << "UR_QUEUE_FLAG_PRIORITY_LOW"; break; - case UR_FUNCTION_ENQUEUE_USM_FILL: - os << "UR_FUNCTION_ENQUEUE_USM_FILL"; + case UR_QUEUE_FLAG_PRIORITY_HIGH: + os << "UR_QUEUE_FLAG_PRIORITY_HIGH"; break; - case UR_FUNCTION_ENQUEUE_USM_MEMCPY: - os << "UR_FUNCTION_ENQUEUE_USM_MEMCPY"; + case UR_QUEUE_FLAG_SUBMISSION_BATCHED: + os << "UR_QUEUE_FLAG_SUBMISSION_BATCHED"; break; - case UR_FUNCTION_ENQUEUE_USM_PREFETCH: - os << "UR_FUNCTION_ENQUEUE_USM_PREFETCH"; + case UR_QUEUE_FLAG_SUBMISSION_IMMEDIATE: + os << "UR_QUEUE_FLAG_SUBMISSION_IMMEDIATE"; break; - case UR_FUNCTION_ENQUEUE_USM_ADVISE: - os << "UR_FUNCTION_ENQUEUE_USM_ADVISE"; + case UR_QUEUE_FLAG_USE_DEFAULT_STREAM: + os << "UR_QUEUE_FLAG_USE_DEFAULT_STREAM"; break; - case UR_FUNCTION_ENQUEUE_DEVICE_GLOBAL_VARIABLE_WRITE: - os << "UR_FUNCTION_ENQUEUE_DEVICE_GLOBAL_VARIABLE_WRITE"; + case UR_QUEUE_FLAG_SYNC_WITH_DEFAULT_STREAM: + os << "UR_QUEUE_FLAG_SYNC_WITH_DEFAULT_STREAM"; break; - - case UR_FUNCTION_ENQUEUE_DEVICE_GLOBAL_VARIABLE_READ: - os << "UR_FUNCTION_ENQUEUE_DEVICE_GLOBAL_VARIABLE_READ"; + default: + os << "unknown enumerator"; break; + } + return os; +} +namespace ur_params { - case UR_FUNCTION_EVENT_GET_INFO: - os << "UR_FUNCTION_EVENT_GET_INFO"; - break; +template <> +inline void serializeFlag(std::ostream &os, uint32_t flag) { + uint32_t val = flag; + bool first = true; - case UR_FUNCTION_EVENT_GET_PROFILING_INFO: - os << "UR_FUNCTION_EVENT_GET_PROFILING_INFO"; - break; + if ((val & UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE) == + (uint32_t)UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE) { + val ^= (uint32_t)UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE; + } - case UR_FUNCTION_EVENT_WAIT: - os << "UR_FUNCTION_EVENT_WAIT"; - break; + if ((val & UR_QUEUE_FLAG_PROFILING_ENABLE) == + (uint32_t)UR_QUEUE_FLAG_PROFILING_ENABLE) { + val ^= (uint32_t)UR_QUEUE_FLAG_PROFILING_ENABLE; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_QUEUE_FLAG_PROFILING_ENABLE; + } - case UR_FUNCTION_EVENT_RETAIN: - os << "UR_FUNCTION_EVENT_RETAIN"; - break; + if ((val & UR_QUEUE_FLAG_ON_DEVICE) == (uint32_t)UR_QUEUE_FLAG_ON_DEVICE) { + val ^= (uint32_t)UR_QUEUE_FLAG_ON_DEVICE; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_QUEUE_FLAG_ON_DEVICE; + } - case UR_FUNCTION_EVENT_RELEASE: - os << "UR_FUNCTION_EVENT_RELEASE"; - break; + if ((val & UR_QUEUE_FLAG_ON_DEVICE_DEFAULT) == + (uint32_t)UR_QUEUE_FLAG_ON_DEVICE_DEFAULT) { + val ^= (uint32_t)UR_QUEUE_FLAG_ON_DEVICE_DEFAULT; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_QUEUE_FLAG_ON_DEVICE_DEFAULT; + } - case UR_FUNCTION_EVENT_GET_NATIVE_HANDLE: - os << "UR_FUNCTION_EVENT_GET_NATIVE_HANDLE"; - break; + if ((val & UR_QUEUE_FLAG_DISCARD_EVENTS) == + (uint32_t)UR_QUEUE_FLAG_DISCARD_EVENTS) { + val ^= (uint32_t)UR_QUEUE_FLAG_DISCARD_EVENTS; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_QUEUE_FLAG_DISCARD_EVENTS; + } - case UR_FUNCTION_EVENT_CREATE_WITH_NATIVE_HANDLE: - os << "UR_FUNCTION_EVENT_CREATE_WITH_NATIVE_HANDLE"; - break; + if ((val & UR_QUEUE_FLAG_PRIORITY_LOW) == + (uint32_t)UR_QUEUE_FLAG_PRIORITY_LOW) { + val ^= (uint32_t)UR_QUEUE_FLAG_PRIORITY_LOW; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_QUEUE_FLAG_PRIORITY_LOW; + } - case UR_FUNCTION_EVENT_SET_CALLBACK: - os << "UR_FUNCTION_EVENT_SET_CALLBACK"; - break; + if ((val & UR_QUEUE_FLAG_PRIORITY_HIGH) == + (uint32_t)UR_QUEUE_FLAG_PRIORITY_HIGH) { + val ^= (uint32_t)UR_QUEUE_FLAG_PRIORITY_HIGH; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_QUEUE_FLAG_PRIORITY_HIGH; + } - case UR_FUNCTION_KERNEL_CREATE: - os << "UR_FUNCTION_KERNEL_CREATE"; - break; + if ((val & UR_QUEUE_FLAG_SUBMISSION_BATCHED) == + (uint32_t)UR_QUEUE_FLAG_SUBMISSION_BATCHED) { + val ^= (uint32_t)UR_QUEUE_FLAG_SUBMISSION_BATCHED; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_QUEUE_FLAG_SUBMISSION_BATCHED; + } - case UR_FUNCTION_KERNEL_SET_ARG_VALUE: - os << "UR_FUNCTION_KERNEL_SET_ARG_VALUE"; - break; + if ((val & UR_QUEUE_FLAG_SUBMISSION_IMMEDIATE) == + (uint32_t)UR_QUEUE_FLAG_SUBMISSION_IMMEDIATE) { + val ^= (uint32_t)UR_QUEUE_FLAG_SUBMISSION_IMMEDIATE; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_QUEUE_FLAG_SUBMISSION_IMMEDIATE; + } - case UR_FUNCTION_KERNEL_SET_ARG_LOCAL: - os << "UR_FUNCTION_KERNEL_SET_ARG_LOCAL"; - break; + if ((val & UR_QUEUE_FLAG_USE_DEFAULT_STREAM) == + (uint32_t)UR_QUEUE_FLAG_USE_DEFAULT_STREAM) { + val ^= (uint32_t)UR_QUEUE_FLAG_USE_DEFAULT_STREAM; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_QUEUE_FLAG_USE_DEFAULT_STREAM; + } - case UR_FUNCTION_KERNEL_GET_INFO: - os << "UR_FUNCTION_KERNEL_GET_INFO"; - break; + if ((val & UR_QUEUE_FLAG_SYNC_WITH_DEFAULT_STREAM) == + (uint32_t)UR_QUEUE_FLAG_SYNC_WITH_DEFAULT_STREAM) { + val ^= (uint32_t)UR_QUEUE_FLAG_SYNC_WITH_DEFAULT_STREAM; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_QUEUE_FLAG_SYNC_WITH_DEFAULT_STREAM; + } + if (val != 0) { + std::bitset<32> bits(val); + if (!first) { + os << " | "; + } + os << "unknown bit flags " << bits; + } else if (first) { + os << "0"; + } +} +} // namespace ur_params +inline std::ostream &operator<<(std::ostream &os, + const struct ur_queue_properties_t params) { + os << "(struct ur_queue_properties_t){"; - case UR_FUNCTION_KERNEL_GET_GROUP_INFO: - os << "UR_FUNCTION_KERNEL_GET_GROUP_INFO"; - break; + os << ".stype = "; - case UR_FUNCTION_KERNEL_GET_SUB_GROUP_INFO: - os << "UR_FUNCTION_KERNEL_GET_SUB_GROUP_INFO"; - break; + os << (params.stype); - case UR_FUNCTION_KERNEL_RETAIN: - os << "UR_FUNCTION_KERNEL_RETAIN"; - break; + os << ", "; + os << ".pNext = "; - case UR_FUNCTION_KERNEL_RELEASE: - os << "UR_FUNCTION_KERNEL_RELEASE"; - break; + ur_params::serializeStruct(os, (params.pNext)); - case UR_FUNCTION_KERNEL_SET_ARG_POINTER: - os << "UR_FUNCTION_KERNEL_SET_ARG_POINTER"; - break; + os << ", "; + os << ".flags = "; - case UR_FUNCTION_KERNEL_SET_EXEC_INFO: - os << "UR_FUNCTION_KERNEL_SET_EXEC_INFO"; - break; + ur_params::serializeFlag(os, (params.flags)); - case UR_FUNCTION_KERNEL_SET_ARG_SAMPLER: - os << "UR_FUNCTION_KERNEL_SET_ARG_SAMPLER"; - break; + os << "}"; + return os; +} +inline std::ostream & +operator<<(std::ostream &os, const struct ur_queue_index_properties_t params) { + os << "(struct ur_queue_index_properties_t){"; - case UR_FUNCTION_KERNEL_SET_ARG_MEM_OBJ: - os << "UR_FUNCTION_KERNEL_SET_ARG_MEM_OBJ"; - break; + os << ".stype = "; - case UR_FUNCTION_KERNEL_SET_SPECIALIZATION_CONSTANTS: - os << "UR_FUNCTION_KERNEL_SET_SPECIALIZATION_CONSTANTS"; - break; + os << (params.stype); - case UR_FUNCTION_KERNEL_GET_NATIVE_HANDLE: - os << "UR_FUNCTION_KERNEL_GET_NATIVE_HANDLE"; - break; + os << ", "; + os << ".pNext = "; - case UR_FUNCTION_KERNEL_CREATE_WITH_NATIVE_HANDLE: - os << "UR_FUNCTION_KERNEL_CREATE_WITH_NATIVE_HANDLE"; - break; + ur_params::serializeStruct(os, (params.pNext)); - case UR_FUNCTION_MEM_IMAGE_CREATE: - os << "UR_FUNCTION_MEM_IMAGE_CREATE"; - break; + os << ", "; + os << ".computeIndex = "; - case UR_FUNCTION_MEM_BUFFER_CREATE: - os << "UR_FUNCTION_MEM_BUFFER_CREATE"; - break; + os << (params.computeIndex); - case UR_FUNCTION_MEM_RETAIN: - os << "UR_FUNCTION_MEM_RETAIN"; - break; + os << "}"; + return os; +} +inline std::ostream &operator<<(std::ostream &os, + const struct ur_queue_native_desc_t params) { + os << "(struct ur_queue_native_desc_t){"; - case UR_FUNCTION_MEM_RELEASE: - os << "UR_FUNCTION_MEM_RELEASE"; - break; + os << ".stype = "; - case UR_FUNCTION_MEM_BUFFER_PARTITION: - os << "UR_FUNCTION_MEM_BUFFER_PARTITION"; - break; + os << (params.stype); - case UR_FUNCTION_MEM_GET_NATIVE_HANDLE: - os << "UR_FUNCTION_MEM_GET_NATIVE_HANDLE"; - break; + os << ", "; + os << ".pNext = "; - case UR_FUNCTION_ENQUEUE_READ_HOST_PIPE: - os << "UR_FUNCTION_ENQUEUE_READ_HOST_PIPE"; - break; + ur_params::serializeStruct(os, (params.pNext)); - case UR_FUNCTION_MEM_GET_INFO: - os << "UR_FUNCTION_MEM_GET_INFO"; - break; + os << ", "; + os << ".pNativeData = "; - case UR_FUNCTION_MEM_IMAGE_GET_INFO: - os << "UR_FUNCTION_MEM_IMAGE_GET_INFO"; - break; + ur_params::serializePtr(os, (params.pNativeData)); - case UR_FUNCTION_PLATFORM_GET: - os << "UR_FUNCTION_PLATFORM_GET"; - break; + os << "}"; + return os; +} +inline std::ostream & +operator<<(std::ostream &os, const struct ur_queue_native_properties_t params) { + os << "(struct ur_queue_native_properties_t){"; - case UR_FUNCTION_PLATFORM_GET_INFO: - os << "UR_FUNCTION_PLATFORM_GET_INFO"; - break; + os << ".stype = "; - case UR_FUNCTION_PLATFORM_GET_API_VERSION: - os << "UR_FUNCTION_PLATFORM_GET_API_VERSION"; - break; + os << (params.stype); - case UR_FUNCTION_PLATFORM_GET_NATIVE_HANDLE: - os << "UR_FUNCTION_PLATFORM_GET_NATIVE_HANDLE"; - break; + os << ", "; + os << ".pNext = "; - case UR_FUNCTION_PLATFORM_CREATE_WITH_NATIVE_HANDLE: - os << "UR_FUNCTION_PLATFORM_CREATE_WITH_NATIVE_HANDLE"; - break; + ur_params::serializeStruct(os, (params.pNext)); - case UR_FUNCTION_PROGRAM_CREATE_WITH_IL: - os << "UR_FUNCTION_PROGRAM_CREATE_WITH_IL"; - break; + os << ", "; + os << ".isNativeHandleOwned = "; - case UR_FUNCTION_PROGRAM_CREATE_WITH_BINARY: - os << "UR_FUNCTION_PROGRAM_CREATE_WITH_BINARY"; - break; + os << (params.isNativeHandleOwned); + + os << "}"; + return os; +} +inline std::ostream &operator<<(std::ostream &os, enum ur_command_t value) { + switch (value) { - case UR_FUNCTION_PROGRAM_BUILD: - os << "UR_FUNCTION_PROGRAM_BUILD"; + case UR_COMMAND_KERNEL_LAUNCH: + os << "UR_COMMAND_KERNEL_LAUNCH"; break; - case UR_FUNCTION_PROGRAM_COMPILE: - os << "UR_FUNCTION_PROGRAM_COMPILE"; + case UR_COMMAND_EVENTS_WAIT: + os << "UR_COMMAND_EVENTS_WAIT"; break; - case UR_FUNCTION_PROGRAM_LINK: - os << "UR_FUNCTION_PROGRAM_LINK"; + case UR_COMMAND_EVENTS_WAIT_WITH_BARRIER: + os << "UR_COMMAND_EVENTS_WAIT_WITH_BARRIER"; break; - case UR_FUNCTION_PROGRAM_RETAIN: - os << "UR_FUNCTION_PROGRAM_RETAIN"; + case UR_COMMAND_MEM_BUFFER_READ: + os << "UR_COMMAND_MEM_BUFFER_READ"; break; - case UR_FUNCTION_PROGRAM_RELEASE: - os << "UR_FUNCTION_PROGRAM_RELEASE"; + case UR_COMMAND_MEM_BUFFER_WRITE: + os << "UR_COMMAND_MEM_BUFFER_WRITE"; break; - case UR_FUNCTION_PROGRAM_GET_FUNCTION_POINTER: - os << "UR_FUNCTION_PROGRAM_GET_FUNCTION_POINTER"; + case UR_COMMAND_MEM_BUFFER_READ_RECT: + os << "UR_COMMAND_MEM_BUFFER_READ_RECT"; break; - case UR_FUNCTION_PROGRAM_GET_INFO: - os << "UR_FUNCTION_PROGRAM_GET_INFO"; + case UR_COMMAND_MEM_BUFFER_WRITE_RECT: + os << "UR_COMMAND_MEM_BUFFER_WRITE_RECT"; break; - case UR_FUNCTION_PROGRAM_GET_BUILD_INFO: - os << "UR_FUNCTION_PROGRAM_GET_BUILD_INFO"; + case UR_COMMAND_MEM_BUFFER_COPY: + os << "UR_COMMAND_MEM_BUFFER_COPY"; break; - case UR_FUNCTION_PROGRAM_SET_SPECIALIZATION_CONSTANTS: - os << "UR_FUNCTION_PROGRAM_SET_SPECIALIZATION_CONSTANTS"; + case UR_COMMAND_MEM_BUFFER_COPY_RECT: + os << "UR_COMMAND_MEM_BUFFER_COPY_RECT"; break; - case UR_FUNCTION_PROGRAM_GET_NATIVE_HANDLE: - os << "UR_FUNCTION_PROGRAM_GET_NATIVE_HANDLE"; + case UR_COMMAND_MEM_BUFFER_FILL: + os << "UR_COMMAND_MEM_BUFFER_FILL"; break; - case UR_FUNCTION_PROGRAM_CREATE_WITH_NATIVE_HANDLE: - os << "UR_FUNCTION_PROGRAM_CREATE_WITH_NATIVE_HANDLE"; + case UR_COMMAND_MEM_IMAGE_READ: + os << "UR_COMMAND_MEM_IMAGE_READ"; break; - case UR_FUNCTION_QUEUE_GET_INFO: - os << "UR_FUNCTION_QUEUE_GET_INFO"; + case UR_COMMAND_MEM_IMAGE_WRITE: + os << "UR_COMMAND_MEM_IMAGE_WRITE"; break; - case UR_FUNCTION_QUEUE_CREATE: - os << "UR_FUNCTION_QUEUE_CREATE"; + case UR_COMMAND_MEM_IMAGE_COPY: + os << "UR_COMMAND_MEM_IMAGE_COPY"; break; - case UR_FUNCTION_QUEUE_RETAIN: - os << "UR_FUNCTION_QUEUE_RETAIN"; + case UR_COMMAND_MEM_BUFFER_MAP: + os << "UR_COMMAND_MEM_BUFFER_MAP"; break; - case UR_FUNCTION_QUEUE_RELEASE: - os << "UR_FUNCTION_QUEUE_RELEASE"; + case UR_COMMAND_MEM_UNMAP: + os << "UR_COMMAND_MEM_UNMAP"; break; - case UR_FUNCTION_QUEUE_GET_NATIVE_HANDLE: - os << "UR_FUNCTION_QUEUE_GET_NATIVE_HANDLE"; + case UR_COMMAND_USM_FILL: + os << "UR_COMMAND_USM_FILL"; break; - case UR_FUNCTION_QUEUE_CREATE_WITH_NATIVE_HANDLE: - os << "UR_FUNCTION_QUEUE_CREATE_WITH_NATIVE_HANDLE"; + case UR_COMMAND_USM_MEMCPY: + os << "UR_COMMAND_USM_MEMCPY"; break; - case UR_FUNCTION_QUEUE_FINISH: - os << "UR_FUNCTION_QUEUE_FINISH"; + case UR_COMMAND_USM_PREFETCH: + os << "UR_COMMAND_USM_PREFETCH"; break; - case UR_FUNCTION_QUEUE_FLUSH: - os << "UR_FUNCTION_QUEUE_FLUSH"; + case UR_COMMAND_USM_ADVISE: + os << "UR_COMMAND_USM_ADVISE"; break; - case UR_FUNCTION_INIT: - os << "UR_FUNCTION_INIT"; + case UR_COMMAND_USM_FILL_2D: + os << "UR_COMMAND_USM_FILL_2D"; break; - case UR_FUNCTION_TEAR_DOWN: - os << "UR_FUNCTION_TEAR_DOWN"; + case UR_COMMAND_USM_MEMCPY_2D: + os << "UR_COMMAND_USM_MEMCPY_2D"; break; - case UR_FUNCTION_SAMPLER_CREATE: - os << "UR_FUNCTION_SAMPLER_CREATE"; + case UR_COMMAND_DEVICE_GLOBAL_VARIABLE_WRITE: + os << "UR_COMMAND_DEVICE_GLOBAL_VARIABLE_WRITE"; break; - case UR_FUNCTION_SAMPLER_RETAIN: - os << "UR_FUNCTION_SAMPLER_RETAIN"; + case UR_COMMAND_DEVICE_GLOBAL_VARIABLE_READ: + os << "UR_COMMAND_DEVICE_GLOBAL_VARIABLE_READ"; break; - case UR_FUNCTION_SAMPLER_RELEASE: - os << "UR_FUNCTION_SAMPLER_RELEASE"; + case UR_COMMAND_READ_HOST_PIPE: + os << "UR_COMMAND_READ_HOST_PIPE"; break; - case UR_FUNCTION_SAMPLER_GET_INFO: - os << "UR_FUNCTION_SAMPLER_GET_INFO"; + case UR_COMMAND_WRITE_HOST_PIPE: + os << "UR_COMMAND_WRITE_HOST_PIPE"; break; - case UR_FUNCTION_SAMPLER_GET_NATIVE_HANDLE: - os << "UR_FUNCTION_SAMPLER_GET_NATIVE_HANDLE"; + case UR_COMMAND_COMMAND_BUFFER_ENQUEUE_EXP: + os << "UR_COMMAND_COMMAND_BUFFER_ENQUEUE_EXP"; break; - case UR_FUNCTION_SAMPLER_CREATE_WITH_NATIVE_HANDLE: - os << "UR_FUNCTION_SAMPLER_CREATE_WITH_NATIVE_HANDLE"; + case UR_COMMAND_INTEROP_SEMAPHORE_WAIT_EXP: + os << "UR_COMMAND_INTEROP_SEMAPHORE_WAIT_EXP"; break; - case UR_FUNCTION_USM_HOST_ALLOC: - os << "UR_FUNCTION_USM_HOST_ALLOC"; + case UR_COMMAND_INTEROP_SEMAPHORE_SIGNAL_EXP: + os << "UR_COMMAND_INTEROP_SEMAPHORE_SIGNAL_EXP"; break; - - case UR_FUNCTION_USM_DEVICE_ALLOC: - os << "UR_FUNCTION_USM_DEVICE_ALLOC"; + default: + os << "unknown enumerator"; break; + } + return os; +} +inline std::ostream &operator<<(std::ostream &os, + enum ur_event_status_t value) { + switch (value) { - case UR_FUNCTION_USM_SHARED_ALLOC: - os << "UR_FUNCTION_USM_SHARED_ALLOC"; + case UR_EVENT_STATUS_COMPLETE: + os << "UR_EVENT_STATUS_COMPLETE"; break; - case UR_FUNCTION_USM_FREE: - os << "UR_FUNCTION_USM_FREE"; + case UR_EVENT_STATUS_RUNNING: + os << "UR_EVENT_STATUS_RUNNING"; break; - case UR_FUNCTION_USM_GET_MEM_ALLOC_INFO: - os << "UR_FUNCTION_USM_GET_MEM_ALLOC_INFO"; + case UR_EVENT_STATUS_SUBMITTED: + os << "UR_EVENT_STATUS_SUBMITTED"; break; - case UR_FUNCTION_USM_POOL_CREATE: - os << "UR_FUNCTION_USM_POOL_CREATE"; + case UR_EVENT_STATUS_QUEUED: + os << "UR_EVENT_STATUS_QUEUED"; break; - - case UR_FUNCTION_COMMAND_BUFFER_CREATE_EXP: - os << "UR_FUNCTION_COMMAND_BUFFER_CREATE_EXP"; + default: + os << "unknown enumerator"; break; + } + return os; +} +inline std::ostream &operator<<(std::ostream &os, enum ur_event_info_t value) { + switch (value) { - case UR_FUNCTION_PLATFORM_GET_BACKEND_OPTION: - os << "UR_FUNCTION_PLATFORM_GET_BACKEND_OPTION"; + case UR_EVENT_INFO_COMMAND_QUEUE: + os << "UR_EVENT_INFO_COMMAND_QUEUE"; break; - case UR_FUNCTION_MEM_BUFFER_CREATE_WITH_NATIVE_HANDLE: - os << "UR_FUNCTION_MEM_BUFFER_CREATE_WITH_NATIVE_HANDLE"; + case UR_EVENT_INFO_CONTEXT: + os << "UR_EVENT_INFO_CONTEXT"; break; - case UR_FUNCTION_MEM_IMAGE_CREATE_WITH_NATIVE_HANDLE: - os << "UR_FUNCTION_MEM_IMAGE_CREATE_WITH_NATIVE_HANDLE"; + case UR_EVENT_INFO_COMMAND_TYPE: + os << "UR_EVENT_INFO_COMMAND_TYPE"; break; - case UR_FUNCTION_ENQUEUE_WRITE_HOST_PIPE: - os << "UR_FUNCTION_ENQUEUE_WRITE_HOST_PIPE"; + case UR_EVENT_INFO_COMMAND_EXECUTION_STATUS: + os << "UR_EVENT_INFO_COMMAND_EXECUTION_STATUS"; break; - case UR_FUNCTION_USM_POOL_RETAIN: - os << "UR_FUNCTION_USM_POOL_RETAIN"; + case UR_EVENT_INFO_REFERENCE_COUNT: + os << "UR_EVENT_INFO_REFERENCE_COUNT"; break; - - case UR_FUNCTION_USM_POOL_RELEASE: - os << "UR_FUNCTION_USM_POOL_RELEASE"; + default: + os << "unknown enumerator"; break; + } + return os; +} +namespace ur_params { +template <> +inline void serializeTagged(std::ostream &os, const void *ptr, + ur_event_info_t value, size_t size) { + if (ptr == NULL) { + serializePtr(os, ptr); + return; + } - case UR_FUNCTION_USM_POOL_GET_INFO: - os << "UR_FUNCTION_USM_POOL_GET_INFO"; - break; + switch (value) { - case UR_FUNCTION_COMMAND_BUFFER_RETAIN_EXP: - os << "UR_FUNCTION_COMMAND_BUFFER_RETAIN_EXP"; - break; + case UR_EVENT_INFO_COMMAND_QUEUE: { + const ur_queue_handle_t *tptr = (const ur_queue_handle_t *)ptr; + if (sizeof(ur_queue_handle_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_queue_handle_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - case UR_FUNCTION_COMMAND_BUFFER_RELEASE_EXP: - os << "UR_FUNCTION_COMMAND_BUFFER_RELEASE_EXP"; - break; + ur_params::serializePtr(os, *tptr); - case UR_FUNCTION_COMMAND_BUFFER_FINALIZE_EXP: - os << "UR_FUNCTION_COMMAND_BUFFER_FINALIZE_EXP"; - break; + os << ")"; + } break; - case UR_FUNCTION_COMMAND_BUFFER_APPEND_KERNEL_LAUNCH_EXP: - os << "UR_FUNCTION_COMMAND_BUFFER_APPEND_KERNEL_LAUNCH_EXP"; - break; + case UR_EVENT_INFO_CONTEXT: { + const ur_context_handle_t *tptr = (const ur_context_handle_t *)ptr; + if (sizeof(ur_context_handle_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_context_handle_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - case UR_FUNCTION_COMMAND_BUFFER_ENQUEUE_EXP: - os << "UR_FUNCTION_COMMAND_BUFFER_ENQUEUE_EXP"; - break; + ur_params::serializePtr(os, *tptr); - case UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMCPY_USM_EXP: - os << "UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMCPY_USM_EXP"; - break; + os << ")"; + } break; - case UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_COPY_EXP: - os << "UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_COPY_EXP"; - break; + case UR_EVENT_INFO_COMMAND_TYPE: { + const ur_command_t *tptr = (const ur_command_t *)ptr; + if (sizeof(ur_command_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_command_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - case UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_COPY_RECT_EXP: - os << "UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_COPY_RECT_EXP"; - break; + os << *tptr; - case UR_FUNCTION_USM_PITCHED_ALLOC_EXP: - os << "UR_FUNCTION_USM_PITCHED_ALLOC_EXP"; - break; + os << ")"; + } break; - case UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_HANDLE_DESTROY_EXP: - os << "UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_HANDLE_DESTROY_EXP"; - break; + case UR_EVENT_INFO_COMMAND_EXECUTION_STATUS: { + const ur_event_status_t *tptr = (const ur_event_status_t *)ptr; + if (sizeof(ur_event_status_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_event_status_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - case UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_HANDLE_DESTROY_EXP: - os << "UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_HANDLE_DESTROY_EXP"; - break; + os << *tptr; - case UR_FUNCTION_BINDLESS_IMAGES_IMAGE_ALLOCATE_EXP: - os << "UR_FUNCTION_BINDLESS_IMAGES_IMAGE_ALLOCATE_EXP"; - break; + os << ")"; + } break; - case UR_FUNCTION_BINDLESS_IMAGES_IMAGE_FREE_EXP: - os << "UR_FUNCTION_BINDLESS_IMAGES_IMAGE_FREE_EXP"; - break; + case UR_EVENT_INFO_REFERENCE_COUNT: { + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint32_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - case UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_CREATE_EXP: - os << "UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_CREATE_EXP"; - break; + os << *tptr; - case UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_CREATE_EXP: - os << "UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_CREATE_EXP"; + os << ")"; + } break; + default: + os << "unknown enumerator"; break; + } +} +} // namespace ur_params +inline std::ostream &operator<<(std::ostream &os, + enum ur_profiling_info_t value) { + switch (value) { - case UR_FUNCTION_BINDLESS_IMAGES_IMAGE_COPY_EXP: - os << "UR_FUNCTION_BINDLESS_IMAGES_IMAGE_COPY_EXP"; + case UR_PROFILING_INFO_COMMAND_QUEUED: + os << "UR_PROFILING_INFO_COMMAND_QUEUED"; break; - case UR_FUNCTION_BINDLESS_IMAGES_IMAGE_GET_INFO_EXP: - os << "UR_FUNCTION_BINDLESS_IMAGES_IMAGE_GET_INFO_EXP"; + case UR_PROFILING_INFO_COMMAND_SUBMIT: + os << "UR_PROFILING_INFO_COMMAND_SUBMIT"; break; - case UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_GET_LEVEL_EXP: - os << "UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_GET_LEVEL_EXP"; + case UR_PROFILING_INFO_COMMAND_START: + os << "UR_PROFILING_INFO_COMMAND_START"; break; - case UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_FREE_EXP: - os << "UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_FREE_EXP"; + case UR_PROFILING_INFO_COMMAND_END: + os << "UR_PROFILING_INFO_COMMAND_END"; break; - case UR_FUNCTION_BINDLESS_IMAGES_IMPORT_OPAQUE_FD_EXP: - os << "UR_FUNCTION_BINDLESS_IMAGES_IMPORT_OPAQUE_FD_EXP"; + case UR_PROFILING_INFO_COMMAND_COMPLETE: + os << "UR_PROFILING_INFO_COMMAND_COMPLETE"; break; - - case UR_FUNCTION_BINDLESS_IMAGES_MAP_EXTERNAL_ARRAY_EXP: - os << "UR_FUNCTION_BINDLESS_IMAGES_MAP_EXTERNAL_ARRAY_EXP"; + default: + os << "unknown enumerator"; break; + } + return os; +} +namespace ur_params { +template <> +inline void serializeTagged(std::ostream &os, const void *ptr, + ur_profiling_info_t value, size_t size) { + if (ptr == NULL) { + serializePtr(os, ptr); + return; + } - case UR_FUNCTION_BINDLESS_IMAGES_RELEASE_INTEROP_EXP: - os << "UR_FUNCTION_BINDLESS_IMAGES_RELEASE_INTEROP_EXP"; - break; + switch (value) { - case UR_FUNCTION_BINDLESS_IMAGES_IMPORT_EXTERNAL_SEMAPHORE_OPAQUE_FD_EXP: - os << "UR_FUNCTION_BINDLESS_IMAGES_IMPORT_EXTERNAL_SEMAPHORE_OPAQUE_FD_" - "EXP"; - break; + case UR_PROFILING_INFO_COMMAND_QUEUED: { + const uint64_t *tptr = (const uint64_t *)ptr; + if (sizeof(uint64_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint64_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - case UR_FUNCTION_BINDLESS_IMAGES_DESTROY_EXTERNAL_SEMAPHORE_EXP: - os << "UR_FUNCTION_BINDLESS_IMAGES_DESTROY_EXTERNAL_SEMAPHORE_EXP"; - break; + os << *tptr; - case UR_FUNCTION_BINDLESS_IMAGES_WAIT_EXTERNAL_SEMAPHORE_EXP: - os << "UR_FUNCTION_BINDLESS_IMAGES_WAIT_EXTERNAL_SEMAPHORE_EXP"; - break; + os << ")"; + } break; - case UR_FUNCTION_BINDLESS_IMAGES_SIGNAL_EXTERNAL_SEMAPHORE_EXP: - os << "UR_FUNCTION_BINDLESS_IMAGES_SIGNAL_EXTERNAL_SEMAPHORE_EXP"; - break; + case UR_PROFILING_INFO_COMMAND_SUBMIT: { + const uint64_t *tptr = (const uint64_t *)ptr; + if (sizeof(uint64_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint64_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - case UR_FUNCTION_PLATFORM_GET_LAST_ERROR: - os << "UR_FUNCTION_PLATFORM_GET_LAST_ERROR"; - break; + os << *tptr; - case UR_FUNCTION_ENQUEUE_USM_FILL_2D: - os << "UR_FUNCTION_ENQUEUE_USM_FILL_2D"; - break; + os << ")"; + } break; - case UR_FUNCTION_ENQUEUE_USM_MEMCPY_2D: - os << "UR_FUNCTION_ENQUEUE_USM_MEMCPY_2D"; - break; + case UR_PROFILING_INFO_COMMAND_START: { + const uint64_t *tptr = (const uint64_t *)ptr; + if (sizeof(uint64_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint64_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - case UR_FUNCTION_VIRTUAL_MEM_GRANULARITY_GET_INFO: - os << "UR_FUNCTION_VIRTUAL_MEM_GRANULARITY_GET_INFO"; - break; + os << *tptr; - case UR_FUNCTION_VIRTUAL_MEM_RESERVE: - os << "UR_FUNCTION_VIRTUAL_MEM_RESERVE"; - break; + os << ")"; + } break; - case UR_FUNCTION_VIRTUAL_MEM_FREE: - os << "UR_FUNCTION_VIRTUAL_MEM_FREE"; - break; + case UR_PROFILING_INFO_COMMAND_END: { + const uint64_t *tptr = (const uint64_t *)ptr; + if (sizeof(uint64_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint64_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - case UR_FUNCTION_VIRTUAL_MEM_MAP: - os << "UR_FUNCTION_VIRTUAL_MEM_MAP"; - break; + os << *tptr; - case UR_FUNCTION_VIRTUAL_MEM_UNMAP: - os << "UR_FUNCTION_VIRTUAL_MEM_UNMAP"; - break; + os << ")"; + } break; - case UR_FUNCTION_VIRTUAL_MEM_SET_ACCESS: - os << "UR_FUNCTION_VIRTUAL_MEM_SET_ACCESS"; - break; + case UR_PROFILING_INFO_COMMAND_COMPLETE: { + const uint64_t *tptr = (const uint64_t *)ptr; + if (sizeof(uint64_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(uint64_t) << ")"; + return; + } + os << (void *)(tptr) << " ("; - case UR_FUNCTION_VIRTUAL_MEM_GET_INFO: - os << "UR_FUNCTION_VIRTUAL_MEM_GET_INFO"; - break; + os << *tptr; - case UR_FUNCTION_PHYSICAL_MEM_CREATE: - os << "UR_FUNCTION_PHYSICAL_MEM_CREATE"; + os << ")"; + } break; + default: + os << "unknown enumerator"; break; + } +} +} // namespace ur_params +inline std::ostream & +operator<<(std::ostream &os, const struct ur_event_native_properties_t params) { + os << "(struct ur_event_native_properties_t){"; - case UR_FUNCTION_PHYSICAL_MEM_RETAIN: - os << "UR_FUNCTION_PHYSICAL_MEM_RETAIN"; - break; + os << ".stype = "; - case UR_FUNCTION_PHYSICAL_MEM_RELEASE: - os << "UR_FUNCTION_PHYSICAL_MEM_RELEASE"; - break; + os << (params.stype); - case UR_FUNCTION_USM_IMPORT_EXP: - os << "UR_FUNCTION_USM_IMPORT_EXP"; - break; + os << ", "; + os << ".pNext = "; - case UR_FUNCTION_USM_RELEASE_EXP: - os << "UR_FUNCTION_USM_RELEASE_EXP"; - break; + ur_params::serializeStruct(os, (params.pNext)); - case UR_FUNCTION_USM_P2P_ENABLE_PEER_ACCESS_EXP: - os << "UR_FUNCTION_USM_P2P_ENABLE_PEER_ACCESS_EXP"; - break; + os << ", "; + os << ".isNativeHandleOwned = "; - case UR_FUNCTION_USM_P2P_DISABLE_PEER_ACCESS_EXP: - os << "UR_FUNCTION_USM_P2P_DISABLE_PEER_ACCESS_EXP"; - break; + os << (params.isNativeHandleOwned); - case UR_FUNCTION_USM_P2P_PEER_ACCESS_GET_INFO_EXP: - os << "UR_FUNCTION_USM_P2P_PEER_ACCESS_GET_INFO_EXP"; - break; + os << "}"; + return os; +} +inline std::ostream &operator<<(std::ostream &os, + enum ur_execution_info_t value) { + switch (value) { - case UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_WRITE_EXP: - os << "UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_WRITE_EXP"; + case UR_EXECUTION_INFO_EXECUTION_INFO_COMPLETE: + os << "UR_EXECUTION_INFO_EXECUTION_INFO_COMPLETE"; break; - case UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_READ_EXP: - os << "UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_READ_EXP"; + case UR_EXECUTION_INFO_EXECUTION_INFO_RUNNING: + os << "UR_EXECUTION_INFO_EXECUTION_INFO_RUNNING"; break; - case UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_WRITE_RECT_EXP: - os << "UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_WRITE_RECT_EXP"; + case UR_EXECUTION_INFO_EXECUTION_INFO_SUBMITTED: + os << "UR_EXECUTION_INFO_EXECUTION_INFO_SUBMITTED"; break; - case UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_READ_RECT_EXP: - os << "UR_FUNCTION_COMMAND_BUFFER_APPEND_MEMBUFFER_READ_RECT_EXP"; + case UR_EXECUTION_INFO_EXECUTION_INFO_QUEUED: + os << "UR_EXECUTION_INFO_EXECUTION_INFO_QUEUED"; break; default: os << "unknown enumerator"; @@ -9425,7 +9669,49 @@ inline void serializeFlag(std::ostream &os, os << "0"; } } -} // namespace ur_params +} // namespace ur_params +inline std::ostream &operator<<(std::ostream &os, + const struct ur_exp_file_descriptor_t params) { + os << "(struct ur_exp_file_descriptor_t){"; + + os << ".stype = "; + + os << (params.stype); + + os << ", "; + os << ".pNext = "; + + ur_params::serializeStruct(os, (params.pNext)); + + os << ", "; + os << ".fd = "; + + os << (params.fd); + + os << "}"; + return os; +} +inline std::ostream &operator<<(std::ostream &os, + const struct ur_exp_win32_handle_t params) { + os << "(struct ur_exp_win32_handle_t){"; + + os << ".stype = "; + + os << (params.stype); + + os << ", "; + os << ".pNext = "; + + ur_params::serializeStruct(os, (params.pNext)); + + os << ", "; + os << ".handle = "; + + ur_params::serializePtr(os, (params.handle)); + + os << "}"; + return os; +} inline std::ostream & operator<<(std::ostream &os, const struct ur_exp_sampler_mip_properties_t params) { @@ -9451,9 +9737,47 @@ operator<<(std::ostream &os, os << (params.maxMipmapLevelClamp); os << ", "; - os << ".maxAnistropy = "; + os << ".maxAnisotropy = "; + + os << (params.maxAnisotropy); + + os << ", "; + os << ".mipFilterMode = "; + + os << (params.mipFilterMode); + + os << "}"; + return os; +} +inline std::ostream &operator<<(std::ostream &os, + const struct ur_exp_interop_mem_desc_t params) { + os << "(struct ur_exp_interop_mem_desc_t){"; + + os << ".stype = "; + + os << (params.stype); + + os << ", "; + os << ".pNext = "; + + ur_params::serializeStruct(os, (params.pNext)); + + os << "}"; + return os; +} +inline std::ostream & +operator<<(std::ostream &os, + const struct ur_exp_interop_semaphore_desc_t params) { + os << "(struct ur_exp_interop_semaphore_desc_t){"; + + os << ".stype = "; + + os << (params.stype); + + os << ", "; + os << ".pNext = "; - os << (params.maxAnistropy); + ur_params::serializeStruct(os, (params.pNext)); os << "}"; return os; @@ -9544,6 +9868,11 @@ inline std::ostream &operator<<(std::ostream &os, ur_params::serializeFlag(os, *(params->pdevice_flags)); + os << ", "; + os << ".hLoaderConfig = "; + + ur_params::serializePtr(os, *(params->phLoaderConfig)); + return os; } @@ -9557,6 +9886,105 @@ inline std::ostream &operator<<(std::ostream &os, return os; } +inline std::ostream &operator<<(std::ostream &os, + const struct ur_adapter_get_params_t *params) { + + os << ".NumEntries = "; + + os << *(params->pNumEntries); + + os << ", "; + os << ".phAdapters = {"; + for (size_t i = 0; + *(params->pphAdapters) != NULL && i < *params->pNumEntries; ++i) { + if (i != 0) { + os << ", "; + } + + ur_params::serializePtr(os, (*(params->pphAdapters))[i]); + } + os << "}"; + + os << ", "; + os << ".pNumAdapters = "; + + ur_params::serializePtr(os, *(params->ppNumAdapters)); + + return os; +} + +inline std::ostream & +operator<<(std::ostream &os, const struct ur_adapter_release_params_t *params) { + + os << ".hAdapter = "; + + ur_params::serializePtr(os, *(params->phAdapter)); + + return os; +} + +inline std::ostream & +operator<<(std::ostream &os, const struct ur_adapter_retain_params_t *params) { + + os << ".hAdapter = "; + + ur_params::serializePtr(os, *(params->phAdapter)); + + return os; +} + +inline std::ostream & +operator<<(std::ostream &os, + const struct ur_adapter_get_last_error_params_t *params) { + + os << ".hAdapter = "; + + ur_params::serializePtr(os, *(params->phAdapter)); + + os << ", "; + os << ".ppMessage = "; + + ur_params::serializePtr(os, *(params->pppMessage)); + + os << ", "; + os << ".pError = "; + + ur_params::serializePtr(os, *(params->ppError)); + + return os; +} + +inline std::ostream & +operator<<(std::ostream &os, + const struct ur_adapter_get_info_params_t *params) { + + os << ".hAdapter = "; + + ur_params::serializePtr(os, *(params->phAdapter)); + + os << ", "; + os << ".propName = "; + + os << *(params->ppropName); + + os << ", "; + os << ".propSize = "; + + os << *(params->ppropSize); + + os << ", "; + os << ".pPropValue = "; + ur_params::serializeTagged(os, *(params->ppPropValue), *(params->ppropName), + *(params->ppropSize)); + + os << ", "; + os << ".pPropSizeRet = "; + + ur_params::serializePtr(os, *(params->ppPropSizeRet)); + + return os; +} + inline std::ostream &operator<<( std::ostream &os, const struct ur_bindless_images_unsampled_image_handle_destroy_exp_params_t @@ -9566,6 +9994,11 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phContext)); + os << ", "; + os << ".hDevice = "; + + ur_params::serializePtr(os, *(params->phDevice)); + os << ", "; os << ".hImage = "; @@ -9583,6 +10016,11 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phContext)); + os << ", "; + os << ".hDevice = "; + + ur_params::serializePtr(os, *(params->phDevice)); + os << ", "; os << ".hImage = "; @@ -9599,6 +10037,11 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phContext)); + os << ", "; + os << ".hDevice = "; + + ur_params::serializePtr(os, *(params->phDevice)); + os << ", "; os << ".pImageFormat = "; @@ -9625,6 +10068,11 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); + os << ", "; + os << ".hDevice = "; + + ur_params::serializePtr(os, *(params->phDevice)); + os << ", "; os << ".hImageMem = "; @@ -9642,6 +10090,11 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); + os << ", "; + os << ".hDevice = "; + + ur_params::serializePtr(os, *(params->phDevice)); + os << ", "; os << ".hImageMem = "; @@ -9678,6 +10131,11 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phContext)); + os << ", "; + os << ".hDevice = "; + + ur_params::serializePtr(os, *(params->phDevice)); + os << ", "; os << ".hImageMem = "; @@ -9715,9 +10173,9 @@ inline std::ostream & operator<<(std::ostream &os, const struct ur_bindless_images_image_copy_exp_params_t *params) { - os << ".hContext = "; + os << ".hQueue = "; - ur_params::serializePtr(os, *(params->phContext)); + ur_params::serializePtr(os, *(params->phQueue)); os << ", "; os << ".pDst = "; @@ -9745,6 +10203,26 @@ operator<<(std::ostream &os, ur_params::serializeFlag( os, *(params->pimageCopyFlags)); + os << ", "; + os << ".srcOffset = "; + + os << *(params->psrcOffset); + + os << ", "; + os << ".dstOffset = "; + + os << *(params->pdstOffset); + + os << ", "; + os << ".copyExtent = "; + + os << *(params->pcopyExtent); + + os << ", "; + os << ".hostExtent = "; + + os << *(params->phostExtent); + os << ", "; os << ".numEventsInWaitList = "; @@ -9805,6 +10283,11 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phContext)); + os << ", "; + os << ".hDevice = "; + + ur_params::serializePtr(os, *(params->phDevice)); + os << ", "; os << ".hImageMem = "; @@ -9831,6 +10314,11 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phContext)); + os << ", "; + os << ".hDevice = "; + + ur_params::serializePtr(os, *(params->phDevice)); + os << ", "; os << ".hMem = "; @@ -9847,15 +10335,20 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phContext)); + os << ", "; + os << ".hDevice = "; + + ur_params::serializePtr(os, *(params->phDevice)); + os << ", "; os << ".size = "; os << *(params->psize); os << ", "; - os << ".fileDescriptor = "; + os << ".pInteropMemDesc = "; - os << *(params->pfileDescriptor); + ur_params::serializePtr(os, *(params->ppInteropMemDesc)); os << ", "; os << ".phInteropMem = "; @@ -9873,6 +10366,11 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phContext)); + os << ", "; + os << ".hDevice = "; + + ur_params::serializePtr(os, *(params->phDevice)); + os << ", "; os << ".pImageFormat = "; @@ -9904,6 +10402,11 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phContext)); + os << ", "; + os << ".hDevice = "; + + ur_params::serializePtr(os, *(params->phDevice)); + os << ", "; os << ".hInteropMem = "; @@ -9922,14 +10425,19 @@ operator<<(std::ostream &os, const struct ur_params::serializePtr(os, *(params->phContext)); os << ", "; - os << ".fileDescriptor = "; + os << ".hDevice = "; + + ur_params::serializePtr(os, *(params->phDevice)); + + os << ", "; + os << ".pInteropSemaphoreDesc = "; - os << *(params->pfileDescriptor); + ur_params::serializePtr(os, *(params->ppInteropSemaphoreDesc)); os << ", "; - os << ".phInteropSemaphoreHandle = "; + os << ".phInteropSemaphore = "; - ur_params::serializePtr(os, *(params->pphInteropSemaphoreHandle)); + ur_params::serializePtr(os, *(params->pphInteropSemaphore)); return os; } @@ -9943,6 +10451,11 @@ inline std::ostream &operator<<( ur_params::serializePtr(os, *(params->phContext)); + os << ", "; + os << ".hDevice = "; + + ur_params::serializePtr(os, *(params->phDevice)); + os << ", "; os << ".hInteropSemaphore = "; @@ -13081,6 +13594,23 @@ operator<<(std::ostream &os, inline std::ostream &operator<<(std::ostream &os, const struct ur_platform_get_params_t *params) { + os << ".phAdapters = {"; + for (size_t i = 0; + *(params->pphAdapters) != NULL && i < *params->pNumAdapters; ++i) { + if (i != 0) { + os << ", "; + } + + ur_params::serializePtr(os, (*(params->pphAdapters))[i]); + } + os << "}"; + + os << ", "; + os << ".NumAdapters = "; + + os << *(params->pNumAdapters); + + os << ", "; os << ".NumEntries = "; os << *(params->pNumEntries); @@ -13173,27 +13703,6 @@ inline std::ostream &operator<<( return os; } -inline std::ostream & -operator<<(std::ostream &os, - const struct ur_platform_get_last_error_params_t *params) { - - os << ".hPlatform = "; - - ur_params::serializePtr(os, *(params->phPlatform)); - - os << ", "; - os << ".ppMessage = "; - - ur_params::serializePtr(os, *(params->pppMessage)); - - os << ", "; - os << ".pError = "; - - ur_params::serializePtr(os, *(params->ppError)); - - return os; -} - inline std::ostream & operator<<(std::ostream &os, const struct ur_platform_get_api_version_params_t *params) { @@ -14654,6 +15163,21 @@ inline int serializeFunctionParams(std::ostream &os, uint32_t function, case UR_FUNCTION_TEAR_DOWN: { os << (const struct ur_tear_down_params_t *)params; } break; + case UR_FUNCTION_ADAPTER_GET: { + os << (const struct ur_adapter_get_params_t *)params; + } break; + case UR_FUNCTION_ADAPTER_RELEASE: { + os << (const struct ur_adapter_release_params_t *)params; + } break; + case UR_FUNCTION_ADAPTER_RETAIN: { + os << (const struct ur_adapter_retain_params_t *)params; + } break; + case UR_FUNCTION_ADAPTER_GET_LAST_ERROR: { + os << (const struct ur_adapter_get_last_error_params_t *)params; + } break; + case UR_FUNCTION_ADAPTER_GET_INFO: { + os << (const struct ur_adapter_get_info_params_t *)params; + } break; case UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_HANDLE_DESTROY_EXP: { os << (const struct ur_bindless_images_unsampled_image_handle_destroy_exp_params_t *) @@ -15001,9 +15525,6 @@ inline int serializeFunctionParams(std::ostream &os, uint32_t function, os << (const struct ur_platform_create_with_native_handle_params_t *) params; } break; - case UR_FUNCTION_PLATFORM_GET_LAST_ERROR: { - os << (const struct ur_platform_get_last_error_params_t *)params; - } break; case UR_FUNCTION_PLATFORM_GET_API_VERSION: { os << (const struct ur_platform_get_api_version_params_t *)params; } break; diff --git a/source/common/ur_pool_manager.hpp b/source/common/ur_pool_manager.hpp index c4cb169fbd..c4da5d149f 100644 --- a/source/common/ur_pool_manager.hpp +++ b/source/common/ur_pool_manager.hpp @@ -128,7 +128,7 @@ inline bool pool_descriptor::equal(const pool_descriptor &lhs, // We want to share a memory pool for sub-devices and sub-sub devices. // Sub-devices and sub-sub-devices might be represented by different ur_device_handle_t but - // they share the same native_handle_t (which is used by UMA provider). + // they share the same native_handle_t (which is used by UMF provider). // Ref: https://github.com/intel/llvm/commit/86511c5dc84b5781dcfd828caadcb5cac157eae1 // TODO: is this L0 specific? auto ret = urDeviceGetNativeHandle(lhs.hDevice, &lhsNative); diff --git a/source/common/ur_util.hpp b/source/common/ur_util.hpp index 5bf556dda6..8276d10048 100644 --- a/source/common/ur_util.hpp +++ b/source/common/ur_util.hpp @@ -42,13 +42,19 @@ inline int ur_getpid(void) { return static_cast(getpid()); } #define SANITIZER_ADDRESS #endif +/* define for running with memory sanitizer */ +#if CLANG_HAS_FEATURE(thread_sanitizer) || defined(__SANITIZE_THREAD__) +#define SANITIZER_THREAD +#endif + /* define for running with memory sanitizer */ #if CLANG_HAS_FEATURE(memory_sanitizer) #define SANITIZER_MEMORY #endif /* define for running with any sanitizer runtime */ -#if defined(SANITIZER_MEMORY) || defined(SANITIZER_ADDRESS) +#if defined(SANITIZER_MEMORY) || defined(SANITIZER_ADDRESS) || \ + defined(SANITIZER_THREAD) #define SANITIZER_ANY #endif /////////////////////////////////////////////////////////////////////////////// @@ -57,8 +63,12 @@ inline int ur_getpid(void) { return static_cast(getpid()); } #define MAKE_LIBRARY_NAME(NAME, VERSION) NAME ".dll" #else #define HMODULE void * +#if defined(__APPLE__) +#define MAKE_LIBRARY_NAME(NAME, VERSION) "lib" NAME "." VERSION ".dylib" +#else #define MAKE_LIBRARY_NAME(NAME, VERSION) "lib" NAME ".so." VERSION #endif +#endif inline std::string create_library_path(const char *name, const char *path) { std::string library_path; @@ -88,7 +98,7 @@ inline std::optional ur_getenv(const char *name) { #if defined(_WIN32) constexpr int buffer_size = 1024; char buffer[buffer_size]; - auto rc = GetEnvironmentVariable(name, buffer, buffer_size); + auto rc = GetEnvironmentVariableA(name, buffer, buffer_size); if (0 != rc && rc < buffer_size) { return std::string(buffer); } else if (rc >= buffer_size) { diff --git a/source/loader/CMakeLists.txt b/source/loader/CMakeLists.txt index 0c4c89eac0..b1a3e8bb91 100644 --- a/source/loader/CMakeLists.txt +++ b/source/loader/CMakeLists.txt @@ -9,7 +9,7 @@ configure_file( @ONLY ) -add_library(ur_loader +add_ur_library(ur_loader SHARED "" ${CMAKE_CURRENT_BINARY_DIR}/UrLoaderVersion.rc diff --git a/source/loader/layers/tracing/ur_tracing_layer.cpp b/source/loader/layers/tracing/ur_tracing_layer.cpp index e12557b599..b022ae831f 100644 --- a/source/loader/layers/tracing/ur_tracing_layer.cpp +++ b/source/loader/layers/tracing/ur_tracing_layer.cpp @@ -34,7 +34,7 @@ context_t::context_t() { streamv.str().data()); } -bool context_t::isEnabled() { return xptiTraceEnabled(); } +bool context_t::isAvailable() const { return xptiTraceEnabled(); } void context_t::notify(uint16_t trace_type, uint32_t id, const char *name, void *args, ur_result_t *resultp, uint64_t instance) { diff --git a/source/loader/layers/tracing/ur_tracing_layer.hpp b/source/loader/layers/tracing/ur_tracing_layer.hpp index c2708ab976..b00d12d301 100644 --- a/source/loader/layers/tracing/ur_tracing_layer.hpp +++ b/source/loader/layers/tracing/ur_tracing_layer.hpp @@ -28,8 +28,11 @@ class __urdlllocal context_t : public proxy_layer_context_t { context_t(); ~context_t(); - bool isEnabled() override; - ur_result_t init(ur_dditable_t *dditable) override; + bool isAvailable() const override; + + std::vector getNames() const override { return {name}; } + ur_result_t init(ur_dditable_t *dditable, + const std::set &enabledLayerNames) override; uint64_t notify_begin(uint32_t id, const char *name, void *args); void notify_end(uint32_t id, const char *name, void *args, ur_result_t *resultp, uint64_t instance); @@ -38,6 +41,8 @@ class __urdlllocal context_t : public proxy_layer_context_t { void notify(uint16_t trace_type, uint32_t id, const char *name, void *args, ur_result_t *resultp, uint64_t instance); uint8_t call_stream_id; + + const std::string name = "UR_LAYER_TRACING"; }; extern context_t context; diff --git a/source/loader/layers/tracing/ur_trcddi.cpp b/source/loader/layers/tracing/ur_trcddi.cpp index dabbdbe485..f30fac3807 100644 --- a/source/loader/layers/tracing/ur_trcddi.cpp +++ b/source/loader/layers/tracing/ur_trcddi.cpp @@ -18,8 +18,10 @@ namespace ur_tracing_layer { /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urInit __urdlllocal ur_result_t UR_APICALL urInit( - ur_device_init_flags_t device_flags ///< [in] device initialization flags. + ur_device_init_flags_t device_flags, ///< [in] device initialization flags. ///< must be 0 (default) or a combination of ::ur_device_init_flag_t. + ur_loader_config_handle_t + hLoaderConfig ///< [in][optional] Handle of loader config handle. ) { auto pfnInit = context.urDdiTable.Global.pfnInit; @@ -27,11 +29,11 @@ __urdlllocal ur_result_t UR_APICALL urInit( return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - ur_init_params_t params = {&device_flags}; + ur_init_params_t params = {&device_flags, &hLoaderConfig}; uint64_t instance = context.notify_begin(UR_FUNCTION_INIT, "urInit", ¶ms); - ur_result_t result = pfnInit(device_flags); + ur_result_t result = pfnInit(device_flags, hLoaderConfig); context.notify_end(UR_FUNCTION_INIT, "urInit", ¶ms, &result, instance); @@ -61,9 +63,157 @@ __urdlllocal ur_result_t UR_APICALL urTearDown( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterGet +__urdlllocal ur_result_t UR_APICALL urAdapterGet( + uint32_t + NumEntries, ///< [in] the number of adapters to be added to phAdapters. + ///< If phAdapters is not NULL, then NumEntries should be greater than + ///< zero, otherwise ::UR_RESULT_ERROR_INVALID_SIZE, + ///< will be returned. + ur_adapter_handle_t * + phAdapters, ///< [out][optional][range(0, NumEntries)] array of handle of adapters. + ///< If NumEntries is less than the number of adapters available, then + ///< ::urAdapterGet shall only retrieve that number of platforms. + uint32_t * + pNumAdapters ///< [out][optional] returns the total number of adapters available. +) { + auto pfnAdapterGet = context.urDdiTable.Global.pfnAdapterGet; + + if (nullptr == pfnAdapterGet) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + ur_adapter_get_params_t params = {&NumEntries, &phAdapters, &pNumAdapters}; + uint64_t instance = + context.notify_begin(UR_FUNCTION_ADAPTER_GET, "urAdapterGet", ¶ms); + + ur_result_t result = pfnAdapterGet(NumEntries, phAdapters, pNumAdapters); + + context.notify_end(UR_FUNCTION_ADAPTER_GET, "urAdapterGet", ¶ms, + &result, instance); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterRelease +__urdlllocal ur_result_t UR_APICALL urAdapterRelease( + ur_adapter_handle_t hAdapter ///< [in] Adapter handle to release +) { + auto pfnAdapterRelease = context.urDdiTable.Global.pfnAdapterRelease; + + if (nullptr == pfnAdapterRelease) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + ur_adapter_release_params_t params = {&hAdapter}; + uint64_t instance = context.notify_begin(UR_FUNCTION_ADAPTER_RELEASE, + "urAdapterRelease", ¶ms); + + ur_result_t result = pfnAdapterRelease(hAdapter); + + context.notify_end(UR_FUNCTION_ADAPTER_RELEASE, "urAdapterRelease", ¶ms, + &result, instance); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterRetain +__urdlllocal ur_result_t UR_APICALL urAdapterRetain( + ur_adapter_handle_t hAdapter ///< [in] Adapter handle to retain +) { + auto pfnAdapterRetain = context.urDdiTable.Global.pfnAdapterRetain; + + if (nullptr == pfnAdapterRetain) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + ur_adapter_retain_params_t params = {&hAdapter}; + uint64_t instance = context.notify_begin(UR_FUNCTION_ADAPTER_RETAIN, + "urAdapterRetain", ¶ms); + + ur_result_t result = pfnAdapterRetain(hAdapter); + + context.notify_end(UR_FUNCTION_ADAPTER_RETAIN, "urAdapterRetain", ¶ms, + &result, instance); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterGetLastError +__urdlllocal ur_result_t UR_APICALL urAdapterGetLastError( + ur_adapter_handle_t hAdapter, ///< [in] handle of the adapter instance + const char ** + ppMessage, ///< [out] pointer to a C string where the adapter specific error message + ///< will be stored. + int32_t * + pError ///< [out] pointer to an integer where the adapter specific error code will + ///< be stored. +) { + auto pfnAdapterGetLastError = + context.urDdiTable.Global.pfnAdapterGetLastError; + + if (nullptr == pfnAdapterGetLastError) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + ur_adapter_get_last_error_params_t params = {&hAdapter, &ppMessage, + &pError}; + uint64_t instance = context.notify_begin(UR_FUNCTION_ADAPTER_GET_LAST_ERROR, + "urAdapterGetLastError", ¶ms); + + ur_result_t result = pfnAdapterGetLastError(hAdapter, ppMessage, pError); + + context.notify_end(UR_FUNCTION_ADAPTER_GET_LAST_ERROR, + "urAdapterGetLastError", ¶ms, &result, instance); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterGetInfo +__urdlllocal ur_result_t UR_APICALL urAdapterGetInfo( + ur_adapter_handle_t hAdapter, ///< [in] handle of the adapter + ur_adapter_info_t propName, ///< [in] type of the info to retrieve + size_t propSize, ///< [in] the number of bytes pointed to by pPropValue. + void * + pPropValue, ///< [out][optional][typename(propName, propSize)] array of bytes holding + ///< the info. + ///< If Size is not equal to or greater to the real number of bytes needed + ///< to return the info then the ::UR_RESULT_ERROR_INVALID_SIZE error is + ///< returned and pPropValue is not used. + size_t * + pPropSizeRet ///< [out][optional] pointer to the actual number of bytes being queried by pPropValue. +) { + auto pfnAdapterGetInfo = context.urDdiTable.Global.pfnAdapterGetInfo; + + if (nullptr == pfnAdapterGetInfo) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + ur_adapter_get_info_params_t params = {&hAdapter, &propName, &propSize, + &pPropValue, &pPropSizeRet}; + uint64_t instance = context.notify_begin(UR_FUNCTION_ADAPTER_GET_INFO, + "urAdapterGetInfo", ¶ms); + + ur_result_t result = pfnAdapterGetInfo(hAdapter, propName, propSize, + pPropValue, pPropSizeRet); + + context.notify_end(UR_FUNCTION_ADAPTER_GET_INFO, "urAdapterGetInfo", + ¶ms, &result, instance); + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urPlatformGet __urdlllocal ur_result_t UR_APICALL urPlatformGet( + ur_adapter_handle_t * + phAdapters, ///< [in][range(0, NumAdapters)] array of adapters to query for platforms. + uint32_t NumAdapters, ///< [in] number of adapters pointed to by phAdapters uint32_t NumEntries, ///< [in] the number of platforms to be added to phPlatforms. ///< If phPlatforms is not NULL, then NumEntries should be greater than @@ -82,12 +232,13 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGet( return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - ur_platform_get_params_t params = {&NumEntries, &phPlatforms, - &pNumPlatforms}; + ur_platform_get_params_t params = {&phAdapters, &NumAdapters, &NumEntries, + &phPlatforms, &pNumPlatforms}; uint64_t instance = context.notify_begin(UR_FUNCTION_PLATFORM_GET, "urPlatformGet", ¶ms); - ur_result_t result = pfnGet(NumEntries, phPlatforms, pNumPlatforms); + ur_result_t result = + pfnGet(phAdapters, NumAdapters, NumEntries, phPlatforms, pNumPlatforms); context.notify_end(UR_FUNCTION_PLATFORM_GET, "urPlatformGet", ¶ms, &result, instance); @@ -186,7 +337,7 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetNativeHandle( /// @brief Intercept function for urPlatformCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urPlatformCreateWithNativeHandle( ur_native_handle_t - hNativePlatform, ///< [in] the native handle of the platform. + hNativePlatform, ///< [in][nocheck] the native handle of the platform. const ur_platform_native_properties_t * pProperties, ///< [in][optional] pointer to native platform properties struct. ur_platform_handle_t * @@ -247,36 +398,6 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetBackendOption( return result; } -/////////////////////////////////////////////////////////////////////////////// -/// @brief Intercept function for urPlatformGetLastError -__urdlllocal ur_result_t UR_APICALL urPlatformGetLastError( - ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance - const char ** - ppMessage, ///< [out] pointer to a C string where the adapter specific error message - ///< will be stored. - int32_t * - pError ///< [out] pointer to an integer where the adapter specific error code will - ///< be stored. -) { - auto pfnGetLastError = context.urDdiTable.Platform.pfnGetLastError; - - if (nullptr == pfnGetLastError) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; - } - - ur_platform_get_last_error_params_t params = {&hPlatform, &ppMessage, - &pError}; - uint64_t instance = context.notify_begin( - UR_FUNCTION_PLATFORM_GET_LAST_ERROR, "urPlatformGetLastError", ¶ms); - - ur_result_t result = pfnGetLastError(hPlatform, ppMessage, pError); - - context.notify_end(UR_FUNCTION_PLATFORM_GET_LAST_ERROR, - "urPlatformGetLastError", ¶ms, &result, instance); - - return result; -} - /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urDeviceGet __urdlllocal ur_result_t UR_APICALL urDeviceGet( @@ -495,8 +616,9 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urDeviceCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urDeviceCreateWithNativeHandle( - ur_native_handle_t hNativeDevice, ///< [in] the native handle of the device. - ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance + ur_native_handle_t + hNativeDevice, ///< [in][nocheck] the native handle of the device. + ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance const ur_device_native_properties_t * pProperties, ///< [in][optional] pointer to native device properties struct. ur_device_handle_t @@ -705,7 +827,7 @@ __urdlllocal ur_result_t UR_APICALL urContextGetNativeHandle( /// @brief Intercept function for urContextCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( ur_native_handle_t - hNativeContext, ///< [in] the native handle of the context. + hNativeContext, ///< [in][nocheck] the native handle of the context. uint32_t numDevices, ///< [in] number of devices associated with the context const ur_device_handle_t * phDevices, ///< [in][range(0, numDevices)] list of devices associated with the context @@ -936,8 +1058,9 @@ __urdlllocal ur_result_t UR_APICALL urMemGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urMemBufferCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( - ur_native_handle_t hNativeMem, ///< [in] the native handle to the memory. - ur_context_handle_t hContext, ///< [in] handle of the context object. + ur_native_handle_t + hNativeMem, ///< [in][nocheck] the native handle to the memory. + ur_context_handle_t hContext, ///< [in] handle of the context object. const ur_mem_native_properties_t * pProperties, ///< [in][optional] pointer to native memory creation properties. ur_mem_handle_t @@ -969,8 +1092,9 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urMemImageCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urMemImageCreateWithNativeHandle( - ur_native_handle_t hNativeMem, ///< [in] the native handle to the memory. - ur_context_handle_t hContext, ///< [in] handle of the context object. + ur_native_handle_t + hNativeMem, ///< [in][nocheck] the native handle to the memory. + ur_context_handle_t hContext, ///< [in] handle of the context object. const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification. const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description. @@ -1214,7 +1338,7 @@ __urdlllocal ur_result_t UR_APICALL urSamplerGetNativeHandle( /// @brief Intercept function for urSamplerCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urSamplerCreateWithNativeHandle( ur_native_handle_t - hNativeSampler, ///< [in] the native handle of the sampler. + hNativeSampler, ///< [in][nocheck] the native handle of the sampler. ur_context_handle_t hContext, ///< [in] handle of the context object const ur_sampler_native_properties_t * pProperties, ///< [in][optional] pointer to native sampler properties struct. @@ -1672,7 +1796,7 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemSetAccess( ur_context_handle_t hContext, ///< [in] handle to the context object. const void *pStart, ///< [in] pointer to the start of the virtual memory range. - size_t size, ///< [in] size in bytes of the virutal memory range. + size_t size, ///< [in] size in bytes of the virtual memory range. ur_virtual_mem_access_flags_t flags ///< [in] access flags to set for the mapped virtual memory range. ) { @@ -1740,7 +1864,7 @@ __urdlllocal ur_result_t UR_APICALL urPhysicalMemCreate( ur_context_handle_t hContext, ///< [in] handle of the context object. ur_device_handle_t hDevice, ///< [in] handle of the device object. size_t - size, ///< [in] size in bytes of phyisical memory to allocate, must be a multiple + size, ///< [in] size in bytes of physical memory to allocate, must be a multiple ///< of ::UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM. const ur_physical_mem_properties_t * pProperties, ///< [in][optional] pointer to physical memory creation properties. @@ -2185,7 +2309,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetNativeHandle( /// @brief Intercept function for urProgramCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urProgramCreateWithNativeHandle( ur_native_handle_t - hNativeProgram, ///< [in] the native handle of the program. + hNativeProgram, ///< [in][nocheck] the native handle of the program. ur_context_handle_t hContext, ///< [in] handle of the context instance const ur_program_native_properties_t * pProperties, ///< [in][optional] pointer to native program properties struct. @@ -2637,8 +2761,9 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urKernelCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urKernelCreateWithNativeHandle( - ur_native_handle_t hNativeKernel, ///< [in] the native handle of the kernel. - ur_context_handle_t hContext, ///< [in] handle of the context object + ur_native_handle_t + hNativeKernel, ///< [in][nocheck] the native handle of the kernel. + ur_context_handle_t hContext, ///< [in] handle of the context object ur_program_handle_t hProgram, ///< [in] handle of the program associated with the kernel const ur_kernel_native_properties_t * @@ -2808,9 +2933,10 @@ __urdlllocal ur_result_t UR_APICALL urQueueGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urQueueCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urQueueCreateWithNativeHandle( - ur_native_handle_t hNativeQueue, ///< [in] the native handle of the queue. - ur_context_handle_t hContext, ///< [in] handle of the context object - ur_device_handle_t hDevice, ///< [in] handle of the device object + ur_native_handle_t + hNativeQueue, ///< [in][nocheck] the native handle of the queue. + ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_queue_native_properties_t * pProperties, ///< [in][optional] pointer to native queue properties struct ur_queue_handle_t @@ -3051,8 +3177,9 @@ __urdlllocal ur_result_t UR_APICALL urEventGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urEventCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urEventCreateWithNativeHandle( - ur_native_handle_t hNativeEvent, ///< [in] the native handle of the event. - ur_context_handle_t hContext, ///< [in] handle of the context object + ur_native_handle_t + hNativeEvent, ///< [in][nocheck] the native handle of the event. + ur_context_handle_t hContext, ///< [in] handle of the context object const ur_event_native_properties_t * pProperties, ///< [in][optional] pointer to native event properties struct ur_event_handle_t @@ -4329,6 +4456,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMPitchedAllocExp( __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageHandleDestroyExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_handle_t hImage ///< [in] pointer to handle of image object to destroy ) { @@ -4340,12 +4468,13 @@ urBindlessImagesUnsampledImageHandleDestroyExp( } ur_bindless_images_unsampled_image_handle_destroy_exp_params_t params = { - &hContext, &hImage}; + &hContext, &hDevice, &hImage}; uint64_t instance = context.notify_begin( UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_HANDLE_DESTROY_EXP, "urBindlessImagesUnsampledImageHandleDestroyExp", ¶ms); - ur_result_t result = pfnUnsampledImageHandleDestroyExp(hContext, hImage); + ur_result_t result = + pfnUnsampledImageHandleDestroyExp(hContext, hDevice, hImage); context.notify_end( UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_HANDLE_DESTROY_EXP, @@ -4360,6 +4489,7 @@ urBindlessImagesUnsampledImageHandleDestroyExp( __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageHandleDestroyExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_handle_t hImage ///< [in] pointer to handle of image object to destroy ) { @@ -4371,12 +4501,13 @@ urBindlessImagesSampledImageHandleDestroyExp( } ur_bindless_images_sampled_image_handle_destroy_exp_params_t params = { - &hContext, &hImage}; + &hContext, &hDevice, &hImage}; uint64_t instance = context.notify_begin( UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_HANDLE_DESTROY_EXP, "urBindlessImagesSampledImageHandleDestroyExp", ¶ms); - ur_result_t result = pfnSampledImageHandleDestroyExp(hContext, hImage); + ur_result_t result = + pfnSampledImageHandleDestroyExp(hContext, hDevice, hImage); context.notify_end( UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_HANDLE_DESTROY_EXP, @@ -4390,6 +4521,7 @@ urBindlessImagesSampledImageHandleDestroyExp( /// @brief Intercept function for urBindlessImagesImageAllocateExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description @@ -4404,13 +4536,13 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( } ur_bindless_images_image_allocate_exp_params_t params = { - &hContext, &pImageFormat, &pImageDesc, &phImageMem}; + &hContext, &hDevice, &pImageFormat, &pImageDesc, &phImageMem}; uint64_t instance = context.notify_begin(UR_FUNCTION_BINDLESS_IMAGES_IMAGE_ALLOCATE_EXP, "urBindlessImagesImageAllocateExp", ¶ms); - ur_result_t result = - pfnImageAllocateExp(hContext, pImageFormat, pImageDesc, phImageMem); + ur_result_t result = pfnImageAllocateExp(hContext, hDevice, pImageFormat, + pImageDesc, phImageMem); context.notify_end(UR_FUNCTION_BINDLESS_IMAGES_IMAGE_ALLOCATE_EXP, "urBindlessImagesImageAllocateExp", ¶ms, &result, @@ -4423,6 +4555,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( /// @brief Intercept function for urBindlessImagesImageFreeExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageFreeExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem ///< [in] handle of image memory to be freed ) { @@ -4432,12 +4565,13 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageFreeExp( return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - ur_bindless_images_image_free_exp_params_t params = {&hContext, &hImageMem}; + ur_bindless_images_image_free_exp_params_t params = {&hContext, &hDevice, + &hImageMem}; uint64_t instance = context.notify_begin(UR_FUNCTION_BINDLESS_IMAGES_IMAGE_FREE_EXP, "urBindlessImagesImageFreeExp", ¶ms); - ur_result_t result = pfnImageFreeExp(hContext, hImageMem); + ur_result_t result = pfnImageFreeExp(hContext, hDevice, hImageMem); context.notify_end(UR_FUNCTION_BINDLESS_IMAGES_IMAGE_FREE_EXP, "urBindlessImagesImageFreeExp", ¶ms, &result, @@ -4450,6 +4584,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageFreeExp( /// @brief Intercept function for urBindlessImagesUnsampledImageCreateExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] handle to memory from which to create the image const ur_image_format_t @@ -4467,13 +4602,14 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( } ur_bindless_images_unsampled_image_create_exp_params_t params = { - &hContext, &hImageMem, &pImageFormat, &pImageDesc, &phMem, &phImage}; + &hContext, &hDevice, &hImageMem, &pImageFormat, + &pImageDesc, &phMem, &phImage}; uint64_t instance = context.notify_begin( UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_CREATE_EXP, "urBindlessImagesUnsampledImageCreateExp", ¶ms); ur_result_t result = pfnUnsampledImageCreateExp( - hContext, hImageMem, pImageFormat, pImageDesc, phMem, phImage); + hContext, hDevice, hImageMem, pImageFormat, pImageDesc, phMem, phImage); context.notify_end(UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_CREATE_EXP, "urBindlessImagesUnsampledImageCreateExp", ¶ms, @@ -4486,6 +4622,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( /// @brief Intercept function for urBindlessImagesSampledImageCreateExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] handle to memory from which to create the image const ur_image_format_t @@ -4504,15 +4641,15 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( } ur_bindless_images_sampled_image_create_exp_params_t params = { - &hContext, &hImageMem, &pImageFormat, &pImageDesc, - &hSampler, &phMem, &phImage}; + &hContext, &hDevice, &hImageMem, &pImageFormat, + &pImageDesc, &hSampler, &phMem, &phImage}; uint64_t instance = context.notify_begin( UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_CREATE_EXP, "urBindlessImagesSampledImageCreateExp", ¶ms); ur_result_t result = - pfnSampledImageCreateExp(hContext, hImageMem, pImageFormat, pImageDesc, - hSampler, phMem, phImage); + pfnSampledImageCreateExp(hContext, hDevice, hImageMem, pImageFormat, + pImageDesc, hSampler, phMem, phImage); context.notify_end(UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_CREATE_EXP, "urBindlessImagesSampledImageCreateExp", ¶ms, @@ -4524,14 +4661,26 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urBindlessImagesImageCopyExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageCopyExp( - ur_context_handle_t hContext, ///< [in] handle of the context object - void *pDst, ///< [in] location the data will be copied to - void *pSrc, ///< [in] location the data will be copied from + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + void *pDst, ///< [in] location the data will be copied to + void *pSrc, ///< [in] location the data will be copied from const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description ur_exp_image_copy_flags_t imageCopyFlags, ///< [in] flags describing copy direction e.g. H2D or D2H + ur_rect_offset_t + srcOffset, ///< [in] defines the (x,y,z) source offset in pixels in the 1D, 2D, or 3D + ///< image + ur_rect_offset_t + dstOffset, ///< [in] defines the (x,y,z) destination offset in pixels in the 1D, 2D, + ///< or 3D image + ur_rect_region_t + copyExtent, ///< [in] defines the (width, height, depth) in pixels of the 1D, 2D, or 3D + ///< region to copy + ur_rect_region_t + hostExtent, ///< [in] defines the (width, height, depth) in pixels of the 1D, 2D, or 3D + ///< region on the host uint32_t numEventsInWaitList, ///< [in] size of the event wait list const ur_event_handle_t * phEventWaitList, ///< [in][optional][range(0, numEventsInWaitList)] pointer to a list of @@ -4549,12 +4698,16 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageCopyExp( return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - ur_bindless_images_image_copy_exp_params_t params = {&hContext, + ur_bindless_images_image_copy_exp_params_t params = {&hQueue, &pDst, &pSrc, &pImageFormat, &pImageDesc, &imageCopyFlags, + &srcOffset, + &dstOffset, + ©Extent, + &hostExtent, &numEventsInWaitList, &phEventWaitList, &phEvent}; @@ -4563,8 +4716,9 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageCopyExp( "urBindlessImagesImageCopyExp", ¶ms); ur_result_t result = pfnImageCopyExp( - hContext, pDst, pSrc, pImageFormat, pImageDesc, imageCopyFlags, - numEventsInWaitList, phEventWaitList, phEvent); + hQueue, pDst, pSrc, pImageFormat, pImageDesc, imageCopyFlags, srcOffset, + dstOffset, copyExtent, hostExtent, numEventsInWaitList, phEventWaitList, + phEvent); context.notify_end(UR_FUNCTION_BINDLESS_IMAGES_IMAGE_COPY_EXP, "urBindlessImagesImageCopyExp", ¶ms, &result, @@ -4608,6 +4762,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( /// @brief Intercept function for urBindlessImagesMipmapGetLevelExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] memory handle to the mipmap image uint32_t mipmapLevel, ///< [in] requested level of the mipmap @@ -4622,13 +4777,13 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( } ur_bindless_images_mipmap_get_level_exp_params_t params = { - &hContext, &hImageMem, &mipmapLevel, &phImageMem}; + &hContext, &hDevice, &hImageMem, &mipmapLevel, &phImageMem}; uint64_t instance = context.notify_begin(UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_GET_LEVEL_EXP, "urBindlessImagesMipmapGetLevelExp", ¶ms); - ur_result_t result = - pfnMipmapGetLevelExp(hContext, hImageMem, mipmapLevel, phImageMem); + ur_result_t result = pfnMipmapGetLevelExp(hContext, hDevice, hImageMem, + mipmapLevel, phImageMem); context.notify_end(UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_GET_LEVEL_EXP, "urBindlessImagesMipmapGetLevelExp", ¶ms, &result, @@ -4641,6 +4796,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( /// @brief Intercept function for urBindlessImagesMipmapFreeExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hMem ///< [in] handle of image memory to be freed ) { auto pfnMipmapFreeExp = @@ -4650,12 +4806,13 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - ur_bindless_images_mipmap_free_exp_params_t params = {&hContext, &hMem}; + ur_bindless_images_mipmap_free_exp_params_t params = {&hContext, &hDevice, + &hMem}; uint64_t instance = context.notify_begin(UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_FREE_EXP, "urBindlessImagesMipmapFreeExp", ¶ms); - ur_result_t result = pfnMipmapFreeExp(hContext, hMem); + ur_result_t result = pfnMipmapFreeExp(hContext, hDevice, hMem); context.notify_end(UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_FREE_EXP, "urBindlessImagesMipmapFreeExp", ¶ms, &result, @@ -4668,8 +4825,10 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( /// @brief Intercept function for urBindlessImagesImportOpaqueFDExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object size_t size, ///< [in] size of the external memory - uint32_t fileDescriptor, ///< [in] the file descriptor + ur_exp_interop_mem_desc_t + *pInteropMemDesc, ///< [in] the interop memory descriptor ur_exp_interop_mem_handle_t *phInteropMem ///< [out] interop memory handle to the external memory ) { @@ -4681,13 +4840,13 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( } ur_bindless_images_import_opaque_fd_exp_params_t params = { - &hContext, &size, &fileDescriptor, &phInteropMem}; + &hContext, &hDevice, &size, &pInteropMemDesc, &phInteropMem}; uint64_t instance = context.notify_begin(UR_FUNCTION_BINDLESS_IMAGES_IMPORT_OPAQUE_FD_EXP, "urBindlessImagesImportOpaqueFDExp", ¶ms); - ur_result_t result = - pfnImportOpaqueFDExp(hContext, size, fileDescriptor, phInteropMem); + ur_result_t result = pfnImportOpaqueFDExp(hContext, hDevice, size, + pInteropMemDesc, phInteropMem); context.notify_end(UR_FUNCTION_BINDLESS_IMAGES_IMPORT_OPAQUE_FD_EXP, "urBindlessImagesImportOpaqueFDExp", ¶ms, &result, @@ -4700,12 +4859,13 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( /// @brief Intercept function for urBindlessImagesMapExternalArrayExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description ur_exp_interop_mem_handle_t hInteropMem, ///< [in] interop memory handle to the external memory - ur_exp_image_handle_t * + ur_exp_image_mem_handle_t * phImageMem ///< [out] image memory handle to the externally allocated memory ) { auto pfnMapExternalArrayExp = @@ -4716,13 +4876,14 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( } ur_bindless_images_map_external_array_exp_params_t params = { - &hContext, &pImageFormat, &pImageDesc, &hInteropMem, &phImageMem}; + &hContext, &hDevice, &pImageFormat, + &pImageDesc, &hInteropMem, &phImageMem}; uint64_t instance = context.notify_begin(UR_FUNCTION_BINDLESS_IMAGES_MAP_EXTERNAL_ARRAY_EXP, "urBindlessImagesMapExternalArrayExp", ¶ms); ur_result_t result = pfnMapExternalArrayExp( - hContext, pImageFormat, pImageDesc, hInteropMem, phImageMem); + hContext, hDevice, pImageFormat, pImageDesc, hInteropMem, phImageMem); context.notify_end(UR_FUNCTION_BINDLESS_IMAGES_MAP_EXTERNAL_ARRAY_EXP, "urBindlessImagesMapExternalArrayExp", ¶ms, &result, @@ -4735,6 +4896,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( /// @brief Intercept function for urBindlessImagesReleaseInteropExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_interop_mem_handle_t hInteropMem ///< [in] handle of interop memory to be freed ) { @@ -4745,13 +4907,13 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - ur_bindless_images_release_interop_exp_params_t params = {&hContext, - &hInteropMem}; + ur_bindless_images_release_interop_exp_params_t params = { + &hContext, &hDevice, &hInteropMem}; uint64_t instance = context.notify_begin(UR_FUNCTION_BINDLESS_IMAGES_RELEASE_INTEROP_EXP, "urBindlessImagesReleaseInteropExp", ¶ms); - ur_result_t result = pfnReleaseInteropExp(hContext, hInteropMem); + ur_result_t result = pfnReleaseInteropExp(hContext, hDevice, hInteropMem); context.notify_end(UR_FUNCTION_BINDLESS_IMAGES_RELEASE_INTEROP_EXP, "urBindlessImagesReleaseInteropExp", ¶ms, &result, @@ -4765,9 +4927,11 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object - uint32_t fileDescriptor, ///< [in] the file descriptor + ur_device_handle_t hDevice, ///< [in] handle of the device object + ur_exp_interop_semaphore_desc_t + *pInteropSemaphoreDesc, ///< [in] the interop semaphore descriptor ur_exp_interop_semaphore_handle_t * - phInteropSemaphoreHandle ///< [out] interop semaphore handle to the external semaphore + phInteropSemaphore ///< [out] interop semaphore handle to the external semaphore ) { auto pfnImportExternalSemaphoreOpaqueFDExp = context.urDdiTable.BindlessImagesExp @@ -4778,13 +4942,13 @@ urBindlessImagesImportExternalSemaphoreOpaqueFDExp( } ur_bindless_images_import_external_semaphore_opaque_fd_exp_params_t params = - {&hContext, &fileDescriptor, &phInteropSemaphoreHandle}; + {&hContext, &hDevice, &pInteropSemaphoreDesc, &phInteropSemaphore}; uint64_t instance = context.notify_begin( UR_FUNCTION_BINDLESS_IMAGES_IMPORT_EXTERNAL_SEMAPHORE_OPAQUE_FD_EXP, "urBindlessImagesImportExternalSemaphoreOpaqueFDExp", ¶ms); ur_result_t result = pfnImportExternalSemaphoreOpaqueFDExp( - hContext, fileDescriptor, phInteropSemaphoreHandle); + hContext, hDevice, pInteropSemaphoreDesc, phInteropSemaphore); context.notify_end( UR_FUNCTION_BINDLESS_IMAGES_IMPORT_EXTERNAL_SEMAPHORE_OPAQUE_FD_EXP, @@ -4798,6 +4962,7 @@ urBindlessImagesImportExternalSemaphoreOpaqueFDExp( /// @brief Intercept function for urBindlessImagesDestroyExternalSemaphoreExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesDestroyExternalSemaphoreExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_interop_semaphore_handle_t hInteropSemaphore ///< [in] handle of interop semaphore to be destroyed ) { @@ -4809,13 +4974,13 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesDestroyExternalSemaphoreExp( } ur_bindless_images_destroy_external_semaphore_exp_params_t params = { - &hContext, &hInteropSemaphore}; + &hContext, &hDevice, &hInteropSemaphore}; uint64_t instance = context.notify_begin( UR_FUNCTION_BINDLESS_IMAGES_DESTROY_EXTERNAL_SEMAPHORE_EXP, "urBindlessImagesDestroyExternalSemaphoreExp", ¶ms); ur_result_t result = - pfnDestroyExternalSemaphoreExp(hContext, hInteropSemaphore); + pfnDestroyExternalSemaphoreExp(hContext, hDevice, hInteropSemaphore); context.notify_end( UR_FUNCTION_BINDLESS_IMAGES_DESTROY_EXTERNAL_SEMAPHORE_EXP, @@ -5669,6 +5834,21 @@ __urdlllocal ur_result_t UR_APICALL urGetGlobalProcAddrTable( dditable.pfnTearDown = pDdiTable->pfnTearDown; pDdiTable->pfnTearDown = ur_tracing_layer::urTearDown; + dditable.pfnAdapterGet = pDdiTable->pfnAdapterGet; + pDdiTable->pfnAdapterGet = ur_tracing_layer::urAdapterGet; + + dditable.pfnAdapterRelease = pDdiTable->pfnAdapterRelease; + pDdiTable->pfnAdapterRelease = ur_tracing_layer::urAdapterRelease; + + dditable.pfnAdapterRetain = pDdiTable->pfnAdapterRetain; + pDdiTable->pfnAdapterRetain = ur_tracing_layer::urAdapterRetain; + + dditable.pfnAdapterGetLastError = pDdiTable->pfnAdapterGetLastError; + pDdiTable->pfnAdapterGetLastError = ur_tracing_layer::urAdapterGetLastError; + + dditable.pfnAdapterGetInfo = pDdiTable->pfnAdapterGetInfo; + pDdiTable->pfnAdapterGetInfo = ur_tracing_layer::urAdapterGetInfo; + return result; } /////////////////////////////////////////////////////////////////////////////// @@ -6296,9 +6476,6 @@ __urdlllocal ur_result_t UR_APICALL urGetPlatformProcAddrTable( pDdiTable->pfnCreateWithNativeHandle = ur_tracing_layer::urPlatformCreateWithNativeHandle; - dditable.pfnGetLastError = pDdiTable->pfnGetLastError; - pDdiTable->pfnGetLastError = ur_tracing_layer::urPlatformGetLastError; - dditable.pfnGetApiVersion = pDdiTable->pfnGetApiVersion; pDdiTable->pfnGetApiVersion = ur_tracing_layer::urPlatformGetApiVersion; @@ -6736,9 +6913,14 @@ __urdlllocal ur_result_t UR_APICALL urGetDeviceProcAddrTable( return result; } -ur_result_t context_t::init(ur_dditable_t *dditable) { +ur_result_t context_t::init(ur_dditable_t *dditable, + const std::set &enabledLayerNames) { ur_result_t result = UR_RESULT_SUCCESS; + if (!enabledLayerNames.count(name)) { + return result; + } + if (UR_RESULT_SUCCESS == result) { result = ur_tracing_layer::urGetGlobalProcAddrTable( UR_API_VERSION_CURRENT, &dditable->Global); diff --git a/source/loader/layers/ur_proxy_layer.hpp b/source/loader/layers/ur_proxy_layer.hpp index 723011eacf..da45017a5f 100644 --- a/source/loader/layers/ur_proxy_layer.hpp +++ b/source/loader/layers/ur_proxy_layer.hpp @@ -15,13 +15,18 @@ #include "ur_ddi.h" #include "ur_util.hpp" +#include + /////////////////////////////////////////////////////////////////////////////// class __urdlllocal proxy_layer_context_t { public: ur_api_version_t version = UR_API_VERSION_0_6; - virtual bool isEnabled() = 0; - virtual ur_result_t init(ur_dditable_t *dditable) = 0; + virtual std::vector getNames() const = 0; + virtual bool isAvailable() const = 0; + virtual ur_result_t + init(ur_dditable_t *dditable, + const std::set &enabledLayerNames) = 0; }; -#endif /* UR_PROXY_LAYER_H */ \ No newline at end of file +#endif /* UR_PROXY_LAYER_H */ diff --git a/source/loader/layers/validation/ur_valddi.cpp b/source/loader/layers/validation/ur_valddi.cpp index 6a2c2f38c9..46b0eef491 100644 --- a/source/loader/layers/validation/ur_valddi.cpp +++ b/source/loader/layers/validation/ur_valddi.cpp @@ -17,13 +17,15 @@ namespace ur_validation_layer { /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urInit __urdlllocal ur_result_t UR_APICALL urInit( - ur_device_init_flags_t device_flags ///< [in] device initialization flags. + ur_device_init_flags_t device_flags, ///< [in] device initialization flags. ///< must be 0 (default) or a combination of ::ur_device_init_flag_t. + ur_loader_config_handle_t + hLoaderConfig ///< [in][optional] Handle of loader config handle. ) { auto pfnInit = context.urDdiTable.Global.pfnInit; if (nullptr == pfnInit) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -32,7 +34,7 @@ __urdlllocal ur_result_t UR_APICALL urInit( } } - ur_result_t result = pfnInit(device_flags); + ur_result_t result = pfnInit(device_flags, hLoaderConfig); return result; } @@ -45,7 +47,7 @@ __urdlllocal ur_result_t UR_APICALL urTearDown( auto pfnTearDown = context.urDdiTable.Global.pfnTearDown; if (nullptr == pfnTearDown) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -64,9 +66,179 @@ __urdlllocal ur_result_t UR_APICALL urTearDown( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterGet +__urdlllocal ur_result_t UR_APICALL urAdapterGet( + uint32_t + NumEntries, ///< [in] the number of adapters to be added to phAdapters. + ///< If phAdapters is not NULL, then NumEntries should be greater than + ///< zero, otherwise ::UR_RESULT_ERROR_INVALID_SIZE, + ///< will be returned. + ur_adapter_handle_t * + phAdapters, ///< [out][optional][range(0, NumEntries)] array of handle of adapters. + ///< If NumEntries is less than the number of adapters available, then + ///< ::urAdapterGet shall only retrieve that number of platforms. + uint32_t * + pNumAdapters ///< [out][optional] returns the total number of adapters available. +) { + auto pfnAdapterGet = context.urDdiTable.Global.pfnAdapterGet; + + if (nullptr == pfnAdapterGet) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + if (context.enableParameterValidation) { + } + + ur_result_t result = pfnAdapterGet(NumEntries, phAdapters, pNumAdapters); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterRelease +__urdlllocal ur_result_t UR_APICALL urAdapterRelease( + ur_adapter_handle_t hAdapter ///< [in] Adapter handle to release +) { + auto pfnAdapterRelease = context.urDdiTable.Global.pfnAdapterRelease; + + if (nullptr == pfnAdapterRelease) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + if (context.enableParameterValidation) { + if (NULL == hAdapter) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + } + + ur_result_t result = pfnAdapterRelease(hAdapter); + + if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + refCountContext.decrementRefCount(hAdapter); + } + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterRetain +__urdlllocal ur_result_t UR_APICALL urAdapterRetain( + ur_adapter_handle_t hAdapter ///< [in] Adapter handle to retain +) { + auto pfnAdapterRetain = context.urDdiTable.Global.pfnAdapterRetain; + + if (nullptr == pfnAdapterRetain) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + if (context.enableParameterValidation) { + if (NULL == hAdapter) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + } + + ur_result_t result = pfnAdapterRetain(hAdapter); + + if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + refCountContext.incrementRefCount(hAdapter); + } + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterGetLastError +__urdlllocal ur_result_t UR_APICALL urAdapterGetLastError( + ur_adapter_handle_t hAdapter, ///< [in] handle of the adapter instance + const char ** + ppMessage, ///< [out] pointer to a C string where the adapter specific error message + ///< will be stored. + int32_t * + pError ///< [out] pointer to an integer where the adapter specific error code will + ///< be stored. +) { + auto pfnAdapterGetLastError = + context.urDdiTable.Global.pfnAdapterGetLastError; + + if (nullptr == pfnAdapterGetLastError) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + if (context.enableParameterValidation) { + if (NULL == hAdapter) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + + if (NULL == ppMessage) { + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + } + + if (NULL == pError) { + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + } + } + + ur_result_t result = pfnAdapterGetLastError(hAdapter, ppMessage, pError); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterGetInfo +__urdlllocal ur_result_t UR_APICALL urAdapterGetInfo( + ur_adapter_handle_t hAdapter, ///< [in] handle of the adapter + ur_adapter_info_t propName, ///< [in] type of the info to retrieve + size_t propSize, ///< [in] the number of bytes pointed to by pPropValue. + void * + pPropValue, ///< [out][optional][typename(propName, propSize)] array of bytes holding + ///< the info. + ///< If Size is not equal to or greater to the real number of bytes needed + ///< to return the info then the ::UR_RESULT_ERROR_INVALID_SIZE error is + ///< returned and pPropValue is not used. + size_t * + pPropSizeRet ///< [out][optional] pointer to the actual number of bytes being queried by pPropValue. +) { + auto pfnAdapterGetInfo = context.urDdiTable.Global.pfnAdapterGetInfo; + + if (nullptr == pfnAdapterGetInfo) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + if (context.enableParameterValidation) { + if (NULL == hAdapter) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + + if (propSize != 0 && pPropValue == NULL) { + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + } + + if (pPropValue == NULL && pPropSizeRet == NULL) { + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + } + + if (UR_ADAPTER_INFO_REFERENCE_COUNT < propName) { + return UR_RESULT_ERROR_INVALID_ENUMERATION; + } + + if (propSize == 0 && pPropValue != NULL) { + return UR_RESULT_ERROR_INVALID_SIZE; + } + } + + ur_result_t result = pfnAdapterGetInfo(hAdapter, propName, propSize, + pPropValue, pPropSizeRet); + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urPlatformGet __urdlllocal ur_result_t UR_APICALL urPlatformGet( + ur_adapter_handle_t * + phAdapters, ///< [in][range(0, NumAdapters)] array of adapters to query for platforms. + uint32_t NumAdapters, ///< [in] number of adapters pointed to by phAdapters uint32_t NumEntries, ///< [in] the number of platforms to be added to phPlatforms. ///< If phPlatforms is not NULL, then NumEntries should be greater than @@ -82,13 +254,17 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGet( auto pfnGet = context.urDdiTable.Platform.pfnGet; if (nullptr == pfnGet) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { + if (NULL == phAdapters) { + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + } } - ur_result_t result = pfnGet(NumEntries, phPlatforms, pNumPlatforms); + ur_result_t result = + pfnGet(phAdapters, NumAdapters, NumEntries, phPlatforms, pNumPlatforms); return result; } @@ -111,7 +287,7 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetInfo( auto pfnGetInfo = context.urDdiTable.Platform.pfnGetInfo; if (nullptr == pfnGetInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -151,7 +327,7 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetApiVersion( auto pfnGetApiVersion = context.urDdiTable.Platform.pfnGetApiVersion; if (nullptr == pfnGetApiVersion) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -179,7 +355,7 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetNativeHandle( auto pfnGetNativeHandle = context.urDdiTable.Platform.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -201,7 +377,7 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetNativeHandle( /// @brief Intercept function for urPlatformCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urPlatformCreateWithNativeHandle( ur_native_handle_t - hNativePlatform, ///< [in] the native handle of the platform. + hNativePlatform, ///< [in][nocheck] the native handle of the platform. const ur_platform_native_properties_t * pProperties, ///< [in][optional] pointer to native platform properties struct. ur_platform_handle_t * @@ -211,14 +387,10 @@ __urdlllocal ur_result_t UR_APICALL urPlatformCreateWithNativeHandle( context.urDdiTable.Platform.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { - if (NULL == hNativePlatform) { - return UR_RESULT_ERROR_INVALID_NULL_HANDLE; - } - if (NULL == phPlatform) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } @@ -243,7 +415,7 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetBackendOption( auto pfnGetBackendOption = context.urDdiTable.Platform.pfnGetBackendOption; if (nullptr == pfnGetBackendOption) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -266,42 +438,6 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetBackendOption( return result; } -/////////////////////////////////////////////////////////////////////////////// -/// @brief Intercept function for urPlatformGetLastError -__urdlllocal ur_result_t UR_APICALL urPlatformGetLastError( - ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance - const char ** - ppMessage, ///< [out] pointer to a C string where the adapter specific error message - ///< will be stored. - int32_t * - pError ///< [out] pointer to an integer where the adapter specific error code will - ///< be stored. -) { - auto pfnGetLastError = context.urDdiTable.Platform.pfnGetLastError; - - if (nullptr == pfnGetLastError) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; - } - - if (context.enableParameterValidation) { - if (NULL == hPlatform) { - return UR_RESULT_ERROR_INVALID_NULL_HANDLE; - } - - if (NULL == ppMessage) { - return UR_RESULT_ERROR_INVALID_NULL_POINTER; - } - - if (NULL == pError) { - return UR_RESULT_ERROR_INVALID_NULL_POINTER; - } - } - - ur_result_t result = pfnGetLastError(hPlatform, ppMessage, pError); - - return result; -} - /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urDeviceGet __urdlllocal ur_result_t UR_APICALL urDeviceGet( @@ -322,7 +458,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGet( auto pfnGet = context.urDdiTable.Device.pfnGet; if (nullptr == pfnGet) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -360,7 +496,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGetInfo( auto pfnGetInfo = context.urDdiTable.Device.pfnGetInfo; if (nullptr == pfnGetInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -400,7 +536,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceRetain( auto pfnRetain = context.urDdiTable.Device.pfnRetain; if (nullptr == pfnRetain) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -426,7 +562,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceRelease( auto pfnRelease = context.urDdiTable.Device.pfnRelease; if (nullptr == pfnRelease) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -462,7 +598,7 @@ __urdlllocal ur_result_t UR_APICALL urDevicePartition( auto pfnPartition = context.urDdiTable.Device.pfnPartition; if (nullptr == pfnPartition) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -498,7 +634,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceSelectBinary( auto pfnSelectBinary = context.urDdiTable.Device.pfnSelectBinary; if (nullptr == pfnSelectBinary) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -535,7 +671,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGetNativeHandle( auto pfnGetNativeHandle = context.urDdiTable.Device.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -556,8 +692,9 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urDeviceCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urDeviceCreateWithNativeHandle( - ur_native_handle_t hNativeDevice, ///< [in] the native handle of the device. - ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance + ur_native_handle_t + hNativeDevice, ///< [in][nocheck] the native handle of the device. + ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance const ur_device_native_properties_t * pProperties, ///< [in][optional] pointer to native device properties struct. ur_device_handle_t @@ -567,14 +704,10 @@ __urdlllocal ur_result_t UR_APICALL urDeviceCreateWithNativeHandle( context.urDdiTable.Device.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { - if (NULL == hNativeDevice) { - return UR_RESULT_ERROR_INVALID_NULL_HANDLE; - } - if (NULL == hPlatform) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -609,7 +742,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGetGlobalTimestamps( context.urDdiTable.Device.pfnGetGlobalTimestamps; if (nullptr == pfnGetGlobalTimestamps) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -638,7 +771,7 @@ __urdlllocal ur_result_t UR_APICALL urContextCreate( auto pfnCreate = context.urDdiTable.Context.pfnCreate; if (nullptr == pfnCreate) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -670,7 +803,7 @@ __urdlllocal ur_result_t UR_APICALL urContextRetain( auto pfnRetain = context.urDdiTable.Context.pfnRetain; if (nullptr == pfnRetain) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -696,7 +829,7 @@ __urdlllocal ur_result_t UR_APICALL urContextRelease( auto pfnRelease = context.urDdiTable.Context.pfnRelease; if (nullptr == pfnRelease) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -734,7 +867,7 @@ __urdlllocal ur_result_t UR_APICALL urContextGetInfo( auto pfnGetInfo = context.urDdiTable.Context.pfnGetInfo; if (nullptr == pfnGetInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -775,7 +908,7 @@ __urdlllocal ur_result_t UR_APICALL urContextGetNativeHandle( auto pfnGetNativeHandle = context.urDdiTable.Context.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -797,7 +930,7 @@ __urdlllocal ur_result_t UR_APICALL urContextGetNativeHandle( /// @brief Intercept function for urContextCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( ur_native_handle_t - hNativeContext, ///< [in] the native handle of the context. + hNativeContext, ///< [in][nocheck] the native handle of the context. uint32_t numDevices, ///< [in] number of devices associated with the context const ur_device_handle_t * phDevices, ///< [in][range(0, numDevices)] list of devices associated with the context @@ -810,14 +943,10 @@ __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( context.urDdiTable.Context.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { - if (NULL == hNativeContext) { - return UR_RESULT_ERROR_INVALID_NULL_HANDLE; - } - if (NULL == phDevices) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } @@ -850,7 +979,7 @@ __urdlllocal ur_result_t UR_APICALL urContextSetExtendedDeleter( context.urDdiTable.Context.pfnSetExtendedDeleter; if (nullptr == pfnSetExtendedDeleter) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -882,7 +1011,7 @@ __urdlllocal ur_result_t UR_APICALL urMemImageCreate( auto pfnImageCreate = context.urDdiTable.Mem.pfnImageCreate; if (nullptr == pfnImageCreate) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -943,7 +1072,7 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreate( auto pfnBufferCreate = context.urDdiTable.Mem.pfnBufferCreate; if (nullptr == pfnBufferCreate) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -992,7 +1121,7 @@ __urdlllocal ur_result_t UR_APICALL urMemRetain( auto pfnRetain = context.urDdiTable.Mem.pfnRetain; if (nullptr == pfnRetain) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1018,7 +1147,7 @@ __urdlllocal ur_result_t UR_APICALL urMemRelease( auto pfnRelease = context.urDdiTable.Mem.pfnRelease; if (nullptr == pfnRelease) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1051,7 +1180,7 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferPartition( auto pfnBufferPartition = context.urDdiTable.Mem.pfnBufferPartition; if (nullptr == pfnBufferPartition) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1092,7 +1221,7 @@ __urdlllocal ur_result_t UR_APICALL urMemGetNativeHandle( auto pfnGetNativeHandle = context.urDdiTable.Mem.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1113,8 +1242,9 @@ __urdlllocal ur_result_t UR_APICALL urMemGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urMemBufferCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( - ur_native_handle_t hNativeMem, ///< [in] the native handle to the memory. - ur_context_handle_t hContext, ///< [in] handle of the context object. + ur_native_handle_t + hNativeMem, ///< [in][nocheck] the native handle to the memory. + ur_context_handle_t hContext, ///< [in] handle of the context object. const ur_mem_native_properties_t * pProperties, ///< [in][optional] pointer to native memory creation properties. ur_mem_handle_t @@ -1124,14 +1254,10 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( context.urDdiTable.Mem.pfnBufferCreateWithNativeHandle; if (nullptr == pfnBufferCreateWithNativeHandle) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { - if (NULL == hNativeMem) { - return UR_RESULT_ERROR_INVALID_NULL_HANDLE; - } - if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -1150,8 +1276,9 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urMemImageCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urMemImageCreateWithNativeHandle( - ur_native_handle_t hNativeMem, ///< [in] the native handle to the memory. - ur_context_handle_t hContext, ///< [in] handle of the context object. + ur_native_handle_t + hNativeMem, ///< [in][nocheck] the native handle to the memory. + ur_context_handle_t hContext, ///< [in] handle of the context object. const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification. const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description. @@ -1164,14 +1291,10 @@ __urdlllocal ur_result_t UR_APICALL urMemImageCreateWithNativeHandle( context.urDdiTable.Mem.pfnImageCreateWithNativeHandle; if (nullptr == pfnImageCreateWithNativeHandle) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { - if (NULL == hNativeMem) { - return UR_RESULT_ERROR_INVALID_NULL_HANDLE; - } - if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -1215,7 +1338,7 @@ __urdlllocal ur_result_t UR_APICALL urMemGetInfo( auto pfnGetInfo = context.urDdiTable.Mem.pfnGetInfo; if (nullptr == pfnGetInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1265,7 +1388,7 @@ __urdlllocal ur_result_t UR_APICALL urMemImageGetInfo( auto pfnImageGetInfo = context.urDdiTable.Mem.pfnImageGetInfo; if (nullptr == pfnImageGetInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1273,9 +1396,21 @@ __urdlllocal ur_result_t UR_APICALL urMemImageGetInfo( return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } + if (propSize != 0 && pPropValue == NULL) { + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + } + + if (pPropValue == NULL && pPropSizeRet == NULL) { + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + } + if (UR_IMAGE_INFO_DEPTH < propName) { return UR_RESULT_ERROR_INVALID_ENUMERATION; } + + if (propSize == 0 && pPropValue != NULL) { + return UR_RESULT_ERROR_INVALID_SIZE; + } } ur_result_t result = @@ -1295,7 +1430,7 @@ __urdlllocal ur_result_t UR_APICALL urSamplerCreate( auto pfnCreate = context.urDdiTable.Sampler.pfnCreate; if (nullptr == pfnCreate) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1339,7 +1474,7 @@ __urdlllocal ur_result_t UR_APICALL urSamplerRetain( auto pfnRetain = context.urDdiTable.Sampler.pfnRetain; if (nullptr == pfnRetain) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1366,7 +1501,7 @@ __urdlllocal ur_result_t UR_APICALL urSamplerRelease( auto pfnRelease = context.urDdiTable.Sampler.pfnRelease; if (nullptr == pfnRelease) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1400,7 +1535,7 @@ __urdlllocal ur_result_t UR_APICALL urSamplerGetInfo( auto pfnGetInfo = context.urDdiTable.Sampler.pfnGetInfo; if (nullptr == pfnGetInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1441,7 +1576,7 @@ __urdlllocal ur_result_t UR_APICALL urSamplerGetNativeHandle( auto pfnGetNativeHandle = context.urDdiTable.Sampler.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1463,7 +1598,7 @@ __urdlllocal ur_result_t UR_APICALL urSamplerGetNativeHandle( /// @brief Intercept function for urSamplerCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urSamplerCreateWithNativeHandle( ur_native_handle_t - hNativeSampler, ///< [in] the native handle of the sampler. + hNativeSampler, ///< [in][nocheck] the native handle of the sampler. ur_context_handle_t hContext, ///< [in] handle of the context object const ur_sampler_native_properties_t * pProperties, ///< [in][optional] pointer to native sampler properties struct. @@ -1474,14 +1609,10 @@ __urdlllocal ur_result_t UR_APICALL urSamplerCreateWithNativeHandle( context.urDdiTable.Sampler.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { - if (NULL == hNativeSampler) { - return UR_RESULT_ERROR_INVALID_NULL_HANDLE; - } - if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -1516,7 +1647,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMHostAlloc( auto pfnHostAlloc = context.urDdiTable.USM.pfnHostAlloc; if (nullptr == pfnHostAlloc) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1559,7 +1690,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMDeviceAlloc( auto pfnDeviceAlloc = context.urDdiTable.USM.pfnDeviceAlloc; if (nullptr == pfnDeviceAlloc) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1607,7 +1738,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMSharedAlloc( auto pfnSharedAlloc = context.urDdiTable.USM.pfnSharedAlloc; if (nullptr == pfnSharedAlloc) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1648,7 +1779,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMFree( auto pfnFree = context.urDdiTable.USM.pfnFree; if (nullptr == pfnFree) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1684,7 +1815,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMGetMemAllocInfo( auto pfnGetMemAllocInfo = context.urDdiTable.USM.pfnGetMemAllocInfo; if (nullptr == pfnGetMemAllocInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1719,7 +1850,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolCreate( auto pfnPoolCreate = context.urDdiTable.USM.pfnPoolCreate; if (nullptr == pfnPoolCreate) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1757,7 +1888,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolRetain( auto pfnPoolRetain = context.urDdiTable.USM.pfnPoolRetain; if (nullptr == pfnPoolRetain) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1783,7 +1914,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolRelease( auto pfnPoolRelease = context.urDdiTable.USM.pfnPoolRelease; if (nullptr == pfnPoolRelease) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1816,7 +1947,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolGetInfo( auto pfnPoolGetInfo = context.urDdiTable.USM.pfnPoolGetInfo; if (nullptr == pfnPoolGetInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1870,7 +2001,7 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemGranularityGetInfo( context.urDdiTable.VirtualMem.pfnGranularityGetInfo; if (nullptr == pfnGranularityGetInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1878,9 +2009,21 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemGranularityGetInfo( return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } + if (propSize != 0 && pPropValue == NULL) { + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + } + + if (pPropValue == NULL && pPropSizeRet == NULL) { + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + } + if (UR_VIRTUAL_MEM_GRANULARITY_INFO_RECOMMENDED < propName) { return UR_RESULT_ERROR_INVALID_ENUMERATION; } + + if (propSize == 0 && pPropValue != NULL) { + return UR_RESULT_ERROR_INVALID_SIZE; + } } ur_result_t result = pfnGranularityGetInfo( @@ -1906,7 +2049,7 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemReserve( auto pfnReserve = context.urDdiTable.VirtualMem.pfnReserve; if (nullptr == pfnReserve) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1935,7 +2078,7 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemFree( auto pfnFree = context.urDdiTable.VirtualMem.pfnFree; if (nullptr == pfnFree) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -1970,7 +2113,7 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemMap( auto pfnMap = context.urDdiTable.VirtualMem.pfnMap; if (nullptr == pfnMap) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2008,7 +2151,7 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemUnmap( auto pfnUnmap = context.urDdiTable.VirtualMem.pfnUnmap; if (nullptr == pfnUnmap) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2032,14 +2175,14 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemSetAccess( ur_context_handle_t hContext, ///< [in] handle to the context object. const void *pStart, ///< [in] pointer to the start of the virtual memory range. - size_t size, ///< [in] size in bytes of the virutal memory range. + size_t size, ///< [in] size in bytes of the virtual memory range. ur_virtual_mem_access_flags_t flags ///< [in] access flags to set for the mapped virtual memory range. ) { auto pfnSetAccess = context.urDdiTable.VirtualMem.pfnSetAccess; if (nullptr == pfnSetAccess) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2082,7 +2225,7 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemGetInfo( auto pfnGetInfo = context.urDdiTable.VirtualMem.pfnGetInfo; if (nullptr == pfnGetInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2111,7 +2254,7 @@ __urdlllocal ur_result_t UR_APICALL urPhysicalMemCreate( ur_context_handle_t hContext, ///< [in] handle of the context object. ur_device_handle_t hDevice, ///< [in] handle of the device object. size_t - size, ///< [in] size in bytes of phyisical memory to allocate, must be a multiple + size, ///< [in] size in bytes of physical memory to allocate, must be a multiple ///< of ::UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM. const ur_physical_mem_properties_t * pProperties, ///< [in][optional] pointer to physical memory creation properties. @@ -2121,7 +2264,7 @@ __urdlllocal ur_result_t UR_APICALL urPhysicalMemCreate( auto pfnCreate = context.urDdiTable.PhysicalMem.pfnCreate; if (nullptr == pfnCreate) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2157,7 +2300,7 @@ __urdlllocal ur_result_t UR_APICALL urPhysicalMemRetain( auto pfnRetain = context.urDdiTable.PhysicalMem.pfnRetain; if (nullptr == pfnRetain) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2184,7 +2327,7 @@ __urdlllocal ur_result_t UR_APICALL urPhysicalMemRelease( auto pfnRelease = context.urDdiTable.PhysicalMem.pfnRelease; if (nullptr == pfnRelease) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2216,7 +2359,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramCreateWithIL( auto pfnCreateWithIL = context.urDdiTable.Program.pfnCreateWithIL; if (nullptr == pfnCreateWithIL) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2273,7 +2416,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramCreateWithBinary( auto pfnCreateWithBinary = context.urDdiTable.Program.pfnCreateWithBinary; if (nullptr == pfnCreateWithBinary) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2325,7 +2468,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramBuild( auto pfnBuild = context.urDdiTable.Program.pfnBuild; if (nullptr == pfnBuild) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2355,7 +2498,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramCompile( auto pfnCompile = context.urDdiTable.Program.pfnCompile; if (nullptr == pfnCompile) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2388,7 +2531,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramLink( auto pfnLink = context.urDdiTable.Program.pfnLink; if (nullptr == pfnLink) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2423,7 +2566,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramRetain( auto pfnRetain = context.urDdiTable.Program.pfnRetain; if (nullptr == pfnRetain) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2449,7 +2592,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramRelease( auto pfnRelease = context.urDdiTable.Program.pfnRelease; if (nullptr == pfnRelease) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2485,7 +2628,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetFunctionPointer( context.urDdiTable.Program.pfnGetFunctionPointer; if (nullptr == pfnGetFunctionPointer) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2531,7 +2674,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetInfo( auto pfnGetInfo = context.urDdiTable.Program.pfnGetInfo; if (nullptr == pfnGetInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2583,7 +2726,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetBuildInfo( auto pfnGetBuildInfo = context.urDdiTable.Program.pfnGetBuildInfo; if (nullptr == pfnGetBuildInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2619,7 +2762,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramSetSpecializationConstants( context.urDdiTable.Program.pfnSetSpecializationConstants; if (nullptr == pfnSetSpecializationConstants) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2652,7 +2795,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetNativeHandle( auto pfnGetNativeHandle = context.urDdiTable.Program.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2674,7 +2817,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetNativeHandle( /// @brief Intercept function for urProgramCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urProgramCreateWithNativeHandle( ur_native_handle_t - hNativeProgram, ///< [in] the native handle of the program. + hNativeProgram, ///< [in][nocheck] the native handle of the program. ur_context_handle_t hContext, ///< [in] handle of the context instance const ur_program_native_properties_t * pProperties, ///< [in][optional] pointer to native program properties struct. @@ -2685,14 +2828,10 @@ __urdlllocal ur_result_t UR_APICALL urProgramCreateWithNativeHandle( context.urDdiTable.Program.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { - if (NULL == hNativeProgram) { - return UR_RESULT_ERROR_INVALID_NULL_HANDLE; - } - if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -2723,7 +2862,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelCreate( auto pfnCreate = context.urDdiTable.Kernel.pfnCreate; if (nullptr == pfnCreate) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2763,7 +2902,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgValue( auto pfnSetArgValue = context.urDdiTable.Kernel.pfnSetArgValue; if (nullptr == pfnSetArgValue) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2795,7 +2934,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgLocal( auto pfnSetArgLocal = context.urDdiTable.Kernel.pfnSetArgLocal; if (nullptr == pfnSetArgLocal) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2830,7 +2969,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetInfo( auto pfnGetInfo = context.urDdiTable.Kernel.pfnGetInfo; if (nullptr == pfnGetInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2879,7 +3018,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetGroupInfo( auto pfnGetGroupInfo = context.urDdiTable.Kernel.pfnGetGroupInfo; if (nullptr == pfnGetGroupInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2920,7 +3059,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetSubGroupInfo( auto pfnGetSubGroupInfo = context.urDdiTable.Kernel.pfnGetSubGroupInfo; if (nullptr == pfnGetSubGroupInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2951,7 +3090,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelRetain( auto pfnRetain = context.urDdiTable.Kernel.pfnRetain; if (nullptr == pfnRetain) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -2977,7 +3116,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelRelease( auto pfnRelease = context.urDdiTable.Kernel.pfnRelease; if (nullptr == pfnRelease) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3009,7 +3148,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgPointer( auto pfnSetArgPointer = context.urDdiTable.Kernel.pfnSetArgPointer; if (nullptr == pfnSetArgPointer) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3039,7 +3178,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetExecInfo( auto pfnSetExecInfo = context.urDdiTable.Kernel.pfnSetExecInfo; if (nullptr == pfnSetExecInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3074,7 +3213,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgSampler( auto pfnSetArgSampler = context.urDdiTable.Kernel.pfnSetArgSampler; if (nullptr == pfnSetArgSampler) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3105,7 +3244,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgMemObj( auto pfnSetArgMemObj = context.urDdiTable.Kernel.pfnSetArgMemObj; if (nullptr == pfnSetArgMemObj) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3132,7 +3271,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetSpecializationConstants( context.urDdiTable.Kernel.pfnSetSpecializationConstants; if (nullptr == pfnSetSpecializationConstants) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3165,7 +3304,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetNativeHandle( auto pfnGetNativeHandle = context.urDdiTable.Kernel.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3186,8 +3325,9 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urKernelCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urKernelCreateWithNativeHandle( - ur_native_handle_t hNativeKernel, ///< [in] the native handle of the kernel. - ur_context_handle_t hContext, ///< [in] handle of the context object + ur_native_handle_t + hNativeKernel, ///< [in][nocheck] the native handle of the kernel. + ur_context_handle_t hContext, ///< [in] handle of the context object ur_program_handle_t hProgram, ///< [in] handle of the program associated with the kernel const ur_kernel_native_properties_t * @@ -3199,14 +3339,10 @@ __urdlllocal ur_result_t UR_APICALL urKernelCreateWithNativeHandle( context.urDdiTable.Kernel.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { - if (NULL == hNativeKernel) { - return UR_RESULT_ERROR_INVALID_NULL_HANDLE; - } - if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -3246,7 +3382,7 @@ __urdlllocal ur_result_t UR_APICALL urQueueGetInfo( auto pfnGetInfo = context.urDdiTable.Queue.pfnGetInfo; if (nullptr == pfnGetInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3290,7 +3426,7 @@ __urdlllocal ur_result_t UR_APICALL urQueueCreate( auto pfnCreate = context.urDdiTable.Queue.pfnCreate; if (nullptr == pfnCreate) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3324,7 +3460,7 @@ __urdlllocal ur_result_t UR_APICALL urQueueRetain( auto pfnRetain = context.urDdiTable.Queue.pfnRetain; if (nullptr == pfnRetain) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3350,7 +3486,7 @@ __urdlllocal ur_result_t UR_APICALL urQueueRelease( auto pfnRelease = context.urDdiTable.Queue.pfnRelease; if (nullptr == pfnRelease) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3380,7 +3516,7 @@ __urdlllocal ur_result_t UR_APICALL urQueueGetNativeHandle( auto pfnGetNativeHandle = context.urDdiTable.Queue.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3401,9 +3537,10 @@ __urdlllocal ur_result_t UR_APICALL urQueueGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urQueueCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urQueueCreateWithNativeHandle( - ur_native_handle_t hNativeQueue, ///< [in] the native handle of the queue. - ur_context_handle_t hContext, ///< [in] handle of the context object - ur_device_handle_t hDevice, ///< [in] handle of the device object + ur_native_handle_t + hNativeQueue, ///< [in][nocheck] the native handle of the queue. + ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_queue_native_properties_t * pProperties, ///< [in][optional] pointer to native queue properties struct ur_queue_handle_t @@ -3413,14 +3550,10 @@ __urdlllocal ur_result_t UR_APICALL urQueueCreateWithNativeHandle( context.urDdiTable.Queue.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { - if (NULL == hNativeQueue) { - return UR_RESULT_ERROR_INVALID_NULL_HANDLE; - } - if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -3452,7 +3585,7 @@ __urdlllocal ur_result_t UR_APICALL urQueueFinish( auto pfnFinish = context.urDdiTable.Queue.pfnFinish; if (nullptr == pfnFinish) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3474,7 +3607,7 @@ __urdlllocal ur_result_t UR_APICALL urQueueFlush( auto pfnFlush = context.urDdiTable.Queue.pfnFlush; if (nullptr == pfnFlush) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3502,7 +3635,7 @@ __urdlllocal ur_result_t UR_APICALL urEventGetInfo( auto pfnGetInfo = context.urDdiTable.Event.pfnGetInfo; if (nullptr == pfnGetInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3550,7 +3683,7 @@ __urdlllocal ur_result_t UR_APICALL urEventGetProfilingInfo( auto pfnGetProfilingInfo = context.urDdiTable.Event.pfnGetProfilingInfo; if (nullptr == pfnGetProfilingInfo) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3584,7 +3717,7 @@ __urdlllocal ur_result_t UR_APICALL urEventWait( auto pfnWait = context.urDdiTable.Event.pfnWait; if (nullptr == pfnWait) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3610,7 +3743,7 @@ __urdlllocal ur_result_t UR_APICALL urEventRetain( auto pfnRetain = context.urDdiTable.Event.pfnRetain; if (nullptr == pfnRetain) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3636,7 +3769,7 @@ __urdlllocal ur_result_t UR_APICALL urEventRelease( auto pfnRelease = context.urDdiTable.Event.pfnRelease; if (nullptr == pfnRelease) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3664,7 +3797,7 @@ __urdlllocal ur_result_t UR_APICALL urEventGetNativeHandle( auto pfnGetNativeHandle = context.urDdiTable.Event.pfnGetNativeHandle; if (nullptr == pfnGetNativeHandle) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3685,8 +3818,9 @@ __urdlllocal ur_result_t UR_APICALL urEventGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urEventCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urEventCreateWithNativeHandle( - ur_native_handle_t hNativeEvent, ///< [in] the native handle of the event. - ur_context_handle_t hContext, ///< [in] handle of the context object + ur_native_handle_t + hNativeEvent, ///< [in][nocheck] the native handle of the event. + ur_context_handle_t hContext, ///< [in] handle of the context object const ur_event_native_properties_t * pProperties, ///< [in][optional] pointer to native event properties struct ur_event_handle_t @@ -3696,14 +3830,10 @@ __urdlllocal ur_result_t UR_APICALL urEventCreateWithNativeHandle( context.urDdiTable.Event.pfnCreateWithNativeHandle; if (nullptr == pfnCreateWithNativeHandle) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { - if (NULL == hNativeEvent) { - return UR_RESULT_ERROR_INVALID_NULL_HANDLE; - } - if (NULL == hContext) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -3735,7 +3865,7 @@ __urdlllocal ur_result_t UR_APICALL urEventSetCallback( auto pfnSetCallback = context.urDdiTable.Event.pfnSetCallback; if (nullptr == pfnSetCallback) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3792,7 +3922,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueKernelLaunch( auto pfnKernelLaunch = context.urDdiTable.Enqueue.pfnKernelLaunch; if (nullptr == pfnKernelLaunch) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3846,7 +3976,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueEventsWait( auto pfnEventsWait = context.urDdiTable.Enqueue.pfnEventsWait; if (nullptr == pfnEventsWait) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3888,7 +4018,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueEventsWaitWithBarrier( context.urDdiTable.Enqueue.pfnEventsWaitWithBarrier; if (nullptr == pfnEventsWaitWithBarrier) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3933,7 +4063,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferRead( auto pfnMemBufferRead = context.urDdiTable.Enqueue.pfnMemBufferRead; if (nullptr == pfnMemBufferRead) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -3989,7 +4119,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferWrite( auto pfnMemBufferWrite = context.urDdiTable.Enqueue.pfnMemBufferWrite; if (nullptr == pfnMemBufferWrite) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -4055,7 +4185,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferReadRect( auto pfnMemBufferReadRect = context.urDdiTable.Enqueue.pfnMemBufferReadRect; if (nullptr == pfnMemBufferReadRect) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -4166,7 +4296,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferWriteRect( context.urDdiTable.Enqueue.pfnMemBufferWriteRect; if (nullptr == pfnMemBufferWriteRect) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -4261,7 +4391,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferCopy( auto pfnMemBufferCopy = context.urDdiTable.Enqueue.pfnMemBufferCopy; if (nullptr == pfnMemBufferCopy) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -4324,7 +4454,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferCopyRect( auto pfnMemBufferCopyRect = context.urDdiTable.Enqueue.pfnMemBufferCopyRect; if (nullptr == pfnMemBufferCopyRect) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -4415,7 +4545,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferFill( auto pfnMemBufferFill = context.urDdiTable.Enqueue.pfnMemBufferFill; if (nullptr == pfnMemBufferFill) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -4474,7 +4604,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemImageRead( auto pfnMemImageRead = context.urDdiTable.Enqueue.pfnMemImageRead; if (nullptr == pfnMemImageRead) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -4534,7 +4664,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemImageWrite( auto pfnMemImageWrite = context.urDdiTable.Enqueue.pfnMemImageWrite; if (nullptr == pfnMemImageWrite) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -4594,7 +4724,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemImageCopy( auto pfnMemImageCopy = context.urDdiTable.Enqueue.pfnMemImageCopy; if (nullptr == pfnMemImageCopy) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -4650,7 +4780,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferMap( auto pfnMemBufferMap = context.urDdiTable.Enqueue.pfnMemBufferMap; if (nullptr == pfnMemBufferMap) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -4706,7 +4836,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemUnmap( auto pfnMemUnmap = context.urDdiTable.Enqueue.pfnMemUnmap; if (nullptr == pfnMemUnmap) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -4763,7 +4893,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMFill( auto pfnUSMFill = context.urDdiTable.Enqueue.pfnUSMFill; if (nullptr == pfnUSMFill) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -4832,7 +4962,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMMemcpy( auto pfnUSMMemcpy = context.urDdiTable.Enqueue.pfnUSMMemcpy; if (nullptr == pfnUSMMemcpy) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -4888,7 +5018,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMPrefetch( auto pfnUSMPrefetch = context.urDdiTable.Enqueue.pfnUSMPrefetch; if (nullptr == pfnUSMPrefetch) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -4938,7 +5068,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMAdvise( auto pfnUSMAdvise = context.urDdiTable.Enqueue.pfnUSMAdvise; if (nullptr == pfnUSMAdvise) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -4993,7 +5123,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMFill2D( auto pfnUSMFill2D = context.urDdiTable.Enqueue.pfnUSMFill2D; if (nullptr == pfnUSMFill2D) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -5083,7 +5213,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMMemcpy2D( auto pfnUSMMemcpy2D = context.urDdiTable.Enqueue.pfnUSMMemcpy2D; if (nullptr == pfnUSMMemcpy2D) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -5162,7 +5292,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueDeviceGlobalVariableWrite( context.urDdiTable.Enqueue.pfnDeviceGlobalVariableWrite; if (nullptr == pfnDeviceGlobalVariableWrite) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -5225,7 +5355,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueDeviceGlobalVariableRead( context.urDdiTable.Enqueue.pfnDeviceGlobalVariableRead; if (nullptr == pfnDeviceGlobalVariableRead) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -5291,7 +5421,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueReadHostPipe( auto pfnReadHostPipe = context.urDdiTable.Enqueue.pfnReadHostPipe; if (nullptr == pfnReadHostPipe) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -5357,7 +5487,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueWriteHostPipe( auto pfnWriteHostPipe = context.urDdiTable.Enqueue.pfnWriteHostPipe; if (nullptr == pfnWriteHostPipe) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -5417,7 +5547,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMPitchedAllocExp( auto pfnPitchedAllocExp = context.urDdiTable.USMExp.pfnPitchedAllocExp; if (nullptr == pfnPitchedAllocExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -5459,6 +5589,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMPitchedAllocExp( __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageHandleDestroyExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_handle_t hImage ///< [in] pointer to handle of image object to destroy ) { @@ -5466,7 +5597,7 @@ urBindlessImagesUnsampledImageHandleDestroyExp( context.urDdiTable.BindlessImagesExp.pfnUnsampledImageHandleDestroyExp; if (nullptr == pfnUnsampledImageHandleDestroyExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -5474,12 +5605,17 @@ urBindlessImagesUnsampledImageHandleDestroyExp( return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } + if (NULL == hDevice) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + if (NULL == hImage) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } } - ur_result_t result = pfnUnsampledImageHandleDestroyExp(hContext, hImage); + ur_result_t result = + pfnUnsampledImageHandleDestroyExp(hContext, hDevice, hImage); return result; } @@ -5489,6 +5625,7 @@ urBindlessImagesUnsampledImageHandleDestroyExp( __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageHandleDestroyExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_handle_t hImage ///< [in] pointer to handle of image object to destroy ) { @@ -5496,7 +5633,7 @@ urBindlessImagesSampledImageHandleDestroyExp( context.urDdiTable.BindlessImagesExp.pfnSampledImageHandleDestroyExp; if (nullptr == pfnSampledImageHandleDestroyExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -5504,12 +5641,17 @@ urBindlessImagesSampledImageHandleDestroyExp( return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } + if (NULL == hDevice) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + if (NULL == hImage) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } } - ur_result_t result = pfnSampledImageHandleDestroyExp(hContext, hImage); + ur_result_t result = + pfnSampledImageHandleDestroyExp(hContext, hDevice, hImage); return result; } @@ -5518,6 +5660,7 @@ urBindlessImagesSampledImageHandleDestroyExp( /// @brief Intercept function for urBindlessImagesImageAllocateExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description @@ -5528,7 +5671,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( context.urDdiTable.BindlessImagesExp.pfnImageAllocateExp; if (nullptr == pfnImageAllocateExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -5536,6 +5679,10 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } + if (NULL == hDevice) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + if (NULL == pImageFormat) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } @@ -5553,8 +5700,8 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( } } - ur_result_t result = - pfnImageAllocateExp(hContext, pImageFormat, pImageDesc, phImageMem); + ur_result_t result = pfnImageAllocateExp(hContext, hDevice, pImageFormat, + pImageDesc, phImageMem); return result; } @@ -5563,13 +5710,14 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( /// @brief Intercept function for urBindlessImagesImageFreeExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageFreeExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem ///< [in] handle of image memory to be freed ) { auto pfnImageFreeExp = context.urDdiTable.BindlessImagesExp.pfnImageFreeExp; if (nullptr == pfnImageFreeExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -5577,12 +5725,16 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageFreeExp( return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } + if (NULL == hDevice) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + if (NULL == hImageMem) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } } - ur_result_t result = pfnImageFreeExp(hContext, hImageMem); + ur_result_t result = pfnImageFreeExp(hContext, hDevice, hImageMem); return result; } @@ -5591,6 +5743,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageFreeExp( /// @brief Intercept function for urBindlessImagesUnsampledImageCreateExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] handle to memory from which to create the image const ur_image_format_t @@ -5604,7 +5757,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( context.urDdiTable.BindlessImagesExp.pfnUnsampledImageCreateExp; if (nullptr == pfnUnsampledImageCreateExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -5612,6 +5765,10 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } + if (NULL == hDevice) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + if (NULL == hImageMem) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -5638,7 +5795,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( } ur_result_t result = pfnUnsampledImageCreateExp( - hContext, hImageMem, pImageFormat, pImageDesc, phMem, phImage); + hContext, hDevice, hImageMem, pImageFormat, pImageDesc, phMem, phImage); return result; } @@ -5647,6 +5804,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( /// @brief Intercept function for urBindlessImagesSampledImageCreateExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] handle to memory from which to create the image const ur_image_format_t @@ -5661,7 +5819,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( context.urDdiTable.BindlessImagesExp.pfnSampledImageCreateExp; if (nullptr == pfnSampledImageCreateExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -5669,6 +5827,10 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } + if (NULL == hDevice) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + if (NULL == hImageMem) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -5699,8 +5861,8 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( } ur_result_t result = - pfnSampledImageCreateExp(hContext, hImageMem, pImageFormat, pImageDesc, - hSampler, phMem, phImage); + pfnSampledImageCreateExp(hContext, hDevice, hImageMem, pImageFormat, + pImageDesc, hSampler, phMem, phImage); return result; } @@ -5708,14 +5870,26 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urBindlessImagesImageCopyExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageCopyExp( - ur_context_handle_t hContext, ///< [in] handle of the context object - void *pDst, ///< [in] location the data will be copied to - void *pSrc, ///< [in] location the data will be copied from + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + void *pDst, ///< [in] location the data will be copied to + void *pSrc, ///< [in] location the data will be copied from const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description ur_exp_image_copy_flags_t imageCopyFlags, ///< [in] flags describing copy direction e.g. H2D or D2H + ur_rect_offset_t + srcOffset, ///< [in] defines the (x,y,z) source offset in pixels in the 1D, 2D, or 3D + ///< image + ur_rect_offset_t + dstOffset, ///< [in] defines the (x,y,z) destination offset in pixels in the 1D, 2D, + ///< or 3D image + ur_rect_region_t + copyExtent, ///< [in] defines the (width, height, depth) in pixels of the 1D, 2D, or 3D + ///< region to copy + ur_rect_region_t + hostExtent, ///< [in] defines the (width, height, depth) in pixels of the 1D, 2D, or 3D + ///< region on the host uint32_t numEventsInWaitList, ///< [in] size of the event wait list const ur_event_handle_t * phEventWaitList, ///< [in][optional][range(0, numEventsInWaitList)] pointer to a list of @@ -5730,11 +5904,11 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageCopyExp( auto pfnImageCopyExp = context.urDdiTable.BindlessImagesExp.pfnImageCopyExp; if (nullptr == pfnImageCopyExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { - if (NULL == hContext) { + if (NULL == hQueue) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -5764,8 +5938,9 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageCopyExp( } ur_result_t result = pfnImageCopyExp( - hContext, pDst, pSrc, pImageFormat, pImageDesc, imageCopyFlags, - numEventsInWaitList, phEventWaitList, phEvent); + hQueue, pDst, pSrc, pImageFormat, pImageDesc, imageCopyFlags, srcOffset, + dstOffset, copyExtent, hostExtent, numEventsInWaitList, phEventWaitList, + phEvent); return result; } @@ -5782,7 +5957,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( context.urDdiTable.BindlessImagesExp.pfnImageGetInfoExp; if (nullptr == pfnImageGetInfoExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -5809,6 +5984,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( /// @brief Intercept function for urBindlessImagesMipmapGetLevelExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] memory handle to the mipmap image uint32_t mipmapLevel, ///< [in] requested level of the mipmap @@ -5819,7 +5995,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( context.urDdiTable.BindlessImagesExp.pfnMipmapGetLevelExp; if (nullptr == pfnMipmapGetLevelExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -5827,6 +6003,10 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } + if (NULL == hDevice) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + if (NULL == hImageMem) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -5836,8 +6016,8 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( } } - ur_result_t result = - pfnMipmapGetLevelExp(hContext, hImageMem, mipmapLevel, phImageMem); + ur_result_t result = pfnMipmapGetLevelExp(hContext, hDevice, hImageMem, + mipmapLevel, phImageMem); return result; } @@ -5846,13 +6026,14 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( /// @brief Intercept function for urBindlessImagesMipmapFreeExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hMem ///< [in] handle of image memory to be freed ) { auto pfnMipmapFreeExp = context.urDdiTable.BindlessImagesExp.pfnMipmapFreeExp; if (nullptr == pfnMipmapFreeExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -5860,12 +6041,16 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } + if (NULL == hDevice) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + if (NULL == hMem) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } } - ur_result_t result = pfnMipmapFreeExp(hContext, hMem); + ur_result_t result = pfnMipmapFreeExp(hContext, hDevice, hMem); return result; } @@ -5874,8 +6059,10 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( /// @brief Intercept function for urBindlessImagesImportOpaqueFDExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object size_t size, ///< [in] size of the external memory - uint32_t fileDescriptor, ///< [in] the file descriptor + ur_exp_interop_mem_desc_t + *pInteropMemDesc, ///< [in] the interop memory descriptor ur_exp_interop_mem_handle_t *phInteropMem ///< [out] interop memory handle to the external memory ) { @@ -5883,7 +6070,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( context.urDdiTable.BindlessImagesExp.pfnImportOpaqueFDExp; if (nullptr == pfnImportOpaqueFDExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -5891,13 +6078,21 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } + if (NULL == hDevice) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + + if (NULL == pInteropMemDesc) { + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + } + if (NULL == phInteropMem) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } } - ur_result_t result = - pfnImportOpaqueFDExp(hContext, size, fileDescriptor, phInteropMem); + ur_result_t result = pfnImportOpaqueFDExp(hContext, hDevice, size, + pInteropMemDesc, phInteropMem); return result; } @@ -5906,19 +6101,20 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( /// @brief Intercept function for urBindlessImagesMapExternalArrayExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description ur_exp_interop_mem_handle_t hInteropMem, ///< [in] interop memory handle to the external memory - ur_exp_image_handle_t * + ur_exp_image_mem_handle_t * phImageMem ///< [out] image memory handle to the externally allocated memory ) { auto pfnMapExternalArrayExp = context.urDdiTable.BindlessImagesExp.pfnMapExternalArrayExp; if (nullptr == pfnMapExternalArrayExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -5926,6 +6122,10 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } + if (NULL == hDevice) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + if (NULL == hInteropMem) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } @@ -5948,7 +6148,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( } ur_result_t result = pfnMapExternalArrayExp( - hContext, pImageFormat, pImageDesc, hInteropMem, phImageMem); + hContext, hDevice, pImageFormat, pImageDesc, hInteropMem, phImageMem); return result; } @@ -5957,6 +6157,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( /// @brief Intercept function for urBindlessImagesReleaseInteropExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_interop_mem_handle_t hInteropMem ///< [in] handle of interop memory to be freed ) { @@ -5964,7 +6165,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( context.urDdiTable.BindlessImagesExp.pfnReleaseInteropExp; if (nullptr == pfnReleaseInteropExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -5972,12 +6173,16 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } + if (NULL == hDevice) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + if (NULL == hInteropMem) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } } - ur_result_t result = pfnReleaseInteropExp(hContext, hInteropMem); + ur_result_t result = pfnReleaseInteropExp(hContext, hDevice, hInteropMem); if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.decrementRefCount(hInteropMem); @@ -5991,16 +6196,18 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object - uint32_t fileDescriptor, ///< [in] the file descriptor + ur_device_handle_t hDevice, ///< [in] handle of the device object + ur_exp_interop_semaphore_desc_t + *pInteropSemaphoreDesc, ///< [in] the interop semaphore descriptor ur_exp_interop_semaphore_handle_t * - phInteropSemaphoreHandle ///< [out] interop semaphore handle to the external semaphore + phInteropSemaphore ///< [out] interop semaphore handle to the external semaphore ) { auto pfnImportExternalSemaphoreOpaqueFDExp = context.urDdiTable.BindlessImagesExp .pfnImportExternalSemaphoreOpaqueFDExp; if (nullptr == pfnImportExternalSemaphoreOpaqueFDExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6008,13 +6215,21 @@ urBindlessImagesImportExternalSemaphoreOpaqueFDExp( return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } - if (NULL == phInteropSemaphoreHandle) { + if (NULL == hDevice) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + + if (NULL == pInteropSemaphoreDesc) { + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + } + + if (NULL == phInteropSemaphore) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } } ur_result_t result = pfnImportExternalSemaphoreOpaqueFDExp( - hContext, fileDescriptor, phInteropSemaphoreHandle); + hContext, hDevice, pInteropSemaphoreDesc, phInteropSemaphore); return result; } @@ -6023,6 +6238,7 @@ urBindlessImagesImportExternalSemaphoreOpaqueFDExp( /// @brief Intercept function for urBindlessImagesDestroyExternalSemaphoreExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesDestroyExternalSemaphoreExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_interop_semaphore_handle_t hInteropSemaphore ///< [in] handle of interop semaphore to be destroyed ) { @@ -6030,7 +6246,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesDestroyExternalSemaphoreExp( context.urDdiTable.BindlessImagesExp.pfnDestroyExternalSemaphoreExp; if (nullptr == pfnDestroyExternalSemaphoreExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6038,13 +6254,17 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesDestroyExternalSemaphoreExp( return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } + if (NULL == hDevice) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + if (NULL == hInteropSemaphore) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } } ur_result_t result = - pfnDestroyExternalSemaphoreExp(hContext, hInteropSemaphore); + pfnDestroyExternalSemaphoreExp(hContext, hDevice, hInteropSemaphore); return result; } @@ -6070,7 +6290,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesWaitExternalSemaphoreExp( context.urDdiTable.BindlessImagesExp.pfnWaitExternalSemaphoreExp; if (nullptr == pfnWaitExternalSemaphoreExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6110,7 +6330,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSignalExternalSemaphoreExp( context.urDdiTable.BindlessImagesExp.pfnSignalExternalSemaphoreExp; if (nullptr == pfnSignalExternalSemaphoreExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6142,7 +6362,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferCreateExp( auto pfnCreateExp = context.urDdiTable.CommandBufferExp.pfnCreateExp; if (nullptr == pfnCreateExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6174,7 +6394,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferRetainExp( auto pfnRetainExp = context.urDdiTable.CommandBufferExp.pfnRetainExp; if (nullptr == pfnRetainExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6201,7 +6421,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferReleaseExp( auto pfnReleaseExp = context.urDdiTable.CommandBufferExp.pfnReleaseExp; if (nullptr == pfnReleaseExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6228,7 +6448,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferFinalizeExp( auto pfnFinalizeExp = context.urDdiTable.CommandBufferExp.pfnFinalizeExp; if (nullptr == pfnFinalizeExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6266,7 +6486,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendKernelLaunchExp( context.urDdiTable.CommandBufferExp.pfnAppendKernelLaunchExp; if (nullptr == pfnAppendKernelLaunchExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6326,7 +6546,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemcpyUSMExp( context.urDdiTable.CommandBufferExp.pfnAppendMemcpyUSMExp; if (nullptr == pfnAppendMemcpyUSMExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6383,7 +6603,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMembufferCopyExp( context.urDdiTable.CommandBufferExp.pfnAppendMembufferCopyExp; if (nullptr == pfnAppendMembufferCopyExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6436,7 +6656,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMembufferWriteExp( context.urDdiTable.CommandBufferExp.pfnAppendMembufferWriteExp; if (nullptr == pfnAppendMembufferWriteExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6488,7 +6708,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMembufferReadExp( context.urDdiTable.CommandBufferExp.pfnAppendMembufferReadExp; if (nullptr == pfnAppendMembufferReadExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6548,7 +6768,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMembufferCopyRectExp( context.urDdiTable.CommandBufferExp.pfnAppendMembufferCopyRectExp; if (nullptr == pfnAppendMembufferCopyRectExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6615,7 +6835,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMembufferWriteRectExp( context.urDdiTable.CommandBufferExp.pfnAppendMembufferWriteRectExp; if (nullptr == pfnAppendMembufferWriteRectExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6680,7 +6900,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMembufferReadRectExp( context.urDdiTable.CommandBufferExp.pfnAppendMembufferReadRectExp; if (nullptr == pfnAppendMembufferReadRectExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6733,7 +6953,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferEnqueueExp( auto pfnEnqueueExp = context.urDdiTable.CommandBufferExp.pfnEnqueueExp; if (nullptr == pfnEnqueueExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6770,7 +6990,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMImportExp( auto pfnImportExp = context.urDdiTable.USMExp.pfnImportExp; if (nullptr == pfnImportExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6797,7 +7017,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMReleaseExp( auto pfnReleaseExp = context.urDdiTable.USMExp.pfnReleaseExp; if (nullptr == pfnReleaseExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6830,7 +7050,7 @@ __urdlllocal ur_result_t UR_APICALL urUsmP2PEnablePeerAccessExp( context.urDdiTable.UsmP2PExp.pfnEnablePeerAccessExp; if (nullptr == pfnEnablePeerAccessExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6859,7 +7079,7 @@ __urdlllocal ur_result_t UR_APICALL urUsmP2PDisablePeerAccessExp( context.urDdiTable.UsmP2PExp.pfnDisablePeerAccessExp; if (nullptr == pfnDisablePeerAccessExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6899,7 +7119,7 @@ __urdlllocal ur_result_t UR_APICALL urUsmP2PPeerAccessGetInfoExp( context.urDdiTable.UsmP2PExp.pfnPeerAccessGetInfoExp; if (nullptr == pfnPeerAccessGetInfoExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_UNINITIALIZED; } if (context.enableParameterValidation) { @@ -6969,6 +7189,22 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetGlobalProcAddrTable( dditable.pfnTearDown = pDdiTable->pfnTearDown; pDdiTable->pfnTearDown = ur_validation_layer::urTearDown; + dditable.pfnAdapterGet = pDdiTable->pfnAdapterGet; + pDdiTable->pfnAdapterGet = ur_validation_layer::urAdapterGet; + + dditable.pfnAdapterRelease = pDdiTable->pfnAdapterRelease; + pDdiTable->pfnAdapterRelease = ur_validation_layer::urAdapterRelease; + + dditable.pfnAdapterRetain = pDdiTable->pfnAdapterRetain; + pDdiTable->pfnAdapterRetain = ur_validation_layer::urAdapterRetain; + + dditable.pfnAdapterGetLastError = pDdiTable->pfnAdapterGetLastError; + pDdiTable->pfnAdapterGetLastError = + ur_validation_layer::urAdapterGetLastError; + + dditable.pfnAdapterGetInfo = pDdiTable->pfnAdapterGetInfo; + pDdiTable->pfnAdapterGetInfo = ur_validation_layer::urAdapterGetInfo; + return result; } @@ -7612,9 +7848,6 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetPlatformProcAddrTable( pDdiTable->pfnCreateWithNativeHandle = ur_validation_layer::urPlatformCreateWithNativeHandle; - dditable.pfnGetLastError = pDdiTable->pfnGetLastError; - pDdiTable->pfnGetLastError = ur_validation_layer::urPlatformGetLastError; - dditable.pfnGetApiVersion = pDdiTable->pfnGetApiVersion; pDdiTable->pfnGetApiVersion = ur_validation_layer::urPlatformGetApiVersion; @@ -8063,9 +8296,26 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetDeviceProcAddrTable( return result; } -ur_result_t context_t::init(ur_dditable_t *dditable) { +ur_result_t context_t::init(ur_dditable_t *dditable, + const std::set &enabledLayerNames) { ur_result_t result = UR_RESULT_SUCCESS; + if (enabledLayerNames.count(nameFullValidation)) { + enableParameterValidation = true; + enableLeakChecking = true; + } else { + if (enabledLayerNames.count(nameParameterValidation)) { + enableParameterValidation = true; + } + if (enabledLayerNames.count(nameLeakChecking)) { + enableLeakChecking = true; + } + } + + if (!enableParameterValidation && !enableLeakChecking) { + return result; + } + if (UR_RESULT_SUCCESS == result) { result = ur_validation_layer::urGetGlobalProcAddrTable( UR_API_VERSION_CURRENT, &dditable->Global); diff --git a/source/loader/layers/validation/ur_validation_layer.cpp b/source/loader/layers/validation/ur_validation_layer.cpp index 7da014054f..5cd3f8c13a 100644 --- a/source/loader/layers/validation/ur_validation_layer.cpp +++ b/source/loader/layers/validation/ur_validation_layer.cpp @@ -15,11 +15,7 @@ namespace ur_validation_layer { context_t context; /////////////////////////////////////////////////////////////////////////////// -context_t::context_t() : logger(logger::create_logger("validation")) { - enableValidation = getenv_tobool("UR_ENABLE_VALIDATION_LAYER"); - enableParameterValidation = getenv_tobool("UR_ENABLE_PARAMETER_VALIDATION"); - enableLeakChecking = getenv_tobool("UR_ENABLE_LEAK_CHECKING"); -} +context_t::context_t() : logger(logger::create_logger("validation")) {} /////////////////////////////////////////////////////////////////////////////// context_t::~context_t() {} diff --git a/source/loader/layers/validation/ur_validation_layer.hpp b/source/loader/layers/validation/ur_validation_layer.hpp index 5aeacc30e9..3201a5345e 100644 --- a/source/loader/layers/validation/ur_validation_layer.hpp +++ b/source/loader/layers/validation/ur_validation_layer.hpp @@ -20,10 +20,8 @@ namespace ur_validation_layer { /////////////////////////////////////////////////////////////////////////////// class __urdlllocal context_t : public proxy_layer_context_t { public: - bool enableValidation = false; bool enableParameterValidation = false; bool enableLeakChecking = false; - logger::Logger logger; ur_dditable_t urDdiTable = {}; @@ -31,8 +29,17 @@ class __urdlllocal context_t : public proxy_layer_context_t { context_t(); ~context_t(); - bool isEnabled() override { return enableValidation; }; - ur_result_t init(ur_dditable_t *dditable) override; + bool isAvailable() const override { return true; } + std::vector getNames() const override { + return {nameFullValidation, nameParameterValidation, nameLeakChecking}; + } + ur_result_t init(ur_dditable_t *dditable, + const std::set &enabledLayerNames) override; + + private: + const std::string nameFullValidation = "UR_LAYER_FULL_VALIDATION"; + const std::string nameParameterValidation = "UR_LAYER_PARAMETER_VALIDATION"; + const std::string nameLeakChecking = "UR_LAYER_LEAK_CHECKING"; }; extern context_t context; diff --git a/source/loader/ur_adapter_registry.hpp b/source/loader/ur_adapter_registry.hpp index 33cf4e130e..744d988336 100644 --- a/source/loader/ur_adapter_registry.hpp +++ b/source/loader/ur_adapter_registry.hpp @@ -106,8 +106,9 @@ class AdapterRegistry { // to load the adapter. std::vector> adaptersLoadPaths; - static constexpr std::array knownAdapterNames{ - MAKE_LIBRARY_NAME("ur_adapter_level_zero", "0")}; + static constexpr std::array knownAdapterNames{ + MAKE_LIBRARY_NAME("ur_adapter_level_zero", "0"), + MAKE_LIBRARY_NAME("ur_adapter_cuda", "0")}; std::optional> getEnvAdapterSearchPaths() { std::optional> pathStringsOpt; diff --git a/source/loader/ur_ldrddi.cpp b/source/loader/ur_ldrddi.cpp index ded860ff5b..e192088bbc 100644 --- a/source/loader/ur_ldrddi.cpp +++ b/source/loader/ur_ldrddi.cpp @@ -14,6 +14,7 @@ namespace ur_loader { /////////////////////////////////////////////////////////////////////////////// +ur_adapter_factory_t ur_adapter_factory; ur_platform_factory_t ur_platform_factory; ur_device_factory_t ur_device_factory; ur_context_factory_t ur_context_factory; @@ -35,8 +36,10 @@ ur_exp_command_buffer_factory_t ur_exp_command_buffer_factory; /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urInit __urdlllocal ur_result_t UR_APICALL urInit( - ur_device_init_flags_t device_flags ///< [in] device initialization flags. + ur_device_init_flags_t device_flags, ///< [in] device initialization flags. ///< must be 0 (default) or a combination of ::ur_device_init_flag_t. + ur_loader_config_handle_t + hLoaderConfig ///< [in][optional] Handle of loader config handle. ) { ur_result_t result = UR_RESULT_SUCCESS; @@ -44,7 +47,8 @@ __urdlllocal ur_result_t UR_APICALL urInit( if (platform.initStatus != UR_RESULT_SUCCESS) { continue; } - platform.initStatus = platform.dditable.ur.Global.pfnInit(device_flags); + platform.initStatus = + platform.dditable.ur.Global.pfnInit(device_flags, hLoaderConfig); } return result; @@ -64,9 +68,163 @@ __urdlllocal ur_result_t UR_APICALL urTearDown( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterGet +__urdlllocal ur_result_t UR_APICALL urAdapterGet( + uint32_t + NumEntries, ///< [in] the number of adapters to be added to phAdapters. + ///< If phAdapters is not NULL, then NumEntries should be greater than + ///< zero, otherwise ::UR_RESULT_ERROR_INVALID_SIZE, + ///< will be returned. + ur_adapter_handle_t * + phAdapters, ///< [out][optional][range(0, NumEntries)] array of handle of adapters. + ///< If NumEntries is less than the number of adapters available, then + ///< ::urAdapterGet shall only retrieve that number of platforms. + uint32_t * + pNumAdapters ///< [out][optional] returns the total number of adapters available. +) { + ur_result_t result = UR_RESULT_SUCCESS; + + size_t adapterIndex = 0; + if (nullptr != phAdapters && NumEntries != 0) { + for (auto &platform : context->platforms) { + platform.dditable.ur.Global.pfnAdapterGet( + 1, &phAdapters[adapterIndex], nullptr); + try { + phAdapters[adapterIndex] = + reinterpret_cast( + ur_adapter_factory.getInstance(phAdapters[adapterIndex], + &platform.dditable)); + } catch (std::bad_alloc &) { + result = UR_RESULT_ERROR_OUT_OF_HOST_MEMORY; + break; + } + adapterIndex++; + } + } + + if (pNumAdapters != nullptr) { + *pNumAdapters = static_cast(context->platforms.size()); + } + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterRelease +__urdlllocal ur_result_t UR_APICALL urAdapterRelease( + ur_adapter_handle_t hAdapter ///< [in] Adapter handle to release +) { + ur_result_t result = UR_RESULT_SUCCESS; + + // extract platform's function pointer table + auto dditable = reinterpret_cast(hAdapter)->dditable; + auto pfnAdapterRelease = dditable->ur.Global.pfnAdapterRelease; + if (nullptr == pfnAdapterRelease) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + // convert loader handle to platform handle + hAdapter = reinterpret_cast(hAdapter)->handle; + + // forward to device-platform + result = pfnAdapterRelease(hAdapter); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterRetain +__urdlllocal ur_result_t UR_APICALL urAdapterRetain( + ur_adapter_handle_t hAdapter ///< [in] Adapter handle to retain +) { + ur_result_t result = UR_RESULT_SUCCESS; + + // extract platform's function pointer table + auto dditable = reinterpret_cast(hAdapter)->dditable; + auto pfnAdapterRetain = dditable->ur.Global.pfnAdapterRetain; + if (nullptr == pfnAdapterRetain) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + // convert loader handle to platform handle + hAdapter = reinterpret_cast(hAdapter)->handle; + + // forward to device-platform + result = pfnAdapterRetain(hAdapter); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterGetLastError +__urdlllocal ur_result_t UR_APICALL urAdapterGetLastError( + ur_adapter_handle_t hAdapter, ///< [in] handle of the adapter instance + const char ** + ppMessage, ///< [out] pointer to a C string where the adapter specific error message + ///< will be stored. + int32_t * + pError ///< [out] pointer to an integer where the adapter specific error code will + ///< be stored. +) { + ur_result_t result = UR_RESULT_SUCCESS; + + // extract platform's function pointer table + auto dditable = reinterpret_cast(hAdapter)->dditable; + auto pfnAdapterGetLastError = dditable->ur.Global.pfnAdapterGetLastError; + if (nullptr == pfnAdapterGetLastError) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + // convert loader handle to platform handle + hAdapter = reinterpret_cast(hAdapter)->handle; + + // forward to device-platform + result = pfnAdapterGetLastError(hAdapter, ppMessage, pError); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterGetInfo +__urdlllocal ur_result_t UR_APICALL urAdapterGetInfo( + ur_adapter_handle_t hAdapter, ///< [in] handle of the adapter + ur_adapter_info_t propName, ///< [in] type of the info to retrieve + size_t propSize, ///< [in] the number of bytes pointed to by pPropValue. + void * + pPropValue, ///< [out][optional][typename(propName, propSize)] array of bytes holding + ///< the info. + ///< If Size is not equal to or greater to the real number of bytes needed + ///< to return the info then the ::UR_RESULT_ERROR_INVALID_SIZE error is + ///< returned and pPropValue is not used. + size_t * + pPropSizeRet ///< [out][optional] pointer to the actual number of bytes being queried by pPropValue. +) { + ur_result_t result = UR_RESULT_SUCCESS; + + // extract platform's function pointer table + auto dditable = reinterpret_cast(hAdapter)->dditable; + auto pfnAdapterGetInfo = dditable->ur.Global.pfnAdapterGetInfo; + if (nullptr == pfnAdapterGetInfo) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + // convert loader handle to platform handle + hAdapter = reinterpret_cast(hAdapter)->handle; + + // forward to device-platform + result = pfnAdapterGetInfo(hAdapter, propName, propSize, pPropValue, + pPropSizeRet); + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urPlatformGet __urdlllocal ur_result_t UR_APICALL urPlatformGet( + ur_adapter_handle_t * + phAdapters, ///< [in][range(0, NumAdapters)] array of adapters to query for platforms. + uint32_t NumAdapters, ///< [in] number of adapters pointed to by phAdapters uint32_t NumEntries, ///< [in] the number of platforms to be added to phPlatforms. ///< If phPlatforms is not NULL, then NumEntries should be greater than @@ -83,10 +241,12 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGet( uint32_t total_platform_handle_count = 0; - for (auto &platform : context->platforms) { - if (platform.initStatus != UR_RESULT_SUCCESS) { - continue; - } + for (uint32_t adapter_index = 0; adapter_index < NumAdapters; + adapter_index++) { + // extract adapter's function pointer table + auto dditable = + reinterpret_cast(phAdapters[adapter_index]) + ->dditable; if ((0 < NumEntries) && (NumEntries == total_platform_handle_count)) { break; @@ -94,8 +254,9 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGet( uint32_t library_platform_handle_count = 0; - result = platform.dditable.ur.Platform.pfnGet( - 0, nullptr, &library_platform_handle_count); + result = dditable->ur.Platform.pfnGet(&phAdapters[adapter_index], 1, 0, + nullptr, + &library_platform_handle_count); if (UR_RESULT_SUCCESS != result) { break; } @@ -106,8 +267,8 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGet( library_platform_handle_count = NumEntries - total_platform_handle_count; } - result = platform.dditable.ur.Platform.pfnGet( - library_platform_handle_count, + result = dditable->ur.Platform.pfnGet( + &phAdapters[adapter_index], 1, library_platform_handle_count, &phPlatforms[total_platform_handle_count], nullptr); if (UR_RESULT_SUCCESS != result) { break; @@ -119,8 +280,7 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGet( phPlatforms[platform_index] = reinterpret_cast( ur_platform_factory.getInstance( - phPlatforms[platform_index], - &platform.dditable)); + phPlatforms[platform_index], dditable)); } } catch (std::bad_alloc &) { result = UR_RESULT_ERROR_OUT_OF_HOST_MEMORY; @@ -239,7 +399,7 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetNativeHandle( /// @brief Intercept function for urPlatformCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urPlatformCreateWithNativeHandle( ur_native_handle_t - hNativePlatform, ///< [in] the native handle of the platform. + hNativePlatform, ///< [in][nocheck] the native handle of the platform. const ur_platform_native_properties_t * pProperties, ///< [in][optional] pointer to native platform properties struct. ur_platform_handle_t * @@ -308,36 +468,6 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetBackendOption( return result; } -/////////////////////////////////////////////////////////////////////////////// -/// @brief Intercept function for urPlatformGetLastError -__urdlllocal ur_result_t UR_APICALL urPlatformGetLastError( - ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance - const char ** - ppMessage, ///< [out] pointer to a C string where the adapter specific error message - ///< will be stored. - int32_t * - pError ///< [out] pointer to an integer where the adapter specific error code will - ///< be stored. -) { - ur_result_t result = UR_RESULT_SUCCESS; - - // extract platform's function pointer table - auto dditable = - reinterpret_cast(hPlatform)->dditable; - auto pfnGetLastError = dditable->ur.Platform.pfnGetLastError; - if (nullptr == pfnGetLastError) { - return UR_RESULT_ERROR_UNINITIALIZED; - } - - // convert loader handle to platform handle - hPlatform = reinterpret_cast(hPlatform)->handle; - - // forward to device-platform - result = pfnGetLastError(hPlatform, ppMessage, pError); - - return result; -} - /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urDeviceGet __urdlllocal ur_result_t UR_APICALL urDeviceGet( @@ -589,8 +719,9 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urDeviceCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urDeviceCreateWithNativeHandle( - ur_native_handle_t hNativeDevice, ///< [in] the native handle of the device. - ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance + ur_native_handle_t + hNativeDevice, ///< [in][nocheck] the native handle of the device. + ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance const ur_device_native_properties_t * pProperties, ///< [in][optional] pointer to native device properties struct. ur_device_handle_t @@ -832,7 +963,7 @@ __urdlllocal ur_result_t UR_APICALL urContextGetNativeHandle( /// @brief Intercept function for urContextCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( ur_native_handle_t - hNativeContext, ///< [in] the native handle of the context. + hNativeContext, ///< [in][nocheck] the native handle of the context. uint32_t numDevices, ///< [in] number of devices associated with the context const ur_device_handle_t * phDevices, ///< [in][range(0, numDevices)] list of devices associated with the context @@ -1122,8 +1253,9 @@ __urdlllocal ur_result_t UR_APICALL urMemGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urMemBufferCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( - ur_native_handle_t hNativeMem, ///< [in] the native handle to the memory. - ur_context_handle_t hContext, ///< [in] handle of the context object. + ur_native_handle_t + hNativeMem, ///< [in][nocheck] the native handle to the memory. + ur_context_handle_t hContext, ///< [in] handle of the context object. const ur_mem_native_properties_t * pProperties, ///< [in][optional] pointer to native memory creation properties. ur_mem_handle_t @@ -1168,8 +1300,9 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urMemImageCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urMemImageCreateWithNativeHandle( - ur_native_handle_t hNativeMem, ///< [in] the native handle to the memory. - ur_context_handle_t hContext, ///< [in] handle of the context object. + ur_native_handle_t + hNativeMem, ///< [in][nocheck] the native handle to the memory. + ur_context_handle_t hContext, ///< [in] handle of the context object. const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification. const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description. @@ -1442,7 +1575,7 @@ __urdlllocal ur_result_t UR_APICALL urSamplerGetNativeHandle( /// @brief Intercept function for urSamplerCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urSamplerCreateWithNativeHandle( ur_native_handle_t - hNativeSampler, ///< [in] the native handle of the sampler. + hNativeSampler, ///< [in][nocheck] the native handle of the sampler. ur_context_handle_t hContext, ///< [in] handle of the context object const ur_sampler_native_properties_t * pProperties, ///< [in][optional] pointer to native sampler properties struct. @@ -1939,7 +2072,7 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemSetAccess( ur_context_handle_t hContext, ///< [in] handle to the context object. const void *pStart, ///< [in] pointer to the start of the virtual memory range. - size_t size, ///< [in] size in bytes of the virutal memory range. + size_t size, ///< [in] size in bytes of the virtual memory range. ur_virtual_mem_access_flags_t flags ///< [in] access flags to set for the mapped virtual memory range. ) { @@ -2004,7 +2137,7 @@ __urdlllocal ur_result_t UR_APICALL urPhysicalMemCreate( ur_context_handle_t hContext, ///< [in] handle of the context object. ur_device_handle_t hDevice, ///< [in] handle of the device object. size_t - size, ///< [in] size in bytes of phyisical memory to allocate, must be a multiple + size, ///< [in] size in bytes of physical memory to allocate, must be a multiple ///< of ::UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM. const ur_physical_mem_properties_t * pProperties, ///< [in][optional] pointer to physical memory creation properties. @@ -2518,7 +2651,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetNativeHandle( /// @brief Intercept function for urProgramCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urProgramCreateWithNativeHandle( ur_native_handle_t - hNativeProgram, ///< [in] the native handle of the program. + hNativeProgram, ///< [in][nocheck] the native handle of the program. ur_context_handle_t hContext, ///< [in] handle of the context instance const ur_program_native_properties_t * pProperties, ///< [in][optional] pointer to native program properties struct. @@ -3001,8 +3134,9 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urKernelCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urKernelCreateWithNativeHandle( - ur_native_handle_t hNativeKernel, ///< [in] the native handle of the kernel. - ur_context_handle_t hContext, ///< [in] handle of the context object + ur_native_handle_t + hNativeKernel, ///< [in][nocheck] the native handle of the kernel. + ur_context_handle_t hContext, ///< [in] handle of the context object ur_program_handle_t hProgram, ///< [in] handle of the program associated with the kernel const ur_kernel_native_properties_t * @@ -3212,9 +3346,10 @@ __urdlllocal ur_result_t UR_APICALL urQueueGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urQueueCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urQueueCreateWithNativeHandle( - ur_native_handle_t hNativeQueue, ///< [in] the native handle of the queue. - ur_context_handle_t hContext, ///< [in] handle of the context object - ur_device_handle_t hDevice, ///< [in] handle of the device object + ur_native_handle_t + hNativeQueue, ///< [in][nocheck] the native handle of the queue. + ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_queue_native_properties_t * pProperties, ///< [in][optional] pointer to native queue properties struct ur_queue_handle_t @@ -3484,8 +3619,9 @@ __urdlllocal ur_result_t UR_APICALL urEventGetNativeHandle( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urEventCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urEventCreateWithNativeHandle( - ur_native_handle_t hNativeEvent, ///< [in] the native handle of the event. - ur_context_handle_t hContext, ///< [in] handle of the context object + ur_native_handle_t + hNativeEvent, ///< [in][nocheck] the native handle of the event. + ur_context_handle_t hContext, ///< [in] handle of the context object const ur_event_native_properties_t * pProperties, ///< [in][optional] pointer to native event properties struct ur_event_handle_t @@ -5264,6 +5400,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMPitchedAllocExp( __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageHandleDestroyExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_handle_t hImage ///< [in] pointer to handle of image object to destroy ) { @@ -5280,11 +5417,14 @@ urBindlessImagesUnsampledImageHandleDestroyExp( // convert loader handle to platform handle hContext = reinterpret_cast(hContext)->handle; + // convert loader handle to platform handle + hDevice = reinterpret_cast(hDevice)->handle; + // convert loader handle to platform handle hImage = reinterpret_cast(hImage)->handle; // forward to device-platform - result = pfnUnsampledImageHandleDestroyExp(hContext, hImage); + result = pfnUnsampledImageHandleDestroyExp(hContext, hDevice, hImage); return result; } @@ -5294,6 +5434,7 @@ urBindlessImagesUnsampledImageHandleDestroyExp( __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageHandleDestroyExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_handle_t hImage ///< [in] pointer to handle of image object to destroy ) { @@ -5310,11 +5451,14 @@ urBindlessImagesSampledImageHandleDestroyExp( // convert loader handle to platform handle hContext = reinterpret_cast(hContext)->handle; + // convert loader handle to platform handle + hDevice = reinterpret_cast(hDevice)->handle; + // convert loader handle to platform handle hImage = reinterpret_cast(hImage)->handle; // forward to device-platform - result = pfnSampledImageHandleDestroyExp(hContext, hImage); + result = pfnSampledImageHandleDestroyExp(hContext, hDevice, hImage); return result; } @@ -5323,6 +5467,7 @@ urBindlessImagesSampledImageHandleDestroyExp( /// @brief Intercept function for urBindlessImagesImageAllocateExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description @@ -5342,9 +5487,12 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( // convert loader handle to platform handle hContext = reinterpret_cast(hContext)->handle; + // convert loader handle to platform handle + hDevice = reinterpret_cast(hDevice)->handle; + // forward to device-platform - result = - pfnImageAllocateExp(hContext, pImageFormat, pImageDesc, phImageMem); + result = pfnImageAllocateExp(hContext, hDevice, pImageFormat, pImageDesc, + phImageMem); if (UR_RESULT_SUCCESS != result) { return result; @@ -5365,6 +5513,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( /// @brief Intercept function for urBindlessImagesImageFreeExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageFreeExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem ///< [in] handle of image memory to be freed ) { @@ -5380,12 +5529,15 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageFreeExp( // convert loader handle to platform handle hContext = reinterpret_cast(hContext)->handle; + // convert loader handle to platform handle + hDevice = reinterpret_cast(hDevice)->handle; + // convert loader handle to platform handle hImageMem = reinterpret_cast(hImageMem)->handle; // forward to device-platform - result = pfnImageFreeExp(hContext, hImageMem); + result = pfnImageFreeExp(hContext, hDevice, hImageMem); return result; } @@ -5394,6 +5546,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageFreeExp( /// @brief Intercept function for urBindlessImagesUnsampledImageCreateExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] handle to memory from which to create the image const ur_image_format_t @@ -5416,13 +5569,16 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( // convert loader handle to platform handle hContext = reinterpret_cast(hContext)->handle; + // convert loader handle to platform handle + hDevice = reinterpret_cast(hDevice)->handle; + // convert loader handle to platform handle hImageMem = reinterpret_cast(hImageMem)->handle; // forward to device-platform - result = pfnUnsampledImageCreateExp(hContext, hImageMem, pImageFormat, - pImageDesc, phMem, phImage); + result = pfnUnsampledImageCreateExp( + hContext, hDevice, hImageMem, pImageFormat, pImageDesc, phMem, phImage); if (UR_RESULT_SUCCESS != result) { return result; @@ -5451,6 +5607,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( /// @brief Intercept function for urBindlessImagesSampledImageCreateExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] handle to memory from which to create the image const ur_image_format_t @@ -5474,6 +5631,9 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( // convert loader handle to platform handle hContext = reinterpret_cast(hContext)->handle; + // convert loader handle to platform handle + hDevice = reinterpret_cast(hDevice)->handle; + // convert loader handle to platform handle hImageMem = reinterpret_cast(hImageMem)->handle; @@ -5482,8 +5642,9 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( hSampler = reinterpret_cast(hSampler)->handle; // forward to device-platform - result = pfnSampledImageCreateExp(hContext, hImageMem, pImageFormat, - pImageDesc, hSampler, phMem, phImage); + result = + pfnSampledImageCreateExp(hContext, hDevice, hImageMem, pImageFormat, + pImageDesc, hSampler, phMem, phImage); if (UR_RESULT_SUCCESS != result) { return result; @@ -5511,14 +5672,26 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urBindlessImagesImageCopyExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageCopyExp( - ur_context_handle_t hContext, ///< [in] handle of the context object - void *pDst, ///< [in] location the data will be copied to - void *pSrc, ///< [in] location the data will be copied from + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + void *pDst, ///< [in] location the data will be copied to + void *pSrc, ///< [in] location the data will be copied from const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description ur_exp_image_copy_flags_t imageCopyFlags, ///< [in] flags describing copy direction e.g. H2D or D2H + ur_rect_offset_t + srcOffset, ///< [in] defines the (x,y,z) source offset in pixels in the 1D, 2D, or 3D + ///< image + ur_rect_offset_t + dstOffset, ///< [in] defines the (x,y,z) destination offset in pixels in the 1D, 2D, + ///< or 3D image + ur_rect_region_t + copyExtent, ///< [in] defines the (width, height, depth) in pixels of the 1D, 2D, or 3D + ///< region to copy + ur_rect_region_t + hostExtent, ///< [in] defines the (width, height, depth) in pixels of the 1D, 2D, or 3D + ///< region on the host uint32_t numEventsInWaitList, ///< [in] size of the event wait list const ur_event_handle_t * phEventWaitList, ///< [in][optional][range(0, numEventsInWaitList)] pointer to a list of @@ -5533,14 +5706,14 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageCopyExp( ur_result_t result = UR_RESULT_SUCCESS; // extract platform's function pointer table - auto dditable = reinterpret_cast(hContext)->dditable; + auto dditable = reinterpret_cast(hQueue)->dditable; auto pfnImageCopyExp = dditable->ur.BindlessImagesExp.pfnImageCopyExp; if (nullptr == pfnImageCopyExp) { return UR_RESULT_ERROR_UNINITIALIZED; } // convert loader handle to platform handle - hContext = reinterpret_cast(hContext)->handle; + hQueue = reinterpret_cast(hQueue)->handle; // convert loader handles to platform handles auto phEventWaitListLocal = @@ -5551,8 +5724,9 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageCopyExp( } // forward to device-platform - result = pfnImageCopyExp(hContext, pDst, pSrc, pImageFormat, pImageDesc, - imageCopyFlags, numEventsInWaitList, + result = pfnImageCopyExp(hQueue, pDst, pSrc, pImageFormat, pImageDesc, + imageCopyFlags, srcOffset, dstOffset, copyExtent, + hostExtent, numEventsInWaitList, phEventWaitListLocal.data(), phEvent); if (UR_RESULT_SUCCESS != result) { @@ -5604,6 +5778,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( /// @brief Intercept function for urBindlessImagesMipmapGetLevelExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] memory handle to the mipmap image uint32_t mipmapLevel, ///< [in] requested level of the mipmap @@ -5623,12 +5798,16 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( // convert loader handle to platform handle hContext = reinterpret_cast(hContext)->handle; + // convert loader handle to platform handle + hDevice = reinterpret_cast(hDevice)->handle; + // convert loader handle to platform handle hImageMem = reinterpret_cast(hImageMem)->handle; // forward to device-platform - result = pfnMipmapGetLevelExp(hContext, hImageMem, mipmapLevel, phImageMem); + result = pfnMipmapGetLevelExp(hContext, hDevice, hImageMem, mipmapLevel, + phImageMem); if (UR_RESULT_SUCCESS != result) { return result; @@ -5649,6 +5828,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( /// @brief Intercept function for urBindlessImagesMipmapFreeExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hMem ///< [in] handle of image memory to be freed ) { ur_result_t result = UR_RESULT_SUCCESS; @@ -5663,11 +5843,14 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( // convert loader handle to platform handle hContext = reinterpret_cast(hContext)->handle; + // convert loader handle to platform handle + hDevice = reinterpret_cast(hDevice)->handle; + // convert loader handle to platform handle hMem = reinterpret_cast(hMem)->handle; // forward to device-platform - result = pfnMipmapFreeExp(hContext, hMem); + result = pfnMipmapFreeExp(hContext, hDevice, hMem); return result; } @@ -5676,8 +5859,10 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( /// @brief Intercept function for urBindlessImagesImportOpaqueFDExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object size_t size, ///< [in] size of the external memory - uint32_t fileDescriptor, ///< [in] the file descriptor + ur_exp_interop_mem_desc_t + *pInteropMemDesc, ///< [in] the interop memory descriptor ur_exp_interop_mem_handle_t *phInteropMem ///< [out] interop memory handle to the external memory ) { @@ -5694,8 +5879,12 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( // convert loader handle to platform handle hContext = reinterpret_cast(hContext)->handle; + // convert loader handle to platform handle + hDevice = reinterpret_cast(hDevice)->handle; + // forward to device-platform - result = pfnImportOpaqueFDExp(hContext, size, fileDescriptor, phInteropMem); + result = pfnImportOpaqueFDExp(hContext, hDevice, size, pInteropMemDesc, + phInteropMem); if (UR_RESULT_SUCCESS != result) { return result; @@ -5716,12 +5905,13 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( /// @brief Intercept function for urBindlessImagesMapExternalArrayExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description ur_exp_interop_mem_handle_t hInteropMem, ///< [in] interop memory handle to the external memory - ur_exp_image_handle_t * + ur_exp_image_mem_handle_t * phImageMem ///< [out] image memory handle to the externally allocated memory ) { ur_result_t result = UR_RESULT_SUCCESS; @@ -5737,12 +5927,15 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( // convert loader handle to platform handle hContext = reinterpret_cast(hContext)->handle; + // convert loader handle to platform handle + hDevice = reinterpret_cast(hDevice)->handle; + // convert loader handle to platform handle hInteropMem = reinterpret_cast(hInteropMem)->handle; // forward to device-platform - result = pfnMapExternalArrayExp(hContext, pImageFormat, pImageDesc, + result = pfnMapExternalArrayExp(hContext, hDevice, pImageFormat, pImageDesc, hInteropMem, phImageMem); if (UR_RESULT_SUCCESS != result) { @@ -5751,8 +5944,8 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( try { // convert platform handle to loader handle - *phImageMem = reinterpret_cast( - ur_exp_image_factory.getInstance(*phImageMem, dditable)); + *phImageMem = reinterpret_cast( + ur_exp_image_mem_factory.getInstance(*phImageMem, dditable)); } catch (std::bad_alloc &) { result = UR_RESULT_ERROR_OUT_OF_HOST_MEMORY; } @@ -5764,6 +5957,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( /// @brief Intercept function for urBindlessImagesReleaseInteropExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_interop_mem_handle_t hInteropMem ///< [in] handle of interop memory to be freed ) { @@ -5780,12 +5974,15 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( // convert loader handle to platform handle hContext = reinterpret_cast(hContext)->handle; + // convert loader handle to platform handle + hDevice = reinterpret_cast(hDevice)->handle; + // convert loader handle to platform handle hInteropMem = reinterpret_cast(hInteropMem)->handle; // forward to device-platform - result = pfnReleaseInteropExp(hContext, hInteropMem); + result = pfnReleaseInteropExp(hContext, hDevice, hInteropMem); return result; } @@ -5795,9 +5992,11 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object - uint32_t fileDescriptor, ///< [in] the file descriptor + ur_device_handle_t hDevice, ///< [in] handle of the device object + ur_exp_interop_semaphore_desc_t + *pInteropSemaphoreDesc, ///< [in] the interop semaphore descriptor ur_exp_interop_semaphore_handle_t * - phInteropSemaphoreHandle ///< [out] interop semaphore handle to the external semaphore + phInteropSemaphore ///< [out] interop semaphore handle to the external semaphore ) { ur_result_t result = UR_RESULT_SUCCESS; @@ -5812,9 +6011,12 @@ urBindlessImagesImportExternalSemaphoreOpaqueFDExp( // convert loader handle to platform handle hContext = reinterpret_cast(hContext)->handle; + // convert loader handle to platform handle + hDevice = reinterpret_cast(hDevice)->handle; + // forward to device-platform - result = pfnImportExternalSemaphoreOpaqueFDExp(hContext, fileDescriptor, - phInteropSemaphoreHandle); + result = pfnImportExternalSemaphoreOpaqueFDExp( + hContext, hDevice, pInteropSemaphoreDesc, phInteropSemaphore); if (UR_RESULT_SUCCESS != result) { return result; @@ -5822,10 +6024,10 @@ urBindlessImagesImportExternalSemaphoreOpaqueFDExp( try { // convert platform handle to loader handle - *phInteropSemaphoreHandle = + *phInteropSemaphore = reinterpret_cast( ur_exp_interop_semaphore_factory.getInstance( - *phInteropSemaphoreHandle, dditable)); + *phInteropSemaphore, dditable)); } catch (std::bad_alloc &) { result = UR_RESULT_ERROR_OUT_OF_HOST_MEMORY; } @@ -5837,6 +6039,7 @@ urBindlessImagesImportExternalSemaphoreOpaqueFDExp( /// @brief Intercept function for urBindlessImagesDestroyExternalSemaphoreExp __urdlllocal ur_result_t UR_APICALL urBindlessImagesDestroyExternalSemaphoreExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_interop_semaphore_handle_t hInteropSemaphore ///< [in] handle of interop semaphore to be destroyed ) { @@ -5853,13 +6056,17 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesDestroyExternalSemaphoreExp( // convert loader handle to platform handle hContext = reinterpret_cast(hContext)->handle; + // convert loader handle to platform handle + hDevice = reinterpret_cast(hDevice)->handle; + // convert loader handle to platform handle hInteropSemaphore = reinterpret_cast(hInteropSemaphore) ->handle; // forward to device-platform - result = pfnDestroyExternalSemaphoreExp(hContext, hInteropSemaphore); + result = + pfnDestroyExternalSemaphoreExp(hContext, hDevice, hInteropSemaphore); return result; } @@ -6789,6 +6996,12 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetGlobalProcAddrTable( // return pointers to loader's DDIs pDdiTable->pfnInit = ur_loader::urInit; pDdiTable->pfnTearDown = ur_loader::urTearDown; + pDdiTable->pfnAdapterGet = ur_loader::urAdapterGet; + pDdiTable->pfnAdapterRelease = ur_loader::urAdapterRelease; + pDdiTable->pfnAdapterRetain = ur_loader::urAdapterRetain; + pDdiTable->pfnAdapterGetLastError = + ur_loader::urAdapterGetLastError; + pDdiTable->pfnAdapterGetInfo = ur_loader::urAdapterGetInfo; } else { // return pointers directly to platform's DDIs *pDdiTable = @@ -7405,7 +7618,6 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetPlatformProcAddrTable( ur_loader::urPlatformGetNativeHandle; pDdiTable->pfnCreateWithNativeHandle = ur_loader::urPlatformCreateWithNativeHandle; - pDdiTable->pfnGetLastError = ur_loader::urPlatformGetLastError; pDdiTable->pfnGetApiVersion = ur_loader::urPlatformGetApiVersion; pDdiTable->pfnGetBackendOption = ur_loader::urPlatformGetBackendOption; diff --git a/source/loader/ur_ldrddi.hpp b/source/loader/ur_ldrddi.hpp index 9ebaeed9d9..4edbabbd8b 100644 --- a/source/loader/ur_ldrddi.hpp +++ b/source/loader/ur_ldrddi.hpp @@ -17,6 +17,10 @@ namespace ur_loader { /////////////////////////////////////////////////////////////////////////////// +using ur_adapter_object_t = object_t; +using ur_adapter_factory_t = + singleton_factory_t; + using ur_platform_object_t = object_t; using ur_platform_factory_t = singleton_factory_t; diff --git a/source/loader/ur_lib.cpp b/source/loader/ur_lib.cpp index cfac087348..964da234f1 100644 --- a/source/loader/ur_lib.cpp +++ b/source/loader/ur_lib.cpp @@ -12,25 +12,58 @@ #include "ur_lib.hpp" #include "logger/ur_logger.hpp" #include "ur_loader.hpp" -#include "ur_proxy_layer.hpp" -#include "validation/ur_validation_layer.hpp" -#if UR_ENABLE_TRACING -#include "tracing/ur_tracing_layer.hpp" -#endif +#include namespace ur_lib { /////////////////////////////////////////////////////////////////////////////// context_t *context; /////////////////////////////////////////////////////////////////////////////// -context_t::context_t() {} +context_t::context_t() { + for (auto l : layers) { + if (l->isAvailable()) { + for (auto &layerName : l->getNames()) { + availableLayers += layerName + ";"; + } + } + } + // Remove the trailing ";" + availableLayers.pop_back(); + parseEnvEnabledLayers(); +} /////////////////////////////////////////////////////////////////////////////// context_t::~context_t() {} +bool context_t::layerExists(const std::string &layerName) const { + return availableLayers.find(layerName) != std::string::npos; +} + +void context_t::parseEnvEnabledLayers() { + auto maybeEnableEnvVarMap = getenv_to_map("UR_ENABLE_LAYERS", false); + if (!maybeEnableEnvVarMap.has_value()) { + return; + } + auto enableEnvVarMap = maybeEnableEnvVarMap.value(); + + for (auto &key : enableEnvVarMap) { + enabledLayerNames.insert(key.first); + } +} + +void context_t::initLayers() const { + for (auto &l : layers) { + if (l->isAvailable()) { + l->init(&context->urDdiTable, enabledLayerNames); + } + } +} + ////////////////////////////////////////////////////////////////////////// -__urdlllocal ur_result_t context_t::Init(ur_device_init_flags_t device_flags) { +__urdlllocal ur_result_t +context_t::Init(ur_device_init_flags_t device_flags, + ur_loader_config_handle_t hLoaderConfig) { ur_result_t result; const char *logger_name = "loader"; logger::init(logger_name); @@ -42,20 +75,103 @@ __urdlllocal ur_result_t context_t::Init(ur_device_init_flags_t device_flags) { result = urInit(); } - proxy_layer_context_t *layers[] = { - &ur_validation_layer::context, -#if UR_ENABLE_TRACING - &ur_tracing_layer::context -#endif - }; + if (hLoaderConfig) { + enabledLayerNames.merge(hLoaderConfig->getEnabledLayerNames()); + } - for (proxy_layer_context_t *l : layers) { - if (l->isEnabled()) { - l->init(&context->urDdiTable); - } + if (!enabledLayerNames.empty()) { + initLayers(); } return result; } +ur_result_t urLoaderConfigCreate(ur_loader_config_handle_t *phLoaderConfig) { + if (!phLoaderConfig) { + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + } + *phLoaderConfig = new ur_loader_config_handle_t_; + return UR_RESULT_SUCCESS; +} + +ur_result_t urLoaderConfigRetain(ur_loader_config_handle_t hLoaderConfig) { + if (!hLoaderConfig) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + hLoaderConfig->incrementReferenceCount(); + return UR_RESULT_SUCCESS; +} + +ur_result_t urLoaderConfigRelease(ur_loader_config_handle_t hLoaderConfig) { + if (!hLoaderConfig) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + if (hLoaderConfig->decrementReferenceCount() == 0) { + delete hLoaderConfig; + } + return UR_RESULT_SUCCESS; +} + +ur_result_t urLoaderConfigGetInfo(ur_loader_config_handle_t hLoaderConfig, + ur_loader_config_info_t propName, + size_t propSize, void *pPropValue, + size_t *pPropSizeRet) { + if (!hLoaderConfig) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + + if (!pPropValue && !pPropSizeRet) { + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + } + + switch (propName) { + case UR_LOADER_CONFIG_INFO_AVAILABLE_LAYERS: { + if (pPropSizeRet) { + *pPropSizeRet = context->availableLayers.size() + 1; + } + if (pPropValue) { + char *outString = static_cast(pPropValue); + if (propSize != context->availableLayers.size() + 1) { + return UR_RESULT_ERROR_INVALID_SIZE; + } + std::memcpy(outString, context->availableLayers.data(), + propSize - 1); + outString[propSize - 1] = '\0'; + } + break; + } + case UR_LOADER_CONFIG_INFO_REFERENCE_COUNT: { + auto refCount = hLoaderConfig->getReferenceCount(); + auto truePropSize = sizeof(refCount); + if (pPropSizeRet) { + *pPropSizeRet = truePropSize; + } + if (pPropValue) { + if (propSize != truePropSize) { + return UR_RESULT_ERROR_INVALID_SIZE; + } + std::memcpy(pPropValue, &refCount, truePropSize); + } + break; + } + default: + return UR_RESULT_ERROR_INVALID_ENUMERATION; + } + return UR_RESULT_SUCCESS; +} + +ur_result_t urLoaderConfigEnableLayer(ur_loader_config_handle_t hLoaderConfig, + const char *pLayerName) { + if (!hLoaderConfig) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + if (!pLayerName) { + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + } + if (!context->layerExists(std::string(pLayerName))) { + return UR_RESULT_ERROR_LAYER_NOT_PRESENT; + } + hLoaderConfig->enabledLayers.insert(pLayerName); + return UR_RESULT_SUCCESS; +} } // namespace ur_lib diff --git a/source/loader/ur_lib.hpp b/source/loader/ur_lib.hpp index bd12597475..1f0f23658b 100644 --- a/source/loader/ur_lib.hpp +++ b/source/loader/ur_lib.hpp @@ -15,13 +15,38 @@ #include "ur_api.h" #include "ur_ddi.h" +#include "ur_proxy_layer.hpp" #include "ur_util.hpp" + +#include "validation/ur_validation_layer.hpp" +#if UR_ENABLE_TRACING +#include "tracing/ur_tracing_layer.hpp" +#endif + +#include #include +#include #include +struct ur_loader_config_handle_t_ { + std::set enabledLayers; + std::atomic_uint32_t refCount = 1; + + uint32_t incrementReferenceCount() { + return refCount.fetch_add(1, std::memory_order_acq_rel) + 1; + } + uint32_t decrementReferenceCount() { + return refCount.fetch_sub(1, std::memory_order_acq_rel) - 1; + } + uint32_t getReferenceCount() { + return refCount.load(std::memory_order_acquire); + } + std::set &getEnabledLayerNames() { return enabledLayers; } +}; + namespace ur_lib { /////////////////////////////////////////////////////////////////////////////// -class context_t { +class __urdlllocal context_t { public: #ifdef DYNAMIC_LOAD_LOADER HMODULE loader = nullptr; @@ -32,14 +57,35 @@ class context_t { std::once_flag initOnce; - ur_result_t Init(ur_device_init_flags_t dflags); + ur_result_t Init(ur_device_init_flags_t dflags, + ur_loader_config_handle_t hLoaderConfig); ur_result_t urInit(); ur_dditable_t urDdiTable = {}; + + const std::vector layers = { + &ur_validation_layer::context, +#if UR_ENABLE_TRACING + &ur_tracing_layer::context +#endif + }; + std::string availableLayers; + std::set enabledLayerNames; + + bool layerExists(const std::string &layerName) const; + void parseEnvEnabledLayers(); + void initLayers() const; }; extern context_t *context; - +ur_result_t urLoaderConfigCreate(ur_loader_config_handle_t *phLoaderConfig); +ur_result_t urLoaderConfigRetain(ur_loader_config_handle_t hLoaderConfig); +ur_result_t urLoaderConfigRelease(ur_loader_config_handle_t hLoaderConfig); +ur_result_t urLoaderConfigGetInfo(ur_loader_config_handle_t hLoaderConfig, + ur_loader_config_info_t propName, + size_t propSize, void *pPropValue, + size_t *pPropSizeRet); +ur_result_t urLoaderConfigEnableLayer(ur_loader_config_handle_t hLoaderConfig, + const char *pLayerName); } // namespace ur_lib - #endif /* UR_LOADER_LIB_H */ diff --git a/source/loader/ur_libapi.cpp b/source/loader/ur_libapi.cpp index 3c2fef794a..9c7060fdbe 100644 --- a/source/loader/ur_libapi.cpp +++ b/source/loader/ur_libapi.cpp @@ -15,6 +15,148 @@ extern "C" { +/////////////////////////////////////////////////////////////////////////////// +/// @brief Create a loader config object. +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == phLoaderConfig` +ur_result_t UR_APICALL urLoaderConfigCreate( + ur_loader_config_handle_t * + phLoaderConfig ///< [out] Pointer to handle of loader config object created. + ) try { + return ur_lib::urLoaderConfigCreate(phLoaderConfig); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Get a reference to the loader config object. +/// +/// @details +/// - Get a reference to the loader config handle. Increment its reference +/// count +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hLoaderConfig` +ur_result_t UR_APICALL urLoaderConfigRetain( + ur_loader_config_handle_t + hLoaderConfig ///< [in] loader config handle to retain + ) try { + return ur_lib::urLoaderConfigRetain(hLoaderConfig); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Release config handle. +/// +/// @details +/// - Decrement reference count and destroy the config handle if reference +/// count becomes zero. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hLoaderConfig` +ur_result_t UR_APICALL urLoaderConfigRelease( + ur_loader_config_handle_t hLoaderConfig ///< [in] config handle to release + ) try { + return ur_lib::urLoaderConfigRelease(hLoaderConfig); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Retrieves various information about the loader. +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hLoaderConfig` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `::UR_LOADER_CONFIG_INFO_REFERENCE_COUNT < propName` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION +/// + If `propName` is not supported by the loader. +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `propSize == 0 && pPropValue != NULL` +/// + If `propSize` is less than the real number of bytes needed to return the info. +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `propSize != 0 && pPropValue == NULL` +/// + `pPropValue == NULL && pPropSizeRet == NULL` +/// - ::UR_RESULT_ERROR_INVALID_DEVICE +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY +ur_result_t UR_APICALL urLoaderConfigGetInfo( + ur_loader_config_handle_t + hLoaderConfig, ///< [in] handle of the loader config object + ur_loader_config_info_t propName, ///< [in] type of the info to retrieve + size_t propSize, ///< [in] the number of bytes pointed to by pPropValue. + void * + pPropValue, ///< [out][optional][typename(propName, propSize)] array of bytes holding + ///< the info. + ///< If propSize is not equal to or greater than the real number of bytes + ///< needed to return the info + ///< then the ::UR_RESULT_ERROR_INVALID_SIZE error is returned and + ///< pPropValue is not used. + size_t * + pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of the queried propName. + ) try { + return ur_lib::urLoaderConfigGetInfo(hLoaderConfig, propName, propSize, + pPropValue, pPropSizeRet); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Enable a layer for the specified loader config. +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hLoaderConfig` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == pLayerName` +/// - ::UR_RESULT_ERROR_LAYER_NOT_PRESENT +/// + If layer specified with `pLayerName` can't be found by the loader. +ur_result_t UR_APICALL urLoaderConfigEnableLayer( + ur_loader_config_handle_t + hLoaderConfig, ///< [in] Handle to config object the layer will be enabled for. + const char * + pLayerName ///< [in] Null terminated string containing the name of the layer to + ///< enable. + ) try { + return ur_lib::urLoaderConfigEnableLayer(hLoaderConfig, pLayerName); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Initialize the 'oneAPI' adapter(s) /// @@ -41,12 +183,14 @@ extern "C" { /// + `::UR_DEVICE_INIT_FLAGS_MASK & device_flags` /// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY ur_result_t UR_APICALL urInit( - ur_device_init_flags_t device_flags ///< [in] device initialization flags. + ur_device_init_flags_t device_flags, ///< [in] device initialization flags. ///< must be 0 (default) or a combination of ::ur_device_init_flag_t. + ur_loader_config_handle_t + hLoaderConfig ///< [in][optional] Handle of loader config handle. ) try { static ur_result_t result = UR_RESULT_SUCCESS; - std::call_once(ur_lib::context->initOnce, [device_flags]() { - result = ur_lib::context->Init(device_flags); + std::call_once(ur_lib::context->initOnce, [device_flags, hLoaderConfig]() { + result = ur_lib::context->Init(device_flags, hLoaderConfig); }); if (UR_RESULT_SUCCESS != result) { @@ -58,7 +202,7 @@ ur_result_t UR_APICALL urInit( return UR_RESULT_ERROR_UNINITIALIZED; } - return pfnInit(device_flags); + return pfnInit(device_flags, hLoaderConfig); } catch (...) { return exceptionToResult(std::current_exception()); } @@ -88,7 +232,219 @@ ur_result_t UR_APICALL urTearDown( } /////////////////////////////////////////////////////////////////////////////// -/// @brief Retrieves all available platforms +/// @brief Retrieves all available adapters +/// +/// @details +/// - Adapter implementations must return exactly one adapter handle from +/// this entry point. +/// - The loader may return more than one adapter handle when there are +/// multiple available. +/// - Each returned adapter has its reference count incremented and should +/// be released with a subsequent call to ::urAdapterRelease. +/// - Adapters may perform adapter-specific state initialization when the +/// first reference to them is taken. +/// - An application may call this entry point multiple times to acquire +/// multiple references to the adapter handle(s). +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_SIZE +ur_result_t UR_APICALL urAdapterGet( + uint32_t + NumEntries, ///< [in] the number of adapters to be added to phAdapters. + ///< If phAdapters is not NULL, then NumEntries should be greater than + ///< zero, otherwise ::UR_RESULT_ERROR_INVALID_SIZE, + ///< will be returned. + ur_adapter_handle_t * + phAdapters, ///< [out][optional][range(0, NumEntries)] array of handle of adapters. + ///< If NumEntries is less than the number of adapters available, then + ///< ::urAdapterGet shall only retrieve that number of platforms. + uint32_t * + pNumAdapters ///< [out][optional] returns the total number of adapters available. + ) try { + auto pfnAdapterGet = ur_lib::context->urDdiTable.Global.pfnAdapterGet; + if (nullptr == pfnAdapterGet) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + return pfnAdapterGet(NumEntries, phAdapters, pNumAdapters); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Releases the adapter handle reference indicating end of its usage +/// +/// @details +/// - When the reference count of the adapter reaches zero, the adapter may +/// perform adapter-specififc resource teardown +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hAdapter` +ur_result_t UR_APICALL urAdapterRelease( + ur_adapter_handle_t hAdapter ///< [in] Adapter handle to release + ) try { + auto pfnAdapterRelease = + ur_lib::context->urDdiTable.Global.pfnAdapterRelease; + if (nullptr == pfnAdapterRelease) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + return pfnAdapterRelease(hAdapter); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Get a reference to the adapter handle. +/// +/// @details +/// - Get a reference to the adapter handle. Increment its reference count +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hAdapter` +ur_result_t UR_APICALL urAdapterRetain( + ur_adapter_handle_t hAdapter ///< [in] Adapter handle to retain + ) try { + auto pfnAdapterRetain = ur_lib::context->urDdiTable.Global.pfnAdapterRetain; + if (nullptr == pfnAdapterRetain) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + return pfnAdapterRetain(hAdapter); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Get the last adapter specific error. +/// +/// @details +/// To be used after another entry-point has returned +/// ::UR_RESULT_ERROR_ADAPTER_SPECIFIC in order to retrieve a message describing +/// the circumstances of the underlying driver error and the error code +/// returned by the failed driver entry-point. +/// +/// * Implementations *must* store the message and error code in thread-local +/// storage prior to returning ::UR_RESULT_ERROR_ADAPTER_SPECIFIC. +/// +/// * The message and error code storage is will only be valid if a previously +/// called entry-point returned ::UR_RESULT_ERROR_ADAPTER_SPECIFIC. +/// +/// * The memory pointed to by the C string returned in `ppMessage` is owned by +/// the adapter and *must* be null terminated. +/// +/// * The application *may* call this function from simultaneous threads. +/// +/// * The implementation of this function *should* be lock-free. +/// +/// Example usage: +/// +/// ```cpp +/// if (::urQueueCreate(hContext, hDevice, nullptr, &hQueue) == +/// ::UR_RESULT_ERROR_ADAPTER_SPECIFIC) { +/// const char* pMessage; +/// int32_t error; +/// ::urAdapterGetLastError(hAdapter, &pMessage, &error); +/// } +/// ``` +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hAdapter` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == ppMessage` +/// + `NULL == pError` +ur_result_t UR_APICALL urAdapterGetLastError( + ur_adapter_handle_t hAdapter, ///< [in] handle of the adapter instance + const char ** + ppMessage, ///< [out] pointer to a C string where the adapter specific error message + ///< will be stored. + int32_t * + pError ///< [out] pointer to an integer where the adapter specific error code will + ///< be stored. + ) try { + auto pfnAdapterGetLastError = + ur_lib::context->urDdiTable.Global.pfnAdapterGetLastError; + if (nullptr == pfnAdapterGetLastError) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + return pfnAdapterGetLastError(hAdapter, ppMessage, pError); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Retrieves information about the adapter +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hAdapter` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `::UR_ADAPTER_INFO_REFERENCE_COUNT < propName` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION +/// + If `propName` is not supported by the adapter. +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `propSize == 0 && pPropValue != NULL` +/// + If `propSize` is less than the real number of bytes needed to return the info. +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `propSize != 0 && pPropValue == NULL` +/// + `pPropValue == NULL && pPropSizeRet == NULL` +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY +ur_result_t UR_APICALL urAdapterGetInfo( + ur_adapter_handle_t hAdapter, ///< [in] handle of the adapter + ur_adapter_info_t propName, ///< [in] type of the info to retrieve + size_t propSize, ///< [in] the number of bytes pointed to by pPropValue. + void * + pPropValue, ///< [out][optional][typename(propName, propSize)] array of bytes holding + ///< the info. + ///< If Size is not equal to or greater to the real number of bytes needed + ///< to return the info then the ::UR_RESULT_ERROR_INVALID_SIZE error is + ///< returned and pPropValue is not used. + size_t * + pPropSizeRet ///< [out][optional] pointer to the actual number of bytes being queried by pPropValue. + ) try { + auto pfnAdapterGetInfo = + ur_lib::context->urDdiTable.Global.pfnAdapterGetInfo; + if (nullptr == pfnAdapterGetInfo) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + return pfnAdapterGetInfo(hAdapter, propName, propSize, pPropValue, + pPropSizeRet); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Retrieves all available platforms for the given adapters /// /// @details /// - Multiple calls to this function will return identical platforms @@ -105,8 +461,13 @@ ur_result_t UR_APICALL urTearDown( /// - ::UR_RESULT_ERROR_UNINITIALIZED /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == phAdapters` /// - ::UR_RESULT_ERROR_INVALID_SIZE ur_result_t UR_APICALL urPlatformGet( + ur_adapter_handle_t * + phAdapters, ///< [in][range(0, NumAdapters)] array of adapters to query for platforms. + uint32_t NumAdapters, ///< [in] number of adapters pointed to by phAdapters uint32_t NumEntries, ///< [in] the number of platforms to be added to phPlatforms. ///< If phPlatforms is not NULL, then NumEntries should be greater than @@ -124,7 +485,8 @@ ur_result_t UR_APICALL urPlatformGet( return UR_RESULT_ERROR_UNINITIALIZED; } - return pfnGet(NumEntries, phPlatforms, pNumPlatforms); + return pfnGet(phAdapters, NumAdapters, NumEntries, phPlatforms, + pNumPlatforms); } catch (...) { return exceptionToResult(std::current_exception()); } @@ -235,6 +597,8 @@ ur_result_t UR_APICALL urPlatformGetApiVersion( /// + `NULL == hPlatform` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativePlatform` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urPlatformGetNativeHandle( ur_platform_handle_t hPlatform, ///< [in] handle of the platform. ur_native_handle_t * @@ -265,13 +629,13 @@ ur_result_t UR_APICALL urPlatformGetNativeHandle( /// - ::UR_RESULT_ERROR_UNINITIALIZED /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC -/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativePlatform` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phPlatform` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urPlatformCreateWithNativeHandle( ur_native_handle_t - hNativePlatform, ///< [in] the native handle of the platform. + hNativePlatform, ///< [in][nocheck] the native handle of the platform. const ur_platform_native_properties_t * pProperties, ///< [in][optional] pointer to native platform properties struct. ur_platform_handle_t * @@ -332,68 +696,6 @@ ur_result_t UR_APICALL urPlatformGetBackendOption( return exceptionToResult(std::current_exception()); } -/////////////////////////////////////////////////////////////////////////////// -/// @brief Get the last adapter specific error. -/// -/// @details -/// To be used after another entry-point has returned -/// ::UR_RESULT_ERROR_ADAPTER_SPECIFIC in order to retrieve a message describing -/// the circumstances of the underlying driver error and the error code -/// returned by the failed driver entry-point. -/// -/// * Implementations *must* store the message and error code in thread-local -/// storage prior to returning ::UR_RESULT_ERROR_ADAPTER_SPECIFIC. -/// -/// * The message and error code storage is will only be valid if a previously -/// called entry-point returned ::UR_RESULT_ERROR_ADAPTER_SPECIFIC. -/// -/// * The memory pointed to by the C string returned in `ppMessage` is owned by -/// the adapter and *must* be null terminated. -/// -/// * The application *may* call this function from simultaneous threads. -/// -/// * The implementation of this function *should* be lock-free. -/// -/// Example usage: -/// -/// ```cpp -/// if (::urQueueCreate(hContext, hDevice, nullptr, &hQueue) == -/// ::UR_RESULT_ERROR_ADAPTER_SPECIFIC) { -/// const char* pMessage; -/// int32_t error; -/// ::urPlatformGetLastError(hPlatform, &pMessage, &error); -/// } -/// ``` -/// -/// @returns -/// - ::UR_RESULT_SUCCESS -/// - ::UR_RESULT_ERROR_UNINITIALIZED -/// - ::UR_RESULT_ERROR_DEVICE_LOST -/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC -/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hPlatform` -/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER -/// + `NULL == ppMessage` -/// + `NULL == pError` -ur_result_t UR_APICALL urPlatformGetLastError( - ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance - const char ** - ppMessage, ///< [out] pointer to a C string where the adapter specific error message - ///< will be stored. - int32_t * - pError ///< [out] pointer to an integer where the adapter specific error code will - ///< be stored. - ) try { - auto pfnGetLastError = ur_lib::context->urDdiTable.Platform.pfnGetLastError; - if (nullptr == pfnGetLastError) { - return UR_RESULT_ERROR_UNINITIALIZED; - } - - return pfnGetLastError(hPlatform, ppMessage, pError); -} catch (...) { - return exceptionToResult(std::current_exception()); -} - /////////////////////////////////////////////////////////////////////////////// /// @brief Retrieves devices within a platform /// @@ -698,6 +1000,8 @@ ur_result_t UR_APICALL urDeviceSelectBinary( /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeDevice` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urDeviceGetNativeHandle( ur_device_handle_t hDevice, ///< [in] handle of the device. ur_native_handle_t @@ -729,13 +1033,15 @@ ur_result_t UR_APICALL urDeviceGetNativeHandle( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeDevice` /// + `NULL == hPlatform` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phDevice` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urDeviceCreateWithNativeHandle( - ur_native_handle_t hNativeDevice, ///< [in] the native handle of the device. - ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance + ur_native_handle_t + hNativeDevice, ///< [in][nocheck] the native handle of the device. + ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance const ur_device_native_properties_t * pProperties, ///< [in][optional] pointer to native device properties struct. ur_device_handle_t @@ -984,6 +1290,8 @@ ur_result_t UR_APICALL urContextGetInfo( /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeContext` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urContextGetNativeHandle( ur_context_handle_t hContext, ///< [in] handle of the context. ur_native_handle_t * @@ -1014,14 +1322,14 @@ ur_result_t UR_APICALL urContextGetNativeHandle( /// - ::UR_RESULT_ERROR_UNINITIALIZED /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC -/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phDevices` /// + `NULL == phContext` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urContextCreateWithNativeHandle( ur_native_handle_t - hNativeContext, ///< [in] the native handle of the context. + hNativeContext, ///< [in][nocheck] the native handle of the context. uint32_t numDevices, ///< [in] number of devices associated with the context const ur_device_handle_t * phDevices, ///< [in][range(0, numDevices)] list of devices associated with the context @@ -1317,6 +1625,8 @@ ur_result_t UR_APICALL urMemBufferPartition( /// + `NULL == hMem` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeMem` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urMemGetNativeHandle( ur_mem_handle_t hMem, ///< [in] handle of the mem. ur_native_handle_t @@ -1347,13 +1657,15 @@ ur_result_t UR_APICALL urMemGetNativeHandle( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeMem` /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phMem` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( - ur_native_handle_t hNativeMem, ///< [in] the native handle to the memory. - ur_context_handle_t hContext, ///< [in] handle of the context object. + ur_native_handle_t + hNativeMem, ///< [in][nocheck] the native handle to the memory. + ur_context_handle_t hContext, ///< [in] handle of the context object. const ur_mem_native_properties_t * pProperties, ///< [in][optional] pointer to native memory creation properties. ur_mem_handle_t @@ -1385,15 +1697,17 @@ ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeMem` /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == pImageFormat` /// + `NULL == pImageDesc` /// + `NULL == phMem` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urMemImageCreateWithNativeHandle( - ur_native_handle_t hNativeMem, ///< [in] the native handle to the memory. - ur_context_handle_t hContext, ///< [in] handle of the context object. + ur_native_handle_t + hNativeMem, ///< [in][nocheck] the native handle to the memory. + ur_context_handle_t hContext, ///< [in] handle of the context object. const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification. const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description. @@ -1488,6 +1802,17 @@ ur_result_t UR_APICALL urMemGetInfo( /// + `NULL == hMemory` /// - ::UR_RESULT_ERROR_INVALID_ENUMERATION /// + `::UR_IMAGE_INFO_DEPTH < propName` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION +/// + If `propName` is not supported by the adapter. +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `propSize == 0 && pPropValue != NULL` +/// + If `propSize` is less than the real number of bytes needed to return the info. +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `propSize != 0 && pPropValue == NULL` +/// + `pPropValue == NULL && pPropSizeRet == NULL` +/// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY ur_result_t UR_APICALL urMemImageGetInfo( ur_mem_handle_t hMemory, ///< [in] handle to the image object being queried. ur_image_info_t propName, ///< [in] type of image info to retrieve. @@ -1693,6 +2018,8 @@ ur_result_t UR_APICALL urSamplerGetInfo( /// + `NULL == hSampler` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeSampler` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urSamplerGetNativeHandle( ur_sampler_handle_t hSampler, ///< [in] handle of the sampler. ur_native_handle_t * @@ -1724,13 +2051,14 @@ ur_result_t UR_APICALL urSamplerGetNativeHandle( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeSampler` /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phSampler` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urSamplerCreateWithNativeHandle( ur_native_handle_t - hNativeSampler, ///< [in] the native handle of the sampler. + hNativeSampler, ///< [in][nocheck] the native handle of the sampler. ur_context_handle_t hContext, ///< [in] handle of the context object const ur_sampler_native_properties_t * pProperties, ///< [in][optional] pointer to native sampler properties struct. @@ -2134,6 +2462,18 @@ ur_result_t UR_APICALL urUSMPoolGetInfo( /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_ENUMERATION /// + `::UR_VIRTUAL_MEM_GRANULARITY_INFO_RECOMMENDED < propName` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION +/// + If `propName` is not supported by the adapter. +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `propSize == 0 && pPropValue != NULL` +/// + If `propSize` is less than the real number of bytes needed to return the info. +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `propSize != 0 && pPropValue == NULL` +/// + `pPropValue == NULL && pPropSizeRet == NULL` +/// - ::UR_RESULT_ERROR_INVALID_DEVICE +/// - ::UR_RESULT_ERROR_INVALID_CONTEXT +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY ur_result_t UR_APICALL urVirtualMemGranularityGetInfo( ur_context_handle_t hContext, ///< [in] handle of the context object. ur_device_handle_t @@ -2312,7 +2652,7 @@ ur_result_t UR_APICALL urVirtualMemSetAccess( ur_context_handle_t hContext, ///< [in] handle to the context object. const void *pStart, ///< [in] pointer to the start of the virtual memory range. - size_t size, ///< [in] size in bytes of the virutal memory range. + size_t size, ///< [in] size in bytes of the virtual memory range. ur_virtual_mem_access_flags_t flags ///< [in] access flags to set for the mapped virtual memory range. ) try { @@ -2380,11 +2720,13 @@ ur_result_t UR_APICALL urVirtualMemGetInfo( /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phPhysicalMem` +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + If size is not a multiple of ::UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM. ur_result_t UR_APICALL urPhysicalMemCreate( ur_context_handle_t hContext, ///< [in] handle of the context object. ur_device_handle_t hDevice, ///< [in] handle of the device object. size_t - size, ///< [in] size in bytes of phyisical memory to allocate, must be a multiple + size, ///< [in] size in bytes of physical memory to allocate, must be a multiple ///< of ::UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM. const ur_physical_mem_properties_t * pProperties, ///< [in][optional] pointer to physical memory creation properties. @@ -2551,7 +2893,7 @@ ur_result_t UR_APICALL urProgramCreateWithBinary( /// /// @details /// - The application may call this function from simultaneous threads. -/// - Following a succesful call to this entry point, the program passed +/// - Following a successful call to this entry point, the program passed /// will contain a binary of the ::UR_PROGRAM_BINARY_TYPE_EXECUTABLE type /// for each device in `hContext`. /// @@ -2592,9 +2934,9 @@ ur_result_t UR_APICALL urProgramBuild( /// /// @details /// - The application may call this function from simultaneous threads. -/// - Following a succesful call to this entry point `hProgram` will contain -/// a binary of the ::UR_PROGRAM_BINARY_TYPE_COMPILED_OBJECT type for each -/// device in `hContext`. +/// - Following a successful call to this entry point `hProgram` will +/// contain a binary of the ::UR_PROGRAM_BINARY_TYPE_COMPILED_OBJECT type +/// for each device in `hContext`. /// /// @remarks /// _Analogues_ @@ -2634,8 +2976,8 @@ ur_result_t UR_APICALL urProgramCompile( /// /// @details /// - The application may call this function from simultaneous threads. -/// - Following a succesful call to this entry point the program returned in -/// `phProgram` will contain a binary of the +/// - Following a successful call to this entry point the program returned +/// in `phProgram` will contain a binary of the /// ::UR_PROGRAM_BINARY_TYPE_EXECUTABLE type for each device in /// `hContext`. /// @@ -2953,6 +3295,8 @@ ur_result_t UR_APICALL urProgramSetSpecializationConstants( /// + `NULL == hProgram` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeProgram` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urProgramGetNativeHandle( ur_program_handle_t hProgram, ///< [in] handle of the program. ur_native_handle_t * @@ -2984,13 +3328,14 @@ ur_result_t UR_APICALL urProgramGetNativeHandle( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeProgram` /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phProgram` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urProgramCreateWithNativeHandle( ur_native_handle_t - hNativeProgram, ///< [in] the native handle of the program. + hNativeProgram, ///< [in][nocheck] the native handle of the program. ur_context_handle_t hContext, ///< [in] handle of the context instance const ur_program_native_properties_t * pProperties, ///< [in][optional] pointer to native program properties struct. @@ -3534,6 +3879,8 @@ ur_result_t UR_APICALL urKernelSetSpecializationConstants( /// + `NULL == hKernel` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeKernel` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urKernelGetNativeHandle( ur_kernel_handle_t hKernel, ///< [in] handle of the kernel. ur_native_handle_t @@ -3565,14 +3912,16 @@ ur_result_t UR_APICALL urKernelGetNativeHandle( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeKernel` /// + `NULL == hContext` /// + `NULL == hProgram` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phKernel` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urKernelCreateWithNativeHandle( - ur_native_handle_t hNativeKernel, ///< [in] the native handle of the kernel. - ur_context_handle_t hContext, ///< [in] handle of the context object + ur_native_handle_t + hNativeKernel, ///< [in][nocheck] the native handle of the kernel. + ur_context_handle_t hContext, ///< [in] handle of the context object ur_program_handle_t hProgram, ///< [in] handle of the program associated with the kernel const ur_kernel_native_properties_t * @@ -3777,6 +4126,8 @@ ur_result_t UR_APICALL urQueueRelease( /// + `NULL == hQueue` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeQueue` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urQueueGetNativeHandle( ur_queue_handle_t hQueue, ///< [in] handle of the queue. ur_queue_native_desc_t @@ -3810,15 +4161,17 @@ ur_result_t UR_APICALL urQueueGetNativeHandle( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeQueue` /// + `NULL == hContext` /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phQueue` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urQueueCreateWithNativeHandle( - ur_native_handle_t hNativeQueue, ///< [in] the native handle of the queue. - ur_context_handle_t hContext, ///< [in] handle of the context object - ur_device_handle_t hDevice, ///< [in] handle of the device object + ur_native_handle_t + hNativeQueue, ///< [in][nocheck] the native handle of the queue. + ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_queue_native_properties_t * pProperties, ///< [in][optional] pointer to native queue properties struct ur_queue_handle_t @@ -4120,6 +4473,8 @@ ur_result_t UR_APICALL urEventRelease( /// + `NULL == hEvent` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeEvent` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urEventGetNativeHandle( ur_event_handle_t hEvent, ///< [in] handle of the event. ur_native_handle_t @@ -4151,13 +4506,15 @@ ur_result_t UR_APICALL urEventGetNativeHandle( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeEvent` /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phEvent` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urEventCreateWithNativeHandle( - ur_native_handle_t hNativeEvent, ///< [in] the native handle of the event. - ur_context_handle_t hContext, ///< [in] handle of the context object + ur_native_handle_t + hNativeEvent, ///< [in][nocheck] the native handle of the event. + ur_context_handle_t hContext, ///< [in] handle of the context object const ur_event_native_properties_t * pProperties, ///< [in][optional] pointer to native event properties struct ur_event_handle_t @@ -5828,11 +6185,13 @@ ur_result_t UR_APICALL urUSMPitchedAllocExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hImage` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE ur_result_t UR_APICALL urBindlessImagesUnsampledImageHandleDestroyExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_handle_t hImage ///< [in] pointer to handle of image object to destroy ) try { @@ -5843,7 +6202,7 @@ ur_result_t UR_APICALL urBindlessImagesUnsampledImageHandleDestroyExp( return UR_RESULT_ERROR_UNINITIALIZED; } - return pfnUnsampledImageHandleDestroyExp(hContext, hImage); + return pfnUnsampledImageHandleDestroyExp(hContext, hDevice, hImage); } catch (...) { return exceptionToResult(std::current_exception()); } @@ -5862,11 +6221,13 @@ ur_result_t UR_APICALL urBindlessImagesUnsampledImageHandleDestroyExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hImage` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE ur_result_t UR_APICALL urBindlessImagesSampledImageHandleDestroyExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_handle_t hImage ///< [in] pointer to handle of image object to destroy ) try { @@ -5877,7 +6238,7 @@ ur_result_t UR_APICALL urBindlessImagesSampledImageHandleDestroyExp( return UR_RESULT_ERROR_UNINITIALIZED; } - return pfnSampledImageHandleDestroyExp(hContext, hImage); + return pfnSampledImageHandleDestroyExp(hContext, hDevice, hImage); } catch (...) { return exceptionToResult(std::current_exception()); } @@ -5897,6 +6258,7 @@ ur_result_t UR_APICALL urBindlessImagesSampledImageHandleDestroyExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == pImageFormat` /// + `NULL == pImageDesc` @@ -5909,6 +6271,7 @@ ur_result_t UR_APICALL urBindlessImagesSampledImageHandleDestroyExp( /// - ::UR_RESULT_ERROR_INVALID_OPERATION ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description @@ -5921,7 +6284,8 @@ ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( return UR_RESULT_ERROR_UNINITIALIZED; } - return pfnImageAllocateExp(hContext, pImageFormat, pImageDesc, phImageMem); + return pfnImageAllocateExp(hContext, hDevice, pImageFormat, pImageDesc, + phImageMem); } catch (...) { return exceptionToResult(std::current_exception()); } @@ -5940,11 +6304,13 @@ ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hImageMem` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE ur_result_t UR_APICALL urBindlessImagesImageFreeExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem ///< [in] handle of image memory to be freed ) try { @@ -5954,7 +6320,7 @@ ur_result_t UR_APICALL urBindlessImagesImageFreeExp( return UR_RESULT_ERROR_UNINITIALIZED; } - return pfnImageFreeExp(hContext, hImageMem); + return pfnImageFreeExp(hContext, hDevice, hImageMem); } catch (...) { return exceptionToResult(std::current_exception()); } @@ -5973,6 +6339,7 @@ ur_result_t UR_APICALL urBindlessImagesImageFreeExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hImageMem` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == pImageFormat` @@ -5987,6 +6354,7 @@ ur_result_t UR_APICALL urBindlessImagesImageFreeExp( /// - ::UR_RESULT_ERROR_INVALID_OPERATION ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] handle to memory from which to create the image const ur_image_format_t @@ -6003,8 +6371,8 @@ ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( return UR_RESULT_ERROR_UNINITIALIZED; } - return pfnUnsampledImageCreateExp(hContext, hImageMem, pImageFormat, - pImageDesc, phMem, phImage); + return pfnUnsampledImageCreateExp(hContext, hDevice, hImageMem, + pImageFormat, pImageDesc, phMem, phImage); } catch (...) { return exceptionToResult(std::current_exception()); } @@ -6023,6 +6391,7 @@ ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hImageMem` /// + `NULL == hSampler` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER @@ -6039,6 +6408,7 @@ ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( /// - ::UR_RESULT_ERROR_INVALID_OPERATION ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] handle to memory from which to create the image const ur_image_format_t @@ -6055,7 +6425,7 @@ ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( return UR_RESULT_ERROR_UNINITIALIZED; } - return pfnSampledImageCreateExp(hContext, hImageMem, pImageFormat, + return pfnSampledImageCreateExp(hContext, hDevice, hImageMem, pImageFormat, pImageDesc, hSampler, phMem, phImage); } catch (...) { return exceptionToResult(std::current_exception()); @@ -6077,7 +6447,7 @@ ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hContext` +/// + `NULL == hQueue` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == pDst` /// + `NULL == pSrc` @@ -6085,21 +6455,33 @@ ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( /// + `NULL == pImageDesc` /// - ::UR_RESULT_ERROR_INVALID_ENUMERATION /// + `::UR_EXP_IMAGE_COPY_FLAGS_MASK & imageCopyFlags` -/// - ::UR_RESULT_ERROR_INVALID_CONTEXT +/// - ::UR_RESULT_ERROR_INVALID_QUEUE /// - ::UR_RESULT_ERROR_INVALID_VALUE /// - ::UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR /// + `pImageDesc && UR_MEM_TYPE_IMAGE1D_BUFFER < pImageDesc->type` /// - ::UR_RESULT_ERROR_INVALID_IMAGE_SIZE /// - ::UR_RESULT_ERROR_INVALID_OPERATION ur_result_t UR_APICALL urBindlessImagesImageCopyExp( - ur_context_handle_t hContext, ///< [in] handle of the context object - void *pDst, ///< [in] location the data will be copied to - void *pSrc, ///< [in] location the data will be copied from + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + void *pDst, ///< [in] location the data will be copied to + void *pSrc, ///< [in] location the data will be copied from const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description ur_exp_image_copy_flags_t imageCopyFlags, ///< [in] flags describing copy direction e.g. H2D or D2H + ur_rect_offset_t + srcOffset, ///< [in] defines the (x,y,z) source offset in pixels in the 1D, 2D, or 3D + ///< image + ur_rect_offset_t + dstOffset, ///< [in] defines the (x,y,z) destination offset in pixels in the 1D, 2D, + ///< or 3D image + ur_rect_region_t + copyExtent, ///< [in] defines the (width, height, depth) in pixels of the 1D, 2D, or 3D + ///< region to copy + ur_rect_region_t + hostExtent, ///< [in] defines the (width, height, depth) in pixels of the 1D, 2D, or 3D + ///< region on the host uint32_t numEventsInWaitList, ///< [in] size of the event wait list const ur_event_handle_t * phEventWaitList, ///< [in][optional][range(0, numEventsInWaitList)] pointer to a list of @@ -6117,8 +6499,9 @@ ur_result_t UR_APICALL urBindlessImagesImageCopyExp( return UR_RESULT_ERROR_UNINITIALIZED; } - return pfnImageCopyExp(hContext, pDst, pSrc, pImageFormat, pImageDesc, - imageCopyFlags, numEventsInWaitList, phEventWaitList, + return pfnImageCopyExp(hQueue, pDst, pSrc, pImageFormat, pImageDesc, + imageCopyFlags, srcOffset, dstOffset, copyExtent, + hostExtent, numEventsInWaitList, phEventWaitList, phEvent); } catch (...) { return exceptionToResult(std::current_exception()); @@ -6176,6 +6559,7 @@ ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hImageMem` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phImageMem` @@ -6183,6 +6567,7 @@ ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( /// - ::UR_RESULT_ERROR_INVALID_VALUE ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] memory handle to the mipmap image uint32_t mipmapLevel, ///< [in] requested level of the mipmap @@ -6195,7 +6580,8 @@ ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( return UR_RESULT_ERROR_UNINITIALIZED; } - return pfnMipmapGetLevelExp(hContext, hImageMem, mipmapLevel, phImageMem); + return pfnMipmapGetLevelExp(hContext, hDevice, hImageMem, mipmapLevel, + phImageMem); } catch (...) { return exceptionToResult(std::current_exception()); } @@ -6214,11 +6600,13 @@ ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hMem` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hMem ///< [in] handle of image memory to be freed ) try { auto pfnMipmapFreeExp = @@ -6227,7 +6615,7 @@ ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( return UR_RESULT_ERROR_UNINITIALIZED; } - return pfnMipmapFreeExp(hContext, hMem); + return pfnMipmapFreeExp(hContext, hDevice, hMem); } catch (...) { return exceptionToResult(std::current_exception()); } @@ -6246,15 +6634,19 @@ ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == pInteropMemDesc` /// + `NULL == phInteropMem` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE /// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object size_t size, ///< [in] size of the external memory - uint32_t fileDescriptor, ///< [in] the file descriptor + ur_exp_interop_mem_desc_t + *pInteropMemDesc, ///< [in] the interop memory descriptor ur_exp_interop_mem_handle_t *phInteropMem ///< [out] interop memory handle to the external memory ) try { @@ -6264,7 +6656,8 @@ ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( return UR_RESULT_ERROR_UNINITIALIZED; } - return pfnImportOpaqueFDExp(hContext, size, fileDescriptor, phInteropMem); + return pfnImportOpaqueFDExp(hContext, hDevice, size, pInteropMemDesc, + phInteropMem); } catch (...) { return exceptionToResult(std::current_exception()); } @@ -6279,6 +6672,7 @@ ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hInteropMem` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == pImageFormat` @@ -6293,12 +6687,13 @@ ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( /// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description ur_exp_interop_mem_handle_t hInteropMem, ///< [in] interop memory handle to the external memory - ur_exp_image_handle_t * + ur_exp_image_mem_handle_t * phImageMem ///< [out] image memory handle to the externally allocated memory ) try { auto pfnMapExternalArrayExp = @@ -6307,7 +6702,7 @@ ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( return UR_RESULT_ERROR_UNINITIALIZED; } - return pfnMapExternalArrayExp(hContext, pImageFormat, pImageDesc, + return pfnMapExternalArrayExp(hContext, hDevice, pImageFormat, pImageDesc, hInteropMem, phImageMem); } catch (...) { return exceptionToResult(std::current_exception()); @@ -6327,11 +6722,13 @@ ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hInteropMem` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_interop_mem_handle_t hInteropMem ///< [in] handle of interop memory to be freed ) try { @@ -6341,7 +6738,7 @@ ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( return UR_RESULT_ERROR_UNINITIALIZED; } - return pfnReleaseInteropExp(hContext, hInteropMem); + return pfnReleaseInteropExp(hContext, hDevice, hInteropMem); } catch (...) { return exceptionToResult(std::current_exception()); } @@ -6360,15 +6757,19 @@ ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER -/// + `NULL == phInteropSemaphoreHandle` +/// + `NULL == pInteropSemaphoreDesc` +/// + `NULL == phInteropSemaphore` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object - uint32_t fileDescriptor, ///< [in] the file descriptor + ur_device_handle_t hDevice, ///< [in] handle of the device object + ur_exp_interop_semaphore_desc_t + *pInteropSemaphoreDesc, ///< [in] the interop semaphore descriptor ur_exp_interop_semaphore_handle_t * - phInteropSemaphoreHandle ///< [out] interop semaphore handle to the external semaphore + phInteropSemaphore ///< [out] interop semaphore handle to the external semaphore ) try { auto pfnImportExternalSemaphoreOpaqueFDExp = ur_lib::context->urDdiTable.BindlessImagesExp @@ -6377,8 +6778,8 @@ ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreOpaqueFDExp( return UR_RESULT_ERROR_UNINITIALIZED; } - return pfnImportExternalSemaphoreOpaqueFDExp(hContext, fileDescriptor, - phInteropSemaphoreHandle); + return pfnImportExternalSemaphoreOpaqueFDExp( + hContext, hDevice, pInteropSemaphoreDesc, phInteropSemaphore); } catch (...) { return exceptionToResult(std::current_exception()); } @@ -6397,11 +6798,13 @@ ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreOpaqueFDExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hInteropSemaphore` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE ur_result_t UR_APICALL urBindlessImagesDestroyExternalSemaphoreExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_interop_semaphore_handle_t hInteropSemaphore ///< [in] handle of interop semaphore to be destroyed ) try { @@ -6412,7 +6815,7 @@ ur_result_t UR_APICALL urBindlessImagesDestroyExternalSemaphoreExp( return UR_RESULT_ERROR_UNINITIALIZED; } - return pfnDestroyExternalSemaphoreExp(hContext, hInteropSemaphore); + return pfnDestroyExternalSemaphoreExp(hContext, hDevice, hInteropSemaphore); } catch (...) { return exceptionToResult(std::current_exception()); } diff --git a/source/ur_api.cpp b/source/ur_api.cpp index b13dfdb44c..c8362e490c 100644 --- a/source/ur_api.cpp +++ b/source/ur_api.cpp @@ -12,6 +12,142 @@ */ #include "ur_api.h" +/////////////////////////////////////////////////////////////////////////////// +/// @brief Create a loader config object. +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == phLoaderConfig` +ur_result_t UR_APICALL urLoaderConfigCreate( + ur_loader_config_handle_t * + phLoaderConfig ///< [out] Pointer to handle of loader config object created. +) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Get a reference to the loader config object. +/// +/// @details +/// - Get a reference to the loader config handle. Increment its reference +/// count +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hLoaderConfig` +ur_result_t UR_APICALL urLoaderConfigRetain( + ur_loader_config_handle_t + hLoaderConfig ///< [in] loader config handle to retain +) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Release config handle. +/// +/// @details +/// - Decrement reference count and destroy the config handle if reference +/// count becomes zero. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hLoaderConfig` +ur_result_t UR_APICALL urLoaderConfigRelease( + ur_loader_config_handle_t hLoaderConfig ///< [in] config handle to release +) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Retrieves various information about the loader. +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hLoaderConfig` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `::UR_LOADER_CONFIG_INFO_REFERENCE_COUNT < propName` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION +/// + If `propName` is not supported by the loader. +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `propSize == 0 && pPropValue != NULL` +/// + If `propSize` is less than the real number of bytes needed to return the info. +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `propSize != 0 && pPropValue == NULL` +/// + `pPropValue == NULL && pPropSizeRet == NULL` +/// - ::UR_RESULT_ERROR_INVALID_DEVICE +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY +ur_result_t UR_APICALL urLoaderConfigGetInfo( + ur_loader_config_handle_t + hLoaderConfig, ///< [in] handle of the loader config object + ur_loader_config_info_t propName, ///< [in] type of the info to retrieve + size_t propSize, ///< [in] the number of bytes pointed to by pPropValue. + void * + pPropValue, ///< [out][optional][typename(propName, propSize)] array of bytes holding + ///< the info. + ///< If propSize is not equal to or greater than the real number of bytes + ///< needed to return the info + ///< then the ::UR_RESULT_ERROR_INVALID_SIZE error is returned and + ///< pPropValue is not used. + size_t * + pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of the queried propName. +) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Enable a layer for the specified loader config. +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hLoaderConfig` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == pLayerName` +/// - ::UR_RESULT_ERROR_LAYER_NOT_PRESENT +/// + If layer specified with `pLayerName` can't be found by the loader. +ur_result_t UR_APICALL urLoaderConfigEnableLayer( + ur_loader_config_handle_t + hLoaderConfig, ///< [in] Handle to config object the layer will be enabled for. + const char * + pLayerName ///< [in] Null terminated string containing the name of the layer to + ///< enable. +) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Initialize the 'oneAPI' adapter(s) /// @@ -38,8 +174,10 @@ /// + `::UR_DEVICE_INIT_FLAGS_MASK & device_flags` /// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY ur_result_t UR_APICALL urInit( - ur_device_init_flags_t device_flags ///< [in] device initialization flags. + ur_device_init_flags_t device_flags, ///< [in] device initialization flags. ///< must be 0 (default) or a combination of ::ur_device_init_flag_t. + ur_loader_config_handle_t + hLoaderConfig ///< [in][optional] Handle of loader config handle. ) { ur_result_t result = UR_RESULT_SUCCESS; return result; @@ -64,7 +202,185 @@ ur_result_t UR_APICALL urTearDown( } /////////////////////////////////////////////////////////////////////////////// -/// @brief Retrieves all available platforms +/// @brief Retrieves all available adapters +/// +/// @details +/// - Adapter implementations must return exactly one adapter handle from +/// this entry point. +/// - The loader may return more than one adapter handle when there are +/// multiple available. +/// - Each returned adapter has its reference count incremented and should +/// be released with a subsequent call to ::urAdapterRelease. +/// - Adapters may perform adapter-specific state initialization when the +/// first reference to them is taken. +/// - An application may call this entry point multiple times to acquire +/// multiple references to the adapter handle(s). +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_SIZE +ur_result_t UR_APICALL urAdapterGet( + uint32_t + NumEntries, ///< [in] the number of adapters to be added to phAdapters. + ///< If phAdapters is not NULL, then NumEntries should be greater than + ///< zero, otherwise ::UR_RESULT_ERROR_INVALID_SIZE, + ///< will be returned. + ur_adapter_handle_t * + phAdapters, ///< [out][optional][range(0, NumEntries)] array of handle of adapters. + ///< If NumEntries is less than the number of adapters available, then + ///< ::urAdapterGet shall only retrieve that number of platforms. + uint32_t * + pNumAdapters ///< [out][optional] returns the total number of adapters available. +) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Releases the adapter handle reference indicating end of its usage +/// +/// @details +/// - When the reference count of the adapter reaches zero, the adapter may +/// perform adapter-specififc resource teardown +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hAdapter` +ur_result_t UR_APICALL urAdapterRelease( + ur_adapter_handle_t hAdapter ///< [in] Adapter handle to release +) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Get a reference to the adapter handle. +/// +/// @details +/// - Get a reference to the adapter handle. Increment its reference count +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hAdapter` +ur_result_t UR_APICALL urAdapterRetain( + ur_adapter_handle_t hAdapter ///< [in] Adapter handle to retain +) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Get the last adapter specific error. +/// +/// @details +/// To be used after another entry-point has returned +/// ::UR_RESULT_ERROR_ADAPTER_SPECIFIC in order to retrieve a message describing +/// the circumstances of the underlying driver error and the error code +/// returned by the failed driver entry-point. +/// +/// * Implementations *must* store the message and error code in thread-local +/// storage prior to returning ::UR_RESULT_ERROR_ADAPTER_SPECIFIC. +/// +/// * The message and error code storage is will only be valid if a previously +/// called entry-point returned ::UR_RESULT_ERROR_ADAPTER_SPECIFIC. +/// +/// * The memory pointed to by the C string returned in `ppMessage` is owned by +/// the adapter and *must* be null terminated. +/// +/// * The application *may* call this function from simultaneous threads. +/// +/// * The implementation of this function *should* be lock-free. +/// +/// Example usage: +/// +/// ```cpp +/// if (::urQueueCreate(hContext, hDevice, nullptr, &hQueue) == +/// ::UR_RESULT_ERROR_ADAPTER_SPECIFIC) { +/// const char* pMessage; +/// int32_t error; +/// ::urAdapterGetLastError(hAdapter, &pMessage, &error); +/// } +/// ``` +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hAdapter` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == ppMessage` +/// + `NULL == pError` +ur_result_t UR_APICALL urAdapterGetLastError( + ur_adapter_handle_t hAdapter, ///< [in] handle of the adapter instance + const char ** + ppMessage, ///< [out] pointer to a C string where the adapter specific error message + ///< will be stored. + int32_t * + pError ///< [out] pointer to an integer where the adapter specific error code will + ///< be stored. +) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Retrieves information about the adapter +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hAdapter` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `::UR_ADAPTER_INFO_REFERENCE_COUNT < propName` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION +/// + If `propName` is not supported by the adapter. +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `propSize == 0 && pPropValue != NULL` +/// + If `propSize` is less than the real number of bytes needed to return the info. +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `propSize != 0 && pPropValue == NULL` +/// + `pPropValue == NULL && pPropSizeRet == NULL` +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY +ur_result_t UR_APICALL urAdapterGetInfo( + ur_adapter_handle_t hAdapter, ///< [in] handle of the adapter + ur_adapter_info_t propName, ///< [in] type of the info to retrieve + size_t propSize, ///< [in] the number of bytes pointed to by pPropValue. + void * + pPropValue, ///< [out][optional][typename(propName, propSize)] array of bytes holding + ///< the info. + ///< If Size is not equal to or greater to the real number of bytes needed + ///< to return the info then the ::UR_RESULT_ERROR_INVALID_SIZE error is + ///< returned and pPropValue is not used. + size_t * + pPropSizeRet ///< [out][optional] pointer to the actual number of bytes being queried by pPropValue. +) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Retrieves all available platforms for the given adapters /// /// @details /// - Multiple calls to this function will return identical platforms @@ -81,8 +397,13 @@ ur_result_t UR_APICALL urTearDown( /// - ::UR_RESULT_ERROR_UNINITIALIZED /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == phAdapters` /// - ::UR_RESULT_ERROR_INVALID_SIZE ur_result_t UR_APICALL urPlatformGet( + ur_adapter_handle_t * + phAdapters, ///< [in][range(0, NumAdapters)] array of adapters to query for platforms. + uint32_t NumAdapters, ///< [in] number of adapters pointed to by phAdapters uint32_t NumEntries, ///< [in] the number of platforms to be added to phPlatforms. ///< If phPlatforms is not NULL, then NumEntries should be greater than @@ -192,6 +513,8 @@ ur_result_t UR_APICALL urPlatformGetApiVersion( /// + `NULL == hPlatform` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativePlatform` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urPlatformGetNativeHandle( ur_platform_handle_t hPlatform, ///< [in] handle of the platform. ur_native_handle_t * @@ -215,13 +538,13 @@ ur_result_t UR_APICALL urPlatformGetNativeHandle( /// - ::UR_RESULT_ERROR_UNINITIALIZED /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC -/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativePlatform` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phPlatform` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urPlatformCreateWithNativeHandle( ur_native_handle_t - hNativePlatform, ///< [in] the native handle of the platform. + hNativePlatform, ///< [in][nocheck] the native handle of the platform. const ur_platform_native_properties_t * pProperties, ///< [in][optional] pointer to native platform properties struct. ur_platform_handle_t * @@ -268,62 +591,6 @@ ur_result_t UR_APICALL urPlatformGetBackendOption( return result; } -/////////////////////////////////////////////////////////////////////////////// -/// @brief Get the last adapter specific error. -/// -/// @details -/// To be used after another entry-point has returned -/// ::UR_RESULT_ERROR_ADAPTER_SPECIFIC in order to retrieve a message describing -/// the circumstances of the underlying driver error and the error code -/// returned by the failed driver entry-point. -/// -/// * Implementations *must* store the message and error code in thread-local -/// storage prior to returning ::UR_RESULT_ERROR_ADAPTER_SPECIFIC. -/// -/// * The message and error code storage is will only be valid if a previously -/// called entry-point returned ::UR_RESULT_ERROR_ADAPTER_SPECIFIC. -/// -/// * The memory pointed to by the C string returned in `ppMessage` is owned by -/// the adapter and *must* be null terminated. -/// -/// * The application *may* call this function from simultaneous threads. -/// -/// * The implementation of this function *should* be lock-free. -/// -/// Example usage: -/// -/// ```cpp -/// if (::urQueueCreate(hContext, hDevice, nullptr, &hQueue) == -/// ::UR_RESULT_ERROR_ADAPTER_SPECIFIC) { -/// const char* pMessage; -/// int32_t error; -/// ::urPlatformGetLastError(hPlatform, &pMessage, &error); -/// } -/// ``` -/// -/// @returns -/// - ::UR_RESULT_SUCCESS -/// - ::UR_RESULT_ERROR_UNINITIALIZED -/// - ::UR_RESULT_ERROR_DEVICE_LOST -/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC -/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hPlatform` -/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER -/// + `NULL == ppMessage` -/// + `NULL == pError` -ur_result_t UR_APICALL urPlatformGetLastError( - ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance - const char ** - ppMessage, ///< [out] pointer to a C string where the adapter specific error message - ///< will be stored. - int32_t * - pError ///< [out] pointer to an integer where the adapter specific error code will - ///< be stored. -) { - ur_result_t result = UR_RESULT_SUCCESS; - return result; -} - /////////////////////////////////////////////////////////////////////////////// /// @brief Retrieves devices within a platform /// @@ -591,6 +858,8 @@ ur_result_t UR_APICALL urDeviceSelectBinary( /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeDevice` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urDeviceGetNativeHandle( ur_device_handle_t hDevice, ///< [in] handle of the device. ur_native_handle_t @@ -615,13 +884,15 @@ ur_result_t UR_APICALL urDeviceGetNativeHandle( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeDevice` /// + `NULL == hPlatform` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phDevice` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urDeviceCreateWithNativeHandle( - ur_native_handle_t hNativeDevice, ///< [in] the native handle of the device. - ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance + ur_native_handle_t + hNativeDevice, ///< [in][nocheck] the native handle of the device. + ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance const ur_device_native_properties_t * pProperties, ///< [in][optional] pointer to native device properties struct. ur_device_handle_t @@ -831,6 +1102,8 @@ ur_result_t UR_APICALL urContextGetInfo( /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeContext` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urContextGetNativeHandle( ur_context_handle_t hContext, ///< [in] handle of the context. ur_native_handle_t * @@ -854,14 +1127,14 @@ ur_result_t UR_APICALL urContextGetNativeHandle( /// - ::UR_RESULT_ERROR_UNINITIALIZED /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC -/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phDevices` /// + `NULL == phContext` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urContextCreateWithNativeHandle( ur_native_handle_t - hNativeContext, ///< [in] the native handle of the context. + hNativeContext, ///< [in][nocheck] the native handle of the context. uint32_t numDevices, ///< [in] number of devices associated with the context const ur_device_handle_t * phDevices, ///< [in][range(0, numDevices)] list of devices associated with the context @@ -1110,6 +1383,8 @@ ur_result_t UR_APICALL urMemBufferPartition( /// + `NULL == hMem` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeMem` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urMemGetNativeHandle( ur_mem_handle_t hMem, ///< [in] handle of the mem. ur_native_handle_t @@ -1133,13 +1408,15 @@ ur_result_t UR_APICALL urMemGetNativeHandle( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeMem` /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phMem` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( - ur_native_handle_t hNativeMem, ///< [in] the native handle to the memory. - ur_context_handle_t hContext, ///< [in] handle of the context object. + ur_native_handle_t + hNativeMem, ///< [in][nocheck] the native handle to the memory. + ur_context_handle_t hContext, ///< [in] handle of the context object. const ur_mem_native_properties_t * pProperties, ///< [in][optional] pointer to native memory creation properties. ur_mem_handle_t @@ -1163,15 +1440,17 @@ ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeMem` /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == pImageFormat` /// + `NULL == pImageDesc` /// + `NULL == phMem` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urMemImageCreateWithNativeHandle( - ur_native_handle_t hNativeMem, ///< [in] the native handle to the memory. - ur_context_handle_t hContext, ///< [in] handle of the context object. + ur_native_handle_t + hNativeMem, ///< [in][nocheck] the native handle to the memory. + ur_context_handle_t hContext, ///< [in] handle of the context object. const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification. const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description. @@ -1252,6 +1531,17 @@ ur_result_t UR_APICALL urMemGetInfo( /// + `NULL == hMemory` /// - ::UR_RESULT_ERROR_INVALID_ENUMERATION /// + `::UR_IMAGE_INFO_DEPTH < propName` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION +/// + If `propName` is not supported by the adapter. +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `propSize == 0 && pPropValue != NULL` +/// + If `propSize` is less than the real number of bytes needed to return the info. +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `propSize != 0 && pPropValue == NULL` +/// + `pPropValue == NULL && pPropSizeRet == NULL` +/// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY ur_result_t UR_APICALL urMemImageGetInfo( ur_mem_handle_t hMemory, ///< [in] handle to the image object being queried. ur_image_info_t propName, ///< [in] type of image info to retrieve. @@ -1426,6 +1716,8 @@ ur_result_t UR_APICALL urSamplerGetInfo( /// + `NULL == hSampler` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeSampler` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urSamplerGetNativeHandle( ur_sampler_handle_t hSampler, ///< [in] handle of the sampler. ur_native_handle_t * @@ -1450,13 +1742,14 @@ ur_result_t UR_APICALL urSamplerGetNativeHandle( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeSampler` /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phSampler` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urSamplerCreateWithNativeHandle( ur_native_handle_t - hNativeSampler, ///< [in] the native handle of the sampler. + hNativeSampler, ///< [in][nocheck] the native handle of the sampler. ur_context_handle_t hContext, ///< [in] handle of the context object const ur_sampler_native_properties_t * pProperties, ///< [in][optional] pointer to native sampler properties struct. @@ -1796,6 +2089,18 @@ ur_result_t UR_APICALL urUSMPoolGetInfo( /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_ENUMERATION /// + `::UR_VIRTUAL_MEM_GRANULARITY_INFO_RECOMMENDED < propName` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION +/// + If `propName` is not supported by the adapter. +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `propSize == 0 && pPropValue != NULL` +/// + If `propSize` is less than the real number of bytes needed to return the info. +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `propSize != 0 && pPropValue == NULL` +/// + `pPropValue == NULL && pPropSizeRet == NULL` +/// - ::UR_RESULT_ERROR_INVALID_DEVICE +/// - ::UR_RESULT_ERROR_INVALID_CONTEXT +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY ur_result_t UR_APICALL urVirtualMemGranularityGetInfo( ur_context_handle_t hContext, ///< [in] handle of the context object. ur_device_handle_t @@ -1942,7 +2247,7 @@ ur_result_t UR_APICALL urVirtualMemSetAccess( ur_context_handle_t hContext, ///< [in] handle to the context object. const void *pStart, ///< [in] pointer to the start of the virtual memory range. - size_t size, ///< [in] size in bytes of the virutal memory range. + size_t size, ///< [in] size in bytes of the virtual memory range. ur_virtual_mem_access_flags_t flags ///< [in] access flags to set for the mapped virtual memory range. ) { @@ -1997,11 +2302,13 @@ ur_result_t UR_APICALL urVirtualMemGetInfo( /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phPhysicalMem` +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + If size is not a multiple of ::UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM. ur_result_t UR_APICALL urPhysicalMemCreate( ur_context_handle_t hContext, ///< [in] handle of the context object. ur_device_handle_t hDevice, ///< [in] handle of the device object. size_t - size, ///< [in] size in bytes of phyisical memory to allocate, must be a multiple + size, ///< [in] size in bytes of physical memory to allocate, must be a multiple ///< of ::UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM. const ur_physical_mem_properties_t * pProperties, ///< [in][optional] pointer to physical memory creation properties. @@ -2136,7 +2443,7 @@ ur_result_t UR_APICALL urProgramCreateWithBinary( /// /// @details /// - The application may call this function from simultaneous threads. -/// - Following a succesful call to this entry point, the program passed +/// - Following a successful call to this entry point, the program passed /// will contain a binary of the ::UR_PROGRAM_BINARY_TYPE_EXECUTABLE type /// for each device in `hContext`. /// @@ -2171,9 +2478,9 @@ ur_result_t UR_APICALL urProgramBuild( /// /// @details /// - The application may call this function from simultaneous threads. -/// - Following a succesful call to this entry point `hProgram` will contain -/// a binary of the ::UR_PROGRAM_BINARY_TYPE_COMPILED_OBJECT type for each -/// device in `hContext`. +/// - Following a successful call to this entry point `hProgram` will +/// contain a binary of the ::UR_PROGRAM_BINARY_TYPE_COMPILED_OBJECT type +/// for each device in `hContext`. /// /// @remarks /// _Analogues_ @@ -2207,8 +2514,8 @@ ur_result_t UR_APICALL urProgramCompile( /// /// @details /// - The application may call this function from simultaneous threads. -/// - Following a succesful call to this entry point the program returned in -/// `phProgram` will contain a binary of the +/// - Following a successful call to this entry point the program returned +/// in `phProgram` will contain a binary of the /// ::UR_PROGRAM_BINARY_TYPE_EXECUTABLE type for each device in /// `hContext`. /// @@ -2480,6 +2787,8 @@ ur_result_t UR_APICALL urProgramSetSpecializationConstants( /// + `NULL == hProgram` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeProgram` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urProgramGetNativeHandle( ur_program_handle_t hProgram, ///< [in] handle of the program. ur_native_handle_t * @@ -2504,13 +2813,14 @@ ur_result_t UR_APICALL urProgramGetNativeHandle( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeProgram` /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phProgram` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urProgramCreateWithNativeHandle( ur_native_handle_t - hNativeProgram, ///< [in] the native handle of the program. + hNativeProgram, ///< [in][nocheck] the native handle of the program. ur_context_handle_t hContext, ///< [in] handle of the context instance const ur_program_native_properties_t * pProperties, ///< [in][optional] pointer to native program properties struct. @@ -2964,6 +3274,8 @@ ur_result_t UR_APICALL urKernelSetSpecializationConstants( /// + `NULL == hKernel` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeKernel` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urKernelGetNativeHandle( ur_kernel_handle_t hKernel, ///< [in] handle of the kernel. ur_native_handle_t @@ -2988,14 +3300,16 @@ ur_result_t UR_APICALL urKernelGetNativeHandle( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeKernel` /// + `NULL == hContext` /// + `NULL == hProgram` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phKernel` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urKernelCreateWithNativeHandle( - ur_native_handle_t hNativeKernel, ///< [in] the native handle of the kernel. - ur_context_handle_t hContext, ///< [in] handle of the context object + ur_native_handle_t + hNativeKernel, ///< [in][nocheck] the native handle of the kernel. + ur_context_handle_t hContext, ///< [in] handle of the context object ur_program_handle_t hProgram, ///< [in] handle of the program associated with the kernel const ur_kernel_native_properties_t * @@ -3168,6 +3482,8 @@ ur_result_t UR_APICALL urQueueRelease( /// + `NULL == hQueue` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeQueue` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urQueueGetNativeHandle( ur_queue_handle_t hQueue, ///< [in] handle of the queue. ur_queue_native_desc_t @@ -3194,15 +3510,17 @@ ur_result_t UR_APICALL urQueueGetNativeHandle( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeQueue` /// + `NULL == hContext` /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phQueue` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urQueueCreateWithNativeHandle( - ur_native_handle_t hNativeQueue, ///< [in] the native handle of the queue. - ur_context_handle_t hContext, ///< [in] handle of the context object - ur_device_handle_t hDevice, ///< [in] handle of the device object + ur_native_handle_t + hNativeQueue, ///< [in][nocheck] the native handle of the queue. + ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_queue_native_properties_t * pProperties, ///< [in][optional] pointer to native queue properties struct ur_queue_handle_t @@ -3452,6 +3770,8 @@ ur_result_t UR_APICALL urEventRelease( /// + `NULL == hEvent` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phNativeEvent` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urEventGetNativeHandle( ur_event_handle_t hEvent, ///< [in] handle of the event. ur_native_handle_t @@ -3476,13 +3796,15 @@ ur_result_t UR_APICALL urEventGetNativeHandle( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hNativeEvent` /// + `NULL == hContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phEvent` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. ur_result_t UR_APICALL urEventCreateWithNativeHandle( - ur_native_handle_t hNativeEvent, ///< [in] the native handle of the event. - ur_context_handle_t hContext, ///< [in] handle of the context object + ur_native_handle_t + hNativeEvent, ///< [in][nocheck] the native handle of the event. + ur_context_handle_t hContext, ///< [in] handle of the context object const ur_event_native_properties_t * pProperties, ///< [in][optional] pointer to native event properties struct ur_event_handle_t @@ -4930,11 +5252,13 @@ ur_result_t UR_APICALL urUSMPitchedAllocExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hImage` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE ur_result_t UR_APICALL urBindlessImagesUnsampledImageHandleDestroyExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_handle_t hImage ///< [in] pointer to handle of image object to destroy ) { @@ -4956,11 +5280,13 @@ ur_result_t UR_APICALL urBindlessImagesUnsampledImageHandleDestroyExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hImage` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE ur_result_t UR_APICALL urBindlessImagesSampledImageHandleDestroyExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_handle_t hImage ///< [in] pointer to handle of image object to destroy ) { @@ -4983,6 +5309,7 @@ ur_result_t UR_APICALL urBindlessImagesSampledImageHandleDestroyExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == pImageFormat` /// + `NULL == pImageDesc` @@ -4995,6 +5322,7 @@ ur_result_t UR_APICALL urBindlessImagesSampledImageHandleDestroyExp( /// - ::UR_RESULT_ERROR_INVALID_OPERATION ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description @@ -5019,11 +5347,13 @@ ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hImageMem` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE ur_result_t UR_APICALL urBindlessImagesImageFreeExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem ///< [in] handle of image memory to be freed ) { @@ -5045,6 +5375,7 @@ ur_result_t UR_APICALL urBindlessImagesImageFreeExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hImageMem` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == pImageFormat` @@ -5059,6 +5390,7 @@ ur_result_t UR_APICALL urBindlessImagesImageFreeExp( /// - ::UR_RESULT_ERROR_INVALID_OPERATION ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] handle to memory from which to create the image const ur_image_format_t @@ -5086,6 +5418,7 @@ ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hImageMem` /// + `NULL == hSampler` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER @@ -5102,6 +5435,7 @@ ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( /// - ::UR_RESULT_ERROR_INVALID_OPERATION ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] handle to memory from which to create the image const ur_image_format_t @@ -5132,7 +5466,7 @@ ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( /// - ::UR_RESULT_ERROR_DEVICE_LOST /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `NULL == hContext` +/// + `NULL == hQueue` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == pDst` /// + `NULL == pSrc` @@ -5140,21 +5474,33 @@ ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( /// + `NULL == pImageDesc` /// - ::UR_RESULT_ERROR_INVALID_ENUMERATION /// + `::UR_EXP_IMAGE_COPY_FLAGS_MASK & imageCopyFlags` -/// - ::UR_RESULT_ERROR_INVALID_CONTEXT +/// - ::UR_RESULT_ERROR_INVALID_QUEUE /// - ::UR_RESULT_ERROR_INVALID_VALUE /// - ::UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR /// + `pImageDesc && UR_MEM_TYPE_IMAGE1D_BUFFER < pImageDesc->type` /// - ::UR_RESULT_ERROR_INVALID_IMAGE_SIZE /// - ::UR_RESULT_ERROR_INVALID_OPERATION ur_result_t UR_APICALL urBindlessImagesImageCopyExp( - ur_context_handle_t hContext, ///< [in] handle of the context object - void *pDst, ///< [in] location the data will be copied to - void *pSrc, ///< [in] location the data will be copied from + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + void *pDst, ///< [in] location the data will be copied to + void *pSrc, ///< [in] location the data will be copied from const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description ur_exp_image_copy_flags_t imageCopyFlags, ///< [in] flags describing copy direction e.g. H2D or D2H + ur_rect_offset_t + srcOffset, ///< [in] defines the (x,y,z) source offset in pixels in the 1D, 2D, or 3D + ///< image + ur_rect_offset_t + dstOffset, ///< [in] defines the (x,y,z) destination offset in pixels in the 1D, 2D, + ///< or 3D image + ur_rect_region_t + copyExtent, ///< [in] defines the (width, height, depth) in pixels of the 1D, 2D, or 3D + ///< region to copy + ur_rect_region_t + hostExtent, ///< [in] defines the (width, height, depth) in pixels of the 1D, 2D, or 3D + ///< region on the host uint32_t numEventsInWaitList, ///< [in] size of the event wait list const ur_event_handle_t * phEventWaitList, ///< [in][optional][range(0, numEventsInWaitList)] pointer to a list of @@ -5215,6 +5561,7 @@ ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hImageMem` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phImageMem` @@ -5222,6 +5569,7 @@ ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( /// - ::UR_RESULT_ERROR_INVALID_VALUE ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hImageMem, ///< [in] memory handle to the mipmap image uint32_t mipmapLevel, ///< [in] requested level of the mipmap @@ -5246,11 +5594,13 @@ ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hMem` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_image_mem_handle_t hMem ///< [in] handle of image memory to be freed ) { ur_result_t result = UR_RESULT_SUCCESS; @@ -5271,15 +5621,19 @@ ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == pInteropMemDesc` /// + `NULL == phInteropMem` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE /// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object size_t size, ///< [in] size of the external memory - uint32_t fileDescriptor, ///< [in] the file descriptor + ur_exp_interop_mem_desc_t + *pInteropMemDesc, ///< [in] the interop memory descriptor ur_exp_interop_mem_handle_t *phInteropMem ///< [out] interop memory handle to the external memory ) { @@ -5297,6 +5651,7 @@ ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hInteropMem` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == pImageFormat` @@ -5311,12 +5666,13 @@ ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( /// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description ur_exp_interop_mem_handle_t hInteropMem, ///< [in] interop memory handle to the external memory - ur_exp_image_handle_t * + ur_exp_image_mem_handle_t * phImageMem ///< [out] image memory handle to the externally allocated memory ) { ur_result_t result = UR_RESULT_SUCCESS; @@ -5337,11 +5693,13 @@ ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hInteropMem` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_interop_mem_handle_t hInteropMem ///< [in] handle of interop memory to be freed ) { @@ -5363,15 +5721,19 @@ ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER -/// + `NULL == phInteropSemaphoreHandle` +/// + `NULL == pInteropSemaphoreDesc` +/// + `NULL == phInteropSemaphore` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreOpaqueFDExp( ur_context_handle_t hContext, ///< [in] handle of the context object - uint32_t fileDescriptor, ///< [in] the file descriptor + ur_device_handle_t hDevice, ///< [in] handle of the device object + ur_exp_interop_semaphore_desc_t + *pInteropSemaphoreDesc, ///< [in] the interop semaphore descriptor ur_exp_interop_semaphore_handle_t * - phInteropSemaphoreHandle ///< [out] interop semaphore handle to the external semaphore + phInteropSemaphore ///< [out] interop semaphore handle to the external semaphore ) { ur_result_t result = UR_RESULT_SUCCESS; return result; @@ -5391,11 +5753,13 @@ ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreOpaqueFDExp( /// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hContext` +/// + `NULL == hDevice` /// + `NULL == hInteropSemaphore` /// - ::UR_RESULT_ERROR_INVALID_CONTEXT /// - ::UR_RESULT_ERROR_INVALID_VALUE ur_result_t UR_APICALL urBindlessImagesDestroyExternalSemaphoreExp( ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object ur_exp_interop_semaphore_handle_t hInteropSemaphore ///< [in] handle of interop semaphore to be destroyed ) { diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 79265fe742..79ca48236c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -17,7 +17,7 @@ enable_testing() add_subdirectory(python) add_subdirectory(loader) add_subdirectory(conformance) -add_subdirectory(unified_memory_allocation) +add_subdirectory(unified_malloc_framework) add_subdirectory(usm) add_subdirectory(layers) add_subdirectory(unit) diff --git a/test/conformance/CMakeLists.txt b/test/conformance/CMakeLists.txt index fe6eb43f9b..c078168cf9 100644 --- a/test/conformance/CMakeLists.txt +++ b/test/conformance/CMakeLists.txt @@ -7,7 +7,7 @@ set(UR_CONFORMANCE_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) function(add_conformance_test name) set(TEST_TARGET_NAME test-${name}) - add_executable(${TEST_TARGET_NAME} + add_ur_executable(${TEST_TARGET_NAME} ${ARGN} ${UR_CONFORMANCE_TEST_DIR}/source/environment.cpp ${UR_CONFORMANCE_TEST_DIR}/source/main.cpp) @@ -47,6 +47,7 @@ endfunction() add_subdirectory(testing) add_subdirectory(adapters) +add_subdirectory(runtime) add_subdirectory(platform) add_subdirectory(device) add_subdirectory(context) @@ -55,6 +56,7 @@ add_subdirectory(usm) add_subdirectory(event) add_subdirectory(queue) add_subdirectory(sampler) +add_subdirectory(virtual_memory) if(DEFINED UR_DPCXX) add_custom_target(generate_device_binaries) diff --git a/test/conformance/context/urContextCreateWithNativeHandle.cpp b/test/conformance/context/urContextCreateWithNativeHandle.cpp index b227cebbf3..04ef93c0f0 100644 --- a/test/conformance/context/urContextCreateWithNativeHandle.cpp +++ b/test/conformance/context/urContextCreateWithNativeHandle.cpp @@ -5,14 +5,26 @@ #include -using urContextCreateWithNativeHandleTest = uur::urDeviceTest; - +using urContextCreateWithNativeHandleTest = uur::urContextTest; UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urContextCreateWithNativeHandleTest); -TEST_P(urContextCreateWithNativeHandleTest, InvalidNullHandleNativeHandle) { - ur_context_handle_t context = nullptr; +TEST_P(urContextCreateWithNativeHandleTest, Success) { + ur_native_handle_t native_context = nullptr; + if (urContextGetNativeHandle(context, &native_context)) { + GTEST_SKIP(); + } + + // We cannot assume anything about a native_handle, not even if it's + // `nullptr` since this could be a valid representation within a backend. + // We can however convert the native_handle back into a unified-runtime handle + // and perform some query on it to verify that it works. + ur_context_handle_t ctx = nullptr; ur_context_native_properties_t props{}; - ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, - urContextCreateWithNativeHandle(nullptr, 0u, nullptr, - &props, &context)); + ASSERT_SUCCESS(urContextCreateWithNativeHandle(native_context, 0, nullptr, + &props, &ctx)); + ASSERT_NE(ctx, nullptr); + + uint32_t n_devices = 0; + ASSERT_SUCCESS(urContextGetInfo(ctx, UR_CONTEXT_INFO_NUM_DEVICES, + sizeof(uint32_t), &n_devices, nullptr)); } diff --git a/test/conformance/context/urContextGetNativeHandle.cpp b/test/conformance/context/urContextGetNativeHandle.cpp index 328649d590..fda7222568 100644 --- a/test/conformance/context/urContextGetNativeHandle.cpp +++ b/test/conformance/context/urContextGetNativeHandle.cpp @@ -6,26 +6,13 @@ #include using urContextGetNativeHandleTest = uur::urContextTest; - UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urContextGetNativeHandleTest); TEST_P(urContextGetNativeHandleTest, Success) { ur_native_handle_t native_context = nullptr; - ASSERT_SUCCESS(urContextGetNativeHandle(context, &native_context)); - - // We cannot assume anything about a native_handle, not even if it's - // `nullptr` since this could be a valid representation within a backend. - // We can however convert the native_handle back into a unified-runtime handle - // and perform some query on it to verify that it works. - ur_context_handle_t ctx = nullptr; - ur_context_native_properties_t props{}; - ASSERT_SUCCESS(urContextCreateWithNativeHandle(native_context, 0, nullptr, - &props, &ctx)); - ASSERT_NE(ctx, nullptr); - - uint32_t n_devices = 0; - ASSERT_SUCCESS(urContextGetInfo(ctx, UR_CONTEXT_INFO_NUM_DEVICES, - sizeof(uint32_t), &n_devices, nullptr)); + if (auto error = urContextGetNativeHandle(context, &native_context)) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_UNSUPPORTED_FEATURE, error); + } } TEST_P(urContextGetNativeHandleTest, InvalidNullHandleContext) { diff --git a/test/conformance/device/urDeviceCreateWithNativeHandle.cpp b/test/conformance/device/urDeviceCreateWithNativeHandle.cpp index ab16ca74a5..fbcd5e2f4b 100644 --- a/test/conformance/device/urDeviceCreateWithNativeHandle.cpp +++ b/test/conformance/device/urDeviceCreateWithNativeHandle.cpp @@ -4,11 +4,26 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include -using urDeviceCreateWithNativeHandleTest = uur::urPlatformTest; +using urDeviceCreateWithNativeHandleTest = uur::urAllDevicesTest; -TEST_F(urDeviceCreateWithNativeHandleTest, InvalidNullHandleNativeDevice) { - ur_device_handle_t device = nullptr; - ASSERT_EQ_RESULT( - UR_RESULT_ERROR_INVALID_NULL_HANDLE, - urDeviceCreateWithNativeHandle(nullptr, platform, nullptr, &device)); +TEST_F(urDeviceCreateWithNativeHandleTest, Success) { + for (auto device : devices) { + ur_native_handle_t native_handle = nullptr; + if (urDeviceGetNativeHandle(device, &native_handle)) { + continue; + } + + // We cannot assume anything about a native_handle, not even if it's + // `nullptr` since this could be a valid representation within a backend. + // We can however convert the native_handle back into a unified-runtime handle + // and perform some query on it to verify that it works. + ur_device_handle_t dev = nullptr; + ASSERT_SUCCESS(urDeviceCreateWithNativeHandle(native_handle, platform, + nullptr, &dev)); + ASSERT_NE(dev, nullptr); + + uint32_t dev_id = 0; + ASSERT_SUCCESS(urDeviceGetInfo(dev, UR_DEVICE_INFO_TYPE, + sizeof(uint32_t), &dev_id, nullptr)); + } } diff --git a/test/conformance/device/urDeviceGet.cpp b/test/conformance/device/urDeviceGet.cpp index 9b053f1f46..85a4818d09 100644 --- a/test/conformance/device/urDeviceGet.cpp +++ b/test/conformance/device/urDeviceGet.cpp @@ -56,6 +56,6 @@ TEST_F(urDeviceGetTest, InvalidValueNumEntries) { ASSERT_NE(count, 0); std::vector devices(count); ASSERT_EQ_RESULT( - UR_RESULT_ERROR_INVALID_VALUE, + UR_RESULT_ERROR_INVALID_SIZE, urDeviceGet(platform, UR_DEVICE_TYPE_ALL, 0, devices.data(), nullptr)); } diff --git a/test/conformance/device/urDeviceGetInfo.cpp b/test/conformance/device/urDeviceGetInfo.cpp index bbe08fe6d8..e5e9f7c310 100644 --- a/test/conformance/device/urDeviceGetInfo.cpp +++ b/test/conformance/device/urDeviceGetInfo.cpp @@ -13,7 +13,6 @@ static std::unordered_map device_info_size_map = { {UR_DEVICE_INFO_MAX_COMPUTE_UNITS, sizeof(uint32_t)}, {UR_DEVICE_INFO_MAX_WORK_ITEM_DIMENSIONS, sizeof(uint32_t)}, {UR_DEVICE_INFO_MAX_WORK_GROUP_SIZE, sizeof(size_t)}, - {UR_DEVICE_INFO_MAX_WORK_GROUP_SIZE, sizeof(size_t)}, {UR_DEVICE_INFO_SINGLE_FP_CONFIG, sizeof(ur_device_fp_capability_flags_t)}, {UR_DEVICE_INFO_HALF_FP_CONFIG, sizeof(ur_device_fp_capability_flags_t)}, {UR_DEVICE_INFO_DOUBLE_FP_CONFIG, sizeof(ur_device_fp_capability_flags_t)}, @@ -107,7 +106,7 @@ static std::unordered_map device_info_size_map = { {UR_DEVICE_INFO_BFLOAT16, sizeof(ur_bool_t)}, {UR_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES, sizeof(uint32_t)}, {UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS, sizeof(ur_bool_t)}, - {UR_DEVICE_INFO_MEMORY_BUS_WIDTH, sizeof(ur_bool_t)}, + {UR_DEVICE_INFO_MEMORY_BUS_WIDTH, sizeof(uint32_t)}, {UR_DEVICE_INFO_MAX_WORK_GROUPS_3D, sizeof(size_t[3])}, {UR_DEVICE_INFO_ASYNC_BARRIER, sizeof(ur_bool_t)}, {UR_DEVICE_INFO_MEM_CHANNEL_SUPPORT, sizeof(ur_bool_t)}, @@ -232,7 +231,8 @@ INSTANTIATE_TEST_SUITE_P( UR_DEVICE_INFO_ASYNC_BARRIER, // UR_DEVICE_INFO_MEM_CHANNEL_SUPPORT, // UR_DEVICE_INFO_HOST_PIPE_READ_WRITE_SUPPORTED, // - UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP // + UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP, // + UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT // ), [](const ::testing::TestParamInfo &info) { std::stringstream ss; @@ -258,7 +258,7 @@ TEST_P(urDeviceGetInfoTest, Success) { ASSERT_SUCCESS(urDeviceGetInfo(device, info_type, size, info_data.data(), nullptr)); } else { - ASSERT_EQ_RESULT(result, UR_RESULT_ERROR_INVALID_ENUMERATION); + ASSERT_EQ_RESULT(result, UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION); } } } diff --git a/test/conformance/device/urDeviceGetNativeHandle.cpp b/test/conformance/device/urDeviceGetNativeHandle.cpp index 0ce43d37bc..f6bdec3dd6 100644 --- a/test/conformance/device/urDeviceGetNativeHandle.cpp +++ b/test/conformance/device/urDeviceGetNativeHandle.cpp @@ -9,20 +9,9 @@ using urDeviceGetNativeHandleTest = uur::urAllDevicesTest; TEST_F(urDeviceGetNativeHandleTest, Success) { for (auto device : devices) { ur_native_handle_t native_handle = nullptr; - ASSERT_SUCCESS(urDeviceGetNativeHandle(device, &native_handle)); - - // We cannot assume anything about a native_handle, not even if it's - // `nullptr` since this could be a valid representation within a backend. - // We can however convert the native_handle back into a unified-runtime handle - // and perform some query on it to verify that it works. - ur_device_handle_t dev = nullptr; - ASSERT_SUCCESS(urDeviceCreateWithNativeHandle(native_handle, platform, - nullptr, &dev)); - ASSERT_NE(dev, nullptr); - - uint32_t dev_id = 0; - ASSERT_SUCCESS(urDeviceGetInfo(dev, UR_DEVICE_INFO_TYPE, - sizeof(uint32_t), &dev_id, nullptr)); + if (auto error = urDeviceGetNativeHandle(device, &native_handle)) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_UNSUPPORTED_FEATURE, error); + } } } diff --git a/test/conformance/device/urDeviceRelease.cpp b/test/conformance/device/urDeviceRelease.cpp index 300f646851..3b5e74a575 100644 --- a/test/conformance/device/urDeviceRelease.cpp +++ b/test/conformance/device/urDeviceRelease.cpp @@ -26,6 +26,12 @@ TEST_F(urDeviceReleaseTest, Success) { TEST_F(urDeviceReleaseTest, SuccessSubdevices) { for (auto device : devices) { + if (!uur::hasDevicePartitionSupport(device, + UR_DEVICE_PARTITION_EQUALLY)) { + ::testing::Message() << "Device: \'" << device + << "\' does not support partitioning equally."; + continue; + } ur_device_partition_property_t prop = uur::makePartitionEquallyDesc(1); diff --git a/test/conformance/device/urDeviceRetain.cpp b/test/conformance/device/urDeviceRetain.cpp index e5999ba24b..77a9c58b79 100644 --- a/test/conformance/device/urDeviceRetain.cpp +++ b/test/conformance/device/urDeviceRetain.cpp @@ -27,6 +27,12 @@ TEST_F(urDeviceRetainTest, Success) { TEST_F(urDeviceRetainTest, SuccessSubdevices) { for (auto device : devices) { + if (!uur::hasDevicePartitionSupport(device, + UR_DEVICE_PARTITION_EQUALLY)) { + ::testing::Message() << "Device: \'" << device + << "\' does not support partitioning equally."; + continue; + } ur_device_partition_property_t prop = uur::makePartitionEquallyDesc(1); ur_device_partition_properties_t properties{ diff --git a/test/conformance/device/urDeviceSelectBinary.cpp b/test/conformance/device/urDeviceSelectBinary.cpp index 34d008a3cd..44d32e3c6d 100644 --- a/test/conformance/device/urDeviceSelectBinary.cpp +++ b/test/conformance/device/urDeviceSelectBinary.cpp @@ -56,7 +56,7 @@ TEST_F(urDeviceSelectBinaryTest, InvalidValueNumBinaries) { for (auto device : devices) { uint32_t selected_binary; ASSERT_EQ_RESULT( - UR_RESULT_ERROR_INVALID_VALUE, + UR_RESULT_ERROR_INVALID_SIZE, urDeviceSelectBinary(device, binaries, 0, &selected_binary)); } } diff --git a/test/conformance/device_code/CMakeLists.txt b/test/conformance/device_code/CMakeLists.txt index e834d414fb..1d3f28df7f 100644 --- a/test/conformance/device_code/CMakeLists.txt +++ b/test/conformance/device_code/CMakeLists.txt @@ -24,6 +24,7 @@ macro(add_device_binary SOURCE_FILE) endmacro() add_device_binary(${CMAKE_CURRENT_SOURCE_DIR}/bar.cpp) +add_device_binary(${CMAKE_CURRENT_SOURCE_DIR}/device_global.cpp) add_device_binary(${CMAKE_CURRENT_SOURCE_DIR}/fill.cpp) add_device_binary(${CMAKE_CURRENT_SOURCE_DIR}/fill_2d.cpp) add_device_binary(${CMAKE_CURRENT_SOURCE_DIR}/fill_3d.cpp) diff --git a/test/conformance/device_code/device_global.cpp b/test/conformance/device_code/device_global.cpp new file mode 100644 index 0000000000..3ead86bbf5 --- /dev/null +++ b/test/conformance/device_code/device_global.cpp @@ -0,0 +1,23 @@ +// Copyright (C) 2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include + +sycl::ext::oneapi::experimental::device_global dev_var; + +int main() { + + sycl::queue deviceQueue; + sycl::range<1> numOfItems{1}; + deviceQueue.submit([&](sycl::handler &cgh) { + auto kern = [=](sycl::id<1>) { + // just increment + dev_var = dev_var + 1; + }; + cgh.parallel_for(numOfItems, kern); + }); + + return 0; +} diff --git a/test/conformance/enqueue/CMakeLists.txt b/test/conformance/enqueue/CMakeLists.txt index 48ee69d8f2..532cab1b85 100644 --- a/test/conformance/enqueue/CMakeLists.txt +++ b/test/conformance/enqueue/CMakeLists.txt @@ -4,6 +4,8 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception add_conformance_test_with_kernels_environment(enqueue + urEnqueueDeviceGlobalVariableRead.cpp + urEnqueueDeviceGlobalVariableWrite.cpp urEnqueueEventsWait.cpp urEnqueueEventsWaitWithBarrier.cpp urEnqueueKernelLaunch.cpp @@ -16,8 +18,6 @@ add_conformance_test_with_kernels_environment(enqueue urEnqueueMemBufferWrite.cpp urEnqueueMemBufferWriteRect.cpp urEnqueueMemImageCopy.cpp - urEnqueueMemImageFill.cpp - urEnqueueMemImageMap.cpp urEnqueueMemImageRead.cpp urEnqueueMemImageWrite.cpp urEnqueueMemUnmap.cpp diff --git a/test/conformance/enqueue/urEnqueueDeviceGlobalVariableRead.cpp b/test/conformance/enqueue/urEnqueueDeviceGlobalVariableRead.cpp new file mode 100644 index 0000000000..df1e70b2b3 --- /dev/null +++ b/test/conformance/enqueue/urEnqueueDeviceGlobalVariableRead.cpp @@ -0,0 +1,91 @@ +// Copyright (C) 2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include + +using urEnqueueDeviceGetGlobalVariableReadTest = uur::urGlobalVariableTest; +UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urEnqueueDeviceGetGlobalVariableReadTest); + +TEST_P(urEnqueueDeviceGetGlobalVariableReadTest, Success) { + + ASSERT_SUCCESS(urEnqueueDeviceGlobalVariableWrite( + queue, program, global_var.name.c_str(), true, sizeof(global_var.value), + 0, &global_var.value, 0, nullptr, nullptr)); + + size_t global_offset = 0; + size_t n_dimensions = 1; + size_t global_size = 1; + + // execute the kernel + ASSERT_SUCCESS(urEnqueueKernelLaunch(queue, kernel, n_dimensions, + &global_offset, &global_size, nullptr, + 1, nullptr, nullptr)); + ASSERT_SUCCESS(urQueueFinish(queue)); + + // read global var back to host + ASSERT_SUCCESS(urEnqueueDeviceGlobalVariableRead( + queue, program, global_var.name.c_str(), true, sizeof(global_var.value), + 0, &global_var.value, 0, nullptr, nullptr)); + + // kernel should increment value + ASSERT_EQ(global_var.value, 1); +} + +TEST_P(urEnqueueDeviceGetGlobalVariableReadTest, InvalidNullHandleQueue) { + ASSERT_EQ_RESULT(urEnqueueDeviceGlobalVariableRead( + nullptr, program, global_var.name.c_str(), true, + sizeof(global_var.value), 0, &global_var.value, 0, + nullptr, nullptr), + UR_RESULT_ERROR_INVALID_NULL_HANDLE); +} + +TEST_P(urEnqueueDeviceGetGlobalVariableReadTest, InvalidNullHandleProgram) { + ASSERT_EQ_RESULT(urEnqueueDeviceGlobalVariableRead( + queue, nullptr, global_var.name.c_str(), true, + sizeof(global_var.value), 0, &global_var.value, 0, + nullptr, nullptr), + UR_RESULT_ERROR_INVALID_NULL_HANDLE); +} + +TEST_P(urEnqueueDeviceGetGlobalVariableReadTest, InvalidNullPointerName) { + ASSERT_EQ_RESULT(urEnqueueDeviceGlobalVariableRead( + queue, program, nullptr, true, + sizeof(global_var.value), 0, &global_var.value, 0, + nullptr, nullptr), + UR_RESULT_ERROR_INVALID_NULL_POINTER); +} + +TEST_P(urEnqueueDeviceGetGlobalVariableReadTest, InvalidNullPointerDst) { + ASSERT_EQ_RESULT(urEnqueueDeviceGlobalVariableRead( + queue, program, global_var.name.c_str(), true, + sizeof(global_var.value), 0, nullptr, 0, nullptr, + nullptr), + UR_RESULT_ERROR_INVALID_NULL_POINTER); +} + +TEST_P(urEnqueueDeviceGetGlobalVariableReadTest, + InvalidEventWaitListNullEvents) { + ASSERT_EQ_RESULT(urEnqueueDeviceGlobalVariableRead( + queue, program, global_var.name.c_str(), true, + sizeof(global_var.value), 0, &global_var.value, 1, + nullptr, nullptr), + UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST); +} + +TEST_P(urEnqueueDeviceGetGlobalVariableReadTest, InvalidEventWaitListZeroSize) { + ur_event_handle_t evt = nullptr; + ASSERT_EQ_RESULT(urEnqueueDeviceGlobalVariableRead( + queue, program, global_var.name.c_str(), true, + sizeof(global_var.value), 0, &global_var.value, 0, + &evt, nullptr), + UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST); +} +TEST_P(urEnqueueDeviceGetGlobalVariableReadTest, InvalidEventWaitInvalidEvent) { + ur_event_handle_t inv_evt = nullptr; + ASSERT_EQ_RESULT(urEnqueueDeviceGlobalVariableRead( + queue, program, global_var.name.c_str(), true, + sizeof(global_var.value), 0, &global_var.value, 1, + &inv_evt, nullptr), + UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST); +} diff --git a/test/conformance/enqueue/urEnqueueDeviceGlobalVariableWrite.cpp b/test/conformance/enqueue/urEnqueueDeviceGlobalVariableWrite.cpp new file mode 100644 index 0000000000..b665314b48 --- /dev/null +++ b/test/conformance/enqueue/urEnqueueDeviceGlobalVariableWrite.cpp @@ -0,0 +1,68 @@ +// Copyright (C) 2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include + +using urEnqueueDeviceGetGlobalVariableWriteTest = uur::urGlobalVariableTest; +UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urEnqueueDeviceGetGlobalVariableWriteTest); + +TEST_P(urEnqueueDeviceGetGlobalVariableWriteTest, InvalidNullHandleQueue) { + ASSERT_EQ_RESULT(urEnqueueDeviceGlobalVariableWrite( + nullptr, program, global_var.name.c_str(), true, + sizeof(global_var.value), 0, &global_var.value, 0, + nullptr, nullptr), + UR_RESULT_ERROR_INVALID_NULL_HANDLE); +} + +TEST_P(urEnqueueDeviceGetGlobalVariableWriteTest, InvalidNullHandleProgram) { + ASSERT_EQ_RESULT(urEnqueueDeviceGlobalVariableWrite( + queue, nullptr, global_var.name.c_str(), true, + sizeof(global_var.value), 0, &global_var.value, 0, + nullptr, nullptr), + UR_RESULT_ERROR_INVALID_NULL_HANDLE); +} + +TEST_P(urEnqueueDeviceGetGlobalVariableWriteTest, InvalidNullPointerName) { + ASSERT_EQ_RESULT(urEnqueueDeviceGlobalVariableWrite( + queue, program, nullptr, true, + sizeof(global_var.value), 0, &global_var.value, 0, + nullptr, nullptr), + UR_RESULT_ERROR_INVALID_NULL_POINTER); +} + +TEST_P(urEnqueueDeviceGetGlobalVariableWriteTest, InvalidNullPointerSrc) { + ASSERT_EQ_RESULT(urEnqueueDeviceGlobalVariableWrite( + queue, program, global_var.name.c_str(), true, + sizeof(global_var.value), 0, nullptr, 0, nullptr, + nullptr), + UR_RESULT_ERROR_INVALID_NULL_POINTER); +} + +TEST_P(urEnqueueDeviceGetGlobalVariableWriteTest, + InvalidEventWaitListNullEvents) { + ASSERT_EQ_RESULT(urEnqueueDeviceGlobalVariableWrite( + queue, program, global_var.name.c_str(), true, + sizeof(global_var.value), 0, &global_var.value, 1, + nullptr, nullptr), + UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST); +} + +TEST_P(urEnqueueDeviceGetGlobalVariableWriteTest, + InvalidEventWaitListZeroSize) { + ur_event_handle_t evt = nullptr; + ASSERT_EQ_RESULT(urEnqueueDeviceGlobalVariableWrite( + queue, program, global_var.name.c_str(), true, + sizeof(global_var.value), 0, &global_var.value, 0, + &evt, nullptr), + UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST); +} +TEST_P(urEnqueueDeviceGetGlobalVariableWriteTest, + InvalidEventWaitInvalidEvent) { + ur_event_handle_t inv_evt = nullptr; + ASSERT_EQ_RESULT(urEnqueueDeviceGlobalVariableWrite( + queue, program, global_var.name.c_str(), true, + sizeof(global_var.value), 0, &global_var.value, 1, + &inv_evt, nullptr), + UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST); +} diff --git a/test/conformance/enqueue/urEnqueueMemImageCopy.cpp b/test/conformance/enqueue/urEnqueueMemImageCopy.cpp index 281aa8badb..d3cb5b566e 100644 --- a/test/conformance/enqueue/urEnqueueMemImageCopy.cpp +++ b/test/conformance/enqueue/urEnqueueMemImageCopy.cpp @@ -2,3 +2,246 @@ // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include + +struct urEnqueueMemImageCopyTest + : public uur::urQueueTestWithParam { + // Helper type so element offset calculations work the same as pixel offsets + struct rgba_pixel { + uint32_t data[4]; + }; + void SetUp() override { + UUR_RETURN_ON_FATAL_FAILURE(urQueueTestWithParam::SetUp()); + type = getParam(); + size = (type == UR_MEM_TYPE_IMAGE1D) ? ur_rect_region_t{width, 1, 1} + : (type == UR_MEM_TYPE_IMAGE2D) + ? ur_rect_region_t{width, height, 1} + : ur_rect_region_t{width, height, depth}; + buffSize = size.width * size.height * size.depth; + // Create a region that is half the size on each dimension so we can + // test partial copies of images + partialRegion = { + size.width / 2, + size.height > 1 ? size.height / 2 : 1, + size.depth > 1 ? size.depth / 2 : 1, + }; + // Create an offset that is the centre of the image on each dimension. + // Used with the above region to test partial copies to non-zero offsets + partialRegionOffset = { + size.width / 2, + size.height > 1 ? size.height / 2 : 0, + size.depth > 1 ? size.depth / 2 : 0, + }; + + ur_image_desc_t desc = {UR_STRUCTURE_TYPE_IMAGE_DESC, // stype + nullptr, // pNext + type, // mem object type + size.width, // image width + size.height, // image height + size.depth, // image depth + 1, // array size + 0, // row pitch + 0, // slice pitch + 0, // mip levels + 0}; // num samples + ASSERT_SUCCESS(urMemImageCreate(this->context, UR_MEM_FLAG_READ_WRITE, + &format, &desc, nullptr, &srcImage)); + ASSERT_SUCCESS(urMemImageCreate(this->context, UR_MEM_FLAG_READ_WRITE, + &format, &desc, nullptr, &dstImage)); + input.assign(buffSize, inputFill); + ASSERT_SUCCESS(urEnqueueMemImageWrite(queue, srcImage, true, origin, + size, 0, 0, input.data(), 0, + nullptr, nullptr)); + // Fill the dst image with arbitrary data that is different to the + // input image so we can test partial copies + std::vector dstData(buffSize, outputFill); + ASSERT_SUCCESS(urEnqueueMemImageWrite(queue, dstImage, true, origin, + size, 0, 0, dstData.data(), 0, + nullptr, nullptr)); + } + + void TearDown() override { + if (srcImage) { + EXPECT_SUCCESS(urMemRelease(dstImage)); + } + if (dstImage) { + EXPECT_SUCCESS(urMemRelease(dstImage)); + } + UUR_RETURN_ON_FATAL_FAILURE(urQueueTestWithParam::TearDown()); + } + + const size_t width = 32; + const size_t height = 8; + const size_t depth = 4; + const ur_rect_offset_t origin{0, 0, 0}; + const ur_image_format_t format = {UR_IMAGE_CHANNEL_ORDER_RGBA, + UR_IMAGE_CHANNEL_TYPE_FLOAT}; + const rgba_pixel inputFill = {42, 42, 42, 42}; + const rgba_pixel outputFill = {21, 21, 21, 21}; + + ur_mem_type_t type; + ur_rect_region_t size; + ur_rect_region_t partialRegion; + ur_rect_offset_t partialRegionOffset; + size_t buffSize; + ur_mem_handle_t srcImage = nullptr; + ur_mem_handle_t dstImage = nullptr; + std::vector input; +}; + +bool operator==(urEnqueueMemImageCopyTest::rgba_pixel lhs, + urEnqueueMemImageCopyTest::rgba_pixel rhs) { + return lhs.data[0] == rhs.data[0] && lhs.data[1] == rhs.data[1] && + lhs.data[2] == rhs.data[2] && lhs.data[3] == rhs.data[3]; +} + +template +inline std::string printImageCopyTestString( + const testing::TestParamInfo &info) { + // ParamType will be std::tuple + const auto device_handle = std::get<0>(info.param); + const auto platform_device_name = + uur::GetPlatformAndDeviceName(device_handle); + const auto image_type = std::get<1>(info.param); + auto test_name = (image_type == UR_MEM_TYPE_IMAGE1D) ? "1D" + : (image_type == UR_MEM_TYPE_IMAGE2D) ? "2D" + : "3D"; + return platform_device_name + "__" + test_name; +} + +UUR_TEST_SUITE_P(urEnqueueMemImageCopyTest, + testing::ValuesIn({UR_MEM_TYPE_IMAGE1D, UR_MEM_TYPE_IMAGE2D, + UR_MEM_TYPE_IMAGE3D}), + printImageCopyTestString); + +TEST_P(urEnqueueMemImageCopyTest, Success) { + ASSERT_SUCCESS(urEnqueueMemImageCopy(queue, srcImage, dstImage, {0, 0, 0}, + {0, 0, 0}, size, 0, nullptr, nullptr)); + std::vector output(buffSize, {1, 1, 1, 1}); + ASSERT_SUCCESS(urEnqueueMemImageRead(queue, dstImage, true, origin, size, 0, + 0, output.data(), 0, nullptr, + nullptr)); + ASSERT_EQ(input, output); +} + +TEST_P(urEnqueueMemImageCopyTest, SuccessPartialCopy) { + ASSERT_SUCCESS(urEnqueueMemImageCopy(queue, srcImage, dstImage, {0, 0, 0}, + {0, 0, 0}, partialRegion, 0, nullptr, + nullptr)); + std::vector output(buffSize, {0, 0, 0, 0}); + ASSERT_SUCCESS(urEnqueueMemImageRead(queue, dstImage, true, origin, size, 0, + 0, output.data(), 0, nullptr, + nullptr)); + + // Perform equivalent copy of the region on the host + std::vector expectedOutput(buffSize, outputFill); + for (size_t z = 0; z < partialRegion.depth; z++) { + for (size_t y = 0; y < partialRegion.height; y++) { + for (size_t x = 0; x < partialRegion.width; x++) { + size_t index = + (z * (size.width * size.height)) + (y * size.width) + x; + expectedOutput.data()[index] = input.data()[index]; + } + } + } + + ASSERT_EQ(expectedOutput, output); +} + +TEST_P(urEnqueueMemImageCopyTest, SuccessPartialCopyWithSrcOffset) { + ASSERT_SUCCESS(urEnqueueMemImageCopy(queue, srcImage, dstImage, + partialRegionOffset, {0, 0, 0}, + partialRegion, 0, nullptr, nullptr)); + std::vector output(buffSize, {0, 0, 0, 0}); + ASSERT_SUCCESS(urEnqueueMemImageRead(queue, dstImage, true, origin, size, 0, + 0, output.data(), 0, nullptr, + nullptr)); + + // Perform equivalent copy of the region on the host + std::vector expectedOutput(buffSize, outputFill); + for (size_t z = 0; z < partialRegion.depth; z++) { + for (size_t y = 0; y < partialRegion.height; y++) { + for (size_t x = 0; x < partialRegion.width; x++) { + size_t index = + (z * (size.width * size.height)) + (y * size.width) + x; + expectedOutput.data()[index] = input.data()[index]; + } + } + } + + ASSERT_EQ(expectedOutput, output); +} + +TEST_P(urEnqueueMemImageCopyTest, SuccessPartialCopyWithDstOffset) { + ASSERT_SUCCESS(urEnqueueMemImageCopy(queue, srcImage, dstImage, {0, 0, 0}, + partialRegionOffset, partialRegion, 0, + nullptr, nullptr)); + std::vector output(buffSize, {0, 0, 0, 0}); + ASSERT_SUCCESS(urEnqueueMemImageRead(queue, dstImage, true, origin, size, 0, + 0, output.data(), 0, nullptr, + nullptr)); + + // Perform equivalent copy of the region on the host + std::vector expectedOutput(buffSize, outputFill); + for (size_t z = partialRegionOffset.z; + z < partialRegionOffset.z + partialRegion.depth; z++) { + for (size_t y = partialRegionOffset.y; + y < partialRegionOffset.y + partialRegion.height; y++) { + for (size_t x = partialRegionOffset.x; + x < partialRegionOffset.x + partialRegion.width; x++) { + size_t index = + (z * (size.width * size.height)) + (y * size.width) + x; + expectedOutput.data()[index] = input.data()[index]; + } + } + } + + ASSERT_EQ(expectedOutput, output); +} + +TEST_P(urEnqueueMemImageCopyTest, InvalidNullHandleQueue) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urEnqueueMemImageCopy(nullptr, srcImage, dstImage, + {0, 0, 0}, {0, 0, 0}, size, 0, + nullptr, nullptr)); +} + +TEST_P(urEnqueueMemImageCopyTest, InvalidNullHandleImageSrc) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urEnqueueMemImageCopy(queue, nullptr, dstImage, {0, 0, 0}, + {0, 0, 0}, size, 0, nullptr, + nullptr)); +} + +TEST_P(urEnqueueMemImageCopyTest, InvalidNullHandleImageDst) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urEnqueueMemImageCopy(queue, srcImage, nullptr, {0, 0, 0}, + {0, 0, 0}, size, 0, nullptr, + nullptr)); +} + +TEST_P(urEnqueueMemImageCopyTest, InvalidNullPtrEventWaitList) { + ASSERT_EQ_RESULT(urEnqueueMemImageCopy(queue, srcImage, dstImage, {0, 0, 0}, + {0, 0, 0}, size, 1, nullptr, + nullptr), + UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST); + + ur_event_handle_t validEvent; + ASSERT_SUCCESS(urEnqueueEventsWait(queue, 0, nullptr, &validEvent)); + + ASSERT_EQ_RESULT(urEnqueueMemImageCopy(queue, srcImage, dstImage, {0, 0, 0}, + {0, 0, 0}, size, 0, &validEvent, + nullptr), + UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST); +} + +TEST_P(urEnqueueMemImageCopyTest, InvalidSize) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, + urEnqueueMemImageCopy(queue, srcImage, dstImage, {1, 0, 0}, + {0, 0, 0}, size, 0, nullptr, + nullptr)); + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, + urEnqueueMemImageCopy(queue, srcImage, dstImage, {0, 0, 0}, + {1, 0, 0}, size, 0, nullptr, + nullptr)); +} diff --git a/test/conformance/enqueue/urEnqueueMemImageFill.cpp b/test/conformance/enqueue/urEnqueueMemImageFill.cpp deleted file mode 100644 index 281aa8badb..0000000000 --- a/test/conformance/enqueue/urEnqueueMemImageFill.cpp +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (C) 2023 Intel Corporation -// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. -// See LICENSE.TXT -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception diff --git a/test/conformance/enqueue/urEnqueueMemImageMap.cpp b/test/conformance/enqueue/urEnqueueMemImageMap.cpp deleted file mode 100644 index 281aa8badb..0000000000 --- a/test/conformance/enqueue/urEnqueueMemImageMap.cpp +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (C) 2023 Intel Corporation -// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. -// See LICENSE.TXT -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception diff --git a/test/conformance/enqueue/urEnqueueMemImageRead.cpp b/test/conformance/enqueue/urEnqueueMemImageRead.cpp index 281aa8badb..d40625c3e1 100644 --- a/test/conformance/enqueue/urEnqueueMemImageRead.cpp +++ b/test/conformance/enqueue/urEnqueueMemImageRead.cpp @@ -2,3 +2,125 @@ // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include + +using urEnqueueMemImageReadTest = uur::urMemImageQueueTest; +UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urEnqueueMemImageReadTest); + +// Note that for each test, we multiply the size in pixels by 4 to account for +// each channel in the RGBA image + +TEST_P(urEnqueueMemImageReadTest, Success1D) { + std::vector output(width * 4, 42); + ASSERT_SUCCESS(urEnqueueMemImageRead(queue, image1D, true, origin, region1D, + 0, 0, output.data(), 0, nullptr, + nullptr)); +} + +TEST_P(urEnqueueMemImageReadTest, Success2D) { + std::vector output(width * height * 4, 42); + ASSERT_SUCCESS(urEnqueueMemImageRead(queue, image2D, true, origin, region2D, + 0, 0, output.data(), 0, nullptr, + nullptr)); +} + +TEST_P(urEnqueueMemImageReadTest, Success3D) { + std::vector output(width * height * depth * 4, 42); + ASSERT_SUCCESS(urEnqueueMemImageRead(queue, image3D, true, origin, region3D, + 0, 0, output.data(), 0, nullptr, + nullptr)); +} + +TEST_P(urEnqueueMemImageReadTest, InvalidNullHandleQueue) { + std::vector output(width * 4, 42); + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urEnqueueMemImageRead(nullptr, image1D, true, origin, + region1D, 0, 0, output.data(), 0, + nullptr, nullptr)); +} + +TEST_P(urEnqueueMemImageReadTest, InvalidNullHandleImage) { + std::vector output(width * 4, 42); + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urEnqueueMemImageRead(queue, nullptr, true, origin, + region1D, 0, 0, output.data(), 0, + nullptr, nullptr)); +} + +TEST_P(urEnqueueMemImageReadTest, InvalidNullPointerDst) { + std::vector output(width * 4, 42); + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, + urEnqueueMemImageRead(queue, image1D, true, origin, + region1D, 0, 0, nullptr, 0, nullptr, + nullptr)); +} + +TEST_P(urEnqueueMemImageReadTest, InvalidNullPtrEventWaitList) { + std::vector output(width * 4, 42); + ASSERT_EQ_RESULT(urEnqueueMemImageRead(queue, image1D, true, origin, + region1D, 0, 0, output.data(), 1, + nullptr, nullptr), + UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST); + + ur_event_handle_t validEvent; + ASSERT_SUCCESS(urEnqueueEventsWait(queue, 0, nullptr, &validEvent)); + + ASSERT_EQ_RESULT(urEnqueueMemImageRead(queue, image1D, true, origin, + region1D, 0, 0, output.data(), 0, + &validEvent, nullptr), + UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST); +} + +TEST_P(urEnqueueMemImageReadTest, InvalidOrigin1D) { + std::vector output(width * 4, 42); + ur_rect_offset_t bad_origin{1, 0, 0}; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, + urEnqueueMemImageRead(queue, image1D, true, bad_origin, + region1D, 0, 0, output.data(), 0, + nullptr, nullptr)); +} + +TEST_P(urEnqueueMemImageReadTest, InvalidOrigin2D) { + std::vector output(width * height * 4, 42); + ur_rect_offset_t bad_origin{0, 1, 0}; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, + urEnqueueMemImageRead(queue, image2D, true, bad_origin, + region2D, 0, 0, output.data(), 0, + nullptr, nullptr)); +} + +TEST_P(urEnqueueMemImageReadTest, InvalidOrigin3D) { + std::vector output(width * height * depth * 4, 42); + ur_rect_offset_t bad_origin{0, 0, 1}; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, + urEnqueueMemImageRead(queue, image3D, true, bad_origin, + region3D, 0, 0, output.data(), 0, + nullptr, nullptr)); +} + +TEST_P(urEnqueueMemImageReadTest, InvalidRegion1D) { + std::vector output(width * 4, 42); + ur_rect_region_t bad_region{width + 1, 1, 1}; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, + urEnqueueMemImageRead(queue, image1D, true, origin, + bad_region, 0, 0, output.data(), 0, + nullptr, nullptr)); +} + +TEST_P(urEnqueueMemImageReadTest, InvalidRegion2D) { + std::vector output(width * height * 4, 42); + ur_rect_region_t bad_region{width, height + 1, 1}; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, + urEnqueueMemImageRead(queue, image2D, true, origin, + bad_region, 0, 0, output.data(), 0, + nullptr, nullptr)); +} + +TEST_P(urEnqueueMemImageReadTest, InvalidRegion3D) { + std::vector output(width * height * depth * 4, 42); + ur_rect_region_t bad_region{width, height, depth + 1}; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, + urEnqueueMemImageRead(queue, image3D, true, origin, + bad_region, 0, 0, output.data(), 0, + nullptr, nullptr)); +} diff --git a/test/conformance/enqueue/urEnqueueMemImageWrite.cpp b/test/conformance/enqueue/urEnqueueMemImageWrite.cpp index 281aa8badb..7f7968bdff 100644 --- a/test/conformance/enqueue/urEnqueueMemImageWrite.cpp +++ b/test/conformance/enqueue/urEnqueueMemImageWrite.cpp @@ -2,3 +2,122 @@ // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include + +using urEnqueueMemImageWriteTest = uur::urMemImageQueueTest; +UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urEnqueueMemImageWriteTest); + +TEST_P(urEnqueueMemImageWriteTest, Success1D) { + std::vector input(width * 4, 42); + ASSERT_SUCCESS(urEnqueueMemImageWrite(queue, image1D, true, origin, + region1D, 0, 0, input.data(), 0, + nullptr, nullptr)); +} + +TEST_P(urEnqueueMemImageWriteTest, Success2D) { + std::vector input(width * height * 4, 42); + ASSERT_SUCCESS(urEnqueueMemImageWrite(queue, image2D, true, origin, + region2D, 0, 0, input.data(), 0, + nullptr, nullptr)); +} + +TEST_P(urEnqueueMemImageWriteTest, Success3D) { + std::vector input(width * height * depth * 4, 42); + ASSERT_SUCCESS(urEnqueueMemImageWrite(queue, image3D, true, origin, + region3D, 0, 0, input.data(), 0, + nullptr, nullptr)); +} + +TEST_P(urEnqueueMemImageWriteTest, InvalidNullHandleQueue) { + std::vector input(width * 4, 42); + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urEnqueueMemImageWrite(nullptr, image1D, true, origin, + region1D, 0, 0, input.data(), 0, + nullptr, nullptr)); +} + +TEST_P(urEnqueueMemImageWriteTest, InvalidNullHandleImage) { + std::vector input(width * 4, 42); + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urEnqueueMemImageWrite(queue, nullptr, true, origin, + region1D, 0, 0, input.data(), 0, + nullptr, nullptr)); +} + +TEST_P(urEnqueueMemImageWriteTest, InvalidNullPointerSrc) { + std::vector input(width * 4, 42); + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, + urEnqueueMemImageWrite(queue, image1D, true, origin, + region1D, 0, 0, nullptr, 0, nullptr, + nullptr)); +} + +TEST_P(urEnqueueMemImageWriteTest, InvalidNullPtrEventWaitList) { + std::vector input(width * 4, 42); + ASSERT_EQ_RESULT(urEnqueueMemImageWrite(queue, image1D, true, origin, + region1D, 0, 0, input.data(), 1, + nullptr, nullptr), + UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST); + + ur_event_handle_t validEvent; + ASSERT_SUCCESS(urEnqueueEventsWait(queue, 0, nullptr, &validEvent)); + + ASSERT_EQ_RESULT(urEnqueueMemImageWrite(queue, image1D, true, origin, + region1D, 0, 0, input.data(), 0, + &validEvent, nullptr), + UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST); +} + +TEST_P(urEnqueueMemImageWriteTest, InvalidOrigin1D) { + std::vector input(width * 4, 42); + ur_rect_offset_t bad_origin{1, 0, 0}; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, + urEnqueueMemImageWrite(queue, image1D, true, bad_origin, + region1D, 0, 0, input.data(), 0, + nullptr, nullptr)); +} + +TEST_P(urEnqueueMemImageWriteTest, InvalidOrigin2D) { + std::vector input(width * height * 4, 42); + ur_rect_offset_t bad_origin{0, 1, 0}; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, + urEnqueueMemImageWrite(queue, image2D, true, bad_origin, + region2D, 0, 0, input.data(), 0, + nullptr, nullptr)); +} + +TEST_P(urEnqueueMemImageWriteTest, InvalidOrigin3D) { + std::vector input(width * height * depth * 4, 42); + ur_rect_offset_t bad_origin{0, 0, 1}; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, + urEnqueueMemImageWrite(queue, image3D, true, bad_origin, + region3D, 0, 0, input.data(), 0, + nullptr, nullptr)); +} + +TEST_P(urEnqueueMemImageWriteTest, InvalidRegion1D) { + std::vector input(width * 4, 42); + ur_rect_region_t bad_region{width + 1, 1, 1}; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, + urEnqueueMemImageWrite(queue, image1D, true, origin, + bad_region, 0, 0, input.data(), 0, + nullptr, nullptr)); +} + +TEST_P(urEnqueueMemImageWriteTest, InvalidRegion2D) { + std::vector input(width * height * 4, 42); + ur_rect_region_t bad_region{width, height + 1, 1}; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, + urEnqueueMemImageWrite(queue, image2D, true, origin, + bad_region, 0, 0, input.data(), 0, + nullptr, nullptr)); +} + +TEST_P(urEnqueueMemImageWriteTest, InvalidRegion3D) { + std::vector input(width * height * depth * 4, 42); + ur_rect_region_t bad_region{width, height, depth + 1}; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, + urEnqueueMemImageWrite(queue, image3D, true, origin, + bad_region, 0, 0, input.data(), 0, + nullptr, nullptr)); +} diff --git a/test/conformance/event/urEventCreateWithNativeHandle.cpp b/test/conformance/event/urEventCreateWithNativeHandle.cpp index b8613540cb..3a2d6eea84 100644 --- a/test/conformance/event/urEventCreateWithNativeHandle.cpp +++ b/test/conformance/event/urEventCreateWithNativeHandle.cpp @@ -3,14 +3,30 @@ // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#include +#include "fixtures.h" -using urEventCreateWithNativeHandleTest = uur::urContextTest; +using urEventCreateWithNativeHandleTest = uur::event::urEventTest; UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urEventCreateWithNativeHandleTest); -TEST_P(urEventCreateWithNativeHandleTest, InvalidNullHandleNativeEvent) { - ur_event_handle_t event = nullptr; - ASSERT_EQ_RESULT( - UR_RESULT_ERROR_INVALID_NULL_HANDLE, - urEventCreateWithNativeHandle(nullptr, context, nullptr, &event)); +TEST_P(urEventCreateWithNativeHandleTest, Success) { + ur_native_handle_t native_event = nullptr; + if (urEventGetNativeHandle(event, &native_event)) { + GTEST_SKIP(); + } + + // We cannot assume anything about a native_handle, not even if it's + // `nullptr` since this could be a valid representation within a backend. + // We can however convert the native_handle back into a unified-runtime handle + // and perform some query on it to verify that it works. + ur_event_handle_t evt = nullptr; + ASSERT_SUCCESS( + urEventCreateWithNativeHandle(native_event, context, nullptr, &evt)); + ASSERT_NE(evt, nullptr); + + ur_execution_info_t exec_info; + ASSERT_SUCCESS(urEventGetInfo(evt, UR_EVENT_INFO_COMMAND_EXECUTION_STATUS, + sizeof(ur_execution_info_t), &exec_info, + nullptr)); + + ASSERT_SUCCESS(urEventRelease(evt)); } diff --git a/test/conformance/event/urEventGetNativeHandle.cpp b/test/conformance/event/urEventGetNativeHandle.cpp index b97f63c8ba..fa2a2cffdf 100644 --- a/test/conformance/event/urEventGetNativeHandle.cpp +++ b/test/conformance/event/urEventGetNativeHandle.cpp @@ -10,23 +10,9 @@ UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urEventGetNativeHandleTest); TEST_P(urEventGetNativeHandleTest, Success) { ur_native_handle_t native_event = nullptr; - ASSERT_SUCCESS(urEventGetNativeHandle(event, &native_event)); - - // We cannot assume anything about a native_handle, not even if it's - // `nullptr` since this could be a valid representation within a backend. - // We can however convert the native_handle back into a unified-runtime handle - // and perform some query on it to verify that it works. - ur_event_handle_t evt = nullptr; - ASSERT_SUCCESS( - urEventCreateWithNativeHandle(native_event, context, nullptr, &evt)); - ASSERT_NE(evt, nullptr); - - ur_execution_info_t exec_info; - ASSERT_SUCCESS(urEventGetInfo(evt, UR_EVENT_INFO_COMMAND_EXECUTION_STATUS, - sizeof(ur_execution_info_t), &exec_info, - nullptr)); - - ASSERT_SUCCESS(urEventRelease(evt)); + if (auto error = urEventGetNativeHandle(event, &native_event)) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_UNSUPPORTED_FEATURE, error); + } } TEST_P(urEventGetNativeHandleTest, InvalidNullHandleEvent) { diff --git a/test/conformance/kernel/urKernelCreateWithNativeHandle.cpp b/test/conformance/kernel/urKernelCreateWithNativeHandle.cpp index 365bc8cc08..7575fb309f 100644 --- a/test/conformance/kernel/urKernelCreateWithNativeHandle.cpp +++ b/test/conformance/kernel/urKernelCreateWithNativeHandle.cpp @@ -8,7 +8,9 @@ struct urKernelCreateWithNativeHandleTest : uur::urKernelTest { void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(urKernelTest::SetUp()); - ASSERT_SUCCESS(urKernelGetNativeHandle(kernel, &native_kernel_handle)); + if (urKernelGetNativeHandle(kernel, &native_kernel_handle)) { + GTEST_SKIP(); + } } void TearDown() override { @@ -54,13 +56,6 @@ TEST_P(urKernelCreateWithNativeHandleTest, InvalidNullHandleProgram) { &properties, &native_kernel)); } -TEST_P(urKernelCreateWithNativeHandleTest, InvalidNullHandleNativeKernel) { - ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, - urKernelCreateWithNativeHandle(nullptr, context, program, - &properties, - &native_kernel)); -} - TEST_P(urKernelCreateWithNativeHandleTest, InvalidNullPointerProperties) { ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, urKernelCreateWithNativeHandle(native_kernel_handle, diff --git a/test/conformance/kernel/urKernelGetNativeHandle.cpp b/test/conformance/kernel/urKernelGetNativeHandle.cpp index 8e83f7afb3..39978a9ad9 100644 --- a/test/conformance/kernel/urKernelGetNativeHandle.cpp +++ b/test/conformance/kernel/urKernelGetNativeHandle.cpp @@ -10,25 +10,9 @@ UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urKernelGetNativeHandleTest); TEST_P(urKernelGetNativeHandleTest, Success) { ur_native_handle_t native_kernel_handle = nullptr; - ASSERT_SUCCESS(urKernelGetNativeHandle(kernel, &native_kernel_handle)); - - ur_kernel_handle_t native_kernel = nullptr; - - ur_kernel_native_properties_t properties = { - UR_STRUCTURE_TYPE_KERNEL_NATIVE_PROPERTIES, /*sType*/ - nullptr, /*pNext*/ - true /*isNativeHandleOwned*/ - }; - ASSERT_SUCCESS(urKernelCreateWithNativeHandle( - native_kernel_handle, context, program, &properties, &native_kernel)); - - uint32_t ref_count = 0; - ASSERT_SUCCESS(urKernelGetInfo(native_kernel, - UR_KERNEL_INFO_REFERENCE_COUNT, - sizeof(ref_count), &ref_count, nullptr)); - ASSERT_NE(ref_count, 0); - - ASSERT_SUCCESS(urKernelRelease(native_kernel)); + if (auto error = urKernelGetNativeHandle(kernel, &native_kernel_handle)) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_UNSUPPORTED_FEATURE, error); + } } TEST_P(urKernelGetNativeHandleTest, InvalidNullHandleKernel) { diff --git a/test/conformance/kernel/urKernelSetArgPointer.cpp b/test/conformance/kernel/urKernelSetArgPointer.cpp index dfe1085990..4cb4cb2c8f 100644 --- a/test/conformance/kernel/urKernelSetArgPointer.cpp +++ b/test/conformance/kernel/urKernelSetArgPointer.cpp @@ -43,7 +43,8 @@ TEST_P(urKernelSetArgPointerTest, SuccessHost) { ASSERT_NE(allocation, nullptr); ASSERT_SUCCESS(urKernelSetArgPointer(kernel, 0, nullptr, &allocation)); - ASSERT_SUCCESS(urKernelSetArgValue(kernel, 1, sizeof(data), &data)); + ASSERT_SUCCESS( + urKernelSetArgValue(kernel, 1, sizeof(data), nullptr, &data)); Launch1DRange(array_size); ValidateAllocation(allocation); } @@ -60,7 +61,8 @@ TEST_P(urKernelSetArgPointerTest, SuccessDevice) { ASSERT_NE(allocation, nullptr); ASSERT_SUCCESS(urKernelSetArgPointer(kernel, 0, nullptr, &allocation)); - ASSERT_SUCCESS(urKernelSetArgValue(kernel, 1, sizeof(data), &data)); + ASSERT_SUCCESS( + urKernelSetArgValue(kernel, 1, sizeof(data), nullptr, &data)); Launch1DRange(array_size); // Copy the device allocation to a host one so we can validate the results. @@ -86,7 +88,8 @@ TEST_P(urKernelSetArgPointerTest, SuccessShared) { ASSERT_NE(allocation, nullptr); ASSERT_SUCCESS(urKernelSetArgPointer(kernel, 0, nullptr, &allocation)); - ASSERT_SUCCESS(urKernelSetArgValue(kernel, 1, sizeof(data), &data)); + ASSERT_SUCCESS( + urKernelSetArgValue(kernel, 1, sizeof(data), nullptr, &data)); Launch1DRange(array_size); ValidateAllocation(allocation); } diff --git a/test/conformance/memory/urMemBufferCreateWithNativeHandle.cpp b/test/conformance/memory/urMemBufferCreateWithNativeHandle.cpp index b5c470df72..2d6babd56e 100644 --- a/test/conformance/memory/urMemBufferCreateWithNativeHandle.cpp +++ b/test/conformance/memory/urMemBufferCreateWithNativeHandle.cpp @@ -8,9 +8,29 @@ using urMemBufferCreateWithNativeHandleTest = uur::urMemBufferTest; UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urMemBufferCreateWithNativeHandleTest); -TEST_P(urMemBufferCreateWithNativeHandleTest, InvalidNullHandleNativeMem) { +TEST_P(urMemBufferCreateWithNativeHandleTest, Success) { + ur_native_handle_t hNativeMem = nullptr; + if (urMemGetNativeHandle(buffer, &hNativeMem)) { + GTEST_SKIP(); + } + + // We cannot assume anything about a native_handle, not even if it's + // `nullptr` since this could be a valid representation within a backend. + // We can however convert the native_handle back into a unified-runtime handle + // and perform some query on it to verify that it works. ur_mem_handle_t mem = nullptr; - ASSERT_EQ_RESULT( - UR_RESULT_ERROR_INVALID_NULL_HANDLE, - urMemBufferCreateWithNativeHandle(nullptr, context, nullptr, &mem)); + ur_mem_native_properties_t props = { + /*.stype =*/UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES, + /*.pNext =*/nullptr, + /*.isNativeHandleOwned =*/false, + }; + ASSERT_SUCCESS( + urMemBufferCreateWithNativeHandle(hNativeMem, context, &props, &mem)); + ASSERT_NE(mem, nullptr); + + size_t alloc_size = 0; + ASSERT_SUCCESS(urMemGetInfo(mem, UR_MEM_INFO_SIZE, sizeof(size_t), + &alloc_size, nullptr)); + + ASSERT_SUCCESS(urMemRelease(mem)); } diff --git a/test/conformance/memory/urMemGetNativeHandle.cpp b/test/conformance/memory/urMemGetNativeHandle.cpp index 325986a23a..1dbb959c3f 100644 --- a/test/conformance/memory/urMemGetNativeHandle.cpp +++ b/test/conformance/memory/urMemGetNativeHandle.cpp @@ -9,27 +9,9 @@ UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urMemGetNativeHandleTest); TEST_P(urMemGetNativeHandleTest, Success) { ur_native_handle_t hNativeMem = nullptr; - ASSERT_SUCCESS(urMemGetNativeHandle(buffer, &hNativeMem)); - - // We cannot assume anything about a native_handle, not even if it's - // `nullptr` since this could be a valid representation within a backend. - // We can however convert the native_handle back into a unified-runtime handle - // and perform some query on it to verify that it works. - ur_mem_handle_t mem = nullptr; - ur_mem_native_properties_t props = { - /*.stype =*/UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES, - /*.pNext =*/nullptr, - /*.isNativeHandleOwned =*/false, - }; - ASSERT_SUCCESS( - urMemBufferCreateWithNativeHandle(hNativeMem, context, &props, &mem)); - ASSERT_NE(mem, nullptr); - - size_t alloc_size = 0; - ASSERT_SUCCESS(urMemGetInfo(mem, UR_MEM_INFO_SIZE, sizeof(size_t), - &alloc_size, nullptr)); - - ASSERT_SUCCESS(urMemRelease(mem)); + if (auto error = urMemGetNativeHandle(buffer, &hNativeMem)) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_UNSUPPORTED_FEATURE, error); + } } TEST_P(urMemGetNativeHandleTest, InvalidNullHandleMem) { diff --git a/test/conformance/memory/urMemImageCreateWithNativeHandle.cpp b/test/conformance/memory/urMemImageCreateWithNativeHandle.cpp index b5fa232a6f..f22e6c38e5 100644 --- a/test/conformance/memory/urMemImageCreateWithNativeHandle.cpp +++ b/test/conformance/memory/urMemImageCreateWithNativeHandle.cpp @@ -5,30 +5,25 @@ #include -using urMemImageCreateWithNativeHandleTest = uur::urMemBufferTest; +using urMemImageCreateWithNativeHandleTest = uur::urMemImageTest; UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urMemImageCreateWithNativeHandleTest); -TEST_P(urMemImageCreateWithNativeHandleTest, InvalidNullHandleNativeMem) { +TEST_P(urMemImageCreateWithNativeHandleTest, Success) { + ur_native_handle_t native_handle = nullptr; + if (urMemGetNativeHandle(image, &native_handle)) { + GTEST_SKIP(); + } + ur_mem_handle_t mem = nullptr; - ur_image_format_t imageFormat = { - /*.channelOrder =*/UR_IMAGE_CHANNEL_ORDER_ARGB, - /*.channelType =*/UR_IMAGE_CHANNEL_TYPE_UNORM_INT8, - }; - ur_image_desc_t imageDesc = { - /*.stype =*/UR_STRUCTURE_TYPE_IMAGE_DESC, - /*.pNext =*/nullptr, - /*.type =*/UR_MEM_TYPE_IMAGE2D, - /*.width =*/16, - /*.height =*/16, - /*.depth =*/1, - /*.arraySize =*/1, - /*.rowPitch =*/16, - /*.slicePitch =*/16 * 16, - /*.numMipLevel =*/0, - /*.numSamples =*/0, - }; - ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, - urMemImageCreateWithNativeHandle(nullptr, context, - &imageFormat, &imageDesc, - nullptr, &mem)); + ASSERT_EQ_RESULT( + UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urMemImageCreateWithNativeHandle(native_handle, context, &image_format, + &image_desc, nullptr, &mem)); + ASSERT_NE(nullptr, mem); + + ur_context_handle_t mem_context = nullptr; + ASSERT_SUCCESS(urMemGetInfo(mem, UR_MEM_INFO_CONTEXT, + sizeof(ur_context_handle_t), &mem_context, + nullptr)); + ASSERT_EQ(context, mem_context); } diff --git a/test/conformance/memory/urMemImageGetInfo.cpp b/test/conformance/memory/urMemImageGetInfo.cpp index 281aa8badb..48e6d6274f 100644 --- a/test/conformance/memory/urMemImageGetInfo.cpp +++ b/test/conformance/memory/urMemImageGetInfo.cpp @@ -2,3 +2,85 @@ // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include + +using urMemImageGetInfoTest = uur::urMemImageTestWithParam; + +static std::unordered_map image_info_size_map = { + {UR_IMAGE_INFO_FORMAT, sizeof(ur_image_format_t)}, + {UR_IMAGE_INFO_ELEMENT_SIZE, sizeof(size_t)}, + {UR_IMAGE_INFO_ROW_PITCH, sizeof(size_t)}, + {UR_IMAGE_INFO_SLICE_PITCH, sizeof(size_t)}, + {UR_IMAGE_INFO_WIDTH, sizeof(size_t)}, + {UR_IMAGE_INFO_HEIGHT, sizeof(size_t)}, + {UR_IMAGE_INFO_DEPTH, sizeof(size_t)}, +}; + +UUR_TEST_SUITE_P(urMemImageGetInfoTest, + ::testing::Values(UR_IMAGE_INFO_FORMAT, + UR_IMAGE_INFO_ELEMENT_SIZE, + UR_IMAGE_INFO_ROW_PITCH, + UR_IMAGE_INFO_SLICE_PITCH, + UR_IMAGE_INFO_WIDTH, UR_IMAGE_INFO_HEIGHT, + UR_IMAGE_INFO_DEPTH), + uur::deviceTestWithParamPrinter); + +TEST_P(urMemImageGetInfoTest, Success) { + ur_image_info_t info = getParam(); + size_t size; + ASSERT_SUCCESS(urMemImageGetInfo(image, info, 0, nullptr, &size)); + ASSERT_NE(size, 0); + + if (const auto expected_size = image_info_size_map.find(info); + expected_size != image_info_size_map.end()) { + ASSERT_EQ(expected_size->second, size); + } else { + FAIL() << "Missing info value in image info size map"; + } + + std::vector info_data(size); + ASSERT_SUCCESS( + urMemImageGetInfo(image, info, size, info_data.data(), nullptr)); +} + +TEST_P(urMemImageGetInfoTest, InvalidNullHandleImage) { + size_t info_size = 0; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urMemImageGetInfo(nullptr, UR_IMAGE_INFO_FORMAT, + sizeof(size_t), &info_size, nullptr)); +} + +TEST_P(urMemImageGetInfoTest, InvalidEnumerationImageInfoType) { + size_t info_size = 0; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_ENUMERATION, + urMemImageGetInfo(image, UR_IMAGE_INFO_FORCE_UINT32, + sizeof(size_t), &info_size, nullptr)); +} + +TEST_P(urMemImageGetInfoTest, InvalidSizeZero) { + size_t info_size = 0; + ASSERT_EQ_RESULT( + urMemImageGetInfo(image, UR_IMAGE_INFO_FORMAT, 0, &info_size, nullptr), + UR_RESULT_ERROR_INVALID_SIZE); +} + +TEST_P(urMemImageGetInfoTest, InvalidSizeSmall) { + int info_size = 0; + ASSERT_EQ_RESULT(urMemImageGetInfo(image, UR_IMAGE_INFO_FORMAT, + sizeof(info_size) - 1, &info_size, + nullptr), + UR_RESULT_ERROR_INVALID_SIZE); +} + +TEST_P(urMemImageGetInfoTest, InvalidNullPointerParamValue) { + size_t info_size = 0; + ASSERT_EQ_RESULT(urMemImageGetInfo(image, UR_IMAGE_INFO_FORMAT, + sizeof(info_size), nullptr, nullptr), + UR_RESULT_ERROR_INVALID_NULL_POINTER); +} + +TEST_P(urMemImageGetInfoTest, InvalidNullPointerPropSizeRet) { + ASSERT_EQ_RESULT( + urMemImageGetInfo(image, UR_IMAGE_INFO_FORMAT, 0, nullptr, nullptr), + UR_RESULT_ERROR_INVALID_NULL_POINTER); +} diff --git a/test/conformance/platform/CMakeLists.txt b/test/conformance/platform/CMakeLists.txt index cc87c7366a..eec1e9bee3 100644 --- a/test/conformance/platform/CMakeLists.txt +++ b/test/conformance/platform/CMakeLists.txt @@ -4,8 +4,9 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception add_conformance_test(platform - urInit.cpp + urPlatformCreateWithNativeHandle.cpp urPlatformGet.cpp + urPlatformGetApiVersion.cpp urPlatformGetBackendOption.cpp urPlatformGetInfo.cpp - urTearDown.cpp) + urPlatformGetNativeHandle.cpp) diff --git a/test/conformance/platform/fixtures.h b/test/conformance/platform/fixtures.h index 77f1f5465d..5b532fb433 100644 --- a/test/conformance/platform/fixtures.h +++ b/test/conformance/platform/fixtures.h @@ -14,13 +14,30 @@ struct urTest : ::testing::Test { void SetUp() override { ur_device_init_flags_t device_flags = 0; - ASSERT_SUCCESS(urInit(device_flags)); + ASSERT_SUCCESS(urLoaderConfigCreate(&loader_config)); + ASSERT_SUCCESS(urLoaderConfigEnableLayer(loader_config, + "UR_LAYER_FULL_VALIDATION")); + ASSERT_SUCCESS(urInit(device_flags, loader_config)); + + uint32_t adapter_count; + ASSERT_SUCCESS(urAdapterGet(0, nullptr, &adapter_count)); + adapters.resize(adapter_count); + ASSERT_SUCCESS(urAdapterGet(adapter_count, adapters.data(), nullptr)); } void TearDown() override { + for (auto adapter : adapters) { + ASSERT_SUCCESS(urAdapterRelease(adapter)); + } + if (loader_config) { + ASSERT_SUCCESS(urLoaderConfigRelease(loader_config)); + } ur_tear_down_params_t tear_down_params{}; ASSERT_SUCCESS(urTearDown(&tear_down_params)); } + + ur_loader_config_handle_t loader_config = nullptr; + std::vector adapters; }; struct urPlatformsTest : urTest { @@ -28,10 +45,14 @@ struct urPlatformsTest : urTest { void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(urTest::SetUp()); uint32_t count; - ASSERT_SUCCESS(urPlatformGet(0, nullptr, &count)); + ASSERT_SUCCESS(urPlatformGet(adapters.data(), + static_cast(adapters.size()), 0, + nullptr, &count)); ASSERT_NE(count, 0); platforms.resize(count); - ASSERT_SUCCESS(urPlatformGet(count, platforms.data(), nullptr)); + ASSERT_SUCCESS(urPlatformGet(adapters.data(), + static_cast(adapters.size()), + count, platforms.data(), nullptr)); } std::vector platforms; diff --git a/test/conformance/platform/urPlatformCreateWithNativeHandle.cpp b/test/conformance/platform/urPlatformCreateWithNativeHandle.cpp new file mode 100644 index 0000000000..6dd3310f6a --- /dev/null +++ b/test/conformance/platform/urPlatformCreateWithNativeHandle.cpp @@ -0,0 +1,43 @@ +// Copyright (C) 2022-2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include "fixtures.h" + +using urPlatformCreateWithNativeHandleTest = uur::platform::urPlatformTest; + +TEST_F(urPlatformCreateWithNativeHandleTest, Success) { + for (auto platform : platforms) { + ur_native_handle_t native_handle = nullptr; + if (urPlatformGetNativeHandle(platform, &native_handle)) { + continue; + }; + + // We cannot assume anything about a native_handle, not even if it's + // `nullptr` since this could be a valid representation within a backend. + // We can however convert the native_handle back into a unified-runtime + // handle and perform some query on it to verify that it works. + ur_platform_handle_t plat = nullptr; + ASSERT_SUCCESS( + urPlatformCreateWithNativeHandle(native_handle, nullptr, &plat)); + ASSERT_NE(plat, nullptr); + + ur_platform_backend_t backend; + ASSERT_SUCCESS(urPlatformGetInfo(plat, UR_PLATFORM_INFO_BACKEND, + sizeof(ur_platform_backend_t), + &backend, nullptr)); + } +} + +TEST_F(urPlatformCreateWithNativeHandleTest, InvalidNullPointerPlatform) { + for (auto platform : platforms) { + ur_native_handle_t native_handle = nullptr; + if (urPlatformGetNativeHandle(platform, &native_handle)) { + continue; + } + ASSERT_EQ_RESULT( + UR_RESULT_ERROR_INVALID_NULL_POINTER, + urPlatformCreateWithNativeHandle(native_handle, nullptr, nullptr)); + } +} diff --git a/test/conformance/platform/urPlatformGet.cpp b/test/conformance/platform/urPlatformGet.cpp index d7c369e0bd..2f3b28279d 100644 --- a/test/conformance/platform/urPlatformGet.cpp +++ b/test/conformance/platform/urPlatformGet.cpp @@ -9,10 +9,14 @@ using urPlatformGetTest = uur::platform::urTest; TEST_F(urPlatformGetTest, Success) { uint32_t count; - ASSERT_SUCCESS(urPlatformGet(0, nullptr, &count)); + ASSERT_SUCCESS(urPlatformGet(adapters.data(), + static_cast(adapters.size()), 0, + nullptr, &count)); ASSERT_NE(count, 0); std::vector platforms(count); - ASSERT_SUCCESS(urPlatformGet(count, platforms.data(), nullptr)); + ASSERT_SUCCESS(urPlatformGet(adapters.data(), + static_cast(adapters.size()), count, + platforms.data(), nullptr)); for (auto platform : platforms) { ASSERT_NE(nullptr, platform); } @@ -20,8 +24,12 @@ TEST_F(urPlatformGetTest, Success) { TEST_F(urPlatformGetTest, InvalidNumEntries) { uint32_t count; - ASSERT_SUCCESS(urPlatformGet(0, nullptr, &count)); + ASSERT_SUCCESS(urPlatformGet(adapters.data(), + static_cast(adapters.size()), 0, + nullptr, &count)); std::vector platforms(count); ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, - urPlatformGet(0, platforms.data(), nullptr)); + urPlatformGet(adapters.data(), + static_cast(adapters.size()), 0, + platforms.data(), nullptr)); } diff --git a/test/conformance/platform/urPlatformGetApiVersion.cpp b/test/conformance/platform/urPlatformGetApiVersion.cpp new file mode 100644 index 0000000000..10279d560a --- /dev/null +++ b/test/conformance/platform/urPlatformGetApiVersion.cpp @@ -0,0 +1,26 @@ +// Copyright (C) 2022-2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include "fixtures.h" + +using urPlatformGetApiVersionTest = uur::platform::urPlatformTest; + +TEST_F(urPlatformGetApiVersionTest, Success) { + ur_api_version_t version; + ASSERT_EQ_RESULT(UR_RESULT_SUCCESS, + urPlatformGetApiVersion(platform, &version)); + ASSERT_GE(UR_API_VERSION_CURRENT, version); +} + +TEST_F(urPlatformGetApiVersionTest, InvalidPlatform) { + ur_api_version_t version; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urPlatformGetApiVersion(nullptr, &version)); +} + +TEST_F(urPlatformGetApiVersionTest, InvalidVersionPtr) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, + urPlatformGetApiVersion(platform, nullptr)); +} diff --git a/test/conformance/platform/urPlatformGetNativeHandle.cpp b/test/conformance/platform/urPlatformGetNativeHandle.cpp new file mode 100644 index 0000000000..1a19cf4918 --- /dev/null +++ b/test/conformance/platform/urPlatformGetNativeHandle.cpp @@ -0,0 +1,30 @@ +// Copyright (C) 2022-2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include "fixtures.h" + +using urPlatformGetNativeHandleTest = uur::platform::urPlatformsTest; + +TEST_F(urPlatformGetNativeHandleTest, Success) { + for (auto platform : platforms) { + ur_native_handle_t native_handle = nullptr; + if (auto error = urPlatformGetNativeHandle(platform, &native_handle)) { + ASSERT_EQ(UR_RESULT_ERROR_UNSUPPORTED_FEATURE, error); + } + } +} + +TEST_F(urPlatformGetNativeHandleTest, InvalidNullHandlePlatform) { + ur_native_handle_t native_handle = nullptr; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urPlatformGetNativeHandle(nullptr, &native_handle)); +} + +TEST_F(urPlatformGetNativeHandleTest, InvalidNullPointerNativePlatform) { + for (auto platform : platforms) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, + urPlatformGetNativeHandle(platform, nullptr)); + } +} diff --git a/test/conformance/program/urProgramCreateWithNativeHandle.cpp b/test/conformance/program/urProgramCreateWithNativeHandle.cpp index 7a833c77e9..7e0400d294 100644 --- a/test/conformance/program/urProgramCreateWithNativeHandle.cpp +++ b/test/conformance/program/urProgramCreateWithNativeHandle.cpp @@ -25,8 +25,10 @@ struct urProgramCreateWithNativeHandleTest : uur::urProgramTest { UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urProgramCreateWithNativeHandleTest); TEST_P(urProgramCreateWithNativeHandleTest, Success) { - ASSERT_SUCCESS(urProgramCreateWithNativeHandle( - native_program_handle, context, nullptr, &native_program)); + if (urProgramCreateWithNativeHandle(native_program_handle, context, nullptr, + &native_program)) { + GTEST_SKIP(); + } uint32_t ref_count = 0; ASSERT_SUCCESS(urProgramGetInfo(native_program, @@ -43,12 +45,6 @@ TEST_P(urProgramCreateWithNativeHandleTest, InvalidNullHandleContext) { &native_program)); } -TEST_P(urProgramCreateWithNativeHandleTest, InvalidNullHandleNativeProgram) { - ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, - urProgramCreateWithNativeHandle(nullptr, context, nullptr, - &native_program)); -} - TEST_P(urProgramCreateWithNativeHandleTest, InvalidNullPointerProgram) { ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, urProgramCreateWithNativeHandle( diff --git a/test/conformance/program/urProgramGetNativeHandle.cpp b/test/conformance/program/urProgramGetNativeHandle.cpp index 9984fb7768..7f176263ad 100644 --- a/test/conformance/program/urProgramGetNativeHandle.cpp +++ b/test/conformance/program/urProgramGetNativeHandle.cpp @@ -10,19 +10,10 @@ UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urProgramGetNativeHandleTest); TEST_P(urProgramGetNativeHandleTest, Success) { ur_native_handle_t native_program_handle = nullptr; - ASSERT_SUCCESS(urProgramGetNativeHandle(program, &native_program_handle)); - - ur_program_handle_t native_program = nullptr; - ASSERT_SUCCESS(urProgramCreateWithNativeHandle( - native_program_handle, context, nullptr, &native_program)); - - uint32_t ref_count = 0; - ASSERT_SUCCESS(urProgramGetInfo(native_program, - UR_PROGRAM_INFO_REFERENCE_COUNT, - sizeof(ref_count), &ref_count, nullptr)); - ASSERT_NE(ref_count, 0); - - ASSERT_SUCCESS(urProgramRelease(native_program)); + if (auto error = + urProgramGetNativeHandle(program, &native_program_handle)) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_UNSUPPORTED_FEATURE, error); + } } TEST_P(urProgramGetNativeHandleTest, InvalidNullHandleProgram) { diff --git a/test/conformance/queue/urQueueCreateWithNativeHandle.cpp b/test/conformance/queue/urQueueCreateWithNativeHandle.cpp index cf326bc46e..01e7ca16d5 100644 --- a/test/conformance/queue/urQueueCreateWithNativeHandle.cpp +++ b/test/conformance/queue/urQueueCreateWithNativeHandle.cpp @@ -4,13 +4,28 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include -using urQueueCreateWithNativeHandleTest = uur::urContextTest; +using urQueueCreateWithNativeHandleTest = uur::urQueueTest; UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urQueueCreateWithNativeHandleTest); -TEST_P(urQueueCreateWithNativeHandleTest, InvalidNullHandleNativeQueue) { - ur_queue_handle_t queue = nullptr; +TEST_P(urQueueCreateWithNativeHandleTest, Success) { + ur_native_handle_t native_handle = nullptr; + if (urQueueGetNativeHandle(queue, nullptr, &native_handle)) { + GTEST_SKIP(); + } + + // We cannot assume anything about a native_handle, not even if it's + // `nullptr` since this could be a valid representation within a backend. + // We can however convert the native_handle back into a unified-runtime handle + // and perform some query on it to verify that it works. + ur_queue_handle_t q = nullptr; ur_queue_native_properties_t properties{}; - ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, - urQueueCreateWithNativeHandle(nullptr, context, device, - &properties, &queue)); + ASSERT_SUCCESS(urQueueCreateWithNativeHandle(native_handle, context, device, + &properties, &q)); + ASSERT_NE(q, nullptr); + + uint32_t q_size = 0; + ASSERT_SUCCESS(urQueueGetInfo(q, UR_QUEUE_INFO_SIZE, sizeof(uint32_t), + &q_size, nullptr)); + + ASSERT_SUCCESS(urQueueRelease(q)); } diff --git a/test/conformance/queue/urQueueGetNativeHandle.cpp b/test/conformance/queue/urQueueGetNativeHandle.cpp index 5702359b08..914ee21831 100644 --- a/test/conformance/queue/urQueueGetNativeHandle.cpp +++ b/test/conformance/queue/urQueueGetNativeHandle.cpp @@ -9,23 +9,9 @@ UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urQueueGetNativeHandleTest); TEST_P(urQueueGetNativeHandleTest, Success) { ur_native_handle_t native_handle = nullptr; - ASSERT_SUCCESS(urQueueGetNativeHandle(queue, nullptr, &native_handle)); - - // We cannot assume anything about a native_handle, not even if it's - // `nullptr` since this could be a valid representation within a backend. - // We can however convert the native_handle back into a unified-runtime handle - // and perform some query on it to verify that it works. - ur_queue_handle_t q = nullptr; - ur_queue_native_properties_t properties{}; - ASSERT_SUCCESS(urQueueCreateWithNativeHandle(native_handle, context, device, - &properties, &q)); - ASSERT_NE(q, nullptr); - - uint32_t q_size = 0; - ASSERT_SUCCESS(urQueueGetInfo(q, UR_QUEUE_INFO_SIZE, sizeof(uint32_t), - &q_size, nullptr)); - - ASSERT_SUCCESS(urQueueRelease(q)); + if (auto error = urQueueGetNativeHandle(queue, nullptr, &native_handle)) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_UNSUPPORTED_FEATURE, error); + } } TEST_P(urQueueGetNativeHandleTest, InvalidNullHandleQueue) { diff --git a/test/conformance/runtime/CMakeLists.txt b/test/conformance/runtime/CMakeLists.txt new file mode 100644 index 0000000000..8c46abd82b --- /dev/null +++ b/test/conformance/runtime/CMakeLists.txt @@ -0,0 +1,13 @@ +# Copyright (C) 2023 Intel Corporation +# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +# See LICENSE.TXT +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +add_conformance_test(runtime + urAdapterGet.cpp + urAdapterGetInfo.cpp + urAdapterGetLastError.cpp + urAdapterRetain.cpp + urAdapterRelease.cpp + urInit.cpp + urTearDown.cpp) diff --git a/test/conformance/runtime/fixtures.h b/test/conformance/runtime/fixtures.h new file mode 100644 index 0000000000..04f72617dd --- /dev/null +++ b/test/conformance/runtime/fixtures.h @@ -0,0 +1,53 @@ +// Copyright (C) 2022-2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +namespace uur { +namespace runtime { + +struct urTest : ::testing::Test { + + void SetUp() override { + ur_device_init_flags_t device_flags = 0; + ASSERT_SUCCESS(urLoaderConfigCreate(&loader_config)); + ASSERT_SUCCESS(urLoaderConfigEnableLayer(loader_config, + "UR_LAYER_FULL_VALIDATION")); + ASSERT_SUCCESS(urInit(device_flags, loader_config)); + } + + void TearDown() override { + if (loader_config) { + ASSERT_SUCCESS(urLoaderConfigRelease(loader_config)); + } + ur_tear_down_params_t tear_down_params{}; + ASSERT_SUCCESS(urTearDown(&tear_down_params)); + } + + ur_loader_config_handle_t loader_config = nullptr; +}; + +struct urAdapterTest : urTest { + + void SetUp() override { + UUR_RETURN_ON_FATAL_FAILURE(urTest::SetUp()); + + uint32_t adapter_count; + ASSERT_SUCCESS(urAdapterGet(0, nullptr, &adapter_count)); + adapters.resize(adapter_count); + ASSERT_SUCCESS(urAdapterGet(adapter_count, adapters.data(), nullptr)); + } + + void TearDown() override { + for (auto adapter : adapters) { + ASSERT_SUCCESS(urAdapterRelease(adapter)); + } + UUR_RETURN_ON_FATAL_FAILURE(urTest::TearDown()); + } + + std::vector adapters; +}; + +} // namespace runtime +} // namespace uur diff --git a/test/conformance/runtime/urAdapterGet.cpp b/test/conformance/runtime/urAdapterGet.cpp new file mode 100644 index 0000000000..2c3b62a620 --- /dev/null +++ b/test/conformance/runtime/urAdapterGet.cpp @@ -0,0 +1,22 @@ +// Copyright (C) 2022-2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include "fixtures.h" + +using urAdapterGetTest = uur::runtime::urTest; + +TEST_F(urAdapterGetTest, Success) { + uint32_t adapter_count; + ASSERT_SUCCESS(urAdapterGet(0, nullptr, &adapter_count)); + std::vector adapters(adapter_count); + ASSERT_SUCCESS(urAdapterGet(adapter_count, adapters.data(), nullptr)); +} + +TEST_F(urAdapterGetTest, InvalidNumEntries) { + uint32_t adapter_count; + ASSERT_SUCCESS(urAdapterGet(0, nullptr, &adapter_count)); + std::vector adapters(adapter_count); + ASSERT_SUCCESS(urAdapterGet(0, adapters.data(), nullptr)); +} diff --git a/test/conformance/runtime/urAdapterGetInfo.cpp b/test/conformance/runtime/urAdapterGetInfo.cpp new file mode 100644 index 0000000000..6eea5182d8 --- /dev/null +++ b/test/conformance/runtime/urAdapterGetInfo.cpp @@ -0,0 +1,89 @@ +// Copyright (C) 2022-2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include "fixtures.h" + +#include + +struct urAdapterGetInfoTest : uur::runtime::urAdapterTest, + ::testing::WithParamInterface { + + void SetUp() { + UUR_RETURN_ON_FATAL_FAILURE(uur::runtime::urAdapterTest::SetUp()); + adapter = adapters[0]; + } + + ur_adapter_handle_t adapter; +}; + +std::unordered_map adapter_info_size_map = { + {UR_ADAPTER_INFO_BACKEND, sizeof(ur_adapter_backend_t)}, + {UR_ADAPTER_INFO_REFERENCE_COUNT, sizeof(uint32_t)}, +}; + +INSTANTIATE_TEST_SUITE_P( + urAdapterGetInfo, urAdapterGetInfoTest, + ::testing::Values(UR_ADAPTER_INFO_BACKEND, UR_ADAPTER_INFO_REFERENCE_COUNT), + [](const ::testing::TestParamInfo &info) { + std::stringstream ss; + ss << info.param; + return ss.str(); + }); + +TEST_P(urAdapterGetInfoTest, Success) { + size_t size = 0; + ur_adapter_info_t info_type = GetParam(); + ASSERT_SUCCESS(urAdapterGetInfo(adapter, info_type, 0, nullptr, &size)); + ASSERT_NE(size, 0); + + if (const auto expected_size = adapter_info_size_map.find(info_type); + expected_size != adapter_info_size_map.end()) { + ASSERT_EQ(expected_size->second, size); + } + + std::vector info_data(size); + ASSERT_SUCCESS( + urAdapterGetInfo(adapter, info_type, size, info_data.data(), nullptr)); +} + +TEST_P(urAdapterGetInfoTest, InvalidNullHandleAdapter) { + size_t size = 0; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urAdapterGetInfo(nullptr, GetParam(), 0, nullptr, &size)); +} + +TEST_F(urAdapterGetInfoTest, InvalidEnumerationAdapterInfoType) { + size_t size = 0; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_ENUMERATION, + urAdapterGetInfo(adapter, UR_ADAPTER_INFO_FORCE_UINT32, 0, + nullptr, &size)); +} + +TEST_F(urAdapterGetInfoTest, InvalidSizeZero) { + ur_adapter_backend_t backend; + ASSERT_EQ_RESULT(urAdapterGetInfo(adapter, UR_ADAPTER_INFO_BACKEND, 0, + &backend, nullptr), + UR_RESULT_ERROR_INVALID_SIZE); +} + +TEST_F(urAdapterGetInfoTest, InvalidSizeSmall) { + ur_adapter_backend_t backend; + ASSERT_EQ_RESULT(urAdapterGetInfo(adapter, UR_ADAPTER_INFO_BACKEND, + sizeof(backend) - 1, &backend, nullptr), + UR_RESULT_ERROR_INVALID_SIZE); +} + +TEST_F(urAdapterGetInfoTest, InvalidNullPointerPropValue) { + ur_adapter_backend_t backend; + ASSERT_EQ_RESULT(urAdapterGetInfo(adapter, UR_ADAPTER_INFO_BACKEND, + sizeof(backend), nullptr, nullptr), + UR_RESULT_ERROR_INVALID_NULL_POINTER); +} + +TEST_F(urAdapterGetInfoTest, InvalidNullPointerPropSizeRet) { + ASSERT_EQ_RESULT( + urAdapterGetInfo(adapter, UR_ADAPTER_INFO_BACKEND, 0, nullptr, nullptr), + UR_RESULT_ERROR_INVALID_NULL_POINTER); +} diff --git a/test/conformance/runtime/urAdapterGetLastError.cpp b/test/conformance/runtime/urAdapterGetLastError.cpp new file mode 100644 index 0000000000..a82b0664f0 --- /dev/null +++ b/test/conformance/runtime/urAdapterGetLastError.cpp @@ -0,0 +1,35 @@ +// Copyright (C) 2022-2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include "fixtures.h" + +struct urAdapterGetLastErrorTest : uur::runtime::urAdapterTest { + int32_t error; + const char *message = nullptr; +}; + +TEST_F(urAdapterGetLastErrorTest, Success) { + // We can't reliably generate a UR_RESULT_ERROR_ADAPTER_SPECIFIC error to + // test the full functionality of this entry point, so instead do a minimal + // smoke test and check that the call returns successfully, even if no + // actual error was set. + ASSERT_EQ_RESULT(UR_RESULT_SUCCESS, + urAdapterGetLastError(adapters[0], &message, &error)); +} + +TEST_F(urAdapterGetLastErrorTest, InvalidHandle) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urAdapterGetLastError(nullptr, &message, &error)); +} + +TEST_F(urAdapterGetLastErrorTest, InvalidMessagePtr) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, + urAdapterGetLastError(adapters[0], nullptr, &error)); +} + +TEST_F(urAdapterGetLastErrorTest, InvalidErrorPtr) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, + urAdapterGetLastError(adapters[0], &message, nullptr)); +} diff --git a/test/conformance/runtime/urAdapterRelease.cpp b/test/conformance/runtime/urAdapterRelease.cpp new file mode 100644 index 0000000000..e7c5bd11ce --- /dev/null +++ b/test/conformance/runtime/urAdapterRelease.cpp @@ -0,0 +1,25 @@ +// Copyright (C) 2022-2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include "fixtures.h" + +struct urAdapterReleaseTest : uur::runtime::urAdapterTest { + void SetUp() { + UUR_RETURN_ON_FATAL_FAILURE(uur::runtime::urAdapterTest::SetUp()); + adapter = adapters[0]; + } + + ur_adapter_handle_t adapter; +}; + +TEST_F(urAdapterReleaseTest, Success) { + ASSERT_SUCCESS(urAdapterRetain(adapter)); + EXPECT_SUCCESS(urAdapterRelease(adapter)); +} + +TEST_F(urAdapterReleaseTest, InvalidNullHandleAdapter) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urAdapterRelease(nullptr)); +} diff --git a/test/conformance/runtime/urAdapterRetain.cpp b/test/conformance/runtime/urAdapterRetain.cpp new file mode 100644 index 0000000000..2a5efd0344 --- /dev/null +++ b/test/conformance/runtime/urAdapterRetain.cpp @@ -0,0 +1,25 @@ +// Copyright (C) 2022-2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include "fixtures.h" + +struct urAdapterRetainTest : uur::runtime::urAdapterTest { + void SetUp() { + UUR_RETURN_ON_FATAL_FAILURE(uur::runtime::urAdapterTest::SetUp()); + adapter = adapters[0]; + } + + ur_adapter_handle_t adapter; +}; + +TEST_F(urAdapterRetainTest, Success) { + ASSERT_SUCCESS(urAdapterRetain(adapter)); + EXPECT_SUCCESS(urAdapterRelease(adapter)); +} + +TEST_F(urAdapterRetainTest, InvalidNullHandleAdapter) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urAdapterRetain(nullptr)); +} diff --git a/test/conformance/platform/urInit.cpp b/test/conformance/runtime/urInit.cpp similarity index 81% rename from test/conformance/platform/urInit.cpp rename to test/conformance/runtime/urInit.cpp index eedf58af34..1de30ff471 100644 --- a/test/conformance/platform/urInit.cpp +++ b/test/conformance/runtime/urInit.cpp @@ -20,8 +20,12 @@ INSTANTIATE_TEST_SUITE_P( }); TEST_P(urInitTestWithParam, Success) { + ur_loader_config_handle_t config = nullptr; + urLoaderConfigCreate(&config); + urLoaderConfigEnableLayer(config, "UR_LAYER_FULL_VALIDATION"); + ur_device_init_flags_t device_flags = GetParam(); - ASSERT_SUCCESS(urInit(device_flags)); + ASSERT_SUCCESS(urInit(device_flags, config)); ur_tear_down_params_t tear_down_params{nullptr}; ASSERT_SUCCESS(urTearDown(&tear_down_params)); @@ -30,5 +34,6 @@ TEST_P(urInitTestWithParam, Success) { TEST(urInitTest, ErrorInvalidEnumerationDeviceFlags) { const ur_device_init_flags_t device_flags = UR_DEVICE_INIT_FLAG_FORCE_UINT32; - ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_ENUMERATION, urInit(device_flags)); + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_ENUMERATION, + urInit(device_flags, nullptr)); } diff --git a/test/conformance/platform/urTearDown.cpp b/test/conformance/runtime/urTearDown.cpp similarity index 92% rename from test/conformance/platform/urTearDown.cpp rename to test/conformance/runtime/urTearDown.cpp index e4dd0bbcb8..3639515f82 100644 --- a/test/conformance/platform/urTearDown.cpp +++ b/test/conformance/runtime/urTearDown.cpp @@ -7,7 +7,7 @@ struct urTearDownTest : testing::Test { void SetUp() override { ur_device_init_flags_t device_flags = 0; - ASSERT_SUCCESS(urInit(device_flags)); + ASSERT_SUCCESS(urInit(device_flags, nullptr)); } }; diff --git a/test/conformance/sampler/urSamplerCreateWithNativeHandle.cpp b/test/conformance/sampler/urSamplerCreateWithNativeHandle.cpp index f9f114ffe0..1954b93096 100644 --- a/test/conformance/sampler/urSamplerCreateWithNativeHandle.cpp +++ b/test/conformance/sampler/urSamplerCreateWithNativeHandle.cpp @@ -5,14 +5,28 @@ #include -using urSamplerCreateWithNativeHandleTest = uur::urContextTest; +using urSamplerCreateWithNativeHandleTest = uur::urSamplerTest; UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urSamplerCreateWithNativeHandleTest); -TEST_P(urSamplerCreateWithNativeHandleTest, InvalidNullHandleNativeHandle) { - ur_sampler_handle_t sampler = nullptr; +TEST_P(urSamplerCreateWithNativeHandleTest, Success) { + ur_native_handle_t native_sampler = nullptr; + if (urSamplerGetNativeHandle(sampler, &native_sampler)) { + GTEST_SKIP(); + } + + // We cannot assume anything about a native_handle, not even if it's + // `nullptr` since this could be a valid representation within a backend. + // We can however convert the native_handle back into a unified-runtime handle + // and perform some query on it to verify that it works. + ur_sampler_handle_t hSampler = nullptr; ur_sampler_native_properties_t props{}; - ASSERT_EQ_RESULT( - UR_RESULT_ERROR_INVALID_NULL_HANDLE, - urSamplerCreateWithNativeHandle(nullptr, context, &props, &sampler)); + ASSERT_SUCCESS(urSamplerCreateWithNativeHandle(native_sampler, context, + &props, &hSampler)); + ASSERT_NE(hSampler, nullptr); + + ur_sampler_addressing_mode_t addr_mode; + ASSERT_SUCCESS(urSamplerGetInfo(hSampler, UR_SAMPLER_INFO_ADDRESSING_MODE, + sizeof(addr_mode), &addr_mode, nullptr)); + ASSERT_EQ(addr_mode, sampler_desc.addressingMode); } diff --git a/test/conformance/sampler/urSamplerGetNativeHandle.cpp b/test/conformance/sampler/urSamplerGetNativeHandle.cpp index 5f7ed7508a..7fcb8a20ad 100644 --- a/test/conformance/sampler/urSamplerGetNativeHandle.cpp +++ b/test/conformance/sampler/urSamplerGetNativeHandle.cpp @@ -11,22 +11,9 @@ UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urSamplerGetNativeHandleTest); TEST_P(urSamplerGetNativeHandleTest, Success) { ur_native_handle_t native_sampler = nullptr; - ASSERT_SUCCESS(urSamplerGetNativeHandle(sampler, &native_sampler)); - - // We cannot assume anything about a native_handle, not even if it's - // `nullptr` since this could be a valid representation within a backend. - // We can however convert the native_handle back into a unified-runtime handle - // and perform some query on it to verify that it works. - ur_sampler_handle_t hSampler = nullptr; - ur_sampler_native_properties_t props{}; - ASSERT_SUCCESS(urSamplerCreateWithNativeHandle(native_sampler, context, - &props, &hSampler)); - ASSERT_NE(hSampler, nullptr); - - ur_sampler_addressing_mode_t addr_mode; - ASSERT_SUCCESS(urSamplerGetInfo(hSampler, UR_SAMPLER_INFO_ADDRESSING_MODE, - sizeof(addr_mode), &addr_mode, nullptr)); - ASSERT_EQ(addr_mode, sampler_desc.addressingMode); + if (auto error = urSamplerGetNativeHandle(sampler, &native_sampler)) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_UNSUPPORTED_FEATURE, error); + } } TEST_P(urSamplerGetNativeHandleTest, InvalidNullHandleSampler) { diff --git a/test/conformance/source/environment.cpp b/test/conformance/source/environment.cpp index 1da7ad7c86..287310f679 100644 --- a/test/conformance/source/environment.cpp +++ b/test/conformance/source/environment.cpp @@ -43,8 +43,23 @@ std::ostream &operator<<(std::ostream &out, uur::PlatformEnvironment::PlatformEnvironment(int argc, char **argv) : platform_options{parsePlatformOptions(argc, argv)} { instance = this; + + ur_loader_config_handle_t config; + if (urLoaderConfigCreate(&config) == UR_RESULT_SUCCESS) { + if (urLoaderConfigEnableLayer(config, "UR_LAYER_FULL_VALIDATION")) { + urLoaderConfigRelease(config); + error = "Failed to enable validation layer"; + return; + } + } else { + error = "Failed to create loader config handle"; + return; + } + ur_device_init_flags_t device_flags = 0; - switch (urInit(device_flags)) { + auto initResult = urInit(device_flags, config); + auto configReleaseResult = urLoaderConfigRelease(config); + switch (initResult) { case UR_RESULT_SUCCESS: break; case UR_RESULT_ERROR_UNINITIALIZED: @@ -55,8 +70,18 @@ uur::PlatformEnvironment::PlatformEnvironment(int argc, char **argv) return; } + if (configReleaseResult) { + error = "Failed to destroy loader config handle"; + return; + } + + uint32_t adapter_count = 0; + urAdapterGet(0, nullptr, &adapter_count); + adapters.resize(adapter_count); + urAdapterGet(adapter_count, adapters.data(), nullptr); + uint32_t count = 0; - if (urPlatformGet(0, nullptr, &count)) { + if (urPlatformGet(adapters.data(), adapter_count, 0, nullptr, &count)) { error = "urPlatformGet() failed to get number of platforms."; return; } @@ -67,7 +92,8 @@ uur::PlatformEnvironment::PlatformEnvironment(int argc, char **argv) } std::vector platforms(count); - if (urPlatformGet(count, platforms.data(), nullptr)) { + if (urPlatformGet(adapters.data(), adapter_count, count, platforms.data(), + nullptr)) { error = "urPlatformGet failed to get platforms."; return; } @@ -130,6 +156,9 @@ void uur::PlatformEnvironment::TearDown() { if (error == ERROR_NO_ADAPTER) { return; } + for (auto adapter : adapters) { + urAdapterRelease(adapter); + } ur_tear_down_params_t tear_down_params{}; if (urTearDown(&tear_down_params)) { FAIL() << "urTearDown() failed"; diff --git a/test/conformance/testing/CMakeLists.txt b/test/conformance/testing/CMakeLists.txt index a894478fe4..47e90915ed 100644 --- a/test/conformance/testing/CMakeLists.txt +++ b/test/conformance/testing/CMakeLists.txt @@ -3,7 +3,7 @@ # See LICENSE.TXT # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -add_library(ur_testing STATIC +add_ur_library(ur_testing STATIC source/utils.cpp) target_include_directories(ur_testing PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) target_link_libraries(ur_testing PRIVATE gtest_main unified-runtime::headers) diff --git a/test/conformance/testing/include/uur/environment.h b/test/conformance/testing/include/uur/environment.h index f42c5a6436..5cc6756364 100644 --- a/test/conformance/testing/include/uur/environment.h +++ b/test/conformance/testing/include/uur/environment.h @@ -28,6 +28,7 @@ struct PlatformEnvironment : ::testing::Environment { PlatformOptions parsePlatformOptions(int argc, char **argv); PlatformOptions platform_options; + std::vector adapters{}; ur_platform_handle_t platform = nullptr; std::string error; static PlatformEnvironment *instance; diff --git a/test/conformance/testing/include/uur/fixtures.h b/test/conformance/testing/include/uur/fixtures.h index 249fc795b5..7765e00ade 100644 --- a/test/conformance/testing/include/uur/fixtures.h +++ b/test/conformance/testing/include/uur/fixtures.h @@ -54,7 +54,6 @@ inline bool hasDevicePartitionSupport(ur_device_handle_t device, } struct urAllDevicesTest : urPlatformTest { - void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(urPlatformTest::SetUp()); auto devicesPair = GetDevices(platform); @@ -76,7 +75,6 @@ struct urAllDevicesTest : urPlatformTest { struct urDeviceTest : urPlatformTest, ::testing::WithParamInterface { - void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(urPlatformTest::SetUp()); device = GetParam(); @@ -138,7 +136,6 @@ struct urContextTest : urDeviceTest { }; struct urSamplerTest : urContextTest { - void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(urContextTest::SetUp()); sampler_desc = { @@ -161,7 +158,6 @@ struct urSamplerTest : urContextTest { }; struct urMemBufferTest : urContextTest { - void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(urContextTest::SetUp()); ASSERT_SUCCESS(urMemBufferCreate(context, UR_MEM_FLAG_READ_WRITE, 4096, @@ -179,6 +175,38 @@ struct urMemBufferTest : urContextTest { ur_mem_handle_t buffer = nullptr; }; +struct urMemImageTest : urContextTest { + void SetUp() override { + UUR_RETURN_ON_FATAL_FAILURE(urContextTest::SetUp()); + } + + void TearDown() override { + if (image) { + EXPECT_SUCCESS(urMemRelease(image)); + } + UUR_RETURN_ON_FATAL_FAILURE(urContextTest::TearDown()); + } + + ur_image_format_t image_format = { + /*.channelOrder =*/UR_IMAGE_CHANNEL_ORDER_ARGB, + /*.channelType =*/UR_IMAGE_CHANNEL_TYPE_UNORM_INT8, + }; + ur_image_desc_t image_desc = { + /*.stype =*/UR_STRUCTURE_TYPE_IMAGE_DESC, + /*.pNext =*/nullptr, + /*.type =*/UR_MEM_TYPE_IMAGE2D, + /*.width =*/16, + /*.height =*/16, + /*.depth =*/1, + /*.arraySize =*/1, + /*.rowPitch =*/16 * sizeof(char[4]), + /*.slicePitch =*/16 * 16 * sizeof(char[4]), + /*.numMipLevel =*/0, + /*.numSamples =*/0, + }; + ur_mem_handle_t image = nullptr; +}; + } // namespace uur #define UUR_TEST_SUITE_P(FIXTURE, VALUES, PRINTER) \ @@ -205,7 +233,6 @@ template struct urContextTestWithParam : urDeviceTestWithParam { }; template struct urSamplerTestWithParam : urContextTestWithParam { - void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(urContextTestWithParam::SetUp()); sampler_desc = { @@ -244,6 +271,36 @@ template struct urMemBufferTestWithParam : urContextTestWithParam { ur_mem_handle_t buffer = nullptr; }; +template struct urMemImageTestWithParam : urContextTestWithParam { + void SetUp() override { + UUR_RETURN_ON_FATAL_FAILURE(urContextTestWithParam::SetUp()); + ASSERT_SUCCESS(urMemImageCreate(this->context, UR_MEM_FLAG_READ_WRITE, + &format, &desc, nullptr, &image)); + ASSERT_NE(nullptr, image); + } + + void TearDown() override { + if (image) { + EXPECT_SUCCESS(urMemRelease(image)); + } + UUR_RETURN_ON_FATAL_FAILURE(urContextTestWithParam::TearDown()); + } + ur_mem_handle_t image = nullptr; + ur_image_format_t format = {UR_IMAGE_CHANNEL_ORDER_RGBA, + UR_IMAGE_CHANNEL_TYPE_FLOAT}; + ur_image_desc_t desc = {UR_STRUCTURE_TYPE_IMAGE_DESC, // stype + nullptr, // pNext + UR_MEM_TYPE_IMAGE1D, // mem object type + 1024, // image width + 1, // image height + 1, // image depth + 1, // array size + 0, // row pitch + 0, // slice pitch + 0, // mip levels + 0}; // num samples +}; + struct urQueueTest : urContextTest { void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(urContextTest::SetUp()); @@ -305,7 +362,6 @@ struct urHostPipeTest : urQueueTest { }; template struct urQueueTestWithParam : urContextTestWithParam { - void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(urContextTestWithParam::SetUp()); ASSERT_SUCCESS(urQueueCreate(this->context, this->device, 0, &queue)); @@ -468,6 +524,81 @@ struct urMemBufferQueueTest : urQueueTest { ur_mem_handle_t buffer = nullptr; }; +struct urMemImageQueueTest : urQueueTest { + void SetUp() override { + UUR_RETURN_ON_FATAL_FAILURE(urQueueTest::SetUp()); + ASSERT_SUCCESS(urMemImageCreate(this->context, UR_MEM_FLAG_READ_WRITE, + &format, &desc1D, nullptr, &image1D)); + + ASSERT_SUCCESS(urMemImageCreate(this->context, UR_MEM_FLAG_READ_WRITE, + &format, &desc2D, nullptr, &image2D)); + + ASSERT_SUCCESS(urMemImageCreate(this->context, UR_MEM_FLAG_READ_WRITE, + &format, &desc3D, nullptr, &image3D)); + } + + void TearDown() override { + if (image1D) { + EXPECT_SUCCESS(urMemRelease(image1D)); + } + if (image2D) { + EXPECT_SUCCESS(urMemRelease(image2D)); + } + if (image3D) { + EXPECT_SUCCESS(urMemRelease(image3D)); + } + UUR_RETURN_ON_FATAL_FAILURE(urQueueTest::TearDown()); + } + + const size_t width = 1024; + const size_t height = 8; + const size_t depth = 2; + ur_mem_handle_t image1D = nullptr; + ur_mem_handle_t image2D = nullptr; + ur_mem_handle_t image3D = nullptr; + ur_rect_region_t region1D{width, 1, 1}; + ur_rect_region_t region2D{width, height, 1}; + ur_rect_region_t region3D{width, height, depth}; + ur_rect_offset_t origin{0, 0, 0}; + ur_image_format_t format = {UR_IMAGE_CHANNEL_ORDER_RGBA, + UR_IMAGE_CHANNEL_TYPE_FLOAT}; + ur_image_desc_t desc1D = {UR_STRUCTURE_TYPE_IMAGE_DESC, // stype + nullptr, // pNext + UR_MEM_TYPE_IMAGE1D, // mem object type + width, // image width + 1, // image height + 1, // image depth + 1, // array size + 0, // row pitch + 0, // slice pitch + 0, // mip levels + 0}; // num samples + + ur_image_desc_t desc2D = {UR_STRUCTURE_TYPE_IMAGE_DESC, // stype + nullptr, // pNext + UR_MEM_TYPE_IMAGE2D, // mem object type + width, // image width + height, // image height + 1, // image depth + 1, // array size + 0, // row pitch + 0, // slice pitch + 0, // mip levels + 0}; // num samples + + ur_image_desc_t desc3D = {UR_STRUCTURE_TYPE_IMAGE_DESC, // stype + nullptr, // pNext + UR_MEM_TYPE_IMAGE3D, // mem object type + width, // image width + height, // image height + depth, // image depth + 1, // array size + 0, // row pitch + 0, // slice pitch + 0, // mip levels + 0}; // num samples +}; + struct urUSMDeviceAllocTest : urQueueTest { void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(uur::urQueueTest::SetUp()); @@ -504,7 +635,6 @@ struct urUSMPoolTest : urContextTest { UUR_RETURN_ON_FATAL_FAILURE(urContextTest::SetUp()); ur_usm_pool_desc_t pool_desc{UR_STRUCTURE_TYPE_USM_POOL_DESC, nullptr, UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK}; - ur_usm_pool_handle_t pool = nullptr; ASSERT_SUCCESS(urUSMPoolCreate(this->context, &pool_desc, &pool)); } @@ -519,7 +649,6 @@ struct urUSMPoolTest : urContextTest { }; template struct urUSMPoolTestWithParam : urContextTestWithParam { - void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(urContextTestWithParam::SetUp()); ur_usm_pool_desc_t pool_desc{UR_STRUCTURE_TYPE_USM_POOL_DESC, nullptr, @@ -538,6 +667,152 @@ template struct urUSMPoolTestWithParam : urContextTestWithParam { ur_usm_pool_handle_t pool; }; +struct urVirtualMemGranularityTest : urContextTest { + void SetUp() override { + UUR_RETURN_ON_FATAL_FAILURE(urContextTest::SetUp()); + ASSERT_SUCCESS(urVirtualMemGranularityGetInfo( + context, device, UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM, + sizeof(granularity), &granularity, nullptr)); + } + size_t granularity; +}; + +template +struct urVirtualMemGranularityTestWithParam : urContextTestWithParam { + void SetUp() override { + UUR_RETURN_ON_FATAL_FAILURE(urContextTestWithParam::SetUp()); + ASSERT_SUCCESS(urVirtualMemGranularityGetInfo( + this->context, this->device, + UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM, sizeof(granularity), + &granularity, nullptr)); + ASSERT_NE(granularity, 0); + } + + size_t granularity = 0; +}; + +struct urPhysicalMemTest : urVirtualMemGranularityTest { + void SetUp() override { + UUR_RETURN_ON_FATAL_FAILURE(urVirtualMemGranularityTest::SetUp()); + size = granularity * 256; + ur_physical_mem_properties_t props{ + UR_STRUCTURE_TYPE_PHYSICAL_MEM_PROPERTIES, + nullptr, + 0 /*flags*/, + }; + ASSERT_SUCCESS( + urPhysicalMemCreate(context, device, size, &props, &physical_mem)); + ASSERT_NE(physical_mem, nullptr); + } + + void TearDown() override { + if (physical_mem) { + EXPECT_SUCCESS(urPhysicalMemRelease(physical_mem)); + } + UUR_RETURN_ON_FATAL_FAILURE(urVirtualMemGranularityTest::TearDown()); + } + + size_t size = 0; + ur_physical_mem_handle_t physical_mem = nullptr; +}; + +template +struct urPhysicalMemTestWithParam : urVirtualMemGranularityTestWithParam { + void SetUp() override { + UUR_RETURN_ON_FATAL_FAILURE( + urVirtualMemGranularityTestWithParam::SetUp()); + size = this->granularity * 256; + ur_physical_mem_properties_t props{ + UR_STRUCTURE_TYPE_PHYSICAL_MEM_PROPERTIES, + nullptr, + 0 /*flags*/, + }; + ASSERT_SUCCESS(urPhysicalMemCreate(this->context, this->device, size, + &props, &physical_mem)); + ASSERT_NE(physical_mem, nullptr); + } + + void TearDown() override { + if (physical_mem) { + EXPECT_SUCCESS(urPhysicalMemRelease(physical_mem)); + } + UUR_RETURN_ON_FATAL_FAILURE( + urVirtualMemGranularityTestWithParam::TearDown()); + } + + size_t size = 0; + ur_physical_mem_handle_t physical_mem = nullptr; +}; + +struct urVirtualMemTest : urPhysicalMemTest { + void SetUp() override { + UUR_RETURN_ON_FATAL_FAILURE(urPhysicalMemTest::SetUp()); + ASSERT_SUCCESS( + urVirtualMemReserve(context, nullptr, size, &virtual_ptr)); + ASSERT_NE(virtual_ptr, nullptr); + } + + void TearDown() override { + if (virtual_ptr) { + EXPECT_SUCCESS(urVirtualMemFree(context, virtual_ptr, size)); + } + UUR_RETURN_ON_FATAL_FAILURE(urPhysicalMemTest::TearDown()); + } + + void *virtual_ptr = nullptr; +}; + +template +struct urVirtualMemTestWithParam : urPhysicalMemTestWithParam { + void SetUp() override { + UUR_RETURN_ON_FATAL_FAILURE(urPhysicalMemTestWithParam::SetUp()); + ASSERT_SUCCESS(urVirtualMemReserve(this->context, nullptr, this->size, + &virtual_ptr)); + } + + void TearDown() override { + if (virtual_ptr) { + EXPECT_SUCCESS( + urVirtualMemFree(this->context, virtual_ptr, this->size)); + } + UUR_RETURN_ON_FATAL_FAILURE(urPhysicalMemTestWithParam::TearDown()); + } + + void *virtual_ptr = nullptr; +}; + +struct urVirtualMemMappedTest : urVirtualMemTest { + + void SetUp() override { + UUR_RETURN_ON_FATAL_FAILURE(urVirtualMemTest::SetUp()); + ASSERT_SUCCESS(urVirtualMemMap(context, virtual_ptr, size, physical_mem, + 0, + UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE)); + } + + void TearDown() override { + EXPECT_SUCCESS(urVirtualMemUnmap(context, virtual_ptr, size)); + UUR_RETURN_ON_FATAL_FAILURE(urVirtualMemTest::TearDown()); + } +}; + +template +struct urVirtualMemMappedTestWithParam : urVirtualMemTestWithParam { + + void SetUp() override { + UUR_RETURN_ON_FATAL_FAILURE(urVirtualMemTestWithParam::SetUp()); + ASSERT_SUCCESS(urVirtualMemMap(this->context, this->virtual_ptr, + this->size, this->physical_mem, 0, + UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE)); + } + + void TearDown() override { + EXPECT_SUCCESS( + urVirtualMemUnmap(this->context, this->virtual_ptr, this->size)); + UUR_RETURN_ON_FATAL_FAILURE(urVirtualMemTestWithParam::TearDown()); + } +}; + template struct urUSMDeviceAllocTestWithParam : urQueueTestWithParam { @@ -749,6 +1024,22 @@ struct urKernelExecutionTest : urKernelTest { std::vector buffer_args; uint32_t current_arg_index = 0; }; + +template struct GlobalVar { + std::string name; + T value; +}; + +struct urGlobalVariableTest : uur::urKernelExecutionTest { + void SetUp() override { + program_name = "device_global"; + global_var = {"_Z7dev_var", 0}; + UUR_RETURN_ON_FATAL_FAILURE(uur::urKernelExecutionTest::SetUp()); + } + + GlobalVar global_var; +}; + } // namespace uur #endif // UR_CONFORMANCE_INCLUDE_FIXTURES_H_INCLUDED diff --git a/test/conformance/testing/include/uur/utils.h b/test/conformance/testing/include/uur/utils.h index 75e1c51b9c..027e270f25 100644 --- a/test/conformance/testing/include/uur/utils.h +++ b/test/conformance/testing/include/uur/utils.h @@ -14,6 +14,10 @@ namespace uur { +inline size_t RoundUpToNearestFactor(size_t num, size_t factor) { + return ((num + factor - 1) / factor) * factor; +} + /// @brief Make a string a valid identifier for gtest. /// @param str The string to sanitize. inline std::string GTestSanitizeString(const std::string &str) { diff --git a/test/conformance/usm/urUSMDeviceAlloc.cpp b/test/conformance/usm/urUSMDeviceAlloc.cpp index 5b0d834c44..8fd4742d90 100644 --- a/test/conformance/usm/urUSMDeviceAlloc.cpp +++ b/test/conformance/usm/urUSMDeviceAlloc.cpp @@ -40,11 +40,11 @@ TEST_P(urUSMDeviceAllocTest, SuccessWithDescriptors) { ur_usm_device_desc_t usm_device_desc{UR_STRUCTURE_TYPE_USM_DEVICE_DESC, nullptr, - /* device flags*/ 0}; + /* device flags */ 0}; ur_usm_desc_t usm_desc{UR_STRUCTURE_TYPE_USM_DESC, &usm_device_desc, - /* common usm flags */ 0, - /* mem advice flags*/ UR_USM_ADVICE_FLAG_DEFAULT}; + /* mem advice flags */ UR_USM_ADVICE_FLAG_DEFAULT, + /* alignment */ 0}; void *ptr = nullptr; size_t allocation_size = sizeof(int); ASSERT_SUCCESS(urUSMDeviceAlloc(context, device, &usm_desc, nullptr, diff --git a/test/conformance/usm/urUSMHostAlloc.cpp b/test/conformance/usm/urUSMHostAlloc.cpp index ee27cc85cd..48d1e098d0 100644 --- a/test/conformance/usm/urUSMHostAlloc.cpp +++ b/test/conformance/usm/urUSMHostAlloc.cpp @@ -60,11 +60,11 @@ TEST_P(urUSMHostAllocTest, Success) { TEST_P(urUSMHostAllocTest, SuccessWithDescriptors) { ur_usm_host_desc_t usm_host_desc{UR_STRUCTURE_TYPE_USM_HOST_DESC, nullptr, - /* host flags*/ 0}; + /* host flags */ 0}; ur_usm_desc_t usm_desc{UR_STRUCTURE_TYPE_USM_DESC, &usm_host_desc, - /* common usm flags */ 0, - /* mem advice flags*/ UR_USM_ADVICE_FLAG_DEFAULT}; + /* mem advice flags */ UR_USM_ADVICE_FLAG_DEFAULT, + /* alignment */ 0}; void *ptr = nullptr; size_t allocation_size = sizeof(int); ASSERT_SUCCESS( diff --git a/test/conformance/usm/urUSMPoolRetain.cpp b/test/conformance/usm/urUSMPoolRetain.cpp index 1e961a5989..17d36308be 100644 --- a/test/conformance/usm/urUSMPoolRetain.cpp +++ b/test/conformance/usm/urUSMPoolRetain.cpp @@ -25,7 +25,7 @@ TEST_P(urUSMPoolRetainTest, Success) { uint32_t afterRefCount = 0; ASSERT_SUCCESS(uur::GetObjectReferenceCount(pool, afterRefCount)); - ASSERT_LT(afterRefCount, prevRefCount); + ASSERT_LT(afterRefCount, refCount); } TEST_P(urUSMPoolRetainTest, InvalidNullHandlePool) { diff --git a/test/conformance/usm/urUSMSharedAlloc.cpp b/test/conformance/usm/urUSMSharedAlloc.cpp index fc8044d517..5e92183500 100644 --- a/test/conformance/usm/urUSMSharedAlloc.cpp +++ b/test/conformance/usm/urUSMSharedAlloc.cpp @@ -43,15 +43,15 @@ TEST_P(urUSMSharedAllocTest, SuccessWithDescriptors) { ur_usm_device_desc_t usm_device_desc{UR_STRUCTURE_TYPE_USM_DEVICE_DESC, nullptr, - /* device flags*/ 0}; + /* device flags */ 0}; ur_usm_host_desc_t usm_host_desc{UR_STRUCTURE_TYPE_USM_HOST_DESC, &usm_device_desc, - /* host flags*/ 0}; + /* host flags */ 0}; ur_usm_desc_t usm_desc{UR_STRUCTURE_TYPE_USM_DESC, &usm_host_desc, - /* common usm flags */ 0, - /* mem advice flags*/ UR_USM_ADVICE_FLAG_DEFAULT}; + /* mem advice flags */ UR_USM_ADVICE_FLAG_DEFAULT, + /* alignment */ 0}; void *ptr = nullptr; size_t allocation_size = sizeof(int); ASSERT_SUCCESS(urUSMSharedAlloc(context, device, &usm_desc, nullptr, @@ -70,9 +70,9 @@ TEST_P(urUSMSharedAllocTest, SuccessWithDescriptors) { TEST_P(urUSMSharedAllocTest, SuccessWithMultipleAdvices) { ur_usm_desc_t usm_desc{ UR_STRUCTURE_TYPE_USM_DESC, nullptr, - /* common usm flags */ 0, - /* mem advice flags*/ UR_USM_ADVICE_FLAG_SET_READ_MOSTLY | - UR_USM_ADVICE_FLAG_BIAS_CACHED}; + /* mem advice flags */ UR_USM_ADVICE_FLAG_SET_READ_MOSTLY | + UR_USM_ADVICE_FLAG_BIAS_CACHED, + /* alignment */ 0}; void *ptr = nullptr; size_t allocation_size = sizeof(int); ASSERT_SUCCESS(urUSMSharedAlloc(context, device, &usm_desc, nullptr, diff --git a/test/conformance/virtual_memory/CMakeLists.txt b/test/conformance/virtual_memory/CMakeLists.txt new file mode 100644 index 0000000000..6ae27f443b --- /dev/null +++ b/test/conformance/virtual_memory/CMakeLists.txt @@ -0,0 +1,17 @@ +# Copyright (C) 2023 Intel Corporation +# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +# See LICENSE.TXT +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +add_conformance_test_with_devices_environment(virtual_memory + urPhysicalMemCreate.cpp + urPhysicalMemRelease.cpp + urPhysicalMemRetain.cpp + urVirtualMemFree.cpp + urVirtualMemGetInfo.cpp + urVirtualMemGranularityGetInfo.cpp + urVirtualMemMap.cpp + urVirtualMemReserve.cpp + urVirtualMemSetAccess.cpp + urVirtualMemUnmap.cpp +) diff --git a/test/conformance/virtual_memory/urPhysicalMemCreate.cpp b/test/conformance/virtual_memory/urPhysicalMemCreate.cpp new file mode 100644 index 0000000000..078b0e68db --- /dev/null +++ b/test/conformance/virtual_memory/urPhysicalMemCreate.cpp @@ -0,0 +1,61 @@ +// Copyright (C) 2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include + +struct urPhysicalMemCreateTest + : uur::urVirtualMemGranularityTestWithParam { + + void SetUp() override { + UUR_RETURN_ON_FATAL_FAILURE( + uur::urVirtualMemGranularityTestWithParam::SetUp()); + size = getParam() * granularity; + } + + size_t size; +}; + +UUR_TEST_SUITE_P(urPhysicalMemCreateTest, + ::testing::Values(1, 2, 3, 7, 12, 44, 1024, 4000, 12345), + uur::deviceTestWithParamPrinter); + +TEST_P(urPhysicalMemCreateTest, Success) { + ur_physical_mem_handle_t physical_mem = nullptr; + ASSERT_SUCCESS( + urPhysicalMemCreate(context, device, size, nullptr, &physical_mem)); + ASSERT_NE(physical_mem, nullptr); + EXPECT_SUCCESS(urPhysicalMemRelease(physical_mem)); +} + +TEST_P(urPhysicalMemCreateTest, InvalidNullHandleContext) { + ur_physical_mem_handle_t physical_mem = nullptr; + ASSERT_EQ_RESULT( + urPhysicalMemCreate(nullptr, device, size, nullptr, &physical_mem), + UR_RESULT_ERROR_INVALID_NULL_HANDLE); +} + +TEST_P(urPhysicalMemCreateTest, InvalidNullHandleDevice) { + ur_physical_mem_handle_t physical_mem = nullptr; + ASSERT_EQ_RESULT( + urPhysicalMemCreate(context, nullptr, size, nullptr, &physical_mem), + UR_RESULT_ERROR_INVALID_NULL_HANDLE); +} + +TEST_P(urPhysicalMemCreateTest, InvalidNullPointerPhysicalMem) { + ASSERT_EQ_RESULT( + urPhysicalMemCreate(context, device, size, nullptr, nullptr), + UR_RESULT_ERROR_INVALID_NULL_POINTER); +} + +TEST_P(urPhysicalMemCreateTest, InvalidSize) { + if (granularity == 1) { + GTEST_SKIP() + << "A granularity of 1 means that any size will be accepted."; + } + ur_physical_mem_handle_t physical_mem = nullptr; + size_t invalid_size = size - 1; + ASSERT_EQ_RESULT(urPhysicalMemCreate(context, device, invalid_size, nullptr, + &physical_mem), + UR_RESULT_ERROR_INVALID_SIZE); +} diff --git a/test/conformance/virtual_memory/urPhysicalMemRelease.cpp b/test/conformance/virtual_memory/urPhysicalMemRelease.cpp new file mode 100644 index 0000000000..834a15e50f --- /dev/null +++ b/test/conformance/virtual_memory/urPhysicalMemRelease.cpp @@ -0,0 +1,18 @@ +// Copyright (C) 2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include + +using urPhysicalMemReleaseTest = uur::urPhysicalMemTest; +UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urPhysicalMemReleaseTest); + +TEST_P(urPhysicalMemReleaseTest, Success) { + ASSERT_SUCCESS(urPhysicalMemRetain(physical_mem)); + ASSERT_SUCCESS(urPhysicalMemRelease(physical_mem)); +} + +TEST_P(urPhysicalMemReleaseTest, InvalidNullHandlePhysicalMem) { + ASSERT_EQ_RESULT(urPhysicalMemRelease(nullptr), + UR_RESULT_ERROR_INVALID_NULL_HANDLE); +} diff --git a/test/conformance/virtual_memory/urPhysicalMemRetain.cpp b/test/conformance/virtual_memory/urPhysicalMemRetain.cpp new file mode 100644 index 0000000000..a438e1072d --- /dev/null +++ b/test/conformance/virtual_memory/urPhysicalMemRetain.cpp @@ -0,0 +1,18 @@ +// Copyright (C) 2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include + +using urPhysicalMemRetainTest = uur::urPhysicalMemTest; +UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urPhysicalMemRetainTest); + +TEST_P(urPhysicalMemRetainTest, Success) { + ASSERT_SUCCESS(urPhysicalMemRetain(physical_mem)); + ASSERT_SUCCESS(urPhysicalMemRelease(physical_mem)); +} + +TEST_P(urPhysicalMemRetainTest, InvalidNullHandlePhysicalMem) { + ASSERT_EQ_RESULT(urPhysicalMemRetain(nullptr), + UR_RESULT_ERROR_INVALID_NULL_HANDLE); +} diff --git a/test/conformance/virtual_memory/urVirtualMemFree.cpp b/test/conformance/virtual_memory/urVirtualMemFree.cpp new file mode 100644 index 0000000000..6cb8795547 --- /dev/null +++ b/test/conformance/virtual_memory/urVirtualMemFree.cpp @@ -0,0 +1,23 @@ +// Copyright (C) 2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include + +using urVirtualMemFreeTest = uur::urVirtualMemTest; +UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urVirtualMemFreeTest); + +TEST_P(urVirtualMemFreeTest, Success) { + ASSERT_SUCCESS(urVirtualMemFree(context, virtual_ptr, size)); + virtual_ptr = nullptr; // set to nullptr to prevent double-free +} + +TEST_P(urVirtualMemFreeTest, InvalidNullHandleContext) { + ASSERT_EQ_RESULT(urVirtualMemFree(nullptr, virtual_ptr, size), + UR_RESULT_ERROR_INVALID_NULL_HANDLE); +} + +TEST_P(urVirtualMemFreeTest, InvalidNullPointerStart) { + ASSERT_EQ_RESULT(urVirtualMemFree(context, nullptr, size), + UR_RESULT_ERROR_INVALID_NULL_HANDLE); +} diff --git a/test/conformance/virtual_memory/urVirtualMemGetInfo.cpp b/test/conformance/virtual_memory/urVirtualMemGetInfo.cpp new file mode 100644 index 0000000000..79579e9297 --- /dev/null +++ b/test/conformance/virtual_memory/urVirtualMemGetInfo.cpp @@ -0,0 +1,63 @@ +// Copyright (C) 2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include + +using urVirtualMemGetInfoTestWithParam = + uur::urVirtualMemMappedTestWithParam; +UUR_TEST_SUITE_P(urVirtualMemGetInfoTestWithParam, + ::testing::Values(UR_VIRTUAL_MEM_INFO_ACCESS_MODE), + uur::deviceTestWithParamPrinter); + +TEST_P(urVirtualMemGetInfoTestWithParam, Success) { + size_t info_size = 0; + ur_virtual_mem_info_t info = getParam(); + ASSERT_SUCCESS(urVirtualMemGetInfo(context, virtual_ptr, size, info, 0, + nullptr, &info_size)); + ASSERT_NE(info_size, 0); + + std::vector data(info_size); + ASSERT_SUCCESS(urVirtualMemGetInfo(context, virtual_ptr, size, info, + data.size(), data.data(), nullptr)); + + switch (info) { + case UR_VIRTUAL_MEM_INFO_ACCESS_MODE: { + ASSERT_EQ(sizeof(ur_virtual_mem_access_flags_t), data.size()); + ur_virtual_mem_access_flags_t flags = + *reinterpret_cast(data.data()); + ASSERT_TRUE(flags & UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE); + } break; + + default: + FAIL() << "Unhandled ur_virtual_mem_info_t enumeration: " << info; + break; + } +} + +using urVirtualMemGetInfoTest = uur::urVirtualMemMappedTest; +UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urVirtualMemGetInfoTest); + +TEST_P(urVirtualMemGetInfoTest, InvalidNullHandleContext) { + ur_virtual_mem_access_flags_t flags = 0; + ASSERT_EQ_RESULT(urVirtualMemGetInfo(nullptr, virtual_ptr, size, + UR_VIRTUAL_MEM_INFO_ACCESS_MODE, + sizeof(flags), &flags, nullptr), + UR_RESULT_ERROR_INVALID_NULL_HANDLE); +} + +TEST_P(urVirtualMemGetInfoTest, InvalidNullPointerStart) { + ur_virtual_mem_access_flags_t flags = 0; + ASSERT_EQ_RESULT(urVirtualMemGetInfo(context, nullptr, size, + UR_VIRTUAL_MEM_INFO_ACCESS_MODE, + sizeof(flags), &flags, nullptr), + UR_RESULT_ERROR_INVALID_NULL_POINTER); +} + +TEST_P(urVirtualMemGetInfoTest, InvalidEnumerationInfo) { + size_t info_size = 0; + ASSERT_EQ_RESULT(urVirtualMemGetInfo(context, virtual_ptr, size, + UR_VIRTUAL_MEM_INFO_FORCE_UINT32, 0, + nullptr, &info_size), + UR_RESULT_ERROR_INVALID_ENUMERATION); +} diff --git a/test/conformance/virtual_memory/urVirtualMemGranularityGetInfo.cpp b/test/conformance/virtual_memory/urVirtualMemGranularityGetInfo.cpp new file mode 100644 index 0000000000..d4feccd6dc --- /dev/null +++ b/test/conformance/virtual_memory/urVirtualMemGranularityGetInfo.cpp @@ -0,0 +1,100 @@ +// Copyright (C) 2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include + +using urVirtualMemGranularityGetInfoTest = + uur::urContextTestWithParam; + +UUR_TEST_SUITE_P( + urVirtualMemGranularityGetInfoTest, + ::testing::Values(UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM, + UR_VIRTUAL_MEM_GRANULARITY_INFO_RECOMMENDED), + uur::deviceTestWithParamPrinter); + +TEST_P(urVirtualMemGranularityGetInfoTest, Success) { + size_t size = 0; + ur_virtual_mem_granularity_info_t info = getParam(); + ASSERT_SUCCESS(urVirtualMemGranularityGetInfo(context, device, info, 0, + nullptr, &size)); + ASSERT_NE(size, 0); + + std::vector infoData(size); + ASSERT_SUCCESS(urVirtualMemGranularityGetInfo( + context, device, info, infoData.size(), infoData.data(), nullptr)); + + switch (info) { + case UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM: { + ASSERT_EQ(size, sizeof(size_t)); + size_t minimum = *reinterpret_cast(infoData.data()); + ASSERT_GT(minimum, 0); + } break; + case UR_VIRTUAL_MEM_GRANULARITY_INFO_RECOMMENDED: { + ASSERT_EQ(size, sizeof(size_t)); + size_t recommended = *reinterpret_cast(infoData.data()); + ASSERT_GT(recommended, 0); + } break; + default: + FAIL() << "Unhandled ur_virtual_mem_granularity_info_t enumeration: " + << info; + break; + } +} + +using urVirtualMemGranularityGetInfoNegativeTest = uur::urContextTest; +UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urVirtualMemGranularityGetInfoNegativeTest); + +TEST_P(urVirtualMemGranularityGetInfoNegativeTest, InvalidNullHandleContext) { + size_t size = 0; + ASSERT_EQ_RESULT( + urVirtualMemGranularityGetInfo(nullptr, device, + UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM, + 0, nullptr, &size), + UR_RESULT_ERROR_INVALID_NULL_HANDLE); +} + +TEST_P(urVirtualMemGranularityGetInfoNegativeTest, InvalidEnumeration) { + size_t size = 0; + ASSERT_EQ_RESULT(urVirtualMemGranularityGetInfo( + context, device, + UR_VIRTUAL_MEM_GRANULARITY_INFO_FORCE_UINT32, 0, + nullptr, &size), + UR_RESULT_ERROR_INVALID_NULL_HANDLE); +} + +TEST_P(urVirtualMemGranularityGetInfoNegativeTest, + InvalidNullPointerPropSizeRet) { + ASSERT_EQ_RESULT( + urVirtualMemGranularityGetInfo(context, device, + UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM, + 0, nullptr, nullptr), + UR_RESULT_ERROR_INVALID_NULL_POINTER); +} + +TEST_P(urVirtualMemGranularityGetInfoNegativeTest, + InvalidNullPointerPropValue) { + ASSERT_EQ_RESULT( + urVirtualMemGranularityGetInfo(context, device, + UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM, + sizeof(size_t), nullptr, nullptr), + UR_RESULT_ERROR_INVALID_NULL_POINTER); +} + +TEST_P(urVirtualMemGranularityGetInfoNegativeTest, InvalidPropSizeZero) { + size_t minimum = 0; + ASSERT_EQ_RESULT( + urVirtualMemGranularityGetInfo(context, device, + UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM, + 0, &minimum, nullptr), + UR_RESULT_ERROR_INVALID_SIZE); +} + +TEST_P(urVirtualMemGranularityGetInfoNegativeTest, InvalidSizePropSizeSmall) { + size_t minimum = 0; + ASSERT_EQ_RESULT( + urVirtualMemGranularityGetInfo(context, device, + UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM, + sizeof(size_t) - 1, &minimum, nullptr), + UR_RESULT_ERROR_INVALID_SIZE); +} diff --git a/test/conformance/virtual_memory/urVirtualMemMap.cpp b/test/conformance/virtual_memory/urVirtualMemMap.cpp new file mode 100644 index 0000000000..bed65e2018 --- /dev/null +++ b/test/conformance/virtual_memory/urVirtualMemMap.cpp @@ -0,0 +1,39 @@ +// Copyright (C) 2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include + +using urVirtualMemMapTest = uur::urVirtualMemTest; +UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urVirtualMemMapTest); + +TEST_P(urVirtualMemMapTest, Success) { + ASSERT_SUCCESS(urVirtualMemMap(context, virtual_ptr, size, physical_mem, 0, + UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE)); + EXPECT_SUCCESS(urVirtualMemUnmap(context, virtual_ptr, size)); +} + +TEST_P(urVirtualMemMapTest, InvalidNullHandleContext) { + ASSERT_EQ_RESULT(urVirtualMemMap(nullptr, virtual_ptr, size, physical_mem, + 0, UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE), + UR_RESULT_ERROR_INVALID_NULL_HANDLE); +} + +TEST_P(urVirtualMemMapTest, InvalidNullHandlePhysicalMem) { + ASSERT_EQ_RESULT(urVirtualMemMap(context, virtual_ptr, size, nullptr, 0, + UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE), + UR_RESULT_ERROR_INVALID_NULL_HANDLE); +} + +TEST_P(urVirtualMemMapTest, InvalidNullPointerStart) { + ASSERT_EQ_RESULT(urVirtualMemMap(context, nullptr, size, physical_mem, 0, + UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE), + UR_RESULT_ERROR_INVALID_NULL_POINTER); +} + +TEST_P(urVirtualMemMapTest, InvalidEnumerationFlags) { + ASSERT_EQ_RESULT(urVirtualMemMap(context, virtual_ptr, size, physical_mem, + 0, + UR_VIRTUAL_MEM_ACCESS_FLAG_FORCE_UINT32), + UR_RESULT_ERROR_INVALID_ENUMERATION); +} diff --git a/test/conformance/virtual_memory/urVirtualMemReserve.cpp b/test/conformance/virtual_memory/urVirtualMemReserve.cpp new file mode 100644 index 0000000000..7d870dfb05 --- /dev/null +++ b/test/conformance/virtual_memory/urVirtualMemReserve.cpp @@ -0,0 +1,62 @@ +// Copyright (C) 2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include + +using urVirtualMemReserveTestWithParam = + uur::urVirtualMemGranularityTestWithParam; +UUR_TEST_SUITE_P(urVirtualMemReserveTestWithParam, + ::testing::Values(2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, + 2048, 5000, 100000), + uur::deviceTestWithParamPrinter); + +TEST_P(urVirtualMemReserveTestWithParam, SuccessNoStartPointer) { + // round up to nearest granularity + size_t virtual_mem_size = + uur::RoundUpToNearestFactor(getParam(), granularity); + void *virtual_mem_start = nullptr; + ASSERT_SUCCESS(urVirtualMemReserve(context, nullptr, virtual_mem_size, + &virtual_mem_start)); + ASSERT_NE(virtual_mem_start, nullptr); + + EXPECT_SUCCESS( + urVirtualMemFree(context, virtual_mem_start, virtual_mem_size)); +} + +TEST_P(urVirtualMemReserveTestWithParam, SuccessWithStartPointer) { + // roundup to nearest granularity + size_t page_size = uur::RoundUpToNearestFactor(getParam(), granularity); + void *origin_ptr = nullptr; + ASSERT_SUCCESS( + urVirtualMemReserve(context, nullptr, page_size, &origin_ptr)); + ASSERT_NE(origin_ptr, nullptr); + + // try to reserve at the end of origin_ptr + void *virtual_mem_ptr = nullptr; + void *pStart = (uint8_t *)origin_ptr + page_size; + ASSERT_SUCCESS( + urVirtualMemReserve(context, pStart, page_size, &virtual_mem_ptr)); + ASSERT_NE(virtual_mem_ptr, nullptr); + + // both pointers have to be freed + EXPECT_SUCCESS(urVirtualMemFree(context, origin_ptr, page_size)); + EXPECT_SUCCESS(urVirtualMemFree(context, virtual_mem_ptr, page_size)); +} + +using urVirtualMemReserveTest = uur::urVirtualMemGranularityTest; +UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urVirtualMemReserveTest); + +TEST_P(urVirtualMemReserveTest, InvalidNullHandleContext) { + size_t page_size = uur::RoundUpToNearestFactor(1024, granularity); + void *virtual_ptr = nullptr; + ASSERT_EQ_RESULT( + urVirtualMemReserve(nullptr, nullptr, page_size, &virtual_ptr), + UR_RESULT_ERROR_INVALID_NULL_HANDLE); +} + +TEST_P(urVirtualMemReserveTest, InvalidNullPointer) { + size_t page_size = uur::RoundUpToNearestFactor(1024, granularity); + ASSERT_EQ_RESULT(urVirtualMemReserve(context, nullptr, page_size, nullptr), + UR_RESULT_ERROR_INVALID_NULL_POINTER); +} diff --git a/test/conformance/virtual_memory/urVirtualMemSetAccess.cpp b/test/conformance/virtual_memory/urVirtualMemSetAccess.cpp new file mode 100644 index 0000000000..7b06ffb6ba --- /dev/null +++ b/test/conformance/virtual_memory/urVirtualMemSetAccess.cpp @@ -0,0 +1,33 @@ +// Copyright (C) 2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include + +using urVirtualMemSetAccessTest = uur::urVirtualMemMappedTest; +UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urVirtualMemSetAccessTest); + +TEST_P(urVirtualMemSetAccessTest, Success) { + ASSERT_SUCCESS(urVirtualMemSetAccess(context, virtual_ptr, size, + UR_VIRTUAL_MEM_ACCESS_FLAG_READ_ONLY)); + + ur_virtual_mem_access_flags_t flags = 0; + ASSERT_SUCCESS(urVirtualMemGetInfo(context, virtual_ptr, size, + UR_VIRTUAL_MEM_INFO_ACCESS_MODE, + sizeof(flags), &flags, nullptr)); + ASSERT_TRUE(flags & UR_VIRTUAL_MEM_ACCESS_FLAG_READ_ONLY); +} + +TEST_P(urVirtualMemSetAccessTest, InvalidNullHandleContext) { + ASSERT_EQ_RESULT( + urVirtualMemSetAccess(nullptr, virtual_ptr, size, + UR_VIRTUAL_MEM_ACCESS_FLAG_READ_ONLY), + UR_RESULT_ERROR_INVALID_NULL_HANDLE); +} + +TEST_P(urVirtualMemSetAccessTest, InvalidNullPointerStart) { + ASSERT_EQ_RESULT( + urVirtualMemSetAccess(context, nullptr, size, + UR_VIRTUAL_MEM_ACCESS_FLAG_READ_ONLY), + UR_RESULT_ERROR_INVALID_NULL_POINTER); +} diff --git a/test/conformance/virtual_memory/urVirtualMemUnmap.cpp b/test/conformance/virtual_memory/urVirtualMemUnmap.cpp new file mode 100644 index 0000000000..ae5bbb3050 --- /dev/null +++ b/test/conformance/virtual_memory/urVirtualMemUnmap.cpp @@ -0,0 +1,24 @@ +// Copyright (C) 2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include + +using urVirtualMemUnmapTest = uur::urVirtualMemTest; +UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urVirtualMemUnmapTest); + +TEST_P(urVirtualMemUnmapTest, Success) { + ASSERT_SUCCESS(urVirtualMemMap(context, virtual_ptr, size, physical_mem, 0, + UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE)); + ASSERT_SUCCESS(urVirtualMemUnmap(context, virtual_ptr, size)); +} + +TEST_P(urVirtualMemUnmapTest, InvalidNullHandleContext) { + ASSERT_EQ_RESULT(urVirtualMemUnmap(nullptr, virtual_ptr, size), + UR_RESULT_ERROR_INVALID_NULL_HANDLE); +} + +TEST_P(urVirtualMemUnmapTest, InvalidNullPointerStart) { + ASSERT_EQ_RESULT(urVirtualMemUnmap(context, nullptr, size), + UR_RESULT_ERROR_INVALID_NULL_POINTER); +} diff --git a/test/layers/tracing/CMakeLists.txt b/test/layers/tracing/CMakeLists.txt index 3fe641824d..db4b9da590 100644 --- a/test/layers/tracing/CMakeLists.txt +++ b/test/layers/tracing/CMakeLists.txt @@ -22,4 +22,5 @@ set_property(TEST ${TEST_NAME} PROPERTY ENVIRONMENT "XPTI_TRACE_ENABLE=1" "XPTI_FRAMEWORK_DISPATCHER=$" "XPTI_SUBSCRIBERS=$" - "UR_ADAPTERS_FORCE_LOAD=\"$\"") + "UR_ADAPTERS_FORCE_LOAD=\"$\"" + "UR_ENABLE_LAYERS=UR_LAYER_TRACING") diff --git a/test/layers/tracing/hello_world.out.match b/test/layers/tracing/hello_world.out.match index 3df85ca49a..7658650d04 100644 --- a/test/layers/tracing/hello_world.out.match +++ b/test/layers/tracing/hello_world.out.match @@ -1,21 +1,27 @@ function_with_args_begin(1) - urInit(.device_flags = 0); function_with_args_end(1) - urInit(...) -> ur_result_t(0); Platform initialized. -function_with_args_begin(2) - urPlatformGet(unimplemented); -function_with_args_end(2) - urPlatformGet(...) -> ur_result_t(0); -function_with_args_begin(3) - urPlatformGet(unimplemented); -function_with_args_end(3) - urPlatformGet(...) -> ur_result_t(0); -function_with_args_begin(4) - urPlatformGetApiVersion(unimplemented); -function_with_args_end(4) - urPlatformGetApiVersion(...) -> ur_result_t(0); +function_with_args_begin(2) - urAdapterGet(unimplemented); +function_with_args_end(2) - urAdapterGet(...) -> ur_result_t(0); +function_with_args_begin(3) - urAdapterGet(unimplemented); +function_with_args_end(3) - urAdapterGet(...) -> ur_result_t(0); +function_with_args_begin(4) - urPlatformGet(unimplemented); +function_with_args_end(4) - urPlatformGet(...) -> ur_result_t(0); +function_with_args_begin(5) - urPlatformGet(unimplemented); +function_with_args_end(5) - urPlatformGet(...) -> ur_result_t(0); +function_with_args_begin(6) - urPlatformGetApiVersion(unimplemented); +function_with_args_end(6) - urPlatformGetApiVersion(...) -> ur_result_t(0); API version: {{0\.[0-9]+}} -function_with_args_begin(5) - urDeviceGet(unimplemented); -function_with_args_end(5) - urDeviceGet(...) -> ur_result_t(0); -function_with_args_begin(6) - urDeviceGet(unimplemented); -function_with_args_end(6) - urDeviceGet(...) -> ur_result_t(0); -function_with_args_begin(7) - urDeviceGetInfo(unimplemented); -function_with_args_end(7) - urDeviceGetInfo(...) -> ur_result_t(0); -function_with_args_begin(8) - urDeviceGetInfo(unimplemented); -function_with_args_end(8) - urDeviceGetInfo(...) -> ur_result_t(0); +function_with_args_begin(7) - urDeviceGet(unimplemented); +function_with_args_end(7) - urDeviceGet(...) -> ur_result_t(0); +function_with_args_begin(8) - urDeviceGet(unimplemented); +function_with_args_end(8) - urDeviceGet(...) -> ur_result_t(0); +function_with_args_begin(9) - urDeviceGetInfo(unimplemented); +function_with_args_end(9) - urDeviceGetInfo(...) -> ur_result_t(0); +function_with_args_begin(10) - urDeviceGetInfo(unimplemented); +function_with_args_end(10) - urDeviceGetInfo(...) -> ur_result_t(0); Found a Null Device gpu. -function_with_args_begin(9) - urTearDown(unimplemented); -function_with_args_end(9) - urTearDown(...) -> ur_result_t(0); +function_with_args_begin(11) - urAdapterRelease(unimplemented); +function_with_args_end(11) - urAdapterRelease(...) -> ur_result_t(0); +function_with_args_begin(12) - urTearDown(unimplemented); +function_with_args_end(12) - urTearDown(...) -> ur_result_t(0); diff --git a/test/layers/validation/CMakeLists.txt b/test/layers/validation/CMakeLists.txt index 7ebd23c11b..85d639d196 100644 --- a/test/layers/validation/CMakeLists.txt +++ b/test/layers/validation/CMakeLists.txt @@ -7,7 +7,7 @@ set(UR_VALIDATION_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) function(add_validation_test name) set(TEST_TARGET_NAME validation_test-${name}) - add_executable(${TEST_TARGET_NAME} + add_ur_executable(${TEST_TARGET_NAME} ${ARGN}) target_link_libraries(${TEST_TARGET_NAME} PRIVATE @@ -20,9 +20,7 @@ function(add_validation_test name) WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) set_tests_properties(${name} PROPERTIES LABELS "validation") set_property(TEST ${name} PROPERTY ENVIRONMENT - "UR_ENABLE_VALIDATION_LAYER=1" - "UR_ENABLE_PARAMETER_VALIDATION=1" - "UR_ENABLE_LEAK_CHECKING=1" + "UR_ENABLE_LAYERS=UR_LAYER_FULL_VALIDATION" "UR_ADAPTERS_FORCE_LOAD=\"$\"" "UR_LOG_VALIDATION=level:debug\;flush:debug\;output:stdout") endfunction() diff --git a/test/layers/validation/fixtures.hpp b/test/layers/validation/fixtures.hpp index 0348068fa9..a41e48b3a4 100644 --- a/test/layers/validation/fixtures.hpp +++ b/test/layers/validation/fixtures.hpp @@ -12,28 +12,50 @@ struct urTest : ::testing::Test { void SetUp() override { + ASSERT_EQ(urLoaderConfigCreate(&loader_config), UR_RESULT_SUCCESS); + ASSERT_EQ(urLoaderConfigEnableLayer(loader_config, + "UR_LAYER_FULL_VALIDATION"), + UR_RESULT_SUCCESS); ur_device_init_flags_t device_flags = 0; - ASSERT_EQ(urInit(device_flags), UR_RESULT_SUCCESS); + ASSERT_EQ(urInit(device_flags, loader_config), UR_RESULT_SUCCESS); } void TearDown() override { + if (loader_config) { + ASSERT_EQ(urLoaderConfigRelease(loader_config), UR_RESULT_SUCCESS); + } ur_tear_down_params_t tear_down_params{}; ASSERT_EQ(urTearDown(&tear_down_params), UR_RESULT_SUCCESS); } + + ur_loader_config_handle_t loader_config = nullptr; }; struct valPlatformsTest : urTest { void SetUp() override { urTest::SetUp(); + + uint32_t adapter_count; + ASSERT_EQ(urAdapterGet(0, nullptr, &adapter_count), UR_RESULT_SUCCESS); + adapters.resize(adapter_count); + ASSERT_EQ(urAdapterGet(adapter_count, adapters.data(), nullptr), + UR_RESULT_SUCCESS); + uint32_t count; - ASSERT_EQ(urPlatformGet(0, nullptr, &count), UR_RESULT_SUCCESS); + ASSERT_EQ( + urPlatformGet(adapters.data(), adapter_count, 0, nullptr, &count), + UR_RESULT_SUCCESS); ASSERT_NE(count, 0); platforms.resize(count); - ASSERT_EQ(urPlatformGet(count, platforms.data(), nullptr), + ASSERT_EQ(urPlatformGet(adapters.data(), adapter_count, count, + platforms.data(), nullptr), UR_RESULT_SUCCESS); } + void TearDown() override { urTest::TearDown(); } + + std::vector adapters; std::vector platforms; }; diff --git a/test/layers/validation/parameters.cpp b/test/layers/validation/parameters.cpp index e7f73e87fc..ee679363dc 100644 --- a/test/layers/validation/parameters.cpp +++ b/test/layers/validation/parameters.cpp @@ -6,9 +6,15 @@ #include "fixtures.hpp" TEST(valTest, urInit) { + ur_loader_config_handle_t config; + urLoaderConfigCreate(&config); + urLoaderConfigEnableLayer(config, "UR_PARAMETER_VALIDATION_LAYER"); + const ur_device_init_flags_t device_flags = UR_DEVICE_INIT_FLAG_FORCE_UINT32; - ASSERT_EQ(UR_RESULT_ERROR_INVALID_ENUMERATION, urInit(device_flags)); + ASSERT_EQ(urInit(device_flags, config), + UR_RESULT_ERROR_INVALID_ENUMERATION); + ASSERT_EQ(urLoaderConfigRelease(config), UR_RESULT_SUCCESS); } TEST_F(valPlatformsTest, testUrPlatformGetApiVersion) { diff --git a/test/loader/CMakeLists.txt b/test/loader/CMakeLists.txt index e26e065ff8..0dbf999c45 100644 --- a/test/loader/CMakeLists.txt +++ b/test/loader/CMakeLists.txt @@ -9,4 +9,5 @@ set_tests_properties(example-hello-world PROPERTIES LABELS "loader" ) add_subdirectory(adapter_registry) +add_subdirectory(loader_config) add_subdirectory(platforms) diff --git a/test/loader/adapter_registry/CMakeLists.txt b/test/loader/adapter_registry/CMakeLists.txt index 01e93b6a72..2778ad5c40 100644 --- a/test/loader/adapter_registry/CMakeLists.txt +++ b/test/loader/adapter_registry/CMakeLists.txt @@ -7,15 +7,15 @@ function(add_adapter_reg_search_test name) cmake_parse_arguments(TEST "" "" "SEARCH_PATH;ENVS;SOURCES" ${ARGN}) set(TEST_TARGET_NAME adapter-reg-test-${name}) - add_executable(${TEST_TARGET_NAME} + add_ur_executable(${TEST_TARGET_NAME} ${TEST_SOURCES}) if(WIN32) target_sources(${TEST_TARGET_NAME} PRIVATE - ${CMAKE_SOURCE_DIR}/source/loader/windows/adapter_search.cpp) + ${PROJECT_SOURCE_DIR}/source/loader/windows/adapter_search.cpp) else() target_sources(${TEST_TARGET_NAME} PRIVATE - ${CMAKE_SOURCE_DIR}/source/loader/linux/adapter_search.cpp) + ${PROJECT_SOURCE_DIR}/source/loader/linux/adapter_search.cpp) endif() target_link_libraries(${TEST_TARGET_NAME} @@ -25,7 +25,7 @@ function(add_adapter_reg_search_test name) GTest::gtest_main) target_include_directories(${TEST_TARGET_NAME} PRIVATE - ${CMAKE_SOURCE_DIR}/source/loader) + ${PROJECT_SOURCE_DIR}/source/loader) add_test(NAME adapter-reg-${name} COMMAND ${TEST_TARGET_NAME} @@ -35,7 +35,7 @@ function(add_adapter_reg_search_test name) ENVIRONMENT "UR_ADAPTERS_SEARCH_PATH=\"${TEST_SEARCH_PATH}\"" ${TEST_ENVS}) endfunction() -set(TEST_SEARCH_PATH ${CMAKE_SOURCE_DIR}) +set(TEST_SEARCH_PATH ${PROJECT_SOURCE_DIR}) set(TEST_BIN_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) add_adapter_reg_search_test(search-with-env SEARCH_PATH ${TEST_SEARCH_PATH} diff --git a/test/loader/loader_config/CMakeLists.txt b/test/loader/loader_config/CMakeLists.txt new file mode 100644 index 0000000000..b2c2ffc4ec --- /dev/null +++ b/test/loader/loader_config/CMakeLists.txt @@ -0,0 +1,26 @@ +# Copyright (C) 2023 Intel Corporation +# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +# See LICENSE.TXT +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +add_executable(test-loader-config + urLoaderConfigCreate.cpp + urLoaderConfigGetInfo.cpp + urLoaderConfigEnableLayer.cpp + urLoaderConfigRelease.cpp + urLoaderConfigRetain.cpp +) + +target_link_libraries(test-loader-config + PRIVATE + ${PROJECT_NAME}::common + ${PROJECT_NAME}::headers + ${PROJECT_NAME}::loader + gmock + GTest::gtest_main +) + +add_test(NAME loader-config + COMMAND test-loader-config + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} +) diff --git a/test/loader/loader_config/fixtures.hpp b/test/loader/loader_config/fixtures.hpp new file mode 100644 index 0000000000..3c1c52a0b1 --- /dev/null +++ b/test/loader/loader_config/fixtures.hpp @@ -0,0 +1,30 @@ +// Copyright (C) 2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#ifndef UR_LOADER_CONFIG_TEST_FIXTURES_H +#define UR_LOADER_CONFIG_TEST_FIXTURES_H + +#include "ur_api.h" +#include + +#ifndef ASSERT_SUCCESS +#define ASSERT_SUCCESS(ACTUAL) ASSERT_EQ(UR_RESULT_SUCCESS, ACTUAL) +#endif + +struct LoaderConfigTest : ::testing::Test { + void SetUp() override { + ASSERT_SUCCESS(urLoaderConfigCreate(&loaderConfig)); + } + + void TearDown() override { + if (loaderConfig) { + ASSERT_SUCCESS(urLoaderConfigRelease(loaderConfig)); + } + } + + ur_loader_config_handle_t loaderConfig = nullptr; +}; + +#endif diff --git a/test/loader/loader_config/urLoaderConfigCreate.cpp b/test/loader/loader_config/urLoaderConfigCreate.cpp new file mode 100644 index 0000000000..df1293661b --- /dev/null +++ b/test/loader/loader_config/urLoaderConfigCreate.cpp @@ -0,0 +1,25 @@ +// Copyright (C) 2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include "fixtures.hpp" + +struct LoaderConfigCreateTest : ::testing::Test { + void TearDown() override { + if (loaderConfig) { + ASSERT_SUCCESS(urLoaderConfigRelease(loaderConfig)); + } + } + + ur_loader_config_handle_t loaderConfig = nullptr; +}; + +TEST_F(LoaderConfigCreateTest, Success) { + ASSERT_SUCCESS(urLoaderConfigCreate(&loaderConfig)); +} + +TEST_F(LoaderConfigCreateTest, InvalidNullPointerLoaderConfig) { + ASSERT_EQ(UR_RESULT_ERROR_INVALID_NULL_POINTER, + urLoaderConfigCreate(nullptr)); +} diff --git a/test/loader/loader_config/urLoaderConfigEnableLayer.cpp b/test/loader/loader_config/urLoaderConfigEnableLayer.cpp new file mode 100644 index 0000000000..60a50c1469 --- /dev/null +++ b/test/loader/loader_config/urLoaderConfigEnableLayer.cpp @@ -0,0 +1,46 @@ +// Copyright (C) 2022-2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include "fixtures.hpp" + +struct urLoaderConfigEnableLayerTest : LoaderConfigTest { + void SetUp() override { + LoaderConfigTest::SetUp(); + // Get the first available layer to test with + size_t availableLayersLen = 0; + ASSERT_SUCCESS(urLoaderConfigGetInfo( + loaderConfig, UR_LOADER_CONFIG_INFO_AVAILABLE_LAYERS, 0, nullptr, + &availableLayersLen)); + validLayerName.resize(availableLayersLen); + ASSERT_SUCCESS(urLoaderConfigGetInfo( + loaderConfig, UR_LOADER_CONFIG_INFO_AVAILABLE_LAYERS, + availableLayersLen, validLayerName.data(), nullptr)); + if (validLayerName.find(";") != std::string::npos) { + validLayerName = validLayerName.substr(0, validLayerName.find(";")); + } + } + + std::string validLayerName; +}; + +TEST_F(urLoaderConfigEnableLayerTest, Success) { + ASSERT_SUCCESS( + urLoaderConfigEnableLayer(loaderConfig, validLayerName.data())); +} + +TEST_F(urLoaderConfigEnableLayerTest, LayerNotPresent) { + ASSERT_EQ(UR_RESULT_ERROR_LAYER_NOT_PRESENT, + urLoaderConfigEnableLayer(loaderConfig, "not a real layer")); +} + +TEST_F(urLoaderConfigEnableLayerTest, InvalidNullHandleLoaderConfig) { + ASSERT_EQ(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urLoaderConfigEnableLayer(nullptr, validLayerName.data())); +} + +TEST_F(urLoaderConfigEnableLayerTest, InvalidNullPointerLayerName) { + ASSERT_EQ(UR_RESULT_ERROR_INVALID_NULL_POINTER, + urLoaderConfigEnableLayer(loaderConfig, nullptr)); +} diff --git a/test/loader/loader_config/urLoaderConfigGetInfo.cpp b/test/loader/loader_config/urLoaderConfigGetInfo.cpp new file mode 100644 index 0000000000..1985e57060 --- /dev/null +++ b/test/loader/loader_config/urLoaderConfigGetInfo.cpp @@ -0,0 +1,52 @@ +// Copyright (C) 2022-2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include "fixtures.hpp" + +struct urLoaderConfigGetInfoTest + : LoaderConfigTest, + ::testing::WithParamInterface { + void SetUp() override { + LoaderConfigTest::SetUp(); + infoType = GetParam(); + ASSERT_SUCCESS(urLoaderConfigGetInfo(loaderConfig, infoType, 0, nullptr, + &infoSize)); + EXPECT_NE(0, infoSize); + infoAllocation.resize(infoSize); + } + + ur_loader_config_info_t infoType; + size_t infoSize = 0; + std::vector infoAllocation; +}; + +INSTANTIATE_TEST_SUITE_P( + , urLoaderConfigGetInfoTest, + ::testing::Values(UR_LOADER_CONFIG_INFO_AVAILABLE_LAYERS, + UR_LOADER_CONFIG_INFO_REFERENCE_COUNT)); + +TEST_P(urLoaderConfigGetInfoTest, Success) { + ASSERT_SUCCESS(urLoaderConfigGetInfo(loaderConfig, infoType, infoSize, + infoAllocation.data(), nullptr)); +} + +TEST_P(urLoaderConfigGetInfoTest, InvalidNullHandleLoaderConfig) { + ASSERT_EQ(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urLoaderConfigGetInfo(nullptr, infoType, infoSize, + infoAllocation.data(), nullptr)); +} + +TEST_P(urLoaderConfigGetInfoTest, InvalidNullPointer) { + ASSERT_EQ( + UR_RESULT_ERROR_INVALID_NULL_POINTER, + urLoaderConfigGetInfo(loaderConfig, infoType, 0, nullptr, nullptr)); +} + +TEST_P(urLoaderConfigGetInfoTest, InvalidEnumerationInfoType) { + ASSERT_EQ(UR_RESULT_ERROR_INVALID_ENUMERATION, + urLoaderConfigGetInfo(loaderConfig, + UR_LOADER_CONFIG_INFO_FORCE_UINT32, 0, + nullptr, &infoSize)); +} diff --git a/test/loader/loader_config/urLoaderConfigRelease.cpp b/test/loader/loader_config/urLoaderConfigRelease.cpp new file mode 100644 index 0000000000..b58a954a1f --- /dev/null +++ b/test/loader/loader_config/urLoaderConfigRelease.cpp @@ -0,0 +1,31 @@ +// Copyright (C) 2022-2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include "fixtures.hpp" + +using urLoaderConfigReleaseTest = LoaderConfigTest; + +TEST_F(urLoaderConfigReleaseTest, Success) { + ASSERT_SUCCESS(urLoaderConfigRetain(loaderConfig)); + + uint32_t prevRefCount = 0; + ASSERT_SUCCESS(urLoaderConfigGetInfo( + loaderConfig, UR_LOADER_CONFIG_INFO_REFERENCE_COUNT, + sizeof(prevRefCount), &prevRefCount, nullptr)); + + ASSERT_SUCCESS(urLoaderConfigRelease(loaderConfig)); + + uint32_t refCount = 0; + ASSERT_SUCCESS(urLoaderConfigGetInfo(loaderConfig, + UR_LOADER_CONFIG_INFO_REFERENCE_COUNT, + sizeof(refCount), &refCount, nullptr)); + + ASSERT_LT(refCount, prevRefCount); +} + +TEST_F(urLoaderConfigReleaseTest, InvalidNullHandleLoaderConfig) { + ASSERT_EQ(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urLoaderConfigRelease(nullptr)); +} diff --git a/test/loader/loader_config/urLoaderConfigRetain.cpp b/test/loader/loader_config/urLoaderConfigRetain.cpp new file mode 100644 index 0000000000..583b37c13e --- /dev/null +++ b/test/loader/loader_config/urLoaderConfigRetain.cpp @@ -0,0 +1,31 @@ +// Copyright (C) 2022-2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include "fixtures.hpp" + +using urLoaderConfigRetainTest = LoaderConfigTest; + +TEST_F(urLoaderConfigRetainTest, Success) { + uint32_t prevRefCount = 0; + ASSERT_SUCCESS(urLoaderConfigGetInfo( + loaderConfig, UR_LOADER_CONFIG_INFO_REFERENCE_COUNT, + sizeof(prevRefCount), &prevRefCount, nullptr)); + + ASSERT_SUCCESS(urLoaderConfigRetain(loaderConfig)); + + uint32_t refCount = 0; + ASSERT_SUCCESS(urLoaderConfigGetInfo(loaderConfig, + UR_LOADER_CONFIG_INFO_REFERENCE_COUNT, + sizeof(refCount), &refCount, nullptr)); + + ASSERT_GT(refCount, prevRefCount); + + ASSERT_SUCCESS(urLoaderConfigRelease(loaderConfig)); +} + +TEST_F(urLoaderConfigRetainTest, InvalidNullHandleLoaderConfig) { + ASSERT_EQ(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urLoaderConfigRetain(nullptr)); +} diff --git a/test/loader/platforms/CMakeLists.txt b/test/loader/platforms/CMakeLists.txt index f943fffd23..86f8eea085 100644 --- a/test/loader/platforms/CMakeLists.txt +++ b/test/loader/platforms/CMakeLists.txt @@ -3,7 +3,7 @@ # See LICENSE.TXT # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -add_executable(test-loader-platforms +add_ur_executable(test-loader-platforms platforms.cpp ) diff --git a/test/loader/platforms/platforms.cpp b/test/loader/platforms/platforms.cpp index 5f7ee416e2..bb4f8fb79d 100644 --- a/test/loader/platforms/platforms.cpp +++ b/test/loader/platforms/platforms.cpp @@ -24,17 +24,33 @@ int main(int argc, char *argv[]) { ur_result_t status; // Initialize the platform - status = urInit(0); + status = urInit(0, nullptr); if (status != UR_RESULT_SUCCESS) { out.error("urInit failed with return code: {}", status); return 1; } out.info("urInit succeeded."); + uint32_t adapterCount = 0; + std::vector adapters; + status = urAdapterGet(0, nullptr, &adapterCount); + if (status != UR_RESULT_SUCCESS) { + error("urAdapterGet failed with return code: {}", status); + return 1; + } + + adapters.resize(adapterCount); + status = urAdapterGet(adapterCount, adapters.data(), nullptr); + if (status != UR_RESULT_SUCCESS) { + error("urAdapterGet failed with return code: {}", status); + return 1; + } + uint32_t platformCount = 0; std::vector platforms; - status = urPlatformGet(1, nullptr, &platformCount); + status = urPlatformGet(adapters.data(), adapterCount, 1, nullptr, + &platformCount); if (status != UR_RESULT_SUCCESS) { out.error("urPlatformGet failed with return code: {}", status); goto out; @@ -42,7 +58,8 @@ int main(int argc, char *argv[]) { out.info("urPlatformGet found {} platforms", platformCount); platforms.resize(platformCount); - status = urPlatformGet(platformCount, platforms.data(), nullptr); + status = urPlatformGet(adapters.data(), adapterCount, platformCount, + platforms.data(), nullptr); if (status != UR_RESULT_SUCCESS) { out.error("urPlatformGet failed with return code: {}", status); goto out; diff --git a/test/tools/urtrace/null_hello.match b/test/tools/urtrace/null_hello.match index 59e4c95367..b58a4d8d96 100644 --- a/test/tools/urtrace/null_hello.match +++ b/test/tools/urtrace/null_hello.match @@ -1,7 +1,9 @@ -urInit(.device_flags = 0) -> UR_RESULT_SUCCESS; +urInit(.device_flags = 0, .hLoaderConfig = nullptr) -> UR_RESULT_SUCCESS; Platform initialized. -urPlatformGet(.NumEntries = 1, .phPlatforms = {}, .pNumPlatforms = {{.*}} (1)) -> UR_RESULT_SUCCESS; -urPlatformGet(.NumEntries = 1, .phPlatforms = {{{.*}}}, .pNumPlatforms = nullptr) -> UR_RESULT_SUCCESS; +urAdapterGet(.NumEntries = 0, .phAdapters = {}, .pNumAdapters = {{.*}} (1)) -> UR_RESULT_SUCCESS; +urAdapterGet(.NumEntries = 1, .phAdapters = {{{.*}}}, .pNumAdapters = nullptr) -> UR_RESULT_SUCCESS; +urPlatformGet(.phAdapters = {{{.*}}}, .NumAdapters = 1, .NumEntries = 1, .phPlatforms = {}, .pNumPlatforms = {{.*}} (1)) -> UR_RESULT_SUCCESS; +urPlatformGet(.phAdapters = {{{.*}}}, .NumAdapters = 1, .NumEntries = 1, .phPlatforms = {{{.*}}}, .pNumPlatforms = nullptr) -> UR_RESULT_SUCCESS; urPlatformGetApiVersion(.hPlatform = {{.*}}, .pVersion = {{.*}} ({{.*}})) -> UR_RESULT_SUCCESS; API version: {{.*}} urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 0, .phDevices = {}, .pNumDevices = {{.*}} (1)) -> UR_RESULT_SUCCESS; @@ -9,4 +11,5 @@ urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_TYPE, .propSize = {{.*}}, .pPropValue = {{.*}}, .pPropSizeRet = nullptr) -> UR_RESULT_SUCCESS; urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_NAME, .propSize = {{.*}}, .pPropValue = {{.*}}, .pPropSizeRet = nullptr) -> UR_RESULT_SUCCESS; Found a Null Device gpu. +urAdapterRelease(.hAdapter = {{.*}}) -> UR_RESULT_SUCCESS; urTearDown(.pParams = nullptr) -> UR_RESULT_SUCCESS; diff --git a/test/tools/urtrace/null_hello_begin.match b/test/tools/urtrace/null_hello_begin.match index c706e5616d..571b01bb89 100644 --- a/test/tools/urtrace/null_hello_begin.match +++ b/test/tools/urtrace/null_hello_begin.match @@ -1,21 +1,27 @@ -begin(1) - urInit(.device_flags = 0); -end(1) - urInit(.device_flags = 0) -> UR_RESULT_SUCCESS; +begin(1) - urInit(.device_flags = 0, .hLoaderConfig = nullptr); +end(1) - urInit(.device_flags = 0, .hLoaderConfig = nullptr) -> UR_RESULT_SUCCESS; Platform initialized. -begin(2) - urPlatformGet(.NumEntries = 1, .phPlatforms = {}, .pNumPlatforms = {{.*}} (0)); -end(2) - urPlatformGet(.NumEntries = 1, .phPlatforms = {}, .pNumPlatforms = {{.*}} (1)) -> UR_RESULT_SUCCESS; -begin(3) - urPlatformGet(.NumEntries = 1, .phPlatforms = {nullptr}, .pNumPlatforms = nullptr); -end(3) - urPlatformGet(.NumEntries = 1, .phPlatforms = {{{.*}}}, .pNumPlatforms = nullptr) -> UR_RESULT_SUCCESS; -begin(4) - urPlatformGetApiVersion(.hPlatform = {{.*}}, .pVersion = {{.*}} (0.0)); -end(4) - urPlatformGetApiVersion(.hPlatform = {{.*}}, .pVersion = {{.*}} (0.6)) -> UR_RESULT_SUCCESS; +begin(2) - urAdapterGet(.NumEntries = 0, .phAdapters = {}, .pNumAdapters = {{.*}} (0)); +end(2) - urAdapterGet(.NumEntries = 0, .phAdapters = {}, .pNumAdapters = {{.*}} (1)) -> UR_RESULT_SUCCESS; +begin(3) - urAdapterGet(.NumEntries = 1, .phAdapters = {{{.*}}}, .pNumAdapters = nullptr); +end(3) - urAdapterGet(.NumEntries = 1, .phAdapters = {{{.*}}}, .pNumAdapters = nullptr) -> UR_RESULT_SUCCESS; +begin(4) - urPlatformGet(.phAdapters = {{{.*}}}, .NumAdapters = 1, .NumEntries = 1, .phPlatforms = {}, .pNumPlatforms = {{.*}} (0)); +end(4) - urPlatformGet(.phAdapters = {{{.*}}}, .NumAdapters = 1, .NumEntries = 1, .phPlatforms = {}, .pNumPlatforms = {{.*}} (1)) -> UR_RESULT_SUCCESS; +begin(5) - urPlatformGet(.phAdapters = {{{.*}}}, .NumAdapters = 1, .NumEntries = 1, .phPlatforms = {nullptr}, .pNumPlatforms = nullptr); +end(5) - urPlatformGet(.phAdapters = {{{.*}}}, .NumAdapters = 1, .NumEntries = 1, .phPlatforms = {{{.*}}}, .pNumPlatforms = nullptr) -> UR_RESULT_SUCCESS; +begin(6) - urPlatformGetApiVersion(.hPlatform = {{.*}}, .pVersion = {{.*}} (0.0)); +end(6) - urPlatformGetApiVersion(.hPlatform = {{.*}}, .pVersion = {{.*}} (0.6)) -> UR_RESULT_SUCCESS; API version: {{.*}} -begin(5) - urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 0, .phDevices = {}, .pNumDevices = {{.*}} (0)); -end(5) - urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 0, .phDevices = {}, .pNumDevices = {{.*}} (1)) -> UR_RESULT_SUCCESS; -begin(6) - urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 1, .phDevices = {nullptr}, .pNumDevices = nullptr); -end(6) - urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 1, .phDevices = {{{.*}}}, .pNumDevices = nullptr) -> UR_RESULT_SUCCESS; -begin(7) - urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_TYPE, .propSize = 4, .pPropValue = {{.*}}, .pPropSizeRet = nullptr); -end(7) - urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_TYPE, .propSize = 4, .pPropValue = {{.*}}, .pPropSizeRet = nullptr) -> UR_RESULT_SUCCESS; -begin(8) - urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_NAME, .propSize = 1023, .pPropValue = {{.*}}, .pPropSizeRet = nullptr); -end(8) - urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_NAME, .propSize = 1023, .pPropValue = {{.*}}, .pPropSizeRet = nullptr) -> UR_RESULT_SUCCESS; +begin(7) - urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 0, .phDevices = {}, .pNumDevices = {{.*}} (0)); +end(7) - urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 0, .phDevices = {}, .pNumDevices = {{.*}} (1)) -> UR_RESULT_SUCCESS; +begin(8) - urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 1, .phDevices = {nullptr}, .pNumDevices = nullptr); +end(8) - urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 1, .phDevices = {{{.*}}}, .pNumDevices = nullptr) -> UR_RESULT_SUCCESS; +begin(9) - urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_TYPE, .propSize = 4, .pPropValue = {{.*}}, .pPropSizeRet = nullptr); +end(9) - urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_TYPE, .propSize = 4, .pPropValue = {{.*}}, .pPropSizeRet = nullptr) -> UR_RESULT_SUCCESS; +begin(10) - urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_NAME, .propSize = 1023, .pPropValue = {{.*}}, .pPropSizeRet = nullptr); +end(10) - urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_NAME, .propSize = 1023, .pPropValue = {{.*}}, .pPropSizeRet = nullptr) -> UR_RESULT_SUCCESS; Found a Null Device gpu. -begin(9) - urTearDown(.pParams = nullptr); -end(9) - urTearDown(.pParams = nullptr) -> UR_RESULT_SUCCESS; +begin(11) - urAdapterRelease(.hAdapter = {{.*}}); +end(11) - urAdapterRelease(.hAdapter = {{.*}}) -> UR_RESULT_SUCCESS; +begin(12) - urTearDown(.pParams = nullptr); +end(12) - urTearDown(.pParams = nullptr) -> UR_RESULT_SUCCESS; diff --git a/test/tools/urtrace/null_hello_json.match b/test/tools/urtrace/null_hello_json.match index 9b41e6e0d7..9ba4d93f62 100644 --- a/test/tools/urtrace/null_hello_json.match +++ b/test/tools/urtrace/null_hello_json.match @@ -1,9 +1,11 @@ { "traceEvents": [ -{ "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urInit", "args": "(.device_flags = 0)" }, +{ "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urInit", "args": "(.device_flags = 0, .hLoaderConfig = nullptr)" }, Platform initialized. -{ "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urPlatformGet", "args": "(.NumEntries = 1, .phPlatforms = {}, .pNumPlatforms = {{.*}} (1))" }, -{ "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urPlatformGet", "args": "(.NumEntries = 1, .phPlatforms = {{{.*}}}, .pNumPlatforms = nullptr)" }, +{ "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urAdapterGet", "args": "(.NumEntries = 0, .phAdapters = {}, .pNumAdapters = {{.*}} (1))" }, +{ "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urAdapterGet", "args": "(.NumEntries = 1, .phAdapters = {{{.*}}}, .pNumAdapters = nullptr)" }, +{ "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urPlatformGet", "args": "(.phAdapters = {{{.*}}}, .NumAdapters = 1, .NumEntries = 1, .phPlatforms = {}, .pNumPlatforms = {{.*}} (1))" }, +{ "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urPlatformGet", "args": "(.phAdapters = {{{.*}}}, .NumAdapters = 1, .NumEntries = 1, .phPlatforms = {{{.*}}}, .pNumPlatforms = nullptr)" }, { "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urPlatformGetApiVersion", "args": "(.hPlatform = {{.*}}, .pVersion = {{.*}} (0.6))" }, API version: 0.6 { "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urDeviceGet", "args": "(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 0, .phDevices = {}, .pNumDevices = {{.*}} (1))" }, @@ -11,7 +13,8 @@ API version: 0.6 { "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urDeviceGetInfo", "args": "(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_TYPE, .propSize = 4, .pPropValue = {{.*}} (UR_DEVICE_TYPE_GPU), .pPropSizeRet = nullptr)" }, { "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urDeviceGetInfo", "args": "(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_NAME, .propSize = 1023, .pPropValue = {{.*}} (Null Device), .pPropSizeRet = nullptr)" }, Found a Null Device gpu. +{ "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urAdapterRelease", "args": "(.hAdapter = {{.*}})" }, { "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urTearDown", "args": "(.pParams = nullptr)" }, {"name": "", "cat": "", "ph": "", "pid": "", "tid": "", "ts": ""} ] -} \ No newline at end of file +} diff --git a/test/tools/urtrace/null_hello_no_args.match b/test/tools/urtrace/null_hello_no_args.match index b4edbe85f7..e0afcd2868 100644 --- a/test/tools/urtrace/null_hello_no_args.match +++ b/test/tools/urtrace/null_hello_no_args.match @@ -1,5 +1,7 @@ urInit(...) -> UR_RESULT_SUCCESS; Platform initialized. +urAdapterGet(...) -> UR_RESULT_SUCCESS; +urAdapterGet(...) -> UR_RESULT_SUCCESS; urPlatformGet(...) -> UR_RESULT_SUCCESS; urPlatformGet(...) -> UR_RESULT_SUCCESS; urPlatformGetApiVersion(...) -> UR_RESULT_SUCCESS; @@ -9,4 +11,5 @@ urDeviceGet(...) -> UR_RESULT_SUCCESS; urDeviceGetInfo(...) -> UR_RESULT_SUCCESS; urDeviceGetInfo(...) -> UR_RESULT_SUCCESS; Found a Null Device gpu. +urAdapterRelease(...) -> UR_RESULT_SUCCESS; urTearDown(...) -> UR_RESULT_SUCCESS; diff --git a/test/tools/urtrace/null_hello_profiling.match b/test/tools/urtrace/null_hello_profiling.match index 1162bb4a53..635c3c8784 100644 --- a/test/tools/urtrace/null_hello_profiling.match +++ b/test/tools/urtrace/null_hello_profiling.match @@ -1,7 +1,9 @@ -urInit(.device_flags = 0) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) +urInit(.device_flags = 0, .hLoaderConfig = nullptr) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) Platform initialized. -urPlatformGet(.NumEntries = 1, .phPlatforms = {}, .pNumPlatforms = {{.*}} (1)) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) -urPlatformGet(.NumEntries = 1, .phPlatforms = {{{.*}}}, .pNumPlatforms = nullptr) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) +urAdapterGet(.NumEntries = 0, .phAdapters = {}, .pNumAdapters = {{.*}} (1)) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) +urAdapterGet(.NumEntries = 1, .phAdapters = {{{.*}}}, .pNumAdapters = nullptr) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) +urPlatformGet(.phAdapters = {{{.*}}}, .NumAdapters = 1, .NumEntries = 1, .phPlatforms = {}, .pNumPlatforms = {{.*}} (1)) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) +urPlatformGet(.phAdapters = {{{.*}}}, .NumAdapters = 1, .NumEntries = 1, .phPlatforms = {{{.*}}}, .pNumPlatforms = nullptr) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) urPlatformGetApiVersion(.hPlatform = {{.*}}, .pVersion = {{.*}} ({{.*}})) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) API version: {{.*}} urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 0, .phDevices = {}, .pNumDevices = {{.*}} (1)) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) @@ -9,4 +11,5 @@ urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_TYPE, .propSize = {{.*}}, .pPropValue = {{.*}}, .pPropSizeRet = nullptr) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_NAME, .propSize = {{.*}}, .pPropValue = {{.*}}, .pPropSizeRet = nullptr) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) Found a Null Device gpu. +urAdapterRelease(.hAdapter = {{.*}}) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) urTearDown(.pParams = nullptr) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) diff --git a/test/unified_malloc_framework/CMakeLists.txt b/test/unified_malloc_framework/CMakeLists.txt new file mode 100644 index 0000000000..386ea5bdf9 --- /dev/null +++ b/test/unified_malloc_framework/CMakeLists.txt @@ -0,0 +1,40 @@ +# Copyright (C) 2022-2023 Intel Corporation +# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +# See LICENSE.TXT +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +set(UR_UMF_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + +add_ur_library(umf_test_helpers STATIC + ${UR_UMF_TEST_DIR}/common/pool.c + ${UR_UMF_TEST_DIR}/common/provider.c +) + +target_link_libraries(umf_test_helpers PRIVATE ${PROJECT_NAME}::common) + +function(add_umf_test name) + set(TEST_TARGET_NAME umf_test-${name}) + add_ur_executable(${TEST_TARGET_NAME} + ${ARGN}) + target_link_libraries(${TEST_TARGET_NAME} + PRIVATE + ${PROJECT_NAME}::unified_malloc_framework + ${PROJECT_NAME}::common + umf_test_helpers + GTest::gtest_main) + target_include_directories(${TEST_TARGET_NAME} PRIVATE + ${UR_UMF_TEST_DIR}/common) + add_test(NAME umf-${name} + COMMAND ${TEST_TARGET_NAME} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + set_tests_properties(umf-${name} PROPERTIES LABELS "umf") + if (UMF_ENABLE_POOL_TRACKING) + target_compile_definitions(${TEST_TARGET_NAME} PRIVATE UMF_ENABLE_POOL_TRACKING_TESTS=1) + endif() +endfunction() + +add_subdirectory(umf_pools) + +add_umf_test(memoryProvider memoryProviderAPI.cpp) +add_umf_test(memoryPool memoryPoolAPI.cpp) +add_umf_test(base base.cpp) diff --git a/test/unified_memory_allocation/base.cpp b/test/unified_malloc_framework/base.cpp similarity index 60% rename from test/unified_memory_allocation/base.cpp rename to test/unified_malloc_framework/base.cpp index 49ff6b425d..c9f6211f66 100644 --- a/test/unified_memory_allocation/base.cpp +++ b/test/unified_malloc_framework/base.cpp @@ -5,12 +5,12 @@ #include "base.hpp" -#include +#include -using uma_test::test; +using umf_test::test; TEST_F(test, versionEncodeDecode) { - auto encoded = UMA_MAKE_VERSION(0, 9); - ASSERT_EQ(UMA_MAJOR_VERSION(encoded), 0); - ASSERT_EQ(UMA_MINOR_VERSION(encoded), 9); + auto encoded = UMF_MAKE_VERSION(0, 9); + ASSERT_EQ(UMF_MAJOR_VERSION(encoded), 0); + ASSERT_EQ(UMF_MINOR_VERSION(encoded), 9); } diff --git a/test/unified_memory_allocation/common/base.hpp b/test/unified_malloc_framework/common/base.hpp similarity index 90% rename from test/unified_memory_allocation/common/base.hpp rename to test/unified_malloc_framework/common/base.hpp index d454b3822d..c4d6ccd129 100644 --- a/test/unified_memory_allocation/common/base.hpp +++ b/test/unified_malloc_framework/common/base.hpp @@ -8,12 +8,12 @@ * */ -#ifndef UMA_TEST_BASE_HPP -#define UMA_TEST_BASE_HPP 1 +#ifndef UMF_TEST_BASE_HPP +#define UMF_TEST_BASE_HPP 1 #include -namespace uma_test { +namespace umf_test { #define NOEXCEPT_COND(cond, val, expected_val) \ try { \ @@ -32,6 +32,6 @@ struct test : ::testing::Test { void SetUp() override { ::testing::Test::SetUp(); } void TearDown() override { ::testing::Test::TearDown(); } }; -} // namespace uma_test +} // namespace umf_test -#endif /* UMA_TEST_BASE_HPP */ +#endif /* UMF_TEST_BASE_HPP */ diff --git a/test/unified_memory_allocation/common/pool.c b/test/unified_malloc_framework/common/pool.c similarity index 50% rename from test/unified_memory_allocation/common/pool.c rename to test/unified_malloc_framework/common/pool.c index 7d229cf11f..7481557760 100644 --- a/test/unified_memory_allocation/common/pool.c +++ b/test/unified_malloc_framework/common/pool.c @@ -6,12 +6,12 @@ #include "pool.h" #include "provider.h" -#include +#include #include #include -static enum uma_result_t nullInitialize(uma_memory_provider_handle_t *providers, +static enum umf_result_t nullInitialize(umf_memory_provider_handle_t *providers, size_t numProviders, void *params, void **pool) { (void)providers; @@ -19,7 +19,7 @@ static enum uma_result_t nullInitialize(uma_memory_provider_handle_t *providers, (void)params; assert(providers && numProviders); *pool = NULL; - return UMA_RESULT_SUCCESS; + return UMF_RESULT_SUCCESS; } static void nullFinalize(void *pool) { (void)pool; } @@ -57,41 +57,41 @@ static size_t nullMallocUsableSize(void *pool, void *ptr) { return 0; } -static void nullFree(void *pool, void *ptr) { +static enum umf_result_t nullFree(void *pool, void *ptr) { (void)pool; (void)ptr; + return UMF_RESULT_SUCCESS; } -enum uma_result_t nullGetLastResult(void *pool, const char **ppMsg) { +enum umf_result_t nullGetLastStatus(void *pool) { (void)pool; - (void)ppMsg; - return UMA_RESULT_SUCCESS; -} - -uma_memory_pool_handle_t nullPoolCreate(void) { - struct uma_memory_pool_ops_t ops = {.version = UMA_VERSION_CURRENT, - .initialize = nullInitialize, - .finalize = nullFinalize, - .malloc = nullMalloc, - .realloc = nullRealloc, - .calloc = nullCalloc, - .aligned_malloc = nullAlignedMalloc, - .malloc_usable_size = - nullMallocUsableSize, - .free = nullFree, - .get_last_result = nullGetLastResult}; - - uma_memory_provider_handle_t providerDesc = nullProviderCreate(); - uma_memory_pool_handle_t hPool; - enum uma_result_t ret = umaPoolCreate(&ops, &providerDesc, 1, NULL, &hPool); + return UMF_RESULT_SUCCESS; +} + +umf_memory_pool_handle_t nullPoolCreate(void) { + struct umf_memory_pool_ops_t ops = { + .version = UMF_VERSION_CURRENT, + .initialize = nullInitialize, + .finalize = nullFinalize, + .malloc = nullMalloc, + .realloc = nullRealloc, + .calloc = nullCalloc, + .aligned_malloc = nullAlignedMalloc, + .malloc_usable_size = nullMallocUsableSize, + .free = nullFree, + .get_last_allocation_error = nullGetLastStatus}; + + umf_memory_provider_handle_t providerDesc = nullProviderCreate(); + umf_memory_pool_handle_t hPool; + enum umf_result_t ret = umfPoolCreate(&ops, &providerDesc, 1, NULL, &hPool); (void)ret; /* silence unused variable warning */ - assert(ret == UMA_RESULT_SUCCESS); + assert(ret == UMF_RESULT_SUCCESS); return hPool; } struct traceParams { - uma_memory_pool_handle_t hUpstreamPool; + umf_memory_pool_handle_t hUpstreamPool; void (*trace)(const char *); }; @@ -99,8 +99,8 @@ struct tracePool { struct traceParams params; }; -static enum uma_result_t -traceInitialize(uma_memory_provider_handle_t *providers, size_t numProviders, +static enum umf_result_t +traceInitialize(umf_memory_provider_handle_t *providers, size_t numProviders, void *params, void **pool) { struct tracePool *tracePool = (struct tracePool *)malloc(sizeof(struct tracePool)); @@ -111,7 +111,7 @@ traceInitialize(uma_memory_provider_handle_t *providers, size_t numProviders, assert(providers && numProviders); *pool = tracePool; - return UMA_RESULT_SUCCESS; + return UMF_RESULT_SUCCESS; } static void traceFinalize(void *pool) { free(pool); } @@ -120,28 +120,28 @@ static void *traceMalloc(void *pool, size_t size) { struct tracePool *tracePool = (struct tracePool *)pool; tracePool->params.trace("malloc"); - return umaPoolMalloc(tracePool->params.hUpstreamPool, size); + return umfPoolMalloc(tracePool->params.hUpstreamPool, size); } static void *traceCalloc(void *pool, size_t num, size_t size) { struct tracePool *tracePool = (struct tracePool *)pool; tracePool->params.trace("calloc"); - return umaPoolCalloc(tracePool->params.hUpstreamPool, num, size); + return umfPoolCalloc(tracePool->params.hUpstreamPool, num, size); } static void *traceRealloc(void *pool, void *ptr, size_t size) { struct tracePool *tracePool = (struct tracePool *)pool; tracePool->params.trace("realloc"); - return umaPoolRealloc(tracePool->params.hUpstreamPool, ptr, size); + return umfPoolRealloc(tracePool->params.hUpstreamPool, ptr, size); } static void *traceAlignedMalloc(void *pool, size_t size, size_t alignment) { struct tracePool *tracePool = (struct tracePool *)pool; tracePool->params.trace("aligned_malloc"); - return umaPoolAlignedMalloc(tracePool->params.hUpstreamPool, size, + return umfPoolAlignedMalloc(tracePool->params.hUpstreamPool, size, alignment); } @@ -149,47 +149,47 @@ static size_t traceMallocUsableSize(void *pool, void *ptr) { struct tracePool *tracePool = (struct tracePool *)pool; tracePool->params.trace("malloc_usable_size"); - return umaPoolMallocUsableSize(tracePool->params.hUpstreamPool, ptr); + return umfPoolMallocUsableSize(tracePool->params.hUpstreamPool, ptr); } -static void traceFree(void *pool, void *ptr) { +static enum umf_result_t traceFree(void *pool, void *ptr) { struct tracePool *tracePool = (struct tracePool *)pool; tracePool->params.trace("free"); - umaPoolFree(tracePool->params.hUpstreamPool, ptr); + return umfPoolFree(tracePool->params.hUpstreamPool, ptr); } -enum uma_result_t traceGetLastResult(void *pool, const char **ppMsg) { +enum umf_result_t traceGetLastStatus(void *pool) { struct tracePool *tracePool = (struct tracePool *)pool; - tracePool->params.trace("get_last_result"); - return umaPoolGetLastResult(tracePool->params.hUpstreamPool, ppMsg); + tracePool->params.trace("get_last_native_error"); + return umfPoolGetLastAllocationError(tracePool->params.hUpstreamPool); } -uma_memory_pool_handle_t -tracePoolCreate(uma_memory_pool_handle_t hUpstreamPool, - uma_memory_provider_handle_t providerDesc, +umf_memory_pool_handle_t +tracePoolCreate(umf_memory_pool_handle_t hUpstreamPool, + umf_memory_provider_handle_t providerDesc, void (*trace)(const char *)) { - struct uma_memory_pool_ops_t ops = {.version = UMA_VERSION_CURRENT, - .initialize = traceInitialize, - .finalize = traceFinalize, - .malloc = traceMalloc, - .realloc = traceRealloc, - .calloc = traceCalloc, - .aligned_malloc = traceAlignedMalloc, - .malloc_usable_size = - traceMallocUsableSize, - .free = traceFree, - .get_last_result = traceGetLastResult}; + struct umf_memory_pool_ops_t ops = { + .version = UMF_VERSION_CURRENT, + .initialize = traceInitialize, + .finalize = traceFinalize, + .malloc = traceMalloc, + .realloc = traceRealloc, + .calloc = traceCalloc, + .aligned_malloc = traceAlignedMalloc, + .malloc_usable_size = traceMallocUsableSize, + .free = traceFree, + .get_last_allocation_error = traceGetLastStatus}; struct traceParams params = {.hUpstreamPool = hUpstreamPool, .trace = trace}; - uma_memory_pool_handle_t hPool; - enum uma_result_t ret = - umaPoolCreate(&ops, &providerDesc, 1, ¶ms, &hPool); + umf_memory_pool_handle_t hPool; + enum umf_result_t ret = + umfPoolCreate(&ops, &providerDesc, 1, ¶ms, &hPool); (void)ret; /* silence unused variable warning */ - assert(ret == UMA_RESULT_SUCCESS); + assert(ret == UMF_RESULT_SUCCESS); return hPool; } diff --git a/test/unified_memory_allocation/common/pool.h b/test/unified_malloc_framework/common/pool.h similarity index 53% rename from test/unified_memory_allocation/common/pool.h rename to test/unified_malloc_framework/common/pool.h index d9719ad458..69d4711e3e 100644 --- a/test/unified_memory_allocation/common/pool.h +++ b/test/unified_malloc_framework/common/pool.h @@ -3,23 +3,23 @@ // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#ifndef UR_UMA_TEST_POOL_H -#define UR_UMA_TEST_POOL_H +#ifndef UR_UMF_TEST_POOL_H +#define UR_UMF_TEST_POOL_H -#include +#include #if defined(__cplusplus) extern "C" { #endif -uma_memory_pool_handle_t nullPoolCreate(void); -uma_memory_pool_handle_t -tracePoolCreate(uma_memory_pool_handle_t hUpstreamPool, - uma_memory_provider_handle_t providerDesc, +umf_memory_pool_handle_t nullPoolCreate(void); +umf_memory_pool_handle_t +tracePoolCreate(umf_memory_pool_handle_t hUpstreamPool, + umf_memory_provider_handle_t providerDesc, void (*trace)(const char *)); #if defined(__cplusplus) } #endif -#endif // UR_UMA_TEST_POOL_H +#endif // UR_UMF_TEST_POOL_H diff --git a/test/unified_malloc_framework/common/pool.hpp b/test/unified_malloc_framework/common/pool.hpp new file mode 100644 index 0000000000..7a7b650e11 --- /dev/null +++ b/test/unified_malloc_framework/common/pool.hpp @@ -0,0 +1,170 @@ +/* + * + * Copyright (C) 2023 Intel Corporation + * + * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. + * See LICENSE.TXT + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + */ + +#ifndef UMF_TEST_POOL_HPP +#define UMF_TEST_POOL_HPP 1 + +#if defined(__APPLE__) +#include +#else +#include +#endif +#include +#include + +#include +#include + +#include "base.hpp" +#include "umf_helpers.hpp" + +namespace umf_test { + +auto wrapPoolUnique(umf_memory_pool_handle_t hPool) { + return umf::pool_unique_handle_t(hPool, &umfPoolDestroy); +} + +bool isReallocSupported(umf_memory_pool_handle_t hPool) { + static constexpr size_t allocSize = 8; + bool supported; + auto *ptr = umfPoolMalloc(hPool, allocSize); + auto *new_ptr = umfPoolRealloc(hPool, ptr, allocSize * 2); + + if (new_ptr) { + supported = true; + umfPoolFree(hPool, new_ptr); + } else if (umfPoolGetLastAllocationError(hPool) == + UMF_RESULT_ERROR_NOT_SUPPORTED) { + umfPoolFree(hPool, ptr); + supported = false; + } else { + umfPoolFree(hPool, new_ptr); + throw std::runtime_error("realloc failed with unexpected error"); + } + + return supported; +} + +bool isCallocSupported(umf_memory_pool_handle_t hPool) { + static constexpr size_t num = 8; + static constexpr size_t size = sizeof(int); + bool supported; + auto *ptr = umfPoolCalloc(hPool, num, size); + + if (ptr) { + supported = true; + umfPoolFree(hPool, ptr); + } else if (umfPoolGetLastAllocationError(hPool) == + UMF_RESULT_ERROR_NOT_SUPPORTED) { + supported = false; + } else { + umfPoolFree(hPool, ptr); + throw std::runtime_error("calloc failed with unexpected error"); + } + + return supported; +} + +struct pool_base { + umf_result_t initialize(umf_memory_provider_handle_t *, size_t) noexcept { + return UMF_RESULT_SUCCESS; + }; + void *malloc(size_t size) noexcept { return nullptr; } + void *calloc(size_t, size_t) noexcept { return nullptr; } + void *realloc(void *, size_t) noexcept { return nullptr; } + void *aligned_malloc(size_t, size_t) noexcept { return nullptr; } + size_t malloc_usable_size(void *) noexcept { return 0; } + enum umf_result_t free(void *) noexcept { return UMF_RESULT_SUCCESS; } + enum umf_result_t get_last_allocation_error() noexcept { + return UMF_RESULT_SUCCESS; + } +}; + +struct malloc_pool : public pool_base { + void *malloc(size_t size) noexcept { return ::malloc(size); } + void *calloc(size_t num, size_t size) noexcept { + return ::calloc(num, size); + } + void *realloc(void *ptr, size_t size) noexcept { + return ::realloc(ptr, size); + } + void *aligned_malloc(size_t size, size_t alignment) noexcept { +#ifdef _WIN32 + // we could use _aligned_malloc but it requires using _aligned_free... + return nullptr; +#else + return ::aligned_alloc(alignment, size); +#endif + } + size_t malloc_usable_size(void *ptr) noexcept { +#ifdef _WIN32 + return _msize(ptr); +#elif __APPLE__ + return ::malloc_size(ptr); +#else + return ::malloc_usable_size(ptr); +#endif + } + enum umf_result_t free(void *ptr) noexcept { + ::free(ptr); + return UMF_RESULT_SUCCESS; + } +}; + +struct proxy_pool : public pool_base { + umf_result_t initialize(umf_memory_provider_handle_t *providers, + size_t numProviders) noexcept { + this->provider = providers[0]; + return UMF_RESULT_SUCCESS; + } + void *malloc(size_t size) noexcept { return aligned_malloc(size, 0); } + void *calloc(size_t num, size_t size) noexcept { + void *ptr; + auto ret = umfMemoryProviderAlloc(provider, num * size, 0, &ptr); + + memset(ptr, 0, num * size); + + if (ptr) { + EXPECT_EQ_NOEXCEPT(ret, UMF_RESULT_SUCCESS); + } + return ptr; + } + void *realloc(void *ptr, size_t size) noexcept { + // TODO: not supported + umf::getPoolLastStatusRef() = + UMF_RESULT_ERROR_NOT_SUPPORTED; + return nullptr; + } + void *aligned_malloc(size_t size, size_t alignment) noexcept { + void *ptr; + auto ret = umfMemoryProviderAlloc(provider, size, alignment, &ptr); + if (ptr) { + EXPECT_EQ_NOEXCEPT(ret, UMF_RESULT_SUCCESS); + } + return ptr; + } + size_t malloc_usable_size(void *ptr) noexcept { + // TODO: not supported + return 0; + } + enum umf_result_t free(void *ptr) noexcept { + auto ret = umfMemoryProviderFree(provider, ptr, 0); + EXPECT_EQ_NOEXCEPT(ret, UMF_RESULT_SUCCESS); + return ret; + } + enum umf_result_t get_last_allocation_error() { + return umf::getPoolLastStatusRef(); + } + umf_memory_provider_handle_t provider; +}; + +} // namespace umf_test + +#endif /* UMF_TEST_POOL_HPP */ diff --git a/test/unified_memory_allocation/common/provider.c b/test/unified_malloc_framework/common/provider.c similarity index 58% rename from test/unified_memory_allocation/common/provider.c rename to test/unified_malloc_framework/common/provider.c index 05dce162ed..8f9e946bfc 100644 --- a/test/unified_memory_allocation/common/provider.c +++ b/test/unified_malloc_framework/common/provider.c @@ -5,195 +5,196 @@ #include "provider.h" -#include +#include #include #include -static enum uma_result_t nullInitialize(void *params, void **pool) { +static enum umf_result_t nullInitialize(void *params, void **pool) { (void)params; *pool = NULL; - return UMA_RESULT_SUCCESS; + return UMF_RESULT_SUCCESS; } static void nullFinalize(void *pool) { (void)pool; } -static enum uma_result_t nullAlloc(void *provider, size_t size, +static enum umf_result_t nullAlloc(void *provider, size_t size, size_t alignment, void **ptr) { (void)provider; (void)size; (void)alignment; (void)ptr; - return UMA_RESULT_SUCCESS; + return UMF_RESULT_SUCCESS; } -static enum uma_result_t nullFree(void *provider, void *ptr, size_t size) { +static enum umf_result_t nullFree(void *provider, void *ptr, size_t size) { (void)provider; (void)ptr; (void)size; - return UMA_RESULT_SUCCESS; + return UMF_RESULT_SUCCESS; } -static enum uma_result_t nullGetLastResult(void *provider, const char **ppMsg) { +static void nullGetLastError(void *provider, const char **ppMsg, + int32_t *pError) { (void)provider; (void)ppMsg; - return UMA_RESULT_SUCCESS; + (void)pError; } -static enum uma_result_t nullGetRecommendedPageSize(void *provider, size_t size, +static enum umf_result_t nullGetRecommendedPageSize(void *provider, size_t size, size_t *pageSize) { (void)provider; (void)size; (void)pageSize; - return UMA_RESULT_SUCCESS; + return UMF_RESULT_SUCCESS; } -static enum uma_result_t nullGetPageSize(void *provider, void *ptr, +static enum umf_result_t nullGetPageSize(void *provider, void *ptr, size_t *pageSize) { (void)provider; (void)ptr; (void)pageSize; - return UMA_RESULT_SUCCESS; + return UMF_RESULT_SUCCESS; } -static enum uma_result_t nullPurgeLazy(void *provider, void *ptr, size_t size) { +static enum umf_result_t nullPurgeLazy(void *provider, void *ptr, size_t size) { (void)provider; (void)ptr; (void)size; - return UMA_RESULT_SUCCESS; + return UMF_RESULT_SUCCESS; } -static enum uma_result_t nullPurgeForce(void *provider, void *ptr, +static enum umf_result_t nullPurgeForce(void *provider, void *ptr, size_t size) { (void)provider; (void)ptr; (void)size; - return UMA_RESULT_SUCCESS; + return UMF_RESULT_SUCCESS; } -static void nullName(void *provider, const char **ppName) { +static const char *nullName(void *provider) { (void)provider; - *ppName = "null"; + return "null"; } -uma_memory_provider_handle_t nullProviderCreate(void) { - struct uma_memory_provider_ops_t ops = { - .version = UMA_VERSION_CURRENT, +umf_memory_provider_handle_t nullProviderCreate(void) { + struct umf_memory_provider_ops_t ops = { + .version = UMF_VERSION_CURRENT, .initialize = nullInitialize, .finalize = nullFinalize, .alloc = nullAlloc, .free = nullFree, - .get_last_result = nullGetLastResult, + .get_last_native_error = nullGetLastError, .get_recommended_page_size = nullGetRecommendedPageSize, .get_min_page_size = nullGetPageSize, .purge_lazy = nullPurgeLazy, .purge_force = nullPurgeForce, .get_name = nullName}; - uma_memory_provider_handle_t hProvider; - enum uma_result_t ret = umaMemoryProviderCreate(&ops, NULL, &hProvider); + umf_memory_provider_handle_t hProvider; + enum umf_result_t ret = umfMemoryProviderCreate(&ops, NULL, &hProvider); (void)ret; /* silence unused variable warning */ - assert(ret == UMA_RESULT_SUCCESS); + assert(ret == UMF_RESULT_SUCCESS); return hProvider; } struct traceParams { - uma_memory_provider_handle_t hUpstreamProvider; + umf_memory_provider_handle_t hUpstreamProvider; void (*trace)(const char *); }; -static enum uma_result_t traceInitialize(void *params, void **pool) { +static enum umf_result_t traceInitialize(void *params, void **pool) { struct traceParams *tracePool = (struct traceParams *)malloc(sizeof(struct traceParams)); *tracePool = *((struct traceParams *)params); *pool = tracePool; - return UMA_RESULT_SUCCESS; + return UMF_RESULT_SUCCESS; } static void traceFinalize(void *pool) { free(pool); } -static enum uma_result_t traceAlloc(void *provider, size_t size, +static enum umf_result_t traceAlloc(void *provider, size_t size, size_t alignment, void **ptr) { struct traceParams *traceProvider = (struct traceParams *)provider; traceProvider->trace("alloc"); - return umaMemoryProviderAlloc(traceProvider->hUpstreamProvider, size, + return umfMemoryProviderAlloc(traceProvider->hUpstreamProvider, size, alignment, ptr); } -static enum uma_result_t traceFree(void *provider, void *ptr, size_t size) { +static enum umf_result_t traceFree(void *provider, void *ptr, size_t size) { struct traceParams *traceProvider = (struct traceParams *)provider; traceProvider->trace("free"); - return umaMemoryProviderFree(traceProvider->hUpstreamProvider, ptr, size); + return umfMemoryProviderFree(traceProvider->hUpstreamProvider, ptr, size); } -static enum uma_result_t traceGetLastResult(void *provider, - const char **ppMsg) { +static void traceGetLastError(void *provider, const char **ppMsg, + int32_t *pError) { struct traceParams *traceProvider = (struct traceParams *)provider; - traceProvider->trace("get_last_result"); - return umaMemoryProviderGetLastResult(traceProvider->hUpstreamProvider, - ppMsg); + traceProvider->trace("get_last_native_error"); + umfMemoryProviderGetLastNativeError(traceProvider->hUpstreamProvider, ppMsg, + pError); } -static enum uma_result_t +static enum umf_result_t traceGetRecommendedPageSize(void *provider, size_t size, size_t *pageSize) { struct traceParams *traceProvider = (struct traceParams *)provider; traceProvider->trace("get_recommended_page_size"); - return umaMemoryProviderGetRecommendedPageSize( + return umfMemoryProviderGetRecommendedPageSize( traceProvider->hUpstreamProvider, size, pageSize); } -static enum uma_result_t traceGetPageSize(void *provider, void *ptr, +static enum umf_result_t traceGetPageSize(void *provider, void *ptr, size_t *pageSize) { struct traceParams *traceProvider = (struct traceParams *)provider; traceProvider->trace("get_min_page_size"); - return umaMemoryProviderGetMinPageSize(traceProvider->hUpstreamProvider, + return umfMemoryProviderGetMinPageSize(traceProvider->hUpstreamProvider, ptr, pageSize); } -static enum uma_result_t tracePurgeLazy(void *provider, void *ptr, +static enum umf_result_t tracePurgeLazy(void *provider, void *ptr, size_t size) { struct traceParams *traceProvider = (struct traceParams *)provider; traceProvider->trace("purge_lazy"); - return umaMemoryProviderPurgeLazy(traceProvider->hUpstreamProvider, ptr, + return umfMemoryProviderPurgeLazy(traceProvider->hUpstreamProvider, ptr, size); } -static enum uma_result_t tracePurgeForce(void *provider, void *ptr, +static enum umf_result_t tracePurgeForce(void *provider, void *ptr, size_t size) { struct traceParams *traceProvider = (struct traceParams *)provider; traceProvider->trace("purge_force"); - return umaMemoryProviderPurgeForce(traceProvider->hUpstreamProvider, ptr, + return umfMemoryProviderPurgeForce(traceProvider->hUpstreamProvider, ptr, size); } -static void traceName(void *provider, const char **ppName) { +static const char *traceName(void *provider) { struct traceParams *traceProvider = (struct traceParams *)provider; traceProvider->trace("name"); - umaMemoryProviderGetName(traceProvider->hUpstreamProvider, ppName); + return umfMemoryProviderGetName(traceProvider->hUpstreamProvider); } -uma_memory_provider_handle_t -traceProviderCreate(uma_memory_provider_handle_t hUpstreamProvider, +umf_memory_provider_handle_t +traceProviderCreate(umf_memory_provider_handle_t hUpstreamProvider, void (*trace)(const char *)) { - struct uma_memory_provider_ops_t ops = { - .version = UMA_VERSION_CURRENT, + struct umf_memory_provider_ops_t ops = { + .version = UMF_VERSION_CURRENT, .initialize = traceInitialize, .finalize = traceFinalize, .alloc = traceAlloc, .free = traceFree, - .get_last_result = traceGetLastResult, + .get_last_native_error = traceGetLastError, .get_recommended_page_size = traceGetRecommendedPageSize, .get_min_page_size = traceGetPageSize, .purge_lazy = tracePurgeLazy, @@ -203,10 +204,10 @@ traceProviderCreate(uma_memory_provider_handle_t hUpstreamProvider, struct traceParams params = {.hUpstreamProvider = hUpstreamProvider, .trace = trace}; - uma_memory_provider_handle_t hProvider; - enum uma_result_t ret = umaMemoryProviderCreate(&ops, ¶ms, &hProvider); + umf_memory_provider_handle_t hProvider; + enum umf_result_t ret = umfMemoryProviderCreate(&ops, ¶ms, &hProvider); (void)ret; /* silence unused variable warning */ - assert(ret == UMA_RESULT_SUCCESS); + assert(ret == UMF_RESULT_SUCCESS); return hProvider; } diff --git a/test/unified_memory_allocation/common/provider.h b/test/unified_malloc_framework/common/provider.h similarity index 55% rename from test/unified_memory_allocation/common/provider.h rename to test/unified_malloc_framework/common/provider.h index d0ffdf8069..e8451c5dde 100644 --- a/test/unified_memory_allocation/common/provider.h +++ b/test/unified_malloc_framework/common/provider.h @@ -3,22 +3,22 @@ // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#ifndef UR_UMA_TEST_PROVIDER_H -#define UR_UMA_TEST_PROVIDER_H +#ifndef UR_UMF_TEST_PROVIDER_H +#define UR_UMF_TEST_PROVIDER_H -#include +#include #if defined(__cplusplus) extern "C" { #endif -uma_memory_provider_handle_t nullProviderCreate(void); -uma_memory_provider_handle_t -traceProviderCreate(uma_memory_provider_handle_t hUpstreamProvider, +umf_memory_provider_handle_t nullProviderCreate(void); +umf_memory_provider_handle_t +traceProviderCreate(umf_memory_provider_handle_t hUpstreamProvider, void (*trace)(const char *)); #if defined(__cplusplus) } #endif -#endif // UR_UMA_TEST_PROVIDER_H +#endif // UR_UMF_TEST_PROVIDER_H diff --git a/test/unified_malloc_framework/common/provider.hpp b/test/unified_malloc_framework/common/provider.hpp new file mode 100644 index 0000000000..518b2b0528 --- /dev/null +++ b/test/unified_malloc_framework/common/provider.hpp @@ -0,0 +1,81 @@ +/* + * + * Copyright (C) 2023 Intel Corporation + * + * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. + * See LICENSE.TXT + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + */ + +#ifndef UMF_TEST_PROVIDER_HPP +#define UMF_TEST_PROVIDER_HPP 1 + +#include +#include + +#include + +#include "base.hpp" +#include "umf_helpers.hpp" + +namespace umf_test { + +auto wrapProviderUnique(umf_memory_provider_handle_t hProvider) { + return umf::provider_unique_handle_t(hProvider, &umfMemoryProviderDestroy); +} + +struct provider_base { + umf_result_t initialize() noexcept { return UMF_RESULT_SUCCESS; }; + enum umf_result_t alloc(size_t, size_t, void **) noexcept { + return UMF_RESULT_ERROR_UNKNOWN; + } + enum umf_result_t free(void *ptr, size_t size) noexcept { + return UMF_RESULT_ERROR_UNKNOWN; + } + void get_last_native_error(const char **, int32_t *) noexcept {} + enum umf_result_t get_recommended_page_size(size_t size, + size_t *pageSize) noexcept { + return UMF_RESULT_ERROR_UNKNOWN; + } + enum umf_result_t get_min_page_size(void *ptr, size_t *pageSize) noexcept { + return UMF_RESULT_ERROR_UNKNOWN; + } + enum umf_result_t purge_lazy(void *ptr, size_t size) noexcept { + return UMF_RESULT_ERROR_UNKNOWN; + } + enum umf_result_t purge_force(void *ptr, size_t size) noexcept { + return UMF_RESULT_ERROR_UNKNOWN; + } + const char *get_name() noexcept { return "base"; } +}; + +struct provider_malloc : public provider_base { + enum umf_result_t alloc(size_t size, size_t align, void **ptr) noexcept { + if (!align) { + align = 8; + } + +#ifdef _WIN32 + *ptr = _aligned_malloc(size, align); +#else + *ptr = ::aligned_alloc(align, size); +#endif + + return (*ptr) ? UMF_RESULT_SUCCESS + : UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY; + } + enum umf_result_t free(void *ptr, size_t) noexcept { +#ifdef _WIN32 + _aligned_free(ptr); +#else + ::free(ptr); +#endif + return UMF_RESULT_SUCCESS; + } + const char *get_name() noexcept { return "malloc"; } +}; + +} // namespace umf_test + +#endif /* UMF_TEST_PROVIDER_HPP */ diff --git a/test/unified_malloc_framework/memoryPool.hpp b/test/unified_malloc_framework/memoryPool.hpp new file mode 100644 index 0000000000..fde5954cf8 --- /dev/null +++ b/test/unified_malloc_framework/memoryPool.hpp @@ -0,0 +1,293 @@ +// Copyright (C) 2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include "pool.hpp" + +#include +#include +#include +#include +#include +#include + +#ifndef UMF_TEST_MEMORY_POOL_OPS_HPP +#define UMF_TEST_MEMORY_POOL_OPS_HPP + +struct umfPoolTest : umf_test::test, + ::testing::WithParamInterface< + std::function> { + umfPoolTest() : pool(nullptr, nullptr) {} + void SetUp() override { + test::SetUp(); + this->pool = makePool(); + } + + void TearDown() override { test::TearDown(); } + + umf::pool_unique_handle_t makePool() { + auto pool = this->GetParam()(); + EXPECT_NE(pool, nullptr); + return pool; + } + + umf::pool_unique_handle_t pool; + static constexpr int NTHREADS = 5; +}; + +struct umfMultiPoolTest : umfPoolTest { + static constexpr auto numPools = 16; + + void SetUp() override { + umfPoolTest::SetUp(); + + pools.emplace_back(std::move(pool)); + for (size_t i = 1; i < numPools; i++) { + pools.emplace_back(makePool()); + } + } + + void TearDown() override { umfPoolTest::TearDown(); } + + std::vector pools; +}; + +TEST_P(umfPoolTest, allocFree) { + static constexpr size_t allocSize = 64; + auto *ptr = umfPoolMalloc(pool.get(), allocSize); + ASSERT_NE(ptr, nullptr); + std::memset(ptr, 0, allocSize); + umfPoolFree(pool.get(), ptr); +} + +TEST_P(umfPoolTest, reallocFree) { + if (!umf_test::isReallocSupported(pool.get())) { + GTEST_SKIP(); + } + static constexpr size_t allocSize = 64; + static constexpr size_t multiplier = 3; + auto *ptr = umfPoolMalloc(pool.get(), allocSize); + ASSERT_NE(ptr, nullptr); + auto *new_ptr = umfPoolRealloc(pool.get(), ptr, allocSize * multiplier); + ASSERT_NE(new_ptr, nullptr); + std::memset(new_ptr, 0, allocSize * multiplier); + umfPoolFree(pool.get(), new_ptr); +} + +TEST_P(umfPoolTest, callocFree) { + if (!umf_test::isCallocSupported(pool.get())) { + GTEST_SKIP(); + } + static constexpr size_t num = 10; + static constexpr size_t size = sizeof(int); + auto *ptr = umfPoolCalloc(pool.get(), num, size); + ASSERT_NE(ptr, nullptr); + for (size_t i = 0; i < num; ++i) { + ASSERT_EQ(((int *)ptr)[i], 0); + } + umfPoolFree(pool.get(), ptr); +} + +void pow2AlignedAllocHelper(umf_memory_pool_handle_t pool) { + static constexpr size_t maxAlignment = (1u << 22); + static constexpr size_t numAllocs = 4; + for (size_t alignment = 1; alignment <= maxAlignment; alignment <<= 1) { + std::cout << alignment << std::endl; + std::vector allocs; + + for (size_t alloc = 0; alloc < numAllocs; alloc++) { + auto *ptr = umfPoolAlignedMalloc(pool, alignment, alignment); + ASSERT_NE(ptr, nullptr); + ASSERT_TRUE(reinterpret_cast(ptr) % alignment == 0); + std::memset(ptr, 0, alignment); + allocs.push_back(ptr); + } + + for (auto &ptr : allocs) { + umfPoolFree(pool, ptr); + } + } +} + +TEST_P(umfPoolTest, pow2AlignedAlloc) { +#ifdef _WIN32 + // TODO: implement support for windows + GTEST_SKIP(); +#endif + pow2AlignedAllocHelper(pool.get()); +} + +TEST_P(umfPoolTest, freeNullptr) { + void *ptr = nullptr; + auto ret = umfPoolFree(pool.get(), ptr); + ASSERT_EQ(ret, UMF_RESULT_SUCCESS); +} + +TEST_P(umfPoolTest, multiThreadedMallocFree) { + static constexpr size_t allocSize = 64; + auto poolMalloc = [](size_t allocSize, umf_memory_pool_handle_t pool) { + std::vector allocations; + for (size_t i = 0; i <= 10; ++i) { + allocations.emplace_back(umfPoolMalloc(pool, allocSize)); + ASSERT_NE(allocations.back(), nullptr); + } + + for (auto allocation : allocations) { + umfPoolFree(pool, allocation); + } + }; + + std::vector threads; + for (int i = 0; i < NTHREADS; i++) { + threads.emplace_back(poolMalloc, allocSize, pool.get()); + ; + } + + for (auto &thread : threads) { + thread.join(); + } +} + +TEST_P(umfPoolTest, multiThreadedpow2AlignedAlloc) { +#ifdef _WIN32 + // TODO: implement support for windows + GTEST_SKIP(); +#endif + + auto poolpow2AlignedAlloc = [](umf_memory_pool_handle_t pool) { + pow2AlignedAllocHelper(pool); + }; + + std::vector threads; + for (int i = 0; i < NTHREADS; i++) { + threads.emplace_back(poolpow2AlignedAlloc, pool.get()); + } + + for (auto &thread : threads) { + thread.join(); + } +} + +TEST_P(umfPoolTest, multiThreadedReallocFree) { + if (!umf_test::isReallocSupported(pool.get())) { + GTEST_SKIP(); + } + static constexpr size_t allocSize = 64; + static constexpr size_t multiplier = 3; + auto poolRealloc = [](size_t allocSize, size_t multiplier, + umf_memory_pool_handle_t pool) { + std::vector allocations; + for (size_t i = 0; i <= 10; ++i) { + allocations.emplace_back(umfPoolMalloc(pool, allocSize)); + ASSERT_NE(allocations.back(), nullptr); + } + + for (auto allocation : allocations) { + auto *ptr = + umfPoolRealloc(pool, allocation, allocSize * multiplier); + umfPoolFree(pool, ptr); + } + }; + + std::vector threads; + for (int i = 0; i < NTHREADS; i++) { + threads.emplace_back(poolRealloc, allocSize, multiplier, pool.get()); + } + + for (auto &thread : threads) { + thread.join(); + } +} + +TEST_P(umfPoolTest, multiThreadedCallocFree) { + if (!umf_test::isCallocSupported(pool.get())) { + GTEST_SKIP(); + } + static constexpr size_t num = 10; + auto poolCalloc = [](size_t num, size_t size, + umf_memory_pool_handle_t pool) { + std::vector allocations; + for (size_t i = 0; i <= 10; ++i) { + allocations.emplace_back(umfPoolCalloc(pool, num, size)); + ASSERT_NE(allocations.back(), nullptr); + } + + for (auto allocation : allocations) { + umfPoolFree(pool, allocation); + } + }; + + std::vector threads; + for (int i = 0; i < NTHREADS; i++) { + threads.emplace_back(poolCalloc, num, sizeof(int), pool.get()); + } + + for (auto &thread : threads) { + thread.join(); + } +} + +TEST_P(umfPoolTest, multiThreadedMallocFreeRandomSizes) { + auto poolMalloc = [](size_t allocSize, umf_memory_pool_handle_t pool) { + std::vector allocations; + for (size_t i = 0; i <= 10; ++i) { + allocations.emplace_back(umfPoolMalloc(pool, allocSize)); + ASSERT_NE(allocations.back(), nullptr); + } + + for (auto allocation : allocations) { + umfPoolFree(pool, allocation); + } + }; + + std::vector threads; + for (int i = 0; i < NTHREADS; i++) { + threads.emplace_back(poolMalloc, (rand() % 16) * 8, pool.get()); + } + + for (auto &thread : threads) { + thread.join(); + } +} + +#ifdef UMF_ENABLE_POOL_TRACKING_TESTS +// TODO: add similar tests for realloc/aligned_alloc, etc. +// TODO: add multithreaded tests +TEST_P(umfMultiPoolTest, memoryTracking) { + static constexpr int allocSizes[] = {8, 16, 32, 40, 64, 128, 1024, 4096}; + static constexpr auto nAllocs = 256; + + std::mt19937_64 g(0); + std::uniform_int_distribution allocSizesDist( + 0, static_cast(std::size(allocSizes) - 1)); + std::uniform_int_distribution poolsDist(0, + static_cast(pools.size() - 1)); + + std::vector> ptrs; + for (size_t i = 0; i < nAllocs; i++) { + auto &pool = pools[poolsDist(g)]; + auto size = allocSizes[allocSizesDist(g)]; + + auto *ptr = umfPoolMalloc(pool.get(), size); + ASSERT_NE(ptr, nullptr); + + ptrs.emplace_back(ptr, size, pool.get()); + } + + for (auto [ptr, size, expectedPool] : ptrs) { + auto pool = umfPoolByPtr(ptr); + ASSERT_EQ(pool, expectedPool); + + pool = umfPoolByPtr(reinterpret_cast( + reinterpret_cast(ptr) + size - 1)); + ASSERT_EQ(pool, expectedPool); + } + + for (auto &p : ptrs) { + umfFree(std::get<0>(p)); + } +} +#endif /* UMF_ENABLE_POOL_TRACKING_TESTS */ + +#endif /* UMF_TEST_MEMORY_POOL_OPS_HPP */ diff --git a/test/unified_malloc_framework/memoryPoolAPI.cpp b/test/unified_malloc_framework/memoryPoolAPI.cpp new file mode 100644 index 0000000000..d40254fbf0 --- /dev/null +++ b/test/unified_malloc_framework/memoryPoolAPI.cpp @@ -0,0 +1,300 @@ +// Copyright (C) 2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// This file contains tests for UMF pool API + +#include "pool.h" +#include "pool.hpp" +#include "provider.h" +#include "provider.hpp" + +#include "memoryPool.hpp" +#include "umf/memory_provider.h" + +#include +#include +#include +#include + +using umf_test::test; + +TEST_F(test, memoryPoolTrace) { + static std::unordered_map poolCalls; + static std::unordered_map providerCalls; + auto tracePool = [](const char *name) { poolCalls[name]++; }; + auto traceProvider = [](const char *name) { providerCalls[name]++; }; + + auto nullProvider = umf_test::wrapProviderUnique(nullProviderCreate()); + auto tracingProvider = umf_test::wrapProviderUnique( + traceProviderCreate(nullProvider.get(), traceProvider)); + auto provider = tracingProvider.get(); + + auto [ret, proxyPool] = + umf::poolMakeUnique(&provider, 1); + ASSERT_EQ(ret, UMF_RESULT_SUCCESS); + + umf_memory_provider_handle_t providerDesc = nullProviderCreate(); + auto tracingPool = umf_test::wrapPoolUnique( + tracePoolCreate(proxyPool.get(), providerDesc, tracePool)); + + size_t pool_call_count = 0; + size_t provider_call_count = 0; + + umfPoolMalloc(tracingPool.get(), 0); + ASSERT_EQ(poolCalls["malloc"], 1); + ASSERT_EQ(poolCalls.size(), ++pool_call_count); + + ASSERT_EQ(providerCalls["alloc"], 1); + ASSERT_EQ(providerCalls.size(), ++provider_call_count); + + umfPoolFree(tracingPool.get(), nullptr); + ASSERT_EQ(poolCalls["free"], 1); + ASSERT_EQ(poolCalls.size(), ++pool_call_count); + + ASSERT_EQ(providerCalls["free"], 1); + ASSERT_EQ(providerCalls.size(), ++provider_call_count); + + umfPoolCalloc(tracingPool.get(), 0, 0); + ASSERT_EQ(poolCalls["calloc"], 1); + ASSERT_EQ(poolCalls.size(), ++pool_call_count); + + ASSERT_EQ(providerCalls["alloc"], 2); + ASSERT_EQ(providerCalls.size(), provider_call_count); + + umfPoolRealloc(tracingPool.get(), nullptr, 0); + ASSERT_EQ(poolCalls["realloc"], 1); + ASSERT_EQ(poolCalls.size(), ++pool_call_count); + + ASSERT_EQ(providerCalls.size(), provider_call_count); + + umfPoolAlignedMalloc(tracingPool.get(), 0, 0); + ASSERT_EQ(poolCalls["aligned_malloc"], 1); + ASSERT_EQ(poolCalls.size(), ++pool_call_count); + + ASSERT_EQ(providerCalls["alloc"], 3); + ASSERT_EQ(providerCalls.size(), provider_call_count); + + umfPoolMallocUsableSize(tracingPool.get(), nullptr); + ASSERT_EQ(poolCalls["malloc_usable_size"], 1); + ASSERT_EQ(poolCalls.size(), ++pool_call_count); + + ASSERT_EQ(providerCalls.size(), provider_call_count); + + ret = umfPoolGetLastAllocationError(tracingPool.get()); + ASSERT_EQ(ret, UMF_RESULT_ERROR_NOT_SUPPORTED); + ASSERT_EQ(poolCalls["get_last_native_error"], 1); + ASSERT_EQ(poolCalls.size(), ++pool_call_count); + + umfMemoryProviderDestroy(providerDesc); +} + +TEST_F(test, memoryPoolWithCustomProviders) { + umf_memory_provider_handle_t providers[] = {nullProviderCreate(), + nullProviderCreate()}; + + struct pool : public umf_test::pool_base { + umf_result_t initialize(umf_memory_provider_handle_t *providers, + size_t numProviders) noexcept { + EXPECT_NE_NOEXCEPT(providers, nullptr); + EXPECT_EQ_NOEXCEPT(numProviders, 2); + return UMF_RESULT_SUCCESS; + } + }; + + auto ret = umf::poolMakeUnique(providers, 2); + ASSERT_EQ(ret.first, UMF_RESULT_SUCCESS); + ASSERT_NE(ret.second, nullptr); + + for (auto &provider : providers) { + umfMemoryProviderDestroy(provider); + } +} + +TEST_F(test, retrieveMemoryProviders) { + static constexpr size_t numProviders = 4; + std::array providers = { + (umf_memory_provider_handle_t)0x1, (umf_memory_provider_handle_t)0x2, + (umf_memory_provider_handle_t)0x3, (umf_memory_provider_handle_t)0x4}; + + auto [ret, pool] = umf::poolMakeUnique( + providers.data(), numProviders); + + std::array retProviders; + size_t numProvidersRet = 0; + + ret = umfPoolGetMemoryProviders(pool.get(), 0, nullptr, &numProvidersRet); + ASSERT_EQ(ret, UMF_RESULT_SUCCESS); + ASSERT_EQ(numProvidersRet, numProviders); + + ret = umfPoolGetMemoryProviders(pool.get(), numProviders, + retProviders.data(), nullptr); + ASSERT_EQ(ret, UMF_RESULT_SUCCESS); + ASSERT_EQ(retProviders, providers); +} + +INSTANTIATE_TEST_SUITE_P( + mallocPoolTest, umfPoolTest, ::testing::Values([] { + return umf::poolMakeUnique( + {umf_test::wrapProviderUnique(nullProviderCreate())}) + .second; + })); + +INSTANTIATE_TEST_SUITE_P( + mallocProviderPoolTest, umfPoolTest, ::testing::Values([] { + return umf::poolMakeUnique( + {umf::memoryProviderMakeUnique() + .second}) + .second; + })); + +GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(umfMultiPoolTest); +INSTANTIATE_TEST_SUITE_P( + mallocMultiPoolTest, umfMultiPoolTest, ::testing::Values([] { + return umf::poolMakeUnique( + {umf::memoryProviderMakeUnique() + .second}) + .second; + })); + +////////////////// Negative test cases ///////////////// + +TEST_F(test, memoryPoolInvalidProvidersNullptr) { + auto ret = umf::poolMakeUnique(nullptr, 1); + ASSERT_EQ(ret.first, UMF_RESULT_ERROR_INVALID_ARGUMENT); +} + +TEST_F(test, memoryPoolInvalidProvidersNum) { + auto nullProvider = umf_test::wrapProviderUnique(nullProviderCreate()); + umf_memory_provider_handle_t providers[] = {nullProvider.get()}; + + auto ret = umf::poolMakeUnique(providers, 0); + ASSERT_EQ(ret.first, UMF_RESULT_ERROR_INVALID_ARGUMENT); +} + +struct poolInitializeTest : umf_test::test, + ::testing::WithParamInterface {}; + +INSTANTIATE_TEST_SUITE_P( + poolInitializeTest, poolInitializeTest, + ::testing::Values(UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY, + UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC, + UMF_RESULT_ERROR_INVALID_ARGUMENT, + UMF_RESULT_ERROR_UNKNOWN)); + +TEST_P(poolInitializeTest, errorPropagation) { + auto nullProvider = umf_test::wrapProviderUnique(nullProviderCreate()); + umf_memory_provider_handle_t providers[] = {nullProvider.get()}; + + struct pool : public umf_test::pool_base { + umf_result_t initialize(umf_memory_provider_handle_t *providers, + size_t numProviders, + umf_result_t errorToReturn) noexcept { + return errorToReturn; + } + }; + auto ret = umf::poolMakeUnique(providers, 1, this->GetParam()); + ASSERT_EQ(ret.first, this->GetParam()); + ASSERT_EQ(ret.second, nullptr); +} + +TEST_F(test, retrieveMemoryProvidersError) { + static constexpr size_t numProviders = 4; + std::array providers = { + (umf_memory_provider_handle_t)0x1, (umf_memory_provider_handle_t)0x2, + (umf_memory_provider_handle_t)0x3, (umf_memory_provider_handle_t)0x4}; + + auto [ret, pool] = umf::poolMakeUnique( + providers.data(), numProviders); + + ret = umfPoolGetMemoryProviders(pool.get(), 1, providers.data(), nullptr); + ASSERT_EQ(ret, UMF_RESULT_ERROR_INVALID_ARGUMENT); +} + +// TODO: extend test for different functions (not only alloc) +TEST_F(test, getLastFailedMemoryProvider) { + static constexpr size_t allocSize = 8; + static umf_result_t allocResult = UMF_RESULT_SUCCESS; + + struct memory_provider : public umf_test::provider_base { + umf_result_t initialize(const char *name) { + this->name = name; + return UMF_RESULT_SUCCESS; + } + + enum umf_result_t alloc(size_t size, size_t, void **ptr) noexcept { + if (allocResult == UMF_RESULT_SUCCESS) { + *ptr = malloc(size); + } else { + *ptr = nullptr; + } + + return allocResult; + } + + enum umf_result_t free(void *ptr, size_t size) noexcept { + ::free(ptr); + return UMF_RESULT_SUCCESS; + } + + const char *get_name() noexcept { return this->name; } + + const char *name; + }; + + auto [ret1, providerUnique1] = + umf::memoryProviderMakeUnique("provider1"); + ASSERT_EQ(ret1, UMF_RESULT_SUCCESS); + auto [ret2, providerUnique2] = + umf::memoryProviderMakeUnique("provider2"); + ASSERT_EQ(ret2, UMF_RESULT_SUCCESS); + + auto hProvider = providerUnique1.get(); + + auto [ret, pool] = umf::poolMakeUnique(&hProvider, 1); + ASSERT_EQ(ret, UMF_RESULT_SUCCESS); + + ASSERT_EQ(umfGetLastFailedMemoryProvider(), nullptr); + auto ptr = umfPoolMalloc(pool.get(), allocSize); + ASSERT_NE(ptr, nullptr); + ASSERT_EQ(umfGetLastFailedMemoryProvider(), nullptr); + umfPoolFree(pool.get(), ptr); + + // make provider return an error during allocation + allocResult = UMF_RESULT_ERROR_UNKNOWN; + ptr = umfPoolMalloc(pool.get(), allocSize); + ASSERT_EQ(ptr, nullptr); + ASSERT_EQ(std::string_view( + umfMemoryProviderGetName(umfGetLastFailedMemoryProvider())), + "provider1"); + + ret = umfMemoryProviderAlloc(providerUnique2.get(), allocSize, 0, &ptr); + ASSERT_EQ(ptr, nullptr); + ASSERT_EQ(std::string_view( + umfMemoryProviderGetName(umfGetLastFailedMemoryProvider())), + "provider2"); + + // successful provider should not be returned by umfGetLastFailedMemoryProvider + allocResult = UMF_RESULT_SUCCESS; + ptr = umfPoolMalloc(pool.get(), allocSize); + ASSERT_NE(ptr, nullptr); + ASSERT_EQ(std::string_view( + umfMemoryProviderGetName(umfGetLastFailedMemoryProvider())), + "provider2"); + umfPoolFree(pool.get(), ptr); + + // error in another thread should not impact umfGetLastFailedMemoryProvider on this thread + allocResult = UMF_RESULT_ERROR_UNKNOWN; + std::thread t([&, hPool = pool.get()] { + ptr = umfPoolMalloc(hPool, allocSize); + ASSERT_EQ(ptr, nullptr); + ASSERT_EQ(std::string_view(umfMemoryProviderGetName( + umfGetLastFailedMemoryProvider())), + "provider1"); + }); + t.join(); + + ASSERT_EQ(std::string_view( + umfMemoryProviderGetName(umfGetLastFailedMemoryProvider())), + "provider2"); +} diff --git a/test/unified_memory_allocation/memoryProvider.hpp b/test/unified_malloc_framework/memoryProvider.hpp similarity index 60% rename from test/unified_memory_allocation/memoryProvider.hpp rename to test/unified_malloc_framework/memoryProvider.hpp index c7b5cc9f35..fe61ca39ae 100644 --- a/test/unified_memory_allocation/memoryProvider.hpp +++ b/test/unified_malloc_framework/memoryProvider.hpp @@ -8,23 +8,23 @@ #include #include -#ifndef UMA_TEST_MEMORY_PROVIDER_OPS_HPP -#define UMA_TEST_MEMORY_PROVIDER_OPS_HPP +#ifndef UMF_TEST_MEMORY_PROVIDER_OPS_HPP +#define UMF_TEST_MEMORY_PROVIDER_OPS_HPP -struct umaProviderTest - : uma_test::test, +struct umfProviderTest + : umf_test::test, ::testing::WithParamInterface()>> { - umaProviderTest() : provider(nullptr, nullptr) {} + std::pair()>> { + umfProviderTest() : provider(nullptr, nullptr) {} void SetUp() { test::SetUp(); auto [res, provider] = this->GetParam()(); - EXPECT_EQ(res, UMA_RESULT_SUCCESS); + EXPECT_EQ(res, UMF_RESULT_SUCCESS); EXPECT_NE(provider, nullptr); this->provider = std::move(provider); } void TearDown() override { test::TearDown(); } - uma::provider_unique_handle_t provider; + umf::provider_unique_handle_t provider; }; -#endif /* UMA_TEST_MEMORY_PROVIDER_OPS_HPP */ +#endif /* UMF_TEST_MEMORY_PROVIDER_OPS_HPP */ diff --git a/test/unified_memory_allocation/memoryProviderAPI.cpp b/test/unified_malloc_framework/memoryProviderAPI.cpp similarity index 53% rename from test/unified_memory_allocation/memoryProviderAPI.cpp rename to test/unified_malloc_framework/memoryProviderAPI.cpp index f770050f32..fa02f9eb99 100644 --- a/test/unified_memory_allocation/memoryProviderAPI.cpp +++ b/test/unified_malloc_framework/memoryProviderAPI.cpp @@ -2,7 +2,7 @@ // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// This file contains tests for UMA provider API +// This file contains tests for UMF provider API #include "pool.h" #include "provider.h" @@ -11,57 +11,56 @@ #include #include -using uma_test::test; +using umf_test::test; TEST_F(test, memoryProviderTrace) { static std::unordered_map calls; auto trace = [](const char *name) { calls[name]++; }; - auto nullProvider = uma_test::wrapProviderUnique(nullProviderCreate()); - auto tracingProvider = uma_test::wrapProviderUnique( + auto nullProvider = umf_test::wrapProviderUnique(nullProviderCreate()); + auto tracingProvider = umf_test::wrapProviderUnique( traceProviderCreate(nullProvider.get(), trace)); size_t call_count = 0; - auto ret = umaMemoryProviderAlloc(tracingProvider.get(), 0, 0, nullptr); - ASSERT_EQ(ret, UMA_RESULT_SUCCESS); + auto ret = umfMemoryProviderAlloc(tracingProvider.get(), 0, 0, nullptr); + ASSERT_EQ(ret, UMF_RESULT_SUCCESS); ASSERT_EQ(calls["alloc"], 1); ASSERT_EQ(calls.size(), ++call_count); - ret = umaMemoryProviderFree(tracingProvider.get(), nullptr, 0); - ASSERT_EQ(ret, UMA_RESULT_SUCCESS); + ret = umfMemoryProviderFree(tracingProvider.get(), nullptr, 0); + ASSERT_EQ(ret, UMF_RESULT_SUCCESS); ASSERT_EQ(calls["free"], 1); ASSERT_EQ(calls.size(), ++call_count); - ret = umaMemoryProviderGetLastResult(tracingProvider.get(), nullptr); - ASSERT_EQ(ret, UMA_RESULT_SUCCESS); - ASSERT_EQ(calls["get_last_result"], 1); + umfMemoryProviderGetLastNativeError(tracingProvider.get(), nullptr, + nullptr); + ASSERT_EQ(calls["get_last_native_error"], 1); ASSERT_EQ(calls.size(), ++call_count); - ret = umaMemoryProviderGetRecommendedPageSize(tracingProvider.get(), 0, + ret = umfMemoryProviderGetRecommendedPageSize(tracingProvider.get(), 0, nullptr); - ASSERT_EQ(ret, UMA_RESULT_SUCCESS); + ASSERT_EQ(ret, UMF_RESULT_SUCCESS); ASSERT_EQ(calls["get_recommended_page_size"], 1); ASSERT_EQ(calls.size(), ++call_count); - ret = umaMemoryProviderGetMinPageSize(tracingProvider.get(), nullptr, + ret = umfMemoryProviderGetMinPageSize(tracingProvider.get(), nullptr, nullptr); - ASSERT_EQ(ret, UMA_RESULT_SUCCESS); + ASSERT_EQ(ret, UMF_RESULT_SUCCESS); ASSERT_EQ(calls["get_min_page_size"], 1); ASSERT_EQ(calls.size(), ++call_count); - ret = umaMemoryProviderPurgeLazy(tracingProvider.get(), nullptr, 0); - ASSERT_EQ(ret, UMA_RESULT_SUCCESS); + ret = umfMemoryProviderPurgeLazy(tracingProvider.get(), nullptr, 0); + ASSERT_EQ(ret, UMF_RESULT_SUCCESS); ASSERT_EQ(calls["purge_lazy"], 1); ASSERT_EQ(calls.size(), ++call_count); - ret = umaMemoryProviderPurgeForce(tracingProvider.get(), nullptr, 0); - ASSERT_EQ(ret, UMA_RESULT_SUCCESS); + ret = umfMemoryProviderPurgeForce(tracingProvider.get(), nullptr, 0); + ASSERT_EQ(ret, UMF_RESULT_SUCCESS); ASSERT_EQ(calls["purge_force"], 1); ASSERT_EQ(calls.size(), ++call_count); - const char *pName; - umaMemoryProviderGetName(tracingProvider.get(), &pName); + const char *pName = umfMemoryProviderGetName(tracingProvider.get()); ASSERT_EQ(calls["name"], 1); ASSERT_EQ(calls.size(), ++call_count); ASSERT_EQ(std::string(pName), std::string("null")); @@ -70,24 +69,23 @@ TEST_F(test, memoryProviderTrace) { //////////////////////////// Negative test cases /////////////////////////////////// -struct providerInitializeTest : uma_test::test, - ::testing::WithParamInterface {}; +struct providerInitializeTest : umf_test::test, + ::testing::WithParamInterface {}; INSTANTIATE_TEST_SUITE_P( providerInitializeTest, providerInitializeTest, - ::testing::Values(UMA_RESULT_ERROR_OUT_OF_HOST_MEMORY, - UMA_RESULT_ERROR_POOL_SPECIFIC, - UMA_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC, - UMA_RESULT_ERROR_INVALID_ARGUMENT, - UMA_RESULT_ERROR_UNKNOWN)); + ::testing::Values(UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY, + UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC, + UMF_RESULT_ERROR_INVALID_ARGUMENT, + UMF_RESULT_ERROR_UNKNOWN)); TEST_P(providerInitializeTest, errorPropagation) { - struct provider : public uma_test::provider_base { - uma_result_t initialize(uma_result_t errorToReturn) noexcept { + struct provider : public umf_test::provider_base { + umf_result_t initialize(umf_result_t errorToReturn) noexcept { return errorToReturn; } }; - auto ret = uma::memoryProviderMakeUnique(this->GetParam()); + auto ret = umf::memoryProviderMakeUnique(this->GetParam()); ASSERT_EQ(ret.first, this->GetParam()); ASSERT_EQ(ret.second, nullptr); } diff --git a/test/unified_memory_allocation/uma_pools/CMakeLists.txt b/test/unified_malloc_framework/umf_pools/CMakeLists.txt similarity index 52% rename from test/unified_memory_allocation/uma_pools/CMakeLists.txt rename to test/unified_malloc_framework/umf_pools/CMakeLists.txt index c38921d146..578059ed16 100644 --- a/test/unified_memory_allocation/uma_pools/CMakeLists.txt +++ b/test/unified_malloc_framework/umf_pools/CMakeLists.txt @@ -3,8 +3,8 @@ # See LICENSE.TXT # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -add_uma_test(disjointPool disjoint_pool.cpp) -add_uma_test(disjointPoolConfigParser disjoint_pool_config_parser.cpp) +add_umf_test(disjointPool disjoint_pool.cpp) +add_umf_test(disjointPoolConfigParser disjoint_pool_config_parser.cpp) -target_include_directories(uma_test-disjointPool PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..) -target_link_libraries(uma_test-disjointPool PRIVATE ${PROJECT_NAME}::common) +target_include_directories(umf_test-disjointPool PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..) +target_link_libraries(umf_test-disjointPool PRIVATE ${PROJECT_NAME}::common) diff --git a/test/unified_malloc_framework/umf_pools/disjoint_pool.cpp b/test/unified_malloc_framework/umf_pools/disjoint_pool.cpp new file mode 100644 index 0000000000..9e4d4f7ee6 --- /dev/null +++ b/test/unified_malloc_framework/umf_pools/disjoint_pool.cpp @@ -0,0 +1,77 @@ +/* + * + * Copyright (C) 2023 Intel Corporation + * + * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. + * See LICENSE.TXT + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + */ + +#include "disjoint_pool.hpp" + +#include "memoryPool.hpp" +#include "provider.h" +#include "provider.hpp" + +static usm::DisjointPool::Config poolConfig() { + usm::DisjointPool::Config config{}; + config.SlabMinSize = 4096; + config.MaxPoolableSize = 4096; + config.Capacity = 4; + config.MinBucketSize = 64; + return config; +} + +static auto makePool() { + auto [ret, provider] = + umf::memoryProviderMakeUnique(); + EXPECT_EQ(ret, UMF_RESULT_SUCCESS); + auto [retp, pool] = umf::poolMakeUnique( + {std::move(provider)}, poolConfig()); + EXPECT_EQ(retp, UMF_RESULT_SUCCESS); + return std::move(pool); +} + +using umf_test::test; + +TEST_F(test, freeErrorPropagation) { + static enum umf_result_t freeReturn = UMF_RESULT_SUCCESS; + struct memory_provider : public umf_test::provider_base { + enum umf_result_t alloc(size_t size, size_t, void **ptr) noexcept { + *ptr = malloc(size); + return UMF_RESULT_SUCCESS; + } + enum umf_result_t free(void *ptr, size_t size) noexcept { + ::free(ptr); + return freeReturn; + } + }; + + auto [ret, providerUnique] = + umf::memoryProviderMakeUnique(); + ASSERT_EQ(ret, UMF_RESULT_SUCCESS); + + auto config = poolConfig(); + config.MaxPoolableSize = + 0; // force all allocations to go to memory provider + + auto [retp, pool] = umf::poolMakeUnique( + {std::move(providerUnique)}, config); + EXPECT_EQ(retp, UMF_RESULT_SUCCESS); + + static constexpr size_t size = 1024; + void *ptr = umfPoolMalloc(pool.get(), size); + + freeReturn = UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC; + auto freeRet = umfPoolFree(pool.get(), ptr); + + EXPECT_EQ(freeRet, freeReturn); +} + +INSTANTIATE_TEST_SUITE_P(disjointPoolTests, umfPoolTest, + ::testing::Values(makePool)); + +GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(umfMultiPoolTest); +INSTANTIATE_TEST_SUITE_P(disjointMultiPoolTests, umfMultiPoolTest, + ::testing::Values(makePool)); diff --git a/test/unified_memory_allocation/uma_pools/disjoint_pool_config_parser.cpp b/test/unified_malloc_framework/umf_pools/disjoint_pool_config_parser.cpp similarity index 100% rename from test/unified_memory_allocation/uma_pools/disjoint_pool_config_parser.cpp rename to test/unified_malloc_framework/umf_pools/disjoint_pool_config_parser.cpp diff --git a/test/unified_memory_allocation/CMakeLists.txt b/test/unified_memory_allocation/CMakeLists.txt deleted file mode 100644 index 7cb5c1c8fc..0000000000 --- a/test/unified_memory_allocation/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright (C) 2022-2023 Intel Corporation -# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. -# See LICENSE.TXT -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -set(UR_UMA_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) - -add_library(uma_test_helpers STATIC - ${UR_UMA_TEST_DIR}/common/pool.c - ${UR_UMA_TEST_DIR}/common/provider.c -) - -target_link_libraries(uma_test_helpers PRIVATE ${PROJECT_NAME}::common) - -function(add_uma_test name) - set(TEST_TARGET_NAME uma_test-${name}) - add_executable(${TEST_TARGET_NAME} - ${ARGN}) - target_link_libraries(${TEST_TARGET_NAME} - PRIVATE - ${PROJECT_NAME}::unified_memory_allocation - ${PROJECT_NAME}::common - uma_test_helpers - GTest::gtest_main) - target_include_directories(${TEST_TARGET_NAME} PRIVATE - ${UR_UMA_TEST_DIR}/common) - add_test(NAME uma-${name} - COMMAND ${TEST_TARGET_NAME} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - set_tests_properties(uma-${name} PROPERTIES LABELS "uma") -endfunction() - -add_subdirectory(uma_pools) - -add_uma_test(memoryProvider memoryProviderAPI.cpp) -add_uma_test(memoryPool memoryPoolAPI.cpp) -add_uma_test(base base.cpp) diff --git a/test/unified_memory_allocation/common/pool.hpp b/test/unified_memory_allocation/common/pool.hpp deleted file mode 100644 index f360af34dd..0000000000 --- a/test/unified_memory_allocation/common/pool.hpp +++ /dev/null @@ -1,113 +0,0 @@ -/* - * - * Copyright (C) 2023 Intel Corporation - * - * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. - * See LICENSE.TXT - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - * - */ - -#ifndef UMA_TEST_POOL_HPP -#define UMA_TEST_POOL_HPP 1 - -#include -#include -#include - -#include -#include - -#include "base.hpp" -#include "uma_helpers.hpp" - -namespace uma_test { - -auto wrapPoolUnique(uma_memory_pool_handle_t hPool) { - return uma::pool_unique_handle_t(hPool, &umaPoolDestroy); -} - -struct pool_base { - uma_result_t initialize(uma_memory_provider_handle_t *, size_t) noexcept { - return UMA_RESULT_SUCCESS; - }; - void *malloc(size_t size) noexcept { return nullptr; } - void *calloc(size_t, size_t) noexcept { return nullptr; } - void *realloc(void *, size_t) noexcept { return nullptr; } - void *aligned_malloc(size_t, size_t) noexcept { return nullptr; } - size_t malloc_usable_size(void *) noexcept { return 0; } - void free(void *) noexcept {} - enum uma_result_t get_last_result(const char **ppMessage) noexcept { - return UMA_RESULT_ERROR_UNKNOWN; - } -}; - -struct malloc_pool : public pool_base { - void *malloc(size_t size) noexcept { return ::malloc(size); } - void *calloc(size_t num, size_t size) noexcept { - return ::calloc(num, size); - } - void *realloc(void *ptr, size_t size) noexcept { - return ::realloc(ptr, size); - } - void *aligned_malloc(size_t size, size_t alignment) noexcept { -#ifdef _WIN32 - // we could use _aligned_malloc but it requires using _aligned_free... - return nullptr; -#else - return ::aligned_alloc(alignment, size); -#endif - } - size_t malloc_usable_size(void *ptr) noexcept { -#ifdef _WIN32 - return _msize(ptr); -#else - return ::malloc_usable_size(ptr); -#endif - } - void free(void *ptr) noexcept { return ::free(ptr); } -}; - -struct proxy_pool : public pool_base { - uma_result_t initialize(uma_memory_provider_handle_t *providers, - size_t numProviders) noexcept { - this->provider = providers[0]; - return UMA_RESULT_SUCCESS; - } - void *malloc(size_t size) noexcept { return aligned_malloc(size, 0); } - void *calloc(size_t num, size_t size) noexcept { - void *ptr; - auto ret = umaMemoryProviderAlloc(provider, num * size, 0, &ptr); - - memset(ptr, 0, num * size); - - EXPECT_EQ_NOEXCEPT(ret, UMA_RESULT_SUCCESS); - return ptr; - } - void *realloc(void *ptr, size_t size) noexcept { - // TODO: not supported - return nullptr; - } - void *aligned_malloc(size_t size, size_t alignment) noexcept { - void *ptr; - auto ret = umaMemoryProviderAlloc(provider, size, alignment, &ptr); - EXPECT_EQ_NOEXCEPT(ret, UMA_RESULT_SUCCESS); - return ptr; - } - size_t malloc_usable_size(void *ptr) noexcept { - // TODO: not supported - return 0; - } - void free(void *ptr) noexcept { - auto ret = umaMemoryProviderFree(provider, ptr, 0); - EXPECT_EQ_NOEXCEPT(ret, UMA_RESULT_SUCCESS); - } - enum uma_result_t get_last_result(const char **ppMessage) noexcept { - return umaMemoryProviderGetLastResult(provider, ppMessage); - } - uma_memory_provider_handle_t provider; -}; - -} // namespace uma_test - -#endif /* UMA_TEST_POOL_HPP */ diff --git a/test/unified_memory_allocation/common/provider.hpp b/test/unified_memory_allocation/common/provider.hpp deleted file mode 100644 index c60ebf0c3d..0000000000 --- a/test/unified_memory_allocation/common/provider.hpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * - * Copyright (C) 2023 Intel Corporation - * - * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. - * See LICENSE.TXT - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - * - */ - -#ifndef UMA_TEST_PROVIDER_HPP -#define UMA_TEST_PROVIDER_HPP 1 - -#include -#include - -#include - -#include "base.hpp" -#include "uma_helpers.hpp" - -namespace uma_test { - -auto wrapProviderUnique(uma_memory_provider_handle_t hProvider) { - return uma::provider_unique_handle_t(hProvider, &umaMemoryProviderDestroy); -} - -struct provider_base { - uma_result_t initialize() noexcept { return UMA_RESULT_SUCCESS; }; - enum uma_result_t alloc(size_t, size_t, void **) noexcept { - return UMA_RESULT_ERROR_UNKNOWN; - } - enum uma_result_t free(void *ptr, size_t size) noexcept { - return UMA_RESULT_ERROR_UNKNOWN; - } - enum uma_result_t get_last_result(const char **) noexcept { - return UMA_RESULT_ERROR_UNKNOWN; - } - enum uma_result_t get_recommended_page_size(size_t size, - size_t *pageSize) noexcept { - return UMA_RESULT_ERROR_UNKNOWN; - } - enum uma_result_t get_min_page_size(void *ptr, size_t *pageSize) noexcept { - return UMA_RESULT_ERROR_UNKNOWN; - } - enum uma_result_t purge_lazy(void *ptr, size_t size) noexcept { - return UMA_RESULT_ERROR_UNKNOWN; - } - enum uma_result_t purge_force(void *ptr, size_t size) noexcept { - return UMA_RESULT_ERROR_UNKNOWN; - } - void get_name(const char **ppName) noexcept { *ppName = "base"; } -}; - -struct provider_malloc : public provider_base { - enum uma_result_t alloc(size_t size, size_t align, void **ptr) noexcept { - if (!align) { - align = 8; - } - -#ifdef _WIN32 - *ptr = _aligned_malloc(size, align); -#else - *ptr = ::aligned_alloc(align, size); -#endif - - return (*ptr) ? UMA_RESULT_SUCCESS - : UMA_RESULT_ERROR_OUT_OF_HOST_MEMORY; - } - enum uma_result_t free(void *ptr, size_t) noexcept { -#ifdef _WIN32 - _aligned_free(ptr); -#else - ::free(ptr); -#endif - return UMA_RESULT_SUCCESS; - } - void get_name(const char **ppName) noexcept { *ppName = "malloc"; } -}; - -} // namespace uma_test - -#endif /* UMA_TEST_PROVIDER_HPP */ diff --git a/test/unified_memory_allocation/memoryPool.hpp b/test/unified_memory_allocation/memoryPool.hpp deleted file mode 100644 index c242419ba1..0000000000 --- a/test/unified_memory_allocation/memoryPool.hpp +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright (C) 2023 Intel Corporation -// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. -// See LICENSE.TXT -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -#include "pool.hpp" - -#include -#include -#include - -#ifndef UMA_TEST_MEMORY_POOL_OPS_HPP -#define UMA_TEST_MEMORY_POOL_OPS_HPP - -struct umaPoolTest : uma_test::test, - ::testing::WithParamInterface< - std::function> { - umaPoolTest() : pool(nullptr, nullptr) {} - void SetUp() override { - test::SetUp(); - this->pool = makePool(); - } - - void TearDown() override { test::TearDown(); } - - uma::pool_unique_handle_t makePool() { - auto pool = this->GetParam()(); - EXPECT_NE(pool, nullptr); - return pool; - } - - uma::pool_unique_handle_t pool; -}; - -struct umaMultiPoolTest : umaPoolTest { - static constexpr auto numPools = 16; - - void SetUp() override { - umaPoolTest::SetUp(); - - pools.emplace_back(std::move(pool)); - for (size_t i = 1; i < numPools; i++) { - pools.emplace_back(makePool()); - } - } - - void TearDown() override { umaPoolTest::TearDown(); } - - std::vector pools; -}; - -TEST_P(umaPoolTest, allocFree) { - static constexpr size_t allocSize = 64; - auto *ptr = umaPoolMalloc(pool.get(), allocSize); - ASSERT_NE(ptr, nullptr); - std::memset(ptr, 0, allocSize); - umaPoolFree(pool.get(), ptr); -} - -TEST_P(umaPoolTest, pow2AlignedAlloc) { -#ifdef _WIN32 - // TODO: implement support for windows - GTEST_SKIP(); -#endif - - static constexpr size_t maxAlignment = (1u << 22); - static constexpr size_t numAllocs = 4; - - for (size_t alignment = 1; alignment <= maxAlignment; alignment <<= 1) { - std::cout << alignment << std::endl; - std::vector allocs; - - for (size_t alloc = 0; alloc < numAllocs; alloc++) { - auto *ptr = umaPoolAlignedMalloc(pool.get(), alignment, alignment); - ASSERT_NE(ptr, nullptr); - ASSERT_TRUE(reinterpret_cast(ptr) % alignment == 0); - std::memset(ptr, 0, alignment); - allocs.push_back(ptr); - } - - for (auto &ptr : allocs) { - umaPoolFree(pool.get(), ptr); - } - } -} - -// TODO: add similar tests for realloc/aligned_alloc, etc. -// TODO: add multithreaded tests -TEST_P(umaMultiPoolTest, memoryTracking) { - static constexpr int allocSizes[] = {1, 2, 4, 8, 16, 20, - 32, 40, 64, 128, 1024, 4096}; - static constexpr auto nAllocs = 256; - - std::mt19937_64 g(0); - std::uniform_int_distribution allocSizesDist( - 0, static_cast(std::size(allocSizes) - 1)); - std::uniform_int_distribution poolsDist(0, - static_cast(pools.size() - 1)); - - std::vector> ptrs; - for (size_t i = 0; i < nAllocs; i++) { - auto &pool = pools[poolsDist(g)]; - auto size = allocSizes[allocSizesDist(g)]; - - auto *ptr = umaPoolMalloc(pool.get(), size); - ASSERT_NE(ptr, nullptr); - - ptrs.emplace_back(ptr, size, pool.get()); - } - - for (auto [ptr, size, expectedPool] : ptrs) { - auto pool = umaPoolByPtr(ptr); - ASSERT_EQ(pool, expectedPool); - - pool = umaPoolByPtr(reinterpret_cast( - reinterpret_cast(ptr) + size - 1)); - ASSERT_EQ(pool, expectedPool); - } - - for (auto p : ptrs) { - umaFree(std::get<0>(p)); - } -} - -#endif /* UMA_TEST_MEMORY_POOL_OPS_HPP */ diff --git a/test/unified_memory_allocation/memoryPoolAPI.cpp b/test/unified_memory_allocation/memoryPoolAPI.cpp deleted file mode 100644 index af5aa5f077..0000000000 --- a/test/unified_memory_allocation/memoryPoolAPI.cpp +++ /dev/null @@ -1,229 +0,0 @@ -// Copyright (C) 2023 Intel Corporation -// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. -// See LICENSE.TXT -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// This file contains tests for UMA pool API - -#include "pool.h" -#include "pool.hpp" -#include "provider.h" -#include "provider.hpp" - -#include "memoryPool.hpp" -#include "uma/memory_provider.h" - -#include -#include -#include - -using uma_test::test; - -TEST_F(test, memoryPoolTrace) { - static std::unordered_map poolCalls; - static std::unordered_map providerCalls; - auto tracePool = [](const char *name) { poolCalls[name]++; }; - auto traceProvider = [](const char *name) { providerCalls[name]++; }; - - auto nullProvider = uma_test::wrapProviderUnique(nullProviderCreate()); - auto tracingProvider = uma_test::wrapProviderUnique( - traceProviderCreate(nullProvider.get(), traceProvider)); - auto provider = tracingProvider.get(); - - auto [ret, proxyPool] = - uma::poolMakeUnique(&provider, 1); - ASSERT_EQ(ret, UMA_RESULT_SUCCESS); - - uma_memory_provider_handle_t providerDesc = nullProviderCreate(); - auto tracingPool = uma_test::wrapPoolUnique( - tracePoolCreate(proxyPool.get(), providerDesc, tracePool)); - - size_t pool_call_count = 0; - size_t provider_call_count = 0; - - umaPoolMalloc(tracingPool.get(), 0); - ASSERT_EQ(poolCalls["malloc"], 1); - ASSERT_EQ(poolCalls.size(), ++pool_call_count); - - ASSERT_EQ(providerCalls["alloc"], 1); - ASSERT_EQ(providerCalls.size(), ++provider_call_count); - - umaPoolFree(tracingPool.get(), nullptr); - ASSERT_EQ(poolCalls["free"], 1); - ASSERT_EQ(poolCalls.size(), ++pool_call_count); - - ASSERT_EQ(providerCalls["free"], 1); - ASSERT_EQ(providerCalls.size(), ++provider_call_count); - - umaPoolCalloc(tracingPool.get(), 0, 0); - ASSERT_EQ(poolCalls["calloc"], 1); - ASSERT_EQ(poolCalls.size(), ++pool_call_count); - - ASSERT_EQ(providerCalls["alloc"], 2); - ASSERT_EQ(providerCalls.size(), provider_call_count); - - umaPoolRealloc(tracingPool.get(), nullptr, 0); - ASSERT_EQ(poolCalls["realloc"], 1); - ASSERT_EQ(poolCalls.size(), ++pool_call_count); - - ASSERT_EQ(providerCalls.size(), provider_call_count); - - umaPoolAlignedMalloc(tracingPool.get(), 0, 0); - ASSERT_EQ(poolCalls["aligned_malloc"], 1); - ASSERT_EQ(poolCalls.size(), ++pool_call_count); - - ASSERT_EQ(providerCalls["alloc"], 3); - ASSERT_EQ(providerCalls.size(), provider_call_count); - - umaPoolMallocUsableSize(tracingPool.get(), nullptr); - ASSERT_EQ(poolCalls["malloc_usable_size"], 1); - ASSERT_EQ(poolCalls.size(), ++pool_call_count); - - ASSERT_EQ(providerCalls.size(), provider_call_count); - - ret = umaPoolGetLastResult(tracingPool.get(), nullptr); - ASSERT_EQ(ret, UMA_RESULT_SUCCESS); - - ASSERT_EQ(poolCalls["get_last_result"], 1); - ASSERT_EQ(poolCalls.size(), ++pool_call_count); - - ASSERT_EQ(providerCalls["get_last_result"], 1); - ASSERT_EQ(providerCalls.size(), ++provider_call_count); - - umaMemoryProviderDestroy(providerDesc); -} - -TEST_F(test, memoryPoolWithCustomProviders) { - uma_memory_provider_handle_t providers[] = {nullProviderCreate(), - nullProviderCreate()}; - - struct pool : public uma_test::pool_base { - uma_result_t initialize(uma_memory_provider_handle_t *providers, - size_t numProviders) noexcept { - EXPECT_NE_NOEXCEPT(providers, nullptr); - EXPECT_EQ_NOEXCEPT(numProviders, 2); - return UMA_RESULT_SUCCESS; - } - }; - - auto ret = uma::poolMakeUnique(providers, 2); - ASSERT_EQ(ret.first, UMA_RESULT_SUCCESS); - ASSERT_NE(ret.second, nullptr); - - for (auto &provider : providers) { - umaMemoryProviderDestroy(provider); - } -} - -TEST_F(test, retrieveMemoryProviders) { - static constexpr size_t numProviders = 4; - std::array providers = { - (uma_memory_provider_handle_t)0x1, (uma_memory_provider_handle_t)0x2, - (uma_memory_provider_handle_t)0x3, (uma_memory_provider_handle_t)0x4}; - - auto [ret, pool] = uma::poolMakeUnique( - providers.data(), numProviders); - - std::array retProviders; - size_t numProvidersRet = 0; - - ret = umaPoolGetMemoryProviders(pool.get(), 0, nullptr, &numProvidersRet); - ASSERT_EQ(ret, UMA_RESULT_SUCCESS); - ASSERT_EQ(numProvidersRet, numProviders); - - ret = umaPoolGetMemoryProviders(pool.get(), numProviders, - retProviders.data(), nullptr); - ASSERT_EQ(ret, UMA_RESULT_SUCCESS); - ASSERT_EQ(retProviders, providers); -} - -template -static auto -makePool(std::function makeProvider) { - auto providerUnique = makeProvider(); - uma_memory_provider_handle_t provider = providerUnique.get(); - auto pool = uma::poolMakeUnique(&provider, 1).second; - auto dtor = [provider = - providerUnique.release()](uma_memory_pool_handle_t hPool) { - umaPoolDestroy(hPool); - umaMemoryProviderDestroy(provider); - }; - return uma::pool_unique_handle_t(pool.release(), std::move(dtor)); -} - -INSTANTIATE_TEST_SUITE_P(mallocPoolTest, umaPoolTest, ::testing::Values([] { - return makePool([] { - return uma_test::wrapProviderUnique( - nullProviderCreate()); - }); - })); - -INSTANTIATE_TEST_SUITE_P( - mallocProviderPoolTest, umaPoolTest, ::testing::Values([] { - return makePool([] { - return uma::memoryProviderMakeUnique() - .second; - }); - })); - -INSTANTIATE_TEST_SUITE_P( - mallocMultiPoolTest, umaMultiPoolTest, ::testing::Values([] { - return makePool([] { - return uma::memoryProviderMakeUnique() - .second; - }); - })); - -////////////////// Negative test cases ///////////////// - -TEST_F(test, memoryPoolInvalidProvidersNullptr) { - auto ret = uma::poolMakeUnique(nullptr, 1); - ASSERT_EQ(ret.first, UMA_RESULT_ERROR_INVALID_ARGUMENT); -} - -TEST_F(test, memoryPoolInvalidProvidersNum) { - auto nullProvider = uma_test::wrapProviderUnique(nullProviderCreate()); - uma_memory_provider_handle_t providers[] = {nullProvider.get()}; - - auto ret = uma::poolMakeUnique(providers, 0); - ASSERT_EQ(ret.first, UMA_RESULT_ERROR_INVALID_ARGUMENT); -} - -struct poolInitializeTest : uma_test::test, - ::testing::WithParamInterface {}; - -INSTANTIATE_TEST_SUITE_P( - poolInitializeTest, poolInitializeTest, - ::testing::Values(UMA_RESULT_ERROR_OUT_OF_HOST_MEMORY, - UMA_RESULT_ERROR_POOL_SPECIFIC, - UMA_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC, - UMA_RESULT_ERROR_INVALID_ARGUMENT, - UMA_RESULT_ERROR_UNKNOWN)); - -TEST_P(poolInitializeTest, errorPropagation) { - auto nullProvider = uma_test::wrapProviderUnique(nullProviderCreate()); - uma_memory_provider_handle_t providers[] = {nullProvider.get()}; - - struct pool : public uma_test::pool_base { - uma_result_t initialize(uma_memory_provider_handle_t *providers, - size_t numProviders, - uma_result_t errorToReturn) noexcept { - return errorToReturn; - } - }; - auto ret = uma::poolMakeUnique(providers, 1, this->GetParam()); - ASSERT_EQ(ret.first, this->GetParam()); - ASSERT_EQ(ret.second, nullptr); -} - -TEST_F(test, retrieveMemoryProvidersError) { - static constexpr size_t numProviders = 4; - std::array providers = { - (uma_memory_provider_handle_t)0x1, (uma_memory_provider_handle_t)0x2, - (uma_memory_provider_handle_t)0x3, (uma_memory_provider_handle_t)0x4}; - - auto [ret, pool] = uma::poolMakeUnique( - providers.data(), numProviders); - - ret = umaPoolGetMemoryProviders(pool.get(), 1, providers.data(), nullptr); - ASSERT_EQ(ret, UMA_RESULT_ERROR_INVALID_ARGUMENT); -} diff --git a/test/unified_memory_allocation/uma_pools/disjoint_pool.cpp b/test/unified_memory_allocation/uma_pools/disjoint_pool.cpp deleted file mode 100644 index 88b6d769d8..0000000000 --- a/test/unified_memory_allocation/uma_pools/disjoint_pool.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * Copyright (C) 2023 Intel Corporation - * - * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. - * See LICENSE.TXT - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - * - */ - -#include "disjoint_pool.hpp" - -#include "memoryPool.hpp" -#include "provider.h" -#include "provider.hpp" - -static usm::DisjointPool::Config poolConfig() { - usm::DisjointPool::Config config{}; - config.SlabMinSize = 4096; - config.MaxPoolableSize = 4096; - config.Capacity = 4; - config.MinBucketSize = 64; - return config; -} - -static auto makePool() { - auto [ret, providerUnique] = - uma::memoryProviderMakeUnique(); - EXPECT_EQ(ret, UMA_RESULT_SUCCESS); - auto provider = providerUnique.release(); - auto [retp, pool] = - uma::poolMakeUnique(&provider, 1, poolConfig()); - EXPECT_EQ(retp, UMA_RESULT_SUCCESS); - auto dtor = [provider = provider](uma_memory_pool_handle_t hPool) { - umaPoolDestroy(hPool); - umaMemoryProviderDestroy(provider); - }; - return uma::pool_unique_handle_t(pool.release(), std::move(dtor)); -} - -INSTANTIATE_TEST_SUITE_P(disjointPoolTests, umaPoolTest, - ::testing::Values(makePool)); - -INSTANTIATE_TEST_SUITE_P(disjointMultiPoolTests, umaMultiPoolTest, - ::testing::Values(makePool)); diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index 58ba249c10..fbb3b0cea3 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -12,7 +12,7 @@ target_include_directories(unit_tests_helpers INTERFACE function(add_unit_test name) set(TEST_TARGET_NAME test-${name}) - add_executable(${TEST_TARGET_NAME} + add_ur_executable(${TEST_TARGET_NAME} ${ARGN} ) target_link_libraries(${TEST_TARGET_NAME} diff --git a/test/unit/logger/CMakeLists.txt b/test/unit/logger/CMakeLists.txt index 22ed897916..86e5859a22 100644 --- a/test/unit/logger/CMakeLists.txt +++ b/test/unit/logger/CMakeLists.txt @@ -8,7 +8,7 @@ add_unit_test(logger ) set(TEST_TARGET_NAME test-logger_env_var) -add_executable(${TEST_TARGET_NAME} +add_ur_executable(${TEST_TARGET_NAME} env_var.cpp ) target_link_libraries(${TEST_TARGET_NAME} diff --git a/test/unit/utils/params.cpp b/test/unit/utils/params.cpp index 742804101d..964d117e49 100644 --- a/test/unit/utils/params.cpp +++ b/test/unit/utils/params.cpp @@ -20,8 +20,11 @@ template class ParamsTest : public testing::Test { struct UrInitParams { ur_init_params_t params; ur_device_init_flags_t flags; - UrInitParams(ur_device_init_flags_t _flags) : flags(_flags) { + ur_loader_config_handle_t config; + UrInitParams(ur_device_init_flags_t _flags) + : flags(_flags), config(nullptr) { params.pdevice_flags = &flags; + params.phLoaderConfig = &config; } ur_init_params_t *get_struct() { return ¶ms; } @@ -29,7 +32,9 @@ struct UrInitParams { struct UrInitParamsNoFlags : UrInitParams { UrInitParamsNoFlags() : UrInitParams(0) {} - const char *get_expected() { return ".device_flags = 0"; }; + const char *get_expected() { + return ".device_flags = 0, .hLoaderConfig = nullptr"; + }; }; struct UrInitParamsInvalidFlags : UrInitParams { @@ -39,19 +44,26 @@ struct UrInitParamsInvalidFlags : UrInitParams { const char *get_expected() { return ".device_flags = UR_DEVICE_INIT_FLAG_GPU \\| " "UR_DEVICE_INIT_FLAG_MCA \\| unknown bit flags " - "11000010000000000000000000000000"; + "11000010000000000000000000000000, " + ".hLoaderConfig = nullptr"; }; }; struct UrPlatformGet { ur_platform_get_params_t params; + uint32_t num_adapters; + ur_adapter_handle_t *phAdapters; uint32_t num_entries; uint32_t *pNumPlatforms; ur_platform_handle_t *pPlatforms; UrPlatformGet() { + num_adapters = 0; + phAdapters = nullptr; num_entries = 0; pPlatforms = nullptr; pNumPlatforms = nullptr; + params.pNumAdapters = &num_adapters; + params.pphAdapters = &phAdapters; params.pNumEntries = &num_entries; params.pphPlatforms = &pPlatforms; params.ppNumPlatforms = &pNumPlatforms; @@ -63,7 +75,8 @@ struct UrPlatformGet { struct UrPlatformGetEmptyArray : UrPlatformGet { UrPlatformGetEmptyArray() : UrPlatformGet() {} const char *get_expected() { - return ".NumEntries = 0, .phPlatforms = \\{\\}, .pNumPlatforms = " + return ".phAdapters = \\{\\}, .NumAdapters = 0, .NumEntries = 0, " + ".phPlatforms = \\{\\}, .pNumPlatforms = " "nullptr"; }; }; @@ -79,7 +92,8 @@ struct UrPlatformGetTwoPlatforms : UrPlatformGet { pNumPlatforms = &num_platforms; } const char *get_expected() { - return ".NumEntries = 2, .phPlatforms = \\{.+, .+\\}, " + return ".phAdapters = \\{\\}, .NumAdapters = 0, .NumEntries = 2, " + ".phPlatforms = \\{.+, .+\\}, " ".pNumPlatforms = .+ \\(2\\)"; }; }; @@ -306,6 +320,53 @@ struct UrContextGetInfoParamsDevicesArray : UrContextGetInfoParams { }; }; +struct UrProgramMetadataTest { + UrProgramMetadataTest() { + meta.pName = "MY_META"; + meta.size = 0; + meta.type = UR_PROGRAM_METADATA_TYPE_UINT32; + ur_program_metadata_value_t value{}; + value.data32 = 42; + meta.value = value; + } + + ur_program_metadata_t &get_struct() { return meta; } + const char *get_expected() { + return "\\(struct ur_program_metadata_t\\)" + "\\{" + ".pName = .+ \\(MY_META\\), " + ".type = UR_PROGRAM_METADATA_TYPE_UINT32, " + ".size = 0, " + ".value = \\(union ur_program_metadata_value_t\\)\\{" + ".data32 = 42" + "\\}" + "\\}"; + } + ur_program_metadata_t meta; +}; + +struct UrDevicePartitionPropertyTest { + UrDevicePartitionPropertyTest() { + prop.type = UR_DEVICE_PARTITION_EQUALLY; + ur_device_partition_value_t value{}; + value.equally = 4; + prop.value = value; + } + + ur_device_partition_property_t &get_struct() { return prop; } + const char *get_expected() { + return "\\(struct ur_device_partition_property_t\\)" + "\\{" + ".type = UR_DEVICE_PARTITION_EQUALLY, " + ".value = \\(union ur_device_partition_value_t\\)\\{" + ".equally = 4" + "\\}" + "\\}"; + } + + ur_device_partition_property_t prop; +}; + using testing::Types; typedef Types< UrInitParamsNoFlags, UrInitParamsInvalidFlags, UrUsmHostAllocParamsEmpty, @@ -313,7 +374,8 @@ typedef Types< UrUsmHostAllocParamsUsmDesc, UrUsmHostAllocParamsHostDesc, UrDeviceGetInfoParamsEmpty, UrDeviceGetInfoParamsName, UrDeviceGetInfoParamsQueueFlag, UrDeviceGetInfoParamsPartitionArray, - UrContextGetInfoParamsDevicesArray, UrDeviceGetInfoParamsInvalidSize> + UrContextGetInfoParamsDevicesArray, UrDeviceGetInfoParamsInvalidSize, + UrProgramMetadataTest, UrDevicePartitionPropertyTest> Implementations; using ::testing::MatchesRegex; diff --git a/test/usm/CMakeLists.txt b/test/usm/CMakeLists.txt index e0cb5fd943..b673b6d1b9 100644 --- a/test/usm/CMakeLists.txt +++ b/test/usm/CMakeLists.txt @@ -7,7 +7,7 @@ set(UR_USM_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) function(add_usm_test name) set(TEST_TARGET_NAME usm_test-${name}) - add_executable(${TEST_TARGET_NAME} + add_ur_executable(${TEST_TARGET_NAME} ${UR_USM_TEST_DIR}/../conformance/source/environment.cpp ${UR_USM_TEST_DIR}/../conformance/source/main.cpp ${ARGN}) diff --git a/test/usm/usmPoolManager.cpp b/test/usm/usmPoolManager.cpp index b244a89c83..eaf44e119d 100644 --- a/test/usm/usmPoolManager.cpp +++ b/test/usm/usmPoolManager.cpp @@ -3,8 +3,8 @@ // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#include "../unified_memory_allocation/common/pool.hpp" -#include "../unified_memory_allocation/common/provider.hpp" +#include "../unified_malloc_framework/common/pool.hpp" +#include "../unified_malloc_framework/common/provider.hpp" #include "ur_pool_manager.hpp" #include diff --git a/tools/urtrace/CMakeLists.txt b/tools/urtrace/CMakeLists.txt index be81a11e25..085f361223 100644 --- a/tools/urtrace/CMakeLists.txt +++ b/tools/urtrace/CMakeLists.txt @@ -5,7 +5,7 @@ set(TARGET_NAME ur_collector) -add_library(${TARGET_NAME} SHARED +add_ur_library(${TARGET_NAME} SHARED ${CMAKE_CURRENT_SOURCE_DIR}/collector.cpp ) diff --git a/tools/urtrace/collector.cpp b/tools/urtrace/collector.cpp index 3655cbe3c8..b502f0d802 100644 --- a/tools/urtrace/collector.cpp +++ b/tools/urtrace/collector.cpp @@ -181,7 +181,7 @@ static class cli_args { bool no_args; enum output_format output_format; std::optional - filter_str; //the filter_str is kept primarly for printing. + filter_str; //the filter_str is kept primarily for printing. std::optional filter; } cli_args; diff --git a/tools/urtrace/urtrace.py b/tools/urtrace/urtrace.py index 8ed43abc50..7b337d7cc8 100755 --- a/tools/urtrace/urtrace.py +++ b/tools/urtrace/urtrace.py @@ -96,6 +96,8 @@ def get_dynamic_library_name(name): env['XPTI_TRACE_ENABLE'] = "1" +env['UR_ENABLE_LAYERS'] = "UR_LAYER_TRACING" + xptifw_lib = get_dynamic_library_name("xptifw") xptifw = find_library(args.libpath, xptifw_lib, args.recursive) if xptifw is None: