PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

Serialize inner loop (CUDA C)

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



Joined: 02 Aug 2011
Posts: 4

PostPosted: Mon Nov 28, 2011 4:13 pm    Post subject: Serialize inner loop (CUDA C) Reply with quote

Hello,

How to make sure that inner loop in a nested for loop does not get parallelized? I tried to use "seq", but somehow compiler seems to ignore it. What is a right way to use it? A sample code is given below.

Code:

#pragma acc region
{
#pragma for independent
for ( int i =0; i <outer; i ++) {
     int temp = 0;
     for ( int y=0; y<inner ; y++) { // make this loop execute serially
          temp += array[y][i];
     }
     final[i] = temp;
}

}


Thanks!
Back to top
View user's profile
mkcolg



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

PostPosted: Mon Nov 28, 2011 4:22 pm    Post subject: Reply with quote

Hi WalS,

You can try using the "kernel" clause on the outer loop.

Quote:
#pragma for independent, kernel
for ( int i =0; i <outer; i ++) {


Though, you probably don't need the independent clause here.

Hope this helps,
Mat
Back to top
View user's profile
WalS



Joined: 02 Aug 2011
Posts: 4

PostPosted: Mon Nov 28, 2011 4:45 pm    Post subject: Reply with quote

Hi Mat,

Thanks for quick reply. I had also tried using "kernel". Still the loop is parallelized by compiler. After your suggestion, I tried it without "independent" clause, but no use.

Any other suggestions?

Thank you!
Back to top
View user's profile
mkcolg



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

PostPosted: Mon Nov 28, 2011 5:57 pm    Post subject: Reply with quote

Hi WalS,

Can you please post a reproducing example? I'll need to see the code in context to get a better idea of what's going on.

Thanks,
Mat
Back to top
View user's profile
WalS



Joined: 02 Aug 2011
Posts: 4

PostPosted: Tue Nov 29, 2011 2:09 am    Post subject: Reply with quote

Hello Mat,

It was a stupid mistake of checking wrong compiler report. It is getting compiled correctly. Sorry for the trouble. Thanks a ton!
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