Project
Loading...
Searching...
No Matches
Array2D.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
14
15#ifndef O2_GPU_ARRAY2D_H
16#define O2_GPU_ARRAY2D_H
17
18#include "clusterFinderDefs.h"
19#include "ChargePos.h"
20
21namespace o2::gpu
22{
23
24template <typename T, typename Layout>
26{
27
28 public:
29 GPUdi() explicit AbstractArray2D(T* d) : data(d) {}
30
31 GPUdi() T& operator[](const ChargePos& p) { return data[Layout::idx(p)]; }
32 GPUdi() const T& operator[](const ChargePos& p) const { return data[Layout::idx(p)]; }
33
34 GPUdi() void safeWrite(const ChargePos& p, const T& v)
35 {
36 if (data != nullptr) {
37 (*this)[p] = v;
38 }
39 }
40
41 private:
42 T* data;
43};
44
45template <typename Grid>
47{
48 public:
49 enum {
50 Height = Grid::Height,
51 Width = Grid::Width,
53 };
54
55 GPUdi() static tpccf::SizeT idx(const ChargePos& p)
56 {
57 const tpccf::SizeT tilePad = p.gpad / Width;
58 const tpccf::SizeT tileTime = p.timePadded / Height;
59
60 const tpccf::SizeT inTilePad = p.gpad % Width;
61 const tpccf::SizeT inTileTime = p.timePadded % Height;
62
63 return (tileTime * WidthInTiles + tilePad) * (Width * Height) + inTileTime * Width + inTilePad;
64 }
65
66 GPUd() static size_t items(size_t fragmentLen)
67 {
68 return (TPC_NUM_OF_PADS + Width - 1) / Width * Width * (TPC_MAX_FRAGMENT_LEN_PADDED(fragmentLen) + Height - 1) / Height * Height;
69 }
70};
71
73{
74 public:
75 GPUdi() static tpccf::SizeT idx(const ChargePos& p)
76 {
77 return TPC_NUM_OF_PADS * p.timePadded + p.gpad;
78 }
79
80 GPUd() static size_t items(size_t fragmentLen)
81 {
82 return TPC_NUM_OF_PADS * TPC_MAX_FRAGMENT_LEN_PADDED(fragmentLen);
83 }
84};
85
86template <tpccf::SizeT S>
87struct GridSize;
88
89template <>
90struct GridSize<1> {
91 enum {
92 Width = 8,
93 Height = 8,
94 };
95};
96
97template <>
98struct GridSize<2> {
99 enum {
100 Width = 8,
101 Height = 4,
102 };
103};
104
105template <>
106struct GridSize<4> {
107 enum {
108 Width = 4,
109 Height = 4,
110 };
111};
112
113#if defined(CHARGEMAP_TILING_LAYOUT)
114template <typename T>
115using TPCMapMemoryLayout = TilingLayout<GridSize<sizeof(T)>>;
116#else
117template <typename T>
119#endif
120
121template <typename T>
123
124} // namespace o2::gpu
125
126#endif
GPUdi() T &operator[](const ChargePos &p)
Definition Array2D.h:31
GPUdi() const T &operator[](const ChargePos &p) const
Definition Array2D.h:32
GPUdi() explicit AbstractArray2D(T *d)
Definition Array2D.h:29
GPUdi() void safeWrite(const ChargePos &p
GPUdi() static tpccf
Definition Array2D.h:75
GPUd() static size_t items(size_t fragmentLen)
Definition Array2D.h:80
GPUdi() static tpccf
Definition Array2D.h:55
GPUd() static size_t items(size_t fragmentLen)
Definition Array2D.h:66
#define TPC_NUM_OF_PADS
#define TPC_MAX_FRAGMENT_LEN_PADDED(size)
const GLdouble * v
Definition glcorearb.h:832
GLboolean * data
Definition glcorearb.h:298
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
LinearLayout TPCMapMemoryLayout
Definition Array2D.h:118