title: Updating a maximum value from multiple threads
body: <p>Is there a way to update a maximum from multiple threads using atomic operations?</p>
  
  <p>Illustrative example:</p>
  
  <pre><code>std::vector&lt;float&gt; coord_max(128);
  #pragma omp parallel for
  for (int i = 0; i &lt; limit; ++i) {
      int j = get_coord(i); // can return any value in range [0,128)
      float x = compute_value(j, i);
      #pragma omp critical (coord_max_update)
      coord_max[j] = std::max(coord_max[j], x);
  }
  </code></pre>
  
  <p>In the above case, the critical section synchronizes access to the entire vector, whereas we only need to synchronize access to each of the values independently.</p>