-
Notifications
You must be signed in to change notification settings - Fork 35
[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
base: main
Are you sure you want to change the base?
[WIP] mem props #1301
Conversation
92db71d
to
56573df
Compare
a5c357c
to
17f6335
Compare
96bb935
to
5015432
Compare
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 tests too all umf pools
you should use poolfixtures.hpp
Including it's abstraction to create custom pools and providers.
benchmark/ubench.c
Outdated
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); |
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 in final version add benchmark to new framework.
include/umf/memory_props.h
Outdated
/// be filled. NOTE: the type and size of the value depends on the | ||
/// memory property ID and should be checked in the documentation |
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.
api like this should include size parameter for safety
/// @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); |
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.
document ownership of this handle.
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; |
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 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" |
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.
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. |
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.
This is not true:
Please include tests to ensure that comment it true (as far i see we return EINVAL
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.
Especially please include also test with custom user provided provider, which support extra property which is user defined.
daa3c56
to
96e5b38
Compare
todo