Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get build time #39368

Merged
merged 1 commit into from
Feb 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,15 @@ option(NEW_RELEASE_CUBIN "PaddlePaddle next-level release strategy for pypi cu
option(NEW_RELEASE_JIT "PaddlePaddle next-level release strategy for backup jit package" OFF)
option(WITH_ASCEND_INT64 "Compile with int64 kernel for ascend NPU" OFF)
option(WITH_POCKETFFT "Compile with pocketfft support" ON)
option(WITH_RECORD_BUILDTIME "Compile PaddlePaddle with record all targets build time" OFF)

if(WITH_RECORD_BUILDTIME)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CMAKE_CURRENT_SOURCE_DIR}/tools/get_build_time.sh")
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CMAKE_CURRENT_SOURCE_DIR}/tools/get_build_time.sh")
else()
include(ccache) # set ccache for compilation ; if WITH_RECORD_BUILDTIME=ON can't use ccache
endif()
unset(WITH_RECORD_BUILDTIME CACHE)

# PY_VERSION
if(NOT PY_VERSION)
Expand Down Expand Up @@ -382,7 +391,6 @@ if(WITH_PROFILER)
add_definitions(-DWITH_GPERFTOOLS)
endif()

include(ccache) # set ccache for compilation
include(util) # set unittest and link libs
include(version) # set PADDLE_VERSION
include(coveralls) # set code coverage
Expand Down
1 change: 0 additions & 1 deletion cmake/cuda.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ if(NOT WITH_GPU)
return()
endif()


if(WITH_NV_JETSON)
add_definitions(-DWITH_NV_JETSON)
set(paddle_known_gpu_archs "53 62 72")
Expand Down
21 changes: 20 additions & 1 deletion paddle/scripts/paddle_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ function cmake_base() {
-DON_INFER=${ON_INFER:-OFF}
-DWITH_HETERPS=${WITH_HETERPS:-OFF}
-DWITH_FLUID_ONLY=${WITH_FLUID_ONLY:-OFF}
-DWITH_RECORD_BUILDTIME=${WITH_RECORD_BUILDTIME:-OFF}
-DCUDA_ARCH_BIN="${CUDA_ARCH_BIN}"
========================================
EOF
Expand Down Expand Up @@ -289,6 +290,7 @@ EOF
-DWITH_HETERPS=${WITH_HETERPS:-OFF} \
-DWITH_FLUID_ONLY=${WITH_FLUID_ONLY:-OFF} \
-DCUDA_ARCH_BIN="${CUDA_ARCH_BIN}" \
-DWITH_RECORD_BUILDTIME=${WITH_RECORD_BUILDTIME:-OFF} \
-DWITH_UNITY_BUILD=${WITH_UNITY_BUILD:-OFF};build_error=$?
if [ "$build_error" != 0 ];then
exit 7;
Expand Down Expand Up @@ -452,6 +454,14 @@ function cmake_gen_and_build() {
echo "ipipe_log_param_Build_Time: $[ $endTime_s - $startTime_s ]s" >> ${PADDLE_ROOT}/build/build_summary.txt
}

function get_build_time_file() {
python ${PADDLE_ROOT}/tools/analysis_build_time.py
cat ${PADDLE_ROOT}/tools/buildTime.txt
today=$(date "+%Y-%m-%d")
mkdir -p /paddle_targets_buildtime_record
cp ${PADDLE_ROOT}/tools/buildTime.txt /paddle_targets_buildtime_record/${today}-buildTime.txt
}

function build_mac() {
set +e
mkdir -p ${PADDLE_ROOT}/build
Expand Down Expand Up @@ -2483,6 +2493,10 @@ function build_pr_and_develop() {
mkdir ${PADDLE_ROOT}/build/dev_whl && cp ${PADDLE_ROOT}/build/python/dist/*.whl ${PADDLE_ROOT}/build/dev_whl
}

function build_develop() {
#git checkout -b develop_base_pr upstream/$BRANCH
cmake_gen_and_build ${PYTHON_ABI:-""} ${parallel_number}
}

function main() {
local CMD=$1
Expand All @@ -2493,7 +2507,12 @@ function main() {
cmake_gen_and_build ${PYTHON_ABI:-""} ${parallel_number}
;;
build_pr_dev)
build_pr_and_develop
build_pr_and_develop
;;
build_dev_test)
#build_develop
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

build_develop是不是不需要了,可以删掉吗?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR-CI-Build-Daily当前只测试了PR的编译,这个函数留着是为了测试develop的编译,需要等待这个PR合入后,我测试无问题下个PR进行删除

cmake_gen_and_build ${PYTHON_ABI:-""} ${parallel_number}
get_build_time_file
;;
build_and_check)
set +e
Expand Down
63 changes: 63 additions & 0 deletions tools/analysis_build_time.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os

root_path = os.path.abspath(os.path.join(os.getcwd(), ".."))


def strToSecond(strTime):
minute = int(strTime.split(':')[0])
second = int(strTime.split(':')[1].split('.')[0]) + 1
return minute * 60 + second


def getUsefulBuildTimeFile(filename):
os.system(
"grep -Po -- '-o .*' %s | grep ' elapsed' | grep -P -v '0:00.* elapse' > %s/tools/analysis_build_time"
% (filename, root_path))
os.system(
"grep -v -- '-o .*' %s |grep ' elapse' | grep -P -v '0:00.* elapse' >> %s/tools/analysis_build_time"
% (filename, root_path))


def analysisBuildTime():
filename = '%s/build/build-time' % root_path
getUsefulBuildTimeFile(filename)
os.system('rm -rf %s/tools/tempbuildTime.txt' % root_path)
with open('%s/tools/analysis_build_time' % root_path, 'r') as f:
lines = f.readlines()
for line in lines:
try:
line = line.strip()
if '-o ' in line:
buildFile = line.split(', ')[0].split(' ')[1]
buildTime = line.split(', ')[1].split('elapsed')[0].strip()
secondTime = strToSecond(buildTime)
os.system("echo %s, %s >> %s/tools/tempbuildTime.txt" %
(buildFile, secondTime, root_path))
else:
buildTime = line.split(', ')[1].split('elapsed')[0].strip()
secondTime = strToSecond(buildTime)
if secondTime > 30:
os.system("echo %s, %s >> %s/tools/tempbuildTime.txt" %
(line, secondTime, root_path))
except ValueError:
print(line)
os.system(
'sort -n -k 2 -r %s/tools/tempbuildTime.txt > %s/tools/buildTime.txt' %
(root_path, root_path))


analysisBuildTime()
18 changes: 18 additions & 0 deletions tools/get_build_time.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

CUR_ROOT=$(dirname "$0")/..
/usr/bin/time -f '%C, %E elapsed, %U user, %S sys' "$@" >> $CUR_ROOT/build/build-time 2>&1