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

ASAN Setup #96

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions .jenkins/asan.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/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('hipRAND', 'address-sanitizer')
prj.libraryDependencies = ['rocRAND']

def nodes = new dockerNodes(nodeDetails, jobName, prj)

def commonGroovy

boolean formatCheck = false

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 = []
propertyList = auxiliary.appendPropertyList(propertyList)

def jobNameList = [:]
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 * * 6')])]))
stage(urlJobName) {
runCI(['ubuntu20-cuda11':['anycuda']], urlJobName)
}
}
}
27 changes: 20 additions & 7 deletions .jenkins/common.groovy
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// 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 sameOrg=false)
def runCompileCommand(platform, project, jobName, settings)
{
project.paths.construct_build_prefix()

boolean sameOrg = settings.sameOrg ?: false

def getDependenciesCommand = ""
if (project.installLibraryDependenciesFromCI)
{
Expand All @@ -16,13 +18,14 @@ def runCompileCommand(platform, project, jobName, boolean debug=false, boolean s
}

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 buildTypeArg = settings.debug ? '-DCMAKE_BUILD_TYPE=Debug' : '-DCMAKE_BUILD_TYPE=Release'
String buildTypeDir = settings.debug ? 'debug' : 'release'
String buildStatic = settings.staticLibrary ? '-DBUILD_STATIC_LIBS=ON' : '-DBUILD_SHARED=OFF'
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 compiler = '/opt/rocm/bin/hipcc'
String asanFlag = settings.addressSanitizer ? '-DBUILD_ADDRESS_SANITIZER=ON' : ''
String useCUDA = ''
if (platform.jenkinsLabel.contains('cuda'))
{
Expand All @@ -39,25 +42,35 @@ def runCompileCommand(platform, project, jobName, boolean debug=false, boolean s
# gfxTargetParser reads gfxarch and adds target features such as xnack
${auxiliary.gfxTargetParser()}
echo "ROCM_PATH = \${ROCM_PATH}"
${cmake} -DCMAKE_CXX_COMPILER=${compiler} ${useCUDA} ${buildTypeArg} ${buildStatic} ${amdgpuTargets} -DBUILD_TEST=ON -DBUILD_BENCHMARK=ON ../..
${cmake} -DCMAKE_CXX_COMPILER=${compiler} ${useCUDA} ${buildTypeArg} ${buildStatic} ${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 extraArgs = platform.jenkinsLabel.contains('cuda') ? "-E test_hiprand_linkage" : ""
def testCommand = "ctest ${extraArgs} --output-on-failure"

def LD_PATH = 'export LD_LIBRARY_PATH=/opt/rocm/lib/'
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}/build/release
make -j4
${sudo} LD_LIBRARY_PATH=/opt/rocm/lib/ ${testCommand}
${LD_PATH}
${sudo} ${testCommand}
"""

platform.runCommand(this, command)
Expand Down
6 changes: 4 additions & 2 deletions .jenkins/precheckin-cuda.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,24 @@ def runCI =

def commonGroovy

def settings = [:]

boolean formatCheck = false

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 =
Expand Down
6 changes: 4 additions & 2 deletions .jenkins/staticanalysis.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ 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)
buildProject(prj, formatCheck, nodes.dockerArray, compileCommand, null, null, staticAnalysis)
}

ci: {
Expand Down
7 changes: 4 additions & 3 deletions .jenkins/staticlibrary.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,22 @@ def runCI =
def commonGroovy

boolean formatCheck = false

def settings = [staticLibrary: true]

def compileCommand =
{
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)
}


def testCommand =
{
platform, project->

commonGroovy.runTestCommand(platform, project)
commonGroovy.runTestCommand(platform, project, settings)
}

def packageCommand =
Expand Down