From 1fb0489e012102c3ca544316859d3a3b1f9a20ac Mon Sep 17 00:00:00 2001 From: Slava Krutelyov Date: Fri, 19 Jul 2024 08:55:13 -0700 Subject: [PATCH] split ranges from modules --- RecoTracker/LSTCore/src/alpaka/ObjectRanges.h | 155 ++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 RecoTracker/LSTCore/src/alpaka/ObjectRanges.h diff --git a/RecoTracker/LSTCore/src/alpaka/ObjectRanges.h b/RecoTracker/LSTCore/src/alpaka/ObjectRanges.h new file mode 100644 index 0000000000000..e8cb17a301fab --- /dev/null +++ b/RecoTracker/LSTCore/src/alpaka/ObjectRanges.h @@ -0,0 +1,155 @@ +#ifndef RecoTracker_LSTCore_interface_ObjectRanges_h +#define RecoTracker_LSTCore_interface_ObjectRanges_h + +#include "RecoTracker/LSTCore/interface/Constants.h" + +namespace SDL { + + struct ObjectRanges { + int* hitRanges; + int* hitRangesLower; + int* hitRangesUpper; + int8_t* hitRangesnLower; + int8_t* hitRangesnUpper; + int* mdRanges; + int* segmentRanges; + int* trackletRanges; + int* tripletRanges; + int* trackCandidateRanges; + // Others will be added later + int* quintupletRanges; + + // This number is just nEligibleModules - 1, but still we want this to be independent of the TC kernel + uint16_t* nEligibleT5Modules; + // Will be allocated in createQuintuplets kernel! + uint16_t* indicesOfEligibleT5Modules; + // To store different starting points for variable occupancy stuff + int* quintupletModuleIndices; + int* quintupletModuleOccupancy; + int* miniDoubletModuleIndices; + int* miniDoubletModuleOccupancy; + int* segmentModuleIndices; + int* segmentModuleOccupancy; + int* tripletModuleIndices; + int* tripletModuleOccupancy; + + unsigned int* device_nTotalMDs; + unsigned int* device_nTotalSegs; + unsigned int* device_nTotalTrips; + unsigned int* device_nTotalQuints; + + template + void setData(TBuff& buf) { + hitRanges = alpaka::getPtrNative(buf.hitRanges_buf); + hitRangesLower = alpaka::getPtrNative(buf.hitRangesLower_buf); + hitRangesUpper = alpaka::getPtrNative(buf.hitRangesUpper_buf); + hitRangesnLower = alpaka::getPtrNative(buf.hitRangesnLower_buf); + hitRangesnUpper = alpaka::getPtrNative(buf.hitRangesnUpper_buf); + mdRanges = alpaka::getPtrNative(buf.mdRanges_buf); + segmentRanges = alpaka::getPtrNative(buf.segmentRanges_buf); + trackletRanges = alpaka::getPtrNative(buf.trackletRanges_buf); + tripletRanges = alpaka::getPtrNative(buf.tripletRanges_buf); + trackCandidateRanges = alpaka::getPtrNative(buf.trackCandidateRanges_buf); + quintupletRanges = alpaka::getPtrNative(buf.quintupletRanges_buf); + + nEligibleT5Modules = alpaka::getPtrNative(buf.nEligibleT5Modules_buf); + indicesOfEligibleT5Modules = alpaka::getPtrNative(buf.indicesOfEligibleT5Modules_buf); + + quintupletModuleIndices = alpaka::getPtrNative(buf.quintupletModuleIndices_buf); + quintupletModuleOccupancy = alpaka::getPtrNative(buf.quintupletModuleOccupancy_buf); + miniDoubletModuleIndices = alpaka::getPtrNative(buf.miniDoubletModuleIndices_buf); + miniDoubletModuleOccupancy = alpaka::getPtrNative(buf.miniDoubletModuleOccupancy_buf); + segmentModuleIndices = alpaka::getPtrNative(buf.segmentModuleIndices_buf); + segmentModuleOccupancy = alpaka::getPtrNative(buf.segmentModuleOccupancy_buf); + tripletModuleIndices = alpaka::getPtrNative(buf.tripletModuleIndices_buf); + tripletModuleOccupancy = alpaka::getPtrNative(buf.tripletModuleOccupancy_buf); + + device_nTotalMDs = alpaka::getPtrNative(buf.device_nTotalMDs_buf); + device_nTotalSegs = alpaka::getPtrNative(buf.device_nTotalSegs_buf); + device_nTotalTrips = alpaka::getPtrNative(buf.device_nTotalTrips_buf); + device_nTotalQuints = alpaka::getPtrNative(buf.device_nTotalQuints_buf); + } + }; + + template + struct ObjectRangesBuffer { + Buf hitRanges_buf; + Buf hitRangesLower_buf; + Buf hitRangesUpper_buf; + Buf hitRangesnLower_buf; + Buf hitRangesnUpper_buf; + Buf mdRanges_buf; + Buf segmentRanges_buf; + Buf trackletRanges_buf; + Buf tripletRanges_buf; + Buf trackCandidateRanges_buf; + Buf quintupletRanges_buf; + + Buf nEligibleT5Modules_buf; + Buf indicesOfEligibleT5Modules_buf; + + Buf quintupletModuleIndices_buf; + Buf quintupletModuleOccupancy_buf; + Buf miniDoubletModuleIndices_buf; + Buf miniDoubletModuleOccupancy_buf; + Buf segmentModuleIndices_buf; + Buf segmentModuleOccupancy_buf; + Buf tripletModuleIndices_buf; + Buf tripletModuleOccupancy_buf; + + Buf device_nTotalMDs_buf; + Buf device_nTotalSegs_buf; + Buf device_nTotalTrips_buf; + Buf device_nTotalQuints_buf; + + ObjectRanges data_; + + template + ObjectRangesBuffer(unsigned int nMod, unsigned int nLowerMod, TDevAcc const& devAccIn, TQueue& queue) + : hitRanges_buf(allocBufWrapper(devAccIn, nMod * 2, queue)), + hitRangesLower_buf(allocBufWrapper(devAccIn, nMod, queue)), + hitRangesUpper_buf(allocBufWrapper(devAccIn, nMod, queue)), + hitRangesnLower_buf(allocBufWrapper(devAccIn, nMod, queue)), + hitRangesnUpper_buf(allocBufWrapper(devAccIn, nMod, queue)), + mdRanges_buf(allocBufWrapper(devAccIn, nMod * 2, queue)), + segmentRanges_buf(allocBufWrapper(devAccIn, nMod * 2, queue)), + trackletRanges_buf(allocBufWrapper(devAccIn, nMod * 2, queue)), + tripletRanges_buf(allocBufWrapper(devAccIn, nMod * 2, queue)), + trackCandidateRanges_buf(allocBufWrapper(devAccIn, nMod * 2, queue)), + quintupletRanges_buf(allocBufWrapper(devAccIn, nMod * 2, queue)), + nEligibleT5Modules_buf(allocBufWrapper(devAccIn, 1, queue)), + indicesOfEligibleT5Modules_buf(allocBufWrapper(devAccIn, nLowerMod, queue)), + quintupletModuleIndices_buf(allocBufWrapper(devAccIn, nLowerMod, queue)), + quintupletModuleOccupancy_buf(allocBufWrapper(devAccIn, nLowerMod, queue)), + miniDoubletModuleIndices_buf(allocBufWrapper(devAccIn, nLowerMod + 1, queue)), + miniDoubletModuleOccupancy_buf(allocBufWrapper(devAccIn, nLowerMod + 1, queue)), + segmentModuleIndices_buf(allocBufWrapper(devAccIn, nLowerMod + 1, queue)), + segmentModuleOccupancy_buf(allocBufWrapper(devAccIn, nLowerMod + 1, queue)), + tripletModuleIndices_buf(allocBufWrapper(devAccIn, nLowerMod, queue)), + tripletModuleOccupancy_buf(allocBufWrapper(devAccIn, nLowerMod, queue)), + device_nTotalMDs_buf(allocBufWrapper(devAccIn, 1, queue)), + device_nTotalSegs_buf(allocBufWrapper(devAccIn, 1, queue)), + device_nTotalTrips_buf(allocBufWrapper(devAccIn, 1, queue)), + device_nTotalQuints_buf(allocBufWrapper(devAccIn, 1, queue)) { + alpaka::memset(queue, hitRanges_buf, 0xff); + alpaka::memset(queue, hitRangesLower_buf, 0xff); + alpaka::memset(queue, hitRangesUpper_buf, 0xff); + alpaka::memset(queue, hitRangesnLower_buf, 0xff); + alpaka::memset(queue, hitRangesnUpper_buf, 0xff); + alpaka::memset(queue, mdRanges_buf, 0xff); + alpaka::memset(queue, segmentRanges_buf, 0xff); + alpaka::memset(queue, trackletRanges_buf, 0xff); + alpaka::memset(queue, tripletRanges_buf, 0xff); + alpaka::memset(queue, trackCandidateRanges_buf, 0xff); + alpaka::memset(queue, quintupletRanges_buf, 0xff); + alpaka::memset(queue, quintupletModuleIndices_buf, 0xff); + alpaka::wait(queue); + data_.setData(*this); + } + + inline ObjectRanges const* data() const { return &data_; } + void setData(ObjectRangesBuffer& buf) { data_.setData(buf); } + }; + +} // namespace SDL +#endif