PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

WHERE Construct in CUDA Code

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



Joined: 06 Jul 2009
Posts: 306
Location: Greenbelt, MD

PostPosted: Tue Sep 21, 2010 5:33 am    Post subject: WHERE Construct in CUDA Code Reply with quote

Simple question. I'm going to soon work on moving some code to the GPU that uses the WHERE/ELSEWHERE construct liberally (often, say, to prevent division-by-zero):
Code:
  where( QA > 0.0 )
    fQi_A = QAi / QA
  elsewhere
    fQi_A = 0.0
  endwhere

My question is, is WHERE/ELSEWHERE supported in CUDA Fortran or will I need to translate them into IF blocks? (My guess is that I'll have to since the GPUs require more explicit knowledge of program flow than this construct.)

Thanks,
Matt
Back to top
View user's profile
mkcolg



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

PostPosted: Tue Sep 21, 2010 6:10 am    Post subject: Reply with quote

Hi Matt,

The WHERE statement should work within device code. I just tried it with a simple case and it seemed fine. Though, I would avoid using it on global arrays for performance reasons.

- Mat
Back to top
View user's profile
TheMatt



Joined: 06 Jul 2009
Posts: 306
Location: Greenbelt, MD

PostPosted: Wed Sep 22, 2010 7:33 am    Post subject: Reply with quote

mkcolg wrote:
The WHERE statement should work within device code. I just tried it with a simple case and it seemed fine. Though, I would avoid using it on global arrays for performance reasons.

Sounds good, thanks.

Just out of curiosity, is there a good CUDA Fortran equivalent to WHERE someone has come up with? Say with warp-vote operators or something? WHERE is just so elegant...
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