├── .clang-format ├── .editorconfig ├── .gitattributes ├── .github ├── CODEOWNERS ├── dependabot.yml ├── docker │ ├── README.md │ ├── fedora-40.Dockerfile │ ├── install_dpcpp.sh │ ├── install_libbacktrace.sh │ ├── opensuse-leap-15.Dockerfile │ ├── rockylinux-8.Dockerfile │ ├── rockylinux-9.Dockerfile │ ├── ubuntu-20.04.Dockerfile │ ├── ubuntu-22.04.Dockerfile │ └── ubuntu-24.04.Dockerfile ├── intel-llvm-mirror-base-commit ├── labeler.yml ├── scripts │ ├── get_system_info.sh │ └── install_hwloc.sh └── workflows │ ├── benchmarks-nightly.yml │ ├── benchmarks-reusable.yml │ ├── benchmarks.yml │ ├── docs.yml │ ├── labeler.yml │ ├── mirror-intel-llvm-commits.yml │ ├── pr-migration-auto-close.yml │ ├── pr-migration-warn.yml │ ├── scorecard.yml │ └── trivy.yml ├── .gitignore ├── .trivyignore ├── CHANGELOG.md ├── CMakeLists.txt ├── LICENSE.TXT ├── README.md ├── REQUIREMENTS.md ├── SECURITY.md ├── ci ├── README.md ├── pyenv.cmd └── setup_manifest.cmd ├── cmake ├── Assertions.cmake ├── FetchLevelZero.cmake ├── FindLibbacktrace.cmake ├── FindLit.cmake ├── FindRocmAgentEnumerator.cmake ├── helpers.cmake └── unified-runtime-config.cmake.in ├── examples ├── CMakeLists.txt ├── codegen │ ├── CMakeLists.txt │ ├── README.md │ ├── codegen.cpp │ ├── helpers.cpp │ └── helpers.h ├── collector │ ├── CMakeLists.txt │ ├── README.md │ └── collector.cpp └── hello_world │ ├── CMakeLists.txt │ └── hello_world.cpp ├── include ├── ur_api.h ├── ur_api_funcs.def ├── ur_ddi.h ├── ur_print.h └── ur_print.hpp ├── sanitizer-ignorelist.txt ├── scripts ├── Doxyfile ├── README.md ├── YaML.md ├── __init__.py ├── add_experimental_feature.py ├── assets │ ├── html │ │ ├── _static │ │ │ └── custom.css │ │ └── _templates │ │ │ └── breadcrumbs.html │ └── images │ │ ├── intel-logo.png │ │ ├── one_api_sw_stack.png │ │ ├── programs.png │ │ └── runtime_object_hier.png ├── check-hardening.sh ├── config.ini ├── core │ ├── CONTRIB.rst │ ├── CUDA.rst │ ├── EXP-2D-BLOCK-ARRAY-CAPABILITIES.rst │ ├── EXP-ASYNC-ALLOC.rst │ ├── EXP-BINDLESS-IMAGES.rst │ ├── EXP-COMMAND-BUFFER.rst │ ├── EXP-ENQUEUE-TIMESTAMP-RECORDING.rst │ ├── EXP-LOW-POWER-EVENTS.rst │ ├── EXP-MULTI-DEVICE-COMPILE.rst │ ├── EXP-NATIVE-ENQUEUE.rst │ ├── EXP-USM-CONTEXT-MEMCPY.rst │ ├── EXP-USM-IMPORT-RELEASE.rst │ ├── EXP-USM-P2P.rst │ ├── HIP.rst │ ├── INTRO.rst │ ├── LEVEL_ZERO.rst │ ├── PROG.rst │ ├── adapter.yml │ ├── common.yml │ ├── context.yml │ ├── device.yml │ ├── enqueue.yml │ ├── event.yml │ ├── exp-2d-block-array-capabilities.yml │ ├── exp-async-alloc.yml │ ├── exp-bindless-images.yml │ ├── exp-command-buffer.yml │ ├── exp-enqueue-timestamp-recording.yml │ ├── exp-low-power-events.yml │ ├── exp-multi-device-compile.yml │ ├── exp-native-enqueue.yml │ ├── exp-usm-context-memcpy.yml │ ├── exp-usm-import-release.yml │ ├── exp-usm-p2p.yml │ ├── kernel.yml │ ├── loader.yml │ ├── manifests.yml │ ├── memory.yml │ ├── platform.yml │ ├── program.yml │ ├── queue.yml │ ├── registry.yml │ ├── sampler.yml │ ├── usm.yml │ └── virtual_memory.yml ├── generate_code.py ├── generate_docs.py ├── generate_ids.py ├── generate_kernel_header.py ├── json2src.py ├── mirror-commits-from-intel-llvm.py ├── move-pr-to-intel-llvm.py ├── parse_specs.py ├── run.py ├── strip-guarded-lines.py ├── templates │ ├── __init__.py │ ├── adapter.def.in.mako │ ├── adapter.map.in.mako │ ├── api.cpp.mako │ ├── api.h.mako │ ├── api.rst.mako │ ├── api_funcs.def.mako │ ├── api_listing.mako │ ├── conf.py.mako │ ├── ddi.h.mako │ ├── exp-features.rst.mako │ ├── exp_feat.rst.mako │ ├── exp_feat.yml.mako │ ├── helper.py │ ├── index.rst.mako │ ├── ldrddi.cpp.mako │ ├── libapi.cpp.mako │ ├── libddi.cpp.mako │ ├── loader.def.in.mako │ ├── loader.map.in.mako │ ├── manifests.hpp.mako │ ├── mockddi.cpp.mako │ ├── optional_queries.h.mako │ ├── print.cpp.mako │ ├── print.h.mako │ ├── print.hpp.mako │ ├── print_helper.py │ ├── queue_api.cpp.mako │ ├── queue_api.hpp.mako │ ├── stype_map_helpers.hpp.mako │ ├── tools-info.hpp.mako │ ├── trcddi.cpp.mako │ ├── ur_interface_loader.cpp.mako │ ├── ur_interface_loader.hpp.mako │ └── valddi.cpp.mako ├── util.py ├── verify_license.py └── version.py ├── source ├── CMakeLists.txt ├── adapters │ ├── CMakeLists.txt │ ├── adapter.def.in │ ├── adapter.map.in │ ├── cuda │ │ ├── CMakeLists.txt │ │ ├── adapter.cpp │ │ ├── adapter.hpp │ │ ├── async_alloc.cpp │ │ ├── command_buffer.cpp │ │ ├── command_buffer.hpp │ │ ├── common.cpp │ │ ├── common.hpp │ │ ├── context.cpp │ │ ├── context.hpp │ │ ├── device.cpp │ │ ├── device.hpp │ │ ├── enqueue.cpp │ │ ├── enqueue.hpp │ │ ├── enqueue_native.cpp │ │ ├── event.cpp │ │ ├── event.hpp │ │ ├── image.cpp │ │ ├── image.hpp │ │ ├── kernel.cpp │ │ ├── kernel.hpp │ │ ├── memory.cpp │ │ ├── memory.hpp │ │ ├── physical_mem.cpp │ │ ├── physical_mem.hpp │ │ ├── platform.cpp │ │ ├── platform.hpp │ │ ├── program.cpp │ │ ├── program.hpp │ │ ├── queue.cpp │ │ ├── queue.hpp │ │ ├── sampler.cpp │ │ ├── sampler.hpp │ │ ├── tracing.cpp │ │ ├── tracing.hpp │ │ ├── ur_interface_loader.cpp │ │ ├── usm.cpp │ │ ├── usm.hpp │ │ ├── usm_p2p.cpp │ │ └── virtual_mem.cpp │ ├── hip │ │ ├── CMakeLists.txt │ │ ├── adapter.cpp │ │ ├── adapter.hpp │ │ ├── async_alloc.cpp │ │ ├── command_buffer.cpp │ │ ├── command_buffer.hpp │ │ ├── common.cpp │ │ ├── common.hpp │ │ ├── context.cpp │ │ ├── context.hpp │ │ ├── device.cpp │ │ ├── device.hpp │ │ ├── enqueue.cpp │ │ ├── enqueue.hpp │ │ ├── enqueue_native.cpp │ │ ├── event.cpp │ │ ├── event.hpp │ │ ├── image.cpp │ │ ├── image.hpp │ │ ├── kernel.cpp │ │ ├── kernel.hpp │ │ ├── memory.cpp │ │ ├── memory.hpp │ │ ├── physical_mem.cpp │ │ ├── physical_mem.hpp │ │ ├── platform.cpp │ │ ├── platform.hpp │ │ ├── program.cpp │ │ ├── program.hpp │ │ ├── queue.cpp │ │ ├── queue.hpp │ │ ├── sampler.cpp │ │ ├── sampler.hpp │ │ ├── ur_interface_loader.cpp │ │ ├── usm.cpp │ │ ├── usm.hpp │ │ ├── usm_p2p.cpp │ │ └── virtual_mem.cpp │ ├── level_zero │ │ ├── CMakeLists.txt │ │ ├── adapter.cpp │ │ ├── adapter.hpp │ │ ├── adapter_lib_init_linux.cpp │ │ ├── async_alloc.cpp │ │ ├── command_buffer.cpp │ │ ├── command_buffer.hpp │ │ ├── command_buffer_command.cpp │ │ ├── command_buffer_command.hpp │ │ ├── common.cpp │ │ ├── common.hpp │ │ ├── context.cpp │ │ ├── context.hpp │ │ ├── device.cpp │ │ ├── device.hpp │ │ ├── enqueue_native.cpp │ │ ├── enqueued_pool.cpp │ │ ├── enqueued_pool.hpp │ │ ├── event.cpp │ │ ├── event.hpp │ │ ├── helpers │ │ │ ├── kernel_helpers.cpp │ │ │ ├── kernel_helpers.hpp │ │ │ ├── memory_helpers.cpp │ │ │ ├── memory_helpers.hpp │ │ │ ├── mutable_helpers.cpp │ │ │ └── mutable_helpers.hpp │ │ ├── image.cpp │ │ ├── image_common.cpp │ │ ├── image_common.hpp │ │ ├── kernel.cpp │ │ ├── kernel.hpp │ │ ├── memory.cpp │ │ ├── memory.hpp │ │ ├── physical_mem.cpp │ │ ├── physical_mem.hpp │ │ ├── platform.cpp │ │ ├── platform.hpp │ │ ├── program.cpp │ │ ├── program.hpp │ │ ├── queue.cpp │ │ ├── queue.hpp │ │ ├── sampler.cpp │ │ ├── sampler.hpp │ │ ├── ur_interface_loader.cpp │ │ ├── ur_interface_loader.hpp │ │ ├── ur_level_zero.cpp │ │ ├── ur_level_zero.hpp │ │ ├── usm.cpp │ │ ├── usm.hpp │ │ ├── usm_p2p.cpp │ │ ├── v2 │ │ │ ├── README.md │ │ │ ├── api.cpp │ │ │ ├── command_buffer.cpp │ │ │ ├── command_buffer.hpp │ │ │ ├── command_list_cache.cpp │ │ │ ├── command_list_cache.hpp │ │ │ ├── command_list_manager.cpp │ │ │ ├── command_list_manager.hpp │ │ │ ├── common.hpp │ │ │ ├── context.cpp │ │ │ ├── context.hpp │ │ │ ├── event.cpp │ │ │ ├── event.hpp │ │ │ ├── event_pool.cpp │ │ │ ├── event_pool.hpp │ │ │ ├── event_pool_cache.cpp │ │ │ ├── event_pool_cache.hpp │ │ │ ├── event_provider.hpp │ │ │ ├── event_provider_counter.cpp │ │ │ ├── event_provider_counter.hpp │ │ │ ├── event_provider_normal.cpp │ │ │ ├── event_provider_normal.hpp │ │ │ ├── kernel.cpp │ │ │ ├── kernel.hpp │ │ │ ├── lockable.hpp │ │ │ ├── memory.cpp │ │ │ ├── memory.hpp │ │ │ ├── queue_api.cpp │ │ │ ├── queue_api.hpp │ │ │ ├── queue_create.cpp │ │ │ ├── queue_handle.hpp │ │ │ ├── queue_immediate_in_order.cpp │ │ │ ├── queue_immediate_in_order.hpp │ │ │ ├── usm.cpp │ │ │ └── usm.hpp │ │ └── virtual_mem.cpp │ ├── mock │ │ ├── CMakeLists.txt │ │ ├── ur_mock.cpp │ │ ├── ur_mock.hpp │ │ └── ur_mockddi.cpp │ ├── native_cpu │ │ ├── CMakeLists.txt │ │ ├── adapter.cpp │ │ ├── adapter.hpp │ │ ├── async_alloc.cpp │ │ ├── command_buffer.cpp │ │ ├── common.cpp │ │ ├── common.hpp │ │ ├── context.cpp │ │ ├── context.hpp │ │ ├── device.cpp │ │ ├── device.hpp │ │ ├── enqueue.cpp │ │ ├── event.cpp │ │ ├── event.hpp │ │ ├── image.cpp │ │ ├── kernel.cpp │ │ ├── kernel.hpp │ │ ├── memory.cpp │ │ ├── memory.hpp │ │ ├── nativecpu_state.hpp │ │ ├── physical_mem.cpp │ │ ├── physical_mem.hpp │ │ ├── platform.cpp │ │ ├── platform.hpp │ │ ├── program.cpp │ │ ├── program.hpp │ │ ├── queue.cpp │ │ ├── queue.hpp │ │ ├── sampler.cpp │ │ ├── threadpool.hpp │ │ ├── ur_interface_loader.cpp │ │ ├── usm.cpp │ │ ├── usm_p2p.cpp │ │ └── virtual_mem.cpp │ ├── offload │ │ ├── CMakeLists.txt │ │ ├── adapter.cpp │ │ ├── adapter.hpp │ │ ├── common.hpp │ │ ├── context.cpp │ │ ├── context.hpp │ │ ├── device.cpp │ │ ├── device.hpp │ │ ├── enqueue.cpp │ │ ├── event.cpp │ │ ├── event.hpp │ │ ├── kernel.cpp │ │ ├── kernel.hpp │ │ ├── platform.cpp │ │ ├── platform.hpp │ │ ├── program.cpp │ │ ├── program.hpp │ │ ├── queue.cpp │ │ ├── queue.hpp │ │ ├── ur2offload.hpp │ │ ├── ur_interface_loader.cpp │ │ └── usm.cpp │ └── opencl │ │ ├── CMakeLists.txt │ │ ├── adapter.cpp │ │ ├── adapter.hpp │ │ ├── async_alloc.cpp │ │ ├── command_buffer.cpp │ │ ├── command_buffer.hpp │ │ ├── common.cpp │ │ ├── common.hpp │ │ ├── context.cpp │ │ ├── context.hpp │ │ ├── core_functions.def │ │ ├── device.cpp │ │ ├── device.hpp │ │ ├── enqueue.cpp │ │ ├── enqueue_native.cpp │ │ ├── event.cpp │ │ ├── event.hpp │ │ ├── extension_functions.def │ │ ├── image.cpp │ │ ├── kernel.cpp │ │ ├── kernel.hpp │ │ ├── memory.cpp │ │ ├── memory.hpp │ │ ├── physical_mem.cpp │ │ ├── physical_mem.hpp │ │ ├── platform.cpp │ │ ├── platform.hpp │ │ ├── program.cpp │ │ ├── program.hpp │ │ ├── queue.cpp │ │ ├── queue.hpp │ │ ├── sampler.cpp │ │ ├── sampler.hpp │ │ ├── ur_interface_loader.cpp │ │ ├── usm.cpp │ │ ├── usm.hpp │ │ ├── usm_p2p.cpp │ │ └── virtual_mem.cpp ├── common │ ├── CMakeLists.txt │ ├── cuda-hip │ │ └── stream_queue.hpp │ ├── latency_tracker.hpp │ ├── linux │ │ └── ur_lib_loader.cpp │ ├── logger │ │ ├── ur_level.hpp │ │ ├── ur_logger.hpp │ │ ├── ur_logger_details.hpp │ │ └── ur_sinks.hpp │ ├── stype_map_helpers.def │ ├── umf_helpers.hpp │ ├── umf_pools │ │ ├── disjoint_pool_config_parser.cpp │ │ └── disjoint_pool_config_parser.hpp │ ├── ur_filesystem_resolved.hpp │ ├── ur_lib_loader.hpp │ ├── ur_pool_manager.hpp │ ├── ur_util.cpp │ ├── ur_util.hpp │ └── windows │ │ └── ur_lib_loader.cpp ├── loader │ ├── CMakeLists.txt │ ├── UrLoaderVersion.rc.in │ ├── layers │ │ ├── sanitizer │ │ │ ├── asan │ │ │ │ ├── asan_allocator.cpp │ │ │ │ ├── asan_allocator.hpp │ │ │ │ ├── asan_buffer.cpp │ │ │ │ ├── asan_buffer.hpp │ │ │ │ ├── asan_ddi.cpp │ │ │ │ ├── asan_ddi.hpp │ │ │ │ ├── asan_interceptor.cpp │ │ │ │ ├── asan_interceptor.hpp │ │ │ │ ├── asan_libdevice.hpp │ │ │ │ ├── asan_quarantine.cpp │ │ │ │ ├── asan_quarantine.hpp │ │ │ │ ├── asan_report.cpp │ │ │ │ ├── asan_report.hpp │ │ │ │ ├── asan_shadow.cpp │ │ │ │ ├── asan_shadow.hpp │ │ │ │ ├── asan_statistics.cpp │ │ │ │ ├── asan_statistics.hpp │ │ │ │ ├── asan_validator.cpp │ │ │ │ └── asan_validator.hpp │ │ │ ├── msan │ │ │ │ ├── msan_allocator.cpp │ │ │ │ ├── msan_allocator.hpp │ │ │ │ ├── msan_buffer.cpp │ │ │ │ ├── msan_buffer.hpp │ │ │ │ ├── msan_ddi.cpp │ │ │ │ ├── msan_ddi.hpp │ │ │ │ ├── msan_interceptor.cpp │ │ │ │ ├── msan_interceptor.hpp │ │ │ │ ├── msan_libdevice.hpp │ │ │ │ ├── msan_report.cpp │ │ │ │ ├── msan_report.hpp │ │ │ │ ├── msan_shadow.cpp │ │ │ │ └── msan_shadow.hpp │ │ │ ├── sanitizer_common │ │ │ │ ├── linux │ │ │ │ │ ├── backtrace.cpp │ │ │ │ │ ├── sanitizer_utils.cpp │ │ │ │ │ └── symbolizer.cpp │ │ │ │ ├── sanitizer_allocator.hpp │ │ │ │ ├── sanitizer_common.hpp │ │ │ │ ├── sanitizer_libdevice.hpp │ │ │ │ ├── sanitizer_options.cpp │ │ │ │ ├── sanitizer_options.hpp │ │ │ │ ├── sanitizer_options_impl.hpp │ │ │ │ ├── sanitizer_stacktrace.cpp │ │ │ │ ├── sanitizer_stacktrace.hpp │ │ │ │ ├── sanitizer_utils.cpp │ │ │ │ └── sanitizer_utils.hpp │ │ │ ├── tsan │ │ │ │ ├── tsan_buffer.cpp │ │ │ │ ├── tsan_buffer.hpp │ │ │ │ ├── tsan_ddi.cpp │ │ │ │ ├── tsan_ddi.hpp │ │ │ │ ├── tsan_interceptor.cpp │ │ │ │ ├── tsan_interceptor.hpp │ │ │ │ ├── tsan_libdevice.hpp │ │ │ │ ├── tsan_report.cpp │ │ │ │ ├── tsan_report.hpp │ │ │ │ ├── tsan_shadow.cpp │ │ │ │ └── tsan_shadow.hpp │ │ │ ├── ur_sanddi.cpp │ │ │ ├── ur_sanitizer_layer.cpp │ │ │ └── ur_sanitizer_layer.hpp │ │ ├── tracing │ │ │ ├── ur_tracing_layer.cpp │ │ │ ├── ur_tracing_layer.hpp │ │ │ └── ur_trcddi.cpp │ │ ├── ur_proxy_layer.hpp │ │ └── validation │ │ │ ├── backtrace.hpp │ │ │ ├── backtrace_libbacktrace.cpp │ │ │ ├── backtrace_lin.cpp │ │ │ ├── backtrace_win.cpp │ │ │ ├── ur_leak_check.hpp │ │ │ ├── ur_valddi.cpp │ │ │ ├── ur_validation_layer.cpp │ │ │ └── ur_validation_layer.hpp │ ├── libur_loader.pc.in │ ├── linux │ │ └── adapter_search.cpp │ ├── loader.def.in │ ├── loader.map.in │ ├── ur_adapter_registry.hpp │ ├── ur_adapter_search.hpp │ ├── ur_codeloc.hpp │ ├── ur_ldrddi.cpp │ ├── ur_lib.cpp │ ├── ur_lib.hpp │ ├── ur_libapi.cpp │ ├── ur_libddi.cpp │ ├── ur_loader.cpp │ ├── ur_loader.hpp │ ├── ur_manifests.hpp │ ├── ur_print.cpp │ └── windows │ │ └── adapter_search.cpp ├── mock │ ├── CMakeLists.txt │ ├── ur_mock_helpers.cpp │ └── ur_mock_helpers.hpp ├── ur │ ├── ur.cpp │ └── ur.hpp └── ur_api.cpp ├── test ├── .clang-format ├── CMakeLists.txt ├── adapters │ ├── CMakeLists.txt │ ├── cuda │ │ ├── CMakeLists.txt │ │ ├── context_tests.cpp │ │ ├── event_tests.cpp │ │ ├── fixtures.h │ │ ├── kernel_tests.cpp │ │ ├── lit.cfg.py │ │ ├── lit.site.cfg.py.in │ │ ├── memory_tests.cpp │ │ ├── raii.h │ │ ├── urContextGetNativeHandle.cpp │ │ ├── urDeviceCreateWithNativeHandle.cpp │ │ ├── urDeviceGetNativeHandle.cpp │ │ ├── urEventCreateWithNativeHandle.cpp │ │ ├── urEventGetNativeHandle.cpp │ │ └── urQueueGetNativeHandle.cpp │ ├── hip │ │ ├── CMakeLists.txt │ │ ├── fixtures.h │ │ ├── kernel_tests.cpp │ │ ├── lit.cfg.py │ │ ├── lit.site.cfg.py.in │ │ ├── test_context.cpp │ │ ├── test_event.cpp │ │ ├── urContextGetNativeHandle.cpp │ │ ├── urDeviceGetNativeHandle.cpp │ │ └── urEventGetNativeHandle.cpp │ ├── level_zero │ │ ├── CMakeLists.txt │ │ ├── confirm_version.cpp │ │ ├── enqueue_alloc.cpp │ │ ├── event_cache_tests.cpp │ │ ├── ipc.cpp │ │ ├── lit.local.cfg.py │ │ ├── memcheck.test │ │ ├── multi_device_event_cache_tests.cpp │ │ ├── urDeviceSelectBinary.cpp │ │ ├── urEnqueueMemBufferMapHostPtr.cpp │ │ ├── urEventCreateWithNativeHandle.cpp │ │ ├── urKernelCreateWithNativeHandle.cpp │ │ ├── urMemBufferCreateWithNativeHandleShared.cpp │ │ ├── urProgramLink.cpp │ │ ├── v2 │ │ │ ├── CMakeLists.txt │ │ │ ├── command_list_cache_test.cpp │ │ │ ├── deferred_kernel.cpp │ │ │ ├── deferred_kernel_memcheck.test │ │ │ ├── event_pool_test.cpp │ │ │ └── memory_residency.cpp │ │ ├── ze_helpers.hpp │ │ └── ze_tracer_common.hpp │ └── lit.local.cfg.py ├── conformance │ ├── CMakeLists.txt │ ├── README.md │ ├── adapter │ │ ├── CMakeLists.txt │ │ ├── urAdapterGet.cpp │ │ ├── urAdapterGetInfo.cpp │ │ ├── urAdapterGetLastError.cpp │ │ ├── urAdapterRelease.cpp │ │ └── urAdapterRetain.cpp │ ├── context │ │ ├── CMakeLists.txt │ │ ├── urContextCreate.cpp │ │ ├── urContextCreateWithNativeHandle.cpp │ │ ├── urContextGetInfo.cpp │ │ ├── urContextGetNativeHandle.cpp │ │ ├── urContextRelease.cpp │ │ ├── urContextRetain.cpp │ │ └── urContextSetExtendedDeleter.cpp │ ├── device │ │ ├── CMakeLists.txt │ │ ├── urDeviceCreateWithNativeHandle.cpp │ │ ├── urDeviceGet.cpp │ │ ├── urDeviceGetGlobalTimestamps.cpp │ │ ├── urDeviceGetInfo.cpp │ │ ├── urDeviceGetNativeHandle.cpp │ │ ├── urDeviceGetSelected.cpp │ │ ├── urDevicePartition.cpp │ │ ├── urDeviceRelease.cpp │ │ ├── urDeviceRetain.cpp │ │ └── urDeviceSelectBinary.cpp │ ├── device_code │ │ ├── CMakeLists.txt │ │ ├── bar.cpp │ │ ├── build_failure.cpp │ │ ├── cpy_and_mult.cpp │ │ ├── cpy_and_mult_usm.cpp │ │ ├── device_global.cpp │ │ ├── fill.cpp │ │ ├── fill_2d.cpp │ │ ├── fill_3d.cpp │ │ ├── fill_usm.cpp │ │ ├── fill_usm_2d.cpp │ │ ├── fixed_sg_size.cpp │ │ ├── fixed_wg_size.cpp │ │ ├── foo.cpp │ │ ├── image_copy.cpp │ │ ├── inc.cpp │ │ ├── increment.cpp │ │ ├── indexers_usm.cpp │ │ ├── linker_error.cpp │ │ ├── max_wg_size.cpp │ │ ├── mean.cpp │ │ ├── multiply.cpp │ │ ├── no_args.cpp │ │ ├── saxpy.cpp │ │ ├── saxpy_usm.cpp │ │ ├── saxpy_usm_local_mem.cpp │ │ ├── sequence.cpp │ │ ├── spec_constant.cpp │ │ ├── spec_constant_multiple.cpp │ │ ├── standard_types.cpp │ │ ├── subgroup.cpp │ │ └── usm_ll.cpp │ ├── enqueue │ │ ├── CMakeLists.txt │ │ ├── helpers.h │ │ ├── urEnqueueDeviceGlobalVariableRead.cpp │ │ ├── urEnqueueDeviceGlobalVariableWrite.cpp │ │ ├── urEnqueueEventsWait.cpp │ │ ├── urEnqueueEventsWaitMultiDevice.cpp │ │ ├── urEnqueueEventsWaitWithBarrier.cpp │ │ ├── urEnqueueKernelLaunch.cpp │ │ ├── urEnqueueKernelLaunchAndMemcpyInOrder.cpp │ │ ├── urEnqueueMemBufferCopy.cpp │ │ ├── urEnqueueMemBufferCopyRect.cpp │ │ ├── urEnqueueMemBufferFill.cpp │ │ ├── urEnqueueMemBufferMap.cpp │ │ ├── urEnqueueMemBufferRead.cpp │ │ ├── urEnqueueMemBufferReadRect.cpp │ │ ├── urEnqueueMemBufferWrite.cpp │ │ ├── urEnqueueMemBufferWriteRect.cpp │ │ ├── urEnqueueMemImageCopy.cpp │ │ ├── urEnqueueMemImageRead.cpp │ │ ├── urEnqueueMemImageWrite.cpp │ │ ├── urEnqueueMemUnmap.cpp │ │ ├── urEnqueueReadHostPipe.cpp │ │ ├── urEnqueueTimestampRecording.cpp │ │ ├── urEnqueueUSMAdvise.cpp │ │ ├── urEnqueueUSMFill.cpp │ │ ├── urEnqueueUSMFill2D.cpp │ │ ├── urEnqueueUSMMemcpy.cpp │ │ ├── urEnqueueUSMMemcpy2D.cpp │ │ ├── urEnqueueUSMPrefetch.cpp │ │ └── urEnqueueWriteHostPipe.cpp │ ├── event │ │ ├── CMakeLists.txt │ │ ├── fixtures.h │ │ ├── urEventCreateWithNativeHandle.cpp │ │ ├── urEventGetInfo.cpp │ │ ├── urEventGetNativeHandle.cpp │ │ ├── urEventGetProfilingInfo.cpp │ │ ├── urEventRelease.cpp │ │ ├── urEventRetain.cpp │ │ ├── urEventSetCallback.cpp │ │ └── urEventWait.cpp │ ├── exp_command_buffer │ │ ├── CMakeLists.txt │ │ ├── commands.cpp │ │ ├── copy.cpp │ │ ├── enqueue.cpp │ │ ├── event_sync.cpp │ │ ├── fill.cpp │ │ ├── fixtures.h │ │ ├── in-order.cpp │ │ ├── invalid.cpp │ │ ├── kernel_event_sync.cpp │ │ ├── native-command │ │ │ ├── CMakeLists.txt │ │ │ ├── append_native_L0.cpp │ │ │ ├── append_native_cuda.cpp │ │ │ ├── append_native_hip.cpp │ │ │ ├── append_native_opencl.cpp │ │ │ └── common.h │ │ ├── read.cpp │ │ ├── rect_read.cpp │ │ ├── rect_write.cpp │ │ ├── regression │ │ │ └── usm_copy.cpp │ │ ├── release.cpp │ │ ├── retain.cpp │ │ ├── update │ │ │ ├── buffer_fill_kernel_update.cpp │ │ │ ├── buffer_saxpy_kernel_update.cpp │ │ │ ├── enqueue_update.cpp │ │ │ ├── event_sync.cpp │ │ │ ├── invalid_update.cpp │ │ │ ├── kernel_event_sync.cpp │ │ │ ├── kernel_handle_update.cpp │ │ │ ├── local_memory_update.cpp │ │ │ ├── ndrange_update.cpp │ │ │ ├── usm_fill_kernel_update.cpp │ │ │ └── usm_saxpy_kernel_update.cpp │ │ └── write.cpp │ ├── exp_enqueue_native │ │ ├── CMakeLists.txt │ │ └── enqueue_native_cuda.cpp │ ├── exp_usm_context_memcpy │ │ ├── CMakeLists.txt │ │ └── urUSMContextMemcpyExp.cpp │ ├── exp_usm_p2p │ │ ├── CMakeLists.txt │ │ └── usm_p2p.cpp │ ├── integration │ │ ├── CMakeLists.txt │ │ ├── QueueBuffer.cpp │ │ ├── QueueEmptyStatus.cpp │ │ ├── QueueUSM.cpp │ │ └── fixtures.h │ ├── kernel │ │ ├── CMakeLists.txt │ │ ├── kernel_adapter_opencl.match │ │ ├── urKernelCreate.cpp │ │ ├── urKernelCreateWithNativeHandle.cpp │ │ ├── urKernelGetGroupInfo.cpp │ │ ├── urKernelGetInfo.cpp │ │ ├── urKernelGetNativeHandle.cpp │ │ ├── urKernelGetSubGroupInfo.cpp │ │ ├── urKernelGetSuggestedLocalWorkSize.cpp │ │ ├── urKernelRelease.cpp │ │ ├── urKernelRetain.cpp │ │ ├── urKernelSetArgLocal.cpp │ │ ├── urKernelSetArgMemObj.cpp │ │ ├── urKernelSetArgPointer.cpp │ │ ├── urKernelSetArgSampler.cpp │ │ ├── urKernelSetArgValue.cpp │ │ ├── urKernelSetExecInfo.cpp │ │ ├── urKernelSetSpecializationConstants.cpp │ │ └── urKernelSuggestMaxCooperativeGroupCount.cpp │ ├── lit.cfg.py │ ├── lit.site.cfg.py.in │ ├── memory-migrate │ │ ├── CMakeLists.txt │ │ └── urMemBufferMigrateAcrossDevices.cpp │ ├── memory │ │ ├── CMakeLists.txt │ │ ├── urMemBufferCreate.cpp │ │ ├── urMemBufferCreateWithNativeHandle.cpp │ │ ├── urMemBufferPartition.cpp │ │ ├── urMemGetInfo.cpp │ │ ├── urMemGetNativeHandle.cpp │ │ ├── urMemImageCreate.cpp │ │ ├── urMemImageCreateWithImageFormatParam.cpp │ │ ├── urMemImageCreateWithNativeHandle.cpp │ │ ├── urMemImageGetInfo.cpp │ │ ├── urMemRelease.cpp │ │ └── urMemRetain.cpp │ ├── platform │ │ ├── CMakeLists.txt │ │ ├── fixtures.h │ │ ├── urPlatformCreateWithNativeHandle.cpp │ │ ├── urPlatformGet.cpp │ │ ├── urPlatformGetApiVersion.cpp │ │ ├── urPlatformGetBackendOption.cpp │ │ ├── urPlatformGetInfo.cpp │ │ └── urPlatformGetNativeHandle.cpp │ ├── program │ │ ├── CMakeLists.txt │ │ ├── urMultiDeviceProgramCreateWithBinary.cpp │ │ ├── urMultiDeviceProgramCreateWithIL.cpp │ │ ├── urProgramBuild.cpp │ │ ├── urProgramCompile.cpp │ │ ├── urProgramCreateWithBinary.cpp │ │ ├── urProgramCreateWithIL.cpp │ │ ├── urProgramCreateWithNativeHandle.cpp │ │ ├── urProgramGetBuildInfo.cpp │ │ ├── urProgramGetFunctionPointer.cpp │ │ ├── urProgramGetGlobalVariablePointer.cpp │ │ ├── urProgramGetInfo.cpp │ │ ├── urProgramGetNativeHandle.cpp │ │ ├── urProgramLink.cpp │ │ ├── urProgramRelease.cpp │ │ ├── urProgramRetain.cpp │ │ └── urProgramSetSpecializationConstants.cpp │ ├── queue │ │ ├── CMakeLists.txt │ │ ├── urQueueCreate.cpp │ │ ├── urQueueCreateWithNativeHandle.cpp │ │ ├── urQueueFinish.cpp │ │ ├── urQueueFlush.cpp │ │ ├── urQueueGetInfo.cpp │ │ ├── urQueueGetNativeHandle.cpp │ │ ├── urQueueRelease.cpp │ │ └── urQueueRetain.cpp │ ├── sampler │ │ ├── CMakeLists.txt │ │ ├── urSamplerCreate.cpp │ │ ├── urSamplerCreateWithNativeHandle.cpp │ │ ├── urSamplerGetInfo.cpp │ │ ├── urSamplerGetNativeHandle.cpp │ │ ├── urSamplerRelease.cpp │ │ └── urSamplerRetain.cpp │ ├── source │ │ ├── environment.cpp │ │ └── main.cpp │ ├── testing │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── uur │ │ │ │ ├── checks.h │ │ │ │ ├── environment.h │ │ │ │ ├── fixtures.h │ │ │ │ ├── known_failure.h │ │ │ │ ├── optional_queries.h │ │ │ │ ├── raii.h │ │ │ │ └── utils.h │ │ └── source │ │ │ ├── fixtures.cpp │ │ │ └── utils.cpp │ ├── usm │ │ ├── CMakeLists.txt │ │ ├── helpers.h │ │ ├── urUSMDeviceAlloc.cpp │ │ ├── urUSMFree.cpp │ │ ├── urUSMGetMemAllocInfo.cpp │ │ ├── urUSMHostAlloc.cpp │ │ ├── urUSMPoolCreate.cpp │ │ ├── urUSMPoolGetInfo.cpp │ │ ├── urUSMPoolRelease.cpp │ │ ├── urUSMPoolRetain.cpp │ │ └── urUSMSharedAlloc.cpp │ └── virtual_memory │ │ ├── CMakeLists.txt │ │ ├── urPhysicalMemCreate.cpp │ │ ├── urPhysicalMemGetInfo.cpp │ │ ├── urPhysicalMemRelease.cpp │ │ ├── urPhysicalMemRetain.cpp │ │ ├── urVirtualMemFree.cpp │ │ ├── urVirtualMemGetInfo.cpp │ │ ├── urVirtualMemGranularityGetInfo.cpp │ │ ├── urVirtualMemMap.cpp │ │ ├── urVirtualMemReserve.cpp │ │ ├── urVirtualMemSetAccess.cpp │ │ └── urVirtualMemUnmap.cpp ├── fuzz │ ├── CMakeLists.txt │ ├── README.md │ ├── corpus │ │ ├── alloc │ │ ├── create-release │ │ ├── kernel-launch │ │ └── pool-alloc │ ├── level_zero-long.test │ ├── level_zero-short.test │ ├── lit.local.cfg.py │ ├── mock-long.test │ ├── mock-short.test │ ├── urFuzz.cpp │ └── utils.hpp ├── layers │ ├── CMakeLists.txt │ ├── sanitizer │ │ ├── CMakeLists.txt │ │ ├── asan.cpp │ │ ├── lit.local.cfg.py │ │ └── sanitizer_options.cpp │ ├── tracing │ │ ├── CMakeLists.txt │ │ ├── codeloc.cpp │ │ ├── codeloc.test │ │ ├── hello_world_collected.test │ │ ├── hello_world_logged.test │ │ ├── lit.local.cfg.py │ │ └── test_collector.cpp │ └── validation │ │ ├── CMakeLists.txt │ │ ├── fixtures.hpp │ │ ├── leaks.cpp │ │ ├── leaks_mt.cpp │ │ ├── lifetime.cpp │ │ ├── lit.local.cfg.py │ │ └── parameters.cpp ├── lit.cfg.py ├── lit.site.cfg.py.in ├── loader │ ├── CMakeLists.txt │ ├── adapter_registry │ │ ├── CMakeLists.txt │ │ ├── fixtures.hpp │ │ ├── lit.local.cfg.py │ │ ├── prefilter.cpp │ │ ├── search_no_env.cpp │ │ ├── search_order.cpp │ │ └── search_with_env.cpp │ ├── handles │ │ ├── CMakeLists.txt │ │ ├── fixtures.hpp │ │ ├── handles.test │ │ └── urLoaderHandles.cpp │ ├── hello_world.test │ ├── loader_config │ │ ├── CMakeLists.txt │ │ ├── fixtures.hpp │ │ ├── loader_config.test │ │ ├── urLoaderConfigCreate.cpp │ │ ├── urLoaderConfigEnableLayer.cpp │ │ ├── urLoaderConfigGetInfo.cpp │ │ ├── urLoaderConfigRelease.cpp │ │ ├── urLoaderConfigRetain.cpp │ │ └── urLoaderConfigSetCodeLocationCallback.cpp │ ├── loader_lifetime │ │ ├── CMakeLists.txt │ │ ├── fixtures.hpp │ │ ├── loader_lifetime.test │ │ ├── mixed.cpp │ │ ├── urLoaderInit.cpp │ │ └── urLoaderTearDown.cpp │ └── platforms │ │ ├── CMakeLists.txt │ │ ├── no_platforms.test │ │ ├── null_platform.test │ │ └── platforms.cpp ├── logger │ ├── CMakeLists.txt │ ├── env_var.cpp │ ├── fixtures.hpp │ ├── level-debug.test │ ├── level-error.test │ ├── level-info.test │ ├── level-none.test │ ├── level-warning.test │ └── validation.test ├── tools │ ├── CMakeLists.txt │ └── urtrace │ │ ├── CMakeLists.txt │ │ ├── begin.test │ │ ├── default.test │ │ ├── filter_device.test │ │ ├── json.test │ │ ├── lit.local.cfg.py │ │ ├── no_args.test │ │ └── profiling.test ├── unit │ ├── CMakeLists.txt │ ├── getenv.cpp │ ├── helpers.cpp │ ├── helpers.h │ ├── lit.cfg.py │ ├── lit.site.cfg.py.in │ ├── logger.cpp │ ├── mock.cpp │ ├── params.cpp │ ├── print.cpp │ └── print.h └── usm │ ├── CMakeLists.txt │ ├── lit.local.cfg.py │ └── usmPoolManager.cpp ├── third_party ├── CMakeLists.txt ├── deps.yml ├── requirements.txt └── requirements_testing.txt └── tools ├── CMakeLists.txt ├── urinfo ├── CMakeLists.txt ├── urinfo.cpp ├── urinfo.hpp └── utils.hpp └── urtrace ├── CMakeLists.txt ├── README.md ├── collector.cpp └── urtrace.py /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | BasedOnStyle: LLVM 4 | ... 5 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @oneapi-src/unified-runtime-maintain 2 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.github/intel-llvm-mirror-base-commit: -------------------------------------------------------------------------------- 1 | f2fa17634a57a52c490aa3e8c95539b7e80a4423 2 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.github/workflows/labeler.yml: -------------------------------------------------------------------------------- 1 | # Automatically add labels to pull requests based on globs in the 2 | # .github/labeler.yml config file. For documentation see: 3 | # https://github.com/marketplace/actions/labeler 4 | --- 5 | name: Pull Request Labeler 6 | 7 | on: [ pull_request_target ] 8 | 9 | concurrency: 10 | group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} 11 | cancel-in-progress: true 12 | 13 | permissions: 14 | contents: read 15 | 16 | jobs: 17 | labeler: 18 | permissions: 19 | contents: read 20 | pull-requests: write 21 | runs-on: ${{ github.repository_owner == 'oneapi-src' && 'intel-ubuntu-22.04' || 'ubuntu-latest' }} 22 | steps: 23 | - uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 # v5.0.0 24 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Unified Runtime changelog 2 | 3 | ## v.X.X.X 4 | * Placeholder for first release 5 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /examples/collector/README.md: -------------------------------------------------------------------------------- 1 | # Unified Runtime XPTI collector example 2 | 3 | This example demonstrates how to use the tracing layer integrated into 4 | Unified Runtime. It leverages XPTI to intercept all UR calls in the traced 5 | application and prints information about each function to standard output. 6 | 7 | ## Running the example 8 | 9 | To run the example, you will need to build Unified Runtime with 10 | tracing enabled (`-DUR_ENABLE_TRACING=ON`), link it with your application, 11 | and then set appropriate environment variables for the collector (`XPTI_SUBSCRIBERS`) and the 12 | XPTI dispatcher (`XPTI_FRAMEWORK_DISPATCHER`) to be loaded and enabled (`XPTI_TRACE_ENABLE`). 13 | You will also need to setup your chosen adapter (`UR_ADAPTERS_FORCE_LOAD`). 14 | 15 | For example, to run the `hello_world` example with the collector, use: 16 | 17 | ``` 18 | $ mkdir build 19 | $ cd build 20 | $ cmake .. -DUR_ENABLE_TRACING=ON 21 | $ make 22 | $ UR_ADAPTERS_FORCE_LOAD=./lib/libur_adapter_mock.so UR_ENABLE_LAYERS=UR_LAYER_TRACING XPTI_TRACE_ENABLE=1 XPTI_FRAMEWORK_DISPATCHER=./lib/libxptifw.so XPTI_SUBSCRIBERS=./lib/libcollector.so ./bin/hello_world 23 | ``` 24 | 25 | See [XPTI framework documentation](https://github.com/intel/llvm/blob/sycl/xptifw/doc/XPTI_Framework.md) for more information. 26 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /scripts/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oneapi-src/unified-runtime/87a5db2e3bfd234b03a7a0d43b8c14f024823177/scripts/__init__.py -------------------------------------------------------------------------------- /scripts/assets/html/_static/custom.css: -------------------------------------------------------------------------------- 1 | .wy-side-nav-search, .wy-nav-top { 2 | background: #4308E5; 3 | } 4 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /scripts/assets/images/intel-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oneapi-src/unified-runtime/87a5db2e3bfd234b03a7a0d43b8c14f024823177/scripts/assets/images/intel-logo.png -------------------------------------------------------------------------------- /scripts/assets/images/one_api_sw_stack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oneapi-src/unified-runtime/87a5db2e3bfd234b03a7a0d43b8c14f024823177/scripts/assets/images/one_api_sw_stack.png -------------------------------------------------------------------------------- /scripts/assets/images/programs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oneapi-src/unified-runtime/87a5db2e3bfd234b03a7a0d43b8c14f024823177/scripts/assets/images/programs.png -------------------------------------------------------------------------------- /scripts/assets/images/runtime_object_hier.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oneapi-src/unified-runtime/87a5db2e3bfd234b03a7a0d43b8c14f024823177/scripts/assets/images/runtime_object_hier.png -------------------------------------------------------------------------------- /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_headers.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 | -------------------------------------------------------------------------------- /scripts/config.ini: -------------------------------------------------------------------------------- 1 | [core] 2 | OneApi='oneAPI' 3 | namespace=ur 4 | tags=OneApi,x 5 | x=${namespace} 6 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | ${tbl['export']['name']} 11 | %endfor 12 | -------------------------------------------------------------------------------- /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 | ${tbl['export']['name']}; 11 | %endfor 12 | local: 13 | *; 14 | }; 15 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | _UR_API(${th.make_func_name(n, tags, obj)}) 32 | %endfor 33 | %endfor 34 | %for obj in th.get_loader_functions(specs, meta, n, tags): 35 | %if n + "Loader" in obj['name']: 36 | _UR_API(${obj['name']}) 37 | %endif 38 | %endfor 39 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /scripts/templates/libddi.cpp.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) 2022 Intel Corporation 13 | * 14 | * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM 15 | * Exceptions. 16 | * See LICENSE.TXT 17 | * 18 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 19 | * 20 | * @file ${name}.cpp 21 | * 22 | */ 23 | #include "${x}_lib.hpp" 24 | #ifndef DYNAMIC_LOAD_LOADER 25 | #include "${n}_ddi.h" 26 | #endif 27 | 28 | namespace ${x}_lib 29 | { 30 | /////////////////////////////////////////////////////////////////////////////// 31 | 32 | 33 | __${x}dlllocal ${x}_result_t context_t::ddiInit() 34 | { 35 | ${x}_result_t result = ${X}_RESULT_SUCCESS; 36 | 37 | %for tbl in th.get_pfntables(specs, meta, n, tags): 38 | if( ${X}_RESULT_SUCCESS == result ) 39 | { 40 | result = ${tbl['export']['name']}( ${X}_API_VERSION_CURRENT, &${n}DdiTable.${tbl['name']} ); 41 | } 42 | 43 | %endfor 44 | return result; 45 | } 46 | 47 | } // namespace ${x}_lib 48 | -------------------------------------------------------------------------------- /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 | ${func['name']} 11 | %endfor 12 | -------------------------------------------------------------------------------- /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 | ${func['name']}; 11 | %endfor 12 | local: 13 | *; 14 | }; 15 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | 29 | struct ur_queue_t_ { 30 | virtual ~ur_queue_t_(); 31 | 32 | %for obj in th.get_queue_related_functions(specs, n, tags): 33 | %if not 'Release' in obj['name'] and not 'Retain' in obj['name']: 34 | virtual ${x}_result_t ${th.transform_queue_related_function_name(n, tags, obj, format=["type"])} = 0; 35 | %endif 36 | %endfor 37 | }; 38 | -------------------------------------------------------------------------------- /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 | // This file is autogenerated from the template at ${os.path.dirname(self.template.filename)}/${os.path.basename(self.template.filename)} 12 | 13 | %for obj in th.extract_objs(specs, r"enum"): 14 | %if obj["name"] == '$x_structure_type_t': 15 | %for etor in th.get_etors(obj): 16 | %if 'UINT32' not in etor['name']: 17 | template <> 18 | struct stype_map<${x}_${etor['desc'][3:]}> : stype_map_impl<${X}_${etor['name'][3:]}> {}; 19 | %endif 20 | %endfor 21 | %endif 22 | %endfor 23 | 24 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | urGetKernelProcAddrTable 11 | urGetMemProcAddrTable 12 | urGetPhysicalMemProcAddrTable 13 | urGetPlatformProcAddrTable 14 | urGetProgramProcAddrTable 15 | urGetProgramExpProcAddrTable 16 | urGetQueueProcAddrTable 17 | urGetSamplerProcAddrTable 18 | urGetUSMProcAddrTable 19 | urGetUSMExpProcAddrTable 20 | urGetUsmP2PExpProcAddrTable 21 | urGetVirtualMemProcAddrTable 22 | urGetDeviceProcAddrTable 23 | -------------------------------------------------------------------------------- /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 | urGetKernelProcAddrTable; 11 | urGetMemProcAddrTable; 12 | urGetPhysicalMemProcAddrTable; 13 | urGetPlatformProcAddrTable; 14 | urGetProgramProcAddrTable; 15 | urGetProgramExpProcAddrTable; 16 | urGetQueueProcAddrTable; 17 | urGetSamplerProcAddrTable; 18 | urGetUSMProcAddrTable; 19 | urGetUSMExpProcAddrTable; 20 | urGetUsmP2PExpProcAddrTable; 21 | urGetVirtualMemProcAddrTable; 22 | urGetDeviceProcAddrTable; 23 | local: 24 | *; 25 | }; 26 | -------------------------------------------------------------------------------- /source/adapters/cuda/adapter.hpp: -------------------------------------------------------------------------------- 1 | //===--------- adapter.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_ADAPTER_HPP_INCLUDED 12 | #define UR_CUDA_ADAPTER_HPP_INCLUDED 13 | 14 | #include "logger/ur_logger.hpp" 15 | #include "platform.hpp" 16 | #include "tracing.hpp" 17 | #include 18 | 19 | #include 20 | #include 21 | 22 | struct ur_adapter_handle_t_ : ur::cuda::handle_base { 23 | std::atomic RefCount = 0; 24 | struct cuda_tracing_context_t_ *TracingCtx = nullptr; 25 | logger::Logger &logger; 26 | std::unique_ptr Platform; 27 | ur_adapter_handle_t_(); 28 | ~ur_adapter_handle_t_(); 29 | ur_adapter_handle_t_(const ur_adapter_handle_t_ &) = delete; 30 | }; 31 | 32 | // Keep the global namespace'd 33 | namespace ur::cuda { 34 | extern ur_adapter_handle_t adapter; 35 | } // namespace ur::cuda 36 | 37 | #endif // UR_CUDA_ADAPTER_HPP_INCLUDED 38 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 "logger/ur_logger.hpp" 15 | #include "platform.hpp" 16 | 17 | #include 18 | #include 19 | 20 | struct ur_adapter_handle_t_ : ur::hip::handle_base { 21 | std::atomic RefCount = 0; 22 | logger::Logger &logger; 23 | std::unique_ptr Platform; 24 | ur_adapter_handle_t_(); 25 | }; 26 | 27 | namespace ur::hip { 28 | extern ur_adapter_handle_t adapter; 29 | } 30 | 31 | #endif // UR_HIP_ADAPTER_HPP_INCLUDED 32 | -------------------------------------------------------------------------------- /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 "device.hpp" 14 | #include "platform.hpp" 15 | 16 | /// UR queue mapping on physical memory allocations used in virtual memory 17 | /// management. 18 | /// TODO: Implement. 19 | /// 20 | struct ur_physical_mem_handle_t_ : ur::hip::handle_base { 21 | std::atomic_uint32_t RefCount; 22 | 23 | ur_physical_mem_handle_t_() : handle_base(), RefCount(1) {} 24 | 25 | uint32_t incrementReferenceCount() noexcept { return ++RefCount; } 26 | 27 | uint32_t decrementReferenceCount() noexcept { return --RefCount; } 28 | 29 | uint32_t getReferenceCount() const noexcept { return RefCount; } 30 | }; 31 | -------------------------------------------------------------------------------- /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/adapters/level_zero/adapter_lib_init_linux.cpp: -------------------------------------------------------------------------------- 1 | //===--------- adapter_lib_init_linux.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 "adapter.hpp" 12 | #include "ur_level_zero.hpp" 13 | 14 | void __attribute__((constructor)) createAdapterHandle() { 15 | if (!GlobalAdapter) { 16 | GlobalAdapter = new ur_adapter_handle_t_(); 17 | } 18 | } 19 | 20 | void __attribute__((destructor)) deleteAdapterHandle() { 21 | if (GlobalAdapter) { 22 | delete GlobalAdapter; 23 | GlobalAdapter = nullptr; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /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/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 | 14 | struct ur_physical_mem_handle_t_ : ur_object { 15 | ur_physical_mem_handle_t_(ze_physical_mem_handle_t ZePhysicalMem, 16 | ur_context_handle_t Context) 17 | : ZePhysicalMem{ZePhysicalMem}, Context{Context} {} 18 | 19 | // Level Zero physical memory handle. 20 | ze_physical_mem_handle_t ZePhysicalMem; 21 | 22 | // Keeps the PI context of this memory handle. 23 | ur_context_handle_t Context; 24 | }; 25 | -------------------------------------------------------------------------------- /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 | 14 | struct ur_sampler_handle_t_ : ur_object { 15 | ur_sampler_handle_t_(ze_sampler_handle_t Sampler) : ZeSampler{Sampler} {} 16 | 17 | // Level Zero sampler handle. 18 | ze_sampler_handle_t ZeSampler; 19 | 20 | ZeStruct ZeSamplerDesc; 21 | }; 22 | 23 | // Construct ZE sampler desc from UR sampler desc. 24 | ur_result_t ur2zeSamplerDesc(ze_api_version_t ZeApiVersion, 25 | const ur_sampler_desc_t *SamplerDesc, 26 | ZeStruct &ZeSamplerDesc); 27 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 15 | 16 | namespace ur::offload { 17 | struct ddi_getter { 18 | const static ur_dditable_t *value(); 19 | }; 20 | using handle_base = ur::handle_base; 21 | } // namespace ur::offload 22 | 23 | struct RefCounted : ur::offload::handle_base { 24 | std::atomic_uint32_t RefCount = 1; 25 | }; 26 | -------------------------------------------------------------------------------- /source/adapters/offload/context.hpp: -------------------------------------------------------------------------------- 1 | //===----------- context.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_context_handle_t_ : RefCounted { 19 | ur_context_handle_t_(ur_device_handle_t hDevice) : Device{hDevice} { 20 | urDeviceRetain(Device); 21 | } 22 | ~ur_context_handle_t_() { urDeviceRelease(Device); } 23 | 24 | ur_device_handle_t Device; 25 | std::unordered_map AllocTypeMap; 26 | }; 27 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | }; 21 | -------------------------------------------------------------------------------- /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/program.hpp: -------------------------------------------------------------------------------- 1 | //===----------- program.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_program_handle_t_ : RefCounted { 19 | ol_program_handle_t OffloadProgram; 20 | }; 21 | -------------------------------------------------------------------------------- /source/adapters/offload/queue.hpp: -------------------------------------------------------------------------------- 1 | //===----------- queue.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_queue_handle_t_ : RefCounted { 19 | ol_queue_handle_t OffloadQueue; 20 | ol_device_handle_t OffloadDevice; 21 | }; 22 | -------------------------------------------------------------------------------- /source/adapters/offload/ur2offload.hpp: -------------------------------------------------------------------------------- 1 | //===--------- ur2offload.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 | #include 12 | #include 13 | 14 | inline ur_result_t offloadResultToUR(ol_result_t Result) { 15 | if (Result == OL_SUCCESS) { 16 | return UR_RESULT_SUCCESS; 17 | } 18 | 19 | switch (Result->Code) { 20 | case OL_ERRC_INVALID_NULL_HANDLE: 21 | return UR_RESULT_ERROR_INVALID_NULL_HANDLE; 22 | case OL_ERRC_INVALID_NULL_POINTER: 23 | return UR_RESULT_ERROR_INVALID_NULL_POINTER; 24 | case OL_ERRC_UNSUPPORTED: 25 | return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION; 26 | // Returned whenever a kernel can't be found 27 | case OL_ERRC_NOT_FOUND: 28 | return UR_RESULT_ERROR_INVALID_KERNEL_NAME; 29 | default: 30 | return UR_RESULT_ERROR_UNKNOWN; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /source/loader/layers/sanitizer/msan/msan_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 msan_ddi.hpp 11 | * 12 | */ 13 | 14 | #include "ur_ddi.h" 15 | 16 | namespace ur_sanitizer_layer { 17 | 18 | void initMsanInterceptor(); 19 | void destroyMsanInterceptor(); 20 | 21 | ur_result_t initMsanDDITable(ur_dditable_t *dditable); 22 | 23 | } // namespace ur_sanitizer_layer 24 | -------------------------------------------------------------------------------- /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 | void ReportUsesUninitializedValue(const MsanErrorReport &Report, 25 | ur_kernel_handle_t Kernel); 26 | 27 | } // namespace msan 28 | } // namespace ur_sanitizer_layer 29 | -------------------------------------------------------------------------------- /source/loader/layers/sanitizer/sanitizer_common/sanitizer_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 sanitizer_allocator.hpp 11 | * 12 | */ 13 | 14 | #pragma once 15 | 16 | namespace ur_sanitizer_layer { 17 | 18 | enum class AllocType { 19 | UNKNOWN, 20 | DEVICE_USM, 21 | SHARED_USM, 22 | HOST_USM, 23 | MEM_BUFFER, 24 | DEVICE_GLOBAL 25 | }; 26 | 27 | inline const char *ToString(AllocType Type) { 28 | switch (Type) { 29 | case AllocType::DEVICE_USM: 30 | return "Device USM"; 31 | case AllocType::HOST_USM: 32 | return "Host USM"; 33 | case AllocType::SHARED_USM: 34 | return "Shared USM"; 35 | case AllocType::MEM_BUFFER: 36 | return "Memory Buffer"; 37 | case AllocType::DEVICE_GLOBAL: 38 | return "Device Global"; 39 | default: 40 | return "Unknown Type"; 41 | } 42 | } 43 | 44 | } // namespace ur_sanitizer_layer 45 | -------------------------------------------------------------------------------- /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 | 36 | void Init(const std::string &EnvName, logger::Logger &Logger); 37 | }; 38 | 39 | } // namespace ur_sanitizer_layer 40 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /source/loader/layers/validation/backtrace.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 | #ifndef UR_BACKTRACE_H 7 | #define UR_BACKTRACE_H 1 8 | 9 | #include "ur_validation_layer.hpp" 10 | 11 | #define MAX_BACKTRACE_FRAMES 64 12 | 13 | namespace ur_validation_layer { 14 | 15 | using BacktraceLine = std::string; 16 | std::vector getCurrentBacktrace(); 17 | 18 | } // namespace ur_validation_layer 19 | 20 | #endif /* UR_BACKTRACE_H */ 21 | -------------------------------------------------------------------------------- /source/loader/layers/validation/backtrace_lin.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 | #include "backtrace.hpp" 12 | 13 | #include 14 | #include 15 | 16 | namespace ur_validation_layer { 17 | 18 | std::vector getCurrentBacktrace() { 19 | void *backtraceFrames[MAX_BACKTRACE_FRAMES]; 20 | int frameCount = backtrace(backtraceFrames, MAX_BACKTRACE_FRAMES); 21 | char **backtraceStr = backtrace_symbols(backtraceFrames, frameCount); 22 | 23 | if (backtraceStr == nullptr) { 24 | return std::vector(1, "Failed to acquire a backtrace"); 25 | } 26 | 27 | std::vector backtrace; 28 | try { 29 | for (int i = 0; i < frameCount; i++) { 30 | backtrace.emplace_back(backtraceStr[i]); 31 | } 32 | } catch (std::bad_alloc &) { 33 | free(backtraceStr); 34 | return std::vector(1, "Failed to acquire a backtrace"); 35 | } 36 | 37 | free(backtraceStr); 38 | 39 | return backtrace; 40 | } 41 | 42 | } // namespace ur_validation_layer 43 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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_library (ur_mock_headers SHARED 7 | "${CMAKE_CURRENT_SOURCE_DIR}/ur_mock_helpers.cpp") 8 | 9 | target_include_directories(ur_mock_headers 10 | INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}" 11 | ) 12 | 13 | target_link_libraries(ur_mock_headers PRIVATE 14 | ${PROJECT_NAME}::headers 15 | ) 16 | 17 | add_library(${PROJECT_NAME}::mock ALIAS ur_mock_headers) 18 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/.clang-format: -------------------------------------------------------------------------------- 1 | ReflowComments: false 2 | -------------------------------------------------------------------------------- /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/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/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/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/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/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 | -------------------------------------------------------------------------------- /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/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/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/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/adapters/cuda/urEventGetNativeHandle.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 urCudaEventGetNativeHandleTest = uur::urQueueTest; 11 | UUR_INSTANTIATE_DEVICE_TEST_SUITE(urCudaEventGetNativeHandleTest); 12 | 13 | TEST_P(urCudaEventGetNativeHandleTest, Success) { 14 | constexpr size_t buffer_size = 1024; 15 | uur::raii::Mem mem = nullptr; 16 | ASSERT_SUCCESS(urMemBufferCreate(context, UR_MEM_FLAG_READ_WRITE, buffer_size, 17 | nullptr, mem.ptr())); 18 | 19 | uur::raii::Event event = nullptr; 20 | uint8_t pattern = 6; 21 | ASSERT_SUCCESS(urEnqueueMemBufferFill(queue, mem, &pattern, sizeof(pattern), 22 | 0, buffer_size, 0, nullptr, 23 | event.ptr())); 24 | 25 | ur_native_handle_t native_event = 0; 26 | ASSERT_SUCCESS(urEventGetNativeHandle(event, &native_event)); 27 | CUevent cuda_event = reinterpret_cast(native_event); 28 | 29 | ASSERT_SUCCESS_CUDA(cuEventSynchronize(cuda_event)); 30 | } 31 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/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/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/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/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/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/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 | EXPECT_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/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/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/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/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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /test/conformance/device_code/fill_3d.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 = 4; 11 | size_t nd_range_y = 4; 12 | size_t nd_range_z = 4; 13 | auto nd_range = sycl::range<3>(nd_range_x, nd_range_y, nd_range_z); 14 | 15 | std::vector A(nd_range_x * nd_range_y * nd_range_y, 1); 16 | uint32_t val = 42; 17 | sycl::queue sycl_queue; 18 | 19 | auto work_range = sycl::nd_range<3>(nd_range, sycl::range<3>(1, 1, 1)); 20 | auto A_buff = 21 | sycl::buffer(A.data(), sycl::range<1>(nd_range_x * nd_range_y)); 22 | sycl_queue.submit([&](sycl::handler &cgh) { 23 | auto A_acc = A_buff.get_access(cgh); 24 | cgh.parallel_for(work_range, 25 | [A_acc, val](sycl::nd_item<3> item_id) { 26 | auto id = item_id.get_global_linear_id(); 27 | A_acc[id] = val; 28 | }); 29 | }); 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /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/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_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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/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/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/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/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/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 | -------------------------------------------------------------------------------- /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/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/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_compile_definitions(exp_command_buffer-test PRIVATE CL_TARGET_OPENCL_VERSION=300) 24 | target_link_libraries(exp_command_buffer-test PRIVATE OpenCLICDLoader) 25 | endif() 26 | -------------------------------------------------------------------------------- /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 | EXPECT_SUCCESS(urCommandBufferRetainExp(cmd_buf_handle)); 16 | 17 | uint32_t prev_ref_count = 0; 18 | EXPECT_SUCCESS(uur::GetObjectReferenceCount(cmd_buf_handle, prev_ref_count)); 19 | 20 | EXPECT_SUCCESS(urCommandBufferReleaseExp(cmd_buf_handle)); 21 | 22 | uint32_t ref_count = 0; 23 | EXPECT_SUCCESS(uur::GetObjectReferenceCount(cmd_buf_handle, ref_count)); 24 | 25 | EXPECT_GT(prev_ref_count, ref_count); 26 | } 27 | 28 | TEST_P(urCommandBufferReleaseExpTest, InvalidNullHandle) { 29 | EXPECT_EQ_RESULT(urCommandBufferReleaseExp(nullptr), 30 | UR_RESULT_ERROR_INVALID_NULL_HANDLE); 31 | } 32 | -------------------------------------------------------------------------------- /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 | uint32_t prev_ref_count = 0; 16 | EXPECT_SUCCESS(uur::GetObjectReferenceCount(cmd_buf_handle, prev_ref_count)); 17 | 18 | EXPECT_SUCCESS(urCommandBufferRetainExp(cmd_buf_handle)); 19 | 20 | uint32_t ref_count = 0; 21 | EXPECT_SUCCESS(uur::GetObjectReferenceCount(cmd_buf_handle, ref_count)); 22 | 23 | EXPECT_LT(prev_ref_count, ref_count); 24 | 25 | EXPECT_SUCCESS(urCommandBufferReleaseExp(cmd_buf_handle)); 26 | } 27 | 28 | TEST_P(urCommandBufferRetainExpTest, InvalidNullHandle) { 29 | EXPECT_EQ_RESULT(urCommandBufferRetainExp(nullptr), 30 | UR_RESULT_ERROR_INVALID_NULL_HANDLE); 31 | } 32 | -------------------------------------------------------------------------------- /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/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/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/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/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/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/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/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/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/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 | -------------------------------------------------------------------------------- /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/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/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/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 | -------------------------------------------------------------------------------- /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/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 | EXPECT_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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | EXPECT_SUCCESS(urQueueRelease(queue)); 26 | } 27 | 28 | TEST_P(urQueueRetainTest, InvalidNullHandleQueue) { 29 | ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, urQueueRetain(nullptr)); 30 | } 31 | -------------------------------------------------------------------------------- /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/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/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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | EXPECT_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 | -------------------------------------------------------------------------------- /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 | EXPECT_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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /test/fuzz/corpus/alloc: -------------------------------------------------------------------------------- 1 | x d 2 |  -------------------------------------------------------------------------------- /test/fuzz/corpus/create-release: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /test/fuzz/corpus/kernel-launch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oneapi-src/unified-runtime/87a5db2e3bfd234b03a7a0d43b8c14f024823177/test/fuzz/corpus/kernel-launch -------------------------------------------------------------------------------- /test/fuzz/corpus/pool-alloc: -------------------------------------------------------------------------------- 1 | x d  -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/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/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/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/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/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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/loader/handles/handles.test: -------------------------------------------------------------------------------- 1 | RUN: UR_ENABLE_LOADER_INTERCEPT=1 %use-mock loader-handles-test 2 | -------------------------------------------------------------------------------- /test/loader/hello_world.test: -------------------------------------------------------------------------------- 1 | RUN: %use-mock hello_world 2 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /test/loader/loader_config/loader_config.test: -------------------------------------------------------------------------------- 1 | RUN: loader-config-test 2 | -------------------------------------------------------------------------------- /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_config/urLoaderConfigRelease.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 urLoaderConfigReleaseTest = LoaderConfigTest; 10 | 11 | TEST_F(urLoaderConfigReleaseTest, Success) { 12 | ASSERT_SUCCESS(urLoaderConfigRetain(loaderConfig)); 13 | 14 | uint32_t prevRefCount = 0; 15 | ASSERT_SUCCESS( 16 | urLoaderConfigGetInfo(loaderConfig, UR_LOADER_CONFIG_INFO_REFERENCE_COUNT, 17 | sizeof(prevRefCount), &prevRefCount, nullptr)); 18 | 19 | ASSERT_SUCCESS(urLoaderConfigRelease(loaderConfig)); 20 | 21 | uint32_t refCount = 0; 22 | ASSERT_SUCCESS(urLoaderConfigGetInfo(loaderConfig, 23 | UR_LOADER_CONFIG_INFO_REFERENCE_COUNT, 24 | sizeof(refCount), &refCount, nullptr)); 25 | 26 | ASSERT_LT(refCount, prevRefCount); 27 | } 28 | 29 | TEST_F(urLoaderConfigReleaseTest, InvalidNullHandleLoaderConfig) { 30 | ASSERT_EQ(UR_RESULT_ERROR_INVALID_NULL_HANDLE, 31 | urLoaderConfigRelease(nullptr)); 32 | } 33 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/loader/loader_lifetime/loader_lifetime.test: -------------------------------------------------------------------------------- 1 | RUN: loader-lifetime-test 2 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/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/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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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.2 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.2.2 41 | dataclasses-json==0.6.7 42 | 43 | # Unified-runtime is formatted using black 44 | black==25.1.0 45 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | --------------------------------------------------------------------------------