PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

Optimization disablement using pragmas.
Goto page 1, 2  Next
 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Accelerator Programming
View previous topic :: View next topic  
Author Message
alfvenwave



Joined: 08 Apr 2010
Posts: 78

PostPosted: Tue Aug 23, 2011 6:24 am    Post subject: Optimization disablement using pragmas. Reply with quote

Hi.

I have a piece of code which behaves differently if I turn optimization (-fast) on (infact, it crashes). I would like to be able to selectively blank out which bits of code are being optimized in order to find the offending code.

I can disable loop unrolling and vectorization using:

Code:
!pgi$r nounroll
!pgi$r novector


However there are still a bunch of optimizations I'd like to disable (I am not quite sure what some of them do):

Code:
1. FUNCTION reduction inlined
2. Memory zero idiom, loop replaced by call to __c_mzero8
3. Memory set idiom, loop replaced by call to __c_mset8
4. Memory copy idiom, array assignment replaced by call to pgf90_mcopy8
5. Copy in and copy out of X in call to Y


Can anyone tell me which are the directives to prevent these optimizations, effectively meaning that I can remove "all optimization" on a routine by routine basis?

Thanks,

Rob.
Back to top
View user's profile
mkcolg



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

PostPosted: Tue Aug 23, 2011 9:31 am    Post subject: Reply with quote

Hi Rob,

The "!pgi$r opt" directive allows you to select the optimization on a per routine basis. These are -O1 and -O2 optimizations so you can add ""!pgi$r opt 0" before the routine to disable them.

Though, these optimizations are pretty safe so I doubt they are the cause. Have you run your program through Valgrind (www.valgrind.org) and/or added diagnostic flags like -Mbounds? Not that there can't be compiler optimization bug, but more likely there is an error in the program such as a UMR or out-of-bounds error, that only causes problems when optimization is applied.

- Mat
Back to top
View user's profile
alfvenwave



Joined: 08 Apr 2010
Posts: 78

PostPosted: Wed Aug 24, 2011 3:52 am    Post subject: Reply with quote

Hi Mat,

yes I use -Mbounds, no it's not been through valgrind yet - does valgrind work on CUDA kernels? I suspect it is my code that's to blame - it's just that the module in which the problem lies is now enormous.....I'll keep you updated.

Rob.
Back to top
View user's profile
mkcolg



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

PostPosted: Wed Aug 24, 2011 8:05 am    Post subject: Reply with quote

Quote:
does valgrind work on CUDA kernels?
No, only host code.

- Mat
Back to top
View user's profile
alfvenwave



Joined: 08 Apr 2010
Posts: 78

PostPosted: Thu Aug 25, 2011 2:06 am    Post subject: Reply with quote

Not sure what'd going on here. All I have done now is to add !pgi$r opt 0 in front of every routine in a module. I haven't turned on optimization yet - so I would have thought that the effect of doing this should be no change, and just a straight compile of an unoptimized module. That's not what happens though - I get this:

Code:
bdry_find:
   8336, maxval reduction inlined
         minval reduction inlined
/tmp/pgnvdbTPed2dRjJjL.nv4(0): Warning: Olimit was exceeded on function curk4_kernel; will not perform function-scope optimization.
   To still perform function-scope optimization, use -OPT:Olimit=0 (no limit) or -OPT:Olimit=128634


then a huge scroll of:

Code:
/tmp/pgcudaforb7Ped_1oTOrn.gpu(128): Warning: Cannot tell what pointer points to, assuming global memory space


I am compiling with:

Code:
pgfortran -c foo_mod.cuf -Mpreprocess -lcurand -lcuda
-Mcuda=fastmath,ptxinfo -Mbounds -mp -Mcuda=4.0 -Minfo
-Mneginfo -Mcuda=keepbin -Mcuda=keepptx (+ some user defined pre-processor directives)


Any idea what might be going on - why it's complaining about some optimization when it should all be disabled?

Rob.
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
Goto page 1, 2  Next
Page 1 of 2

 
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