Refactor CMake scripts. (#4323)
* Refactor CMake scripts. * Remove CMake CUDA wrapper. * Bump CMake version for CUDA. * Use CMake to handle Doxygen. * Split up CMakeList. * Export install target. * Use modern CMake. * Remove build.sh * Workaround for gpu_hist test. * Use cmake 3.12. * Revert machine.conf. * Move CLI test to gpu. * Small cleanup. * Support using XGBoost as submodule. * Fix windows * Fix cpp tests on Windows * Remove duplicated find_package.
This commit is contained in:
committed by
Philip Hyunsu Cho
parent
84d992babc
commit
207f058711
@@ -7,7 +7,9 @@ ENV DEBIAN_FRONTEND noninteractive
|
||||
# Install all basic requirements
|
||||
RUN \
|
||||
apt-get update && \
|
||||
apt-get install -y tar unzip wget git build-essential cmake python3 python3-pip llvm-7 clang-tidy-7 clang-7
|
||||
apt-get install -y tar unzip wget git build-essential python3 python3-pip llvm-7 clang-tidy-7 clang-7 && \
|
||||
wget -nv -nc https://cmake.org/files/v3.12/cmake-3.12.0-Linux-x86_64.sh --no-check-certificate && \
|
||||
bash cmake-3.12.0-Linux-x86_64.sh --skip-license --prefix=/usr
|
||||
|
||||
# Set default clang-tidy version
|
||||
RUN \
|
||||
|
||||
@@ -15,8 +15,8 @@ RUN \
|
||||
wget https://repo.continuum.io/miniconda/Miniconda2-4.3.27-Linux-x86_64.sh && \
|
||||
bash Miniconda2-4.3.27-Linux-x86_64.sh -b -p /opt/python && \
|
||||
# CMake
|
||||
wget -nv -nc https://cmake.org/files/v3.6/cmake-3.6.0-Linux-x86_64.sh --no-check-certificate && \
|
||||
bash cmake-3.6.0-Linux-x86_64.sh --skip-license --prefix=/usr
|
||||
wget -nv -nc https://cmake.org/files/v3.12/cmake-3.12.0-Linux-x86_64.sh --no-check-certificate && \
|
||||
bash cmake-3.12.0-Linux-x86_64.sh --skip-license --prefix=/usr
|
||||
|
||||
# NCCL2 (License: https://docs.nvidia.com/deeplearning/sdk/nccl-sla/index.html)
|
||||
RUN \
|
||||
|
||||
@@ -14,7 +14,7 @@ rm -rf release-1.7.0.zip*
|
||||
rm -rf build
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. "$@" -DGOOGLE_TEST=ON -DGTEST_ROOT=$PWD/../gtest
|
||||
cmake .. "$@" -DGOOGLE_TEST=ON -DGTEST_ROOT=$PWD/../gtest -DCMAKE_VERBOSE_MAKEFILE=ON
|
||||
make clean
|
||||
make -j
|
||||
cd ..
|
||||
|
||||
@@ -5,4 +5,8 @@ cd python-package
|
||||
python setup.py install --user
|
||||
cd ..
|
||||
pytest -v -s --fulltrace -m "(not mgpu) and (not slow)" tests/python-gpu
|
||||
./build/testxgboost --gtest_filter=-*.MGPU_*
|
||||
pushd .
|
||||
cd build
|
||||
./testxgboost --gtest_filter=-*.MGPU_*
|
||||
ctest --output-on-failure --tests-regex "TestXGBoostCLI"
|
||||
popd
|
||||
|
||||
@@ -60,7 +60,7 @@ class ClangTidy(object):
|
||||
'''Run CMake to generate compilation database.'''
|
||||
os.mkdir(self.cdb_path)
|
||||
os.chdir(self.cdb_path)
|
||||
cmake_args = ['cmake', '..', '-DGENERATE_COMPILATION_DATABASE=ON',
|
||||
cmake_args = ['cmake', '..', '-DCMAKE_EXPORT_COMPILE_COMMANDS=ON',
|
||||
'-DGOOGLE_TEST=ON', '-DGTEST_ROOT={}'.format(
|
||||
self.gtest_path)]
|
||||
if self.cuda_lint:
|
||||
@@ -68,23 +68,64 @@ class ClangTidy(object):
|
||||
subprocess.run(cmake_args)
|
||||
os.chdir(self.root_path)
|
||||
|
||||
def convert_nvcc_command_to_clang(self, command):
|
||||
'''Convert nvcc flags to corresponding clang flags.'''
|
||||
components = command.split()
|
||||
compiler: str = components[0]
|
||||
if compiler.find('nvcc') != -1:
|
||||
compiler = 'clang++'
|
||||
components[0] = compiler
|
||||
# check each component in a command
|
||||
converted_components = [compiler]
|
||||
|
||||
for i in range(len(components)):
|
||||
if components[i] == '-lineinfo':
|
||||
continue
|
||||
elif components[i] == '-fuse-ld=gold':
|
||||
continue
|
||||
elif components[i] == '-rdynamic':
|
||||
continue
|
||||
elif (components[i] == '-x' and
|
||||
components[i+1] == 'cu'):
|
||||
# -x cu -> -x cuda
|
||||
converted_components.append('-x')
|
||||
converted_components.append('cuda')
|
||||
components[i+1] = ''
|
||||
continue
|
||||
elif components[i].find('-Xcompiler') != -1:
|
||||
continue
|
||||
elif components[i].find('--expt') != -1:
|
||||
continue
|
||||
elif components[i].find('-ccbin') != -1:
|
||||
continue
|
||||
elif components[i].find('--generate-code') != -1:
|
||||
keyword = 'code=sm'
|
||||
pos = components[i].find(keyword)
|
||||
capability = components[i][pos + len(keyword) + 1:
|
||||
pos + len(keyword) + 3]
|
||||
if pos != -1:
|
||||
converted_components.append(
|
||||
'--cuda-gpu-arch=sm_' + capability)
|
||||
elif components[i].find('--std=c++11') != -1:
|
||||
converted_components.append('-std=c++11')
|
||||
else:
|
||||
converted_components.append(components[i])
|
||||
|
||||
command = ''
|
||||
for c in converted_components:
|
||||
command = command + ' ' + c
|
||||
command = command.strip()
|
||||
return command
|
||||
|
||||
def _configure_flags(self, path, command):
|
||||
common_args = ['clang-tidy',
|
||||
"-header-filter='(xgboost\\/src|xgboost\\/include)'",
|
||||
'-config='+self.clang_tidy]
|
||||
common_args.append(path)
|
||||
common_args.append('--')
|
||||
command = self.convert_nvcc_command_to_clang(command)
|
||||
|
||||
command = command.split()[1:] # remove clang/c++/g++
|
||||
# filter out not used flags
|
||||
if '-fuse-ld=gold' in command:
|
||||
command.remove('-fuse-ld=gold')
|
||||
if '-rdynamic' in command:
|
||||
command.remove('-rdynamic')
|
||||
if '-Xcompiler=-fPIC' in command:
|
||||
command.remove('-Xcompiler=-fPIC')
|
||||
if '-Xcompiler=-fPIE' in command:
|
||||
command.remove('-Xcompiler=-fPIE')
|
||||
if '-c' in command:
|
||||
index = command.index('-c')
|
||||
del command[index+1]
|
||||
|
||||
Reference in New Issue
Block a user