-
Notifications
You must be signed in to change notification settings - Fork 4
/
Jenkinsfile
185 lines (168 loc) · 6.32 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
def rocmnode(name) {
def node_name = 'tunatest'
if(name == 'fiji') {
node_name = 'tunatest && fiji';
} else if(name == 'vega') {
node_name = 'tunatest && vega';
} else if(name == 'vega10') {
node_name = 'tunatest && vega10';
} else if(name == 'vega20') {
node_name = 'tunatest && vega20';
} else if(name == 'gfx908') {
node_name = 'gfx908';
} else {
node_name = name
}
return node_name
}
def cmake_build(compiler, flags, prefixpath="/opt/rocm"){
def workspace_dir = pwd()
def archive = (flags == '-DCMAKE_BUILD_TYPE=release')
def config_targets = "all"
def test_flags = "--disable-verification-cache"
def debug_flags = "-g -fno-omit-frame-pointer -fsanitize=undefined -fno-sanitize-recover=undefined"
def compilerpath = ""
def configargs = ""
if (prefixpath == "")
compilerpath = compiler;
else
{
compilerpath = prefixpath + "/bin/" + compiler
configargs = "-DCMAKE_PREFIX_PATH=${prefixpath}"
}
if (archive == true) {
config_targets = "package"
}
def cmd = """
echo \$HSA_ENABLE_SDMA
ulimit -c unlimited
rm -rf build
mkdir build
cd build
CXX=${compilerpath} cmake ${configargs} ${flags} ..
dumb-init make -j\$(nproc) ${config_targets}
"""
echo cmd
sh cmd
// Only archive from master or develop
if (archive == true && (env.BRANCH_NAME == "develop" || env.BRANCH_NAME == "master")) {
archiveArtifacts artifacts: "build/*.deb", allowEmptyArchive: true, fingerprint: true
}
}
def buildJob(compiler, flags, image, prefixpath="/opt/rocm", cmd = ""){
env.HSA_ENABLE_SDMA=0
checkout scm
def dockerOpts="--device=/dev/kfd --device=/dev/dri --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --user=root --privileged "
def dockerArgs = "--build-arg PREFIX=${prefixpath} "
if(prefixpath == "")
{
dockerArgs = ""
}
def date = sh(script: 'date +"%m%d%H"', returnStdout: true).trim()
dockerArgs += " --build-arg CACHE_DATE=${date} "
def retimage
try {
echo "build docker"
retimage = docker.build("${image}", dockerArgs + ' .')
withDockerContainer(image: image, args: dockerOpts) {
timeout(time: 5, unit: 'MINUTES')
{
sh 'PATH="/opt/rocm/opencl/bin:/opt/rocm/opencl/bin/x86_64/:$PATH" clinfo'
}
}
} catch(Exception ex) {
echo "exception ocurred"
retimage = docker.build("${image}", dockerArgs + " --no-cache .")
withDockerContainer(image: image, args: dockerOpts) {
timeout(time: 5, unit: 'MINUTES')
{
sh 'PATH="/opt/rocm/opencl/bin:/opt/rocm/opencl/bin/x86_64/:$PATH" clinfo'
}
}
}
withDockerContainer(image: image, args: dockerOpts + ' -v=/var/jenkins/:/var/jenkins') {
timeout(time: 5, unit: 'HOURS')
{
if(cmd == ""){
cmake_build(compiler, flags, prefixpath)
}else{
echo "run shell command"
sh cmd
}
}
}
return retimage
}
pipeline {
agent none
options {
parallelsAlwaysFailFast()
}
environment{
image = "fin"
}
stages{
// Run all static analysis tests
stage("Static checks"){
parallel{
stage('Clang Format') {
agent{ label rocmnode("tunatest") }
environment{
cmd = "cd src; find . -iname \'*.h\' \
-o -iname \'*.hpp\' \
-o -iname \'*.cpp\' \
-o -iname \'*.h.in\' \
-o -iname \'*.hpp.in\' \
-o -iname \'*.cpp.in\' \
-o -iname \'*.cl\' \
| grep -v 'build/' \
| grep -v 'base64' \
| xargs -n 1 -P 1 -I{} -t sh -c \'clang-format-12 -style=file {} | diff - {}\'"
}
steps{
buildJob('clang++', '-DCMAKE_BUILD_TYPE=release', image, "", cmd)
}
}
stage('Hip Tidy') {
agent{ label rocmnode("tunatest") }
environment{
cmd = "rm -rf build; \
mkdir build; \
cd build; \
CXX=/opt/rocm/llvm/bin/clang++ cmake -DCMAKE_PREFIX_PATH=/opt/rocm -DBUILD_DEV=On ..; \
make -j\$(nproc) -k analyze;"
}
steps{
buildJob('clang++', '-DCMAKE_BUILD_TYPE=release', image, "", cmd)
}
}
stage('Build Fin') {
agent{ label rocmnode("tunatest") }
environment{
cmd = "rm -rf build; \
mkdir build; \
cd build; \
CXX=/opt/rocm/llvm/bin/clang++ cmake -DBUILD_DEV=On -DCMAKE_PREFIX_PATH=/opt/rocm ..; \
make -j\$(nproc) all;"
}
steps{
buildJob('clang++', '-DCMAKE_BUILD_TYPE=release', image, "", cmd)
}
}
stage('Fin Tests') {
agent{ label rocmnode("tunatest") }
environment{
cmd = "rm -rf build; \
mkdir build; \
cd build; \
CXX=/opt/rocm/llvm/bin/clang++ cmake -DBUILD_DEV=On -DCMAKE_PREFIX_PATH=/opt/rocm ..; \
make -j\$(nproc) fin_check;"
}
steps{
buildJob('clang++', '-DCMAKE_BUILD_TYPE=release', image, "", cmd)
}
}
}
}
}
}