domains.h
3.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/*
* domains.h
*
* Created on: 06/01/2017
* Author: pedro
*/
#ifndef SRC_DOMAINS_H_
#define SRC_DOMAINS_H_
// Host configuration
#ifndef __OPENCL_VERSION__
#include <stdbool.h>
#include <stddef.h>
#include <sys/types.h>
#include "CL/cl.h"
#include "CL/cl_platform.h"
// when interval domains are used
typedef cl_ushort2 interval; // [16-bits;16-bits] <-> [min,max]
// Bitmap size used on host
#ifndef BITS
#define BITS 1024
#endif
// Size of words used on host
#ifndef H_WORD
#define H_WORD 64
#endif
// host word parameters
#if H_WORD < 33
#define H_ONE 1U
#define H_DIV 5
#define H_WORD_TYPE unsigned int
#else
#define H_ONE 1ULL
#define H_DIV 6
#define H_WORD_TYPE cl_ulong
#endif
#define H_ALL_ONES ((H_WORD_TYPE) -1)
#if BITS < 33
#define H_N_WORDS 1
#define H_BITS 32
#elif BITS < 65
#if H_WORD == 64
#define H_N_WORDS 1
#else
#define H_N_WORDS 2
#endif
#define H_BITS 64
#else
#if (BITS % 64) > 0
#define H_BITS (BITS / 64 * 64 + 64)
#else
#define H_BITS (BITS / 64 * 64)
#endif
#define H_N_WORDS H_BITS / H_WORD
#endif
#if H_N_WORDS == 1
typedef H_WORD_TYPE bitmap;
#else
typedef H_WORD_TYPE bitmap[H_N_WORDS];
#endif
// never used. Just for compilation and syntax correction
#define CL_BITMAP 0
#define CL_INTERVAL 1
#define CL_D_TYPE CL_BITMAP
#define DOMAIN_ cl_bitmap
#define CL_D_MIN 0
// 32 bits 1 word
#define CL_WORD 32
#define CL_BITS 32
#define CL_D_MAX 32
#define CL_ONE_ 1U
#define CL_DIV 5
#define CL_REM 31
#define CL_N_WORDS 1
#define CL_WORD_TYPE cl_uint
typedef CL_WORD_TYPE cl_bitmap;
/*
// 64 bits 1 word
#define CL_WORD 64
#define CL_BITS 64
#define CL_D_MAX 64
#define CL_ONE_ 1UL
#define CL_DIV 6
#define CL_REM 63
#define CL_N_WORDS 1
#define CL_WORD_TYPE cl_ulong
typedef CL_WORD_TYPE cl_bitmap;
*/
/*
// 64 bits 2 words
#define CL_WORD 64
#define CL_BITS 128
#define CL_D_MAX 128
#define CL_ONE_ 1UL
#define CL_DIV 6
#define CL_REM 63
#define CL_N_WORDS 2
#define CL_WORD_TYPE cl_ulong
typedef CL_WORD_TYPE cl_bitmap[CL_N_WORDS];
*/
#define CL_ALL_ONES ((CL_WORD_TYPE) -1)
// Device configuration (used during kernel compilation)
#else
// Choose domains size on OpenCL kernel compilation
// host word parameters
#if CL_WORD < 33
#define CL_ONE_ 1U
#define CL_DIV 5
#define CL_REM 31
#define CL_WORD_TYPE uint
#else
#define CL_ONE_ 1UL
#define CL_DIV 6
#define CL_REM 63
#define CL_WORD_TYPE ulong
#endif
#define CL_ALL_ONES ((CL_WORD_TYPE) -1)
#if CL_BITS < 33
#define CL_N_WORDS 1
#elif CL_BITS < 65
#if CL_WORD == 32
#define CL_N_WORDS 2
#else
#define CL_N_WORDS 1
#endif
#else
#define CL_N_WORDS (CL_BITS / CL_WORD)
#endif
#if CL_N_WORDS == 1
typedef CL_WORD_TYPE cl_bitmap;
#else
typedef CL_WORD_TYPE cl_bitmap[CL_N_WORDS];
#endif
#define CL_BITMAP 0
#define CL_INTERVAL 1
#ifndef CL_D_TYPE
#define CL_D_TYPE CL_BITMAP
#endif
#if CL_D_TYPE == CL_BITMAP
#define DOMAIN_ cl_bitmap
#define VARS cl_var_bitmap
#define VARS_PROP cl_var_p_bitmap
#elif CL_D_TYPE == CL_INTERVAL
typedef ushort2 interval;// [16-bits;16-bits] <-> [min,max]
#define DOMAIN_ interval
#define VARS cl_var_interval
#define VARS_PROP cl_var_p_interval
#endif
#ifndef CL_D_MAX
#define CL_D_MAX 32
#endif
#ifndef CL_D_MIN
#define CL_D_MIN 0
#endif
#endif
#endif /* SRC_DOMAINS_H_ */