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

[DRAFT] Implement IPC API of the Coarse provider #907

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

ldorau
Copy link
Contributor

@ldorau ldorau commented Nov 18, 2024

Description

Implement IPC API of the Coarse provider.

Split and merge in Coarse provider to enable IPC API.
Coarse provider should always call:

  • umfMemoryProviderAllocationSplit(upstream_provider) or
  • umfMemoryProviderAllocationMerge(upstream_provider)

when splitting or merging memory blocks, because the IPC API would not work on split/merged memory blocks otherwise.

Fixes: #900

Checklist

  • Code compiles without errors locally
  • All tests pass locally
  • CI workflows execute properly

@ldorau ldorau requested a review from a team as a code owner November 18, 2024 12:19
@ldorau ldorau force-pushed the Implement_IPC_API_of_the_Coarse_provider branch from 0a806a3 to a4646f7 Compare November 18, 2024 13:30
@ldorau ldorau force-pushed the Implement_IPC_API_of_the_Coarse_provider branch from a4646f7 to 40e3160 Compare November 18, 2024 17:25
@bratpiorka
Copy link
Contributor

please add the following test:

  • use Proxy Pool, Coarse Provider and L0 Provider
  • alloc 4KB, free it - this way L0 should allocate single 4KB buffer that should be kept inside the Coarse Provider
  • alloc 2KB twice - Coarse Prov should call split
  • open IPC handle on both allocations

Copy link
Contributor

@lplewa lplewa left a comment

Choose a reason for hiding this comment

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

This PR will not work with L0/Cuda providers as they do not (and probably will not) have split/merge functionality.

Not sure how we should solve this issue. Tracking provider all ready has this functionality on the pool level . We could copy it to coarse provider - but is this HORRIBLE idea (code duplication and performance implications).

Performance is something which should also consider. We have too much trackers, list, and trees. I'm currently working on benchmark those, but still in my opinion, we should try to limit those to absolute minimum. When at each level we have minimum one extra data structure with non constant time complexity of inserts or delete.

For now i would recommend to make this PR a draft, and have good architectural discussion about this issue.

@vinser52
Copy link
Contributor

This PR will not work with L0/Cuda providers as they do not (and probably will not) have split/merge functionality.

Not sure how we should solve this issue. Tracking provider all ready has this functionality on the pool level . We could copy it to coarse provider - but is this HORRIBLE idea (code duplication and performance implications).

Performance is something which should also consider. We have too much trackers, list, and trees. I'm currently working on benchmark those, but still in my opinion, we should try to limit those to absolute minimum. When at each level we have minimum one extra data structure with non constant time complexity of inserts or delete.

For now i would recommend to make this PR a draft, and have good architectural discussion about this issue.

I totally agree with @lplewa. In fact, the coarse provider implements memory pooling logic, but it is implemented as a provider and used inside UMF stack as a provider. As a result, it resides below our memory tracker, because tracking provider is always on the top (between the pool manager and memory providers). I agree that we need an architecture discussion current implementation experience shows that current approach has issues.

@ldorau
Copy link
Contributor Author

ldorau commented Nov 19, 2024

please add the following test:

  • use Proxy Pool, Coarse Provider and L0 Provider
  • alloc 4KB, free it - this way L0 should allocate single 4KB buffer that should be kept inside the Coarse Provider
  • alloc 2KB twice - Coarse Prov should call split
  • open IPC handle on both allocations

ze_memory_provider_allocation_split() is NOT_SUPPORTED yet :-(

static umf_result_t ze_memory_provider_allocation_split(void *provider,
                                                        void *ptr,
                                                        size_t totalSize,
                                                        size_t firstSize) {
    (void)provider;
    (void)ptr;
    (void)totalSize;
    (void)firstSize;

    // TODO not supported yet
    return UMF_RESULT_ERROR_NOT_SUPPORTED;
}

I added such test for the file provider.

@ldorau ldorau marked this pull request as draft November 19, 2024 12:10
@ldorau ldorau changed the title Implement IPC API of the Coarse provider [DRAFT] Implement IPC API of the Coarse provider Nov 19, 2024
Coarse provider has to always call:
- umfMemoryProviderAllocationSplit(upstream_provider) or
- umfMemoryProviderAllocationMerge(upstream_provider)
when splitting or merging memory blocks,
because the IPC API would not work on split/merged memory
blocks otherwise.

Signed-off-by: Lukasz Dorau <[email protected]>
@ldorau ldorau force-pushed the Implement_IPC_API_of_the_Coarse_provider branch 2 times, most recently from d6d3337 to 2ac56a1 Compare November 21, 2024 08:22
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.

IPC API is not implemented in the Coarse provider
4 participants