-
Notifications
You must be signed in to change notification settings - Fork 50
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
Adding strong type assertions to AoSoA #203
Conversation
2cef5fe
to
5c4bf3f
Compare
Per our conversation, LGTM. A few additional notes:
|
Codecov Report
@@ Coverage Diff @@
## master #203 +/- ##
======================================
Coverage 47.6% 47.6%
======================================
Files 25 25
Lines 2692 2692
======================================
Hits 1283 1283
Misses 1409 1409
Continue to review full report at Codecov.
|
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.
Per our conversation, LGTM.
The one possible exception that comes to mind is "fundamental" float or double, which of course is an eternally sore subject as evidenced by every library ever having their own. Playing devil's advocate on myself: It also has the trivial workaround of using a There could also be an argument against even that for CPU side codes---someone with more CPU vectorization experience should comment, or with Kokkos kernels complex (I think it's there?) may be able to shed some light. I know that with the correct |
Part of the issue here is how we are computing strides between |
@sslattery sorry, I had a big typo there, I look like an idiot right now. I meant a "fundamental" complex float or double. |
That said, that doesn't fundamentally change the point you're making. |
//---------------------------------------------------------------------------// | ||
/*! | ||
\class CheckMemberTypes | ||
\brief Check that member types are valied. |
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.
s/valied/valid/
Also from that description I cannot tell how this differs from is_member_type
|
||
using value_type = typename std::remove_all_extents<type>::type; | ||
static_assert( std::is_arithmetic<value_type>::value, | ||
"Member value types must be arithmetic" ); |
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.
Only built-in types will have a specialization of is_arithmetic
with a value that is true
and all are trivial as far as I know.
A user tried to use their own class in an
AoSoA
which violated the design structure. Astatic_assert
was thrown but it wasn't clear why the user's class was invalid. This PR adds stronger checks. We assert types must be both trivial and fundamental allowing us to do a lot of compile-time work. This prevents users from using their own classes directly asAoSoA
members although I would argue that theAoSoA
andTuple
was intended to replace the user's particle classes with primitive data.We are still working to identify if there are valid performance-based use cases for allowing users to use their own classes within
AoSoA
but for now this makes our restrictions more clear and obvious. For example:will now fail to compile as:
Which clearly indicates that the
MyObject
class is not valid.