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

[REVIEW] Enable clang tidy on cuML c++ sources #1945

Merged
merged 65 commits into from
May 24, 2020
Merged
Show file tree
Hide file tree
Changes from 61 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
3e7c2aa
initial version of clang-tidy wrapper script
teju85 Mar 6, 2020
5492263
minor fixes/hacks to make clang-tidy command run
teju85 Mar 6, 2020
0fa695c
making PEP8 format fixes
teju85 Mar 6, 2020
3ef6616
removed an unnecessary break statement + added initial .clang-tidy
teju85 Mar 6, 2020
210f1a5
removed google-* clang tidy rules for now
teju85 Mar 6, 2020
671d5d6
added a select option to only check for certain source files
teju85 Mar 6, 2020
8e5176d
disabled most clang tidy checks for now
teju85 Mar 6, 2020
8519b5a
made warnings as errors
teju85 Mar 6, 2020
477aae2
suppressed switch-case warning too
teju85 Mar 6, 2020
f305336
enabled warnings/errors in the included header files too
teju85 Mar 6, 2020
8b9ef20
fixed correct option for clang gpu-arch
teju85 Mar 6, 2020
f3e065d
optimal packing order for cumlHandle_impl members based on clang-tidy
teju85 Mar 6, 2020
59a9c03
removed other unknown options to clang
teju85 Mar 6, 2020
3f687ed
disabled checks on cuda files for now
teju85 Mar 6, 2020
23cbab3
filter diagnostics for headers from cuml only
teju85 Mar 6, 2020
546946f
fixed clang-tidy error in holtwinters C code
teju85 Mar 6, 2020
1fb02ad
currently do not consider examples/ folder for clang tidy checks
teju85 Mar 6, 2020
60f54a0
fixed clang tidy errors
teju85 Mar 6, 2020
1f9d330
removed google clang-tidy rules, for now
teju85 Mar 12, 2020
a3705ee
use clang-based system headers instead of the ones from gcc toolchain
teju85 Mar 12, 2020
cfae269
updated the location of latest clang headers
teju85 Mar 13, 2020
b1956e9
enabled compilation database generation in cmake for clang-tidy purposes
teju85 Mar 13, 2020
4869ad7
removed nocudalib option
teju85 Mar 13, 2020
344f4ac
-j option for parallel compilation
teju85 Mar 13, 2020
ffc5825
relaxed the ignore regex slightly
teju85 Mar 13, 2020
e58e2b8
parallel processing of clang-tidy targets for runtime reduction
teju85 Mar 13, 2020
1f6d9c3
by default do parallel clang-tidy processing
teju85 Mar 13, 2020
c2f79dc
Merge branch 'branch-0.14' of https://github.com/rapidsai/cuml into f…
teju85 Mar 29, 2020
6350ecd
Merge branch 'branch-0.14' of https://github.com/rapidsai/cuml into f…
teju85 Apr 2, 2020
b06171b
update changelog
teju85 Apr 2, 2020
4d25d0d
clang format updates
teju85 Apr 2, 2020
9161a0e
install clang and clang-tools needed for clang-tidy checker
teju85 Apr 2, 2020
d356642
updated clang-tidy expected version to 8.0.1
teju85 Apr 2, 2020
d4d3429
explicit code paths to run tidy checks sequentially and parallely
teju85 Apr 2, 2020
e2fbee4
usage of subprocess.run in order to capture clang-tidy output accurately
teju85 Apr 2, 2020
689c192
added run-clang-tidy command inside ci/gpu/build.sh
teju85 Apr 2, 2020
40cedc1
Merge branch 'branch-0.14' of https://github.com/rapidsai/cuml into f…
teju85 Apr 3, 2020
c1a43ab
Merge branch 'branch-0.14' of https://github.com/rapidsai/cuml into f…
teju85 Apr 7, 2020
a7ef858
ENH removed clang and clang-tools installation as they are already in…
teju85 Apr 7, 2020
bc335a9
ENH removed code duplication between parallel and sequential paths
teju85 May 7, 2020
131e0cd
Merge branch 'branch-0.14' of https://github.com/rapidsai/cuml into f…
teju85 May 7, 2020
d56ced1
FIX do not lint spdlog headers
teju85 May 7, 2020
4c2c1a5
FIX clang-format fixes
teju85 May 7, 2020
395aee8
CI moved tidy checker logic from gpu/build.sh to checks/style.sh
teju85 May 8, 2020
56e2362
FIX help discover nvcc during the check-style CI
teju85 May 9, 2020
932de36
FIX do not evaluate_gpu_archs in check-style CI
teju85 May 9, 2020
9a7f9cf
FIX download all dependencies in check-styl CI before starting clang-…
teju85 May 9, 2020
f0fb06f
FIX added faiss blas libaries option to cmake command in style.sh
teju85 May 9, 2020
fe4a10c
FIX reordered dependencies to simplify clang-tidy check setup in styl…
teju85 May 9, 2020
2423a5c
FIX download all dependencies for clang-tidy to run correctly in styl…
teju85 May 9, 2020
57a8969
FIX install ucx-py dependency in style.sh
teju85 May 9, 2020
0548880
FIX install more dependencies
teju85 May 9, 2020
0803f67
FIX install openblas needed for faiss build
teju85 May 9, 2020
c46fb0e
Merge branch 'branch-0.14' of https://github.com/rapidsai/cuml into f…
teju85 May 9, 2020
52d46ea
FIX use anaconda channel for installing openblas
teju85 May 9, 2020
152976c
FIX update LD_LIBRARY_PATH to be able to use openblas library success…
teju85 May 9, 2020
f86b7ea
DOC copyright year update
teju85 May 9, 2020
00aa3fe
FIX ignore tidy for the 3rd-party headers
teju85 May 9, 2020
2cb30cf
FIX updated clang-tidy header-filter to only look at cuml source/head…
teju85 May 9, 2020
fd0fca5
Merge branch 'branch-0.14' of https://github.com/rapidsai/cuml into f…
teju85 May 11, 2020
ab16823
Merge branch 'branch-0.14' of https://github.com/rapidsai/cuml into f…
teju85 May 13, 2020
5a2d6a8
Merge branch 'branch-0.14' of https://github.com/rapidsai/cuml into f…
teju85 May 16, 2020
6c88a6d
CI only install latest ucx-py inside style.sh
teju85 May 16, 2020
440aa31
Merge branch 'branch-0.15' of https://github.com/rapidsai/cuml into f…
teju85 May 24, 2020
7acbf99
DOC update changelog
teju85 May 24, 2020
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- PR #1947: Cleaning up cmake
- PR #1927: Use Cython's `new_build_ext` (if available)
- PR #1946: Removed zlib dependency from cmake
- PR #1945: enable clang tidy
- PR #1988: C++: cpp bench refactor
- PR #1873: Remove usage of nvstring and nvcat from LabelEncoder
- PR #1968: Update SVC SVR with cuML Array
Expand Down
50 changes: 46 additions & 4 deletions ci/checks/style.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
#!/bin/bash
# Copyright (c) 2019, NVIDIA CORPORATION.
# Copyright (c) 2019-2020, NVIDIA CORPORATION.
#####################
# cuML Style Tester #
#####################

