Cannot Understand the Output of OMP Program

Hi,
I ran an OMP program:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <stdio.h>
#include <omp.h>

/* gcc -fopenmp prg1.c */
void main(){
//Write  a multithreaded program that prints "hello World"
#pragma omp parallel
{

int ID = 0;
printf("hello(%d) ", ID);

printf("World(%d)\n",ID);
}
}


I am getting the following output:


./a.out
hello(0) World(0)
hello(0) World(0)
hello(0) World(0)
hello(0) World(0)
hello(0) World(0)
hello(0) World(0)
hello(0) World(0)
hello(0) World(0)
hello(0) World(0)
hello(0) World(0)
hello(0) World(0)
hello(0) World(0)


Can some body please tell mewhy its printing hello World so many times?

Zulfi.
https://www.ibm.com/developerworks/aix/library/au-aix-openmp-framework/index.html
Because without any further guidance from you, it just ran the parallelised bit of the code on every available core.
Hi,

Thanks for your good link. I have 6 enabled cores. So there are 12 threads.


God bless you.
Zulfi.
> God bless you.
Which one?
https://simple.wikipedia.org/wiki/List_of_gods_and_goddesses

Call me Poseidon - god of the 'C'.

Topic archived. No new replies allowed.