OpenMP parallel for loop, bigIntegers
2 answers
The OpenMP 4.0 specification was finalized and published a year ago. It provides that a parallel loop variable must have an integer or unsigned type, or a type or a random access pointer type or type (ยง2.6, p. 51).
So, basically no, it's impossible to create parallel for-loops with any type of variable.
+2
source to share
You can implement the planning yourself. Below is an example of using the equivalent schedule(static)
with GCC's built-in 128-bit targets.
#pragma omp parallel
{
__int128 start = omp_get_thread_num()*N/omp_get_num_threads();
__int128 finish = (omp_get_thread_num()+1)*N/omp_get_num_threads();
for(__int128 i=start; i<finish; i++) foo(i);
}
If you want an equivalent schedule(dynamic)
you can do
__int128 cnt = 0;
#pragma omp parallel
for(__int128 i=0;;) {
#pragma omp atomic capture
i = cnt++;
if(i>=N) break;
foo(i);
}
+1
source to share