Skip to content

Commit 0cbacd8

Browse files
authored
Merge pull request #1212 from aarongreig/aaron/specMotivatedRefactors
Batch adapter changes: spec motivated refactors
2 parents 022df8a + 2f121cd commit 0cbacd8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+205
-167
lines changed

include/ur_api.h

Lines changed: 18 additions & 6 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
@@ -1597,6 +1598,9 @@ typedef enum ur_device_info_t {
15971598
///< this composite device.
15981599
UR_DEVICE_INFO_COMPOSITE_DEVICE = 117, ///< [::ur_device_handle_t] The composite device containing this component
15991600
///< device.
1601+
UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT = 118, ///< [::ur_bool_t] return true if the device supports the
1602+
///< `EnqueueDeviceGlobalVariableWrite` and
1603+
///< `EnqueueDeviceGlobalVariableRead` entry points.
16001604
UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP = 0x1000, ///< [::ur_bool_t] Returns true if the device supports the use of
16011605
///< command-buffers.
16021606
UR_DEVICE_INFO_COMMAND_BUFFER_UPDATE_SUPPORT_EXP = 0x1001, ///< [::ur_bool_t] Returns true if the device supports updating the kernel
@@ -2556,8 +2560,8 @@ typedef struct ur_image_desc_t {
25562560
size_t arraySize; ///< [in] image array size
25572561
size_t rowPitch; ///< [in] image row pitch
25582562
size_t slicePitch; ///< [in] image slice pitch
2559-
uint32_t numMipLevel; ///< [in] number of MIP levels
2560-
uint32_t numSamples; ///< [in] number of samples
2563+
uint32_t numMipLevel; ///< [in] number of MIP levels, must be `0`
2564+
uint32_t numSamples; ///< [in] number of samples, must be `0`
25612565

25622566
} ur_image_desc_t;
25632567

@@ -2601,6 +2605,10 @@ typedef struct ur_image_desc_t {
26012605
/// - ::UR_RESULT_ERROR_INVALID_VALUE
26022606
/// - ::UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR
26032607
/// + `pImageDesc && UR_MEM_TYPE_IMAGE1D_ARRAY < pImageDesc->type`
2608+
/// + `pImageDesc && pImageDesc->numMipLevel != 0`
2609+
/// + `pImageDesc && pImageDesc->numSamples != 0`
2610+
/// + `pImageDesc && pImageDesc->rowPitch != 0 && pHost == nullptr`
2611+
/// + `pImageDesc && pImageDesc->slicePitch != 0 && pHost == nullptr`
26042612
/// - ::UR_RESULT_ERROR_INVALID_IMAGE_SIZE
26052613
/// - ::UR_RESULT_ERROR_INVALID_OPERATION
26062614
/// - ::UR_RESULT_ERROR_INVALID_HOST_PTR
@@ -4355,8 +4363,8 @@ urProgramRelease(
43554363
/// @details
43564364
/// - Retrieves a pointer to the functions with the given name and defined
43574365
/// in the given program.
4358-
/// - ::UR_RESULT_ERROR_INVALID_FUNCTION_NAME is returned if the function
4359-
/// can not be obtained.
4366+
/// - ::UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE is returned if the
4367+
/// function can not be obtained.
43604368
/// - The application may call this function from simultaneous threads for
43614369
/// the same device.
43624370
/// - The implementation of this function should be thread-safe.
@@ -4376,6 +4384,10 @@ urProgramRelease(
43764384
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
43774385
/// + `NULL == pFunctionName`
43784386
/// + `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.
43794391
UR_APIEXPORT ur_result_t UR_APICALL
43804392
urProgramGetFunctionPointer(
43814393
ur_device_handle_t hDevice, ///< [in] handle of the device to retrieve pointer for.
@@ -4777,7 +4789,7 @@ urKernelSetArgLocal(
47774789
/// @brief Get Kernel object information
47784790
typedef enum ur_kernel_info_t {
47794791
UR_KERNEL_INFO_FUNCTION_NAME = 0, ///< [char[]] Return null-terminated kernel function name.
4780-
UR_KERNEL_INFO_NUM_ARGS = 1, ///< [size_t] Return Kernel number of arguments.
4792+
UR_KERNEL_INFO_NUM_ARGS = 1, ///< [uint32_t] Return Kernel number of arguments.
47814793
UR_KERNEL_INFO_REFERENCE_COUNT = 2, ///< [uint32_t] Reference count of the kernel object.
47824794
///< The reference count returned should be considered immediately stale.
47834795
///< It is unsuitable for general use in applications. This feature is

include/ur_print.hpp

Lines changed: 20 additions & 5 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";
@@ -2524,6 +2524,9 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_device_info_t value) {
25242524
case UR_DEVICE_INFO_COMPOSITE_DEVICE:
25252525
os << "UR_DEVICE_INFO_COMPOSITE_DEVICE";
25262526
break;
2527+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT:
2528+
os << "UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT";
2529+
break;
25272530
case UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP:
25282531
os << "UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP";
25292532
break;
@@ -4008,6 +4011,18 @@ inline ur_result_t printTagged(std::ostream &os, const void *ptr, ur_device_info
40084011

40094012
os << ")";
40104013
} break;
4014+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT: {
4015+
const ur_bool_t *tptr = (const ur_bool_t *)ptr;
4016+
if (sizeof(ur_bool_t) > size) {
4017+
os << "invalid size (is: " << size << ", expected: >=" << sizeof(ur_bool_t) << ")";
4018+
return UR_RESULT_ERROR_INVALID_SIZE;
4019+
}
4020+
os << (const void *)(tptr) << " (";
4021+
4022+
os << *tptr;
4023+
4024+
os << ")";
4025+
} break;
40114026
case UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP: {
40124027
const ur_bool_t *tptr = (const ur_bool_t *)ptr;
40134028
if (sizeof(ur_bool_t) > size) {
@@ -7855,9 +7870,9 @@ inline ur_result_t printTagged(std::ostream &os, const void *ptr, ur_kernel_info
78557870
printPtr(os, tptr);
78567871
} break;
78577872
case UR_KERNEL_INFO_NUM_ARGS: {
7858-
const size_t *tptr = (const size_t *)ptr;
7859-
if (sizeof(size_t) > size) {
7860-
os << "invalid size (is: " << size << ", expected: >=" << sizeof(size_t) << ")";
7873+
const uint32_t *tptr = (const uint32_t *)ptr;
7874+
if (sizeof(uint32_t) > size) {
7875+
os << "invalid size (is: " << size << ", expected: >=" << sizeof(uint32_t) << ")";
78617876
return UR_RESULT_ERROR_INVALID_SIZE;
78627877
}
78637878
os << (const void *)(tptr) << " (";

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/device.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,8 @@ etors:
439439
desc: "[$x_device_handle_t[]] The set of component devices contained by this composite device."
440440
- name: COMPOSITE_DEVICE
441441
desc: "[$x_device_handle_t] The composite device containing this component device."
442+
- name: GLOBAL_VARIABLE_SUPPORT
443+
desc: "[$x_bool_t] return true if the device supports the `EnqueueDeviceGlobalVariableWrite` and `EnqueueDeviceGlobalVariableRead` entry points."
442444
--- #--------------------------------------------------------------------------
443445
type: function
444446
desc: "Retrieves various information about device"

scripts/core/kernel.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ etors:
109109
- name: FUNCTION_NAME
110110
desc: "[char[]] Return null-terminated kernel function name."
111111
- name: NUM_ARGS
112-
desc: "[size_t] Return Kernel number of arguments."
112+
desc: "[uint32_t] Return Kernel number of arguments."
113113
- name: REFERENCE_COUNT
114114
desc: |
115115
[uint32_t] Reference count of the kernel object.

scripts/core/memory.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,10 @@ members:
197197
desc: "[in] image slice pitch"
198198
- type: uint32_t
199199
name: numMipLevel
200-
desc: "[in] number of MIP levels"
200+
desc: "[in] number of MIP levels, must be `0`"
201201
- type: uint32_t
202202
name: numSamples
203-
desc: "[in] number of samples"
203+
desc: "[in] number of samples, must be `0`"
204204
--- #--------------------------------------------------------------------------
205205
type: function
206206
desc: "Create an image object"
@@ -242,6 +242,10 @@ returns:
242242
- $X_RESULT_ERROR_INVALID_VALUE
243243
- $X_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR:
244244
- "`pImageDesc && UR_MEM_TYPE_IMAGE1D_ARRAY < pImageDesc->type`"
245+
- "`pImageDesc && pImageDesc->numMipLevel != 0`"
246+
- "`pImageDesc && pImageDesc->numSamples != 0`"
247+
- "`pImageDesc && pImageDesc->rowPitch != 0 && pHost == nullptr`"
248+
- "`pImageDesc && pImageDesc->slicePitch != 0 && pHost == nullptr`"
245249
- $X_RESULT_ERROR_INVALID_IMAGE_SIZE
246250
- $X_RESULT_ERROR_INVALID_OPERATION
247251
- $X_RESULT_ERROR_INVALID_HOST_PTR:

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/device.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,6 +1075,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
10751075
return ReturnValue(true);
10761076
case UR_DEVICE_INFO_ESIMD_SUPPORT:
10771077
return ReturnValue(false);
1078+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT:
1079+
return ReturnValue(true);
10781080
case UR_DEVICE_INFO_COMPONENT_DEVICES:
10791081
case UR_DEVICE_INFO_COMPOSITE_DEVICE:
10801082
case UR_DEVICE_INFO_MAX_READ_WRITE_IMAGE_ARGS:

source/adapters/cuda/kernel.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,9 @@ struct ur_kernel_handle_t_ {
204204
/// Note this only returns the current known number of arguments, not the
205205
/// real one required by the kernel, since this cannot be queried from
206206
/// the CUDA Driver API
207-
size_t getNumArgs() const noexcept { return Args.Indices.size() - 1; }
207+
uint32_t getNumArgs() const noexcept {
208+
return static_cast<uint32_t>(Args.Indices.size() - 1);
209+
}
208210

209211
void setKernelArg(int Index, size_t Size, const void *Arg) {
210212
Args.addArg(Index, Size, Arg);

source/adapters/cuda/memory.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -208,16 +208,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemImageCreate(
208208
UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR);
209209
UR_ASSERT(pImageDesc->type <= UR_MEM_TYPE_IMAGE1D_ARRAY,
210210
UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR);
211-
UR_ASSERT(pImageDesc->numMipLevel == 0,
212-
UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR);
213-
UR_ASSERT(pImageDesc->numSamples == 0,
214-
UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR);
215-
if (!pHost) {
216-
UR_ASSERT(pImageDesc->rowPitch == 0,
217-
UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR);
218-
UR_ASSERT(pImageDesc->slicePitch == 0,
219-
UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR);
220-
}
221211

222212
// We only support RBGA channel order
223213
// TODO: check SYCL CTS and spec. May also have to support BGRA

0 commit comments

Comments
 (0)