diff --git a/RecoTracker/LSTCore/interface/LSTESData.h b/RecoTracker/LSTCore/interface/LSTESData.h index 833770e631d2d..321c2f371cc32 100644 --- a/RecoTracker/LSTCore/interface/LSTESData.h +++ b/RecoTracker/LSTCore/interface/LSTESData.h @@ -19,16 +19,16 @@ namespace lst { uint16_t nLowerModules; unsigned int nPixels; unsigned int nEndCapMap; - std::shared_ptr> modulesBuffers; - std::shared_ptr> endcapGeometryBuffers; + ModulesBuffer modulesBuffers; + EndcapGeometryBuffer endcapGeometryBuffers; std::shared_ptr pixelMapping; LSTESData(uint16_t const& nModulesIn, uint16_t const& nLowerModulesIn, unsigned int const& nPixelsIn, unsigned int const& nEndCapMapIn, - std::shared_ptr> const& modulesBuffersIn, - std::shared_ptr> const& endcapGeometryBuffersIn, + ModulesBuffer const& modulesBuffersIn, + EndcapGeometryBuffer const& endcapGeometryBuffersIn, std::shared_ptr const& pixelMappingIn) : nModules(nModulesIn), nLowerModules(nLowerModulesIn), @@ -49,19 +49,17 @@ namespace cms::alpakatools { template static lst::LSTESData> copyAsync(TQueue& queue, lst::LSTESData const& srcData) { - auto deviceModulesBuffers = std::make_shared>>( - alpaka::getDev(queue), srcData.nModules, srcData.nPixels); - deviceModulesBuffers->copyFromSrc(queue, *srcData.modulesBuffers); - auto deviceEndcapGeometryBuffers = - std::make_shared>>(alpaka::getDev(queue), srcData.nEndCapMap); - deviceEndcapGeometryBuffers->copyFromSrc(queue, *srcData.endcapGeometryBuffers); + auto deviceModulesBuffers = lst::ModulesBuffer>(alpaka::getDev(queue), srcData.nModules, srcData.nPixels); + deviceModulesBuffers.copyFromSrc(queue, srcData.modulesBuffers); + auto deviceEndcapGeometryBuffers = lst::EndcapGeometryBuffer>(alpaka::getDev(queue), srcData.nEndCapMap); + deviceEndcapGeometryBuffers.copyFromSrc(queue, srcData.endcapGeometryBuffers); return lst::LSTESData>(srcData.nModules, srcData.nLowerModules, srcData.nPixels, srcData.nEndCapMap, - deviceModulesBuffers, - deviceEndcapGeometryBuffers, + std::move(deviceModulesBuffers), + std::move(deviceEndcapGeometryBuffers), srcData.pixelMapping); } }; diff --git a/RecoTracker/LSTCore/src/LSTESData.cc b/RecoTracker/LSTCore/src/LSTESData.cc index 482d97d34249c..01210d89a82f3 100644 --- a/RecoTracker/LSTCore/src/LSTESData.cc +++ b/RecoTracker/LSTCore/src/LSTESData.cc @@ -39,9 +39,9 @@ namespace { } void loadMapsHost(lst::MapPLStoLayer& pLStoLayer, - std::shared_ptr endcapGeometry, - std::shared_ptr tiltedGeometry, - std::shared_ptr moduleConnectionMap) { + lst::EndcapGeometry& endcapGeometry, + lst::TiltedGeometry& tiltedGeometry, + lst::ModuleConnectionMap& moduleConnectionMap) { // Module orientation information (DrDz or phi angles) auto endcap_geom = get_absolute_path_after_check_file_exists(trackLooperDir() + "/data/OT800_IT615_pt0.8/endcap_orientation.bin"); @@ -51,9 +51,9 @@ namespace { auto mappath = get_absolute_path_after_check_file_exists( trackLooperDir() + "/data/OT800_IT615_pt0.8/module_connection_tracing_merged.bin"); - endcapGeometry->load(endcap_geom); - tiltedGeometry->load(tilted_geom); - moduleConnectionMap->load(mappath); + endcapGeometry.load(endcap_geom); + tiltedGeometry.load(tilted_geom); + moduleConnectionMap.load(mappath); auto pLSMapDir = trackLooperDir() + "/data/OT800_IT615_pt0.8/pixelmap/pLS_map"; const std::array connects{ @@ -80,34 +80,28 @@ std::unique_ptr> lst::loadAndFillESHost() uint16_t nModules; uint16_t nLowerModules; unsigned int nPixels; - std::shared_ptr> modulesBuffers = nullptr; - auto pLStoLayer = std::make_shared(); - auto endcapGeometry = std::make_shared(); - auto tiltedGeometry = std::make_shared(); + MapPLStoLayer pLStoLayer; + EndcapGeometry endcapGeometry; + TiltedGeometry tiltedGeometry; auto pixelMapping = std::make_shared(); - auto moduleConnectionMap = std::make_shared(); - ::loadMapsHost(*pLStoLayer, endcapGeometry, tiltedGeometry, moduleConnectionMap); + ModuleConnectionMap moduleConnectionMap; + ::loadMapsHost(pLStoLayer, endcapGeometry, tiltedGeometry, moduleConnectionMap); - auto endcapGeometryBuffers = std::make_shared>( - cms::alpakatools::host(), endcapGeometry->nEndCapMap); - alpaka::QueueCpuBlocking queue(cms::alpakatools::host()); - alpaka::memcpy( - queue, endcapGeometryBuffers->geoMapDetId_buf, endcapGeometry->geoMapDetId_buf, endcapGeometry->nEndCapMap); - alpaka::memcpy( - queue, endcapGeometryBuffers->geoMapPhi_buf, endcapGeometry->geoMapPhi_buf, endcapGeometry->nEndCapMap); + auto endcapGeometryBuffers = EndcapGeometryBuffer(cms::alpakatools::host(), endcapGeometry.nEndCapMap); + std::memcpy(alpaka::getPtrNative(endcapGeometryBuffers.geoMapDetId_buf), endcapGeometry.geoMapDetId_buf.data(), endcapGeometry.nEndCapMap); + std::memcpy(alpaka::getPtrNative(endcapGeometryBuffers.geoMapPhi_buf), endcapGeometry.geoMapPhi_buf.data(), endcapGeometry.nEndCapMap); auto path = get_absolute_path_after_check_file_exists(trackLooperDir() + "/data/OT800_IT615_pt0.8/sensor_centroids.bin"); - lst::loadModulesFromFile(pLStoLayer.get(), + auto modulesBuffers = lst::loadModulesFromFile(pLStoLayer, path.c_str(), nModules, nLowerModules, nPixels, - modulesBuffers, pixelMapping.get(), - endcapGeometry.get(), - tiltedGeometry.get(), - moduleConnectionMap.get()); + endcapGeometry, + tiltedGeometry, + moduleConnectionMap); return std::make_unique>( - nModules, nLowerModules, nPixels, endcapGeometry->nEndCapMap, modulesBuffers, endcapGeometryBuffers, pixelMapping); + nModules, nLowerModules, nPixels, endcapGeometry.nEndCapMap, std::move(modulesBuffers), std::move(endcapGeometryBuffers), pixelMapping); } diff --git a/RecoTracker/LSTCore/src/ModuleMethods.h b/RecoTracker/LSTCore/src/ModuleMethods.h index 9693a464fcf1a..f4b74917bec13 100644 --- a/RecoTracker/LSTCore/src/ModuleMethods.h +++ b/RecoTracker/LSTCore/src/ModuleMethods.h @@ -23,15 +23,13 @@ namespace lst { // https://github.com/cms-sw/cmssw/blob/5e809e8e0a625578aa265dc4b128a93830cb5429/Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h#L29 }; - template - inline void fillPixelMap(std::shared_ptr>& modulesBuf, + inline void fillPixelMap(ModulesBuffer& modulesBuf, uint16_t nModules, unsigned int& nPixels, PixelMap& pixelMapping, - TQueue queue, - const MapPLStoLayer& pLStoLayer, - ModuleMetaData& mmd) { - pixelMapping.pixelModuleIndex = mmd.detIdToIndex[1]; + MapPLStoLayer const& pLStoLayer, + ModuleMetaData const& mmd) { + pixelMapping.pixelModuleIndex = mmd.detIdToIndex.at(1); std::vector connectedModuleDetIds; std::vector connectedModuleDetIds_pos; @@ -81,68 +79,44 @@ namespace lst { unsigned int connectedPix_size = totalSizes + totalSizes_pos + totalSizes_neg; nPixels = connectedPix_size; - // Now we can initialize modulesBuf - alpaka_common::DevHost const& devHost = cms::alpakatools::host(); - if (modulesBuf == nullptr) { - modulesBuf = std::make_shared>(devHost, nModules, nPixels); - } + // Now we re-initialize connectedPixels_buf since nPixels is now known + modulesBuf.connectedPixels_buf = allocBufWrapper(cms::alpakatools::host(), nPixels); + modulesBuf.data_.setData(modulesBuf); - auto connectedPixels_buf = allocBufWrapper(devHost, connectedPix_size); - unsigned int* connectedPixels = alpaka::getPtrNative(connectedPixels_buf); + unsigned int* connectedPixels = alpaka::getPtrNative(modulesBuf.connectedPixels_buf); for (unsigned int icondet = 0; icondet < totalSizes; icondet++) { - connectedPixels[icondet] = mmd.detIdToIndex[connectedModuleDetIds[icondet]]; + connectedPixels[icondet] = mmd.detIdToIndex.at(connectedModuleDetIds[icondet]); } for (unsigned int icondet = 0; icondet < totalSizes_pos; icondet++) { - connectedPixels[icondet + totalSizes] = mmd.detIdToIndex[connectedModuleDetIds_pos[icondet]]; + connectedPixels[icondet + totalSizes] = mmd.detIdToIndex.at(connectedModuleDetIds_pos[icondet]); } for (unsigned int icondet = 0; icondet < totalSizes_neg; icondet++) { - connectedPixels[icondet + totalSizes + totalSizes_pos] = mmd.detIdToIndex[connectedModuleDetIds_neg[icondet]]; + connectedPixels[icondet + totalSizes + totalSizes_pos] = mmd.detIdToIndex.at(connectedModuleDetIds_neg[icondet]); } - - alpaka::memcpy(queue, modulesBuf->connectedPixels_buf, connectedPixels_buf); - alpaka::wait(queue); }; - template - inline void fillConnectedModuleArrayExplicit(ModulesBuffer* modulesBuf, - unsigned int nMod, - TQueue queue, - ModuleMetaData& mmd, - const ModuleConnectionMap* moduleConnectionMap) { - alpaka_common::DevHost const& devHost = cms::alpakatools::host(); - auto moduleMap_buf = allocBufWrapper(devHost, nMod * max_connected_modules); - uint16_t* moduleMap = alpaka::getPtrNative(moduleMap_buf); - - auto nConnectedModules_buf = allocBufWrapper(devHost, nMod); - uint16_t* nConnectedModules = alpaka::getPtrNative(nConnectedModules_buf); + inline void fillConnectedModuleArrayExplicit(ModulesBuffer& modulesBuf, + ModuleMetaData const& mmd, + ModuleConnectionMap const& moduleConnectionMap) { + uint16_t* moduleMap = alpaka::getPtrNative(modulesBuf.moduleMap_buf); + uint16_t* nConnectedModules = alpaka::getPtrNative(modulesBuf.nConnectedModules_buf); for (auto it = mmd.detIdToIndex.begin(); it != mmd.detIdToIndex.end(); ++it) { unsigned int detId = it->first; uint16_t index = it->second; - auto& connectedModules = moduleConnectionMap->getConnectedModuleDetIds(detId); + auto& connectedModules = moduleConnectionMap.getConnectedModuleDetIds(detId); nConnectedModules[index] = connectedModules.size(); for (uint16_t i = 0; i < nConnectedModules[index]; i++) { - moduleMap[index * max_connected_modules + i] = mmd.detIdToIndex[connectedModules[i]]; + moduleMap[index * max_connected_modules + i] = mmd.detIdToIndex.at(connectedModules[i]); } } - - alpaka::memcpy(queue, modulesBuf->moduleMap_buf, moduleMap_buf); - alpaka::memcpy(queue, modulesBuf->nConnectedModules_buf, nConnectedModules_buf); - alpaka::wait(queue); }; - template - inline void fillMapArraysExplicit(ModulesBuffer* modulesBuf, - unsigned int nMod, - TQueue queue, - ModuleMetaData& mmd) { - alpaka_common::DevHost const& devHost = cms::alpakatools::host(); - auto mapIdx_buf = allocBufWrapper(devHost, nMod); - uint16_t* mapIdx = alpaka::getPtrNative(mapIdx_buf); - - auto mapdetId_buf = allocBufWrapper(devHost, nMod); - unsigned int* mapdetId = alpaka::getPtrNative(mapdetId_buf); + inline void fillMapArraysExplicit(ModulesBuffer& modulesBuf, + ModuleMetaData const& mmd) { + uint16_t* mapIdx = alpaka::getPtrNative(modulesBuf.mapIdx_buf); + unsigned int* mapdetId = alpaka::getPtrNative(modulesBuf.mapdetId_buf); unsigned int counter = 0; for (auto it = mmd.detIdToIndex.begin(); it != mmd.detIdToIndex.end(); ++it) { @@ -152,10 +126,6 @@ namespace lst { mapdetId[counter] = detId; counter++; } - - alpaka::memcpy(queue, modulesBuf->mapIdx_buf, mapIdx_buf); - alpaka::memcpy(queue, modulesBuf->mapdetId_buf, mapdetId_buf); - alpaka::wait(queue); }; inline void setDerivedQuantities(unsigned int detId, @@ -218,59 +188,44 @@ namespace lst { nModules = counter; }; - inline void loadModulesFromFile(const MapPLStoLayer* pLStoLayer, + inline ModulesBuffer loadModulesFromFile(MapPLStoLayer const& pLStoLayer, const char* moduleMetaDataFilePath, uint16_t& nModules, uint16_t& nLowerModules, unsigned int& nPixels, - std::shared_ptr>& modulesBuf, PixelMap* pixelMapping, - const EndcapGeometry* endcapGeometry, - const TiltedGeometry* tiltedGeometry, - const ModuleConnectionMap* moduleConnectionMap) { + const EndcapGeometry& endcapGeometry, + const TiltedGeometry& tiltedGeometry, + const ModuleConnectionMap& moduleConnectionMap) { ModuleMetaData mmd; loadCentroidsFromFile(moduleMetaDataFilePath, mmd, nModules); - alpaka_common::DevHost const& devHost = cms::alpakatools::host(); - auto detIds_buf = allocBufWrapper(devHost, nModules); - auto layers_buf = allocBufWrapper(devHost, nModules); - auto rings_buf = allocBufWrapper(devHost, nModules); - auto rods_buf = allocBufWrapper(devHost, nModules); - auto modules_buf = allocBufWrapper(devHost, nModules); - auto subdets_buf = allocBufWrapper(devHost, nModules); - auto sides_buf = allocBufWrapper(devHost, nModules); - auto eta_buf = allocBufWrapper(devHost, nModules); - auto r_buf = allocBufWrapper(devHost, nModules); - auto isInverted_buf = allocBufWrapper(devHost, nModules); - auto isLower_buf = allocBufWrapper(devHost, nModules); - auto isAnchor_buf = allocBufWrapper(devHost, nModules); - auto moduleType_buf = allocBufWrapper(devHost, nModules); - auto moduleLayerType_buf = allocBufWrapper(devHost, nModules); - auto dxdys_buf = allocBufWrapper(devHost, nModules); - auto drdzs_buf = allocBufWrapper(devHost, nModules); - auto partnerModuleIndices_buf = allocBufWrapper(devHost, nModules); - auto lstLayers_buf = allocBufWrapper(devHost, nModules); + // Initialize modulesBuf, but with nPixels = 0 + // The fields that require nPixels are re-initialized in fillPixelMap + ModulesBuffer modulesBuf(cms::alpakatools::host(), nModules, 0); // Getting the underlying data pointers - unsigned int* host_detIds = alpaka::getPtrNative(detIds_buf); - short* host_layers = alpaka::getPtrNative(layers_buf); - short* host_rings = alpaka::getPtrNative(rings_buf); - short* host_rods = alpaka::getPtrNative(rods_buf); - short* host_modules = alpaka::getPtrNative(modules_buf); - short* host_subdets = alpaka::getPtrNative(subdets_buf); - short* host_sides = alpaka::getPtrNative(sides_buf); - float* host_eta = alpaka::getPtrNative(eta_buf); - float* host_r = alpaka::getPtrNative(r_buf); - bool* host_isInverted = alpaka::getPtrNative(isInverted_buf); - bool* host_isLower = alpaka::getPtrNative(isLower_buf); - bool* host_isAnchor = alpaka::getPtrNative(isAnchor_buf); - ModuleType* host_moduleType = alpaka::getPtrNative(moduleType_buf); - ModuleLayerType* host_moduleLayerType = alpaka::getPtrNative(moduleLayerType_buf); - float* host_dxdys = alpaka::getPtrNative(dxdys_buf); - float* host_drdzs = alpaka::getPtrNative(drdzs_buf); - uint16_t* host_partnerModuleIndices = alpaka::getPtrNative(partnerModuleIndices_buf); - int* host_lstLayers = alpaka::getPtrNative(lstLayers_buf); + unsigned int* host_detIds = alpaka::getPtrNative(modulesBuf.detIds_buf); + short* host_layers = alpaka::getPtrNative(modulesBuf.layers_buf); + short* host_rings = alpaka::getPtrNative(modulesBuf.rings_buf); + short* host_rods = alpaka::getPtrNative(modulesBuf.rods_buf); + short* host_modules = alpaka::getPtrNative(modulesBuf.modules_buf); + short* host_subdets = alpaka::getPtrNative(modulesBuf.subdets_buf); + short* host_sides = alpaka::getPtrNative(modulesBuf.sides_buf); + float* host_eta = alpaka::getPtrNative(modulesBuf.eta_buf); + float* host_r = alpaka::getPtrNative(modulesBuf.r_buf); + bool* host_isInverted = alpaka::getPtrNative(modulesBuf.isInverted_buf); + bool* host_isLower = alpaka::getPtrNative(modulesBuf.isLower_buf); + bool* host_isAnchor = alpaka::getPtrNative(modulesBuf.isAnchor_buf); + ModuleType* host_moduleType = alpaka::getPtrNative(modulesBuf.moduleType_buf); + ModuleLayerType* host_moduleLayerType = alpaka::getPtrNative(modulesBuf.moduleLayerType_buf); + float* host_dxdys = alpaka::getPtrNative(modulesBuf.dxdys_buf); + float* host_drdzs = alpaka::getPtrNative(modulesBuf.drdzs_buf); + uint16_t* host_nModules = alpaka::getPtrNative(modulesBuf.nModules_buf); + uint16_t* host_nLowerModules = alpaka::getPtrNative(modulesBuf.nLowerModules_buf); + uint16_t* host_partnerModuleIndices = alpaka::getPtrNative(modulesBuf.partnerModuleIndices_buf); + int* host_lstLayers = alpaka::getPtrNative(modulesBuf.lstLayers_buf); //reassign detIdToIndex indices here nLowerModules = (nModules - 1) / 2; @@ -347,8 +302,8 @@ namespace lst { host_isAnchor[index] = false; } - host_dxdys[index] = (subdet == Endcap) ? endcapGeometry->getdxdy_slope(detId) : tiltedGeometry->getDxDy(detId); - host_drdzs[index] = (subdet == Barrel) ? tiltedGeometry->getDrDz(detId) : 0; + host_dxdys[index] = (subdet == Endcap) ? endcapGeometry.getdxdy_slope(detId) : tiltedGeometry.getDxDy(detId); + host_drdzs[index] = (subdet == Barrel) ? tiltedGeometry.getDrDz(detId) : 0; } host_lstLayers[index] = @@ -372,41 +327,15 @@ namespace lst { } } - // TODO: We don't need a queue, but this code needs to be refactored - alpaka::QueueCpuBlocking queue(cms::alpakatools::host()); - - // modulesBuf is initialized in fillPixelMap since both nModules and nPix will be known - fillPixelMap(modulesBuf, nModules, nPixels, *pixelMapping, queue, *pLStoLayer, mmd); - - auto src_view_nModules = alpaka::createView(devHost, &nModules, (alpaka_common::Idx)1u); - alpaka::memcpy(queue, modulesBuf->nModules_buf, src_view_nModules); - - auto src_view_nLowerModules = alpaka::createView(devHost, &nLowerModules, (alpaka_common::Idx)1u); - alpaka::memcpy(queue, modulesBuf->nLowerModules_buf, src_view_nLowerModules); - - alpaka::memcpy(queue, modulesBuf->moduleType_buf, moduleType_buf); - alpaka::memcpy(queue, modulesBuf->moduleLayerType_buf, moduleLayerType_buf); - - alpaka::memcpy(queue, modulesBuf->detIds_buf, detIds_buf); - alpaka::memcpy(queue, modulesBuf->layers_buf, layers_buf); - alpaka::memcpy(queue, modulesBuf->rings_buf, rings_buf); - alpaka::memcpy(queue, modulesBuf->rods_buf, rods_buf); - alpaka::memcpy(queue, modulesBuf->modules_buf, modules_buf); - alpaka::memcpy(queue, modulesBuf->subdets_buf, subdets_buf); - alpaka::memcpy(queue, modulesBuf->sides_buf, sides_buf); - alpaka::memcpy(queue, modulesBuf->eta_buf, eta_buf); - alpaka::memcpy(queue, modulesBuf->r_buf, r_buf); - alpaka::memcpy(queue, modulesBuf->isInverted_buf, isInverted_buf); - alpaka::memcpy(queue, modulesBuf->isLower_buf, isLower_buf); - alpaka::memcpy(queue, modulesBuf->isAnchor_buf, isAnchor_buf); - alpaka::memcpy(queue, modulesBuf->dxdys_buf, dxdys_buf); - alpaka::memcpy(queue, modulesBuf->drdzs_buf, drdzs_buf); - alpaka::memcpy(queue, modulesBuf->partnerModuleIndices_buf, partnerModuleIndices_buf); - alpaka::memcpy(queue, modulesBuf->lstLayers_buf, lstLayers_buf); - alpaka::wait(queue); - - fillConnectedModuleArrayExplicit(modulesBuf.get(), nModules, queue, mmd, moduleConnectionMap); - fillMapArraysExplicit(modulesBuf.get(), nModules, queue, mmd); + fillPixelMap(modulesBuf, nModules, nPixels, *pixelMapping, pLStoLayer, mmd); + + *host_nModules = nModules; + *host_nLowerModules = nLowerModules; + + fillConnectedModuleArrayExplicit(modulesBuf, mmd, moduleConnectionMap); + fillMapArraysExplicit(modulesBuf, mmd); + + return modulesBuf; }; } // namespace lst #endif diff --git a/RecoTracker/LSTCore/src/alpaka/Event.dev.cc b/RecoTracker/LSTCore/src/alpaka/Event.dev.cc index 43f5bb7d9c3fe..6d4a2073d7e7e 100644 --- a/RecoTracker/LSTCore/src/alpaka/Event.dev.cc +++ b/RecoTracker/LSTCore/src/alpaka/Event.dev.cc @@ -195,9 +195,9 @@ void lst::Event::addHitToEvent(std::vector const& x, TwoS, nModules_, nEndCapMap_, - alpaka::getPtrNative(endcapGeometryBuffers_->geoMapDetId_buf), - alpaka::getPtrNative(endcapGeometryBuffers_->geoMapPhi_buf), - *modulesBuffers_->data(), + alpaka::getPtrNative(endcapGeometryBuffers_.geoMapDetId_buf), + alpaka::getPtrNative(endcapGeometryBuffers_.geoMapPhi_buf), + *modulesBuffers_.data(), *hitsInGPU, nHits)); @@ -209,7 +209,7 @@ void lst::Event::addHitToEvent(std::vector const& x, moduleRangesKernel module_ranges_kernel; auto const module_ranges_task(alpaka::createTaskKernel( - module_ranges_workdiv, module_ranges_kernel, *modulesBuffers_->data(), *hitsInGPU, nLowerModules_)); + module_ranges_workdiv, module_ranges_kernel, *modulesBuffers_.data(), *hitsInGPU, nLowerModules_)); // Waiting isn't needed after second kernel call. Saves ~100 us. // This is because addPixelSegmentToEvent (which is run next) doesn't rely on hitsBuffers->hitrange variables. @@ -268,7 +268,7 @@ void lst::Event::addPixelSegmentToEvent(std::vector const& lst::createMDArrayRangesGPU createMDArrayRangesGPU_kernel; auto const createMDArrayRangesGPUTask(alpaka::createTaskKernel( - createMDArrayRangesGPU_workDiv, createMDArrayRangesGPU_kernel, *modulesBuffers_->data(), *rangesInGPU)); + createMDArrayRangesGPU_workDiv, createMDArrayRangesGPU_kernel, *modulesBuffers_.data(), *rangesInGPU)); alpaka::enqueue(queue, createMDArrayRangesGPUTask); alpaka::wait(queue); @@ -300,7 +300,7 @@ void lst::Event::addPixelSegmentToEvent(std::vector const& lst::createSegmentArrayRanges createSegmentArrayRanges_kernel; auto const createSegmentArrayRangesTask(alpaka::createTaskKernel(createSegmentArrayRanges_workDiv, createSegmentArrayRanges_kernel, - *modulesBuffers_->data(), + *modulesBuffers_.data(), *rangesInGPU, *mdsInGPU)); @@ -376,7 +376,7 @@ void lst::Event::addPixelSegmentToEvent(std::vector const& addPixelSegmentToEventKernel addPixelSegmentToEvent_kernel; auto const addPixelSegmentToEvent_task(alpaka::createTaskKernel(addPixelSegmentToEvent_workdiv, addPixelSegmentToEvent_kernel, - *modulesBuffers_->data(), + *modulesBuffers_.data(), *rangesInGPU, *hitsInGPU, *mdsInGPU, @@ -412,7 +412,7 @@ void lst::Event::createMiniDoublets() { lst::createMDArrayRangesGPU createMDArrayRangesGPU_kernel; auto const createMDArrayRangesGPUTask(alpaka::createTaskKernel( - createMDArrayRangesGPU_workDiv, createMDArrayRangesGPU_kernel, *modulesBuffers_->data(), *rangesInGPU)); + createMDArrayRangesGPU_workDiv, createMDArrayRangesGPU_kernel, *modulesBuffers_.data(), *rangesInGPU)); alpaka::enqueue(queue, createMDArrayRangesGPUTask); alpaka::wait(queue); @@ -440,7 +440,7 @@ void lst::Event::createMiniDoublets() { lst::createMiniDoubletsInGPUv2 createMiniDoubletsInGPUv2_kernel; auto const createMiniDoubletsInGPUv2Task(alpaka::createTaskKernel(createMiniDoubletsInGPUv2_workDiv, createMiniDoubletsInGPUv2_kernel, - *modulesBuffers_->data(), + *modulesBuffers_.data(), *hitsInGPU, *mdsInGPU, *rangesInGPU)); @@ -456,7 +456,7 @@ void lst::Event::createMiniDoublets() { auto const addMiniDoubletRangesToEventExplicitTask( alpaka::createTaskKernel(addMiniDoubletRangesToEventExplicit_workDiv, addMiniDoubletRangesToEventExplicit_kernel, - *modulesBuffers_->data(), + *modulesBuffers_.data(), *mdsInGPU, *rangesInGPU, *hitsInGPU)); @@ -485,7 +485,7 @@ void lst::Event::createSegmentsWithModuleMap() { lst::createSegmentsInGPUv2 createSegmentsInGPUv2_kernel; auto const createSegmentsInGPUv2Task(alpaka::createTaskKernel(createSegmentsInGPUv2_workDiv, createSegmentsInGPUv2_kernel, - *modulesBuffers_->data(), + *modulesBuffers_.data(), *mdsInGPU, *segmentsInGPU, *rangesInGPU)); @@ -501,7 +501,7 @@ void lst::Event::createSegmentsWithModuleMap() { auto const addSegmentRangesToEventExplicitTask( alpaka::createTaskKernel(addSegmentRangesToEventExplicit_workDiv, addSegmentRangesToEventExplicit_kernel, - *modulesBuffers_->data(), + *modulesBuffers_.data(), *segmentsInGPU, *rangesInGPU)); @@ -523,7 +523,7 @@ void lst::Event::createTriplets() { lst::createTripletArrayRanges createTripletArrayRanges_kernel; auto const createTripletArrayRangesTask(alpaka::createTaskKernel(createTripletArrayRanges_workDiv, createTripletArrayRanges_kernel, - *modulesBuffers_->data(), + *modulesBuffers_.data(), *rangesInGPU, *segmentsInGPU)); @@ -564,7 +564,7 @@ void lst::Event::createTriplets() { // Allocate and copy module_nConnectedModules from device to host auto module_nConnectedModules_buf = allocBufWrapper(devHost, nLowerModules_, queue); - alpaka::memcpy(queue, module_nConnectedModules_buf, modulesBuffers_->nConnectedModules_buf, nLowerModules_); + alpaka::memcpy(queue, module_nConnectedModules_buf, modulesBuffers_.nConnectedModules_buf, nLowerModules_); alpaka::wait(queue); uint16_t* module_nConnectedModules = alpaka::getPtrNative(module_nConnectedModules_buf); @@ -591,7 +591,7 @@ void lst::Event::createTriplets() { lst::createTripletsInGPUv2 createTripletsInGPUv2_kernel; auto const createTripletsInGPUv2Task(alpaka::createTaskKernel(createTripletsInGPUv2_workDiv, createTripletsInGPUv2_kernel, - *modulesBuffers_->data(), + *modulesBuffers_.data(), *mdsInGPU, *segmentsInGPU, *tripletsInGPU, @@ -610,7 +610,7 @@ void lst::Event::createTriplets() { auto const addTripletRangesToEventExplicitTask( alpaka::createTaskKernel(addTripletRangesToEventExplicit_workDiv, addTripletRangesToEventExplicit_kernel, - *modulesBuffers_->data(), + *modulesBuffers_.data(), *tripletsInGPU, *rangesInGPU)); @@ -644,7 +644,7 @@ void lst::Event::createTrackCandidates(bool no_pls_dupclean, bool tc_pls_ lst::crossCleanpT3 crossCleanpT3_kernel; auto const crossCleanpT3Task(alpaka::createTaskKernel(crossCleanpT3_workDiv, crossCleanpT3_kernel, - *modulesBuffers_->data(), + *modulesBuffers_.data(), *rangesInGPU, *pixelTripletsInGPU, *segmentsInGPU, @@ -690,7 +690,7 @@ void lst::Event::createTrackCandidates(bool no_pls_dupclean, bool tc_pls_ lst::crossCleanT5 crossCleanT5_kernel; auto const crossCleanT5Task(alpaka::createTaskKernel(crossCleanT5_workDiv, crossCleanT5_kernel, - *modulesBuffers_->data(), + *modulesBuffers_.data(), *quintupletsInGPU, *pixelQuintupletsInGPU, *pixelTripletsInGPU, @@ -721,7 +721,7 @@ void lst::Event::createTrackCandidates(bool no_pls_dupclean, bool tc_pls_ lst::checkHitspLS checkHitspLS_kernel; auto const checkHitspLSTask(alpaka::createTaskKernel( - checkHitspLS_workDiv, checkHitspLS_kernel, *modulesBuffers_->data(), *segmentsInGPU, true)); + checkHitspLS_workDiv, checkHitspLS_kernel, *modulesBuffers_.data(), *segmentsInGPU, true)); alpaka::enqueue(queue, checkHitspLSTask); } @@ -734,7 +734,7 @@ void lst::Event::createTrackCandidates(bool no_pls_dupclean, bool tc_pls_ lst::crossCleanpLS crossCleanpLS_kernel; auto const crossCleanpLSTask(alpaka::createTaskKernel(crossCleanpLS_workDiv, crossCleanpLS_kernel, - *modulesBuffers_->data(), + *modulesBuffers_.data(), *rangesInGPU, *pixelTripletsInGPU, *trackCandidatesInGPU, @@ -868,7 +868,7 @@ void lst::Event::createPixelTriplets() { auto const createPixelTripletsInGPUFromMapv2Task( alpaka::createTaskKernel(createPixelTripletsInGPUFromMapv2_workDiv, createPixelTripletsInGPUFromMapv2_kernel, - *modulesBuffers_->data(), + *modulesBuffers_.data(), *rangesInGPU, *mdsInGPU, *segmentsInGPU, @@ -915,7 +915,7 @@ void lst::Event::createQuintuplets() { auto const createEligibleModulesListForQuintupletsGPUTask( alpaka::createTaskKernel(createEligibleModulesListForQuintupletsGPU_workDiv, createEligibleModulesListForQuintupletsGPU_kernel, - *modulesBuffers_->data(), + *modulesBuffers_.data(), *tripletsInGPU, *rangesInGPU)); @@ -949,7 +949,7 @@ void lst::Event::createQuintuplets() { lst::createQuintupletsInGPUv2 createQuintupletsInGPUv2_kernel; auto const createQuintupletsInGPUv2Task(alpaka::createTaskKernel(createQuintupletsInGPUv2_workDiv, createQuintupletsInGPUv2_kernel, - *modulesBuffers_->data(), + *modulesBuffers_.data(), *mdsInGPU, *segmentsInGPU, *tripletsInGPU, @@ -968,7 +968,7 @@ void lst::Event::createQuintuplets() { auto const removeDupQuintupletsInGPUAfterBuildTask( alpaka::createTaskKernel(removeDupQuintupletsInGPUAfterBuild_workDiv, removeDupQuintupletsInGPUAfterBuild_kernel, - *modulesBuffers_->data(), + *modulesBuffers_.data(), *quintupletsInGPU, *rangesInGPU)); @@ -983,7 +983,7 @@ void lst::Event::createQuintuplets() { auto const addQuintupletRangesToEventExplicitTask( alpaka::createTaskKernel(addQuintupletRangesToEventExplicit_workDiv, addQuintupletRangesToEventExplicit_kernel, - *modulesBuffers_->data(), + *modulesBuffers_.data(), *quintupletsInGPU, *rangesInGPU)); @@ -1004,7 +1004,7 @@ void lst::Event::pixelLineSegmentCleaning(bool no_pls_dupclean) { lst::checkHitspLS checkHitspLS_kernel; auto const checkHitspLSTask(alpaka::createTaskKernel( - checkHitspLS_workDiv, checkHitspLS_kernel, *modulesBuffers_->data(), *segmentsInGPU, false)); + checkHitspLS_workDiv, checkHitspLS_kernel, *modulesBuffers_.data(), *segmentsInGPU, false)); alpaka::enqueue(queue, checkHitspLSTask); alpaka::wait(queue); @@ -1097,7 +1097,7 @@ void lst::Event::createPixelQuintuplets() { auto const createPixelQuintupletsInGPUFromMapv2Task( alpaka::createTaskKernel(createPixelQuintupletsInGPUFromMapv2_workDiv, createPixelQuintupletsInGPUFromMapv2_kernel, - *modulesBuffers_->data(), + *modulesBuffers_.data(), *mdsInGPU, *segmentsInGPU, *tripletsInGPU, @@ -1155,10 +1155,10 @@ void lst::Event::addMiniDoubletsToEventExplicit() { alpaka::memcpy(queue, nMDsCPU_buf, miniDoubletsBuffers->nMDs_buf, nLowerModules_); auto module_subdets_buf = allocBufWrapper(devHost, nLowerModules_, queue); - alpaka::memcpy(queue, module_subdets_buf, modulesBuffers_->subdets_buf, nLowerModules_); + alpaka::memcpy(queue, module_subdets_buf, modulesBuffers_.subdets_buf, nLowerModules_); auto module_layers_buf = allocBufWrapper(devHost, nLowerModules_, queue); - alpaka::memcpy(queue, module_layers_buf, modulesBuffers_->layers_buf, nLowerModules_); + alpaka::memcpy(queue, module_layers_buf, modulesBuffers_.layers_buf, nLowerModules_); auto module_hitRanges_buf = allocBufWrapper(devHost, nLowerModules_ * 2, queue); alpaka::memcpy(queue, module_hitRanges_buf, hitsBuffers->hitRanges_buf, nLowerModules_ * 2u); @@ -1186,10 +1186,10 @@ void lst::Event::addSegmentsToEventExplicit() { alpaka::memcpy(queue, nSegmentsCPU_buf, segmentsBuffers->nSegments_buf, nLowerModules_); auto module_subdets_buf = allocBufWrapper(devHost, nLowerModules_, queue); - alpaka::memcpy(queue, module_subdets_buf, modulesBuffers_->subdets_buf, nLowerModules_); + alpaka::memcpy(queue, module_subdets_buf, modulesBuffers_.subdets_buf, nLowerModules_); auto module_layers_buf = allocBufWrapper(devHost, nLowerModules_, queue); - alpaka::memcpy(queue, module_layers_buf, modulesBuffers_->layers_buf, nLowerModules_); + alpaka::memcpy(queue, module_layers_buf, modulesBuffers_.layers_buf, nLowerModules_); alpaka::wait(queue); @@ -1213,10 +1213,10 @@ void lst::Event::addQuintupletsToEventExplicit() { alpaka::memcpy(queue, nQuintupletsCPU_buf, quintupletsBuffers->nQuintuplets_buf); auto module_subdets_buf = allocBufWrapper(devHost, nModules_, queue); - alpaka::memcpy(queue, module_subdets_buf, modulesBuffers_->subdets_buf, nModules_); + alpaka::memcpy(queue, module_subdets_buf, modulesBuffers_.subdets_buf, nModules_); auto module_layers_buf = allocBufWrapper(devHost, nLowerModules_, queue); - alpaka::memcpy(queue, module_layers_buf, modulesBuffers_->layers_buf, nLowerModules_); + alpaka::memcpy(queue, module_layers_buf, modulesBuffers_.layers_buf, nLowerModules_); auto module_quintupletModuleIndices_buf = allocBufWrapper(devHost, nLowerModules_, queue); alpaka::memcpy(queue, module_quintupletModuleIndices_buf, rangesBuffers->quintupletModuleIndices_buf); @@ -1244,10 +1244,10 @@ void lst::Event::addTripletsToEventExplicit() { alpaka::memcpy(queue, nTripletsCPU_buf, tripletsBuffers->nTriplets_buf); auto module_subdets_buf = allocBufWrapper(devHost, nLowerModules_, queue); - alpaka::memcpy(queue, module_subdets_buf, modulesBuffers_->subdets_buf, nLowerModules_); + alpaka::memcpy(queue, module_subdets_buf, modulesBuffers_.subdets_buf, nLowerModules_); auto module_layers_buf = allocBufWrapper(devHost, nLowerModules_, queue); - alpaka::memcpy(queue, module_layers_buf, modulesBuffers_->layers_buf, nLowerModules_); + alpaka::memcpy(queue, module_layers_buf, modulesBuffers_.layers_buf, nLowerModules_); alpaka::wait(queue); unsigned int* nTripletsCPU = alpaka::getPtrNative(nTripletsCPU_buf); @@ -1822,7 +1822,7 @@ lst::ModulesBuffer* lst::Event::getModules(bool isFull) { // The last input here is just a small placeholder for the allocation. modulesInCPU = new lst::ModulesBuffer(devHost, nModules_, nPixels_); - modulesInCPU->copyFromSrc(queue, *modulesBuffers_, isFull); + modulesInCPU->copyFromSrc(queue, modulesBuffers_, isFull); } return modulesInCPU; } diff --git a/RecoTracker/LSTCore/src/alpaka/Event.h b/RecoTracker/LSTCore/src/alpaka/Event.h index 01abacba7dc74..cbf4302dcc465 100644 --- a/RecoTracker/LSTCore/src/alpaka/Event.h +++ b/RecoTracker/LSTCore/src/alpaka/Event.h @@ -87,9 +87,9 @@ namespace lst { const uint16_t nLowerModules_; const unsigned int nPixels_; const unsigned int nEndCapMap_; - const std::shared_ptr> modulesBuffers_; - const std::shared_ptr pixelMapping_; - const std::shared_ptr> endcapGeometryBuffers_; + ModulesBuffer const& modulesBuffers_; + std::shared_ptr pixelMapping_; + EndcapGeometryBuffer const& endcapGeometryBuffers_; public: // Constructor used for CMSSW integration. Uses an external queue.