-
Notifications
You must be signed in to change notification settings - Fork 40
The last CTL patch :) #1524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
The last CTL patch :) #1524
Conversation
629b379
to
2706166
Compare
Split between initialize and post-initialize function is necessary for properly handling CTL defaults.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after all, this is super huge PR - I'd split this somehow, if easily done...
defaults changes global state, so using forks will isolate tests
|
||
UMF's experimental CTL API is showcased in the [CTL example](examples/ctl/ctl.c), | ||
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 | ||
provider. These examples rely on experimental headers whose interfaces may |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whose
refer to people -> perhaps: ... experimental headers which may change ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
sizeof(alloc_count), name, i); | ||
} | ||
|
||
Ensure that the types of wildcard arguments match the expected node types. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
otherwise what? you get an error, a crash, ...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
undefined behavior may happen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
undefined by C standard not our code.
sizeof(capacity)); | ||
|
||
Every subsequently created disjoint pool will use ``16`` as its starting | ||
capacity overriding it's creation parameters. Defaults are keyed by the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's
-> its
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
UMF_CONF="umf.logger.output=stdout;umf.logger.level=0" | ||
|
||
CTL options available through environment variables are limited—you can only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
limited—you
misspell
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done?
Within each subsystem the path continues with an addressing scheme followed by | ||
the module or leaf of interest. | ||
|
||
Reading this reference |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider renaming this section to Reading below sections
or dunno, something else ;d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
w/e done.
:type:`umf_memory_provider_handle_t` argument to reach a specific provider. | ||
Providers can also be addressed by name through ``umf.provider.by_name.{provider}``; | ||
append ``.{index}`` to address specific provider when multiple providers share the same label. | ||
Defaults for future providers reside under ``umf.provider.default.{provider}`` and track the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure what you meant by ... and track the name ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
=========== | ||
|
||
A ``{}`` in the path acts as a wildcard and is replaced with successive | ||
arguments of ``umfCtlGet``, ``umfCtlSet`` or ``umfCtlExec``. Wildcards can |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set and get are explained, but umfCtlExec
wasn't
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH we do not explain set or get either. Do we need such section?
target_include_directories(${ EXAMPLE_NAME} PRIVATE ${ LIBUMF_INCLUDE_DIRS}) | ||
target_link_directories( | ||
${ | ||
EXAMPLE_NAME} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's a weird formatting - can you make it like ${EXAMPLE_NAME}
...?
// fix below, as well pls
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not my faults - this is done by cmake format
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. | ||
|
||
UMF's experimental CTL API is showcased in the [CTL example](examples/ctl/ctl.c), | ||
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bespoke -> customized
UMF repository. | ||
|
||
The sample configures an OS memory provider and a disjoint pool, reuses the | ||
provider's canonical ``OS`` selector obtained at runtime, assigns a custom pool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cannonical?
name, and then mixes ``by_handle`` and ``by_name`` selectors to explore CTL | ||
statistics. Wildcard nodes are used to choose provider counters, build a | ||
four-segment ``{}.{}`` chain for the named pool, reset the peak tracker, and | ||
drill into per-bucket disjoint pool telemetry. The program prints hints on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
drill
This example configures an OS memory provider and disjoint pool, then queries | ||
statistics through CTL using both ``by_handle`` and ``by_name`` selectors. It | ||
demonstrates wildcard nodes to mix selectors, reset peak counters, and drill |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
drill into?
add_executable(${ EXAMPLE_NAME} custom_ctl.c) | ||
target_include_directories(${ EXAMPLE_NAME} PRIVATE ${ LIBUMF_INCLUDE_DIRS}) | ||
target_link_directories( | ||
${ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix formatting
TEST ${ EXAMPLE_NAME} | ||
PROPERTY ENVIRONMENT_MODIFICATION | ||
"LD_LIBRARY_PATH=path_list_append:" | ||
"${LIBUMF_LIBRARY_DIRS};LD_" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not break "LD_LIBRARY..."
* | ||
*/ | ||
|
||
#include "umf/base.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use <> for system headers, group and change order
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
*/ | ||
|
||
#include "ctl_defaults.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move down to other internal includes
|
||
static char *DEFAULT_NAME = "disjoint"; | ||
|
||
enum { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add a comment how this is used
as I understand you create single bitmask instead of multiple bool flags .. maybe you could keep this enum close to "params_overriden" filed?
static char *DEFAULT_NAME = "disjoint"; | ||
|
||
enum { | ||
DP_OVERRIDE_SLAB_MIN_SIZE = 1 << 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you initialize the bitmask to 0 does it mean that by default slab min size is always overriden?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR consolidates final CTL (Control Interface) changes for version 1.0, including error code adjustments and comprehensive implementation of CTL functionality for providers and pools. The CTL system provides a hierarchical interface for configuring and querying UMF components.
Key changes:
- Introduced new error code
UMF_RESULT_ERROR_INVALID_CTL_PATH
for invalid CTL paths - Added comprehensive CTL parameter support for disjoint pools with default overrides
- Enhanced provider and pool initialization with post-initialization hooks
- Added extensive test coverage and examples for CTL functionality
Reviewed Changes
Copilot reviewed 49 out of 49 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
include/umf/base.h |
Added new error code UMF_RESULT_ERROR_INVALID_CTL_PATH |
test/utils/cpp_helpers.hpp |
Updated default error return from UMF_RESULT_ERROR_UNKNOWN to UMF_RESULT_ERROR_INVALID_CTL_PATH |
test/pools/disjoint_pool_ctl.cpp |
Added comprehensive CTL tests for disjoint pool parameters and defaults |
test/pools/disjoint_pool.cpp |
Added post-initialization CTL calls to existing tests |
src/pool/pool_disjoint.c |
Implemented extensive CTL parameter support with read/write handlers |
src/memory_provider.c |
Added provider CTL defaults system and post-initialization support |
src/memory_pool.c |
Enhanced pool creation with CTL defaults and post-initialization |
examples/ctl/ |
Added comprehensive CTL usage examples |
ret = umfCtlGet("umf.pool.by_handle.{}.stats.buckets.count", &arg, 1, | ||
poolWrapper.get()); | ||
EXPECT_EQ(ret, UMF_RESULT_ERROR_INVALID_ARGUMENT); | ||
EXPECT_EQ(ret, UMF_RESULT_ERROR_INVALID_CTL_PATH); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The buffer size is too small (1 byte) for a size_t
value. This should be sizeof(arg)
to match the expected data type size.
Copilot uses AI. Check for mistakes.
ret = umfCtlGet("umf.pool.by_handle.{}.stats.1.alloc_num", &arg, 1, | ||
poolWrapper.get()); | ||
EXPECT_EQ(ret, UMF_RESULT_ERROR_INVALID_ARGUMENT); | ||
EXPECT_EQ(ret, UMF_RESULT_ERROR_INVALID_CTL_PATH); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The buffer size is too small (1 byte) for a size_t
value. This should be sizeof(arg)
to match the expected data type size.
Copilot uses AI. Check for mistakes.
|
||
// no bucket id | ||
ret = umfCtlGet("umf.pool.by_handle.{}.stats.buckets.alloc_num", &arg, | ||
sizeof(arg), poolWrapper.get()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The buffer size is inconsistent with other similar test cases. For consistency with the test pattern, this should use 1
as the buffer size to test the invalid path scenario.
sizeof(arg), poolWrapper.get()); | |
1, poolWrapper.get()); |
Copilot uses AI. Check for mistakes.
|
||
// bucked id + count | ||
ret = umfCtlGet("umf.pool.by_handle.{}.stats.buckets.1.count", &arg, | ||
sizeof(arg), poolWrapper.get()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The buffer size is inconsistent with other similar test cases. For consistency with the test pattern, this should use 1
as the buffer size to test the invalid path scenario.
sizeof(arg), poolWrapper.get()); | |
1, poolWrapper.get()); |
Copilot uses AI. Check for mistakes.
int a; | ||
int b; | ||
int c; | ||
int m; // modulus value, optional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typedef struct ctl_provider_t {
int a, b, c, m;
} ctl_provider_t;
PRIVATE | ||
${ | ||
LIBHWLOC_LIBRARY_DIRS}) | ||
target_link_libraries(${ EXAMPLE_NAME} PRIVATE ${LIBUMF_LIBRARIES} hwloc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is needed to keep those spaces in brackets?
I mean:
${hereEXAMPLE_NAME}
void *provider, const void *ptr, | ||
umf_memory_property_id_t memory_property_id, void *property_value); | ||
|
||
/// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In memory_pool.h
you removed such line :)
umf_ctl_query_type_t queryType) { | ||
(void)source; | ||
if (strstr(extra_name, "{}") != NULL) { | ||
LOG_ERR("%s, default setting do not support wildcard parameters {}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not -> does not?
#include "umf.h" | ||
#include <gtest/gtest.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
different header groups
No description provided.