diff --git a/src/doc/users-guide/convert-a-c++-program.md b/src/doc/users-guide/convert-a-c++-program.md index 524fad7a..53f526de 100644 --- a/src/doc/users-guide/convert-a-c++-program.md +++ b/src/doc/users-guide/convert-a-c++-program.md @@ -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. \ No newline at end of file +\ +\ +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") \ No newline at end of file diff --git a/src/img/cilkscale-qsort-execution-time.png b/src/img/cilkscale-qsort-execution-time.png new file mode 100644 index 00000000..bd24718d Binary files /dev/null and b/src/img/cilkscale-qsort-execution-time.png differ diff --git a/src/img/cilkscale-qsort-speedup.png b/src/img/cilkscale-qsort-speedup.png new file mode 100644 index 00000000..d4e999f7 Binary files /dev/null and b/src/img/cilkscale-qsort-speedup.png differ