-
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
Adding HeterogeneousCore/AlpakaUtilities and changes into HeterogeneousCore/AlpakaInterface #40932
Closed
+1,325
−0
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<use name="HeterogeneousCore/AlpakaInterface"/> | ||
<export> | ||
<lib name="1"/> | ||
</export> | ||
|
||
|
53 changes: 53 additions & 0 deletions
53
HeterogeneousCore/AlpakaUtilities/interface/AtomicPairCounter.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#ifndef AlpakaCore_AtomicPairCounter_h | ||
#define AlpakaCore_AtomicPairCounter_h | ||
|
||
#include <cstdint> | ||
|
||
#include <alpaka/alpaka.hpp> | ||
|
||
namespace cms::alpakatools { | ||
|
||
class AtomicPairCounter { | ||
public: | ||
using c_type = unsigned long long int; | ||
|
||
ALPAKA_FN_HOST_ACC AtomicPairCounter() {} | ||
ALPAKA_FN_HOST_ACC AtomicPairCounter(c_type i) { counter.ac = i; } | ||
|
||
ALPAKA_FN_HOST_ACC AtomicPairCounter& operator=(c_type i) { | ||
counter.ac = i; | ||
return *this; | ||
} | ||
|
||
struct Counters { | ||
uint32_t n; // in a "One to Many" association is the number of "One" | ||
uint32_t m; // in a "One to Many" association is the total number of associations | ||
}; | ||
|
||
union Atomic2 { | ||
Counters counters; | ||
c_type ac; | ||
}; | ||
|
||
static constexpr c_type incr = 1UL << 32; | ||
|
||
ALPAKA_FN_ACC Counters get() const { return counter.counters; } | ||
|
||
// increment n by 1 and m by i. return previous value | ||
template <typename TAcc> | ||
ALPAKA_FN_ACC ALPAKA_FN_INLINE Counters add(const TAcc& acc, uint32_t i) { | ||
c_type c = i; | ||
c += incr; | ||
|
||
Atomic2 ret; | ||
ret.ac = alpaka::atomicAdd(acc, &counter.ac, c, alpaka::hierarchy::Blocks{}); | ||
return ret.counters; | ||
} | ||
|
||
private: | ||
Atomic2 counter; | ||
}; | ||
|
||
} // namespace cms::alpakatools | ||
|
||
#endif // AlpakaCore_AtomicPairCounter_h |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@borzari @nothingface0 could you point me to the use cases for
and
?
Regarding the latter, do you prefer the lambda approach (pass a function object or lambda to the
for_each_element_in_...
call) or the range loop approach (get the index via a range loop, as withelements_with_stride
) ?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.
element_index_range_in_block
workdivision.h
here and here. It's then used by
element_index_range_in_block_truncated
andelement_index_range_in_grid
.gpuClusterChargeCut.h
here
gpuPixelRecHits.h
here
gpuFishbone.h
here
gpuPixelDoubletsAlgos.h
here
element_index_range_in_block_truncated
workdivision.h
here. See
for_each_element_in_block
for implicit uses.element_index_range_in_grid
workdivision.h
Inside
for_each_element_in_grid_strided
here.gpuFishbone.h
here
gpuPixelDoubletsAlgos.h
here
element_index_range_in_grid_truncated
workdivision.h
Only used from overloaded function here. Not used anywhere else, can be deleted.
for_each_element_in_block
workdivision.h
Call from overloaded function here.
radixSort.h
here, here, here, here, here.
for_each_element_in_block_strided
workdivision.h
Call from overloaded function here.
radixSort.h
here, here, here, here, here, here, here, here, here, here, here, and here.
for_each_element_in_grid_strided
workdivision.h
Call from overloaded function here.
HistoContainer.h
here, here and here.
Comments
Since we didn't have the time to go in-depth in the
patatrack-standalone
algorithms, we did not try to change different ways of looping over the elements so that they're more uniform.That said, personally speaking, the range approach (
elements_with_stride
) seems more intuitive, and it's cleaner in the code, too.A visualized overview of the functions that depend on those functions can be seen below for easier(?) comprehension: