54b0c5a3db8a37c19219aa53c9be4c8e554dc52a
[GPU.git] / Indice2D.h
1 #ifndef INDICE_2D
2 #define INDICE_2D
3
4 /*----------------------------------------------------------------------*\
5 |* Declaration *|
6 \*---------------------------------------------------------------------*/
7
8 /*--------------------------------------*\
9 |* Public *|
10 \*-------------------------------------*/
11
12 class Indice2D
13 {
14
15 /*--------------------------------------*\
16 |* Constructor *|
17 \*-------------------------------------*/
18
19 public:
20
21 /*--------------------------------------*\
22 |* Methodes *|
23 \*-------------------------------------*/
24
25 public:
26
27 /*------------------*\
28 |* tid *|
29 \*-----------------*/
30
31 __device__
32 static int tid()
33 {
34 return (threadIdx.x + (blockDim.x * blockIdx.x)) + ((threadIdx.y + (blockDim.y * blockIdx.y)) * (gridDim.x * blockDim.x));
35 }
36
37 /**
38 * output in [0,nbThreadBlock()[
39 * return threadIdx.x+blockDim.x*threadIdx.y;
40 */
41 __device__
42 static int tidLocalBlock()
43 {
44 return threadIdx.x + blockDim.x * threadIdx.y;
45 }
46
47 /**
48 * idem tidLocalBlock
49 */
50 __device__
51 static int tidBlock()
52 {
53 return threadIdx.x + blockDim.x * threadIdx.y;
54 }
55
56 /**
57 * idem tidLocalBlock
58 */
59 __device__
60 static int tidLocal()
61 {
62 return threadIdx.x + blockDim.x * threadIdx.y;
63 }
64
65 /*------------------*\
66 |* nbThread *|
67 \*-------------------*/
68
69 __device__
70 static int nbThread()
71 {
72 return (gridDim.x * gridDim.y) * (blockDim.x * blockDim.y);
73 }
74
75 __device__
76 static int nbThreadX()
77 {
78 return gridDim.x * blockDim.x;
79 }
80
81 __device__
82 static int nbThreadY()
83 {
84 return gridDim.y * blockDim.y;
85 }
86
87 __device__
88 static int nbThreadBlock()
89 {
90 return blockDim.x * blockDim.y;
91 }
92
93
94
95 /*--------------------------------------*\
96 |* Attributs *|
97 \*-------------------------------------*/
98
99 private:
100
101 };
102
103 #endif
104
105 /*----------------------------------------------------------------------*\
106 |* End *|
107 \*---------------------------------------------------------------------*/