Jenkinsfile 6.84 KB
Newer Older
Paul's avatar
Paul committed
1

2
3
4
5
6
7
8
9
// def rocmtestnode(variant, name, body, args, pre) {
def rocmtestnode(Map conf) {
    def variant = conf.get("variant")
    def name = conf.get("node")
    def body = conf.get("body")
    def docker_args = conf.get("docker_args", "")
    def docker_build_args = conf.get("docker_build_args", "")
    def pre = conf.get("pre", {})
Paul's avatar
Paul committed
10
    def image = 'migraphxlib'
Paul's avatar
Paul committed
11
12
    def cmake_build = { compiler, flags ->
        def cmd = """
Paul's avatar
Paul committed
13
            env
Paul's avatar
Paul committed
14
            ulimit -c unlimited
Paul's avatar
Paul committed
15
16
17
            rm -rf build
            mkdir build
            cd build
Paul's avatar
Paul committed
18
            CXX=${compiler} CXXFLAGS='-Werror -Wno-fallback' cmake ${flags} .. 
Paul's avatar
Paul committed
19
            CTEST_PARALLEL_LEVEL=32 make -j\$(nproc) generate all doc package check
Paul's avatar
Paul committed
20
21
22
        """
        echo cmd
        sh cmd
Paul's avatar
Paul committed
23
        if (compiler == "hcc") {
Paul's avatar
Paul committed
24
25
26
27
            // Only archive from master or develop
            if (env.BRANCH_NAME == "develop" || env.BRANCH_NAME == "master") {
                archiveArtifacts artifacts: "build/*.deb", allowEmptyArchive: true, fingerprint: true
            }
Paul's avatar
Paul committed
28
        }
Paul's avatar
Paul committed
29
30
    }
    node(name) {
Paul's avatar
Paul committed
31
32
33
34
        withEnv(['HSA_ENABLE_SDMA=0', 'MIOPEN_DEBUG_GCN_ASM_KERNELS=0']) {
            stage("checkout ${variant}") {
                checkout scm
            }
35
            gitStatusWrapper(credentialsId: '7126e5fe-eb51-4576-b52b-9aaf1de8f0fd', gitHubContext: "Jenkins - ${variant}", account: 'ROCmSoftwarePlatform', repo: 'AMDMIGraphX') {
Paul's avatar
Paul committed
36
37
38
39
40
41
                pre()
                stage("image ${variant}") {
                    try {
                        docker.build("${image}", "${docker_build_args} .")
                    } catch(Exception ex) {
                        docker.build("${image}", "${docker_build_args} --no-cache .")
Paul's avatar
Paul committed
42

Paul's avatar
Paul committed
43
                    }
Paul's avatar
Paul committed
44
                }
Paul's avatar
Paul committed
45
                withDockerContainer(image: image, args: "--device=/dev/kfd --device=/dev/dri --group-add video --cap-add SYS_PTRACE ${docker_args}") {
46
                    timeout(time: 2, unit: 'HOURS') {
Paul's avatar
Paul committed
47
48
                        body(cmake_build)
                    }
Paul's avatar
Paul committed
49
                }
Paul's avatar
Paul committed
50
51
52
53
54
55
            }
        }
    }
}
def rocmtest(m) {
    def builders = [:]
Paul Fultz II's avatar
Paul Fultz II committed
56
    m.each { e ->
Paul's avatar
Paul committed
57
58
59
60
61
62
63
64
65
        def label = e.key;
        def action = e.value;
        builders[label] = {
            action(label)
        }
    }
    parallel builders
}

66
def rocmnodename(name) {
Paul's avatar
Paul committed
67
68
69
70
71
72
    def rocmtest_name = "(rocmtest || migraphx)"
    def node_name = "${rocmtest_name}"
    if(name == "fiji") {
        node_name = "${rocmtest_name} && fiji";
    } else if(name == "vega") {
        node_name = "${rocmtest_name} && vega";
Paul's avatar
Paul committed
73
    }
74
    return node_name
Paul's avatar
Paul committed
75
76
}

Paul Fultz II's avatar
Paul Fultz II committed
77
def rocmnode(name, body) {
78
79
80
    return { label ->
        rocmtestnode(variant: label, node: rocmnodename(name), body: body)
    }
Paul Fultz II's avatar
Paul Fultz II committed
81
82
}

83
84
85
86
def rocmhipclangnode(name, body) {
    return { label ->
        rocmtestnode(variant: label, node: rocmnodename(name), docker_build_args: '-f hip-clang.docker', body: body)
    }
Paul's avatar
Paul committed
87
88
89
}

