Skip to content

Commit 23c931a

Browse files
committed
Update User's guide “convert-a-c++-program”
1 parent 3b2d2f2 commit 23c931a

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

src/doc/users-guide/convert-a-c++-program.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,5 +157,33 @@ Sorting 10000000 integers
157157
1.468 seconds Sort succeeded.
158158
```
159159

160+
### Checking for race conditions using Cilksan
161+
162+
The Cilksan race detector can be used to check for race conditions in the parallelized quicksort code. To run Cilksan on our parallel quicksort routine, we must compile the program with Cilksan enabled and then execute the instrumented program.
163+
164+
```shell
165+
> clang++ qsort.cpp -o qsort –Og -g -fopencilk -fsanitize=cilk
166+
./qsort 10000000
167+
```
168+
169+
The Cilksan race detector will report any race conditions present in the program and verify the absence of races in a race-free program.
170+
171+
### Measuring scalability using Cilkscale
172+
173+
Cilkscale can be used to benchmark and analyze the parallelism, in terms of work and span, of an OpenCilk program. These measurements can be used to predict parallel performance on parallel processors.\
174+
\
175+
The Cilkscale visualizer tool can be used to illustrate the scalability of the quicksort program by compiling the program with the additional flag `-fcilktool=cilkscale` and then executing the program as shown below.
176+
177+
```shell
178+
> clang++ qsort.cpp -o qsort –O3 -fopencilk -fcilktool=cilkscale
179+
./qsort 10000000
180+
```
181+
160182
\
161-
One can also use the cilkscale tool to generate more detailed performance graphs.
183+
\
184+
\
185+
The plots generated by Cilkscale for the example quicksort program are shown below.
186+
187+
![Cilkscale speedup for quicksort.](/img/cilkscale-qsort-speedup.png "Quicksort speedup")
188+
189+
![Cilkscale execution time for quicksort.](/img/cilkscale-qsort-execution-time.png "Quicksort execution time")
32.1 KB
Loading

src/img/cilkscale-qsort-speedup.png

35 KB
Loading

0 commit comments

Comments
 (0)