From 5e4625f6b4723ce6193623350ecaef38b4562d9c Mon Sep 17 00:00:00 2001 From: Illia Silin <98187287+illsilin@users.noreply.github.com> Date: Mon, 15 Jan 2024 09:11:45 -0800 Subject: [PATCH] Add cppcheck to CK CI. (#1125) * add cppcheck to the CK CI * fix the path to CK source for cppcheck * fix the path to CK source for cppcheck one more time * fix the path to CK source for cppcheck third time * change the path to ck_cppcheck.log * install latest cppcheck from source * fix bug in ck.hpp and use 20 threads for cppcheck * create a switch to turn cppckeck on and off in CI [ROCm/composable_kernel commit: e6d099c8309576c73ed3129d4e87ebc126c9a03e] --- Dockerfile | 7 ++++++- Jenkinsfile | 34 +++++++++++++++++++++++++++++++++- include/ck/ck.hpp | 2 +- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4b72855bac..a805285a77 100644 --- a/Dockerfile +++ b/Dockerfile @@ -74,7 +74,7 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --allow- apt-get clean && \ rm -rf /var/lib/apt/lists/* -#Install latest version of cmake +#Install ninja build tracing tools RUN wget -qO /usr/local/bin/ninja.gz https://github.com/ninja-build/ninja/releases/latest/download/ninja-linux.zip RUN gunzip /usr/local/bin/ninja.gz RUN chmod a+x /usr/local/bin/ninja @@ -82,6 +82,11 @@ RUN git clone https://github.com/nico/ninjatracing.git # Update the cmake to the latest version RUN pip install --upgrade cmake==3.27.5 +#Install latest cppcheck +RUN git clone https://github.com/danmar/cppcheck.git && \ + cd cppcheck && mkdir build && cd build && cmake .. && cmake --build . +WORKDIR / + # Setup ubsan environment to printstacktrace RUN ln -s /usr/bin/llvm-symbolizer-3.8 /usr/local/bin/llvm-symbolizer ENV UBSAN_OPTIONS=print_stacktrace=1 diff --git a/Jenkinsfile b/Jenkinsfile index 268cc7606f..e333a35ecd 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -304,7 +304,7 @@ def buildHipClangJob(Map conf=[:]){ gitStatusWrapper(credentialsId: "${status_wrapper_creds}", gitHubContext: "Jenkins - ${variant}", account: 'ROCm', repo: 'composable_kernel') { withDockerContainer(image: image, args: dockerOpts + ' -v=/var/jenkins/:/var/jenkins') { - timeout(time: 5, unit: 'HOURS') + timeout(time: 20, unit: 'HOURS') { cmake_build(conf) } @@ -709,6 +709,10 @@ pipeline { name: "USE_SCCACHE", defaultValue: true, description: "Use the sccache for building CK (default: ON)") + booleanParam( + name: "RUN_CPPCHECK", + defaultValue: false, + description: "Run the cppcheck static analysis (default: OFF)") } environment{ dbuser = "${dbuser}" @@ -735,7 +739,35 @@ pipeline { } stage("Static checks") { parallel{ + stage('Clang Format and Cppcheck') { + when { + beforeAgent true + expression { params.RUN_CPPCHECK.toBoolean() } + } + agent{ label rocmnode("nogpu") } + environment{ + execute_cmd = "find .. -not -path \'*.git*\' -iname \'*.h\' \ + -o -not -path \'*.git*\' -iname \'*.hpp\' \ + -o -not -path \'*.git*\' -iname \'*.cpp\' \ + -o -iname \'*.h.in\' \ + -o -iname \'*.hpp.in\' \ + -o -iname \'*.cpp.in\' \ + -o -iname \'*.cl\' \ + | grep -v 'build/' \ + | xargs -n 1 -P 1 -I{} -t sh -c \'clang-format-12 -style=file {} | diff - {}\' && \ + /cppcheck/build/bin/cppcheck ../* -v -j \$(nproc) -I ../include -I ../profiler/include -I ../library/include --file-filter=*.cpp --enable=all --output-file=ck_cppcheck.log" + } + steps{ + buildHipClangJobAndReboot(setup_cmd: "", build_cmd: "", execute_cmd: execute_cmd, no_reboot:true) + archiveArtifacts "build/ck_cppcheck.log" + cleanWs() + } + } stage('Clang Format') { + when { + beforeAgent true + expression { !params.RUN_CPPCHECK.toBoolean() } + } agent{ label rocmnode("nogpu") } environment{ execute_cmd = "find .. -not -path \'*.git*\' -iname \'*.h\' \ diff --git a/include/ck/ck.hpp b/include/ck/ck.hpp index a94057be4a..88efb0277b 100644 --- a/include/ck/ck.hpp +++ b/include/ck/ck.hpp @@ -218,7 +218,7 @@ // denorm test fix, required to work around dissue #ifndef CK_WORKAROUND_DENORM_FIX #define CK_WORKAROUND_DENORM_FIX 0 -#elif +#else // enable only on MI200 #define CK_WORKAROUND_DENORM_FIX = CK_WORKAROUND_DENORM_FIX && defined(__gfx90a__) #endif // CK_WORKAROUND_DENORM_FIX