├── scripts ├── __init__.py ├── config.ini ├── assets │ ├── html │ │ ├── _static │ │ │ └── custom.css │ │ └── _templates │ │ │ └── breadcrumbs.html │ └── images │ │ ├── programs.png │ │ ├── intel-logo.png │ │ ├── one_api_sw_stack.png │ │ └── runtime_object_hier.png ├── templates │ ├── __init__.py │ ├── api.rst.mako │ ├── adapter.def.in.mako │ ├── loader.def.in.mako │ ├── adapter.map.in.mako │ ├── loader.map.in.mako │ ├── index.rst.mako │ ├── exp-features.rst.mako │ ├── api_funcs.def.mako │ ├── exp_feat.yml.mako │ ├── stype_map_helpers.hpp.mako │ ├── optional_queries.h.mako │ ├── queue_api.hpp.mako │ └── manifests.hpp.mako ├── README.md ├── core │ └── exp-device-is-integrated-gpu.yml ├── verify_license.py └── check-hardening.sh ├── test ├── fuzz │ ├── corpus │ │ ├── alloc │ │ ├── pool-alloc │ │ ├── create-release │ │ └── kernel-launch │ ├── mock-long.test │ ├── level_zero-long.test │ ├── mock-short.test │ ├── level_zero-short.test │ └── lit.local.cfg.py ├── .clang-format ├── loader │ ├── hello_world.test │ ├── loader_config │ │ ├── loader_config.test │ │ ├── CMakeLists.txt │ │ ├── fixtures.hpp │ │ ├── urLoaderConfigCreate.cpp │ │ └── urLoaderConfigRetain.cpp │ ├── loader_lifetime │ │ ├── loader_lifetime.test │ │ ├── CMakeLists.txt │ │ ├── urLoaderTearDown.cpp │ │ └── fixtures.hpp │ ├── handles │ │ ├── handles.test │ │ └── CMakeLists.txt │ ├── platforms │ │ ├── null_platform.test │ │ ├── no_platforms.test │ │ └── CMakeLists.txt │ ├── adapter_registry │ │ ├── lit.local.cfg.py │ │ ├── CMakeLists.txt │ │ ├── search_no_env.cpp │ │ └── search_with_env.cpp │ └── CMakeLists.txt ├── unit │ ├── lit.site.cfg.py.in │ ├── CMakeLists.txt │ ├── lit.cfg.py │ ├── helpers.h │ └── helpers.cpp ├── adapters │ ├── cuda │ │ ├── lit.site.cfg.py.in │ │ ├── lit.cfg.py │ │ ├── raii.h │ │ ├── fixtures.h │ │ ├── urContextGetNativeHandle.cpp │ │ ├── urDeviceGetNativeHandle.cpp │ │ ├── urEventCreateWithNativeHandle.cpp │ │ ├── memory_tests.cpp │ │ └── urDeviceCreateWithNativeHandle.cpp │ ├── hip │ │ ├── lit.site.cfg.py.in │ │ ├── lit.cfg.py │ │ ├── urContextGetNativeHandle.cpp │ │ ├── fixtures.h │ │ ├── kernel_tests.cpp │ │ ├── urDeviceGetNativeHandle.cpp │ │ └── CMakeLists.txt │ ├── level_zero │ │ ├── v2 │ │ │ └── deferred_kernel_memcheck.test │ │ ├── memcheck.test │ │ └── lit.local.cfg.py │ ├── lit.local.cfg.py │ └── CMakeLists.txt ├── layers │ ├── tracing │ │ ├── codeloc.test │ │ ├── lit.local.cfg.py │ │ └── CMakeLists.txt │ ├── sanitizer │ │ ├── lit.local.cfg.py │ │ └── CMakeLists.txt │ ├── validation │ │ ├── CMakeLists.txt │ │ ├── lit.local.cfg.py │ │ └── parameters.cpp │ └── CMakeLists.txt ├── usm │ ├── lit.local.cfg.py │ └── CMakeLists.txt ├── logger │ ├── CMakeLists.txt │ ├── env_var.cpp │ ├── level-none.test │ ├── level-info.test │ ├── level-debug.test │ ├── level-error.test │ └── level-warning.test ├── tools │ ├── CMakeLists.txt │ └── urtrace │ │ ├── CMakeLists.txt │ │ ├── lit.local.cfg.py │ │ ├── no_args.test │ │ └── filter_device.test └── conformance │ ├── exp_usm_p2p │ └── CMakeLists.txt │ ├── memory-migrate │ └── CMakeLists.txt │ ├── exp_usm_context_memcpy │ └── CMakeLists.txt │ ├── integration │ └── CMakeLists.txt │ ├── exp_enqueue_kernel_launch_with_args │ └── CMakeLists.txt │ ├── adapter │ └── CMakeLists.txt │ ├── kernel │ ├── kernel_adapter_opencl.match │ ├── CMakeLists.txt │ └── urKernelGetNativeHandle.cpp │ ├── lit.site.cfg.py.in │ ├── sampler │ ├── CMakeLists.txt │ ├── urSamplerRetain.cpp │ ├── urSamplerRelease.cpp │ └── urSamplerGetNativeHandle.cpp │ ├── platform │ ├── CMakeLists.txt │ ├── urPlatformGetApiVersion.cpp │ └── urPlatformGetNativeHandle.cpp │ ├── queue │ ├── CMakeLists.txt │ ├── urQueueRetain.cpp │ ├── urQueueRelease.cpp │ └── urQueueFlush.cpp │ ├── context │ ├── CMakeLists.txt │ ├── urContextRetain.cpp │ ├── urContextRelease.cpp │ └── urContextGetNativeHandle.cpp │ ├── event │ ├── CMakeLists.txt │ ├── urEventRetain.cpp │ ├── urEventRelease.cpp │ └── urEventGetNativeHandle.cpp │ ├── usm │ ├── CMakeLists.txt │ ├── urUSMPoolRetain.cpp │ └── urUSMPoolRelease.cpp │ ├── device_code │ ├── bar.cpp │ ├── foo.cpp │ ├── no_args.cpp │ ├── inc.cpp │ ├── build_failure.cpp │ ├── multiply.cpp │ ├── increment.cpp │ ├── linker_error.cpp │ ├── fill_usm.cpp │ ├── fixed_sg_size.cpp │ ├── fixed_wg_size.cpp │ ├── max_wg_size.cpp │ ├── fill.cpp │ ├── cpy_and_mult_usm.cpp │ ├── device_global.cpp │ ├── saxpy_usm.cpp │ ├── spec_constant.cpp │ ├── cpy_and_mult.cpp │ ├── fill_usm_2d.cpp │ ├── sequence.cpp │ └── fill_2d.cpp │ ├── exp_graph │ ├── CMakeLists.txt │ ├── urGraphDestroyExp.cpp │ ├── urQueueBeginGraphCaptureExp.cpp │ ├── urGraphCreateExp.cpp │ └── urQueueEndGraphCaptureExp.cpp │ ├── device │ ├── CMakeLists.txt │ └── urDeviceGetNativeHandle.cpp │ ├── testing │ └── CMakeLists.txt │ ├── memory │ └── CMakeLists.txt │ ├── virtual_memory │ ├── CMakeLists.txt │ ├── urVirtualMemFree.cpp │ └── urVirtualMemUnmap.cpp │ ├── exp_enqueue_native │ └── CMakeLists.txt │ ├── source │ └── main.cpp │ ├── program │ ├── CMakeLists.txt │ ├── urProgramRetain.cpp │ └── urProgramRelease.cpp │ └── exp_command_buffer │ ├── CMakeLists.txt │ ├── native-command │ └── CMakeLists.txt │ ├── retain.cpp │ └── release.cpp ├── .github ├── CODEOWNERS ├── intel-llvm-mirror-base-commit ├── scripts │ └── install_hwloc.sh ├── dependabot.yml └── docker │ ├── install_libbacktrace.sh │ └── install_dpcpp.sh ├── .clang-format ├── CHANGELOG.md ├── third_party ├── requirements_testing.txt ├── CMakeLists.txt ├── deps.yml └── requirements.txt ├── cmake ├── unified-runtime-config.cmake.in ├── FindRocmAgentEnumerator.cmake ├── FindLibbacktrace.cmake └── FindLit.cmake ├── source ├── adapters │ ├── level_zero │ │ ├── external │ │ │ ├── README.md │ │ │ └── driver_experimental │ │ │ │ ├── zex_api.h │ │ │ │ ├── mcl_ext │ │ │ │ └── zex_mutable_cmdlist_ext.h │ │ │ │ └── zex_context.h │ │ ├── ur_level_zero.cpp │ │ ├── v2 │ │ │ └── queue_extensions.hpp │ │ ├── physical_mem.hpp │ │ ├── enqueue_native.cpp │ │ ├── sampler.hpp │ │ └── ur_level_zero.hpp │ ├── opencl │ │ ├── core_functions.def │ │ ├── physical_mem.hpp │ │ └── enqueue_native.cpp │ ├── native_cpu │ │ ├── adapter.hpp │ │ ├── physical_mem.hpp │ │ ├── platform.hpp │ │ ├── device.hpp │ │ ├── usm_p2p.cpp │ │ └── common.cpp │ ├── cuda │ │ ├── platform.hpp │ │ └── tracing.hpp │ ├── mock │ │ └── CMakeLists.txt │ ├── adapter.def.in │ ├── hip │ │ ├── physical_mem.hpp │ │ ├── platform.hpp │ │ └── adapter.hpp │ ├── offload │ │ ├── platform.hpp │ │ ├── device.hpp │ │ ├── adapter.hpp │ │ ├── common.hpp │ │ └── event.hpp │ └── adapter.map.in ├── loader │ ├── libur_loader.pc.in │ ├── layers │ │ ├── sanitizer │ │ │ ├── asan │ │ │ │ ├── asan_ddi.hpp │ │ │ │ ├── asan_allocator.cpp │ │ │ │ ├── asan_statistics.hpp │ │ │ │ └── asan_quarantine.cpp │ │ │ ├── tsan │ │ │ │ ├── tsan_ddi.hpp │ │ │ │ └── tsan_report.hpp │ │ │ ├── msan │ │ │ │ ├── msan_report.hpp │ │ │ │ ├── msan_allocator.cpp │ │ │ │ └── msan_allocator.hpp │ │ │ └── sanitizer_common │ │ │ │ ├── sanitizer_stacktrace.hpp │ │ │ │ ├── sanitizer_options.hpp │ │ │ │ └── sanitizer_stackdepot.hpp │ │ └── ur_proxy_layer.hpp │ ├── ur_adapter_search.hpp │ ├── ur_codeloc.hpp │ └── linux │ │ └── adapter_search.cpp ├── CMakeLists.txt ├── mock │ ├── ur_mock_helpers.cpp │ └── CMakeLists.txt ├── common │ ├── backtrace.hpp │ ├── ur_filesystem_resolved.hpp │ ├── ur_ref_count.hpp │ ├── ur_lib_loader.hpp │ └── backtrace_lin.cpp └── ur │ └── ur.cpp ├── .editorconfig ├── .trivyignore ├── tools ├── CMakeLists.txt ├── urinfo │ └── CMakeLists.txt └── urtrace │ └── CMakeLists.txt ├── examples ├── codegen │ ├── helpers.h │ └── README.md ├── CMakeLists.txt ├── hello_world │ └── CMakeLists.txt └── collector │ └── CMakeLists.txt ├── sanitizer-ignorelist.txt ├── SECURITY.md └── .gitignore /scripts/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/fuzz/corpus/alloc: -------------------------------------------------------------------------------- 1 | x d 2 |  -------------------------------------------------------------------------------- /test/.clang-format: -------------------------------------------------------------------------------- 1 | ReflowComments: false 2 | -------------------------------------------------------------------------------- /test/fuzz/corpus/pool-alloc: -------------------------------------------------------------------------------- 1 | x d  -------------------------------------------------------------------------------- /test/fuzz/corpus/create-release: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @oneapi-src/unified-runtime-maintain 2 | -------------------------------------------------------------------------------- /test/loader/hello_world.test: -------------------------------------------------------------------------------- 1 | RUN: %use-mock hello_world 2 | -------------------------------------------------------------------------------- /test/loader/loader_config/loader_config.test: -------------------------------------------------------------------------------- 1 | RUN: loader-config-test 2 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | BasedOnStyle: LLVM 4 | ... 5 | -------------------------------------------------------------------------------- /test/loader/loader_lifetime/loader_lifetime.test: -------------------------------------------------------------------------------- 1 | RUN: loader-lifetime-test 2 | -------------------------------------------------------------------------------- /.github/intel-llvm-mirror-base-commit: -------------------------------------------------------------------------------- 1 | 0879472b3ef5b3180876a63a3cfc3b8dc2844b14 2 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Unified Runtime changelog 2 | 3 | ## v.X.X.X 4 | * Placeholder for first release 5 | -------------------------------------------------------------------------------- /scripts/config.ini: -------------------------------------------------------------------------------- 1 | [core] 2 | OneApi='oneAPI' 3 | namespace=ur 4 | tags=OneApi,x 5 | x=${namespace} 6 | -------------------------------------------------------------------------------- /test/loader/handles/handles.test: -------------------------------------------------------------------------------- 1 | RUN: UR_ENABLE_LOADER_INTERCEPT=1 %use-mock loader-handles-test 2 | -------------------------------------------------------------------------------- /scripts/assets/html/_static/custom.css: -------------------------------------------------------------------------------- 1 | .wy-side-nav-search, .wy-nav-top { 2 | background: #4308E5; 3 | } 4 | -------------------------------------------------------------------------------- /test/fuzz/corpus/kernel-launch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oneapi-src/unified-runtime/HEAD/test/fuzz/corpus/kernel-launch -------------------------------------------------------------------------------- /scripts/assets/images/programs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oneapi-src/unified-runtime/HEAD/scripts/assets/images/programs.png -------------------------------------------------------------------------------- /scripts/assets/images/intel-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oneapi-src/unified-runtime/HEAD/scripts/assets/images/intel-logo.png -------------------------------------------------------------------------------- /scripts/assets/images/one_api_sw_stack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oneapi-src/unified-runtime/HEAD/scripts/assets/images/one_api_sw_stack.png -------------------------------------------------------------------------------- /scripts/assets/images/runtime_object_hier.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oneapi-src/unified-runtime/HEAD/scripts/assets/images/runtime_object_hier.png -------------------------------------------------------------------------------- /test/fuzz/mock-long.test: -------------------------------------------------------------------------------- 1 | RUN: %fuzz-options %use-mock fuzztest-base -max_total_time=600 -seed=1 -verbosity=1 -detect_leaks=0 2 | 3 | REQUIRES: fuzztesting 4 | -------------------------------------------------------------------------------- /test/unit/lit.site.cfg.py.in: -------------------------------------------------------------------------------- 1 | config.binary_dir = "@CMAKE_CURRENT_BINARY_DIR@" 2 | 3 | lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg.py") 4 | -------------------------------------------------------------------------------- /test/adapters/cuda/lit.site.cfg.py.in: -------------------------------------------------------------------------------- 1 | config.binary_dir = "@CMAKE_CURRENT_BINARY_DIR@" 2 | 3 | lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg.py") 4 | -------------------------------------------------------------------------------- /test/adapters/hip/lit.site.cfg.py.in: -------------------------------------------------------------------------------- 1 | config.binary_dir = "@CMAKE_CURRENT_BINARY_DIR@" 2 | 3 | lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg.py") 4 | -------------------------------------------------------------------------------- /third_party/requirements_testing.txt: -------------------------------------------------------------------------------- 1 | # Note: Filecheck 1.0.1 requires Python 3.10 2 | filecheck==1.0.1 3 | lit==18.1.8 4 | 5 | # For timeouts in lit 6 | psutil==7.0.0 7 | -------------------------------------------------------------------------------- /cmake/unified-runtime-config.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake") 4 | check_required_components("@PROJECT_NAME@") 5 | -------------------------------------------------------------------------------- /source/adapters/level_zero/external/README.md: -------------------------------------------------------------------------------- 1 | This subdirectory contains a copy of Level Zero experimental headers. 2 | Repo: https://github.com/intel/compute-runtime 3 | Tag: 25.44.36015.5 4 | -------------------------------------------------------------------------------- /test/fuzz/level_zero-long.test: -------------------------------------------------------------------------------- 1 | RUN: %fuzz-options %use-level_zero fuzztest-base -max_total_time=600 -seed=1 -verbosity=1 -detect_leaks=0 2 | 3 | REQUIRES: adapter-level_zero 4 | REQUIRES: fuzztesting 5 | -------------------------------------------------------------------------------- /scripts/assets/html/_templates/breadcrumbs.html: -------------------------------------------------------------------------------- 1 | {%- extends "sphinx_rtd_theme/breadcrumbs.html" %} 2 | 3 | {% block breadcrumbs %} 4 | {% endblock %} 5 | {% block breadcrumbs_aside %} 6 | {% endblock %} 7 | 8 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | [*] 2 | indent_style = space 3 | indent_size = 2 4 | 5 | [*.py] 6 | indent_size = 4 7 | 8 | [scripts/core/*] 9 | indent_size = 4 10 | 11 | [CMakeLists.txt] 12 | indent_size = 4 13 | 14 | [*.cmake] 15 | indent_size = 4 16 | -------------------------------------------------------------------------------- /test/layers/tracing/codeloc.test: -------------------------------------------------------------------------------- 1 | RUN: %use-mock %xptienable XPTI_SUBSCRIBERS=%{shlibpre}test_collector%{shlibext} codeloc-test 2>&1 | FileCheck %s 2 | 3 | REQUIRES: tracing 4 | 5 | CHECK: begin urAdapterGet 178 fname sfile 2 1 6 | CHECK: end urAdapterGet 178 fname sfile 2 1 7 | -------------------------------------------------------------------------------- /test/loader/platforms/null_platform.test: -------------------------------------------------------------------------------- 1 | RUN: UR_LOG_TEST="level:info;output:stdout;flush:debug" %use-mock platforms-test 2 | 3 | CHECK: [INFO]: urLoaderInit succeeded. 4 | CHECK: [INFO]: urPlatformGet found 1 platforms 5 | CHECK: [INFO]: Found Mock Platform 6 | -------------------------------------------------------------------------------- /test/loader/platforms/no_platforms.test: -------------------------------------------------------------------------------- 1 | RUN: UR_ADAPTERS_FORCE_LOAD="invalid.so" UR_LOG_TEST="level:info;output:stdout;flush:debug" platforms-test 2 | 3 | REQUIRES: linux 4 | 5 | CHECK: [INFO]: urLoaderInit succeeded. 6 | CHECK: [INFO]: urPlatformGet found 0 platforms 7 | -------------------------------------------------------------------------------- /scripts/templates/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (C) 2023 Intel Corporation 3 | 4 | Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 5 | Exceptions. 6 | See LICENSE.TXT 7 | 8 | SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 9 | 10 | """ 11 | -------------------------------------------------------------------------------- /test/adapters/level_zero/v2/deferred_kernel_memcheck.test: -------------------------------------------------------------------------------- 1 | RUN: %with-v2 %valgrind --tool=memcheck --leak-check=full ./deferred_kernel-test 2>&1 | FileCheck %s 2 | REQUIRES: v2 3 | REQUIRES: valgrind 4 | UNSUPPORTED: system-windows 5 | 6 | CHECK: ERROR SUMMARY: 0 errors from 0 contexts 7 | -------------------------------------------------------------------------------- /test/loader/platforms/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | add_gtest_test(platforms platforms.cpp) 7 | -------------------------------------------------------------------------------- /.trivyignore: -------------------------------------------------------------------------------- 1 | # Docs: https://aquasecurity.github.io/trivy/latest/docs/configuration/filtering/#trivyignore 2 | 3 | # In docker files: 4 | # HEALTHCHECK is not required for development, nor in CI (failed docker = failed CI). 5 | # We're not hosting any application with usage of the dockers. 6 | AVD-DS-0026 7 | -------------------------------------------------------------------------------- /test/usm/lit.local.cfg.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (C) 2025 Intel Corporation 3 | 4 | Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 5 | See LICENSE.TXT 6 | SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7 | 8 | """ 9 | 10 | config.suffixes = [".cpp"] 11 | -------------------------------------------------------------------------------- /test/loader/handles/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | add_gtest_test(loader-handles urLoaderHandles.cpp) 7 | -------------------------------------------------------------------------------- /third_party/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | # Placeholder to fix FetchContent issues for projects from outside 6 | -------------------------------------------------------------------------------- /test/layers/sanitizer/lit.local.cfg.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (C) 2025 Intel Corporation 3 | 4 | Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 5 | See LICENSE.TXT 6 | SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7 | 8 | """ 9 | 10 | config.suffixes = [".cpp"] 11 | -------------------------------------------------------------------------------- /test/logger/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | add_ur_lit_testsuite(logger) 7 | add_gtest_test(logger env_var.cpp) 8 | -------------------------------------------------------------------------------- /test/tools/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | if(UR_ENABLE_TRACING) 7 | add_subdirectory(urtrace) 8 | endif() 9 | -------------------------------------------------------------------------------- /test/conformance/exp_usm_p2p/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2024 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | add_conformance_devices_test(exp_usm_p2p 7 | usm_p2p.cpp 8 | ) 9 | -------------------------------------------------------------------------------- /test/tools/urtrace/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | add_ur_lit_testsuite(urtrace DEPENDS hello_world ur_trace_cli ur_collector xptifw) 7 | -------------------------------------------------------------------------------- /tools/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | add_subdirectory(urinfo) 7 | if(UR_ENABLE_TRACING) 8 | add_subdirectory(urtrace) 9 | endif() 10 | -------------------------------------------------------------------------------- /test/conformance/memory-migrate/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022-2024 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | add_conformance_kernels_test(memory-migrate 7 | urMemBufferMigrateAcrossDevices.cpp) 8 | -------------------------------------------------------------------------------- /test/conformance/exp_usm_context_memcpy/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2025 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | add_conformance_devices_test( 7 | exp_usm_context_memcpy 8 | urUSMContextMemcpyExp.cpp 9 | ) 10 | -------------------------------------------------------------------------------- /test/loader/loader_lifetime/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | add_gtest_test(loader-lifetime 7 | urLoaderInit.cpp 8 | urLoaderTearDown.cpp 9 | mixed.cpp 10 | ) 11 | -------------------------------------------------------------------------------- /scripts/templates/api.rst.mako: -------------------------------------------------------------------------------- 1 | <% 2 | import os 3 | 4 | apidocs = [] 5 | for section in sections: 6 | apidocs.append(section + "/api.rst") 7 | %> 8 | =================== 9 | API Documentation 10 | =================== 11 | 12 | .. toctree:: 13 | 14 | %for apidoc in apidocs: 15 | %if os.path.exists(os.path.join(sourcepath, apidoc)): 16 | ${apidoc} 17 | %endif 18 | %endfor 19 | -------------------------------------------------------------------------------- /examples/codegen/helpers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (C) 2023 Intel Corporation 4 | * 5 | * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | * Exceptions. See LICENSE.TXT 7 | * 8 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | 15 | std::string generate_plus_one_spv(); 16 | -------------------------------------------------------------------------------- /sanitizer-ignorelist.txt: -------------------------------------------------------------------------------- 1 | [cfi-unrelated-cast] 2 | # std::_Sp_counted_ptr_inplace::_Sp_counted_ptr_inplace() (libstdc++). 3 | # This ctor is used by std::make_shared and needs to cast to uninitialized T* 4 | # in order to call std::allocator_traits::construct. 5 | # See: https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/cfi/cfi_ignorelist.txt 6 | fun:_ZNSt23_Sp_counted_ptr_inplace* 7 | -------------------------------------------------------------------------------- /scripts/templates/adapter.def.in.mako: -------------------------------------------------------------------------------- 1 | <%! 2 | import re 3 | from templates import helper as th 4 | %><% 5 | n=namespace 6 | %>\ 7 | LIBRARY @TARGET_LIBNAME@ 8 | EXPORTS 9 | %for tbl in th.get_pfntables(specs, meta, n, tags): 10 | %if 'guard' in tbl: 11 | #if ${tbl['guard']} 12 | %endif 13 | ${tbl['export']['name']} 14 | %if 'guard' in tbl: 15 | #endif // ${tbl['guard']} 16 | %endif 17 | %endfor 18 | -------------------------------------------------------------------------------- /scripts/templates/loader.def.in.mako: -------------------------------------------------------------------------------- 1 | <%! 2 | import re 3 | from templates import helper as th 4 | %><% 5 | n=namespace 6 | %>\ 7 | LIBRARY @TARGET_LIBNAME@ 8 | EXPORTS 9 | %for func in th.get_loader_functions(specs, meta, n, tags): 10 | %if 'guard' in func: 11 | #if ${func['guard']} 12 | %endif 13 | ${func['name']} 14 | %if 'guard' in func: 15 | #endif // ${func['guard']} 16 | %endif 17 | %endfor 18 | -------------------------------------------------------------------------------- /test/conformance/integration/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2024 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | add_conformance_kernels_test(integration 7 | QueueEmptyStatus.cpp 8 | QueueUSM.cpp 9 | QueueBuffer.cpp 10 | ) 11 | -------------------------------------------------------------------------------- /test/conformance/exp_enqueue_kernel_launch_with_args/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2025 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | add_conformance_kernels_test( 7 | exp_kernel_launch_with_args 8 | urEnqueueKernelLaunchWithArgsExp.cpp 9 | ) 10 | -------------------------------------------------------------------------------- /source/loader/libur_loader.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | includedir=${prefix}/include 3 | libdir=${prefix}/lib 4 | 5 | 6 | Name: Unified Runtime Loader 7 | Description: Unified Runtime Library Loader for Unified Runtime 8 | URL: TBD 9 | Version: @PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@ 10 | Requires: 11 | Libs: -L${libdir} -lur_loader 12 | CFlags: -I${includedir} 13 | 14 | 15 | -------------------------------------------------------------------------------- /scripts/templates/adapter.map.in.mako: -------------------------------------------------------------------------------- 1 | <%! 2 | import re 3 | from templates import helper as th 4 | %><% 5 | n=namespace 6 | %>\ 7 | @TARGET_LIBNAME@ { 8 | global: 9 | %for tbl in th.get_pfntables(specs, meta, n, tags): 10 | %if 'guard' in tbl: 11 | #if ${tbl['guard']} 12 | %endif 13 | ${tbl['export']['name']}; 14 | %if 'guard' in tbl: 15 | #endif // ${tbl['guard']} 16 | %endif 17 | %endfor 18 | local: 19 | *; 20 | }; 21 | -------------------------------------------------------------------------------- /scripts/templates/loader.map.in.mako: -------------------------------------------------------------------------------- 1 | <%! 2 | import re 3 | from templates import helper as th 4 | %><% 5 | n=namespace 6 | %>\ 7 | @TARGET_LIBNAME@ { 8 | global: 9 | %for func in th.get_loader_functions(specs, meta, n, tags): 10 | %if 'guard' in func: 11 | #if ${func['guard']} 12 | %endif 13 | ${func['name']}; 14 | %if 'guard' in func: 15 | #endif // ${func['guard']} 16 | %endif 17 | %endfor 18 | local: 19 | *; 20 | }; 21 | -------------------------------------------------------------------------------- /test/fuzz/mock-short.test: -------------------------------------------------------------------------------- 1 | RUN: %fuzz-options %use-mock fuzztest-base %p/corpus/alloc -verbosity=1 -detect_leaks=0 2 | RUN: %fuzz-options %use-mock fuzztest-base %p/corpus/create-release -verbosity=1 -detect_leaks=0 3 | RUN: %fuzz-options %use-mock fuzztest-base %p/corpus/kernel-launch -verbosity=1 -detect_leaks=0 4 | RUN: %fuzz-options %use-mock fuzztest-base %p/corpus/pool-alloc -verbosity=1 -detect_leaks=0 5 | 6 | REQUIRES: fuzztesting 7 | -------------------------------------------------------------------------------- /test/conformance/adapter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | add_conformance_test(adapter 7 | urAdapterGet.cpp 8 | urAdapterGetInfo.cpp 9 | urAdapterGetLastError.cpp 10 | urAdapterRetain.cpp 11 | urAdapterRelease.cpp) 12 | -------------------------------------------------------------------------------- /test/tools/urtrace/lit.local.cfg.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (C) 2025 Intel Corporation 3 | 4 | Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 5 | See LICENSE.TXT 6 | SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7 | 8 | """ 9 | 10 | config.substitutions.append( 11 | ( 12 | r"%trace", 13 | f"urtrace --stdout --flush info --mock --libpath {config.main_lib_dir}", 14 | ) 15 | ) 16 | -------------------------------------------------------------------------------- /test/conformance/kernel/kernel_adapter_opencl.match: -------------------------------------------------------------------------------- 1 | # Match tests that use fixed_wg_size.cpp as it fails to compile on some 2 | # hardware. 3 | {{OPT}}urKernelGetGroupInfoMaxWorkGroupSizeTest.CompileMaxWorkGroupSize/* 4 | {{OPT}}urKernelGetGroupInfoMaxWorkGroupSizeTest.CompileMaxLinearWorkGroupSize/* 5 | 6 | # Match tests that use fixed_sg_size.cpp as it fails to compile on some 7 | # hardware. 8 | {{OPT}}urKernelGetSubGroupInfoFixedSubGroupSizeTest.CompileNumSubGroups/* 9 | -------------------------------------------------------------------------------- /test/unit/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | add_ur_lit_testsuite(unit) 7 | add_gtest_test(getenv getenv.cpp) 8 | add_gtest_test(params params.cpp) 9 | add_gtest_test(print print.cpp) 10 | add_gtest_test(helpers helpers.cpp) 11 | add_gtest_test(mock mock.cpp) 12 | -------------------------------------------------------------------------------- /test/conformance/lit.site.cfg.py.in: -------------------------------------------------------------------------------- 1 | config.runtime_dir = "@CMAKE_RUNTIME_OUTPUT_DIRECTORY@" 2 | config.binary_dir = "@CMAKE_CURRENT_BINARY_DIR@" 3 | config.using_l0_v2 = "@UR_BUILD_ADAPTER_L0_V2@" == "ON" 4 | config.default_selector = "@UR_CONFORMANCE_SELECTOR@" 5 | 6 | config.adapters_built = [] 7 | if r"@UR_ADAPTERS_LIST@": 8 | config.adapters_built = r"@UR_ADAPTERS_LIST@".split(";") 9 | 10 | lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg.py") 11 | -------------------------------------------------------------------------------- /test/loader/adapter_registry/lit.local.cfg.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (C) 2025 Intel Corporation 3 | 4 | Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 5 | See LICENSE.TXT 6 | SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7 | 8 | """ 9 | 10 | from os import path 11 | 12 | config.suffixes = [".cpp"] 13 | 14 | config.substitutions.append( 15 | (r"%cwd", path.join(config.test_exec_root, "loader", "adapter_registry")) 16 | ) 17 | -------------------------------------------------------------------------------- /source/adapters/opencl/core_functions.def: -------------------------------------------------------------------------------- 1 | // Introduced in OpenCL 2.0 2 | // TODO: clCreateCommandQueueWithProperties 3 | 4 | // Introduced in OpenCL 2.1 5 | // TODO: clGetKernelSubGroupInfo 6 | // TODO: clCreateProgramWithIL 7 | // TODO: clGetHostTimer 8 | // TODO: clGetDeviceAndHostTimer 9 | 10 | // Introduced in OpenCL 2.2 11 | CL_CORE_FUNCTION(clSetProgramSpecializationConstant) 12 | 13 | // Introduced in OpenCL 3.0 14 | CL_CORE_FUNCTION(clSetContextDestructorCallback) 15 | -------------------------------------------------------------------------------- /scripts/templates/index.rst.mako: -------------------------------------------------------------------------------- 1 | .. 2 | Copyright 2022 Intel Corporation 3 | 4 | .. oneAPI Unified Runtime Specification v${ver} 5 | 6 | .. _l0-section: 7 | 8 | =================================== 9 | |full_name|: |spec_version| 10 | =================================== 11 | 12 | .. toctree:: 13 | 14 | core/INTRO.rst 15 | core/PROG.rst 16 | core/CONTRIB.rst 17 | core/CUDA.rst 18 | core/HIP.rst 19 | core/LEVEL_ZERO.rst 20 | exp-features.rst 21 | api.rst 22 | -------------------------------------------------------------------------------- /test/fuzz/level_zero-short.test: -------------------------------------------------------------------------------- 1 | RUN: %fuzz-options %use-level_zero fuzztest-base %p/corpus/alloc -verbosity=1 -detect_leaks=0 2 | RUN: %fuzz-options %use-level_zero fuzztest-base %p/corpus/create-release -verbosity=1 -detect_leaks=0 3 | RUN: %fuzz-options %use-level_zero fuzztest-base %p/corpus/kernel-launch -verbosity=1 -detect_leaks=0 4 | RUN: %fuzz-options %use-level_zero fuzztest-base %p/corpus/pool-alloc -verbosity=1 -detect_leaks=0 5 | 6 | REQUIRES: adapter-level_zero 7 | REQUIRES: fuzztesting 8 | -------------------------------------------------------------------------------- /test/layers/validation/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023-2024 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | set(UR_VALIDATION_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 7 | 8 | add_gtest_test(parameters parameters.cpp) 9 | add_gtest_test(leaks leaks.cpp) 10 | add_gtest_test(leaks_mt leaks_mt.cpp) 11 | add_gtest_test(lifetime lifetime.cpp) 12 | -------------------------------------------------------------------------------- /test/loader/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | add_ur_lit_testsuite(loader DEPENDS ur_loader hello_world) 7 | 8 | add_subdirectory(adapter_registry) 9 | add_subdirectory(loader_config) 10 | add_subdirectory(loader_lifetime) 11 | add_subdirectory(platforms) 12 | add_subdirectory(handles) 13 | -------------------------------------------------------------------------------- /examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) 7 | 8 | add_subdirectory(hello_world) 9 | if(UR_BUILD_EXAMPLE_CODEGEN) 10 | add_subdirectory(codegen) 11 | endif() 12 | if(UR_ENABLE_TRACING) 13 | add_subdirectory(collector) 14 | endif() 15 | -------------------------------------------------------------------------------- /test/conformance/sampler/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | add_conformance_devices_test(sampler 7 | urSamplerCreate.cpp 8 | urSamplerCreateWithNativeHandle.cpp 9 | urSamplerGetInfo.cpp 10 | urSamplerGetNativeHandle.cpp 11 | urSamplerRelease.cpp 12 | urSamplerRetain.cpp 13 | ) 14 | -------------------------------------------------------------------------------- /test/layers/tracing/lit.local.cfg.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (C) 2025 Intel Corporation 3 | 4 | Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 5 | See LICENSE.TXT 6 | SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7 | 8 | """ 9 | 10 | config.substitutions.append( 11 | ( 12 | r"%xptienable", 13 | f"UR_ENABLE_LAYERS=UR_LAYER_TRACING XPTI_TRACE_ENABLE=1 XPTI_FRAMEWORK_DISPATCHER={config.shlibpre}xptifw{config.shlibext}", 14 | ) 15 | ) 16 | -------------------------------------------------------------------------------- /source/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | add_definitions(-DUR_VERSION="${PROJECT_VERSION_MAJOR}") 7 | add_definitions(-DUR_VALIDATION_LAYER_SUPPORTED_VERSION="${PROJECT_VERSION_MAJOR}") 8 | 9 | add_subdirectory(common) 10 | add_subdirectory(loader) 11 | add_subdirectory(mock) 12 | add_subdirectory(adapters) 13 | -------------------------------------------------------------------------------- /test/unit/lit.cfg.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (C) 2025 Intel Corporation 3 | 4 | Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 5 | See LICENSE.TXT 6 | SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7 | 8 | """ 9 | 10 | import lit.formats 11 | from os import path 12 | 13 | config.name = "Unified Runtime Unit" 14 | config.test_format = lit.formats.GoogleTest(".", "-test") 15 | config.test_source_root = config.binary_dir 16 | config.test_exec_root = config.binary_dir 17 | -------------------------------------------------------------------------------- /test/conformance/platform/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | add_conformance_platform_test(platform 7 | urPlatformCreateWithNativeHandle.cpp 8 | urPlatformGet.cpp 9 | urPlatformGetApiVersion.cpp 10 | urPlatformGetBackendOption.cpp 11 | urPlatformGetInfo.cpp 12 | urPlatformGetNativeHandle.cpp) 13 | -------------------------------------------------------------------------------- /test/conformance/queue/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | add_conformance_devices_test(queue 7 | urQueueCreate.cpp 8 | urQueueCreateWithNativeHandle.cpp 9 | urQueueFinish.cpp 10 | urQueueFlush.cpp 11 | urQueueGetInfo.cpp 12 | urQueueGetNativeHandle.cpp 13 | urQueueRetain.cpp 14 | urQueueRelease.cpp) 15 | -------------------------------------------------------------------------------- /test/layers/validation/lit.local.cfg.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (C) 2025 Intel Corporation 3 | 4 | Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 5 | See LICENSE.TXT 6 | SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7 | 8 | """ 9 | 10 | config.suffixes = [".cpp"] 11 | 12 | config.substitutions.append( 13 | ( 14 | r"%validate", 15 | r"UR_ENABLE_LAYERS=UR_LAYER_FULL_VALIDATION UR_LOG_VALIDATION=level:debug\;flush:debug\;output:stdout", 16 | ) 17 | ) 18 | -------------------------------------------------------------------------------- /test/loader/loader_config/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | add_gtest_test(loader-config 7 | urLoaderConfigCreate.cpp 8 | urLoaderConfigGetInfo.cpp 9 | urLoaderConfigEnableLayer.cpp 10 | urLoaderConfigRelease.cpp 11 | urLoaderConfigRetain.cpp 12 | urLoaderConfigSetCodeLocationCallback.cpp 13 | ) 14 | -------------------------------------------------------------------------------- /test/unit/helpers.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef UR_UNIT_TEST_HELPERS_H 8 | #define UR_UNIT_TEST_HELPERS_H 1 9 | 10 | #if defined(_WIN32) 11 | #define setenv(name, value, overwrite) _putenv_s(name, value) 12 | #define unsetenv(name) _putenv_s(name, "") 13 | #endif 14 | 15 | #endif /* UR_UNIT_TEST_HELPERS_H */ 16 | -------------------------------------------------------------------------------- /source/adapters/native_cpu/adapter.hpp: -------------------------------------------------------------------------------- 1 | //===---------------- adapter.hpp - Native CPU Adapter --------------------===// 2 | // 3 | // Copyright (C) 2024 Intel Corporation 4 | // 5 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | // Exceptions. See LICENSE.TXT 7 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 8 | // 9 | //===----------------------------------------------------------------------===// 10 | 11 | struct ur_adapter_handle_t_; 12 | 13 | extern ur_adapter_handle_t_ Adapter; 14 | -------------------------------------------------------------------------------- /source/mock/ur_mock_helpers.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (C) 2024 Intel Corporation 4 | * 5 | * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | * Exceptions. See LICENSE.TXT 7 | * 8 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 9 | * 10 | * @file ur_mock_helpers.cpp 11 | * 12 | */ 13 | 14 | #include "ur_mock_helpers.hpp" 15 | 16 | namespace mock { 17 | static callbacks_t callbacks = {}; 18 | 19 | callbacks_t &getCallbacks() { return callbacks; } 20 | 21 | } // namespace mock 22 | -------------------------------------------------------------------------------- /test/conformance/context/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | add_conformance_devices_test(context 7 | urContextCreate.cpp 8 | urContextCreateWithNativeHandle.cpp 9 | urContextGetInfo.cpp 10 | urContextGetNativeHandle.cpp 11 | urContextRelease.cpp 12 | urContextRetain.cpp 13 | urContextSetExtendedDeleter.cpp) 14 | -------------------------------------------------------------------------------- /test/conformance/event/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | add_conformance_devices_test(event 7 | urEventGetInfo.cpp 8 | urEventGetProfilingInfo.cpp 9 | urEventWait.cpp 10 | urEventRetain.cpp 11 | urEventRelease.cpp 12 | urEventGetNativeHandle.cpp 13 | urEventCreateWithNativeHandle.cpp 14 | urEventSetCallback.cpp) 15 | -------------------------------------------------------------------------------- /test/conformance/usm/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | add_conformance_kernels_test(usm 7 | urUSMDeviceAlloc.cpp 8 | urUSMFree.cpp 9 | urUSMGetMemAllocInfo.cpp 10 | urUSMHostAlloc.cpp 11 | urUSMPoolCreate.cpp 12 | urUSMPoolGetInfo.cpp 13 | urUSMPoolRelease.cpp 14 | urUSMPoolRetain.cpp 15 | urUSMSharedAlloc.cpp) 16 | -------------------------------------------------------------------------------- /scripts/README.md: -------------------------------------------------------------------------------- 1 | Python dependencies: 2 | * Python v3.6.6 or later 3 | * [Mako Templates for Python](https://www.makotemplates.org/) v1.0.7 4 | * [PyYAML](https://pyyaml.org/) v3.13 5 | * [Sphinx](https://www.sphinx-doc.org/en/master/) v2.2.2 6 | 7 | To install all Python dependencies, execute: 8 | ```bash 9 | $ python -m pip install -r ../third_party/requirements.txt 10 | ``` 11 | 12 | Documentation is generated from source code using Doxygen. 13 | * [Doxygen](http://www.doxygen.nl/) v1.8.15 14 | * [MiKTex](https://miktex.org/) v2.9.6930 15 | -------------------------------------------------------------------------------- /test/adapters/hip/lit.cfg.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (C) 2025 Intel Corporation 3 | 4 | Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 5 | See LICENSE.TXT 6 | SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7 | 8 | """ 9 | 10 | import lit.formats 11 | 12 | config.name = "Unified Runtime Adapter (HIP)" 13 | config.test_format = lit.formats.GoogleTest("", "-test") 14 | config.test_source_root = config.binary_dir 15 | config.test_exec_root = config.binary_dir 16 | 17 | config.environment["ONEAPI_DEVICE_SELECTOR"] = "hip:*" 18 | -------------------------------------------------------------------------------- /test/adapters/cuda/lit.cfg.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (C) 2025 Intel Corporation 3 | 4 | Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 5 | See LICENSE.TXT 6 | SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7 | 8 | """ 9 | 10 | import lit.formats 11 | 12 | config.name = "Unified Runtime Adapter (CUDA)" 13 | config.test_format = lit.formats.GoogleTest("", "-test") 14 | config.test_source_root = config.binary_dir 15 | config.test_exec_root = config.binary_dir 16 | 17 | config.environment["ONEAPI_DEVICE_SELECTOR"] = "cuda:*" 18 | -------------------------------------------------------------------------------- /test/fuzz/lit.local.cfg.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (C) 2025 Intel Corporation 3 | 4 | Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 5 | See LICENSE.TXT 6 | SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7 | 8 | """ 9 | 10 | config.substitutions.append( 11 | ( 12 | r"%fuzz-options", 13 | " ".join( 14 | [ 15 | "NEOReadDebugKeys=1" 16 | "DisableDeepBind=1" 17 | "UBSAN_OPTIONS=print_stacktrace=1" 18 | ] 19 | ), 20 | ) 21 | ) 22 | -------------------------------------------------------------------------------- /.github/scripts/install_hwloc.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright (C) 2024 Intel Corporation 4 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 5 | # See LICENSE.TXT 6 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7 | 8 | # install_hwloc.sh - Script for building and installing HWLOC library from source code 9 | 10 | set -e 11 | 12 | git clone -b hwloc-2.3.0 https://github.com/open-mpi/hwloc.git 13 | pushd hwloc 14 | ./autogen.sh 15 | ./configure 16 | make -j$(nproc) 17 | sudo make install -j$(nproc) 18 | popd 19 | -------------------------------------------------------------------------------- /test/conformance/device_code/bar.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include 8 | 9 | int main() { 10 | sycl::queue deviceQueue; 11 | sycl::range<1> numOfItems{1}; 12 | 13 | deviceQueue.submit([&](sycl::handler &cgh) { 14 | auto kern = [=](sycl::id<1>) {}; 15 | cgh.parallel_for(numOfItems, kern); 16 | }); 17 | 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /test/conformance/device_code/foo.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include 8 | 9 | int main() { 10 | sycl::queue deviceQueue; 11 | sycl::range<1> numOfItems{1}; 12 | 13 | deviceQueue.submit([&](sycl::handler &cgh) { 14 | auto kern = [=](sycl::id<1>) {}; 15 | cgh.parallel_for(numOfItems, kern); 16 | }); 17 | 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # Run dependencies versions update 2 | version: 2 3 | updates: 4 | - package-ecosystem: "pip" 5 | directory: "/third_party" # Location of package manifests 6 | schedule: 7 | interval: "daily" 8 | # Run only required security updates 9 | open-pull-requests-limit: 0 10 | 11 | - package-ecosystem: "github-actions" 12 | directory: "/.github/workflows/" 13 | schedule: 14 | interval: "monthly" 15 | groups: 16 | actions-dependencies: 17 | applies-to: version-updates 18 | patterns: 19 | - "*" 20 | -------------------------------------------------------------------------------- /source/mock/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2024 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | add_ur_library(ur_mock SHARED 7 | "${CMAKE_CURRENT_SOURCE_DIR}/ur_mock_helpers.cpp" 8 | ) 9 | target_include_directories(ur_mock 10 | INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}" 11 | ) 12 | 13 | target_link_libraries(ur_mock PRIVATE 14 | ${PROJECT_NAME}::headers 15 | ) 16 | 17 | add_library(${PROJECT_NAME}::mock ALIAS ur_mock) 18 | -------------------------------------------------------------------------------- /test/adapters/lit.local.cfg.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (C) 2025 Intel Corporation 3 | 4 | Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 5 | See LICENSE.TXT 6 | SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7 | 8 | """ 9 | 10 | # Skip adapter testing for adapters that have not been built 11 | if "cuda" not in config.adapters_built: 12 | config.excludes.add("cuda") 13 | if "hip" not in config.adapters_built: 14 | config.excludes.add("hip") 15 | if "level_zero" not in config.adapters_built: 16 | config.excludes.add("level_zero") 17 | -------------------------------------------------------------------------------- /test/conformance/device_code/no_args.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include 8 | 9 | int main() { 10 | sycl::queue sycl_queue; 11 | sycl_queue.submit([&](sycl::handler &cgh) { 12 | cgh.parallel_for( 13 | sycl::range<3>{128, 128, 128}, 14 | [](sycl::item<3> itemId) { itemId.get_id(0); }); 15 | }); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /source/common/backtrace.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023-2025 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | #ifndef UR_BACKTRACE_H 7 | #define UR_BACKTRACE_H 1 8 | 9 | #include 10 | #include 11 | 12 | #define MAX_BACKTRACE_FRAMES 64 13 | 14 | namespace ur { 15 | 16 | using BacktraceLine = std::string; 17 | std::vector getCurrentBacktrace(); 18 | 19 | } // namespace ur 20 | 21 | #endif /* UR_BACKTRACE_H */ 22 | -------------------------------------------------------------------------------- /source/loader/layers/sanitizer/asan/asan_ddi.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (C) 2024 Intel Corporation 4 | * 5 | * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | * Exceptions. See LICENSE.TXT 7 | * 8 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 9 | * 10 | * @file asan_ddi.hpp 11 | * 12 | */ 13 | 14 | #include "ur_ddi.h" 15 | 16 | namespace ur_sanitizer_layer { 17 | 18 | void initAsanInterceptor(); 19 | void destroyAsanInterceptor(); 20 | 21 | ur_result_t initAsanDDITable(ur_dditable_t *dditable); 22 | 23 | } // namespace ur_sanitizer_layer 24 | -------------------------------------------------------------------------------- /source/loader/layers/sanitizer/tsan/tsan_ddi.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (C) 2025 Intel Corporation 4 | * 5 | * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | * Exceptions. See LICENSE.TXT 7 | * 8 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 9 | * 10 | * @file tsan_ddi.hpp 11 | * 12 | */ 13 | 14 | #include "ur_ddi.h" 15 | 16 | namespace ur_sanitizer_layer { 17 | 18 | void initTsanInterceptor(); 19 | void destroyTsanInterceptor(); 20 | 21 | ur_result_t initTsanDDITable(ur_dditable_t *dditable); 22 | 23 | } // namespace ur_sanitizer_layer 24 | -------------------------------------------------------------------------------- /test/loader/loader_lifetime/urLoaderTearDown.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022-2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | #include "fixtures.hpp" 7 | 8 | struct urLoaderTearDownTest : testing::Test { 9 | void SetUp() override { 10 | ur_device_init_flags_t device_flags = 0; 11 | ASSERT_SUCCESS(urLoaderInit(device_flags, nullptr)); 12 | } 13 | }; 14 | 15 | TEST_F(urLoaderTearDownTest, Success) { ASSERT_SUCCESS(urLoaderTearDown()); } 16 | -------------------------------------------------------------------------------- /test/conformance/exp_graph/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2025 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | add_conformance_devices_test(exp_graph 7 | urEnqueueGraphExp.cpp 8 | urGraphCreateExp.cpp 9 | urGraphDestroyExp.cpp 10 | urGraphInstantiateGraphExp.cpp 11 | urGraphIsEmptyExp.cpp 12 | urQueueBeginCaptureIntoGraphExp.cpp 13 | urQueueBeginGraphCaptureExp.cpp 14 | urQueueEndGraphCaptureExp.cpp 15 | urQueueIsGraphCaptureEnabledExp.cpp) 16 | -------------------------------------------------------------------------------- /test/conformance/device/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | add_conformance_devices_test(device 7 | urDeviceCreateWithNativeHandle.cpp 8 | urDeviceGet.cpp 9 | urDeviceGetGlobalTimestamps.cpp 10 | urDeviceGetInfo.cpp 11 | urDeviceGetNativeHandle.cpp 12 | urDeviceGetSelected.cpp 13 | urDevicePartition.cpp 14 | urDeviceRelease.cpp 15 | urDeviceRetain.cpp 16 | urDeviceSelectBinary.cpp) 17 | -------------------------------------------------------------------------------- /test/conformance/testing/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022-2023 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | add_ur_library(ur_testing STATIC 7 | source/utils.cpp 8 | source/fixtures.cpp) 9 | target_include_directories(ur_testing PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) 10 | target_link_libraries(ur_testing PRIVATE 11 | gtest_main 12 | ${PROJECT_NAME}::common 13 | ${PROJECT_NAME}::headers) 14 | add_library(${PROJECT_NAME}::testing ALIAS ur_testing) 15 | -------------------------------------------------------------------------------- /source/common/ur_filesystem_resolved.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef UR_FILESYSTEM_RESOLVED_HPP 8 | #define UR_FILESYSTEM_RESOLVED_HPP 1 9 | 10 | #if __has_include() 11 | #include 12 | namespace filesystem = std::filesystem; 13 | #else 14 | #include 15 | namespace filesystem = std::experimental::filesystem; 16 | #endif 17 | 18 | #endif /* UR_FILESYSTEM_RESOLVED_HPP */ 19 | -------------------------------------------------------------------------------- /test/conformance/device_code/inc.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include 8 | 9 | class inc; 10 | 11 | int main() { 12 | uint32_t *ptr; 13 | sycl::buffer buf{ptr, 1}; 14 | sycl::queue{}.submit([&](sycl::handler &cgh) { 15 | sycl::accessor acc{buf, cgh}; 16 | auto kernel = [acc](sycl::item<1> it) { acc[it]++; }; 17 | cgh.parallel_for(sycl::range<1>{1}, kernel); 18 | }); 19 | } 20 | -------------------------------------------------------------------------------- /test/layers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | add_ur_lit_testsuite(layers DEPENDS 7 | ur_adapter_mock 8 | hello_world) 9 | 10 | add_subdirectory(validation) 11 | 12 | if(UR_ENABLE_TRACING) 13 | add_subdirectory(tracing) 14 | add_dependencies(deps_check-unified-runtime-layers ur_collector test_collector collector xptifw) 15 | endif() 16 | 17 | if(UR_ENABLE_SANITIZER) 18 | add_subdirectory(sanitizer) 19 | endif() 20 | -------------------------------------------------------------------------------- /test/adapters/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023-2024 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | add_custom_target(check-unified-runtime-adapter) 7 | 8 | if(UR_BUILD_ADAPTER_CUDA OR UR_BUILD_ADAPTER_ALL) 9 | add_subdirectory(cuda) 10 | endif() 11 | 12 | if(UR_BUILD_ADAPTER_HIP OR UR_BUILD_ADAPTER_ALL) 13 | add_subdirectory(hip) 14 | endif() 15 | 16 | if(UR_BUILD_ADAPTER_L0 OR UR_BUILD_ADAPTER_L0_V2 OR UR_BUILD_ADAPTER_ALL) 17 | add_subdirectory(level_zero) 18 | endif() 19 | -------------------------------------------------------------------------------- /test/conformance/device_code/build_failure.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include 8 | 9 | int main() { 10 | sycl::queue deviceQueue; 11 | 12 | auto Kernel = []() { 13 | #ifdef __SYCL_DEVICE_ONLY__ 14 | asm volatile("undefined\n"); 15 | #endif // __SYCL_DEVICE_ONLY__ 16 | }; 17 | 18 | deviceQueue.submit( 19 | [&](sycl::handler &cgh) { cgh.single_task(Kernel); }); 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /tools/urinfo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | add_ur_executable(urinfo 7 | urinfo.hpp 8 | utils.hpp 9 | urinfo.cpp 10 | ) 11 | target_compile_definitions(urinfo PRIVATE 12 | UR_VERSION="${PROJECT_VERSION}" 13 | ) 14 | target_include_directories(urinfo PRIVATE 15 | ${PROJECT_SOURCE_DIR}/source/common 16 | ) 17 | target_link_libraries(urinfo PRIVATE 18 | ${PROJECT_NAME}::headers 19 | ${PROJECT_NAME}::loader 20 | ) 21 | -------------------------------------------------------------------------------- /source/adapters/level_zero/ur_level_zero.cpp: -------------------------------------------------------------------------------- 1 | //===--------- ur_level_zero.cpp - Level Zero Adapter ---------------------===// 2 | // 3 | // Copyright (C) 2023 Intel Corporation 4 | // 5 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | // Exceptions. See LICENSE.TXT 7 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 8 | // 9 | //===----------------------------------------------------------------------===// 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #include "ur_level_zero.hpp" 16 | 17 | // Define the static class field 18 | std::mutex ZeCall::GlobalLock; 19 | -------------------------------------------------------------------------------- /source/adapters/native_cpu/physical_mem.hpp: -------------------------------------------------------------------------------- 1 | //===---------- physical_mem.hpp - NATIVE CPU Adapter ---------------------===// 2 | // 3 | // Copyright (C) 2023 Intel Corporation 4 | // 5 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | // Exceptions. See LICENSE.TXT 7 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 8 | // 9 | //===----------------------------------------------------------------------===// 10 | #pragma once 11 | 12 | /// UR queue mapping on physical memory allocations used in virtual memory 13 | /// management. 14 | /// TODO: Implement. 15 | /// 16 | struct ur_physical_mem_handle_t_ {}; 17 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | Intel is committed to rapidly addressing security vulnerabilities affecting our customers 4 | and providing clear guidance on the solution, impact, severity and mitigation. 5 | 6 | ## Report a Vulnerability 7 | 8 | Please report security issues or vulnerabilities to the [Intel Security Center]. 9 | 10 | For more information on how Intel works to resolve security issues, see [Vulnerability Handling Guidelines]. 11 | 12 | [Intel Security Center]:https://www.intel.com/security 13 | 14 | [Vulnerability Handling Guidelines]:https://www.intel.com/content/www/us/en/security-center/vulnerability-handling-guidelines.html 15 | -------------------------------------------------------------------------------- /test/conformance/memory/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | add_conformance_devices_test(memory 7 | urMemBufferCreate.cpp 8 | urMemBufferCreateWithNativeHandle.cpp 9 | urMemBufferPartition.cpp 10 | urMemGetInfo.cpp 11 | urMemGetNativeHandle.cpp 12 | urMemImageCreate.cpp 13 | urMemImageCreateWithImageFormatParam.cpp 14 | urMemImageCreateWithNativeHandle.cpp 15 | urMemImageGetInfo.cpp 16 | urMemRelease.cpp 17 | urMemRetain.cpp) 18 | -------------------------------------------------------------------------------- /source/adapters/native_cpu/platform.hpp: -------------------------------------------------------------------------------- 1 | //===--------- platform.hpp - Native CPU Adapter --------------------------===// 2 | // 3 | // Copyright (C) 2023 Intel Corporation 4 | // 5 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | // Exceptions. See LICENSE.TXT 7 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 8 | // 9 | //===----------------------------------------------------------------------===// 10 | 11 | #pragma once 12 | 13 | #include 14 | 15 | #include "common.hpp" 16 | #include "device.hpp" 17 | 18 | struct ur_platform_handle_t_ : ur::native_cpu::handle_base { 19 | ur_device_handle_t_ TheDevice{this}; 20 | }; 21 | -------------------------------------------------------------------------------- /test/conformance/virtual_memory/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | add_conformance_devices_test(virtual_memory 7 | urPhysicalMemCreate.cpp 8 | urPhysicalMemRelease.cpp 9 | urPhysicalMemRetain.cpp 10 | urPhysicalMemGetInfo.cpp 11 | urVirtualMemFree.cpp 12 | urVirtualMemGetInfo.cpp 13 | urVirtualMemGranularityGetInfo.cpp 14 | urVirtualMemMap.cpp 15 | urVirtualMemReserve.cpp 16 | urVirtualMemSetAccess.cpp 17 | urVirtualMemUnmap.cpp 18 | ) 19 | -------------------------------------------------------------------------------- /source/loader/layers/sanitizer/tsan/tsan_report.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (C) 2025 Intel Corporation 4 | * 5 | * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | * Exceptions. See LICENSE.TXT 7 | * 8 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 9 | * 10 | * @file tsan_report.hpp 11 | * 12 | */ 13 | 14 | #pragma once 15 | 16 | #include "sanitizer_common/sanitizer_common.hpp" 17 | #include "tsan_libdevice.hpp" 18 | 19 | namespace ur_sanitizer_layer { 20 | namespace tsan { 21 | 22 | void ReportDataRace(const TsanErrorReport &Report, ur_kernel_handle_t Kernel); 23 | 24 | } // namespace tsan 25 | } // namespace ur_sanitizer_layer 26 | -------------------------------------------------------------------------------- /test/adapters/hip/urContextGetNativeHandle.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022-2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include "fixtures.h" 8 | 9 | using urHipContextGetNativeHandleTest = uur::urContextTest; 10 | UUR_INSTANTIATE_DEVICE_TEST_SUITE(urHipContextGetNativeHandleTest); 11 | 12 | TEST_P(urHipContextGetNativeHandleTest, Success) { 13 | ur_native_handle_t native_context = 0; 14 | auto status = urContextGetNativeHandle(context, &native_context); 15 | ASSERT_EQ(status, UR_RESULT_ERROR_UNSUPPORTED_FEATURE); 16 | } 17 | -------------------------------------------------------------------------------- /source/adapters/opencl/physical_mem.hpp: -------------------------------------------------------------------------------- 1 | //===---------- physical_mem.hpp - OpenCL Adapter -------------------------===// 2 | // 3 | // Copyright (C) 2023 Intel Corporation 4 | // 5 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | // Exceptions. See LICENSE.TXT 7 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 8 | // 9 | //===----------------------------------------------------------------------===// 10 | #pragma once 11 | 12 | #include "common.hpp" 13 | 14 | /// UR queue mapping on physical memory allocations used in virtual memory 15 | /// management. 16 | /// TODO: Implement. 17 | /// 18 | struct ur_physical_mem_handle_t_ : ur::opencl::handle_base {}; 19 | -------------------------------------------------------------------------------- /test/conformance/exp_graph/urGraphDestroyExp.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include "fixtures.h" 8 | 9 | using urGraphDestroyExpTest = uur::urGraphSupportedExpTest; 10 | 11 | UUR_INSTANTIATE_DEVICE_TEST_SUITE(urGraphDestroyExpTest); 12 | 13 | /* TODO: Test destroying graph with active executable graph instances. */ 14 | 15 | TEST_P(urGraphDestroyExpTest, InvalidNullHandle) { 16 | ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, 17 | urGraphDestroyExp(nullptr)); 18 | } 19 | -------------------------------------------------------------------------------- /.github/docker/install_libbacktrace.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright (C) 2023 Intel Corporation 3 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 4 | # See LICENSE.TXT 5 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | # 8 | # install_libbacktrace.sh - builds and installs tracing library 9 | # 10 | 11 | set -e 12 | 13 | if [ "${SKIP_LIBBACKTRACE_BUILD}" ]; then 14 | echo "Variable 'SKIP_LIBBACKTRACE_BUILD' is set; skipping building libbacktrace" 15 | exit 16 | fi 17 | 18 | git clone https://github.com/ianlancetaylor/libbacktrace.git 19 | pushd libbacktrace 20 | ./configure 21 | make -j$(nproc) 22 | make install -j$(nproc) 23 | popd 24 | -------------------------------------------------------------------------------- /test/conformance/exp_enqueue_native/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2024 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | if (UR_BUILD_ADAPTER_CUDA) 7 | add_conformance_kernels_test( 8 | exp_enqueue_native 9 | enqueue_native_cuda.cpp 10 | ) 11 | target_include_directories(exp_enqueue_native-test PRIVATE 12 | ${PROJECT_SOURCE_DIR}/source 13 | ${PROJECT_SOURCE_DIR}/source/adapters/cuda 14 | ) 15 | target_link_libraries(exp_enqueue_native-test PRIVATE cudadrv) 16 | endif() 17 | 18 | # TODO: Add more tests for different triples 19 | -------------------------------------------------------------------------------- /test/conformance/device_code/multiply.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include 8 | 9 | int main() { 10 | 11 | const size_t inputSize = 1; 12 | sycl::queue sycl_queue; 13 | uint32_t *inputArray = sycl::malloc_shared(inputSize, sycl_queue); 14 | 15 | sycl_queue.submit([&](sycl::handler &cgh) { 16 | cgh.parallel_for( 17 | sycl::range<1>(inputSize), 18 | [=](sycl::id<1> itemID) { inputArray[itemID] *= 2; }); 19 | }); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /test/conformance/device_code/increment.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include 8 | 9 | int main() { 10 | 11 | const size_t inputSize = 1; 12 | sycl::queue sycl_queue; 13 | uint32_t *inputArray = sycl::malloc_shared(inputSize, sycl_queue); 14 | 15 | sycl_queue.submit([&](sycl::handler &cgh) { 16 | cgh.parallel_for( 17 | sycl::range<1>(inputSize), 18 | [=](sycl::id<1> itemID) { inputArray[itemID] += 1; }); 19 | }); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /source/adapters/level_zero/external/driver_experimental/zex_api.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022-2025 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | */ 7 | 8 | #ifndef _ZEX_API_H 9 | #define _ZEX_API_H 10 | #if defined(__cplusplus) 11 | #pragma once 12 | #endif 13 | 14 | // 'core' API headers 15 | #include "level_zero/ze_stypes.h" 16 | #include 17 | // 'sysman' API headers 18 | #include 19 | 20 | // driver experimental API headers 21 | #include "zex_cmdlist.h" 22 | #include "zex_context.h" 23 | #include "zex_driver.h" 24 | #include "zex_event.h" 25 | #include "zex_graph.h" 26 | #include "zex_memory.h" 27 | #include "zex_module.h" 28 | 29 | #endif // _ZEX_API_H 30 | -------------------------------------------------------------------------------- /source/loader/ur_adapter_search.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (C) 2023 Intel Corporation 4 | * 5 | * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | * Exceptions. See LICENSE.TXT 7 | * 8 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 9 | * 10 | */ 11 | 12 | #ifndef UR_ADAPTER_SEARCH_HPP 13 | #define UR_ADAPTER_SEARCH_HPP 1 14 | 15 | #include 16 | 17 | #include "ur_filesystem_resolved.hpp" 18 | 19 | namespace fs = filesystem; 20 | 21 | namespace ur_loader { 22 | 23 | std::optional getLoaderLibPath(); 24 | std::optional getAdapterNameAsPath(std::string adapterName); 25 | 26 | } // namespace ur_loader 27 | 28 | #endif /* UR_ADAPTER_SEARCH_HPP */ 29 | -------------------------------------------------------------------------------- /examples/hello_world/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | set(TARGET_NAME hello_world) 7 | 8 | add_ur_executable(${TARGET_NAME} 9 | ${CMAKE_CURRENT_SOURCE_DIR}/hello_world.cpp 10 | ) 11 | 12 | if(MSVC) 13 | set_target_properties(${TARGET_NAME} 14 | PROPERTIES 15 | VS_DEBUGGER_COMMAND_ARGUMENTS "" 16 | VS_DEBUGGER_WORKING_DIRECTORY "$(OutDir)" 17 | ) 18 | endif() 19 | 20 | target_link_libraries(${TARGET_NAME} PRIVATE 21 | ${PROJECT_NAME}::loader 22 | ${CMAKE_DL_LIBS} 23 | ${PROJECT_NAME}::headers 24 | ) 25 | -------------------------------------------------------------------------------- /source/loader/layers/sanitizer/msan/msan_report.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (C) 2024 Intel Corporation 4 | * 5 | * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | * Exceptions. See LICENSE.TXT 7 | * 8 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 9 | * 10 | * @file msan_report.hpp 11 | * 12 | */ 13 | 14 | #pragma once 15 | 16 | #include "ur_api.h" 17 | 18 | namespace ur_sanitizer_layer { 19 | 20 | struct MsanErrorReport; 21 | 22 | namespace msan { 23 | 24 | // Abort the program if the return value is true 25 | bool ReportUsesUninitializedValue(const MsanErrorReport &Report, 26 | ur_kernel_handle_t Kernel); 27 | 28 | } // namespace msan 29 | } // namespace ur_sanitizer_layer 30 | -------------------------------------------------------------------------------- /test/adapters/cuda/raii.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022-2024 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef UR_TEST_CONFORMANCE_ADAPTERS_CUDA_RAII_H_INCLUDED 8 | #define UR_TEST_CONFORMANCE_ADAPTERS_CUDA_RAII_H_INCLUDED 9 | 10 | #include "uur/raii.h" 11 | #include 12 | 13 | struct RAIICUevent { 14 | CUevent handle = nullptr; 15 | 16 | ~RAIICUevent() { 17 | if (handle) { 18 | cuEventDestroy(handle); 19 | } 20 | } 21 | 22 | CUevent *ptr() { return &handle; } 23 | CUevent get() { return handle; } 24 | }; 25 | 26 | #endif // UR_TEST_CONFORMANCE_ADAPTERS_CUDA_RAII_H_INCLUDED 27 | -------------------------------------------------------------------------------- /source/loader/layers/sanitizer/msan/msan_allocator.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (C) 2024 Intel Corporation 4 | * 5 | * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | * Exceptions. See LICENSE.TXT 7 | * 8 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 9 | * 10 | * @file msan_allocator.cpp 11 | * 12 | */ 13 | 14 | #include "msan_allocator.hpp" 15 | #include "ur_sanitizer_layer.hpp" 16 | 17 | namespace ur_sanitizer_layer { 18 | namespace msan { 19 | 20 | void MsanAllocInfo::print() { 21 | UR_LOG_L(getContext()->logger, INFO, "AllocInfo(Alloc=[{}-{}), AllocSize={})", 22 | (void *)AllocBegin, (void *)(AllocBegin + AllocSize), AllocSize); 23 | } 24 | 25 | } // namespace msan 26 | } // namespace ur_sanitizer_layer 27 | -------------------------------------------------------------------------------- /.github/docker/install_dpcpp.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright (C) 2023-2024 Intel Corporation 3 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 4 | # See LICENSE.TXT 5 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | # 8 | # install_dpcpp.sh - unpacks DPC++ in ${DPCPP_PATH}, to be used while building UR 9 | # 10 | 11 | set -e 12 | 13 | if [ "${SKIP_DPCPP_BUILD}" ]; then 14 | echo "Variable 'SKIP_DPCPP_BUILD' is set; skipping building DPC++" 15 | exit 16 | fi 17 | 18 | mkdir -p ${DPCPP_PATH}/dpcpp_compiler 19 | wget -O ${DPCPP_PATH}/dpcpp_compiler.tar.gz https://github.com/intel/llvm/releases/download/nightly-2024-12-12/sycl_linux.tar.gz 20 | tar -xvf ${DPCPP_PATH}/dpcpp_compiler.tar.gz -C ${DPCPP_PATH}/dpcpp_compiler 21 | -------------------------------------------------------------------------------- /source/adapters/native_cpu/device.hpp: -------------------------------------------------------------------------------- 1 | //===--------- device.hpp - Native CPU Adapter ----------------------------===// 2 | // 3 | // Copyright (C) 2023 Intel Corporation 4 | // 5 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | // Exceptions. See LICENSE.TXT 7 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 8 | // 9 | //===----------------------------------------------------------------------===// 10 | 11 | #pragma once 12 | 13 | #include "common.hpp" 14 | #include "threadpool.hpp" 15 | #include 16 | 17 | struct ur_device_handle_t_ : ur::native_cpu::handle_base { 18 | native_cpu::threadpool_t tp; 19 | ur_device_handle_t_(ur_platform_handle_t ArgPlt); 20 | 21 | const uint64_t mem_size; 22 | ur_platform_handle_t Platform; 23 | }; 24 | -------------------------------------------------------------------------------- /test/layers/validation/parameters.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | // COM: This test doesn't have any filecheck rules 8 | // RUN: %use-mock %validate parameters-test 9 | 10 | #include "fixtures.hpp" 11 | 12 | TEST_F(valPlatformsTest, testUrPlatformGetApiVersion) { 13 | ur_api_version_t api_version = {}; 14 | 15 | ASSERT_EQ(urPlatformGetApiVersion(nullptr, &api_version), 16 | UR_RESULT_ERROR_INVALID_NULL_HANDLE); 17 | 18 | for (auto p : platforms) { 19 | ASSERT_EQ(urPlatformGetApiVersion(p, nullptr), 20 | UR_RESULT_ERROR_INVALID_NULL_POINTER); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test/logger/env_var.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include "fixtures.hpp" 8 | 9 | ////////////////////////////////////////////////////////////////////////////// 10 | TEST_F(LoggerFromEnvVar, DebugMessage) { 11 | UR_LOG(DEBUG, "Test message: {}", "success"); 12 | } 13 | 14 | TEST_F(LoggerFromEnvVar, InfoMessage) { 15 | UR_LOG(INFO, "Test message: {}", "success"); 16 | } 17 | 18 | TEST_F(LoggerFromEnvVar, WarningMessage) { 19 | UR_LOG(WARN, "Test message: {}", "success"); 20 | } 21 | 22 | TEST_F(LoggerFromEnvVar, ErrorMessage) { 23 | UR_LOG(ERR, "Test message: {}", "success"); 24 | } 25 | -------------------------------------------------------------------------------- /test/tools/urtrace/no_args.test: -------------------------------------------------------------------------------- 1 | RUN: %trace --no-args hello_world | FileCheck %s 2 | 3 | REQUIRES: tracing 4 | 5 | CHECK: Platform initialized. 6 | CHECK-NEXT: urAdapterGet(...) -> UR_RESULT_SUCCESS; 7 | CHECK-NEXT: urAdapterGet(...) -> UR_RESULT_SUCCESS; 8 | CHECK-NEXT: urPlatformGet(...) -> UR_RESULT_SUCCESS; 9 | CHECK-NEXT: urPlatformGet(...) -> UR_RESULT_SUCCESS; 10 | CHECK-NEXT: urPlatformGetApiVersion(...) -> UR_RESULT_SUCCESS; 11 | CHECK-NEXT: API version: {{.*}} 12 | CHECK-NEXT: urDeviceGet(...) -> UR_RESULT_SUCCESS; 13 | CHECK-NEXT: urDeviceGet(...) -> UR_RESULT_SUCCESS; 14 | CHECK-NEXT: urDeviceGetInfo(...) -> UR_RESULT_SUCCESS; 15 | CHECK-NEXT: urDeviceGetInfo(...) -> UR_RESULT_SUCCESS; 16 | CHECK-NEXT: Found a Mock Device gpu. 17 | CHECK-NEXT: urAdapterRelease(...) -> UR_RESULT_SUCCESS; 18 | -------------------------------------------------------------------------------- /test/adapters/cuda/fixtures.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022-2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef UR_TEST_CONFORMANCE_ADAPTERS_CUDA_FIXTURES_H_INCLUDED 8 | #define UR_TEST_CONFORMANCE_ADAPTERS_CUDA_FIXTURES_H_INCLUDED 9 | #include 10 | #include 11 | 12 | #ifndef ASSERT_SUCCESS_CUDA 13 | #define ASSERT_SUCCESS_CUDA(ACTUAL) ASSERT_EQ(CUDA_SUCCESS, (ACTUAL)) 14 | #endif // ASSERT_SUCCESS_CUDA 15 | 16 | #ifndef EXPECT_SUCCESS_CUDA 17 | #define EXPECT_SUCCESS_CUDA(ACTUAL) EXPECT_EQ(CUDA_SUCCESS, (ACTUAL)) 18 | #endif // EXPECT_EQ_RESULT_CUDA 19 | 20 | #endif // UR_TEST_CONFORMANCE_ADAPTERS_CUDA_FIXTURES_H_INCLUDED 21 | -------------------------------------------------------------------------------- /test/adapters/cuda/urContextGetNativeHandle.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022-2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include "fixtures.h" 8 | 9 | using urCudaContextGetNativeHandle = uur::urContextTest; 10 | UUR_INSTANTIATE_DEVICE_TEST_SUITE(urCudaContextGetNativeHandle); 11 | 12 | TEST_P(urCudaContextGetNativeHandle, Success) { 13 | ur_native_handle_t native_context = 0; 14 | ASSERT_SUCCESS(urContextGetNativeHandle(context, &native_context)); 15 | CUcontext cuda_context = reinterpret_cast(native_context); 16 | 17 | unsigned int cudaVersion; 18 | ASSERT_SUCCESS_CUDA(cuCtxGetApiVersion(cuda_context, &cudaVersion)); 19 | } 20 | -------------------------------------------------------------------------------- /test/adapters/hip/fixtures.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022-2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef UR_TEST_CONFORMANCE_ADAPTERS_HIP_FIXTURES_H_INCLUDED 8 | #define UR_TEST_CONFORMANCE_ADAPTERS_HIP_FIXTURES_H_INCLUDED 9 | #include 10 | #include 11 | 12 | #ifndef ASSERT_SUCCESS_HIP 13 | #define ASSERT_SUCCESS_HIP(ACTUAL) ASSERT_EQ(hipSuccess, (ACTUAL)) 14 | #endif // ASSERT_SUCCESS_HIP 15 | 16 | #ifndef EXPECT_SUCCESS_HIP 17 | #define EXPECT_SUCCESS_HIP(ACTUAL) EXPECT_EQ(hipSuccess, (ACTUAL)) 18 | #endif // EXPECT_EQ_RESULT_HIP 19 | 20 | #endif // UR_TEST_CONFORMANCE_ADAPTERS_HIP_FIXTURES_H_INCLUDED 21 | -------------------------------------------------------------------------------- /cmake/FindRocmAgentEnumerator.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | # 7 | # FindRocmAgentEnumerator.cmake -- module searching for rocm_agent_enumerator. 8 | # ROCM_AGENT_ENUMERATOR_FOUND is set to true if 9 | # rocm_agent_enumerator is found. 10 | # 11 | 12 | find_program(ROCM_AGENT_ENUMERATOR NAMES rocm_agent_enumerator PATHS /opt/rocm/bin) 13 | 14 | if(ROCM_AGENT_ENUMERATOR) 15 | set(ROCM_AGENT_ENUMERATOR_FOUND TRUE) 16 | endif() 17 | 18 | include(FindPackageHandleStandardArgs) 19 | find_package_handle_standard_args(RocmAgentEnumerator DEFAULT_MSG ROCM_AGENT_ENUMERATOR) 20 | -------------------------------------------------------------------------------- /examples/collector/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | set(TARGET_NAME collector) 7 | 8 | add_ur_library(${TARGET_NAME} SHARED 9 | ${CMAKE_CURRENT_SOURCE_DIR}/collector.cpp 10 | ) 11 | 12 | target_include_directories(${TARGET_NAME} PRIVATE 13 | ${PROJECT_SOURCE_DIR}/include 14 | ) 15 | 16 | target_link_libraries(${TARGET_NAME} PRIVATE ${TARGET_XPTI}) 17 | target_include_directories(${TARGET_NAME} PRIVATE ${xpti_SOURCE_DIR}/include) 18 | 19 | if(MSVC) 20 | target_compile_definitions(${TARGET_NAME} PRIVATE XPTI_STATIC_LIBRARY) 21 | endif() 22 | target_compile_definitions(${TARGET_NAME} PRIVATE XPTI_CALLBACK_API_EXPORTS) 23 | -------------------------------------------------------------------------------- /test/adapters/hip/kernel_tests.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include "kernel.hpp" 8 | #include "uur/fixtures.h" 9 | #include "uur/raii.h" 10 | 11 | using hipKernelTest = uur::urKernelExecutionTest; 12 | UUR_INSTANTIATE_DEVICE_TEST_SUITE(hipKernelTest); 13 | 14 | TEST_P(hipKernelTest, URKernelArgumentLarge) { 15 | // The HIP adapter can't do proper argument validation so any kernel will 16 | // work for this test. 17 | std::array data; 18 | data.fill(0); 19 | ASSERT_EQ_RESULT(urKernelSetArgValue(kernel, 0, 4004, nullptr, data.data()), 20 | UR_RESULT_ERROR_OUT_OF_RESOURCES); 21 | } 22 | -------------------------------------------------------------------------------- /test/adapters/level_zero/memcheck.test: -------------------------------------------------------------------------------- 1 | RUN: %maybe-v1 %valgrind --tool=memcheck --leak-check=full ./link-test 2>&1 | FileCheck %s 2 | RUN: %maybe-v1 %valgrind --tool=memcheck --leak-check=full ./event_create-test 2>&1 | FileCheck %s 3 | RUN: %maybe-v1 %valgrind --tool=memcheck --leak-check=full ./kernel_create-test 2>&1 | FileCheck %s 4 | 5 | RUN: %maybe-v2 %valgrind --tool=memcheck --leak-check=full ./link-test 2>&1 | FileCheck %s 6 | RUN: %maybe-v2 %valgrind --tool=memcheck --leak-check=full ./event_create-test 2>&1 | FileCheck %s 7 | RUN: %maybe-v2 %valgrind --tool=memcheck --leak-check=full ./kernel_create-test 2>&1 | FileCheck %s 8 | 9 | REQUIRES: valgrind 10 | 11 | COM: TODO: valgrind tests require very new environment. Enable once all L0 runners are updated. 12 | XFAIL: * 13 | 14 | CHECK: ERROR SUMMARY: 0 errors from 0 contexts 15 | -------------------------------------------------------------------------------- /source/adapters/level_zero/external/driver_experimental/mcl_ext/zex_mutable_cmdlist_ext.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "level_zero/driver_experimental/mcl_ext/ze_mutable_command_list_exp.h" 11 | #include "level_zero/driver_experimental/mcl_ext/zex_mutable_cmdlist_control_flow_ext.h" 12 | #include "level_zero/driver_experimental/mcl_ext/zex_mutable_cmdlist_dispatch_ext.h" 13 | #include "level_zero/driver_experimental/mcl_ext/zex_mutable_cmdlist_serialization_ext.h" 14 | #include "level_zero/driver_experimental/mcl_ext/zex_mutable_cmdlist_temp_mem_ext.h" 15 | #include "level_zero/driver_experimental/mcl_ext/zex_mutable_cmdlist_variable_ext.h" 16 | #include "level_zero/driver_experimental/mcl_ext/zex_mutable_cmdlist_variable_info_ext.h" 17 | -------------------------------------------------------------------------------- /test/layers/tracing/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | add_ur_library(test_collector SHARED 7 | ${CMAKE_CURRENT_SOURCE_DIR}/test_collector.cpp 8 | ) 9 | 10 | target_include_directories(test_collector PRIVATE 11 | ${PROJECT_SOURCE_DIR}/include 12 | ) 13 | 14 | target_link_libraries(test_collector PRIVATE ${TARGET_XPTI}) 15 | target_include_directories(test_collector PRIVATE ${xpti_SOURCE_DIR}/include) 16 | 17 | if(MSVC) 18 | target_compile_definitions(test_collector PRIVATE XPTI_STATIC_LIBRARY) 19 | endif() 20 | target_compile_definitions(test_collector PRIVATE XPTI_CALLBACK_API_EXPORTS) 21 | 22 | add_gtest_test(codeloc codeloc.cpp) 23 | -------------------------------------------------------------------------------- /source/adapters/cuda/platform.hpp: -------------------------------------------------------------------------------- 1 | //===--------- platform.hpp - CUDA Adapter --------------------------------===// 2 | // 3 | // Copyright (C) 2023 Intel Corporation 4 | // 5 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | // Exceptions. See LICENSE.TXT 7 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 8 | // 9 | //===----------------------------------------------------------------------===// 10 | 11 | #ifndef UR_CUDA_PLATFORM_HPP_INCLUDED 12 | #define UR_CUDA_PLATFORM_HPP_INCLUDED 13 | 14 | #include "common.hpp" 15 | #include "device.hpp" 16 | #include 17 | 18 | #include 19 | #include 20 | 21 | struct ur_platform_handle_t_ : ur::cuda::handle_base { 22 | std::vector> Devices; 23 | }; 24 | 25 | #endif // UR_CUDA_PLATFORM_HPP_INCLUDED 26 | -------------------------------------------------------------------------------- /source/adapters/level_zero/v2/queue_extensions.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #pragma once 8 | 9 | #include "ur_api.h" 10 | 11 | struct ur_queue_extensions { 12 | // Non-batched queues don't need to perform any action 13 | // 14 | // This function is intended to be called by the event. If the event has been 15 | // created by the given queue and is associated with the current batch, this 16 | // batch should be enqueued for execution. Otherwise, the event would never be 17 | // signalled 18 | virtual ur_result_t 19 | onEventWaitListUse([[maybe_unused]] int64_t batch_generation) { 20 | return UR_RESULT_SUCCESS; 21 | } 22 | }; 23 | -------------------------------------------------------------------------------- /source/adapters/opencl/enqueue_native.cpp: -------------------------------------------------------------------------------- 1 | //===--------- enqueue_native.cpp - OpenCL Adapter ------------------------===// 2 | // 3 | // Copyright (C) 2024 Intel Corporation 4 | // 5 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | // Exceptions. See LICENSE.TXT 7 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 8 | // 9 | //===----------------------------------------------------------------------===// 10 | 11 | #include 12 | 13 | UR_APIEXPORT ur_result_t UR_APICALL urEnqueueNativeCommandExp( 14 | ur_queue_handle_t, ur_exp_enqueue_native_command_function_t, void *, 15 | uint32_t, const ur_mem_handle_t *, 16 | const ur_exp_enqueue_native_command_properties_t *, uint32_t, 17 | const ur_event_handle_t *, ur_event_handle_t *) { 18 | return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; 19 | } 20 | -------------------------------------------------------------------------------- /source/loader/layers/sanitizer/sanitizer_common/sanitizer_stacktrace.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (C) 2024 Intel Corporation 4 | * 5 | * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | * Exceptions. See LICENSE.TXT 7 | * 8 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 9 | * 10 | * @file sanitizer_stacktrace.hpp 11 | * 12 | */ 13 | 14 | #pragma once 15 | 16 | #include "sanitizer_common.hpp" 17 | 18 | #include 19 | 20 | namespace ur_sanitizer_layer { 21 | 22 | constexpr size_t MAX_BACKTRACE_FRAMES = 64; 23 | 24 | struct StackTrace { 25 | std::vector stack; 26 | 27 | void print() const; 28 | }; 29 | 30 | StackTrace GetCurrentBacktrace(); 31 | 32 | char **GetBacktraceSymbols(const std::vector &BacktraceFrames); 33 | 34 | } // namespace ur_sanitizer_layer 35 | -------------------------------------------------------------------------------- /test/adapters/hip/urDeviceGetNativeHandle.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022-2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include "fixtures.h" 8 | 9 | using urHipGetDeviceNativeHandle = uur::urDeviceTest; 10 | UUR_INSTANTIATE_DEVICE_TEST_SUITE(urHipGetDeviceNativeHandle); 11 | 12 | TEST_P(urHipGetDeviceNativeHandle, Success) { 13 | ur_native_handle_t native_handle; 14 | ASSERT_SUCCESS(urDeviceGetNativeHandle(device, &native_handle)); 15 | 16 | hipDevice_t hip_device; 17 | memcpy(&hip_device, &native_handle, sizeof(hip_device)); 18 | 19 | char hip_device_name[256]; 20 | ASSERT_SUCCESS_HIP( 21 | hipDeviceGetName(hip_device_name, sizeof(hip_device_name), hip_device)); 22 | } 23 | -------------------------------------------------------------------------------- /source/adapters/cuda/tracing.hpp: -------------------------------------------------------------------------------- 1 | //===--------- tracing.hpp - CUDA Host API Tracing -------------------------==// 2 | // 3 | // Copyright (C) 2023 Intel Corporation 4 | // 5 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | // Exceptions. See LICENSE.TXT 7 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 8 | // 9 | //===----------------------------------------------------------------------===// 10 | 11 | struct cuda_tracing_context_t_; 12 | 13 | cuda_tracing_context_t_ *createCUDATracingContext(); 14 | void freeCUDATracingContext(cuda_tracing_context_t_ *Ctx); 15 | 16 | bool loadCUDATracingLibrary(cuda_tracing_context_t_ *Ctx); 17 | void unloadCUDATracingLibrary(cuda_tracing_context_t_ *Ctx); 18 | 19 | void enableCUDATracing(cuda_tracing_context_t_ *Ctx); 20 | void disableCUDATracing(cuda_tracing_context_t_ *Ctx); 21 | -------------------------------------------------------------------------------- /test/adapters/cuda/urDeviceGetNativeHandle.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022-2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include "fixtures.h" 8 | 9 | using urCudaGetDeviceNativeHandle = uur::urDeviceTest; 10 | UUR_INSTANTIATE_DEVICE_TEST_SUITE(urCudaGetDeviceNativeHandle); 11 | 12 | TEST_P(urCudaGetDeviceNativeHandle, Success) { 13 | ur_native_handle_t native_handle; 14 | ASSERT_SUCCESS(urDeviceGetNativeHandle(device, &native_handle)); 15 | 16 | CUdevice cuda_device; 17 | memcpy(&cuda_device, &native_handle, sizeof(cuda_device)); 18 | 19 | char cuda_device_name[256]; 20 | ASSERT_SUCCESS_CUDA( 21 | cuDeviceGetName(cuda_device_name, sizeof(cuda_device_name), cuda_device)); 22 | } 23 | -------------------------------------------------------------------------------- /test/conformance/source/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022-2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include 8 | 9 | int main(int argc, char **argv) { 10 | #ifdef KERNELS_ENVIRONMENT 11 | auto *environment = 12 | new uur::KernelsEnvironment(argc, argv, KERNELS_DEFAULT_DIR); 13 | #elif DEVICES_ENVIRONMENT 14 | auto *environment = new uur::DevicesEnvironment(); 15 | #elif PLATFORM_ENVIRONMENT 16 | auto *environment = new uur::PlatformEnvironment(); 17 | #else 18 | auto *environment = new uur::AdapterEnvironment(); 19 | #endif 20 | ::testing::InitGoogleTest(&argc, argv); 21 | ::testing::AddGlobalTestEnvironment(environment); 22 | return RUN_ALL_TESTS(); 23 | } 24 | -------------------------------------------------------------------------------- /source/adapters/mock/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | set(TARGET_NAME ur_adapter_mock) 7 | 8 | add_ur_adapter(${TARGET_NAME} 9 | SHARED 10 | ${CMAKE_CURRENT_SOURCE_DIR}/ur_mock.hpp 11 | ${CMAKE_CURRENT_SOURCE_DIR}/ur_mock.cpp 12 | ${CMAKE_CURRENT_SOURCE_DIR}/ur_mockddi.cpp 13 | ) 14 | 15 | set_target_properties(${TARGET_NAME} PROPERTIES 16 | VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}" 17 | SOVERSION "${PROJECT_VERSION_MAJOR}" 18 | ) 19 | 20 | target_link_libraries(${TARGET_NAME} PRIVATE 21 | ${PROJECT_NAME}::headers 22 | ${PROJECT_NAME}::common 23 | ${PROJECT_NAME}::mock 24 | ) 25 | -------------------------------------------------------------------------------- /source/adapters/adapter.def.in: -------------------------------------------------------------------------------- 1 | LIBRARY @TARGET_LIBNAME@ 2 | EXPORTS 3 | urGetAdapterProcAddrTable 4 | urGetBindlessImagesExpProcAddrTable 5 | urGetCommandBufferExpProcAddrTable 6 | urGetContextProcAddrTable 7 | urGetEnqueueProcAddrTable 8 | urGetEnqueueExpProcAddrTable 9 | urGetEventProcAddrTable 10 | urGetGraphExpProcAddrTable 11 | urGetIPCExpProcAddrTable 12 | urGetKernelProcAddrTable 13 | urGetMemProcAddrTable 14 | urGetMemoryExportExpProcAddrTable 15 | urGetPhysicalMemProcAddrTable 16 | urGetPlatformProcAddrTable 17 | urGetProgramProcAddrTable 18 | urGetProgramExpProcAddrTable 19 | urGetQueueProcAddrTable 20 | urGetQueueExpProcAddrTable 21 | urGetSamplerProcAddrTable 22 | urGetUSMProcAddrTable 23 | urGetUSMExpProcAddrTable 24 | urGetUsmP2PExpProcAddrTable 25 | urGetVirtualMemProcAddrTable 26 | urGetDeviceProcAddrTable 27 | urGetDeviceExpProcAddrTable 28 | -------------------------------------------------------------------------------- /source/loader/ur_codeloc.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (C) 2023 Intel Corporation 4 | * 5 | * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | * Exceptions. See LICENSE.TXT 7 | * 8 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 9 | * 10 | * @file ur_codeloc.hpp 11 | * 12 | */ 13 | 14 | #ifndef UR_CODELOC_HPP 15 | #define UR_CODELOC_HPP 1 16 | 17 | #include "ur_api.h" 18 | #include 19 | 20 | struct codeloc_data { 21 | codeloc_data() { 22 | codelocCb = nullptr; 23 | codelocUserdata = nullptr; 24 | } 25 | ur_code_location_callback_t codelocCb; 26 | void *codelocUserdata; 27 | 28 | std::optional get_codeloc() { 29 | if (!codelocCb) { 30 | return std::nullopt; 31 | } 32 | return codelocCb(codelocUserdata); 33 | } 34 | }; 35 | 36 | #endif /* UR_CODELOC_HPP */ 37 | -------------------------------------------------------------------------------- /source/adapters/hip/physical_mem.hpp: -------------------------------------------------------------------------------- 1 | //===---------- physical_mem.hpp - HIP Adapter ----------------------------===// 2 | // 3 | // Copyright (C) 2023 Intel Corporation 4 | // 5 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | // Exceptions. See LICENSE.TXT 7 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 8 | // 9 | //===----------------------------------------------------------------------===// 10 | #pragma once 11 | 12 | #include "common.hpp" 13 | #include "common/ur_ref_count.hpp" 14 | #include "device.hpp" 15 | #include "platform.hpp" 16 | 17 | /// UR queue mapping on physical memory allocations used in virtual memory 18 | /// management. 19 | /// TODO: Implement. 20 | /// 21 | struct ur_physical_mem_handle_t_ : ur::hip::handle_base { 22 | ur::RefCount RefCount; 23 | 24 | ur_physical_mem_handle_t_() : handle_base() {} 25 | }; 26 | -------------------------------------------------------------------------------- /source/adapters/hip/platform.hpp: -------------------------------------------------------------------------------- 1 | //===--------- platform.hpp - HIP Adapter ---------------------------------===// 2 | // 3 | // Copyright (C) 2023 Intel Corporation 4 | // 5 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | // Exceptions. See LICENSE.TXT 7 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 8 | // 9 | //===----------------------------------------------------------------------===// 10 | #pragma once 11 | 12 | #include "common.hpp" 13 | #include "device.hpp" 14 | 15 | #include 16 | 17 | /// A UR platform stores all known UR devices, 18 | /// in the HIP plugin this is just a vector of 19 | /// available devices since initialization is done 20 | /// when devices are used. 21 | /// 22 | struct ur_platform_handle_t_ : ur::hip::handle_base { 23 | std::vector> Devices; 24 | }; 25 | -------------------------------------------------------------------------------- /source/loader/layers/sanitizer/asan/asan_allocator.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (C) 2024 Intel Corporation 4 | * 5 | * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | * Exceptions. See LICENSE.TXT 7 | * 8 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 9 | * 10 | * @file asan_allocator.cpp 11 | * 12 | */ 13 | 14 | #include "asan_allocator.hpp" 15 | #include "ur_sanitizer_layer.hpp" 16 | 17 | namespace ur_sanitizer_layer { 18 | namespace asan { 19 | 20 | void AllocInfo::print() { 21 | UR_LOG_L(getContext()->logger, INFO, 22 | "AllocInfo(Alloc=[{}-{}), User=[{}-{}), AllocSize={}, Type={})", 23 | (void *)AllocBegin, (void *)(AllocBegin + AllocSize), 24 | (void *)UserBegin, (void *)(UserEnd), AllocSize, ToString(Type)); 25 | } 26 | 27 | } // namespace asan 28 | } // namespace ur_sanitizer_layer 29 | -------------------------------------------------------------------------------- /test/usm/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022-2023 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | add_ur_lit_testsuite(usm) 7 | set(UR_USM_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 8 | 9 | function(add_usm_test name) 10 | set(TEST_TARGET_NAME ${name}-test) 11 | add_gtest_test(${name} 12 | ${UR_USM_TEST_DIR}/../conformance/source/environment.cpp 13 | ${UR_USM_TEST_DIR}/../conformance/source/main.cpp 14 | ${ARGN}) 15 | target_link_libraries(${TEST_TARGET_NAME} 16 | PRIVATE 17 | ${PROJECT_NAME}::umf 18 | ur_testing) 19 | target_compile_definitions(${TEST_TARGET_NAME} PRIVATE DEVICES_ENVIRONMENT) 20 | endfunction() 21 | 22 | add_usm_test(usmPoolManager usmPoolManager.cpp) 23 | -------------------------------------------------------------------------------- /test/conformance/program/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | add_conformance_kernels_test(program 7 | urProgramBuild.cpp 8 | urProgramCompile.cpp 9 | urProgramCreateWithBinary.cpp 10 | urMultiDeviceProgramCreateWithBinary.cpp 11 | urMultiDeviceProgramCreateWithIL.cpp 12 | urProgramCreateWithIL.cpp 13 | urProgramCreateWithNativeHandle.cpp 14 | urProgramGetBuildInfo.cpp 15 | urProgramGetFunctionPointer.cpp 16 | urProgramGetGlobalVariablePointer.cpp 17 | urProgramGetInfo.cpp 18 | urProgramGetNativeHandle.cpp 19 | urProgramLink.cpp 20 | urProgramRelease.cpp 21 | urProgramRetain.cpp 22 | urProgramSetSpecializationConstants.cpp) 23 | -------------------------------------------------------------------------------- /source/adapters/offload/platform.hpp: -------------------------------------------------------------------------------- 1 | //===----------- platform.hpp - LLVM Offload Adapter ---------------------===// 2 | // 3 | // Copyright (C) 2025 Intel Corporation 4 | // 5 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | // Exceptions. See LICENSE.TXT 7 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 8 | // 9 | //===----------------------------------------------------------------------===// 10 | 11 | #pragma once 12 | 13 | #include "common.hpp" 14 | #include 15 | #include 16 | #include 17 | 18 | struct ur_platform_handle_t_ : ur::offload::handle_base { 19 | ur_platform_handle_t_(ol_platform_handle_t OffloadPlatform) 20 | : handle_base(), OffloadPlatform(OffloadPlatform) {}; 21 | 22 | ol_platform_handle_t OffloadPlatform; 23 | std::vector> Devices; 24 | }; 25 | -------------------------------------------------------------------------------- /source/adapters/offload/device.hpp: -------------------------------------------------------------------------------- 1 | //===----------- device.hpp - LLVM Offload Adapter -----------------------===// 2 | // 3 | // Copyright (C) 2025 Intel Corporation 4 | // 5 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | // Exceptions. See LICENSE.TXT 7 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 8 | // 9 | //===----------------------------------------------------------------------===// 10 | 11 | #pragma once 12 | 13 | #include "common.hpp" 14 | #include 15 | #include 16 | 17 | struct ur_device_handle_t_ : ur::offload::handle_base { 18 | ur_device_handle_t_(ur_platform_handle_t Platform, 19 | ol_device_handle_t OffloadDevice) 20 | : handle_base(), Platform(Platform), OffloadDevice(OffloadDevice) {} 21 | 22 | ur_platform_handle_t Platform; 23 | ol_device_handle_t OffloadDevice; 24 | }; 25 | -------------------------------------------------------------------------------- /test/conformance/kernel/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | add_conformance_kernels_test(kernel 7 | urKernelCreate.cpp 8 | urKernelCreateWithNativeHandle.cpp 9 | urKernelGetGroupInfo.cpp 10 | urKernelGetInfo.cpp 11 | urKernelGetNativeHandle.cpp 12 | urKernelGetSubGroupInfo.cpp 13 | urKernelRelease.cpp 14 | urKernelRetain.cpp 15 | urKernelSetArgLocal.cpp 16 | urKernelSetArgMemObj.cpp 17 | urKernelSetArgPointer.cpp 18 | urKernelSetArgSampler.cpp 19 | urKernelSetArgValue.cpp 20 | urKernelSetExecInfo.cpp 21 | urKernelSetSpecializationConstants.cpp 22 | urKernelSuggestMaxCooperativeGroupCount.cpp 23 | urKernelGetSuggestedLocalWorkSize.cpp) 24 | -------------------------------------------------------------------------------- /test/loader/loader_config/fixtures.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef UR_LOADER_CONFIG_TEST_FIXTURES_H 8 | #define UR_LOADER_CONFIG_TEST_FIXTURES_H 9 | 10 | #include "ur_api.h" 11 | #include 12 | 13 | #ifndef ASSERT_SUCCESS 14 | #define ASSERT_SUCCESS(ACTUAL) ASSERT_EQ(UR_RESULT_SUCCESS, ACTUAL) 15 | #endif 16 | 17 | struct LoaderConfigTest : ::testing::Test { 18 | void SetUp() override { ASSERT_SUCCESS(urLoaderConfigCreate(&loaderConfig)); } 19 | 20 | void TearDown() override { 21 | if (loaderConfig) { 22 | ASSERT_SUCCESS(urLoaderConfigRelease(loaderConfig)); 23 | } 24 | } 25 | 26 | ur_loader_config_handle_t loaderConfig = nullptr; 27 | }; 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /scripts/templates/exp-features.rst.mako: -------------------------------------------------------------------------------- 1 | <% 2 | import os 3 | import glob 4 | 5 | expdocs = [] 6 | for section in sections: 7 | foundDocs = glob.glob(section + "/EXP-*.rst") 8 | for found in sorted(foundDocs): 9 | expdocs.append(found) 10 | %> 11 | ===================== 12 | Experimental Features 13 | ===================== 14 | 15 | .. warning:: 16 | 17 | Experimental features: 18 | 19 | * May be replaced, updated, or removed at any time. 20 | * Do not require maintaining API/ABI stability of their own additions 21 | over time. 22 | * Do not require conformance testing of their own additions. 23 | 24 | More information about experimental features can be found in :ref:`core/CONTRIB:Experimental Features`. 25 | 26 | .. toctree:: 27 | 28 | %for expdoc in expdocs: 29 | %if os.path.exists(os.path.join(sourcepath, expdoc)): 30 | ${expdoc} 31 | %endif 32 | %endfor 33 | -------------------------------------------------------------------------------- /test/tools/urtrace/filter_device.test: -------------------------------------------------------------------------------- 1 | RUN: %trace --filter ".*Device.*" hello_world | FileCheck %s 2 | 3 | REQUIRES: tracing 4 | 5 | CHECK: Platform initialized. 6 | CHECK-NEXT: API version: {{.*}} 7 | CHECK-NEXT: urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 0, .phDevices = nullptr, .pNumDevices = {{.*}} (1)) -> UR_RESULT_SUCCESS; 8 | CHECK-NEXT: urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 1, .phDevices = {{.*}} {{{.*}}}, .pNumDevices = nullptr) -> UR_RESULT_SUCCESS; 9 | CHECK-NEXT: urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_TYPE, .propSize = 4, .pPropValue = {{.*}}, .pPropSizeRet = nullptr) -> UR_RESULT_SUCCESS; 10 | CHECK-NEXT: urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_NAME, .propSize = 1023, .pPropValue = {{.*}}, .pPropSizeRet = nullptr) -> UR_RESULT_SUCCESS; 11 | CHECK-NEXT: Found a Mock Device gpu. 12 | -------------------------------------------------------------------------------- /test/conformance/device_code/linker_error.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include 8 | 9 | SYCL_EXTERNAL void this_function_does_not_exist(); 10 | 11 | int main() { 12 | sycl::queue deviceQueue; 13 | sycl::range<1> numOfItems{1}; 14 | 15 | try { 16 | deviceQueue.submit([&](sycl::handler &cgh) { 17 | auto kern = [=](sycl::id<1>) { 18 | #ifdef __SYCL_DEVICE_ONLY__ 19 | this_function_does_not_exist(); 20 | #endif 21 | }; 22 | cgh.parallel_for(numOfItems, kern); 23 | }); 24 | std::cout << "Expected an error compiling the program." << std::endl; 25 | abort(); 26 | } catch (sycl::exception &e) { 27 | // OK 28 | } 29 | 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /test/loader/loader_config/urLoaderConfigCreate.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include "fixtures.hpp" 8 | 9 | struct LoaderConfigCreateTest : ::testing::Test { 10 | void TearDown() override { 11 | if (loaderConfig) { 12 | ASSERT_SUCCESS(urLoaderConfigRelease(loaderConfig)); 13 | } 14 | } 15 | 16 | ur_loader_config_handle_t loaderConfig = nullptr; 17 | }; 18 | 19 | TEST_F(LoaderConfigCreateTest, Success) { 20 | ASSERT_SUCCESS(urLoaderConfigCreate(&loaderConfig)); 21 | ASSERT_TRUE(loaderConfig != nullptr); 22 | } 23 | 24 | TEST_F(LoaderConfigCreateTest, InvalidNullPointerLoaderConfig) { 25 | ASSERT_EQ(UR_RESULT_ERROR_INVALID_NULL_POINTER, 26 | urLoaderConfigCreate(nullptr)); 27 | } 28 | -------------------------------------------------------------------------------- /test/loader/loader_lifetime/fixtures.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef UR_LOADER_CONFIG_TEST_FIXTURES_H 8 | #define UR_LOADER_CONFIG_TEST_FIXTURES_H 9 | 10 | #include "ur_api.h" 11 | #include 12 | #include 13 | 14 | #ifndef ASSERT_SUCCESS 15 | #define ASSERT_SUCCESS(ACTUAL) ASSERT_EQ(UR_RESULT_SUCCESS, ACTUAL) 16 | #endif 17 | 18 | /// @brief Make a string a valid identifier for gtest. 19 | /// @param str The string to sanitize. 20 | inline std::string GTestSanitizeString(const std::string &str) { 21 | auto str_cpy = str; 22 | std::replace_if( 23 | str_cpy.begin(), str_cpy.end(), [](char c) { return !std::isalnum(c); }, 24 | '_'); 25 | return str_cpy; 26 | } 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /test/conformance/device_code/fill_usm.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include 8 | 9 | int main() { 10 | size_t array_size = 16; 11 | std::vector A(array_size, 1); 12 | uint32_t val = 42; 13 | sycl::queue sycl_queue; 14 | uint32_t *data = sycl::malloc_shared(array_size, sycl_queue); 15 | sycl_queue.submit([&](sycl::handler &cgh) { 16 | cgh.parallel_for(sycl::range<1>{array_size}, 17 | [data, val](sycl::item<1> itemId) { 18 | auto id = itemId.get_id(0); 19 | data[id] = val; 20 | }); 21 | }); 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /test/conformance/device_code/fixed_sg_size.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include 8 | 9 | struct KernelFunctor { 10 | void operator()(sycl::nd_item<3>) const {} 11 | void operator()(sycl::item<3>) const {} 12 | 13 | auto get(sycl::ext::oneapi::experimental::properties_tag) const { 14 | return sycl::ext::oneapi::experimental::properties{ 15 | sycl::ext::oneapi::experimental::sub_group_size<8>}; 16 | } 17 | }; 18 | 19 | int main() { 20 | sycl::queue myQueue; 21 | myQueue.submit([&](sycl::handler &cgh) { 22 | cgh.parallel_for(sycl::range<3>(8, 8, 8), 23 | KernelFunctor{}); 24 | }); 25 | 26 | myQueue.wait(); 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /source/adapters/adapter.map.in: -------------------------------------------------------------------------------- 1 | @TARGET_LIBNAME@ { 2 | global: 3 | urGetAdapterProcAddrTable; 4 | urGetBindlessImagesExpProcAddrTable; 5 | urGetCommandBufferExpProcAddrTable; 6 | urGetContextProcAddrTable; 7 | urGetEnqueueProcAddrTable; 8 | urGetEnqueueExpProcAddrTable; 9 | urGetEventProcAddrTable; 10 | urGetGraphExpProcAddrTable; 11 | urGetIPCExpProcAddrTable; 12 | urGetKernelProcAddrTable; 13 | urGetMemProcAddrTable; 14 | urGetMemoryExportExpProcAddrTable; 15 | urGetPhysicalMemProcAddrTable; 16 | urGetPlatformProcAddrTable; 17 | urGetProgramProcAddrTable; 18 | urGetProgramExpProcAddrTable; 19 | urGetQueueProcAddrTable; 20 | urGetQueueExpProcAddrTable; 21 | urGetSamplerProcAddrTable; 22 | urGetUSMProcAddrTable; 23 | urGetUSMExpProcAddrTable; 24 | urGetUsmP2PExpProcAddrTable; 25 | urGetVirtualMemProcAddrTable; 26 | urGetDeviceProcAddrTable; 27 | urGetDeviceExpProcAddrTable; 28 | local: 29 | *; 30 | }; 31 | -------------------------------------------------------------------------------- /test/conformance/device_code/fixed_wg_size.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include 8 | 9 | struct KernelFunctor { 10 | void operator()(sycl::nd_item<3>) const {} 11 | void operator()(sycl::item<3>) const {} 12 | 13 | auto get(sycl::ext::oneapi::experimental::properties_tag) const { 14 | return sycl::ext::oneapi::experimental::properties{ 15 | sycl::ext::oneapi::experimental::work_group_size<8, 4, 2>}; 16 | } 17 | }; 18 | 19 | int main() { 20 | sycl::queue myQueue; 21 | myQueue.submit([&](sycl::handler &cgh) { 22 | cgh.parallel_for(sycl::range<3>(8, 8, 8), 23 | KernelFunctor{}); 24 | }); 25 | 26 | myQueue.wait(); 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /test/conformance/exp_graph/urQueueBeginGraphCaptureExp.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include "fixtures.h" 8 | 9 | using urQueueBeginGraphCaptureExpTest = uur::urGraphExpTest; 10 | 11 | UUR_INSTANTIATE_DEVICE_TEST_SUITE(urQueueBeginGraphCaptureExpTest); 12 | 13 | TEST_P(urQueueBeginGraphCaptureExpTest, Success) { 14 | ASSERT_SUCCESS(urQueueBeginGraphCaptureExp(queue)); 15 | 16 | ur_exp_graph_handle_t graph = nullptr; 17 | ASSERT_SUCCESS(urQueueEndGraphCaptureExp(queue, &graph)); 18 | ASSERT_SUCCESS(urGraphDestroyExp(graph)); 19 | } 20 | 21 | TEST_P(urQueueBeginGraphCaptureExpTest, InvalidNullHandleQueue) { 22 | ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, 23 | urQueueBeginGraphCaptureExp(nullptr)); 24 | } 25 | -------------------------------------------------------------------------------- /scripts/core/exp-device-is-integrated-gpu.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2025 Intel Corporation 3 | # 4 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 5 | # Exceptions. 6 | # See LICENSE.TXT 7 | # 8 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 9 | # 10 | # See YaML.md for syntax definition 11 | # 12 | --- #-------------------------------------------------------------------------- 13 | type: header 14 | desc: "Intel $OneApi Unified Runtime Experimental APIs for quering if device is integrated GPU" 15 | ordinal: "99" 16 | --- #-------------------------------------------------------------------------- 17 | type: enum 18 | extend: true 19 | typed_etors: true 20 | desc: "Extension enums for $x_device_info_t to support quering if device is integrated GPU." 21 | name: $x_device_info_t 22 | etors: 23 | - name: IS_INTEGRATED_GPU 24 | value: "0x2070" 25 | desc: "[$x_bool_t] returns true if the device is integrated GPU." 26 | -------------------------------------------------------------------------------- /source/common/ur_ref_count.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (C) 2025 Intel Corporation 4 | * 5 | * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | * Exceptions. See LICENSE.TXT 7 | * 8 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 9 | * 10 | */ 11 | #ifndef UR_REF_COUNT_HPP 12 | #define UR_REF_COUNT_HPP 1 13 | 14 | #include 15 | #include 16 | 17 | namespace ur { 18 | 19 | class RefCount { 20 | public: 21 | RefCount(uint32_t count = 1) : Count(count) {} 22 | RefCount(const RefCount &) = delete; 23 | RefCount &operator=(const RefCount &) = delete; 24 | 25 | uint32_t getCount() const noexcept { return Count.load(); } 26 | uint32_t retain() { return ++Count; } 27 | bool release() { return --Count == 0; } 28 | void reset(uint32_t value = 1) { Count = value; } 29 | 30 | private: 31 | std::atomic_uint32_t Count; 32 | }; 33 | 34 | } // namespace ur 35 | 36 | #endif // UR_REF_COUNT_HPP 37 | -------------------------------------------------------------------------------- /test/adapters/cuda/urEventCreateWithNativeHandle.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022-2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include "fixtures.h" 8 | #include "raii.h" 9 | 10 | using urCudaEventCreateWithNativeHandleTest = uur::urQueueTest; 11 | UUR_INSTANTIATE_DEVICE_TEST_SUITE(urCudaEventCreateWithNativeHandleTest); 12 | 13 | TEST_P(urCudaEventCreateWithNativeHandleTest, Success) { 14 | RAIICUevent cuda_event; 15 | ASSERT_SUCCESS_CUDA(cuEventCreate(cuda_event.ptr(), CU_EVENT_DEFAULT)); 16 | 17 | ur_native_handle_t native_event = 18 | reinterpret_cast(cuda_event.get()); 19 | 20 | uur::raii::Event event = nullptr; 21 | EXPECT_SUCCESS(urEventCreateWithNativeHandle(native_event, context, nullptr, 22 | event.ptr())); 23 | } 24 | -------------------------------------------------------------------------------- /test/conformance/event/urEventRetain.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include "fixtures.h" 8 | 9 | using urEventRetainTest = uur::event::urEventTest; 10 | UUR_INSTANTIATE_DEVICE_TEST_SUITE(urEventRetainTest); 11 | 12 | TEST_P(urEventRetainTest, Success) { 13 | uint32_t prevRefCount = 0; 14 | ASSERT_SUCCESS(uur::GetObjectReferenceCount(event, prevRefCount)); 15 | 16 | ASSERT_SUCCESS(urEventRetain(event)); 17 | 18 | uint32_t refCount = 0; 19 | ASSERT_SUCCESS(uur::GetObjectReferenceCount(event, refCount)); 20 | 21 | ASSERT_LT(prevRefCount, refCount); 22 | 23 | ASSERT_SUCCESS(urEventRelease(event)); 24 | } 25 | 26 | TEST_P(urEventRetainTest, InvalidNullHandle) { 27 | ASSERT_EQ_RESULT(urEventRetain(nullptr), UR_RESULT_ERROR_INVALID_NULL_HANDLE); 28 | } 29 | -------------------------------------------------------------------------------- /test/conformance/device_code/max_wg_size.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include 8 | 9 | struct KernelFunctor { 10 | void operator()(sycl::nd_item<3>) const {} 11 | void operator()(sycl::item<3>) const {} 12 | 13 | auto get(sycl::ext::oneapi::experimental::properties_tag) const { 14 | return sycl::ext::oneapi::experimental::properties{ 15 | sycl::ext::oneapi::experimental::max_work_group_size<8, 4, 2>, 16 | sycl::ext::oneapi::experimental::max_linear_work_group_size<64>}; 17 | } 18 | }; 19 | 20 | int main() { 21 | sycl::queue myQueue; 22 | myQueue.submit([&](sycl::handler &cgh) { 23 | cgh.parallel_for(sycl::range<3>(8, 8, 8), KernelFunctor{}); 24 | }); 25 | 26 | myQueue.wait(); 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /source/loader/linux/adapter_search.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (C) 2023 Intel Corporation 4 | * 5 | * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | * Exceptions. See LICENSE.TXT 7 | * 8 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 9 | * 10 | */ 11 | 12 | #include 13 | #include 14 | 15 | #include "ur_filesystem_resolved.hpp" 16 | #include "ur_loader.hpp" 17 | 18 | namespace fs = filesystem; 19 | 20 | namespace ur_loader { 21 | 22 | std::optional getLoaderLibPath() { 23 | Dl_info info; 24 | if (dladdr((void *)getLoaderLibPath, &info)) { 25 | auto libPath = fs::path(info.dli_fname); 26 | if (fs::exists(libPath)) { 27 | return fs::absolute(libPath).parent_path(); 28 | } 29 | } 30 | 31 | return std::nullopt; 32 | } 33 | 34 | std::optional getAdapterNameAsPath(std::string adapterName) { 35 | return fs::path(adapterName); 36 | } 37 | 38 | } // namespace ur_loader 39 | -------------------------------------------------------------------------------- /test/conformance/device_code/fill.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include 8 | 9 | int main() { 10 | size_t array_size = 16; 11 | std::vector A(array_size, 1); 12 | uint32_t val = 42; 13 | sycl::queue sycl_queue; 14 | auto A_buff = sycl::buffer(A.data(), sycl::range<1>(array_size)); 15 | sycl_queue.submit([&](sycl::handler &cgh) { 16 | auto A_acc = A_buff.get_access(cgh); 17 | cgh.parallel_for(sycl::range<1>{array_size}, 18 | [A_acc, val](sycl::item<1> itemId) { 19 | auto id = itemId.get_id(0); 20 | A_acc[id] = val; 21 | }); 22 | }); 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /test/conformance/device_code/cpy_and_mult_usm.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include 8 | 9 | int main() { 10 | size_t array_size = 16; 11 | sycl::queue sycl_queue; 12 | uint32_t *src = sycl::malloc_device(array_size, sycl_queue); 13 | uint32_t *dst = sycl::malloc_device(array_size, sycl_queue); 14 | sycl_queue.submit([&](sycl::handler &cgh) { 15 | cgh.parallel_for(sycl::range<1>{array_size}, 16 | [src, dst](sycl::item<1> itemId) { 17 | auto id = itemId.get_id(0); 18 | dst[id] = src[id] * 2; 19 | }); 20 | }); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /third_party/deps.yml: -------------------------------------------------------------------------------- 1 | # This file is used to initialize a conda environment to run codegen example. 2 | name: examples 3 | channels: 4 | - conda-forge 5 | dependencies: 6 | - _libgcc_mutex=0.1 7 | - _openmp_mutex=4.5 8 | - bzip2=1.0.8 9 | - c-ares=1.19.1 10 | - ca-certificates=2023.5.7 11 | - cmake=3.26.4 12 | - expat=2.5.0 13 | - keyutils=1.6.1 14 | - krb5=1.20.1 15 | - level-zero=1.11.0 16 | - level-zero-devel=1.11.0 17 | - libcurl=8.1.2 18 | - libedit=3.1.20191231 19 | - libev=4.33 20 | - libexpat=2.5.0 21 | - libgcc-ng=13.1.0 22 | - libgomp=13.1.0 23 | - libllvm14=14.0.6 24 | - libnghttp2=1.52.0 25 | - libssh2=1.11.0 26 | - libstdcxx-ng=13.1.0 27 | - libuv=1.44.2 28 | - libzlib=1.3.1 29 | - llvm-spirv=14.0.0 30 | - llvm-tools=14.0.6 31 | - llvmdev=14.0.6 32 | - ncurses=6.4 33 | - openssl=3.1.1 34 | - pkg-config=0.29.2 35 | - rhash=1.4.3 36 | # don't upgrade xz utils due to CVE-2024-3094 37 | - xz=5.2.6 38 | - zlib=1.3.1 39 | - zstd=1.5.2 40 | -------------------------------------------------------------------------------- /test/conformance/event/urEventRelease.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include "fixtures.h" 8 | 9 | using urEventReleaseTest = uur::event::urEventTest; 10 | 11 | UUR_INSTANTIATE_DEVICE_TEST_SUITE(urEventReleaseTest); 12 | 13 | TEST_P(urEventReleaseTest, Success) { 14 | ASSERT_SUCCESS(urEventRetain(event)); 15 | 16 | uint32_t prevRefCount = 0; 17 | ASSERT_SUCCESS(uur::GetObjectReferenceCount(event, prevRefCount)); 18 | 19 | ASSERT_SUCCESS(urEventRelease(event)); 20 | 21 | uint32_t refCount = 0; 22 | ASSERT_SUCCESS(uur::GetObjectReferenceCount(event, refCount)); 23 | 24 | ASSERT_GT(prevRefCount, refCount); 25 | } 26 | 27 | TEST_P(urEventReleaseTest, InvalidNullHandle) { 28 | ASSERT_EQ_RESULT(urEventRelease(nullptr), 29 | UR_RESULT_ERROR_INVALID_NULL_HANDLE); 30 | } 31 | -------------------------------------------------------------------------------- /source/adapters/hip/adapter.hpp: -------------------------------------------------------------------------------- 1 | //===--------- adapter.hpp - HIP Adapter ----------------------------------===// 2 | // 3 | // Copyright (C) 2023 Intel Corporation 4 | // 5 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | // Exceptions. See LICENSE.TXT 7 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 8 | // 9 | //===----------------------------------------------------------------------===// 10 | 11 | #ifndef UR_HIP_ADAPTER_HPP_INCLUDED 12 | #define UR_HIP_ADAPTER_HPP_INCLUDED 13 | 14 | #include "common/ur_ref_count.hpp" 15 | #include "logger/ur_logger.hpp" 16 | #include "platform.hpp" 17 | 18 | #include 19 | #include 20 | 21 | struct ur_adapter_handle_t_ : ur::hip::handle_base { 22 | ur::RefCount RefCount; 23 | logger::Logger &logger; 24 | std::unique_ptr Platform; 25 | ur_adapter_handle_t_(); 26 | }; 27 | 28 | namespace ur::hip { 29 | extern ur_adapter_handle_t adapter; 30 | } 31 | 32 | #endif // UR_HIP_ADAPTER_HPP_INCLUDED 33 | -------------------------------------------------------------------------------- /source/adapters/level_zero/physical_mem.hpp: -------------------------------------------------------------------------------- 1 | //===---------------- physical_mem.hpp - Level Zero Adapter ---------------===// 2 | // 3 | // Copyright (C) 2023 Intel Corporation 4 | // 5 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | // Exceptions. See LICENSE.TXT 7 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 8 | // 9 | //===----------------------------------------------------------------------===// 10 | #pragma once 11 | 12 | #include "common.hpp" 13 | #include "common/ur_ref_count.hpp" 14 | 15 | struct ur_physical_mem_handle_t_ : ur_object { 16 | ur_physical_mem_handle_t_(ze_physical_mem_handle_t ZePhysicalMem, 17 | ur_context_handle_t Context) 18 | : ZePhysicalMem{ZePhysicalMem}, Context{Context} {} 19 | 20 | // Level Zero physical memory handle. 21 | ze_physical_mem_handle_t ZePhysicalMem; 22 | 23 | // Keeps the PI context of this memory handle. 24 | ur_context_handle_t Context; 25 | 26 | ur::RefCount RefCount; 27 | }; 28 | -------------------------------------------------------------------------------- /source/adapters/native_cpu/usm_p2p.cpp: -------------------------------------------------------------------------------- 1 | //===--------- usm_p2p.cpp - Native CPU Adapter ---------------------------===// 2 | // 3 | // Copyright (C) 2023 Intel Corporation 4 | // 5 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | // Exceptions. See LICENSE.TXT 7 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 8 | // 9 | //===----------------------------------------------------------------------===// 10 | 11 | #include "common.hpp" 12 | 13 | UR_APIEXPORT ur_result_t UR_APICALL 14 | urUsmP2PEnablePeerAccessExp(ur_device_handle_t, ur_device_handle_t) { 15 | DIE_NO_IMPLEMENTATION; 16 | } 17 | 18 | UR_APIEXPORT ur_result_t UR_APICALL 19 | urUsmP2PDisablePeerAccessExp(ur_device_handle_t, ur_device_handle_t) { 20 | DIE_NO_IMPLEMENTATION; 21 | } 22 | 23 | UR_APIEXPORT ur_result_t UR_APICALL 24 | urUsmP2PPeerAccessGetInfoExp(ur_device_handle_t, ur_device_handle_t, 25 | ur_exp_peer_info_t, size_t, void *, size_t *) { 26 | DIE_NO_IMPLEMENTATION; 27 | } 28 | -------------------------------------------------------------------------------- /test/conformance/device_code/device_global.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include 8 | 9 | /* device_image_scope is needed to make sure that sycl generates device code 10 | * with an integer global variable instead of a pointer */ 11 | sycl::ext::oneapi::experimental::device_global< 12 | int, decltype(sycl::ext::oneapi::experimental::properties( 13 | sycl::ext::oneapi::experimental::device_image_scope))> 14 | dev_var; 15 | 16 | int main() { 17 | 18 | sycl::queue deviceQueue; 19 | sycl::range<1> numOfItems{1}; 20 | deviceQueue.submit([&](sycl::handler &cgh) { 21 | auto kern = [=](sycl::id<1>) { 22 | // just increment 23 | dev_var = dev_var + 1; 24 | }; 25 | cgh.parallel_for(numOfItems, kern); 26 | }); 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /test/conformance/virtual_memory/urVirtualMemFree.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | #include 7 | 8 | using urVirtualMemFreeTest = uur::urVirtualMemTest; 9 | UUR_INSTANTIATE_DEVICE_TEST_SUITE(urVirtualMemFreeTest); 10 | 11 | TEST_P(urVirtualMemFreeTest, Success) { 12 | ASSERT_SUCCESS(urVirtualMemFree(context, virtual_ptr, size)); 13 | virtual_ptr = nullptr; // set to nullptr to prevent double-free 14 | } 15 | 16 | TEST_P(urVirtualMemFreeTest, InvalidNullHandleContext) { 17 | ASSERT_EQ_RESULT(urVirtualMemFree(nullptr, virtual_ptr, size), 18 | UR_RESULT_ERROR_INVALID_NULL_HANDLE); 19 | } 20 | 21 | TEST_P(urVirtualMemFreeTest, InvalidNullPointerStart) { 22 | ASSERT_EQ_RESULT(urVirtualMemFree(context, nullptr, size), 23 | UR_RESULT_ERROR_INVALID_NULL_POINTER); 24 | } 25 | -------------------------------------------------------------------------------- /test/logger/level-none.test: -------------------------------------------------------------------------------- 1 | RUN: UR_LOG_ADAPTER_TEST="" logger-test 2>&1 1>%null | FileCheck --allow-empty %s 2 | RUN: UR_LOG_ADAPTER_TEST="output:stdout" logger-test | FileCheck --allow-empty %s 3 | RUN: UR_LOG_ADAPTER_TEST="output:stderr" logger-test 2>&1 1>%null | FileCheck --allow-empty %s 4 | RUN: UR_LOG_ADAPTER_TEST="output:file,%t" logger-test 5 | RUN: FileCheck --allow-empty --input-file %t %s 6 | 7 | RUN: UR_LOG_ADAPTER_TEST="" logger-test 2>&1 1>%null | FileCheck --allow-empty %s 8 | RUN: UR_LOG_ADAPTER_TEST="output:stdout" logger-test | FileCheck --allow-empty %s 9 | RUN: UR_LOG_ADAPTER_TEST="output:stderr" logger-test 2>&1 1>%null | FileCheck --allow-empty %s 10 | RUN: UR_LOG_ADAPTER_TEST="output:file,%t" logger-test 11 | RUN: FileCheck --allow-empty --input-file %t %s 12 | 13 | CHECK-NOT: [DEBUG]: Test message: success 14 | CHECK-NOT: [INFO]: Test message: success 15 | CHECK-NOT: [WARNING]: Test message: success 16 | CHECK-NOT: [ERROR]: Test message: success 17 | -------------------------------------------------------------------------------- /test/conformance/context/urContextRetain.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include 8 | 9 | using urContextRetainTest = uur::urContextTest; 10 | UUR_INSTANTIATE_DEVICE_TEST_SUITE(urContextRetainTest); 11 | 12 | TEST_P(urContextRetainTest, Success) { 13 | uint32_t prevRefCount = 0; 14 | ASSERT_SUCCESS(uur::GetObjectReferenceCount(context, prevRefCount)); 15 | 16 | ASSERT_SUCCESS(urContextRetain(context)); 17 | 18 | uint32_t refCount = 0; 19 | ASSERT_SUCCESS(uur::GetObjectReferenceCount(context, refCount)); 20 | 21 | ASSERT_LT(prevRefCount, refCount); 22 | 23 | ASSERT_SUCCESS(urContextRelease(context)); 24 | } 25 | 26 | TEST_P(urContextRetainTest, InvalidNullHandleContext) { 27 | ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, 28 | urContextRetain(nullptr)); 29 | } 30 | -------------------------------------------------------------------------------- /test/conformance/device_code/saxpy_usm.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include 8 | 9 | int main() { 10 | size_t array_size = 16; 11 | 12 | sycl::queue sycl_queue; 13 | uint32_t *X = sycl::malloc_shared(array_size, sycl_queue); 14 | uint32_t *Y = sycl::malloc_shared(array_size, sycl_queue); 15 | uint32_t *Z = sycl::malloc_shared(array_size, sycl_queue); 16 | uint32_t A = 42; 17 | 18 | sycl_queue.submit([&](sycl::handler &cgh) { 19 | cgh.parallel_for(sycl::range<1>{array_size}, 20 | [=](sycl::item<1> itemId) { 21 | auto i = itemId.get_id(0); 22 | Z[i] = A * X[i] + Y[i]; 23 | }); 24 | }); 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /test/conformance/program/urProgramRetain.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include 8 | 9 | using urProgramRetainTest = uur::urProgramTest; 10 | UUR_INSTANTIATE_DEVICE_TEST_SUITE(urProgramRetainTest); 11 | 12 | TEST_P(urProgramRetainTest, Success) { 13 | uint32_t prevRefCount = 0; 14 | ASSERT_SUCCESS(uur::GetObjectReferenceCount(program, prevRefCount)); 15 | 16 | ASSERT_SUCCESS(urProgramRetain(program)); 17 | 18 | uint32_t refCount = 0; 19 | ASSERT_SUCCESS(uur::GetObjectReferenceCount(program, refCount)); 20 | 21 | ASSERT_LT(prevRefCount, refCount); 22 | 23 | ASSERT_SUCCESS(urProgramRetain(program)); 24 | } 25 | 26 | TEST_P(urProgramRetainTest, InvalidNullHandleProgram) { 27 | ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, 28 | urProgramRetain(nullptr)); 29 | } 30 | -------------------------------------------------------------------------------- /test/logger/level-info.test: -------------------------------------------------------------------------------- 1 | RUN: UR_LOG_ADAPTER_TEST="level:info" logger-test 2>&1 1>%null | FileCheck %s 2 | RUN: UR_LOG_ADAPTER_TEST="level:info;output:stdout" logger-test | FileCheck %s 3 | RUN: UR_LOG_ADAPTER_TEST="level:info;output:stderr" logger-test 2>&1 1>%null | FileCheck %s 4 | RUN: UR_LOG_ADAPTER_TEST="level:info;output:file,%t" logger-test 5 | RUN: FileCheck --input-file %t %s 6 | 7 | RUN: UR_LOG_ADAPTER_TEST="flush:info;level:info" logger-test 2>&1 1>%null | FileCheck %s 8 | RUN: UR_LOG_ADAPTER_TEST="flush:info;level:info;output:stdout" logger-test | FileCheck %s 9 | RUN: UR_LOG_ADAPTER_TEST="flush:info;level:info;output:stderr" logger-test 2>&1 1>%null | FileCheck %s 10 | RUN: UR_LOG_ADAPTER_TEST="flush:info;level:info;output:file,%t" logger-test 11 | RUN: FileCheck --input-file %t %s 12 | 13 | CHECK-NOT: [DEBUG]: Test message: success 14 | CHECK: [INFO]: Test message: success 15 | CHECK: [WARNING]: Test message: success 16 | CHECK: [ERROR]: Test message: success 17 | -------------------------------------------------------------------------------- /source/adapters/level_zero/external/driver_experimental/zex_context.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-2025 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | */ 7 | 8 | #ifndef _ZEX_CONTEXT_H 9 | #define _ZEX_CONTEXT_H 10 | #if defined(__cplusplus) 11 | #pragma once 12 | #endif 13 | 14 | #include "level_zero/ze_intel_gpu.h" 15 | #include 16 | 17 | #include "zex_common.h" 18 | 19 | #if defined(__cplusplus) 20 | extern "C" { 21 | #endif 22 | 23 | ZE_APIEXPORT ze_result_t ZE_APICALL zeIntelMediaCommunicationCreate( 24 | ze_context_handle_t hContext, ze_device_handle_t hDevice, 25 | ze_intel_media_communication_desc_t *desc, 26 | ze_intel_media_doorbell_handle_desc_t *phDoorbell); 27 | ZE_APIEXPORT ze_result_t ZE_APICALL zeIntelMediaCommunicationDestroy( 28 | ze_context_handle_t hContext, ze_device_handle_t hDevice, 29 | ze_intel_media_doorbell_handle_desc_t *phDoorbell); 30 | 31 | #if defined(__cplusplus) 32 | } // extern "C" 33 | #endif 34 | 35 | #endif // _ZEX_CONTEXT_H 36 | -------------------------------------------------------------------------------- /source/common/ur_lib_loader.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (C) 2023 Intel Corporation 4 | * 5 | * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | * Exceptions. See LICENSE.TXT 7 | * 8 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 9 | * 10 | */ 11 | #ifndef UR_LIB_LOADER_HPP 12 | #define UR_LIB_LOADER_HPP 1 13 | 14 | #include 15 | 16 | #if _WIN32 17 | #include 18 | #else 19 | #define HMODULE void * 20 | #endif 21 | 22 | namespace ur_loader { 23 | 24 | class LibLoader { 25 | public: 26 | struct lib_dtor { 27 | typedef HMODULE pointer; 28 | void operator()(HMODULE handle) { freeAdapterLibrary(handle); } 29 | }; 30 | 31 | using Lib = std::unique_ptr; 32 | 33 | static Lib loadAdapterLibrary(const char *name); 34 | 35 | static void freeAdapterLibrary(HMODULE handle); 36 | 37 | static void *getFunctionPtr(HMODULE handle, const char *func_name); 38 | }; 39 | 40 | } // namespace ur_loader 41 | 42 | #endif // UR_LIB_LOADER_HPP 43 | -------------------------------------------------------------------------------- /test/conformance/context/urContextRelease.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include 8 | 9 | using urContextReleaseTest = uur::urContextTest; 10 | UUR_INSTANTIATE_DEVICE_TEST_SUITE(urContextReleaseTest); 11 | 12 | TEST_P(urContextReleaseTest, Success) { 13 | ASSERT_SUCCESS(urContextRetain(context)); 14 | 15 | uint32_t prevRefCount = 0; 16 | ASSERT_SUCCESS(uur::GetObjectReferenceCount(context, prevRefCount)); 17 | 18 | ASSERT_SUCCESS(urContextRelease(context)); 19 | 20 | uint32_t refCount = 0; 21 | ASSERT_SUCCESS(uur::GetObjectReferenceCount(context, refCount)); 22 | 23 | ASSERT_GT(prevRefCount, refCount); 24 | } 25 | 26 | TEST_P(urContextReleaseTest, InvalidNullHandleContext) { 27 | ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, 28 | urContextRelease(nullptr)); 29 | } 30 | -------------------------------------------------------------------------------- /test/conformance/program/urProgramRelease.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include 8 | 9 | using urProgramReleaseTest = uur::urProgramTest; 10 | UUR_INSTANTIATE_DEVICE_TEST_SUITE(urProgramReleaseTest); 11 | 12 | TEST_P(urProgramReleaseTest, Success) { 13 | ASSERT_SUCCESS(urProgramRetain(program)); 14 | 15 | uint32_t prevRefCount = 0; 16 | ASSERT_SUCCESS(uur::GetObjectReferenceCount(program, prevRefCount)); 17 | 18 | ASSERT_SUCCESS(urProgramRelease(program)); 19 | 20 | uint32_t refCount = 0; 21 | ASSERT_SUCCESS(uur::GetObjectReferenceCount(program, refCount)); 22 | 23 | ASSERT_GT(prevRefCount, refCount); 24 | } 25 | 26 | TEST_P(urProgramReleaseTest, InvalidNullHandleProgram) { 27 | ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, 28 | urProgramRelease(nullptr)); 29 | } 30 | -------------------------------------------------------------------------------- /test/adapters/cuda/memory_tests.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022-2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include "fixtures.h" 8 | #include "uur/raii.h" 9 | 10 | using cudaMemoryTest = uur::urContextTest; 11 | UUR_INSTANTIATE_DEVICE_TEST_SUITE(cudaMemoryTest); 12 | 13 | TEST_P(cudaMemoryTest, urMemBufferNoActiveContext) { 14 | constexpr size_t memSize = 1024u; 15 | 16 | CUcontext current = nullptr; 17 | ASSERT_SUCCESS_CUDA(cuCtxGetCurrent(¤t)); 18 | while (current != nullptr) { 19 | CUcontext oldContext = nullptr; 20 | ASSERT_SUCCESS_CUDA(cuCtxPopCurrent(&oldContext)); 21 | ASSERT_SUCCESS_CUDA(cuCtxGetCurrent(¤t)); 22 | } 23 | 24 | uur::raii::Mem mem; 25 | ASSERT_SUCCESS(urMemBufferCreate(context, UR_MEM_FLAG_READ_WRITE, memSize, 26 | nullptr, mem.ptr())); 27 | ASSERT_NE(mem, nullptr); 28 | } 29 | -------------------------------------------------------------------------------- /test/conformance/device_code/spec_constant.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include 8 | #include 9 | 10 | using namespace sycl; 11 | 12 | constexpr specialization_id spec_const{1000}; 13 | 14 | int main() { 15 | queue myQueue; 16 | uint32_t out_val = 0; 17 | buffer out(&out_val, sycl::range<1>{1}); 18 | myQueue.submit([&](handler &cgh) { 19 | accessor out_acc{out, cgh, write_only}; 20 | 21 | cgh.set_specialization_constant(0); 22 | 23 | cgh.parallel_for( 24 | out.get_range(), [=](item<1> item_id, kernel_handler h) { 25 | uint32_t spec_const_val = h.get_specialization_constant(); 26 | out_acc[0] = spec_const_val; 27 | }); 28 | }); 29 | 30 | myQueue.wait(); 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /test/layers/sanitizer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023-2024 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | function(add_sanitizer_test name) 7 | add_gtest_test(${name} ${ARGN}) 8 | target_include_directories(${name}-test PRIVATE 9 | ${PROJECT_SOURCE_DIR}/source 10 | ${PROJECT_SOURCE_DIR}/source/common 11 | ${PROJECT_SOURCE_DIR}/source/loader/layers/sanitizer/sanitizer_common 12 | ) 13 | endfunction() 14 | 15 | function(add_test_source name source) 16 | target_sources(${name}-test PRIVATE ${source}) 17 | endfunction() 18 | 19 | add_sanitizer_test(asan asan.cpp) 20 | add_sanitizer_test(sanitizer_options sanitizer_options.cpp) 21 | 22 | # add the source here in order to test for unexported functions 23 | add_test_source(sanitizer_options 24 | ${PROJECT_SOURCE_DIR}/source/loader/layers/sanitizer/sanitizer_common/sanitizer_options.cpp 25 | ) 26 | -------------------------------------------------------------------------------- /test/logger/level-debug.test: -------------------------------------------------------------------------------- 1 | RUN: UR_LOG_ADAPTER_TEST="level:debug" logger-test 2>&1 1>%null | FileCheck %s 2 | RUN: UR_LOG_ADAPTER_TEST="level:debug;output:stdout" logger-test | FileCheck %s 3 | RUN: UR_LOG_ADAPTER_TEST="level:debug;output:stderr" logger-test 2>&1 1>%null | FileCheck %s 4 | RUN: UR_LOG_ADAPTER_TEST="level:debug;output:file,%t" logger-test 5 | RUN: FileCheck --input-file %t %s 6 | 7 | RUN: UR_LOG_ADAPTER_TEST="flush:debug;level:debug" logger-test 2>&1 1>%null | FileCheck %s 8 | RUN: UR_LOG_ADAPTER_TEST="flush:debug;level:debug;output:stdout" logger-test | FileCheck %s 9 | RUN: UR_LOG_ADAPTER_TEST="flush:debug;level:debug;output:stderr" logger-test 2>&1 1>%null | FileCheck %s 10 | RUN: UR_LOG_ADAPTER_TEST="flush:debug;level:debug;output:file,%t" logger-test 11 | RUN: FileCheck --input-file %t %s 12 | 13 | CHECK: [DEBUG]: Test message: success 14 | CHECK: [INFO]: Test message: success 15 | CHECK: [WARNING]: Test message: success 16 | CHECK: [ERROR]: Test message: success 17 | -------------------------------------------------------------------------------- /scripts/templates/api_funcs.def.mako: -------------------------------------------------------------------------------- 1 | <%! 2 | import re 3 | from templates import helper as th 4 | %><% 5 | n=namespace 6 | N=n.upper() 7 | 8 | x=tags['$x'] 9 | X=x.upper() 10 | %> 11 | /* 12 | * 13 | * Copyright (C) 2024 Intel Corporation 14 | * 15 | * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 16 | * Exceptions. 17 | * 18 | * See LICENSE.TXT 19 | * 20 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 21 | * 22 | * @file ${name}.def 23 | * @version v${ver}-r${rev} 24 | * 25 | */ 26 | 27 | // Auto-generated file, do not edit. 28 | 29 | %for tbl in th.get_pfntables(specs, meta, n, tags): 30 | %for obj in tbl['functions']: 31 | %if 'guard' in obj: 32 | // ${obj['guard']} 33 | %endif 34 | _UR_API(${th.make_func_name(n, tags, obj)}) 35 | %if 'guard' in obj: 36 | // end ${obj['guard']} 37 | %endif 38 | %endfor 39 | %endfor 40 | %for obj in th.get_loader_functions(specs, meta, n, tags): 41 | %if n + "Loader" in obj['name']: 42 | _UR_API(${obj['name']}) 43 | %endif 44 | %endfor 45 | -------------------------------------------------------------------------------- /source/adapters/offload/adapter.hpp: -------------------------------------------------------------------------------- 1 | //===----------- adapter.hpp - LLVM Offload Adapter ----------------------===// 2 | // 3 | // Copyright (C) 2025 Intel Corporation 4 | // 5 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | // Exceptions. See LICENSE.TXT 7 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 8 | // 9 | //===----------------------------------------------------------------------===// 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | 19 | #include "common.hpp" 20 | #include "logger/ur_logger.hpp" 21 | #include "platform.hpp" 22 | 23 | struct ur_adapter_handle_t_ : ur::offload::handle_base { 24 | std::atomic_uint32_t RefCount = 0; 25 | logger::Logger &Logger = logger::get_logger("offload"); 26 | ol_device_handle_t HostDevice = nullptr; 27 | std::vector> Platforms; 28 | 29 | ur_result_t init(); 30 | }; 31 | 32 | extern ur_adapter_handle_t Adapter; 33 | -------------------------------------------------------------------------------- /source/loader/layers/ur_proxy_layer.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (C) 2023 Corporation 4 | * 5 | * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | * Exceptions. See LICENSE.TXT 7 | * 8 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 9 | * 10 | * @file ur_proxy_layer.h 11 | * 12 | */ 13 | #ifndef UR_PROXY_LAYER_H 14 | #define UR_PROXY_LAYER_H 1 15 | 16 | #include "ur_codeloc.hpp" 17 | #include "ur_ddi.h" 18 | #include "ur_util.hpp" 19 | 20 | #include 21 | 22 | /////////////////////////////////////////////////////////////////////////////// 23 | class __urdlllocal proxy_layer_context_t { 24 | public: 25 | virtual ~proxy_layer_context_t() {}; 26 | ur_api_version_t version = UR_API_VERSION_CURRENT; 27 | 28 | virtual ur_result_t init(ur_dditable_t *dditable, 29 | const std::set &enabledLayerNames, 30 | codeloc_data codelocData) = 0; 31 | virtual ur_result_t tearDown() = 0; 32 | }; 33 | 34 | #endif /* UR_PROXY_LAYER_H */ 35 | -------------------------------------------------------------------------------- /test/loader/adapter_registry/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | function(add_adapter_reg_search_test name) 7 | set(TEST_TARGET_NAME ${name}-test) 8 | add_gtest_test(${name} ${TEST_SOURCES}) 9 | 10 | if(WIN32) 11 | target_sources(${TEST_TARGET_NAME} PRIVATE 12 | ${PROJECT_SOURCE_DIR}/source/loader/windows/adapter_search.cpp) 13 | else() 14 | target_sources(${TEST_TARGET_NAME} PRIVATE 15 | ${PROJECT_SOURCE_DIR}/source/loader/linux/adapter_search.cpp) 16 | endif() 17 | 18 | target_include_directories(${TEST_TARGET_NAME} PRIVATE 19 | ${PROJECT_SOURCE_DIR}/source/loader) 20 | endfunction() 21 | 22 | add_adapter_reg_search_test(search-with-env) 23 | add_adapter_reg_search_test(search-no-env) 24 | add_adapter_reg_search_test(search-order) 25 | add_adapter_reg_search_test(prefilter) 26 | -------------------------------------------------------------------------------- /third_party/requirements.txt: -------------------------------------------------------------------------------- 1 | alabaster==0.7.12 2 | Babel==2.14.0 3 | bandit==1.6.2 4 | beautifulsoup4==4.11.1 5 | breathe==4.33.1 6 | bs4==0.0.1 7 | certifi==2024.07.04 8 | chardet==3.0.4 9 | clang-format==19.1.6 10 | colorama==0.4.1 11 | docutils==0.15.2 12 | exhale==0.3.0 13 | idna==3.7 14 | imagesize==1.1.0 15 | Jinja2==3.1.6 16 | lxml==4.9.3 17 | Mako==1.3.0 18 | MarkupSafe==2.1.5 19 | packaging==24.2 20 | Pygments==2.17.2 21 | pyparsing==2.4.5 22 | pytest>=7.0 23 | pytz==2019.3 24 | PyYAML==6.0.1 25 | requests==2.32.4 26 | rst2pdf==0.102 27 | six==1.13.0 28 | snowballstemmer==2.0.0 29 | soupsieve==1.9.5 30 | Sphinx==4.5.0 31 | sphinx-book-theme==0.3.3 32 | sphinxcontrib-applehelp==1.0.2 33 | sphinxcontrib-devhelp==1.0.2 34 | sphinxcontrib-htmlhelp==2.0.0 35 | sphinxcontrib-jsmath==1.0.1 36 | sphinxcontrib-qthelp==1.0.3 37 | sphinxcontrib-serializinghtml==1.1.5 38 | sphinxcontrib-websupport==1.2.4 39 | sphinx-rtd-theme==1.0.0 40 | urllib3==2.5.0 41 | dataclasses-json==0.6.7 42 | 43 | # Unified-runtime is formatted using black 44 | black==25.9.0 45 | -------------------------------------------------------------------------------- /scripts/templates/exp_feat.yml.mako: -------------------------------------------------------------------------------- 1 | <% 2 | import re 3 | from templates import helper as th 4 | import datetime 5 | %><% 6 | year_now=datetime.date.today().year 7 | %># 8 | # Copyright (C) ${year_now} Intel Corporation 9 | # 10 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 11 | # Exceptions. 12 | # See LICENSE.TXT 13 | # 14 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 15 | # 16 | # See YaML.md for syntax definition 17 | # 18 | --- #-------------------------------------------------------------------------- 19 | type: header 20 | desc: "Intel $OneApi Unified Runtime Experimental APIs for ${" ".join(name.split("-")).title()}" 21 | ordinal: "99" 22 | --- #-------------------------------------------------------------------------- 23 | type: macro 24 | desc: | 25 | The extension string which defines support for ${name} 26 | which is returned when querying device extensions. 27 | name: $X_${"_".join(name.split("-")).upper()}_EXTENSION_STRING_EXP 28 | value: "\"$x_exp_${"_".join(name.split("-"))}\"" 29 | -------------------------------------------------------------------------------- /test/logger/level-error.test: -------------------------------------------------------------------------------- 1 | RUN: UR_LOG_ADAPTER_TEST="level:error" logger-test 2>&1 1>%null | FileCheck %s 2 | RUN: UR_LOG_ADAPTER_TEST="level:error;output:stdout" logger-test | FileCheck %s 3 | RUN: UR_LOG_ADAPTER_TEST="level:error;output:stderr" logger-test 2>&1 1>%null | FileCheck %s 4 | RUN: UR_LOG_ADAPTER_TEST="level:error;output:file,%t" logger-test 5 | RUN: FileCheck --input-file %t %s 6 | 7 | RUN: UR_LOG_ADAPTER_TEST="flush:error;level:error" logger-test 2>&1 1>%null | FileCheck %s 8 | RUN: UR_LOG_ADAPTER_TEST="flush:error;level:error;output:stdout" logger-test | FileCheck %s 9 | RUN: UR_LOG_ADAPTER_TEST="flush:error;level:error;output:stderr" logger-test 2>&1 1>%null | FileCheck %s 10 | RUN: UR_LOG_ADAPTER_TEST="flush:error;level:error;output:file,%t" logger-test 11 | RUN: FileCheck --input-file %t %s 12 | 13 | CHECK-NOT: [DEBUG]: Test message: success 14 | CHECK-NOT: [INFO]: Test message: success 15 | CHECK-NOT: [WARNING]: Test message: success 16 | CHECK: [ERROR]: Test message: success 17 | -------------------------------------------------------------------------------- /source/adapters/native_cpu/common.cpp: -------------------------------------------------------------------------------- 1 | //===---------------- common.cpp - Native CPU Adapter ---------------------===// 2 | // 3 | // Copyright (C) 2023 Intel Corporation 4 | // 5 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | // Exceptions. See LICENSE.TXT 7 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 8 | // 9 | //===----------------------------------------------------------------------===// 10 | 11 | #include "common.hpp" 12 | 13 | // Global variables for UR_RESULT_ADAPTER_SPECIFIC_ERROR 14 | thread_local int32_t ErrorMessageCode = 0; 15 | thread_local char ErrorMessage[MaxMessageSize]{}; 16 | 17 | // Utility function for setting a message and warning 18 | [[maybe_unused]] void setErrorMessage(const char *pMessage, int32_t ErrorCode) { 19 | assert(strlen(pMessage) < MaxMessageSize); 20 | // Copy at most MaxMessageSize - 1 bytes to ensure the resultant string is 21 | // always null terminated. 22 | strncpy(ErrorMessage, pMessage, MaxMessageSize - 1); 23 | ErrorMessageCode = ErrorCode; 24 | } 25 | -------------------------------------------------------------------------------- /test/conformance/queue/urQueueRetain.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | #include 7 | #include 8 | 9 | using urQueueRetainTest = uur::urQueueTest; 10 | UUR_INSTANTIATE_DEVICE_TEST_SUITE(urQueueRetainTest); 11 | 12 | TEST_P(urQueueRetainTest, Success) { 13 | UUR_KNOWN_FAILURE_ON(uur::NativeCPU{}); 14 | 15 | uint32_t prevRefCount = 0; 16 | ASSERT_SUCCESS(uur::GetObjectReferenceCount(queue, prevRefCount)); 17 | 18 | ASSERT_SUCCESS(urQueueRetain(queue)); 19 | 20 | uint32_t refCount = 0; 21 | ASSERT_SUCCESS(uur::GetObjectReferenceCount(queue, refCount)); 22 | 23 | ASSERT_LT(prevRefCount, refCount); 24 | 25 | ASSERT_SUCCESS(urQueueRelease(queue)); 26 | } 27 | 28 | TEST_P(urQueueRetainTest, InvalidNullHandleQueue) { 29 | ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, urQueueRetain(nullptr)); 30 | } 31 | -------------------------------------------------------------------------------- /scripts/templates/stype_map_helpers.hpp.mako: -------------------------------------------------------------------------------- 1 | <%! 2 | import os 3 | import re 4 | from templates import helper as th 5 | %><% 6 | n=namespace 7 | N=n.upper() 8 | x=tags['$x'] 9 | X=x.upper() 10 | %> 11 | // Copyright (C) 2025 Intel Corporation 12 | // 13 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 14 | // See LICENSE.TXT 15 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 16 | 17 | // This file is autogenerated from the template at ${os.path.dirname(self.template.filename)}/${os.path.basename(self.template.filename)} 18 | 19 | %for obj in th.extract_objs(specs, r"enum"): 20 | %if obj["name"] == '$x_structure_type_t': 21 | %for etor in th.get_etors(obj): 22 | %if 'UINT32' not in etor['name']: 23 | %if 'guard' in etor: 24 | // ${etor['guard']} 25 | %endif 26 | template <> 27 | struct stype_map<${x}_${etor['desc'][3:]}> : stype_map_impl<${X}_${etor['name'][3:]}> {}; 28 | %if 'guard' in etor: 29 | // end ${etor['guard']} 30 | %endif 31 | %endif 32 | %endfor 33 | %endif 34 | %endfor 35 | 36 | -------------------------------------------------------------------------------- /test/conformance/exp_graph/urGraphCreateExp.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include "fixtures.h" 8 | 9 | using urGraphCreateExpTest = uur::urGraphSupportedExpTest; 10 | 11 | UUR_INSTANTIATE_DEVICE_TEST_SUITE(urGraphCreateExpTest); 12 | 13 | TEST_P(urGraphCreateExpTest, Success) { 14 | ur_exp_graph_handle_t graph = nullptr; 15 | ASSERT_SUCCESS(urGraphCreateExp(context, &graph)); 16 | ASSERT_SUCCESS(urGraphDestroyExp(graph)); 17 | } 18 | 19 | TEST_P(urGraphCreateExpTest, InvalidNullHandleContext) { 20 | ur_exp_graph_handle_t graph = nullptr; 21 | ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, 22 | urGraphCreateExp(nullptr, &graph)); 23 | } 24 | 25 | TEST_P(urGraphCreateExpTest, InvalidNullPtrGraph) { 26 | ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, 27 | urGraphCreateExp(context, nullptr)); 28 | } 29 | -------------------------------------------------------------------------------- /test/conformance/exp_command_buffer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2024 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | add_conformance_kernels_test(exp_command_buffer 7 | release.cpp 8 | retain.cpp 9 | commands.cpp 10 | fill.cpp 11 | event_sync.cpp 12 | kernel_event_sync.cpp 13 | invalid.cpp 14 | copy.cpp 15 | read.cpp 16 | write.cpp 17 | rect_read.cpp 18 | rect_write.cpp 19 | enqueue.cpp 20 | in-order.cpp 21 | update/buffer_fill_kernel_update.cpp 22 | update/invalid_update.cpp 23 | update/kernel_handle_update.cpp 24 | update/usm_fill_kernel_update.cpp 25 | update/buffer_saxpy_kernel_update.cpp 26 | update/ndrange_update.cpp 27 | update/usm_saxpy_kernel_update.cpp 28 | update/event_sync.cpp 29 | update/kernel_event_sync.cpp 30 | update/local_memory_update.cpp 31 | update/enqueue_update.cpp 32 | regression/usm_copy.cpp 33 | ) 34 | 35 | add_subdirectory(native-command) 36 | -------------------------------------------------------------------------------- /test/logger/level-warning.test: -------------------------------------------------------------------------------- 1 | RUN: UR_LOG_ADAPTER_TEST="level:warning" logger-test 2>&1 1>%null | FileCheck %s 2 | RUN: UR_LOG_ADAPTER_TEST="level:warning;output:stdout" logger-test | FileCheck %s 3 | RUN: UR_LOG_ADAPTER_TEST="level:warning;output:stderr" logger-test 2>&1 1>%null | FileCheck %s 4 | RUN: UR_LOG_ADAPTER_TEST="level:warning;output:file,%t" logger-test 5 | RUN: FileCheck --input-file %t %s 6 | 7 | RUN: UR_LOG_ADAPTER_TEST="flush:warning;level:warning" logger-test 2>&1 1>%null | FileCheck %s 8 | RUN: UR_LOG_ADAPTER_TEST="flush:warning;level:warning;output:stdout" logger-test | FileCheck %s 9 | RUN: UR_LOG_ADAPTER_TEST="flush:warning;level:warning;output:stderr" logger-test 2>&1 1>%null | FileCheck %s 10 | RUN: UR_LOG_ADAPTER_TEST="flush:warning;level:warning;output:file,%t" logger-test 11 | RUN: FileCheck --input-file %t %s 12 | 13 | CHECK-NOT: [DEBUG]: Test message: success 14 | CHECK-NOT: [INFO]: Test message: success 15 | CHECK: [WARNING]: Test message: success 16 | CHECK: [ERROR]: Test message: success 17 | -------------------------------------------------------------------------------- /source/loader/layers/sanitizer/asan/asan_statistics.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (C) 2024 Intel Corporation 4 | * 5 | * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | * Exceptions. See LICENSE.TXT 7 | * 8 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 9 | * 10 | * @file asan_statistics.hpp 11 | * 12 | */ 13 | 14 | #pragma once 15 | 16 | #include "sanitizer_common/sanitizer_common.hpp" 17 | 18 | namespace ur_sanitizer_layer { 19 | namespace asan { 20 | 21 | struct AsanStats; 22 | 23 | struct AsanStatsWrapper { 24 | 25 | AsanStatsWrapper(); 26 | ~AsanStatsWrapper(); 27 | 28 | void UpdateUSMMalloced(uptr MallocedSize, uptr RedzoneSize); 29 | void UpdateUSMFreed(uptr FreedSize); 30 | void UpdateUSMRealFreed(uptr FreedSize, uptr RedzoneSize); 31 | 32 | void UpdateShadowMalloced(uptr ShadowSize); 33 | void UpdateShadowFreed(uptr ShadowSize); 34 | 35 | void Print(ur_context_handle_t Context); 36 | 37 | private: 38 | AsanStats *Stat; 39 | }; 40 | 41 | } // namespace asan 42 | } // namespace ur_sanitizer_layer 43 | -------------------------------------------------------------------------------- /source/ur/ur.cpp: -------------------------------------------------------------------------------- 1 | 2 | //===--------- ur.cpp - Unified Runtime ----------------------------------===// 3 | // 4 | // Copyright (C) 2023 Intel Corporation 5 | // 6 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 7 | // Exceptions. See LICENSE.TXT 8 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 9 | // 10 | //===----------------------------------------------------------------------===// 11 | 12 | #include "ur.hpp" 13 | #include 14 | 15 | // Controls tracing UR calls from within the UR itself. 16 | bool PrintTrace = [] { 17 | const char *UrRet = std::getenv("SYCL_UR_TRACE"); 18 | const char *PiRet = std::getenv("SYCL_PI_TRACE"); 19 | const char *Trace = UrRet ? UrRet : (PiRet ? PiRet : nullptr); 20 | int TraceValue = 0; 21 | if (Trace) { 22 | try { 23 | TraceValue = std::stoi(Trace); 24 | } catch (...) { 25 | // no-op, we don't have a logger yet to output an error. 26 | } 27 | } 28 | 29 | if (TraceValue == -1 || TraceValue == 2) { 30 | return true; 31 | } 32 | return false; 33 | }(); 34 | -------------------------------------------------------------------------------- /test/conformance/queue/urQueueRelease.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | #include 7 | #include 8 | 9 | using urQueueReleaseTest = uur::urQueueTest; 10 | UUR_INSTANTIATE_DEVICE_TEST_SUITE(urQueueReleaseTest); 11 | 12 | TEST_P(urQueueReleaseTest, Success) { 13 | UUR_KNOWN_FAILURE_ON(uur::NativeCPU{}); 14 | 15 | ASSERT_SUCCESS(urQueueRetain(queue)); 16 | 17 | uint32_t prevRefCount = 0; 18 | ASSERT_SUCCESS(uur::GetObjectReferenceCount(queue, prevRefCount)); 19 | 20 | ASSERT_SUCCESS(urQueueRelease(queue)); 21 | 22 | uint32_t refCount = 0; 23 | ASSERT_SUCCESS(uur::GetObjectReferenceCount(queue, refCount)); 24 | 25 | ASSERT_GT(prevRefCount, refCount); 26 | } 27 | 28 | TEST_P(urQueueReleaseTest, InvalidNullHandleQueue) { 29 | ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, 30 | urQueueRelease(nullptr)); 31 | } 32 | -------------------------------------------------------------------------------- /source/loader/layers/sanitizer/sanitizer_common/sanitizer_options.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (C) 2025 Intel Corporation 4 | * 5 | * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | * Exceptions. See LICENSE.TXT 7 | * 8 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 9 | * 10 | * @file sanitizer_options.hpp 11 | * 12 | */ 13 | 14 | #pragma once 15 | 16 | #include "logger/ur_logger.hpp" 17 | #include "ur/ur.hpp" 18 | 19 | #include 20 | #include 21 | 22 | namespace ur_sanitizer_layer { 23 | 24 | struct SanitizerOptions { 25 | bool Debug = false; 26 | uint64_t MinRZSize = 16; 27 | uint64_t MaxQuarantineSizeMB = 8; 28 | bool DetectLocals = true; 29 | bool DetectPrivates = true; 30 | bool PrintStats = false; 31 | bool DetectKernelArguments = true; 32 | bool DetectLeaks = true; 33 | bool HaltOnError = true; 34 | bool Recover = false; 35 | bool MsanCheckHostAndSharedUSM = true; 36 | 37 | void Init(const std::string &EnvName, logger::Logger &Logger); 38 | }; 39 | 40 | } // namespace ur_sanitizer_layer 41 | -------------------------------------------------------------------------------- /source/adapters/level_zero/enqueue_native.cpp: -------------------------------------------------------------------------------- 1 | //===--------- enqueue_native.cpp - LevelZero Adapter ---------------------===// 2 | // 3 | // Copyright (C) 2024 Intel Corporation 4 | // 5 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | // Exceptions. See LICENSE.TXT 7 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 8 | // 9 | //===----------------------------------------------------------------------===// 10 | 11 | #include 12 | 13 | namespace ur::level_zero { 14 | 15 | ur_result_t urEnqueueNativeCommandExp( 16 | ur_queue_handle_t /*hQueue*/, 17 | ur_exp_enqueue_native_command_function_t /*pfnNativeEnqueue*/, 18 | void * /*data*/, uint32_t /*numMemsInMemList*/, 19 | const ur_mem_handle_t * /*phMemList*/, 20 | const ur_exp_enqueue_native_command_properties_t * /*pProperties*/, 21 | uint32_t /*numEventsInWaitList*/, 22 | const ur_event_handle_t * /*phEventWaitList*/, 23 | ur_event_handle_t * /*phEvent*/) { 24 | 25 | return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; 26 | } 27 | 28 | } // namespace ur::level_zero 29 | -------------------------------------------------------------------------------- /source/adapters/level_zero/sampler.hpp: -------------------------------------------------------------------------------- 1 | //===--------- sampler.hpp - Level Zero Adapter ---------------------------===// 2 | // 3 | // Copyright (C) 2023 Intel Corporation 4 | // 5 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | // Exceptions. See LICENSE.TXT 7 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 8 | // 9 | //===----------------------------------------------------------------------===// 10 | #pragma once 11 | 12 | #include "common.hpp" 13 | #include "common/ur_ref_count.hpp" 14 | 15 | struct ur_sampler_handle_t_ : ur_object { 16 | ur_sampler_handle_t_(ze_sampler_handle_t Sampler) : ZeSampler{Sampler} {} 17 | 18 | // Level Zero sampler handle. 19 | ze_sampler_handle_t ZeSampler; 20 | 21 | ZeStruct ZeSamplerDesc; 22 | 23 | ur::RefCount RefCount; 24 | }; 25 | 26 | // Construct ZE sampler desc from UR sampler desc. 27 | ur_result_t ur2zeSamplerDesc(ze_api_version_t ZeApiVersion, 28 | const ur_sampler_desc_t *SamplerDesc, 29 | ZeStruct &ZeSamplerDesc); 30 | -------------------------------------------------------------------------------- /cmake/FindLibbacktrace.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | # 7 | # FindLIBBACKTRACE.cmake -- module searching for libbacktrace library. 8 | # LIBBACKTRACE_FOUND is set to true if libbacktrace is found. 9 | # 10 | 11 | find_library(LIBBACKTRACE_LIBRARIES NAMES backtrace) 12 | find_path(LIBBACKTRACE_INCLUDE_DIR NAMES backtrace.h) 13 | 14 | if (LIBBACKTRACE_LIBRARIES AND LIBBACKTRACE_INCLUDE_DIR) 15 | set(LIBBACKTRACE_FOUND TRUE) 16 | endif() 17 | 18 | if (LIBBACKTRACE_FOUND) 19 | add_library(Libbacktrace INTERFACE IMPORTED) 20 | set_target_properties(Libbacktrace PROPERTIES 21 | INTERFACE_INCLUDE_DIRECTORIES "${LIBBACKTRACE_INCLUDE_DIR}" 22 | INTERFACE_LINK_LIBRARIES "${LIBBACKTRACE_LIBRARIES}" 23 | ) 24 | endif() 25 | 26 | include(FindPackageHandleStandardArgs) 27 | find_package_handle_standard_args(Libbacktrace DEFAULT_MSG LIBBACKTRACE_LIBRARIES LIBBACKTRACE_INCLUDE_DIR) 28 | -------------------------------------------------------------------------------- /scripts/verify_license.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 Intel Corporation 2 | # 3 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 4 | # See LICENSE.TXT 5 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | import sys 8 | import argparse 9 | 10 | 11 | def verify_file_has_license(file): 12 | with open(file, "r") as in_file: 13 | contents = in_file.read(400) 14 | if "SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception" not in contents: 15 | raise Exception(f"{file} does not contain a license!") 16 | 17 | 18 | def main(): 19 | parser = argparse.ArgumentParser() 20 | parser.add_argument("-f", "--files", nargs="+", default=[]) 21 | args = parser.parse_args() 22 | failed = [] 23 | for file in args.files: 24 | try: 25 | verify_file_has_license(file) 26 | except Exception: 27 | failed.append(file) 28 | 29 | for fail in failed: 30 | print(f"{fail}", file=sys.stderr) 31 | 32 | return len(failed) != 0 33 | 34 | 35 | if __name__ == "__main__": 36 | sys.exit(main()) 37 | -------------------------------------------------------------------------------- /test/conformance/virtual_memory/urVirtualMemUnmap.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | #include 7 | 8 | using urVirtualMemUnmapTest = uur::urVirtualMemTest; 9 | UUR_INSTANTIATE_DEVICE_TEST_SUITE(urVirtualMemUnmapTest); 10 | 11 | TEST_P(urVirtualMemUnmapTest, Success) { 12 | ASSERT_SUCCESS(urVirtualMemMap(context, virtual_ptr, size, physical_mem, 0, 13 | UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE)); 14 | ASSERT_SUCCESS(urVirtualMemUnmap(context, virtual_ptr, size)); 15 | } 16 | 17 | TEST_P(urVirtualMemUnmapTest, InvalidNullHandleContext) { 18 | ASSERT_EQ_RESULT(urVirtualMemUnmap(nullptr, virtual_ptr, size), 19 | UR_RESULT_ERROR_INVALID_NULL_HANDLE); 20 | } 21 | 22 | TEST_P(urVirtualMemUnmapTest, InvalidNullPointerStart) { 23 | ASSERT_EQ_RESULT(urVirtualMemUnmap(context, nullptr, size), 24 | UR_RESULT_ERROR_INVALID_NULL_POINTER); 25 | } 26 | -------------------------------------------------------------------------------- /source/adapters/offload/common.hpp: -------------------------------------------------------------------------------- 1 | //===----------- common.hpp - LLVM Offload Adapter -----------------------===// 2 | // 3 | // Copyright (C) 2024 Intel Corporation 4 | // 5 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | // Exceptions. See LICENSE.TXT 7 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 8 | // 9 | //===----------------------------------------------------------------------===// 10 | 11 | #pragma once 12 | 13 | #include "ur/ur.hpp" 14 | #include "ur2offload.hpp" 15 | #include 16 | 17 | namespace ur::offload { 18 | struct ddi_getter { 19 | const static ur_dditable_t *value(); 20 | }; 21 | using handle_base = ur::handle_base; 22 | } // namespace ur::offload 23 | 24 | struct RefCounted : ur::offload::handle_base { 25 | std::atomic_uint32_t RefCount = 1; 26 | }; 27 | 28 | #define OL_RETURN_ON_ERR(call) \ 29 | if (auto OlRes = call) { \ 30 | return offloadResultToUR(OlRes); \ 31 | } 32 | -------------------------------------------------------------------------------- /source/adapters/level_zero/ur_level_zero.hpp: -------------------------------------------------------------------------------- 1 | //===--------- ur_level_zero.hpp - Level Zero Adapter ---------------------===// 2 | // 3 | // Copyright (C) 2023 Intel Corporation 4 | // 5 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | // Exceptions. See LICENSE.TXT 7 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 8 | // 9 | //===----------------------------------------------------------------------===// 10 | #pragma once 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include "common.hpp" 28 | #include "context.hpp" 29 | #include "device.hpp" 30 | #include "event.hpp" 31 | #include "kernel.hpp" 32 | #include "memory.hpp" 33 | #include "physical_mem.hpp" 34 | #include "platform.hpp" 35 | #include "program.hpp" 36 | #include "queue.hpp" 37 | #include "sampler.hpp" 38 | #include "usm.hpp" 39 | -------------------------------------------------------------------------------- /test/conformance/sampler/urSamplerRetain.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include 8 | #include 9 | 10 | using urSamplerRetainTest = uur::urSamplerTest; 11 | UUR_INSTANTIATE_DEVICE_TEST_SUITE(urSamplerRetainTest); 12 | 13 | TEST_P(urSamplerRetainTest, Success) { 14 | UUR_KNOWN_FAILURE_ON(uur::LevelZero{}, uur::LevelZeroV2{}); 15 | 16 | uint32_t prevRefCount = 0; 17 | ASSERT_SUCCESS(uur::GetObjectReferenceCount(sampler, prevRefCount)); 18 | 19 | ASSERT_SUCCESS(urSamplerRetain(sampler)); 20 | 21 | uint32_t refCount = 0; 22 | ASSERT_SUCCESS(uur::GetObjectReferenceCount(sampler, refCount)); 23 | 24 | ASSERT_LT(prevRefCount, refCount); 25 | 26 | EXPECT_SUCCESS(urSamplerRelease(sampler)); 27 | } 28 | 29 | TEST_P(urSamplerRetainTest, InvalidNullHandleSampler) { 30 | ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, 31 | urSamplerRetain(nullptr)); 32 | } 33 | -------------------------------------------------------------------------------- /test/conformance/platform/urPlatformGetApiVersion.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022-2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include 8 | 9 | using urPlatformGetApiVersionTest = uur::urPlatformTest; 10 | UUR_INSTANTIATE_PLATFORM_TEST_SUITE(urPlatformGetApiVersionTest); 11 | 12 | TEST_P(urPlatformGetApiVersionTest, Success) { 13 | ur_api_version_t version; 14 | ASSERT_EQ_RESULT(UR_RESULT_SUCCESS, 15 | urPlatformGetApiVersion(platform, &version)); 16 | ASSERT_GE(UR_API_VERSION_CURRENT, version); 17 | } 18 | 19 | TEST_P(urPlatformGetApiVersionTest, InvalidPlatform) { 20 | ur_api_version_t version; 21 | ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, 22 | urPlatformGetApiVersion(nullptr, &version)); 23 | } 24 | 25 | TEST_P(urPlatformGetApiVersionTest, InvalidVersionPtr) { 26 | ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, 27 | urPlatformGetApiVersion(platform, nullptr)); 28 | } 29 | -------------------------------------------------------------------------------- /test/conformance/sampler/urSamplerRelease.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include 8 | #include 9 | 10 | using urSamplerReleaseTest = uur::urSamplerTest; 11 | UUR_INSTANTIATE_DEVICE_TEST_SUITE(urSamplerReleaseTest); 12 | 13 | TEST_P(urSamplerReleaseTest, Success) { 14 | UUR_KNOWN_FAILURE_ON(uur::LevelZero{}, uur::LevelZeroV2{}); 15 | 16 | ASSERT_SUCCESS(urSamplerRetain(sampler)); 17 | 18 | uint32_t prevRefCount = 0; 19 | ASSERT_SUCCESS(uur::GetObjectReferenceCount(sampler, prevRefCount)); 20 | 21 | ASSERT_SUCCESS(urSamplerRelease(sampler)); 22 | 23 | uint32_t refCount = 0; 24 | ASSERT_SUCCESS(uur::GetObjectReferenceCount(sampler, refCount)); 25 | 26 | ASSERT_GT(prevRefCount, refCount); 27 | } 28 | 29 | TEST_P(urSamplerReleaseTest, InvalidNullHandleSampler) { 30 | ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, 31 | urSamplerRelease(nullptr)); 32 | } 33 | -------------------------------------------------------------------------------- /test/conformance/device_code/cpy_and_mult.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include 8 | 9 | int main() { 10 | size_t array_size = 16; 11 | sycl::queue sycl_queue; 12 | std::vector src(array_size, 1); 13 | std::vector dst(array_size, 1); 14 | auto src_buff = 15 | sycl::buffer(src.data(), sycl::range<1>(array_size)); 16 | auto dst_buff = 17 | sycl::buffer(dst.data(), sycl::range<1>(array_size)); 18 | 19 | sycl_queue.submit([&](sycl::handler &cgh) { 20 | auto src_acc = src_buff.get_access(cgh); 21 | auto dst_acc = dst_buff.get_access(cgh); 22 | cgh.parallel_for( 23 | sycl::range<1>{array_size}, [src_acc, dst_acc](sycl::item<1> itemId) { 24 | auto id = itemId.get_id(0); 25 | dst_acc[id] = src_acc[id] * 2; 26 | }); 27 | }); 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /test/loader/adapter_registry/search_no_env.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | // RUN: UR_ADAPTERS_SEARCH_PATH="" TEST_ADAPTER_SEARCH_PATH="" TEST_CUR_SEARCH_PATH="%cwd" search-no-env-test 8 | 9 | #include "fixtures.hpp" 10 | 11 | TEST_F(adapterRegSearchTest, testSearchNoEnv) { 12 | // Check if there's any path that's just a library name (disabled on Windows) 13 | #ifndef _WIN32 14 | auto testLibNameExists = 15 | std::any_of(registry.cbegin(), registry.cend(), hasTestLibName); 16 | ASSERT_TRUE(testLibNameExists); 17 | #endif 18 | 19 | // Check for path obtained from 'UR_ADAPTERS_SEARCH_PATH' 20 | auto testEnvPathExists = 21 | std::any_of(registry.cbegin(), registry.cend(), hasTestEnvPath); 22 | ASSERT_FALSE(testEnvPathExists); 23 | 24 | // Check for current directory path 25 | auto testCurPathExists = 26 | std::any_of(registry.cbegin(), registry.cend(), hasCurPath); 27 | ASSERT_TRUE(testCurPathExists); 28 | } 29 | -------------------------------------------------------------------------------- /source/loader/layers/sanitizer/msan/msan_allocator.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (C) 2024 Intel Corporation 4 | * 5 | * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | * Exceptions. See LICENSE.TXT 7 | * 8 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 9 | * 10 | * @file msan_allocator.hpp 11 | * 12 | */ 13 | 14 | #pragma once 15 | 16 | #include "sanitizer_common/sanitizer_allocator.hpp" 17 | #include "sanitizer_common/sanitizer_common.hpp" 18 | #include "sanitizer_common/sanitizer_stacktrace.hpp" 19 | 20 | namespace ur_sanitizer_layer { 21 | namespace msan { 22 | 23 | struct MsanAllocInfo { 24 | uptr AllocBegin = 0; 25 | size_t AllocSize = 0; 26 | 27 | bool IsReleased = false; 28 | 29 | ur_context_handle_t Context = nullptr; 30 | ur_device_handle_t Device = nullptr; 31 | 32 | StackTrace AllocStack; 33 | StackTrace ReleaseStack; 34 | 35 | void print(); 36 | }; 37 | 38 | using MsanAllocationMap = std::map>; 39 | using MsanAllocationIterator = MsanAllocationMap::iterator; 40 | 41 | } // namespace msan 42 | } // namespace ur_sanitizer_layer 43 | -------------------------------------------------------------------------------- /scripts/check-hardening.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if [ -z $1 ]; then 3 | echo "Usage: $0 builddir" >&2; 4 | exit; 5 | fi 6 | 7 | which hardening-check >> /dev/null; 8 | if [ $? != "0" ]; then 9 | echo "hardening-check not found - on Ubuntu it is from the 'devscripts' package." >&2; 10 | exit; 11 | fi 12 | 13 | RET=0; 14 | 15 | for file in $1/bin/*; do 16 | case "$file" in 17 | */urtrace) 18 | # This is a python script 19 | true;; 20 | *) 21 | hardening-check -q --nocfprotection --nofortify $file;; 22 | esac 23 | RET=$(($RET + $?)) 24 | done; 25 | 26 | for file in $1/lib/*.so; do 27 | case "$file" in 28 | */libOpenCL*) 29 | # This is not built as part of UR 30 | true;; 31 | */libzeCallMap.so | */libur_mock.so) 32 | # Only used in testing, and are too simple for many of the hardening flags to have an effect. 33 | true;; 34 | *) 35 | hardening-check -q --nocfprotection --nofortify $file;; 36 | esac 37 | RET=$(($RET + $?)) 38 | done; 39 | 40 | if [ $RET != "0" ]; then 41 | exit 1; 42 | fi 43 | -------------------------------------------------------------------------------- /test/conformance/event/urEventGetNativeHandle.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include "fixtures.h" 8 | 9 | using urEventGetNativeHandleTest = uur::event::urEventTest; 10 | UUR_INSTANTIATE_DEVICE_TEST_SUITE(urEventGetNativeHandleTest); 11 | 12 | TEST_P(urEventGetNativeHandleTest, Success) { 13 | ur_native_handle_t native_event = 0; 14 | if (auto error = urEventGetNativeHandle(event, &native_event)) { 15 | ASSERT_EQ_RESULT(UR_RESULT_ERROR_UNSUPPORTED_FEATURE, error); 16 | } 17 | } 18 | 19 | TEST_P(urEventGetNativeHandleTest, InvalidNullHandleEvent) { 20 | ur_native_handle_t native_event = 0; 21 | ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, 22 | urEventGetNativeHandle(nullptr, &native_event)); 23 | } 24 | 25 | TEST_P(urEventGetNativeHandleTest, InvalidNullPointerNativeEvent) { 26 | ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, 27 | urEventGetNativeHandle(event, nullptr)); 28 | } 29 | -------------------------------------------------------------------------------- /test/conformance/exp_command_buffer/native-command/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2024 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | if (UR_BUILD_ADAPTER_CUDA) 7 | target_sources(exp_command_buffer-test PRIVATE "append_native_cuda.cpp") 8 | target_link_libraries(exp_command_buffer-test PRIVATE cudadrv) 9 | endif() 10 | 11 | if (UR_BUILD_ADAPTER_HIP) 12 | target_sources(exp_command_buffer-test PRIVATE "append_native_hip.cpp") 13 | target_link_libraries(exp_command_buffer-test PRIVATE rocmdrv) 14 | endif() 15 | 16 | if (UR_BUILD_ADAPTER_L0 OR UR_BUILD_ADAPTER_L0_v2) 17 | target_sources(exp_command_buffer-test PRIVATE "append_native_L0.cpp") 18 | target_link_libraries(exp_command_buffer-test PRIVATE LevelZeroLoader LevelZeroLoader-Headers) 19 | endif() 20 | 21 | if (UR_BUILD_ADAPTER_OPENCL) 22 | target_sources(exp_command_buffer-test PRIVATE "append_native_opencl.cpp") 23 | target_link_libraries(exp_command_buffer-test PRIVATE ${OpenCL_LIBRARY} OpenCL-Headers) 24 | endif() 25 | -------------------------------------------------------------------------------- /test/conformance/exp_graph/urQueueEndGraphCaptureExp.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include "fixtures.h" 8 | 9 | using urQueueEndGraphCaptureExpTest = uur::urGraphExpTest; 10 | 11 | UUR_INSTANTIATE_DEVICE_TEST_SUITE(urQueueEndGraphCaptureExpTest); 12 | 13 | TEST_P(urQueueEndGraphCaptureExpTest, SuccessSameGraph) { 14 | ASSERT_SUCCESS(urQueueBeginCaptureIntoGraphExp(queue, graph)); 15 | ur_exp_graph_handle_t sameGraph = nullptr; 16 | ASSERT_SUCCESS(urQueueEndGraphCaptureExp(queue, &sameGraph)); 17 | ASSERT_EQ(graph, sameGraph); 18 | } 19 | 20 | TEST_P(urQueueEndGraphCaptureExpTest, InvalidNullHandleQueue) { 21 | ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, 22 | urQueueEndGraphCaptureExp(nullptr, &graph)); 23 | } 24 | 25 | TEST_P(urQueueEndGraphCaptureExpTest, InvalidNullPtrGraph) { 26 | ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, 27 | urQueueEndGraphCaptureExp(queue, nullptr)); 28 | } 29 | -------------------------------------------------------------------------------- /scripts/templates/optional_queries.h.mako: -------------------------------------------------------------------------------- 1 | <%! 2 | import re 3 | from templates import helper as th 4 | %><% 5 | optional_queries = th.get_optional_queries(specs, namespace, tags) 6 | %>/* 7 | * 8 | * Copyright (C) 2024 Intel Corporation 9 | * 10 | * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 11 | * Exceptions. 12 | * See LICENSE.TXT 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 15 | * 16 | * @file ${filename}.h 17 | * 18 | */ 19 | 20 | // Auto-generated file, do not edit. 21 | 22 | #pragma once 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | namespace uur { 29 | 30 | template bool isQueryOptional(T) { return false; } 31 | 32 | %for type, names in optional_queries.items(): 33 | constexpr std::array optional_${type} = { 34 | %for name in names: 35 | ${name}, 36 | %endfor 37 | }; 38 | 39 | template <> inline bool isQueryOptional(${type} query) { 40 | return std::find(optional_${type}.begin(), 41 | optional_${type}.end(), 42 | query) != optional_${type}.end(); 43 | } 44 | 45 | %endfor 46 | 47 | } 48 | -------------------------------------------------------------------------------- /test/conformance/device_code/fill_usm_2d.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include 8 | 9 | int main() { 10 | 11 | size_t nd_range_x = 8; 12 | size_t nd_range_y = 8; 13 | 14 | auto nd_range = sycl::range<2>(nd_range_x, nd_range_y); 15 | 16 | std::vector A(nd_range_x * nd_range_y, 1); 17 | uint32_t val = 42; 18 | sycl::queue sycl_queue; 19 | 20 | auto work_range = sycl::nd_range<2>(nd_range, sycl::range<2>(1, 1)); 21 | 22 | uint32_t *data = 23 | sycl::malloc_shared(nd_range_x * nd_range_y, sycl_queue); 24 | sycl_queue.submit([&](sycl::handler &cgh) { 25 | cgh.parallel_for(work_range, 26 | [data, val](sycl::nd_item<2> item_id) { 27 | auto id = item_id.get_global_linear_id(); 28 | data[id] = val; 29 | }); 30 | }); 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /test/conformance/device/urDeviceGetNativeHandle.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022-2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | #include 7 | 8 | using urDeviceGetNativeHandleTest = uur::urDeviceTest; 9 | UUR_INSTANTIATE_DEVICE_TEST_SUITE(urDeviceGetNativeHandleTest); 10 | 11 | TEST_P(urDeviceGetNativeHandleTest, Success) { 12 | ur_native_handle_t native_handle = 0; 13 | if (auto error = urDeviceGetNativeHandle(device, &native_handle)) { 14 | ASSERT_EQ_RESULT(UR_RESULT_ERROR_UNSUPPORTED_FEATURE, error); 15 | } 16 | } 17 | 18 | TEST_P(urDeviceGetNativeHandleTest, InvalidNullHandleDevice) { 19 | ur_native_handle_t native_handle = 0; 20 | ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, 21 | urDeviceGetNativeHandle(nullptr, &native_handle)); 22 | } 23 | 24 | TEST_P(urDeviceGetNativeHandleTest, InvalidNullPointerNativeDevice) { 25 | ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, 26 | urDeviceGetNativeHandle(device, nullptr)); 27 | } 28 | -------------------------------------------------------------------------------- /test/conformance/device_code/sequence.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include 8 | #include 9 | 10 | class Add; 11 | class Mul; 12 | 13 | int main() { 14 | sycl::queue deviceQueue; 15 | uint32_t val = 0; 16 | 17 | auto buff = sycl::buffer(&val, 1); 18 | 19 | deviceQueue.submit([&](sycl::handler &cgh) { 20 | auto acc = buff.get_access(cgh); 21 | cgh.single_task([=]() { 22 | for (uint32_t i = 0; i < 1000; i++) { 23 | volatile uint32_t tmp = acc[0]; 24 | acc[0] = tmp + 1; 25 | } 26 | }); 27 | }); 28 | 29 | deviceQueue.submit([&](sycl::handler &cgh) { 30 | auto acc = buff.get_access(cgh); 31 | cgh.single_task([=]() { 32 | for (uint32_t i = 0; i < 2; i++) { 33 | volatile uint32_t tmp = acc[0]; 34 | acc[0] = tmp * 2; 35 | } 36 | }); 37 | }); 38 | 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /test/loader/adapter_registry/search_with_env.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | // RUN: UR_ADAPTERS_SEARCH_PATH="%binary-dir" TEST_ADAPTER_SEARCH_PATH="%binary-dir" TEST_CUR_SEARCH_PATH="%cwd" search-with-env-test 8 | 9 | #include "fixtures.hpp" 10 | 11 | TEST_F(adapterRegSearchTest, testSearchWithEnv) { 12 | // Check if there's any path that's just a library name (disabled on Windows). 13 | #ifndef _WIN32 14 | auto testLibNameExists = 15 | std::any_of(registry.cbegin(), registry.cend(), hasTestLibName); 16 | ASSERT_TRUE(testLibNameExists); 17 | #endif 18 | 19 | // Check for path obtained from 'UR_ADAPTERS_SEARCH_PATH' 20 | auto testEnvPathExists = 21 | std::any_of(registry.cbegin(), registry.cend(), hasTestEnvPath); 22 | ASSERT_TRUE(testEnvPathExists); 23 | 24 | // Check for current directory path 25 | auto testCurPathExists = 26 | std::any_of(registry.cbegin(), registry.cend(), hasCurPath); 27 | ASSERT_TRUE(testCurPathExists); 28 | } 29 | -------------------------------------------------------------------------------- /source/loader/layers/sanitizer/asan/asan_quarantine.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (C) 2024 Intel Corporation 4 | * 5 | * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | * Exceptions. See LICENSE.TXT 7 | * 8 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 9 | * 10 | * @file asan_quarantine.cpp 11 | * 12 | */ 13 | 14 | #include "asan_quarantine.hpp" 15 | 16 | namespace ur_sanitizer_layer { 17 | namespace asan { 18 | 19 | std::vector Quarantine::put(ur_device_handle_t Device, 20 | AllocationIterator &It) { 21 | auto &AI = It->second; 22 | auto AllocSize = AI->AllocSize; 23 | auto &Cache = getCache(Device); 24 | 25 | std::vector DequeueList; 26 | std::scoped_lock Guard(Cache.Mutex); 27 | while (Cache.size() + AllocSize > m_MaxQuarantineSize) { 28 | auto ElementOp = Cache.dequeue(); 29 | if (!ElementOp) { 30 | break; 31 | } 32 | DequeueList.emplace_back(*ElementOp); 33 | } 34 | Cache.enqueue(It); 35 | return DequeueList; 36 | } 37 | 38 | } // namespace asan 39 | } // namespace ur_sanitizer_layer 40 | -------------------------------------------------------------------------------- /source/loader/layers/sanitizer/sanitizer_common/sanitizer_stackdepot.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (C) 2025 Intel Corporation 4 | * 5 | * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | * Exceptions. See LICENSE.TXT 7 | * 8 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 9 | * 10 | * @file sanitizer_stackdepot.hpp 11 | * 12 | */ 13 | 14 | #pragma once 15 | 16 | #include "sanitizer_stacktrace.hpp" 17 | 18 | namespace ur_sanitizer_layer { 19 | 20 | const uint32_t kHeapTypeCount = 4; 21 | enum HeapType { DeviceUSM, HostUSM, SharedUSM, Local }; 22 | 23 | inline const char *ToString(HeapType Type) { 24 | switch (Type) { 25 | case HeapType::DeviceUSM: 26 | return "Device USM"; 27 | case HeapType::HostUSM: 28 | return "Host USM"; 29 | case HeapType::SharedUSM: 30 | return "Shared USM"; 31 | case HeapType::Local: 32 | return "Local Memory"; 33 | default: 34 | return "Unknown Heap Type"; 35 | } 36 | } 37 | 38 | // Save/load stack with corresponding stack id 39 | void StackDepotPut(uint32_t Id, StackTrace &Stack); 40 | StackTrace StackDepotGet(uint32_t Id); 41 | 42 | } // namespace ur_sanitizer_layer 43 | -------------------------------------------------------------------------------- /test/unit/helpers.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include 8 | #include 9 | 10 | #include "ur_util.hpp" 11 | 12 | TEST(groupDigits, Success) { 13 | EXPECT_EQ(groupDigits(-1), "-1"); 14 | EXPECT_EQ(groupDigits(-12), "-12"); 15 | EXPECT_EQ(groupDigits(-123), "-123"); 16 | EXPECT_EQ(groupDigits(-1234), "-1'234"); 17 | EXPECT_EQ(groupDigits(-12345), "-12'345"); 18 | EXPECT_EQ(groupDigits(-123456), "-123'456"); 19 | EXPECT_EQ(groupDigits(-1234567), "-1'234'567"); 20 | EXPECT_EQ(groupDigits(-12345678), "-12'345'678"); 21 | 22 | EXPECT_EQ(groupDigits(0), "0"); 23 | EXPECT_EQ(groupDigits(1), "1"); 24 | EXPECT_EQ(groupDigits(12), "12"); 25 | EXPECT_EQ(groupDigits(123), "123"); 26 | EXPECT_EQ(groupDigits(1234), "1'234"); 27 | EXPECT_EQ(groupDigits(12345), "12'345"); 28 | EXPECT_EQ(groupDigits(123456), "123'456"); 29 | EXPECT_EQ(groupDigits(1234567), "1'234'567"); 30 | EXPECT_EQ(groupDigits(12345678), "12'345'678"); 31 | } 32 | -------------------------------------------------------------------------------- /tools/urtrace/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | set(TARGET_NAME ur_collector) 7 | 8 | add_ur_library(${TARGET_NAME} SHARED 9 | ${CMAKE_CURRENT_SOURCE_DIR}/collector.cpp 10 | ) 11 | 12 | target_include_directories(${TARGET_NAME} PRIVATE 13 | ${PROJECT_SOURCE_DIR}/include 14 | ) 15 | 16 | target_link_libraries(${TARGET_NAME} PRIVATE ${TARGET_XPTI} ${PROJECT_NAME}::common ${CMAKE_DL_LIBS}) 17 | target_include_directories(${TARGET_NAME} PRIVATE ${xpti_SOURCE_DIR}/include) 18 | 19 | if(MSVC) 20 | target_compile_definitions(${TARGET_NAME} PRIVATE XPTI_STATIC_LIBRARY) 21 | endif() 22 | target_compile_definitions(${TARGET_NAME} PRIVATE XPTI_CALLBACK_API_EXPORTS) 23 | 24 | set(UR_TRACE_CLI_BIN ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/urtrace) 25 | 26 | add_custom_target(ur_trace_cli) 27 | add_custom_command(TARGET ur_trace_cli PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/urtrace.py ${UR_TRACE_CLI_BIN}) 28 | add_dependencies(ur_collector ur_trace_cli) 29 | -------------------------------------------------------------------------------- /source/adapters/offload/event.hpp: -------------------------------------------------------------------------------- 1 | //===----------- event.hpp - LLVM Offload Adapter ------------------------===// 2 | // 3 | // Copyright (C) 2025 Intel Corporation 4 | // 5 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | // Exceptions. See LICENSE.TXT 7 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 8 | // 9 | //===----------------------------------------------------------------------===// 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | 16 | #include "common.hpp" 17 | 18 | struct ur_event_handle_t_ : RefCounted { 19 | ol_event_handle_t OffloadEvent; 20 | ur_command_t Type; 21 | ur_queue_handle_t UrQueue; 22 | 23 | ur_event_handle_t_(ur_command_t Type, ur_queue_handle_t Queue) 24 | : Type(Type), UrQueue(Queue) {} 25 | 26 | static ur_event_handle_t createEmptyEvent(ur_command_t Type, 27 | ur_queue_handle_t Queue) { 28 | auto *Event = new ur_event_handle_t_(Type, Queue); 29 | // Null event represents an empty event. Waiting on it is a no-op. 30 | Event->OffloadEvent = nullptr; 31 | 32 | return Event; 33 | } 34 | }; 35 | -------------------------------------------------------------------------------- /test/conformance/context/urContextGetNativeHandle.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include 8 | 9 | using urContextGetNativeHandleTest = uur::urContextTest; 10 | UUR_INSTANTIATE_DEVICE_TEST_SUITE(urContextGetNativeHandleTest); 11 | 12 | TEST_P(urContextGetNativeHandleTest, Success) { 13 | ur_native_handle_t native_context = 0; 14 | if (auto error = urContextGetNativeHandle(context, &native_context)) { 15 | ASSERT_EQ_RESULT(UR_RESULT_ERROR_UNSUPPORTED_FEATURE, error); 16 | } 17 | } 18 | 19 | TEST_P(urContextGetNativeHandleTest, InvalidNullHandleContext) { 20 | ur_native_handle_t native_handle = 0; 21 | ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, 22 | urContextGetNativeHandle(nullptr, &native_handle)); 23 | } 24 | 25 | TEST_P(urContextGetNativeHandleTest, InvalidNullPointerNativeHandle) { 26 | ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, 27 | urContextGetNativeHandle(context, nullptr)); 28 | } 29 | -------------------------------------------------------------------------------- /test/conformance/sampler/urSamplerGetNativeHandle.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include 8 | 9 | using urSamplerGetNativeHandleTest = uur::urSamplerTest; 10 | 11 | UUR_INSTANTIATE_DEVICE_TEST_SUITE(urSamplerGetNativeHandleTest); 12 | 13 | TEST_P(urSamplerGetNativeHandleTest, Success) { 14 | ur_native_handle_t native_sampler = 0; 15 | if (auto error = urSamplerGetNativeHandle(sampler, &native_sampler)) { 16 | ASSERT_EQ_RESULT(UR_RESULT_ERROR_UNSUPPORTED_FEATURE, error); 17 | } 18 | } 19 | 20 | TEST_P(urSamplerGetNativeHandleTest, InvalidNullHandleSampler) { 21 | ur_native_handle_t native_handle = 0; 22 | ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, 23 | urSamplerGetNativeHandle(nullptr, &native_handle)); 24 | } 25 | 26 | TEST_P(urSamplerGetNativeHandleTest, InvalidNullPointerNativeHandle) { 27 | ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, 28 | urSamplerGetNativeHandle(sampler, nullptr)); 29 | } 30 | -------------------------------------------------------------------------------- /test/conformance/usm/urUSMPoolRetain.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include "ur_api.h" 8 | #include 9 | 10 | using urUSMPoolRetainTest = uur::urUSMPoolTest; 11 | UUR_INSTANTIATE_DEVICE_TEST_SUITE(urUSMPoolRetainTest); 12 | 13 | TEST_P(urUSMPoolRetainTest, Success) { 14 | uint32_t prevRefCount = 0; 15 | ASSERT_SUCCESS(uur::GetObjectReferenceCount(pool, prevRefCount)); 16 | 17 | ASSERT_SUCCESS(urUSMPoolRetain(pool)); 18 | 19 | uint32_t refCount = 0; 20 | ASSERT_SUCCESS(uur::GetObjectReferenceCount(pool, refCount)); 21 | 22 | ASSERT_LT(prevRefCount, refCount); 23 | 24 | ASSERT_SUCCESS(urUSMPoolRelease(pool)); 25 | 26 | uint32_t afterRefCount = 0; 27 | ASSERT_SUCCESS(uur::GetObjectReferenceCount(pool, afterRefCount)); 28 | 29 | ASSERT_LT(afterRefCount, refCount); 30 | } 31 | 32 | TEST_P(urUSMPoolRetainTest, InvalidNullHandlePool) { 33 | ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, 34 | urUSMPoolRetain(nullptr)); 35 | } 36 | -------------------------------------------------------------------------------- /scripts/templates/queue_api.hpp.mako: -------------------------------------------------------------------------------- 1 | <%! 2 | import re 3 | from templates import helper as th 4 | %><% 5 | n=namespace 6 | N=n.upper() 7 | 8 | x=tags['$x'] 9 | X=x.upper() 10 | %>/* 11 | * 12 | * Copyright (C) 2024 Intel Corporation 13 | * 14 | * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 15 | * Exceptions. See LICENSE.TXT 16 | * 17 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 18 | * 19 | * @file ${name}.hpp 20 | * 21 | */ 22 | 23 | // Do not edit. This file is auto generated from a template: scripts/templates/queue_api.hpp.mako 24 | 25 | #pragma once 26 | 27 | #include 28 | #include "queue_extensions.hpp" 29 | 30 | struct ur_queue_t_ : ur_queue_extensions { 31 | virtual ~ur_queue_t_(); 32 | 33 | %for obj in th.get_queue_related_functions(specs, n, tags): 34 | %if not 'Release' in obj['name'] and not 'Retain' in obj['name']: 35 | %if 'guard' in obj: 36 | #if ${obj['guard']} 37 | %endif 38 | virtual ${x}_result_t ${th.transform_queue_related_function_name(n, tags, obj, format=["type"])} = 0; 39 | %if 'guard' in obj: 40 | #endif // ${obj['guard']} 41 | %endif 42 | %endif 43 | %endfor 44 | }; 45 | -------------------------------------------------------------------------------- /test/conformance/kernel/urKernelGetNativeHandle.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include 8 | 9 | using urKernelGetNativeHandleTest = uur::urKernelTest; 10 | UUR_INSTANTIATE_DEVICE_TEST_SUITE(urKernelGetNativeHandleTest); 11 | 12 | TEST_P(urKernelGetNativeHandleTest, Success) { 13 | ur_native_handle_t native_kernel_handle = 0; 14 | if (auto error = urKernelGetNativeHandle(kernel, &native_kernel_handle)) { 15 | ASSERT_EQ_RESULT(UR_RESULT_ERROR_UNSUPPORTED_FEATURE, error); 16 | } 17 | } 18 | 19 | TEST_P(urKernelGetNativeHandleTest, InvalidNullHandleKernel) { 20 | ur_native_handle_t native_kernel_handle = 0; 21 | ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, 22 | urKernelGetNativeHandle(nullptr, &native_kernel_handle)); 23 | } 24 | 25 | TEST_P(urKernelGetNativeHandleTest, InvalidNullPointerNativeKernel) { 26 | ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, 27 | urKernelGetNativeHandle(kernel, nullptr)); 28 | } 29 | -------------------------------------------------------------------------------- /test/conformance/platform/urPlatformGetNativeHandle.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022-2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include 8 | 9 | using urPlatformGetNativeHandleTest = uur::urPlatformTest; 10 | UUR_INSTANTIATE_PLATFORM_TEST_SUITE(urPlatformGetNativeHandleTest); 11 | 12 | TEST_P(urPlatformGetNativeHandleTest, Success) { 13 | ur_native_handle_t native_handle = 0; 14 | if (auto error = urPlatformGetNativeHandle(platform, &native_handle)) { 15 | ASSERT_EQ(UR_RESULT_ERROR_UNSUPPORTED_FEATURE, error); 16 | } 17 | } 18 | 19 | TEST_P(urPlatformGetNativeHandleTest, InvalidNullHandlePlatform) { 20 | ur_native_handle_t native_handle = 0; 21 | ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, 22 | urPlatformGetNativeHandle(nullptr, &native_handle)); 23 | } 24 | 25 | TEST_P(urPlatformGetNativeHandleTest, InvalidNullPointerNativePlatform) { 26 | ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, 27 | urPlatformGetNativeHandle(platform, nullptr)); 28 | } 29 | -------------------------------------------------------------------------------- /test/adapters/cuda/urDeviceCreateWithNativeHandle.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022-2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include "fixtures.h" 8 | 9 | using urCudaDeviceCreateWithNativeHandle = uur::urPlatformTest; 10 | UUR_INSTANTIATE_PLATFORM_TEST_SUITE(urCudaDeviceCreateWithNativeHandle); 11 | 12 | TEST_P(urCudaDeviceCreateWithNativeHandle, Success) { 13 | // get a device from cuda 14 | int nCudaDevices; 15 | ASSERT_SUCCESS_CUDA(cuDeviceGetCount(&nCudaDevices)); 16 | ASSERT_GT(nCudaDevices, 0); 17 | CUdevice cudaDevice; 18 | ASSERT_SUCCESS_CUDA(cuDeviceGet(&cudaDevice, 0)); 19 | 20 | ur_native_handle_t nativeCuda = static_cast(cudaDevice); 21 | 22 | ur_adapter_handle_t adapter = nullptr; 23 | ASSERT_SUCCESS(urPlatformGetInfo(platform, UR_PLATFORM_INFO_ADAPTER, 24 | sizeof(adapter), &adapter, nullptr)); 25 | 26 | ur_device_handle_t urDevice = nullptr; 27 | ASSERT_SUCCESS( 28 | urDeviceCreateWithNativeHandle(nativeCuda, adapter, nullptr, &urDevice)); 29 | } 30 | -------------------------------------------------------------------------------- /test/conformance/device_code/fill_2d.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include 8 | 9 | int main() { 10 | size_t nd_range_x = 8; 11 | size_t nd_range_y = 8; 12 | auto nd_range = sycl::range<2>(nd_range_x, nd_range_y); 13 | 14 | std::vector A(nd_range_x * nd_range_y, 1); 15 | uint32_t val = 42; 16 | sycl::queue sycl_queue; 17 | 18 | auto work_range = sycl::nd_range<2>(nd_range, sycl::range<2>(1, 1)); 19 | auto A_buff = 20 | sycl::buffer(A.data(), sycl::range<1>(nd_range_x * nd_range_y)); 21 | sycl_queue.submit([&](sycl::handler &cgh) { 22 | auto A_acc = A_buff.get_access(cgh); 23 | cgh.parallel_for(work_range, 24 | [A_acc, val](sycl::nd_item<2> item_id) { 25 | auto id = item_id.get_global_linear_id(); 26 | A_acc[id] = val; 27 | }); 28 | }); 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | *.exp 10 | *.pdb 11 | *.log 12 | *.tlog 13 | *.ilk 14 | *.idb 15 | *.CopyComplete 16 | *.pyc 17 | *.tmp 18 | 19 | # Precompiled Headers 20 | *.gch 21 | *.pch 22 | *.ipch 23 | 24 | # Compiled Dynamic libraries 25 | *.so 26 | *.dylib 27 | *.dll 28 | 29 | # Project files 30 | *.sln 31 | *.vcproj 32 | *.vcxproj 33 | *.pyproj 34 | *.suo 35 | *.db 36 | *.opendb 37 | *.user 38 | *.filters 39 | .vs/ 40 | .idea/ 41 | 42 | # Compiled Static libraries 43 | *.lai 44 | *.la 45 | *.a 46 | *.lib 47 | 48 | # Executables 49 | *.exe 50 | *.out 51 | *.app 52 | 53 | # Debug files 54 | scripts/**/*.json 55 | 56 | # Python cache 57 | __pycache__/ 58 | *.py[cod] 59 | 60 | # Generated docs 61 | docs/ 62 | 63 | # Build files 64 | /build*/ 65 | out/ 66 | 67 | # irepo files 68 | .irepo 69 | 70 | # ci deps 71 | .deps 72 | 73 | # third_party files 74 | /third_party/*/ 75 | 76 | 77 | # VS CMake settings 78 | /CMakeSettings.json 79 | 80 | # Temporary files 81 | *.~vsdx 82 | 83 | # IDE Files 84 | /.vscode 85 | /.devcontainer 86 | 87 | # External content 88 | */**/external 89 | 90 | # VS clangd 91 | /.cache 92 | /compile_commands.json 93 | -------------------------------------------------------------------------------- /cmake/FindLit.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2025 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | 7 | # There are two modes to finding lit and filecheck 8 | # If we are a standalone build, use the python packages 9 | # If we are not a standalone build, use the one provided by LLVM 10 | # Note that the python filecheck re-implementation isn't 100% compatible, but hopefully for simple tests it should be 11 | # good enough 12 | 13 | if(UR_STANDALONE_BUILD) 14 | # Standalone build 15 | find_program(URLIT_LIT_BINARY "lit") 16 | if(NOT URLIT_LIT_BINARY) 17 | message(FATAL_ERROR "No `lit` binary was found in path. Consider installing the python Package `lit`") 18 | endif() 19 | 20 | find_program(URLIT_FILECHECK_BINARY NAMES "filecheck" "FileCheck") 21 | if(NOT URLIT_FILECHECK_BINARY) 22 | message(FATAL_ERROR "No `filecheck` or `FileCheck` binary was found in path. Consider installing the python Package `filecheck`") 23 | endif() 24 | else() 25 | # In source build 26 | 27 | # This will be in the $PATH 28 | set(URLIT_FILECHECK_BINARY "FileCheck") 29 | endif() 30 | -------------------------------------------------------------------------------- /scripts/templates/manifests.hpp.mako: -------------------------------------------------------------------------------- 1 | <%! 2 | from templates import helper as th 3 | %>/* 4 | * 5 | * Copyright (C) 2025 Intel Corporation 6 | * 7 | * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 8 | * Exceptions. 9 | * See LICENSE.TXT 10 | * 11 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 12 | * 13 | * @file ${name}.hpp 14 | * 15 | */ 16 | 17 | // Auto-generated file, do not edit. 18 | 19 | #pragma once 20 | 21 | #include 22 | #include 23 | 24 | #include "ur_util.hpp" 25 | #include 26 | 27 | namespace ur_loader { 28 | struct ur_adapter_manifest { 29 | std::string name; 30 | std::string library; 31 | ur_backend_t backend; 32 | std::vector device_types; 33 | }; 34 | 35 | const std::vector ur_adapter_manifests = { 36 | %for manifest in th.get_adapter_manifests(specs): 37 | { 38 | "${manifest['name']}", 39 | MAKE_LIBRARY_NAME("ur_adapter_${manifest['name']}", "0"), 40 | ${th.subt(namespace, tags, manifest['backend'])}, 41 | { 42 | %for device_type in manifest['device_types']: 43 | ${th.subt(namespace, tags, device_type)}, 44 | %endfor 45 | } 46 | }, 47 | %endfor 48 | }; 49 | } 50 | -------------------------------------------------------------------------------- /test/adapters/hip/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 Intel Corporation 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 3 | # See LICENSE.TXT 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | if(NOT UR_FOUND_DPCXX) 7 | message(WARNING 8 | "UR_DPCXX is not defined, skipping adapter-specific tests for HIP") 9 | return() 10 | endif() 11 | 12 | add_ur_lit_testsuite(hip) 13 | add_dependencies(check-unified-runtime-adapter check-unified-runtime-hip) 14 | 15 | add_conformance_kernels_test(adapter-hip 16 | fixtures.h 17 | urContextGetNativeHandle.cpp 18 | urDeviceGetNativeHandle.cpp 19 | urEventGetNativeHandle.cpp 20 | test_context.cpp 21 | test_event.cpp 22 | kernel_tests.cpp 23 | ) 24 | 25 | target_include_directories(adapter-hip-test PRIVATE 26 | ${PROJECT_SOURCE_DIR}/source 27 | ${PROJECT_SOURCE_DIR}/source/adapters/hip 28 | ) 29 | 30 | get_target_property(HIP_COMPILE_DEFINITIONS 31 | ur_adapter_hip COMPILE_DEFINITIONS) 32 | target_compile_definitions(adapter-hip-test PRIVATE 33 | ${HIP_COMPILE_DEFINITIONS} 34 | ) 35 | 36 | target_link_libraries(adapter-hip-test PRIVATE rocmdrv ${PROJECT_NAME}::umf) 37 | -------------------------------------------------------------------------------- /test/conformance/usm/urUSMPoolRelease.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include 8 | 9 | using urUSMPoolReleaseTest = uur::urUSMPoolTest; 10 | UUR_INSTANTIATE_DEVICE_TEST_SUITE(urUSMPoolReleaseTest); 11 | 12 | TEST_P(urUSMPoolReleaseTest, Success) { 13 | uint32_t prevRefCount = 0; 14 | ASSERT_SUCCESS(uur::GetObjectReferenceCount(pool, prevRefCount)); 15 | 16 | ASSERT_SUCCESS(urUSMPoolRetain(pool)); 17 | 18 | uint32_t refCount = 0; 19 | ASSERT_SUCCESS(uur::GetObjectReferenceCount(pool, refCount)); 20 | 21 | ASSERT_LT(prevRefCount, refCount); 22 | 23 | ASSERT_SUCCESS(urUSMPoolRelease(pool)); 24 | 25 | uint32_t afterRefCount = 0; 26 | ASSERT_SUCCESS(uur::GetObjectReferenceCount(pool, afterRefCount)); 27 | 28 | ASSERT_LT(afterRefCount, refCount); 29 | 30 | pool = nullptr; // prevent double-delete 31 | } 32 | 33 | TEST_P(urUSMPoolReleaseTest, InvalidNullHandle) { 34 | ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, 35 | urUSMPoolRelease(nullptr)); 36 | } 37 | -------------------------------------------------------------------------------- /examples/codegen/README.md: -------------------------------------------------------------------------------- 1 | ## End-to-end code generation example 2 | 3 | This example demonstrates an end-to-end pipeline of code generation and execution that typically occurs in a JIT engine. 4 | It creates a simple function (adding +1 to an array and storing the result in a second one) via llvm API, 5 | converts it to spirv, and submits it to the runtime. 6 | 7 | ## Running the example 8 | 9 | The following commands are executed from the project root directory. 10 | 11 | ### Using conda environment 12 | 13 | ``` 14 | $ conda env create -f third_party/deps.yml 15 | $ conda activate examples 16 | $ mkdir build && cd build 17 | # configure with: 18 | $ cmake .. -DUR_BUILD_ADAPTER_L0=ON -DUR_BUILD_EXAMPLE_CODEGEN=ON 19 | $ make 20 | $ ./bin/codegen 21 | ``` 22 | 23 | ### Without using conda 24 | 25 | To run the example with llvm 13, you will need to make sure that `llvm-13` and `libllvmspirvlib-13-dev` are installed. 26 | 27 | **NOTE**: The example could be working with other llvm versions but it was tested with version 13. 28 | 29 | ``` 30 | $ mkdir build && cd build 31 | # configure with: 32 | $ cmake .. -DUR_BUILD_ADAPTER_L0=ON -DUR_BUILD_EXAMPLE_CODEGEN=ON -DLLVM_DIR=/usr/lib/llvm-13/cmake 33 | $ make 34 | $ ./bin/codegen 35 | ``` 36 | -------------------------------------------------------------------------------- /test/adapters/level_zero/lit.local.cfg.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (C) 2025 Intel Corporation 3 | 4 | Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. 5 | See LICENSE.TXT 6 | SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7 | 8 | """ 9 | 10 | from os import path 11 | import lit.formats 12 | 13 | config.suffixes = [".test", ".cpp"] 14 | 15 | if config.l0_v1_enabled: 16 | config.substitutions.append((r"%maybe-v1", r"%with-v1")) 17 | config.substitutions.append((r"%with-v1", "UR_LOADER_USE_LEVEL_ZERO_V2=0")) 18 | config.available_features.add("v1") 19 | else: 20 | config.substitutions.append( 21 | (r"%maybe-v1", "echo 'Level Zero V1 is not available' || ") 22 | ) 23 | 24 | if config.l0_v2_enabled: 25 | config.substitutions.append((r"%maybe-v2", r"%with-v2")) 26 | config.substitutions.append((r"%with-v2", "UR_LOADER_USE_LEVEL_ZERO_V2=1")) 27 | config.available_features.add("v2") 28 | else: 29 | config.substitutions.append( 30 | (r"%maybe-v2", "echo 'Level Zero V2 is not available' || ") 31 | ) 32 | 33 | if config.l0_static_link: 34 | config.available_features.add("static-link") 35 | 36 | config.environment["ONEAPI_DEVICE_SELECTOR"] = "level_zero:*" 37 | -------------------------------------------------------------------------------- /test/conformance/exp_command_buffer/retain.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include "fixtures.h" 8 | 9 | using urCommandBufferRetainExpTest = 10 | uur::command_buffer::urCommandBufferExpTest; 11 | 12 | UUR_INSTANTIATE_DEVICE_TEST_SUITE(urCommandBufferRetainExpTest); 13 | 14 | TEST_P(urCommandBufferRetainExpTest, Success) { 15 | // https://github.com/intel/llvm/issues/19139 16 | UUR_KNOWN_FAILURE_ON(uur::OpenCL{}); 17 | uint32_t prev_ref_count = 0; 18 | EXPECT_SUCCESS(uur::GetObjectReferenceCount(cmd_buf_handle, prev_ref_count)); 19 | 20 | EXPECT_SUCCESS(urCommandBufferRetainExp(cmd_buf_handle)); 21 | 22 | uint32_t ref_count = 0; 23 | EXPECT_SUCCESS(uur::GetObjectReferenceCount(cmd_buf_handle, ref_count)); 24 | 25 | EXPECT_LT(prev_ref_count, ref_count); 26 | 27 | EXPECT_SUCCESS(urCommandBufferReleaseExp(cmd_buf_handle)); 28 | } 29 | 30 | TEST_P(urCommandBufferRetainExpTest, InvalidNullHandle) { 31 | EXPECT_EQ_RESULT(urCommandBufferRetainExp(nullptr), 32 | UR_RESULT_ERROR_INVALID_NULL_HANDLE); 33 | } 34 | -------------------------------------------------------------------------------- /test/loader/loader_config/urLoaderConfigRetain.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022-2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include "fixtures.hpp" 8 | 9 | using urLoaderConfigRetainTest = LoaderConfigTest; 10 | 11 | TEST_F(urLoaderConfigRetainTest, Success) { 12 | uint32_t prevRefCount = 0; 13 | ASSERT_SUCCESS( 14 | urLoaderConfigGetInfo(loaderConfig, UR_LOADER_CONFIG_INFO_REFERENCE_COUNT, 15 | sizeof(prevRefCount), &prevRefCount, nullptr)); 16 | 17 | ASSERT_SUCCESS(urLoaderConfigRetain(loaderConfig)); 18 | 19 | uint32_t refCount = 0; 20 | ASSERT_SUCCESS(urLoaderConfigGetInfo(loaderConfig, 21 | UR_LOADER_CONFIG_INFO_REFERENCE_COUNT, 22 | sizeof(refCount), &refCount, nullptr)); 23 | 24 | ASSERT_GT(refCount, prevRefCount); 25 | 26 | ASSERT_SUCCESS(urLoaderConfigRelease(loaderConfig)); 27 | } 28 | 29 | TEST_F(urLoaderConfigRetainTest, InvalidNullHandleLoaderConfig) { 30 | ASSERT_EQ(UR_RESULT_ERROR_INVALID_NULL_HANDLE, urLoaderConfigRetain(nullptr)); 31 | } 32 | -------------------------------------------------------------------------------- /test/conformance/exp_command_buffer/release.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include "fixtures.h" 8 | 9 | using urCommandBufferReleaseExpTest = 10 | uur::command_buffer::urCommandBufferExpTest; 11 | 12 | UUR_INSTANTIATE_DEVICE_TEST_SUITE(urCommandBufferReleaseExpTest); 13 | 14 | TEST_P(urCommandBufferReleaseExpTest, Success) { 15 | // https://github.com/intel/llvm/issues/19139 16 | UUR_KNOWN_FAILURE_ON(uur::OpenCL{}); 17 | ASSERT_SUCCESS(urCommandBufferRetainExp(cmd_buf_handle)); 18 | 19 | uint32_t prev_ref_count = 0; 20 | ASSERT_SUCCESS(uur::GetObjectReferenceCount(cmd_buf_handle, prev_ref_count)); 21 | 22 | ASSERT_SUCCESS(urCommandBufferReleaseExp(cmd_buf_handle)); 23 | 24 | uint32_t ref_count = 0; 25 | ASSERT_SUCCESS(uur::GetObjectReferenceCount(cmd_buf_handle, ref_count)); 26 | 27 | EXPECT_GT(prev_ref_count, ref_count); 28 | } 29 | 30 | TEST_P(urCommandBufferReleaseExpTest, InvalidNullHandle) { 31 | EXPECT_EQ_RESULT(urCommandBufferReleaseExp(nullptr), 32 | UR_RESULT_ERROR_INVALID_NULL_HANDLE); 33 | } 34 | -------------------------------------------------------------------------------- /source/common/backtrace_lin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (C) 2023-2025 Intel Corporation 4 | * 5 | * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 6 | * Exceptions. See LICENSE.TXT 7 | * 8 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 9 | * 10 | */ 11 | #include "backtrace.hpp" 12 | #include 13 | 14 | namespace ur { 15 | 16 | std::vector getCurrentBacktrace() { 17 | void *backtraceFrames[MAX_BACKTRACE_FRAMES]; 18 | int frameCount = ::backtrace(backtraceFrames, MAX_BACKTRACE_FRAMES); 19 | char **backtraceStr = ::backtrace_symbols(backtraceFrames, frameCount); 20 | // TODO: implement getting demangled symbols using abi::__cxa_demangle 21 | if (backtraceStr == nullptr) { 22 | return std::vector(1, "Failed to acquire a backtrace"); 23 | } 24 | 25 | std::vector backtrace; 26 | try { 27 | for (int i = 0; i < frameCount; i++) { 28 | backtrace.emplace_back(backtraceStr[i]); 29 | } 30 | } catch (std::bad_alloc &) { 31 | free(backtraceStr); 32 | return std::vector(1, "Failed to acquire a backtrace"); 33 | } 34 | 35 | free(backtraceStr); 36 | 37 | return backtrace; 38 | } 39 | 40 | } // namespace ur 41 | -------------------------------------------------------------------------------- /test/conformance/queue/urQueueFlush.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 Intel Corporation 2 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 3 | // Exceptions. See LICENSE.TXT 4 | // 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #include "uur/fixtures.h" 8 | #include "uur/known_failure.h" 9 | #include "uur/raii.h" 10 | 11 | using urQueueFlushTest = uur::urQueueTest; 12 | UUR_INSTANTIATE_DEVICE_TEST_SUITE(urQueueFlushTest); 13 | 14 | TEST_P(urQueueFlushTest, Success) { 15 | UUR_KNOWN_FAILURE_ON(uur::NativeCPU{}); 16 | 17 | constexpr size_t buffer_size = 1024; 18 | uur::raii::Mem buffer = nullptr; 19 | ASSERT_SUCCESS(urMemBufferCreate(context, UR_MEM_FLAG_READ_WRITE, buffer_size, 20 | nullptr, buffer.ptr())); 21 | 22 | std::vector data(buffer_size, 42); 23 | ASSERT_SUCCESS(urEnqueueMemBufferWrite(queue, buffer, /* blocking */ false, 0, 24 | 1024, data.data(), 0, nullptr, 25 | nullptr)); 26 | 27 | ASSERT_SUCCESS(urQueueFlush(queue)); 28 | } 29 | 30 | TEST_P(urQueueFlushTest, InvalidNullHandleQueue) { 31 | ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, urQueueFlush(nullptr)); 32 | } 33 | --------------------------------------------------------------------------------