Re: Having trouble with very basic OpenMP program
- From: "Hari" <Hari@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 19 Sep 2005 07:58:01 -0700
Carl,
I am ashamed to say that, that was indeed the problem.
I now recall deleting the original project, and creating a new one. I set
the flag in the first project, and not in the second.
Thanks for your help,
Hari
"Carl Daniel [VC++ MVP]" wrote:
> Hari wrote:
> > Hello,
> >
> > I have a hello world program that uses OpenMP, and I am unable to
> > understand it's behavior.
> >
> > The code is:
> >
> > #include <iostream>
> > #include <omp.h>
> >
> > using namespace std;
> >
> > int main ()
> > {
> > cout << "Max openMP threads = " << omp_get_max_threads () << endl;
> >
> > #pragma omp parallel
> > {
> > int num = omp_get_thread_num ();
> > cout << "Hello from thread " << num << endl;
> > }
> >
> > cout << endl << "Number of threads " << omp_get_num_threads ();
> > }
> >
> > Very basic program.
> >
> > My machine is a HyperThreaded P4, and omp_get_max_threads () returns
> > 2.
> >
> > I would now expect that the parallel code segment will be run on two
> > separate threads. But it is run on only 1.
> >
> > The program output is:
> >
> > "Max OpenMP threads = 2
> > Hello from thread 0
> >
> > Number of threads 1"
> >
> > So, the parallel segment is run on only 1 thread. Can someone explain
> > this behavior, and how I can fix it?
>
> Are you compiling with VC++ 2005? Are you using the /openmp command-line
> switch (or the corresponding IDE setting)?
>
> -cd
>
>
>
.
- References:
- Re: Having trouble with very basic OpenMP program
- From: Carl Daniel [VC++ MVP]
- Re: Having trouble with very basic OpenMP program
- Prev by Date: Re: GetCurrentDirectory() in service???
- Next by Date: Re: Repost: easy include question
- Previous by thread: Re: Having trouble with very basic OpenMP program
- Next by thread: GetCurrentDirectory() in service???
- Index(es):