Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions benchmark/benchmark_umf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ struct provider_interface {
}
}

virtual umf_memory_provider_ops_t *
virtual const umf_memory_provider_ops_t *
getOps([[maybe_unused]] ::benchmark::State &state) = 0;

virtual params_ptr getParams([[maybe_unused]] ::benchmark::State &state) {
Expand Down Expand Up @@ -129,7 +129,7 @@ struct pool_interface {
provider.TearDown(state);
};

virtual umf_memory_pool_ops_t *
virtual const umf_memory_pool_ops_t *
getOps([[maybe_unused]] ::benchmark::State &state) = 0;

virtual params_ptr getParams([[maybe_unused]] ::benchmark::State &state) {
Expand Down Expand Up @@ -189,7 +189,7 @@ struct os_provider : public provider_interface {
deleter};
}

umf_memory_provider_ops_t *
const umf_memory_provider_ops_t *
getOps([[maybe_unused]] ::benchmark::State &state) override {
return umfOsMemoryProviderOps();
}
Expand Down Expand Up @@ -245,7 +245,7 @@ struct fixed_provider : public provider_interface {
deleter};
}

umf_memory_provider_ops_t *
const umf_memory_provider_ops_t *
getOps([[maybe_unused]] ::benchmark::State &state) override {
return umfFixedMemoryProviderOps();
}
Expand All @@ -254,7 +254,7 @@ struct fixed_provider : public provider_interface {

template <typename Provider>
struct proxy_pool : public pool_interface<Provider> {
umf_memory_pool_ops_t *
const umf_memory_pool_ops_t *
getOps([[maybe_unused]] ::benchmark::State &state) override {
return umfProxyPoolOps();
}
Expand All @@ -264,7 +264,7 @@ struct proxy_pool : public pool_interface<Provider> {

template <typename Provider>
struct disjoint_pool : public pool_interface<Provider> {
umf_memory_pool_ops_t *
const umf_memory_pool_ops_t *
getOps([[maybe_unused]] ::benchmark::State &state) override {
return umfDisjointPoolOps();
}
Expand Down Expand Up @@ -319,7 +319,7 @@ struct disjoint_pool : public pool_interface<Provider> {
#ifdef UMF_POOL_JEMALLOC_ENABLED
template <typename Provider>
struct jemalloc_pool : public pool_interface<Provider> {
umf_memory_pool_ops_t *
const umf_memory_pool_ops_t *
getOps([[maybe_unused]] ::benchmark::State &state) override {
return umfJemallocPoolOps();
}
Expand All @@ -333,7 +333,7 @@ struct jemalloc_pool : public pool_interface<Provider> {
#ifdef UMF_POOL_SCALABLE_ENABLED
template <typename Provider>
struct scalable_pool : public pool_interface<Provider> {
umf_memory_pool_ops_t *
const umf_memory_pool_ops_t *
getOps([[maybe_unused]] ::benchmark::State &state) override {
return umfScalablePoolOps();
}
Expand Down
5 changes: 3 additions & 2 deletions benchmark/multithread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ struct bench_params {
size_t alloc_size = 64;
};

using poolCreateExtParams = std::tuple<umf_memory_pool_ops_t *, void *,
umf_memory_provider_ops_t *, void *>;
using poolCreateExtParams =
std::tuple<const umf_memory_pool_ops_t *, const void *,
const umf_memory_provider_ops_t *, const void *>;

static auto poolCreateExtUnique(poolCreateExtParams params) {
umf_memory_pool_handle_t hPool;
Expand Down
4 changes: 2 additions & 2 deletions examples/basic/basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ int main(void) {
// Allocations are made with mmap. The default values of params result
// in an mmap call like this:
// mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0)
umf_memory_provider_ops_t *provider_ops = umfOsMemoryProviderOps();
const umf_memory_provider_ops_t *provider_ops = umfOsMemoryProviderOps();
Copy link
Contributor

Choose a reason for hiding this comment

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

compat tests should fail here - I need to investigate this

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

/home/runner/work/unified-memory-framework/unified-memory-framework/tag_version/examples/basic/basic.c: In function ‘main’:
/home/runner/work/unified-memory-framework/unified-memory-framework/tag_version/examples/basic/basic.c:25:47: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
   25 |     umf_memory_provider_ops_t *provider_ops = umfOsMemoryProviderOps();
      |                                               ^~~~~~~~~~~~~~~~~~~~~~
/home/runner/work/unified-memory-framework/unified-memory-framework/tag_version/examples/basic/basic.c:72:39: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
   72 |     umf_memory_pool_ops_t *pool_ops = umfScalablePoolOps();
      |                                       ^~~~~~~~~~~~~~~~~~

umf_os_memory_provider_params_handle_t params = NULL;
umf_memory_provider_handle_t provider;

Expand Down Expand Up @@ -69,7 +69,7 @@ int main(void) {
printf("Freed memory at %p\n", ptr_provider);

// Create a memory pool
umf_memory_pool_ops_t *pool_ops = umfScalablePoolOps();
const umf_memory_pool_ops_t *pool_ops = umfScalablePoolOps();
void *pool_params = NULL;
umf_pool_create_flags_t flags = 0;
umf_memory_pool_handle_t pool;
Expand Down
8 changes: 4 additions & 4 deletions examples/custom_file_provider/custom_file_provider.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ typedef struct file_params_t {
} file_params_t;

// Function to initialize the file provider
static umf_result_t file_init(void *params, void **provider) {
static umf_result_t file_init(const void *params, void **provider) {
file_provider_t *file_provider = NULL;

if (params == NULL || provider == NULL) {
fprintf(stderr, "Params or provider cannot be null\n");
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
}

file_params_t *file_params = (file_params_t *)params;
const file_params_t *file_params = params;
int page_size = 0;
umf_result_t ret = UMF_RESULT_SUCCESS;

Expand Down Expand Up @@ -224,7 +224,7 @@ static umf_result_t file_get_recommended_page_size(void *provider, size_t size,
}

// Function to get the minimum page size of the file provider
static umf_result_t file_get_min_page_size(void *provider, void *ptr,
static umf_result_t file_get_min_page_size(void *provider, const void *ptr,
size_t *pageSize) {
(void)ptr; // Unused parameter
file_provider_t *file_provider = (file_provider_t *)provider;
Expand Down Expand Up @@ -291,7 +291,7 @@ int main(void) {
printf("Freed memory at %p\n", ptr_provider);

// Create a memory pool
umf_memory_pool_ops_t *pool_ops = umfScalablePoolOps();
const umf_memory_pool_ops_t *pool_ops = umfScalablePoolOps();
void *pool_params = NULL;
umf_pool_create_flags_t flags = 0;
umf_memory_pool_handle_t pool;
Expand Down
6 changes: 3 additions & 3 deletions include/umf/memory_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ typedef uint32_t umf_pool_create_flags_t;
/// @return UMF_RESULT_SUCCESS on success or appropriate error code on failure.
///
umf_result_t umfPoolCreate(const umf_memory_pool_ops_t *ops,
umf_memory_provider_handle_t provider, void *params,
umf_pool_create_flags_t flags,
umf_memory_provider_handle_t provider,
const void *params, umf_pool_create_flags_t flags,
umf_memory_pool_handle_t *hPool);

///
Expand Down Expand Up @@ -106,7 +106,7 @@ void *umfPoolRealloc(umf_memory_pool_handle_t hPool, void *ptr, size_t size);
/// @param ptr pointer to the allocated memory
/// @return size of the memory block allocated from the \p hPool
///
size_t umfPoolMallocUsableSize(umf_memory_pool_handle_t hPool, void *ptr);
size_t umfPoolMallocUsableSize(umf_memory_pool_handle_t hPool, const void *ptr);

///
/// @brief Frees the memory space of the specified \p hPool pointed by \p ptr
Expand Down
6 changes: 3 additions & 3 deletions include/umf/memory_pool_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extern "C" {
/// @brief Version of the Memory Pool ops structure.
/// NOTE: This is equal to the latest UMF version, in which the ops structure
/// has been modified.
#define UMF_POOL_OPS_VERSION_CURRENT UMF_MAKE_VERSION(0, 11)
#define UMF_POOL_OPS_VERSION_CURRENT UMF_MAKE_VERSION(0, 12)

///
/// @brief This structure comprises function pointers used by corresponding umfPool*
Expand All @@ -42,7 +42,7 @@ typedef struct umf_memory_pool_ops_t {
/// @return UMF_RESULT_SUCCESS on success or appropriate error code on failure.
///
umf_result_t (*initialize)(umf_memory_provider_handle_t provider,
void *params, void **pool);
const void *params, void **pool);

///
/// @brief Finalizes memory pool
Expand Down Expand Up @@ -94,7 +94,7 @@ typedef struct umf_memory_pool_ops_t {
/// @param ptr pointer to the allocated memory
/// @return size of the memory block allocated from the \p pool
///
size_t (*malloc_usable_size)(void *pool, void *ptr);
size_t (*malloc_usable_size)(void *pool, const void *ptr);

///
/// @brief Frees the memory space of the specified \p pool pointed by \p ptr
Expand Down
6 changes: 3 additions & 3 deletions include/umf/memory_provider.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (C) 2023-2024 Intel Corporation
* Copyright (C) 2023-2025 Intel Corporation
*
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Expand Down Expand Up @@ -45,7 +45,7 @@ typedef struct umf_memory_provider_t *umf_memory_provider_handle_t;
/// @return UMF_RESULT_SUCCESS on success or appropriate error code on failure.
///
umf_result_t umfMemoryProviderCreate(const umf_memory_provider_ops_t *ops,
void *params,
const void *params,
umf_memory_provider_handle_t *hProvider);

///
Expand Down Expand Up @@ -125,7 +125,7 @@ umfMemoryProviderGetRecommendedPageSize(umf_memory_provider_handle_t hProvider,
///
umf_result_t
umfMemoryProviderGetMinPageSize(umf_memory_provider_handle_t hProvider,
void *ptr, size_t *pageSize);
const void *ptr, size_t *pageSize);

///
/// @brief Discard physical pages within the virtual memory mapping associated at the given addr
Expand Down
6 changes: 3 additions & 3 deletions include/umf/memory_provider_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ extern "C" {
/// @brief Version of the Memory Provider ops structure.
/// NOTE: This is equal to the latest UMF version, in which the ops structure
/// has been modified.
#define UMF_PROVIDER_OPS_VERSION_CURRENT UMF_MAKE_VERSION(0, 11)
#define UMF_PROVIDER_OPS_VERSION_CURRENT UMF_MAKE_VERSION(0, 12)

///
/// @brief This structure comprises optional function pointers used
Expand Down Expand Up @@ -156,7 +156,7 @@ typedef struct umf_memory_provider_ops_t {
/// @param provider returns pointer to the provider
/// @return UMF_RESULT_SUCCESS on success or appropriate error code on failure.
///
umf_result_t (*initialize)(void *params, void **provider);
umf_result_t (*initialize)(const void *params, void **provider);

///
/// @brief Finalizes memory provider.
Expand Down Expand Up @@ -230,7 +230,7 @@ typedef struct umf_memory_provider_ops_t {
/// @param pageSize [out] pointer to the minimum possible page size
/// @return UMF_RESULT_SUCCESS on success or appropriate error code on failure.
///
umf_result_t (*get_min_page_size)(void *provider, void *ptr,
umf_result_t (*get_min_page_size)(void *provider, const void *ptr,
size_t *pageSize);

///
Expand Down
2 changes: 1 addition & 1 deletion include/umf/pools/pool_disjoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ umf_result_t
umfDisjointPoolParamsSetName(umf_disjoint_pool_params_handle_t hParams,
const char *name);

umf_memory_pool_ops_t *umfDisjointPoolOps(void);
const umf_memory_pool_ops_t *umfDisjointPoolOps(void);

#ifdef __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion include/umf/pools/pool_jemalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ umf_result_t
umfJemallocPoolParamsSetNumArenas(umf_jemalloc_pool_params_handle_t hParams,
size_t numArenas);

umf_memory_pool_ops_t *umfJemallocPoolOps(void);
const umf_memory_pool_ops_t *umfJemallocPoolOps(void);

#ifdef __cplusplus
}
Expand Down
4 changes: 2 additions & 2 deletions include/umf/pools/pool_proxy.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (C) 2024 Intel Corporation
* Copyright (C) 2024-2025 Intel Corporation
*
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Expand All @@ -18,7 +18,7 @@
extern "C" {
#endif

umf_memory_pool_ops_t *umfProxyPoolOps(void);
const umf_memory_pool_ops_t *umfProxyPoolOps(void);

#ifdef __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion include/umf/pools/pool_scalable.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ umfScalablePoolParamsSetKeepAllMemory(umf_scalable_pool_params_handle_t hParams,

/// @brief Return \p ops structure containing pointers to the scalable pool implementation.
/// @return pointer to the \p umf_memory_pool_ops_t struct.
umf_memory_pool_ops_t *umfScalablePoolOps(void);
const umf_memory_pool_ops_t *umfScalablePoolOps(void);

#ifdef __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion include/umf/providers/provider_cuda.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ umf_result_t umfCUDAMemoryProviderParamsSetMemoryType(
umf_result_t umfCUDAMemoryProviderParamsSetAllocFlags(
umf_cuda_memory_provider_params_handle_t hParams, unsigned int flags);

umf_memory_provider_ops_t *umfCUDAMemoryProviderOps(void);
const umf_memory_provider_ops_t *umfCUDAMemoryProviderOps(void);

#ifdef __cplusplus
}
Expand Down
4 changes: 2 additions & 2 deletions include/umf/providers/provider_devdax_memory.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2024 Intel Corporation
* Copyright (C) 2024-2025 Intel Corporation
*
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Expand Down Expand Up @@ -65,7 +65,7 @@ typedef enum umf_devdax_memory_provider_native_error {
UMF_DEVDAX_RESULT_ERROR_PURGE_FORCE_FAILED, ///< Force purging failed
} umf_devdax_memory_provider_native_error_t;

umf_memory_provider_ops_t *umfDevDaxMemoryProviderOps(void);
const umf_memory_provider_ops_t *umfDevDaxMemoryProviderOps(void);

#ifdef __cplusplus
}
Expand Down
4 changes: 2 additions & 2 deletions include/umf/providers/provider_file_memory.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2024 Intel Corporation
* Copyright (C) 2024-2025 Intel Corporation
*
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Expand Down Expand Up @@ -66,7 +66,7 @@ typedef enum umf_file_memory_provider_native_error {
UMF_FILE_RESULT_ERROR_PURGE_FORCE_FAILED, ///< Force purging failed
} umf_file_memory_provider_native_error_t;

umf_memory_provider_ops_t *umfFileMemoryProviderOps(void);
const umf_memory_provider_ops_t *umfFileMemoryProviderOps(void);

#ifdef __cplusplus
}
Expand Down
4 changes: 2 additions & 2 deletions include/umf/providers/provider_fixed_memory.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2024 Intel Corporation
* Copyright (C) 2024-2025 Intel Corporation
*
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Expand Down Expand Up @@ -49,7 +49,7 @@ umf_result_t umfFixedMemoryProviderParamsDestroy(

/// @brief Retrieve the operations structure for the Fixed Memory Provider.
/// @return Pointer to the umf_memory_provider_ops_t structure.
umf_memory_provider_ops_t *umfFixedMemoryProviderOps(void);
const umf_memory_provider_ops_t *umfFixedMemoryProviderOps(void);

/// @brief Fixed Memory Provider operation results
typedef enum umf_fixed_memory_provider_native_error {
Expand Down
2 changes: 1 addition & 1 deletion include/umf/providers/provider_level_zero.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ umf_result_t umfLevelZeroMemoryProviderParamsSetDeviceOrdinal(
umf_level_zero_memory_provider_params_handle_t hParams,
uint32_t deviceOrdinal);

umf_memory_provider_ops_t *umfLevelZeroMemoryProviderOps(void);
const umf_memory_provider_ops_t *umfLevelZeroMemoryProviderOps(void);

#ifdef __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion include/umf/providers/provider_os_memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ typedef enum umf_os_memory_provider_native_error {
UMF_OS_RESULT_ERROR_TOPO_DISCOVERY_FAILED, ///< HWLOC topology discovery failed
} umf_os_memory_provider_native_error_t;

umf_memory_provider_ops_t *umfOsMemoryProviderOps(void);
const umf_memory_provider_ops_t *umfOsMemoryProviderOps(void);

#ifdef __cplusplus
}
Expand Down
4 changes: 2 additions & 2 deletions src/base_alloc/base_alloc_global.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ static void *add_metadata_and_align(void *ptr, size_t size, size_t alignment) {
// return original ptr (the one that has been passed to add_metadata_and_align)
// along with total allocation size (needed to find proper alloc class
// in free) and usable size
static void *get_original_alloc(void *user_ptr, size_t *total_size,
static void *get_original_alloc(const void *user_ptr, size_t *total_size,
size_t *usable_size) {
assert(user_ptr);

Expand Down Expand Up @@ -233,7 +233,7 @@ void umf_ba_global_free(void *ptr) {
umf_ba_free(BASE_ALLOC.ac[ac_index], ptr);
}

size_t umf_ba_global_malloc_usable_size(void *ptr) {
size_t umf_ba_global_malloc_usable_size(const void *ptr) {
if (!ptr) {
return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions src/base_alloc/base_alloc_global.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2024 Intel Corporation
* Copyright (C) 2024-2025 Intel Corporation
*
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Expand All @@ -20,7 +20,7 @@ void *umf_ba_global_alloc(size_t size);
void umf_ba_global_free(void *ptr);
void umf_ba_destroy_global(void);
bool umf_ba_global_is_destroyed(void);
size_t umf_ba_global_malloc_usable_size(void *ptr);
size_t umf_ba_global_malloc_usable_size(const void *ptr);
void *umf_ba_global_aligned_alloc(size_t size, size_t alignment);

#ifdef __cplusplus
Expand Down
Loading
Loading