diff --git a/.jenkins/asan.groovy b/.jenkins/asan.groovy new file mode 100644 index 00000000..71fbc01c --- /dev/null +++ b/.jenkins/asan.groovy @@ -0,0 +1,80 @@ +#!/usr/bin/env groovy +@Library('rocJenkins@pong') _ +import com.amd.project.* +import com.amd.docker.* +import java.nio.file.Path; + +def runCI = +{ + nodeDetails, jobName-> + + def prj = new rocProject('rocRAND', 'address-sanitizer') + + def nodes = new dockerNodes(nodeDetails, jobName, prj) + + def commonGroovy + + def settings = [addressSanitizer: true] + + boolean formatCheck = false + + 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)) + } + + jobNameList.each + { + jobName, nodeDetails-> + if (urlJobName == jobName) + stage(jobName) { + runCI(nodeDetails, jobName) + } + } + + // For url job names that are not listed by the jobNameList i.e. compute-rocm-dkms-no-npi-1901 + if(!jobNameList.keySet().contains(urlJobName)) + { + properties(auxiliary.addCommonProperties([pipelineTriggers([cron('0 1 * * *')])])) + stage(urlJobName) { + runCI([ubuntu16:['gfx906']], urlJobName) + } + } +} \ No newline at end of file diff --git a/.jenkins/codecov.groovy b/.jenkins/codecov.groovy index ef6c6a7d..616f37af 100644 --- a/.jenkins/codecov.groovy +++ b/.jenkins/codecov.groovy @@ -14,6 +14,8 @@ def runCI = def commonGroovy + def settings = [codeCoverage: 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, false, true) + commonGroovy.runCompileCommand(platform, project, jobName, settings) } def testCommand = diff --git a/.jenkins/common.groovy b/.jenkins/common.groovy index d157cbb3..9cc362a4 100644 --- a/.jenkins/common.groovy +++ b/.jenkins/common.groovy @@ -1,15 +1,16 @@ // 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 staticLibrary=false, boolean codeCoverage=false) +def runCompileCommand(platform, project, jobName, settings) { project.paths.construct_build_prefix() project.paths.build_command = './install -c' - String buildTypeArg = debug ? '-DCMAKE_BUILD_TYPE=Debug' : '-DCMAKE_BUILD_TYPE=Release' - String buildTypeDir = debug ? 'debug' : 'release' - String buildStatic = staticLibrary ? '-DBUILD_STATIC_LIBS=ON' : '-DBUILD_SHARED=OFF' - String codeCovFlag = codeCoverage ? '-DCODE_COVERAGE=ON' : '' + String buildTypeArg = settings.debug ? '-DCMAKE_BUILD_TYPE=Debug' : '-DCMAKE_BUILD_TYPE=Release' + String buildTypeDir = settings.debug ?: 'release' + String buildStatic = settings.staticLibrary ? '-DBUILD_STATIC_LIBS=ON' : '-DBUILD_SHARED=OFF' + String codeCovFlag = settings.codeCoverage ? '-DCODE_COVERAGE=ON' : '' + String asanFlag = settings.addressSanitizer ? '-DBUILD_ADDRESS_SANITIZER=ON' : '' 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' : '' @@ -20,14 +21,14 @@ def runCompileCommand(platform, project, jobName, boolean debug=false, boolean s mkdir -p build/${buildTypeDir} && cd build/${buildTypeDir} # gfxTargetParser reads gfxarch and adds target features such as xnack ${auxiliary.gfxTargetParser()} - ${cmake} -DCMAKE_CXX_COMPILER=/opt/rocm/bin/hipcc ${buildTypeArg} ${buildStatic} ${amdgpuTargets} ${codeCovFlag} -DBUILD_TEST=ON -DBUILD_BENCHMARK=ON ../.. + ${cmake} -DCMAKE_CXX_COMPILER=/opt/rocm/bin/hipcc ${buildTypeArg} ${buildStatic} ${amdgpuTargets} ${codeCovFlag} ${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) // String centos = platform.jenkinsLabel.contains('centos') ? '3' : '' @@ -35,11 +36,15 @@ def runTestCommand (platform, project) // def testCommand = "ctest${centos} --output-on-failure" def testCommand = "ctest --output-on-failure" + String LD_PATH = settings.addressSanitizer ? """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 LD_LIBRARY_PATH=/opt/rocm/lib/' + def command = """#!/usr/bin/env bash set -x cd ${project.paths.project_build_prefix}/build/release make -j4 - ${sudo} LD_LIBRARY_PATH=/opt/rocm/lib/ ${testCommand} + ${LD_PATH} + ${sudo} ${testCommand} """ platform.runCommand(this, command) diff --git a/.jenkins/precheckin.groovy b/.jenkins/precheckin.groovy index d067fd85..386e56fc 100644 --- a/.jenkins/precheckin.groovy +++ b/.jenkins/precheckin.groovy @@ -14,6 +14,8 @@ def runCI = def commonGroovy + def settings = [:] + 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) + 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 = diff --git a/.jenkins/staticanalysis.groovy b/.jenkins/staticanalysis.groovy index 1bb7b4fa..6a08920f 100644 --- a/.jenkins/staticanalysis.groovy +++ b/.jenkins/staticanalysis.groovy @@ -9,13 +9,15 @@ import com.amd.project.* import com.amd.docker.* import java.nio.file.Path -def runCompileCommand(platform, project, jobName, boolean debug=false) +def runCompileCommand(platform, project, jobName, settings) { project.paths.construct_build_prefix() } def runCI = { + def settings = [:] + nodeDetails, jobName-> def prj = new rocProject('rocRAND', 'StaticAnalysis') @@ -30,7 +32,7 @@ def runCI = { platform, project-> - runCompileCommand(platform, project, jobName, false) + runCompileCommand(platform, project, jobName, settings) } buildProject(prj , formatCheck, nodes.dockerArray, compileCommand, null, null, staticAnalysis)