OpenMP atomic memory order

I started learning OpenMP and found a directive #pragma omp atomic.

I have a basic understanding of the atomicity of C ++ 11 and know that you can pass a parameter memory_orderto the atomization method. Correct me if I am wrong, but I think that this allows you to use atomics as a synchronization point if you use memory_order_seq_cst, for example.

Some less restrictive memory order, for example memory_order_relaxed, just make sure atom operations are synchronized and visible to others. He knows nothing about other memory updates.

I would like to know what memory order is used by the OpenMP atomic directive. Will it only synchronize access to atomic or will it act as a memory synchronization point?

I assume this will be more like memory_order_relaxed, because it criticalprovides full synchronization here.

I welcome any good explanation / information. Thank.

+3
source share
1 answer

The OpenMP memory model is evolving. Up to and including OpenMP 3.1, the model is based on flash operations. They are not comparable to anything in the C ++ memory model. In short, a flash roughly corresponds to atom_thread_fence (x), where x is memory_order_seq_cst. But there is where it is not, if "the intersection of two flash sets of two flushes is empty."

OpenMP 4.0 adds the seq_cst clause and directly answers the question:

. , 1.4.4 . 20 , . , , ++ 11 C11, , memory_order_seq_cst ++ 11/C11. , , memory_order_relaxed ++ 11/C11.

(4.0 ) 1.4.4 " OpenMP" 2.12.6 " ".

+7

All Articles