increase the stack size limit in the constructor
authorWerner Saar <wernsaar@googlemail.com>
Fri, 20 Nov 2015 08:23:01 +0000 (09:23 +0100)
committerWerner Saar <wernsaar@googlemail.com>
Fri, 20 Nov 2015 08:23:01 +0000 (09:23 +0100)
driver/others/memory.c

index 3d83a40..af7bd81 100644 (file)
@@ -104,6 +104,8 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include <errno.h>
 #include <linux/unistd.h>
 #include <sys/syscall.h>
+#include <sys/time.h>
+#include <sys/resource.h>
 #endif
 
 #if defined(OS_FREEBSD) || defined(OS_DARWIN)
@@ -1361,6 +1363,18 @@ void CONSTRUCTOR gotoblas_init(void) {
    gotoblas_memory_init();
 #endif
 
+#if defined(OS_LINUX)
+   struct rlimit curlimit;
+   if ( getrlimit(RLIMIT_STACK, &curlimit ) == 0 )
+   {
+       if ( curlimit.rlim_cur != curlimit.rlim_max )
+       {
+               curlimit.rlim_cur = curlimit.rlim_max;
+               setrlimit(RLIMIT_STACK, &curlimit);
+       }
+   }
+#endif
+
 #ifdef SMP
   if (blas_cpu_number == 0) blas_get_cpu_number();
 #ifdef SMP_SERVER