From c363e03874a0427a50fc0b186d9c4db2d96fd294 Mon Sep 17 00:00:00 2001 From: Kent Knox Date: Thu, 10 Aug 2017 12:08:46 -0500 Subject: [PATCH 1/6] Adding support to upload images to docker-hub --- hipamd/Jenkinsfile | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/hipamd/Jenkinsfile b/hipamd/Jenkinsfile index ee3a301dd3..280ea9b5ad 100644 --- a/hipamd/Jenkinsfile +++ b/hipamd/Jenkinsfile @@ -156,7 +156,7 @@ def docker_build_inside_image( def build_image, String inside_args, String platf //////////////////////////////////////////////////////////////////////// // This builds a fresh docker image FROM a clean base image, with no build dependencies included // Uploads the new docker image to internal artifactory -def docker_upload_artifactory( String hcc_ver, String from_image, String source_hip_rel, String build_dir_rel ) +def docker_upload_install_image( String hcc_ver, String from_image, String source_hip_rel, String build_dir_rel ) { def hip_install_image = null String image_name = "hip-${hcc_ver}-ubuntu-16.04" @@ -194,15 +194,33 @@ def docker_upload_artifactory( String hcc_ver, String from_image, String source_ hip_install_image.push( 'latest' ) } } - - // Lots of images with tags are created above; no apparent way to delete images:tags with docker global variable - // run bash script to clean images:tags after successful pushing - sh "docker images | grep \"${artifactory_org}/${image_name}\" | awk '{print \$1 \":\" \$2}' | xargs docker rmi" } catch( err ) { currentBuild.result = 'SUCCESS' } + + // Do not treat failures to push to docker-hub as a build fail + try + { + // Only push changes to the master branch to docker-hub + if( env.BRANCH_NAME.toLowerCase( ).startsWith( 'docker' ) ) + { + docker.withRegistry('https://hub.docker.com', 'docker-hub-cred' ) + { + hip_install_image.push( "${env.BUILD_NUMBER}" ) + hip_install_image.push( 'latest' ) + } + } + } + catch( err ) + { + currentBuild.result = 'SUCCESS' + } + + // Lots of images with tags are created above; no apparent way to delete images:tags with docker global variable + // run bash script to clean images:tags after successful pushing + sh "docker images | grep \"${artifactory_org}/${image_name}\" | awk '{print \$1 \":\" \$2}' | xargs docker rmi" } } @@ -242,7 +260,7 @@ parallel hcc_ctu: docker_build_inside_image( hip_build_image, inside_args, hcc_ver, '', build_config, source_hip_rel, build_hip_rel ) // After a successful build, upload a docker image of the results - docker_upload_artifactory( hcc_ver, from_image, source_hip_rel, build_hip_rel ) + docker_upload_install_image( hcc_ver, from_image, source_hip_rel, build_hip_rel ) } }, hcc_1_6: @@ -276,7 +294,7 @@ hcc_1_6: docker_build_inside_image( hip_build_image, inside_args, hcc_ver, '', build_config, source_hip_rel, build_hip_rel ) // After a successful build, upload a docker image of the results - docker_upload_artifactory( hcc_ver, from_image, source_hip_rel, build_hip_rel ) + docker_upload_install_image( hcc_ver, from_image, source_hip_rel, build_hip_rel ) } }, nvcc: From c8c50166018a9573c71b9e362fdbf72b08d4dff5 Mon Sep 17 00:00:00 2001 From: Kent Knox Date: Thu, 10 Aug 2017 14:52:09 -0500 Subject: [PATCH 2/6] Adding docker_upload_dockerhub Refactored when docker images get deleted to the end of the pipeline --- hipamd/Jenkinsfile | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/hipamd/Jenkinsfile b/hipamd/Jenkinsfile index 280ea9b5ad..7bb6fc8756 100644 --- a/hipamd/Jenkinsfile +++ b/hipamd/Jenkinsfile @@ -156,7 +156,7 @@ def docker_build_inside_image( def build_image, String inside_args, String platf //////////////////////////////////////////////////////////////////////// // This builds a fresh docker image FROM a clean base image, with no build dependencies included // Uploads the new docker image to internal artifactory -def docker_upload_install_image( String hcc_ver, String from_image, String source_hip_rel, String build_dir_rel ) +def docker_upload_artifactory( String hcc_ver, String from_image, String source_hip_rel, String build_dir_rel ) { def hip_install_image = null String image_name = "hip-${hcc_ver}-ubuntu-16.04" @@ -173,7 +173,6 @@ def docker_upload_install_image( String hcc_ver, String from_image, String sourc // Docker inspect failing on FROM statements with ARG https://issues.jenkins-ci.org/browse/JENKINS-44836 // hip_install_image = docker.build( "${artifactory_org}/${image_name}:${env.BUILD_NUMBER}", "--pull -f ${build_dir_rel}/dockerfile-hip-ubuntu-16.04 --build-arg base_image=${from_image} ${build_dir_rel}" ) - // The --build-arg REPO_RADEON= is a temporary fix to get around a DNS issue with our build machines // JENKINS-44836 workaround by using a bash script instead of docker.build() sh "docker build -t ${artifactory_org}/${image_name}:${env.BUILD_NUMBER} --pull -f ${build_dir_rel}/dockerfile-hip-ubuntu-16.04 --build-arg base_image=${from_image} ${build_dir_rel}" hip_install_image = docker.image( "${artifactory_org}/${image_name}:${env.BUILD_NUMBER}" ) @@ -199,6 +198,21 @@ def docker_upload_install_image( String hcc_ver, String from_image, String sourc { currentBuild.result = 'SUCCESS' } + } + + return hip_install_image +} + +//////////////////////////////////////////////////////////////////////// +// This builds a fresh docker image FROM a clean base image, with no build dependencies included +// Uploads the new docker image to internal artifactory +def docker_upload_dockerhub( def hip_install_image, String hcc_ver ) +{ + String image_name = "hip-${hcc_ver}-ubuntu-16.04" + + stage( 'docker-hub' ) + { + docker_hub_image = docker.tag( "rocm/${image_name}:${env.BUILD_NUMBER}" ) // Do not treat failures to push to docker-hub as a build fail try @@ -208,8 +222,8 @@ def docker_upload_install_image( String hcc_ver, String from_image, String sourc { docker.withRegistry('https://hub.docker.com', 'docker-hub-cred' ) { - hip_install_image.push( "${env.BUILD_NUMBER}" ) - hip_install_image.push( 'latest' ) + docker_hub_image.push( "${env.BUILD_NUMBER}" ) + docker_hub_image.push( 'latest' ) } } } @@ -218,12 +232,22 @@ def docker_upload_install_image( String hcc_ver, String from_image, String sourc currentBuild.result = 'SUCCESS' } - // Lots of images with tags are created above; no apparent way to delete images:tags with docker global variable - // run bash script to clean images:tags after successful pushing - sh "docker images | grep \"${artifactory_org}/${image_name}\" | awk '{print \$1 \":\" \$2}' | xargs docker rmi" } } +// Lots of images with tags are created above; no apparent way to delete images:tags with docker global variable +def docker_clean_images( String hcc_ver ) +{ + String image_name = "hip-${hcc_ver}-ubuntu-16.04" + String artifactory_org = env.JOB_NAME.toLowerCase( ) + + // run bash script to clean images:tags after successful pushing + sh "docker images | grep \"${artifactory_org}/${image_name}\" | awk '{print \$1 \":\" \$2}' | xargs docker rmi" + + // run bash script to clean images:tags after successful pushing + sh "docker images | grep \"rocm/${image_name}\" | awk '{print \$1 \":\" \$2}' | xargs docker rmi" +} + //////////////////////////////////////////////////////////////////////// // -- MAIN // Following this line is the start of MAIN of this Jenkinsfile @@ -260,7 +284,8 @@ parallel hcc_ctu: docker_build_inside_image( hip_build_image, inside_args, hcc_ver, '', build_config, source_hip_rel, build_hip_rel ) // After a successful build, upload a docker image of the results - docker_upload_install_image( hcc_ver, from_image, source_hip_rel, build_hip_rel ) + hip_install_image = docker_upload_artifactory( hcc_ver, from_image, source_hip_rel, build_hip_rel ) + docker_upload_dockerhub( hip_install_image, hcc_ver ) } }, hcc_1_6: @@ -294,7 +319,7 @@ hcc_1_6: docker_build_inside_image( hip_build_image, inside_args, hcc_ver, '', build_config, source_hip_rel, build_hip_rel ) // After a successful build, upload a docker image of the results - docker_upload_install_image( hcc_ver, from_image, source_hip_rel, build_hip_rel ) + docker_upload_artifactory( hcc_ver, from_image, source_hip_rel, build_hip_rel ) } }, nvcc: From 46f9300a12e1564f2ddfcad8705b9fc5e542a292 Mon Sep 17 00:00:00 2001 From: Kent Knox Date: Thu, 10 Aug 2017 16:13:57 -0500 Subject: [PATCH 3/6] Adding docker_clean_images --- hipamd/Jenkinsfile | 155 ++++++++++++++++++++++++--------------------- 1 file changed, 84 insertions(+), 71 deletions(-) diff --git a/hipamd/Jenkinsfile b/hipamd/Jenkinsfile index 7bb6fc8756..efcb0b955b 100644 --- a/hipamd/Jenkinsfile +++ b/hipamd/Jenkinsfile @@ -140,7 +140,6 @@ def docker_build_inside_image( def build_image, String inside_args, String platf // No matter the base platform, all packages have the same name // Only upload 1 set of packages, so we don't have a race condition uploading packages - // Using hcc-ctu since that is what most people want if( platform.toLowerCase( ).startsWith( 'hcc-ctu' ) ) { archiveArtifacts artifacts: "${build_dir_rel}/*.deb", fingerprint: true @@ -174,8 +173,8 @@ def docker_upload_artifactory( String hcc_ver, String from_image, String source_ // hip_install_image = docker.build( "${artifactory_org}/${image_name}:${env.BUILD_NUMBER}", "--pull -f ${build_dir_rel}/dockerfile-hip-ubuntu-16.04 --build-arg base_image=${from_image} ${build_dir_rel}" ) // JENKINS-44836 workaround by using a bash script instead of docker.build() - sh "docker build -t ${artifactory_org}/${image_name}:${env.BUILD_NUMBER} --pull -f ${build_dir_rel}/dockerfile-hip-ubuntu-16.04 --build-arg base_image=${from_image} ${build_dir_rel}" - hip_install_image = docker.image( "${artifactory_org}/${image_name}:${env.BUILD_NUMBER}" ) + sh "docker build -t ${artifactory_org}/${image_name} --pull -f ${build_dir_rel}/dockerfile-hip-ubuntu-16.04 --build-arg base_image=${from_image} ${build_dir_rel}" + hip_install_image = docker.image( "${artifactory_org}/${image_name}" ) // The connection to artifactory can fail sometimes, but this should not be treated as a build fail try @@ -204,31 +203,43 @@ def docker_upload_artifactory( String hcc_ver, String from_image, String source_ } //////////////////////////////////////////////////////////////////////// -// This builds a fresh docker image FROM a clean base image, with no build dependencies included -// Uploads the new docker image to internal artifactory +// Uploads the new docker image to the public docker-hub def docker_upload_dockerhub( def hip_install_image, String hcc_ver ) { String image_name = "hip-${hcc_ver}-ubuntu-16.04" + String artifactory_org = env.JOB_NAME.toLowerCase( ) stage( 'docker-hub' ) { - docker_hub_image = docker.tag( "rocm/${image_name}:${env.BUILD_NUMBER}" ) - // Do not treat failures to push to docker-hub as a build fail try { // Only push changes to the master branch to docker-hub if( env.BRANCH_NAME.toLowerCase( ).startsWith( 'docker' ) ) { - docker.withRegistry('https://hub.docker.com', 'docker-hub-cred' ) + println "inside startswith" + + sh """#!/usr/bin/env bash + set -x + echo inside sh + docker tag ${artifactory_org}/${image_name} rocm/${image_name} + """ + println "after sh" + + hip_install_image = docker.image( "rocm/${image_name}" ) + println "after docker.image" + + docker.withRegistry('https://registry.hub.docker.com', 'docker-hub-cred' ) { - docker_hub_image.push( "${env.BUILD_NUMBER}" ) - docker_hub_image.push( 'latest' ) + println "docker.withRegistry" + hip_install_image.push( "${env.BUILD_NUMBER}" ) + hip_install_image.push( 'latest' ) } } } catch( err ) { + println "err: " + err.toString() currentBuild.result = 'SUCCESS' } @@ -253,43 +264,43 @@ def docker_clean_images( String hcc_ver ) // Following this line is the start of MAIN of this Jenkinsfile String build_config = 'Release' -parallel hcc_ctu: -{ - node('docker && rocm && gfx803') - { - String hcc_ver = 'hcc-ctu' - String from_image = 'compute-artifactory:5001/radeonopencompute/hcc/clang_tot_upgrade/hcc-lc-ubuntu-16.04:latest' - String inside_args = '--device=/dev/kfd' +// parallel hcc_ctu: +// { +// node('docker && rocm && gfx803') +// { +// String hcc_ver = 'hcc-ctu' +// String from_image = 'compute-artifactory:5001/radeonopencompute/hcc/clang_tot_upgrade/hcc-lc-ubuntu-16.04:latest' +// String inside_args = '--device=/dev/kfd' - // Checkout source code, dependencies and version files - String source_hip_rel = checkout_and_version( hcc_ver ) +// // Checkout source code, dependencies and version files +// String source_hip_rel = checkout_and_version( hcc_ver ) - // Create/reuse a docker image that represents the hip build environment - def hip_build_image = docker_build_image( hcc_ver, source_hip_rel, from_image ) +// // Create/reuse a docker image that represents the hip build environment +// def hip_build_image = docker_build_image( hcc_ver, source_hip_rel, from_image ) - // Print system information for the log - hip_build_image.inside( inside_args ) - { - sh """#!/usr/bin/env bash - set -x - /opt/rocm/bin/rocm_agent_enumerator -t ALL - /opt/rocm/bin/hcc --version - """ - } +// // Print system information for the log +// hip_build_image.inside( inside_args ) +// { +// sh """#!/usr/bin/env bash +// set -x +// /opt/rocm/bin/rocm_agent_enumerator -t ALL +// /opt/rocm/bin/hcc --version +// """ +// } - // Conctruct a binary directory path based on build config - String build_hip_rel = build_directory_rel( build_config ); +// // Conctruct a binary directory path based on build config +// String build_hip_rel = build_directory_rel( build_config ); - // Build hip inside of the build environment - docker_build_inside_image( hip_build_image, inside_args, hcc_ver, '', build_config, source_hip_rel, build_hip_rel ) +// // Build hip inside of the build environment +// docker_build_inside_image( hip_build_image, inside_args, hcc_ver, '', build_config, source_hip_rel, build_hip_rel ) - // After a successful build, upload a docker image of the results - hip_install_image = docker_upload_artifactory( hcc_ver, from_image, source_hip_rel, build_hip_rel ) - docker_upload_dockerhub( hip_install_image, hcc_ver ) - } -}, -hcc_1_6: -{ +// // After a successful build, upload a docker image of the results +// hip_install_image = docker_upload_artifactory( hcc_ver, from_image, source_hip_rel, build_hip_rel ) +// docker_upload_dockerhub( hip_install_image, hcc_ver ) +// } +// }, +// hcc_1_6: +// { node('docker && rocm && gfx803') { String hcc_ver = 'hcc-1.6' @@ -319,45 +330,47 @@ hcc_1_6: docker_build_inside_image( hip_build_image, inside_args, hcc_ver, '', build_config, source_hip_rel, build_hip_rel ) // After a successful build, upload a docker image of the results - docker_upload_artifactory( hcc_ver, from_image, source_hip_rel, build_hip_rel ) + hip_install_image = docker_upload_artifactory( hcc_ver, from_image, source_hip_rel, build_hip_rel ) + docker_upload_dockerhub( hip_install_image, hcc_ver ) + docker_clean_images( hcc_ver ) } -}, -nvcc: -{ - node('docker && cuda') - { - //////////////////////////////////////////////////////////////////////// - // Block of string constants customizing behavior for cuda - String nvcc_ver = 'nvcc-8.0' - String from_image = 'nvidia/cuda:8.0-devel' +// }, +// nvcc: +// { +// node('docker && cuda') +// { +// //////////////////////////////////////////////////////////////////////// +// // Block of string constants customizing behavior for cuda +// String nvcc_ver = 'nvcc-8.0' +// String from_image = 'nvidia/cuda:8.0-devel' // This unfortunately hardcodes the driver version nvidia_driver_375.74 in the volume mount. Research if a way // exists to get volume driver to customize the volume names to leave out driver version String inside_args = '''--device=/dev/nvidiactl --device=/dev/nvidia0 --device=/dev/nvidia-uvm --device=/dev/nvidia-uvm-tools --volume-driver=nvidia-docker --volume=nvidia_driver_375.74:/usr/local/nvidia:ro'''; - // Checkout source code, dependencies and version files - String source_hip_rel = checkout_and_version( nvcc_ver ) +// // Checkout source code, dependencies and version files +// String source_hip_rel = checkout_and_version( nvcc_ver ) - // We pull public nvidia images - def hip_build_image = docker_build_image( nvcc_ver, source_hip_rel, from_image ) +// // We pull public nvidia images +// def hip_build_image = docker_build_image( nvcc_ver, source_hip_rel, from_image ) - // Print system information for the log - hip_build_image.inside( inside_args ) - { - sh """#!/usr/bin/env bash - set -x - nvidia-smi - nvcc --version - """ - } +// // Print system information for the log +// hip_build_image.inside( inside_args ) +// { +// sh """#!/usr/bin/env bash +// set -x +// nvidia-smi +// nvcc --version +// """ +// } - // Conctruct a binary directory path based on build config - String build_hip_rel = build_directory_rel( build_config ); +// // Conctruct a binary directory path based on build config +// String build_hip_rel = build_directory_rel( build_config ); - // Build hip inside of the build environment - docker_build_inside_image( hip_build_image, inside_args, nvcc_ver, "-DHIP_NVCC_FLAGS=--Wno-deprecated-gpu-targets", build_config, source_hip_rel, build_hip_rel ) +// // Build hip inside of the build environment +// docker_build_inside_image( hip_build_image, inside_args, nvcc_ver, "-DHIP_NVCC_FLAGS=--Wno-deprecated-gpu-targets", build_config, source_hip_rel, build_hip_rel ) - // Not pushing an Nvidia based HiP to artifactory at this time - } -} +// // Not pushing an Nvidia based HiP to artifactory at this time +// } +// } From 60908fe8da600eecc3869fdeb3b686b0e0f08856 Mon Sep 17 00:00:00 2001 From: Kent Knox Date: Fri, 11 Aug 2017 14:14:27 -0500 Subject: [PATCH 4/6] Adding support to take parameters from upstream hcc HCC build can start passing in build parameters into hip build --- hipamd/Jenkinsfile | 214 ++++++++++++++++++++++++++------------------- 1 file changed, 122 insertions(+), 92 deletions(-) diff --git a/hipamd/Jenkinsfile b/hipamd/Jenkinsfile index efcb0b955b..392c018259 100644 --- a/hipamd/Jenkinsfile +++ b/hipamd/Jenkinsfile @@ -10,6 +10,45 @@ properties([buildDiscarder(logRotator( [$class: 'CopyArtifactPermissionProperty', projectNames: '*'] ]) +//////////////////////////////////////////////////////////////////////// +// -- Test & Bootstrapping code + +node('docker && rocm') +{ + String hcc_ver = 'hcc-1.6' + String from_image = 'compute-artifactory:5001/radeonopencompute/hcc/roc-1.6.x/hcc-lc-ubuntu-16.04:latest' + String inside_args = '--device=/dev/kfd' + + stage( 'parameters' ) + { + cleanWs( ) + + println "upstream_hcc: ${params.upstream_hcc}" + if( params.upstream_hcc ) + { + step([$class: 'CopyArtifact', filter: 'archive/**/*.deb, docker/dockerfile-*', + fingerprintArtifacts: true, projectName: "${params.upstream_hcc}", flatten: true, + selector: [$class: 'TriggeredBuildSelector', allowUpstreamDependencies: false, fallbackToLastSuccessful: false, upstreamFilterStrategy: 'UseGlobalSetting'], + target: 'integration-testing' ]) + + // // The following that copies from workspace apparently copies from the PREVIOUS COMPLETED build, so not as handy + // step( [$class: 'CopyArtifact', filter: '**', fingerprintArtifacts: true, flatten: true, + // projectName: "${params.upstream_hcc}", selector: [$class: 'WorkspaceSelector'], target: 'integration-testing'] ) + } + else + { + println "upstream_hcc: tested false" + } + + sh """#!/usr/bin/env bash + set -x + ls -Rlah + """ + } +} + +return + //////////////////////////////////////////////////////////////////////// // -- AUXILLARY HELPER FUNCTIONS @@ -155,11 +194,10 @@ def docker_build_inside_image( def build_image, String inside_args, String platf //////////////////////////////////////////////////////////////////////// // This builds a fresh docker image FROM a clean base image, with no build dependencies included // Uploads the new docker image to internal artifactory -def docker_upload_artifactory( String hcc_ver, String from_image, String source_hip_rel, String build_dir_rel ) +String docker_upload_artifactory( String hcc_ver, String artifactory_org, String from_image, String source_hip_rel, String build_dir_rel ) { def hip_install_image = null String image_name = "hip-${hcc_ver}-ubuntu-16.04" - String artifactory_org = env.JOB_NAME.toLowerCase( ) stage( 'artifactory' ) { @@ -199,16 +237,13 @@ def docker_upload_artifactory( String hcc_ver, String from_image, String source_ } } - return hip_install_image + return image_name } //////////////////////////////////////////////////////////////////////// // Uploads the new docker image to the public docker-hub -def docker_upload_dockerhub( def hip_install_image, String hcc_ver ) +def docker_upload_dockerhub( String artifactory_org, String image_name ) { - String image_name = "hip-${hcc_ver}-ubuntu-16.04" - String artifactory_org = env.JOB_NAME.toLowerCase( ) - stage( 'docker-hub' ) { // Do not treat failures to push to docker-hub as a build fail @@ -217,90 +252,86 @@ def docker_upload_dockerhub( def hip_install_image, String hcc_ver ) // Only push changes to the master branch to docker-hub if( env.BRANCH_NAME.toLowerCase( ).startsWith( 'docker' ) ) { - println "inside startswith" - sh """#!/usr/bin/env bash set -x echo inside sh docker tag ${artifactory_org}/${image_name} rocm/${image_name} """ - println "after sh" - hip_install_image = docker.image( "rocm/${image_name}" ) - println "after docker.image" + docker_hub_image = docker.image( "rocm/${image_name}" ) - docker.withRegistry('https://registry.hub.docker.com', 'docker-hub-cred' ) - { - println "docker.withRegistry" - hip_install_image.push( "${env.BUILD_NUMBER}" ) - hip_install_image.push( 'latest' ) - } + // docker.withRegistry('https://registry.hub.docker.com', 'docker-hub-cred' ) + // { + // docker_hub_image.push( "${env.BUILD_NUMBER}" ) + // docker_hub_image.push( 'latest' ) + // } } } catch( err ) { - println "err: " + err.toString() currentBuild.result = 'SUCCESS' } - } } // Lots of images with tags are created above; no apparent way to delete images:tags with docker global variable -def docker_clean_images( String hcc_ver ) +def docker_clean_images( String artifactory_org, String image_name ) { - String image_name = "hip-${hcc_ver}-ubuntu-16.04" - String artifactory_org = env.JOB_NAME.toLowerCase( ) + // Check if any images exist first, the script returns a 0 for success, indicating grep found images + def docker_images = sh( script: "docker images | grep \"${artifactory_org}/${image_name}\"", returnStatus: true ) - // run bash script to clean images:tags after successful pushing - sh "docker images | grep \"${artifactory_org}/${image_name}\" | awk '{print \$1 \":\" \$2}' | xargs docker rmi" - - // run bash script to clean images:tags after successful pushing - sh "docker images | grep \"rocm/${image_name}\" | awk '{print \$1 \":\" \$2}' | xargs docker rmi" + if( docker_images == 0 ) + { + // run bash script to clean images:tags after successful pushing + sh "docker images | grep \"${artifactory_org}/${image_name}\" | awk '{print \$1 \":\" \$2}' | xargs docker rmi" + } } //////////////////////////////////////////////////////////////////////// // -- MAIN // Following this line is the start of MAIN of this Jenkinsfile String build_config = 'Release' +String job_name = env.JOB_NAME.toLowerCase( ) -// parallel hcc_ctu: -// { -// node('docker && rocm && gfx803') -// { -// String hcc_ver = 'hcc-ctu' -// String from_image = 'compute-artifactory:5001/radeonopencompute/hcc/clang_tot_upgrade/hcc-lc-ubuntu-16.04:latest' -// String inside_args = '--device=/dev/kfd' +parallel hcc_ctu: +{ + node('docker && rocm && gfx803') + { + String hcc_ver = 'hcc-ctu' + String from_image = 'compute-artifactory:5001/radeonopencompute/hcc/clang_tot_upgrade/hcc-lc-ubuntu-16.04:latest' + String inside_args = '--device=/dev/kfd' -// // Checkout source code, dependencies and version files -// String source_hip_rel = checkout_and_version( hcc_ver ) + // Checkout source code, dependencies and version files + String source_hip_rel = checkout_and_version( hcc_ver ) -// // Create/reuse a docker image that represents the hip build environment -// def hip_build_image = docker_build_image( hcc_ver, source_hip_rel, from_image ) + // Create/reuse a docker image that represents the hip build environment + def hip_build_image = docker_build_image( hcc_ver, source_hip_rel, from_image ) -// // Print system information for the log -// hip_build_image.inside( inside_args ) -// { -// sh """#!/usr/bin/env bash -// set -x -// /opt/rocm/bin/rocm_agent_enumerator -t ALL -// /opt/rocm/bin/hcc --version -// """ -// } + // Print system information for the log + hip_build_image.inside( inside_args ) + { + sh """#!/usr/bin/env bash + set -x + /opt/rocm/bin/rocm_agent_enumerator -t ALL + /opt/rocm/bin/hcc --version + """ + } -// // Conctruct a binary directory path based on build config -// String build_hip_rel = build_directory_rel( build_config ); + // Conctruct a binary directory path based on build config + String build_hip_rel = build_directory_rel( build_config ); -// // Build hip inside of the build environment -// docker_build_inside_image( hip_build_image, inside_args, hcc_ver, '', build_config, source_hip_rel, build_hip_rel ) + // Build hip inside of the build environment + docker_build_inside_image( hip_build_image, inside_args, hcc_ver, '', build_config, source_hip_rel, build_hip_rel ) -// // After a successful build, upload a docker image of the results -// hip_install_image = docker_upload_artifactory( hcc_ver, from_image, source_hip_rel, build_hip_rel ) -// docker_upload_dockerhub( hip_install_image, hcc_ver ) -// } -// }, -// hcc_1_6: -// { + // After a successful build, upload a docker image of the results + hip_install_image = docker_upload_artifactory( hcc_ver, job_name, from_image, source_hip_rel, build_hip_rel ) + docker_upload_dockerhub( job_name, hip_image_name ) + docker_clean_images( job_name, hip_image_name ) + docker_clean_images( 'rocm', hip_image_name ) + } +}, +hcc_1_6: +{ node('docker && rocm && gfx803') { String hcc_ver = 'hcc-1.6' @@ -329,48 +360,47 @@ String build_config = 'Release' // Build hip inside of the build environment docker_build_inside_image( hip_build_image, inside_args, hcc_ver, '', build_config, source_hip_rel, build_hip_rel ) - // After a successful build, upload a docker image of the results - hip_install_image = docker_upload_artifactory( hcc_ver, from_image, source_hip_rel, build_hip_rel ) - docker_upload_dockerhub( hip_install_image, hcc_ver ) - docker_clean_images( hcc_ver ) + // Not pushing hip-hcc-1.6 builds at this time + hip_image_name = docker_upload_artifactory( hcc_ver, job_name, from_image, source_hip_rel, build_hip_rel ) + docker_clean_images( job_name, hip_image_name ) } -// }, -// nvcc: -// { -// node('docker && cuda') -// { -// //////////////////////////////////////////////////////////////////////// -// // Block of string constants customizing behavior for cuda -// String nvcc_ver = 'nvcc-8.0' -// String from_image = 'nvidia/cuda:8.0-devel' +}, +nvcc: +{ + node('docker && cuda') + { + //////////////////////////////////////////////////////////////////////// + // Block of string constants customizing behavior for cuda + String nvcc_ver = 'nvcc-8.0' + String from_image = 'nvidia/cuda:8.0-devel' // This unfortunately hardcodes the driver version nvidia_driver_375.74 in the volume mount. Research if a way // exists to get volume driver to customize the volume names to leave out driver version String inside_args = '''--device=/dev/nvidiactl --device=/dev/nvidia0 --device=/dev/nvidia-uvm --device=/dev/nvidia-uvm-tools --volume-driver=nvidia-docker --volume=nvidia_driver_375.74:/usr/local/nvidia:ro'''; -// // Checkout source code, dependencies and version files -// String source_hip_rel = checkout_and_version( nvcc_ver ) + // Checkout source code, dependencies and version files + String source_hip_rel = checkout_and_version( nvcc_ver ) -// // We pull public nvidia images -// def hip_build_image = docker_build_image( nvcc_ver, source_hip_rel, from_image ) + // We pull public nvidia images + def hip_build_image = docker_build_image( nvcc_ver, source_hip_rel, from_image ) -// // Print system information for the log -// hip_build_image.inside( inside_args ) -// { -// sh """#!/usr/bin/env bash -// set -x -// nvidia-smi -// nvcc --version -// """ -// } + // Print system information for the log + hip_build_image.inside( inside_args ) + { + sh """#!/usr/bin/env bash + set -x + nvidia-smi + nvcc --version + """ + } -// // Conctruct a binary directory path based on build config -// String build_hip_rel = build_directory_rel( build_config ); + // Conctruct a binary directory path based on build config + String build_hip_rel = build_directory_rel( build_config ); -// // Build hip inside of the build environment -// docker_build_inside_image( hip_build_image, inside_args, nvcc_ver, "-DHIP_NVCC_FLAGS=--Wno-deprecated-gpu-targets", build_config, source_hip_rel, build_hip_rel ) + // Build hip inside of the build environment + docker_build_inside_image( hip_build_image, inside_args, nvcc_ver, "-DHIP_NVCC_FLAGS=--Wno-deprecated-gpu-targets", build_config, source_hip_rel, build_hip_rel ) -// // Not pushing an Nvidia based HiP to artifactory at this time -// } -// } + // Not pushing an Nvidia based HiP to artifactory at this time + } +} From 8840fc3f87c4f7b5b1a2c769b1736c966a933f3d Mon Sep 17 00:00:00 2001 From: Kent Knox Date: Tue, 15 Aug 2017 17:53:21 -0500 Subject: [PATCH 5/6] Made function hcc_integration_testing --- hipamd/Jenkinsfile | 163 ++++++++++++++++++++++++++++++--------------- 1 file changed, 111 insertions(+), 52 deletions(-) diff --git a/hipamd/Jenkinsfile b/hipamd/Jenkinsfile index 392c018259..12d76803b8 100644 --- a/hipamd/Jenkinsfile +++ b/hipamd/Jenkinsfile @@ -7,50 +7,36 @@ properties([buildDiscarder(logRotator( daysToKeepStr: '', numToKeepStr: '10')), disableConcurrentBuilds(), + // parameters([string(name: 'sample_string', defaultValue: '', description: 'description of a sample string')]), [$class: 'CopyArtifactPermissionProperty', projectNames: '*'] ]) //////////////////////////////////////////////////////////////////////// -// -- Test & Bootstrapping code - -node('docker && rocm') -{ - String hcc_ver = 'hcc-1.6' - String from_image = 'compute-artifactory:5001/radeonopencompute/hcc/roc-1.6.x/hcc-lc-ubuntu-16.04:latest' - String inside_args = '--device=/dev/kfd' - - stage( 'parameters' ) - { - cleanWs( ) - - println "upstream_hcc: ${params.upstream_hcc}" - if( params.upstream_hcc ) - { - step([$class: 'CopyArtifact', filter: 'archive/**/*.deb, docker/dockerfile-*', - fingerprintArtifacts: true, projectName: "${params.upstream_hcc}", flatten: true, - selector: [$class: 'TriggeredBuildSelector', allowUpstreamDependencies: false, fallbackToLastSuccessful: false, upstreamFilterStrategy: 'UseGlobalSetting'], - target: 'integration-testing' ]) - - // // The following that copies from workspace apparently copies from the PREVIOUS COMPLETED build, so not as handy - // step( [$class: 'CopyArtifact', filter: '**', fingerprintArtifacts: true, flatten: true, - // projectName: "${params.upstream_hcc}", selector: [$class: 'WorkspaceSelector'], target: 'integration-testing'] ) - } - else - { - println "upstream_hcc: tested false" - } - - sh """#!/usr/bin/env bash - set -x - ls -Rlah - """ - } -} - -return +// -- AUXILLARY HELPER FUNCTIONS //////////////////////////////////////////////////////////////////////// -// -- AUXILLARY HELPER FUNCTIONS +// Return build number of upstream job +@NonCPS +int get_upstream_build_num( ) +{ + def upstream_cause = currentBuild.rawBuild.getCause( hudson.model.Cause$UpstreamCause ) + if( upstream_cause == null) + return 0 + + return upstream_cause.getUpstreamBuild() +} + +//////////////////////////////////////////////////////////////////////// +// Return project name of upstream job +@NonCPS +String get_upstream_build_project( ) +{ + def upstream_cause = currentBuild.rawBuild.getCause( hudson.model.Cause$UpstreamCause ) + if( upstream_cause == null) + return null + + return upstream_cause.getUpstreamProject() +} //////////////////////////////////////////////////////////////////////// // Construct the relative path of the build directory @@ -99,12 +85,10 @@ String checkout_and_version( String platform ) //////////////////////////////////////////////////////////////////////// // This creates the docker image that we use to build the project in // The docker images contains all dependencies, including OS platform, to build -def docker_build_image( String platform, String source_hip_rel, String from_image ) +def docker_build_image( String platform, String org, String optional_build_parm, String source_hip_rel, String from_image ) { - String project = "hip" - String build_type_name = "build-ubuntu-16.04" - String dockerfile_name = "dockerfile-${build_type_name}" - String build_image_name = "${build_type_name}" + String build_image_name = "build-ubuntu-16.04" + String dockerfile_name = "dockerfile-build-ubuntu-16.04" def build_image = null stage("${platform} build image") @@ -115,11 +99,11 @@ def docker_build_image( String platform, String source_hip_rel, String from_imag // Docker 17.05 introduced the ability to use ARG values in FROM statements // Docker inspect failing on FROM statements with ARG https://issues.jenkins-ci.org/browse/JENKINS-44836 - //build_image = docker.build( "${project}/${build_image_name}:latest", "--pull -f docker/${dockerfile_name} --build-arg user_uid=${user_uid} --build-arg base_image=${from_image} ." ) + // build_image = docker.build( "${org}/${build_image_name}:latest", "--pull -f docker/${dockerfile_name} --build-arg user_uid=${user_uid} --build-arg base_image=${from_image} ." ) // JENKINS-44836 workaround by using a bash script instead of docker.build() - sh "docker build -t ${project}/${build_image_name}:latest --pull -f docker/${dockerfile_name} --build-arg user_uid=${user_uid} --build-arg base_image=${from_image} ." - build_image = docker.image( "${project}/${build_image_name}:latest" ) + sh "docker build -t ${org}/${build_image_name}:latest -f docker/${dockerfile_name} ${optional_build_parm} --build-arg user_uid=${user_uid} --build-arg base_image=${from_image} ." + build_image = docker.image( "${org}/${build_image_name}:latest" ) } } @@ -275,24 +259,99 @@ def docker_upload_dockerhub( String artifactory_org, String image_name ) } // Lots of images with tags are created above; no apparent way to delete images:tags with docker global variable -def docker_clean_images( String artifactory_org, String image_name ) +def docker_clean_images( String org, String image_name ) { // Check if any images exist first, the script returns a 0 for success, indicating grep found images - def docker_images = sh( script: "docker images | grep \"${artifactory_org}/${image_name}\"", returnStatus: true ) + def docker_images = sh( script: "docker images | grep \"${org}/${image_name}\"", returnStatus: true ) if( docker_images == 0 ) { // run bash script to clean images:tags after successful pushing - sh "docker images | grep \"${artifactory_org}/${image_name}\" | awk '{print \$1 \":\" \$2}' | xargs docker rmi" + sh "docker images | grep \"${org}/${image_name}\" | awk '{print \$1 \":\" \$2}' | xargs docker rmi" } } +//////////////////////////////////////////////////////////////////////// +// hcc_integration_testing +// This function is sets up compilation and testing of HiP on a compiler downloaded from an upstream build +// Integration testing is centered around docker and constructing clean test environments every time + +// NOTES: I have implemeneted integration testing 3 different ways, and I've come to the conclusion nothing is perfect +// 1. I've tried having HCC push the test compiler to artifactory, and having HiP download the test docker image from artifactory +// a. The act of uploading and downloading images from artifactory takes minutes +// b. There is no good way of deleting images from a repository. You have to use an arcane CURL command and I don't know how +// to keep the password secret. These test integration images are meant to be ephemeral. +// 2. I tried 'docker save' to export a docker image into a tarball, and transfering the image through 'copy artifacts plugin' +// a. The HCC docker image uncompressed is over 1GB +// b. Compressing the docker image takes even longer than uploading the image to artifactory +// 3. Download the HCC .deb and dockerfile through 'copy artifacts plugin'. Create a new HCC image on the fly +// a. There is inefficency in building a new ubuntu image and installing HCC twice (once in HCC build, once here) +// b. This solution doesn't scale when we start testing downstream libraries + +// I've implemented solution #3 above, probably transitioning to #2 down the line (probably without compression) +String hcc_integration_testing( String inside_args, String job, String build_config ) +{ + // Attempt to make unique docker image names for each build, to support concurrent builds + // Mangle docker org name with upstream build info + String testing_org_name = 'hcc-test-' + get_upstream_build_project( ).replaceAll('/','-') + '-' + get_upstream_build_num( ) + + // Tag image name with this build number + String hcc_test_image_name = "hcc:${env.BUILD_NUMBER}" + + def hip_integration_image = null + + dir( 'integration-testing' ) + { + deleteDir( ) + + // This invokes 'copy artifact plugin' to copy archived files from upstream build + step([$class: 'CopyArtifact', filter: 'archive/**/*.deb, docker/dockerfile-*', + fingerprintArtifacts: true, projectName: get_upstream_build_project( ), flatten: true, + selector: [$class: 'TriggeredBuildSelector', allowUpstreamDependencies: false, fallbackToLastSuccessful: false, upstreamFilterStrategy: 'UseGlobalSetting'], + target: '.' ]) +// // The following 'copy artifact' is supposed to copy direct from workspace, but it doesn't seem to work across machines +// step( [$class: 'CopyArtifact', filter: '**', fingerprintArtifacts: true, flatten: true, +// projectName: "${params.upstream_hcc}", selector: [$class: 'WorkspaceSelector'], target: 'integration-testing'] ) + + docker.build( "${testing_org_name}/${hcc_test_image_name}", "-f dockerfile-hcc-lc-ubuntu-16.04 ." ) + } + + // Checkout source code, dependencies and version files + String source_hip_rel = checkout_and_version( job ) + + // Conctruct a binary directory path based on build config + String build_hip_rel = build_directory_rel( build_config ); + + // Build hip inside of the build environment + hip_integration_image = docker_build_image( job, testing_org_name, '', source_hip_rel, "${testing_org_name}/${hcc_test_image_name}" ) + + docker_build_inside_image( hip_integration_image, inside_args, job, '', build_config, source_hip_rel, build_hip_rel ) + + docker_clean_images( testing_org_name, '*' ) +} + //////////////////////////////////////////////////////////////////////// // -- MAIN // Following this line is the start of MAIN of this Jenkinsfile String build_config = 'Release' String job_name = env.JOB_NAME.toLowerCase( ) +// Integration testing is a special path which implies testing of an upsteam build of hcc, +// but does not need testing across older builds of hcc or cuda. This is more of a compiler +// hcc unit test +if( params.hcc_integration_test ) +{ + println "HCC integration testing" + + node('docker && rocm') + { + hcc_integration_testing( '--device=/dev/kfd', 'hcc-ctu', build_config ) + } + + return +} + +// The following launches 3 builds in parallel: hcc-ctu, hcc-1.6 and cuda parallel hcc_ctu: { node('docker && rocm && gfx803') @@ -305,7 +364,7 @@ parallel hcc_ctu: String source_hip_rel = checkout_and_version( hcc_ver ) // Create/reuse a docker image that represents the hip build environment - def hip_build_image = docker_build_image( hcc_ver, source_hip_rel, from_image ) + def hip_build_image = docker_build_image( hcc_ver, 'hip', ' --pull', source_hip_rel, from_image ) // Print system information for the log hip_build_image.inside( inside_args ) @@ -342,7 +401,7 @@ hcc_1_6: String source_hip_rel = checkout_and_version( hcc_ver ) // Create/reuse a docker image that represents the hip build environment - def hip_build_image = docker_build_image( hcc_ver, source_hip_rel, from_image ) + def hip_build_image = docker_build_image( hcc_ver, 'hip', ' --pull', source_hip_rel, from_image ) // Print system information for the log hip_build_image.inside( inside_args ) @@ -383,7 +442,7 @@ nvcc: String source_hip_rel = checkout_and_version( nvcc_ver ) // We pull public nvidia images - def hip_build_image = docker_build_image( nvcc_ver, source_hip_rel, from_image ) + def hip_build_image = docker_build_image( nvcc_ver, 'hip', ' --pull', source_hip_rel, from_image ) // Print system information for the log hip_build_image.inside( inside_args ) From 6020c8b49968ad39538ac12ffb7b062c950bd152 Mon Sep 17 00:00:00 2001 From: Kent Knox Date: Fri, 18 Aug 2017 13:21:15 -0500 Subject: [PATCH 6/6] Adding boolean parameter to job to push to docker-hub Remove the restriction to build only on gfx803 --- hipamd/Jenkinsfile | 81 +++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 40 deletions(-) diff --git a/hipamd/Jenkinsfile b/hipamd/Jenkinsfile index 12d76803b8..ce59476626 100644 --- a/hipamd/Jenkinsfile +++ b/hipamd/Jenkinsfile @@ -7,7 +7,7 @@ properties([buildDiscarder(logRotator( daysToKeepStr: '', numToKeepStr: '10')), disableConcurrentBuilds(), - // parameters([string(name: 'sample_string', defaultValue: '', description: 'description of a sample string')]), + parameters([booleanParam( name: 'push_image_to_docker_hub', defaultValue: false, description: 'Push hip & hcc image to rocm docker-hub' )]), [$class: 'CopyArtifactPermissionProperty', projectNames: '*'] ]) @@ -52,6 +52,21 @@ String build_directory_rel( String build_config ) } } +//////////////////////////////////////////////////////////////////////// +// Lots of images are created above; no apparent way to delete images:tags with docker global variable +def docker_clean_images( String org, String image_name ) +{ + // Check if any images exist first grepping for image names + int docker_images = sh( script: "docker images | grep \"${org}/${image_name}\"", returnStatus: true ) + + // The script returns a 0 for success (images were found ) + if( docker_images == 0 ) + { + // run bash script to clean images:tags after successful pushing + sh "docker images | grep \"${org}/${image_name}\" | awk '{print \$1 \":\" \$2}' | xargs docker rmi" + } +} + //////////////////////////////////////////////////////////////////////// // -- BUILD RELATED FUNCTIONS @@ -226,29 +241,25 @@ String docker_upload_artifactory( String hcc_ver, String artifactory_org, String //////////////////////////////////////////////////////////////////////// // Uploads the new docker image to the public docker-hub -def docker_upload_dockerhub( String artifactory_org, String image_name ) +def docker_upload_dockerhub( String local_org, String image_name, String remote_org ) { stage( 'docker-hub' ) { // Do not treat failures to push to docker-hub as a build fail try { - // Only push changes to the master branch to docker-hub - if( env.BRANCH_NAME.toLowerCase( ).startsWith( 'docker' ) ) + sh """#!/usr/bin/env bash + set -x + echo inside sh + docker tag ${local_org}/${image_name} ${remote_org}/${image_name} + """ + + docker_hub_image = docker.image( "${remote_org}/${image_name}" ) + + docker.withRegistry('https://registry.hub.docker.com', 'docker-hub-cred' ) { - sh """#!/usr/bin/env bash - set -x - echo inside sh - docker tag ${artifactory_org}/${image_name} rocm/${image_name} - """ - - docker_hub_image = docker.image( "rocm/${image_name}" ) - - // docker.withRegistry('https://registry.hub.docker.com', 'docker-hub-cred' ) - // { - // docker_hub_image.push( "${env.BUILD_NUMBER}" ) - // docker_hub_image.push( 'latest' ) - // } + docker_hub_image.push( "${env.BUILD_NUMBER}" ) + docker_hub_image.push( 'latest' ) } } catch( err ) @@ -258,19 +269,6 @@ def docker_upload_dockerhub( String artifactory_org, String image_name ) } } -// Lots of images with tags are created above; no apparent way to delete images:tags with docker global variable -def docker_clean_images( String org, String image_name ) -{ - // Check if any images exist first, the script returns a 0 for success, indicating grep found images - def docker_images = sh( script: "docker images | grep \"${org}/${image_name}\"", returnStatus: true ) - - if( docker_images == 0 ) - { - // run bash script to clean images:tags after successful pushing - sh "docker images | grep \"${org}/${image_name}\" | awk '{print \$1 \":\" \$2}' | xargs docker rmi" - } -} - //////////////////////////////////////////////////////////////////////// // hcc_integration_testing // This function is sets up compilation and testing of HiP on a compiler downloaded from an upstream build @@ -339,6 +337,7 @@ String job_name = env.JOB_NAME.toLowerCase( ) // Integration testing is a special path which implies testing of an upsteam build of hcc, // but does not need testing across older builds of hcc or cuda. This is more of a compiler // hcc unit test +// params.hcc_integration_test is set in HCC build if( params.hcc_integration_test ) { println "HCC integration testing" @@ -354,7 +353,7 @@ if( params.hcc_integration_test ) // The following launches 3 builds in parallel: hcc-ctu, hcc-1.6 and cuda parallel hcc_ctu: { - node('docker && rocm && gfx803') + node('docker && rocm') { String hcc_ver = 'hcc-ctu' String from_image = 'compute-artifactory:5001/radeonopencompute/hcc/clang_tot_upgrade/hcc-lc-ubuntu-16.04:latest' @@ -383,15 +382,19 @@ parallel hcc_ctu: docker_build_inside_image( hip_build_image, inside_args, hcc_ver, '', build_config, source_hip_rel, build_hip_rel ) // After a successful build, upload a docker image of the results - hip_install_image = docker_upload_artifactory( hcc_ver, job_name, from_image, source_hip_rel, build_hip_rel ) - docker_upload_dockerhub( job_name, hip_image_name ) + String hip_image_name = docker_upload_artifactory( hcc_ver, job_name, from_image, source_hip_rel, build_hip_rel ) + + if( params.push_image_to_docker_hub ) + { + docker_upload_dockerhub( job_name, hip_image_name, 'rocm' ) + docker_clean_images( 'rocm', hip_image_name ) + } docker_clean_images( job_name, hip_image_name ) - docker_clean_images( 'rocm', hip_image_name ) } }, hcc_1_6: { - node('docker && rocm && gfx803') + node('docker && rocm') { String hcc_ver = 'hcc-1.6' String from_image = 'compute-artifactory:5001/radeonopencompute/hcc/roc-1.6.x/hcc-lc-ubuntu-16.04:latest' @@ -419,9 +422,9 @@ hcc_1_6: // Build hip inside of the build environment docker_build_inside_image( hip_build_image, inside_args, hcc_ver, '', build_config, source_hip_rel, build_hip_rel ) - // Not pushing hip-hcc-1.6 builds at this time - hip_image_name = docker_upload_artifactory( hcc_ver, job_name, from_image, source_hip_rel, build_hip_rel ) - docker_clean_images( job_name, hip_image_name ) + // Not pushing hip-hcc-1.6 builds at this time; saves a minute and nobody needs? + // String hip_image_name = docker_upload_artifactory( hcc_ver, job_name, from_image, source_hip_rel, build_hip_rel ) + // docker_clean_images( job_name, hip_image_name ) } }, nvcc: @@ -459,7 +462,5 @@ nvcc: // Build hip inside of the build environment docker_build_inside_image( hip_build_image, inside_args, nvcc_ver, "-DHIP_NVCC_FLAGS=--Wno-deprecated-gpu-targets", build_config, source_hip_rel, build_hip_rel ) - - // Not pushing an Nvidia based HiP to artifactory at this time } }