diff --git a/DataFormats/VertexSoA/test/alpaka/ZVertexSoA_test.cc b/DataFormats/VertexSoA/test/alpaka/ZVertexSoA_test.cc index 79a2964c2db85..bd358d7c45c53 100644 --- a/DataFormats/VertexSoA/test/alpaka/ZVertexSoA_test.cc +++ b/DataFormats/VertexSoA/test/alpaka/ZVertexSoA_test.cc @@ -56,11 +56,10 @@ int main() { // If the device is actually the host, use the collection as-is. // Otherwise, copy the data from the device to the host. - ZVertexHost zvertex_h; #ifdef ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED - zvertex_h = std::move(zvertex_d); + ZVertexHost zvertex_h = std::move(zvertex_d); #else - zvertex_h = cms::alpakatools::CopyToHost::copyAsync(queue, zvertex_d); + ZVertexHost zvertex_h = cms::alpakatools::CopyToHost::copyAsync(queue, zvertex_d); #endif alpaka::wait(queue); std::cout << zvertex_h.view().metadata().size() << std::endl; diff --git a/EventFilter/HcalRawToDigi/plugins/alpaka/HcalDigisSoAProducer.cc b/EventFilter/HcalRawToDigi/plugins/alpaka/HcalDigisSoAProducer.cc index 3299b01a41ecf..ae10b24a32b86 100644 --- a/EventFilter/HcalRawToDigi/plugins/alpaka/HcalDigisSoAProducer.cc +++ b/EventFilter/HcalRawToDigi/plugins/alpaka/HcalDigisSoAProducer.cc @@ -116,8 +116,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { event.emplace(digisF5HBToken_, std::move(df5_)); if (qie11Digis.empty()) { - event.emplace(digisF01HEToken_); - event.emplace(digisF3HBToken_); + event.emplace(digisF01HEToken_, 0, event.queue()); + event.emplace(digisF3HBToken_, 0, event.queue()); } else { auto size_f1 = 0; diff --git a/HeterogeneousCore/AlpakaTest/plugins/alpaka/TestHelperClass.cc b/HeterogeneousCore/AlpakaTest/plugins/alpaka/TestHelperClass.cc index aa4c26e4c93bd..8de494e37430f 100644 --- a/HeterogeneousCore/AlpakaTest/plugins/alpaka/TestHelperClass.cc +++ b/HeterogeneousCore/AlpakaTest/plugins/alpaka/TestHelperClass.cc @@ -23,8 +23,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { hostProductMulti2_ = portabletest::TestHostMultiCollection2{deviceProductMulti2.sizes(), iEvent.queue()}; hostProductMulti3_ = portabletest::TestHostMultiCollection3{deviceProductMulti3.sizes(), iEvent.queue()}; - alpaka::memcpy(iEvent.queue(), hostProduct_.buffer(), deviceProduct.const_buffer()); - alpaka::memcpy(iEvent.queue(), hostProductMulti2_.buffer(), deviceProductMulti2.const_buffer()); - alpaka::memcpy(iEvent.queue(), hostProductMulti3_.buffer(), deviceProductMulti3.const_buffer()); + alpaka::memcpy(iEvent.queue(), hostProduct_->buffer(), deviceProduct.const_buffer()); + alpaka::memcpy(iEvent.queue(), hostProductMulti2_->buffer(), deviceProductMulti2.const_buffer()); + alpaka::memcpy(iEvent.queue(), hostProductMulti3_->buffer(), deviceProductMulti3.const_buffer()); } } // namespace ALPAKA_ACCELERATOR_NAMESPACE diff --git a/HeterogeneousCore/AlpakaTest/plugins/alpaka/TestHelperClass.h b/HeterogeneousCore/AlpakaTest/plugins/alpaka/TestHelperClass.h index d592fb40b4210..c369e78fc639a 100644 --- a/HeterogeneousCore/AlpakaTest/plugins/alpaka/TestHelperClass.h +++ b/HeterogeneousCore/AlpakaTest/plugins/alpaka/TestHelperClass.h @@ -1,6 +1,8 @@ #ifndef HeterogeneousCore_AlpakaTest_plugins_alpaka_TestHelperClass_h #define HeterogeneousCore_AlpakaTest_plugins_alpaka_TestHelperClass_h +#include + #include "DataFormats/PortableTestObjects/interface/TestHostCollection.h" #include "DataFormats/PortableTestObjects/interface/alpaka/TestDeviceCollection.h" #include "FWCore/Framework/interface/ConsumesCollector.h" @@ -23,9 +25,23 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { void makeAsync(device::Event const& iEvent, device::EventSetup const& iSetup); - portabletest::TestHostCollection moveFrom() { return std::move(hostProduct_); } - portabletest::TestHostMultiCollection2 moveFromMulti2() { return std::move(hostProductMulti2_); } - portabletest::TestHostMultiCollection3 moveFromMulti3() { return std::move(hostProductMulti3_); } + portabletest::TestHostCollection moveFrom() { + auto product = std::move(*hostProduct_); + hostProduct_.reset(); + return product; + } + + portabletest::TestHostMultiCollection2 moveFromMulti2() { + auto product = std::move(*hostProductMulti2_); + hostProductMulti2_.reset(); + return product; + } + + portabletest::TestHostMultiCollection3 moveFromMulti3() { + auto product = std::move(*hostProductMulti3_); + hostProductMulti3_.reset(); + return product; + } private: const device::EDGetToken getToken_; @@ -35,9 +51,9 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { const device::ESGetToken esTokenDevice_; // hold the output product between acquire() and produce() - portabletest::TestHostCollection hostProduct_; - portabletest::TestHostMultiCollection2 hostProductMulti2_; - portabletest::TestHostMultiCollection3 hostProductMulti3_; + std::optional hostProduct_; + std::optional hostProductMulti2_; + std::optional hostProductMulti3_; }; } // namespace ALPAKA_ACCELERATOR_NAMESPACE diff --git a/RecoLocalTracker/SiPixelClusterizer/plugins/alpaka/SiPixelPhase2DigiToCluster.cc b/RecoLocalTracker/SiPixelClusterizer/plugins/alpaka/SiPixelPhase2DigiToCluster.cc index 4b97366b060be..cd8445e9c25b8 100644 --- a/RecoLocalTracker/SiPixelClusterizer/plugins/alpaka/SiPixelPhase2DigiToCluster.cc +++ b/RecoLocalTracker/SiPixelClusterizer/plugins/alpaka/SiPixelPhase2DigiToCluster.cc @@ -1,5 +1,6 @@ // C++ includes #include +#include #include #include #include @@ -43,16 +44,13 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { const edm::ESGetToken geomToken_; const edm::EDGetTokenT> pixelDigiToken_; - - device::EDPutToken digiPutToken_; - device::EDPutToken clusterPutToken_; - - Algo Algo_; - + const device::EDPutToken digiPutToken_; + const device::EDPutToken clusterPutToken_; const SiPixelClusterThresholds clusterThresholds_; - uint32_t nDigis_ = 0; - SiPixelDigisSoACollection digis_d; + Algo algo_; + uint32_t nDigis_ = 0; + std::optional digis_d_; }; SiPixelPhase2DigiToCluster::SiPixelPhase2DigiToCluster(const edm::ParameterSet& iConfig) @@ -87,19 +85,18 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { const TrackerGeometry* geom_ = &iSetup.getData(geomToken_); - uint32_t nDigis = 0; - + nDigis_ = 0; for (const auto& det : input) { - nDigis += det.size(); + nDigis_ += det.size(); } + digis_d_ = SiPixelDigisSoACollection(nDigis_, iEvent.queue()); - if (nDigis == 0) + if (nDigis_ == 0) return; - nDigis_ = nDigis; SiPixelDigisHost digis_h(nDigis_, iEvent.queue()); - nDigis = 0; + uint32_t nDigis = 0; for (const auto& det : input) { unsigned int detid = det.detId(); DetId detIdObject(detid); @@ -107,39 +104,31 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { auto const gind = genericDet->index(); for (auto const& px : det) { digis_h.view()[nDigis].moduleId() = uint16_t(gind); - digis_h.view()[nDigis].xx() = uint16_t(px.row()); digis_h.view()[nDigis].yy() = uint16_t(px.column()); digis_h.view()[nDigis].adc() = uint16_t(px.adc()); - digis_h.view()[nDigis].clus() = 0; - digis_h.view()[nDigis].pdigi() = uint32_t(px.packedData()); - digis_h.view()[nDigis].rawIdArr() = uint32_t(detid); - - nDigis++; + ++nDigis; } } + assert(nDigis == nDigis_); - digis_d = SiPixelDigisSoACollection(nDigis, iEvent.queue()); - alpaka::memcpy(iEvent.queue(), digis_d.buffer(), digis_h.buffer()); - - Algo_.makePhase2ClustersAsync(iEvent.queue(), clusterThresholds_, digis_d.view(), nDigis_); + alpaka::memcpy(iEvent.queue(), digis_d_->buffer(), digis_h.buffer()); + algo_.makePhase2ClustersAsync(iEvent.queue(), clusterThresholds_, digis_d_->view(), nDigis_); } void SiPixelPhase2DigiToCluster::produce(device::Event& iEvent, device::EventSetup const& iSetup) { if (nDigis_ == 0) { - SiPixelClustersSoACollection clusters_d{pixelTopology::Phase2::numberOfModules, iEvent.queue()}; - SiPixelDigisSoACollection digis_d_zero{nDigis_, iEvent.queue()}; - iEvent.emplace(digiPutToken_, std::move(digis_d_zero)); - iEvent.emplace(clusterPutToken_, std::move(clusters_d)); - return; + iEvent.emplace(digiPutToken_, std::move(*digis_d_)); + iEvent.emplace(clusterPutToken_, pixelTopology::Phase2::numberOfModules, iEvent.queue()); + } else { + digis_d_->setNModules(algo_.nModules()); + iEvent.emplace(digiPutToken_, std::move(*digis_d_)); + iEvent.emplace(clusterPutToken_, algo_.getClusters()); } - - digis_d.setNModules(Algo_.nModules()); - iEvent.emplace(digiPutToken_, std::move(digis_d)); - iEvent.emplace(clusterPutToken_, Algo_.getClusters()); + digis_d_.reset(); } } // namespace ALPAKA_ACCELERATOR_NAMESPACE diff --git a/RecoLocalTracker/SiPixelClusterizer/plugins/alpaka/SiPixelRawToCluster.cc b/RecoLocalTracker/SiPixelClusterizer/plugins/alpaka/SiPixelRawToCluster.cc index 8f14c50f09263..7eafcbf336cd3 100644 --- a/RecoLocalTracker/SiPixelClusterizer/plugins/alpaka/SiPixelRawToCluster.cc +++ b/RecoLocalTracker/SiPixelClusterizer/plugins/alpaka/SiPixelRawToCluster.cc @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -262,10 +263,10 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { // are no valid pointers to clusters' Collection columns, instantiation // of TrackingRecHits fail. Example: workflow 11604.0 - iEvent.emplace(digiPutToken_, nDigis_, iEvent.queue()); + iEvent.emplace(digiPutToken_, 0, iEvent.queue()); iEvent.emplace(clusterPutToken_, pixelTopology::Phase1::numberOfModules, iEvent.queue()); if (includeErrors_) { - iEvent.emplace(digiErrorPutToken_); + iEvent.emplace(digiErrorPutToken_, 0, iEvent.queue()); iEvent.emplace(fmtErrorToken_); } return;