OpenMP Parallel for-loop showing little performance increase
问题 I am in the process of learning how to use OpenMP in C, and as a HelloWorld exercise I am writing a program to count primes. I then parallelise this as follows: int numprimes = 0; #pragma omp parallel for reduction (+:numprimes) for (i = 1; i <= n; i++) { if (is_prime(i) == true) numprimes ++; } I compile this code using gcc -g -Wall -fopenmp -o primes primes.c -lm ( -lm for the math.h functions I am using). Then I run this code on an Intel® Core™2 Duo CPU E8400 @ 3.00GHz × 2 , and as