Skip to content

Commit

Permalink
Removed unnecessary CopyToHost
Browse files Browse the repository at this point in the history
  • Loading branch information
ariostas committed Oct 4, 2024
1 parent 96be4f7 commit efef777
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 21 deletions.
19 changes: 12 additions & 7 deletions RecoTracker/LSTCore/src/alpaka/Event.dev.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1396,16 +1396,21 @@ MiniDoubletsBuffer<alpaka_common::DevHost>& Event::getMiniDoublets(bool sync) {
return mdsInCPU_.value();
}

template <typename TSoA>
template <typename TSoA, typename TDev>
typename TSoA::ConstView Event::getSegments(bool sync) {
if constexpr (std::is_same_v<Device, DevHost>)
if constexpr (std::is_same_v<TDev, DevHost>) {
return segmentsDev_->const_view<TSoA>();
if (!segmentsHost_) {
segmentsHost_.emplace(cms::alpakatools::CopyToHost<SegmentsDeviceCollection>::copyAsync(queue_, *segmentsDev_));
if (sync)
alpaka::wait(queue_); // host consumers expect filled data
} else {
if (!segmentsHost_) {
segmentsHost_.emplace(
cms::alpakatools::
CopyToHost<PortableMultiCollection<TDev, SegmentsSoA, SegmentsOccupancySoA, SegmentsPixelSoA>>::copyAsync(
queue_, *segmentsDev_));
if (sync)
alpaka::wait(queue_); // host consumers expect filled data
}
return segmentsHost_->const_view<TSoA>();
}
return segmentsHost_->const_view<TSoA>();
}
template SegmentsConst Event::getSegments<SegmentsSoA>(bool);
template SegmentsOccupancyConst Event::getSegments<SegmentsOccupancySoA>(bool);
Expand Down
2 changes: 1 addition & 1 deletion RecoTracker/LSTCore/src/alpaka/Event.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
HitsBuffer<DevHost>& getHitsInCMSSW(bool sync = true);
ObjectRangesBuffer<DevHost>& getRanges(bool sync = true);
MiniDoubletsBuffer<DevHost>& getMiniDoublets(bool sync = true);
template <typename TSoA>
template <typename TSoA, typename TDev = Device>
typename TSoA::ConstView getSegments(bool sync = true);
TripletsBuffer<DevHost>& getTriplets(bool sync = true);
QuintupletsBuffer<DevHost>& getQuintuplets(bool sync = true);
Expand Down
13 changes: 0 additions & 13 deletions RecoTracker/LSTCore/src/alpaka/Segment.h
Original file line number Diff line number Diff line change
Expand Up @@ -910,17 +910,4 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
};
} // namespace ALPAKA_ACCELERATOR_NAMESPACE::lst

namespace cms::alpakatools {
// This is not used, but it is needed for compilation
template <typename T0, typename... Args>
struct CopyToHost<PortableHostMultiCollection<T0, Args...>> {
template <typename TQueue>
static auto copyAsync(TQueue& queue, PortableHostMultiCollection<T0, Args...> const& srcData) {
PortableHostMultiCollection<T0, Args...> dstData(srcData.sizes(), queue);
alpaka::memcpy(queue, dstData.buffer(), srcData.buffer());
return dstData;
}
};
} // namespace cms::alpakatools

#endif

0 comments on commit efef777

Please sign in to comment.