-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Port generic alpaka phi functions to DataFormats/Math
#47033
Port generic alpaka phi functions to DataFormats/Math
#47033
Conversation
cms-bot internal usage |
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-47033/43155 |
A new Pull Request was created by @VourMa for master. It involves the following packages:
@cmsbuild, @jfernan2, @mandrenguyen can you please review it and eventually sign? Thanks. cms-bot commands are listed here |
@cms-sw/heterogeneous-l2 (not sure if this PR would need to be assigned to
Thinking out loud
|
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.
I'd suggest to add unit tests.
is there a way to keep the dependence only via |
No. For link-time dependencies that wouldn't work. Some source-level operations, like IIRC |
Based on this and the follow up discussion, I understand that the current placement is not ideal, since the dependencies cannot be reduced. During our internal review, I had this initially placed under a new |
Sure. Do you have in mind some unit test that I can use as a template (to speed up the work and to make sure that I cover what needs to be tested)? |
IIUC, |
Ah, sorry, I misinterpreted the comment to mean that the new subpackage would be under |
I guess @makortel could confirm the preference to avoid further confusion. |
By quick look I see the existing cmssw/DataFormats/Math/test/testAtan2.cpp Lines 187 to 189 in f55e6a5
(and even there it is not immediately clear whether reduceRange() or int2phi() is the one being tested).
I'd say the primary objective would be to ensure all functions can be called for the relevant data types (I suppose both Here are a few rather simple Alpaka-using unit tests
I personally prefer the Catch2 unit test framework (used in |
I'd wait for next week before moving things around to get more feedback (after more people will presumably be back) I would not be against
|
My estimation is that it's tiny, so I will not go with that option.
I cannot really predict and I don't have a use case right now, but I can see people needing, e.g., |
dbf0fbf
to
99036e0
Compare
-code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-47033/43221 Code check has found code style and quality issues which could be resolved by applying following patch(s)
|
Thanks for the extra suggestions, @makortel, I applied all of them. |
@cmsbuild please test |
+1 Size: This PR adds an extra 24KB to repository Comparison SummarySummary:
GPU Comparison SummarySummary:
|
constexpr T o2pi = T{1.} / (T{2.} * std::numbers::pi_v<T>); | ||
if (alpaka::math::abs(acc, x) <= std::numbers::pi_v<T>) | ||
return x; | ||
T n = alpaka::math::round(acc, x * o2pi); |
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.
Just curious: why not simply
T n = alpaka::math::round(acc, x * o2pi); | |
T n = alpaka::math::round(acc, x / (T{2} * std::numbers::pi_v<T>)); |
or
T n = alpaka::math::round(acc, x * o2pi); | |
T n = alpaka::math::round(acc, x * std::numbers::inv_pi_v<T> * T{0.5}); |
?
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.
As initially mentioned, this was meant to be an alpaka-adjusted copy of the reco::reduceRange
function
cmssw/DataFormats/Math/interface/deltaPhi.h
Lines 18 to 24 in a475844
constexpr T reduceRange(T x) { | |
constexpr T o2pi = 1. / (2. * M_PI); | |
if (std::abs(x) <= T(M_PI)) | |
return x; | |
T n = std::round(x * o2pi); | |
return x - n * T(2. * M_PI); | |
} |
hence I didn't apply any other simplifications, apart from the ones suggested in this PR.
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.
ok
Anything still pending for this PR? Or can it be merged so that I can continue with the follow up PRs? |
We can't formally sign until cms-sw/cms-bot#2413 gets merged and the package assigned |
cms-sw/cms-bot#2413 is merged now |
+heterogeneous |
This pull request is fully signed and it will be integrated in one of the next master IBs (tests are also fine). This pull request will now be reviewed by the release team before it's merged. @rappoccio, @antoniovilela, @mandrenguyen, @sextonkennedy (and backports should be raised in the release meeting by the corresponding L2) |
+1 |
During the review of the LST integration PR #45117 it was identified that some of the math functions rewritten in the alpaka framework for usage in the LST algorithm could be made more widely available in CMSSW by porting them to a more central package:
This PR follows up on those comments. After the initial PR review, the choice made was to port these functions under
Heterogeneous/AlpakaMath
. The function logic is as close as possible to the non-alpaka equivalentDataFormats/Math/interface/deltaPhi.h
file.This PR only introduces the new function to CMSSW + the relevant unit tests. A follow-up PR will be made to actually use these functions in the LST algorithm and delete the LST-specific implementations.