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