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.chpl,
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