Skip to content

Commit 08bfe78

Browse files
authored
Merge pull request #543 from veselypeta/petr/fix-sampler-spec
[UR] clarify sampler spec and add CTS
2 parents 4a9e53b + dc037d2 commit 08bfe78

File tree

17 files changed

+408
-27
lines changed

17 files changed

+408
-27
lines changed

include/ur_api.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2289,20 +2289,23 @@ urSamplerRelease(
22892289
/// + `NULL == hSampler`
22902290
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
22912291
/// + `::UR_SAMPLER_INFO_FILTER_MODE < propName`
2292-
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
2293-
/// + `NULL == pPropValue`
2294-
/// + `NULL == pPropSizeRet`
22952292
/// - ::UR_RESULT_ERROR_INVALID_SAMPLER
22962293
/// - ::UR_RESULT_ERROR_INVALID_VALUE
22972294
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
22982295
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
2296+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
2297+
/// + `propSize == 0 && pPropValue != NULL`
2298+
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
2299+
/// + `propSize != 0 && pPropValue == NULL`
2300+
/// + `pPropValue == NULL && pPropSizeRet == NULL`
22992301
UR_APIEXPORT ur_result_t UR_APICALL
23002302
urSamplerGetInfo(
23012303
ur_sampler_handle_t hSampler, ///< [in] handle of the sampler object
23022304
ur_sampler_info_t propName, ///< [in] name of the sampler property to query
23032305
size_t propSize, ///< [in] size in bytes of the sampler property value provided
2304-
void *pPropValue, ///< [out][typename(propName, propSize)] value of the sampler property
2305-
size_t *pPropSizeRet ///< [out] size in bytes returned in sampler property value
2306+
void *pPropValue, ///< [out][typename(propName, propSize)][optional] value of the sampler
2307+
///< property
2308+
size_t *pPropSizeRet ///< [out][optional] size in bytes returned in sampler property value
23062309
);
23072310

23082311
///////////////////////////////////////////////////////////////////////////////

scripts/core/sampler.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,20 @@ params:
155155
desc: "[in] size in bytes of the sampler property value provided"
156156
- type: "void*"
157157
name: pPropValue
158-
desc: "[out][typename(propName, propSize)] value of the sampler property"
158+
desc: "[out][typename(propName, propSize)][optional] value of the sampler property"
159159
- type: "size_t*"
160160
name: pPropSizeRet
161-
desc: "[out] size in bytes returned in sampler property value"
161+
desc: "[out][optional] size in bytes returned in sampler property value"
162162
returns:
163163
- $X_RESULT_ERROR_INVALID_SAMPLER
164164
- $X_RESULT_ERROR_INVALID_VALUE
165165
- $X_RESULT_ERROR_OUT_OF_HOST_MEMORY
166166
- $X_RESULT_ERROR_OUT_OF_RESOURCES
167+
- $X_RESULT_ERROR_INVALID_SIZE:
168+
- "`propSize == 0 && pPropValue != NULL`"
169+
- $X_RESULT_ERROR_INVALID_NULL_POINTER:
170+
- "`propSize != 0 && pPropValue == NULL`"
171+
- "`pPropValue == NULL && pPropSizeRet == NULL`"
167172
--- #--------------------------------------------------------------------------
168173
type: function
169174
desc: "Return sampler native sampler handle."

source/adapters/null/ur_nullddi.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,9 +1019,10 @@ __urdlllocal ur_result_t UR_APICALL urSamplerGetInfo(
10191019
size_t
10201020
propSize, ///< [in] size in bytes of the sampler property value provided
10211021
void *
1022-
pPropValue, ///< [out][typename(propName, propSize)] value of the sampler property
1022+
pPropValue, ///< [out][typename(propName, propSize)][optional] value of the sampler
1023+
///< property
10231024
size_t *
1024-
pPropSizeRet ///< [out] size in bytes returned in sampler property value
1025+
pPropSizeRet ///< [out][optional] size in bytes returned in sampler property value
10251026
) try {
10261027
ur_result_t result = UR_RESULT_SUCCESS;
10271028

source/loader/layers/tracing/ur_trcddi.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,9 +1152,10 @@ __urdlllocal ur_result_t UR_APICALL urSamplerGetInfo(
11521152
size_t
11531153
propSize, ///< [in] size in bytes of the sampler property value provided
11541154
void *
1155-
pPropValue, ///< [out][typename(propName, propSize)] value of the sampler property
1155+
pPropValue, ///< [out][typename(propName, propSize)][optional] value of the sampler
1156+
///< property
11561157
size_t *
1157-
pPropSizeRet ///< [out] size in bytes returned in sampler property value
1158+
pPropSizeRet ///< [out][optional] size in bytes returned in sampler property value
11581159
) {
11591160
auto pfnGetInfo = context.urDdiTable.Sampler.pfnGetInfo;
11601161

source/loader/layers/validation/ur_valddi.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,9 +1335,10 @@ __urdlllocal ur_result_t UR_APICALL urSamplerGetInfo(
13351335
size_t
13361336
propSize, ///< [in] size in bytes of the sampler property value provided
13371337
void *
1338-
pPropValue, ///< [out][typename(propName, propSize)] value of the sampler property
1338+
pPropValue, ///< [out][typename(propName, propSize)][optional] value of the sampler
1339+
///< property
13391340
size_t *
1340-
pPropSizeRet ///< [out] size in bytes returned in sampler property value
1341+
pPropSizeRet ///< [out][optional] size in bytes returned in sampler property value
13411342
) {
13421343
auto pfnGetInfo = context.urDdiTable.Sampler.pfnGetInfo;
13431344

@@ -1350,17 +1351,21 @@ __urdlllocal ur_result_t UR_APICALL urSamplerGetInfo(
13501351
return UR_RESULT_ERROR_INVALID_NULL_HANDLE;
13511352
}
13521353

1353-
if (NULL == pPropValue) {
1354+
if (propSize != 0 && pPropValue == NULL) {
13541355
return UR_RESULT_ERROR_INVALID_NULL_POINTER;
13551356
}
13561357

1357-
if (NULL == pPropSizeRet) {
1358+
if (pPropValue == NULL && pPropSizeRet == NULL) {
13581359
return UR_RESULT_ERROR_INVALID_NULL_POINTER;
13591360
}
13601361

13611362
if (UR_SAMPLER_INFO_FILTER_MODE < propName) {
13621363
return UR_RESULT_ERROR_INVALID_ENUMERATION;
13631364
}
1365+
1366+
if (propSize == 0 && pPropValue != NULL) {
1367+
return UR_RESULT_ERROR_INVALID_SIZE;
1368+
}
13641369
}
13651370

13661371
ur_result_t result =

source/loader/ur_ldrddi.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,9 +1366,10 @@ __urdlllocal ur_result_t UR_APICALL urSamplerGetInfo(
13661366
size_t
13671367
propSize, ///< [in] size in bytes of the sampler property value provided
13681368
void *
1369-
pPropValue, ///< [out][typename(propName, propSize)] value of the sampler property
1369+
pPropValue, ///< [out][typename(propName, propSize)][optional] value of the sampler
1370+
///< property
13701371
size_t *
1371-
pPropSizeRet ///< [out] size in bytes returned in sampler property value
1372+
pPropSizeRet ///< [out][optional] size in bytes returned in sampler property value
13721373
) {
13731374
ur_result_t result = UR_RESULT_SUCCESS;
13741375

source/loader/ur_libapi.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,22 +1538,25 @@ ur_result_t UR_APICALL urSamplerRelease(
15381538
/// + `NULL == hSampler`
15391539
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
15401540
/// + `::UR_SAMPLER_INFO_FILTER_MODE < propName`
1541-
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
1542-
/// + `NULL == pPropValue`
1543-
/// + `NULL == pPropSizeRet`
15441541
/// - ::UR_RESULT_ERROR_INVALID_SAMPLER
15451542
/// - ::UR_RESULT_ERROR_INVALID_VALUE
15461543
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
15471544
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
1545+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
1546+
/// + `propSize == 0 && pPropValue != NULL`
1547+
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
1548+
/// + `propSize != 0 && pPropValue == NULL`
1549+
/// + `pPropValue == NULL && pPropSizeRet == NULL`
15481550
ur_result_t UR_APICALL urSamplerGetInfo(
15491551
ur_sampler_handle_t hSampler, ///< [in] handle of the sampler object
15501552
ur_sampler_info_t propName, ///< [in] name of the sampler property to query
15511553
size_t
15521554
propSize, ///< [in] size in bytes of the sampler property value provided
15531555
void *
1554-
pPropValue, ///< [out][typename(propName, propSize)] value of the sampler property
1556+
pPropValue, ///< [out][typename(propName, propSize)][optional] value of the sampler
1557+
///< property
15551558
size_t *
1556-
pPropSizeRet ///< [out] size in bytes returned in sampler property value
1559+
pPropSizeRet ///< [out][optional] size in bytes returned in sampler property value
15571560
) try {
15581561
auto pfnGetInfo = ur_lib::context->urDdiTable.Sampler.pfnGetInfo;
15591562
if (nullptr == pfnGetInfo) {

source/ur_api.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,22 +1277,25 @@ ur_result_t UR_APICALL urSamplerRelease(
12771277
/// + `NULL == hSampler`
12781278
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
12791279
/// + `::UR_SAMPLER_INFO_FILTER_MODE < propName`
1280-
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
1281-
/// + `NULL == pPropValue`
1282-
/// + `NULL == pPropSizeRet`
12831280
/// - ::UR_RESULT_ERROR_INVALID_SAMPLER
12841281
/// - ::UR_RESULT_ERROR_INVALID_VALUE
12851282
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
12861283
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
1284+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
1285+
/// + `propSize == 0 && pPropValue != NULL`
1286+
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
1287+
/// + `propSize != 0 && pPropValue == NULL`
1288+
/// + `pPropValue == NULL && pPropSizeRet == NULL`
12871289
ur_result_t UR_APICALL urSamplerGetInfo(
12881290
ur_sampler_handle_t hSampler, ///< [in] handle of the sampler object
12891291
ur_sampler_info_t propName, ///< [in] name of the sampler property to query
12901292
size_t
12911293
propSize, ///< [in] size in bytes of the sampler property value provided
12921294
void *
1293-
pPropValue, ///< [out][typename(propName, propSize)] value of the sampler property
1295+
pPropValue, ///< [out][typename(propName, propSize)][optional] value of the sampler
1296+
///< property
12941297
size_t *
1295-
pPropSizeRet ///< [out] size in bytes returned in sampler property value
1298+
pPropSizeRet ///< [out][optional] size in bytes returned in sampler property value
12961299
) {
12971300
ur_result_t result = UR_RESULT_SUCCESS;
12981301
return result;

test/conformance/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ add_subdirectory(memory)
5050
add_subdirectory(usm)
5151
add_subdirectory(event)
5252
add_subdirectory(queue)
53+
add_subdirectory(sampler)
5354
add_subdirectory(enqueue)
5455

5556
if(DEFINED UR_DPCXX)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copyright (C) 2023 Intel Corporation
2+
# SPDX-License-Identifier: MIT
3+
4+
add_conformance_test_with_devices_environment(sampler
5+
urSamplerCreate.cpp
6+
urSamplerCreateWithNativeHandle.cpp
7+
urSamplerGetInfo.cpp
8+
urSamplerGetNativeHandle.cpp
9+
urSamplerRelease.cpp
10+
urSamplerRetain.cpp
11+
)

0 commit comments

Comments
 (0)