[Omp] Private or shared
Breshears, Clay
clay.breshears at intel.com
Tue Mar 29 10:53:33 PST 2005
Patricia -
The first slide (145 of the SC'99 presentation) is attempting to use a
SPMD model of parallelism. This uses the thread id's to divide the work
and a parallel for pragma is not needed.
Declaring variables within a parallel region automatically makes them
private to each thread. So, there is no need to explicitly declare "id"
and "x" within private clauses.
I think your second question is coming from slide 147. This is still
the SPMD model and uses the thread numbers for dividing the work. The
work-sharing slide (#148) does use a parallel for and the loop does
start with "1". This slide also uses the "reduction" clause to get
around needing the "critical" from the previous example.
I hope that helps clear things up a bit.
clay
--
Clay Breshears
Parallel Applications Engineer
Intel Parallel Applications Center
1906 Fox Drive, Champaign, IL 61820
phone: 217-403-4206
Questions about threading? Check out IDS Threading Forum.
-----Original Message-----
From: Omp-bounces at openmp.org [mailto:Omp-bounces at openmp.org] On Behalf
Of Patricia Bittencourt Sampaio
Sent: Tuesday, March 29, 2005 12:31 PM
To: Omp at openmp.org
Subject: [Omp] Private or shared
Hi to all,
I'm new to openmp and I've already take a look at
the openmp oficial site a couple of times.
I've found a presentation where at the end of it
there is an example of a program that compute PI's
value. But I couldn't understand some points of this
example.
At the first slide of this example, it's defined a
parallel region where a loop exists. However the for
directive has not been used for this loop. For my
surprise the variables "id" and "x" (which all threads
write on) is not defined as private. Actually, nothing
is defined for these variables . So it's assumed that
they're shared for default.
They're declared, however, inside the parallel
region. Is this suggests something?
Going to slide that focus on work sharing, it has
been used a for directive. Unexpectually, the variable
"i" (iteration) starts with the corresponding id of
the thread. Shouldn't it starts with 1 as the for
directive distributes the iterations among the threads
uniformily?
I'd appreciate your help.
[]'s
Patricia B. Sampaio
------------------------------------
Federal University of Rio de Janeiro
__________________________________________________
Converse com seus amigos em tempo real com o Yahoo! Messenger
http://br.download.yahoo.com/messenger/
_______________________________________________
Omp mailing list
Omp at openmp.org
http://openmp.org/mailman/listinfo/omp_openmp.org
More information about the Omp
mailing list