Skip to content

Commit

Permalink
Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
driazati committed Nov 18, 2022
1 parent bd260ee commit e9f70fa
Show file tree
Hide file tree
Showing 10 changed files with 208 additions and 190 deletions.
163 changes: 77 additions & 86 deletions Jenkinsfile

Large diffs are not rendered by default.

40 changes: 6 additions & 34 deletions ci/jenkins/Build.groovy.j2
Original file line number Diff line number Diff line change
Expand Up @@ -56,34 +56,6 @@ def cmake_build(image, path, make_flag) {
)
}

def add_microtvm_permissions() {
{% for folder in microtvm_template_projects %}
sh(
script: 'find {{ folder }} -type f | grep qemu-hack | xargs chmod +x',
label: 'Add execute permissions for microTVM files',
)
{% endfor %}
}

def add_hexagon_permissions() {
{% for folder in hexagon_api %}
sh(
script: 'find {{ folder }} -type f | xargs chmod +x',
label: 'Add execute permissions for hexagon files',
)
{% endfor %}
}

def add_crttest_permissions() {
{% for file in crttest %}
sh(
script: 'chmod +x {{ file }}',
label: 'Add execute permissions for crttest',
)
{% endfor %}
}


def build() {
stage('Build') {
environment {
Expand All @@ -101,7 +73,7 @@ stage('Build') {
sh "${docker_run} --no-gpu ${ci_gpu} ./tests/scripts/task_config_build_gpu.sh build"
cmake_build("${ci_gpu} --no-gpu", 'build', '-j2')
make_standalone_crt("${ci_gpu} --no-gpu", 'build')
{{ m.upload_artifacts(tag='gpu', filenames=tvm_multilib + microtvm_template_projects + crttest + standalone_crt) }}
{{ m.upload_artifacts(tag='gpu', filenames=tvm_multilib + tvm_allvisible + microtvm_template_projects + crttest + standalone_crt) }}

// compiler test
sh "rm -rf build"
Expand All @@ -125,7 +97,7 @@ stage('Build') {
cmake_build(ci_cpu, 'build', '-j2')
make_standalone_crt(ci_cpu, 'build')
make_cpp_tests(ci_cpu, 'build')
{{ m.upload_artifacts(tag='cpu', filenames=tvm_multilib_tsim + crttest + cpptest + standalone_crt) }}
{{ m.upload_artifacts(tag='cpu', filenames=tvm_multilib_tsim + tvm_allvisible + crttest + cpptest + standalone_crt) }}
ci_setup(ci_cpu)
// sh "${docker_run} ${ci_cpu} ./tests/scripts/task_golang.sh"
// TODO(@jroesch): need to resolve CI issue will turn back on in follow up patch
Expand All @@ -145,7 +117,7 @@ stage('Build') {
)
cmake_build(ci_minimal, 'build', '-j2')
make_cpp_tests(ci_minimal, 'build')
{{ m.upload_artifacts(tag='cpu-minimal', filenames=tvm_lib + cpptest) }}
{{ m.upload_artifacts(tag='cpu-minimal', filenames=tvm_lib + tvm_allvisible + cpptest) }}
{% endcall %}

{% call m.build_step(
Expand Down Expand Up @@ -201,7 +173,7 @@ stage('Build') {
cmake_build(ci_arm, 'build', '-j4')
make_standalone_crt(ci_arm, 'build')
make_cpp_tests(ci_arm, 'build')
{{ m.upload_artifacts(tag='arm', filenames=tvm_multilib + cpptest + standalone_crt) }}
{{ m.upload_artifacts(tag='arm', filenames=tvm_multilib + cpptest + crttest + standalone_crt) }}
{% endcall %}

{% call m.build_step(
Expand All @@ -218,7 +190,7 @@ stage('Build') {
cmake_build(ci_cortexm, 'build', '-j2')
make_standalone_crt(ci_cortexm, 'build')
make_cpp_tests(ci_cortexm, 'build')
{{ m.upload_artifacts(tag='cortexm', filenames=tvm_lib + crttest + standalone_crt + cpptest + microtvm_template_projects) }}
{{ m.upload_artifacts(tag='cortexm', filenames=tvm_lib + tvm_allvisible + crttest + standalone_crt + cpptest + microtvm_template_projects) }}
{% endcall %}

{% call m.build_step(
Expand Down Expand Up @@ -255,7 +227,7 @@ stage('Build') {
cmake_build(ci_riscv, 'build', '-j2')
make_standalone_crt(ci_riscv, 'build')
make_cpp_tests(ci_riscv, 'build')
{{ m.upload_artifacts(tag='riscv', filenames=tvm_lib + crttest + cpptest + microtvm_template_projects) }}
{{ m.upload_artifacts(tag='riscv', filenames=tvm_lib + tvm_allvisible + standalone_crt + crttest + cpptest + microtvm_template_projects) }}
{% endcall %}

)
Expand Down
2 changes: 1 addition & 1 deletion ci/jenkins/Deploy.groovy.j2
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def deploy() {
ws="tvm/deploy-docs",
) %}
init_git()
{{ m.download_artifacts(tag='docs', filenames=["docs.tgz"]) }}
{{ m.download_artifacts(tag='docs') }}
deploy_docs()
{% endcall %}
{% call m.deploy_step(
Expand Down
5 changes: 3 additions & 2 deletions ci/jenkins/Jenkinsfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,14 @@ rebuild_docker_images = false
// Filenames for stashing between build and test steps
{% set tvm_runtime = ['build/libtvm_runtime.so', 'build/config.cmake'] %}
{% set crttest = ['build/crttest'] %}
{% set cpptest = ['build/cpptest'] %}
{% set tvm_allvisible = ['build/libtvm_allvisible.so'] %}
{% set cpptest = ['build/cpptest', 'build/build.ninja', 'build/CMakeFiles/rules.ninja'] %}
{% set tvm_lib = ['build/libtvm.so'] + tvm_runtime %}
{% set tvm_multilib = ['build/libtvm.so', 'build/libvta_fsim.so'] + tvm_runtime %}
{% set tvm_multilib_tsim = ['build/libvta_tsim.so'] + tvm_multilib %}
{% set microtvm_template_projects = ['build/microtvm_template_projects',] %}
{% set hexagon_api = ['build/hexagon_api_output',] %}
{% set standalone_crt = ['build/standalone_crt'] %}
{% set standalone_crt = ['build/standalone_crt', 'build/build.ninja'] %}
s3_bucket = 'tvm-jenkins-artifacts-prod'
s3_prefix = "tvm/${env.BRANCH_NAME}/${env.BUILD_NUMBER}"

Expand Down
47 changes: 30 additions & 17 deletions ci/jenkins/Test.groovy.j2
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ def cpp_unittest(image) {
)
}

def micro_cpp_unittest(image) {
sh (
script: "${docker_run} --env CI_NUM_EXECUTORS ${image} ./tests/scripts/task_microtvm_cpp_tests.sh build",
label: 'Run microTVM C++ tests',
)
}

// We have to do this whacky split of the code from where it's used since the
// JVM limits method length to 64k and we easily exceed that with all this
// autogenerated code. This makes it so each test step is in its own method so
Expand All @@ -21,22 +28,23 @@ def cpp_unittest(image) {
test_method_names=test_method_names,
) %}
{% if shard_index == 1 %}
{{ m.download_artifacts(tag='gpu2', filenames=tvm_multilib + crttest + standalone_crt) }}
{{ m.download_artifacts(tag='gpu2') }}
sh "${docker_run} --no-gpu ${ci_gpu} ./tests/scripts/task_config_build_gpu_other.sh build"
// These require a GPU to finish the build (i.e. CUDA needs to be load-able)
make_standalone_crt(ci_gpu, 'build')
// make_cpp_tests(ci_gpu, 'build')
// cpp_unittest(ci_gpu)

sh "rm -rf build"
{{ m.download_artifacts(tag='gpu', filenames=tvm_multilib + microtvm_template_projects + crttest + standalone_crt) }}
{{ m.download_artifacts(tag='gpu') }}
ci_setup(ci_gpu)
sh "${docker_run} --no-gpu ${ci_gpu} ./tests/scripts/task_config_build_gpu.sh build"
make_standalone_crt(ci_gpu, 'build')
make_cpp_tests(ci_gpu, 'build')
cpp_unittest(ci_gpu)
micro_cpp_unittest(ci_gpu)
{% else %}
{{ m.download_artifacts(tag='gpu', filenames=tvm_multilib) }}
{{ m.download_artifacts(tag='gpu') }}
ci_setup(ci_gpu)
{% endif %}
{% if shard_index == 2 or num_shards < 2 %}
Expand All @@ -63,7 +71,7 @@ def cpp_unittest(image) {
docker_image="ci_cpu",
test_method_names=test_method_names,
) %}
{{ m.download_artifacts(tag='cpu', filenames=tvm_multilib_tsim + standalone_crt) }}
{{ m.download_artifacts(tag='cpu') }}
ci_setup(ci_cpu)
sh (
script: "${docker_run} ${ci_cpu} ./tests/scripts/task_python_integration.sh",
Expand All @@ -79,10 +87,11 @@ def cpp_unittest(image) {
docker_image="ci_i386",
test_method_names=test_method_names,
) %}
{{ m.download_artifacts(tag='i386', filenames=tvm_multilib_tsim + standalone_crt + crttest + cpptest) }}
{{ m.download_artifacts(tag='i386') }}
ci_setup(ci_i386)
{% if shard_index == 1 %}
cpp_unittest(ci_i386)
micro_cpp_unittest(ci_i386)
{% endif %}
python_unittest(ci_i386)
sh (
Expand All @@ -102,7 +111,7 @@ def cpp_unittest(image) {
test_method_names=test_method_names,
num_shards=8,
) %}
{{ m.download_artifacts(tag='hexagon', filenames=tvm_lib + hexagon_api + cpptest) }}
{{ m.download_artifacts(tag='hexagon') }}
ci_setup(ci_hexagon)
{% if shard_index == 1 %}
cpp_unittest(ci_hexagon)
Expand All @@ -121,7 +130,7 @@ def cpp_unittest(image) {
docker_image="ci_arm",
test_method_names=test_method_names,
) %}
{{ m.download_artifacts(tag='arm', filenames=tvm_multilib + standalone_crt) }}
{{ m.download_artifacts(tag='arm') }}
ci_setup(ci_arm)
python_unittest(ci_arm)
sh (
Expand All @@ -138,7 +147,7 @@ def cpp_unittest(image) {
docker_image="ci_gpu",
test_method_names=test_method_names,
) %}
{{ m.download_artifacts(tag='gpu', filenames=tvm_multilib) }}
{{ m.download_artifacts(tag='gpu') }}
ci_setup(ci_gpu)
sh (
script: "${docker_run} ${ci_gpu} ./tests/scripts/task_python_topi.sh",
Expand All @@ -154,7 +163,7 @@ def cpp_unittest(image) {
docker_image="ci_gpu",
test_method_names=test_method_names,
) %}
{{ m.download_artifacts(tag='gpu', filenames=tvm_multilib) }}
{{ m.download_artifacts(tag='gpu') }}
ci_setup(ci_gpu)
sh (
script: "${docker_run} ${ci_gpu} ./tests/scripts/task_python_frontend.sh",
Expand All @@ -170,10 +179,11 @@ def cpp_unittest(image) {
num_shards=2,
test_method_names=test_method_names,
) %}
{{ m.download_artifacts(tag='arm', filenames=tvm_multilib + cpptest) }}
{{ m.download_artifacts(tag='arm') }}
ci_setup(ci_arm)
{% if shard_index == 1 %}
cpp_unittest(ci_arm)
micro_cpp_unittest(ci_arm)
{% endif %}
sh (
script: "${docker_run} ${ci_arm} ./tests/scripts/task_python_arm_compute_library.sh",
Expand All @@ -193,7 +203,7 @@ def cpp_unittest(image) {
num_shards=2,
test_method_names=test_method_names,
) %}
{{ m.download_artifacts(tag='arm', filenames=tvm_multilib) }}
{{ m.download_artifacts(tag='arm') }}
ci_setup(ci_arm)
sh (
script: "${docker_run} ${ci_arm} ./tests/scripts/task_python_frontend_cpu.sh",
Expand All @@ -209,10 +219,11 @@ def cpp_unittest(image) {
num_shards=12,
test_method_names=test_method_names,
) %}
{{ m.download_artifacts(tag='cortexm', filenames=tvm_lib + microtvm_template_projects + cpptest + standalone_crt) }}
{{ m.download_artifacts(tag='cortexm') }}
ci_setup(ci_cortexm)
{% if shard_index == 1%}
cpp_unittest(ci_cortexm)
micro_cpp_unittest(ci_cortexm)
sh (
script: "${docker_run} ${ci_cortexm} ./tests/scripts/task_demo_microtvm.sh",
label: 'Run microTVM demos',
Expand All @@ -232,10 +243,11 @@ def cpp_unittest(image) {
num_shards=1,
test_method_names=test_method_names,
) %}
{{ m.download_artifacts(tag='riscv', filenames=tvm_lib + microtvm_template_projects + cpptest) }}
{{ m.download_artifacts(tag='riscv') }}
ci_setup(ci_riscv)
{% if shard_index == 1%}
cpp_unittest(ci_cortexm)
micro_cpp_unittest(ci_cortexm)
{% endif %}
sh (
script: "${docker_run} ${ci_riscv} ./tests/scripts/task_riscv_microtvm.sh",
Expand All @@ -251,7 +263,7 @@ def run_unittest_minimal() {
platform="minimal",
docker_image="ci_minimal",
) %}
{{ m.download_artifacts(tag='cpu-minimal', filenames=tvm_lib + cpptest) }}
{{ m.download_artifacts(tag='cpu-minimal') }}
cpp_unittest(ci_minimal)
python_unittest(ci_minimal)
{% endcall %}
Expand All @@ -278,9 +290,10 @@ stage('Test') {
platform="cpu",
docker_image="ci_cpu",
) %}
{{ m.download_artifacts(tag='cpu', filenames=tvm_multilib_tsim + cpptest + standalone_crt) }}
{{ m.download_artifacts(tag='cpu') }}
ci_setup(ci_cpu)
cpp_unittest(ci_cpu)
micro_cpp_unittest(ci_cpu)
python_unittest(ci_cpu)
fsim_test(ci_cpu)
sh (
Expand All @@ -295,7 +308,7 @@ stage('Test') {
platform="cpu",
docker_image="ci_cpu",
) %}
{{ m.download_artifacts(tag='cpu', filenames=tvm_multilib) }}
{{ m.download_artifacts(tag='cpu') }}
ci_setup(ci_cpu)
sh (
script: "${docker_run} ${ci_cpu} ./tests/scripts/task_python_frontend_cpu.sh",
Expand All @@ -308,7 +321,7 @@ stage('Test') {
ws({{ m.per_exec_ws('tvm/docs-python-gpu') }}) {
init_git()
docker_init(ci_gpu)
{{ m.download_artifacts(tag='gpu', filenames=tvm_multilib + microtvm_template_projects + standalone_crt) }}
{{ m.download_artifacts(tag='gpu') }}
timeout(time: 180, unit: 'MINUTES') {
ci_setup(ci_gpu)
sh (
Expand Down
5 changes: 2 additions & 3 deletions ci/jenkins/macros.j2
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,9 @@ sh(
)
{% endmacro %}

{% macro download_artifacts(tag, filenames) %}
{% set items = ' '.join(filenames) %}
{% macro download_artifacts(tag) %}
sh(
script: "./${jenkins_scripts_root}/s3.py --action download --bucket ${s3_bucket} --prefix ${s3_prefix}/{{ tag }} --items {{ items }}",
script: "./${jenkins_scripts_root}/s3.py --action download --bucket ${s3_bucket} --prefix ${s3_prefix}/{{ tag }}",
label: 'Download artifacts from S3',
)
{% endmacro %}
11 changes: 11 additions & 0 deletions ci/scripts/jenkins/cmd_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import logging
import sys
import re
import tempfile
from pathlib import Path
from typing import List

Expand Down Expand Up @@ -53,6 +54,16 @@ def __init__(self, env=None, cwd=None):
self.env.update(env)
self.cwd = cwd

def tee(self, cmd: str, **kwargs):
"""
Run 'cmd' in a shell then return the (process, stdout) as a tuple
"""
with tempfile.NamedTemporaryFile(delete=False) as f:
proc = self.run(f"{cmd} | tee {f.name}", **kwargs)
with open(f.name, "r") as f:
output = f.read()
return proc, output

def run(self, cmd: str, **kwargs):
logging.info(f"+ {cmd}")
defaults = {
Expand Down
Loading

0 comments on commit e9f70fa

Please sign in to comment.