|
| View previous topic :: View next topic |
| Author |
Message |
appleluo
Joined: 21 Nov 2012 Posts: 19
|
Posted: Wed Feb 20, 2013 2:38 pm Post subject: scalars, parallel construct and kernel construct |
|
|
I have a general question about how scalars are treated by default in a parallel construct or a kernel construct.
The OpenACC standard 1.0 says a scalar will be treated as private if it doesn't appear in a data clause for the construct or any enclosing data construct if it is not live-in or live-out.
According to the definition of PRIVATE in a parallel construct, a copy of the scalar will be created for each gang. Which means the copy of the scalar for a particular gang will be shared by the threads in that gang, right?
There is no definition of PRIVATE in a kernel construct, but there is a definition for loop construct, which says the scalar will be created for each iteration of associated loop or loops. Since kernel construct always works with loops to be useful, I consider this is an explanation of how PRIVATE is defined in kernel construct. Right?
My last question is if I have a parallel construct combined with a loop construct, what will happen to the scalar that doesn't appear in a data clause for the construct or any enclosing data construct if it is not live-in or live-out?
Thanks,
Ping |
|
| Back to top |
|
 |
mkcolg
Joined: 30 Jun 2004 Posts: 4996 Location: The Portland Group Inc.
|
Posted: Wed Feb 20, 2013 5:03 pm Post subject: |
|
|
Hi Ping,
| Quote: | | According to the definition of PRIVATE in a parallel construct, a copy of the scalar will be created for each gang. Which means the copy of the scalar for a particular gang will be shared by the threads in that gang, right? | Correct, when a "private" clause is used with a "parallel" directive, then the scalar is private to a gang but shared amongst vectors within the gang.
| Quote: | | There is no definition of PRIVATE in a kernel construct, but there is a definition for loop construct, which says the scalar will be created for each iteration of associated loop or loops. Since kernel construct always works with loops to be useful, I consider this is an explanation of how PRIVATE is defined in kernel construct. Right? | The "loop" directive can be used for both "parallel" and "kernel" so it works the same for both constructs.
| Quote: | | My last question is if I have a parallel construct combined with a loop construct, what will happen to the scalar that doesn't appear in a data clause for the construct or any enclosing data construct if it is not live-in or live-out? | It becomes a local variable within the generated kernel or an argument to the kernel. Either way, it essentially becomes private to each vector (i.e. thread). It also increases the likelihood the variable can be placed in a register file for faster access.
Hope this helps,
Mat |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2002 phpBB Group
|