Hello Przemek --

I'm just sending a quick early response, and will look into this
further, later today.

Chapel's default call stack size is 8 MiB (see executing.rst), which is
too small to hold the array below.  So, the immediate problem is that
you are seeing call stack overflows.  Setting the stack size ulimit does
not affect our stack size.  With fifo tasking and setting the call stack
size to 9 MiB using CHPL_RT_CALL_STACK_SIZE=9m, I see the program below
run to completion.

But with CHPL_TASKS=qthreads I still see the same failure even with a 9
MiB stack size.  If I set the stack size all the way up to 32 MiB the
mprotect message goes away, but I get a segfault.  I'm not sure what
causes this yet, but I will look into it and get back to you.

greg


On Mon, 21 Mar 2016, Przemek Leśniak wrote:

The story:

As chapel learning excercise I wanted to implement parallel MergeSort which
would be faster than library version (since the library version doesn't use
parallelised merge). I noticed that running the MergeSort on 'big enough'
arrays (probably depends on architecture used, in my case 10^6 was enough),
resulted in huge wall of text consisting of messages:

...
mprotect in ALLOC_STACK (2): Cannot allocate memory
mprotect in ALLOC_STACK (1): Cannot allocate memory
..

Here is example code to force this behaviour:

use Sort;

proc main()
{
    var A : [1..1000000] int;
    MergeSort(A);
}

I guess that this happens because there are too many pre-allocated threads
which take too much of space. Solutions which didn't work:
- Reducing size of stack using ulimit, or changing the value of
- Reducing size of stack by changing the value of
CHPL_RT_NUM_THREADS_PER_LOCALE didn;t help either.
- Playing with fifo, massivethreads, qthreads didn't also help (they are
probably mapped to pthreads anyway).
Workaround which helped:
- Controlling number of tasks explicitly in the code like 
in:https://github.com/coodie/ChapelDataStructures/blob/master/MergeSort/MergeSort.chp
l, by using atomic variable which counts number of tasks, and only starting
new task when the limit hasn't been reached yet
Note that code actually sorts the array, it's just very slow due to error
handling and switching between kernel space and user space. This probably
requires some investigation in how scheduling and tasking is done in
chapel.

Note that this is just example. Starting too many tasks (in numbers of
million) in any way also produces this error. By using standard library
MergeSort in this example wanted to show that there are some bugs in it
aswell.

This bug is hard to insert into test system because this is probably
platform dependent, that's why I'm sending e-mail.

Information which will probably be useful:

chpl --version
chpl Version 1.13.0.-999
Copyright (c) 2004-2016, Cray Inc.  (See LICENSE file for more details)

$CHPL_HOME/util/printchplenv
machine info: Linux goovie-U36SG 3.13.0-37-generic #64-Ubuntu SMP Mon Sep
22 21:28:38 UTC 2014 x86_64
CHPL_HOME: /home/goovie/Dokumenty/Programowanie/chapel *
script location: /home/goovie/Dokumenty/Programowanie/chapel/util
CHPL_TARGET_PLATFORM: linux64
CHPL_TARGET_COMPILER: gnu
CHPL_TARGET_ARCH: native
CHPL_LOCALE_MODEL: flat
CHPL_COMM: none
CHPL_TASKS: qthreads
CHPL_LAUNCHER: none
CHPL_TIMERS: generic
CHPL_MEM: jemalloc
CHPL_MAKE: make
CHPL_ATOMICS: intrinsics
CHPL_GMP: gmp
CHPL_HWLOC: hwloc
CHPL_REGEXP: re2
CHPL_WIDE_POINTERS: struct
CHPL_AUX_FILESYS: none

gcc --version
gcc (Ubuntu 4.8.4-2ubuntu1~14.04.1) 4.8.4
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.



------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785351&iu=/4140
_______________________________________________
Chapel-bugs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-bugs

Reply via email to