Skip to content

Commit a433766

Browse files
committed
Rename INVALID_FUNCTION_NAME to FUNCTION_ADDRESS_NOT_AVAILABLE.
This lines up better with the original PI error code and what it was meant to convey. Also clarify the spec around return codes for urProgramGetFunctionPointer and update the relevant CTS test.
1 parent caab344 commit a433766

17 files changed

+43
-31
lines changed

include/ur_api.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,8 @@ typedef enum ur_result_t {
481481
UR_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT = 55, ///< [Validation] image format is not supported by the device
482482
UR_RESULT_ERROR_INVALID_NATIVE_BINARY = 56, ///< [Validation] native binary is not supported by the device
483483
UR_RESULT_ERROR_INVALID_GLOBAL_NAME = 57, ///< [Validation] global variable is not found in the program
484-
UR_RESULT_ERROR_INVALID_FUNCTION_NAME = 58, ///< [Validation] function name is not found in the program
484+
UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE = 58, ///< [Validation] function name is in the program but its address could not
485+
///< be determined
485486
UR_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION = 59, ///< [Validation] group size dimension is not valid for the kernel or
486487
///< device
487488
UR_RESULT_ERROR_INVALID_GLOBAL_WIDTH_DIMENSION = 60, ///< [Validation] global width dimension is not valid for the kernel or
@@ -4362,8 +4363,8 @@ urProgramRelease(
43624363
/// @details
43634364
/// - Retrieves a pointer to the functions with the given name and defined
43644365
/// in the given program.
4365-
/// - ::UR_RESULT_ERROR_INVALID_FUNCTION_NAME is returned if the function
4366-
/// can not be obtained.
4366+
/// - ::UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE is returned if the
4367+
/// function can not be obtained.
43674368
/// - The application may call this function from simultaneous threads for
43684369
/// the same device.
43694370
/// - The implementation of this function should be thread-safe.
@@ -4383,6 +4384,10 @@ urProgramRelease(
43834384
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
43844385
/// + `NULL == pFunctionName`
43854386
/// + `NULL == ppFunctionPointer`
4387+
/// - ::UR_RESULT_ERROR_INVALID_KERNEL_NAME
4388+
/// + If `pFunctionName` couldn't be found in `hProgram`.
4389+
/// - ::UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE
4390+
/// + If `pFunctionName` could be located, but its address couldn't be retrieved.
43864391
UR_APIEXPORT ur_result_t UR_APICALL
43874392
urProgramGetFunctionPointer(
43884393
ur_device_handle_t hDevice, ///< [in] handle of the device to retrieve pointer for.

include/ur_print.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,8 +1541,8 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_result_t value) {
15411541
case UR_RESULT_ERROR_INVALID_GLOBAL_NAME:
15421542
os << "UR_RESULT_ERROR_INVALID_GLOBAL_NAME";
15431543
break;
1544-
case UR_RESULT_ERROR_INVALID_FUNCTION_NAME:
1545-
os << "UR_RESULT_ERROR_INVALID_FUNCTION_NAME";
1544+
case UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE:
1545+
os << "UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE";
15461546
break;
15471547
case UR_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION:
15481548
os << "UR_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION";

scripts/core/common.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,8 @@ etors:
251251
desc: "[Validation] native binary is not supported by the device"
252252
- name: ERROR_INVALID_GLOBAL_NAME
253253
desc: "[Validation] global variable is not found in the program"
254-
- name: ERROR_INVALID_FUNCTION_NAME
255-
desc: "[Validation] function name is not found in the program"
254+
- name: ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE
255+
desc: "[Validation] function name is in the program but its address could not be determined"
256256
- name: ERROR_INVALID_GROUP_SIZE_DIMENSION
257257
desc: "[Validation] group size dimension is not valid for the kernel or device"
258258
- name: ERROR_INVALID_GLOBAL_WIDTH_DIMENSION

scripts/core/program.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ analogue:
291291
- "**clGetDeviceFunctionPointerINTEL**"
292292
details:
293293
- "Retrieves a pointer to the functions with the given name and defined in the given program."
294-
- "$X_RESULT_ERROR_INVALID_FUNCTION_NAME is returned if the function can not be obtained."
294+
- "$X_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE is returned if the function can not be obtained."
295295
- "The application may call this function from simultaneous threads for the same device."
296296
- "The implementation of this function should be thread-safe."
297297
params:
@@ -313,6 +313,11 @@ params:
313313
name: ppFunctionPointer
314314
desc: |
315315
[out] Returns the pointer to the function if it is found in the program.
316+
returns:
317+
- $X_RESULT_ERROR_INVALID_KERNEL_NAME:
318+
- "If `pFunctionName` couldn't be found in `hProgram`."
319+
- $X_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE:
320+
- "If `pFunctionName` could be located, but its address couldn't be retrieved."
316321
--- #--------------------------------------------------------------------------
317322
type: function
318323
desc: "Retrieves a pointer to a device global variable."

source/adapters/cuda/program.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramGetFunctionPointer(
503503
UR_CHECK_ERROR(Ret);
504504
if (Ret == CUDA_ERROR_NOT_FOUND) {
505505
*ppFunctionPointer = 0;
506-
Result = UR_RESULT_ERROR_INVALID_FUNCTION_NAME;
506+
Result = UR_RESULT_ERROR_INVALID_KERNEL_NAME;
507507
}
508508

509509
return Result;

source/adapters/hip/program.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramGetFunctionPointer(
539539
UR_CHECK_ERROR(Ret);
540540
if (Ret == hipErrorNotFound) {
541541
*ppFunctionPointer = 0;
542-
Result = UR_RESULT_ERROR_INVALID_FUNCTION_NAME;
542+
Result = UR_RESULT_ERROR_INVALID_KERNEL_NAME;
543543
}
544544

545545
return Result;

source/adapters/level_zero/common.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,8 @@ ur_result_t ze2urResult(ze_result_t ZeResult) {
4646
case ZE_RESULT_ERROR_INVALID_NATIVE_BINARY:
4747
return UR_RESULT_ERROR_INVALID_BINARY;
4848
case ZE_RESULT_ERROR_INVALID_KERNEL_NAME:
49-
return UR_RESULT_ERROR_INVALID_KERNEL_NAME;
5049
case ZE_RESULT_ERROR_INVALID_FUNCTION_NAME:
51-
return UR_RESULT_ERROR_INVALID_FUNCTION_NAME;
50+
return UR_RESULT_ERROR_INVALID_KERNEL_NAME;
5251
case ZE_RESULT_ERROR_OVERLAPPING_REGIONS:
5352
return UR_RESULT_ERROR_INVALID_OPERATION;
5453
case ZE_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION:

source/adapters/level_zero/common.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ static auto getUrResultString = [](ur_result_t Result) {
145145
return "UR_RESULT_ERROR_INVALID_NATIVE_BINARY";
146146
case UR_RESULT_ERROR_INVALID_GLOBAL_NAME:
147147
return "UR_RESULT_ERROR_INVALID_GLOBAL_NAME";
148-
case UR_RESULT_ERROR_INVALID_FUNCTION_NAME:
149-
return "UR_RESULT_ERROR_INVALID_FUNCTION_NAME";
148+
case UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE:
149+
return "UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE";
150150
case UR_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION:
151151
return "UR_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION";
152152
case UR_RESULT_ERROR_INVALID_GLOBAL_WIDTH_DIMENSION:

source/adapters/level_zero/program.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramGetFunctionPointer(
570570
// exists
571571
ClResult.pop_back();
572572
if (is_in_separated_string(ClResult, ';', std::string(FunctionName)))
573-
return UR_RESULT_ERROR_INVALID_FUNCTION_NAME;
573+
return UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE;
574574

575575
return UR_RESULT_ERROR_INVALID_KERNEL_NAME;
576576
}

source/adapters/opencl/program.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -451,10 +451,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramGetFunctionPointer(
451451
CLContext, cl_ext::ExtFuncPtrCache->clGetDeviceFunctionPointerCache,
452452
cl_ext::GetDeviceFunctionPointerName, &FuncT));
453453

454-
if (!FuncT) {
455-
return UR_RESULT_ERROR_INVALID_FUNCTION_NAME;
456-
}
457-
458454
// Check if the kernel name exists to prevent the OpenCL runtime from throwing
459455
// an exception with the cpu runtime.
460456
// TODO: Use fallback search method if the clGetDeviceFunctionPointerINTEL
@@ -488,7 +484,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramGetFunctionPointer(
488484
// that the function name is invalid.
489485
if (CLResult == CL_INVALID_ARG_VALUE) {
490486
*ppFunctionPointer = 0;
491-
return UR_RESULT_ERROR_INVALID_FUNCTION_NAME;
487+
return UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE;
492488
}
493489

494490
CL_RETURN_ON_FAILURE(CLResult);

0 commit comments

Comments
 (0)