Cleaned up, debugged. Ready for 1st release
[RBC.git] / readme.txt
1 ***Random Ball Cover (RBC)***
2 Lawrence Cayton
3 lcayton@tuebingen.mpg.de
4
5 (C) Copyright 2010, Lawrence Cayton [lcayton@tuebingen.mpg.de]
6
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20 ---------------------------------------------------------------------
21 SUMMARY
22
23 This is a C and CUDA implementation of the Random Ball Cover data
24 structure for nearest neighbor search described in
25
26 L. Cayton, A nearest neighbor data structure for graphics hardware.
27 ADMS, 2010.
28
29
30 ---------------------------------------------------------------------
31 FILES
32
33 * brute.{h,cu} -- implementation of brute force search (CPU and GPU
34 versions)
35 * defs.h -- definitions of constants and macros, including the
36 distance metric.
37 * driver.cu -- example code for using the RBC data structure.
38 * kernels.{h,cu} -- implementation of all the (device) kernel functions,
39 except those related to the scan (see sKernels below)
40 * kernelWrap.{h,cu} -- CPU wrapper code around the kernels.
41 * rbc.{h,cu} -- the core of the RBC data structure. Includes the
42 implementation of build and search algorithms.
43 * sKernel.{h,cu} -- implementation of the kernel functions related to
44 the parallel scan algorithm (used within the build method).
45 * sKernelWrap.{h,cu} -- wrappers for the kernels in sKernel.
46 * utils.{h,cu} -- misc utilities used in the code.
47 * utilsGPU.{h,cu} -- misc utilities related to the GPU.
48
49
50 ---------------------------------------------------------------------
51 COMPILATION
52
53 Type make in a shell. Requires GCC and NVCC (CUDA). The code has
54 been tested under GCC 4.4 and CUDA 3.1.
55
56
57 ---------------------------------------------------------------------
58 USE
59
60 To use the RBC data structure, you will likely need to integrate this
61 code into your own. The driver.cu file provides an example of how to
62 use the RBC implementation. To try it out, type
63 >testRBC
64 at the prompt and a list of options will be displayed. Currently, the
65 test program assumes that the input is a single binary file, which it
66 then splits into queries and a the database randomly. Clearly, such a
67 setup is only useful for testing the performance of the data
68 structure. To use the data structure in a more useful fashion, you
69 may wish to call the readData function on separate files. There is
70 also a readDataText function in the driver.cu for your convenience.
71
72 The core of the implementation is in rbc.cu and in the kernel files.
73 There is a buildRBC function and a queryRBC function which should
74 suffice for basic use of the data structure.
75
76 Currently, the kernel functions are not seriously optimized. Indeed,
77 the results appearing in the ADMS paper came from a slightly more
78 optimized version than this one. A tuned version will be available at
79 some point.
80
81
82 ---------------------------------------------------------------------
83 MISC NOTES ON THE CODE
84
85 * The code currently computes distance using the L_1 (manhattan)
86 metric. If you wish to use a different notion of distance, you must
87 modify defs.h. It is quite simple to switch to any metric that
88 operates alongs the coordinates independently (eg, any L_p metric),
89 but more complex metrics will require some aditional work. The L_2
90 metric (standard Euclidean distance) is already defined in defs.h.
91
92 * The code requires that the entire DB and query set fit into the
93 device memory.
94
95 * For the most part, device variables (ie arrays residing on the GPU)
96 begin with a lowercase d. For example, the device version of the
97 DB variable x is dx.
98
99 * The computePlan code is a bit more complex than is needed for the
100 version of the RBC search algorithm described in the paper. The
101 search algorithm described in the paper has two steps: (1) Find the
102 closest representative to the query. (2) Explore the points owned
103 by that representative (ie the s-closest points to the representative
104 in the DB). The computePlan code is more complex to make it easy
105 to try out other options. For example, one could search the points
106 owned by the *two* closest representatives to the query instead. This
107 would require only minor changes to the code, though is currently
108 untested.
109
110 * Currently the software works in single precision. If you wish to
111 switch to double precision, you must edit the defs.h file. Simply
112 uncomment the lines
113
114 typedef double real;
115 #define MAX_REAL DBL_MAX
116
117 and comment out the lines
118
119 typedef float real;
120 #define MAX_REAL FLT_MAX
121
122 Then, you must do a
123
124 make clean
125
126 followed by another make.
127
128 * This software has been tested on the following graphics cards:
129 NVIDIA GTX 285
130 NVIDIA Tesla c2050.
131
132 * This sotware has been tested under the following software setup:
133 Ubuntu 9.10 (linux)
134 gcc 4.4
135 cuda 3.1
136
137 Please share your experience getting it to work under Windows and
138 Mac OSX!
139
140 * If you are running this code on a GPU which is also driving your
141 display: A well-known issue with CUDA code in this situation is that
142 a process within the operating system will automatically kill
143 kernels that have been running for more than 5-10 seconds or so.
144 You can get around this in Linux by switching out of X-Windows (often
145 CTRL-ALT-F1 does the trick) and running the code directly from the
146 terminal.
147
148