Error compiling file fig4.12-two-for-loops.c

Use this forum to discuss the book: Using OpenMP - Portable Shared Memory Parallel Programming, by Barbara Chapman, Gabriele Jost and Ruud van der Pas Read the viewtopic.php?f=8&t=465 for book info and to download the examples. Post your feedback about the book and examples to this forum

Error compiling file fig4.12-two-for-loops.c

Postby jpaulorio » Thu Oct 22, 2009 11:18 am

Hello, I´m getting the followin error message while trying to compile the example in file fig4.12-two-for-loops.c :

error C3052: '??_C@_0CG@JLJKIPDP@Thread?5?$CFd?5executes?5loop?5iteratio@' : variable doesn't appear in a data-sharing clause under a default(none) clause

Here follows the source code where the compiler complains:

Code: Select all
#pragma omp parallel default(none) shared(n,a,b) private(i)
{
   #pragma omp single
   printf("First for-loop: number of threads is %d\n", #ERROR HERE
             omp_get_num_threads());
   #pragma omp for schedule(runtime)
   for (i=0; i<n; i++)
   {
      printf("Thread %d executes loop iteration %d\n",
             omp_get_thread_num(),i);
      a[i] = i;
   }

   #pragma omp single
      printf("Second for-loop: number of threads is %d\n",
             omp_get_num_threads());

   #pragma omp for schedule(runtime)
   for (i=0; i<n; i++)
   {
      printf("Thread %d executes loop iteration %d\n",
             omp_get_thread_num(),i);
      b[i] = 2 * a[i];
   }
} /*-- End of parallel region --*/


I´ve already compiled some others examples successfully. Any ideas?
jpaulorio
 
Posts: 2
Joined: Thu Oct 22, 2009 11:03 am

Re: Error compiling file fig4.12-two-for-loops.c

Postby a_covar » Wed Dec 30, 2009 3:04 am

I try the code and did not show any mistakes maybe is the compiler configuration. here is the code that I used. I'm using Intel C++ compiler

#include "stdafx.h"
#include <omp.h>

int _tmain(int argc, _TCHAR* argv[])
{
long long int i;
long long int a[10000];
long long int b[10000];
long long int n = 10000;
#pragma omp parallel default(none) shared(n,a,b) private(i)
{
#pragma omp single
printf("First for-loop: number of threads is %d\n",omp_get_num_threads());
#pragma omp for schedule(runtime)
for (i=0; i<n; i++)
{
printf("Thread %d executes loop iteration %d\n",omp_get_thread_num(),i);
a[i] = i;
}

#pragma omp single
printf("Second for-loop: number of threads is %d\n",omp_get_num_threads());

#pragma omp for schedule(runtime)
for (i=0; i<n; i++)
{
printf("Thread %d executes loop iteration %d\n",
omp_get_thread_num(),i);
b[i] = 2 * a[i];
}
} /*-- End of parallel region --*/
system ("PAUSE");
return 0;
}
a_covar
 
Posts: 3
Joined: Wed Dec 30, 2009 2:14 am

Re: Error compiling file fig4.12-two-for-loops.c

Postby saif bajjali » Wed Dec 30, 2009 6:42 am

hi

there is no error in the code
saif bajjali
 
Posts: 22
Joined: Fri Dec 18, 2009 12:08 pm
Location: Jordan


Return to Using OpenMP - The Book and Examples

Who is online

Users browsing this forum: Google [Bot] and 0 guests

cron