|
| 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 | +#include "event.hpp" |
| 7 | +#include "fixtures.h" |
| 8 | +#include "raii.h" |
| 9 | + |
| 10 | +using cudaEventTest = uur::urContextTest; |
| 11 | +UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(cudaEventTest); |
| 12 | + |
| 13 | +// Testing the urEventGetInfo behaviour for natively constructed (Cuda) events. |
| 14 | +// Backend interop APIs can lead to creating event objects that are not fully |
| 15 | +// initialized. In the Cuda adapter, an event can have nullptr command queue |
| 16 | +// because the interop API does not associate a UR-owned queue with the event. |
| 17 | +TEST_P(cudaEventTest, GetQueueFromEventCreatedWithNativeHandle) { |
| 18 | + RAIICUevent cuda_event; |
| 19 | + ASSERT_SUCCESS_CUDA(cuEventCreate(cuda_event.ptr(), CU_EVENT_DEFAULT)); |
| 20 | + |
| 21 | + auto native_event = reinterpret_cast<ur_native_handle_t>(cuda_event.get()); |
| 22 | + uur::raii::Event event{nullptr}; |
| 23 | + ASSERT_SUCCESS(urEventCreateWithNativeHandle(native_event, context, nullptr, |
| 24 | + event.ptr())); |
| 25 | + EXPECT_NE(event, nullptr); |
| 26 | + |
| 27 | + size_t ret_size{}; |
| 28 | + ur_queue_handle_t q{}; |
| 29 | + ASSERT_EQ_RESULT(urEventGetInfo(event, UR_EVENT_INFO_COMMAND_QUEUE, |
| 30 | + sizeof(ur_queue_handle_t), &q, &ret_size), |
| 31 | + UR_RESULT_ERROR_ADAPTER_SPECIFIC); |
| 32 | +} |
0 commit comments