Francisco Jesús Martínez Serrano wrote:
I'm trying to port a (big) scientific code from linux to opensolaris. All is
more or less done by now but I'm facing a strange problem with stacksize.
The small size simulations (size 1) require that i reserve (through ulimit -s)
at least ~44MB of stack, with that, the code runs fine. The size 2 simulations
are 8 times (2^3) as big and hence would need around 352 MB of stack. When I
try to set that, all i get is:
$ ulimit -s
unlimited
as if I were hitting some sort of hard limit.
I compile using the latest sun studio early release with the options:
f90 -g -fsimple=1 -xopenmp=noopt -xtarget=opteron -xarch=sse3a -m64 (debug)
f90 -fast -fsimple=1 -xopenmp -xtarget=opteron -xarch=sse3a -m64 (optimized)
My STACKSIZE environment variable is set to 1024, but setting it to 512MB makes
no difference.
Anybody knows what might be happening (beware i'm not a CS type, I just do
scientific codes)
pmap, pstack and registers follow (I've had some kind help from people at
#opensolaris):
I'm a little confused. You apparently have a multi-threaded
program. The stacksize of the threads in a multi-threaded
program isn't controlled via those limits, but through the
attributes passed to pthread_create.
There is a good discussion of this in the pthread_create
man page.
Apparently the OpenMP compiler run-time sets the stacksize
via the STACKSIZE variable:
If you're using Studio 11, the following may be helpful:
http://docs.sun.com/source/819-3694/5_compiling.html
From that page:
5.5 Stacks and Stack Sizes
The executing program maintains a main memory stack for the initial
thread executing the program, as well as distinct stacks for each slave
thread. Stacks are temporary memory address spaces used to hold
arguments and automatic variables during invocation of a subprogram or
function reference.
In general, the default main stack size is 8 megabytes. Compiling
Fortran programs with the f95 -stackvar option forces the allocation of
local variables and arrays on the stack as if they were automatic
variables. Use of -stackvar with OpenMP programs is implied with
explicitly parallelized programs because it improves the optimizer's
ability to parallelize calls in loops. (See the Fortran User's Guide for
a discussion of the -stackvar flag.) However, this may lead to stack
overflow if not enough memory is allocated for the stack.
Use the limit C-shell command, or the ulimit ksh/sh command, to display
or set the size of the main stack.
Each slave thread of an OpenMP program has its own thread stack. This
stack mimics the initial (or main) thread stack but is unique to the
thread. The thread's PRIVATE arrays and variables (local to the thread)
are allocated on the thread stack. The default size is 4 megabytes on
32-bit SPARC V8 and x86 platforms, and 8 megabytes on 64-bit SPARC V9
and x86 platforms. The size of the helper thread stack is set with the
STACKSIZE environment variable.
demo% setenv STACKSIZE 16384 <-Set thread stack size to 16 Mb (C shell)
demo$ STACKSIZE=16384 <-Same, using Bourne/Korn shell
demo$ export STACKSIZE
Finding the best stack size might have to be determined by trial and
error. If the stack size is too small for a thread to run it may cause
silent data corruption in neighboring threads, or segmentation faults.
If you are unsure about stack overflows, compile your Fortran, C, or C++
programs with the -xcheck=stkovf flag to force a segmentation fault on
stack overflow. This stops the program before any data corruption can
occur.
- Bart
--
Bart Smaalders Solaris Kernel Performance
[EMAIL PROTECTED] http://blogs.sun.com/barts
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code