updated text files
[RBC.git] / defs.h
1 #ifndef DEFS_H
2 #define DEFS_H
3
4 #include<float.h>
5 #include<stdint.h>
6
7 #define FLOAT_TOL 1e-7
8
9 #define KMAX 32 //Internal parameter. Do not change!
10 #define BLOCK_SIZE 16 //must be a power of 2 (current
11 // implementation of findRange requires a power of 4, in fact)
12
13 #define MAX_BS 65535 //max block size (specified by CUDA)
14 #define SCAN_WIDTH 1024
15
16 #define MEM_USED_IN_SCAN(n) ( 2*( (n) + SCAN_WIDTH-1 )/SCAN_WIDTH*sizeof(unint))
17
18 //The distance measure that is used. This macro returns the
19 //distance for a single coordinate.
20 //#define DIST(i,j) ( fabs((i)-(j)) ) // L_1
21 #define DIST(i,j) ( ( (i)-(j) )*( (i)-(j) ) ) // L_2
22
23 // Format that the data is manipulated in:
24 typedef float real;
25 #define MAX_REAL FLT_MAX
26
27 // To switch to double precision, comment out the above
28 // 2 lines and uncomment the following two lines.
29
30 //typedef double real;
31 //#define MAX_REAL DBL_MAX
32
33 //Percentage of device mem to use
34 #define MEM_USABLE .95
35
36 #define DUMMY_IDX UINT_MAX
37
38 //Row major indexing
39 #define IDX(i,j,ld) (((size_t)(i)*(ld))+(j))
40
41 //increase an int to the next multiple of BLOCK_SIZE
42 #define PAD(i) ( ((i)%BLOCK_SIZE)==0 ? (i):((i)/BLOCK_SIZE)*BLOCK_SIZE+BLOCK_SIZE )
43
44 //decrease an int to the next multiple of BLOCK_SIZE
45 #define DPAD(i) ( ((i)%BLOCK_SIZE)==0 ? (i):((i)/BLOCK_SIZE)*BLOCK_SIZE )
46
47 #define MAX(i,j) ((i) > (j) ? (i) : (j))
48 #define MIN(i,j) ((i) <= (j) ? (i) : (j))
49 #define MAXi(i,j,k,l) ((i) > (j) ? (k) : (l)) //indexed version
50 #define MINi(i,j,k,l) ((i) <= (j) ? (k) : (l))
51
52
53 typedef uint32_t unint;
54
55
56 typedef struct {
57 real *mat;
58 unint r; //rows
59 unint c; //cols
60 unint pr; //padded rows
61 unint pc; //padded cols
62 unint ld; //the leading dimension (in this code, this is the same as pc)
63 } matrix;
64
65
66 typedef struct {
67 char *mat;
68 unint r;
69 unint c;
70 unint pr;
71 unint pc;
72 unint ld;
73 } charMatrix;
74
75
76 typedef struct {
77 unint *mat;
78 unint r;
79 unint c;
80 unint pr;
81 unint pc;
82 unint ld;
83 } intMatrix;
84
85
86 typedef struct{
87 unint *numGroups; //The number of groups of DB points to be examined.
88 unint *groupCountX; //The number of elements in each DB group.
89 unint *qToQGroup; //map from query to query group #.
90 unint *qGroupToXGroup; //map from query group to DB gruop
91 unint ld; //the width of memPos and groupCount (= max over numGroups)
92 } compPlan;
93
94
95 typedef struct {
96 matrix dx;
97 intMatrix dxMap;
98 matrix dr;
99 unint *groupCount;
100 } rbcStruct;
101
102 #endif