Skip to content

Commit 94517a8

Browse files
committed
rename examples and mark ctl as experimental in those
1 parent 15e7433 commit 94517a8

File tree

8 files changed

+70
-15
lines changed

8 files changed

+70
-15
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ documentation, which includes the code of the
2121
[basic example](https://github.com/oneapi-src/unified-memory-framework/blob/main/examples/basic/basic.c).
2222
There are also more advanced examples that allocate USM memory from the [Level Zero device](examples/level_zero_shared_memory/level_zero_shared_memory.c) using the Level Zero API and UMF Level Zero memory provider and [CUDA device](examples/cuda_shared_memory/cuda_shared_memory.c) using the CUDA API and UMF CUDA memory provider.
2323

24+
UMF's experimental CTL API is showcased in the [CTL example](examples/ctl/ctl.c),
25+
which explores provider and pool statistics, and in the [custom CTL example](examples/ctl/custom_ctl.c), which wires CTL support into a bespoke memory
26+
provider. These examples rely on experimental headers whose interfaces may
27+
change in future releases.
28+
2429
## Build
2530

2631
### Requirements

docs/config/ctl.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ configuration options, statistics and auxiliary APIs. CTL entries can also be
88
set through environment variables or a configuration file, allowing adjustment
99
of UMF behavior without modifying the program.
1010

11+
.. note::
12+
The CTL API is experimental and may change in future releases.
13+
1114
Main concepts
1215
=============
1316

@@ -663,17 +666,16 @@ The jemalloc-backed pool currently exposes only the common statistics nodes.
663666
Adding CTL support to custom providers and pools
664667
================================================
665668

666-
The :file:`examples/ctl/ctl_example.c` source demonstrates how a minimal
669+
The :file:`examples/ctl/custom_ctl.c` source demonstrates how a minimal
667670
provider can expose configuration entries, statistics and runnables through the
668671
CTL API. To add similar support to your own provider or pool you must implement
669672
an ``ext_ctl`` callback – parse incoming CTL paths and handle
670-
`CTL_QUERY_READ``, ``CTL_QUERY_WRITE`` and ``CTL_QUERY_RUNNABLE`` requests.
673+
``CTL_QUERY_READ``, ``CTL_QUERY_WRITE`` and ``CTL_QUERY_RUNNABLE`` requests.
671674
The callback receives a ``umf_ctl_query_source_t`` indicating whether the
672675
query came from the application or a configuration source. Programmatic
673676
calls pass typed binary data, while configuration sources deliver strings
674677
that must be parsed. Wildcards (``{}``) may appear in paths and are supplied
675678
as additional arguments.
676-
new entries.
677679

678680
During initialization UMF will execute ``post_initialize`` on the callback after
679681
applying any queued defaults, allowing the provider or pool to finalize its

docs/config/examples.rst

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,19 +147,23 @@ in the UMF repository.
147147

148148
TODO
149149

150-
CTL statistics example
150+
CTL example
151151
==============================================================================
152152

153-
You can find the full example code in the `examples/ctl/ctl_statistics_example.c`_ file
154-
in the UMF repository.
153+
.. note::
154+
The CTL API is experimental and may change in future releases.
155+
156+
You can find the full example code in the `examples/ctl/ctl.c`_ file in the
157+
UMF repository.
155158

156159
The sample configures an OS memory provider and a disjoint pool, reuses the
157160
provider's canonical ``OS`` selector obtained at runtime, assigns a custom pool
158161
name, and then mixes ``by_handle`` and ``by_name`` selectors to explore CTL
159162
statistics. Wildcard nodes are used to choose provider counters, build a
160163
four-segment ``{}.{}`` chain for the named pool, reset the peak tracker, and
161-
drill into per-bucket disjoint pool telemetry. The program prints hints on ``stderr``
162-
explaining which tracing level is necessary when a statistic is unavailable.
164+
drill into per-bucket disjoint pool telemetry. The program prints hints on
165+
``stderr`` explaining which tracing level is necessary when a statistic is
166+
unavailable.
163167

164168
Build and run the example with::
165169

@@ -176,6 +180,26 @@ Tracing level ``1`` enables slab usage counters, level ``2`` adds allocation
176180
and free statistics, and level ``3`` additionally emits verbose log messages
177181
from the pool implementation.
178182

183+
Custom CTL example
184+
==============================================================================
185+
186+
You can find the full example code in the `examples/ctl/custom_ctl.c`_ file in
187+
the UMF repository. The program implements a minimal memory provider with CTL
188+
hooks that accept configuration values, execute runnables, and expose provider
189+
state through the experimental API. It highlights converting wildcard segments
190+
to ``printf``-style format strings and reading integers supplied via
191+
configuration defaults.
192+
193+
Build and run the example with::
194+
195+
cmake -B build
196+
cmake --build build
197+
./build/examples/umf_example_ctl
198+
199+
Optionally supply a modulus via configuration defaults::
200+
201+
UMF_CONF="umf.provider.default.ctl.m=10" ./build/examples/umf_example_ctl
202+
179203
IPC example with Level Zero Memory Provider
180204
==============================================================================
181205
The full code of the example is in the `examples/ipc_level_zero/ipc_level_zero.c`_ file in the UMF repository.
@@ -260,7 +284,8 @@ the :any:`umfCloseIPCHandle` function is called.
260284
.. _examples/cuda_shared_memory/cuda_shared_memory.c: https://github.com/oneapi-src/unified-memory-framework/blob/main/examples/cuda_shared_memory/cuda_shared_memory.c
261285
.. _examples/ipc_level_zero/ipc_level_zero.c: https://github.com/oneapi-src/unified-memory-framework/blob/main/examples/ipc_level_zero/ipc_level_zero.c
262286
.. _examples/custom_file_provider/custom_file_provider.c: https://github.com/oneapi-src/unified-memory-framework/blob/main/examples/custom_file_provider/custom_file_provider.c
263-
.. _examples/ctl/ctl_statistics_example.c: https://github.com/oneapi-src/unified-memory-framework/blob/main/examples/ctl/ctl_statistics_example.c
287+
.. _examples/ctl/ctl.c: https://github.com/oneapi-src/unified-memory-framework/blob/main/examples/ctl/ctl.c
288+
.. _examples/ctl/custom_ctl.c: https://github.com/oneapi-src/unified-memory-framework/blob/main/examples/ctl/custom_ctl.c
264289
.. _examples/memspace: https://github.com/oneapi-src/unified-memory-framework/blob/main/examples/memspace/
265290
.. _README: https://github.com/oneapi-src/unified-memory-framework/blob/main/README.md#memory-pool-managers
266291
.. _umf/ipc.h: https://github.com/oneapi-src/unified-memory-framework/blob/main/include/umf/ipc.h

examples/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ if(LINUX)
277277

278278
add_umf_executable(
279279
NAME ${EXAMPLE_NAME}
280-
SRCS ctl/ctl_example.c
280+
SRCS ctl/custom_ctl.c
281281
LIBS umf ${UMF_HWLOC_NAME})
282282

283283
target_include_directories(
@@ -295,7 +295,7 @@ if(LINUX)
295295

296296
add_umf_executable(
297297
NAME ${EXAMPLE_NAME}
298-
SRCS ctl/ctl_statistics_example.c
298+
SRCS ctl/ctl.c
299299
LIBS umf ${UMF_HWLOC_NAME})
300300

301301
target_include_directories(

examples/README.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,28 @@ processes: a producer and a consumer that communicate in the following way
6969

7070
## CTL example
7171

72+
> **Note**: The CTL API is experimental and may change in future releases.
73+
74+
This example configures an OS memory provider and disjoint pool, then queries
75+
statistics through CTL using both ``by_handle`` and ``by_name`` selectors. It
76+
demonstrates wildcard nodes to mix selectors, reset peak counters, and drill
77+
into disjoint-pool bucket telemetry. Run it with:
78+
79+
./umf_example_ctl_statistics
80+
81+
Tracing for detailed disjoint pool counters can be enabled through:
82+
83+
UMF_CONF="umf.pool.default.disjoint.params.pool_trace=2" ./umf_example_ctl_statistics
84+
85+
## Custom CTL example
86+
87+
> **Note**: The CTL API is experimental and may change in future releases.
88+
7289
This example demonstrates how to add CTL support to a custom memory
7390
provider. It sets variables ``a`` and ``b`` through CTL, plus it allows
74-
for the modulus ``m`` loaded from the environment or a configuration file.
91+
for the modulus ``m`` to be loaded from the environment or a configuration file.
7592
Addition and subtraction operations return results modulo ``m`` and the
7693
result ``c`` can be retrieved using the CTL API. For example, to set the
77-
modulus through an environment variable run::
94+
modulus through an environment variable run:
7895

7996
UMF_CONF="umf.provider.default.ctl.m=10" ./umf_example_ctl

examples/ctl/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ endif()
2323

2424
# build the example
2525
set(EXAMPLE_NAME umf_example_ctl)
26-
add_executable(${ EXAMPLE_NAME} ctl_example.c)
26+
add_executable(${ EXAMPLE_NAME} custom_ctl.c)
2727
target_include_directories(${ EXAMPLE_NAME} PRIVATE ${ LIBUMF_INCLUDE_DIRS})
2828
target_link_directories(
2929
${
@@ -52,7 +52,7 @@ if(LINUX)
5252
endif()
5353

5454
set(EXAMPLE_NAME umf_example_ctl_statistics)
55-
add_executable(${ EXAMPLE_NAME} ctl_statistics_example.c)
55+
add_executable(${ EXAMPLE_NAME} ctl.c)
5656
target_include_directories(${ EXAMPLE_NAME} PRIVATE ${ LIBUMF_INCLUDE_DIRS})
5757
target_link_directories(
5858
${

examples/ctl/ctl_statistics_example.c renamed to examples/ctl/ctl.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
#include <stdio.h>
1313

1414
#include <umf/experimental/ctl.h>
15+
16+
// This example relies on the experimental CTL API, which may change without
17+
// notice.
1518
#include <umf/memory_pool.h>
1619
#include <umf/memory_provider.h>
1720
#include <umf/pools/pool_disjoint.h>

examples/ctl/ctl_example.c renamed to examples/ctl/custom_ctl.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
#include <umf/memory_provider.h>
2020
#include <umf/memory_provider_ops.h>
2121

22+
// This example relies on the experimental CTL API, which may change without
23+
// notice.
24+
2225
// Minimal memory provider demonstrating CTL integration
2326

2427
// Provider state exposed via CTL

0 commit comments

Comments
 (0)