No data races, No need for locks, No memory contention
In this video, Charles E. Leiserson, CTO of Cilk Arts, discusses the issues of global variables and data races, and how Cilk++ hyperobjects address these.
|
Global and other non-local variables can inhibit parallelism by inducing data races. Cilk hyperobjects are an innovative construct designed to solve data race problems created by parallel accesses to global variables. Although locking can solve data races, lock contention can destroy all parallelism. Making local copies of the non-local variables can remove contention, but at the cost of restructuring program logic.
Cilk hyperobjects mitigate data races on non-local variables without the need for locks or code restructuring. Now, non-local variables may resolve differently in the individual threads of a Cilk++ parallel program, but still consistently with the serial C++ execution. Furthermore, Cilk hyperobjects are straightforward to use: Simply by declaring a global variable to be a hyperobject of the appropriate type, data races on the global variable are automatically resolved.
Related blog posts:
Are Determinacy Race Bugs Lurking in YOUR Multicore Application?
Global Variable Reconsidered