# Ignore errors and set path
set +e
PATH=/conda/bin:$PATH
export PATH=/conda/bin:/usr/local/cuda/bin:$PATH

# Activate common conda env
# Activate common conda env and install any dependencies needed
source activate gdf
cd $WORKSPACE
export GIT_DESCRIBE_TAG=`git describe --tags`
export MINOR_VERSION=`echo $GIT_DESCRIBE_TAG | grep -o -E '([0-9]+\.[0-9]+)'`
conda install -c rapidsai -c anaconda \
"lapack" \
"openblas" \
"ucx-py=${MINOR_VERSION}"

# Run flake8 and get results/return code
FLAKE=`flake8 --exclude=cpp,thirdparty,__init__.py,versioneer.py && flake8 --config=python/.flake8.cython`
Expand Down Expand Up @@ -66,7 +73,6 @@ else
fi

# Check for a consistent code format
# TODO: keep adding more dirs when we add more source folders in cuml
FORMAT=`python cpp/scripts/run-clang-format.py 2>&1`
FORMAT_RETVAL=$?
if [ "$RETVAL" = "0" ]; then
Expand All @@ -82,4 +88,40 @@ else
echo -e "\n\n>>>> PASSED: clang format check\n\n"
fi

# clang-tidy check
# NOTE:
# explicitly pass GPU_ARCHS flag to avoid having to evaluate gpu archs
# because there's no GPU on the CI machine where this script runs!
# NOTE:
# also, sync all dependencies as they'll be needed by clang-tidy to find
# relevant headers
function setup_and_run_clang_tidy() {
local LD_LIBRARY_PATH_CACHED=$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH
mkdir cpp/build && \
cd cpp/build && \
cmake -DGPU_ARCHS=70 \
-DBLAS_LIBRARIES=${CONDA_PREFIX}/lib/libopenblas.so.0 \
.. && \
make treelite && \
cd ../.. && \
python cpp/scripts/run-clang-tidy.py
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH_CACHED
}
TIDY=`setup_and_run_clang_tidy 2>&1`
TIDY_RETVAL=$?
if [ "$RETVAL" = "0" ]; then
RETVAL=$TIDY_RETVAL
fi

