Does OpenMP support atomic minimum for C ++ 11? If OpenMP doesn't have a portable method: is there a way to do this using the x86 or amd64 function?
In the OpenMP specs, I didn't find anything for C ++, but the Fortran version seems to support it. See 2.8.5 v3.1 for details. For C ++, it points
binop is one of +, *, -, /, &, ^, |, <, or โ.
but for Fortran he points
intrinsic_procedure_name is one of MAX, MIN, IAND, IOR or IEOR.
If you are interested in more context: I'm looking for a way without mutex to do the following:
vector<omp_lock_t>lock; vector<int>val; #pragma omp parallel {
I know that you can calculate the minimum using the reduction algorithm. I know that there are circumstances when this greatly exceeds any approach to the atomic minimum. However, I also know that this is not the case in my situation.
EDIT: one of the options, which in my case is a bit faster:
int x = ...; int y = ...; while(y < val[x]) val[x] = y;
but this is not an atomic operation.
All new GPUs have this feature, and I skip it on the CPU. (See Atom_min for OpenCL.)