-
Notifications
You must be signed in to change notification settings - Fork 124
[L0] L0 impl for enqueue native command #1880
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
Changes from all commits
f2afed2
7d14d84
8020612
d76742e
7fbc58b
245afb3
382325d
6111fb2
632ba6b
5e1195e
071223f
352015f
1528f4c
716ee15
3f13f69
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| // Copyright (C) 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 "ze_api.h" | ||
|
|
||
| #include <uur/fixtures.h> | ||
| #include <vector> | ||
|
|
||
| using T = uint32_t; | ||
|
|
||
| struct urLevelZeroEnqueueNativeCommandTest : uur::urQueueTest { | ||
| void SetUp() { | ||
| UUR_RETURN_ON_FATAL_FAILURE(uur::urQueueTest::SetUp()); | ||
|
|
||
| host_vec = std::vector<T>(global_size, 0); | ||
| ASSERT_EQ(host_vec.size(), global_size); | ||
| ASSERT_SUCCESS(urUSMDeviceAlloc(context, device, nullptr, nullptr, | ||
| allocation_size, &device_ptr)); | ||
| ASSERT_NE(device_ptr, nullptr); | ||
| } | ||
| static constexpr T val = 42; | ||
| static constexpr uint32_t global_size = 1e7; | ||
| std::vector<T> host_vec; | ||
| void *device_ptr = nullptr; | ||
| static constexpr size_t allocation_size = sizeof(val) * global_size; | ||
| }; | ||
|
|
||
| UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urLevelZeroEnqueueNativeCommandTest); | ||
|
|
||
| struct InteropData1 { | ||
| void *fill_ptr; | ||
| }; | ||
|
|
||
| // Fill a device ptr with the pattern val | ||
| void interop_func_1(ur_queue_handle_t hQueue, void *data) { | ||
| ze_command_list_handle_t CommandList; | ||
| ASSERT_SUCCESS(urQueueGetNativeHandle(hQueue, nullptr, | ||
| (ur_native_handle_t *)&CommandList)); | ||
| InteropData1 *func_data = reinterpret_cast<InteropData1 *>(data); | ||
|
|
||
| // If L0 interop becomes a real use case we should make a new UR entry point | ||
| // to propagate events into and out of the the interop func. | ||
| zeCommandListAppendMemoryFill( | ||
| CommandList, func_data->fill_ptr, | ||
| &urLevelZeroEnqueueNativeCommandTest::val, | ||
| sizeof(urLevelZeroEnqueueNativeCommandTest::val), | ||
| urLevelZeroEnqueueNativeCommandTest::allocation_size, nullptr, 0, | ||
| nullptr); | ||
| } | ||
|
|
||
| struct InteropData2 { | ||
| void *from, *to; | ||
| }; | ||
|
|
||
| // Read from device ptr to host ptr | ||
| void interop_func_2(ur_queue_handle_t hQueue, void *data) { | ||
| ze_command_list_handle_t CommandList; | ||
| ASSERT_SUCCESS(urQueueGetNativeHandle(hQueue, nullptr, | ||
| (ur_native_handle_t *)&CommandList)); | ||
| InteropData2 *func_data = reinterpret_cast<InteropData2 *>(data); | ||
|
|
||
| // If L0 interop becomes a real use case we should make a new UR entry point | ||
| // to propagate events into and out of the the interop func. | ||
| zeCommandListAppendMemoryCopy( | ||
| CommandList, func_data->to, func_data->from, | ||
| urLevelZeroEnqueueNativeCommandTest::allocation_size, nullptr, 0, | ||
| nullptr); | ||
| } | ||
|
|
||
| TEST_P(urLevelZeroEnqueueNativeCommandTest, Success) { | ||
| InteropData1 data_1{device_ptr}; | ||
| ur_event_handle_t event_1; | ||
| ASSERT_SUCCESS(urEnqueueNativeCommandExp( | ||
| queue, &interop_func_1, &data_1, 0, nullptr /*phMemList=*/, | ||
| nullptr /*pProperties=*/, 0, nullptr /*phEventWaitList=*/, &event_1)); | ||
| } | ||
|
|
||
| TEST_P(urLevelZeroEnqueueNativeCommandTest, Dependencies) { | ||
| ur_event_handle_t event_1, event_2; | ||
|
|
||
| InteropData1 data_1{device_ptr}; | ||
| ASSERT_SUCCESS(urEnqueueNativeCommandExp( | ||
| queue, &interop_func_1, &data_1, 0, nullptr /*phMemList=*/, | ||
| nullptr /*pProperties=*/, 0, nullptr /*phEventWaitList=*/, &event_1)); | ||
|
|
||
| InteropData2 data_2{device_ptr, host_vec.data()}; | ||
| ASSERT_SUCCESS(urEnqueueNativeCommandExp( | ||
| queue, &interop_func_2, &data_2, 0, nullptr /*phMemList=*/, | ||
| nullptr /*pProperties=*/, 1, &event_1, &event_2)); | ||
| urQueueFinish(queue); | ||
| for (auto &i : host_vec) { | ||
| ASSERT_EQ(i, val); | ||
| } | ||
| } | ||
|
|
||
| TEST_P(urLevelZeroEnqueueNativeCommandTest, DependenciesURBefore) { | ||
| ur_event_handle_t event_1, event_2; | ||
|
|
||
| ASSERT_SUCCESS(urEnqueueUSMFill(queue, device_ptr, sizeof(val), &val, | ||
| allocation_size, 0, | ||
| nullptr /*phEventWaitList=*/, &event_1)); | ||
|
|
||
| InteropData2 data_2{device_ptr, host_vec.data()}; | ||
| ASSERT_SUCCESS(urEnqueueNativeCommandExp( | ||
| queue, &interop_func_2, &data_2, 0, nullptr /*phMemList=*/, | ||
| nullptr /*pProperties=*/, 1, &event_1, &event_2)); | ||
| urQueueFinish(queue); | ||
| for (auto &i : host_vec) { | ||
| ASSERT_EQ(i, val); | ||
| } | ||
| } | ||
|
|
||
| TEST_P(urLevelZeroEnqueueNativeCommandTest, DependenciesURAfter) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is failing. If the queue this test is using is out of order, this may be a result of the problem we talked about. If that is indeed the case, one of the solutions might be something like: @nrspruit do you know whether, in the case of out-of-order command list, there's a better way to ensure ordering between the three different operations (wait, callback, signal) in the implementation of The current one is based on
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have updated. Let me know what you think |
||
| ur_event_handle_t event_1; | ||
|
|
||
| InteropData1 data_1{device_ptr}; | ||
| ASSERT_SUCCESS(urEnqueueNativeCommandExp( | ||
| queue, &interop_func_1, &data_1, 0, nullptr /*phMemList=*/, | ||
| nullptr /*pProperties=*/, 0, nullptr /*phEventWaitList=*/, &event_1)); | ||
|
|
||
| urEnqueueUSMMemcpy(queue, /*blocking*/ true, host_vec.data(), device_ptr, | ||
| allocation_size, 1, &event_1, nullptr); | ||
| for (auto &i : host_vec) { | ||
| ASSERT_EQ(i, val); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| urLevelZeroEnqueueNativeCommandTest.Success{{.*}} | ||
| urLevelZeroEnqueueNativeCommandTest.Dependencies{{.*}} | ||
| urLevelZeroEnqueueNativeCommandTest.DependenciesURBefore{{.*}} | ||
| urLevelZeroEnqueueNativeCommandTest.DependenciesURAfter{{.*}} |
Uh oh!
There was an error while loading. Please reload this page.