Skip to content

Commit

Permalink
Update User's guide “convert-a-c++-program”
Browse files Browse the repository at this point in the history
  • Loading branch information
timkaler committed Jul 20, 2022
1 parent 3b2d2f2 commit 23c931a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src/doc/users-guide/convert-a-c++-program.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,33 @@ Sorting 10000000 integers
1.468 seconds Sort succeeded.
```

### Checking for race conditions using Cilksan

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.

```shell
> clang++ qsort.cpp -o qsort –Og -g -fopencilk -fsanitize=cilk
./qsort 10000000
```

The Cilksan race detector will report any race conditions present in the program and verify the absence of races in a race-free program.

### Measuring scalability using Cilkscale

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.\
\
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.

```shell
> clang++ qsort.cpp -o qsort –O3 -fopencilk -fcilktool=cilkscale
./qsort 10000000
```

\
One can also use the cilkscale tool to generate more detailed performance graphs.
\
\
The plots generated by Cilkscale for the example quicksort program are shown below.

![Cilkscale speedup for quicksort.](/img/cilkscale-qsort-speedup.png "Quicksort speedup")

![Cilkscale execution time for quicksort.](/img/cilkscale-qsort-execution-time.png "Quicksort execution time")
Binary file added src/img/cilkscale-qsort-execution-time.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/img/cilkscale-qsort-speedup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 23c931a

Please sign in to comment.