// Static checks
Paul's avatar
Paul committed
90
rocmtest format: rocmnode('rocmtest') { cmake_build ->
kahmed10's avatar
kahmed10 committed
91
    stage('Format') {
Paul's avatar
Paul committed
92
93
94
95
96
97
98
99
100
101
        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 - {}\'
kahmed10's avatar
kahmed10 committed
102
103
104
            find . -iname \'*.py\' \
            | grep -v 'build/'  \
            | xargs -n 1 -P 1 -I{} -t sh -c \'yapf {} | diff - {}\'
Paul's avatar
Paul committed
105
106
        '''
    }
Paul's avatar
Paul committed
107
}, clang_debug: rocmnode('vega') { cmake_build ->
Paul's avatar
Paul committed
108
    stage('Clang Debug') {
Paul's avatar
Paul committed
109
        // TODO: Enable integer
Paul's avatar
Paul committed
110
        def sanitizers = "undefined"
111
        def debug_flags = "-O2 -fsanitize=${sanitizers} -fno-sanitize-recover=${sanitizers}"
112
        cmake_build("hcc", "-DCMAKE_BUILD_TYPE=debug -DMIGRAPHX_ENABLE_PYTHON=Off -DCMAKE_CXX_FLAGS_DEBUG='${debug_flags}'")
Paul's avatar
Paul committed
113
    }
Paul's avatar
Paul committed
114
}, clang_release: rocmnode('vega') { cmake_build ->
Paul's avatar
Paul committed
115
    stage('Clang Release') {
Paul's avatar
Paul committed
116
        cmake_build("hcc", "-DCMAKE_BUILD_TYPE=release")
Paul Fultz II's avatar
Paul Fultz II committed
117
        stash includes: 'build/*.deb', name: 'migraphx-package'
Paul's avatar
Paul committed
118
    }
119
120
121
122
123
124
125
}, hip_clang_release: rocmhipclangnode('vega') { cmake_build ->
    stage('Hip Clang Release') {
        cmake_build("/opt/rocm/llvm/bin/clang++", "-DCMAKE_BUILD_TYPE=release")
        // stash includes: 'build/*.deb', name: 'migraphx-package'
    }
}, hip_clang_tidy: rocmhipclangnode('rocmtest') { cmake_build ->
    stage('Hip Clang Tidy') {
Paul's avatar
Paul committed
126
127
128
129
130
131
132
        sh '''
            rm -rf build
            mkdir build
            cd build
            CXX=/opt/rocm/llvm/bin/clang++ cmake .. 
            make -j$(nproc) -k analyze
        '''
133
    }
Paul's avatar
Paul committed
134
135
}, gcc5: rocmnode('rocmtest') { cmake_build ->
    stage('GCC 5 Debug') {
Paul's avatar
Paul committed
136
        cmake_build("g++-5", "-DCMAKE_BUILD_TYPE=debug")
Paul's avatar
Paul committed
137
    }
Paul's avatar
Paul committed
138
    stage('GCC 5 Release') {
Paul's avatar
Paul committed
139
        cmake_build("g++-5", "-DCMAKE_BUILD_TYPE=release")
Paul's avatar
Paul committed
140
    }
141
}, gcc7: rocmhipclangnode('rocmtest') { cmake_build ->
Paul's avatar
Paul committed
142
    stage('GCC 7 Debug') {
Paul's avatar
Paul committed
143
        def linker_flags = '-fuse-ld=gold'
Paul's avatar
Paul committed
144
        def cmake_linker_flags = "-DCMAKE_EXE_LINKER_FLAGS='${linker_flags}' -DCMAKE_SHARED_LINKER_FLAGS='${linker_flags}'"
Paul's avatar
Paul committed
145
146
        // TODO: Add bounds-strict
        def sanitizers = "undefined,address"
Paul's avatar
Paul committed
147
148
149
150
151
152
153
154
155
        def debug_flags = "-g -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_CPU=On -DMIGRAPHX_ENABLE_PYTHON=Off ${cmake_linker_flags} -DCMAKE_CXX_FLAGS_DEBUG='${debug_flags}'")

    }
}, codecov: rocmnode('rocmtest') { cmake_build ->
    stage('GCC 7 Codecov') {
        def linker_flags = '-fuse-ld=gold'
        def cmake_linker_flags = "-DCMAKE_EXE_LINKER_FLAGS='${linker_flags}' -DCMAKE_SHARED_LINKER_FLAGS='${linker_flags}'"
        def debug_flags = "-g -fprofile-arcs -ftest-coverage -fno-omit-frame-pointer"
156
        cmake_build("g++-7", "-DCMAKE_BUILD_TYPE=debug -DMIGRAPHX_ENABLE_CPU=Off -DMIGRAPHX_ENABLE_PYTHON=Off ${cmake_linker_flags} -DCMAKE_CXX_FLAGS_DEBUG='${debug_flags}'")
Paul's avatar
Paul committed
157
158
159
160
161
162

    }
    stage('Codecov') {
        env.CODECOV_TOKEN="8545af1c-f90b-4345-92a5-0d075503ca56"
        sh '''
            cd build
Paul Fultz II's avatar
Paul Fultz II committed
163
164
165
            lcov --directory . --capture --output-file $(pwd)/coverage.info
            lcov --remove $(pwd)/coverage.info '/usr/*' --output-file $(pwd)/coverage.info
            lcov --list $(pwd)/coverage.info
Paul's avatar
Paul committed
166
            curl -s https://codecov.io/bash | bash
Paul's avatar
Paul committed
167
            echo "Uploaded"
Paul's avatar
Paul committed
168
        '''
Paul's avatar
Paul committed
169
    }
Paul's avatar
Paul committed
170
}
Paul Fultz II's avatar
Paul Fultz II committed
171

172
173
174
175
176
177
178
179
180
181
def onnxnode(name, body) {
    return { label ->
        rocmtestnode(variant: label, node: rocmnodename(name), docker_args: '-u root', body: body, pre: {
            sh 'rm -rf ./build/*.deb'
            unstash 'migraphx-package' 
        })
    }
}

rocmtest onnx: onnxnode('rocmtest') { cmake_build ->
Paul Fultz II's avatar
Paul Fultz II committed
182
183
184
185
186
187
188
189
    stage("Onnx runtime") {
        sh '''
            ls -lR
            dpkg -i --force-depends ./build/*.deb
            cd /onnxruntime && ./build_and_test_onnxrt.sh
        '''
    }
}