https://github.com/halide/Halide
Revision 81ad45e160dd2d4d36236247aa2835cc047b9e3d authored by Andrew Adams on 01 October 2021, 21:41:29 UTC, committed by GitHub on 01 October 2021, 21:41:29 UTC
* Reduce compiler stack usage, and grant more control over stack usage

I found some code in the wild that needs 9mb of stack to lower. It's a
pain to even diagnose the problem definitively, because it requires
plumbing platform-specific linker flags to grant more stack.

This commit:

- Reduces peak stack usage of similar code in the repo (the FFT)
- Increases the stack size for lowering and codegen to 32mb on all
platforms, using stack switching techniques. We started doing this on
Windows a while ago and it hasn't bitten us, so let's try on more
platforms.
- Gives user control over the amount of stack used for lowering and
codegen. It shouldn't be necessary except when diagnosing problems like
this in future.

Using the control I was able to determine that the correctness tests all
pass with 500k of stack, and the apps all pass with 1MB, so 32MB ought
to be enough for anybody.

I found a never-checked-in test for the mux helper which uses 10MB of
stack and really shouldn't need to, so I added that (and opened an
issue) as an example of how to grant more stack when necessary, even
though 10MB is less than our default now.

Also fixed an incorrect comment on the Block node.

* Fixes for macos

* Add test to cmake

* Fix type of temporary

* Reduce number of exprs in the mux

* Fix quadratic memory usage in new test

* Better comment

* Variable name fix

* Try giving windows a little more stack

* Clarify why we want a live Stmt in scope

* Review comments

* Check some return values

* tickle buildbots

* Fixes for arm macos

* Remove stray character

* clang-tidy had some reasonable concerns

* Comment fix

* Maybe windows needs yet more stack

Co-authored-by: Steven Johnson <srj@google.com>
1 parent 4b9f728
History
Tip revision: 81ad45e160dd2d4d36236247aa2835cc047b9e3d authored by Andrew Adams on 01 October 2021, 21:41:29 UTC
compiler stack usage improvements (#6239)
Tip revision: 81ad45e
File Mode Size
.github
apps
cmake
dependencies
doc
packaging
python_bindings
src
test
tools
tutorial
util
.clang-format -rw-r--r-- 1.4 KB
.clang-format-ignore -rw-r--r-- 265 bytes
.clang-tidy -rw-r--r-- 1.8 KB
.gitattributes -rw-r--r-- 342 bytes
.gitignore -rw-r--r-- 1.1 KB
.gitmodules -rw-r--r-- 0 bytes
CMakeLists.txt -rw-r--r-- 5.5 KB
CMakePresets.json -rw-r--r-- 5.2 KB
CODE_OF_CONDUCT.md -rw-r--r-- 3.5 KB
LICENSE.txt -rw-r--r-- 3.2 KB
Makefile -rw-r--r-- 100.8 KB
README.md -rw-r--r-- 16.5 KB
README_cmake.md -rw-r--r-- 69.3 KB
README_rungen.md -rw-r--r-- 12.1 KB
README_webassembly.md -rw-r--r-- 8.6 KB
run-clang-format.sh -rwxr-xr-x 1.4 KB
run-clang-tidy.sh -rwxr-xr-x 3.2 KB

README.md

back to top