Changes in / [692de479:396ee0a]


Ignore:
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • Jenkins/FullBuild

    r692de479 r396ee0a  
    11#!groovy
    22
    3 //===========================================================================================================
    4 // Main loop of the compilation
    5 //===========================================================================================================
    6 
    7 node ('master') {
    8         def err = null
    9 
    10         try {
    11                 //Prevent the build from exceeding 30 minutes
    12                 timeout(60) {
    13 
    14                         //Wrap build to add timestamp to command line
    15                         wrap([$class: 'TimestamperBuildWrapper']) {
    16 
    17                                 stage 'Build'
    18 
    19                                         results = [null, null]
    20 
    21                                         parallel (
    22                                                 gcc_6_x64: { trigger_build( 'gcc-6', 'x64' ) },
    23                                                 gcc_6_x86: { trigger_build( 'gcc-6', 'x86' ) },
    24                                                 gcc_5_x64: { trigger_build( 'gcc-5', 'x64' ) },
    25                                                 gcc_5_x86: { trigger_build( 'gcc-5', 'x86' ) },
    26                                                 gcc_4_x64: { trigger_build( 'gcc-4', 'x64' ) },
    27                                                 gcc_4_x86: { trigger_build( 'gcc-4', 'x86' ) },
    28                                                 clang_x64: { trigger_build( 'clang', 'x64' ) },
    29                                                 clang_x86: { trigger_build( 'clang', 'x86' ) },
    30                                         )
    31 
    32                                 //Push latest changes to do-lang repo
    33                                 push_build()
    34                         }
    35                 }
    36         }
    37 
    38         //If an exception is caught we need to change the status and remember to
    39         //attach the build log to the email
    40         catch (Exception caughtError) {
    41                 echo('error caught')
    42 
    43                 //rethrow error later
    44                 err = caughtError
    45 
    46                 //Store the result of the build log
    47                 currentBuild.result = 'FAILURE'
    48 
    49                 //Send email to notify the failure
    50                 promote_failure_email()
    51         }
    52 
    53         finally {
    54                 //Must re-throw exception to propagate error
    55                 if (err) {
    56                         throw err
    57                 }
    58         }
    59 }
    603//===========================================================================================================
    614// Main compilation routines
    625//===========================================================================================================
    636
    64 def trigger_build(String cc, String arch) {
     7def trigger_build(String arch) {
    658        def result = build job: 'Cforall/master',               \
    669                parameters: [                                           \
     10                        [$class: 'BooleanParameterValue',               \
     11                          name: 'isFullBuild',                          \
     12                          value: true],                                         \
    6713                        [$class: 'StringParameterValue',                \
    68                           name: 'pCompiler',                            \
    69                           value: cc],                                   \
    70                         [$class: 'StringParameterValue',                \
    71                           name: 'pArchitecture',                        \
    72                           value: arch],                                 \
    73                         [$class: 'BooleanParameterValue',               \
    74                           name: 'pRunAllTests',                         \
    75                           value: true],                                         \
    76                         [$class: 'BooleanParameterValue',               \
    77                           name: 'pRunBenchmark',                        \
    78                           value: true],                                         \
    79                         [$class: 'BooleanParameterValue',               \
    80                           name: 'pBuildDocumentation',          \
    81                           value: true],                                         \
    82                         [$class: 'BooleanParameterValue',               \
    83                           name: 'pPublish',                             \
    84                           value: true],                                         \
    85                         [$class: 'BooleanParameterValue',               \
    86                           name: 'pSilent',                              \
    87                           value: true],                                         \
     14                          name: 'buildArchitecture',                    \
     15                          value: arch]                                  \
    8816                ],                                                              \
    8917                propagate: false
     
    14169
    14270//===========================================================================================================
     71// Main loop of the compilation
     72//===========================================================================================================
     73
     74node ('master') {
     75        def err = null
     76
     77        try {
     78                //Prevent the build from exceeding 30 minutes
     79                timeout(60) {
     80
     81                        //Wrap build to add timestamp to command line
     82                        wrap([$class: 'TimestamperBuildWrapper']) {
     83
     84                                stage 'Build'
     85
     86                                        results = [null, null]
     87
     88                                        parallel (
     89                                                x64: {
     90                                                        trigger_build('64-bit')
     91                                                },
     92                                                x32: {
     93                                                        trigger_build('32-bit')
     94                                                }
     95                                        )
     96
     97                                //Push latest changes to do-lang repo
     98                                push_build()
     99                        }
     100                }
     101        }
     102
     103        //If an exception is caught we need to change the status and remember to
     104        //attach the build log to the email
     105        catch (Exception caughtError) {
     106                echo('error caught')
     107
     108                //rethrow error later
     109                err = caughtError
     110
     111                //Store the result of the build log
     112                currentBuild.result = 'FAILURE'
     113
     114                //Send email to notify the failure
     115                promote_failure_email()
     116        }
     117
     118        finally {
     119                //Must re-throw exception to propagate error
     120                if (err) {
     121                        throw err
     122                }
     123        }
     124}
     125//===========================================================================================================
    143126//Routine responsible of sending the email notification once the build is completed
    144127//===========================================================================================================
  • Jenkinsfile

    r692de479 r396ee0a  
    22
    33//===========================================================================================================
     4// Main compilation routines
     5//===========================================================================================================
     6//Compilation script is done here but environnement set-up and error handling is done in main loop
     7def cfa_build(boolean full_build, String flags) {
     8        build_stage 'Checkout'
     9                def install_dir = pwd tmp: true
     10                //checkout the source code and clean the repo
     11                checkout scm
     12
     13                //Clean all temporary files to make sure no artifacts of the previous build remain
     14                sh 'git clean -fdqx'
     15
     16                //Reset the git repo so no local changes persist
     17                sh 'git reset --hard'
     18
     19        build_stage 'Build'
     20
     21                //Configure the conpilation (Output is not relevant)
     22                //Use the current directory as the installation target so nothing
     23                //escapes the sandbox
     24                //Also specify the compiler by hand
     25                sh "./configure CXX=${currentCC.cpp_cc} ${flags} --with-backend-compiler=${currentCC.cfa_backend_cc} --prefix=${install_dir} --enable-silent-rules --quiet"
     26
     27                //Compile the project
     28                sh 'make -j 8 --no-print-directory V=0 install'
     29
     30        build_stage 'Test'
     31
     32                //Run the tests from the tests directory
     33                if (full_build) {
     34                        sh 'make -C src/tests all-tests debug=yes'
     35                        sh 'make -C src/tests all-tests debug=no'
     36                }
     37                else {
     38                        sh 'make -C src/tests'
     39                }
     40
     41        build_stage 'Cleanup'
     42
     43                //do a maintainer-clean to make sure we need to remake from scratch
     44                sh 'make maintainer-clean > /dev/null'
     45}
     46
     47def make_doc() {
     48        def err = null
     49
     50        try {
     51                sh 'make clean > /dev/null'
     52                sh 'make > /dev/null 2>&1'
     53        }
     54
     55        catch (Exception caughtError) {
     56                //rethrow error later
     57                err = caughtError
     58
     59                sh 'cat *.log'
     60        }
     61
     62        finally {
     63                /* Must re-throw exception to propagate error */
     64                if (err) {
     65                        throw err
     66                }
     67        }
     68}
     69
     70def doc_build() {
     71        stage 'Documentation'
     72
     73                status_prefix = 'Documentation'
     74
     75                dir ('doc/user') {
     76                        make_doc()
     77                }
     78
     79                dir ('doc/refrat') {
     80                        make_doc()
     81                }
     82}
     83
     84def benchmark() {
     85        stage 'Benchmark'
     86
     87                status_prefix = 'Documentation'
     88
     89                // //We can't just write to a file outside our repo
     90                // //Copy the file locally using ssh
     91                // sh 'scp plg2.cs.uwaterloo.ca:/u/cforall/public_html/perf-history/concurrency.csv bench.csv'
     92
     93                // //Then append to the local file
     94                // sh 'make -C src/benchmark csv-data >> bench.csv'
     95
     96                // //Then publish the file again
     97                // sh 'scp bench.csv plg2.cs.uwaterloo.ca:/u/cforall/public_html/perf-history/concurrency.csv'         
     98}
     99
     100//===========================================================================================================
     101// Helper classes/variables/routines to make the status and stage name easier to use
     102//===========================================================================================================
     103//Description of a compiler (Must be serializable since pipelines are persistent)
     104class CC_Desc implements Serializable {
     105        public String cc_name
     106        public String cpp_cc
     107        public String cfa_backend_cc
     108
     109        CC_Desc(String cc_name, String cpp_cc, String cfa_backend_cc) {
     110                this.cc_name = cc_name
     111                this.cpp_cc = cpp_cc
     112                this.cfa_backend_cc = cfa_backend_cc
     113        }
     114}
     115
     116//Global Variables defining the compiler and at which point in the build we are
     117// These variables are used but can't be declared before hand because of wierd scripting rules
     118// @Field String currentCC
     119// @Field String status_prefix
     120
     121//Wrapper to sync stage name and status name
     122def build_stage(String name) {
     123        def stage_name = "${currentCC.cc_name} ${name}".trim()
     124        stage stage_name
     125
     126                status_prefix = stage_name
     127}
     128
     129//Helper routine to collect information about the git history
     130def collect_git_info() {
     131
     132        //create the temporary output directory in case it doesn't already exist
     133        def out_dir = pwd tmp: true
     134        sh "mkdir -p ${out_dir}"
     135
     136        //parse git logs to find what changed
     137        gitRefName = env.BRANCH_NAME
     138        dir("../${gitRefName}@script") {
     139                sh "git reflog > ${out_dir}/GIT_COMMIT"
     140        }
     141        git_reflog = readFile("${out_dir}/GIT_COMMIT")
     142        gitRefOldValue = (git_reflog =~ /moving from (.+) to (.+)/)[0][1]
     143        gitRefNewValue = (git_reflog =~ /moving from (.+) to (.+)/)[0][2]
     144}
     145
     146//===========================================================================================================
    4147// Main loop of the compilation
    5148//===========================================================================================================
    6149node ('master'){
    7150
    8         boolean bIsSandbox = env.BRANCH_NAME == "jenkins-sandbox"
     151        boolean bIsFullBuild
    9152        def err = null
    10153        def log_needed = false
    11 
    12         compiler                = null
    13         architecture    = ''
    14        
    15         do_alltests             = false
    16         do_benchmark    = false
    17         do_doc          = false
    18         do_publish              = false
    19         do_sendemail    = true
    20 
    21154        currentBuild.result = "SUCCESS"
     155        status_prefix = ''
    22156
    23157        try {
    24                 //Wrap build to add timestamp to command line
    25                 wrap([$class: 'TimestamperBuildWrapper']) {
    26 
    27                         //Prevent the build from exceeding 60 minutes
    28                         timeout(60) {
    29 
    30                                 notify_server()
    31 
    32                                 prepare_build()
    33 
    34                                 checkout()
    35 
    36                                 build()
    37 
    38                                 test()
    39 
     158                //Prevent the build from exceeding 30 minutes
     159                timeout(60) {
     160
     161                        //Wrap build to add timestamp to command line
     162                        wrap([$class: 'TimestamperBuildWrapper']) {
     163
     164                                collect_git_info()
     165
     166                                properties ([                                                                   \
     167                                        [$class: 'ParametersDefinitionProperty',                                \
     168                                                parameterDefinitions: [                                         \
     169                                                [$class: 'BooleanParameterDefinition',                          \
     170                                                  defaultValue: false,                                          \
     171                                                  description: 'If true, the build will be promoted to the do-lang git repository (on successful builds only)', \
     172                                                  name: 'isFullBuild'                                   \
     173                                                ],                                                              \
     174                                                [$class: 'ChoiceParameterDefinition',                           \
     175                                                  choices: '64-bit\n32-bit',                                    \
     176                                                  defaultValue: '64-bit',                                       \
     177                                                  description: 'The architecture to use for compilation',       \
     178                                                  name: 'buildArchitecture'                                     \
     179                                                ]]                                                              \
     180                                        ]])
     181
     182                                bIsSandbox = env.BRANCH_NAME == "jenkins-sandbox"
     183                                bIsFullBuild = isFullBuild == 'true'
     184                                architectureFlag = ''
     185                                if (buildArchitecture == '64-bit') {
     186                                        architectureFlag = '--host=x86_64 CXXFLAGS="-m64" CFAFLAGS="-m64"'
     187                                } else if (buildArchitecture == '32-bit'){
     188                                        architectureFlag = '--host=i386 CXXFLAGS="-m32" CFAFLAGS="-m32"'
     189                                } else {
     190                                        architectureFlag = 'ERROR'
     191                                }
     192
     193                                echo "FULL BUILD = ${isFullBuild}\nArchitecture = ${buildArchitecture} (flag ${architectureFlag})"
     194
     195                                //Compile using gcc-4.9
     196                                currentCC = new CC_Desc('gcc-4.9', 'g++-4.9', 'gcc-4.9')
     197                                cfa_build(bIsFullBuild, architectureFlag)
     198
     199                                //Compile latex documentation
     200                                doc_build()
     201
     202                                //Run benchmark and save result
    40203                                benchmark()
    41204
    42                                 clean()
    43 
    44                                 build_doc()
    45 
    46                                 publish()
    47 
    48                                 notify_server()
     205                                if( bIsFullBuild ) {
     206                                        //Compile using gcc-5
     207                                        currentCC = new CC_Desc('gcc-5', 'g++-5', 'gcc-5')
     208                                        cfa_build(true, architectureFlag)
     209
     210                                        //Compile using gcc-4.9
     211                                        currentCC = new CC_Desc('gcc-6', 'g++-6', 'gcc-6')
     212                                        cfa_build(true, architectureFlag)
     213                                }
    49214                        }
    50215                }
     
    68233
    69234                //Send email with final results if this is not a full build
    70                 if( !do_sendemail && !bIsSandbox ) {
     235                if( !bIsFullBuild && !bIsSandbox ) {
    71236                        echo 'Notifying users of result'
    72237                        email(currentBuild.result, log_needed)
     
    78243                }
    79244        }
    80 }
    81 
    82 //===========================================================================================================
    83 // Helper classes/variables/routines
    84 //===========================================================================================================
    85 //Helper routine to collect information about the git history
    86 def collect_git_info() {
    87 
    88         //create the temporary output directory in case it doesn't already exist
    89         def out_dir = pwd tmp: true
    90         sh "mkdir -p ${out_dir}"
    91 
    92         //parse git logs to find what changed
    93         gitRefName = env.BRANCH_NAME
    94         dir("../${gitRefName}@script") {
    95                 sh "git reflog > ${out_dir}/GIT_COMMIT"
    96         }
    97         git_reflog = readFile("${out_dir}/GIT_COMMIT")
    98         gitRefOldValue = (git_reflog =~ /moving from (.+) to (.+)/)[0][1]
    99         gitRefNewValue = (git_reflog =~ /moving from (.+) to (.+)/)[0][2]
    100 }
    101 
    102 def prepare_build() {
    103         properties ([                                                                                                   \
    104                 [$class: 'ParametersDefinitionProperty',                                                                \
    105                         parameterDefinitions: [                                                                         \
    106                                 [$class: 'ChoiceParameterDefinition',                                           \
    107                                         description: 'Which compiler to use',                                   \
    108                                         name: 'pCompiler',                                                              \
    109                                         choices: 'gcc-6\ngcc-5\ngcc-4.9\nclang',                                        \
    110                                         defaultValue: 'gcc-6',                                                          \
    111                                 ],                                                                                              \
    112                                 [$class: 'ChoiceParameterDefinition',                                           \
    113                                         description: 'The target architecture',                                 \
    114                                         name: 'pArchitecture',                                                          \
    115                                         choices: 'x64\nx86',                                                            \
    116                                         defaultValue: 'x64',                                                            \
    117                                 ],                                                                                              \
    118                                 [$class: 'BooleanParameterDefinition',                                                  \
    119                                         description: 'If false, only the quick test suite is ran',              \
    120                                         name: 'pRunAllTests',                                                           \
    121                                         defaultValue: false,                                                            \
    122                                 ],                                                                                              \
    123                                 [$class: 'BooleanParameterDefinition',                                                  \
    124                                         description: 'If true, jenkins also runs benchmarks',           \
    125                                         name: 'pRunBenchmark',                                                          \
    126                                         defaultValue: true,                                                             \
    127                                 ],                                                                                              \
    128                                 [$class: 'BooleanParameterDefinition',                                                  \
    129                                         description: 'If true, jenkins also builds documentation',              \
    130                                         name: 'pBuildDocumentation',                                                            \
    131                                         defaultValue: true,                                                             \
    132                                 ],                                                                                              \
    133                                 [$class: 'BooleanParameterDefinition',                                                  \
    134                                         description: 'If true, jenkins also publishes results',                 \
    135                                         name: 'pPublish',                                                               \
    136                                         defaultValue: true,                                                             \
    137                                 ],                                                                                              \
    138                                 [$class: 'BooleanParameterDefinition',                                                  \
    139                                         description: 'If true, jenkins will not send emails',           \
    140                                         name: 'pSilent',                                                \
    141                                         defaultValue: false,                                                            \
    142                                 ],                                                                                              \
    143                         ],
    144                 ]])
    145 
    146         compiler                = compiler_from_params( pCompiler )
    147         architecture    = architecture_from_params( pArchitecture )
    148 
    149         do_alltests             = (pRunAllTests == 'true')
    150         do_benchmark    = (pRunBenchmark == 'true')
    151         do_doc          = (pBuildDocumentation == 'true')
    152         do_publish              = (pPublish == 'true')
    153         do_sendemail    = ! (pSilent == 'true')
    154 
    155         echo """Compiler                : ${compiler.cc_name} (${compiler.cpp_cc}/${compiler.cfa_cc})
    156 Architecture            : ${architecture}
    157 Run All Tests           : ${ pRunAllTests.toString() }
    158 Run Benchmark           : ${ pRunBenchmark.toString() }
    159 Build Documentation     : ${ pBuildDocumentation.toString() }
    160 Publish         : ${ pPublish.toString() }
    161 Silent                  : ${ pSilent.toString() }
    162 """
    163 
    164         collect_git_info()
    165 }
    166 
    167 def notify_server() {
    168         sh 'curl --silent -X POST http://plg2:8082/jenkins/notify > /dev/null'
    169         return
    170 }
    171 
    172 def make_doc() {
    173         def err = null
    174         try {
    175                 sh 'make clean > /dev/null'
    176                 sh 'make > /dev/null 2>&1'
    177         }
    178         catch (Exception caughtError) {
    179                 err = caughtError //rethrow error later
    180                 sh 'cat *.log'
    181         }
    182         finally {
    183                 if (err) throw err // Must re-throw exception to propagate error
    184         }
    185 }
    186 
    187 //Description of a compiler (Must be serializable since pipelines are persistent)
    188 class CC_Desc implements Serializable {
    189         public String cc_name
    190         public String cpp_cc
    191         public String cfa_cc
    192 
    193         CC_Desc(String cc_name, String cpp_cc, String cfa_cc) {
    194                 this.cc_name = cc_name
    195                 this.cpp_cc = cpp_cc
    196                 this.cfa_cc = cfa_cc
    197         }
    198 }
    199 
    200 def compiler_from_params(cc) {
    201         switch( cc ) {
    202                 case 'gcc-6':
    203                         return new CC_Desc('gcc-6', 'g++-6', 'gcc-6')
    204                 break
    205                 case 'gcc-5':
    206                         return new CC_Desc('gcc-5', 'g++-5', 'gcc-5')
    207                 break
    208                 case 'gcc-4.9':
    209                         return new CC_Desc('gcc-4.9', 'g++-4.9', 'gcc-4.9')
    210                 break
    211                 case 'clang':
    212                         return new CC_Desc('clang', 'clang++', 'gcc-6')
    213                 break
    214                 default :
    215                         error "Unhandled compiler : ${cc}"
    216         }
    217 }
    218 
    219 def architecture_from_params( arch ) {
    220         switch( arch ) {
    221                 case 'x64':
    222                         return '--host=x86_64 CXXFLAGS="-m64" CFAFLAGS="-m64"'
    223                 break
    224                 case 'x86':
    225                         return '--host=i386   CXXFLAGS="-m32" CFAFLAGS="-m32"'
    226                 break
    227                 default :
    228                         error "Unhandled architecture : ${arch}"
    229         }
    230 }
    231 
    232 //===========================================================================================================
    233 // Main compilation routines
    234 //===========================================================================================================
    235 //Compilation script is done here but environnement set-up and error handling is done in main loop
    236 def checkout() {
    237         stage 'Checkout'
    238                 //checkout the source code and clean the repo
    239                 checkout scm
    240 
    241                 //Clean all temporary files to make sure no artifacts of the previous build remain
    242                 sh 'git clean -fdqx'
    243 
    244                 //Reset the git repo so no local changes persist
    245                 sh 'git reset --hard'
    246 }
    247 
    248 def build() {
    249         stage 'Build'
    250        
    251                 def install_dir = pwd tmp: true
    252                
    253                 //Configure the conpilation (Output is not relevant)
    254                 //Use the current directory as the installation target so nothing
    255                 //escapes the sandbox
    256                 //Also specify the compiler by hand
    257                 sh "./configure CXX=${compiler.cpp_cc} ${architecture} --with-backend-compiler=${compiler.cfa_cc} --prefix=${install_dir} --enable-silent-rules --quiet"
    258 
    259                 //Compile the project
    260                 sh 'make -j 8 --no-print-directory V=0 install'
    261 }
    262 
    263 def test() {
    264         stage 'Test'
    265 
    266                 //Run the tests from the tests directory
    267                 if ( do_alltests ) {
    268                         sh 'make -C src/tests all-tests debug=yes'
    269                         sh 'make -C src/tests all-tests debug=no'
    270                 }
    271                 else {
    272                         sh 'make -C src/tests'
    273                 }
    274 }
    275 
    276 def benchmark() {
    277         stage 'Benchmark'
    278 
    279                 if( !do_benchmark ) return
    280 
    281                 //Write the commit id to Benchmark
    282                 writeFile  file: 'bench.csv', text:'data=' + gitRefNewValue + ','
    283  
    284                 //Append bench results
    285                 sh 'make -C src/benchmark --no-print-directory csv-data >> bench.csv'
    286 }
    287 
    288 def clean() {
    289         stage 'Cleanup'
    290 
    291                 //do a maintainer-clean to make sure we need to remake from scratch
    292                 sh 'make maintainer-clean > /dev/null'
    293 }
    294 
    295 def build_doc() {
    296         stage 'Documentation'
    297 
    298                 if( !do_doc ) return
    299 
    300                 dir ('doc/user') {
    301                         make_doc()
    302                 }
    303 
    304                 dir ('doc/refrat') {
    305                         make_doc()
    306                 }
    307 }
    308 
    309 def publish() {
    310         stage 'Publish'
    311 
    312                 if( !do_publish ) return
    313 
    314                 //Then publish the results
    315                 sh 'curl --silent --data @bench.csv http://plg2:8082/jenkins/publish > /dev/null'
    316245}
    317246
  • src/benchmark/csv-data.c

    r692de479 r396ee0a  
    8484int main()
    8585{
    86         sout | time(NULL) | ',' | measure_coroutine() | ',' | measure_thread() | endl;
     86        sout | time(NULL) | "," | measure_coroutine() | "," | measure_thread() | endl;
    8787}
Note: See TracChangeset for help on using the changeset viewer.