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
makortel authored and fwyzard committed Dec 29, 2020
1 parent 93dd141 commit 7cd3e8e
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions RecoLocalCalo/EcalRecAlgos/interface/EcalGainRatiosGPU.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#ifndef __CUDACC__
#include "HeterogeneousCore/CUDAUtilities/interface/CUDAHostAllocator.h"
#include "HeterogeneousCore/CUDACore/interface/CUDAESProduct.h"
#include "HeterogeneousCore/CUDACore/interface/ESProduct.h"
#endif

#include <cuda_runtime.h>
Expand Down Expand Up @@ -37,7 +37,7 @@ class EcalGainRatiosGPU {
std::vector<float, CUDAHostAllocator<float>> gain12Over6_;
std::vector<float, CUDAHostAllocator<float>> gain6Over1_;

CUDAESProduct<Product> product_;
cms::cuda::ESProduct<Product> product_;

#endif
};
Expand Down
4 changes: 2 additions & 2 deletions RecoLocalCalo/EcalRecAlgos/interface/EcalPedestalsGPU.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#ifndef __CUDACC__
#include "HeterogeneousCore/CUDAUtilities/interface/CUDAHostAllocator.h"
#include "HeterogeneousCore/CUDACore/interface/CUDAESProduct.h"
#include "HeterogeneousCore/CUDACore/interface/ESProduct.h"
#endif

#include <cuda_runtime.h>
Expand Down Expand Up @@ -42,7 +42,7 @@ class EcalPedestalsGPU {
std::vector<float, CUDAHostAllocator<float>> mean_x1_;
std::vector<float, CUDAHostAllocator<float>> rms_x1_;

CUDAESProduct<Product> product_;
cms::cuda::ESProduct<Product> product_;
#endif
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#ifndef __CUDACC__
#include "HeterogeneousCore/CUDAUtilities/interface/CUDAHostAllocator.h"
#include "HeterogeneousCore/CUDACore/interface/CUDAESProduct.h"
#include "HeterogeneousCore/CUDACore/interface/ESProduct.h"
#endif

#include <cuda_runtime.h>
Expand Down Expand Up @@ -35,7 +35,7 @@ class EcalPulseCovariancesGPU {
std::vector<EcalPulseCovariance> const& valuesEB_;
std::vector<EcalPulseCovariance> const& valuesEE_;

CUDAESProduct<Product> product_;
cms::cuda::ESProduct<Product> product_;
#endif
};

Expand Down
4 changes: 2 additions & 2 deletions RecoLocalCalo/EcalRecAlgos/interface/EcalPulseShapesGPU.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#ifndef __CUDACC__
#include "HeterogeneousCore/CUDAUtilities/interface/CUDAHostAllocator.h"
#include "HeterogeneousCore/CUDACore/interface/CUDAESProduct.h"
#include "HeterogeneousCore/CUDACore/interface/ESProduct.h"
#endif

#include <cuda_runtime.h>
Expand Down Expand Up @@ -35,7 +35,7 @@ class EcalPulseShapesGPU {
std::vector<EcalPulseShape> const& valuesEB_;
std::vector<EcalPulseShape> const& valuesEE_;

CUDAESProduct<Product> product_;
cms::cuda::ESProduct<Product> product_;
#endif
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#ifndef __CUDACC__
#include "HeterogeneousCore/CUDAUtilities/interface/CUDAHostAllocator.h"
#include "HeterogeneousCore/CUDACore/interface/CUDAESProduct.h"
#include "HeterogeneousCore/CUDACore/interface/ESProduct.h"
#endif

#include <cuda_runtime.h>
Expand Down Expand Up @@ -39,7 +39,7 @@ class EcalSamplesCorrelationGPU {
std::vector<double> const& EEG6SamplesCorrelation_;
std::vector<double> const& EEG1SamplesCorrelation_;

CUDAESProduct<Product> product_;
cms::cuda::ESProduct<Product> product_;
#endif
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#ifndef __CUDACC__
#include "HeterogeneousCore/CUDAUtilities/interface/CUDAHostAllocator.h"
#include "HeterogeneousCore/CUDACore/interface/CUDAESProduct.h"
#include "HeterogeneousCore/CUDACore/interface/ESProduct.h"
#endif

#include <cuda_runtime.h>
Expand Down Expand Up @@ -44,7 +44,7 @@ class EcalTimeBiasCorrectionsGPU {
std::vector<float> const& EETimeCorrShiftBins_;

#ifndef __CUDACC__
CUDAESProduct<Product> product_;
cms::cuda::ESProduct<Product> product_;
#endif
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#ifndef __CUDACC__
#include "HeterogeneousCore/CUDAUtilities/interface/CUDAHostAllocator.h"
#include "HeterogeneousCore/CUDACore/interface/CUDAESProduct.h"
#include "HeterogeneousCore/CUDACore/interface/ESProduct.h"
#endif

#include <cuda_runtime.h>
Expand Down Expand Up @@ -38,7 +38,7 @@ class EcalTimeCalibConstantsGPU {
std::vector<float> const& valuesEB_;
std::vector<float> const& valuesEE_;

CUDAESProduct<Product> product_;
cms::cuda::ESProduct<Product> product_;
#endif
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//#include "HeterogeneousCore/Producer/interface/HeterogeneousEvent.h"

#include "HeterogeneousCore/CUDAUtilities/interface/cudaCheck.h"
#include "HeterogeneousCore/CUDACore/interface/CUDAScopedContext.h"
#include "HeterogeneousCore/CUDACore/interface/ScopedContext.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
Expand Down Expand Up @@ -79,7 +79,7 @@ class EcalUncalibRecHitProducerGPU : public edm::stream::EDProducer<edm::Externa
ecal::multifit::EventDataForScratchGPU eventDataForScratchGPU_;
bool shouldTransferToHost_{true};

CUDAContextState cudaState_;
cms::cuda::ContextState cudaState_;

std::unique_ptr<ecal::UncalibratedRecHit<ecal::Tag::soa>> ebRecHits_{nullptr}, eeRecHits_{nullptr};

Expand Down Expand Up @@ -294,7 +294,7 @@ void EcalUncalibRecHitProducerGPU::acquire(edm::Event const& event,
//DurationMeasurer<std::chrono::milliseconds> timer{std::string{"acquire duration"}};

// raii
CUDAScopedContextAcquire ctx{event.streamID(), std::move(holder), cudaState_};
cms::cuda::ScopedContextAcquire ctx{event.streamID(), std::move(holder), cudaState_};

// conditions
setup.get<EcalPedestalsRcd>().get(pedestalsHandle_);
Expand Down Expand Up @@ -364,7 +364,7 @@ void EcalUncalibRecHitProducerGPU::acquire(edm::Event const& event,

void EcalUncalibRecHitProducerGPU::produce(edm::Event& event, edm::EventSetup const& setup) {
//DurationMeasurer<std::chrono::milliseconds> timer{std::string{"produce duration"}};
CUDAScopedContextProduce ctx{cudaState_};
cms::cuda::ScopedContextProduce ctx{cudaState_};

if (shouldTransferToHost_) {
// rec hits objects were not originally member variables
Expand Down

0 comments on commit 7cd3e8e

Please sign in to comment.