Skip to content

Commit cabd5c6

Browse files
committed
better documentation
1 parent b9ec08a commit cabd5c6

File tree

5 files changed

+104
-38
lines changed

5 files changed

+104
-38
lines changed

README.md

+52-18
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ About
88

99
atJIT is an early-phase experiment in online autotuning.
1010

11-
The code was originally based on the [Easy::jit](https://github.com/jmmartinez/easy-just-in-time) project.
11+
The code was originally based on the Easy::jit project.
1212

1313
Prerequisites
1414
--------
@@ -23,8 +23,8 @@ Then, do the following:
2323

2424
#### Step 1
2525

26-
Install a compatible version of clang and LLVM version 6.
27-
To do this on Ubuntu 18.04, you can simply install using the following command.
26+
Install a compatible version of [clang](http://clang.llvm.org/) and [LLVM](http://llvm.org/) version 6.
27+
To do this on Ubuntu 18.04, you can simply install using the following command:
2828

2929
```bash
3030
sudo apt update
@@ -80,6 +80,17 @@ and add the flags ```-DEASY_JIT_EXAMPLE=1``` to the cmake command.
8080
To enable benchmarking, install the [google benchmark](https://github.com/google/benchmark) framework,
8181
and add the flags ```-DEASY_JIT_BENCHMARK=1 -DBENCHMARK_DIR=<path_to_google_benchmark_install>``` to the cmake command.
8282

83+
##### Regression Testing
84+
85+
The test suite (`check` target) can be run after the `install` target has been built:
86+
87+
```bash
88+
cmake --build . --target install
89+
cmake --build . --target check
90+
```
91+
92+
None of the tests should have an unexpected failure/success.
93+
8394
<!--
8495
### Docker
8596
@@ -104,17 +115,17 @@ You can use `atjitc` as if it were `clang++`, as it forwards its arguments to `c
104115
Here's an example:
105116

106117
```bash
107-
➤ install/bin/atjitc -O2 tests/simple/int_a.cpp -o int_a
118+
➤ install/bin/atjitc -Wall -O2 tests/simple/int_a.cpp -o int_a
108119
➤ ./int_a
109120
inc(4) is 5
110121
inc(5) is 6
111122
inc(6) is 7
112123
inc(7) is 8
113124
```
114125

115-
### Using atJIT inside my project
126+
### Using atJIT in my project
116127

117-
The C++ library to use atJIT is quite simple.
128+
The C++ library interface to atJIT is quite minimal.
118129
To get started, construct the driver for the autotuner:
119130

120131
```c++
@@ -126,13 +137,8 @@ To get started, construct the driver for the autotuner:
126137
}
127138
```
128139

129-
A single driver can handle the tuning of multiple functions.
140+
A single driver can handle the tuning of multiple functions, each with their own unique partial argument applications.
130141
The driver only exposes one, do-it-all, variadic method `reoptimize`.
131-
To actually "drive" the autotuning process, you should ideally call
132-
`reoptimize` before every function call.
133-
Sometimes the tuner will JIT compile a new version, or it will return
134-
an already-compiled version that needs further runtime measurements.
135-
136142
Given a tuner `AT`, `reoptimize` has the following generic usage:
137143

138144
```c++
@@ -151,32 +157,57 @@ Given a tuner `AT`, `reoptimize` has the following generic usage:
151157
Providing a runtime value will allow the JIT compiler to specialize based on the value, and [std::placeholders](https://en.cppreference.com/w/cpp/utility/functional/placeholders) (e.g., `std::placeholders::_1`) leave parameters as-is. For example:
152158

153159
```c++
154-
// returns a function computing fsub(a, 1.0)
160+
using namespace std::placeholders;
161+
162+
float fsub(float a, float b) { return a-b; }
163+
164+
int main () {
165+
tuner::ATDriver AT;
166+
167+
// returns a function computing fsub(a, 1.0)
155168
easy::FunctionWrapper<float(float)> const& decrement =
156-
AT.reoptimize(fsub, _1, 1.0);
169+
AT.reoptimize(fsub, _1, 1.0);
157170

158171
// returns a function computing fsub(0.0, b)
159172
auto const& negate = AT.reoptimize(fsub, 0.0, _1);
160173

161174
printf("dec(5) == %f\n", decrement(5));
162175
printf("neg(3) == %f\n", negate(3));
176+
// ...
163177
```
164178
165179
4. The main option for the tuner is what algorithm to use during the search. If no option is specified, the tuner currently will not perform any search.
166180
To use the random search, we would specify `tuner::AT_Random` like so:
167181
182+
```c++
183+
using namespace easy::options;
184+
185+
// returns a function equivalent to fsub(a, b)
186+
auto const& fsubJIT = AT.reoptimize(fsub, _1, _2,
187+
tuner_kind(tuner::AT_Random));
188+
189+
printf("fsubJIT(3, 2) == %f\n", fsubJIT(3.0, 2.0));
190+
```
191+
192+
#### Autotuning a Function
193+
194+
To actually *drive* the online autotuning process for some function F, you must repeatedly `reoptimize` F and call the newly returned version F' at least once. Ideally, you would ask the tuner for a reoptimized version of F before every call. For example:
195+
168196
```c++
169197
for (int i = 0; i < 100; ++i) {
170198
auto const& tunedSub7 =
171-
AT.reoptimize(fsub, _1, 7.0,
172-
easy::options::tuner_kind(tuner::AT_Random));
199+
AT.reoptimize(fsub, _1, 7.0, tuner_kind(tuner::AT_Random));
173200

174201
printf("8 - 7 == %f\n", tunedSub7(8));
175202
}
176203
```
177204
205+
Don't worry about calling `reoptimize` too often. Sometimes the tuner will JIT compile a new version, but often it will return
206+
a ready-to-go version that needs more runtime measurements to determine its quality.
207+
178208
See `doc/readme/simple_at.cpp` for the complete example we have walked through in this section.
179209
210+
180211
<!--
181212
182213
Consider the code below from a software that applies image filters on a video stream.
@@ -291,5 +322,8 @@ See file `LICENSE` at the top-level directory of this project.
291322
Acknowledgements
292323
------
293324
294-
Special thanks to Serge Guelton and Juan Manuel Martinez Caamaño for
295-
originally developing Easy::jit.
325+
Special thanks to:
326+
327+
* Hal Finkel & Michael Kruse (Argonne National Laboratory)
328+
* John Reppy (University of Chicago)
329+
* Serge Guelton & Juan Manuel Martinez Caamaño (originally developed [Easy::jit](https://github.com/jmmartinez/easy-just-in-time))

TODO.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Todos
99
- create a range/set type usable by both tuner and user.
1010
- smarter navigation of the search space
1111
- ~~JIT only when we have feedback from last version~~
12-
- integrate XGBoost
12+
- ~~integrate XGBoost~~
1313
- create a SURF tuner
1414
- running-time normalization
1515
- first thing to try is put in user-interface to specify indicators of workload for normalization

doc/readme/README.md.in

+35-14
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ About
88

99
atJIT is an early-phase experiment in online autotuning.
1010

11-
The code was originally based on the [Easy::jit](https://github.com/jmmartinez/easy-just-in-time) project.
11+
The code was originally based on the Easy::jit project.
1212

1313
Prerequisites
1414
--------
@@ -23,8 +23,8 @@ Then, do the following:
2323

2424
#### Step 1
2525

26-
Install a compatible version of clang and LLVM version 6.
27-
To do this on Ubuntu 18.04, you can simply install using the following command.
26+
Install a compatible version of [clang](http://clang.llvm.org/) and [LLVM](http://llvm.org/) version 6.
27+
To do this on Ubuntu 18.04, you can simply install using the following command:
2828

2929
```bash
3030
sudo apt update
@@ -80,6 +80,17 @@ and add the flags ```-DEASY_JIT_EXAMPLE=1``` to the cmake command.
8080
To enable benchmarking, install the [google benchmark](https://github.com/google/benchmark) framework,
8181
and add the flags ```-DEASY_JIT_BENCHMARK=1 -DBENCHMARK_DIR=<path_to_google_benchmark_install>``` to the cmake command.
8282

83+
##### Regression Testing
84+
85+
The test suite (`check` target) can be run after the `install` target has been built:
86+
87+
```bash
88+
cmake --build . --target install
89+
cmake --build . --target check
90+
```
91+
92+
None of the tests should have an unexpected failure/success.
93+
8394
<!--
8495
### Docker
8596

@@ -104,17 +115,17 @@ You can use `atjitc` as if it were `clang++`, as it forwards its arguments to `c
104115
Here's an example:
105116

106117
```bash
107-
➤ install/bin/atjitc -O2 tests/simple/int_a.cpp -o int_a
118+
➤ install/bin/atjitc -Wall -O2 tests/simple/int_a.cpp -o int_a
108119
➤ ./int_a
109120
inc(4) is 5
110121
inc(5) is 6
111122
inc(6) is 7
112123
inc(7) is 8
113124
```
114125

115-
### Using atJIT inside my project
126+
### Using atJIT in my project
116127

117-
The C++ library to use atJIT is quite simple.
128+
The C++ library interface to atJIT is quite minimal.
118129
To get started, construct the driver for the autotuner:
119130

120131
```c++
@@ -126,13 +137,8 @@ To get started, construct the driver for the autotuner:
126137
}
127138
```
128139

129-
A single driver can handle the tuning of multiple functions.
140+
A single driver can handle the tuning of multiple functions, each with their own unique partial argument applications.
130141
The driver only exposes one, do-it-all, variadic method `reoptimize`.
131-
To actually "drive" the autotuning process, you should ideally call
132-
`reoptimize` before every function call.
133-
Sometimes the tuner will JIT compile a new version, or it will return
134-
an already-compiled version that needs further runtime measurements.
135-
136142
Given a tuner `AT`, `reoptimize` has the following generic usage:
137143

138144
```c++
@@ -157,12 +163,24 @@ Providing a runtime value will allow the JIT compiler to specialize based on the
157163
4. The main option for the tuner is what algorithm to use during the search. If no option is specified, the tuner currently will not perform any search.
158164
To use the random search, we would specify `tuner::AT_Random` like so:
159165

166+
```c++
167+
</include simple_at.cpp TUNERKIND/>
168+
```
169+
170+
#### Autotuning a Function
171+
172+
To actually *drive* the online autotuning process for some function F, you must repeatedly `reoptimize` F and call the newly returned version F' at least once. Ideally, you would ask the tuner for a reoptimized version of F before every call. For example:
173+
160174
```c++
161175
</include simple_at.cpp TUNING/>
162176
```
163177

178+
Don't worry about calling `reoptimize` too often. Sometimes the tuner will JIT compile a new version, but often it will return
179+
a ready-to-go version that needs more runtime measurements to determine its quality.
180+
164181
See `doc/readme/simple_at.cpp` for the complete example we have walked through in this section.
165182

183+
166184
<!--
167185

168186
Consider the code below from a software that applies image filters on a video stream.
@@ -242,5 +260,8 @@ See file `LICENSE` at the top-level directory of this project.
242260
Acknowledgements
243261
------
244262

245-
Special thanks to Serge Guelton and Juan Manuel Martinez Caamaño for
246-
originally developing Easy::jit.
263+
Special thanks to:
264+
265+
* Hal Finkel & Michael Kruse (Argonne National Laboratory)
266+
* John Reppy (University of Chicago)
267+
* Serge Guelton & Juan Manuel Martinez Caamaño (originally developed [Easy::jit](https://github.com/jmmartinez/easy-just-in-time))

doc/readme/simple_at.cpp

+16-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
// CHECK: dec(5) == 4.0
66
// CHECK: neg(3) == -3.0
7+
// CHECK: fsubJIT(3, 2) == 1.0
78
// CHECK: 8 - 7 == 1.0
89

910

@@ -15,26 +16,36 @@
1516
using namespace std::placeholders;
1617

1718
float fsub(float a, float b) { return a-b; }
18-
// TO HERE #USAGE#
1919

2020
int main () {
2121
tuner::ATDriver AT;
22-
// INLINE FROM HERE #USAGE#
22+
2323
// returns a function computing fsub(a, 1.0)
2424
easy::FunctionWrapper<float(float)> const& decrement =
25-
AT.reoptimize(fsub, _1, 1.0);
25+
AT.reoptimize(fsub, _1, 1.0);
2626

2727
// returns a function computing fsub(0.0, b)
2828
auto const& negate = AT.reoptimize(fsub, 0.0, _1);
2929

3030
printf("dec(5) == %f\n", decrement(5));
3131
printf("neg(3) == %f\n", negate(3));
32+
// ...
3233
// TO HERE #USAGE#
34+
35+
// INLINE FROM HERE #TUNERKIND#
36+
using namespace easy::options;
37+
38+
// returns a function equivalent to fsub(a, b)
39+
auto const& fsubJIT = AT.reoptimize(fsub, _1, _2,
40+
tuner_kind(tuner::AT_Random));
41+
42+
printf("fsubJIT(3, 2) == %f\n", fsubJIT(3.0, 2.0));
43+
// TO HERE #TUNERKIND#
44+
3345
// INLINE FROM HERE #TUNING#
3446
for (int i = 0; i < 100; ++i) {
3547
auto const& tunedSub7 =
36-
AT.reoptimize(fsub, _1, 7.0,
37-
easy::options::tuner_kind(tuner::AT_Random));
48+
AT.reoptimize(fsub, _1, 7.0, tuner_kind(tuner::AT_Random));
3849

3950
printf("8 - 7 == %f\n", tunedSub7(8));
4051
}
1.44 MB
Binary file not shown.

0 commit comments

Comments
 (0)