PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Webinar

scalars, parallel construct and kernel construct

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Accelerator Programming
View previous topic :: View next topic  
Author Message
appleluo



Joined: 21 Nov 2012
Posts: 19

PostPosted: Wed Feb 20, 2013 2:38 pm    Post subject: scalars, parallel construct and kernel construct Reply with quote

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
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6218
Location: The Portland Group Inc.

PostPosted: Wed Feb 20, 2013 5:03 pm    Post subject: Reply with quote

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
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Accelerator Programming All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
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 © phpBB Group