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

MDRangePolicy has no API to obtain the default tile size #6609

Open
biergaizi opened this issue Nov 18, 2023 · 6 comments
Open

MDRangePolicy has no API to obtain the default tile size #6609

biergaizi opened this issue Nov 18, 2023 · 6 comments
Assignees
Labels
Feature Request Create new capability; will potentially require voting Question For Kokkos internal and external contributors and users

Comments

@biergaizi
Copy link

I have parallelized a loop with Kokkos that iterates across 3D space using an MDRangePolicy with rank 3, and I want to investigate the performance impact of different tile sizes. Unfortunately, according to the documentation, MDRangePolicy has no public API to query the default tile sizes, so the default decision by Kokkos is a mystery to users. I've tried to manually specify various tile sizes, none of the sizes I've guessed is as fast as the unknown one used picked by Kokkos, so knowing the values is of great practical significance.

MDRangePolicy should provide a public API to expose this runtime setting, similar to chunk_size() or team_size_recommended() in TeamPolicy.

@masterleinad
Copy link
Contributor

Note that m_tile is public as of now (which we might change).

@biergaizi
Copy link
Author

biergaizi commented Nov 19, 2023

Note that m_tile is public as of now (which we might change).

Interesting, thanks for the hint. I'll use m_tile for debugging purpose for now.

@biergaizi
Copy link
Author

biergaizi commented Nov 20, 2023

In case anyone's wondering, I've solved my original question that motivated the creation of this issue: understanding the default behaviors of Kokkos.

Right now under most situations, MDRangePolicy's default tiling has a size of 2, with the exception of the last dimension (or stride-1 dimension), which is used in full. Thus, a 100x100x100 index space would usually be tiled by default as 2x2x100. This is consistent with the common programmer experience that 2D loop tiling in 3D space is faster than 3D loop tiling in 3D space since the last loop dimension consists of stride-1 streaming accesses. This practice is sometimes known as "2.5D tiling" in research papers.

Storing the array in a tiled format can reduce the 3D tiling overhead if its use is preferred. Right now Kokkos offers LayoutTiled but it only supports static tile sizes, not dynamic ones.

@ajpowelsnl ajpowelsnl added the Question For Kokkos internal and external contributors and users label Nov 20, 2023
@ajpowelsnl
Copy link
Contributor

@biergaizi - have we been able to answer your questions, and provide the help you need?

@biergaizi
Copy link
Author

It solved my personal problem but I don't think it has solved this Kokkos problem. There's still no public API to obtain the default tile size, so this is at best a workaround and there's still no "legal" way to do it.

@crtrott
Copy link
Member

crtrott commented Jan 22, 2024

Yeah, we actually probably need a max tile size as well. Possibly this needs to follow the TeamPolicy pattern of recommended and max team_size. I am putting this on our to-do list.

@crtrott crtrott added the Feature Request Create new capability; will potentially require voting label Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request Create new capability; will potentially require voting Question For Kokkos internal and external contributors and users
Projects
None yet
Development

No branches or pull requests

5 participants