-
Notifications
You must be signed in to change notification settings - Fork 35
add mempolicy with support of interleave, bind and preferred #500
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* | ||
* Copyright (C) 2024 Intel Corporation | ||
* | ||
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. | ||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
* | ||
*/ | ||
|
||
#ifndef UMF_MEMPOLICY_H | ||
#define UMF_MEMPOLICY_H 1 | ||
|
||
#include <umf/base.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
typedef struct umf_mempolicy_t *umf_mempolicy_handle_t; | ||
typedef const struct umf_mempolicy_t *umf_const_mempolicy_handle_t; | ||
|
||
typedef enum umf_mempolicy_membind_t { | ||
/// Interleave memory from all memory in memspace | ||
UMF_MEMPOLICY_INTERLEAVE, | ||
/// Bind memory to namespace | ||
UMF_MEMPOLICY_BIND, | ||
/// Prefer memory from namespace but fallback to other memory if not available | ||
UMF_MEMPOLICY_PREFERRED | ||
} umf_mempolicy_membind_t; | ||
|
||
/// | ||
/// @brief Creates a new memory policy | ||
/// @param bind memory binding policy | ||
/// @param hPolicy [out] handle to the newly created memory policy | ||
/// @return UMF_RESULT_SUCCESS on success or appropriate error code on failure. | ||
/// | ||
umf_result_t umfMempolicyCreate(umf_mempolicy_membind_t bind, | ||
umf_mempolicy_handle_t *hPolicy); | ||
|
||
/// | ||
/// @brief Destroys memory policy | ||
/// @param hPolicy handle to memory policy | ||
/// @return UMF_RESULT_SUCCESS on success or appropriate error code on failure. | ||
/// | ||
umf_result_t umfMempolicyDestroy(umf_mempolicy_handle_t hPolicy); | ||
|
||
/// | ||
/// @brief Sets custom part size for interleaved memory policy - by default it's interleaved by pages | ||
/// @param hPolicy handle to memory policy | ||
/// @param partSize size of the part or zero to use default part size (page size) | ||
/// @return UMF_RESULT_SUCCESS on success or appropriate error code on failure. | ||
/// | ||
umf_result_t umfMempolicySetInterleavePartSize(umf_mempolicy_handle_t hPolicy, | ||
size_t partSize); | ||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* UMF_MEMPOLICY_H */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* | ||
* Copyright (C) 2024 Intel Corporation | ||
* | ||
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. | ||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
* | ||
*/ | ||
#include <umf/mempolicy.h> | ||
|
||
#include "base_alloc_global.h" | ||
#include "mempolicy_internal.h" | ||
|
||
umf_result_t umfMempolicyCreate(umf_mempolicy_membind_t bind, | ||
umf_mempolicy_handle_t *policy) { | ||
if (policy == NULL) { | ||
return UMF_RESULT_ERROR_INVALID_ARGUMENT; | ||
} | ||
|
||
*policy = umf_ba_global_alloc(sizeof(**policy)); | ||
|
||
if (*policy == NULL) { | ||
return UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY; | ||
} | ||
|
||
(*policy)->type = bind; | ||
if (bind == UMF_MEMPOLICY_INTERLEAVE) { | ||
(*policy)->ops.part_size = 0; | ||
} | ||
return UMF_RESULT_SUCCESS; | ||
} | ||
|
||
umf_result_t umfMempolicyDestroy(umf_mempolicy_handle_t policy) { | ||
umf_ba_global_free(policy); | ||
return UMF_RESULT_SUCCESS; | ||
} | ||
|
||
umf_result_t umfMempolicySetInterleavePartSize(umf_mempolicy_handle_t policy, | ||
size_t partSize) { | ||
if (policy == NULL) { | ||
return UMF_RESULT_ERROR_INVALID_ARGUMENT; | ||
} | ||
|
||
if (policy->type != UMF_MEMPOLICY_INTERLEAVE) { | ||
return UMF_RESULT_ERROR_INVALID_ARGUMENT; | ||
} | ||
|
||
policy->ops.part_size = partSize; | ||
return UMF_RESULT_SUCCESS; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* | ||
* Copyright (C) 2024 Intel Corporation | ||
* | ||
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. | ||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
* | ||
*/ | ||
|
||
#ifndef UMF_MEMPOLICY_INTERNAL_H | ||
#define UMF_MEMPOLICY_INTERNAL_H 1 | ||
|
||
#include <umf/mempolicy.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
typedef struct umf_mempolicy_t { | ||
umf_mempolicy_membind_t type; | ||
union { | ||
size_t part_size; | ||
} ops; | ||
} umf_mempolicy_t; | ||
|
||
typedef const umf_mempolicy_t umf_const_mempolicy_t; | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* UMF_MEMPOLICY_INTERNAL_H */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.