From ff4d3e2cdc2ae62605680bc1b0a2fb0bcbcafd1a Mon Sep 17 00:00:00 2001 From: thansen-amd Date: Thu, 26 Oct 2023 16:45:32 -0600 Subject: [PATCH 1/4] asan CI setup and settings map rework --- .jenkins/asan.groovy | 93 ++++++++++++++++++++++++++++++++++ .jenkins/common.groovy | 23 ++++++--- .jenkins/precheckin.groovy | 6 ++- .jenkins/staticanalysis.groovy | 4 +- .jenkins/staticlibrary.groovy | 6 ++- 5 files changed, 121 insertions(+), 11 deletions(-) create mode 100644 .jenkins/asan.groovy diff --git a/.jenkins/asan.groovy b/.jenkins/asan.groovy new file mode 100644 index 000000000..e859cf4e6 --- /dev/null +++ b/.jenkins/asan.groovy @@ -0,0 +1,93 @@ +#!/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('rocThrust', 'address-sanitizer') + + prj.defaults.ccache = true + prj.timeout.compile = 420 + + // 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":[pipelineTriggers([cron('0 1 * * 0')])], + "compute-rocm-dkms-no-npi-hipclang":[pipelineTriggers([cron('0 1 * * 0')])], + "rocm-docker":[]] + propertyList = auxiliary.appendPropertyList(propertyList) + + Set standardJobNameSet = ["compute-rocm-dkms-no-npi", "compute-rocm-dkms-no-npi-hipclang", "rocm-docker"] + + def jobNameList = ["compute-rocm-dkms-no-npi":([ubuntu16:['gfx900'],centos7:['gfx906'],sles15sp1:['gfx908']]), + "compute-rocm-dkms-no-npi-hipclang":([ubuntu16:['gfx900'],centos7:['gfx906'],sles15sp1:['gfx908']]), + "rocm-docker":([ubuntu16:['gfx900'],centos7:['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 e8ce7e00c..b45167288 100644 --- a/.jenkins/common.groovy +++ b/.jenkins/common.groovy @@ -1,17 +1,18 @@ // 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' : '' - def getRocPRIM = auxiliary.getLibrary('rocPRIM', platform.jenkinsLabel, null, sameOrg) + def getRocPRIM = auxiliary.getLibrary('rocPRIM', platform.jenkinsLabel, null, settings.sameOrg) def command = """#!/usr/bin/env bash set -x @@ -19,20 +20,21 @@ def runCompileCommand(platform, project, jobName, boolean debug=false, boolean s cd ${project.paths.project_build_prefix} mkdir -p build/${buildTypeDir} && cd build/${buildTypeDir} ${auxiliary.gfxTargetParser()} - ${cmake} -DCMAKE_CXX_COMPILER=/opt/rocm/bin/hipcc ${buildTypeArg} ${amdgpuTargets} -DBUILD_TEST=ON -DBUILD_BENCHMARK=ON ../.. + ${cmake} -DCMAKE_CXX_COMPILER=/opt/rocm/bin/hipcc ${buildTypeArg} ${amdgpuTargets} ${asanFlag} -DBUILD_TEST=ON -DBUILD_BENCHMARK=ON ../.. make -j\$(nproc) """ platform.runCommand(this, command) } -def runTestCommand (platform, project) +def runTestCommand (platform, project, settings) { String sudo = auxiliary.sudo(platform.jenkinsLabel) def testCommand = "ctest --output-on-failure" def hmmTestCommand = '' def excludeRegex = 'reduce_by_key.hip' + def LD_PATH = '' if (platform.jenkinsLabel.contains('gfx11')) { @@ -51,11 +53,20 @@ def runTestCommand (platform, project) // """ } + 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}") + """ + } + def command = """ #!/usr/bin/env bash set -x cd ${project.paths.project_build_prefix} cd ${project.testDirectory} + ${LD_PATH} ${testCommand} ${testCommandExclude} ${hmmTestCommand} """ diff --git a/.jenkins/precheckin.groovy b/.jenkins/precheckin.groovy index 6e633a92d..2e083ea10 100644 --- a/.jenkins/precheckin.groovy +++ b/.jenkins/precheckin.groovy @@ -25,19 +25,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 7d2cf06a3..f9c01198a 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 636995caf..1b02917dd 100644 --- a/.jenkins/staticlibrary.groovy +++ b/.jenkins/staticlibrary.groovy @@ -17,6 +17,8 @@ def runCI = def commonGroovy + def settings = [debug: false, sameOrg: true] + boolean formatCheck = false def compileCommand = @@ -24,7 +26,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) } @@ -32,7 +34,7 @@ def runCI = { platform, project-> - commonGroovy.runTestCommand(platform, project) + commonGroovy.runTestCommand(platform, project, settings) } def packageCommand = From df9e3df461ba68a715ee96ff89163d415bacf4ba Mon Sep 17 00:00:00 2001 From: thansen-amd Date: Tue, 31 Oct 2023 08:20:10 -0600 Subject: [PATCH 2/4] formatting --- .jenkins/common.groovy | 6 +++--- .jenkins/staticanalysis.groovy | 4 ++-- .jenkins/staticlibrary.groovy | 1 - 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.jenkins/common.groovy b/.jenkins/common.groovy index b45167288..66130dd93 100644 --- a/.jenkins/common.groovy +++ b/.jenkins/common.groovy @@ -56,9 +56,9 @@ def runTestCommand (platform, project, settings) 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}") - """ + 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}") + """ } def command = """ diff --git a/.jenkins/staticanalysis.groovy b/.jenkins/staticanalysis.groovy index f9c01198a..6c437b7ec 100644 --- a/.jenkins/staticanalysis.groovy +++ b/.jenkins/staticanalysis.groovy @@ -32,10 +32,10 @@ def runCI = { platform, project-> - runCompileCommand(platform, project, jobName, settings) + runCompileCommand(platform, project, jobName, settings.debug) } - buildProject(prj , formatCheck, nodes.dockerArray, compileCommand, null, null, staticAnalysis) + buildProject(prj, formatCheck, nodes.dockerArray, compileCommand, null, null, staticAnalysis) } ci: { diff --git a/.jenkins/staticlibrary.groovy b/.jenkins/staticlibrary.groovy index 1b02917dd..dd65c2221 100644 --- a/.jenkins/staticlibrary.groovy +++ b/.jenkins/staticlibrary.groovy @@ -28,7 +28,6 @@ def runCI = commonGroovy = load "${project.paths.project_src_prefix}/.jenkins/common.groovy" commonGroovy.runCompileCommand(platform, project, jobName, settings) } - def testCommand = { From a44de7e35f6fd08b499b41580f65d167faeeeb9b Mon Sep 17 00:00:00 2001 From: thansen-amd Date: Tue, 31 Oct 2023 16:08:13 -0600 Subject: [PATCH 3/4] sameOrg but more bool --- .jenkins/common.groovy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.jenkins/common.groovy b/.jenkins/common.groovy index 66130dd93..6d1bb0c38 100644 --- a/.jenkins/common.groovy +++ b/.jenkins/common.groovy @@ -11,8 +11,9 @@ def runCompileCommand(platform, project, jobName, settings) //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, settings.sameOrg) + def getRocPRIM = auxiliary.getLibrary('rocPRIM', platform.jenkinsLabel, null, sameOrg) def command = """#!/usr/bin/env bash set -x From e6ac7f8861fbfacb70907eede6b79bfb1335711d Mon Sep 17 00:00:00 2001 From: thansen-amd Date: Thu, 2 Nov 2023 09:25:53 -0600 Subject: [PATCH 4/4] compile time += 1 hour --- .jenkins/asan.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.jenkins/asan.groovy b/.jenkins/asan.groovy index e859cf4e6..b80d7b6b1 100644 --- a/.jenkins/asan.groovy +++ b/.jenkins/asan.groovy @@ -16,7 +16,7 @@ def runCI = def prj = new rocProject('rocThrust', 'address-sanitizer') prj.defaults.ccache = true - prj.timeout.compile = 420 + prj.timeout.compile = 480 // Define test architectures, optional rocm version argument is available def nodes = new dockerNodes(nodeDetails, jobName, prj)