Skip to content

Commit 8c524ef

Browse files
committed
Merge branch 'main' into detect-memory-leak
2 parents 9f7bf16 + 167ddf9 commit 8c524ef

File tree

149 files changed

+10338
-3921
lines changed

Some content is hidden

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

149 files changed

+10338
-3921
lines changed

examples/collector/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ $ mkdir build
1919
$ cd build
2020
$ cmake .. -DUR_ENABLE_TRACING=ON
2121
$ make
22-
$ UR_ADAPTERS_FORCE_LOAD=./lib/libur_adapter_null.so UR_ENABLE_LAYERS=UR_LAYER_TRACING XPTI_TRACE_ENABLE=1 XPTI_FRAMEWORK_DISPATCHER=./lib/libxptifw.so XPTI_SUBSCRIBERS=./lib/libcollector.so ./bin/hello_world
22+
$ UR_ADAPTERS_FORCE_LOAD=./lib/libur_adapter_mock.so UR_ENABLE_LAYERS=UR_LAYER_TRACING XPTI_TRACE_ENABLE=1 XPTI_FRAMEWORK_DISPATCHER=./lib/libxptifw.so XPTI_SUBSCRIBERS=./lib/libcollector.so ./bin/hello_world
2323
```
2424

2525
See [XPTI framework documentation](https://github.com/intel/llvm/blob/sycl/xptifw/doc/XPTI_Framework.md) for more information.

include/ur_api.h

Lines changed: 128 additions & 91 deletions
Large diffs are not rendered by default.

include/ur_ddi.h

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,14 +1531,14 @@ typedef ur_result_t(UR_APICALL *ur_pfnGetEnqueueExpProcAddrTable_t)(
15311531
typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesUnsampledImageHandleDestroyExp_t)(
15321532
ur_context_handle_t,
15331533
ur_device_handle_t,
1534-
ur_exp_image_handle_t);
1534+
ur_exp_image_native_handle_t);
15351535

15361536
///////////////////////////////////////////////////////////////////////////////
15371537
/// @brief Function-pointer for urBindlessImagesSampledImageHandleDestroyExp
15381538
typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesSampledImageHandleDestroyExp_t)(
15391539
ur_context_handle_t,
15401540
ur_device_handle_t,
1541-
ur_exp_image_handle_t);
1541+
ur_exp_image_native_handle_t);
15421542

15431543
///////////////////////////////////////////////////////////////////////////////
15441544
/// @brief Function-pointer for urBindlessImagesImageAllocateExp
@@ -1547,35 +1547,35 @@ typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesImageAllocateExp_t)(
15471547
ur_device_handle_t,
15481548
const ur_image_format_t *,
15491549
const ur_image_desc_t *,
1550-
ur_exp_image_mem_handle_t *);
1550+
ur_exp_image_mem_native_handle_t *);
15511551

15521552
///////////////////////////////////////////////////////////////////////////////
15531553
/// @brief Function-pointer for urBindlessImagesImageFreeExp
15541554
typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesImageFreeExp_t)(
15551555
ur_context_handle_t,
15561556
ur_device_handle_t,
1557-
ur_exp_image_mem_handle_t);
1557+
ur_exp_image_mem_native_handle_t);
15581558

15591559
///////////////////////////////////////////////////////////////////////////////
15601560
/// @brief Function-pointer for urBindlessImagesUnsampledImageCreateExp
15611561
typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesUnsampledImageCreateExp_t)(
15621562
ur_context_handle_t,
15631563
ur_device_handle_t,
1564-
ur_exp_image_mem_handle_t,
1564+
ur_exp_image_mem_native_handle_t,
15651565
const ur_image_format_t *,
15661566
const ur_image_desc_t *,
1567-
ur_exp_image_handle_t *);
1567+
ur_exp_image_native_handle_t *);
15681568

15691569
///////////////////////////////////////////////////////////////////////////////
15701570
/// @brief Function-pointer for urBindlessImagesSampledImageCreateExp
15711571
typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesSampledImageCreateExp_t)(
15721572
ur_context_handle_t,
15731573
ur_device_handle_t,
1574-
ur_exp_image_mem_handle_t,
1574+
ur_exp_image_mem_native_handle_t,
15751575
const ur_image_format_t *,
15761576
const ur_image_desc_t *,
15771577
ur_sampler_handle_t,
1578-
ur_exp_image_handle_t *);
1578+
ur_exp_image_native_handle_t *);
15791579

15801580
///////////////////////////////////////////////////////////////////////////////
15811581
/// @brief Function-pointer for urBindlessImagesImageCopyExp
@@ -1597,7 +1597,8 @@ typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesImageCopyExp_t)(
15971597
///////////////////////////////////////////////////////////////////////////////
15981598
/// @brief Function-pointer for urBindlessImagesImageGetInfoExp
15991599
typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesImageGetInfoExp_t)(
1600-
ur_exp_image_mem_handle_t,
1600+
ur_context_handle_t,
1601+
ur_exp_image_mem_native_handle_t,
16011602
ur_image_info_t,
16021603
void *,
16031604
size_t *);
@@ -1607,16 +1608,16 @@ typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesImageGetInfoExp_t)(
16071608
typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesMipmapGetLevelExp_t)(
16081609
ur_context_handle_t,
16091610
ur_device_handle_t,
1610-
ur_exp_image_mem_handle_t,
1611+
ur_exp_image_mem_native_handle_t,
16111612
uint32_t,
1612-
ur_exp_image_mem_handle_t *);
1613+
ur_exp_image_mem_native_handle_t *);
16131614

16141615
///////////////////////////////////////////////////////////////////////////////
16151616
/// @brief Function-pointer for urBindlessImagesMipmapFreeExp
16161617
typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesMipmapFreeExp_t)(
16171618
ur_context_handle_t,
16181619
ur_device_handle_t,
1619-
ur_exp_image_mem_handle_t);
1620+
ur_exp_image_mem_native_handle_t);
16201621

16211622
///////////////////////////////////////////////////////////////////////////////
16221623
/// @brief Function-pointer for urBindlessImagesImportExternalMemoryExp
@@ -1636,7 +1637,7 @@ typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesMapExternalArrayExp_t)(
16361637
const ur_image_format_t *,
16371638
const ur_image_desc_t *,
16381639
ur_exp_interop_mem_handle_t,
1639-
ur_exp_image_mem_handle_t *);
1640+
ur_exp_image_mem_native_handle_t *);
16401641

16411642
///////////////////////////////////////////////////////////////////////////////
16421643
/// @brief Function-pointer for urBindlessImagesReleaseInteropExp

include/ur_print.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,6 +1106,14 @@ UR_APIEXPORT ur_result_t UR_APICALL urPrintLoaderConfigEnableLayerParams(const s
11061106
/// - `buff_size < out_size`
11071107
UR_APIEXPORT ur_result_t UR_APICALL urPrintLoaderConfigSetCodeLocationCallbackParams(const struct ur_loader_config_set_code_location_callback_params_t *params, char *buffer, const size_t buff_size, size_t *out_size);
11081108

1109+
///////////////////////////////////////////////////////////////////////////////
1110+
/// @brief Print ur_loader_config_set_mocking_enabled_params_t struct
1111+
/// @returns
1112+
/// - ::UR_RESULT_SUCCESS
1113+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
1114+
/// - `buff_size < out_size`
1115+
UR_APIEXPORT ur_result_t UR_APICALL urPrintLoaderConfigSetMockingEnabledParams(const struct ur_loader_config_set_mocking_enabled_params_t *params, char *buffer, const size_t buff_size, size_t *out_size);
1116+
11091117
///////////////////////////////////////////////////////////////////////////////
11101118
/// @brief Print ur_platform_get_params_t struct
11111119
/// @returns

include/ur_print.hpp

Lines changed: 49 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ struct is_handle<ur_kernel_handle_t> : std::true_type {};
3939
template <>
4040
struct is_handle<ur_queue_handle_t> : std::true_type {};
4141
template <>
42-
struct is_handle<ur_native_handle_t> : std::true_type {};
43-
template <>
4442
struct is_handle<ur_sampler_handle_t> : std::true_type {};
4543
template <>
4644
struct is_handle<ur_mem_handle_t> : std::true_type {};
@@ -49,14 +47,12 @@ struct is_handle<ur_physical_mem_handle_t> : std::true_type {};
4947
template <>
5048
struct is_handle<ur_usm_pool_handle_t> : std::true_type {};
5149
template <>
52-
struct is_handle<ur_exp_image_handle_t> : std::true_type {};
53-
template <>
54-
struct is_handle<ur_exp_image_mem_handle_t> : std::true_type {};
55-
template <>
5650
struct is_handle<ur_exp_interop_mem_handle_t> : std::true_type {};
5751
template <>
5852
struct is_handle<ur_exp_interop_semaphore_handle_t> : std::true_type {};
5953
template <>
54+
struct is_handle<ur_exp_win32_handle_t> : std::true_type {};
55+
template <>
6056
struct is_handle<ur_exp_command_buffer_handle_t> : std::true_type {};
6157
template <>
6258
struct is_handle<ur_exp_command_buffer_command_handle_t> : std::true_type {};
@@ -942,6 +938,9 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_function_t value) {
942938
case UR_FUNCTION_ENQUEUE_NATIVE_COMMAND_EXP:
943939
os << "UR_FUNCTION_ENQUEUE_NATIVE_COMMAND_EXP";
944940
break;
941+
case UR_FUNCTION_LOADER_CONFIG_SET_MOCKING_ENABLED:
942+
os << "UR_FUNCTION_LOADER_CONFIG_SET_MOCKING_ENABLED";
943+
break;
945944
default:
946945
os << "unknown enumerator";
947946
break;
@@ -10281,6 +10280,25 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct
1028110280
return os;
1028210281
}
1028310282

10283+
///////////////////////////////////////////////////////////////////////////////
10284+
/// @brief Print operator for the ur_loader_config_set_mocking_enabled_params_t type
10285+
/// @returns
10286+
/// std::ostream &
10287+
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_loader_config_set_mocking_enabled_params_t *params) {
10288+
10289+
os << ".hLoaderConfig = ";
10290+
10291+
ur::details::printPtr(os,
10292+
*(params->phLoaderConfig));
10293+
10294+
os << ", ";
10295+
os << ".enable = ";
10296+
10297+
os << *(params->penable);
10298+
10299+
return os;
10300+
}
10301+
1028410302
///////////////////////////////////////////////////////////////////////////////
1028510303
/// @brief Print operator for the ur_platform_get_params_t type
1028610304
/// @returns
@@ -14646,8 +14664,8 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct
1464614664
os << ", ";
1464714665
os << ".hImage = ";
1464814666

14649-
ur::details::printPtr(os,
14650-
*(params->phImage));
14667+
ur::details::printPtr(os, reinterpret_cast<void *>(
14668+
*(params->phImage)));
1465114669

1465214670
return os;
1465314671
}
@@ -14672,8 +14690,8 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct
1467214690
os << ", ";
1467314691
os << ".hImage = ";
1467414692

14675-
ur::details::printPtr(os,
14676-
*(params->phImage));
14693+
ur::details::printPtr(os, reinterpret_cast<void *>(
14694+
*(params->phImage)));
1467714695

1467814696
return os;
1467914697
}
@@ -14736,8 +14754,8 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct
1473614754
os << ", ";
1473714755
os << ".hImageMem = ";
1473814756

14739-
ur::details::printPtr(os,
14740-
*(params->phImageMem));
14757+
ur::details::printPtr(os, reinterpret_cast<void *>(
14758+
*(params->phImageMem)));
1474114759

1474214760
return os;
1474314761
}
@@ -14762,8 +14780,8 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct
1476214780
os << ", ";
1476314781
os << ".hImageMem = ";
1476414782

14765-
ur::details::printPtr(os,
14766-
*(params->phImageMem));
14783+
ur::details::printPtr(os, reinterpret_cast<void *>(
14784+
*(params->phImageMem)));
1476714785

1476814786
os << ", ";
1476914787
os << ".pImageFormat = ";
@@ -14806,8 +14824,8 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct
1480614824
os << ", ";
1480714825
os << ".hImageMem = ";
1480814826

14809-
ur::details::printPtr(os,
14810-
*(params->phImageMem));
14827+
ur::details::printPtr(os, reinterpret_cast<void *>(
14828+
*(params->phImageMem)));
1481114829

1481214830
os << ", ";
1481314831
os << ".pImageFormat = ";
@@ -14929,10 +14947,16 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct
1492914947
/// std::ostream &
1493014948
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_bindless_images_image_get_info_exp_params_t *params) {
1493114949

14932-
os << ".hImageMem = ";
14950+
os << ".hContext = ";
1493314951

1493414952
ur::details::printPtr(os,
14935-
*(params->phImageMem));
14953+
*(params->phContext));
14954+
14955+
os << ", ";
14956+
os << ".hImageMem = ";
14957+
14958+
ur::details::printPtr(os, reinterpret_cast<void *>(
14959+
*(params->phImageMem)));
1493614960

1493714961
os << ", ";
1493814962
os << ".propName = ";
@@ -14974,8 +14998,8 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct
1497414998
os << ", ";
1497514999
os << ".hImageMem = ";
1497615000

14977-
ur::details::printPtr(os,
14978-
*(params->phImageMem));
15001+
ur::details::printPtr(os, reinterpret_cast<void *>(
15002+
*(params->phImageMem)));
1497915003

1498015004
os << ", ";
1498115005
os << ".mipmapLevel = ";
@@ -15011,8 +15035,8 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct
1501115035
os << ", ";
1501215036
os << ".hMem = ";
1501315037

15014-
ur::details::printPtr(os,
15015-
*(params->phMem));
15038+
ur::details::printPtr(os, reinterpret_cast<void *>(
15039+
*(params->phMem)));
1501615040

1501715041
return os;
1501815042
}
@@ -17330,6 +17354,9 @@ inline ur_result_t UR_APICALL printFunctionParams(std::ostream &os, ur_function_
1733017354
case UR_FUNCTION_LOADER_CONFIG_SET_CODE_LOCATION_CALLBACK: {
1733117355
os << (const struct ur_loader_config_set_code_location_callback_params_t *)params;
1733217356
} break;
17357+
case UR_FUNCTION_LOADER_CONFIG_SET_MOCKING_ENABLED: {
17358+
os << (const struct ur_loader_config_set_mocking_enabled_params_t *)params;
17359+
} break;
1733317360
case UR_FUNCTION_PLATFORM_GET: {
1733417361
os << (const struct ur_platform_get_params_t *)params;
1733517362
} break;

scripts/YaML.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,11 +620,12 @@ class ur_name_t(Structure):
620620
- `out` is used for params that are write-only; if the param is a pointer, then the memory being pointed to is also write-only
621621
- `in,out` is used for params that are both read and write; typically this is used for pointers to other data structures that contain both read and write params
622622
- `nocheck` is used to specify that no additional validation checks will be generated.
623-
+ `desc` may include one the following annotations: {`"[optional]"`, `"[range(start,end)]"`, `"[release]"`, `"[typename(typeVarName)]"`, `"[bounds(offset,size)]"`}
623+
+ `desc` may include one the following annotations: {`"[optional]"`, `"[range(start,end)]"`, `"[retain]"`, `"[release]"`, `"[typename(typeVarName)]"`, `"[bounds(offset,size)]"`}
624624
- `optional` is used for params that are handles or pointers where it is legal for the value to be `nullptr`
625625
- `range` is used for params that are array pointers to specify the valid range that the is valid to read
626626
+ `start` and `end` must be an ISO-C standard identifier or literal
627627
+ `start` is inclusive and `end` is exclusive
628+
- `retain` is used for params that are handles or pointers to handles where the function will increment the reference counter associated with the handle(s).
628629
- `release` is used for params that are handles or pointers to handles where the function will decrement the handle's reference count, potentially leaving it in an invalid state if the reference count reaches zero.
629630
- `typename` is used to denote the type enum for params that are opaque pointers to values of tagged data types.
630631
- `bounds` is used for params that are memory objects or USM allocations. It specifies the range within the memory allocation represented by the param that will be accessed by the operation.

scripts/core/EXP-BINDLESS-IMAGES.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ Enums
148148
Types
149149
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
150150
* ${x}_exp_sampler_mip_properties_t
151-
* ${x}_exp_image_handle_t
152-
* ${x}_exp_image_mem_handle_t
151+
* ${x}_exp_image_native_handle_t
152+
* ${x}_exp_image_mem_native_handle_t
153153
* ${x}_exp_interop_mem_handle_t
154154
* ${x}_exp_interop_semaphore_handle_t
155155
* ${x}_exp_interop_mem_desc_t

scripts/core/EXP-NATIVE-ENQUEUE.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,13 @@ Functions
6565
Changelog
6666
--------------------------------------------------------------------------------
6767

68-
+-----------+------------------------+
69-
| Revision | Changes |
70-
+===========+========================+
71-
| 1.0 | Initial Draft |
72-
+-----------+------------------------+
68+
+-----------+-------------------------+
69+
| Revision | Changes |
70+
+===========+=========================+
71+
| 1.0 | Initial Draft |
72+
+-----------+-------------------------+
73+
| 1.1 | Make `phEvent` optional |
74+
+-----------+-------------------------+
7375

7476

7577
Support
@@ -83,3 +85,4 @@ Contributors
8385
--------------------------------------------------------------------------------
8486

8587
* Hugh Delaney `hugh.delaney@codeplay.com <hugh.delaney@codeplay.com>`_
88+
* Kenneth Benzie (Benie) `k.benzie@codeplay.com <k.benzie@codeplay.com>`_

scripts/core/INTRO.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,33 @@ Currently, UR looks for these adapter libraries:
256256

257257
For more information about the usage of mentioned environment variables see `Environment Variables`_ section.
258258

259+
Mocking
260+
---------------------
261+
A mock UR adapter can be accessed for test purposes by enabling it via
262+
${x}LoaderConfigSetMockingEnabled.
263+
264+
The default fallback behavior for entry points in the mock adapter is to simply
265+
return ``UR_RESULT_SUCCESS``. For entry points concerning handles, i.e. those
266+
that create a new handle or modify the reference count of an existing one, a
267+
dummy handle mechanism is used. This means the adapter will return generic
268+
handles that track a reference count, and ``Retain``/``Release`` entry points will
269+
function as expected when used with these handles.
270+
271+
The behavior of the mock adapter can be customized by linking the
272+
``unified-runtime::mock`` library and making use of the object accessed via the
273+
``mock::getCallbacks()`` helper. Callbacks can be passed into this object to
274+
run either before or after a given entry point, or they can be set to entirely
275+
replace the default behavior. Only one callback of each type (before, replace,
276+
after) can be set per entry point, with subsequent callbacks set in the same
277+
"slot" overwriting any set previously.
278+
279+
The callback signature defined by ``ur_mock_callback_t`` takes a single
280+
``void *`` parameter. When calling a user callback the adapter will pack the
281+
entry point's parameters into the appropriate ``_params_t`` struct (e.g.
282+
``ur_adapter_get_params_t``) and pass a pointer to that struct into the
283+
callback. This allows parameters to be accessed and modified. The definitions
284+
for these parameter structs can be found in the main API header.
285+
259286
Layers
260287
---------------------
261288
UR comes with a mechanism that allows various API intercept layers to be enabled, either through the API or with an environment variable (see `Environment Variables`_).

scripts/core/adapter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ params:
7070
- type: "$x_adapter_handle_t"
7171
name: hAdapter
7272
desc: |
73-
[in] Adapter handle to retain
73+
[in][retain] Adapter handle to retain
7474
--- #--------------------------------------------------------------------------
7575
type: function
7676
desc: "Get the last adapter specific error."

0 commit comments

Comments
 (0)