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

def rocmtestnode(variant, name, body) {
Paul's avatar
Paul committed
3
    def image = 'migraphlib'
Paul's avatar
Paul committed
4
5
6
7
8
    def cmake_build = { compiler, flags ->
        def cmd = """
            rm -rf build
            mkdir build
            cd build
Paul's avatar
Paul committed
9
            CXX=${compiler} CXXFLAGS='-Werror -Wno-fallback' cmake -DCMAKE_CXX_FLAGS_DEBUG='-g -fno-omit-frame-pointer -fsanitize=undefined -fno-sanitize-recover=undefined' ${flags} .. 
Paul's avatar
Paul committed
10
            CTEST_PARALLEL_LEVEL=32 make -j32 all doc check
Paul's avatar
Paul committed
11
12
13
14
15
16
17
18
19
20
21
        """
        echo cmd
        sh cmd
    }
    node(name) {
        stage("checkout ${variant}") {
            env.HSA_ENABLE_SDMA=0 
            checkout scm
        }
        stage("image ${variant}") {
            try {
Paul's avatar
Paul committed
22
                docker.build("${image}", '.')
Paul's avatar
Paul committed
23
            } catch(Exception ex) {
Paul's avatar
Paul committed
24
                docker.build("${image}", '--no-cache .')
Paul's avatar
Paul committed
25
26
27

            }
        }
Paul's avatar
Paul committed
28
        withDockerContainer(image: image, args: '--device=/dev/kfd --device=/dev/dri --group-add video --cap-add SYS_PTRACE') {
Paul's avatar
Paul committed
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
            timeout(time: 1, unit: 'HOURS') {
                body(cmake_build)
            }
        }
    }
}
@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
65
    rocmnode('rocmtest', body)
Paul's avatar
Paul committed
66
67
68
}

// Static checks
Paul's avatar
Paul committed
69
rocmtest tidy: rocmnode('rocmtest') { cmake_build ->
Paul's avatar
Paul committed
70
71
    stage('Clang Tidy') {
        sh '''
Paul's avatar
Paul committed
72
            sed -i 's/  #/ /g' .clang-tidy
Paul's avatar
Paul committed
73
74
75
76
77
78
79
            rm -rf build
            mkdir build
            cd build
            CXX='clang++-5.0' cmake .. 
            make -j8 -k analyze
        '''
    }
Paul's avatar
Paul committed
80
}, format: rocmnode('rocmtest') { cmake_build ->
Paul's avatar
Paul committed
81
82
83
84
85
86
87
88
89
90
91
92
93
    stage('Clang 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 - {}\'
        '''
    }
Paul's avatar
Paul committed
94
}, clang: rocmnode('rocmtest') { cmake_build ->
Paul's avatar
Paul committed
95
    stage('Clang Debug') {
Paul's avatar
Paul committed
96
        cmake_build('hcc', '-DCMAKE_BUILD_TYPE=debug')
Paul's avatar
Paul committed
97
98
    }
    stage('Clang Release') {
Paul's avatar
Paul committed
99
        cmake_build('hcc', '-DCMAKE_BUILD_TYPE=release')
Paul's avatar
Paul committed
100
    }
Paul's avatar
Paul committed
101
}, gcc: rocmnode('rocmtest') { cmake_build ->
Paul's avatar
Paul committed
102
103
104
105
106
107
108
    stage('GCC Debug') {
        cmake_build('g++-5', '-DCMAKE_BUILD_TYPE=debug')
    }
    stage('GCC Release') {
        cmake_build('g++-5', '-DCMAKE_BUILD_TYPE=release')
    }
}