diff --git a/RecoTracker/LSTCore/interface/EndcapGeometryBuffer.h b/RecoTracker/LSTCore/interface/EndcapGeometryBuffer.h index 005d2a7a32d75..afacfc4ba6d25 100644 --- a/RecoTracker/LSTCore/interface/EndcapGeometryBuffer.h +++ b/RecoTracker/LSTCore/interface/EndcapGeometryBuffer.h @@ -18,21 +18,22 @@ namespace SDL { const float* geoMapPhi; template - void setData(const TBuff& endcapgeombuf) { - geoMapDetId = alpaka::getPtrNative(endcapgeombuf.geoMapDetId_buf); - geoMapPhi = alpaka::getPtrNative(endcapgeombuf.geoMapPhi_buf); + void setData(const TBuff& buf) { + geoMapDetId = alpaka::getPtrNative(buf.geoMapDetId_buf); + geoMapPhi = alpaka::getPtrNative(buf.geoMapPhi_buf); } }; template - struct EndcapGeometryBuffer : EndcapGeometryDev { + struct EndcapGeometryBuffer { Buf geoMapDetId_buf; Buf geoMapPhi_buf; + EndcapGeometryDev data_; EndcapGeometryBuffer(TDev const& dev, unsigned int nEndCapMap) : geoMapDetId_buf(allocBufWrapper(dev, nEndCapMap)), geoMapPhi_buf(allocBufWrapper(dev, nEndCapMap)) { - setData(*this); + data_.setData(*this); } template @@ -47,7 +48,7 @@ namespace SDL { copyFromSrc(queue, src); } - inline EndcapGeometryDev const* data() const { return this; } + inline EndcapGeometryDev const* data() const { return &data_; } }; } // namespace SDL diff --git a/RecoTracker/LSTCore/interface/LSTESData.h b/RecoTracker/LSTCore/interface/LSTESData.h index c2a0a92bb668a..72ad204af1b43 100644 --- a/RecoTracker/LSTCore/interface/LSTESData.h +++ b/RecoTracker/LSTCore/interface/LSTESData.h @@ -19,7 +19,7 @@ namespace SDL { uint16_t nLowerModules; unsigned int nPixels; unsigned int nEndCapMap; - std::shared_ptr> modulesBuffers; + std::shared_ptr> modulesBuffers; std::shared_ptr> endcapGeometryBuffers; std::shared_ptr pixelMapping; @@ -27,7 +27,7 @@ namespace SDL { uint16_t const& nLowerModulesIn, unsigned int const& nPixelsIn, unsigned int const& nEndCapMapIn, - std::shared_ptr> const& modulesBuffersIn, + std::shared_ptr> const& modulesBuffersIn, std::shared_ptr> const& endcapGeometryBuffersIn, std::shared_ptr const& pixelMappingIn) : nModules(nModulesIn), @@ -49,7 +49,7 @@ namespace cms::alpakatools { template static SDL::LSTESData> copyAsync(TQueue& queue, SDL::LSTESData const& srcData) { - auto deviceModulesBuffers = std::make_shared>>( + auto deviceModulesBuffers = std::make_shared>>( alpaka::getDev(queue), srcData.nModules, srcData.nPixels); deviceModulesBuffers->copyFromSrc(queue, *srcData.modulesBuffers); auto deviceEndcapGeometryBuffers = diff --git a/RecoTracker/LSTCore/interface/Module.h b/RecoTracker/LSTCore/interface/Module.h index 62ef8a630400a..3b94508c529e0 100644 --- a/RecoTracker/LSTCore/interface/Module.h +++ b/RecoTracker/LSTCore/interface/Module.h @@ -12,147 +12,7 @@ namespace SDL { enum ModuleLayerType { Pixel, Strip, InnerPixelLayer }; - 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& objectRangesbuf) { - hitRanges = alpaka::getPtrNative(objectRangesbuf.hitRanges_buf); - hitRangesLower = alpaka::getPtrNative(objectRangesbuf.hitRangesLower_buf); - hitRangesUpper = alpaka::getPtrNative(objectRangesbuf.hitRangesUpper_buf); - hitRangesnLower = alpaka::getPtrNative(objectRangesbuf.hitRangesnLower_buf); - hitRangesnUpper = alpaka::getPtrNative(objectRangesbuf.hitRangesnUpper_buf); - mdRanges = alpaka::getPtrNative(objectRangesbuf.mdRanges_buf); - segmentRanges = alpaka::getPtrNative(objectRangesbuf.segmentRanges_buf); - trackletRanges = alpaka::getPtrNative(objectRangesbuf.trackletRanges_buf); - tripletRanges = alpaka::getPtrNative(objectRangesbuf.tripletRanges_buf); - trackCandidateRanges = alpaka::getPtrNative(objectRangesbuf.trackCandidateRanges_buf); - quintupletRanges = alpaka::getPtrNative(objectRangesbuf.quintupletRanges_buf); - - nEligibleT5Modules = alpaka::getPtrNative(objectRangesbuf.nEligibleT5Modules_buf); - indicesOfEligibleT5Modules = alpaka::getPtrNative(objectRangesbuf.indicesOfEligibleT5Modules_buf); - - quintupletModuleIndices = alpaka::getPtrNative(objectRangesbuf.quintupletModuleIndices_buf); - quintupletModuleOccupancy = alpaka::getPtrNative(objectRangesbuf.quintupletModuleOccupancy_buf); - miniDoubletModuleIndices = alpaka::getPtrNative(objectRangesbuf.miniDoubletModuleIndices_buf); - miniDoubletModuleOccupancy = alpaka::getPtrNative(objectRangesbuf.miniDoubletModuleOccupancy_buf); - segmentModuleIndices = alpaka::getPtrNative(objectRangesbuf.segmentModuleIndices_buf); - segmentModuleOccupancy = alpaka::getPtrNative(objectRangesbuf.segmentModuleOccupancy_buf); - tripletModuleIndices = alpaka::getPtrNative(objectRangesbuf.tripletModuleIndices_buf); - tripletModuleOccupancy = alpaka::getPtrNative(objectRangesbuf.tripletModuleOccupancy_buf); - - device_nTotalMDs = alpaka::getPtrNative(objectRangesbuf.device_nTotalMDs_buf); - device_nTotalSegs = alpaka::getPtrNative(objectRangesbuf.device_nTotalSegs_buf); - device_nTotalTrips = alpaka::getPtrNative(objectRangesbuf.device_nTotalTrips_buf); - device_nTotalQuints = alpaka::getPtrNative(objectRangesbuf.device_nTotalQuints_buf); - } - }; - - template - struct objectRangesBuffer : objectRanges { - 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; - - 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); - } - }; - - struct modules { + struct Modules { const unsigned int* detIds; const uint16_t* moduleMap; const unsigned int* mapdetId; @@ -223,38 +83,38 @@ namespace SDL { }; template - void setData(const TBuff& modulesbuf) { - detIds = alpaka::getPtrNative(modulesbuf.detIds_buf); - moduleMap = alpaka::getPtrNative(modulesbuf.moduleMap_buf); - mapdetId = alpaka::getPtrNative(modulesbuf.mapdetId_buf); - mapIdx = alpaka::getPtrNative(modulesbuf.mapIdx_buf); - nConnectedModules = alpaka::getPtrNative(modulesbuf.nConnectedModules_buf); - drdzs = alpaka::getPtrNative(modulesbuf.drdzs_buf); - dxdys = alpaka::getPtrNative(modulesbuf.dxdys_buf); - nModules = alpaka::getPtrNative(modulesbuf.nModules_buf); - nLowerModules = alpaka::getPtrNative(modulesbuf.nLowerModules_buf); - partnerModuleIndices = alpaka::getPtrNative(modulesbuf.partnerModuleIndices_buf); - - layers = alpaka::getPtrNative(modulesbuf.layers_buf); - rings = alpaka::getPtrNative(modulesbuf.rings_buf); - modules = alpaka::getPtrNative(modulesbuf.modules_buf); - rods = alpaka::getPtrNative(modulesbuf.rods_buf); - subdets = alpaka::getPtrNative(modulesbuf.subdets_buf); - sides = alpaka::getPtrNative(modulesbuf.sides_buf); - eta = alpaka::getPtrNative(modulesbuf.eta_buf); - r = alpaka::getPtrNative(modulesbuf.r_buf); - isInverted = alpaka::getPtrNative(modulesbuf.isInverted_buf); - isLower = alpaka::getPtrNative(modulesbuf.isLower_buf); - isAnchor = alpaka::getPtrNative(modulesbuf.isAnchor_buf); - moduleType = alpaka::getPtrNative(modulesbuf.moduleType_buf); - moduleLayerType = alpaka::getPtrNative(modulesbuf.moduleLayerType_buf); - sdlLayers = alpaka::getPtrNative(modulesbuf.sdlLayers_buf); - connectedPixels = alpaka::getPtrNative(modulesbuf.connectedPixels_buf); + void setData(const TBuff& buf) { + detIds = alpaka::getPtrNative(buf.detIds_buf); + moduleMap = alpaka::getPtrNative(buf.moduleMap_buf); + mapdetId = alpaka::getPtrNative(buf.mapdetId_buf); + mapIdx = alpaka::getPtrNative(buf.mapIdx_buf); + nConnectedModules = alpaka::getPtrNative(buf.nConnectedModules_buf); + drdzs = alpaka::getPtrNative(buf.drdzs_buf); + dxdys = alpaka::getPtrNative(buf.dxdys_buf); + nModules = alpaka::getPtrNative(buf.nModules_buf); + nLowerModules = alpaka::getPtrNative(buf.nLowerModules_buf); + partnerModuleIndices = alpaka::getPtrNative(buf.partnerModuleIndices_buf); + + layers = alpaka::getPtrNative(buf.layers_buf); + rings = alpaka::getPtrNative(buf.rings_buf); + modules = alpaka::getPtrNative(buf.modules_buf); + rods = alpaka::getPtrNative(buf.rods_buf); + subdets = alpaka::getPtrNative(buf.subdets_buf); + sides = alpaka::getPtrNative(buf.sides_buf); + eta = alpaka::getPtrNative(buf.eta_buf); + r = alpaka::getPtrNative(buf.r_buf); + isInverted = alpaka::getPtrNative(buf.isInverted_buf); + isLower = alpaka::getPtrNative(buf.isLower_buf); + isAnchor = alpaka::getPtrNative(buf.isAnchor_buf); + moduleType = alpaka::getPtrNative(buf.moduleType_buf); + moduleLayerType = alpaka::getPtrNative(buf.moduleLayerType_buf); + sdlLayers = alpaka::getPtrNative(buf.sdlLayers_buf); + connectedPixels = alpaka::getPtrNative(buf.connectedPixels_buf); } }; template - struct modulesBuffer : modules { + struct ModulesBuffer { Buf detIds_buf; Buf moduleMap_buf; Buf mapdetId_buf; @@ -282,7 +142,9 @@ namespace SDL { Buf sdlLayers_buf; Buf connectedPixels_buf; - modulesBuffer(TDev const& dev, unsigned int nMod, unsigned int nPixs) + Modules data_; + + ModulesBuffer(TDev const& dev, unsigned int nMod, unsigned int nPixs) : detIds_buf(allocBufWrapper(dev, nMod)), moduleMap_buf(allocBufWrapper(dev, nMod * MAX_CONNECTED_MODULES)), mapdetId_buf(allocBufWrapper(dev, nMod)), @@ -309,11 +171,11 @@ namespace SDL { moduleLayerType_buf(allocBufWrapper(dev, nMod)), sdlLayers_buf(allocBufWrapper(dev, nMod)), connectedPixels_buf(allocBufWrapper(dev, nPixs)) { - setData(*this); + data_.setData(*this); } template - inline void copyFromSrc(TQueue queue, const modulesBuffer& src, bool isFull = true) { + inline void copyFromSrc(TQueue queue, const ModulesBuffer& src, bool isFull = true) { alpaka::memcpy(queue, detIds_buf, src.detIds_buf); if (isFull) { alpaka::memcpy(queue, moduleMap_buf, src.moduleMap_buf); @@ -354,12 +216,12 @@ namespace SDL { } template - modulesBuffer(TQueue queue, const modulesBuffer& src, unsigned int nMod, unsigned int nPixs) - : modulesBuffer(alpaka::getDev(queue), nMod, nPixs) { + ModulesBuffer(TQueue queue, const ModulesBuffer& src, unsigned int nMod, unsigned int nPixs) + : ModulesBuffer(alpaka::getDev(queue), nMod, nPixs) { copyFromSrc(queue, src); } - inline SDL::modules const* data() const { return this; } + inline Modules const* data() const { return &data_; } }; } // namespace SDL diff --git a/RecoTracker/LSTCore/src/LSTESData.cc b/RecoTracker/LSTCore/src/LSTESData.cc index cb64bf928a5bc..d91019852165e 100644 --- a/RecoTracker/LSTCore/src/LSTESData.cc +++ b/RecoTracker/LSTCore/src/LSTESData.cc @@ -81,7 +81,7 @@ std::unique_ptr> SDL::loadAndFillESHost() uint16_t nModules; uint16_t nLowerModules; unsigned int nPixels; - std::shared_ptr> modulesBuffers = nullptr; + std::shared_ptr> modulesBuffers = nullptr; auto pLStoLayer = std::make_shared(); auto endcapGeometry = std::make_shared(); auto tiltedGeometry = std::make_shared(); diff --git a/RecoTracker/LSTCore/src/ModuleMethods.h b/RecoTracker/LSTCore/src/ModuleMethods.h index 5d91f1bd59b7a..a5649ab9bf85b 100644 --- a/RecoTracker/LSTCore/src/ModuleMethods.h +++ b/RecoTracker/LSTCore/src/ModuleMethods.h @@ -24,7 +24,7 @@ namespace SDL { }; template - inline void fillPixelMap(std::shared_ptr>& modulesBuf, + inline void fillPixelMap(std::shared_ptr>& modulesBuf, uint16_t nModules, unsigned int& nPixels, pixelMap& pixelMapping, @@ -84,7 +84,7 @@ namespace SDL { // Now we can initialize modulesBuf alpaka_common::DevHost const& devHost = cms::alpakatools::host(); if (modulesBuf == nullptr) { - modulesBuf = std::make_shared>(devHost, nModules, nPixels); + modulesBuf = std::make_shared>(devHost, nModules, nPixels); } auto connectedPixels_buf = allocBufWrapper(devHost, connectedPix_size); @@ -105,7 +105,7 @@ namespace SDL { }; template - inline void fillConnectedModuleArrayExplicit(struct modulesBuffer* modulesBuf, + inline void fillConnectedModuleArrayExplicit(struct ModulesBuffer* modulesBuf, unsigned int nMod, TQueue queue, struct ModuleMetaData& mmd, @@ -133,7 +133,7 @@ namespace SDL { }; template - inline void fillMapArraysExplicit(struct modulesBuffer* modulesBuf, + inline void fillMapArraysExplicit(struct ModulesBuffer* modulesBuf, unsigned int nMod, TQueue queue, struct ModuleMetaData& mmd) { @@ -223,7 +223,7 @@ namespace SDL { uint16_t& nModules, uint16_t& nLowerModules, unsigned int& nPixels, - std::shared_ptr>& modulesBuf, + std::shared_ptr>& modulesBuf, pixelMap* pixelMapping, const EndcapGeometry* endcapGeometry, const TiltedGeometry* tiltedGeometry, @@ -302,8 +302,8 @@ namespace SDL { r = 0; } else { setDerivedQuantities(detId, layer, ring, rod, module, subdet, side, m_x, m_y, m_z, eta, r); - isInverted = SDL::modules::parseIsInverted(subdet, side, module, layer); - isLower = SDL::modules::parseIsLower(isInverted, detId); + isInverted = SDL::Modules::parseIsInverted(subdet, side, module, layer); + isLower = SDL::Modules::parseIsLower(isInverted, detId); } if (isLower) { index = lowerModuleCounter; @@ -361,7 +361,7 @@ namespace SDL { auto& index = it->second; if (detId != 1) { host_partnerModuleIndices[index] = - mmd.detIdToIndex[SDL::modules::parsePartnerModuleId(detId, host_isLower[index], host_isInverted[index])]; + mmd.detIdToIndex[SDL::Modules::parsePartnerModuleId(detId, host_isLower[index], host_isInverted[index])]; //add drdz and slope importing stuff here! if (host_drdzs[index] == 0) { host_drdzs[index] = host_drdzs[host_partnerModuleIndices[index]]; diff --git a/RecoTracker/LSTCore/src/alpaka/Event.dev.cc b/RecoTracker/LSTCore/src/alpaka/Event.dev.cc index 9c8228fc9a266..fa524d859af67 100644 --- a/RecoTracker/LSTCore/src/alpaka/Event.dev.cc +++ b/RecoTracker/LSTCore/src/alpaka/Event.dev.cc @@ -160,14 +160,14 @@ void SDL::Event::addHitToEvent(std::vector x, // Initialize space on device/host for next event. if (hitsInGPU == nullptr) { - hitsInGPU = new SDL::hits(); - hitsBuffers = new SDL::hitsBuffer(nModules_, nHits, devAcc, queue); + hitsInGPU = new SDL::Hits(); + hitsBuffers = new SDL::HitsBuffer(nModules_, nHits, devAcc, queue); hitsInGPU->setData(*hitsBuffers); } if (rangesInGPU == nullptr) { - rangesInGPU = new SDL::objectRanges(); - rangesBuffers = new SDL::objectRangesBuffer(nModules_, nLowerModules_, devAcc, queue); + rangesInGPU = new SDL::ObjectRanges(); + rangesBuffers = new SDL::ObjectRangesBuffer(nModules_, nLowerModules_, devAcc, queue); rangesInGPU->setData(*rangesBuffers); } @@ -281,8 +281,8 @@ void SDL::Event::addPixelSegmentToEvent(std::vector hitIndi nTotalMDs += N_MAX_PIXEL_MD_PER_MODULES; - mdsInGPU = new SDL::miniDoublets(); - miniDoubletsBuffers = new SDL::miniDoubletsBuffer(nTotalMDs, nLowerModules_, devAcc, queue); + mdsInGPU = new SDL::MiniDoublets(); + miniDoubletsBuffers = new SDL::MiniDoubletsBuffer(nTotalMDs, nLowerModules_, devAcc, queue); mdsInGPU->setData(*miniDoubletsBuffers); alpaka::memcpy(queue, miniDoubletsBuffers->nMemoryLocations_buf, nTotalMDs_view); @@ -314,9 +314,9 @@ void SDL::Event::addPixelSegmentToEvent(std::vector hitIndi nTotalSegments += N_MAX_PIXEL_SEGMENTS_PER_MODULE; - segmentsInGPU = new SDL::segments(); + segmentsInGPU = new SDL::Segments(); segmentsBuffers = - new SDL::segmentsBuffer(nTotalSegments, nLowerModules_, N_MAX_PIXEL_SEGMENTS_PER_MODULE, devAcc, queue); + new SDL::SegmentsBuffer(nTotalSegments, nLowerModules_, N_MAX_PIXEL_SEGMENTS_PER_MODULE, devAcc, queue); segmentsInGPU->setData(*segmentsBuffers); alpaka::memcpy(queue, segmentsBuffers->nMemoryLocations_buf, nTotalSegments_view); @@ -427,8 +427,8 @@ void SDL::Event::createMiniDoublets() { nTotalMDs += N_MAX_PIXEL_MD_PER_MODULES; if (mdsInGPU == nullptr) { - mdsInGPU = new SDL::miniDoublets(); - miniDoubletsBuffers = new SDL::miniDoubletsBuffer(nTotalMDs, nLowerModules_, devAcc, queue); + mdsInGPU = new SDL::MiniDoublets(); + miniDoubletsBuffers = new SDL::MiniDoubletsBuffer(nTotalMDs, nLowerModules_, devAcc, queue); mdsInGPU->setData(*miniDoubletsBuffers); } @@ -471,9 +471,9 @@ void SDL::Event::createMiniDoublets() { void SDL::Event::createSegmentsWithModuleMap() { if (segmentsInGPU == nullptr) { - segmentsInGPU = new SDL::segments(); + segmentsInGPU = new SDL::Segments(); segmentsBuffers = - new SDL::segmentsBuffer(nTotalSegments, nLowerModules_, N_MAX_PIXEL_SEGMENTS_PER_MODULE, devAcc, queue); + new SDL::SegmentsBuffer(nTotalSegments, nLowerModules_, N_MAX_PIXEL_SEGMENTS_PER_MODULE, devAcc, queue); segmentsInGPU->setData(*segmentsBuffers); } @@ -536,9 +536,9 @@ void SDL::Event::createTriplets() { alpaka::memcpy(queue, maxTriplets_buf, rangesBuffers->device_nTotalTrips_buf); alpaka::wait(queue); - tripletsInGPU = new SDL::triplets(); + tripletsInGPU = new SDL::Triplets(); tripletsBuffers = - new SDL::tripletsBuffer(*alpaka::getPtrNative(maxTriplets_buf), nLowerModules_, devAcc, queue); + new SDL::TripletsBuffer(*alpaka::getPtrNative(maxTriplets_buf), nLowerModules_, devAcc, queue); tripletsInGPU->setData(*tripletsBuffers); alpaka::memcpy(queue, tripletsBuffers->nMemoryLocations_buf, maxTriplets_buf); @@ -624,8 +624,8 @@ void SDL::Event::createTriplets() { void SDL::Event::createTrackCandidates(bool no_pls_dupclean, bool tc_pls_triplets) { if (trackCandidatesInGPU == nullptr) { - trackCandidatesInGPU = new SDL::trackCandidates(); - trackCandidatesBuffers = new SDL::trackCandidatesBuffer( + trackCandidatesInGPU = new SDL::TrackCandidates(); + trackCandidatesBuffers = new SDL::TrackCandidatesBuffer( N_MAX_NONPIXEL_TRACK_CANDIDATES + N_MAX_PIXEL_TRACK_CANDIDATES, devAcc, queue); trackCandidatesInGPU->setData(*trackCandidatesBuffers); } @@ -789,8 +789,8 @@ void SDL::Event::createTrackCandidates(bool no_pls_dupclean, bool tc_pls_ void SDL::Event::createPixelTriplets() { if (pixelTripletsInGPU == nullptr) { - pixelTripletsInGPU = new SDL::pixelTriplets(); - pixelTripletsBuffers = new SDL::pixelTripletsBuffer(N_MAX_PIXEL_TRIPLETS, devAcc, queue); + pixelTripletsInGPU = new SDL::PixelTriplets(); + pixelTripletsBuffers = new SDL::PixelTripletsBuffer(N_MAX_PIXEL_TRIPLETS, devAcc, queue); pixelTripletsInGPU->setData(*pixelTripletsBuffers); } @@ -934,8 +934,8 @@ void SDL::Event::createQuintuplets() { unsigned int nTotalQuintuplets = *alpaka::getPtrNative(nTotalQuintuplets_buf); if (quintupletsInGPU == nullptr) { - quintupletsInGPU = new SDL::quintuplets(); - quintupletsBuffers = new SDL::quintupletsBuffer(nTotalQuintuplets, nLowerModules_, devAcc, queue); + quintupletsInGPU = new SDL::Quintuplets(); + quintupletsBuffers = new SDL::QuintupletsBuffer(nTotalQuintuplets, nLowerModules_, devAcc, queue); quintupletsInGPU->setData(*quintupletsBuffers); alpaka::memcpy(queue, quintupletsBuffers->nMemoryLocations_buf, nTotalQuintuplets_buf); @@ -1014,13 +1014,13 @@ void SDL::Event::pixelLineSegmentCleaning(bool no_pls_dupclean) { void SDL::Event::createPixelQuintuplets() { if (pixelQuintupletsInGPU == nullptr) { - pixelQuintupletsInGPU = new SDL::pixelQuintuplets(); - pixelQuintupletsBuffers = new SDL::pixelQuintupletsBuffer(N_MAX_PIXEL_QUINTUPLETS, devAcc, queue); + pixelQuintupletsInGPU = new SDL::PixelQuintuplets(); + pixelQuintupletsBuffers = new SDL::PixelQuintupletsBuffer(N_MAX_PIXEL_QUINTUPLETS, devAcc, queue); pixelQuintupletsInGPU->setData(*pixelQuintupletsBuffers); } if (trackCandidatesInGPU == nullptr) { - trackCandidatesInGPU = new SDL::trackCandidates(); - trackCandidatesBuffers = new SDL::trackCandidatesBuffer( + trackCandidatesInGPU = new SDL::TrackCandidates(); + trackCandidatesBuffers = new SDL::TrackCandidatesBuffer( N_MAX_NONPIXEL_TRACK_CANDIDATES + N_MAX_PIXEL_TRACK_CANDIDATES, devAcc, queue); trackCandidatesInGPU->setData(*trackCandidatesBuffers); } @@ -1492,7 +1492,7 @@ int SDL::Event::getNumberOfT5TrackCandidates() { return nTrackCandidatesT5; } -SDL::hitsBuffer* SDL::Event::getHits() //std::shared_ptr should take care of garbage collection +SDL::HitsBuffer* SDL::Event::getHits() //std::shared_ptr should take care of garbage collection { if (hitsInCPU == nullptr) { auto nHits_buf = allocBufWrapper(devHost, 1, queue); @@ -1500,7 +1500,7 @@ SDL::hitsBuffer* SDL::Event::getHits() //std::shared_ptr should alpaka::wait(queue); unsigned int nHits = *alpaka::getPtrNative(nHits_buf); - hitsInCPU = new SDL::hitsBuffer(nModules_, nHits, devHost, queue); + hitsInCPU = new SDL::HitsBuffer(nModules_, nHits, devHost, queue); hitsInCPU->setData(*hitsInCPU); *alpaka::getPtrNative(hitsInCPU->nHits_buf) = nHits; @@ -1515,14 +1515,14 @@ SDL::hitsBuffer* SDL::Event::getHits() //std::shared_ptr should return hitsInCPU; } -SDL::hitsBuffer* SDL::Event::getHitsInCMSSW() { +SDL::HitsBuffer* SDL::Event::getHitsInCMSSW() { if (hitsInCPU == nullptr) { auto nHits_buf = allocBufWrapper(devHost, 1, queue); alpaka::memcpy(queue, nHits_buf, hitsBuffers->nHits_buf); alpaka::wait(queue); unsigned int nHits = *alpaka::getPtrNative(nHits_buf); - hitsInCPU = new SDL::hitsBuffer(nModules_, nHits, devHost, queue); + hitsInCPU = new SDL::HitsBuffer(nModules_, nHits, devHost, queue); hitsInCPU->setData(*hitsInCPU); *alpaka::getPtrNative(hitsInCPU->nHits_buf) = nHits; @@ -1532,9 +1532,9 @@ SDL::hitsBuffer* SDL::Event::getHitsInCMSSW() { return hitsInCPU; } -SDL::objectRangesBuffer* SDL::Event::getRanges() { +SDL::ObjectRangesBuffer* SDL::Event::getRanges() { if (rangesInCPU == nullptr) { - rangesInCPU = new SDL::objectRangesBuffer(nModules_, nLowerModules_, devHost, queue); + rangesInCPU = new SDL::ObjectRangesBuffer(nModules_, nLowerModules_, devHost, queue); rangesInCPU->setData(*rangesInCPU); alpaka::memcpy(queue, rangesInCPU->hitRanges_buf, rangesBuffers->hitRanges_buf); @@ -1547,7 +1547,7 @@ SDL::objectRangesBuffer* SDL::Event::getRanges() { return rangesInCPU; } -SDL::miniDoubletsBuffer* SDL::Event::getMiniDoublets() { +SDL::MiniDoubletsBuffer* SDL::Event::getMiniDoublets() { if (mdsInCPU == nullptr) { // Get nMemoryLocations parameter to initialize host based mdsInCPU auto nMemHost_buf = allocBufWrapper(devHost, 1, queue); @@ -1555,7 +1555,7 @@ SDL::miniDoubletsBuffer* SDL::Event::getMiniDoublets() { alpaka::wait(queue); unsigned int nMemHost = *alpaka::getPtrNative(nMemHost_buf); - mdsInCPU = new SDL::miniDoubletsBuffer(nMemHost, nLowerModules_, devHost, queue); + mdsInCPU = new SDL::MiniDoubletsBuffer(nMemHost, nLowerModules_, devHost, queue); mdsInCPU->setData(*mdsInCPU); *alpaka::getPtrNative(mdsInCPU->nMemoryLocations_buf) = nMemHost; @@ -1569,7 +1569,7 @@ SDL::miniDoubletsBuffer* SDL::Event::getMiniDoublets() { return mdsInCPU; } -SDL::segmentsBuffer* SDL::Event::getSegments() { +SDL::SegmentsBuffer* SDL::Event::getSegments() { if (segmentsInCPU == nullptr) { // Get nMemoryLocations parameter to initialize host based segmentsInCPU auto nMemHost_buf = allocBufWrapper(devHost, 1, queue); @@ -1578,7 +1578,7 @@ SDL::segmentsBuffer* SDL::Event::getSegments() { unsigned int nMemHost = *alpaka::getPtrNative(nMemHost_buf); segmentsInCPU = - new SDL::segmentsBuffer(nMemHost, nLowerModules_, N_MAX_PIXEL_SEGMENTS_PER_MODULE, devHost, queue); + new SDL::SegmentsBuffer(nMemHost, nLowerModules_, N_MAX_PIXEL_SEGMENTS_PER_MODULE, devHost, queue); segmentsInCPU->setData(*segmentsInCPU); *alpaka::getPtrNative(segmentsInCPU->nMemoryLocations_buf) = nMemHost; @@ -1605,7 +1605,7 @@ SDL::segmentsBuffer* SDL::Event::getSegments() { return segmentsInCPU; } -SDL::tripletsBuffer* SDL::Event::getTriplets() { +SDL::TripletsBuffer* SDL::Event::getTriplets() { if (tripletsInCPU == nullptr) { // Get nMemoryLocations parameter to initialize host based tripletsInCPU auto nMemHost_buf = allocBufWrapper(devHost, 1, queue); @@ -1613,7 +1613,7 @@ SDL::tripletsBuffer* SDL::Event::getTriplets() { alpaka::wait(queue); unsigned int nMemHost = *alpaka::getPtrNative(nMemHost_buf); - tripletsInCPU = new SDL::tripletsBuffer(nMemHost, nLowerModules_, devHost, queue); + tripletsInCPU = new SDL::TripletsBuffer(nMemHost, nLowerModules_, devHost, queue); tripletsInCPU->setData(*tripletsInCPU); *alpaka::getPtrNative(tripletsInCPU->nMemoryLocations_buf) = nMemHost; @@ -1641,7 +1641,7 @@ SDL::tripletsBuffer* SDL::Event::getTriplets() { return tripletsInCPU; } -SDL::quintupletsBuffer* SDL::Event::getQuintuplets() { +SDL::QuintupletsBuffer* SDL::Event::getQuintuplets() { if (quintupletsInCPU == nullptr) { // Get nMemoryLocations parameter to initialize host based quintupletsInCPU auto nMemHost_buf = allocBufWrapper(devHost, 1, queue); @@ -1649,7 +1649,7 @@ SDL::quintupletsBuffer* SDL::Event::getQuintuplets() { alpaka::wait(queue); unsigned int nMemHost = *alpaka::getPtrNative(nMemHost_buf); - quintupletsInCPU = new SDL::quintupletsBuffer(nMemHost, nLowerModules_, devHost, queue); + quintupletsInCPU = new SDL::QuintupletsBuffer(nMemHost, nLowerModules_, devHost, queue); quintupletsInCPU->setData(*quintupletsInCPU); *alpaka::getPtrNative(quintupletsInCPU->nMemoryLocations_buf) = nMemHost; @@ -1677,7 +1677,7 @@ SDL::quintupletsBuffer* SDL::Event::getQuintuplets() { return quintupletsInCPU; } -SDL::pixelTripletsBuffer* SDL::Event::getPixelTriplets() { +SDL::PixelTripletsBuffer* SDL::Event::getPixelTriplets() { if (pixelTripletsInCPU == nullptr) { // Get nPixelTriplets parameter to initialize host based quintupletsInCPU auto nPixelTriplets_buf = allocBufWrapper(devHost, 1, queue); @@ -1685,7 +1685,7 @@ SDL::pixelTripletsBuffer* SDL::Event::getPixelTriplets() { alpaka::wait(queue); unsigned int nPixelTriplets = *alpaka::getPtrNative(nPixelTriplets_buf); - pixelTripletsInCPU = new SDL::pixelTripletsBuffer(nPixelTriplets, devHost, queue); + pixelTripletsInCPU = new SDL::PixelTripletsBuffer(nPixelTriplets, devHost, queue); pixelTripletsInCPU->setData(*pixelTripletsInCPU); *alpaka::getPtrNative(pixelTripletsInCPU->nPixelTriplets_buf) = nPixelTriplets; @@ -1716,7 +1716,7 @@ SDL::pixelTripletsBuffer* SDL::Event::getPixelTriplets() { return pixelTripletsInCPU; } -SDL::pixelQuintupletsBuffer* SDL::Event::getPixelQuintuplets() { +SDL::PixelQuintupletsBuffer* SDL::Event::getPixelQuintuplets() { if (pixelQuintupletsInCPU == nullptr) { // Get nPixelQuintuplets parameter to initialize host based quintupletsInCPU auto nPixelQuintuplets_buf = allocBufWrapper(devHost, 1, queue); @@ -1724,7 +1724,7 @@ SDL::pixelQuintupletsBuffer* SDL::Event::getPixelQuintuplets() { alpaka::wait(queue); unsigned int nPixelQuintuplets = *alpaka::getPtrNative(nPixelQuintuplets_buf); - pixelQuintupletsInCPU = new SDL::pixelQuintupletsBuffer(nPixelQuintuplets, devHost, queue); + pixelQuintupletsInCPU = new SDL::PixelQuintupletsBuffer(nPixelQuintuplets, devHost, queue); pixelQuintupletsInCPU->setData(*pixelQuintupletsInCPU); *alpaka::getPtrNative(pixelQuintupletsInCPU->nPixelQuintuplets_buf) = nPixelQuintuplets; @@ -1752,7 +1752,7 @@ SDL::pixelQuintupletsBuffer* SDL::Event::getPixelQuintuplets() { return pixelQuintupletsInCPU; } -SDL::trackCandidatesBuffer* SDL::Event::getTrackCandidates() { +SDL::TrackCandidatesBuffer* SDL::Event::getTrackCandidates() { if (trackCandidatesInCPU == nullptr) { // Get nTrackCanHost parameter to initialize host based trackCandidatesInCPU auto nTrackCanHost_buf = allocBufWrapper(devHost, 1, queue); @@ -1760,7 +1760,7 @@ SDL::trackCandidatesBuffer* SDL::Event::getTrackCandidates() { alpaka::wait(queue); unsigned int nTrackCanHost = *alpaka::getPtrNative(nTrackCanHost_buf); - trackCandidatesInCPU = new SDL::trackCandidatesBuffer( + trackCandidatesInCPU = new SDL::TrackCandidatesBuffer( N_MAX_NONPIXEL_TRACK_CANDIDATES + N_MAX_PIXEL_TRACK_CANDIDATES, devHost, queue); trackCandidatesInCPU->setData(*trackCandidatesInCPU); @@ -1790,7 +1790,7 @@ SDL::trackCandidatesBuffer* SDL::Event::getTrackCandidates() { return trackCandidatesInCPU; } -SDL::trackCandidatesBuffer* SDL::Event::getTrackCandidatesInCMSSW() { +SDL::TrackCandidatesBuffer* SDL::Event::getTrackCandidatesInCMSSW() { if (trackCandidatesInCPU == nullptr) { // Get nTrackCanHost parameter to initialize host based trackCandidatesInCPU auto nTrackCanHost_buf = allocBufWrapper(devHost, 1, queue); @@ -1798,7 +1798,7 @@ SDL::trackCandidatesBuffer* SDL::Event::getTrackCandidatesInCMSS alpaka::wait(queue); unsigned int nTrackCanHost = *alpaka::getPtrNative(nTrackCanHost_buf); - trackCandidatesInCPU = new SDL::trackCandidatesBuffer( + trackCandidatesInCPU = new SDL::TrackCandidatesBuffer( N_MAX_NONPIXEL_TRACK_CANDIDATES + N_MAX_PIXEL_TRACK_CANDIDATES, devHost, queue); trackCandidatesInCPU->setData(*trackCandidatesInCPU); @@ -1818,10 +1818,10 @@ SDL::trackCandidatesBuffer* SDL::Event::getTrackCandidatesInCMSS return trackCandidatesInCPU; } -SDL::modulesBuffer* SDL::Event::getModules(bool isFull) { +SDL::ModulesBuffer* SDL::Event::getModules(bool isFull) { if (modulesInCPU == nullptr) { // The last input here is just a small placeholder for the allocation. - modulesInCPU = new SDL::modulesBuffer(devHost, nModules_, nPixels_); + modulesInCPU = new SDL::ModulesBuffer(devHost, nModules_, nPixels_); modulesInCPU->copyFromSrc(queue, *modulesBuffers_, isFull); } diff --git a/RecoTracker/LSTCore/src/alpaka/Event.h b/RecoTracker/LSTCore/src/alpaka/Event.h index 3c8dea32612af..281da93d07c9e 100644 --- a/RecoTracker/LSTCore/src/alpaka/Event.h +++ b/RecoTracker/LSTCore/src/alpaka/Event.h @@ -46,36 +46,36 @@ namespace SDL { //Device stuff unsigned int nTotalSegments; - struct objectRanges* rangesInGPU; - struct objectRangesBuffer* rangesBuffers; - struct hits* hitsInGPU; - struct hitsBuffer* hitsBuffers; - struct miniDoublets* mdsInGPU; - struct miniDoubletsBuffer* miniDoubletsBuffers; - struct segments* segmentsInGPU; - struct segmentsBuffer* segmentsBuffers; - struct triplets* tripletsInGPU; - struct tripletsBuffer* tripletsBuffers; - struct quintuplets* quintupletsInGPU; - struct quintupletsBuffer* quintupletsBuffers; - struct trackCandidates* trackCandidatesInGPU; - struct trackCandidatesBuffer* trackCandidatesBuffers; - struct pixelTriplets* pixelTripletsInGPU; - struct pixelTripletsBuffer* pixelTripletsBuffers; - struct pixelQuintuplets* pixelQuintupletsInGPU; - struct pixelQuintupletsBuffer* pixelQuintupletsBuffers; + struct ObjectRanges* rangesInGPU; + struct ObjectRangesBuffer* rangesBuffers; + struct Hits* hitsInGPU; + struct HitsBuffer* hitsBuffers; + struct MiniDoublets* mdsInGPU; + struct MiniDoubletsBuffer* miniDoubletsBuffers; + struct Segments* segmentsInGPU; + struct SegmentsBuffer* segmentsBuffers; + struct Triplets* tripletsInGPU; + struct TripletsBuffer* tripletsBuffers; + struct Quintuplets* quintupletsInGPU; + struct QuintupletsBuffer* quintupletsBuffers; + struct TrackCandidates* trackCandidatesInGPU; + struct TrackCandidatesBuffer* trackCandidatesBuffers; + struct PixelTriplets* pixelTripletsInGPU; + struct PixelTripletsBuffer* pixelTripletsBuffers; + struct PixelQuintuplets* pixelQuintupletsInGPU; + struct PixelQuintupletsBuffer* pixelQuintupletsBuffers; //CPU interface stuff - objectRangesBuffer* rangesInCPU; - hitsBuffer* hitsInCPU; - miniDoubletsBuffer* mdsInCPU; - segmentsBuffer* segmentsInCPU; - tripletsBuffer* tripletsInCPU; - trackCandidatesBuffer* trackCandidatesInCPU; - modulesBuffer* modulesInCPU; - quintupletsBuffer* quintupletsInCPU; - pixelTripletsBuffer* pixelTripletsInCPU; - pixelQuintupletsBuffer* pixelQuintupletsInCPU; + ObjectRangesBuffer* rangesInCPU; + HitsBuffer* hitsInCPU; + MiniDoubletsBuffer* mdsInCPU; + SegmentsBuffer* segmentsInCPU; + TripletsBuffer* tripletsInCPU; + TrackCandidatesBuffer* trackCandidatesInCPU; + ModulesBuffer* modulesInCPU; + QuintupletsBuffer* quintupletsInCPU; + PixelTripletsBuffer* pixelTripletsInCPU; + PixelQuintupletsBuffer* pixelQuintupletsInCPU; void init(bool verbose); @@ -87,7 +87,7 @@ namespace SDL { const uint16_t nLowerModules_; const unsigned int nPixels_; const unsigned int nEndCapMap_; - const std::shared_ptr> modulesBuffers_; + const std::shared_ptr> modulesBuffers_; const std::shared_ptr pixelMapping_; const std::shared_ptr> endcapGeometryBuffers_; @@ -188,18 +188,18 @@ namespace SDL { int getNumberOfPixelTriplets(); int getNumberOfPixelQuintuplets(); - objectRangesBuffer* getRanges(); - hitsBuffer* getHits(); - hitsBuffer* getHitsInCMSSW(); - miniDoubletsBuffer* getMiniDoublets(); - segmentsBuffer* getSegments(); - tripletsBuffer* getTriplets(); - quintupletsBuffer* getQuintuplets(); - trackCandidatesBuffer* getTrackCandidates(); - trackCandidatesBuffer* getTrackCandidatesInCMSSW(); - pixelTripletsBuffer* getPixelTriplets(); - pixelQuintupletsBuffer* getPixelQuintuplets(); - modulesBuffer* getModules(bool isFull = false); + ObjectRangesBuffer* getRanges(); + HitsBuffer* getHits(); + HitsBuffer* getHitsInCMSSW(); + MiniDoubletsBuffer* getMiniDoublets(); + SegmentsBuffer* getSegments(); + TripletsBuffer* getTriplets(); + QuintupletsBuffer* getQuintuplets(); + TrackCandidatesBuffer* getTrackCandidates(); + TrackCandidatesBuffer* getTrackCandidatesInCMSSW(); + PixelTripletsBuffer* getPixelTriplets(); + PixelQuintupletsBuffer* getPixelQuintuplets(); + ModulesBuffer* getModules(bool isFull = false); }; } // namespace SDL diff --git a/RecoTracker/LSTCore/src/alpaka/Hit.h b/RecoTracker/LSTCore/src/alpaka/Hit.h index 70c0976cd7480..ed5a074b56895 100644 --- a/RecoTracker/LSTCore/src/alpaka/Hit.h +++ b/RecoTracker/LSTCore/src/alpaka/Hit.h @@ -5,7 +5,7 @@ #include "RecoTracker/LSTCore/interface/Module.h" namespace SDL { - struct hits { + struct Hits { unsigned int* nHits; float* xs; float* ys; @@ -27,31 +27,31 @@ namespace SDL { int8_t* hitRangesnUpper; template - void setData(TBuff& hitsbuf) { - nHits = alpaka::getPtrNative(hitsbuf.nHits_buf); - xs = alpaka::getPtrNative(hitsbuf.xs_buf); - ys = alpaka::getPtrNative(hitsbuf.ys_buf); - zs = alpaka::getPtrNative(hitsbuf.zs_buf); - moduleIndices = alpaka::getPtrNative(hitsbuf.moduleIndices_buf); - idxs = alpaka::getPtrNative(hitsbuf.idxs_buf); - detid = alpaka::getPtrNative(hitsbuf.detid_buf); - rts = alpaka::getPtrNative(hitsbuf.rts_buf); - phis = alpaka::getPtrNative(hitsbuf.phis_buf); - etas = alpaka::getPtrNative(hitsbuf.etas_buf); - highEdgeXs = alpaka::getPtrNative(hitsbuf.highEdgeXs_buf); - highEdgeYs = alpaka::getPtrNative(hitsbuf.highEdgeYs_buf); - lowEdgeXs = alpaka::getPtrNative(hitsbuf.lowEdgeXs_buf); - lowEdgeYs = alpaka::getPtrNative(hitsbuf.lowEdgeYs_buf); - hitRanges = alpaka::getPtrNative(hitsbuf.hitRanges_buf); - hitRangesLower = alpaka::getPtrNative(hitsbuf.hitRangesLower_buf); - hitRangesUpper = alpaka::getPtrNative(hitsbuf.hitRangesUpper_buf); - hitRangesnLower = alpaka::getPtrNative(hitsbuf.hitRangesnLower_buf); - hitRangesnUpper = alpaka::getPtrNative(hitsbuf.hitRangesnUpper_buf); + void setData(TBuff& buf) { + nHits = alpaka::getPtrNative(buf.nHits_buf); + xs = alpaka::getPtrNative(buf.xs_buf); + ys = alpaka::getPtrNative(buf.ys_buf); + zs = alpaka::getPtrNative(buf.zs_buf); + moduleIndices = alpaka::getPtrNative(buf.moduleIndices_buf); + idxs = alpaka::getPtrNative(buf.idxs_buf); + detid = alpaka::getPtrNative(buf.detid_buf); + rts = alpaka::getPtrNative(buf.rts_buf); + phis = alpaka::getPtrNative(buf.phis_buf); + etas = alpaka::getPtrNative(buf.etas_buf); + highEdgeXs = alpaka::getPtrNative(buf.highEdgeXs_buf); + highEdgeYs = alpaka::getPtrNative(buf.highEdgeYs_buf); + lowEdgeXs = alpaka::getPtrNative(buf.lowEdgeXs_buf); + lowEdgeYs = alpaka::getPtrNative(buf.lowEdgeYs_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); } }; template - struct hitsBuffer : hits { + struct HitsBuffer { Buf nHits_buf; Buf xs_buf; Buf ys_buf; @@ -72,8 +72,10 @@ namespace SDL { Buf hitRangesnLower_buf; Buf hitRangesnUpper_buf; + Hits data_; + template - hitsBuffer(unsigned int nModules, unsigned int nMaxHits, TDevAcc const& devAccIn, TQueue& queue) + HitsBuffer(unsigned int nModules, unsigned int nMaxHits, TDevAcc const& devAccIn, TQueue& queue) : nHits_buf(allocBufWrapper(devAccIn, 1u, queue)), xs_buf(allocBufWrapper(devAccIn, nMaxHits, queue)), ys_buf(allocBufWrapper(devAccIn, nMaxHits, queue)), @@ -100,6 +102,9 @@ namespace SDL { alpaka::memset(queue, hitRangesnUpper_buf, 0xff); alpaka::wait(queue); } + + inline Hits const* data() const { return &data_; } + inline void setData(HitsBuffer& buf) { data_.setData(buf); } }; // Alpaka does not support log10 natively right now. @@ -189,8 +194,8 @@ namespace SDL { struct moduleRangesKernel { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct SDL::modules modulesInGPU, - struct SDL::hits hitsInGPU, + struct SDL::Modules modulesInGPU, + struct SDL::Hits hitsInGPU, int const& nLowerModules) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); @@ -218,8 +223,8 @@ namespace SDL { unsigned int nEndCapMap, // Number of elements in endcap map const unsigned int* geoMapDetId, // DetId's from endcap map const float* geoMapPhi, // Phi values from endcap map - struct SDL::modules modulesInGPU, - struct SDL::hits hitsInGPU, + struct SDL::Modules modulesInGPU, + struct SDL::Hits hitsInGPU, unsigned int const& nHits) const // Total number of hits in event { auto const globalThreadIdx = alpaka::getIdx(acc); diff --git a/RecoTracker/LSTCore/src/alpaka/Kernels.h b/RecoTracker/LSTCore/src/alpaka/Kernels.h index cd62fc5b8a268..b9072fb288269 100644 --- a/RecoTracker/LSTCore/src/alpaka/Kernels.h +++ b/RecoTracker/LSTCore/src/alpaka/Kernels.h @@ -6,29 +6,30 @@ #include "Hit.h" #include "MiniDoublet.h" +#include "ObjectRanges.h" #include "Segment.h" #include "Triplet.h" #include "Quintuplet.h" #include "PixelTriplet.h" namespace SDL { - ALPAKA_FN_ACC ALPAKA_FN_INLINE void rmQuintupletFromMemory(struct SDL::quintuplets& quintupletsInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE void rmQuintupletFromMemory(struct SDL::Quintuplets& quintupletsInGPU, unsigned int quintupletIndex, bool secondpass = false) { quintupletsInGPU.isDup[quintupletIndex] |= 1 + secondpass; }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE void rmPixelTripletFromMemory(struct SDL::pixelTriplets& pixelTripletsInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE void rmPixelTripletFromMemory(struct SDL::PixelTriplets& pixelTripletsInGPU, unsigned int pixelTripletIndex) { pixelTripletsInGPU.isDup[pixelTripletIndex] = true; }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE void rmPixelQuintupletFromMemory(struct SDL::pixelQuintuplets& pixelQuintupletsInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE void rmPixelQuintupletFromMemory(struct SDL::PixelQuintuplets& pixelQuintupletsInGPU, unsigned int pixelQuintupletIndex) { pixelQuintupletsInGPU.isDup[pixelQuintupletIndex] = true; }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE void rmPixelSegmentFromMemory(struct SDL::segments& segmentsInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE void rmPixelSegmentFromMemory(struct SDL::Segments& segmentsInGPU, unsigned int pixelSegmentArrayIndex, bool secondpass = false) { segmentsInGPU.isDup[pixelSegmentArrayIndex] |= 1 + secondpass; @@ -36,7 +37,7 @@ namespace SDL { ALPAKA_FN_ACC ALPAKA_FN_INLINE int checkHitsT5(unsigned int ix, unsigned int jx, - struct SDL::quintuplets& quintupletsInGPU) { + struct SDL::Quintuplets& quintupletsInGPU) { unsigned int hits1[Params_T5::kHits]; unsigned int hits2[Params_T5::kHits]; @@ -63,7 +64,7 @@ namespace SDL { ALPAKA_FN_ACC ALPAKA_FN_INLINE int checkHitspT5(unsigned int ix, unsigned int jx, - struct SDL::pixelQuintuplets& pixelQuintupletsInGPU) { + struct SDL::PixelQuintuplets& pixelQuintupletsInGPU) { unsigned int hits1[Params_pT5::kHits]; unsigned int hits2[Params_pT5::kHits]; @@ -90,7 +91,7 @@ namespace SDL { ALPAKA_FN_ACC ALPAKA_FN_INLINE void checkHitspT3(unsigned int ix, unsigned int jx, - struct SDL::pixelTriplets& pixelTripletsInGPU, + struct SDL::PixelTriplets& pixelTripletsInGPU, int* matched) { int phits1[Params_pLS::kHits]; int phits2[Params_pLS::kHits]; @@ -143,9 +144,9 @@ namespace SDL { struct removeDupQuintupletsInGPUAfterBuild { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct SDL::modules modulesInGPU, - struct SDL::quintuplets quintupletsInGPU, - struct SDL::objectRanges rangesInGPU) const { + struct SDL::Modules modulesInGPU, + struct SDL::Quintuplets quintupletsInGPU, + struct SDL::ObjectRanges rangesInGPU) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); @@ -193,8 +194,8 @@ namespace SDL { struct removeDupQuintupletsInGPUBeforeTC { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct SDL::quintuplets quintupletsInGPU, - struct SDL::objectRanges rangesInGPU) const { + struct SDL::Quintuplets quintupletsInGPU, + struct SDL::ObjectRanges rangesInGPU) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); @@ -267,7 +268,7 @@ namespace SDL { struct removeDupPixelTripletsInGPUFromMap { template - ALPAKA_FN_ACC void operator()(TAcc const& acc, struct SDL::pixelTriplets pixelTripletsInGPU) const { + ALPAKA_FN_ACC void operator()(TAcc const& acc, struct SDL::PixelTriplets pixelTripletsInGPU) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); @@ -304,7 +305,7 @@ namespace SDL { struct removeDupPixelQuintupletsInGPUFromMap { template - ALPAKA_FN_ACC void operator()(TAcc const& acc, struct SDL::pixelQuintuplets pixelQuintupletsInGPU) const { + ALPAKA_FN_ACC void operator()(TAcc const& acc, struct SDL::PixelQuintuplets pixelQuintupletsInGPU) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); @@ -332,8 +333,8 @@ namespace SDL { struct checkHitspLS { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct SDL::modules modulesInGPU, - struct SDL::segments segmentsInGPU, + struct SDL::Modules modulesInGPU, + struct SDL::Segments segmentsInGPU, bool secondpass) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); diff --git a/RecoTracker/LSTCore/src/alpaka/LST.dev.cc b/RecoTracker/LSTCore/src/alpaka/LST.dev.cc index 11efa869b12f3..79a80c1a66b9d 100644 --- a/RecoTracker/LSTCore/src/alpaka/LST.dev.cc +++ b/RecoTracker/LSTCore/src/alpaka/LST.dev.cc @@ -255,18 +255,18 @@ void SDL::LST::getOutput(SDL::Event& event) { std::vector tc_seedIdx; std::vector tc_trackCandidateType; - SDL::hitsBuffer& hitsInGPU = (*event.getHitsInCMSSW()); - SDL::trackCandidatesBuffer& trackCandidatesInGPU = (*event.getTrackCandidatesInCMSSW()); + SDL::HitsBuffer& hitsInGPU = (*event.getHitsInCMSSW()); + SDL::TrackCandidates const* trackCandidates = event.getTrackCandidatesInCMSSW()->data(); - unsigned int nTrackCandidates = *trackCandidatesInGPU.nTrackCandidates; + unsigned int nTrackCandidates = *trackCandidates->nTrackCandidates; for (unsigned int idx = 0; idx < nTrackCandidates; idx++) { - short trackCandidateType = trackCandidatesInGPU.trackCandidateType[idx]; + short trackCandidateType = trackCandidates->trackCandidateType[idx]; std::vector hit_idx = - getHitIdxs(trackCandidateType, idx, trackCandidatesInGPU.hitIndices, hitsInGPU.idxs); + getHitIdxs(trackCandidateType, idx, trackCandidates->hitIndices, hitsInGPU.data()->idxs); tc_hitIdxs.push_back(hit_idx); tc_len.push_back(hit_idx.size()); - tc_seedIdx.push_back(trackCandidatesInGPU.pixelSeedIndex[idx]); + tc_seedIdx.push_back(trackCandidates->pixelSeedIndex[idx]); tc_trackCandidateType.push_back(trackCandidateType); } @@ -429,4 +429,4 @@ void SDL::LST::run(Queue& queue, getOutput(event); event.resetEvent(); -} \ No newline at end of file +} diff --git a/RecoTracker/LSTCore/src/alpaka/MiniDoublet.h b/RecoTracker/LSTCore/src/alpaka/MiniDoublet.h index a0f5998f643b6..623f95a437e00 100644 --- a/RecoTracker/LSTCore/src/alpaka/MiniDoublet.h +++ b/RecoTracker/LSTCore/src/alpaka/MiniDoublet.h @@ -6,9 +6,10 @@ #include "RecoTracker/LSTCore/interface/EndcapGeometry.h" #include "Hit.h" +#include "ObjectRanges.h" namespace SDL { - struct miniDoublets { + struct MiniDoublets { unsigned int* nMemoryLocations; unsigned int* anchorHitIndices; @@ -53,49 +54,49 @@ namespace SDL { float* outerLowEdgeY; template - void setData(TBuf& mdsbuf) { - nMemoryLocations = alpaka::getPtrNative(mdsbuf.nMemoryLocations_buf); - anchorHitIndices = alpaka::getPtrNative(mdsbuf.anchorHitIndices_buf); - outerHitIndices = alpaka::getPtrNative(mdsbuf.outerHitIndices_buf); - moduleIndices = alpaka::getPtrNative(mdsbuf.moduleIndices_buf); - nMDs = alpaka::getPtrNative(mdsbuf.nMDs_buf); - totOccupancyMDs = alpaka::getPtrNative(mdsbuf.totOccupancyMDs_buf); - dphichanges = alpaka::getPtrNative(mdsbuf.dphichanges_buf); - dzs = alpaka::getPtrNative(mdsbuf.dzs_buf); - dphis = alpaka::getPtrNative(mdsbuf.dphis_buf); - shiftedXs = alpaka::getPtrNative(mdsbuf.shiftedXs_buf); - shiftedYs = alpaka::getPtrNative(mdsbuf.shiftedYs_buf); - shiftedZs = alpaka::getPtrNative(mdsbuf.shiftedZs_buf); - noShiftedDzs = alpaka::getPtrNative(mdsbuf.noShiftedDzs_buf); - noShiftedDphis = alpaka::getPtrNative(mdsbuf.noShiftedDphis_buf); - noShiftedDphiChanges = alpaka::getPtrNative(mdsbuf.noShiftedDphiChanges_buf); - anchorX = alpaka::getPtrNative(mdsbuf.anchorX_buf); - anchorY = alpaka::getPtrNative(mdsbuf.anchorY_buf); - anchorZ = alpaka::getPtrNative(mdsbuf.anchorZ_buf); - anchorRt = alpaka::getPtrNative(mdsbuf.anchorRt_buf); - anchorPhi = alpaka::getPtrNative(mdsbuf.anchorPhi_buf); - anchorEta = alpaka::getPtrNative(mdsbuf.anchorEta_buf); - anchorHighEdgeX = alpaka::getPtrNative(mdsbuf.anchorHighEdgeX_buf); - anchorHighEdgeY = alpaka::getPtrNative(mdsbuf.anchorHighEdgeY_buf); - anchorLowEdgeX = alpaka::getPtrNative(mdsbuf.anchorLowEdgeX_buf); - anchorLowEdgeY = alpaka::getPtrNative(mdsbuf.anchorLowEdgeY_buf); - outerX = alpaka::getPtrNative(mdsbuf.outerX_buf); - outerY = alpaka::getPtrNative(mdsbuf.outerY_buf); - outerZ = alpaka::getPtrNative(mdsbuf.outerZ_buf); - outerRt = alpaka::getPtrNative(mdsbuf.outerRt_buf); - outerPhi = alpaka::getPtrNative(mdsbuf.outerPhi_buf); - outerEta = alpaka::getPtrNative(mdsbuf.outerEta_buf); - outerHighEdgeX = alpaka::getPtrNative(mdsbuf.outerHighEdgeX_buf); - outerHighEdgeY = alpaka::getPtrNative(mdsbuf.outerHighEdgeY_buf); - outerLowEdgeX = alpaka::getPtrNative(mdsbuf.outerLowEdgeX_buf); - outerLowEdgeY = alpaka::getPtrNative(mdsbuf.outerLowEdgeY_buf); - anchorLowEdgePhi = alpaka::getPtrNative(mdsbuf.anchorLowEdgePhi_buf); - anchorHighEdgePhi = alpaka::getPtrNative(mdsbuf.anchorHighEdgePhi_buf); + void setData(TBuf& buf) { + nMemoryLocations = alpaka::getPtrNative(buf.nMemoryLocations_buf); + anchorHitIndices = alpaka::getPtrNative(buf.anchorHitIndices_buf); + outerHitIndices = alpaka::getPtrNative(buf.outerHitIndices_buf); + moduleIndices = alpaka::getPtrNative(buf.moduleIndices_buf); + nMDs = alpaka::getPtrNative(buf.nMDs_buf); + totOccupancyMDs = alpaka::getPtrNative(buf.totOccupancyMDs_buf); + dphichanges = alpaka::getPtrNative(buf.dphichanges_buf); + dzs = alpaka::getPtrNative(buf.dzs_buf); + dphis = alpaka::getPtrNative(buf.dphis_buf); + shiftedXs = alpaka::getPtrNative(buf.shiftedXs_buf); + shiftedYs = alpaka::getPtrNative(buf.shiftedYs_buf); + shiftedZs = alpaka::getPtrNative(buf.shiftedZs_buf); + noShiftedDzs = alpaka::getPtrNative(buf.noShiftedDzs_buf); + noShiftedDphis = alpaka::getPtrNative(buf.noShiftedDphis_buf); + noShiftedDphiChanges = alpaka::getPtrNative(buf.noShiftedDphiChanges_buf); + anchorX = alpaka::getPtrNative(buf.anchorX_buf); + anchorY = alpaka::getPtrNative(buf.anchorY_buf); + anchorZ = alpaka::getPtrNative(buf.anchorZ_buf); + anchorRt = alpaka::getPtrNative(buf.anchorRt_buf); + anchorPhi = alpaka::getPtrNative(buf.anchorPhi_buf); + anchorEta = alpaka::getPtrNative(buf.anchorEta_buf); + anchorHighEdgeX = alpaka::getPtrNative(buf.anchorHighEdgeX_buf); + anchorHighEdgeY = alpaka::getPtrNative(buf.anchorHighEdgeY_buf); + anchorLowEdgeX = alpaka::getPtrNative(buf.anchorLowEdgeX_buf); + anchorLowEdgeY = alpaka::getPtrNative(buf.anchorLowEdgeY_buf); + outerX = alpaka::getPtrNative(buf.outerX_buf); + outerY = alpaka::getPtrNative(buf.outerY_buf); + outerZ = alpaka::getPtrNative(buf.outerZ_buf); + outerRt = alpaka::getPtrNative(buf.outerRt_buf); + outerPhi = alpaka::getPtrNative(buf.outerPhi_buf); + outerEta = alpaka::getPtrNative(buf.outerEta_buf); + outerHighEdgeX = alpaka::getPtrNative(buf.outerHighEdgeX_buf); + outerHighEdgeY = alpaka::getPtrNative(buf.outerHighEdgeY_buf); + outerLowEdgeX = alpaka::getPtrNative(buf.outerLowEdgeX_buf); + outerLowEdgeY = alpaka::getPtrNative(buf.outerLowEdgeY_buf); + anchorLowEdgePhi = alpaka::getPtrNative(buf.anchorLowEdgePhi_buf); + anchorHighEdgePhi = alpaka::getPtrNative(buf.anchorHighEdgePhi_buf); } }; template - struct miniDoubletsBuffer : miniDoublets { + struct MiniDoubletsBuffer { Buf nMemoryLocations_buf; Buf anchorHitIndices_buf; @@ -139,8 +140,10 @@ namespace SDL { Buf outerLowEdgeX_buf; Buf outerLowEdgeY_buf; + MiniDoublets data_; + template - miniDoubletsBuffer(unsigned int nMemoryLoc, uint16_t nLowerModules, TDevAcc const& devAccIn, TQueue& queue) + MiniDoubletsBuffer(unsigned int nMemoryLoc, uint16_t nLowerModules, TDevAcc const& devAccIn, TQueue& queue) : nMemoryLocations_buf(allocBufWrapper(devAccIn, 1, queue)), anchorHitIndices_buf(allocBufWrapper(devAccIn, nMemoryLoc, queue)), outerHitIndices_buf(allocBufWrapper(devAccIn, nMemoryLoc, queue)), @@ -182,13 +185,16 @@ namespace SDL { alpaka::memset(queue, totOccupancyMDs_buf, 0u); alpaka::wait(queue); } + + inline MiniDoublets const* data() const { return &data_; } + inline void setData(MiniDoubletsBuffer& buf) { data_.setData(buf); } }; template ALPAKA_FN_ACC ALPAKA_FN_INLINE void addMDToMemory(TAcc const& acc, - struct SDL::miniDoublets& mdsInGPU, - struct SDL::hits& hitsInGPU, - struct SDL::modules& modulesInGPU, + struct SDL::MiniDoublets& mdsInGPU, + struct SDL::Hits& hitsInGPU, + struct SDL::Modules& modulesInGPU, unsigned int lowerHitIdx, unsigned int upperHitIdx, uint16_t& lowerModuleIdx, @@ -260,7 +266,7 @@ namespace SDL { mdsInGPU.outerLowEdgeY[idx] = hitsInGPU.lowEdgeYs[outerHitIndex]; }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE float isTighterTiltedModules(struct SDL::modules& modulesInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE float isTighterTiltedModules(struct SDL::Modules& modulesInGPU, uint16_t& moduleIndex) { // The "tighter" tilted modules are the subset of tilted modules that have smaller spacing // This is the same as what was previously considered as"isNormalTiltedModules" @@ -281,7 +287,7 @@ namespace SDL { return false; }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE float moduleGapSize(struct SDL::modules& modulesInGPU, uint16_t& moduleIndex) { + ALPAKA_FN_ACC ALPAKA_FN_INLINE float moduleGapSize(struct SDL::Modules& modulesInGPU, uint16_t& moduleIndex) { float miniDeltaTilted[3] = {0.26f, 0.26f, 0.26f}; float miniDeltaFlat[6] = {0.26f, 0.16f, 0.16f, 0.18f, 0.18f, 0.18f}; float miniDeltaLooseTilted[3] = {0.4f, 0.4f, 0.4f}; @@ -335,7 +341,7 @@ namespace SDL { template ALPAKA_FN_ACC ALPAKA_FN_INLINE float dPhiThreshold(TAcc const& acc, float rt, - struct SDL::modules& modulesInGPU, + struct SDL::Modules& modulesInGPU, uint16_t& moduleIndex, float dPhi = 0, float dz = 0) { @@ -397,7 +403,7 @@ namespace SDL { template ALPAKA_FN_INLINE ALPAKA_FN_ACC void shiftStripHits(TAcc const& acc, - struct SDL::modules& modulesInGPU, + struct SDL::Modules& modulesInGPU, uint16_t& lowerModuleIndex, uint16_t& upperModuleIndex, unsigned int lowerHitIndex, @@ -563,7 +569,7 @@ namespace SDL { template ALPAKA_FN_ACC bool runMiniDoubletDefaultAlgo(TAcc const& acc, - struct SDL::modules& modulesInGPU, + struct SDL::Modules& modulesInGPU, uint16_t& lowerModuleIndex, uint16_t& upperModuleIndex, unsigned int lowerHitIndex, @@ -638,7 +644,7 @@ namespace SDL { template ALPAKA_FN_ACC bool runMiniDoubletDefaultAlgoBarrel(TAcc const& acc, - struct SDL::modules& modulesInGPU, + struct SDL::Modules& modulesInGPU, uint16_t& lowerModuleIndex, uint16_t& upperModuleIndex, unsigned int lowerHitIndex, @@ -769,7 +775,7 @@ namespace SDL { template ALPAKA_FN_ACC bool runMiniDoubletDefaultAlgoEndcap(TAcc const& acc, - struct SDL::modules& modulesInGPU, + struct SDL::Modules& modulesInGPU, uint16_t& lowerModuleIndex, uint16_t& upperModuleIndex, unsigned int lowerHitIndex, @@ -883,10 +889,10 @@ namespace SDL { struct createMiniDoubletsInGPUv2 { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct SDL::modules modulesInGPU, - struct SDL::hits hitsInGPU, - struct SDL::miniDoublets mdsInGPU, - struct SDL::objectRanges rangesInGPU) const { + struct SDL::Modules modulesInGPU, + struct SDL::Hits hitsInGPU, + struct SDL::MiniDoublets mdsInGPU, + struct SDL::ObjectRanges rangesInGPU) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); @@ -981,8 +987,8 @@ namespace SDL { struct createMDArrayRangesGPU { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct SDL::modules modulesInGPU, - struct SDL::objectRanges rangesInGPU) const { + struct SDL::Modules modulesInGPU, + struct SDL::ObjectRanges rangesInGPU) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); @@ -1071,10 +1077,10 @@ namespace SDL { struct addMiniDoubletRangesToEventExplicit { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct SDL::modules modulesInGPU, - struct SDL::miniDoublets mdsInGPU, - struct SDL::objectRanges rangesInGPU, - struct SDL::hits hitsInGPU) const { + struct SDL::Modules modulesInGPU, + struct SDL::MiniDoublets mdsInGPU, + struct SDL::ObjectRanges rangesInGPU, + struct SDL::Hits hitsInGPU) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); diff --git a/RecoTracker/LSTCore/src/alpaka/NeuralNetwork.h b/RecoTracker/LSTCore/src/alpaka/NeuralNetwork.h index cc86d60b54af0..8a45d1f8872d5 100644 --- a/RecoTracker/LSTCore/src/alpaka/NeuralNetwork.h +++ b/RecoTracker/LSTCore/src/alpaka/NeuralNetwork.h @@ -14,10 +14,10 @@ namespace T5DNN { template ALPAKA_FN_ACC ALPAKA_FN_INLINE float runInference(TAcc const& acc, - struct SDL::modules& modulesInGPU, - struct SDL::miniDoublets& mdsInGPU, - struct SDL::segments& segmentsInGPU, - struct SDL::triplets& tripletsInGPU, + struct SDL::Modules& modulesInGPU, + struct SDL::MiniDoublets& mdsInGPU, + struct SDL::Segments& segmentsInGPU, + struct SDL::Triplets& tripletsInGPU, const float* xVec, const float* yVec, const unsigned int* mdIndices, 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 diff --git a/RecoTracker/LSTCore/src/alpaka/PixelTriplet.h b/RecoTracker/LSTCore/src/alpaka/PixelTriplet.h index 3f73fb53f717b..bc933469aa022 100644 --- a/RecoTracker/LSTCore/src/alpaka/PixelTriplet.h +++ b/RecoTracker/LSTCore/src/alpaka/PixelTriplet.h @@ -8,11 +8,12 @@ #include "Segment.h" #include "MiniDoublet.h" #include "Hit.h" +#include "ObjectRanges.h" #include "Quintuplet.h" namespace SDL { // One pixel segment, one outer tracker triplet! - struct pixelTriplets { + struct PixelTriplets { unsigned int* pixelSegmentIndices; unsigned int* tripletIndices; unsigned int* nPixelTriplets; @@ -41,35 +42,35 @@ namespace SDL { FPX* centerY; template - void setData(TBuff& pixelTripletsBuffer) { - pixelSegmentIndices = alpaka::getPtrNative(pixelTripletsBuffer.pixelSegmentIndices_buf); - tripletIndices = alpaka::getPtrNative(pixelTripletsBuffer.tripletIndices_buf); - nPixelTriplets = alpaka::getPtrNative(pixelTripletsBuffer.nPixelTriplets_buf); - totOccupancyPixelTriplets = alpaka::getPtrNative(pixelTripletsBuffer.totOccupancyPixelTriplets_buf); - pixelRadius = alpaka::getPtrNative(pixelTripletsBuffer.pixelRadius_buf); - tripletRadius = alpaka::getPtrNative(pixelTripletsBuffer.tripletRadius_buf); - pt = alpaka::getPtrNative(pixelTripletsBuffer.pt_buf); - eta = alpaka::getPtrNative(pixelTripletsBuffer.eta_buf); - phi = alpaka::getPtrNative(pixelTripletsBuffer.phi_buf); - eta_pix = alpaka::getPtrNative(pixelTripletsBuffer.eta_pix_buf); - phi_pix = alpaka::getPtrNative(pixelTripletsBuffer.phi_pix_buf); - score = alpaka::getPtrNative(pixelTripletsBuffer.score_buf); - isDup = alpaka::getPtrNative(pixelTripletsBuffer.isDup_buf); - partOfPT5 = alpaka::getPtrNative(pixelTripletsBuffer.partOfPT5_buf); - logicalLayers = alpaka::getPtrNative(pixelTripletsBuffer.logicalLayers_buf); - hitIndices = alpaka::getPtrNative(pixelTripletsBuffer.hitIndices_buf); - lowerModuleIndices = alpaka::getPtrNative(pixelTripletsBuffer.lowerModuleIndices_buf); - centerX = alpaka::getPtrNative(pixelTripletsBuffer.centerX_buf); - centerY = alpaka::getPtrNative(pixelTripletsBuffer.centerY_buf); - pixelRadiusError = alpaka::getPtrNative(pixelTripletsBuffer.pixelRadiusError_buf); - rPhiChiSquared = alpaka::getPtrNative(pixelTripletsBuffer.rPhiChiSquared_buf); - rPhiChiSquaredInwards = alpaka::getPtrNative(pixelTripletsBuffer.rPhiChiSquaredInwards_buf); - rzChiSquared = alpaka::getPtrNative(pixelTripletsBuffer.rzChiSquared_buf); + void setData(TBuff& buf) { + pixelSegmentIndices = alpaka::getPtrNative(buf.pixelSegmentIndices_buf); + tripletIndices = alpaka::getPtrNative(buf.tripletIndices_buf); + nPixelTriplets = alpaka::getPtrNative(buf.nPixelTriplets_buf); + totOccupancyPixelTriplets = alpaka::getPtrNative(buf.totOccupancyPixelTriplets_buf); + pixelRadius = alpaka::getPtrNative(buf.pixelRadius_buf); + tripletRadius = alpaka::getPtrNative(buf.tripletRadius_buf); + pt = alpaka::getPtrNative(buf.pt_buf); + eta = alpaka::getPtrNative(buf.eta_buf); + phi = alpaka::getPtrNative(buf.phi_buf); + eta_pix = alpaka::getPtrNative(buf.eta_pix_buf); + phi_pix = alpaka::getPtrNative(buf.phi_pix_buf); + score = alpaka::getPtrNative(buf.score_buf); + isDup = alpaka::getPtrNative(buf.isDup_buf); + partOfPT5 = alpaka::getPtrNative(buf.partOfPT5_buf); + logicalLayers = alpaka::getPtrNative(buf.logicalLayers_buf); + hitIndices = alpaka::getPtrNative(buf.hitIndices_buf); + lowerModuleIndices = alpaka::getPtrNative(buf.lowerModuleIndices_buf); + centerX = alpaka::getPtrNative(buf.centerX_buf); + centerY = alpaka::getPtrNative(buf.centerY_buf); + pixelRadiusError = alpaka::getPtrNative(buf.pixelRadiusError_buf); + rPhiChiSquared = alpaka::getPtrNative(buf.rPhiChiSquared_buf); + rPhiChiSquaredInwards = alpaka::getPtrNative(buf.rPhiChiSquaredInwards_buf); + rzChiSquared = alpaka::getPtrNative(buf.rzChiSquared_buf); } }; template - struct pixelTripletsBuffer : pixelTriplets { + struct PixelTripletsBuffer { Buf pixelSegmentIndices_buf; Buf tripletIndices_buf; Buf nPixelTriplets_buf; @@ -94,8 +95,10 @@ namespace SDL { Buf rPhiChiSquaredInwards_buf; Buf rzChiSquared_buf; + PixelTriplets data_; + template - pixelTripletsBuffer(unsigned int maxPixelTriplets, TDevAcc const& devAccIn, TQueue& queue) + PixelTripletsBuffer(unsigned int maxPixelTriplets, TDevAcc const& devAccIn, TQueue& queue) : pixelSegmentIndices_buf(allocBufWrapper(devAccIn, maxPixelTriplets, queue)), tripletIndices_buf(allocBufWrapper(devAccIn, maxPixelTriplets, queue)), nPixelTriplets_buf(allocBufWrapper(devAccIn, 1, queue)), @@ -124,13 +127,16 @@ namespace SDL { alpaka::memset(queue, partOfPT5_buf, false); alpaka::wait(queue); } + + inline PixelTriplets const* data() const { return &data_; } + inline void setData(PixelTripletsBuffer& buf) { data_.setData(buf); } }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE void addPixelTripletToMemory(struct SDL::modules& modulesInGPU, - struct SDL::miniDoublets& mdsInGPU, - struct SDL::segments& segmentsInGPU, - struct SDL::triplets& tripletsInGPU, - struct SDL::pixelTriplets& pixelTripletsInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE void addPixelTripletToMemory(struct SDL::Modules& modulesInGPU, + struct SDL::MiniDoublets& mdsInGPU, + struct SDL::Segments& segmentsInGPU, + struct SDL::Triplets& tripletsInGPU, + struct SDL::PixelTriplets& pixelTripletsInGPU, unsigned int pixelSegmentIndex, unsigned int tripletIndex, float pixelRadius, @@ -208,10 +214,10 @@ namespace SDL { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runPixelTrackletDefaultAlgopT3(TAcc const& acc, - struct SDL::modules& modulesInGPU, - struct SDL::objectRanges& rangesInGPU, - struct SDL::miniDoublets& mdsInGPU, - struct SDL::segments& segmentsInGPU, + struct SDL::Modules& modulesInGPU, + struct SDL::ObjectRanges& rangesInGPU, + struct SDL::MiniDoublets& mdsInGPU, + struct SDL::Segments& segmentsInGPU, uint16_t& pixelLowerModuleIndex, uint16_t& outerInnerLowerModuleIndex, uint16_t& outerOuterLowerModuleIndex, @@ -317,7 +323,7 @@ namespace SDL { return false; }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT3RZChiSquaredCuts(struct SDL::modules& modulesInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT3RZChiSquaredCuts(struct SDL::Modules& modulesInGPU, uint16_t& lowerModuleIndex1, uint16_t& lowerModuleIndex2, uint16_t& lowerModuleIndex3, @@ -420,7 +426,7 @@ namespace SDL { //TODO: merge this one and the pT5 function later into a single function template ALPAKA_FN_ACC ALPAKA_FN_INLINE float computePT3RPhiChiSquared(TAcc const& acc, - struct SDL::modules& modulesInGPU, + struct SDL::Modules& modulesInGPU, uint16_t* lowerModuleIndices, float& g, float& f, @@ -490,7 +496,7 @@ namespace SDL { }; ALPAKA_FN_ACC ALPAKA_FN_INLINE float computePT3RPhiChiSquaredInwards( - struct SDL::modules& modulesInGPU, float& g, float& f, float& r, float* xPix, float* yPix) { + struct SDL::Modules& modulesInGPU, float& g, float& f, float& r, float* xPix, float* yPix) { float residual = (xPix[0] - g) * (xPix[0] - g) + (yPix[0] - f) * (yPix[0] - f) - r * r; float chiSquared = residual * residual; residual = (xPix[1] - g) * (xPix[1] - g) + (yPix[1] - f) * (yPix[1] - f) - r * r; @@ -501,7 +507,7 @@ namespace SDL { }; //90pc threshold - ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT3RPhiChiSquaredCuts(struct SDL::modules& modulesInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT3RPhiChiSquaredCuts(struct SDL::Modules& modulesInGPU, uint16_t& lowerModuleIndex1, uint16_t& lowerModuleIndex2, uint16_t& lowerModuleIndex3, @@ -548,7 +554,7 @@ namespace SDL { return true; }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT3RPhiChiSquaredInwardsCuts(struct SDL::modules& modulesInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT3RPhiChiSquaredInwardsCuts(struct SDL::Modules& modulesInGPU, uint16_t& lowerModuleIndex1, uint16_t& lowerModuleIndex2, uint16_t& lowerModuleIndex3, @@ -717,7 +723,7 @@ namespace SDL { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passRadiusCriterion(TAcc const& acc, - struct SDL::modules const& modulesInGPU, + struct SDL::Modules const& modulesInGPU, float const& pixelRadius, float const& pixelRadiusError, float const& tripletRadius, @@ -737,7 +743,7 @@ namespace SDL { template ALPAKA_FN_ACC ALPAKA_FN_INLINE float computePT3RZChiSquared(TAcc const& acc, - struct SDL::modules const& modulesInGPU, + struct SDL::Modules const& modulesInGPU, const uint16_t* lowerModuleIndices, const float* rtPix, const float* xPix, @@ -826,11 +832,11 @@ namespace SDL { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runPixelTripletDefaultAlgo(TAcc const& acc, - struct SDL::modules& modulesInGPU, - struct SDL::objectRanges& rangesInGPU, - struct SDL::miniDoublets& mdsInGPU, - struct SDL::segments& segmentsInGPU, - struct SDL::triplets& tripletsInGPU, + struct SDL::Modules& modulesInGPU, + struct SDL::ObjectRanges& rangesInGPU, + struct SDL::MiniDoublets& mdsInGPU, + struct SDL::Segments& segmentsInGPU, + struct SDL::Triplets& tripletsInGPU, unsigned int& pixelSegmentIndex, unsigned int tripletIndex, float& pixelRadius, @@ -1023,12 +1029,12 @@ namespace SDL { struct createPixelTripletsInGPUFromMapv2 { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct SDL::modules modulesInGPU, - struct SDL::objectRanges rangesInGPU, - struct SDL::miniDoublets mdsInGPU, - struct SDL::segments segmentsInGPU, - struct SDL::triplets tripletsInGPU, - struct SDL::pixelTriplets pixelTripletsInGPU, + struct SDL::Modules modulesInGPU, + struct SDL::ObjectRanges rangesInGPU, + struct SDL::MiniDoublets mdsInGPU, + struct SDL::Segments segmentsInGPU, + struct SDL::Triplets tripletsInGPU, + struct SDL::PixelTriplets pixelTripletsInGPU, unsigned int* connectedPixelSize, unsigned int* connectedPixelIndex, unsigned int nPixelSegments) const { @@ -1259,10 +1265,10 @@ namespace SDL { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runTripletDefaultAlgoPPBB(TAcc const& acc, - struct SDL::modules& modulesInGPU, - struct SDL::objectRanges& rangesInGPU, - struct SDL::miniDoublets& mdsInGPU, - struct SDL::segments& segmentsInGPU, + struct SDL::Modules& modulesInGPU, + struct SDL::ObjectRanges& rangesInGPU, + struct SDL::MiniDoublets& mdsInGPU, + struct SDL::Segments& segmentsInGPU, uint16_t& pixelModuleIndex, uint16_t& outerInnerLowerModuleIndex, uint16_t& outerOuterLowerModuleIndex, @@ -1538,10 +1544,10 @@ namespace SDL { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runTripletDefaultAlgoPPEE(TAcc const& acc, - struct SDL::modules& modulesInGPU, - struct SDL::objectRanges& rangesInGPU, - struct SDL::miniDoublets& mdsInGPU, - struct SDL::segments& segmentsInGPU, + struct SDL::Modules& modulesInGPU, + struct SDL::ObjectRanges& rangesInGPU, + struct SDL::MiniDoublets& mdsInGPU, + struct SDL::Segments& segmentsInGPU, uint16_t& pixelModuleIndex, uint16_t& outerInnerLowerModuleIndex, uint16_t& outerOuterLowerModuleIndex, @@ -1838,7 +1844,7 @@ namespace SDL { #include "PixelTriplet.h" namespace SDL { - struct pixelQuintuplets { + struct PixelQuintuplets { unsigned int* pixelIndices; unsigned int* T5Indices; unsigned int* nPixelQuintuplets; @@ -1859,30 +1865,30 @@ namespace SDL { float* rPhiChiSquaredInwards; template - void setData(TBuff& pixelQuintupletsBuffer) { - pixelIndices = alpaka::getPtrNative(pixelQuintupletsBuffer.pixelIndices_buf); - T5Indices = alpaka::getPtrNative(pixelQuintupletsBuffer.T5Indices_buf); - nPixelQuintuplets = alpaka::getPtrNative(pixelQuintupletsBuffer.nPixelQuintuplets_buf); - totOccupancyPixelQuintuplets = alpaka::getPtrNative(pixelQuintupletsBuffer.totOccupancyPixelQuintuplets_buf); - isDup = alpaka::getPtrNative(pixelQuintupletsBuffer.isDup_buf); - score = alpaka::getPtrNative(pixelQuintupletsBuffer.score_buf); - eta = alpaka::getPtrNative(pixelQuintupletsBuffer.eta_buf); - phi = alpaka::getPtrNative(pixelQuintupletsBuffer.phi_buf); - logicalLayers = alpaka::getPtrNative(pixelQuintupletsBuffer.logicalLayers_buf); - hitIndices = alpaka::getPtrNative(pixelQuintupletsBuffer.hitIndices_buf); - lowerModuleIndices = alpaka::getPtrNative(pixelQuintupletsBuffer.lowerModuleIndices_buf); - pixelRadius = alpaka::getPtrNative(pixelQuintupletsBuffer.pixelRadius_buf); - quintupletRadius = alpaka::getPtrNative(pixelQuintupletsBuffer.quintupletRadius_buf); - centerX = alpaka::getPtrNative(pixelQuintupletsBuffer.centerX_buf); - centerY = alpaka::getPtrNative(pixelQuintupletsBuffer.centerY_buf); - rzChiSquared = alpaka::getPtrNative(pixelQuintupletsBuffer.rzChiSquared_buf); - rPhiChiSquared = alpaka::getPtrNative(pixelQuintupletsBuffer.rPhiChiSquared_buf); - rPhiChiSquaredInwards = alpaka::getPtrNative(pixelQuintupletsBuffer.rPhiChiSquaredInwards_buf); + void setData(TBuff& buf) { + pixelIndices = alpaka::getPtrNative(buf.pixelIndices_buf); + T5Indices = alpaka::getPtrNative(buf.T5Indices_buf); + nPixelQuintuplets = alpaka::getPtrNative(buf.nPixelQuintuplets_buf); + totOccupancyPixelQuintuplets = alpaka::getPtrNative(buf.totOccupancyPixelQuintuplets_buf); + isDup = alpaka::getPtrNative(buf.isDup_buf); + score = alpaka::getPtrNative(buf.score_buf); + eta = alpaka::getPtrNative(buf.eta_buf); + phi = alpaka::getPtrNative(buf.phi_buf); + logicalLayers = alpaka::getPtrNative(buf.logicalLayers_buf); + hitIndices = alpaka::getPtrNative(buf.hitIndices_buf); + lowerModuleIndices = alpaka::getPtrNative(buf.lowerModuleIndices_buf); + pixelRadius = alpaka::getPtrNative(buf.pixelRadius_buf); + quintupletRadius = alpaka::getPtrNative(buf.quintupletRadius_buf); + centerX = alpaka::getPtrNative(buf.centerX_buf); + centerY = alpaka::getPtrNative(buf.centerY_buf); + rzChiSquared = alpaka::getPtrNative(buf.rzChiSquared_buf); + rPhiChiSquared = alpaka::getPtrNative(buf.rPhiChiSquared_buf); + rPhiChiSquaredInwards = alpaka::getPtrNative(buf.rPhiChiSquaredInwards_buf); } }; template - struct pixelQuintupletsBuffer : pixelQuintuplets { + struct PixelQuintupletsBuffer { Buf pixelIndices_buf; Buf T5Indices_buf; Buf nPixelQuintuplets_buf; @@ -1902,8 +1908,10 @@ namespace SDL { Buf rPhiChiSquared_buf; Buf rPhiChiSquaredInwards_buf; + PixelQuintuplets data_; + template - pixelQuintupletsBuffer(unsigned int maxPixelQuintuplets, TDevAcc const& devAccIn, TQueue& queue) + PixelQuintupletsBuffer(unsigned int maxPixelQuintuplets, TDevAcc const& devAccIn, TQueue& queue) : pixelIndices_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)), T5Indices_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)), nPixelQuintuplets_buf(allocBufWrapper(devAccIn, 1, queue)), @@ -1926,13 +1934,16 @@ namespace SDL { alpaka::memset(queue, totOccupancyPixelQuintuplets_buf, 0u); alpaka::wait(queue); } + + inline PixelQuintuplets const* data() const { return &data_; } + inline void setData(PixelQuintupletsBuffer& buf) { data_.setData(buf); } }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE void addPixelQuintupletToMemory(struct SDL::modules& modulesInGPU, - struct SDL::miniDoublets& mdsInGPU, - struct SDL::segments& segmentsInGPU, - struct SDL::quintuplets& quintupletsInGPU, - struct SDL::pixelQuintuplets& pixelQuintupletsInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE void addPixelQuintupletToMemory(struct SDL::Modules& modulesInGPU, + struct SDL::MiniDoublets& mdsInGPU, + struct SDL::Segments& segmentsInGPU, + struct SDL::Quintuplets& quintupletsInGPU, + struct SDL::PixelQuintuplets& pixelQuintupletsInGPU, unsigned int pixelIndex, unsigned int T5Index, unsigned int pixelQuintupletIndex, @@ -2024,7 +2035,7 @@ namespace SDL { pixelQuintupletsInGPU.rPhiChiSquaredInwards[pixelQuintupletIndex] = rPhiChiSquaredInwards; }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT5RZChiSquaredCuts(struct SDL::modules& modulesInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT5RZChiSquaredCuts(struct SDL::Modules& modulesInGPU, uint16_t& lowerModuleIndex1, uint16_t& lowerModuleIndex2, uint16_t& lowerModuleIndex3, @@ -2114,7 +2125,7 @@ namespace SDL { return true; }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT5RPhiChiSquaredCuts(struct SDL::modules& modulesInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT5RPhiChiSquaredCuts(struct SDL::Modules& modulesInGPU, uint16_t& lowerModuleIndex1, uint16_t& lowerModuleIndex2, uint16_t& lowerModuleIndex3, @@ -2252,7 +2263,7 @@ namespace SDL { template ALPAKA_FN_ACC ALPAKA_FN_INLINE void computeSigmasForRegression_pT5(TAcc const& acc, - SDL::modules& modulesInGPU, + SDL::Modules& modulesInGPU, const uint16_t* lowerModuleIndices, float* delta1, float* delta2, @@ -2338,7 +2349,7 @@ namespace SDL { template ALPAKA_FN_ACC ALPAKA_FN_INLINE float computePT5RPhiChiSquared(TAcc const& acc, - struct SDL::modules& modulesInGPU, + struct SDL::Modules& modulesInGPU, uint16_t* lowerModuleIndices, float& g, float& f, @@ -2360,7 +2371,7 @@ namespace SDL { }; ALPAKA_FN_ACC ALPAKA_FN_INLINE float computePT5RPhiChiSquaredInwards( - struct SDL::modules& modulesInGPU, float& g, float& f, float& r, float* xPix, float* yPix) { + struct SDL::Modules& modulesInGPU, float& g, float& f, float& r, float* xPix, float* yPix) { /* Using the computed regression center and radius, compute the chi squared for the pixels */ @@ -2374,7 +2385,7 @@ namespace SDL { return chiSquared; }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT5RPhiChiSquaredInwardsCuts(struct SDL::modules& modulesInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT5RPhiChiSquaredInwardsCuts(struct SDL::Modules& modulesInGPU, uint16_t& lowerModuleIndex1, uint16_t& lowerModuleIndex2, uint16_t& lowerModuleIndex3, @@ -2466,12 +2477,12 @@ namespace SDL { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runPixelQuintupletDefaultAlgo(TAcc const& acc, - struct SDL::modules& modulesInGPU, - struct SDL::objectRanges& rangesInGPU, - struct SDL::miniDoublets& mdsInGPU, - struct SDL::segments& segmentsInGPU, - struct SDL::triplets& tripletsInGPU, - struct SDL::quintuplets& quintupletsInGPU, + struct SDL::Modules& modulesInGPU, + struct SDL::ObjectRanges& rangesInGPU, + struct SDL::MiniDoublets& mdsInGPU, + struct SDL::Segments& segmentsInGPU, + struct SDL::Triplets& tripletsInGPU, + struct SDL::Quintuplets& quintupletsInGPU, unsigned int& pixelSegmentIndex, unsigned int& quintupletIndex, float& rzChiSquared, @@ -2614,7 +2625,7 @@ namespace SDL { template ALPAKA_FN_ACC ALPAKA_FN_INLINE float computePT5RZChiSquared(TAcc const& acc, - struct SDL::modules& modulesInGPU, + struct SDL::Modules& modulesInGPU, uint16_t* lowerModuleIndices, float* rtPix, float* zPix, @@ -2659,16 +2670,16 @@ namespace SDL { struct createPixelQuintupletsInGPUFromMapv2 { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct SDL::modules modulesInGPU, - struct SDL::miniDoublets mdsInGPU, - struct SDL::segments segmentsInGPU, - struct SDL::triplets tripletsInGPU, - struct SDL::quintuplets quintupletsInGPU, - struct SDL::pixelQuintuplets pixelQuintupletsInGPU, + struct SDL::Modules modulesInGPU, + struct SDL::MiniDoublets mdsInGPU, + struct SDL::Segments segmentsInGPU, + struct SDL::Triplets tripletsInGPU, + struct SDL::Quintuplets quintupletsInGPU, + struct SDL::PixelQuintuplets pixelQuintupletsInGPU, unsigned int* connectedPixelSize, unsigned int* connectedPixelIndex, unsigned int nPixelSegments, - struct SDL::objectRanges rangesInGPU) const { + struct SDL::ObjectRanges rangesInGPU) const { auto const globalBlockIdx = alpaka::getIdx(acc); auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridBlockExtent = alpaka::getWorkDiv(acc); diff --git a/RecoTracker/LSTCore/src/alpaka/Quintuplet.h b/RecoTracker/LSTCore/src/alpaka/Quintuplet.h index b5b21a52c8ae7..26813dbcf4126 100644 --- a/RecoTracker/LSTCore/src/alpaka/Quintuplet.h +++ b/RecoTracker/LSTCore/src/alpaka/Quintuplet.h @@ -9,10 +9,11 @@ #include "Segment.h" #include "MiniDoublet.h" #include "Hit.h" +#include "ObjectRanges.h" #include "Triplet.h" namespace SDL { - struct quintuplets { + struct Quintuplets { unsigned int* tripletIndices; uint16_t* lowerModuleIndices; unsigned int* nQuintuplets; @@ -42,36 +43,36 @@ namespace SDL { float* nonAnchorChiSquared; template - void setData(TBuff& quintupletsbuf) { - tripletIndices = alpaka::getPtrNative(quintupletsbuf.tripletIndices_buf); - lowerModuleIndices = alpaka::getPtrNative(quintupletsbuf.lowerModuleIndices_buf); - nQuintuplets = alpaka::getPtrNative(quintupletsbuf.nQuintuplets_buf); - totOccupancyQuintuplets = alpaka::getPtrNative(quintupletsbuf.totOccupancyQuintuplets_buf); - nMemoryLocations = alpaka::getPtrNative(quintupletsbuf.nMemoryLocations_buf); - innerRadius = alpaka::getPtrNative(quintupletsbuf.innerRadius_buf); - bridgeRadius = alpaka::getPtrNative(quintupletsbuf.bridgeRadius_buf); - outerRadius = alpaka::getPtrNative(quintupletsbuf.outerRadius_buf); - pt = alpaka::getPtrNative(quintupletsbuf.pt_buf); - eta = alpaka::getPtrNative(quintupletsbuf.eta_buf); - phi = alpaka::getPtrNative(quintupletsbuf.phi_buf); - score_rphisum = alpaka::getPtrNative(quintupletsbuf.score_rphisum_buf); - layer = alpaka::getPtrNative(quintupletsbuf.layer_buf); - isDup = alpaka::getPtrNative(quintupletsbuf.isDup_buf); - TightCutFlag = alpaka::getPtrNative(quintupletsbuf.TightCutFlag_buf); - partOfPT5 = alpaka::getPtrNative(quintupletsbuf.partOfPT5_buf); - regressionRadius = alpaka::getPtrNative(quintupletsbuf.regressionRadius_buf); - regressionG = alpaka::getPtrNative(quintupletsbuf.regressionG_buf); - regressionF = alpaka::getPtrNative(quintupletsbuf.regressionF_buf); - logicalLayers = alpaka::getPtrNative(quintupletsbuf.logicalLayers_buf); - hitIndices = alpaka::getPtrNative(quintupletsbuf.hitIndices_buf); - rzChiSquared = alpaka::getPtrNative(quintupletsbuf.rzChiSquared_buf); - chiSquared = alpaka::getPtrNative(quintupletsbuf.chiSquared_buf); - nonAnchorChiSquared = alpaka::getPtrNative(quintupletsbuf.nonAnchorChiSquared_buf); + void setData(TBuff& buf) { + tripletIndices = alpaka::getPtrNative(buf.tripletIndices_buf); + lowerModuleIndices = alpaka::getPtrNative(buf.lowerModuleIndices_buf); + nQuintuplets = alpaka::getPtrNative(buf.nQuintuplets_buf); + totOccupancyQuintuplets = alpaka::getPtrNative(buf.totOccupancyQuintuplets_buf); + nMemoryLocations = alpaka::getPtrNative(buf.nMemoryLocations_buf); + innerRadius = alpaka::getPtrNative(buf.innerRadius_buf); + bridgeRadius = alpaka::getPtrNative(buf.bridgeRadius_buf); + outerRadius = alpaka::getPtrNative(buf.outerRadius_buf); + pt = alpaka::getPtrNative(buf.pt_buf); + eta = alpaka::getPtrNative(buf.eta_buf); + phi = alpaka::getPtrNative(buf.phi_buf); + score_rphisum = alpaka::getPtrNative(buf.score_rphisum_buf); + layer = alpaka::getPtrNative(buf.layer_buf); + isDup = alpaka::getPtrNative(buf.isDup_buf); + TightCutFlag = alpaka::getPtrNative(buf.TightCutFlag_buf); + partOfPT5 = alpaka::getPtrNative(buf.partOfPT5_buf); + regressionRadius = alpaka::getPtrNative(buf.regressionRadius_buf); + regressionG = alpaka::getPtrNative(buf.regressionG_buf); + regressionF = alpaka::getPtrNative(buf.regressionF_buf); + logicalLayers = alpaka::getPtrNative(buf.logicalLayers_buf); + hitIndices = alpaka::getPtrNative(buf.hitIndices_buf); + rzChiSquared = alpaka::getPtrNative(buf.rzChiSquared_buf); + chiSquared = alpaka::getPtrNative(buf.chiSquared_buf); + nonAnchorChiSquared = alpaka::getPtrNative(buf.nonAnchorChiSquared_buf); } }; template - struct quintupletsBuffer : quintuplets { + struct QuintupletsBuffer { Buf tripletIndices_buf; Buf lowerModuleIndices_buf; Buf nQuintuplets_buf; @@ -100,8 +101,10 @@ namespace SDL { Buf chiSquared_buf; Buf nonAnchorChiSquared_buf; + Quintuplets data_; + template - quintupletsBuffer(unsigned int nTotalQuintuplets, unsigned int nLowerModules, TDevAcc const& devAccIn, TQueue& queue) + QuintupletsBuffer(unsigned int nTotalQuintuplets, unsigned int nLowerModules, TDevAcc const& devAccIn, TQueue& queue) : tripletIndices_buf(allocBufWrapper(devAccIn, 2 * nTotalQuintuplets, queue)), lowerModuleIndices_buf(allocBufWrapper(devAccIn, Params_T5::kLayers * nTotalQuintuplets, queue)), nQuintuplets_buf(allocBufWrapper(devAccIn, nLowerModules, queue)), @@ -133,6 +136,9 @@ namespace SDL { alpaka::memset(queue, partOfPT5_buf, false); alpaka::wait(queue); } + + inline Quintuplets const* data() const { return &data_; } + inline void setData(QuintupletsBuffer& buf) { data_.setData(buf); } }; ALPAKA_FN_ACC ALPAKA_FN_INLINE bool checkIntervalOverlap(const float& firstMin, @@ -142,8 +148,8 @@ namespace SDL { return ((firstMin <= secondMin) && (secondMin < firstMax)) || ((secondMin < firstMin) && (firstMin < secondMax)); }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE void addQuintupletToMemory(struct SDL::triplets& tripletsInGPU, - struct SDL::quintuplets& quintupletsInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE void addQuintupletToMemory(struct SDL::Triplets& tripletsInGPU, + struct SDL::Quintuplets& quintupletsInGPU, unsigned int innerTripletIndex, unsigned int outerTripletIndex, uint16_t& lowerModule1, @@ -225,7 +231,7 @@ namespace SDL { }; //90% constraint - ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passChiSquaredConstraint(struct SDL::modules& modulesInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passChiSquaredConstraint(struct SDL::Modules& modulesInGPU, uint16_t& lowerModuleIndex1, uint16_t& lowerModuleIndex2, uint16_t& lowerModuleIndex3, @@ -310,8 +316,8 @@ namespace SDL { //bounds can be found at http://uaf-10.t2.ucsd.edu/~bsathian/SDL/T5_RZFix/t5_rz_thresholds.txt template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passT5RZConstraint(TAcc const& acc, - struct SDL::modules& modulesInGPU, - struct SDL::miniDoublets& mdsInGPU, + struct SDL::Modules& modulesInGPU, + struct SDL::MiniDoublets& mdsInGPU, unsigned int firstMDIndex, unsigned int secondMDIndex, unsigned int thirdMDIndex, @@ -744,8 +750,8 @@ namespace SDL { }; template - ALPAKA_FN_ACC ALPAKA_FN_INLINE bool T5HasCommonMiniDoublet(struct SDL::triplets& tripletsInGPU, - struct SDL::segments& segmentsInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE bool T5HasCommonMiniDoublet(struct SDL::Triplets& tripletsInGPU, + struct SDL::Segments& segmentsInGPU, unsigned int innerTripletIndex, unsigned int outerTripletIndex) { unsigned int innerOuterSegmentIndex = tripletsInGPU.segmentIndices[2 * innerTripletIndex + 1]; @@ -1143,7 +1149,7 @@ namespace SDL { template ALPAKA_FN_ACC ALPAKA_FN_INLINE void computeSigmasForRegression(TAcc const& acc, - SDL::modules& modulesInGPU, + SDL::Modules& modulesInGPU, const uint16_t* lowerModuleIndices, float* delta1, float* delta2, @@ -1471,9 +1477,9 @@ namespace SDL { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runQuintupletDefaultAlgoBBBB(TAcc const& acc, - struct SDL::modules& modulesInGPU, - struct SDL::miniDoublets& mdsInGPU, - struct SDL::segments& segmentsInGPU, + struct SDL::Modules& modulesInGPU, + struct SDL::MiniDoublets& mdsInGPU, + struct SDL::Segments& segmentsInGPU, uint16_t& innerInnerLowerModuleIndex, uint16_t& innerOuterLowerModuleIndex, uint16_t& outerInnerLowerModuleIndex, @@ -1740,9 +1746,9 @@ namespace SDL { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runQuintupletDefaultAlgoBBEE(TAcc const& acc, - struct SDL::modules& modulesInGPU, - struct SDL::miniDoublets& mdsInGPU, - struct SDL::segments& segmentsInGPU, + struct SDL::Modules& modulesInGPU, + struct SDL::MiniDoublets& mdsInGPU, + struct SDL::Segments& segmentsInGPU, uint16_t& innerInnerLowerModuleIndex, uint16_t& innerOuterLowerModuleIndex, uint16_t& outerInnerLowerModuleIndex, @@ -2010,9 +2016,9 @@ namespace SDL { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runQuintupletDefaultAlgoEEEE(TAcc const& acc, - struct SDL::modules& modulesInGPU, - struct SDL::miniDoublets& mdsInGPU, - struct SDL::segments& segmentsInGPU, + struct SDL::Modules& modulesInGPU, + struct SDL::MiniDoublets& mdsInGPU, + struct SDL::Segments& segmentsInGPU, uint16_t& innerInnerLowerModuleIndex, uint16_t& innerOuterLowerModuleIndex, uint16_t& outerInnerLowerModuleIndex, @@ -2266,9 +2272,9 @@ namespace SDL { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runQuintupletAlgoSelector(TAcc const& acc, - struct SDL::modules& modulesInGPU, - struct SDL::miniDoublets& mdsInGPU, - struct SDL::segments& segmentsInGPU, + struct SDL::Modules& modulesInGPU, + struct SDL::MiniDoublets& mdsInGPU, + struct SDL::Segments& segmentsInGPU, uint16_t& innerInnerLowerModuleIndex, uint16_t& innerOuterLowerModuleIndex, uint16_t& outerInnerLowerModuleIndex, @@ -2473,10 +2479,10 @@ namespace SDL { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runQuintupletDefaultAlgo(TAcc const& acc, - struct SDL::modules& modulesInGPU, - struct SDL::miniDoublets& mdsInGPU, - struct SDL::segments& segmentsInGPU, - struct SDL::triplets& tripletsInGPU, + struct SDL::Modules& modulesInGPU, + struct SDL::MiniDoublets& mdsInGPU, + struct SDL::Segments& segmentsInGPU, + struct SDL::Triplets& tripletsInGPU, uint16_t& lowerModuleIndex1, uint16_t& lowerModuleIndex2, uint16_t& lowerModuleIndex3, @@ -2965,12 +2971,12 @@ namespace SDL { struct createQuintupletsInGPUv2 { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct SDL::modules modulesInGPU, - struct SDL::miniDoublets mdsInGPU, - struct SDL::segments segmentsInGPU, - struct SDL::triplets tripletsInGPU, - struct SDL::quintuplets quintupletsInGPU, - struct SDL::objectRanges rangesInGPU, + struct SDL::Modules modulesInGPU, + struct SDL::MiniDoublets mdsInGPU, + struct SDL::Segments segmentsInGPU, + struct SDL::Triplets tripletsInGPU, + struct SDL::Quintuplets quintupletsInGPU, + struct SDL::ObjectRanges rangesInGPU, uint16_t nEligibleT5Modules) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); @@ -3094,9 +3100,9 @@ namespace SDL { struct createEligibleModulesListForQuintupletsGPU { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct SDL::modules modulesInGPU, - struct SDL::triplets tripletsInGPU, - struct SDL::objectRanges rangesInGPU) const { + struct SDL::Modules modulesInGPU, + struct SDL::Triplets tripletsInGPU, + struct SDL::ObjectRanges rangesInGPU) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); @@ -3192,9 +3198,9 @@ namespace SDL { struct addQuintupletRangesToEventExplicit { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct SDL::modules modulesInGPU, - struct SDL::quintuplets quintupletsInGPU, - struct SDL::objectRanges rangesInGPU) const { + struct SDL::Modules modulesInGPU, + struct SDL::Quintuplets quintupletsInGPU, + struct SDL::ObjectRanges rangesInGPU) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); diff --git a/RecoTracker/LSTCore/src/alpaka/Segment.h b/RecoTracker/LSTCore/src/alpaka/Segment.h index 114d29df698fa..5e25f8815e58d 100644 --- a/RecoTracker/LSTCore/src/alpaka/Segment.h +++ b/RecoTracker/LSTCore/src/alpaka/Segment.h @@ -7,9 +7,10 @@ #include "MiniDoublet.h" #include "Hit.h" +#include "ObjectRanges.h" namespace SDL { - struct segments { + struct Segments { FPX* dPhis; FPX* dPhiMins; FPX* dPhiMaxs; @@ -46,46 +47,46 @@ namespace SDL { float* circleRadius; template - void setData(TBuff& segmentsbuf) { - dPhis = alpaka::getPtrNative(segmentsbuf.dPhis_buf); - dPhiMins = alpaka::getPtrNative(segmentsbuf.dPhiMins_buf); - dPhiMaxs = alpaka::getPtrNative(segmentsbuf.dPhiMaxs_buf); - dPhiChanges = alpaka::getPtrNative(segmentsbuf.dPhiChanges_buf); - dPhiChangeMins = alpaka::getPtrNative(segmentsbuf.dPhiChangeMins_buf); - dPhiChangeMaxs = alpaka::getPtrNative(segmentsbuf.dPhiChangeMaxs_buf); - innerLowerModuleIndices = alpaka::getPtrNative(segmentsbuf.innerLowerModuleIndices_buf); - outerLowerModuleIndices = alpaka::getPtrNative(segmentsbuf.outerLowerModuleIndices_buf); - seedIdx = alpaka::getPtrNative(segmentsbuf.seedIdx_buf); - mdIndices = alpaka::getPtrNative(segmentsbuf.mdIndices_buf); - nMemoryLocations = alpaka::getPtrNative(segmentsbuf.nMemoryLocations_buf); - innerMiniDoubletAnchorHitIndices = alpaka::getPtrNative(segmentsbuf.innerMiniDoubletAnchorHitIndices_buf); - outerMiniDoubletAnchorHitIndices = alpaka::getPtrNative(segmentsbuf.outerMiniDoubletAnchorHitIndices_buf); - charge = alpaka::getPtrNative(segmentsbuf.charge_buf); - superbin = alpaka::getPtrNative(segmentsbuf.superbin_buf); - nSegments = alpaka::getPtrNative(segmentsbuf.nSegments_buf); - totOccupancySegments = alpaka::getPtrNative(segmentsbuf.totOccupancySegments_buf); - pLSHitsIdxs = alpaka::getPtrNative(segmentsbuf.pLSHitsIdxs_buf); - pixelType = alpaka::getPtrNative(segmentsbuf.pixelType_buf); - isQuad = alpaka::getPtrNative(segmentsbuf.isQuad_buf); - isDup = alpaka::getPtrNative(segmentsbuf.isDup_buf); - partOfPT5 = alpaka::getPtrNative(segmentsbuf.partOfPT5_buf); - ptIn = alpaka::getPtrNative(segmentsbuf.ptIn_buf); - ptErr = alpaka::getPtrNative(segmentsbuf.ptErr_buf); - px = alpaka::getPtrNative(segmentsbuf.px_buf); - py = alpaka::getPtrNative(segmentsbuf.py_buf); - pz = alpaka::getPtrNative(segmentsbuf.pz_buf); - etaErr = alpaka::getPtrNative(segmentsbuf.etaErr_buf); - eta = alpaka::getPtrNative(segmentsbuf.eta_buf); - phi = alpaka::getPtrNative(segmentsbuf.phi_buf); - score = alpaka::getPtrNative(segmentsbuf.score_buf); - circleCenterX = alpaka::getPtrNative(segmentsbuf.circleCenterX_buf); - circleCenterY = alpaka::getPtrNative(segmentsbuf.circleCenterY_buf); - circleRadius = alpaka::getPtrNative(segmentsbuf.circleRadius_buf); + void setData(TBuff& buf) { + dPhis = alpaka::getPtrNative(buf.dPhis_buf); + dPhiMins = alpaka::getPtrNative(buf.dPhiMins_buf); + dPhiMaxs = alpaka::getPtrNative(buf.dPhiMaxs_buf); + dPhiChanges = alpaka::getPtrNative(buf.dPhiChanges_buf); + dPhiChangeMins = alpaka::getPtrNative(buf.dPhiChangeMins_buf); + dPhiChangeMaxs = alpaka::getPtrNative(buf.dPhiChangeMaxs_buf); + innerLowerModuleIndices = alpaka::getPtrNative(buf.innerLowerModuleIndices_buf); + outerLowerModuleIndices = alpaka::getPtrNative(buf.outerLowerModuleIndices_buf); + seedIdx = alpaka::getPtrNative(buf.seedIdx_buf); + mdIndices = alpaka::getPtrNative(buf.mdIndices_buf); + nMemoryLocations = alpaka::getPtrNative(buf.nMemoryLocations_buf); + innerMiniDoubletAnchorHitIndices = alpaka::getPtrNative(buf.innerMiniDoubletAnchorHitIndices_buf); + outerMiniDoubletAnchorHitIndices = alpaka::getPtrNative(buf.outerMiniDoubletAnchorHitIndices_buf); + charge = alpaka::getPtrNative(buf.charge_buf); + superbin = alpaka::getPtrNative(buf.superbin_buf); + nSegments = alpaka::getPtrNative(buf.nSegments_buf); + totOccupancySegments = alpaka::getPtrNative(buf.totOccupancySegments_buf); + pLSHitsIdxs = alpaka::getPtrNative(buf.pLSHitsIdxs_buf); + pixelType = alpaka::getPtrNative(buf.pixelType_buf); + isQuad = alpaka::getPtrNative(buf.isQuad_buf); + isDup = alpaka::getPtrNative(buf.isDup_buf); + partOfPT5 = alpaka::getPtrNative(buf.partOfPT5_buf); + ptIn = alpaka::getPtrNative(buf.ptIn_buf); + ptErr = alpaka::getPtrNative(buf.ptErr_buf); + px = alpaka::getPtrNative(buf.px_buf); + py = alpaka::getPtrNative(buf.py_buf); + pz = alpaka::getPtrNative(buf.pz_buf); + etaErr = alpaka::getPtrNative(buf.etaErr_buf); + eta = alpaka::getPtrNative(buf.eta_buf); + phi = alpaka::getPtrNative(buf.phi_buf); + score = alpaka::getPtrNative(buf.score_buf); + circleCenterX = alpaka::getPtrNative(buf.circleCenterX_buf); + circleCenterY = alpaka::getPtrNative(buf.circleCenterY_buf); + circleRadius = alpaka::getPtrNative(buf.circleRadius_buf); } }; template - struct segmentsBuffer : segments { + struct SegmentsBuffer { Buf dPhis_buf; Buf dPhiMins_buf; Buf dPhiMaxs_buf; @@ -121,8 +122,10 @@ namespace SDL { Buf circleCenterY_buf; Buf circleRadius_buf; + Segments data_; + template - segmentsBuffer(unsigned int nMemoryLocationsIn, + SegmentsBuffer(unsigned int nMemoryLocationsIn, uint16_t nLowerModules, unsigned int maxPixelSegments, TDevAcc const& devAccIn, @@ -167,9 +170,12 @@ namespace SDL { alpaka::memset(queue, pLSHitsIdxs_buf, 0u); alpaka::wait(queue); } + + inline Segments const* data() const { return &data_; } + inline void setData(SegmentsBuffer& buf) { data_.setData(buf); } }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE float isTighterTiltedModules_seg(struct SDL::modules& modulesInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE float isTighterTiltedModules_seg(struct SDL::Modules& modulesInGPU, unsigned int moduleIndex) { // The "tighter" tilted modules are the subset of tilted modules that have smaller spacing // This is the same as what was previously considered as"isNormalTiltedModules" @@ -223,7 +229,7 @@ namespace SDL { return moduleSeparation; }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE float moduleGapSize_seg(struct SDL::modules& modulesInGPU, unsigned int moduleIndex) { + ALPAKA_FN_ACC ALPAKA_FN_INLINE float moduleGapSize_seg(struct SDL::Modules& modulesInGPU, unsigned int moduleIndex) { static constexpr float miniDeltaTilted[3] = {0.26f, 0.26f, 0.26f}; static constexpr float miniDeltaFlat[6] = {0.26f, 0.16f, 0.16f, 0.18f, 0.18f, 0.18f}; static constexpr float miniDeltaLooseTilted[3] = {0.4f, 0.4f, 0.4f}; @@ -258,8 +264,8 @@ namespace SDL { template ALPAKA_FN_ACC ALPAKA_FN_INLINE void dAlphaThreshold(TAcc const& acc, float* dAlphaThresholdValues, - struct SDL::modules& modulesInGPU, - struct SDL::miniDoublets& mdsInGPU, + struct SDL::Modules& modulesInGPU, + struct SDL::MiniDoublets& mdsInGPU, float& xIn, float& yIn, float& zIn, @@ -350,7 +356,7 @@ namespace SDL { dAlphaThresholdValues[2] = dAlpha_Bfield + alpaka::math::sqrt(acc, dAlpha_res * dAlpha_res + sdMuls * sdMuls); }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE void addSegmentToMemory(struct SDL::segments& segmentsInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE void addSegmentToMemory(struct SDL::Segments& segmentsInGPU, unsigned int lowerMDIndex, unsigned int upperMDIndex, uint16_t innerLowerModuleIndex, @@ -385,8 +391,8 @@ namespace SDL { template ALPAKA_FN_ACC ALPAKA_FN_INLINE void addPixelSegmentToMemory(TAcc const& acc, - struct SDL::segments& segmentsInGPU, - struct SDL::miniDoublets& mdsInGPU, + struct SDL::Segments& segmentsInGPU, + struct SDL::MiniDoublets& mdsInGPU, unsigned int innerMDIndex, unsigned int outerMDIndex, uint16_t pixelModuleIndex, @@ -448,8 +454,8 @@ namespace SDL { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runSegmentDefaultAlgoBarrel(TAcc const& acc, - struct SDL::modules& modulesInGPU, - struct SDL::miniDoublets& mdsInGPU, + struct SDL::Modules& modulesInGPU, + struct SDL::MiniDoublets& mdsInGPU, uint16_t& innerLowerModuleIndex, uint16_t& outerLowerModuleIndex, unsigned int& innerMDIndex, @@ -551,8 +557,8 @@ namespace SDL { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runSegmentDefaultAlgoEndcap(TAcc const& acc, - struct SDL::modules& modulesInGPU, - struct SDL::miniDoublets& mdsInGPU, + struct SDL::Modules& modulesInGPU, + struct SDL::MiniDoublets& mdsInGPU, uint16_t& innerLowerModuleIndex, uint16_t& outerLowerModuleIndex, unsigned int& innerMDIndex, @@ -681,8 +687,8 @@ namespace SDL { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runSegmentDefaultAlgo(TAcc const& acc, - struct SDL::modules& modulesInGPU, - struct SDL::miniDoublets& mdsInGPU, + struct SDL::Modules& modulesInGPU, + struct SDL::MiniDoublets& mdsInGPU, uint16_t& innerLowerModuleIndex, uint16_t& outerLowerModuleIndex, unsigned int& innerMDIndex, @@ -774,10 +780,10 @@ namespace SDL { struct createSegmentsInGPUv2 { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct SDL::modules modulesInGPU, - struct SDL::miniDoublets mdsInGPU, - struct SDL::segments segmentsInGPU, - struct SDL::objectRanges rangesInGPU) const { + struct SDL::Modules modulesInGPU, + struct SDL::MiniDoublets mdsInGPU, + struct SDL::Segments segmentsInGPU, + struct SDL::ObjectRanges rangesInGPU) const { auto const globalBlockIdx = alpaka::getIdx(acc); auto const blockThreadIdx = alpaka::getIdx(acc); auto const gridBlockExtent = alpaka::getWorkDiv(acc); @@ -886,9 +892,9 @@ namespace SDL { struct createSegmentArrayRanges { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct SDL::modules modulesInGPU, - struct SDL::objectRanges rangesInGPU, - struct SDL::miniDoublets mdsInGPU) const { + struct SDL::Modules modulesInGPU, + struct SDL::ObjectRanges rangesInGPU, + struct SDL::MiniDoublets mdsInGPU) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); @@ -984,9 +990,9 @@ namespace SDL { struct addSegmentRangesToEventExplicit { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct SDL::modules modulesInGPU, - struct SDL::segments segmentsInGPU, - struct SDL::objectRanges rangesInGPU) const { + struct SDL::Modules modulesInGPU, + struct SDL::Segments segmentsInGPU, + struct SDL::ObjectRanges rangesInGPU) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); @@ -1005,11 +1011,11 @@ namespace SDL { struct addPixelSegmentToEventKernel { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct SDL::modules modulesInGPU, - struct SDL::objectRanges rangesInGPU, - struct SDL::hits hitsInGPU, - struct SDL::miniDoublets mdsInGPU, - struct SDL::segments segmentsInGPU, + struct SDL::Modules modulesInGPU, + struct SDL::ObjectRanges rangesInGPU, + struct SDL::Hits hitsInGPU, + struct SDL::MiniDoublets mdsInGPU, + struct SDL::Segments segmentsInGPU, unsigned int* hitIndices0, unsigned int* hitIndices1, unsigned int* hitIndices2, diff --git a/RecoTracker/LSTCore/src/alpaka/TrackCandidate.h b/RecoTracker/LSTCore/src/alpaka/TrackCandidate.h index 080abee755f96..96a459c449a50 100644 --- a/RecoTracker/LSTCore/src/alpaka/TrackCandidate.h +++ b/RecoTracker/LSTCore/src/alpaka/TrackCandidate.h @@ -10,9 +10,10 @@ #include "PixelTriplet.h" #include "Quintuplet.h" #include "Hit.h" +#include "ObjectRanges.h" namespace SDL { - struct trackCandidates { + struct TrackCandidates { short* trackCandidateType; // 4-T5 5-pT3 7-pT5 8-pLS unsigned int* directObjectIndices; // Will hold direct indices to each type containers unsigned int* objectIndices; // Will hold tracklet and triplet indices - check the type!! @@ -32,29 +33,29 @@ namespace SDL { FPX* radius; template - void setData(TBuff& trackCandidatesbuf) { - trackCandidateType = alpaka::getPtrNative(trackCandidatesbuf.trackCandidateType_buf); - directObjectIndices = alpaka::getPtrNative(trackCandidatesbuf.directObjectIndices_buf); - objectIndices = alpaka::getPtrNative(trackCandidatesbuf.objectIndices_buf); - nTrackCandidates = alpaka::getPtrNative(trackCandidatesbuf.nTrackCandidates_buf); - nTrackCandidatespT3 = alpaka::getPtrNative(trackCandidatesbuf.nTrackCandidatespT3_buf); - nTrackCandidatespT5 = alpaka::getPtrNative(trackCandidatesbuf.nTrackCandidatespT5_buf); - nTrackCandidatespLS = alpaka::getPtrNative(trackCandidatesbuf.nTrackCandidatespLS_buf); - nTrackCandidatesT5 = alpaka::getPtrNative(trackCandidatesbuf.nTrackCandidatesT5_buf); - - logicalLayers = alpaka::getPtrNative(trackCandidatesbuf.logicalLayers_buf); - hitIndices = alpaka::getPtrNative(trackCandidatesbuf.hitIndices_buf); - pixelSeedIndex = alpaka::getPtrNative(trackCandidatesbuf.pixelSeedIndex_buf); - lowerModuleIndices = alpaka::getPtrNative(trackCandidatesbuf.lowerModuleIndices_buf); - - centerX = alpaka::getPtrNative(trackCandidatesbuf.centerX_buf); - centerY = alpaka::getPtrNative(trackCandidatesbuf.centerY_buf); - radius = alpaka::getPtrNative(trackCandidatesbuf.radius_buf); + void setData(TBuff& buf) { + trackCandidateType = alpaka::getPtrNative(buf.trackCandidateType_buf); + directObjectIndices = alpaka::getPtrNative(buf.directObjectIndices_buf); + objectIndices = alpaka::getPtrNative(buf.objectIndices_buf); + nTrackCandidates = alpaka::getPtrNative(buf.nTrackCandidates_buf); + nTrackCandidatespT3 = alpaka::getPtrNative(buf.nTrackCandidatespT3_buf); + nTrackCandidatespT5 = alpaka::getPtrNative(buf.nTrackCandidatespT5_buf); + nTrackCandidatespLS = alpaka::getPtrNative(buf.nTrackCandidatespLS_buf); + nTrackCandidatesT5 = alpaka::getPtrNative(buf.nTrackCandidatesT5_buf); + + logicalLayers = alpaka::getPtrNative(buf.logicalLayers_buf); + hitIndices = alpaka::getPtrNative(buf.hitIndices_buf); + pixelSeedIndex = alpaka::getPtrNative(buf.pixelSeedIndex_buf); + lowerModuleIndices = alpaka::getPtrNative(buf.lowerModuleIndices_buf); + + centerX = alpaka::getPtrNative(buf.centerX_buf); + centerY = alpaka::getPtrNative(buf.centerY_buf); + radius = alpaka::getPtrNative(buf.radius_buf); } }; template - struct trackCandidatesBuffer : trackCandidates { + struct TrackCandidatesBuffer { Buf trackCandidateType_buf; Buf directObjectIndices_buf; Buf objectIndices_buf; @@ -73,8 +74,10 @@ namespace SDL { Buf centerY_buf; Buf radius_buf; + TrackCandidates data_; + template - trackCandidatesBuffer(unsigned int maxTrackCandidates, TDevAcc const& devAccIn, TQueue& queue) + TrackCandidatesBuffer(unsigned int maxTrackCandidates, TDevAcc const& devAccIn, TQueue& queue) : trackCandidateType_buf(allocBufWrapper(devAccIn, maxTrackCandidates, queue)), directObjectIndices_buf(allocBufWrapper(devAccIn, maxTrackCandidates, queue)), objectIndices_buf(allocBufWrapper(devAccIn, 2 * maxTrackCandidates, queue)), @@ -101,9 +104,12 @@ namespace SDL { alpaka::memset(queue, pixelSeedIndex_buf, 0); alpaka::wait(queue); } + + inline TrackCandidates const* data() const { return &data_; } + inline void setData(TrackCandidatesBuffer& buf) { data_.setData(buf); } }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE void addpLSTrackCandidateToMemory(struct SDL::trackCandidates& trackCandidatesInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE void addpLSTrackCandidateToMemory(struct SDL::TrackCandidates& trackCandidatesInGPU, unsigned int trackletIndex, unsigned int trackCandidateIndex, uint4 hitIndices, @@ -122,7 +128,7 @@ namespace SDL { trackCandidatesInGPU.hitIndices[Params_pT5::kHits * trackCandidateIndex + 3] = hitIndices.w; }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE void addTrackCandidateToMemory(struct SDL::trackCandidates& trackCandidatesInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE void addTrackCandidateToMemory(struct SDL::TrackCandidates& trackCandidatesInGPU, short trackCandidateType, unsigned int innerTrackletIndex, unsigned int outerTrackletIndex, @@ -161,9 +167,9 @@ namespace SDL { ALPAKA_FN_ACC ALPAKA_FN_INLINE int checkPixelHits(unsigned int ix, unsigned int jx, - struct SDL::miniDoublets& mdsInGPU, - struct SDL::segments& segmentsInGPU, - struct SDL::hits& hitsInGPU) { + struct SDL::MiniDoublets& mdsInGPU, + struct SDL::Segments& segmentsInGPU, + struct SDL::Hits& hitsInGPU) { int phits1[Params_pLS::kHits]; int phits2[Params_pLS::kHits]; @@ -202,11 +208,11 @@ namespace SDL { struct crossCleanpT3 { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct SDL::modules modulesInGPU, - struct SDL::objectRanges rangesInGPU, - struct SDL::pixelTriplets pixelTripletsInGPU, - struct SDL::segments segmentsInGPU, - struct SDL::pixelQuintuplets pixelQuintupletsInGPU) const { + struct SDL::Modules modulesInGPU, + struct SDL::ObjectRanges rangesInGPU, + struct SDL::PixelTriplets pixelTripletsInGPU, + struct SDL::Segments segmentsInGPU, + struct SDL::PixelQuintuplets pixelQuintupletsInGPU) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); @@ -243,11 +249,11 @@ namespace SDL { struct crossCleanT5 { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct SDL::modules modulesInGPU, - struct SDL::quintuplets quintupletsInGPU, - struct SDL::pixelQuintuplets pixelQuintupletsInGPU, - struct SDL::pixelTriplets pixelTripletsInGPU, - struct SDL::objectRanges rangesInGPU) const { + struct SDL::Modules modulesInGPU, + struct SDL::Quintuplets quintupletsInGPU, + struct SDL::PixelQuintuplets pixelQuintupletsInGPU, + struct SDL::PixelTriplets pixelTripletsInGPU, + struct SDL::ObjectRanges rangesInGPU) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); @@ -300,14 +306,14 @@ namespace SDL { struct crossCleanpLS { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct SDL::modules modulesInGPU, - struct SDL::objectRanges rangesInGPU, - struct SDL::pixelTriplets pixelTripletsInGPU, - struct SDL::trackCandidates trackCandidatesInGPU, - struct SDL::segments segmentsInGPU, - struct SDL::miniDoublets mdsInGPU, - struct SDL::hits hitsInGPU, - struct SDL::quintuplets quintupletsInGPU) const { + struct SDL::Modules modulesInGPU, + struct SDL::ObjectRanges rangesInGPU, + struct SDL::PixelTriplets pixelTripletsInGPU, + struct SDL::TrackCandidates trackCandidatesInGPU, + struct SDL::Segments segmentsInGPU, + struct SDL::MiniDoublets mdsInGPU, + struct SDL::Hits hitsInGPU, + struct SDL::Quintuplets quintupletsInGPU) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); @@ -382,10 +388,10 @@ namespace SDL { template ALPAKA_FN_ACC void operator()(TAcc const& acc, uint16_t nLowerModules, - struct SDL::pixelTriplets pixelTripletsInGPU, - struct SDL::trackCandidates trackCandidatesInGPU, - struct SDL::segments segmentsInGPU, - struct SDL::objectRanges rangesInGPU) const { + struct SDL::PixelTriplets pixelTripletsInGPU, + struct SDL::TrackCandidates trackCandidatesInGPU, + struct SDL::Segments segmentsInGPU, + struct SDL::ObjectRanges rangesInGPU) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); @@ -434,9 +440,9 @@ namespace SDL { template ALPAKA_FN_ACC void operator()(TAcc const& acc, uint16_t nLowerModules, - struct SDL::quintuplets quintupletsInGPU, - struct SDL::trackCandidates trackCandidatesInGPU, - struct SDL::objectRanges rangesInGPU) const { + struct SDL::Quintuplets quintupletsInGPU, + struct SDL::TrackCandidates trackCandidatesInGPU, + struct SDL::ObjectRanges rangesInGPU) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); @@ -488,8 +494,8 @@ namespace SDL { template ALPAKA_FN_ACC void operator()(TAcc const& acc, uint16_t nLowerModules, - struct SDL::trackCandidates trackCandidatesInGPU, - struct SDL::segments segmentsInGPU, + struct SDL::TrackCandidates trackCandidatesInGPU, + struct SDL::Segments segmentsInGPU, bool tc_pls_triplets) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); @@ -527,10 +533,10 @@ namespace SDL { template ALPAKA_FN_ACC void operator()(TAcc const& acc, uint16_t nLowerModules, - struct SDL::pixelQuintuplets pixelQuintupletsInGPU, - struct SDL::trackCandidates trackCandidatesInGPU, - struct SDL::segments segmentsInGPU, - struct SDL::objectRanges rangesInGPU) const { + struct SDL::PixelQuintuplets pixelQuintupletsInGPU, + struct SDL::TrackCandidates trackCandidatesInGPU, + struct SDL::Segments segmentsInGPU, + struct SDL::ObjectRanges rangesInGPU) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); diff --git a/RecoTracker/LSTCore/src/alpaka/Triplet.h b/RecoTracker/LSTCore/src/alpaka/Triplet.h index 4b1308dbc9067..3362fdaa97991 100644 --- a/RecoTracker/LSTCore/src/alpaka/Triplet.h +++ b/RecoTracker/LSTCore/src/alpaka/Triplet.h @@ -7,9 +7,10 @@ #include "Segment.h" #include "MiniDoublet.h" #include "Hit.h" +#include "ObjectRanges.h" namespace SDL { - struct triplets { + struct Triplets { unsigned int* segmentIndices; uint16_t* lowerModuleIndices; //3 of them now unsigned int* nTriplets; @@ -41,40 +42,40 @@ namespace SDL { float* rtHi; #endif template - void setData(TBuff& tripletsbuf) { - segmentIndices = alpaka::getPtrNative(tripletsbuf.segmentIndices_buf); - lowerModuleIndices = alpaka::getPtrNative(tripletsbuf.lowerModuleIndices_buf); - nTriplets = alpaka::getPtrNative(tripletsbuf.nTriplets_buf); - totOccupancyTriplets = alpaka::getPtrNative(tripletsbuf.totOccupancyTriplets_buf); - nMemoryLocations = alpaka::getPtrNative(tripletsbuf.nMemoryLocations_buf); - logicalLayers = alpaka::getPtrNative(tripletsbuf.logicalLayers_buf); - hitIndices = alpaka::getPtrNative(tripletsbuf.hitIndices_buf); - betaIn = alpaka::getPtrNative(tripletsbuf.betaIn_buf); - circleRadius = alpaka::getPtrNative(tripletsbuf.circleRadius_buf); - circleCenterX = alpaka::getPtrNative(tripletsbuf.circleCenterX_buf); - circleCenterY = alpaka::getPtrNative(tripletsbuf.circleCenterY_buf); - partOfPT5 = alpaka::getPtrNative(tripletsbuf.partOfPT5_buf); - partOfT5 = alpaka::getPtrNative(tripletsbuf.partOfT5_buf); - partOfPT3 = alpaka::getPtrNative(tripletsbuf.partOfPT3_buf); + void setData(TBuff& buf) { + segmentIndices = alpaka::getPtrNative(buf.segmentIndices_buf); + lowerModuleIndices = alpaka::getPtrNative(buf.lowerModuleIndices_buf); + nTriplets = alpaka::getPtrNative(buf.nTriplets_buf); + totOccupancyTriplets = alpaka::getPtrNative(buf.totOccupancyTriplets_buf); + nMemoryLocations = alpaka::getPtrNative(buf.nMemoryLocations_buf); + logicalLayers = alpaka::getPtrNative(buf.logicalLayers_buf); + hitIndices = alpaka::getPtrNative(buf.hitIndices_buf); + betaIn = alpaka::getPtrNative(buf.betaIn_buf); + circleRadius = alpaka::getPtrNative(buf.circleRadius_buf); + circleCenterX = alpaka::getPtrNative(buf.circleCenterX_buf); + circleCenterY = alpaka::getPtrNative(buf.circleCenterY_buf); + partOfPT5 = alpaka::getPtrNative(buf.partOfPT5_buf); + partOfT5 = alpaka::getPtrNative(buf.partOfT5_buf); + partOfPT3 = alpaka::getPtrNative(buf.partOfPT3_buf); #ifdef CUT_VALUE_DEBUG - zOut = alpaka::getPtrNative(tripletsbuf.zOut_buf); - rtOut = alpaka::getPtrNative(tripletsbuf.rtOut_buf); - deltaPhiPos = alpaka::getPtrNative(tripletsbuf.deltaPhiPos_buf); - deltaPhi = alpaka::getPtrNative(tripletsbuf.deltaPhi_buf); - zLo = alpaka::getPtrNative(tripletsbuf.zLo_buf); - zHi = alpaka::getPtrNative(tripletsbuf.zHi_buf); - zLoPointed = alpaka::getPtrNative(tripletsbuf.zLoPointed_buf); - zHiPointed = alpaka::getPtrNative(tripletsbuf.zHiPointed_buf); - sdlCut = alpaka::getPtrNative(tripletsbuf.sdlCut_buf); - betaInCut = alpaka::getPtrNative(tripletsbuf.betaInCut_buf); - rtLo = alpaka::getPtrNative(tripletsbuf.rtLo_buf); - rtHi = alpaka::getPtrNative(tripletsbuf.rtHi_buf); + zOut = alpaka::getPtrNative(buf.zOut_buf); + rtOut = alpaka::getPtrNative(buf.rtOut_buf); + deltaPhiPos = alpaka::getPtrNative(buf.deltaPhiPos_buf); + deltaPhi = alpaka::getPtrNative(buf.deltaPhi_buf); + zLo = alpaka::getPtrNative(buf.zLo_buf); + zHi = alpaka::getPtrNative(buf.zHi_buf); + zLoPointed = alpaka::getPtrNative(buf.zLoPointed_buf); + zHiPointed = alpaka::getPtrNative(buf.zHiPointed_buf); + sdlCut = alpaka::getPtrNative(buf.sdlCut_buf); + betaInCut = alpaka::getPtrNative(buf.betaInCut_buf); + rtLo = alpaka::getPtrNative(buf.rtLo_buf); + rtHi = alpaka::getPtrNative(buf.rtHi_buf); #endif } }; template - struct tripletsBuffer : triplets { + struct TripletsBuffer { Buf segmentIndices_buf; Buf lowerModuleIndices_buf; Buf nTriplets_buf; @@ -105,8 +106,10 @@ namespace SDL { Buf rtHi_buf; #endif + Triplets data_; + template - tripletsBuffer(unsigned int maxTriplets, unsigned int nLowerModules, TDevAcc const& devAccIn, TQueue& queue) + TripletsBuffer(unsigned int maxTriplets, unsigned int nLowerModules, TDevAcc const& devAccIn, TQueue& queue) : segmentIndices_buf(allocBufWrapper(devAccIn, 2 * maxTriplets, queue)), lowerModuleIndices_buf(allocBufWrapper(devAccIn, Params_T3::kLayers * maxTriplets, queue)), nTriplets_buf(allocBufWrapper(devAccIn, nLowerModules, queue)), @@ -143,13 +146,16 @@ namespace SDL { alpaka::memset(queue, partOfT5_buf, false); alpaka::memset(queue, partOfPT3_buf, false); } + + inline Triplets const* data() const { return &data_; } + inline void setData(TripletsBuffer& buf) { data_.setData(buf); } }; #ifdef CUT_VALUE_DEBUG - ALPAKA_FN_ACC ALPAKA_FN_INLINE void addTripletToMemory(struct SDL::modules& modulesInGPU, - struct SDL::miniDoublets& mdsInGPU, - struct SDL::segments& segmentsInGPU, - struct SDL::triplets& tripletsInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE void addTripletToMemory(struct SDL::Modules& modulesInGPU, + struct SDL::MiniDoublets& mdsInGPU, + struct SDL::Segments& segmentsInGPU, + struct SDL::Triplets& tripletsInGPU, unsigned int& innerSegmentIndex, unsigned int& outerSegmentIndex, uint16_t& innerInnerLowerModuleIndex, @@ -173,10 +179,10 @@ namespace SDL { float& betaInCut, unsigned int& tripletIndex) #else - ALPAKA_FN_ACC ALPAKA_FN_INLINE void addTripletToMemory(struct SDL::modules& modulesInGPU, - struct SDL::miniDoublets& mdsInGPU, - struct SDL::segments& segmentsInGPU, - struct SDL::triplets& tripletsInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE void addTripletToMemory(struct SDL::Modules& modulesInGPU, + struct SDL::MiniDoublets& mdsInGPU, + struct SDL::Segments& segmentsInGPU, + struct SDL::Triplets& tripletsInGPU, unsigned int& innerSegmentIndex, unsigned int& outerSegmentIndex, uint16_t& innerInnerLowerModuleIndex, @@ -234,9 +240,9 @@ namespace SDL { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passRZConstraint(TAcc const& acc, - struct SDL::modules& modulesInGPU, - struct SDL::miniDoublets& mdsInGPU, - struct SDL::segments& segmentsInGPU, + struct SDL::Modules& modulesInGPU, + struct SDL::MiniDoublets& mdsInGPU, + struct SDL::Segments& segmentsInGPU, uint16_t& innerInnerLowerModuleIndex, uint16_t& middleLowerModuleIndex, uint16_t& outerOuterLowerModuleIndex, @@ -294,9 +300,9 @@ namespace SDL { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPointingConstraintBBB(TAcc const& acc, - struct SDL::modules& modulesInGPU, - struct SDL::miniDoublets& mdsInGPU, - struct SDL::segments& segmentsInGPU, + struct SDL::Modules& modulesInGPU, + struct SDL::MiniDoublets& mdsInGPU, + struct SDL::Segments& segmentsInGPU, uint16_t& innerInnerLowerModuleIndex, uint16_t& middleLowerModuleIndex, uint16_t& outerOuterLowerModuleIndex, @@ -393,9 +399,9 @@ namespace SDL { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPointingConstraintBBE(TAcc const& acc, - struct SDL::modules& modulesInGPU, - struct SDL::miniDoublets& mdsInGPU, - struct SDL::segments& segmentsInGPU, + struct SDL::Modules& modulesInGPU, + struct SDL::MiniDoublets& mdsInGPU, + struct SDL::Segments& segmentsInGPU, uint16_t& innerInnerLowerModuleIndex, uint16_t& middleLowerModuleIndex, uint16_t& outerOuterLowerModuleIndex, @@ -514,9 +520,9 @@ namespace SDL { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPointingConstraintEEE(TAcc const& acc, - struct SDL::modules& modulesInGPU, - struct SDL::miniDoublets& mdsInGPU, - struct SDL::segments& segmentsInGPU, + struct SDL::Modules& modulesInGPU, + struct SDL::MiniDoublets& mdsInGPU, + struct SDL::Segments& segmentsInGPU, uint16_t& innerInnerLowerModuleIndex, uint16_t& middleLowerModuleIndex, uint16_t& outerOuterLowerModuleIndex, @@ -637,9 +643,9 @@ namespace SDL { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPointingConstraint(TAcc const& acc, - struct SDL::modules& modulesInGPU, - struct SDL::miniDoublets& mdsInGPU, - struct SDL::segments& segmentsInGPU, + struct SDL::Modules& modulesInGPU, + struct SDL::MiniDoublets& mdsInGPU, + struct SDL::Segments& segmentsInGPU, uint16_t& innerInnerLowerModuleIndex, uint16_t& middleLowerModuleIndex, uint16_t& outerOuterLowerModuleIndex, @@ -774,9 +780,9 @@ namespace SDL { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runTripletConstraintsAndAlgo(TAcc const& acc, - struct SDL::modules& modulesInGPU, - struct SDL::miniDoublets& mdsInGPU, - struct SDL::segments& segmentsInGPU, + struct SDL::Modules& modulesInGPU, + struct SDL::MiniDoublets& mdsInGPU, + struct SDL::Segments& segmentsInGPU, uint16_t& innerInnerLowerModuleIndex, uint16_t& middleLowerModuleIndex, uint16_t& outerOuterLowerModuleIndex, @@ -850,11 +856,11 @@ namespace SDL { struct createTripletsInGPUv2 { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct SDL::modules modulesInGPU, - struct SDL::miniDoublets mdsInGPU, - struct SDL::segments segmentsInGPU, - struct SDL::triplets tripletsInGPU, - struct SDL::objectRanges rangesInGPU, + struct SDL::Modules modulesInGPU, + struct SDL::MiniDoublets mdsInGPU, + struct SDL::Segments segmentsInGPU, + struct SDL::Triplets tripletsInGPU, + struct SDL::ObjectRanges rangesInGPU, uint16_t* index_gpu, uint16_t nonZeroModules) const { auto const globalThreadIdx = alpaka::getIdx(acc); @@ -983,9 +989,9 @@ namespace SDL { struct createTripletArrayRanges { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct SDL::modules modulesInGPU, - struct SDL::objectRanges rangesInGPU, - struct SDL::segments segmentsInGPU) const { + struct SDL::Modules modulesInGPU, + struct SDL::ObjectRanges rangesInGPU, + struct SDL::Segments segmentsInGPU) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); @@ -1080,9 +1086,9 @@ namespace SDL { struct addTripletRangesToEventExplicit { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct SDL::modules modulesInGPU, - struct SDL::triplets tripletsInGPU, - struct SDL::objectRanges rangesInGPU) const { + struct SDL::Modules modulesInGPU, + struct SDL::Triplets tripletsInGPU, + struct SDL::ObjectRanges rangesInGPU) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); diff --git a/RecoTracker/LSTCore/standalone/code/core/AccessHelper.cc b/RecoTracker/LSTCore/standalone/code/core/AccessHelper.cc index 55080b6857d37..faccf6b7a25c3 100644 --- a/RecoTracker/LSTCore/standalone/code/core/AccessHelper.cc +++ b/RecoTracker/LSTCore/standalone/code/core/AccessHelper.cc @@ -9,12 +9,12 @@ using namespace ALPAKA_ACCELERATOR_NAMESPACE; //____________________________________________________________________________________________ std::tuple, std::vector> convertHitsToHitIdxsAndHitTypes( SDL::Event* event, std::vector hits) { - SDL::hitsBuffer& hitsInGPU = *(event->getHits()); + SDL::Hits const* hitsEvt = event->getHits()->data(); std::vector hitidxs; std::vector hittypes; for (auto& hit : hits) { - hitidxs.push_back(hitsInGPU.idxs[hit]); - if (hitsInGPU.detid[hit] == 1) + hitidxs.push_back(hitsEvt->idxs[hit]); + if (hitsEvt->detid[hit] == 1) hittypes.push_back(0); else hittypes.push_back(4); @@ -28,17 +28,17 @@ std::tuple, std::vector> convertHitsToHi //____________________________________________________________________________________________ std::vector getPixelHitsFrompLS(SDL::Event* event, unsigned int pLS) { - SDL::segmentsBuffer& segments_ = *(event->getSegments()); - SDL::miniDoubletsBuffer& miniDoublets_ = *(event->getMiniDoublets()); - SDL::objectRangesBuffer& rangesInGPU = (*event->getRanges()); - SDL::modulesBuffer& modulesInGPU = (*event->getModules()); - const unsigned int pLS_offset = rangesInGPU.segmentModuleIndices[*(modulesInGPU.nLowerModules)]; - unsigned int MD_1 = segments_.mdIndices[2 * (pLS + pLS_offset)]; - unsigned int MD_2 = segments_.mdIndices[2 * (pLS + pLS_offset) + 1]; - unsigned int hit_1 = miniDoublets_.anchorHitIndices[MD_1]; - unsigned int hit_2 = miniDoublets_.outerHitIndices[MD_1]; - unsigned int hit_3 = miniDoublets_.anchorHitIndices[MD_2]; - unsigned int hit_4 = miniDoublets_.outerHitIndices[MD_2]; + SDL::Segments const* segments = event->getSegments()->data(); + SDL::MiniDoublets const* miniDoublets = event->getMiniDoublets()->data(); + SDL::ObjectRanges const* rangesEvt = event->getRanges()->data(); + SDL::Modules const* modulesEvt = event->getModules()->data(); + const unsigned int pLS_offset = rangesEvt->segmentModuleIndices[*(modulesEvt->nLowerModules)]; + unsigned int MD_1 = segments->mdIndices[2 * (pLS + pLS_offset)]; + unsigned int MD_2 = segments->mdIndices[2 * (pLS + pLS_offset) + 1]; + unsigned int hit_1 = miniDoublets->anchorHitIndices[MD_1]; + unsigned int hit_2 = miniDoublets->outerHitIndices[MD_1]; + unsigned int hit_3 = miniDoublets->anchorHitIndices[MD_2]; + unsigned int hit_4 = miniDoublets->outerHitIndices[MD_2]; if (hit_3 == hit_4) return {hit_1, hit_2, hit_3}; else @@ -47,11 +47,11 @@ std::vector getPixelHitsFrompLS(SDL::Event* event, unsigned //____________________________________________________________________________________________ std::vector getPixelHitIdxsFrompLS(SDL::Event* event, unsigned int pLS) { - SDL::hitsBuffer& hitsInGPU = *(event->getHits()); + SDL::Hits const* hitsEvt = event->getHits()->data(); std::vector hits = getPixelHitsFrompLS(event, pLS); std::vector hitidxs; for (auto& hit : hits) - hitidxs.push_back(hitsInGPU.idxs[hit]); + hitidxs.push_back(hitsEvt->idxs[hit]); return hitidxs; } @@ -74,9 +74,9 @@ std::tuple, std::vector> getHitIdxsAndHi //____________________________________________________________________________________________ std::vector getHitsFromMD(SDL::Event* event, unsigned int MD) { - SDL::miniDoubletsBuffer& miniDoublets_ = *(event->getMiniDoublets()); - unsigned int hit_1 = miniDoublets_.anchorHitIndices[MD]; - unsigned int hit_2 = miniDoublets_.outerHitIndices[MD]; + SDL::MiniDoublets const* miniDoublets = event->getMiniDoublets()->data(); + unsigned int hit_1 = miniDoublets->anchorHitIndices[MD]; + unsigned int hit_2 = miniDoublets->outerHitIndices[MD]; return {hit_1, hit_2}; } @@ -92,9 +92,9 @@ std::tuple, std::vector> getHitIdxsAndHi //____________________________________________________________________________________________ std::vector getMDsFromLS(SDL::Event* event, unsigned int LS) { - SDL::segmentsBuffer& segments_ = *(event->getSegments()); - unsigned int MD_1 = segments_.mdIndices[2 * LS]; - unsigned int MD_2 = segments_.mdIndices[2 * LS + 1]; + SDL::Segments const* segments = event->getSegments()->data(); + unsigned int MD_1 = segments->mdIndices[2 * LS]; + unsigned int MD_2 = segments->mdIndices[2 * LS + 1]; return {MD_1, MD_2}; } @@ -118,9 +118,9 @@ std::tuple, std::vector> getHitIdxsAndHi //____________________________________________________________________________________________ std::vector getLSsFromT3(SDL::Event* event, unsigned int T3) { - SDL::tripletsBuffer& triplets_ = *(event->getTriplets()); - unsigned int LS_1 = triplets_.segmentIndices[2 * T3]; - unsigned int LS_2 = triplets_.segmentIndices[2 * T3 + 1]; + SDL::Triplets const* triplets = event->getTriplets()->data(); + unsigned int LS_1 = triplets->segmentIndices[2 * T3]; + unsigned int LS_2 = triplets->segmentIndices[2 * T3 + 1]; return {LS_1, LS_2}; } @@ -153,9 +153,9 @@ std::tuple, std::vector> getHitIdxsAndHi //____________________________________________________________________________________________ std::vector getT3sFromT5(SDL::Event* event, unsigned int T5) { - SDL::quintupletsBuffer& quintuplets_ = *(event->getQuintuplets()); - unsigned int T3_1 = quintuplets_.tripletIndices[2 * T5]; - unsigned int T3_2 = quintuplets_.tripletIndices[2 * T5 + 1]; + SDL::Quintuplets const* quintuplets = event->getQuintuplets()->data(); + unsigned int T3_1 = quintuplets->tripletIndices[2 * T5]; + unsigned int T3_2 = quintuplets->tripletIndices[2 * T5 + 1]; return {T3_1, T3_2}; } @@ -190,20 +190,20 @@ std::vector getHitsFromT5(SDL::Event* event, unsigned int T //____________________________________________________________________________________________ std::vector getHitIdxsFromT5(SDL::Event* event, unsigned int T5) { - SDL::hitsBuffer& hitsInGPU = *(event->getHits()); + SDL::Hits const* hitsEvt = event->getHits()->data(); std::vector hits = getHitsFromT5(event, T5); std::vector hitidxs; for (auto& hit : hits) - hitidxs.push_back(hitsInGPU.idxs[hit]); + hitidxs.push_back(hitsEvt->idxs[hit]); return hitidxs; } //____________________________________________________________________________________________ std::vector getModuleIdxsFromT5(SDL::Event* event, unsigned int T5) { std::vector hits = getHitsFromT5(event, T5); std::vector module_idxs; - SDL::hitsBuffer& hitsInGPU = *(event->getHits()); + SDL::Hits const* hitsEvt = event->getHits()->data(); for (auto& hitIdx : hits) { - module_idxs.push_back(hitsInGPU.moduleIndices[hitIdx]); + module_idxs.push_back(hitsEvt->moduleIndices[hitIdx]); } return module_idxs; } @@ -225,17 +225,17 @@ std::tuple, std::vector> getHitIdxsAndHi //____________________________________________________________________________________________ unsigned int getPixelLSFrompT3(SDL::Event* event, unsigned int pT3) { - SDL::pixelTripletsBuffer& pixelTriplets_ = *(event->getPixelTriplets()); - SDL::objectRangesBuffer& rangesInGPU = (*event->getRanges()); - SDL::modulesBuffer& modulesInGPU = (*event->getModules()); - const unsigned int pLS_offset = rangesInGPU.segmentModuleIndices[*(modulesInGPU.nLowerModules)]; - return pixelTriplets_.pixelSegmentIndices[pT3] - pLS_offset; + SDL::PixelTriplets const* pixelTriplets = event->getPixelTriplets()->data(); + SDL::ObjectRanges const* rangesEvt = event->getRanges()->data(); + SDL::Modules const* modulesEvt = event->getModules()->data(); + const unsigned int pLS_offset = rangesEvt->segmentModuleIndices[*(modulesEvt->nLowerModules)]; + return pixelTriplets->pixelSegmentIndices[pT3] - pLS_offset; } //____________________________________________________________________________________________ unsigned int getT3FrompT3(SDL::Event* event, unsigned int pT3) { - SDL::pixelTriplets& pixelTriplets_ = *(event->getPixelTriplets()); - return pixelTriplets_.tripletIndices[pT3]; + SDL::PixelTriplets const* pixelTriplets = event->getPixelTriplets()->data(); + return pixelTriplets->tripletIndices[pT3]; } //____________________________________________________________________________________________ @@ -274,20 +274,20 @@ std::vector getHitsFrompT3(SDL::Event* event, unsigned int //____________________________________________________________________________________________ std::vector getHitIdxsFrompT3(SDL::Event* event, unsigned int pT3) { - SDL::hitsBuffer& hitsInGPU = *(event->getHits()); + SDL::Hits const* hitsEvt = event->getHits()->data(); std::vector hits = getHitsFrompT3(event, pT3); std::vector hitidxs; for (auto& hit : hits) - hitidxs.push_back(hitsInGPU.idxs[hit]); + hitidxs.push_back(hitsEvt->idxs[hit]); return hitidxs; } //____________________________________________________________________________________________ std::vector getModuleIdxsFrompT3(SDL::Event* event, unsigned int pT3) { std::vector hits = getOuterTrackerHitsFrompT3(event, pT3); std::vector module_idxs; - SDL::hitsBuffer& hitsInGPU = *(event->getHits()); + SDL::Hits const* hitsEvt = event->getHits()->data(); for (auto& hitIdx : hits) { - module_idxs.push_back(hitsInGPU.moduleIndices[hitIdx]); + module_idxs.push_back(hitsEvt->moduleIndices[hitIdx]); } return module_idxs; } @@ -314,17 +314,17 @@ std::tuple, std::vector> getHitIdxsAndHi //____________________________________________________________________________________________ unsigned int getPixelLSFrompT5(SDL::Event* event, unsigned int pT5) { - SDL::pixelQuintupletsBuffer& pixelQuintuplets_ = *(event->getPixelQuintuplets()); - SDL::objectRangesBuffer& rangesInGPU = (*event->getRanges()); - SDL::modulesBuffer& modulesInGPU = (*event->getModules()); - const unsigned int pLS_offset = rangesInGPU.segmentModuleIndices[*(modulesInGPU.nLowerModules)]; - return pixelQuintuplets_.pixelIndices[pT5] - pLS_offset; + SDL::PixelQuintuplets const* pixelQuintuplets = event->getPixelQuintuplets()->data(); + SDL::ObjectRanges const* rangesEvt = event->getRanges()->data(); + SDL::Modules const* modulesEvt = event->getModules()->data(); + const unsigned int pLS_offset = rangesEvt->segmentModuleIndices[*(modulesEvt->nLowerModules)]; + return pixelQuintuplets->pixelIndices[pT5] - pLS_offset; } //____________________________________________________________________________________________ unsigned int getT5FrompT5(SDL::Event* event, unsigned int pT5) { - SDL::pixelQuintupletsBuffer& pixelQuintuplets_ = *(event->getPixelQuintuplets()); - return pixelQuintuplets_.T5Indices[pT5]; + SDL::PixelQuintuplets const* pixelQuintuplets = event->getPixelQuintuplets()->data(); + return pixelQuintuplets->T5Indices[pT5]; } //____________________________________________________________________________________________ @@ -369,11 +369,11 @@ std::vector getHitsFrompT5(SDL::Event* event, unsigned int //____________________________________________________________________________________________ std::vector getHitIdxsFrompT5(SDL::Event* event, unsigned int pT5) { - SDL::hitsBuffer& hitsInGPU = *(event->getHits()); + SDL::Hits const* hitsEvt = event->getHits()->data(); std::vector hits = getHitsFrompT5(event, pT5); std::vector hitidxs; for (auto& hit : hits) - hitidxs.push_back(hitsInGPU.idxs[hit]); + hitidxs.push_back(hitsEvt->idxs[hit]); return hitidxs; } @@ -381,9 +381,9 @@ std::vector getHitIdxsFrompT5(SDL::Event* event, unsigned i std::vector getModuleIdxsFrompT5(SDL::Event* event, unsigned int pT5) { std::vector hits = getOuterTrackerHitsFrompT5(event, pT5); std::vector module_idxs; - SDL::hitsBuffer& hitsInGPU = *(event->getHits()); + SDL::Hits const* hitsEvt = event->getHits()->data(); for (auto& hitIdx : hits) { - module_idxs.push_back(hitsInGPU.moduleIndices[hitIdx]); + module_idxs.push_back(hitsEvt->moduleIndices[hitIdx]); } return module_idxs; } @@ -412,9 +412,9 @@ std::tuple, std::vector> getHitIdxsAndHi //____________________________________________________________________________________________ std::vector getLSsFromTC(SDL::Event* event, unsigned int TC) { // Get the type of the track candidate - SDL::trackCandidatesBuffer& trackCandidatesInGPU = (*event->getTrackCandidates()); - short type = trackCandidatesInGPU.trackCandidateType[TC]; - unsigned int objidx = trackCandidatesInGPU.directObjectIndices[TC]; + SDL::TrackCandidates const* trackCandidates = event->getTrackCandidates()->data(); + short type = trackCandidates->trackCandidateType[TC]; + unsigned int objidx = trackCandidates->directObjectIndices[TC]; switch (type) { case kpT5: return getLSsFrompT5(event, objidx); @@ -435,9 +435,9 @@ std::vector getLSsFromTC(SDL::Event* event, unsigned int TC std::tuple, std::vector> getHitIdxsAndHitTypesFromTC(SDL::Event* event, unsigned TC) { // Get the type of the track candidate - SDL::trackCandidatesBuffer& trackCandidatesInGPU = (*event->getTrackCandidates()); - short type = trackCandidatesInGPU.trackCandidateType[TC]; - unsigned int objidx = trackCandidatesInGPU.directObjectIndices[TC]; + SDL::TrackCandidates const* trackCandidates = event->getTrackCandidates()->data(); + short type = trackCandidates->trackCandidateType[TC]; + unsigned int objidx = trackCandidates->directObjectIndices[TC]; switch (type) { case kpT5: return getHitIdxsAndHitTypesFrompT5(event, objidx); diff --git a/RecoTracker/LSTCore/standalone/code/core/write_sdl_ntuple.cc b/RecoTracker/LSTCore/standalone/code/core/write_sdl_ntuple.cc index 987fdfa7c5a70..7ffef21e9005a 100644 --- a/RecoTracker/LSTCore/standalone/code/core/write_sdl_ntuple.cc +++ b/RecoTracker/LSTCore/standalone/code/core/write_sdl_ntuple.cc @@ -226,8 +226,8 @@ void setOutputBranches(SDL::Event* event) { std::vector> tc_matched_simIdx; // ============ Track candidates ============= - SDL::trackCandidatesBuffer& trackCandidatesInGPU = (*event->getTrackCandidates()); - unsigned int nTrackCandidates = *trackCandidatesInGPU.nTrackCandidates; + SDL::TrackCandidates const* trackCandidates = event->getTrackCandidates()->data(); + unsigned int nTrackCandidates = *trackCandidates->nTrackCandidates; for (unsigned int idx = 0; idx < nTrackCandidates; idx++) { // Compute reco quantities of track candidate based on final object int type, isFake; @@ -291,23 +291,23 @@ void setOptionalOutputBranches(SDL::Event* event) { //________________________________________________________________________________________________________________________________ void setPixelQuintupletOutputBranches(SDL::Event* event) { // ============ pT5 ============= - SDL::pixelQuintupletsBuffer& pixelQuintupletsInGPU = (*event->getPixelQuintuplets()); - SDL::quintupletsBuffer& quintupletsInGPU = (*event->getQuintuplets()); - SDL::segmentsBuffer& segmentsInGPU = (*event->getSegments()); - SDL::modulesBuffer& modulesInGPU = (*event->getModules()); + SDL::PixelQuintuplets const* pixelQuintuplets = event->getPixelQuintuplets()->data(); + SDL::Quintuplets const* quintuplets = event->getQuintuplets()->data(); + SDL::Segments const* segments = event->getSegments()->data(); + SDL::Modules const* modules = event->getModules()->data(); int n_accepted_simtrk = ana.tx->getBranch>("sim_TC_matched").size(); unsigned int nPixelQuintuplets = - *pixelQuintupletsInGPU.nPixelQuintuplets; // size of this nPixelTriplets array is 1 (NOTE: parallelism lost here.) + *pixelQuintuplets->nPixelQuintuplets; // size of this nPixelTriplets array is 1 (NOTE: parallelism lost here.) std::vector sim_pT5_matched(n_accepted_simtrk); std::vector> pT5_matched_simIdx; for (unsigned int pT5 = 0; pT5 < nPixelQuintuplets; pT5++) { unsigned int T5Index = getT5FrompT5(event, pT5); unsigned int pLSIndex = getPixelLSFrompT5(event, pT5); - float pt = (__H2F(quintupletsInGPU.innerRadius[T5Index]) * SDL::k2Rinv1GeVf * 2 + segmentsInGPU.ptIn[pLSIndex]) / 2; - float eta = segmentsInGPU.eta[pLSIndex]; - float phi = segmentsInGPU.phi[pLSIndex]; + float pt = (__H2F(quintuplets->innerRadius[T5Index]) * SDL::k2Rinv1GeVf * 2 + segments->ptIn[pLSIndex]) / 2; + float eta = segments->eta[pLSIndex]; + float phi = segments->phi[pLSIndex]; std::vector hit_idx = getHitIdxsFrompT5(event, pT5); std::vector module_idx = getModuleIdxsFrompT5(event, pT5); @@ -316,8 +316,8 @@ void setPixelQuintupletOutputBranches(SDL::Event* event) { int layer_binary = 1; int moduleType_binary = 0; for (size_t i = 0; i < module_idx.size(); i += 2) { - layer_binary |= (1 << (modulesInGPU.layers[module_idx[i]] + 6 * (modulesInGPU.subdets[module_idx[i]] == 4))); - moduleType_binary |= (modulesInGPU.moduleType[module_idx[i]] << i); + layer_binary |= (1 << (modules->layers[module_idx[i]] + 6 * (modules->subdets[module_idx[i]] == 4))); + moduleType_binary |= (modules->moduleType[module_idx[i]] << i); } std::vector simidx = matchedSimTrkIdxs(hit_idx, hit_type); ana.tx->pushbackToBranch("pT5_isFake", static_cast(simidx.size() == 0)); @@ -366,21 +366,21 @@ void setPixelQuintupletOutputBranches(SDL::Event* event) { //________________________________________________________________________________________________________________________________ void setQuintupletOutputBranches(SDL::Event* event) { - SDL::quintupletsBuffer& quintupletsInGPU = (*event->getQuintuplets()); - SDL::objectRangesBuffer& rangesInGPU = (*event->getRanges()); - SDL::modulesBuffer& modulesInGPU = (*event->getModules()); + SDL::Quintuplets const* quintuplets = event->getQuintuplets()->data(); + SDL::ObjectRanges const* ranges = event->getRanges()->data(); + SDL::Modules const* modules = event->getModules()->data(); int n_accepted_simtrk = ana.tx->getBranch>("sim_TC_matched").size(); std::vector sim_t5_matched(n_accepted_simtrk); std::vector> t5_matched_simIdx; - for (unsigned int lowerModuleIdx = 0; lowerModuleIdx < *(modulesInGPU.nLowerModules); ++lowerModuleIdx) { - int nQuintuplets = quintupletsInGPU.nQuintuplets[lowerModuleIdx]; + for (unsigned int lowerModuleIdx = 0; lowerModuleIdx < *(modules->nLowerModules); ++lowerModuleIdx) { + int nQuintuplets = quintuplets->nQuintuplets[lowerModuleIdx]; for (unsigned int idx = 0; idx < nQuintuplets; idx++) { - unsigned int quintupletIndex = rangesInGPU.quintupletModuleIndices[lowerModuleIdx] + idx; - float pt = __H2F(quintupletsInGPU.innerRadius[quintupletIndex]) * SDL::k2Rinv1GeVf * 2; - float eta = __H2F(quintupletsInGPU.eta[quintupletIndex]); - float phi = __H2F(quintupletsInGPU.phi[quintupletIndex]); + unsigned int quintupletIndex = ranges->quintupletModuleIndices[lowerModuleIdx] + idx; + float pt = __H2F(quintuplets->innerRadius[quintupletIndex]) * SDL::k2Rinv1GeVf * 2; + float eta = __H2F(quintuplets->eta[quintupletIndex]); + float phi = __H2F(quintuplets->phi[quintupletIndex]); std::vector hit_idx = getHitIdxsFromT5(event, quintupletIndex); std::vector hit_type = getHitTypesFromT5(event, quintupletIndex); @@ -389,8 +389,8 @@ void setQuintupletOutputBranches(SDL::Event* event) { int layer_binary = 0; int moduleType_binary = 0; for (size_t i = 0; i < module_idx.size(); i += 2) { - layer_binary |= (1 << (modulesInGPU.layers[module_idx[i]] + 6 * (modulesInGPU.subdets[module_idx[i]] == 4))); - moduleType_binary |= (modulesInGPU.moduleType[module_idx[i]] << i); + layer_binary |= (1 << (modules->layers[module_idx[i]] + 6 * (modules->subdets[module_idx[i]] == 4))); + moduleType_binary |= (modules->moduleType[module_idx[i]] << i); } std::vector simidx = matchedSimTrkIdxs(hit_idx, hit_type); @@ -399,11 +399,11 @@ void setQuintupletOutputBranches(SDL::Event* event) { ana.tx->pushbackToBranch("t5_pt", pt); ana.tx->pushbackToBranch("t5_eta", eta); ana.tx->pushbackToBranch("t5_phi", phi); - ana.tx->pushbackToBranch("t5_innerRadius", __H2F(quintupletsInGPU.innerRadius[quintupletIndex])); - ana.tx->pushbackToBranch("t5_bridgeRadius", __H2F(quintupletsInGPU.bridgeRadius[quintupletIndex])); - ana.tx->pushbackToBranch("t5_outerRadius", __H2F(quintupletsInGPU.outerRadius[quintupletIndex])); - ana.tx->pushbackToBranch("t5_chiSquared", quintupletsInGPU.chiSquared[quintupletIndex]); - ana.tx->pushbackToBranch("t5_rzChiSquared", quintupletsInGPU.rzChiSquared[quintupletIndex]); + ana.tx->pushbackToBranch("t5_innerRadius", __H2F(quintuplets->innerRadius[quintupletIndex])); + ana.tx->pushbackToBranch("t5_bridgeRadius", __H2F(quintuplets->bridgeRadius[quintupletIndex])); + ana.tx->pushbackToBranch("t5_outerRadius", __H2F(quintuplets->outerRadius[quintupletIndex])); + ana.tx->pushbackToBranch("t5_chiSquared", quintuplets->chiSquared[quintupletIndex]); + ana.tx->pushbackToBranch("t5_rzChiSquared", quintuplets->rzChiSquared[quintupletIndex]); ana.tx->pushbackToBranch("t5_layer_binary", layer_binary); ana.tx->pushbackToBranch("t5_moduleType_binary", moduleType_binary); @@ -437,24 +437,22 @@ void setQuintupletOutputBranches(SDL::Event* event) { //________________________________________________________________________________________________________________________________ void setPixelTripletOutputBranches(SDL::Event* event) { - SDL::pixelTripletsBuffer& pixelTripletsInGPU = (*event->getPixelTriplets()); - SDL::tripletsBuffer& tripletsInGPU = *(event->getTriplets()); - SDL::modulesBuffer& modulesInGPU = *(event->getModules()); - SDL::segmentsBuffer& segmentsInGPU = *(event->getSegments()); - SDL::hitsBuffer& hitsInGPU = *(event->getHits()); + SDL::PixelTriplets const* pixelTriplets = event->getPixelTriplets()->data(); + SDL::Modules const* modules = event->getModules()->data(); + SDL::Segments const* segments = event->getSegments()->data(); int n_accepted_simtrk = ana.tx->getBranch>("sim_TC_matched").size(); - unsigned int nPixelTriplets = *pixelTripletsInGPU.nPixelTriplets; + unsigned int nPixelTriplets = *pixelTriplets->nPixelTriplets; std::vector sim_pT3_matched(n_accepted_simtrk); std::vector> pT3_matched_simIdx; for (unsigned int pT3 = 0; pT3 < nPixelTriplets; pT3++) { unsigned int T3Index = getT3FrompT3(event, pT3); unsigned int pLSIndex = getPixelLSFrompT3(event, pT3); - const float pt = segmentsInGPU.ptIn[pLSIndex]; + const float pt = segments->ptIn[pLSIndex]; - float eta = segmentsInGPU.eta[pLSIndex]; - float phi = segmentsInGPU.phi[pLSIndex]; + float eta = segments->eta[pLSIndex]; + float phi = segments->phi[pLSIndex]; std::vector hit_idx = getHitIdxsFrompT3(event, pT3); std::vector hit_type = getHitTypesFrompT3(event, pT3); @@ -463,8 +461,8 @@ void setPixelTripletOutputBranches(SDL::Event* event) { int layer_binary = 1; int moduleType_binary = 0; for (size_t i = 0; i < module_idx.size(); i += 2) { - layer_binary |= (1 << (modulesInGPU.layers[module_idx[i]] + 6 * (modulesInGPU.subdets[module_idx[i]] == 4))); - moduleType_binary |= (modulesInGPU.moduleType[module_idx[i]] << i); + layer_binary |= (1 << (modules->layers[module_idx[i]] + 6 * (modules->subdets[module_idx[i]] == 4))); + moduleType_binary |= (modules->moduleType[module_idx[i]] << i); } ana.tx->pushbackToBranch("pT3_isFake", static_cast(simidx.size() == 0)); ana.tx->pushbackToBranch("pT3_pt", pt); @@ -503,12 +501,12 @@ void setPixelTripletOutputBranches(SDL::Event* event) { //________________________________________________________________________________________________________________________________ void setGnnNtupleBranches(SDL::Event* event) { // Get relevant information - SDL::segmentsBuffer& segmentsInGPU = (*event->getSegments()); - SDL::miniDoubletsBuffer& miniDoubletsInGPU = (*event->getMiniDoublets()); - SDL::hitsBuffer& hitsInGPU = (*event->getHits()); - SDL::modulesBuffer& modulesInGPU = (*event->getModules()); - SDL::objectRangesBuffer& rangesInGPU = (*event->getRanges()); - SDL::trackCandidatesBuffer& trackCandidatesInGPU = (*event->getTrackCandidates()); + SDL::Segments const* segments = event->getSegments()->data(); + SDL::MiniDoublets const* miniDoublets = event->getMiniDoublets()->data(); + SDL::Hits const* hitsEvt = event->getHits()->data(); + SDL::Modules const* modules = event->getModules()->data(); + SDL::ObjectRanges const* ranges = event->getRanges()->data(); + SDL::TrackCandidates const* trackCandidates = event->getTrackCandidates()->data(); std::set mds_used_in_sg; std::map md_index_map; @@ -517,13 +515,13 @@ void setGnnNtupleBranches(SDL::Event* event) { // Loop over modules (lower ones where the MDs are saved) unsigned int nTotalMD = 0; unsigned int nTotalLS = 0; - for (unsigned int idx = 0; idx < *(modulesInGPU.nLowerModules); ++idx) { - nTotalMD += miniDoubletsInGPU.nMDs[idx]; - nTotalLS += segmentsInGPU.nSegments[idx]; + for (unsigned int idx = 0; idx < *(modules->nLowerModules); ++idx) { + nTotalMD += miniDoublets->nMDs[idx]; + nTotalLS += segments->nSegments[idx]; } std::set lss_used_in_true_tc; - unsigned int nTrackCandidates = *trackCandidatesInGPU.nTrackCandidates; + unsigned int nTrackCandidates = *trackCandidates->nTrackCandidates; for (unsigned int idx = 0; idx < nTrackCandidates; idx++) { // Only consider true track candidates std::vector hitidxs; @@ -547,20 +545,20 @@ void setGnnNtupleBranches(SDL::Event* event) { // std::cout << " nTotalLS: " << nTotalLS << std::endl; // Loop over modules (lower ones where the MDs are saved) - for (unsigned int idx = 0; idx < *(modulesInGPU.nLowerModules); ++idx) { + for (unsigned int idx = 0; idx < *(modules->nLowerModules); ++idx) { // // Loop over minidoublets - // for (unsigned int jdx = 0; jdx < miniDoubletsInGPU.nMDs[idx]; jdx++) + // for (unsigned int jdx = 0; jdx < miniDoublets->nMDs[idx]; jdx++) // { - // // Get the actual index to the mini-doublet using rangesInGPU - // unsigned int mdIdx = rangesInGPU.miniDoubletModuleIndices[idx] + jdx; + // // Get the actual index to the mini-doublet using ranges + // unsigned int mdIdx = ranges->miniDoubletModuleIndices[idx] + jdx; // setGnnNtupleMiniDoublet(event, mdIdx); // } // Loop over segments - for (unsigned int jdx = 0; jdx < segmentsInGPU.nSegments[idx]; jdx++) { - // Get the actual index to the segments using rangesInGPU - unsigned int sgIdx = rangesInGPU.segmentModuleIndices[idx] + jdx; + for (unsigned int jdx = 0; jdx < segments->nSegments[idx]; jdx++) { + // Get the actual index to the segments using ranges + unsigned int sgIdx = ranges->segmentModuleIndices[idx] + jdx; // Get the hit indices std::vector MDs = getMDsFromLS(event, sgIdx); @@ -584,8 +582,8 @@ void setGnnNtupleBranches(SDL::Event* event) { // Computing line segment pt estimate (assuming beam spot is at zero) SDLMath::Hit hitA(0, 0, 0); - SDLMath::Hit hitB(hitsInGPU.xs[hits[0]], hitsInGPU.ys[hits[0]], hitsInGPU.zs[hits[0]]); - SDLMath::Hit hitC(hitsInGPU.xs[hits[2]], hitsInGPU.ys[hits[2]], hitsInGPU.zs[hits[2]]); + SDLMath::Hit hitB(hitsEvt->xs[hits[0]], hitsEvt->ys[hits[0]], hitsEvt->zs[hits[0]]); + SDLMath::Hit hitC(hitsEvt->xs[hits[2]], hitsEvt->ys[hits[2]], hitsEvt->zs[hits[2]]); SDLMath::Hit center = SDLMath::getCenterFromThreePoints(hitA, hitB, hitC); float pt = SDLMath::ptEstimateFromRadius(center.rt()); float eta = hitC.eta(); @@ -644,25 +642,25 @@ void setGnnNtupleBranches(SDL::Event* event) { //________________________________________________________________________________________________________________________________ void setGnnNtupleMiniDoublet(SDL::Event* event, unsigned int MD) { // Get relevant information - SDL::miniDoubletsBuffer& miniDoubletsInGPU = (*event->getMiniDoublets()); - SDL::hitsBuffer& hitsInGPU = (*event->getHits()); + SDL::MiniDoublets const* miniDoublets = event->getMiniDoublets()->data(); + SDL::Hits const* hitsEvt = event->getHits()->data(); // Get the hit indices - unsigned int hit0 = miniDoubletsInGPU.anchorHitIndices[MD]; - unsigned int hit1 = miniDoubletsInGPU.outerHitIndices[MD]; + unsigned int hit0 = miniDoublets->anchorHitIndices[MD]; + unsigned int hit1 = miniDoublets->outerHitIndices[MD]; // Get the hit infos - const float hit0_x = hitsInGPU.xs[hit0]; - const float hit0_y = hitsInGPU.ys[hit0]; - const float hit0_z = hitsInGPU.zs[hit0]; + const float hit0_x = hitsEvt->xs[hit0]; + const float hit0_y = hitsEvt->ys[hit0]; + const float hit0_z = hitsEvt->zs[hit0]; const float hit0_r = sqrt(hit0_x * hit0_x + hit0_y * hit0_y); - const float hit1_x = hitsInGPU.xs[hit1]; - const float hit1_y = hitsInGPU.ys[hit1]; - const float hit1_z = hitsInGPU.zs[hit1]; + const float hit1_x = hitsEvt->xs[hit1]; + const float hit1_y = hitsEvt->ys[hit1]; + const float hit1_z = hitsEvt->zs[hit1]; const float hit1_r = sqrt(hit1_x * hit1_x + hit1_y * hit1_y); // Do sim matching - std::vector hit_idx = {hitsInGPU.idxs[hit0], hitsInGPU.idxs[hit1]}; + std::vector hit_idx = {hitsEvt->idxs[hit0], hitsEvt->idxs[hit1]}; std::vector hit_type = {4, 4}; std::vector simidxs = matchedSimTrkIdxs(hit_idx, hit_type); @@ -670,8 +668,8 @@ void setGnnNtupleMiniDoublet(SDL::Event* event, unsigned int MD) { int tp_type = getDenomSimTrkType(simidxs); // Obtain where the actual hit is located in terms of their layer, module, rod, and ring number - unsigned int anchitidx = hitsInGPU.idxs[hit0]; - int subdet = trk.ph2_subdet()[hitsInGPU.idxs[anchitidx]]; + unsigned int anchitidx = hitsEvt->idxs[hit0]; + int subdet = trk.ph2_subdet()[hitsEvt->idxs[anchitidx]]; int is_endcap = subdet == 4; int layer = trk.ph2_layer()[anchitidx] + @@ -679,7 +677,7 @@ void setGnnNtupleMiniDoublet(SDL::Event* event, unsigned int MD) { int detId = trk.ph2_detId()[anchitidx]; // Obtaining dPhiChange - float dphichange = miniDoubletsInGPU.dphichanges[MD]; + float dphichange = miniDoublets->dphichanges[MD]; // Computing pt float pt = hit0_r * SDL::k2Rinv1GeVf / sin(dphichange); @@ -713,8 +711,8 @@ void setGnnNtupleMiniDoublet(SDL::Event* event, unsigned int MD) { std::tuple> parseTrackCandidate(SDL::Event* event, unsigned int idx) { // Get the type of the track candidate - SDL::trackCandidatesBuffer& trackCandidatesInGPU = (*event->getTrackCandidates()); - short type = trackCandidatesInGPU.trackCandidateType[idx]; + SDL::TrackCandidates const* trackCandidates = event->getTrackCandidates()->data(); + short type = trackCandidates->trackCandidateType[idx]; enum { pT5 = 7, pT3 = 5, T5 = 4, pLS = 8 }; @@ -747,9 +745,9 @@ std::tuple> parseTrackCandidate( std::tuple, std::vector> parsepT5(SDL::Event* event, unsigned int idx) { // Get relevant information - SDL::trackCandidatesBuffer& trackCandidatesInGPU = (*event->getTrackCandidates()); - SDL::quintupletsBuffer& quintupletsInGPU = (*event->getQuintuplets()); - SDL::segmentsBuffer& segmentsInGPU = (*event->getSegments()); + SDL::TrackCandidates const* trackCandidates = event->getTrackCandidates()->data(); + SDL::Quintuplets const* quintuplets = event->getQuintuplets()->data(); + SDL::Segments const* segments = event->getSegments()->data(); // // pictorial representation of a pT5 @@ -760,7 +758,7 @@ std::tuple, std::vectordirectObjectIndices[idx]; unsigned int pLS = getPixelLSFrompT5(event, pT5); unsigned int T5Index = getT5FrompT5(event, pT5); @@ -842,10 +840,10 @@ std::tuple, std::vectorptIn[pLS]; + const float eta_pLS = segments->eta[pLS]; + const float phi_pLS = segments->phi[pLS]; + float pt_T5 = __H2F(quintuplets->innerRadius[T5Index]) * 2 * SDL::k2Rinv1GeVf; const float pt = (pt_T5 + pt_pLS) / 2; // Form the hit idx/type std::vector @@ -859,9 +857,9 @@ std::tuple, std::vector, std::vector> parsepT3(SDL::Event* event, unsigned int idx) { // Get relevant information - SDL::trackCandidatesBuffer& trackCandidatesInGPU = (*event->getTrackCandidates()); - SDL::tripletsBuffer& tripletsInGPU = (*event->getTriplets()); - SDL::segmentsBuffer& segmentsInGPU = (*event->getSegments()); + SDL::TrackCandidates const* trackCandidates = event->getTrackCandidates()->data(); + SDL::Triplets const* triplets = event->getTriplets()->data(); + SDL::Segments const* segments = event->getSegments()->data(); // // pictorial representation of a pT3 @@ -870,15 +868,15 @@ std::tuple, std::vectordirectObjectIndices[idx]; unsigned int pLS = getPixelLSFrompT3(event, pT3); unsigned int T3 = getT3FrompT3(event, pT3); // pixel pt - const float pt_pLS = segmentsInGPU.ptIn[pLS]; - const float eta_pLS = segmentsInGPU.eta[pLS]; - const float phi_pLS = segmentsInGPU.phi[pLS]; - float pt_T3 = tripletsInGPU.circleRadius[T3] * 2 * SDL::k2Rinv1GeVf; + const float pt_pLS = segments->ptIn[pLS]; + const float eta_pLS = segments->eta[pLS]; + const float phi_pLS = segments->phi[pLS]; + float pt_T3 = triplets->circleRadius[T3] * 2 * SDL::k2Rinv1GeVf; // average pt const float pt = (pt_pLS + pt_T3) / 2; @@ -893,9 +891,9 @@ std::tuple, std::vector, std::vector> parseT5(SDL::Event* event, unsigned int idx) { - SDL::trackCandidatesBuffer& trackCandidatesInGPU = (*event->getTrackCandidates()); - SDL::quintupletsBuffer& quintupletsInGPU = (*event->getQuintuplets()); - unsigned int T5 = trackCandidatesInGPU.directObjectIndices[idx]; + SDL::TrackCandidates const* trackCandidates = event->getTrackCandidates()->data(); + SDL::Quintuplets const* quintuplets = event->getQuintuplets()->data(); + unsigned int T5 = trackCandidates->directObjectIndices[idx]; std::vector hits = getHitsFromT5(event, T5); // @@ -910,7 +908,7 @@ std::tuple, std::vectorinnerRadius[T5] * SDL::k2Rinv1GeVf * 2; // T5 eta and phi are computed using outer and innermost hits SDLMath::Hit hitA(trk.ph2_x()[Hit_0], trk.ph2_y()[Hit_0], trk.ph2_z()[Hit_0]); @@ -927,16 +925,16 @@ std::tuple, std::vector, std::vector> parsepLS(SDL::Event* event, unsigned int idx) { - SDL::trackCandidatesBuffer& trackCandidatesInGPU = (*event->getTrackCandidates()); - SDL::segmentsBuffer& segmentsInGPU = (*event->getSegments()); + SDL::TrackCandidates const* trackCandidates = event->getTrackCandidates()->data(); + SDL::Segments const* segments = event->getSegments()->data(); // Getting pLS index - unsigned int pLS = trackCandidatesInGPU.directObjectIndices[idx]; + unsigned int pLS = trackCandidates->directObjectIndices[idx]; // Getting pt eta and phi - float pt = segmentsInGPU.ptIn[pLS]; - float eta = segmentsInGPU.eta[pLS]; - float phi = segmentsInGPU.phi[pLS]; + float pt = segments->ptIn[pLS]; + float eta = segments->eta[pLS]; + float phi = segments->phi[pLS]; // Getting hit indices and types std::vector hit_idx = getPixelHitIdxsFrompLS(event, pLS); @@ -947,32 +945,32 @@ std::tuple, std::vector* event) { - SDL::modulesBuffer& modulesInGPU = (*event->getModules()); - SDL::objectRangesBuffer& rangesInGPU = (*event->getRanges()); + SDL::Modules const* modules = event->getModules()->data(); + SDL::ObjectRanges const* ranges = event->getRanges()->data(); int nHits = 0; - for (unsigned int idx = 0; idx <= *(modulesInGPU.nLowerModules); + for (unsigned int idx = 0; idx <= *(modules->nLowerModules); idx++) // "<=" because cheating to include pixel track candidate lower module { - nHits += rangesInGPU.hitRanges[4 * idx + 1] - rangesInGPU.hitRanges[4 * idx] + 1; - nHits += rangesInGPU.hitRanges[4 * idx + 3] - rangesInGPU.hitRanges[4 * idx + 2] + 1; + nHits += ranges->hitRanges[4 * idx + 1] - ranges->hitRanges[4 * idx] + 1; + nHits += ranges->hitRanges[4 * idx + 3] - ranges->hitRanges[4 * idx + 2] + 1; } std::cout << " nHits: " << nHits << std::endl; } //________________________________________________________________________________________________________________________________ void printMiniDoubletMultiplicities(SDL::Event* event) { - SDL::miniDoubletsBuffer& miniDoubletsInGPU = (*event->getMiniDoublets()); - SDL::modulesBuffer& modulesInGPU = (*event->getModules()); + SDL::MiniDoublets const* miniDoublets = event->getMiniDoublets()->data(); + SDL::Modules const* modules = event->getModules()->data(); int nMiniDoublets = 0; int totOccupancyMiniDoublets = 0; - for (unsigned int idx = 0; idx <= *(modulesInGPU.nModules); + for (unsigned int idx = 0; idx <= *(modules->nModules); idx++) // "<=" because cheating to include pixel track candidate lower module { - if (modulesInGPU.isLower[idx]) { - nMiniDoublets += miniDoubletsInGPU.nMDs[idx]; - totOccupancyMiniDoublets += miniDoubletsInGPU.totOccupancyMDs[idx]; + if (modules->isLower[idx]) { + nMiniDoublets += miniDoublets->nMDs[idx]; + totOccupancyMiniDoublets += miniDoublets->totOccupancyMDs[idx]; } } std::cout << " nMiniDoublets: " << nMiniDoublets << std::endl; @@ -989,19 +987,19 @@ void printAllObjects(SDL::Event* event) { //________________________________________________________________________________________________________________________________ void printMDs(SDL::Event* event) { - SDL::miniDoubletsBuffer& miniDoubletsInGPU = (*event->getMiniDoublets()); - SDL::hitsBuffer& hitsInGPU = (*event->getHits()); - SDL::modulesBuffer& modulesInGPU = (*event->getModules()); - SDL::objectRangesBuffer& rangesInGPU = (*event->getRanges()); + SDL::MiniDoublets const* miniDoublets = event->getMiniDoublets()->data(); + SDL::Hits const* hitsEvt = event->getHits()->data(); + SDL::Modules const* modules = event->getModules()->data(); + SDL::ObjectRanges const* ranges = event->getRanges()->data(); // Then obtain the lower module index - for (unsigned int idx = 0; idx <= *(modulesInGPU.nLowerModules); ++idx) { - for (unsigned int iMD = 0; iMD < miniDoubletsInGPU.nMDs[idx]; iMD++) { - unsigned int mdIdx = rangesInGPU.miniDoubletModuleIndices[idx] + iMD; - unsigned int LowerHitIndex = miniDoubletsInGPU.anchorHitIndices[mdIdx]; - unsigned int UpperHitIndex = miniDoubletsInGPU.outerHitIndices[mdIdx]; - unsigned int hit0 = hitsInGPU.idxs[LowerHitIndex]; - unsigned int hit1 = hitsInGPU.idxs[UpperHitIndex]; + for (unsigned int idx = 0; idx <= *(modules->nLowerModules); ++idx) { + for (unsigned int iMD = 0; iMD < miniDoublets->nMDs[idx]; iMD++) { + unsigned int mdIdx = ranges->miniDoubletModuleIndices[idx] + iMD; + unsigned int LowerHitIndex = miniDoublets->anchorHitIndices[mdIdx]; + unsigned int UpperHitIndex = miniDoublets->outerHitIndices[mdIdx]; + unsigned int hit0 = hitsEvt->idxs[LowerHitIndex]; + unsigned int hit1 = hitsEvt->idxs[UpperHitIndex]; std::cout << "VALIDATION 'MD': " << "MD" << " hit0: " << hit0 << " hit1: " << hit1 << std::endl; @@ -1011,28 +1009,28 @@ void printMDs(SDL::Event* event) { //________________________________________________________________________________________________________________________________ void printLSs(SDL::Event* event) { - SDL::segmentsBuffer& segmentsInGPU = (*event->getSegments()); - SDL::miniDoubletsBuffer& miniDoubletsInGPU = (*event->getMiniDoublets()); - SDL::hitsBuffer& hitsInGPU = (*event->getHits()); - SDL::modulesBuffer& modulesInGPU = (*event->getModules()); - SDL::objectRangesBuffer& rangesInGPU = (*event->getRanges()); + SDL::Segments const* segments = event->getSegments()->data(); + SDL::MiniDoublets const* miniDoublets = event->getMiniDoublets()->data(); + SDL::Hits const* hitsEvt = event->getHits()->data(); + SDL::Modules const* modules = event->getModules()->data(); + SDL::ObjectRanges const* ranges = event->getRanges()->data(); int nSegments = 0; - for (unsigned int i = 0; i < *(modulesInGPU.nLowerModules); ++i) { - unsigned int idx = i; //modulesInGPU.lowerModuleIndices[i]; - nSegments += segmentsInGPU.nSegments[idx]; - for (unsigned int jdx = 0; jdx < segmentsInGPU.nSegments[idx]; jdx++) { - unsigned int sgIdx = rangesInGPU.segmentModuleIndices[idx] + jdx; - unsigned int InnerMiniDoubletIndex = segmentsInGPU.mdIndices[2 * sgIdx]; - unsigned int OuterMiniDoubletIndex = segmentsInGPU.mdIndices[2 * sgIdx + 1]; - unsigned int InnerMiniDoubletLowerHitIndex = miniDoubletsInGPU.anchorHitIndices[InnerMiniDoubletIndex]; - unsigned int InnerMiniDoubletUpperHitIndex = miniDoubletsInGPU.outerHitIndices[InnerMiniDoubletIndex]; - unsigned int OuterMiniDoubletLowerHitIndex = miniDoubletsInGPU.anchorHitIndices[OuterMiniDoubletIndex]; - unsigned int OuterMiniDoubletUpperHitIndex = miniDoubletsInGPU.outerHitIndices[OuterMiniDoubletIndex]; - unsigned int hit0 = hitsInGPU.idxs[InnerMiniDoubletLowerHitIndex]; - unsigned int hit1 = hitsInGPU.idxs[InnerMiniDoubletUpperHitIndex]; - unsigned int hit2 = hitsInGPU.idxs[OuterMiniDoubletLowerHitIndex]; - unsigned int hit3 = hitsInGPU.idxs[OuterMiniDoubletUpperHitIndex]; + for (unsigned int i = 0; i < *(modules->nLowerModules); ++i) { + unsigned int idx = i; //modules->lowerModuleIndices[i]; + nSegments += segments->nSegments[idx]; + for (unsigned int jdx = 0; jdx < segments->nSegments[idx]; jdx++) { + unsigned int sgIdx = ranges->segmentModuleIndices[idx] + jdx; + unsigned int InnerMiniDoubletIndex = segments->mdIndices[2 * sgIdx]; + unsigned int OuterMiniDoubletIndex = segments->mdIndices[2 * sgIdx + 1]; + unsigned int InnerMiniDoubletLowerHitIndex = miniDoublets->anchorHitIndices[InnerMiniDoubletIndex]; + unsigned int InnerMiniDoubletUpperHitIndex = miniDoublets->outerHitIndices[InnerMiniDoubletIndex]; + unsigned int OuterMiniDoubletLowerHitIndex = miniDoublets->anchorHitIndices[OuterMiniDoubletIndex]; + unsigned int OuterMiniDoubletUpperHitIndex = miniDoublets->outerHitIndices[OuterMiniDoubletIndex]; + unsigned int hit0 = hitsEvt->idxs[InnerMiniDoubletLowerHitIndex]; + unsigned int hit1 = hitsEvt->idxs[InnerMiniDoubletUpperHitIndex]; + unsigned int hit2 = hitsEvt->idxs[OuterMiniDoubletLowerHitIndex]; + unsigned int hit3 = hitsEvt->idxs[OuterMiniDoubletUpperHitIndex]; std::cout << "VALIDATION 'LS': " << "LS" << " hit0: " << hit0 << " hit1: " << hit1 << " hit2: " << hit2 << " hit3: " << hit3 << std::endl; @@ -1043,27 +1041,27 @@ void printLSs(SDL::Event* event) { //________________________________________________________________________________________________________________________________ void printpLSs(SDL::Event* event) { - SDL::segmentsBuffer& segmentsInGPU = (*event->getSegments()); - SDL::miniDoubletsBuffer& miniDoubletsInGPU = (*event->getMiniDoublets()); - SDL::hitsBuffer& hitsInGPU = (*event->getHits()); - SDL::modulesBuffer& modulesInGPU = (*event->getModules()); - SDL::objectRangesBuffer& rangesInGPU = (*event->getRanges()); - - unsigned int i = *(modulesInGPU.nLowerModules); - unsigned int idx = i; //modulesInGPU.lowerModuleIndices[i]; - int npLS = segmentsInGPU.nSegments[idx]; - for (unsigned int jdx = 0; jdx < segmentsInGPU.nSegments[idx]; jdx++) { - unsigned int sgIdx = rangesInGPU.segmentModuleIndices[idx] + jdx; - unsigned int InnerMiniDoubletIndex = segmentsInGPU.mdIndices[2 * sgIdx]; - unsigned int OuterMiniDoubletIndex = segmentsInGPU.mdIndices[2 * sgIdx + 1]; - unsigned int InnerMiniDoubletLowerHitIndex = miniDoubletsInGPU.anchorHitIndices[InnerMiniDoubletIndex]; - unsigned int InnerMiniDoubletUpperHitIndex = miniDoubletsInGPU.outerHitIndices[InnerMiniDoubletIndex]; - unsigned int OuterMiniDoubletLowerHitIndex = miniDoubletsInGPU.anchorHitIndices[OuterMiniDoubletIndex]; - unsigned int OuterMiniDoubletUpperHitIndex = miniDoubletsInGPU.outerHitIndices[OuterMiniDoubletIndex]; - unsigned int hit0 = hitsInGPU.idxs[InnerMiniDoubletLowerHitIndex]; - unsigned int hit1 = hitsInGPU.idxs[InnerMiniDoubletUpperHitIndex]; - unsigned int hit2 = hitsInGPU.idxs[OuterMiniDoubletLowerHitIndex]; - unsigned int hit3 = hitsInGPU.idxs[OuterMiniDoubletUpperHitIndex]; + SDL::Segments const* segments = event->getSegments()->data(); + SDL::MiniDoublets const* miniDoublets = event->getMiniDoublets()->data(); + SDL::Hits const* hitsEvt = event->getHits()->data(); + SDL::Modules const* modules = event->getModules()->data(); + SDL::ObjectRanges const* ranges = event->getRanges()->data(); + + unsigned int i = *(modules->nLowerModules); + unsigned int idx = i; //modules->lowerModuleIndices[i]; + int npLS = segments->nSegments[idx]; + for (unsigned int jdx = 0; jdx < segments->nSegments[idx]; jdx++) { + unsigned int sgIdx = ranges->segmentModuleIndices[idx] + jdx; + unsigned int InnerMiniDoubletIndex = segments->mdIndices[2 * sgIdx]; + unsigned int OuterMiniDoubletIndex = segments->mdIndices[2 * sgIdx + 1]; + unsigned int InnerMiniDoubletLowerHitIndex = miniDoublets->anchorHitIndices[InnerMiniDoubletIndex]; + unsigned int InnerMiniDoubletUpperHitIndex = miniDoublets->outerHitIndices[InnerMiniDoubletIndex]; + unsigned int OuterMiniDoubletLowerHitIndex = miniDoublets->anchorHitIndices[OuterMiniDoubletIndex]; + unsigned int OuterMiniDoubletUpperHitIndex = miniDoublets->outerHitIndices[OuterMiniDoubletIndex]; + unsigned int hit0 = hitsEvt->idxs[InnerMiniDoubletLowerHitIndex]; + unsigned int hit1 = hitsEvt->idxs[InnerMiniDoubletUpperHitIndex]; + unsigned int hit2 = hitsEvt->idxs[OuterMiniDoubletLowerHitIndex]; + unsigned int hit3 = hitsEvt->idxs[OuterMiniDoubletUpperHitIndex]; std::cout << "VALIDATION 'pLS': " << "pLS" << " hit0: " << hit0 << " hit1: " << hit1 << " hit2: " << hit2 << " hit3: " << hit3 << std::endl; @@ -1073,37 +1071,37 @@ void printpLSs(SDL::Event* event) { //________________________________________________________________________________________________________________________________ void printT3s(SDL::Event* event) { - SDL::tripletsBuffer& tripletsInGPU = (*event->getTriplets()); - SDL::segmentsBuffer& segmentsInGPU = (*event->getSegments()); - SDL::miniDoubletsBuffer& miniDoubletsInGPU = (*event->getMiniDoublets()); - SDL::hitsBuffer& hitsInGPU = (*event->getHits()); - SDL::modulesBuffer& modulesInGPU = (*event->getModules()); + SDL::Triplets const* triplets = event->getTriplets()->data(); + SDL::Segments const* segments = event->getSegments()->data(); + SDL::MiniDoublets const* miniDoublets = event->getMiniDoublets()->data(); + SDL::Hits const* hitsEvt = event->getHits()->data(); + SDL::Modules const* modules = event->getModules()->data(); int nTriplets = 0; - for (unsigned int i = 0; i < *(modulesInGPU.nLowerModules); ++i) { - // unsigned int idx = SDL::modulesInGPU->lowerModuleIndices[i]; - nTriplets += tripletsInGPU.nTriplets[i]; + for (unsigned int i = 0; i < *(modules->nLowerModules); ++i) { + // unsigned int idx = modules->lowerModuleIndices[i]; + nTriplets += triplets->nTriplets[i]; unsigned int idx = i; - for (unsigned int jdx = 0; jdx < tripletsInGPU.nTriplets[idx]; jdx++) { + for (unsigned int jdx = 0; jdx < triplets->nTriplets[idx]; jdx++) { unsigned int tpIdx = idx * 5000 + jdx; - unsigned int InnerSegmentIndex = tripletsInGPU.segmentIndices[2 * tpIdx]; - unsigned int OuterSegmentIndex = tripletsInGPU.segmentIndices[2 * tpIdx + 1]; - unsigned int InnerSegmentInnerMiniDoubletIndex = segmentsInGPU.mdIndices[2 * InnerSegmentIndex]; - unsigned int InnerSegmentOuterMiniDoubletIndex = segmentsInGPU.mdIndices[2 * InnerSegmentIndex + 1]; - unsigned int OuterSegmentOuterMiniDoubletIndex = segmentsInGPU.mdIndices[2 * OuterSegmentIndex + 1]; - - unsigned int hit_idx0 = miniDoubletsInGPU.anchorHitIndices[InnerSegmentInnerMiniDoubletIndex]; - unsigned int hit_idx1 = miniDoubletsInGPU.outerHitIndices[InnerSegmentInnerMiniDoubletIndex]; - unsigned int hit_idx2 = miniDoubletsInGPU.anchorHitIndices[InnerSegmentOuterMiniDoubletIndex]; - unsigned int hit_idx3 = miniDoubletsInGPU.outerHitIndices[InnerSegmentOuterMiniDoubletIndex]; - unsigned int hit_idx4 = miniDoubletsInGPU.anchorHitIndices[OuterSegmentOuterMiniDoubletIndex]; - unsigned int hit_idx5 = miniDoubletsInGPU.outerHitIndices[OuterSegmentOuterMiniDoubletIndex]; - - unsigned int hit0 = hitsInGPU.idxs[hit_idx0]; - unsigned int hit1 = hitsInGPU.idxs[hit_idx1]; - unsigned int hit2 = hitsInGPU.idxs[hit_idx2]; - unsigned int hit3 = hitsInGPU.idxs[hit_idx3]; - unsigned int hit4 = hitsInGPU.idxs[hit_idx4]; - unsigned int hit5 = hitsInGPU.idxs[hit_idx5]; + unsigned int InnerSegmentIndex = triplets->segmentIndices[2 * tpIdx]; + unsigned int OuterSegmentIndex = triplets->segmentIndices[2 * tpIdx + 1]; + unsigned int InnerSegmentInnerMiniDoubletIndex = segments->mdIndices[2 * InnerSegmentIndex]; + unsigned int InnerSegmentOuterMiniDoubletIndex = segments->mdIndices[2 * InnerSegmentIndex + 1]; + unsigned int OuterSegmentOuterMiniDoubletIndex = segments->mdIndices[2 * OuterSegmentIndex + 1]; + + unsigned int hit_idx0 = miniDoublets->anchorHitIndices[InnerSegmentInnerMiniDoubletIndex]; + unsigned int hit_idx1 = miniDoublets->outerHitIndices[InnerSegmentInnerMiniDoubletIndex]; + unsigned int hit_idx2 = miniDoublets->anchorHitIndices[InnerSegmentOuterMiniDoubletIndex]; + unsigned int hit_idx3 = miniDoublets->outerHitIndices[InnerSegmentOuterMiniDoubletIndex]; + unsigned int hit_idx4 = miniDoublets->anchorHitIndices[OuterSegmentOuterMiniDoubletIndex]; + unsigned int hit_idx5 = miniDoublets->outerHitIndices[OuterSegmentOuterMiniDoubletIndex]; + + unsigned int hit0 = hitsEvt->idxs[hit_idx0]; + unsigned int hit1 = hitsEvt->idxs[hit_idx1]; + unsigned int hit2 = hitsEvt->idxs[hit_idx2]; + unsigned int hit3 = hitsEvt->idxs[hit_idx3]; + unsigned int hit4 = hitsEvt->idxs[hit_idx4]; + unsigned int hit5 = hitsEvt->idxs[hit_idx5]; std::cout << "VALIDATION 'T3': " << "T3" << " hit0: " << hit0 << " hit1: " << hit1 << " hit2: " << hit2 << " hit3: " << hit3 << " hit4: " << hit4 @@ -1115,29 +1113,26 @@ void printT3s(SDL::Event* event) { //________________________________________________________________________________________________________________________________ void debugPrintOutlierMultiplicities(SDL::Event* event) { - SDL::trackCandidatesBuffer& trackCandidatesInGPU = (*event->getTrackCandidates()); - SDL::tripletsBuffer& tripletsInGPU = (*event->getTriplets()); - SDL::segmentsBuffer& segmentsInGPU = (*event->getSegments()); - SDL::miniDoubletsBuffer& miniDoubletsInGPU = (*event->getMiniDoublets()); - SDL::modulesBuffer& modulesInGPU = (*event->getModules()); - SDL::objectRangesBuffer& rangesInGPU = (*event->getRanges()); + SDL::TrackCandidates const* trackCandidates = event->getTrackCandidates()->data(); + SDL::Triplets const* triplets = event->getTriplets()->data(); + SDL::Segments const* segments = event->getSegments()->data(); + SDL::MiniDoublets const* miniDoublets = event->getMiniDoublets()->data(); + SDL::Modules const* modules = event->getModules()->data(); + SDL::ObjectRanges const* ranges = event->getRanges()->data(); //int nTrackCandidates = 0; - for (unsigned int idx = 0; idx <= *(modulesInGPU.nLowerModules); ++idx) { - if (trackCandidatesInGPU.nTrackCandidates[idx] > 50000) { - std::cout << " SDL::modulesInGPU->detIds[SDL::modulesInGPU->lowerModuleIndices[idx]]: " - << modulesInGPU.detIds[idx] << std::endl; + for (unsigned int idx = 0; idx <= *(modules->nLowerModules); ++idx) { + if (trackCandidates->nTrackCandidates[idx] > 50000) { + std::cout << " modules->detIds[modules->lowerModuleIndices[idx]]: " << modules->detIds[idx] << std::endl; std::cout << " idx: " << idx - << " trackCandidatesInGPU.nTrackCandidates[idx]: " << trackCandidatesInGPU.nTrackCandidates[idx] - << std::endl; - std::cout << " idx: " << idx << " tripletsInGPU.nTriplets[idx]: " << tripletsInGPU.nTriplets[idx] << std::endl; - unsigned int i = idx; //modulesInGPU.lowerModuleIndices[idx]; - std::cout << " idx: " << idx << " i: " << i << " segmentsInGPU.nSegments[i]: " << segmentsInGPU.nSegments[i] - << std::endl; - int nMD = miniDoubletsInGPU.nMDs[2 * idx] + miniDoubletsInGPU.nMDs[2 * idx + 1]; + << " trackCandidates->nTrackCandidates[idx]: " << trackCandidates->nTrackCandidates[idx] << std::endl; + std::cout << " idx: " << idx << " triplets->nTriplets[idx]: " << triplets->nTriplets[idx] << std::endl; + unsigned int i = idx; //modules->lowerModuleIndices[idx]; + std::cout << " idx: " << idx << " i: " << i << " segments->nSegments[i]: " << segments->nSegments[i] << std::endl; + int nMD = miniDoublets->nMDs[2 * idx] + miniDoublets->nMDs[2 * idx + 1]; std::cout << " idx: " << idx << " nMD: " << nMD << std::endl; int nHits = 0; - nHits += rangesInGPU.hitRanges[4 * idx + 1] - rangesInGPU.hitRanges[4 * idx] + 1; - nHits += rangesInGPU.hitRanges[4 * idx + 3] - rangesInGPU.hitRanges[4 * idx + 2] + 1; + nHits += ranges->hitRanges[4 * idx + 1] - ranges->hitRanges[4 * idx] + 1; + nHits += ranges->hitRanges[4 * idx + 3] - ranges->hitRanges[4 * idx + 2] + 1; std::cout << " idx: " << idx << " nHits: " << nHits << std::endl; } }