Open the Code Editor
Depending on the sample code version, your source line numbers may slightly differ from the numbers provided in this tutorial.
The critical section introduced in line 141 protects the global variable from a race condition in a multithreaded application but it spawns a redundant synchronization. To resolve this issue, you may replace the critical section with an atomic operation as follows:
Recompile the Project and Check the Result
Browse to the directory where you extracted the sample code (for example,
Rebuild your target in the release mode using the make command as follows:
$ make clean
nqueens_parallelapplication is rebuilt.
System runs the
nqueens_parallel. Note that execution time reduced from 56566 ms to 14585 ms.