Skip to content

Commit dce122c

Browse files
committed
Add numDevices == 0 condition
1 parent fcc0cef commit dce122c

File tree

9 files changed

+12
-13
lines changed

9 files changed

+12
-13
lines changed

include/ur_api.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4234,6 +4234,7 @@ urProgramCreateWithIL(
42344234
/// + `NULL != pProperties && pProperties->count > 0 && NULL == pProperties->pMetadatas`
42354235
/// - ::UR_RESULT_ERROR_INVALID_SIZE
42364236
/// + `NULL != pProperties && NULL != pProperties->pMetadatas && pProperties->count == 0`
4237+
/// + `numDevices == 0`
42374238
/// - ::UR_RESULT_ERROR_INVALID_NATIVE_BINARY
42384239
/// + If any binary in `ppBinaries` isn't a valid binary for the corresponding device in `phDevices.`
42394240
UR_APIEXPORT ur_result_t UR_APICALL

scripts/core/program.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ returns:
158158
- "`NULL != pProperties && pProperties->count > 0 && NULL == pProperties->pMetadatas`"
159159
- $X_RESULT_ERROR_INVALID_SIZE:
160160
- "`NULL != pProperties && NULL != pProperties->pMetadatas && pProperties->count == 0`"
161+
- "`numDevices == 0`"
161162
- $X_RESULT_ERROR_INVALID_NATIVE_BINARY:
162163
- "If any binary in `ppBinaries` isn't a valid binary for the corresponding device in `phDevices.`"
163164
--- #--------------------------------------------------------------------------

source/adapters/cuda/program.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -489,9 +489,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramCreateWithBinary(
489489
if (numDevices > 1)
490490
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
491491

492-
if (numDevices == 0)
493-
return UR_RESULT_ERROR_INVALID_DEVICE;
494-
495492
UR_CHECK_ERROR(createProgram(hContext, phDevices[0], pLengths[0],
496493
ppBinaries[0], pProperties, phProgram));
497494
(*phProgram)->BinaryType = UR_PROGRAM_BINARY_TYPE_COMPILED_OBJECT;

source/adapters/hip/program.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -487,9 +487,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramCreateWithBinary(
487487
if (numDevices > 1)
488488
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
489489

490-
if (numDevices == 0)
491-
return UR_RESULT_ERROR_INVALID_DEVICE;
492-
493490
auto hDevice = phDevices[0];
494491
auto pBinary = ppBinaries[0];
495492
auto size = pLengths[0];

source/adapters/level_zero/program.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ struct ur_program_handle_t_ : _ur_object {
106106
ur_program_handle_t_(state, ur_context_handle_t Context,
107107
ze_module_handle_t InteropZeModule)
108108
: Context{Context}, NativeProperties{nullptr}, OwnZeModule{true},
109-
AssociatedDevices({Context->getDevices()[0]}),
110-
InteropZeModule{InteropZeModule} {}
109+
AssociatedDevices({Context->getDevices()[0]}), InteropZeModule{
110+
InteropZeModule} {}
111111

112112
// Construct a program in Exe state (interop).
113113
// TODO: Currently it is not possible to get the device associated with the
@@ -117,8 +117,8 @@ struct ur_program_handle_t_ : _ur_object {
117117
ur_program_handle_t_(state, ur_context_handle_t Context,
118118
ze_module_handle_t InteropZeModule, bool OwnZeModule)
119119
: Context{Context}, NativeProperties{nullptr}, OwnZeModule{OwnZeModule},
120-
AssociatedDevices({Context->getDevices()[0]}),
121-
InteropZeModule{InteropZeModule} {
120+
AssociatedDevices({Context->getDevices()[0]}), InteropZeModule{
121+
InteropZeModule} {
122122
// TODO: Currently it is not possible to understand the device associated
123123
// with provided ZeModule. So we can't set the state on that device to Exe.
124124
}

source/adapters/native_cpu/program.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramCreateWithBinary(
6161
if (numDevices > 1)
6262
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
6363

64-
if (numDevices == 0)
65-
return UR_RESULT_ERROR_INVALID_DEVICE;
66-
6764
auto hDevice = phDevices[0];
6865
auto pBinary = ppBinaries[0];
6966
std::ignore = pLengths;

source/loader/layers/validation/ur_valddi.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2773,6 +2773,10 @@ __urdlllocal ur_result_t UR_APICALL urProgramCreateWithBinary(
27732773
pProperties->count == 0) {
27742774
return UR_RESULT_ERROR_INVALID_SIZE;
27752775
}
2776+
2777+
if (numDevices == 0) {
2778+
return UR_RESULT_ERROR_INVALID_SIZE;
2779+
}
27762780
}
27772781

27782782
if (getContext()->enableLifetimeValidation &&

source/loader/ur_libapi.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3030,6 +3030,7 @@ ur_result_t UR_APICALL urProgramCreateWithIL(
30303030
/// + `NULL != pProperties && pProperties->count > 0 && NULL == pProperties->pMetadatas`
30313031
/// - ::UR_RESULT_ERROR_INVALID_SIZE
30323032
/// + `NULL != pProperties && NULL != pProperties->pMetadatas && pProperties->count == 0`
3033+
/// + `numDevices == 0`
30333034
/// - ::UR_RESULT_ERROR_INVALID_NATIVE_BINARY
30343035
/// + If any binary in `ppBinaries` isn't a valid binary for the corresponding device in `phDevices.`
30353036
ur_result_t UR_APICALL urProgramCreateWithBinary(

source/ur_api.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2597,6 +2597,7 @@ ur_result_t UR_APICALL urProgramCreateWithIL(
25972597
/// + `NULL != pProperties && pProperties->count > 0 && NULL == pProperties->pMetadatas`
25982598
/// - ::UR_RESULT_ERROR_INVALID_SIZE
25992599
/// + `NULL != pProperties && NULL != pProperties->pMetadatas && pProperties->count == 0`
2600+
/// + `numDevices == 0`
26002601
/// - ::UR_RESULT_ERROR_INVALID_NATIVE_BINARY
26012602
/// + If any binary in `ppBinaries` isn't a valid binary for the corresponding device in `phDevices.`
26022603
ur_result_t UR_APICALL urProgramCreateWithBinary(

0 commit comments

Comments
 (0)