Determining the stacksize

Good Afternoon,

I was wondering if someone could help me: I would like to know how to determine the stacksize required for my OpenMP code.

I know that using -openmp implies -stackvar, and I know what -stackvar implies. What I would like to know is how to determine how large I should set the stacksize to avoid segmentation faults due to stack overflow. I realise trial and error is an option, but I was looking for a slightly more robust method.

In other words, is there a way to determine how much stack space a program is using at any given time?

I'm using Sun Studio Express February, operating on the x86 version of Solaris 10.

Thanks in advance,

Jon

[699 byte] By [PerryBothrona] at [2007-11-27 7:05:39]
# 1

In general, it is not possible to determine in advance how large

the stack can be. The size of the data on the stack can be data

dependent. If any of the routines are recursive, it is generally

impossible to determine the greatest depth of recursion. I wish

I could be more helpful.

Robert Corbett

rpcorbetta at 2007-7-12 18:56:53 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 2

> In general, it is not possible to determine in

> advance how large

> the stack can be. The size of the data on the stack

> can be data

> dependent. If any of the routines are recursive, it

> is generally

> impossible to determine the greatest depth of

> recursion. I wish

> I could be more helpful.

>

> Robert Corbett

Hi,

Assuming that all my arrays have a static size which I can determine at the time of execution, and there is no recursion, is it possible to determine the stack size in this simplified case?

Thanks in advance,

Jon

PerryBothrona at 2007-7-12 18:56:53 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 3
In theory, with enough restrictions, it should be possible to estimate the maximumstack space required. At the moment, Sun does not provide any tools to providesuch estimates.Robert Corbett
rpcorbetta at 2007-7-12 18:56:53 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 4

Good Afternoon,

I had previously asked how I can determine the stacksize needed for a code.

By trial and error, I found a stack size that works and cures the segmentation faults I had been encountering on Solaris 10 x86

However, when I try and port the code to the Sun Studio compilers on Linux, I get the same segmentation faults as I did before, even if I use the limit command to set the stacksize to the value I had determined for Solaris 10.

I tried increasing the stacksize (significantly) and the segmentation fault remains.

The SEGV's only occur when OpenMP is used and the code runs fine serially.

I'm using Sun Studio Express June 2007 and RHEL 4 AS Update 3.

Any advice would be appreciated.

Cheers,

Jon

PerryBothrona at 2007-7-12 18:56:53 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 5
I don't know what the difference is, but I'll forward your messageto the OpenMP team.Bob Corbett
rpcorbetta at 2007-7-12 18:56:53 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 6

If you have a test case you can share we can take a look. The compiler does issue a warning if the stack requirements become very large when generating OpenMP code. However, this is based on some default settings of the runtime library. Are you changing the stacksize settings using limit and/or the STACKSIZE env var?

Prashanth

prash_nsa at 2007-7-12 18:56:53 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 7
Hi,I don't yet have a simple test case showcasing this problem. I'll work on it though.I'm using limit to change stacksize settings.Thanks,
PerryBothrona at 2007-7-12 18:56:53 > top of Java-index,Development Tools,Solaris and Linux Development Tools...