Previous | Next --- Slide 6 of 60
Back to Lecture Thumbnails
meatie

It is mentioned in lecture that we need three barriers here because there might be very fast thread, fast thread and slow thread, so we need barriers to make sure all threads are on the same page.

However, given the context of this problem, is it unlikely to have some threads running much faster than others? Since all threads are doing the same amount of work.

What are the major factors that affect threads speed? Factors I can think of are: amount of computation work and memory fetching time, any others?

regi

@meatie Generally, numerical operations are very fast compared to memory loads. Even though the work is pretty fairly distributed, a situation where a barrier might be necessary is if one thread has a cache miss when loading and must fetch memory, while another thread continually hits the cache and gets too far ahead.

rokislt10

It's an important thing to remember that in many, if not most cases memory loading is the biggest cost in computation (hundreds of cycles for each memory load). You might be able to avoid threads being faster or slower with clever memory accesses, but it's always good to have the barriers anyways.