HeterogeneousCore
CUDAUtilities
interface
AtomicPairCounter.h
Go to the documentation of this file.
1
#ifndef HeterogeneousCore_CUDAUtilities_interface_AtomicPairCounter_h
2
#define HeterogeneousCore_CUDAUtilities_interface_AtomicPairCounter_h
3
4
#include <cstdint>
5
6
#include "
HeterogeneousCore/CUDAUtilities/interface/cudaCompat.h
"
7
8
namespace
cms
{
9
namespace
cuda
{
10
11
class
AtomicPairCounter
{
12
public
:
13
using
c_type
=
unsigned
long
long
int
;
14
15
AtomicPairCounter
() {}
16
AtomicPairCounter
(
c_type
i
) {
counter
.ac =
i
; }
17
18
__device__
__host__
AtomicPairCounter
&
operator=
(
c_type
i
) {
19
counter
.ac =
i
;
20
return
*
this
;
21
}
22
23
struct
Counters
{
24
uint32_t
n
;
// in a "One to Many" association is the number of "One"
25
uint32_t
m
;
// in a "One to Many" association is the total number of associations
26
};
27
28
union
Atomic2
{
29
Counters
counters
;
30
c_type
ac
;
31
};
32
33
static
constexpr
c_type
incr
= 1UL << 32;
34
35
__device__
__host__
Counters
get
()
const
{
return
counter
.counters; }
36
37
// increment n by 1 and m by i. return previous value
38
__host__
__device__
__forceinline__
Counters
add
(uint32_t
i
) {
39
c_type
c
=
i
;
40
c
+=
incr
;
41
Atomic2
ret
;
42
#ifdef __CUDA_ARCH__
43
ret
.ac =
atomicAdd
(&
counter
.ac,
c
);
44
#else
45
ret
.ac =
counter
.ac;
46
counter
.ac +=
c
;
47
#endif
48
return
ret
.counters;
49
}
50
51
private
:
52
Atomic2
counter
;
53
};
54
55
}
// namespace cuda
56
}
// namespace cms
57
58
#endif // HeterogeneousCore_CUDAUtilities_interface_AtomicPairCounter_h
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition:
runTheMatrix.py:367
counter
Definition:
counter.py:1
mps_fire.i
i
Definition:
mps_fire.py:428
cms::cuda::AtomicPairCounter::AtomicPairCounter
AtomicPairCounter(c_type i)
Definition:
AtomicPairCounter.h:16
cms::cuda::AtomicPairCounter::Counters
Definition:
AtomicPairCounter.h:23
__device__
#define __device__
Definition:
cudaCompat.h:92
cms::cuda::AtomicPairCounter::Atomic2::counters
Counters counters
Definition:
AtomicPairCounter.h:29
cms::cuda::AtomicPairCounter::get
Counters get() const
Definition:
AtomicPairCounter.h:35
cms::cuda::AtomicPairCounter::Atomic2::ac
c_type ac
Definition:
AtomicPairCounter.h:30
cms::cudacompat::atomicAdd
T1 atomicAdd(T1 *a, T2 b)
Definition:
cudaCompat.h:46
prod1Switch_cff.cuda
cuda
Definition:
prod1Switch_cff.py:11
cms::cuda::AtomicPairCounter::AtomicPairCounter
AtomicPairCounter()
Definition:
AtomicPairCounter.h:15
cms::cuda::AtomicPairCounter::Counters::m
uint32_t m
Definition:
AtomicPairCounter.h:25
cms::cuda::AtomicPairCounter
Definition:
AtomicPairCounter.h:11
__host__
#define __host__
Definition:
cudaCompat.h:91
PVValHelper::add
void add(std::map< std::string, TH1 * > &h, TH1 *hist)
Definition:
PVValidationHelpers.cc:12
createfilelist.int
int
Definition:
createfilelist.py:10
cms::cuda::AtomicPairCounter::Counters::n
uint32_t n
Definition:
AtomicPairCounter.h:24
HltBtagPostValidation_cff.c
c
Definition:
HltBtagPostValidation_cff.py:31
cms::cuda::AtomicPairCounter::operator=
AtomicPairCounter & operator=(c_type i)
Definition:
AtomicPairCounter.h:18
__forceinline__
#define __forceinline__
Definition:
cudaCompat.h:103
cms::cuda::AtomicPairCounter::counter
Atomic2 counter
Definition:
AtomicPairCounter.h:52
cms::cuda::AtomicPairCounter::c_type
unsigned long long int c_type
Definition:
AtomicPairCounter.h:13
cudaCompat.h
cms::cuda::AtomicPairCounter::Atomic2
Definition:
AtomicPairCounter.h:28
cms::cuda::AtomicPairCounter::incr
static constexpr c_type incr
Definition:
AtomicPairCounter.h:33
cms
Namespace of DDCMS conversion namespace.
Definition:
ProducerAnalyzer.cc:21
Generated for CMSSW Reference Manual by
1.8.16