Skip to content

[WIP] mem props #1301

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Conversation

bratpiorka
Copy link
Contributor

todo

@bratpiorka bratpiorka force-pushed the rrudnick_props_api branch 15 times, most recently from 92db71d to 56573df Compare May 16, 2025 13:42
@bratpiorka bratpiorka force-pushed the rrudnick_props_api branch 15 times, most recently from a5c357c to 17f6335 Compare June 4, 2025 17:42
@bratpiorka bratpiorka force-pushed the rrudnick_props_api branch 15 times, most recently from 96bb935 to 5015432 Compare June 11, 2025 12:19
Copy link
Contributor

@lplewa lplewa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add tests too all umf pools
you should use poolfixtures.hpp
Including it's abstraction to create custom pools and providers.

Comment on lines 442 to 465
static void do_umf_mem_props_benchmark(ze_context_handle_t context,
bool use_umf, alloc_t *allocs,
size_t num_allocs, size_t repeats) {
assert(context != NULL);

for (size_t r = 0; r < repeats * 10; ++r) {
for (size_t i = 0; i < num_allocs; ++i) {
if (use_umf) {
umf_memory_properties_handle_t props_handle = NULL;
umf_result_t res =
umfGetMemoryPropertiesHandle(allocs[i].ptr, &props_handle);
(void)res;
assert(res == UMF_RESULT_SUCCESS);

umf_usm_memory_type_t type = UMF_MEMORY_TYPE_UNKNOWN;
res = umfGetMemoryProperty(
props_handle, UMF_MEMORY_PROPERTY_POINTER_TYPE, &type);
assert(res == UMF_RESULT_SUCCESS);
if (type != UMF_MEMORY_TYPE_DEVICE) {
fprintf(stderr,
"error: unexpected alloc_props.type value: %d\n",
type);
exit(-1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please in final version add benchmark to new framework.

Comment on lines 31 to 32
/// be filled. NOTE: the type and size of the value depends on the
/// memory property ID and should be checked in the documentation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

api like this should include size parameter for safety

Comment on lines +19 to +25
/// @brief Get the memory properties handle for a given pointer
/// @param ptr pointer to the allocated memory
/// @param props_handle [out] pointer to the memory properties handle
/// @return UMF_RESULT_SUCCESS on success or appropriate error code on failure
umf_result_t
umfGetMemoryPropertiesHandle(const void *ptr,
umf_memory_properties_handle_t *props_handle);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

document ownership of this handle.

Comment on lines +28 to +36
typedef struct umf_memory_properties_t {
// TODO alloc_info_t
void *ptr;
umf_memory_pool_handle_t pool;
umf_memory_provider_handle_t provider;
uint64_t id;
void *base;
size_t base_size;
} umf_memory_properties_t;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we have api to literaly read this structure - it should be defined in .c file

#include <umf/memory_provider.h>

#if UMF_BUILD_LEVEL_ZERO_PROVIDER
#include "ze_api.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i do not see a reason to include this file there

/// @param value [out] pointer to the preallocated variable where the value will be stored
/// @return UMF_RESULT_SUCCESS on success or appropriate error code on failure,
/// UMF_RESULT_ERROR_INVALID_ARGUMENT if memory_property_id is invalid or value is NULL,
/// UMF_RESULT_ERROR_NOT_SUPPORTED if the property is not supported by this provider.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not true:
Please include tests to ensure that comment it true (as far i see we return EINVAL

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Especially please include also test with custom user provided provider, which support extra property which is user defined.

@bratpiorka bratpiorka force-pushed the rrudnick_props_api branch 12 times, most recently from daa3c56 to 96e5b38 Compare June 13, 2025 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants