Skip to content

[SYCL] Support for pooled small allocations. #5438

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 32 commits into from
May 6, 2022
Merged

Conversation

rdeodhar
Copy link
Contributor

@rdeodhar rdeodhar commented Jan 31, 2022

This change enables pooling of USM slabs used for small allocations, i.e. < 32KB. These slabs are used in chunked mode, that is, divided into chunks, and each chunk used for an individual user allocation.

Previously, when all the individual allocations in a chunked slab were freed by the program, the slab was freed from USM. We no longer do that. We retain that slab for future use, in effect, pooling it.

Signed-off-by: Rajiv Deodhar rajiv.deodhar@intel.com

@rdeodhar rdeodhar changed the title [SYCL] Support for pooled small allocations and updated parameters. [SYCL] Support for pooled small allocations. Feb 25, 2022
@rdeodhar rdeodhar marked this pull request as ready for review March 9, 2022 00:16
@rdeodhar rdeodhar requested a review from a team as a code owner March 9, 2022 00:16
@rdeodhar rdeodhar requested a review from asudarsa March 9, 2022 00:16
@asudarsa
Copy link
Contributor

asudarsa commented Mar 9, 2022

Hi Rajiv,

Another nitpick. I was wondering why definition of class Bucket is not in the header file.

Thanks

@rdeodhar
Copy link
Contributor Author

rdeodhar commented Mar 9, 2022

Hi Rajiv,

Another nitpick. I was wondering why definition of class Bucket is not in the header file.

Thanks

The entire implementation of pooling is in the .cpp file. The usm_allocator.hpp header is only the external interface of pooling from the pi_level_zero files.

@asudarsa
Copy link
Contributor

Changes look good. Can you please comment on adding a test for this? Thanks

@rdeodhar
Copy link
Contributor Author

The existing test usm_pooling.cpp will be extended to account for the feature added in this PR.

@rdeodhar
Copy link
Contributor Author

/verify with intel/llvm-test-suite#980

@rdeodhar
Copy link
Contributor Author

/verify with intel/llvm-test-suite#980

@rdeodhar
Copy link
Contributor Author

/verify with intel/llvm-test-suite#980

@rdeodhar
Copy link
Contributor Author

/verify with intel/llvm-test-suite#980

@rdeodhar
Copy link
Contributor Author

/verify with intel/llvm-test-suite#980

@rdeodhar rdeodhar requested a review from smaslov-intel April 27, 2022 17:35
@rdeodhar
Copy link
Contributor Author

rdeodhar commented May 3, 2022

/verify with intel/llvm-test-suite#980

@rdeodhar
Copy link
Contributor Author

rdeodhar commented May 3, 2022

/verify with intel/llvm-test-suite#980

@rdeodhar
Copy link
Contributor Author

rdeodhar commented May 3, 2022

/verify with intel/llvm-test-suite#980

Comment on lines +839 to +842
if (chunkedBucket)
NewFreeSlabsInBucket = chunkedSlabsInPool + 1;
else
NewFreeSlabsInBucket = AvailableSlabs.size() + 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be simpler to maintain "chunked" slabs in a separate list, i.e. break the AvailableSlabs into 2?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know if it would be simpler, but there could be alternative approaches such as adding a third type of list, in effect breaking the AvailableSlabs list into two, with different meaning.
I also tried layering the slab types, to make chunked slabs a specialization of full slabs.

However, the approach implemented here required the least change.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, let's go with what we have ready, and only consider a re-design when we need to changes something again.

smaslov-intel
smaslov-intel previously approved these changes May 3, 2022
@rdeodhar
Copy link
Contributor Author

rdeodhar commented May 4, 2022

/verify with intel/llvm-test-suite#980

@againull againull merged commit 6244efe into intel:sycl May 6, 2022
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.

4 participants