CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends
cms::cuda::StreamCache Class Reference

#include <StreamCache.h>

Classes

class  Deleter
 

Public Types

using BareStream = SharedStreamPtr::element_type
 

Public Member Functions

SharedStreamPtr get ()
 
 StreamCache ()
 

Private Member Functions

void clear ()
 

Private Attributes

std::vector
< edm::ReusableObjectHolder
< BareStream, Deleter > > 
cache_
 

Friends

class ::CUDAService
 

Detailed Description

Definition at line 15 of file StreamCache.h.

Member Typedef Documentation

using cms::cuda::StreamCache::BareStream = SharedStreamPtr::element_type

Definition at line 17 of file StreamCache.h.

Constructor & Destructor Documentation

cms::cuda::StreamCache::StreamCache ( )

Definition at line 18 of file StreamCache.cc.

18 : cache_(deviceCount()) {}
int deviceCount()
Definition: deviceCount.h:10
std::vector< edm::ReusableObjectHolder< BareStream, Deleter > > cache_
Definition: StreamCache.h:41

Member Function Documentation

void cms::cuda::StreamCache::clear ( void  )
private

Definition at line 29 of file StreamCache.cc.

References cache_, and cms::cuda::deviceCount().

Referenced by CUDAService::CUDAService(), and CUDAService::~CUDAService().

29  {
30  // Reset the contents of the caches, but leave an
31  // edm::ReusableObjectHolder alive for each device. This is needed
32  // mostly for the unit tests, where the function-static
33  // StreamCache lives through multiple tests (and go through
34  // multiple shutdowns of the framework).
35  cache_.clear();
36  cache_.resize(deviceCount());
37  }
int deviceCount()
Definition: deviceCount.h:10
std::vector< edm::ReusableObjectHolder< BareStream, Deleter > > cache_
Definition: StreamCache.h:41
SharedStreamPtr cms::cuda::StreamCache::get ( )

Definition at line 20 of file StreamCache.cc.

References cache_, cudaCheck, cms::cuda::currentDevice(), and cms::cuda::stream.

Referenced by Options.Options::__getitem__(), betterConfigParser.BetterConfigParser::__updateDict(), submitPVValidationJobs.BetterConfigParser::__updateDict(), rrapi.RRApi::columns(), rrapi.RRApi::count(), rrapi.RRApi::data(), TestCUDAAnalyzerGPU::endJob(), betterConfigParser.BetterConfigParser::getCompares(), betterConfigParser.BetterConfigParser::getGeneral(), betterConfigParser.BetterConfigParser::getResultingSection(), submitPVValidationJobs.BetterConfigParser::getResultingSection(), rrapi.RRApi::report(), rrapi.RRApi::reports(), cms::cuda::impl::ScopedContextBase::ScopedContextBase(), rrapi.RRApi::tables(), rrapi.RRApi::tags(), rrapi.RRApi::templates(), TestCUDAAnalyzerGPU::TestCUDAAnalyzerGPU(), and rrapi.RRApi::workspaces().

20  {
21  const auto dev = currentDevice();
22  return cache_[dev].makeOrGet([dev]() {
23  cudaStream_t stream;
24  cudaCheck(cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking));
25  return std::unique_ptr<BareStream, Deleter>(stream, Deleter{dev});
26  });
27  }
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
std::vector< edm::ReusableObjectHolder< BareStream, Deleter > > cache_
Definition: StreamCache.h:41
#define cudaCheck(ARG,...)
Definition: cudaCheck.h:69
int currentDevice()
Definition: currentDevice.h:10

Friends And Related Function Documentation

friend class ::CUDAService
friend

Definition at line 27 of file StreamCache.h.

Member Data Documentation

std::vector<edm::ReusableObjectHolder<BareStream, Deleter> > cms::cuda::StreamCache::cache_
private

Definition at line 41 of file StreamCache.h.

Referenced by clear(), and get().