forked from ROCm/AMDMIGraphX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
167 lines (159 loc) · 5.41 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
def rocmtestnode(variant, name, body, args, pre) {
def image = 'migraphxlib'
def cmake_build = { compiler, flags ->
def cmd = """
env
ulimit -c unlimited
rm -rf build
mkdir build
cd build
CXX=${compiler} CXXFLAGS='-Werror -Wno-fallback' cmake ${flags} ..
CTEST_PARALLEL_LEVEL=32 make -j\$(nproc) generate all doc package check
"""
echo cmd
sh cmd
if (compiler == "hcc") {
// Only archive from master or develop
if (env.BRANCH_NAME == "develop" || env.BRANCH_NAME == "master") {
archiveArtifacts artifacts: "build/*.deb", allowEmptyArchive: true, fingerprint: true
}
}
}
node(name) {
withEnv(['HSA_ENABLE_SDMA=0', 'MIOPEN_DEBUG_GCN_ASM_KERNELS=0']) {
stage("checkout ${variant}") {
checkout scm
}
pre()
stage("image ${variant}") {
try {
docker.build("${image}", '.')
} catch(Exception ex) {
docker.build("${image}", '--no-cache .')
}
}
withDockerContainer(image: image, args: "--device=/dev/kfd --device=/dev/dri --group-add video --cap-add SYS_PTRACE ${args}") {
timeout(time: 1, unit: 'HOURS') {
body(cmake_build)
}
}
}
}
}
// @NonCPS
def rocmtest(m) {
def builders = [:]
m.each { e ->
def label = e.key;
def action = e.value;
builders[label] = {
action(label)
}
}
parallel builders
}
// @NonCPS
def rocmnode(name, args, pre, body) {
def node_name = 'rocmtest || rocm'
if(name == 'fiji') {
node_name = 'rocmtest && fiji';
} else if(name == 'vega') {
node_name = 'rocmtest && vega';
} else {
node_name = name
}
return { label ->
rocmtestnode(label, node_name, body, args, pre)
}
}
def rocmnode(name, body) {
rocmnode(name, '', {}, body)
}
// @NonCPS
def rocmnode(body) {
rocmnode('rocmtest', '', {}, body)
}
// Static checks
rocmtest tidy: rocmnode('rocmtest') { cmake_build ->
stage('Clang Tidy') {
sh '''
rm -rf build
mkdir build
cd build
CXX=hcc cmake ..
make -j$(nproc) -k analyze
'''
}
}, format: rocmnode('rocmtest') { cmake_build ->
stage('Format') {
sh '''
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/' \
| xargs -n 1 -P 1 -I{} -t sh -c \'clang-format-5.0 -style=file {} | diff - {}\'
find . -iname \'*.py\' \
| grep -v 'build/' \
| xargs -n 1 -P 1 -I{} -t sh -c \'yapf {} | diff - {}\'
'''
}
}, clang_debug: rocmnode('vega') { cmake_build ->
stage('Clang Debug') {
// TODO: Enable integer
def sanitizers = "undefined"
def debug_flags = "-O2 -fsanitize=${sanitizers} -fno-sanitize-recover=${sanitizers}"
cmake_build("hcc", "-DCMAKE_BUILD_TYPE=debug -DMIGRAPHX_ENABLE_PYTHON=Off -DCMAKE_CXX_FLAGS_DEBUG='${debug_flags}'")
}
}, clang_release: rocmnode('vega') { cmake_build ->
stage('Clang Release') {
cmake_build("hcc", "-DCMAKE_BUILD_TYPE=release")
stash includes: 'build/*.deb', name: 'migraphx-package'
}
}, clang_release_py3: rocmnode('vega') { cmake_build ->
stage('Clang Release Python 3') {
cmake_build("hcc", "-DCMAKE_BUILD_TYPE=release -DPYTHON_EXECUTABLE=/usr/local/bin/python3")
}
}, gcc5: rocmnode('rocmtest') { cmake_build ->
stage('GCC 5 Debug') {
cmake_build("g++-5", "-DCMAKE_BUILD_TYPE=debug")
}
stage('GCC 5 Release') {
cmake_build("g++-5", "-DCMAKE_BUILD_TYPE=release")
}
}, gcc7: rocmnode('rocmtest') { cmake_build ->
stage('GCC 7 Debug') {
def linker_flags = '-fuse-ld=gold'
def cmake_linker_flags = "-DCMAKE_EXE_LINKER_FLAGS='${linker_flags}' -DCMAKE_SHARED_LINKER_FLAGS='${linker_flags}'"
// TODO: Add bounds-strict
def sanitizers = "undefined,address"
def debug_flags = "-g -fprofile-arcs -ftest-coverage -fno-omit-frame-pointer -fsanitize-address-use-after-scope -fsanitize=${sanitizers} -fno-sanitize-recover=${sanitizers}"
cmake_build("g++-7", "-DCMAKE_BUILD_TYPE=debug -DMIGRAPHX_ENABLE_PYTHON=Off ${cmake_linker_flags} -DCMAKE_CXX_FLAGS_DEBUG='${debug_flags}'")
}
stage('Codecov') {
env.CODECOV_TOKEN="8545af1c-f90b-4345-92a5-0d075503ca56"
sh '''
cd build
lcov --directory . --capture --output-file $(pwd)/coverage.info
lcov --remove $(pwd)/coverage.info '/usr/*' --output-file $(pwd)/coverage.info
lcov --list $(pwd)/coverage.info
curl -s https://codecov.io/bash | bash
echo "Uploaded"
'''
}
}
rocmtest onnx: rocmnode('rocmtest', '-u root', {
sh 'rm -rf ./build/*.deb'
unstash 'migraphx-package'
}) { cmake_build ->
stage("Onnx runtime") {
sh '''
ls -lR
dpkg -i --force-depends ./build/*.deb
cd /onnxruntime && ./build_and_test_onnxrt.sh
'''
}
}