forked from oneapi-src/unified-runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CUDA] Return error on silently failing urEventGetInfo queries for in…
…terop created events
- Loading branch information
Showing
6 changed files
with
106 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright (C) 2022-2024 Intel Corporation | ||
// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See LICENSE.TXT | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
#include "event.hpp" | ||
#include "fixtures.h" | ||
#include "raii.h" | ||
|
||
using cudaEventTest = uur::urContextTest; | ||
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(cudaEventTest); | ||
|
||
// Testing the urEventGetInfo behaviour for natively constructed (Cuda) events. | ||
// Backend interop APIs can lead to creating event objects that are not fully | ||
// initialized. In the Cuda adapter, an event can have nullptr command queue | ||
// because the interop API does not associate a UR-owned queue with the event. | ||
TEST_P(cudaEventTest, GetQueueFromEventCreatedWithNativeHandle) { | ||
RAIICUevent cuda_event; | ||
ASSERT_SUCCESS_CUDA(cuEventCreate(cuda_event.ptr(), CU_EVENT_DEFAULT)); | ||
|
||
auto native_event = reinterpret_cast<ur_native_handle_t>(cuda_event.get()); | ||
uur::raii::Event event{nullptr}; | ||
ASSERT_SUCCESS(urEventCreateWithNativeHandle(native_event, context, nullptr, | ||
event.ptr())); | ||
EXPECT_NE(event, nullptr); | ||
|
||
size_t ret_size{}; | ||
ur_queue_handle_t q{}; | ||
ASSERT_EQ_RESULT(urEventGetInfo(event, UR_EVENT_INFO_COMMAND_QUEUE, | ||
sizeof(ur_queue_handle_t), &q, &ret_size), | ||
UR_RESULT_ERROR_ADAPTER_SPECIFIC); | ||
} | ||
|
||
TEST_P(cudaEventTest, GetQueueFromNativeEvent) { | ||
// Create a Cuda event object | ||
CUevent cuda_event{nullptr}; | ||
ASSERT_SUCCESS_CUDA(cuEventCreate(&cuda_event, CU_EVENT_DEFAULT)); | ||
|
||
auto native_event = reinterpret_cast<ur_native_handle_t>(cuda_event); | ||
|
||
{ | ||
uur::raii::Event event{nullptr}; | ||
ASSERT_SUCCESS(urEventCreateWithNativeHandle(native_event, context, | ||
nullptr, event.ptr())); | ||
EXPECT_NE(event, nullptr); | ||
|
||
size_t ret_size{}; | ||
ur_queue_handle_t q{}; | ||
ASSERT_EQ_RESULT(urEventGetInfo(event, UR_EVENT_INFO_COMMAND_QUEUE, | ||
sizeof(ur_queue_handle_t), &q, | ||
&ret_size), | ||
UR_RESULT_ERROR_ADAPTER_SPECIFIC); | ||
} | ||
|
||
// Release the Cuda event object | ||
if (cuda_event) { | ||
ASSERT_SUCCESS_CUDA(cuEventDestroy(cuda_event)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#pragma once | ||
|
||
#include "uur/raii.h" | ||
|
||
struct RAIICUevent { | ||
CUevent handle = nullptr; | ||
|
||
~RAIICUevent() { | ||
if (handle) { | ||
cuEventDestroy(handle); | ||
} | ||
} | ||
|
||
CUevent *ptr() { return &handle; } | ||
CUevent get() { return handle; } | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters