Skip to content

Commit aeb7b32

Browse files
committed
[Odin-II]: increase Odin-II stack size to avoid stack overflows in recursive routine calls for big benchmarks
Related-issue: #2098 Signed-off-by: Seyed Alireza Damghani <[email protected]>
1 parent 0c715b6 commit aeb7b32

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

ODIN_II/main.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "odin_types.h"
33
#include "vtr_time.h"
44
#include "vtr_version.h"
5+
#include <sys/resource.h>
56

67
int main(int argc, char** argv) {
78
vtr::ScopedFinishTimer t("Odin II");
@@ -27,6 +28,19 @@ int main(int argc, char** argv) {
2728
"\n",
2829
vtr::VERSION, vtr::VCS_REVISION, vtr::BUILD_TIMESTAMP, vtr::COMPILER, vtr::BUILD_INFO);
2930

31+
/**
32+
* set stack size to >= 128 MB in linux operating systems to avoid
33+
* stack overflow in recursive routine calls for big benchmarks
34+
*/
35+
#ifdef __linux__
36+
struct rlimit rl;
37+
const rlim_t new_stack_size = 128L * 1024L * 1024L;
38+
if (getrlimit(RLIMIT_STACK, &rl) == 0 && rl.rlim_cur < new_stack_size) {
39+
rl.rlim_cur = new_stack_size;
40+
setrlimit(RLIMIT_STACK, &rl);
41+
}
42+
#endif
43+
3044
netlist_t* odin_netlist = start_odin_ii(argc, argv);
3145
terminate_odin_ii(odin_netlist);
3246
return 0;

0 commit comments

Comments
 (0)