forked from apache/tvm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
executable file
·3475 lines (3267 loc) · 122 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!groovy
// -*- mode: groovy -*-
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
// Jenkins pipeline
// See documents at https://jenkins.io/doc/book/pipeline/jenkinsfile/
// Docker env used for testing
// Different image may have different version tag
// because some of them are more stable than anoter.
//
// Docker images are maintained by PMC, cached in dockerhub
// and remains relatively stable over the time.
// Flow for upgrading docker env(need commiter)
//
// - Send PR to upgrade build script in the repo
// - Build the new docker image
// - Tag the docker image with a new version and push to a binary cache.
// - Update the version in the Jenkinsfile, send a PR
// - Fix any issues wrt to the new image version in the PR
// - Merge the PR and now we are in new version
// - Tag the new version as the lates
// - Periodically cleanup the old versions on local workers
//
// ============================= IMPORTANT NOTE =============================
// This file is generated by 'jenkins/generate.py'. Do not edit this file directly!
// Make edits to 'jenkins/Jenkinsfile.j2' and regenerate this with
// 'python3 jenkins/generate.py'
// Note: This timestamp is here to ensure that updates to the Jenkinsfile are
// always rebased on main before merging:
// Generated at 2022-07-01T12:43:52.727636
import org.jenkinsci.plugins.pipeline.modeldefinition.Utils
// NOTE: these lines are scanned by docker/dev_common.sh. Please update the regex as needed. -->
ci_lint = 'tlcpack/ci-lint:20220630-060117-558ba99c7'
ci_gpu = 'tlcpack/ci-gpu:20220630-060117-558ba99c7'
ci_cpu = 'tlcpack/ci-cpu:20220630-060117-558ba99c7'
ci_wasm = 'tlcpack/ci-wasm:20220630-060117-558ba99c7'
ci_i386 = 'tlcpack/ci-i386:20220630-060117-558ba99c7'
ci_qemu = 'tlcpack/ci-qemu:20220630-060117-558ba99c7'
ci_arm = 'tlcpack/ci-arm:20220630-060117-558ba99c7'
ci_hexagon = 'tlcpack/ci-hexagon:20220630-060117-558ba99c7'
// <--- End of regex-scanned config.
// Parameters to allow overriding (in Jenkins UI), the images
// to be used by a given build. When provided, they take precedence
// over default values above.
properties([
parameters([
string(name: 'ci_arm_param', defaultValue: ''),
string(name: 'ci_cpu_param', defaultValue: ''),
string(name: 'ci_gpu_param', defaultValue: ''),
string(name: 'ci_hexagon_param', defaultValue: ''),
string(name: 'ci_i386_param', defaultValue: ''),
string(name: 'ci_lint_param', defaultValue: ''),
string(name: 'ci_qemu_param', defaultValue: ''),
string(name: 'ci_wasm_param', defaultValue: ''),
])
])
// Global variable assigned during Sanity Check that holds the sha1 which should be
// merged into the PR in all branches.
upstream_revision = null
// command to start a docker container
docker_run = 'docker/bash.sh --env CI --env TVM_SHARD_INDEX --env TVM_NUM_SHARDS --env RUN_DISPLAY_URL --env PLATFORM'
docker_build = 'docker/build.sh'
// timeout in minutes
max_time = 180
rebuild_docker_images = false
// Filenames for stashing between build and test steps
s3_prefix = "tvm-jenkins-artifacts-prod/tvm/${env.BRANCH_NAME}/${env.BUILD_NUMBER}"
// General note: Jenkins has limits on the size of a method (or top level code)
// that are pretty strict, so most usage of groovy methods in these templates
// are purely to satisfy the JVM
def per_exec_ws(folder) {
return "workspace/exec_${env.EXECUTOR_NUMBER}/" + folder
}
// initialize source codes
def init_git() {
checkout scm
// Add more info about job node
sh (
script: './tests/scripts/task_show_node_info.sh',
label: 'Show executor node info',
)
// Determine merge commit to use for all stages
sh (
script: 'git fetch origin main',
label: 'Fetch upstream',
)
if (upstream_revision == null) {
upstream_revision = sh(
script: 'git log -1 FETCH_HEAD --format=\'%H\'',
label: 'Determine upstream revision',
returnStdout: true,
).trim()
}
sh (
script: "git -c user.name=TVM-Jenkins -c [email protected] merge ${upstream_revision}",
label: 'Merge to origin/main'
)
sh(
script: '''
set -eux
n=0
max_retries=3
backoff_max=30
until [ "$n" -ge $max_retries ]
do
timeout 5m git submodule update --init -f --jobs 0 && break
n=$((n+1))
if [ "$n" -eq $max_retries ]; then
echo "failed to update $n / $max_retries, giving up"
exit 1
fi
WAIT=$((RANDOM % "$backoff_max"))
echo "failed to update $n / $max_retries, waiting $WAIT to try again"
sleep $WAIT
done
''',
label: 'Update git submodules',
)
}
def docker_init(image) {
// Clear out all Docker images that aren't going to be used
sh(
script: """
set -eux
docker image ls --all
IMAGES=\$(docker image ls --all --format '{{.Repository}}:{{.Tag}} {{.ID}}')
echo -e "Found images:\\n\$IMAGES"
echo "\$IMAGES" | { grep -vE '${image}' || test \$? = 1; } | { xargs docker rmi || test \$? = 123; }
docker image ls --all
""",
label: 'Clean old Docker images',
)
if (image.contains("amazonaws.com")) {
// If this string is in the image name it's from ECR and needs to be pulled
// with the right credentials
ecr_pull(image)
} else {
sh(
script: "docker pull ${image}",
label: 'Pull docker image',
)
}
}
def should_skip_slow_tests(pr_number) {
withCredentials([string(
credentialsId: 'tvm-bot-jenkins-reader',
variable: 'GITHUB_TOKEN',
)]) {
// Exit code of 1 means run slow tests, exit code of 0 means skip slow tests
result = sh (
returnStatus: true,
script: "./tests/scripts/should_run_slow_tests.py --pr '${pr_number}'",
label: 'Check if CI should run slow tests',
)
}
return result == 0
}
def cancel_previous_build() {
// cancel previous build if it is not on main.
if (env.BRANCH_NAME != 'main') {
def buildNumber = env.BUILD_NUMBER as int
// Milestone API allows us to cancel previous build
// with the same milestone number
if (buildNumber > 1) milestone(buildNumber - 1)
milestone(buildNumber)
}
}
def should_skip_ci(pr_number) {
if (env.BRANCH_NAME == null || !env.BRANCH_NAME.startsWith('PR-')) {
// never skip CI on build sourced from a branch
return false
}
glob_skip_ci_code = sh (
returnStatus: true,
script: "./tests/scripts/git_skip_ci_globs.py",
label: 'Check if CI should be skipped due to changed files',
)
if (glob_skip_ci_code == 0) {
return true
}
withCredentials([string(
credentialsId: 'tvm-bot-jenkins-reader',
variable: 'TOKEN',
)]) {
// Exit code of 1 means run full CI (or the script had an error, so run
// full CI just in case). Exit code of 0 means skip CI.
git_skip_ci_code = sh (
returnStatus: true,
script: "./tests/scripts/git_skip_ci.py --pr '${pr_number}'",
label: 'Check if CI should be skipped',
)
}
return git_skip_ci_code == 0
}
def prepare() {
stage('Prepare') {
node('CPU-SMALL') {
ws("workspace/exec_${env.EXECUTOR_NUMBER}/tvm/prepare") {
init_git()
if (env.DETERMINE_DOCKER_IMAGES == 'yes') {
sh(
script: "./tests/scripts/determine_docker_images.py ci_arm=${ci_arm} ci_cpu=${ci_cpu} ci_gpu=${ci_gpu} ci_hexagon=${ci_hexagon} ci_i386=${ci_i386} ci_lint=${ci_lint} ci_qemu=${ci_qemu} ci_wasm=${ci_wasm} ",
label: 'Decide whether to use tlcpack or tlcpackstaging for Docker images',
)
// Pull image names from the results of should_rebuild_docker.py
ci_arm = sh(
script: "cat .docker-image-names/ci_arm",
label: "Find docker image name for ci_arm",
returnStdout: true,
).trim()
ci_cpu = sh(
script: "cat .docker-image-names/ci_cpu",
label: "Find docker image name for ci_cpu",
returnStdout: true,
).trim()
ci_gpu = sh(
script: "cat .docker-image-names/ci_gpu",
label: "Find docker image name for ci_gpu",
returnStdout: true,
).trim()
ci_hexagon = sh(
script: "cat .docker-image-names/ci_hexagon",
label: "Find docker image name for ci_hexagon",
returnStdout: true,
).trim()
ci_i386 = sh(
script: "cat .docker-image-names/ci_i386",
label: "Find docker image name for ci_i386",
returnStdout: true,
).trim()
ci_lint = sh(
script: "cat .docker-image-names/ci_lint",
label: "Find docker image name for ci_lint",
returnStdout: true,
).trim()
ci_qemu = sh(
script: "cat .docker-image-names/ci_qemu",
label: "Find docker image name for ci_qemu",
returnStdout: true,
).trim()
ci_wasm = sh(
script: "cat .docker-image-names/ci_wasm",
label: "Find docker image name for ci_wasm",
returnStdout: true,
).trim()
}
ci_arm = params.ci_arm_param ?: ci_arm
ci_cpu = params.ci_cpu_param ?: ci_cpu
ci_gpu = params.ci_gpu_param ?: ci_gpu
ci_hexagon = params.ci_hexagon_param ?: ci_hexagon
ci_i386 = params.ci_i386_param ?: ci_i386
ci_lint = params.ci_lint_param ?: ci_lint
ci_qemu = params.ci_qemu_param ?: ci_qemu
ci_wasm = params.ci_wasm_param ?: ci_wasm
sh (script: """
echo "Docker images being used in this build:"
echo " ci_arm = ${ci_arm}"
echo " ci_cpu = ${ci_cpu}"
echo " ci_gpu = ${ci_gpu}"
echo " ci_hexagon = ${ci_hexagon}"
echo " ci_i386 = ${ci_i386}"
echo " ci_lint = ${ci_lint}"
echo " ci_qemu = ${ci_qemu}"
echo " ci_wasm = ${ci_wasm}"
""", label: 'Docker image names')
is_docs_only_build = sh (
returnStatus: true,
script: './tests/scripts/git_change_docs.sh',
label: 'Check for docs only changes',
)
skip_ci = should_skip_ci(env.CHANGE_ID)
skip_slow_tests = should_skip_slow_tests(env.CHANGE_ID)
rebuild_docker_images = sh (
returnStatus: true,
script: './tests/scripts/git_change_docker.sh',
label: 'Check for any docker changes',
)
if (skip_ci) {
// Don't rebuild when skipping CI
rebuild_docker_images = false
}
}
}
}
}
def ecr_push(full_name) {
aws_account_id = sh(
returnStdout: true,
script: 'aws sts get-caller-identity | grep Account | cut -f4 -d\\"',
label: 'Get AWS ID'
).trim()
def ecr_name = "${aws_account_id}.dkr.ecr.us-west-2.amazonaws.com/${full_name}"
try {
withEnv([
"AWS_ACCOUNT_ID=${aws_account_id}",
'AWS_DEFAULT_REGION=us-west-2',
"AWS_ECR_REPO=${aws_account_id}.dkr.ecr.us-west-2.amazonaws.com"]) {
sh(
script: '''
set -eux
aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ECR_REPO
''',
label: 'Log in to ECR'
)
sh(
script: """
set -x
docker tag ${full_name} \$AWS_ECR_REPO/${full_name}
docker push \$AWS_ECR_REPO/${full_name}
""",
label: 'Upload image to ECR'
)
}
} finally {
withEnv([
"AWS_ACCOUNT_ID=${aws_account_id}",
'AWS_DEFAULT_REGION=us-west-2',
"AWS_ECR_REPO=${aws_account_id}.dkr.ecr.us-west-2.amazonaws.com"]) {
sh(
script: 'docker logout $AWS_ECR_REPO',
label: 'Clean up login credentials'
)
}
}
return ecr_name
}
def ecr_pull(full_name) {
aws_account_id = sh(
returnStdout: true,
script: 'aws sts get-caller-identity | grep Account | cut -f4 -d\\"',
label: 'Get AWS ID'
).trim()
try {
withEnv([
"AWS_ACCOUNT_ID=${aws_account_id}",
'AWS_DEFAULT_REGION=us-west-2',
"AWS_ECR_REPO=${aws_account_id}.dkr.ecr.us-west-2.amazonaws.com"]) {
sh(
script: '''
set -eux
aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ECR_REPO
''',
label: 'Log in to ECR'
)
sh(
script: """
set -eux
docker pull ${full_name}
""",
label: 'Pull image from ECR'
)
}
} finally {
withEnv([
"AWS_ACCOUNT_ID=${aws_account_id}",
'AWS_DEFAULT_REGION=us-west-2',
"AWS_ECR_REPO=${aws_account_id}.dkr.ecr.us-west-2.amazonaws.com"]) {
sh(
script: 'docker logout $AWS_ECR_REPO',
label: 'Clean up login credentials'
)
}
}
}
def build_image(image_name) {
hash = sh(
returnStdout: true,
script: 'git log -1 --format=\'%h\''
).trim()
def full_name = "${image_name}:${env.BRANCH_NAME}-${hash}-${env.BUILD_NUMBER}"
sh(
script: "${docker_build} ${image_name} --spec ${full_name}",
label: 'Build docker image'
)
return ecr_push(full_name)
}
def build_docker_images() {
stage('Docker Image Build') {
parallel(
'ci_arm': {
node('ARM') {
timeout(time: max_time, unit: 'MINUTES') {
init_git()
// We're purposefully not setting the built image here since they
// are not yet being uploaded to tlcpack
// ci_arm = build_image('ci_arm')
build_image('ci_arm')
}
}
},
'ci_cpu': {
node('CPU') {
timeout(time: max_time, unit: 'MINUTES') {
init_git()
// We're purposefully not setting the built image here since they
// are not yet being uploaded to tlcpack
// ci_cpu = build_image('ci_cpu')
build_image('ci_cpu')
}
}
},
'ci_gpu': {
node('CPU') {
timeout(time: max_time, unit: 'MINUTES') {
init_git()
// We're purposefully not setting the built image here since they
// are not yet being uploaded to tlcpack
// ci_gpu = build_image('ci_gpu')
build_image('ci_gpu')
}
}
},
'ci_hexagon': {
node('CPU') {
timeout(time: max_time, unit: 'MINUTES') {
init_git()
// We're purposefully not setting the built image here since they
// are not yet being uploaded to tlcpack
// ci_hexagon = build_image('ci_hexagon')
build_image('ci_hexagon')
}
}
},
'ci_i386': {
node('CPU') {
timeout(time: max_time, unit: 'MINUTES') {
init_git()
// We're purposefully not setting the built image here since they
// are not yet being uploaded to tlcpack
// ci_i386 = build_image('ci_i386')
build_image('ci_i386')
}
}
},
'ci_lint': {
node('CPU') {
timeout(time: max_time, unit: 'MINUTES') {
init_git()
// We're purposefully not setting the built image here since they
// are not yet being uploaded to tlcpack
// ci_lint = build_image('ci_lint')
build_image('ci_lint')
}
}
},
'ci_qemu': {
node('CPU') {
timeout(time: max_time, unit: 'MINUTES') {
init_git()
// We're purposefully not setting the built image here since they
// are not yet being uploaded to tlcpack
// ci_qemu = build_image('ci_qemu')
build_image('ci_qemu')
}
}
},
'ci_wasm': {
node('CPU') {
timeout(time: max_time, unit: 'MINUTES') {
init_git()
// We're purposefully not setting the built image here since they
// are not yet being uploaded to tlcpack
// ci_wasm = build_image('ci_wasm')
build_image('ci_wasm')
}
}
},
)
}
}
def lint() {
stage('Lint') {
parallel(
'Lint 1 of 2': {
node('CPU-SMALL') {
ws("workspace/exec_${env.EXECUTOR_NUMBER}/tvm/lint") {
docker_init(ci_lint)
init_git()
timeout(time: max_time, unit: 'MINUTES') {
withEnv([
'TVM_NUM_SHARDS=2',
'TVM_SHARD_INDEX=0'], {
sh (
script: "${docker_run} ${ci_lint} ./tests/scripts/task_lint.sh",
label: 'Run lint',
)
})
}
}
}
},
'Lint 2 of 2': {
node('CPU-SMALL') {
ws("workspace/exec_${env.EXECUTOR_NUMBER}/tvm/lint") {
docker_init(ci_lint)
init_git()
timeout(time: max_time, unit: 'MINUTES') {
withEnv([
'TVM_NUM_SHARDS=2',
'TVM_SHARD_INDEX=1'], {
sh (
script: "${docker_run} ${ci_lint} ./tests/scripts/task_lint.sh",
label: 'Run lint',
)
})
}
}
}
},
)
}
}
def ci_setup(image) {
sh (
script: "${docker_run} ${image} ./tests/scripts/task_ci_setup.sh",
label: 'Set up CI environment',
)
}
def python_unittest(image) {
sh (
script: "${docker_run} ${image} ./tests/scripts/task_python_unittest.sh",
label: 'Run Python unit tests',
)
}
def fsim_test(image) {
sh (
script: "${docker_run} ${image} ./tests/scripts/task_python_vta_fsim.sh",
label: 'Run VTA tests in FSIM',
)
}
def cmake_build(image, path, make_flag) {
sh (
script: "${docker_run} --env CI_NUM_EXECUTORS ${image} ./tests/scripts/task_build.py --sccache-bucket tvm-sccache-prod",
label: 'Run cmake build',
)
}
def cpp_unittest(image) {
sh (
script: "${docker_run} --env CI_NUM_EXECUTORS ${image} ./tests/scripts/task_cpp_unittest.sh",
label: 'Build and run C++ tests',
)
}
def add_microtvm_permissions() {
sh(
script: 'find build/microtvm_template_projects -type f | grep qemu-hack | xargs chmod +x',
label: 'Add execute permissions for microTVM files',
)
}
def add_hexagon_permissions() {
sh(
script: 'find build/hexagon_api_output -type f | xargs chmod +x',
label: 'Add execute permissions for hexagon files',
)
}
// Run make. First try to do an incremental make from a previous workspace in hope to
// accelerate the compilation. If something is wrong, clean the workspace and then
// build from scratch.
def make(docker_type, path, make_flag) {
timeout(time: max_time, unit: 'MINUTES') {
try {
cmake_build(docker_type, path, make_flag)
} catch (hudson.AbortException ae) {
// script exited due to user abort, directly throw instead of retry
if (ae.getMessage().contains('script returned exit code 143')) {
throw ae
}
echo 'Incremental compilation failed. Fall back to build from scratch'
sh (
script: "${docker_run} ${docker_type} ./tests/scripts/task_clean.sh ${path}",
label: 'Clear old cmake workspace',
)
cmake_build(docker_type, path, make_flag)
}
}
}
def build() {
stage('Build') {
environment {
SKIP_SLOW_TESTS = "${skip_slow_tests}"
}
parallel(
'BUILD: GPU': {
if (!skip_ci) {
node('CPU-SMALL') {
ws("workspace/exec_${env.EXECUTOR_NUMBER}/tvm/build-gpu") {
docker_init(ci_gpu)
init_git()
sh "${docker_run} --no-gpu ${ci_gpu} ./tests/scripts/task_config_build_gpu.sh build"
make("${ci_gpu} --no-gpu", 'build', '-j2')
sh(
script: """
set -eux
md5sum build/libtvm.so
aws s3 cp --no-progress build/libtvm.so s3://${s3_prefix}/gpu/build/libtvm.so
md5sum build/libvta_fsim.so
aws s3 cp --no-progress build/libvta_fsim.so s3://${s3_prefix}/gpu/build/libvta_fsim.so
md5sum build/libtvm_runtime.so
aws s3 cp --no-progress build/libtvm_runtime.so s3://${s3_prefix}/gpu/build/libtvm_runtime.so
md5sum build/config.cmake
aws s3 cp --no-progress build/config.cmake s3://${s3_prefix}/gpu/build/config.cmake
aws s3 cp --no-progress build/microtvm_template_projects s3://${s3_prefix}/gpu/build/microtvm_template_projects --recursive
""",
label: 'Upload artifacts to S3',
)
// compiler test
sh "${docker_run} --no-gpu ${ci_gpu} ./tests/scripts/task_config_build_gpu_other.sh build2"
make("${ci_gpu} --no-gpu", 'build2', '-j2')
sh(
script: """
set -eux
md5sum build/libtvm.so
aws s3 cp --no-progress build/libtvm.so s3://${s3_prefix}/gpu2/build/libtvm.so
md5sum build/libvta_fsim.so
aws s3 cp --no-progress build/libvta_fsim.so s3://${s3_prefix}/gpu2/build/libvta_fsim.so
md5sum build/libtvm_runtime.so
aws s3 cp --no-progress build/libtvm_runtime.so s3://${s3_prefix}/gpu2/build/libtvm_runtime.so
md5sum build/config.cmake
aws s3 cp --no-progress build/config.cmake s3://${s3_prefix}/gpu2/build/config.cmake
""",
label: 'Upload artifacts to S3',
)
}
}
}
},
'BUILD: CPU': {
if (!skip_ci && is_docs_only_build != 1) {
node('CPU-SMALL') {
ws("workspace/exec_${env.EXECUTOR_NUMBER}/tvm/build-cpu") {
docker_init(ci_cpu)
init_git()
sh (
script: "${docker_run} ${ci_cpu} ./tests/scripts/task_config_build_cpu.sh build",
label: 'Create CPU cmake config',
)
make(ci_cpu, 'build', '-j2')
sh(
script: """
set -eux
md5sum build/libvta_tsim.so
aws s3 cp --no-progress build/libvta_tsim.so s3://${s3_prefix}/cpu/build/libvta_tsim.so
md5sum build/libtvm.so
aws s3 cp --no-progress build/libtvm.so s3://${s3_prefix}/cpu/build/libtvm.so
md5sum build/libvta_fsim.so
aws s3 cp --no-progress build/libvta_fsim.so s3://${s3_prefix}/cpu/build/libvta_fsim.so
md5sum build/libtvm_runtime.so
aws s3 cp --no-progress build/libtvm_runtime.so s3://${s3_prefix}/cpu/build/libtvm_runtime.so
md5sum build/config.cmake
aws s3 cp --no-progress build/config.cmake s3://${s3_prefix}/cpu/build/config.cmake
""",
label: 'Upload artifacts to S3',
)
timeout(time: max_time, unit: 'MINUTES') {
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
sh (script: "${docker_run} ${ci_cpu} ./tests/scripts/task_rust.sh", label: 'Rust build and test')
}
}
}
} else {
Utils.markStageSkippedForConditional('BUILD: CPU')
}
},
'BUILD: WASM': {
if (!skip_ci && is_docs_only_build != 1) {
node('CPU-SMALL') {
ws("workspace/exec_${env.EXECUTOR_NUMBER}/tvm/build-wasm") {
docker_init(ci_wasm)
init_git()
sh (
script: "${docker_run} ${ci_wasm} ./tests/scripts/task_config_build_wasm.sh build",
label: 'Create WASM cmake config',
)
make(ci_wasm, 'build', '-j2')
cpp_unittest(ci_wasm)
timeout(time: max_time, unit: 'MINUTES') {
ci_setup(ci_wasm)
sh (
script: "${docker_run} ${ci_wasm} ./tests/scripts/task_web_wasm.sh",
label: 'Run WASM lint and tests',
)
}
}
}
} else {
Utils.markStageSkippedForConditional('BUILD: WASM')
}
},
'BUILD: i386': {
if (!skip_ci && is_docs_only_build != 1) {
node('CPU-SMALL') {
ws("workspace/exec_${env.EXECUTOR_NUMBER}/tvm/build-i386") {
docker_init(ci_i386)
init_git()
sh (
script: "${docker_run} ${ci_i386} ./tests/scripts/task_config_build_i386.sh build",
label: 'Create i386 cmake config',
)
make(ci_i386, 'build', '-j2')
sh(
script: """
set -eux
md5sum build/libvta_tsim.so
aws s3 cp --no-progress build/libvta_tsim.so s3://${s3_prefix}/i386/build/libvta_tsim.so
md5sum build/libtvm.so
aws s3 cp --no-progress build/libtvm.so s3://${s3_prefix}/i386/build/libtvm.so
md5sum build/libvta_fsim.so
aws s3 cp --no-progress build/libvta_fsim.so s3://${s3_prefix}/i386/build/libvta_fsim.so
md5sum build/libtvm_runtime.so
aws s3 cp --no-progress build/libtvm_runtime.so s3://${s3_prefix}/i386/build/libtvm_runtime.so
md5sum build/config.cmake
aws s3 cp --no-progress build/config.cmake s3://${s3_prefix}/i386/build/config.cmake
""",
label: 'Upload artifacts to S3',
)
}
}
} else {
Utils.markStageSkippedForConditional('BUILD: i386')
}
},
'BUILD: arm': {
if (!skip_ci && is_docs_only_build != 1) {
node('ARM-SMALL') {
ws("workspace/exec_${env.EXECUTOR_NUMBER}/tvm/build-arm") {
docker_init(ci_arm)
init_git()
sh (
script: "${docker_run} ${ci_arm} ./tests/scripts/task_config_build_arm.sh build",
label: 'Create ARM cmake config',
)
make(ci_arm, 'build', '-j4')
sh(
script: """
set -eux
md5sum build/libtvm.so
aws s3 cp --no-progress build/libtvm.so s3://${s3_prefix}/arm/build/libtvm.so
md5sum build/libvta_fsim.so
aws s3 cp --no-progress build/libvta_fsim.so s3://${s3_prefix}/arm/build/libvta_fsim.so
md5sum build/libtvm_runtime.so
aws s3 cp --no-progress build/libtvm_runtime.so s3://${s3_prefix}/arm/build/libtvm_runtime.so
md5sum build/config.cmake
aws s3 cp --no-progress build/config.cmake s3://${s3_prefix}/arm/build/config.cmake
""",
label: 'Upload artifacts to S3',
)
}
}
} else {
Utils.markStageSkippedForConditional('BUILD: arm')
}
},
'BUILD: QEMU': {
if (!skip_ci && is_docs_only_build != 1) {
node('CPU-SMALL') {
ws("workspace/exec_${env.EXECUTOR_NUMBER}/tvm/build-qemu") {
docker_init(ci_qemu)
init_git()
sh (
script: "${docker_run} ${ci_qemu} ./tests/scripts/task_config_build_qemu.sh build",
label: 'Create QEMU cmake config',
)
make(ci_qemu, 'build', '-j2')
sh(
script: """
set -eux
md5sum build/libtvm.so
aws s3 cp --no-progress build/libtvm.so s3://${s3_prefix}/qemu/build/libtvm.so
md5sum build/libtvm_runtime.so
aws s3 cp --no-progress build/libtvm_runtime.so s3://${s3_prefix}/qemu/build/libtvm_runtime.so
md5sum build/config.cmake
aws s3 cp --no-progress build/config.cmake s3://${s3_prefix}/qemu/build/config.cmake
aws s3 cp --no-progress build/microtvm_template_projects s3://${s3_prefix}/qemu/build/microtvm_template_projects --recursive
""",
label: 'Upload artifacts to S3',
)
}
}
} else {
Utils.markStageSkippedForConditional('BUILD: QEMU')
}
},
'BUILD: Hexagon': {
if (!skip_ci && is_docs_only_build != 1) {
node('CPU-SMALL') {
ws("workspace/exec_${env.EXECUTOR_NUMBER}/tvm/build-hexagon") {
docker_init(ci_hexagon)
init_git()
sh (
script: "${docker_run} ${ci_hexagon} ./tests/scripts/task_config_build_hexagon.sh build",
label: 'Create Hexagon cmake config',
)
make(ci_hexagon, 'build', '-j2')
sh (
script: "${docker_run} ${ci_hexagon} ./tests/scripts/task_build_hexagon_api.sh",
label: 'Build Hexagon API',
)
sh(
script: """
set -eux
md5sum build/libtvm.so
aws s3 cp --no-progress build/libtvm.so s3://${s3_prefix}/hexagon/build/libtvm.so
md5sum build/libtvm_runtime.so
aws s3 cp --no-progress build/libtvm_runtime.so s3://${s3_prefix}/hexagon/build/libtvm_runtime.so
md5sum build/config.cmake
aws s3 cp --no-progress build/config.cmake s3://${s3_prefix}/hexagon/build/config.cmake
aws s3 cp --no-progress build/hexagon_api_output s3://${s3_prefix}/hexagon/build/hexagon_api_output --recursive
""",
label: 'Upload artifacts to S3',
)
}
}
} else {
Utils.markStageSkippedForConditional('BUILD: Hexagon')
}
},
)
}
}
// 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
// that each individual method isn't too big.
def shard_run_unittest_GPU_1_of_3() {
if (!skip_ci && is_docs_only_build != 1) {
node('GPU') {
ws("workspace/exec_${env.EXECUTOR_NUMBER}/tvm/ut-python-gpu") {
try {
docker_init(ci_gpu)
init_git()
timeout(time: max_time, unit: 'MINUTES') {
withEnv([
'PLATFORM=gpu',
'TVM_NUM_SHARDS=3',
'TVM_SHARD_INDEX=0'], {
sh(
script: """
set -eux
aws s3 cp --no-progress s3://${s3_prefix}/gpu2/build/libtvm.so build/libtvm.so
md5sum build/libtvm.so
aws s3 cp --no-progress s3://${s3_prefix}/gpu2/build/libvta_fsim.so build/libvta_fsim.so
md5sum build/libvta_fsim.so
aws s3 cp --no-progress s3://${s3_prefix}/gpu2/build/libtvm_runtime.so build/libtvm_runtime.so
md5sum build/libtvm_runtime.so
aws s3 cp --no-progress s3://${s3_prefix}/gpu2/build/config.cmake build/config.cmake
md5sum build/config.cmake
""",
label: 'Download artifacts from S3',
)
cpp_unittest(ci_gpu)
sh(
script: """
set -eux
aws s3 cp --no-progress s3://${s3_prefix}/gpu/build/libtvm.so build/libtvm.so
md5sum build/libtvm.so
aws s3 cp --no-progress s3://${s3_prefix}/gpu/build/libvta_fsim.so build/libvta_fsim.so
md5sum build/libvta_fsim.so
aws s3 cp --no-progress s3://${s3_prefix}/gpu/build/libtvm_runtime.so build/libtvm_runtime.so
md5sum build/libtvm_runtime.so
aws s3 cp --no-progress s3://${s3_prefix}/gpu/build/config.cmake build/config.cmake
md5sum build/config.cmake
""",
label: 'Download artifacts from S3',
)
ci_setup(ci_gpu)
cpp_unittest(ci_gpu)
sh (
script: "${docker_run} ${ci_gpu} ./tests/scripts/task_python_unittest_gpuonly.sh",
label: 'Run Python GPU unit tests',
)
sh (
script: "${docker_run} ${ci_gpu} ./tests/scripts/task_python_integration_gpuonly.sh",
label: 'Run Python GPU integration tests',
)
})
}
} finally {
sh(
script: """
set -eux
aws s3 cp --no-progress build/pytest-results s3://${s3_prefix}/pytest-results --recursive
""",
label: 'Upload JUnits to S3',
)
junit 'build/pytest-results/*.xml'
}
}
}
} else {
Utils.markStageSkippedForConditional('unittest: GPU 1 of 3')
}
}
def shard_run_unittest_GPU_2_of_3() {
if (!skip_ci && is_docs_only_build != 1) {
node('GPU') {
ws("workspace/exec_${env.EXECUTOR_NUMBER}/tvm/ut-python-gpu") {
try {
docker_init(ci_gpu)
init_git()
timeout(time: max_time, unit: 'MINUTES') {
withEnv([
'PLATFORM=gpu',
'TVM_NUM_SHARDS=3',
'TVM_SHARD_INDEX=1'], {
sh(
script: """
set -eux
aws s3 cp --no-progress s3://${s3_prefix}/gpu/build/libtvm.so build/libtvm.so
md5sum build/libtvm.so
aws s3 cp --no-progress s3://${s3_prefix}/gpu/build/libvta_fsim.so build/libvta_fsim.so
md5sum build/libvta_fsim.so
aws s3 cp --no-progress s3://${s3_prefix}/gpu/build/libtvm_runtime.so build/libtvm_runtime.so
md5sum build/libtvm_runtime.so
aws s3 cp --no-progress s3://${s3_prefix}/gpu/build/config.cmake build/config.cmake
md5sum build/config.cmake
""",
label: 'Download artifacts from S3',
)
ci_setup(ci_gpu)
sh (
script: "${docker_run} ${ci_gpu} ./tests/scripts/task_java_unittest.sh",
label: 'Run Java unit tests',
)
sh (