You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+57-1Lines changed: 57 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -142,6 +142,62 @@ Note that you need to define one of macros below to enable vector division:
142
142
currently no vector multiplication instructions on x86 to efficiently calculate
143
143
64-bit * 64-bit to 128-bit.
144
144
145
+
## Build instructions
146
+
147
+
libdivide has one test program and two benchmark programs which can be built using cmake and a recent C++ compiler that supports C++11 or later. Optionally ```libdivide.h``` can also be installed to ```/usr/local/include```.
148
+
149
+
```bash
150
+
cmake .
151
+
make -j
152
+
sudo make install
153
+
```
154
+
155
+
## Tester program
156
+
157
+
You can pass the **tester** program one or more of the following arguments: ```u32```, ```s32```, ```u64```, ```s64``` to test the four cases (signed, unsigned, 32-bit, or 64-bit), or run it with no arguments to test all four. The tester will verify the correctness of libdivide via a set of randomly chosen numerators and denominators, by comparing the result of libdivide's division to hardware division. It will stop with an error message as soon as it finds a discrepancy.
158
+
159
+
## Benchmark program
160
+
161
+
You can pass the **benchmark** program one or more of the following arguments: ```u16```, ```s16```, ```u32```, ```s32```, ```u64```, ```s64``` to compare libdivide's speed against hardware division. **benchmark** tests a simple function that inputs an array of random numerators and a single divisor, and returns the sum of their quotients. It tests this using both hardware division, and the various division approaches supported by libdivide, including vector division.
162
+
163
+
It will output data like this:
164
+
165
+
```bash
166
+
# system scalar scl_bf vector vec_bf gener algo
167
+
1 9.684 0.792 0.783 0.426 0.426 1.346 0
168
+
2 9.078 0.781 1.609 0.426 1.529 1.346 0
169
+
3 9.078 1.355 1.609 1.334 1.531 29.045 1
170
+
4 9.076 0.787 1.609 0.426 1.529 1.346 0
171
+
5 9.074 1.349 1.609 1.334 1.531 29.045 1
172
+
6 9.078 1.349 1.609 1.334 1.531 29.045 1
173
+
...
174
+
```
175
+
176
+
It will keep going as long as you let it, so it's best to stop it when you are happy with the denominators tested. These columns have the following significance. All times are in nanoseconds, lower is better.
177
+
178
+
```
179
+
#: The divisor that is tested
180
+
system: Hardware divide time
181
+
scalar: libdivide time, using scalar division
182
+
scl_bf: libdivide time, using scalar branchfree division
183
+
vector: libdivide time, using vector division
184
+
vec_bf: libdivide time, using vector branchfree division
185
+
gener: Time taken to generate the divider struct
186
+
algo: The algorithm used.
187
+
```
188
+
189
+
The **benchmark** program will also verify that each function returns the same value, so benchmark is valuable for its verification as well.
190
+
145
191
## Contributing
146
192
147
-
See the [Development Guide](doc/Development_Guide.md)
193
+
Although there are no individual unit tests, the supplied ```cmake``` builds do include several safety nets:
194
+
195
+
* They compile with:
196
+
* All warnings on and;
197
+
* Warnings as errors
198
+
* The CI build will build and run with sanitizers on ; these are available as part of the cmake build: ```-DCMAKE_BUILD_TYPE=Sanitize```
199
+
* The ```cmake``` and CI builds will compile and run both ```C``` and ```C++``` test programs.
200
+
201
+
Before sending in patches, build and run at least the ```tester``` and ```benchmark``` using the supplied ```cmake``` scripts on at least ```MSVC``` and ```GCC``` (or ```Clang```).
0 commit comments