Skip to content

Commit c43ddf8

Browse files
author
omarahmed1111
committed
[SPEC] Add more clarification to invalid size return code
1 parent 8dba1fd commit c43ddf8

File tree

7 files changed

+22
-8
lines changed

7 files changed

+22
-8
lines changed

include/ur_api.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2645,6 +2645,7 @@ typedef struct ur_buffer_alloc_location_properties_t {
26452645
/// - ::UR_RESULT_ERROR_INVALID_CONTEXT
26462646
/// - ::UR_RESULT_ERROR_INVALID_VALUE
26472647
/// - ::UR_RESULT_ERROR_INVALID_BUFFER_SIZE
2648+
/// + `size == 0`
26482649
/// - ::UR_RESULT_ERROR_INVALID_HOST_PTR
26492650
/// + `pProperties == NULL && (flags & (UR_MEM_FLAG_USE_HOST_POINTER | UR_MEM_FLAG_ALLOC_COPY_HOST_POINTER)) != 0`
26502651
/// + `pProperties != NULL && pProperties->pHost == NULL && (flags & (UR_MEM_FLAG_USE_HOST_POINTER | UR_MEM_FLAG_ALLOC_COPY_HOST_POINTER)) != 0`
@@ -2753,6 +2754,8 @@ typedef enum ur_buffer_create_type_t {
27532754
/// - ::UR_RESULT_ERROR_OBJECT_ALLOCATION_FAILURE
27542755
/// - ::UR_RESULT_ERROR_INVALID_VALUE
27552756
/// - ::UR_RESULT_ERROR_INVALID_BUFFER_SIZE
2757+
/// + `pRegion && pRegion->size == 0`
2758+
/// + hBuffer allocation size < (pRegion->origin + pRegion->size)
27562759
/// - ::UR_RESULT_ERROR_INVALID_HOST_PTR
27572760
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
27582761
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES

scripts/core/memory.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,8 @@ params:
319319
returns:
320320
- $X_RESULT_ERROR_INVALID_CONTEXT
321321
- $X_RESULT_ERROR_INVALID_VALUE
322-
- $X_RESULT_ERROR_INVALID_BUFFER_SIZE
322+
- $X_RESULT_ERROR_INVALID_BUFFER_SIZE:
323+
- "`size == 0`"
323324
- $X_RESULT_ERROR_INVALID_HOST_PTR:
324325
- "`pProperties == NULL && (flags & (UR_MEM_FLAG_USE_HOST_POINTER | UR_MEM_FLAG_ALLOC_COPY_HOST_POINTER)) != 0`"
325326
- "`pProperties != NULL && pProperties->pHost == NULL && (flags & (UR_MEM_FLAG_USE_HOST_POINTER | UR_MEM_FLAG_ALLOC_COPY_HOST_POINTER)) != 0`"
@@ -411,7 +412,9 @@ returns:
411412
- $X_RESULT_ERROR_INVALID_MEM_OBJECT
412413
- $X_RESULT_ERROR_OBJECT_ALLOCATION_FAILURE
413414
- $X_RESULT_ERROR_INVALID_VALUE
414-
- $X_RESULT_ERROR_INVALID_BUFFER_SIZE
415+
- $X_RESULT_ERROR_INVALID_BUFFER_SIZE:
416+
- "`pRegion && pRegion->size == 0`"
417+
- "hBuffer allocation size < (pRegion->origin + pRegion->size)"
415418
- $X_RESULT_ERROR_INVALID_HOST_PTR
416419
- $X_RESULT_ERROR_OUT_OF_HOST_MEMORY
417420
- $X_RESULT_ERROR_OUT_OF_RESOURCES

source/loader/layers/validation/ur_valddi.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,6 +1129,10 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreate(
11291129
return UR_RESULT_ERROR_INVALID_ENUMERATION;
11301130
}
11311131

1132+
if (size == 0) {
1133+
return UR_RESULT_ERROR_INVALID_BUFFER_SIZE;
1134+
}
1135+
11321136
if (pProperties == NULL &&
11331137
(flags & (UR_MEM_FLAG_USE_HOST_POINTER |
11341138
UR_MEM_FLAG_ALLOC_COPY_HOST_POINTER)) != 0) {
@@ -1253,6 +1257,10 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferPartition(
12531257
if (UR_BUFFER_CREATE_TYPE_REGION < bufferCreateType) {
12541258
return UR_RESULT_ERROR_INVALID_ENUMERATION;
12551259
}
1260+
1261+
if (pRegion && pRegion->size == 0) {
1262+
return UR_RESULT_ERROR_INVALID_BUFFER_SIZE;
1263+
}
12561264
}
12571265

12581266
if (context.enableLifetimeValidation &&

source/loader/ur_libapi.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,6 +1543,7 @@ ur_result_t UR_APICALL urMemImageCreate(
15431543
/// - ::UR_RESULT_ERROR_INVALID_CONTEXT
15441544
/// - ::UR_RESULT_ERROR_INVALID_VALUE
15451545
/// - ::UR_RESULT_ERROR_INVALID_BUFFER_SIZE
1546+
/// + `size == 0`
15461547
/// - ::UR_RESULT_ERROR_INVALID_HOST_PTR
15471548
/// + `pProperties == NULL && (flags & (UR_MEM_FLAG_USE_HOST_POINTER | UR_MEM_FLAG_ALLOC_COPY_HOST_POINTER)) != 0`
15481549
/// + `pProperties != NULL && pProperties->pHost == NULL && (flags & (UR_MEM_FLAG_USE_HOST_POINTER | UR_MEM_FLAG_ALLOC_COPY_HOST_POINTER)) != 0`
@@ -1657,6 +1658,8 @@ ur_result_t UR_APICALL urMemRelease(
16571658
/// - ::UR_RESULT_ERROR_OBJECT_ALLOCATION_FAILURE
16581659
/// - ::UR_RESULT_ERROR_INVALID_VALUE
16591660
/// - ::UR_RESULT_ERROR_INVALID_BUFFER_SIZE
1661+
/// + `pRegion && pRegion->size == 0`
1662+
/// + hBuffer allocation size < (pRegion->origin + pRegion->size)
16601663
/// - ::UR_RESULT_ERROR_INVALID_HOST_PTR
16611664
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
16621665
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES

source/ur_api.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,6 +1331,7 @@ ur_result_t UR_APICALL urMemImageCreate(
13311331
/// - ::UR_RESULT_ERROR_INVALID_CONTEXT
13321332
/// - ::UR_RESULT_ERROR_INVALID_VALUE
13331333
/// - ::UR_RESULT_ERROR_INVALID_BUFFER_SIZE
1334+
/// + `size == 0`
13341335
/// - ::UR_RESULT_ERROR_INVALID_HOST_PTR
13351336
/// + `pProperties == NULL && (flags & (UR_MEM_FLAG_USE_HOST_POINTER | UR_MEM_FLAG_ALLOC_COPY_HOST_POINTER)) != 0`
13361337
/// + `pProperties != NULL && pProperties->pHost == NULL && (flags & (UR_MEM_FLAG_USE_HOST_POINTER | UR_MEM_FLAG_ALLOC_COPY_HOST_POINTER)) != 0`
@@ -1427,6 +1428,8 @@ ur_result_t UR_APICALL urMemRelease(
14271428
/// - ::UR_RESULT_ERROR_OBJECT_ALLOCATION_FAILURE
14281429
/// - ::UR_RESULT_ERROR_INVALID_VALUE
14291430
/// - ::UR_RESULT_ERROR_INVALID_BUFFER_SIZE
1431+
/// + `pRegion && pRegion->size == 0`
1432+
/// + hBuffer allocation size < (pRegion->origin + pRegion->size)
14301433
/// - ::UR_RESULT_ERROR_INVALID_HOST_PTR
14311434
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
14321435
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES

test/conformance/memory/memory_adapter_level_zero.match

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
urMemBufferCreateWithFlagsTest.InvalidBufferSizeZero/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_UR_MEM_FLAG_READ_WRITE
2-
urMemBufferCreateWithFlagsTest.InvalidBufferSizeZero/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_UR_MEM_FLAG_WRITE_ONLY
3-
urMemBufferCreateWithFlagsTest.InvalidBufferSizeZero/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_UR_MEM_FLAG_READ_ONLY
4-
urMemBufferCreateWithFlagsTest.InvalidBufferSizeZero/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_UR_MEM_FLAG_ALLOC_HOST_POINTER
5-
urMemBufferPartitionTest.InvalidBufferSize/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_
61
urMemBufferPartitionTest.InvalidValueCreateType/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_
72
urMemBufferPartitionTest.InvalidValueBufferCreateInfoOutOfBounds/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_
83
urMemGetInfoImageTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_MEM_INFO_SIZE

test/conformance/memory/memory_adapter_native_cpu.match

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
urMemBufferPartitionTest.InvalidBufferSize/SYCL_NATIVE_CPU___SYCL_Native_CPU_
21
urMemBufferPartitionTest.InvalidValueCreateType/SYCL_NATIVE_CPU___SYCL_Native_CPU_
32
urMemBufferPartitionTest.InvalidValueBufferCreateInfoOutOfBounds/SYCL_NATIVE_CPU___SYCL_Native_CPU_
43
urMemGetInfoTest.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU___UR_MEM_INFO_SIZE

0 commit comments

Comments
 (0)