There is no atomic minimal operation in OpenMP, also no intrinsic in Intel MIC's instruction set.
#pragmma omp critial is very insufficient in the performance.
I want to know if there is a high performance implement of atomic minimal for Intel MIC.
According to the OpenMP 4.0 Specifications (Section 2.12.6), there is a lot of fast atomic minimal operations you can do by using the
#pragma omp atomicconstruct in place of#pragma omp critical(and thereby avoid the huge overhead of its lock).Overview of the possibilities with the
#pragma omp atomicconstructLet
xbe your thread-shared variable:With
#pragma omp atomic readyou can atomically let your shared variablexbe read:With
#pragma omp atomic writeyou can atomically assign a new value to your shared variablex; the new value expression (expr) has to bex-independant:With
#pragma omp atomic updateyou can atomically update your shared variablex; in fact you can only assign a new value as a binary operation (binop) between anx-independant expression andx:With
#pragma omp atomic captureyou can atomically let your shared variablexbe read and updated (in the order you want); in factcaptureis a combination of thereadandupdateconstruct:You have short forms for
updateand thenread:And their structured-block analogs:
And you have a few short forms for
readand thenupdate:And again their structured-block analogs:
And finally you have additional
readthenupdate, which only exists in structured-block forms :In the preceding expressions:
xandvare both l-value expressions with scalar type;expris an expression with scalar type;binopis one of+,*,-,/,&,^,|,<<or>>;binop,binop=,++and--are not overloaded operators.