-
Notifications
You must be signed in to change notification settings - Fork 10
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
Align and minimize One #323
Align and minimize One #323
Conversation
9f89ec5
to
ab5f02e
Compare
@@ -94,17 +136,19 @@ namespace llama | |||
{ | |||
Array<T, N + 1> r{}; | |||
r[0] = v; | |||
for (auto i = 0; i < N; i++) | |||
r[i + 1] = a[i]; | |||
if constexpr (N > 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably want some curly braces behind the if
. I think some compilers even warn about this. Also in the other instances if you change this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a stylistic question, which I strongly oppose. I know the argument that adding braces could avoid accidentially misindenting a statement, believing it belongs to the if
statement. However, clang actually detects such misalignment. Furthermore, our code base is clang-formatted so we would immediately notice. So the only thing braces add here is an extra LOC, spreading the code a little vertically. And I prefer to the code to be compact. I also know clang-tidy can add these braces automatically, so at some point we will have the vote and then we can see what happens :)
ab5f02e
to
42960a3
Compare
/// minimize this padding. | ||
/// \see One | ||
template <typename ArrayDims, typename RecordDim> | ||
using MinAlignedOne = One<ArrayDims, RecordDim, true, FlattenRecordDimMinimizePadding>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is One<ArrayDims, RecordDim, false, FlattenRecordDimMinimizePadding>
missing on purpose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is a valid mapping, but I do not see the use case. One<..., true, ...>
adds padding to respect alignment, so adding field permutations make sense, to play with this padding.
One<..., false, ...>
does not add padding, so permuting the fields has a far smaller effect. So I want to advertise it less.
42960a3
to
3f2f981
Compare
3f2f981
to
20ed3c0
Compare
Fixes #267.