# Output results if failure otherwise show pass
if [ "$TIDY_RETVAL" != "0" ]; then
echo -e "\n\n>>>> FAILED: clang tidy check; begin output\n\n"
echo -e "$TIDY"
echo -e "\n\n>>>> FAILED: clang tidy check; end output\n\n"
else
echo -e "\n\n>>>> PASSED: clang tidy check\n\n"
fi


exit $RETVAL
1 change: 0 additions & 1 deletion ci/gpu/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ python setup.py install

cd $WORKSPACE


################################################################################
# TEST - Run GoogleTest and py.tests for libcuml and cuML
################################################################################
Expand Down
145 changes: 145 additions & 0 deletions cpp/.clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
---
Checks: 'clang-diagnostic-*,clang-analyzer-*,-modernize-*,-clang-diagnostic-#pragma-messages,-readability-identifier-naming,-clang-diagnostic-switch'
WarningsAsErrors: '*'
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle: none
CheckOptions:
- key: cert-dcl16-c.NewSuffixes
value: 'L;LL;LU;LLU'
- key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: '1'
- key: modernize-loop-convert.MaxCopySize
value: '16'
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: modernize-loop-convert.NamingStyle
value: CamelCase
- key: modernize-pass-by-value.IncludeStyle
value: llvm
- key: modernize-pass-by-value.ValuesOnly
value: '0'
- key: modernize-replace-auto-ptr.IncludeStyle
value: llvm
- key: modernize-replace-random-shuffle.IncludeStyle
value: llvm
- key: modernize-use-auto.MinTypeNameLength
value: '5'
- key: modernize-use-auto.RemoveStars
value: '0'
- key: modernize-use-default-member-init.IgnoreMacros
value: '1'
- key: modernize-use-default-member-init.UseAssignment
value: '0'
- key: modernize-use-emplace.ContainersWithPushBack
value: '::std::vector;::std::list;::std::deque'
- key: modernize-use-emplace.SmartPointers
value: '::std::shared_ptr;::std::unique_ptr;::std::auto_ptr;::std::weak_ptr'
- key: modernize-use-emplace.TupleMakeFunctions
value: '::std::make_pair;::std::make_tuple'
- key: modernize-use-emplace.TupleTypes
value: '::std::pair;::std::tuple'
- key: modernize-use-equals-default.IgnoreMacros
value: '1'
- key: modernize-use-equals-delete.IgnoreMacros
value: '1'
- key: modernize-use-nodiscard.ReplacementString
value: '[[nodiscard]]'
- key: modernize-use-noexcept.ReplacementString
value: ''
- key: modernize-use-noexcept.UseNoexceptFalse
value: '1'
- key: modernize-use-nullptr.NullMacros
value: 'NULL'
- key: modernize-use-transparent-functors.SafeMode
value: '0'
- key: modernize-use-using.IgnoreMacros
value: '1'
- key: readability-identifier-naming.ClassCase
value: CamelCase
- key: readability-identifier-naming.ClassPrefix
value: ''
- key: readability-identifier-naming.ClassSuffix
value: ''
- key: readability-identifier-naming.ConstexprVariableCase
value: CamelCase
- key: readability-identifier-naming.ConstexprVariablePrefix
value: k
- key: readability-identifier-naming.ConstexprVariableSuffix
value: ''
- key: readability-identifier-naming.EnumCase
value: CamelCase
- key: readability-identifier-naming.EnumConstantPrefix
value: k
- key: readability-identifier-naming.EnumConstantSuffix
value: ''
- key: readability-identifier-naming.EnumPrefix
value: ''
- key: readability-identifier-naming.EnumSuffix
value: ''
- key: readability-identifier-naming.FunctionCase
value: CamelCase
- key: readability-identifier-naming.FunctionPrefix
value: ''
- key: readability-identifier-naming.FunctionSuffix
value: ''
- key: readability-identifier-naming.GlobalConstantCase
value: CamelCase
- key: readability-identifier-naming.GlobalConstantPrefix
value: k
- key: readability-identifier-naming.GlobalConstantSuffix
value: ''
- key: readability-identifier-naming.IgnoreFailedSplit
value: '0'
- key: readability-identifier-naming.MemberCase
value: lower_case
- key: readability-identifier-naming.MemberPrefix
value: ''
- key: readability-identifier-naming.MemberSuffix
value: ''
- key: readability-identifier-naming.NamespaceCase
value: lower_case
- key: readability-identifier-naming.NamespacePrefix
value: ''
- key: readability-identifier-naming.NamespaceSuffix
value: ''
- key: readability-identifier-naming.PrivateMemberPrefix
value: ''
- key: readability-identifier-naming.PrivateMemberSuffix
value: _
- key: readability-identifier-naming.ProtectedMemberPrefix
value: ''
- key: readability-identifier-naming.ProtectedMemberSuffix
value: _
- key: readability-identifier-naming.StaticConstantCase
value: CamelCase
- key: readability-identifier-naming.StaticConstantPrefix
value: k
- key: readability-identifier-naming.StaticConstantSuffix
value: ''
- key: readability-identifier-naming.StructCase
value: CamelCase
- key: readability-identifier-naming.StructPrefix
value: ''
- key: readability-identifier-naming.StructSuffix
value: ''
- key: readability-identifier-naming.TypeAliasCase
value: CamelCase
- key: readability-identifier-naming.TypeAliasPrefix
value: ''
- key: readability-identifier-naming.TypeAliasSuffix
value: ''
- key: readability-identifier-naming.TypeTemplateParameterCase
value: CamelCase
- key: readability-identifier-naming.TypeTemplateParameterPrefix
value: ''
- key: readability-identifier-naming.TypeTemplateParameterSuffix
value: ''
- key: readability-identifier-naming.TypedefCase
value: CamelCase
- key: readability-identifier-naming.TypedefPrefix
value: ''
- key: readability-identifier-naming.TypedefSuffix
value: ''
...

3 changes: 3 additions & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
"Debug" "Release")
endif()

# this is needed for clang-tidy runs
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

##############################################################################
# - User Options ------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion cpp/bench/prims/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
* limitations under the License.
*/

#include <benchmark/benchmark.h>
#include <benchmark/benchmark.h> // NOLINT

BENCHMARK_MAIN();
2 changes: 1 addition & 1 deletion cpp/bench/sg/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
* limitations under the License.
*/

#include <benchmark/benchmark.h>
#include <benchmark/benchmark.h> // NOLINT

BENCHMARK_MAIN();
6 changes: 3 additions & 3 deletions cpp/cmake/Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ set_property(TARGET benchmarklib PROPERTY
add_dependencies(cub raft)
add_dependencies(cutlass cub)
add_dependencies(spdlog cutlass)
add_dependencies(faiss spdlog)
add_dependencies(googletest spdlog)
add_dependencies(benchmark googletest)
add_dependencies(faiss benchmark)
add_dependencies(faisslib faiss)
add_dependencies(treelite faiss)
add_dependencies(googletest treelite)
add_dependencies(benchmark googletest)
Loading