Skip to content
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

Examples to use both FSDAX permanent memory and normal DRAM #742

Closed
jesHrz opened this issue Sep 19, 2024 · 8 comments
Closed

Examples to use both FSDAX permanent memory and normal DRAM #742

jesHrz opened this issue Sep 19, 2024 · 8 comments
Labels
question Further information is requested

Comments

@jesHrz
Copy link

jesHrz commented Sep 19, 2024

Details

I'd like to use a hybrid memory pool simultaneously, where I allocate memory either from permanent memory from the FSDAX device or the normal DRAM from anonymous mapping.

I found that libmemkind meets my requirement because I can specify the different allocator via struct memkind in memkind_malloc.
Unfortunately, libmemkind is deprecated now...

I am wondering if I could find the same usage example from UMF as libmemkind does?

@jesHrz jesHrz added the question Further information is requested label Sep 19, 2024
@vinser52
Copy link
Contributor

Hi @jesHrz,

UMF is positioned as a replacement for Memkind. While UMF does not provide 1:1 API matching it is targeted to support Memkind use cases.

Could you please describe your use case precisely? What do you mean by “use a hybrid memory pool simultaneously”?

@jesHrz
Copy link
Author

jesHrz commented Sep 19, 2024

Hi @jesHrz,

UMF is positioned as a replacement for Memkind. While UMF does not provide 1:1 API matching it is targeted to support Memkind use cases.

Could you please describe your use case precisely? What do you mean by “use a hybrid memory pool simultaneously”?

Thanks a lot.

Actually, the hybrid memory pool means some objects are allocated from the DRAM and some objects are allocated from the PM.

Here is a simple example for my use case.

void *allocate_from_pm(size_t size)
{
    // allocate from persistent memory via UMF
}

void *allocate_from_dram(size_t size)
{
    // allocate from DRAM via UMF
}

int main() {
    int N = 100, M = 200;
    int *array_a = (int *)allocate_from_dram(sizeof(int) * N);
    int *array_b = (int *)allocate_from_pm(sizeof(int) * M);
    
    // access array_a and array_b

    free(array_a);
    free(array_b);
}

@ldorau
Copy link
Contributor

ldorau commented Sep 23, 2024

Hi @jesHrz, I have just added to UMF the support for FSDAX (#746). In order to handle FSDAX, the file memory provider with the memory visibility mode parameter set to UMF_MEM_MAP_SYNC must be used. I am currently working on the example using both FSDAX permanent memory and normal DRAM, as you need. I will keep you updated. Please stay tuned.

@ldorau ldorau mentioned this issue Sep 24, 2024
3 tasks
ldorau added a commit to ldorau/unified-memory-framework that referenced this issue Sep 24, 2024
ldorau added a commit to ldorau/unified-memory-framework that referenced this issue Sep 24, 2024
ldorau added a commit to ldorau/unified-memory-framework that referenced this issue Sep 24, 2024
ldorau added a commit to ldorau/unified-memory-framework that referenced this issue Sep 24, 2024
ldorau added a commit to ldorau/unified-memory-framework that referenced this issue Sep 25, 2024
ldorau added a commit to ldorau/unified-memory-framework that referenced this issue Sep 25, 2024
ldorau added a commit to ldorau/unified-memory-framework that referenced this issue Sep 25, 2024
ldorau added a commit to ldorau/unified-memory-framework that referenced this issue Sep 25, 2024
ldorau added a commit to ldorau/unified-memory-framework that referenced this issue Sep 25, 2024
@ldorau
Copy link
Contributor

ldorau commented Sep 25, 2024

I have submitted the PR #750 with this example.

@jesHrz
Copy link
Author

jesHrz commented Sep 25, 2024

Hi @ldorau , much thanks for your effort!

BTW, I also want to know if UMF can automatically detect which pool a pointer is allocated from. since memkind can free a pointer with an unknown kind (memkind_free(NULL, ptr)).

@ldorau
Copy link
Contributor

ldorau commented Sep 25, 2024

Hi @ldorau , much thanks for your effort!

BTW, I also want to know if UMF can automatically detect which pool a pointer is allocated from. since memkind can free a pointer with an unknown kind (memkind_free(NULL, ptr)).

Yes, there is the function:

///
/// @brief Retrieve memory pool associated with a given ptr. Only memory allocated
///        with the usage of a memory provider is being tracked.
/// @param ptr pointer to memory belonging to a memory pool
/// @return Handle to a memory pool that contains ptr or NULL if pointer does not belong to any UMF pool.
///
umf_memory_pool_handle_t umfPoolByPtr(const void *ptr);

@jesHrz
Copy link
Author

jesHrz commented Sep 25, 2024

It is actually what I want, thanks!

@jesHrz jesHrz closed this as completed Sep 25, 2024
ldorau added a commit to ldorau/unified-memory-framework that referenced this issue Sep 25, 2024
ldorau added a commit to ldorau/unified-memory-framework that referenced this issue Sep 26, 2024
@ldorau
Copy link
Contributor

ldorau commented Sep 30, 2024

Hi @jesHrz, the "Add dram_and_fsdax example" #750 has already been merged upstream.

@jesHrz jesHrz reopened this Oct 6, 2024
@jesHrz jesHrz closed this as completed Oct 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants