title: How do I prevent race condition WITHOUT using locks in C++?
body: <p>How do I prevent a race condition WITHOUT locking or using mutexes/semaphors in C++? I'm dealing with a nested for loop in which I will be setting a value in an array:</p>
  
  <pre><code>for (int i = 0; i &lt; m; ++i)
    for (int j = 0; j &lt; n; ++j)
      for (int k = 0; k &lt; o; ++k)
        array[k] += foo(...);
  </code></pre>
  
  <p>More or less, I want to deal with this so that I can ensure different threads running at the same time don't write to array[k] at the same time. Any suggestions on how to approach this?</p>
  
  <p>Edit: I am running on a Linux machine and I also have to use the Intel compiler. I will be using "icc" instead of "gcc" to compile the code.</p>