Skip to content

Update spec to make kernel validation optional #2564

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions include/ur_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -7429,6 +7429,11 @@ UR_APIEXPORT ur_result_t UR_APICALL urEventSetCallback(
///////////////////////////////////////////////////////////////////////////////
/// @brief Enqueue a command to execute a kernel
///
/// @details
/// - Adapters may perform validation on the number of arguments set to the
/// kernel, but are not required to do so and may return
/// `::UR_RESULT_SUCCESS` even for invalid invocations.
///
/// @remarks
/// _Analogues_
/// - **clEnqueueNDRangeKernel**
Expand Down Expand Up @@ -7456,8 +7461,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urEventSetCallback(
/// - ::UR_RESULT_ERROR_INVALID_WORK_DIMENSION
/// - ::UR_RESULT_ERROR_INVALID_WORK_GROUP_SIZE
/// - ::UR_RESULT_ERROR_INVALID_VALUE
/// - ::UR_RESULT_ERROR_INVALID_KERNEL_ARGS - "The kernel argument values
/// have not been specified."
/// - ::UR_RESULT_ERROR_INVALID_KERNEL_ARGS
/// + The kernel argument values have not been specified and the adapter
/// is able to detect this.
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
UR_APIEXPORT ur_result_t UR_APICALL urEnqueueKernelLaunch(
Expand Down
7 changes: 5 additions & 2 deletions scripts/core/enqueue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ type: function
desc: "Enqueue a command to execute a kernel"
class: $xEnqueue
name: KernelLaunch
details:
- "Adapters may perform validation on the number of arguments set to the kernel, but are not required to do so and may
return `$X_RESULT_SUCCESS` even for invalid invocations."
ordinal: "0"
analogue:
- "**clEnqueueNDRangeKernel**"
Expand Down Expand Up @@ -65,8 +68,8 @@ returns:
- $X_RESULT_ERROR_INVALID_WORK_DIMENSION
- $X_RESULT_ERROR_INVALID_WORK_GROUP_SIZE
- $X_RESULT_ERROR_INVALID_VALUE
- $X_RESULT_ERROR_INVALID_KERNEL_ARGS
- "The kernel argument values have not been specified."
- $X_RESULT_ERROR_INVALID_KERNEL_ARGS:
- "The kernel argument values have not been specified and the adapter is able to detect this."
- $X_RESULT_ERROR_OUT_OF_HOST_MEMORY
- $X_RESULT_ERROR_OUT_OF_RESOURCES
--- #--------------------------------------------------------------------------
Expand Down
10 changes: 8 additions & 2 deletions source/loader/ur_libapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4980,6 +4980,11 @@ ur_result_t UR_APICALL urEventSetCallback(
///////////////////////////////////////////////////////////////////////////////
/// @brief Enqueue a command to execute a kernel
///
/// @details
/// - Adapters may perform validation on the number of arguments set to the
/// kernel, but are not required to do so and may return
/// `::UR_RESULT_SUCCESS` even for invalid invocations.
///
/// @remarks
/// _Analogues_
/// - **clEnqueueNDRangeKernel**
Expand Down Expand Up @@ -5007,8 +5012,9 @@ ur_result_t UR_APICALL urEventSetCallback(
/// - ::UR_RESULT_ERROR_INVALID_WORK_DIMENSION
/// - ::UR_RESULT_ERROR_INVALID_WORK_GROUP_SIZE
/// - ::UR_RESULT_ERROR_INVALID_VALUE
/// - ::UR_RESULT_ERROR_INVALID_KERNEL_ARGS - "The kernel argument values
/// have not been specified."
/// - ::UR_RESULT_ERROR_INVALID_KERNEL_ARGS
/// + The kernel argument values have not been specified and the adapter
/// is able to detect this.
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
ur_result_t UR_APICALL urEnqueueKernelLaunch(
Expand Down
10 changes: 8 additions & 2 deletions source/ur_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4345,6 +4345,11 @@ ur_result_t UR_APICALL urEventSetCallback(
///////////////////////////////////////////////////////////////////////////////
/// @brief Enqueue a command to execute a kernel
///
/// @details
/// - Adapters may perform validation on the number of arguments set to the
/// kernel, but are not required to do so and may return
/// `::UR_RESULT_SUCCESS` even for invalid invocations.
///
/// @remarks
/// _Analogues_
/// - **clEnqueueNDRangeKernel**
Expand Down Expand Up @@ -4372,8 +4377,9 @@ ur_result_t UR_APICALL urEventSetCallback(
/// - ::UR_RESULT_ERROR_INVALID_WORK_DIMENSION
/// - ::UR_RESULT_ERROR_INVALID_WORK_GROUP_SIZE
/// - ::UR_RESULT_ERROR_INVALID_VALUE
/// - ::UR_RESULT_ERROR_INVALID_KERNEL_ARGS - "The kernel argument values
/// have not been specified."
/// - ::UR_RESULT_ERROR_INVALID_KERNEL_ARGS
/// + The kernel argument values have not been specified and the adapter
/// is able to detect this.
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
ur_result_t UR_APICALL urEnqueueKernelLaunch(
Expand Down
28 changes: 10 additions & 18 deletions test/conformance/enqueue/urEnqueueKernelLaunch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,26 +154,18 @@ TEST_P(urEnqueueKernelLaunchTest, InvalidWorkGroupSize) {
}

TEST_P(urEnqueueKernelLaunchTest, InvalidKernelArgs) {
// Cuda and hip both lack any way to validate kernel args
UUR_KNOWN_FAILURE_ON(uur::CUDA{}, uur::HIP{});
UUR_KNOWN_FAILURE_ON(uur::LevelZero{}, uur::LevelZeroV2{});

ur_platform_backend_t backend;
ASSERT_SUCCESS(urPlatformGetInfo(platform, UR_PLATFORM_INFO_BACKEND,
sizeof(ur_platform_backend_t), &backend,
nullptr));

if (backend == UR_PLATFORM_BACKEND_CUDA ||
backend == UR_PLATFORM_BACKEND_HIP ||
backend == UR_PLATFORM_BACKEND_LEVEL_ZERO) {
GTEST_FAIL() << "AMD, L0 and Nvidia can't check kernel arguments.";
}
// Seems to segfault
UUR_KNOWN_FAILURE_ON(uur::HIP{});
// cuLaunchKernel seems to be returning CUDA_ERROR_INVALID_VALUE which is
// converted to UR_RESULT_ERROR_INVALID_VALUE
UUR_KNOWN_FAILURE_ON(uur::CUDA{});

// Enqueue kernel without setting any args
ASSERT_EQ_RESULT(urEnqueueKernelLaunch(queue, kernel, n_dimensions,
&global_offset, &global_size, nullptr,
0, nullptr, nullptr),
UR_RESULT_ERROR_INVALID_KERNEL_ARGS);
auto error =
urEnqueueKernelLaunch(queue, kernel, n_dimensions, &global_offset,
&global_size, nullptr, 0, nullptr, nullptr);
ASSERT_TRUE(error == UR_RESULT_ERROR_INVALID_KERNEL_ARGS ||
error == UR_RESULT_SUCCESS);
}

TEST_P(urEnqueueKernelLaunchKernelWgSizeTest, Success) {
Expand Down
Loading