-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Extended documentation and tests for SoA methods #49671
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
Conversation
|
cms-bot internal usage |
|
type ngt |
|
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-49671/47223 |
|
A new Pull Request was created by @Electricks94 for master. It involves the following packages:
@cmsbuild, @fwyzard, @makortel can you please review it and eventually sign? Thanks. cms-bot commands are listed here |
|
ping |
|
@cmsbuild, please test |
|
+1 Size: This PR adds an extra 16KB to repository Comparison SummarySummary:
|
| GENERATE_SOA_LAYOUT(SoATemplate, | ||
| SOA_COLUMN(float, x), | ||
| SOA_COLUMN(float, y), | ||
| SOA_COLUMN(float, z), | ||
| SOA_COLUMN(double, v_x), | ||
| SOA_COLUMN(double, v_y), | ||
| SOA_COLUMN(double, v_z), | ||
|
|
||
| SOA_ELEMENT_METHODS( | ||
|
|
||
| SOA_HOST_DEVICE void normalise() { | ||
| float norm_position = square_norm_position(); | ||
| if (norm_position > 0.0f) { | ||
| x() /= norm_position; | ||
| y() /= norm_position; | ||
| z() /= norm_position; | ||
| }; | ||
| double norm_velocity = square_norm_velocity(); | ||
| if (norm_velocity > 0.0f) { | ||
| v_x() /= norm_velocity; | ||
| v_y() /= norm_velocity; | ||
| v_z() /= norm_velocity; | ||
| }; | ||
| }), | ||
|
|
||
| SOA_CONST_ELEMENT_METHODS( | ||
| SOA_HOST_DEVICE float square_norm_position() | ||
| const { return sqrt(x() * x() + y() * y() + z() * z()); }; | ||
|
|
||
| SOA_HOST_DEVICE double square_norm_velocity() | ||
| const { return sqrt(v_x() * v_x() + v_y() * v_y() + v_z() * v_z()); }; | ||
|
|
||
| template <typename T1, typename T2> | ||
| SOA_HOST_DEVICE static auto time(T1 pos, T2 vel) { | ||
| if (!(vel == 0)) | ||
| return pos / vel; | ||
| return 0.; | ||
| }), | ||
|
|
||
| SOA_SCALAR(int, detectorType)) | ||
|
|
||
| using SoA = SoATemplate<>; | ||
| using SoAView = SoA::View; | ||
| using SoAConstView = SoA::ConstView; |
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.
Can you move the SoA to a separate header file, and reuse it for all tests (CPU, CUDA, ROCm, and alpaka) ?
| <bin file="SoACustomizedMethods_t.cu" name="SoACustomizedMethodsCuda"> | ||
| <use name="boost"/> | ||
| <use name="catch2"/> | ||
| <use name="cuda"/> | ||
| <use name="DataFormats/SoATemplate"/> | ||
| </bin> |
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.
This should be wrapped in a <iftool name="cuda"> block.
| <bin file="SoACustomizedMethods_t.hip.cc" name="SoACustomizedMethodsHip"> | ||
| <use name="boost"/> | ||
| <use name="catch2"/> | ||
| <use name="rocm"/> | ||
| <use name="DataFormats/SoATemplate"/> | ||
| </bin> |
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.
This should be wrapped in a <iftool name="rocm"> block
f39007e to
d15197d
Compare
|
-code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-49671/47694
Code check has found code style and quality issues which could be resolved by applying following patch(s)
|
| @@ -0,0 +1,46 @@ | |||
| #include "DataFormats/SoATemplate/interface/SoALayout.h" | |||
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.
Can you add
#include <cmath>
for the use of sqrt() ?
|
|
||
| template <typename T1, typename T2> | ||
| SOA_HOST_DEVICE static auto time(T1 pos, T2 vel) { | ||
| if (not(vel == 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.
why not more simply
| if (not(vel == 0)) | |
| if (vel != 0) |
?
cfb5ee2 to
30d94e9
Compare
|
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-49671/47698
|
|
please test |
|
+heterogeneous |
|
This pull request is fully signed and it will be integrated in one of the next master IBs after it passes the integration tests. This pull request will now be reviewed by the release team before it's merged. @ftenchini, @sextonkennedy, @mandrenguyen (and backports should be raised in the release meeting by the corresponding L2) |
|
+1 Size: This PR adds an extra 24KB to repository Comparison SummarySummary:
|
|
+1 |
PR description:
This PR modifies the test
SoACustomizedMethods_tby addingSOA_HOST_DEVICEto all element methods. Doing so, the test is also extended as aCUDA,HIPandAlpakaversion to show consistency. Furthermore, the documentation is extended to hint to users of the SoA to useSOA_HOST_DEVICEto ensure that element methods can be used in device kernels.A similar idea was promoted previously in #49203 by using
constexprto ensure that functions can run in device kernels. However, as shown, this method is not feasible for us due to a bug in thenvcccompiler. Hence, with this PR #49203 can be closed.@felicepantaleo fyi