Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-03-25 10:54:41

0001 #include "CondFormats/EcalObjects/interface/ElectronicsMappingGPU.h"
0002 
0003 #include "FWCore/Utilities/interface/typelookup.h"
0004 #include "HeterogeneousCore/CUDAUtilities/interface/copyAsync.h"
0005 
0006 #include "DataFormats/EcalDetId/interface/EcalElectronicsId.h"
0007 
0008 namespace ecal {
0009   namespace raw {
0010 
0011     // TODO: 0x3FFFFF * 4B ~= 16MB
0012     // tmp solution for linear mapping of eid -> did
0013     ElectronicsMappingGPU::ElectronicsMappingGPU(EcalMappingElectronics const& mapping) : eid2did_(0x3FFFFF) {
0014       // fill in eb
0015       // TODO: EB vector is actually empty
0016       auto const& barrelValues = mapping.barrelItems();
0017       for (unsigned int i = 0; i < barrelValues.size(); i++) {
0018         EcalElectronicsId eid{barrelValues[i].electronicsid};
0019         EBDetId did{EBDetId::unhashIndex(i)};
0020         eid2did_[eid.linearIndex()] = did.rawId();
0021       }
0022 
0023       // fill in ee
0024       auto const& endcapValues = mapping.endcapItems();
0025       for (unsigned int i = 0; i < endcapValues.size(); i++) {
0026         EcalElectronicsId eid{endcapValues[i].electronicsid};
0027         EEDetId did{EEDetId::unhashIndex(i)};
0028         eid2did_[eid.linearIndex()] = did.rawId();
0029       }
0030     }
0031 
0032     ElectronicsMappingGPU::Product const& ElectronicsMappingGPU::getProduct(cudaStream_t cudaStream) const {
0033       auto const& product = product_.dataForCurrentDeviceAsync(
0034           cudaStream, [this](ElectronicsMappingGPU::Product& product, cudaStream_t cudaStream) {
0035             // allocate
0036             product.eid2did = cms::cuda::make_device_unique<uint32_t[]>(eid2did_.size(), cudaStream);
0037             // transfer
0038             cms::cuda::copyAsync(product.eid2did, eid2did_, cudaStream);
0039           });
0040 
0041       return product;
0042     }
0043 
0044   }  // namespace raw
0045 }  // namespace ecal
0046 
0047 TYPELOOKUP_DATA_REG(ecal::raw::ElectronicsMappingGPU);