a517024e9fcb6991b6d5684745cc06f236645bd8
[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 #define BLOCK_SIZE 16 //must be a power of 2
8
9 #define MAX_BS 65535 //max block size
10 #define SCAN_WIDTH 1024
11
12 // Format that the data is manipulated in:
13 typedef float real;
14 #define MAX_REAL FLT_MAX
15
16 // To switch to double precision, comment out the above
17 // 2 lines and uncomment the following two lines.
18
19 //typedef double real;
20 //#define MAX_REAL DBL_MAX
21
22 //Percentage of device mem to use
23 #define MEM_USABLE .95
24
25 #define DUMMY_IDX INT_MAX
26
27 //Row major indexing
28 #define IDX(i,j,ld) (((i)*(ld))+(j))
29
30 //increase an int to the next multiple of BLOCK_SIZE
31 #define PAD(i) ( ((i)%BLOCK_SIZE)==0 ? (i):((i)/BLOCK_SIZE)*BLOCK_SIZE+BLOCK_SIZE )
32
33 //decrease an int to the next multiple of BLOCK_SIZE
34 #define DPAD(i) ( ((i)%BLOCK_SIZE)==0 ? (i):((i)/BLOCK_SIZE)*BLOCK_SIZE )
35
36 #define MAX(i,j) ((i) > (j) ? (i) : (j))
37
38 #define MIN(i,j) ((i) < (j) ? (i) : (j))
39
40 typedef struct {
41 real *mat;
42 int r; //rows
43 int c; //cols
44 int pr; //padded rows
45 int pc; //padded cols
46 int ld; //the leading dimension (in this code, this is the same as pc)
47 } matrix;
48
49
50 typedef struct {
51 char *mat;
52 int r;
53 int c;
54 int pr;
55 int pc;
56 int ld;
57 } charMatrix;
58
59 typedef struct {
60 int *mat;
61 int r;
62 int c;
63 int pr;
64 int pc;
65 int ld;
66 } intMatrix;
67
68
69 typedef struct {
70 int numComputeSegs;
71 int normSegSize;//The number of points handled in one computation,
72 //though there will always be one leftover segment
73 //with (possibly) a different number of points.
74 int lastSegSize;//.. and this is it.
75 } memPlan;
76
77
78 typedef struct{
79 int *numGroups; //The number of groups of DB points to be examined.
80 int sNumGroups; //size of the above array.
81 int *groupCountX; //The number of elements in each group.
82 int sGroupCountX;
83 int *groupOff;
84 int sGroupOff;
85 int *qToGroup; //map from query to group #.
86 int sQToGroup;
87 int ld; //the width of memPos and groupCount (= max over numGroups)
88 } compPlan;
89 #endif