mirror of
https://github.com/pytorch/pytorch.git
synced 2025-11-05 00:14:54 +08:00
Advertise USE_PRECOMPILED_HEADERS in CONTRIBUTING.md (#62827)
Summary: This option was added in https://github.com/pytorch/pytorch/issues/61940 and fits with this section's theme of improving build times. I've also changed it to a `cmake_dependent_option` instead of `FATAL_ERROR`ing for older CMake versions. Pull Request resolved: https://github.com/pytorch/pytorch/pull/62827 Reviewed By: astaff Differential Revision: D30342102 Pulled By: malfet fbshipit-source-id: 3095b44b7085aee8a884ec95cba9f8998d4442e7
This commit is contained in:
committed by
Facebook GitHub Bot
parent
011fdc3b7e
commit
f70b9ee5de
@ -241,10 +241,9 @@ option(USE_OBSERVERS "Use observers module." OFF)
|
||||
option(USE_OPENCL "Use OpenCL" OFF)
|
||||
option(USE_OPENCV "Use OpenCV" OFF)
|
||||
option(USE_OPENMP "Use OpenMP for parallel code" ON)
|
||||
option(USE_PRECOMPILED_HEADERS "Use pre-compiled headers to accelerate build. Requires cmake >= 3.16." OFF)
|
||||
if(USE_PRECOMPILED_HEADERS AND (CMAKE_VERSION VERSION_LESS "3.16"))
|
||||
message(FATAL_ERROR "Precompiled headers require cmake >= 3.16")
|
||||
endif()
|
||||
cmake_dependent_option(
|
||||
USE_PRECOMPILED_HEADERS "Use pre-compiled headers to accelerate build. Requires cmake >= 3.16." OFF
|
||||
"CMAKE_VERSION VERSION_LESS \"3.16\"" OFF)
|
||||
|
||||
option(USE_PROF "Use profiling" OFF)
|
||||
option(USE_QNNPACK "Use QNNPACK (quantized 8-bit operators)" ON)
|
||||
|
||||
@ -30,6 +30,7 @@
|
||||
- [Use Ninja](#use-ninja)
|
||||
- [Use CCache](#use-ccache)
|
||||
- [Use a faster linker](#use-a-faster-linker)
|
||||
- [Use pre-compiled headers](#use-pre-compiled-headers)
|
||||
- [C++ frontend development tips](#c-frontend-development-tips)
|
||||
- [GDB integration](#gdb-integration)
|
||||
- [CUDA development tips](#cuda-development-tips)
|
||||
@ -850,6 +851,27 @@ The easiest way to use `lld` this is download the
|
||||
ln -s /path/to/downloaded/ld.lld /usr/local/bin/ld
|
||||
```
|
||||
|
||||
#### Use pre-compiled headers
|
||||
|
||||
Sometimes there's no way of getting around rebuilding lots of files, for example
|
||||
editing `native_functions.yaml` usually means 1000+ files being rebuilt. If
|
||||
you're using CMake newer than 3.16, you can enable pre-compiled headers by
|
||||
setting `USE_PRECOMPILED_HEADERS=1` either on first setup, or in the
|
||||
`CMakeCache.txt` file.
|
||||
|
||||
```sh
|
||||
USE_PRECOMPILED_HEADERS=1 python setup.py develop
|
||||
```
|
||||
|
||||
This adds a build step where the compiler takes `<ATen/ATen.h>` and essentially
|
||||
dumps it's internal AST to a file so the compiler can avoid repeating itself for
|
||||
every `.cpp` file.
|
||||
|
||||
One caveat is that when enabled, this header gets included in every file by default.
|
||||
Which may change what code is legal, for example:
|
||||
- internal functions can never alias existing names in `<ATen/ATen.h>`
|
||||
- names in `<ATen/ATen.h>` will work even if you don't explicitly include it.
|
||||
|
||||
### C++ frontend development tips
|
||||
|
||||
We have very extensive tests in the [test/cpp/api](test/cpp/api) folder. The
|
||||
|
||||
Reference in New Issue
Block a user