Skip to content

Commit

Permalink
Implement changes from the CUDA framework review (#429)
Browse files Browse the repository at this point in the history
Rename the cudautils namespace to cms::cuda or cms::cudatest, and drop the CUDA prefix from the symbols defined there.

Always record and query the CUDA event, to minimize need for error checking in CUDAScopedContextProduce destructor.

Add comments to highlight the pieces in CachingDeviceAllocator that have been changed wrt. cub.

Various other updates and clean up:
  - enable CUDA for compute capability 3.5.
  - clean up CUDAService, CUDA tests and plugins.
  - add CUDA existence protections to BuildFiles.
  - mark thread-safe static variables with CMS_THREAD_SAFE.
  • Loading branch information
fwyzard committed Nov 27, 2020
1 parent e451702 commit e0c507e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include <cuda_runtime.h>

#include "CUDADataFormats/Common/interface/CUDAProduct.h"
#include "CUDADataFormats/Common/interface/Product.h"
#include "CUDADataFormats/SiPixelDigi/interface/SiPixelDigisCUDA.h"
#include "CUDADataFormats/TrackingRecHit/interface/TrackingRecHit2DCUDA.h"
#include "DataFormats/Common/interface/DetSetVector.h"
Expand All @@ -29,7 +29,7 @@
#include "FWCore/Utilities/interface/InputTag.h"
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
#include "HeterogeneousCore/CUDACore/interface/CUDAScopedContext.h"
#include "HeterogeneousCore/CUDACore/interface/ScopedContext.h"
#include "HeterogeneousCore/CUDAUtilities/interface/cudaCheck.h"
#include "SimDataFormats/Track/interface/SimTrackContainer.h"
#include "SimDataFormats/TrackerDigiSimLink/interface/PixelDigiSimLink.h"
Expand Down Expand Up @@ -71,10 +71,10 @@ class ClusterTPAssociationProducerCUDA : public edm::global::EDProducer<> {
edm::EDGetTokenT<edmNew::DetSetVector<Phase2TrackerCluster1D>> phase2OTClustersToken_;
edm::EDGetTokenT<TrackingParticleCollection> trackingParticleToken_;

edm::EDGetTokenT<CUDAProduct<SiPixelDigisCUDA>> tGpuDigis;
edm::EDGetTokenT<CUDAProduct<TrackingRecHit2DCUDA>> tGpuHits;
edm::EDGetTokenT<cms::cuda::Product<SiPixelDigisCUDA>> tGpuDigis;
edm::EDGetTokenT<cms::cuda::Product<TrackingRecHit2DCUDA>> tGpuHits;

edm::EDPutTokenT<CUDAProduct<ProductCUDA>> tokenGPUProd_;
edm::EDPutTokenT<cms::cuda::Product<ProductCUDA>> tokenGPUProd_;

clusterSLOnGPU::Kernel m_gpuAlgo;
};
Expand All @@ -94,12 +94,12 @@ ClusterTPAssociationProducerCUDA::ClusterTPAssociationProducerCUDA(const edm::Pa
cfg.getParameter<edm::InputTag>("phase2OTClusterSrc"))),
trackingParticleToken_(
consumes<TrackingParticleCollection>(cfg.getParameter<edm::InputTag>("trackingParticleSrc"))),
tGpuDigis(
consumes<CUDAProduct<SiPixelDigisCUDA>>(cfg.getParameter<edm::InputTag>("heterogeneousPixelDigiClusterSrc"))),
tGpuHits(
consumes<CUDAProduct<TrackingRecHit2DCUDA>>(cfg.getParameter<edm::InputTag>("heterogeneousPixelRecHitSrc"))),
tGpuDigis(consumes<cms::cuda::Product<SiPixelDigisCUDA>>(
cfg.getParameter<edm::InputTag>("heterogeneousPixelDigiClusterSrc"))),
tGpuHits(consumes<cms::cuda::Product<TrackingRecHit2DCUDA>>(
cfg.getParameter<edm::InputTag>("heterogeneousPixelRecHitSrc"))),
m_gpuAlgo(cfg.getParameter<bool>("dumpCSV")) {
tokenGPUProd_ = produces<CUDAProduct<ProductCUDA>>();
tokenGPUProd_ = produces<cms::cuda::Product<ProductCUDA>>();
}

