PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

Seg-fault disappears when compiling with bounds-check option

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Debugging and Profiling
View previous topic :: View next topic  
Author Message
TimStitt



Joined: 13 Jun 2009
Posts: 4
Location: Manno, Switzerland

PostPosted: Sat Jun 13, 2009 3:30 am    Post subject: Seg-fault disappears when compiling with bounds-check option Reply with quote

Hi all,

I wanted to know if anyone had a quick and simple reason why a code that seg faults consistently fails to seg fault when compiled with the check bounds compiler option (-C).

I was hoping that this approach would give some insight into the source of the error...but alas it seems to fix it for some reason.

I require high-performance with this code so I want to be able to run without the overhead of the bounds-checking.

Thanks in advance for any assistance provided.

Tim.
Back to top
View user's profile
mkcolg



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

PostPosted: Sat Jun 13, 2009 9:09 am    Post subject: Reply with quote

Hi Tim,

That is strange but does seem to point to some type of memory issue. I would recommend using Valgrind (www.valgrind.org) on your program. It's very good at finding these types of runtime memory problems and might give at least some clues to the issue.

- Mat
Back to top
View user's profile
TimStitt



Joined: 13 Jun 2009
Posts: 4
Location: Manno, Switzerland

PostPosted: Sat Jun 13, 2009 10:05 am    Post subject: Reply with quote

Hi Mat,

Unfortunately I can't do this as I work on a Cray XT5 supercomputer that doesn't support dynamic libraries, preloads etc. which Valgrind requires. I've discussed this with the developers already and they basically said Valgrind's functionality would be very limited without the above.

I do agree with you though on it being some sort of memory problem. Prior to the current state of the code I was able to highlight some places were the code was apparently giving some problems (using a debugger)...although the cause was strange to say the least.

In particular the seg faults initially were occuring at array initialisation statements of the form

A = 0 (where A is a 2D allocatable array).

The only way I could get execution past this point without seg faulting was to explicitly put in the dimension ranges as follows:

A(1:n, 1:m) =0

This happened in about 3 cases. In each case checking the allocation status indicated the arrays were created successfully. With that done the code still seg-faults but I'm not really able to identify where. I think I have just been trearting the symptoms at the moment as opposed to the cause.

I did notice though when I compile with '-C' (bounds-check) the code runs to termination successfully.

The Pathscale compiler also seg-faulted at the same locations I discussed above but by making the explicit dimension changes the code now runs to completion with or without any equivalent bounds-checking option.

Even stranger...when I compile the code with gfortran the code runs successfully to completion without any code modifications or debugging compiler options!!!

This is parallel MPI code that I am porting from a Blue Gene/L supercomputer to the Cray XT5. The developers apparently compile it on their BG/L, I assume with the IBM compiler, and don't experience any problems.

Sorry for the mini-novel but I just wanted to give you some background info in case it may spark some sort of ideas into what is happening. I'm just not sure if this a coding problem or a compiler bug.

Thanks again for any tips you can pass on to identify the source of the problem.

Thanks,

Tim.
Back to top
View user's profile
mkcolg



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

PostPosted: Mon Jun 15, 2009 2:06 pm    Post subject: Reply with quote

Hi Tim,

My best guess is that "A" isn't allocated, though not all the given information supports this guess. In the case of "A=0", if F2003 allocatable semantics are used (which I believe gfortran does by default), then A would automatically get allocated, if not already. You can try adding the PGI flag "-Mallocatable=03" to have PGI Fortran use F2003 semantics.

However, this doesn't explain why "-C" works when you use an array section. If A was not allocated, then you should get an out of bounds error.

Can you please send a snippet of the problem code to trs@pgroup.com and ask PGI customer service to forward it to me? It might help if I can see the context.

Thanks,
Mat
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
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