diff --git a/.jenkins/asan.groovy b/.jenkins/asan.groovy new file mode 100644 index 00000000..5068f16f --- /dev/null +++ b/.jenkins/asan.groovy @@ -0,0 +1,84 @@ +#!/usr/bin/env groovy +// This shared library is available at https://github.com/ROCmSoftwarePlatform/rocJENKINS/ +@Library('rocJenkins@pong') _ + +// This file is for internal AMD use. +// If you are interested in running your own Jenkins, please raise a github issue for assistance. + +import com.amd.project.* +import com.amd.docker.* +import java.nio.file.Path; + +def runCI = +{ + nodeDetails, jobName-> + + def prj = new rocProject('hipCUB', 'address-sanitizer') + + // Define test architectures, optional rocm version argument is available + def nodes = new dockerNodes(nodeDetails, jobName, prj) + + boolean formatCheck = false + + def commonGroovy + + def settings = [addressSanitizer: true] + + def compileCommand = + { + platform, project-> + + commonGroovy = load "${project.paths.project_src_prefix}/.jenkins/common.groovy" + commonGroovy.runCompileCommand(platform, project, jobName, settings) + } + + def testCommand = + { + platform, project-> + + commonGroovy.runTestCommand(platform, project, settings) + } + + def packageCommand = + { + platform, project-> + + commonGroovy.runPackageCommand(platform, project) + } + + buildProject(prj, formatCheck, nodes.dockerArray, compileCommand, testCommand, packageCommand) +} + +ci: { + String urlJobName = auxiliary.getTopJobName(env.BUILD_URL) + + def propertyList = ["compute-rocm-dkms-no-npi-hipclang":[pipelineTriggers([cron('0 1 * * 0')])]] + propertyList = auxiliary.appendPropertyList(propertyList) + + def jobNameList = ["compute-rocm-dkms-no-npi-hipclang":([ubuntu18:['gfx900'],centos7:['gfx906'],centos8:['gfx906'],sles15sp1:['gfx908']])] + jobNameList = auxiliary.appendJobNameList(jobNameList) + + propertyList.each + { + jobName, property-> + if (urlJobName == jobName) + properties(auxiliary.addCommonProperties(property)) + } + + Set seenJobNames = [] + jobNameList.each + { + jobName, nodeDetails-> + seenJobNames.add(jobName) + if (urlJobName == jobName) + runCI(nodeDetails, jobName) + } + + // For url job names that are outside of the standardJobNameSet i.e. compute-rocm-dkms-no-npi-1901 + if(!seenJobNames.contains(urlJobName)) + { + properties(auxiliary.addCommonProperties([pipelineTriggers([cron('0 1 * * *')])])) + runCI([ubuntu16:['gfx906']], urlJobName) + } +} + diff --git a/.jenkins/common.groovy b/.jenkins/common.groovy index 79ebcb6f..3f08ee73 100644 --- a/.jenkins/common.groovy +++ b/.jenkins/common.groovy @@ -1,25 +1,30 @@ // This file is for internal AMD use. // If you are interested in running your own Jenkins, please raise a github issue for assistance. -def runCompileCommand(platform, project, jobName, boolean debug=false, boolean sameOrg=true) +def runCompileCommand(platform, project, jobName, settings) { project.paths.construct_build_prefix() - String buildTypeArg = debug ? '-DCMAKE_BUILD_TYPE=Debug' : '-DCMAKE_BUILD_TYPE=Release' - String buildTypeDir = debug ? 'debug' : 'release' + String buildTypeArg = settings.debug ? '-DCMAKE_BUILD_TYPE=Debug' : '-DCMAKE_BUILD_TYPE=Release' + String buildTypeDir = settings.debug ? 'debug' : 'release' String cmake = platform.jenkinsLabel.contains('centos') ? 'cmake3' : 'cmake' //Set CI node's gfx arch as target if PR, otherwise use default targets of the library String amdgpuTargets = env.BRANCH_NAME.startsWith('PR-') ? '-DAMDGPU_TARGETS=\$gfx_arch' : '' + String asanFlag = settings.addressSanitizer ? '-DBUILD_ADDRESS_SANITIZER=ON' : '' + boolean sameOrg = settings.sameOrg ?: false def getRocPRIM = auxiliary.getLibrary('rocPRIM', platform.jenkinsLabel, null, sameOrg) + if (settings.addressSanitizer){ + amdgpuTargets = '-DAMDGPU_TARGETS=\$gfx_arch:xnack+' + } def command = """#!/usr/bin/env bash set -x ${getRocPRIM} cd ${project.paths.project_build_prefix} mkdir -p build/${buildTypeDir} && cd build/${buildTypeDir} ${auxiliary.gfxTargetParser()} - ${cmake} --toolchain=toolchain-linux.cmake ${buildTypeArg} ${amdgpuTargets} -DBUILD_TEST=ON -DBUILD_BENCHMARK=ON ../.. + ${cmake} --toolchain=toolchain-linux.cmake ${buildTypeArg} ${amdgpuTargets} ${asanFlag} -DBUILD_TEST=ON -DBUILD_BENCHMARK=ON ../.. make -j\$(nproc) """ @@ -27,16 +32,38 @@ def runCompileCommand(platform, project, jobName, boolean debug=false, boolean s } -def runTestCommand (platform, project) +def runTestCommand (platform, project, settings) { String sudo = auxiliary.sudo(platform.jenkinsLabel) def testCommand = "ctest --output-on-failure --verbose --timeout 900" + def LD_PATH = 'export LD_LIBRARY_PATH=/opt/rocm/lib/' + def asanArgs = '' + if (settings.addressSanitizer) + { + LD_PATH = """ + export ASAN_LIB_PATH=\$(/opt/rocm/llvm/bin/clang -print-file-name=libclang_rt.asan-x86_64.so) + export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:\$(dirname "\${ASAN_LIB_PATH}") + """ + asanArgs = """ + export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/opt/rocm/llvm/lib/clang/18/lib/linux + export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/opt/rocm/lib/asan + export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/opt/rocm/libexec/rocm_smi + export ASAN_SYMBOLIZER_PATH=/opt/rocm/llvm/bin/llvm-symbolizer + export PATH=/opt/rocm/llvm/bin/:\$PATH + export PATH=/opt/rocm/:\$PATH + export HSA_XNACK=1 + export ASAN_OPTIONS=detect_leaks=0 + """ + } + def command = """#!/usr/bin/env bash set -x cd ${project.paths.project_build_prefix} cd ${project.testDirectory} - ${sudo} LD_LIBRARY_PATH=/opt/rocm/lib ${testCommand} + ${LD_PATH} + ${asanArgs} + ${sudo} ${testCommand} """ platform.runCommand(this, command) diff --git a/.jenkins/precheckin.groovy b/.jenkins/precheckin.groovy index e4bca657..6b79a833 100644 --- a/.jenkins/precheckin.groovy +++ b/.jenkins/precheckin.groovy @@ -22,19 +22,21 @@ def runCI = def commonGroovy + def settings = [:] + def compileCommand = { platform, project-> commonGroovy = load "${project.paths.project_src_prefix}/.jenkins/common.groovy" - commonGroovy.runCompileCommand(platform, project, jobName) + commonGroovy.runCompileCommand(platform, project, jobName, settings) } def testCommand = { platform, project-> - commonGroovy.runTestCommand(platform, project) + commonGroovy.runTestCommand(platform, project, settings) } def packageCommand = diff --git a/.jenkins/staticanalysis.groovy b/.jenkins/staticanalysis.groovy index 5c0b9490..c61d59a5 100644 --- a/.jenkins/staticanalysis.groovy +++ b/.jenkins/staticanalysis.groovy @@ -26,11 +26,13 @@ def runCI = boolean formatCheck = false boolean staticAnalysis = true + def settings = [debug: false] + def compileCommand = { platform, project-> - runCompileCommand(platform, project, jobName, false) + runCompileCommand(platform, project, jobName, settings) } buildProject(prj , formatCheck, nodes.dockerArray, compileCommand, null, null, staticAnalysis) diff --git a/.jenkins/staticlibrary.groovy b/.jenkins/staticlibrary.groovy index 549913d8..192f13bf 100644 --- a/.jenkins/staticlibrary.groovy +++ b/.jenkins/staticlibrary.groovy @@ -14,6 +14,8 @@ def runCI = def commonGroovy + def settings = [debug: false, sameOrg: true] + boolean formatCheck = false def compileCommand = @@ -21,7 +23,7 @@ def runCI = platform, project-> commonGroovy = load "${project.paths.project_src_prefix}/.jenkins/common.groovy" - commonGroovy.runCompileCommand(platform, project, jobName, false, true) + commonGroovy.runCompileCommand(platform, project, jobName, settings) } @@ -29,7 +31,7 @@ def runCI = { platform, project-> - commonGroovy.runTestCommand(platform, project) + commonGroovy.runTestCommand(platform, project, settings) } def packageCommand =