PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

-Mbounds, -O2 and debugging
Goto page 1, 2  Next
 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Debugging and Profiling
View previous topic :: View next topic  
Author Message
Tiago



Joined: 08 Mar 2007
Posts: 4

PostPosted: Thu Mar 08, 2007 5:42 pm    Post subject: -Mbounds, -O2 and debugging Reply with quote

Hi,

I am having unexpected results (NaN) when running a program, but these are solved by using -Mbounds at the compilation time. Removing -O2 also works fine, which I find strange as I thought that O2 was the default optimization level.
No warning or error is issued on array bounds being overun so I would like some ideas on how to debug this. The code is mostly f90 with a c function thrown in. Linux 64 (RHE 3), opteron.

Fails with:
pgcc -c -O2 -B *.f90
pgf90 -c -O2 *.c
pgf90 -o a.x *.o

Runs as expected with the following options:
-c -O2 -Mbounds
-c -Mbounds
-c

Problem2
I was having a runtime error executing the following read assignment:

real :: pa(k2,k3) # k3 = 1

read (nsurunit,'(8E12.6)') pa(1:k1,:)

until it was changed to:

read (nsurunit,'(8E12.6)') pa(1:k1,1)

The original line seems perfectly acceptable. any ideas why pgf90 was geting confused?

Cheers,
Tiago
Back to top
View user's profile
mkcolg



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

PostPosted: Fri Mar 09, 2007 2:54 pm    Post subject: Reply with quote

Hi Tiago,

For problem 1, try compiling with "-O2 -Ktrap=fp". It might shed some light where the NaNs are being generated. It is odd that it works with -Mbounds but it's most likely luck than any thing else. Also try compiling with "-O2 -gopt" and running it through the debugger.

For problem two, the code looks ok but without the full context and what the actual error is, it's very hard to tell. Can you please send a test case to PGI Customer Support at trs@prgoup.com? Also include what compiler version you're using as well as which OS you have.

Note that default optimization level is -O1 not -O2.

- Mat
Back to top
View user's profile
Tiago



Joined: 08 Mar 2007
Posts: 4

PostPosted: Fri Mar 09, 2007 5:24 pm    Post subject: Reply with quote

Hi,

Thanks for the suggestions. As you say the errors are not always consistent so it must have been up to luck.
-Ktrap=fp doesn't issue any messages either and I got a segmentation fault.
-O2 -g (-gopt ?) results in NaN and the fortran code STOPS after it runs into NaNs. Can I set an event in pgdbg if *any* variable takes the value NaN? The little matlab debugger does that.

Regarding the problem with array assigment, I was getting the following error:

PGFIO-F-252/formatted read/unit=35/operation attempted after end of file.

It is perhaps worth mention that this code has been used in many different platforms, compilers and OSs. But it had never been tested in my combination: AMD, Linux64 and PGI.

Thanks for any input,
t.
Back to top
View user's profile
mkcolg



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

PostPosted: Mon Mar 12, 2007 1:26 pm    Post subject: Reply with quote

Hi T,

Quote:
Can I set an event in pgdbg if *any* variable takes the value NaN?

No, but I'll send a feature request to our Tools Group.

I like to try an narrowing down the scope of the problem. Let's see if it's porting problem by compiling in 32-bits, "-O2 -tp k8-32" or a precision issue by compiling "-O2 -Kieee". Also, I'd like you to run your program through Valgrind to see if you have any memory problems such as uninitialized memory reads (UMR).

As for problem 2, I'm not sure why your reading past the end of the file and will most likely need to see the full code to understand what's going on. Can you please send an example to trs@pgroup.com? I'll be on a business trip the rest of week, but someone in Customer Service should be able to help.

- Mat
Back to top
View user's profile
Tiago



Joined: 08 Mar 2007
Posts: 4

PostPosted: Fri Apr 06, 2007 11:24 am    Post subject: update Reply with quote

I only just had the time to do some of the suggested test. No improvements using -Kieee but "-O2 -tp k8-32" seems to work well. It also works with -O3 but yields NaN if I use -fastsse :-(

Ok, so it seems to be a problem while generating 64 bit code. Does the suspicion of uninitialized memory reads still apply? Does anyone have other suggestions?

I still want to get it to work in 64 bit to make use of SSE2 goodies such as vectorization.

Thanks
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Debugging and Profiling 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