Cancel if `primes.list[i] >= numRoot'.
It has been solved!!!
This commit is contained in:
parent
b9cafadf8e
commit
a5b68282b3
21
src/main.c
21
src/main.c
@ -190,23 +190,18 @@ int main(int argc, char *argv[]) {
|
|||||||
* number we're analyzing. Also, skip `2' since we're not testing even
|
* number we're analyzing. Also, skip `2' since we're not testing even
|
||||||
* numbers.
|
* numbers.
|
||||||
*/
|
*/
|
||||||
/*for(size_t i = 1; mpz_cmp(primes.list[i], numRoot) <= 0; ++i) {
|
#pragma omp parallel
|
||||||
// If `num' is divisible by a prime then go to the next number
|
|
||||||
if(mpz_divisible_p(num, primes.list[i]) != 0) {
|
|
||||||
isPrime = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
#pragma omp parallel
|
|
||||||
{
|
{
|
||||||
#pragma omp for
|
#pragma omp for
|
||||||
for(size_t i = 1; i < primes.end; ++i) {
|
for(size_t i = 1; i < primes.end; ++i) {
|
||||||
if(mpz_divisible_p(num, primes.list[i])) {
|
if(mpz_cmp(primes.list[i], numRoot) >= 0) {
|
||||||
#pragma omp atomic write
|
#pragma omp cancel for
|
||||||
|
} else if(mpz_divisible_p(num, primes.list[i])) {
|
||||||
|
#pragma omp atomic write
|
||||||
isPrime = false;
|
isPrime = false;
|
||||||
#pragma omp cancel for
|
#pragma omp cancel for
|
||||||
}
|
}
|
||||||
#pragma omp cancellation point for
|
#pragma omp cancellation point for
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user