-
Notifications
You must be signed in to change notification settings - Fork 124
[CUDA][HIP] Return error on silently failing urEventGetInfo queries for interop created events #1399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
omarahmed1111
merged 5 commits into
oneapi-src:main
from
GeorgeWeb:georgi/get-event-info-from-native-fix
Jul 30, 2024
Merged
[CUDA][HIP] Return error on silently failing urEventGetInfo queries for interop created events #1399
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d671824
[CUDA] Return error on silently failing urEventGetInfo queries for in…
e525bc5
[HIP] Return error on silently failing urEventGetInfo queries for int…
e2af0d1
Remove unrelated change in CUDA urEventCreateWithNativeHandle
3e16283
Check explicitly if the queue member of ur_event is null instead of b…
df6e9d2
Fix the Cuda adapter specific GetQueueFromEventCreatedWithNativeHandl…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,36 @@ | ||
| // 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 "device.hpp" | ||
| #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) { | ||
| CUcontext cuda_ctx = device->getNativeContext(); | ||
| EXPECT_NE(cuda_ctx, nullptr); | ||
| RAIICUevent cuda_event; | ||
| ASSERT_SUCCESS_CUDA(cuCtxSetCurrent(cuda_ctx)); | ||
| 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); | ||
| } |
This file contains hidden or 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,25 @@ | ||
| // 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 | ||
|
|
||
| #ifndef UR_TEST_CONFORMANCE_ADAPTERS_CUDA_RAII_H_INCLUDED | ||
| #define UR_TEST_CONFORMANCE_ADAPTERS_CUDA_RAII_H_INCLUDED | ||
|
|
||
| #include "uur/raii.h" | ||
| #include <cuda.h> | ||
|
|
||
| struct RAIICUevent { | ||
| CUevent handle = nullptr; | ||
|
|
||
| ~RAIICUevent() { | ||
| if (handle) { | ||
| cuEventDestroy(handle); | ||
| } | ||
| } | ||
|
|
||
| CUevent *ptr() { return &handle; } | ||
| CUevent get() { return handle; } | ||
| }; | ||
|
|
||
| #endif // UR_TEST_CONFORMANCE_ADAPTERS_CUDA_RAII_H_INCLUDED |
This file contains hidden or 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 hidden or 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 hidden or 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,49 @@ | ||
| // 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 "uur/raii.h" | ||
|
|
||
| #include <hip/hip_runtime.h> | ||
| #include <tuple> | ||
|
|
||
| struct RAIIHipEvent { | ||
jchlanda marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| hipEvent_t handle = nullptr; | ||
|
|
||
| ~RAIIHipEvent() { | ||
| if (handle) { | ||
| std::ignore = hipEventDestroy(handle); | ||
| } | ||
| } | ||
|
|
||
| hipEvent_t *ptr() { return &handle; } | ||
| hipEvent_t get() { return handle; } | ||
| }; | ||
|
|
||
| using urHipEventTest = uur::urContextTest; | ||
| UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urHipEventTest); | ||
|
|
||
| // Testing the urEventGetInfo behaviour for natively constructed (HIP) 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(urHipEventTest, GetQueueFromEventCreatedWithNativeHandle) { | ||
| RAIIHipEvent hip_event; | ||
| ASSERT_SUCCESS_HIP( | ||
| hipEventCreateWithFlags(hip_event.ptr(), hipEventDefault)); | ||
|
|
||
| auto native_event = reinterpret_cast<ur_native_handle_t>(hip_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); | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.