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

Move clang-tidy, ASAN, UBSAN to clang-9 #3627

Closed
RudolfWeeber opened this issue Apr 3, 2020 · 18 comments · Fixed by #3684
Closed

Move clang-tidy, ASAN, UBSAN to clang-9 #3627

RudolfWeeber opened this issue Apr 3, 2020 · 18 comments · Fixed by #3684
Assignees

Comments

@RudolfWeeber
Copy link
Contributor

Results so far:
Build with Clang9 on the ICP machines:

  • Clang++ cannot be used for the Cuda code, unless we are prepared to patch thrust. The code makes use of va_printf which is not defined (Compilation with Clang fails, va_printf undeclared NVIDIA/thrust#1032). Alternatively, we could include the workaround discussed in the isseu in Espresso. Personally, I'd just use Nvcc.

  • The following clang-tidy checks get triggered due to a more modern clang-tidy:

    • bugprone-exception-escape,
    • bugprone-macro-parentheses,
    • bugprone-narrowing-conversions,
    • bugprone-unhandled-self-assignment,
    • modernize-avoid-c-arrays,

    As per the discussion on the Espresso meeting, I'll disable them. If we want, we can address (part of) them separately.

  • The ASAN needs ASAN_OPTIONS="allocator_may_return_null=1" to avoid an error from an OpenMPI library

@fweik
Copy link
Contributor

fweik commented Apr 3, 2020

bugprone-unhandled-self-assignment that sounds scary

@RudolfWeeber
Copy link
Contributor Author

@fweik, I think it was in the (copy or move) constructor of Utils::List

Some of the narrowing warnings should probably also be looked at.

@mkuron
Copy link
Member

mkuron commented Apr 3, 2020

Personally, I'd just use Nvcc.

That would get rid of clang-tidy checking on CUDA code. NVCC basically has no warnings, so if we can patch thrust we should do that to keep clang.

@fweik
Copy link
Contributor

fweik commented Apr 3, 2020

The bugprone-narrowing-conversions in src/shapes/src/SpheroCylinder.cpp:52:8 is almost certainly an actual bug. Seems like a useful warning to me.

@fweik
Copy link
Contributor

fweik commented Apr 3, 2020

The self-assignment is fixed in #3628, please do not remove the check.

@fweik
Copy link
Contributor

fweik commented Apr 3, 2020

The narrowing thing is fixed in #3629.

@fweik
Copy link
Contributor

fweik commented Apr 3, 2020

modernize-avoid-c-arrays has to be disabled I think: Utils::Array uses c-array as portable storage backend that also works on the GPU, which makes changing it more complicated. It's probably not
worthwhile to implemented a more sophisticated solution for this, because the GPU support for
Array can be removed with the soonish (?) removal of the GPU LB.

@RudolfWeeber
Copy link
Contributor Author

@fweik, I'll re-enable the checks corresponding to your fixes.
#mkuron,
Getting rid of patched boost/thrust/other-stuff and getting the CI containers simple is my main goal with this project.
Also, peoples' dev environments should be (apt-install)-simple. People should be able to just use clang-tidy and the sanitizers on the ICP machines.

Also, a lot of the GPU stuff will go away, once we are ready with Walberla.

I'll check, if the workaround suggested in the issue mentioned can easily be integrated. If not...

@fweik
Copy link
Contributor

fweik commented Apr 3, 2020

I'll also fix bugprone-exception-escape

@mkuron
Copy link
Member

mkuron commented Apr 3, 2020

peoples' dev environments should be (apt-install)-simple. People should be able to just use clang-tidy and the sanitizers on the ICP machines.

Sure, but sometimes that is not possible. Clang is a useful tool and helps find actual bugs before they become big problems. Complex tools like that require some maintenance effort; and as long as that only means patching a file, it‘s not worth forgoing correctness in favor of simplicity.

@jngrad
Copy link
Member

jngrad commented Apr 9, 2020

The va_printf compiler error is fixed in thrust 1.9.5, which should be shipped with CUDA 10.1. I've installed thrust 1.9.5 in a local copy of CUDA 10.0 and the compiler error disappeared, and all GPU tests passed, using commit 58bdbc8 from #3582 and the following CMake command:

cmake .. -DWITH_CUDA=ON -DWITH_CUDA_COMPILER=clang \
  -DCMAKE_BUILD_TYPE=RelWithAssert -DWITH_COVERAGE=OFF \
  -DCMAKE_C_COMPILER=$(which clang-9) \
  -DCMAKE_CXX_COMPILER=$(which clang++-9) \
  -DCMAKE_CXX_FLAGS=--cuda-path=/work/jgrad/cuda-10.0-thrust195 \
  -DCUDA_NVCC_FLAGS=--cuda-path=/work/jgrad/cuda-10.0-thrust195

@RudolfWeeber
Copy link
Contributor Author

RudolfWeeber commented Apr 9, 2020 via email

@jngrad
Copy link
Member

jngrad commented Apr 9, 2020

That's odd, because /usr/local/cuda-10.0 is the only CUDA 10 version I see on the ICP machines. I just logged in bee and it only has /usr/local/cuda-10.2 (with thrust 1.9.7). I couldn't try compiling on bee because CMake is too old and pip is not installed.

@fweik
Copy link
Contributor

fweik commented Apr 9, 2020

@jngrad you can load a more recent cmake as a module on bee.

@jngrad
Copy link
Member

jngrad commented Apr 9, 2020

I'm not very used to bee :) I just did module load cmake clang to get the latest CMake, but clang is not found.

@RudolfWeeber
Copy link
Contributor Author

@jngrad, you're right. Looks like I misread sth

@jngrad
Copy link
Member

jngrad commented Apr 9, 2020

@RudolfWeeber I ran into issues with Clang++-9 in the Ubuntu 20.04 image with CUDA 10.1 installed. You might want to have a look at the compiler error, it's in #3650.

@jngrad jngrad self-assigned this Apr 23, 2020
@jngrad
Copy link
Member

jngrad commented Apr 23, 2020

I've addressed the majority of the Clang-Tidy 9 warnings. modernize-avoid-c-arrays was disabled since it's triggered in too many places. bugprone-macro-parentheses was temporarily disabled, until we refactor the macros in the rhomboid shape. The two warnings triggered by boost::mpi in Boost <1.96 were configured such that they don't become compiler errors; we can't exclude those warnings with a line filter: #3650 (comment). // NOLINT was added in a few places where the warning was either a false positive, or a true positive for which I couldn't find a quick fix. The changes to the CUDA code are substantial, since Clang-Tidy 6 ignored them in CI for a while.

@kodiakhq kodiakhq bot closed this as completed in #3684 Apr 25, 2020
kodiakhq bot added a commit that referenced this issue Apr 25, 2020
Fixes #3627, fixes #3650, closes #3636

Description of changes:
- run Clang-Tidy, ASAN, UBSAN in the Ubuntu 20.04 image
- re-enable Clang-Tidy on CUDA code
- fix Clang-Tidy 9 warnings
- replace `boost::optional` by custom code in CUDA sources
- remove unused code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants