Blame view

src/domains.h 3.17 KB
94b2b13d   Pedro Roque   PHACT source
1
2
3
4
/*
 * domains.h
 *
 *  Created on: 06/01/2017
4d26a735   Pedro Roque   Increased recogni...
5
 *      Author: pedro
94b2b13d   Pedro Roque   PHACT source
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 */

#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]

94b2b13d   Pedro Roque   PHACT source
24
// Bitmap size used on host
4d26a735   Pedro Roque   Increased recogni...
25
#ifndef BITS
94b2b13d   Pedro Roque   PHACT source
26
27
#define BITS 1024
#endif
94b2b13d   Pedro Roque   PHACT source
28

4d26a735   Pedro Roque   Increased recogni...
29
// Size of words used on host
94b2b13d   Pedro Roque   PHACT source
30
31
32
33
#ifndef H_WORD
#define H_WORD 64
#endif

4d26a735   Pedro Roque   Increased recogni...
34
35
36
// host word parameters
#if H_WORD < 33
#define H_ONE 1U
94b2b13d   Pedro Roque   PHACT source
37
#define H_DIV 5
4d26a735   Pedro Roque   Increased recogni...
38
39
40
#define H_WORD_TYPE unsigned int
#else
#define H_ONE 1ULL
94b2b13d   Pedro Roque   PHACT source
41
42
#define H_DIV 6
#define H_WORD_TYPE cl_ulong
4d26a735   Pedro Roque   Increased recogni...
43
#endif
94b2b13d   Pedro Roque   PHACT source
44
45

#define H_ALL_ONES ((H_WORD_TYPE) -1)
4d26a735   Pedro Roque   Increased recogni...
46
47

#if BITS < 33
94b2b13d   Pedro Roque   PHACT source
48
#define H_N_WORDS 1
4d26a735   Pedro Roque   Increased recogni...
49
50
#define H_BITS 32
#elif BITS < 65
94b2b13d   Pedro Roque   PHACT source
51
	#if H_WORD == 64
4d26a735   Pedro Roque   Increased recogni...
52
53
54
55
56
57
58
59
60
61
	#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)
94b2b13d   Pedro Roque   PHACT source
62
63
64
	#endif
#define H_N_WORDS H_BITS / H_WORD
#endif
4d26a735   Pedro Roque   Increased recogni...
65

94b2b13d   Pedro Roque   PHACT source
66
#if H_N_WORDS == 1
4d26a735   Pedro Roque   Increased recogni...
67
typedef H_WORD_TYPE bitmap;
94b2b13d   Pedro Roque   PHACT source
68
69
#else
typedef H_WORD_TYPE bitmap[H_N_WORDS];
94b2b13d   Pedro Roque   PHACT source
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#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
4d26a735   Pedro Roque   Increased recogni...
89
90
91
92
93
94
95
96
97
98
99
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
94b2b13d   Pedro Roque   PHACT source
100
#define CL_WORD_TYPE cl_ulong
4d26a735   Pedro Roque   Increased recogni...
101
102
103
104
105
106
107
108
109
110
111
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
94b2b13d   Pedro Roque   PHACT source
112
113
114
#define CL_WORD_TYPE cl_ulong
typedef CL_WORD_TYPE cl_bitmap[CL_N_WORDS];
*/
94b2b13d   Pedro Roque   PHACT source
115
116
117
118
119
120

#define CL_ALL_ONES ((CL_WORD_TYPE) -1)


// Device configuration (used during kernel compilation)
#else
4d26a735   Pedro Roque   Increased recogni...
121
122
123
124

// Choose domains size on OpenCL kernel compilation
// host word parameters
#if CL_WORD < 33
94b2b13d   Pedro Roque   PHACT source
125
#define CL_ONE_ 1U
4d26a735   Pedro Roque   Increased recogni...
126
127
128
129
#define CL_DIV 5
#define CL_REM 31
#define CL_WORD_TYPE uint
#else
94b2b13d   Pedro Roque   PHACT source
130
131
#define CL_ONE_ 1UL
#define CL_DIV 6
4d26a735   Pedro Roque   Increased recogni...
132
#define CL_REM 63
94b2b13d   Pedro Roque   PHACT source
133
134
#define CL_WORD_TYPE ulong
#endif
4d26a735   Pedro Roque   Increased recogni...
135

94b2b13d   Pedro Roque   PHACT source
136
#define CL_ALL_ONES ((CL_WORD_TYPE) -1)
4d26a735   Pedro Roque   Increased recogni...
137
138

#if CL_BITS < 33
94b2b13d   Pedro Roque   PHACT source
139
#define CL_N_WORDS 1
4d26a735   Pedro Roque   Increased recogni...
140
141
142
143
#elif CL_BITS < 65
	#if CL_WORD == 32
	#define CL_N_WORDS 2
	#else
94b2b13d   Pedro Roque   PHACT source
144
145
146
	#define CL_N_WORDS 1
	#endif
#else
4d26a735   Pedro Roque   Increased recogni...
147
#define CL_N_WORDS (CL_BITS / CL_WORD)
94b2b13d   Pedro Roque   PHACT source
148
#endif
4d26a735   Pedro Roque   Increased recogni...
149

94b2b13d   Pedro Roque   PHACT source
150
151
#if CL_N_WORDS == 1
typedef CL_WORD_TYPE cl_bitmap;
4d26a735   Pedro Roque   Increased recogni...
152
153
154
#else
typedef CL_WORD_TYPE cl_bitmap[CL_N_WORDS];
#endif
94b2b13d   Pedro Roque   PHACT source
155

4d26a735   Pedro Roque   Increased recogni...
156
#define CL_BITMAP 0
94b2b13d   Pedro Roque   PHACT source
157
158
159
160
#define CL_INTERVAL 1

#ifndef CL_D_TYPE
#define CL_D_TYPE CL_BITMAP
4d26a735   Pedro Roque   Increased recogni...
161
#endif
94b2b13d   Pedro Roque   PHACT source
162
163
164

#if CL_D_TYPE == CL_BITMAP
#define DOMAIN_ cl_bitmap
4d26a735   Pedro Roque   Increased recogni...
165
166
#define VARS cl_var_bitmap
#define VARS_PROP cl_var_p_bitmap
94b2b13d   Pedro Roque   PHACT source
167
168
169
170
171
#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
4d26a735   Pedro Roque   Increased recogni...
172
#endif
94b2b13d   Pedro Roque   PHACT source
173
174
175
176

#ifndef CL_D_MAX
#define CL_D_MAX 32
#endif
4d26a735   Pedro Roque   Increased recogni...
177

94b2b13d   Pedro Roque   PHACT source
178
179
180
181
182
183
184
#ifndef CL_D_MIN
#define CL_D_MIN 0
#endif

#endif

#endif /* SRC_DOMAINS_H_ */