void ClusterTPAssociationProducerCUDA::fillDescriptions(edm::ConfigurationDescriptions &descriptions) {
Expand Down Expand Up @@ -159,12 +159,12 @@ void ClusterTPAssociationProducerCUDA::produce(edm::StreamID streamID,

auto mapping = makeMap(iEvent);

edm::Handle<CUDAProduct<SiPixelDigisCUDA>> gd;
edm::Handle<cms::cuda::Product<SiPixelDigisCUDA>> gd;
iEvent.getByToken(tGpuDigis, gd);
edm::Handle<CUDAProduct<TrackingRecHit2DCUDA>> gh;
edm::Handle<cms::cuda::Product<TrackingRecHit2DCUDA>> gh;
iEvent.getByToken(tGpuHits, gh);

CUDAScopedContextProduce ctx{*gd};
cms::cuda::ScopedContextProduce ctx{*gd};
auto const &gDigis = ctx.get(*gd);
auto const &gHits = ctx.get(*gh);
auto ndigis = gDigis.nDigis();
Expand Down
2 changes: 1 addition & 1 deletion SimTracker/TrackerHitAssociation/src/classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "DataFormats/Common/interface/AssociationMap.h"
#include "DataFormats/TrackerRecHit2D/interface/OmniClusterRef.h"
#include "SimTracker/TrackerHitAssociation/interface/ClusterTPAssociation.h"
#include "CUDADataFormats/Common/interface/CUDAProduct.h"
#include "CUDADataFormats/Common/interface/Product.h"
#include "SimTracker/TrackerHitAssociation/interface/trackerHitAssociationHeterogeneous.h"

#include "DataFormats/Common/interface/AssociationMap.h"
Expand Down
4 changes: 2 additions & 2 deletions SimTracker/TrackerHitAssociation/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<class name="edm::Wrapper<std::map<OmniClusterRef, std::vector<TrackingParticleRef> > >" persistent="false" />

<class name="trackerHitAssociationHeterogeneous::ProductCUDA" persistent="false"/>
<class name="CUDAProduct<trackerHitAssociationHeterogeneous::ProductCUDA>" persistent="false"/>
<class name="edm::Wrapper<CUDAProduct<trackerHitAssociationHeterogeneous::ProductCUDA>>" persistent="false"/>
<class name="cms::cuda::Product<trackerHitAssociationHeterogeneous::ProductCUDA>" persistent="false"/>
<class name="edm::Wrapper<cms::cuda::Product<trackerHitAssociationHeterogeneous::ProductCUDA>>" persistent="false"/>

</lcgdict>
10 changes: 5 additions & 5 deletions SimTracker/TrackerHitAssociation/test/ClusterTPCUDAdump.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <cuda_runtime.h>

#include "CUDADataFormats/Common/interface/CUDAProduct.h"
#include "CUDADataFormats/Common/interface/Product.h"
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/Framework/interface/ESHandle.h"
Expand All @@ -16,7 +16,7 @@
#include "FWCore/Utilities/interface/EDGetToken.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/Utilities/interface/RunningAverage.h"
#include "HeterogeneousCore/CUDACore/interface/CUDAScopedContext.h"
#include "HeterogeneousCore/CUDACore/interface/ScopedContext.h"
#include "HeterogeneousCore/CUDAServices/interface/CUDAService.h"
#include "SimTracker/TrackerHitAssociation/interface/trackerHitAssociationHeterogeneous.h"

Expand All @@ -34,20 +34,20 @@ class ClusterTPCUDAdump : public edm::global::EDAnalyzer<> {
private:
void analyze(edm::StreamID streamID, edm::Event const& iEvent, const edm::EventSetup& iSetup) const override;
const bool m_onGPU;
edm::EDGetTokenT<CUDAProduct<ProductCUDA>> tokenGPU_;
edm::EDGetTokenT<cms::cuda::Product<ProductCUDA>> tokenGPU_;
};

ClusterTPCUDAdump::ClusterTPCUDAdump(const edm::ParameterSet& iConfig) : m_onGPU(iConfig.getParameter<bool>("onGPU")) {
if (m_onGPU) {
tokenGPU_ = consumes<CUDAProduct<ProductCUDA>>(iConfig.getParameter<edm::InputTag>("clusterTP"));
tokenGPU_ = consumes<cms::cuda::Product<ProductCUDA>>(iConfig.getParameter<edm::InputTag>("clusterTP"));
} else {
}
}

void ClusterTPCUDAdump::analyze(edm::StreamID streamID, edm::Event const& iEvent, const edm::EventSetup& iSetup) const {
if (m_onGPU) {
auto const& hctp = iEvent.get(tokenGPU_);
CUDAScopedContextProduce ctx{hctp};
cms::cuda::ScopedContextProduce ctx{hctp};

auto const& ctp = ctx.get(hctp);
auto const& soa = ctp.view();
Expand Down

0 comments on commit e0c507e

Please sign in to comment.