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

AoS will be aligned and SoA will be multiblob by default #312

Merged
merged 1 commit into from
Jun 30, 2021

Conversation

bernhardmgruber
Copy link
Member

This PR changes the defaults for AoS and SoA to align better with user expectations:

AoS will use alignment and padding by default. This is how native structs in C++ behave.
SoA will use multible blobs by default. This is how SoA is usually implemented. It is sometimes also more efficient.

@bernhardmgruber bernhardmgruber force-pushed the defaults branch 3 times, most recently from f5c1af6 to 5cca014 Compare June 29, 2021 13:14
Copy link
Member

@j-stephan j-stephan left a comment

Choose a reason for hiding this comment

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

Looks like a reasonable change. One comment:

@@ -162,7 +162,7 @@ struct UpdateKernel
if constexpr (MappingSM == AoS)
return llama::mapping::AoS{arrayDims, Particle{}};
if constexpr (MappingSM == SoA)
return llama::mapping::SoA{arrayDims, Particle{}};
return llama::mapping::SoA<decltype(arrayDims), Particle, false>{arrayDims};
Copy link
Member

Choose a reason for hiding this comment

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

It feels weird that we require the <> for SoA and AoSoA, but not for AoS.

Copy link
Member Author

Choose a reason for hiding this comment

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

The story is more complicated. The angle bracket interface is actually the default, AoS<decltype(arrayDims), Particle>{arrayDims} is what you would write normally. Notice that the arrayDims are repeated twice, with is not great. Ideally, we could deduce the type of arrayDims for AoS. This is possible using Constructor Template Argument Deduction (CTAD). However, then we need to be able to deduce all template parameters of AoS. So I added an unused argument for the record dim to AoS, so you can write: AoS{arrayDims, Particle{}};, allowing the template arguments for both array and record dimensions to be deduced. However, that feature immediately fails in case we want to have more complicated constructurs.

The longer discussion is here: #167. Feel free to leave a comment here!

@bernhardmgruber bernhardmgruber merged commit e1dfd94 into alpaka-group:develop Jun 30, 2021
@bernhardmgruber bernhardmgruber deleted the defaults branch June 30, 2021 22:35
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.

2 participants