Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:03:45

0001 #ifndef CUDADataFormats_SiPixelCluster_interface_SiPixelClustersCUDA_h
0002 #define CUDADataFormats_SiPixelCluster_interface_SiPixelClustersCUDA_h
0003 
0004 #include "HeterogeneousCore/CUDAUtilities/interface/device_unique_ptr.h"
0005 #include "HeterogeneousCore/CUDAUtilities/interface/host_unique_ptr.h"
0006 #include "HeterogeneousCore/CUDAUtilities/interface/cudaCompat.h"
0007 
0008 #include "DataFormats/SoATemplate/interface/SoALayout.h"
0009 #include "CUDADataFormats/Common/interface/PortableDeviceCollection.h"
0010 
0011 #include <cuda_runtime.h>
0012 
0013 GENERATE_SOA_LAYOUT(SiPixelClustersCUDALayout,
0014                     SOA_COLUMN(uint32_t, moduleStart),
0015                     SOA_COLUMN(uint32_t, clusInModule),
0016                     SOA_COLUMN(uint32_t, moduleId),
0017                     SOA_COLUMN(uint32_t, clusModuleStart))
0018 
0019 using SiPixelClustersCUDASoA = SiPixelClustersCUDALayout<>;
0020 using SiPixelClustersCUDASOAView = SiPixelClustersCUDALayout<>::View;
0021 using SiPixelClustersCUDASOAConstView = SiPixelClustersCUDALayout<>::ConstView;
0022 
0023 // TODO: The class is created via inheritance of the PortableDeviceCollection.
0024 // This is generally discouraged, and should be done via composition, i.e.,
0025 // by adding a public class attribute like:
0026 // cms::cuda::Portabledevicecollection<SiPixelClustersCUDALayout<>> collection;
0027 // See: https://github.com/cms-sw/cmssw/pull/40465#discussion_r1067364306
0028 class SiPixelClustersCUDA : public cms::cuda::PortableDeviceCollection<SiPixelClustersCUDALayout<>> {
0029 public:
0030   SiPixelClustersCUDA() = default;
0031   ~SiPixelClustersCUDA() = default;
0032 
0033   explicit SiPixelClustersCUDA(size_t maxModules, cudaStream_t stream)
0034       : PortableDeviceCollection<SiPixelClustersCUDALayout<>>(maxModules + 1, stream) {}
0035 
0036   SiPixelClustersCUDA(SiPixelClustersCUDA &&) = default;
0037   SiPixelClustersCUDA &operator=(SiPixelClustersCUDA &&) = default;
0038 
0039   void setNClusters(uint32_t nClusters, int32_t offsetBPIX2) {
0040     nClusters_h = nClusters;
0041     offsetBPIX2_h = offsetBPIX2;
0042   }
0043 
0044   uint32_t nClusters() const { return nClusters_h; }
0045   int32_t offsetBPIX2() const { return offsetBPIX2_h; }
0046 
0047 private:
0048   uint32_t nClusters_h = 0;
0049   int32_t offsetBPIX2_h = 0;
0050 };
0051 
0052 #endif  // CUDADataFormats_SiPixelCluster_interface_SiPixelClustersCUDA_h