OpenMP benchmark: Am I doing it right?
问题 I made a program which calculates the fibonacci sequence. I executed it with different numbers of threads (eg. 1, 2, 10) but the execution time remained almost the same (about 0.500 seconds). I'm using CodeBlocks on Ubuntu and the GNU GCC compiler. In CodeBlocks I linked the library gomp and defined the flag -fopenmp for the compiler. #include <omp.h> #include <stdio.h> #include <stdlib.h> int main() { int i, n=1000, a[n]; omp_set_num_threads(4); for(i=0; i<n; i++) { a[i] = 1 + (rand() % ( 50