Skip to content

Commit 603ceda

Browse files
committed
tracker props
1 parent 1de8ce0 commit 603ceda

File tree

8 files changed

+27
-33
lines changed

8 files changed

+27
-33
lines changed

FlameGraph

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 41fee1f99f9276008b7cd112fca19dc3ea84ac32

src/ipc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ umf_result_t umfGetIPCHandle(const void *ptr, umf_ipc_handle_t *umfIPCHandle,
5858
}
5959

6060
size_t ipcHandleSize = 0;
61-
umf_alloc_info_t allocInfo;
62-
umf_result_t ret = umfMemoryTrackerGetAllocInfo(ptr, &allocInfo, NULL);
61+
umf_alloc_info_t allocInfo = {NULL, 0, NULL, NULL};
62+
umf_result_t ret = umfMemoryTrackerGetAllocInfo(ptr, &allocInfo);
6363
if (ret != UMF_RESULT_SUCCESS) {
6464
LOG_ERR("cannot get alloc info for ptr = %p.", ptr);
6565
return ret;

src/memory_props.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,17 @@ umf_result_t
1919
umfGetMemoryPropertiesHandle(const void *ptr,
2020
umf_memory_properties_handle_t *props_handle) {
2121

22-
// TODO remove?
23-
umf_alloc_info_t allocInfo = {NULL, 0, NULL};
24-
umf_result_t ret = umfMemoryTrackerGetAllocInfo(ptr, &allocInfo, props_handle);
22+
if (props_handle == NULL) {
23+
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
24+
}
25+
26+
umf_alloc_info_t allocInfo = {NULL, 0, NULL, NULL};
27+
umf_result_t ret = umfMemoryTrackerGetAllocInfo(ptr, &allocInfo);
2528
if (ret != UMF_RESULT_SUCCESS) {
2629
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
2730
}
2831

32+
*props_handle = allocInfo.props;
2933

3034
return UMF_RESULT_SUCCESS;
3135
}

src/memory_props_internal.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,6 @@ typedef struct umf_memory_properties_t {
3333
uint64_t id;
3434
void *base;
3535
size_t base_size;
36-
37-
// TODO
38-
bool gpu_properties_initialized;
39-
union {
40-
#if UMF_BUILD_LEVEL_ZERO_PROVIDER
41-
ze_memory_allocation_properties_t ze_properties;
42-
#endif
43-
int unused; // in case of no GPU support
44-
} gpu;
4536
} umf_memory_properties_t;
4637

4738
#ifdef __cplusplus

src/pool/pool_disjoint.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -884,8 +884,8 @@ size_t disjoint_pool_malloc_usable_size(void *pool, const void *ptr) {
884884
critnib_release(disjoint_pool->known_slabs, ref_slab);
885885
}
886886

887-
umf_alloc_info_t allocInfo = {NULL, 0, NULL};
888-
umf_result_t ret = umfMemoryTrackerGetAllocInfo(ptr, &allocInfo, NULL);
887+
umf_alloc_info_t allocInfo = {NULL, 0, NULL, NULL};
888+
umf_result_t ret = umfMemoryTrackerGetAllocInfo(ptr, &allocInfo);
889889
if (ret != UMF_RESULT_SUCCESS) {
890890
return 0;
891891
}
@@ -925,8 +925,8 @@ umf_result_t disjoint_pool_free(void *pool, void *ptr) {
925925
critnib_release(disjoint_pool->known_slabs, ref_slab);
926926
}
927927

928-
umf_alloc_info_t allocInfo = {NULL, 0, NULL};
929-
umf_result_t ret = umfMemoryTrackerGetAllocInfo(ptr, &allocInfo, NULL);
928+
umf_alloc_info_t allocInfo = {NULL, 0, NULL, NULL};
929+
umf_result_t ret = umfMemoryTrackerGetAllocInfo(ptr, &allocInfo);
930930
if (ret != UMF_RESULT_SUCCESS) {
931931
TLS_last_allocation_error = ret;
932932
LOG_ERR("failed to get allocation info from the memory tracker");

src/pool/pool_proxy.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,8 @@ static umf_result_t proxy_free(void *pool, void *ptr) {
9797
struct proxy_memory_pool *hPool = (struct proxy_memory_pool *)pool;
9898

9999
if (ptr) {
100-
umf_alloc_info_t allocInfo = {NULL, 0, NULL};
101-
umf_result_t umf_result =
102-
umfMemoryTrackerGetAllocInfo(ptr, &allocInfo, NULL);
100+
umf_alloc_info_t allocInfo = {NULL, 0, NULL, NULL};
101+
umf_result_t umf_result = umfMemoryTrackerGetAllocInfo(ptr, &allocInfo);
103102
if (umf_result == UMF_RESULT_SUCCESS) {
104103
size = allocInfo.baseSize;
105104
}

src/provider/provider_tracking.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ umfMemoryTrackerAddAtLevel(umf_memory_tracker_handle_t hTracker, int level,
205205
value->props.id = utils_atomic_increment_u64(&unique_alloc_id);
206206
value->props.base = (void *)ptr;
207207
value->props.base_size = size;
208+
value->props.pool = pool;
209+
value->props.ptr = (void *)ptr;
208210

209211
value->size = size;
210212
value->n_children = 0;
@@ -472,18 +474,17 @@ umfMemoryTrackerRemoveIpcSegment(umf_memory_tracker_handle_t hTracker,
472474
}
473475

474476
umf_memory_pool_handle_t umfMemoryTrackerGetPool(const void *ptr) {
475-
umf_alloc_info_t allocInfo = {NULL, 0, NULL};
476-
umf_result_t ret = umfMemoryTrackerGetAllocInfo(ptr, &allocInfo, NULL);
477+
umf_alloc_info_t allocInfo = {NULL, 0, NULL, NULL};
478+
umf_result_t ret = umfMemoryTrackerGetAllocInfo(ptr, &allocInfo);
477479
if (ret != UMF_RESULT_SUCCESS) {
478480
return NULL;
479481
}
480482

481483
return allocInfo.pool;
482484
}
483485

484-
umf_result_t
485-
umfMemoryTrackerGetAllocInfo(const void *ptr, umf_alloc_info_t *pAllocInfo,
486-
umf_memory_properties_handle_t *props) {
486+
umf_result_t umfMemoryTrackerGetAllocInfo(const void *ptr,
487+
umf_alloc_info_t *pAllocInfo) {
487488
assert(pAllocInfo);
488489

489490
if (ptr == NULL) {
@@ -572,11 +573,8 @@ umfMemoryTrackerGetAllocInfo(const void *ptr, umf_alloc_info_t *pAllocInfo,
572573
pAllocInfo->base = (void *)top_most_key;
573574
pAllocInfo->baseSize = top_most_value->size;
574575
pAllocInfo->pool = top_most_value->pool;
576+
pAllocInfo->props = &top_most_value->props;
575577

576-
if (props != NULL) {
577-
*props = &top_most_value->props;
578-
}
579-
580578
assert(ref_top_most_value);
581579
critnib_release(TRACKER->alloc_segments_map[ref_level], ref_top_most_value);
582580

src/provider/provider_tracking.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@ typedef struct umf_alloc_info_t {
4141
void *base;
4242
size_t baseSize;
4343
umf_memory_pool_handle_t pool;
44+
45+
umf_memory_properties_handle_t props;
4446
} umf_alloc_info_t;
4547

46-
umf_result_t
47-
umfMemoryTrackerGetAllocInfo(const void *ptr, umf_alloc_info_t *pAllocInfo,
48-
umf_memory_properties_handle_t *props_handle);
48+
umf_result_t umfMemoryTrackerGetAllocInfo(const void *ptr,
49+
umf_alloc_info_t *pAllocInfo);
4950

5051
typedef struct umf_ipc_info_t {
5152
void *base;

0 commit comments

Comments
 (0)