Use CUDA 11 in clang-tidy (#7701)

* Show command args when clang-tidy fails

* Add option to specify CUDA args

* Use clang-tidy 11

* [CI] Use CUDA 11
This commit is contained in:
Philip Hyunsu Cho 2022-02-24 15:15:07 -08:00 committed by GitHub
parent 83a66b4994
commit 1b25dd59f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 9 deletions

4
Jenkinsfile vendored
View File

@ -123,9 +123,9 @@ def ClangTidy() {
echo "Running clang-tidy job..." echo "Running clang-tidy job..."
def container_type = "clang_tidy" def container_type = "clang_tidy"
def docker_binary = "docker" def docker_binary = "docker"
def dockerArgs = "--build-arg CUDA_VERSION_ARG=10.1" def dockerArgs = "--build-arg CUDA_VERSION_ARG=11.0"
sh """ sh """
${dockerRun} ${container_type} ${docker_binary} ${dockerArgs} python3 tests/ci_build/tidy.py ${dockerRun} ${container_type} ${docker_binary} ${dockerArgs} python3 tests/ci_build/tidy.py --cuda-archs 75
""" """
deleteDir() deleteDir()
} }

View File

@ -11,16 +11,16 @@ RUN \
apt-get install -y tar unzip wget git build-essential python3 python3-pip software-properties-common \ apt-get install -y tar unzip wget git build-essential python3 python3-pip software-properties-common \
apt-transport-https ca-certificates gnupg-agent && \ apt-transport-https ca-certificates gnupg-agent && \
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && \ wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && \
add-apt-repository -u 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main' && \ add-apt-repository -u 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main' && \
apt-get update && \ apt-get update && \
apt-get install -y llvm-10 clang-tidy-10 clang-10 && \ apt-get install -y llvm-11 clang-tidy-11 clang-11 && \
wget -nv -nc https://cmake.org/files/v3.14/cmake-3.14.0-Linux-x86_64.sh --no-check-certificate && \ wget -nv -nc https://cmake.org/files/v3.14/cmake-3.14.0-Linux-x86_64.sh --no-check-certificate && \
bash cmake-3.14.0-Linux-x86_64.sh --skip-license --prefix=/usr bash cmake-3.14.0-Linux-x86_64.sh --skip-license --prefix=/usr
# Set default clang-tidy version # Set default clang-tidy version
RUN \ RUN \
update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-10 100 && \ update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-11 100 && \
update-alternatives --install /usr/bin/clang clang /usr/bin/clang-10 100 update-alternatives --install /usr/bin/clang clang /usr/bin/clang-11 100
# Install Python packages # Install Python packages
RUN \ RUN \

View File

@ -26,7 +26,7 @@ def call(args):
return_code = 0 return_code = 0
else: else:
return_code = 1 return_code = 1
return (completed.returncode, return_code, error_msg) return (completed.returncode, return_code, error_msg, args)
class ClangTidy(object): class ClangTidy(object):
@ -41,6 +41,7 @@ class ClangTidy(object):
self.cpp_lint = args.cpp self.cpp_lint = args.cpp
self.cuda_lint = args.cuda self.cuda_lint = args.cuda
self.use_dmlc_gtest = args.use_dmlc_gtest self.use_dmlc_gtest = args.use_dmlc_gtest
self.cuda_archs = args.cuda_archs.copy() if args.cuda_archs else []
if args.tidy_version: if args.tidy_version:
self.exe = 'clang-tidy-' + str(args.tidy_version) self.exe = 'clang-tidy-' + str(args.tidy_version)
@ -50,6 +51,7 @@ class ClangTidy(object):
print('Run linter on CUDA: ', self.cuda_lint) print('Run linter on CUDA: ', self.cuda_lint)
print('Run linter on C++:', self.cpp_lint) print('Run linter on C++:', self.cpp_lint)
print('Use dmlc gtest:', self.use_dmlc_gtest) print('Use dmlc gtest:', self.use_dmlc_gtest)
print('CUDA archs:', ' '.join(self.cuda_archs))
if not self.cpp_lint and not self.cuda_lint: if not self.cpp_lint and not self.cuda_lint:
raise ValueError('Both --cpp and --cuda are set to 0.') raise ValueError('Both --cpp and --cuda are set to 0.')
@ -83,6 +85,9 @@ class ClangTidy(object):
if self.cuda_lint: if self.cuda_lint:
cmake_args.extend(['-DUSE_CUDA=ON', '-DUSE_NCCL=ON']) cmake_args.extend(['-DUSE_CUDA=ON', '-DUSE_NCCL=ON'])
if self.cuda_archs:
arch_list = ';'.join(self.cuda_archs)
cmake_args.append(f'-DGPU_COMPUTE_VER={arch_list}')
subprocess.run(cmake_args) subprocess.run(cmake_args)
os.chdir(self.root_path) os.chdir(self.root_path)
@ -211,12 +216,13 @@ class ClangTidy(object):
BAR = '-'*32 BAR = '-'*32
with Pool(cpu_count()) as pool: with Pool(cpu_count()) as pool:
results = pool.map(call, all_files) results = pool.map(call, all_files)
for i, (process_status, tidy_status, msg) in enumerate(results): for i, (process_status, tidy_status, msg, args) in enumerate(results):
# Don't enforce clang-tidy to pass for now due to namespace # Don't enforce clang-tidy to pass for now due to namespace
# for cub in thrust is not correct. # for cub in thrust is not correct.
if tidy_status == 1: if tidy_status == 1:
passed = False passed = False
print(BAR, '\n' print(BAR, '\n'
'Command args:', ' '.join(args), ', ',
'Process return code:', process_status, ', ', 'Process return code:', process_status, ', ',
'Tidy result code:', tidy_status, ', ', 'Tidy result code:', tidy_status, ', ',
'Message:\n', msg, 'Message:\n', msg,
@ -259,7 +265,7 @@ right keywords?
else: else:
tidy = 'clang-tidy-' + str(args.tidy_version) tidy = 'clang-tidy-' + str(args.tidy_version)
args = [tidy, tidy_config, test_file_path] args = [tidy, tidy_config, test_file_path]
(proc_code, tidy_status, error_msg) = call(args) (proc_code, tidy_status, error_msg, _) = call(args)
assert proc_code == 0 assert proc_code == 0
assert tidy_status == 1 assert tidy_status == 1
print('clang-tidy is working.') print('clang-tidy is working.')
@ -273,6 +279,8 @@ if __name__ == '__main__':
parser.add_argument('--cuda', type=int, default=1) parser.add_argument('--cuda', type=int, default=1)
parser.add_argument('--use-dmlc-gtest', type=int, default=1, parser.add_argument('--use-dmlc-gtest', type=int, default=1,
help='Whether to use gtest bundled in dmlc-core.') help='Whether to use gtest bundled in dmlc-core.')
parser.add_argument('--cuda-archs', action='append',
help='List of CUDA archs to build')
args = parser.parse_args() args = parser.parse_args()
test_tidy(args) test_tidy(args)