CMS 3D CMS Logo

Enumerations | Functions | Variables
gpuClustering::pixelStatus Namespace Reference

Enumerations

enum  Status : uint32_t { kEmpty = 0x00, kFound = 0x01, kDuplicate = 0x03 }
 

Functions

static __device__ constexpr uint32_t getIndex (uint16_t x, uint16_t y)
 
__device__ constexpr uint32_t getShift (uint16_t x, uint16_t y)
 
__device__ constexpr Status getStatus (uint32_t const *__restrict__ status, uint16_t x, uint16_t y)
 
__device__ constexpr bool isDuplicate (uint32_t const *__restrict__ status, uint16_t x, uint16_t y)
 
__device__ constexpr void promote (uint32_t *__restrict__ status, const uint16_t x, const uint16_t y)
 

Variables

constexpr uint32_t bits = 2
 
constexpr uint32_t mask = (0x01 << bits) - 1
 
constexpr uint32_t size = pixelSizeX * pixelSizeY / valuesPerWord
 
constexpr uint32_t valuesPerWord = sizeof(uint32_t) * 8 / bits
 

Enumeration Type Documentation

◆ Status

Enumerator
kEmpty 
kFound 
kDuplicate 

Definition at line 23 of file gpuClustering.h.

Function Documentation

◆ getIndex()

static __device__ constexpr uint32_t gpuClustering::pixelStatus::getIndex ( uint16_t  x,
uint16_t  y 
)
inlinestatic

Definition at line 30 of file gpuClustering.h.

References gpuClustering::pixelSizeX, valuesPerWord, and x.

Referenced by getStatus(), and promote().

30  {
31  return (pixelSizeX * y + x) / valuesPerWord;
32  }
constexpr uint32_t valuesPerWord
Definition: gpuClustering.h:27
uint16_t *__restrict__ uint16_t const *__restrict__ x
Definition: gpuClustering.h:97
constexpr uint32_t pixelSizeX
Definition: gpuClustering.h:18
uint16_t *__restrict__ uint16_t const *__restrict__ uint16_t const *__restrict__ y
Definition: gpuClustering.h:97

◆ getShift()

__device__ constexpr uint32_t gpuClustering::pixelStatus::getShift ( uint16_t  x,
uint16_t  y 
)
inline

Definition at line 34 of file gpuClustering.h.

References valuesPerWord, and x.

Referenced by getStatus(), and promote().

34 { return (x % valuesPerWord) * 2; }
constexpr uint32_t valuesPerWord
Definition: gpuClustering.h:27
uint16_t *__restrict__ uint16_t const *__restrict__ x
Definition: gpuClustering.h:97

◆ getStatus()

__device__ constexpr Status gpuClustering::pixelStatus::getStatus ( uint32_t const *__restrict__  status,
uint16_t  x,
uint16_t  y 
)
inline

Definition at line 36 of file gpuClustering.h.

References getIndex(), getShift(), mask, edm::shift, gpuClustering::status, and x.

Referenced by isDuplicate().

36  {
37  uint32_t index = getIndex(x, y);
38  uint32_t shift = getShift(x, y);
39  return Status{(status[index] >> shift) & mask};
40  }
uint16_t *__restrict__ uint16_t const *__restrict__ x
Definition: gpuClustering.h:97
constexpr uint32_t mask
Definition: gpuClustering.h:26
uint16_t *__restrict__ uint16_t const *__restrict__ uint16_t const *__restrict__ y
Definition: gpuClustering.h:97
__shared__ uint32_t status[pixelStatusSize]
static __device__ constexpr uint32_t getIndex(uint16_t x, uint16_t y)
Definition: gpuClustering.h:30
__device__ constexpr uint32_t getShift(uint16_t x, uint16_t y)
Definition: gpuClustering.h:34
static unsigned int const shift

◆ isDuplicate()

__device__ constexpr bool gpuClustering::pixelStatus::isDuplicate ( uint32_t const *__restrict__  status,
uint16_t  x,
uint16_t  y 
)
inline

Definition at line 42 of file gpuClustering.h.

References getStatus(), kDuplicate, gpuClustering::status, and x.

42  {
43  return getStatus(status, x, y) == kDuplicate;
44  }
__device__ constexpr Status getStatus(uint32_t const *__restrict__ status, uint16_t x, uint16_t y)
Definition: gpuClustering.h:36
uint16_t *__restrict__ uint16_t const *__restrict__ x
Definition: gpuClustering.h:97
uint16_t *__restrict__ uint16_t const *__restrict__ uint16_t const *__restrict__ y
Definition: gpuClustering.h:97
__shared__ uint32_t status[pixelStatusSize]

◆ promote()

__device__ constexpr void gpuClustering::pixelStatus::promote ( uint32_t *__restrict__  status,
const uint16_t  x,
const uint16_t  y 
)
inline

Definition at line 46 of file gpuClustering.h.

References cms::cudacompat::atomicCAS(), getIndex(), getShift(), kDuplicate, kEmpty, kFound, mask, edm::shift, gpuClustering::status, and x.

46  {
47  uint32_t index = getIndex(x, y);
48  uint32_t shift = getShift(x, y);
49  uint32_t old_word = status[index];
50  uint32_t expected = old_word;
51  do {
52  expected = old_word;
53  Status old_status{(old_word >> shift) & mask};
54  if (kDuplicate == old_status) {
55  // nothing to do
56  return;
57  }
58  Status new_status = (kEmpty == old_status) ? kFound : kDuplicate;
59  uint32_t new_word = old_word | (static_cast<uint32_t>(new_status) << shift);
60  old_word = atomicCAS(&status[index], expected, new_word);
61  } while (expected != old_word);
62  }
T1 atomicCAS(T1 *address, T1 compare, T2 val)
Definition: cudaCompat.h:36
uint16_t *__restrict__ uint16_t const *__restrict__ x
Definition: gpuClustering.h:97
constexpr uint32_t mask
Definition: gpuClustering.h:26
uint16_t *__restrict__ uint16_t const *__restrict__ uint16_t const *__restrict__ y
Definition: gpuClustering.h:97
__shared__ uint32_t status[pixelStatusSize]
static __device__ constexpr uint32_t getIndex(uint16_t x, uint16_t y)
Definition: gpuClustering.h:30
__device__ constexpr uint32_t getShift(uint16_t x, uint16_t y)
Definition: gpuClustering.h:34
static unsigned int const shift

Variable Documentation

◆ bits

constexpr uint32_t gpuClustering::pixelStatus::bits = 2

Definition at line 25 of file gpuClustering.h.

◆ mask

constexpr uint32_t gpuClustering::pixelStatus::mask = (0x01 << bits) - 1

Definition at line 26 of file gpuClustering.h.

Referenced by getStatus(), and promote().

◆ size

constexpr uint32_t gpuClustering::pixelStatus::size = pixelSizeX * pixelSizeY / valuesPerWord

Definition at line 28 of file gpuClustering.h.

◆ valuesPerWord

constexpr uint32_t gpuClustering::pixelStatus::valuesPerWord = sizeof(uint32_t) * 8 / bits

Definition at line 27 of file gpuClustering.h.

Referenced by getIndex(), and getShift().