From 9673a4da574c2e0089e604d3f998b361a739a976 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20A=2E=20Ortega?= Date: Tue, 31 Jan 2017 22:24:06 +0100 Subject: [PATCH] Use shared as default. --- src/main.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main.c b/src/main.c index f88e65a..c82a409 100644 --- a/src/main.c +++ b/src/main.c @@ -163,7 +163,7 @@ int main(int argc, char *argv[]) { goto releaseMemory; } -#pragma omp parallel shared(run, num) +#pragma omp parallel default(shared) { // Variable for sqrt of `privNum' mpz_t numRoot; @@ -172,16 +172,21 @@ int main(int argc, char *argv[]) { mpz_t privNum; mpz_init(privNum); mpz_add_ui(privNum, num, omp_get_thread_num() * 2); - /*mpz_out_str(stdout, base, privNum);*/ - /*printf("-\n");*/ #pragma omp barrier do { // Calculate the sqrt(num) mpz_sqrt(numRoot, privNum); +#pragma omp critical + { + mpz_out_str(stdout, base, numRoot); + printf(" - "); + mpz_out_str(stdout, base, privNum); + printf("\n"); + } // Make sure a number larger than numRoot exists - while(mpz_cmp(primes.list[primes.end], numRoot) <= 0) { + while(mpz_cmp(primes.list[primes.end], numRoot) < 0) { if(!run) goto leaveLoop; }