[SYCL][UR] `Basic/buffer/buffer.cpp` segfaulting on Windows when using `UR_l0_V2_FORCE_BATCHED`
- Dominant language
- LLVM
- Stars
- 1.5k
- Forks
- 854
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 137
Description
### Describe the bug
Failure log:
```
bash-3.2$ env SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=0 env UR_L0_V2_FORCE_BATCHED=1 env ONEAPI_DEVICE_SELECTOR=level_zero:gpu 'llvm\build\tools\sycl\test-e2e\Basic\buffer\Output\buffer.cpp.tmp2.out'
move constructor
move assignment operator
copy constructor
copy assignment operator
Segmentation fault
```
On the face of it, it looks like `FORCE_BATCHED` is misbehaving with Buffer destructor (which is blocking) during application shutdown.
UR calls fail with UR_RESULT_ERROR_UNINITIALIZED. Seems like batch is being enqueued after L0 loader is in teardown.
```
---> urEventWait
UR ---> batchLocked->enqueueCurrentBatchUnlocked()
UR <--- batchLocked->enqueueCurrentBatchUnlocked()(UR_RESULT_ERROR_UNINITIALIZED)
<--- urEventWait(.numEvents = 1, .phEventWaitList = 00000027248FF2E0 {000001B4E108F8C0}) -> UR_RESULT_ERROR_UNINITIALIZED;
```
### To reproduce
### Environment
- OS: Windows
- Target device and vendor: BMG
- DPC++ version: 3634f01dad35fcc6321878058dd6a79c20b35aa6
`sycl-ls --verbose`
```
bash-3.2$ ./sycl-ls.exe --verbose
[level_zero:gpu] Intel(R) oneAPI Unified Runtime over Level-Zero V2, Intel(R) Arc(TM) B580 Graphics 20.1.0 [1.13.35716]
Platforms: 1
Platform [#1]:
Version : 1.13
Name : Intel(R) oneAPI Unified Runtime over Level-Zero V2
Vendor : Intel(R) Corporation
Devices : 1
Type : gpu
Version : 20.1.0
Name : Intel(R) Arc(TM) B580 Graphics
Vendor : Intel(R) Corporation
Driver : 1.13.35716
UUID : 86800be2-0000-0000-0300-000000000000
DeviceID : 57867
Num SubDevices : 0
Num SubSubDevices : 0
Aspects : gpu fp16 fp64 online_compiler online_linker queue_profiling usm_device_allocations usm_host_allocations usm_shared_allocations ext_intel_pci_address ext_intel_gpu_eu_count ext_intel_gpu_eu_simd_width ext_intel_gpu_slices ext_intel_gpu_subslices_per_slice ext_intel_gpu_eu_count_per_subslice atomic64 ext_intel_device_info_uuid ext_oneapi_native_assert ext_intel_gpu_hw_threads_per_eu ext_intel_free_memory ext_intel_device_id ext_intel_memory_clock_rate ext_intel_memory_bus_width ext_intel_legacy_image ext_oneapi_bindless_images ext_oneapi_bindless_images_1d_usm ext_oneapi_bindless_images_2d_usm ext_oneapi_external_memory_import ext_oneapi_external_semaphore_import ext_intel_esimd ext_oneapi_fragment ext_oneapi_chunk ext_oneapi_tangle ext_intel_matrix ext_oneapi_graph ext_oneapi_limited_graph ext_oneapi_private_alloca ext_oneapi_bindless_sampled_image_fetch_1d_usm ext_oneapi_bindless_sampled_image_fetch_1d ext_oneapi_bindless_sampled_image_fetch_2d_usm ext_oneapi_bindless_sampled_image_fetch_2d ext_oneapi_bindless_sampled_image_fetch_3d ext_oneapi_queue_profiling_tag ext_oneapi_virtual_mem ext_oneapi_image_array ext_oneapi_virtual_functions ext_intel_spill_memory_size ext_intel_current_clock_throttle_reasons ext_intel_fan_speed ext_intel_power_limits ext_oneapi_async_memory_alloc ext_intel_device_info_luid ext_intel_device_info_node_mask ext_oneapi_exportable_device_mem ext_oneapi_clock_sub_group
info::device::sub_group_sizes: 16 32
Architecture: intel_gpu_bmg_g21
default_selector() : gpu, Intel(R) oneAPI Unified Runtime over Level-Zero V2, Intel(R) Arc(TM) B580 Graphics 20.1.0 [1.13.35716]
accelerator_selector() : No device of requested type available.
cpu_selector() : No device of requested type available.
gpu_selector() : gpu, Intel(R) oneAPI Unified Runtime over Level-Zero V2, Intel(R) Arc(TM) B580 Graphics 20.1.0 [1.13.35716]
custom_selector(gpu) : gpu, Intel(R) oneAPI Unified Runtime over Level-Zero V2, Intel(R) Arc(TM) B580 Graphics 20.1.0 [1.13.35716]
custom_selector(cpu) : No device of requested type available.
custom_selector(acc) : No device of requested type available.
```
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.