Skip to content

Commit 7ff79c9

Browse files
authored
Merge branch 'develop' into fix_dataloader_memory_leak
2 parents 28f6253 + 3fd34a0 commit 7ff79c9

File tree

1,727 files changed

+85691
-24561
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,727 files changed

+85691
-24561
lines changed

AUTHORS.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
| Github account | name |
22
|---|---|
33
| abhinavarora | Abhinav Arora |
4+
| andreazanetti | Andrea Zanetti |
5+
| arlesniak | Artur Lesniak |
6+
| arogowie-intel | Adam Osewski |
47
| backyes | Yan-Fei Wang |
58
| baiyfbupt | Yi-Fan Bai |
69
| beckett1124 | Bin Qi |
710
| ChengduoZH | Cheng-Duo Zhao|
811
| chengxiaohua1105 | Xiao-Hua Cheng |
912
| cxwangyi, yiwangbaidu, wangkuiyi | Yi Wang |
1013
| cxysteven | Xing-Yi Cheng |
14+
| ddokupil | Dariusz Dokupil |
1115
| dzhwinter | Zhi-Hong Dong |
1216
| dragonwarrior | Long Wang |
1317
| dyning | Yuning Du |
@@ -21,6 +25,7 @@
2125
| hedaoyuan | Dao-Yuan He |
2226
| helinwang | He-Lin Wang |
2327
| jacquesqiao | Long-Fei Qiao |
28+
| jakpiase | Jakub Piasecki |
2429
| [jczaja](https://raw.githubusercontent.com/jczaja/Paddle/paddle-poland-team/doc/images/paddle_poland_team.jpg) | Jacek Czaja |
2530
| JiayiFeng | Jia-Yi Feng |
2631
| kbinias | Krzysztof Binias |
@@ -42,6 +47,7 @@
4247
| pakchoi | Chuan-Jiang Song |
4348
| panyx0718 | Xin Pan |
4449
| pengli09 | Peng Li |
50+
| pmajchrzak |Piotr Majchrzak |
4551
| pkuyym | Ya-Ming Yang |
4652
| pzelazko-intel | Pawel Zelazko |
4753
| [pawelpiotrowicz](https://raw.githubusercontent.com/jczaja/Paddle/paddle-poland-team/doc/images/paddle_poland_team.jpg) | Pawel Piotrowicz |
@@ -72,3 +78,6 @@
7278
| zhaopu7 | Pu Zhao |
7379
| zhouxiao-coder | Xiao Zhou |
7480
| Zrachel | Rui-Qing Zhang |
81+
| jeng1220 | Bai-Cheng(Ryan) Jeng (NVIDIA) |
82+
| mingxu1067 | Ming Huang (NVIDIA) |
83+
| zlsh80826 | Reese Wang (NVIDIA) |

CMakeLists.txt

Lines changed: 54 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,27 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License
1414

15-
cmake_minimum_required(VERSION 3.10)
16-
cmake_policy(VERSION 3.10)
15+
if(APPLE AND WITH_ARM)
16+
# cmake 3.19.2 version starts to support M1
17+
cmake_minimum_required(VERSION 3.19.2)
18+
cmake_policy(VERSION 3.19.2)
19+
else(APPLE AND WITH_ARM)
20+
cmake_minimum_required(VERSION 3.10)
21+
cmake_policy(VERSION 3.10)
22+
endif(APPLE AND WITH_ARM)
1723
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
1824
set(PADDLE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
1925
set(PADDLE_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
2026

2127
include(system)
2228

29+
# Note(zhouwei): Ninja Generator will set CMAKE_BUILD_TYPE to Debug
30+
if(NOT CMAKE_BUILD_TYPE)
31+
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
32+
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel"
33+
FORCE)
34+
endif()
35+
2336
project(paddle CXX C)
2437

2538
# enable language CUDA
@@ -66,6 +79,11 @@ if(WITH_MUSL)
6679
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=deprecated-declarations -Wno-deprecated-declarations -Wno-error=pessimizing-move -Wno-error=deprecated-copy")
6780
endif()
6881

82+
if(APPLE AND WITH_ARM)
83+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -target arm64-apple-darwin")
84+
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -target arm64-apple-darwin")
85+
endif()
86+
6987
if(WITH_ASCEND_CL AND NOT WITH_ASCEND_CXX11)
7088
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
7189
endif()
@@ -90,10 +108,6 @@ if(WIN32)
90108

91109
if (MSVC_STATIC_CRT)
92110
message(STATUS "Use static C runtime time, refer to https://docs.microsoft.com/en-us/cpp/c-runtime-library/crt-library-features?view=vs-2019")
93-
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
94-
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
95-
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
96-
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
97111
foreach(flag_var
98112
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
99113
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO
@@ -105,9 +119,7 @@ if(WIN32)
105119
endforeach(flag_var)
106120
endif()
107121

108-
# NOTE(zhouwei25): temporarily change MP to 1 for reducing CPU & memory utilization
109-
set(PROCESS_MAX 1)
110-
#math(EXPR PROCESS_MAX "${CPU_CORES} * 1 / 2")
122+
math(EXPR PROCESS_MAX "${CPU_CORES} * 2 / 3")
111123

112124
# windows build turn off warnings, use parallel compiling.
113125
foreach(flag_var
@@ -116,7 +128,10 @@ if(WIN32)
116128
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
117129
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
118130
string(REGEX REPLACE "/W[1-4]" " /W0 " ${flag_var} "${${flag_var}}")
119-
set(${flag_var} "${${flag_var}} /MP${PROCESS_MAX}")
131+
# NOTE(zhouwei25): GPU compile have too high memory utilization when parallel compiling
132+
if(NOT WITH_GPU)
133+
set(${flag_var} "${${flag_var}} /MP${PROCESS_MAX}")
134+
endif()
120135
endforeach(flag_var)
121136
foreach(flag_var CMAKE_CXX_FLAGS CMAKE_C_FLAGS)
122137
set(${flag_var} "${${flag_var}} /w")
@@ -208,16 +223,10 @@ option(WITH_STRIP "Strip so files of Whl packages" OFF)
208223

209224
# PY_VERSION
210225
if(NOT PY_VERSION)
211-
set(PY_VERSION 2.7)
226+
set(PY_VERSION 3.6)
212227
endif()
213228
set(PYBIND11_PYTHON_VERSION ${PY_VERSION})
214229

215-
# CMAKE_BUILD_TYPE
216-
if(NOT CMAKE_BUILD_TYPE)
217-
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
218-
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel"
219-
FORCE)
220-
endif()
221230

222231
# the type of sanitizer, options are: Address, Leak, Memory, Thread, Undefined. Default: OFF
223232
if(SANITIZER_TYPE AND NOT "${SANITIZER_TYPE}" MATCHES "^(Address|Leak|Memory|Thread|Undefined)$")
@@ -282,6 +291,27 @@ if(WITH_GPU)
282291
endif()
283292
endif()
284293

294+
if(WITH_ROCM)
295+
include(hip)
296+
include(miopen) # set miopen libraries, must before configure
297+
endif(WITH_ROCM)
298+
299+
if (NOT WITH_ROCM AND WITH_RCCL)
300+
MESSAGE(WARNING
301+
"Disable RCCL when compiling without ROCM. Force WITH_RCCL=OFF.")
302+
set(WITH_RCCL OFF CACHE STRING
303+
"Disable RCCL when compiling without ROCM" FORCE)
304+
endif()
305+
306+
if(WITH_RCCL)
307+
add_definitions("-DPADDLE_WITH_RCCL")
308+
include(rccl)
309+
else()
310+
if(WITH_ROCM)
311+
MESSAGE(WARNING "If the environment is multi-card, the WITH_RCCL option needs to be turned on, otherwise only a single card can be used.")
312+
endif()
313+
endif()
314+
285315
include(third_party) # download, build, install third_party, Contains about 20+ dependencies
286316

287317
include(flags) # set paddle compile flags
@@ -306,35 +336,16 @@ include(configure) # add paddle env configuration
306336

307337
include_directories("${PADDLE_SOURCE_DIR}")
308338

309-
if(WITH_ROCM)
310-
include(hip)
311-
endif(WITH_ROCM)
312-
313-
if (NOT WITH_ROCM AND WITH_RCCL)
314-
MESSAGE(WARNING
315-
"Disable RCCL when compiling without ROCM. Force WITH_RCCL=OFF.")
316-
set(WITH_RCCL OFF CACHE STRING
317-
"Disable RCCL when compiling without ROCM" FORCE)
318-
endif()
319-
320-
if(WITH_RCCL)
321-
add_definitions("-DPADDLE_WITH_RCCL")
322-
include(rccl)
323-
else()
324-
if(WITH_ROCM)
325-
MESSAGE(WARNING "If the environment is multi-card, the WITH_RCCL option needs to be turned on, otherwise only a single card can be used.")
326-
endif()
327-
endif()
328-
329339
if(WITH_NV_JETSON)
330340
set(WITH_ARM ON CACHE STRING "Set WITH_ARM=ON when compiling WITH_NV_JETSON=ON." FORCE)
331341
endif()
332342

333343
if(WITH_ARM)
334344
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
335345
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
336-
set(WITH_XBYAK OFF CACHE STRING "Disable XBYAK when compiling WITH_ARM=ON" FORCE)
346+
set(WITH_XBYAK OFF CACHE STRING "Disable XBYAK when compiling WITH_ARM=ON." FORCE)
337347
set(WITH_MKL OFF CACHE STRING "Disable MKL when compiling WITH_ARM=ON." FORCE)
348+
set(WITH_AVX OFF CACHE STRING "Disable AVX when compiling WITH_AVX=OFF." FORCE)
338349
add_definitions(-DPADDLE_WITH_ARM)
339350
endif()
340351

@@ -352,6 +363,11 @@ if (WITH_MIPS)
352363
add_definitions(-DPADDLE_WITH_MIPS)
353364
endif()
354365

366+
if (WITH_HETERPS)
367+
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)
368+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -faligned-new")
369+
endif()
370+
endif()
355371
set(PADDLE_PYTHON_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/python/build")
356372

357373
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG")

README.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
<p align="center">
32
<img align="center" src="doc/imgs/logo.png", width=1600>
43
<p>
@@ -22,7 +21,7 @@ PaddlePaddle is originated from industrial practices with dedication and commitm
2221

2322
## Installation
2423

25-
### Latest PaddlePaddle Release: [v2.0](https://github.com/PaddlePaddle/Paddle/tree/release/2.0)
24+
### Latest PaddlePaddle Release: [v2.1](https://github.com/PaddlePaddle/Paddle/tree/release/2.1)
2625

2726
Our vision is to enable deep learning for everyone via PaddlePaddle.
2827
Please refer to our [release announcement](https://github.com/PaddlePaddle/Paddle/releases) to track the latest features of PaddlePaddle.
@@ -34,9 +33,9 @@ pip install paddlepaddle
3433
pip install paddlepaddle-gpu
3534
3635
```
37-
More infomation about installation, please view [Quick Install](https://www.paddlepaddle.org.cn/install/quick)
36+
For more information about installation, please view [Quick Install](https://www.paddlepaddle.org.cn/install/quick)
3837

39-
Now our developers can acquire Tesla V100 online computing resources for free. If you create a program by AI Studio, you will obtain 10 hours to train models online per day. [Click here to start](https://aistudio.baidu.com/aistudio/index).
38+
Now our developers can acquire Tesla V100 online computing resources for free. If you create a program by AI Studio, you will obtain 8 hours to train models online per day. [Click here to start](https://aistudio.baidu.com/aistudio/index).
4039

4140
## FOUR LEADING TECHNOLOGIES
4241

@@ -47,14 +46,13 @@ Now our developers can acquire Tesla V100 online computing resources for free. I
4746

4847
- **Support Ultra-Large-Scale Training of Deep Neural Networks**
4948

50-
PaddlePaddle has made breakthroughs in ultra-large-scale deep neural networks training. It launched the world's first large-scale open-source training platform that supports the training of deep networks with 100 billions of features and trillions of parameters using data sources distributed over hundreds of nodes. PaddlePaddle overcomes the online deep learning challenges for ultra-large-scale deep learning models, and further achieved the real-time model updating with more than 1 trillion parameters.
49+
PaddlePaddle has made breakthroughs in ultra-large-scale deep neural networks training. It launched the world's first large-scale open-source training platform that supports the training of deep networks with 100 billion features and trillions of parameters using data sources distributed over hundreds of nodes. PaddlePaddle overcomes the online deep learning challenges for ultra-large-scale deep learning models, and further achieved real-time model updating with more than 1 trillion parameters.
5150
[Click here to learn more](https://github.com/PaddlePaddle/Fleet)
5251

5352

54-
- **Accelerated High-Performance Inference over Ubiquitous Deployments**
53+
- **High-Performance Inference Engines for Comprehensive Deployment Enviroments**
5554

56-
PaddlePaddle is not only compatible with other open-source frameworks for models training, but also works well on the ubiquitous developments, varying from platforms to devices. More specifically, PaddlePaddle accelerates the inference procedure with the fastest speed-up. Note that, a recent breakthrough of inference speed has been made by PaddlePaddle on Huawei's Kirin NPU, through the hardware/software co-optimization.
57-
[Click here to learn more](https://github.com/PaddlePaddle/Paddle-Lite)
55+
PaddlePaddle is not only compatible with models trained in 3rd party open-source frameworks , but also offers complete inference products for various production scenarios. Our inference product line includes [Paddle Inference](https://paddle-inference.readthedocs.io/en/latest/product_introduction/summary.html): Native inference library for high-performance server and cloud inference; [Paddle Serving](https://github.com/PaddlePaddle/Serving): A service-oriented framework suitable for distributed and pipeline productions; [Paddle Lite](https://github.com/PaddlePaddle/Paddle-Lite): Ultra-Lightweight inference engine for mobile and IoT environments; [Paddle.js](https://www.paddlepaddle.org.cn/paddle/paddlejs): A frontend inference engine for browser and mini-apps. Furthermore, by great amounts of optimization with leading hardware in each scenario, Paddle inference engines outperform most of the other mainstream frameworks.
5856

5957

6058
- **Industry-Oriented Models and Libraries with Open Source Repositories**
@@ -87,8 +85,13 @@ We provide [English](https://www.paddlepaddle.org.cn/documentation/docs/en/guide
8785
## Communication
8886

8987
- [Github Issues](https://github.com/PaddlePaddle/Paddle/issues): bug reports, feature requests, install issues, usage issues, etc.
90-
- QQ discussion group: 778260830 (PaddlePaddle).
88+
- QQ discussion group: 793866180 (PaddlePaddle).
9189
- [Forums](https://ai.baidu.com/forum/topic/list/168?pageNo=1): discuss implementations, research, etc.
90+
91+
## Courses
92+
93+
- [Server Deployments](https://aistudio.baidu.com/aistudio/course/introduce/19084): Courses intorducing high performance server deployments via local and remote services.
94+
- [Edge Deployments](https://aistudio.baidu.com/aistudio/course/introduce/22690): Courses intorducing edge deployments from mobile, IoT to web and applets.
9295

9396
## Copyright and License
9497
PaddlePaddle is provided under the [Apache-2.0 license](LICENSE).

README_cn.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
22
<p align="center">
33
<img align="center" src="doc/imgs/logo.png", width=1600>
44
<p>
@@ -19,7 +19,7 @@
1919

2020
## 安装
2121

22-
### PaddlePaddle最新版本: [v2.0](https://github.com/PaddlePaddle/Paddle/tree/release/2.0)
22+
### PaddlePaddle最新版本: [v2.1](https://github.com/PaddlePaddle/Paddle/tree/release/2.1)
2323

2424
跟进PaddlePaddle最新特性请参考我们的[版本说明](https://github.com/PaddlePaddle/Paddle/releases)
2525

@@ -32,7 +32,7 @@ pip install paddlepaddle-gpu
3232
```
3333
更多安装信息详见官网 [安装说明](https://www.paddlepaddle.org.cn/install/quick)
3434

35-
PaddlePaddle用户可领取**免费Tesla V100在线算力资源**,训练模型更高效。**每日登陆即送10小时**[前往使用免费算力](https://aistudio.baidu.com/aistudio/index)
35+
PaddlePaddle用户可领取**免费Tesla V100在线算力资源**,训练模型更高效。**每日登陆即送8小时**[前往使用免费算力](https://aistudio.baidu.com/aistudio/index)
3636

3737
## 四大领先技术
3838

@@ -47,10 +47,9 @@ PaddlePaddle用户可领取**免费Tesla V100在线算力资源**,训练模型
4747
[查看详情](https://github.com/PaddlePaddle/Fleet)
4848

4949

50-
- **多端多平台部署的高性能推理引擎**
50+
- **支持多端多平台的高性能推理部署工具**
5151

52-
飞桨不仅兼容其他开源框架训练的模型,还可以轻松地部署到不同架构的平台设备上。同时,飞桨的推理速度也是全面领先的。尤其经过了跟华为麒麟NPU的软硬一体优化,使得飞桨在NPU上的推理速度进一步突破。
53-
[查看详情](https://github.com/PaddlePaddle/Paddle-Lite)
52+
飞桨不仅广泛兼容第三方开源框架训练的模型部署,并且为不同的场景的生产环境提供了完备的推理引擎,包括适用于高性能服务器及云端推理的原生推理库 [Paddle Inference](https://paddle-inference.readthedocs.io/en/latest/product_introduction/summary.html),面向分布式、流水线生产环境下自动上云、A/B测试等高阶功能的服务化推理框架 [Paddle Serving](https://github.com/PaddlePaddle/Serving),针对于移动端、物联网场景的轻量化推理引擎 [Paddle Lite](https://github.com/PaddlePaddle/Paddle-Lite),以及在浏览器、小程序等环境下使用的前端推理引擎 [Paddle.js](https://www.paddlepaddle.org.cn/paddle/paddlejs)。同时,透过与不同场景下的主流硬件高度适配优化及异构计算的支持, 飞桨的推理性能也领先绝大部分的主流实现。
5453

5554

5655
- **面向产业应用,开源开放覆盖多领域的工业级模型库。**
@@ -83,8 +82,13 @@ PaddlePaddle用户可领取**免费Tesla V100在线算力资源**,训练模型
8382
## 交流与反馈
8483

8584
- 欢迎您通过[Github Issues](https://github.com/PaddlePaddle/Paddle/issues)来提交问题、报告与建议
86-
- QQ群: 778260830 (PaddlePaddle)
85+
- QQ群: 793866180 (PaddlePaddle)
8786
- [论坛](https://ai.baidu.com/forum/topic/list/168): 欢迎大家在PaddlePaddle论坛分享在使用PaddlePaddle中遇到的问题和经验, 营造良好的论坛氛围
87+
88+
## 课程
89+
90+
- [服务器部署](https://aistudio.baidu.com/aistudio/course/introduce/19084): 详细介绍高性能服务器端部署实操,包含本地端及服务化Serving部署等
91+
- [端侧部署](https://aistudio.baidu.com/aistudio/course/introduce/22690): 详细介绍端侧多场景部署实操,从移端端设备、IoT、网页到小程序部署
8892

8993
## 版权和许可证
9094
PaddlePaddle由[Apache-2.0 license](LICENSE)提供

cmake/cblas.cmake

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,21 @@ if(NOT DEFINED CBLAS_PROVIDER)
6969
PATHS ${OPENBLAS_LIB_SEARCH_PATHS})
7070

7171
if(OPENBLAS_LAPACKE_INC_DIR AND OPENBLAS_INC_DIR AND OPENBLAS_LIB)
72-
set(CBLAS_PROVIDER OPENBLAS)
73-
set(CBLAS_INC_DIR ${OPENBLAS_INC_DIR} ${OPENBLAS_LAPACKE_INC_DIR})
74-
set(CBLAS_LIBRARIES ${OPENBLAS_LIB})
75-
76-
add_definitions(-DPADDLE_USE_OPENBLAS)
77-
add_definitions(-DLAPACK_FOUND)
78-
79-
message(STATUS "Found OpenBLAS (include: ${OPENBLAS_INC_DIR}, library: ${CBLAS_LIBRARIES})")
80-
message(STATUS "Found lapack in OpenBLAS (include: ${OPENBLAS_LAPACKE_INC_DIR})")
72+
file(READ "${OPENBLAS_INC_DIR}/openblas_config.h" config_file)
73+
string(REGEX MATCH "OpenBLAS ([0-9]+\.[0-9]+\.[0-9]+)" tmp ${config_file})
74+
string(REGEX MATCH "([0-9]+\.[0-9]+\.[0-9]+)" ver ${tmp})
75+
76+
if (${ver} VERSION_GREATER_EQUAL "0.3.7")
77+
set(CBLAS_PROVIDER OPENBLAS)
78+
set(CBLAS_INC_DIR ${OPENBLAS_INC_DIR} ${OPENBLAS_LAPACKE_INC_DIR})
79+
set(CBLAS_LIBRARIES ${OPENBLAS_LIB})
80+
81+
add_definitions(-DPADDLE_USE_OPENBLAS)
82+
add_definitions(-DLAPACK_FOUND)
83+
84+
message(STATUS "Found OpenBLAS (include: ${OPENBLAS_INC_DIR}, library: ${CBLAS_LIBRARIES})")
85+
message(STATUS "Found lapack in OpenBLAS (include: ${OPENBLAS_LAPACKE_INC_DIR})")
86+
endif()
8187
endif()
8288
endif()
8389

cmake/ccache.cmake

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,29 @@
11
# Use ccache if found ccache program
22

3-
find_program(CCACHE_PATH ccache)
3+
if(NOT WIN32)
4+
find_program(CCACHE_PATH ccache)
5+
if(CCACHE_PATH)
6+
execute_process(COMMAND ccache -V OUTPUT_VARIABLE ccache_output)
7+
execute_process(COMMAND ccache -s cache directory OUTPUT_VARIABLE cache_directory)
8+
string(REGEX MATCH "[0-9]+.[0-9]+" ccache_version ${ccache_output})
9+
message(STATUS "ccache is founded, use ccache to speed up compile on Unix.")
10+
# show statistics summary of ccache
11+
message("ccache version\t\t\t " ${ccache_version} "\n" ${cache_directory})
12+
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_PATH})
13+
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE_PATH})
14+
endif(CCACHE_PATH)
15+
elseif("${CMAKE_GENERATOR}" STREQUAL "Ninja")
16+
# (Note:zhouwei25) Only Ninja Generator can support sccache now
17+
find_program(SCCACHE_PATH sccache)
418

5-
if(CCACHE_PATH)
6-
execute_process(COMMAND ccache -V OUTPUT_VARIABLE ccache_output)
7-
execute_process(COMMAND ccache -s cache directory OUTPUT_VARIABLE cache_directory)
8-
string(REGEX MATCH "[0-9]+.[0-9]+" ccache_version ${ccache_output})
9-
message(STATUS "Ccache is founded, use ccache to speed up compile.")
10-
# show statistics summary of ccache
11-
message("ccache version\t\t\t " ${ccache_version} "\n" ${cache_directory})
12-
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_PATH})
13-
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE_PATH})
14-
endif(CCACHE_PATH)
19+
if(SCCACHE_PATH)
20+
execute_process(COMMAND sccache -V OUTPUT_VARIABLE sccache_version)
21+
message(STATUS "${sccache_version} is founded, use [${SCCACHE_PATH}] to speed up compile on Windows.")
22+
23+
set(CMAKE_C_COMPILER_LAUNCHER ${SCCACHE_PATH})
24+
set(CMAKE_CXX_COMPILER_LAUNCHER ${SCCACHE_PATH})
25+
# (Note:zhouwei25) sccache for cuda compiler has bug so that it can't be hit
26+
# refer to https://github.com/mozilla/sccache/issues/1017, so we fix it
27+
set(CMAKE_CUDA_COMPILER_LAUNCHER ${SCCACHE_PATH})
28+
endif(SCCACHE_PATH)
29+
endif()

0 commit comments

Comments
 (0)