Browse Source

Take default stack size from rlimit before using a default of 8192

Samuel Thibault 10 years ago
parent
commit
85a2bc6b69
1 changed files with 7 additions and 1 deletions
  1. 7 1
      src/core/simgrid.c

+ 7 - 1
src/core/simgrid.c

@@ -27,6 +27,7 @@
 #ifdef STARPU_SIMGRID
 #include <msg/msg.h>
 #include <smpi/smpif.h>
+#include <sys/resource.h>
 
 #define STARPU_MPI_AS_PREFIX "StarPU-MPI"
 
@@ -178,7 +179,12 @@ int main(int argc, char **argv)
 #endif
 	/* Simgrid uses tiny stacks by default.  This comes unexpected to our users.  */
 	extern xbt_cfg_t _sg_cfg_set;
-	xbt_cfg_set_int(_sg_cfg_set, "contexts/stack_size", 8192);
+	unsigned stack_size = 8192;
+	struct rlimit rlim;
+	if (getrlimit(RLIMIT_STACK, &rlim) == 0 && rlim.rlim_cur != 0 && rlim.rlim_cur != RLIM_INFINITY)
+		stack_size = rlim.rlim_cur / 1024;
+
+	xbt_cfg_set_int(_sg_cfg_set, "contexts/stack_size", stack_size);
 
 	/* Load XML platform */
 	_starpu_simgrid_get_platform_path(path, sizeof(path));