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