Jenkinsfile 4.89 KB
Newer Older
Paul's avatar
Paul committed
1
2

def rocmtestnode(variant, name, body) {
Paul's avatar
Paul committed
3
    def image = 'migraphxlib'
Paul's avatar
Paul committed
4
5
    def cmake_build = { compiler, flags ->
        def cmd = """
Paul's avatar
Paul committed
6
            env
Paul's avatar
Paul committed
7
            ulimit -c unlimited
Paul's avatar
Paul committed
8
9
10
            rm -rf build
            mkdir build
            cd build
Paul's avatar
Paul committed
11
            CXX=${compiler} CXXFLAGS='-Werror -Wno-fallback' cmake ${flags} .. 
Paul's avatar
Paul committed
12
            CTEST_PARALLEL_LEVEL=32 make -j\$(nproc) generate all doc package check
Paul's avatar
Paul committed
13
14
15
        """
        echo cmd
        sh cmd
Paul's avatar
Paul committed
16
        if (compiler == "hcc") {
Paul's avatar
Paul committed
17
18
19
20
            // 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
21
        }
Paul's avatar
Paul committed
22
23
    }
    node(name) {
Paul's avatar
Paul committed
24
25
26
27
28
29
30
31
32
        withEnv(['HSA_ENABLE_SDMA=0', 'MIOPEN_DEBUG_GCN_ASM_KERNELS=0']) {
            stage("checkout ${variant}") {
                checkout scm
            }
            stage("image ${variant}") {
                try {
                    docker.build("${image}", '.')
                } catch(Exception ex) {
                    docker.build("${image}", '--no-cache .')
Paul's avatar
Paul committed
33

Paul's avatar
Paul committed
34
                }
Paul's avatar
Paul committed
35
            }
Paul's avatar
Paul committed
36
37
38
39
            withDockerContainer(image: image, args: '--device=/dev/kfd --device=/dev/dri --group-add video --cap-add SYS_PTRACE') {
                timeout(time: 1, unit: 'HOURS') {
                    body(cmake_build)
                }
Paul's avatar
Paul committed
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
            }
        }
    }
}
@NonCPS
def rocmtest(m) {
    def builders = [:]
    for(e in m) {
        def label = e.key;
        def action = e.value;
        builders[label] = {
            action(label)
        }
    }
    parallel builders
}

@NonCPS
def rocmnode(name, 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)
    }
}

@NonCPS
def rocmnode(body) {
Paul's avatar
Paul committed
74
    rocmnode('rocmtest', body)
Paul's avatar
Paul committed
75
76
77
}

// Static checks
Paul's avatar
Paul committed
78
rocmtest tidy: rocmnode('rocmtest') { cmake_build ->
Paul's avatar
Paul committed
79
80
81
82
83
    stage('Clang Tidy') {
        sh '''
            rm -rf build
            mkdir build
            cd build
Paul's avatar
Paul committed
84
            CXX=hcc cmake .. 
Paul's avatar
Paul committed
85
            make -j$(nproc) -k analyze
Paul's avatar
Paul committed
86
87
        '''
    }
Paul's avatar
Paul committed
88
}, format: rocmnode('rocmtest') { cmake_build ->
kahmed10's avatar
kahmed10 committed
89
    stage('Format') {
Paul's avatar
Paul committed
90
91
92
93
94
95
96
97
98
99
        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
100
101
102
            find . -iname \'*.py\' \
            | grep -v 'build/'  \
            | xargs -n 1 -P 1 -I{} -t sh -c \'yapf {} | diff - {}\'
Paul's avatar
Paul committed
103
104
        '''
    }
Paul's avatar
Paul committed
105
}, clang_debug: rocmnode('vega') { cmake_build ->
Paul's avatar
Paul committed
106
    stage('Clang Debug') {
Paul's avatar
Paul committed
107
        // TODO: Enable integer
Paul's avatar
Paul committed
108
        def sanitizers = "undefined"
109
110
        def debug_flags = "-g -fno-omit-frame-pointer -fsanitize=${sanitizers} -fno-sanitize-recover=${sanitizers}"
        cmake_build("hcc", "-DCMAKE_BUILD_TYPE=debug -DMIGRAPHX_ENABLE_PYTHON=Off -DCMAKE_CXX_FLAGS_DEBUG='${debug_flags}'")
Paul's avatar
Paul committed
111
    }
Paul's avatar
Paul committed
112
}, clang_release: rocmnode('vega') { cmake_build ->
Paul's avatar
Paul committed
113
    stage('Clang Release') {
Paul's avatar
Paul committed
114
        cmake_build("hcc", "-DCMAKE_BUILD_TYPE=release")
Paul's avatar
Paul committed
115
    }
Paul's avatar
Paul committed
116
}, clang_release_py3: rocmnode('vega') { cmake_build ->
Paul's avatar
Paul committed
117
118
119
    stage('Clang Release Python 3') {
        cmake_build("hcc", "-DCMAKE_BUILD_TYPE=release -DPYTHON_EXECUTABLE=/usr/local/bin/python3")
    }
Paul's avatar
Paul committed
120
121
}, gcc5: rocmnode('rocmtest') { cmake_build ->
    stage('GCC 5 Debug') {
Paul's avatar
Paul committed
122
        cmake_build("g++-5", "-DCMAKE_BUILD_TYPE=debug")
Paul's avatar
Paul committed
123
    }
Paul's avatar
Paul committed
124
    stage('GCC 5 Release') {
Paul's avatar
Paul committed
125
        cmake_build("g++-5", "-DCMAKE_BUILD_TYPE=release")
Paul's avatar
Paul committed
126
    }
Paul's avatar
Paul committed
127
128
}, gcc7: rocmnode('rocmtest') { cmake_build ->
    stage('GCC 7 Debug') {
Paul's avatar
Paul committed
129
        def linker_flags = '-fuse-ld=gold'
Paul's avatar
Paul committed
130
        def cmake_linker_flags = "-DCMAKE_EXE_LINKER_FLAGS='${linker_flags}' -DCMAKE_SHARED_LINKER_FLAGS='${linker_flags}'"
Paul's avatar
Paul committed
131
132
        // TODO: Add bounds-strict
        def sanitizers = "undefined,address"
Paul's avatar
Paul committed
133
        def debug_flags = "-g -fprofile-arcs -ftest-coverage -fno-omit-frame-pointer -fsanitize-address-use-after-scope -fsanitize=${sanitizers} -fno-sanitize-recover=${sanitizers}"
134
        cmake_build("g++-7", "-DCMAKE_BUILD_TYPE=debug -DMIGRAPHX_ENABLE_PYTHON=Off ${cmake_linker_flags} -DCMAKE_CXX_FLAGS_DEBUG='${debug_flags}'")
Paul's avatar
Paul committed
135
136
137
138
139
140

    }
    stage('Codecov') {
        env.CODECOV_TOKEN="8545af1c-f90b-4345-92a5-0d075503ca56"
        sh '''
            cd build
Paul's avatar
Paul committed
141
142
143
            lcov --directory . --capture --output-file coverage.info
            lcov --remove coverage.info '/usr/*' --output-file coverage.info
            lcov --list coverage.info
Paul's avatar
Paul committed
144
            curl -s https://codecov.io/bash | bash
Paul's avatar
Paul committed
145
            echo "Uploaded"
Paul's avatar
Paul committed
146
        '''
Paul's avatar
Paul committed
147
    }
Paul's avatar
Paul committed
148
}