Previous | Next --- Slide 12 of 83
Back to Lecture Thumbnails
czh

With this example the printed x could either be 1 or 2

qwerty

x++ isn’t atomic. This is because we have to read the value of x from memory, then add 1 to it, then store the result back in memory. Otherwise, thread 2 won’t see the updated value.

awu

@czh If the print(x) was within the lock() block, the printed value would always be 1.

vgupta22

If we were doing this sort of multithreaded approach with locks on a large vector, does the inclusion of these locks essentially invalidate the speed up seen by SIMD? Basically, is it possible to get SIMD speedup if we are accessing the same data in multiple threads?

lee

Is thread synchronization overhead time referring to the work done between the lock and unlock? is this significant?

Please log in to leave a comment.