In: Computer Science
What is the main benefit of thread synchronization? Why do you think CUDA does not allow block synchronization?
Thread Synchronization is the process of excecuting more than one threads that share the same critical resources at the same time (i.e. concurrently) in such a way that no resource conflicts happen. This is generally achieved by restricting the execution of a thread until another thread or part of it is not executed completely. This simplest example in this scenario is:
Consider two threads that share the same critical resources ( such resources which can only be used by a single process at a time). If these threads are allowed to run asynchronously (i.e. without synchronization) then they can try to access the same critical resource at the same time (as actual thread execution in CPU depends on the time slices provided by the OS and is effectively unpredictable). So, this can cause several anomalies like unpredictable and inconsistant outputs resulting in serious bugs or even system crashes or a condition called Race Condition.
So, the main benefits of thread synchronization are:
CUDA does not allow block synchronization because: