HeterogeneousCore
CUDAUtilities
interface
EventCache.h
Go to the documentation of this file.
1
#ifndef HeterogeneousCore_CUDAUtilities_EventCache_h
2
#define HeterogeneousCore_CUDAUtilities_EventCache_h
3
4
#include <vector>
5
6
#include <cuda_runtime.h>
7
8
#include "
FWCore/Utilities/interface/ReusableObjectHolder.h
"
9
#include "
HeterogeneousCore/CUDAUtilities/interface/SharedEventPtr.h
"
10
11
class
CUDAService
;
12
13
namespace
cms
{
14
namespace
cuda
{
15
class
EventCache
{
16
public
:
17
using
BareEvent
= SharedEventPtr::element_type;
18
19
EventCache
();
20
21
// Gets a (cached) CUDA event for the current device. The event
22
// will be returned to the cache by the shared_ptr destructor. The
23
// returned event is guaranteed to be in the state where all
24
// captured work has completed, i.e. cudaEventQuery() == cudaSuccess.
25
//
26
// This function is thread safe
27
SharedEventPtr
get
();
28
29
private
:
30
friend
class ::CUDAService;
31
32
// thread safe
33
SharedEventPtr
makeOrGet
(
int
dev);
34
35
// not thread safe, intended to be called only from CUDAService destructor
36
void
clear
();
37
38
class
Deleter
{
39
public
:
40
Deleter
() =
default
;
41
Deleter
(
int
d
) :
device_
{
d
} {}
42
void
operator()
(cudaEvent_t
event
)
const
;
43
44
private
:
45
int
device_
= -1;
46
};
47
48
std::vector<edm::ReusableObjectHolder<BareEvent, Deleter>>
cache_
;
49
};
50
51
// Gets the global instance of a EventCache
52
// This function is thread safe
53
EventCache
&
getEventCache
();
54
}
// namespace cuda
55
}
// namespace cms
56
57
#endif
cms::cuda::SharedEventPtr
std::shared_ptr< std::remove_pointer_t< cudaEvent_t > > SharedEventPtr
Definition:
SharedEventPtr.h:14
cms::cuda::EventCache
Definition:
EventCache.h:15
cms::cuda::EventCache::makeOrGet
SharedEventPtr makeOrGet(int dev)
Definition:
EventCache.cc:45
cms::cuda::EventCache::cache_
std::vector< edm::ReusableObjectHolder< BareEvent, Deleter > > cache_
Definition:
EventCache.h:48
cms::cuda::EventCache::get
SharedEventPtr get()
Definition:
EventCache.cc:21
ReusableObjectHolder.h
cms::cuda::EventCache::clear
void clear()
Definition:
EventCache.cc:54
cms::cuda::EventCache::EventCache
EventCache()
Definition:
EventCache.cc:19
prod1Switch_cff.cuda
cuda
Definition:
prod1Switch_cff.py:11
cms::cuda::EventCache::Deleter::Deleter
Deleter(int d)
Definition:
EventCache.h:41
cms::cuda::EventCache::BareEvent
SharedEventPtr::element_type BareEvent
Definition:
EventCache.h:17
cms::cuda::EventCache::Deleter::device_
int device_
Definition:
EventCache.h:45
cms::cuda::EventCache::Deleter::Deleter
Deleter()=default
SharedEventPtr.h
ztail.d
d
Definition:
ztail.py:151
event
Definition:
event.py:1
CUDAService
Definition:
CUDAService.h:15
cms::cuda::EventCache::Deleter
Definition:
EventCache.h:38
cms::cuda::getEventCache
EventCache & getEventCache()
Definition:
EventCache.cc:64
cms::cuda::EventCache::Deleter::operator()
void operator()(cudaEvent_t event) const
Definition:
EventCache.cc:10
cms
Namespace of DDCMS conversion namespace.
Definition:
ProducerAnalyzer.cc:21
Generated for CMSSW Reference Manual by
1.8.16