beginner question (c++)

General OpenMP discussion

beginner question (c++)

Postby orxan_shibli » Fri Oct 07, 2011 12:52 am

Code: Select all
#include <omp.h>
#include <stdio.h>
#include <iostream>

using namespace std;

void main ()
{
   cout << "Hello parallel world from threads:" << endl;
   
   #pragma omp parallel num_threads(2)
   {
      cout << omp_get_num_threads() << endl;
   }

   cout << "Back to the sequential world." << endl;   

   cin.ignore();
}


Code result says that there is only one thread. I've checked maximum number of threads and it is 2. Any suggestion?
orxan_shibli
 
Posts: 3
Joined: Thu Oct 06, 2011 2:16 pm

Re: beginner question (c++)

Postby ftinetti » Fri Oct 07, 2011 1:56 am

Compiler and compiler options you are using?
ftinetti
 
Posts: 567
Joined: Wed Feb 10, 2010 2:44 pm

Re: beginner question (c++)

Postby orxan_shibli » Fri Oct 07, 2011 2:21 am

Using Visual Studio 2010. What exactly you mean with compiler options?
orxan_shibli
 
Posts: 3
Joined: Thu Oct 06, 2011 2:16 pm

Re: beginner question (c++)

Postby ftinetti » Fri Oct 07, 2011 3:10 am

Using Visual Studio 2010. What exactly you mean with compiler options?


I don't know VS 2010... maybe you should look at something like "project options"... I think it was discussed/described in this forum before, but I don't remember the thread, try searching... or asking in a VS 2010 forum...

HTH.
ftinetti
 
Posts: 567
Joined: Wed Feb 10, 2010 2:44 pm

Re: beginner question (c++)

Postby orxan_shibli » Fri Oct 07, 2011 3:54 am

SOLVED:

1) Right click on project (not Solution)
2) Properties
3) Configuration Properties
4) C/C++
5) Language
6) Open MP Support --> Yes

Thanks for your help!
orxan_shibli
 
Posts: 3
Joined: Thu Oct 06, 2011 2:16 pm


Return to Using OpenMP

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 13 guests