Cilk locks

Cilk locks

I am a former GPUprogrammer and sometimes we worry about resource contention. That scenariois when two threads access the same memory at the same time. The operatng system then serializes theprocess so all advantages to parallelizingcode are lost and who programs in parallel if not for speed up? So at that point you are back to serial processing and its slowness.

Now in several places in the Programmer's Guide they talk aboutlocks and they claim that reducers are preferred over locks because with a lock you could have two threads accessing memory that is locked. Thus slowing down the system.

This seems analogous towhat I talked about in the first paragraph. Are we atalking about the same thing here? It seems so.

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

There are two issues with accessing the same location in memory that could both be classified as "resource contention" and both are concerns:

1. data races -- which we have already discussed.

2. cache contention: Even when using atomic operations to change values in memory (often a way to resolve race conditions without using locks), one core may invalidate another core's cache line. This is typically referred to as a problem with "sharing." Two cores want to "share" the cache line, but in order to maintain cache coherency (where each core sees the new value that the other core wrote), a write into a cache line will cause all other cores to lose that cache line and have to re-fetch it when they want to access that memory again. That causes serious slowdown because the cores then, as you say, serialize on a particular location in memory.

Hyperobjects solve the contention problem because no two cores are accessing the same locations in memory. And our implementation creates the different views such that no two views happen to exist on the same cache line. Basically, each view is padded out to the size of a cache line so that it won't conflict with any other.

So, the short answer is: yes, it looks like we're talking about the same thing. And, yes, hyperobjects are implemented in such a way so as not to trigger this problem.

Login to leave a comment.