I have a question to OpenMP. In loop parallelisation, there is the option schedule and in this, one can use static and dynamic.
What is the exact difference between them?
Here an example program:
Expand|Select|Wrap|Line Numbers
- //---------------------------------------------------------------
- #include <omp.h>
- #include <valarray>
- #define N 1000
- #define CHUNKSIZE 100
- int main() {
- int i,chunk;
- std::valarray<double> a(N);
- std::valarray<double> b(N);
- std::valarray<double> c(N);
- for(i=0; i<N; i++) a[ i ] = b[ i ] = i * 1.0;
- chunk = CHUNKSIZE;
- #pragma omp parallel shared(a,b,c,chunk) private(i) {
- #pragma omp for schedule(dynamic,chunk) nowait
- for(i=0; i<N; i++) c[ i ] = a[ i ] + b[ i ];
- }
- }
- //---------------------------------------------------------------
In tutorials is always written, the loop iterations are divided into pieces of size chunk, and than statically or dynamically assigned to threads.
What is the difference between them? If I run this program with dynamic or static, there is (apparently) no difference.
Thank you for help!