Skip to content

add memory properties API #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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bratpiorka
Copy link
Contributor

@bratpiorka bratpiorka commented May 8, 2025

@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 2 times, most recently from a972d25 to 94a3476 Compare July 15, 2025 09:09
@bratpiorka bratpiorka marked this pull request as ready for review July 16, 2025 09:27
@bratpiorka bratpiorka requested a review from a team as a code owner July 16, 2025 09:27
@bratpiorka bratpiorka force-pushed the rrudnick_props_api branch from 94a3476 to 218fccf Compare July 17, 2025 09:15
@bratpiorka bratpiorka changed the title [WIP] mem props add memory properties API Jul 17, 2025
@bratpiorka bratpiorka force-pushed the rrudnick_props_api branch 3 times, most recently from 4c40aae to b24d000 Compare July 17, 2025 10:32
@bratpiorka bratpiorka force-pushed the rrudnick_props_api branch 7 times, most recently from 787d15d to 845f2b4 Compare July 21, 2025 10:02
@lukaszstolarczuk lukaszstolarczuk requested a review from Copilot July 22, 2025 11:10
Copy link

@Copilot Copilot AI left a 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 adds a comprehensive memory properties API to the unified memory framework, enabling users to query various properties of allocated memory such as memory type, base address, size, and provider-specific information.

  • Introduces memory properties API with two main functions: umfGetMemoryPropertiesHandle and umfGetMemoryProperty
  • Extends memory provider operations with ext_get_allocation_properties function
  • Adds comprehensive test coverage for the new memory properties functionality

Reviewed Changes

Copilot reviewed 37 out of 38 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
include/umf/base.h Defines memory property types and handle structures
include/umf/experimental/memory_props.h Public API for memory properties functionality
src/memory_props.c Core implementation of memory properties API
src/provider/provider_tracking.c Updates tracking provider to support memory properties
test/props/ Comprehensive test suite for memory properties API
Various provider files Updates all providers to support new allocation properties interface

@bratpiorka bratpiorka force-pushed the rrudnick_props_api branch 3 times, most recently from 7166723 to cfae388 Compare July 22, 2025 13:42
@bratpiorka bratpiorka force-pushed the rrudnick_props_api branch 2 times, most recently from 55cd0ea to f0d0c8c Compare July 23, 2025 08:22
/// @param property_value [out] pointer to the value of the memory property
/// which will be filled
/// @return UMF_RESULT_SUCCESS on success or appropriate error code on failure
umf_result_t umfGetMemoryProperty(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.

const handle?

@@ -144,3 +144,6 @@ EXPORTS
umfJemallocPoolParamsDestroy
umfJemallocPoolParamsSetNumArenas
umfPoolGetName
; Added in UMF_1.1
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm... should we bump VERSION on top of this file?

// UMF specific
UMF_MEMORY_PROPERTY_PROVIDER_HANDLE =
0, ///< Handle to the memory provider (void*)
UMF_MEMORY_PROPERTY_POOL_HANDLE = 1, ///< Handle to the memory pool (void*)
Copy link
Contributor

Choose a reason for hiding this comment

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

mention handle types, perhaps

/// @param memory_property_id ID of the memory property to get
/// @param max_property_size size of the property value buffer
/// @param property_value [out] pointer to the value of the memory property
/// which will be filled
Copy link
Contributor

Choose a reason for hiding this comment

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

perhaps mention that value's type depends on the property (and link to enum umf_memory_property_id_t)


#include <inttypes.h>

#include <umf/experimental/memory_props.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe rename the file to memory_properties instead of "props"

@@ -133,6 +133,17 @@ umfDefaultCtlHandle(void *provider, umf_ctl_query_source_t operationType,
return UMF_RESULT_ERROR_NOT_SUPPORTED;
}

static umf_result_t umfDefaultGetAllocationProperties(
void *provider, const void *ptr, umf_memory_property_id_t propertyId,
Copy link
Contributor

Choose a reason for hiding this comment

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

perhaps property_id to match style of other names

sizeof(baseAddress), &baseAddress);
ASSERT_EQ(result, UMF_RESULT_SUCCESS);
ASSERT_EQ(baseAddress, ptr);

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm missing an invalid test for umfGetMemoryProperty with wrong mem_property_id

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.

add memory properties API​
4 participants