Skip to content

Commit

Permalink
Move raw data pinned host buffers to be allocated in constructor with…
Browse files Browse the repository at this point in the history
… cudaHostAllocWriteCombined
  • Loading branch information
makortel committed Apr 10, 2019
1 parent e55192a commit 3ac4c7c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "HeterogeneousCore/CUDACore/interface/CUDAScopedContext.h"
#include "HeterogeneousCore/CUDAServices/interface/CUDAService.h"
#include "RecoLocalTracker/SiPixelClusterizer/interface/SiPixelFedCablingMapGPUWrapper.h"
#include "RecoTracker/Record/interface/CkfComponentsRecord.h"

Expand Down Expand Up @@ -62,6 +64,7 @@ class SiPixelRawToClusterCUDA: public edm::stream::EDProducer<edm::ExternalWork>
std::unique_ptr<PixelUnpackingRegions> regions_;

pixelgpudetails::SiPixelRawToClusterGPUKernel gpuAlgo_;
std::unique_ptr<pixelgpudetails::SiPixelRawToClusterGPUKernel::WordFedAppender> wordFedAppender_;
PixelDataFormatter::Errors errors_;

const bool includeErrors_;
Expand Down Expand Up @@ -90,6 +93,11 @@ SiPixelRawToClusterCUDA::SiPixelRawToClusterCUDA(const edm::ParameterSet& iConfi
}

if(usePilotBlade_) edm::LogInfo("SiPixelRawToCluster") << " Use pilot blade data (FED 40)";

edm::Service<CUDAService> cs;
if(cs->enabled()) {
wordFedAppender_ = std::make_unique<pixelgpudetails::SiPixelRawToClusterGPUKernel::WordFedAppender>();
}
}

void SiPixelRawToClusterCUDA::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
Expand Down Expand Up @@ -164,7 +172,6 @@ void SiPixelRawToClusterCUDA::acquire(const edm::Event& iEvent, const edm::Event

// In CPU algorithm this loop is part of PixelDataFormatter::interpretRawData()
ErrorChecker errorcheck;
auto wordFedAppender = pixelgpudetails::SiPixelRawToClusterGPUKernel::WordFedAppender(ctx.stream());
for(int fedId: fedIds_) {
if (!usePilotBlade_ && (fedId==40) ) continue; // skip pilot blade data
if (regions_ && !regions_->mayUnpackFED(fedId)) continue;
Expand Down Expand Up @@ -212,13 +219,13 @@ void SiPixelRawToClusterCUDA::acquire(const edm::Event& iEvent, const edm::Event
const cms_uint32_t * ew = (const cms_uint32_t *)(trailer);

assert(0 == (ew-bw)%2);
wordFedAppender.initializeWordFed(fedId, wordCounterGPU, bw, (ew-bw));
wordFedAppender_->initializeWordFed(fedId, wordCounterGPU, bw, (ew-bw));
wordCounterGPU+=(ew-bw);

} // end of for loop

gpuAlgo_.makeClustersAsync(gpuMap, gpuModulesToUnpack, gpuGains,
wordFedAppender,
*wordFedAppender_,
std::move(errors_),
wordCounterGPU, fedCounter, convertADCtoElectrons_,
useQuality_, includeErrors_,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@ namespace pixelgpudetails {
// number of words for all the FEDs
constexpr uint32_t MAX_FED_WORDS = pixelgpudetails::MAX_FED * pixelgpudetails::MAX_WORD;

SiPixelRawToClusterGPUKernel::WordFedAppender::WordFedAppender(cuda::stream_t<>& cudaStream) {
edm::Service<CUDAService> cs;
word_ = cs->make_host_unique<unsigned int[]>(MAX_FED_WORDS, cudaStream);
fedId_ = cs->make_host_unique<unsigned char[]>(MAX_FED_WORDS, cudaStream);
SiPixelRawToClusterGPUKernel::WordFedAppender::WordFedAppender() {
word_ = cudautils::make_host_noncached_unique<unsigned int[]>(MAX_FED_WORDS, cudaHostAllocWriteCombined);
fedId_ = cudautils::make_host_noncached_unique<unsigned char[]>(MAX_FED_WORDS, cudaHostAllocWriteCombined);
}

void SiPixelRawToClusterGPUKernel::WordFedAppender::initializeWordFed(int fedId, unsigned int wordCounterGPU, const cms_uint32_t *src, unsigned int length) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "FWCore/Utilities/interface/typedefs.h"
#include "HeterogeneousCore/CUDAUtilities/interface/GPUSimpleVector.h"
#include "HeterogeneousCore/CUDAUtilities/interface/host_unique_ptr.h"
#include "HeterogeneousCore/CUDAUtilities/interface/host_noncached_unique_ptr.h"
#include "DataFormats/SiPixelDigi/interface/PixelErrors.h"

struct SiPixelFedCablingMapGPU;
Expand Down Expand Up @@ -159,7 +160,7 @@ namespace pixelgpudetails {
public:
class WordFedAppender {
public:
WordFedAppender(cuda::stream_t<>& cudaStream);
WordFedAppender();
~WordFedAppender() = default;

void initializeWordFed(int fedId, unsigned int wordCounterGPU, const cms_uint32_t *src, unsigned int length);
Expand All @@ -168,8 +169,8 @@ namespace pixelgpudetails {
const unsigned char *fedId() const { return fedId_.get(); }

private:
cudautils::host::unique_ptr<unsigned int[]> word_;
cudautils::host::unique_ptr<unsigned char[]> fedId_;
cudautils::host::noncached::unique_ptr<unsigned int[]> word_;
cudautils::host::noncached::unique_ptr<unsigned char[]> fedId_;
};

SiPixelRawToClusterGPUKernel() = default;
Expand Down

0 comments on commit 3ac4c7c

Please sign in to comment.