Skip to content

Commit b8a6095

Browse files
committed
[TEST] CI infrastructure (#30)
1 parent c588502 commit b8a6095

23 files changed

+483
-7
lines changed

vta/Jenkinsfile

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
#!groovy
2+
// -*- mode: groovy -*-
3+
// Jenkins pipeline
4+
// See documents at https://jenkins.io/doc/book/pipeline/jenkinsfile/
5+
6+
// nnvm libraries
7+
vta_lib += "lib/libvta.so, lib/libvta.so.json"
8+
vta_lib += ", nnvm/tvm/lib/libtvm.so, nnvm/tvm/lib/libtopi.so, nnvm/lib/libnnvm_compiler.so"
9+
10+
11+
// command to start a docker container
12+
docker_run = 'tests/ci_build/ci_build.sh'
13+
// timeout in minutes
14+
max_time = 60
15+
16+
// initialize source codes
17+
def init_git() {
18+
checkout scm
19+
retry(5) {
20+
timeout(time: 2, unit: 'MINUTES') {
21+
sh 'git submodule update --init --recursive'
22+
}
23+
}
24+
}
25+
26+
def init_git_win() {
27+
checkout scm
28+
retry(5) {
29+
timeout(time: 2, unit: 'MINUTES') {
30+
bat 'git submodule update --init --recursive'
31+
}
32+
}
33+
}
34+
35+
stage("Sanity Check") {
36+
timeout(time: max_time, unit: 'MINUTES') {
37+
node('linux') {
38+
ws('workspace/vta/sanity') {
39+
init_git()
40+
sh "${docker_run} lint ./tests/scripts/task_lint.sh"
41+
}
42+
}
43+
}
44+
}
45+
46+
// Run make. First try to do an incremental make from a previous workspace in hope to
47+
// accelerate the compilation. If something wrong, clean the workspace and then
48+
// build from scratch.
49+
def make(docker_type, make_flag) {
50+
timeout(time: max_time, unit: 'MINUTES') {
51+
sh "${docker_run} ${docker_type} cp make/sim_sample.json config.json"
52+
try {
53+
sh "${docker_run} ${docker_type} ./tests/scripts/task_build.sh ${make_flag}"
54+
} catch (exc) {
55+
echo 'Incremental compilation failed. Fall back to build from scratch'
56+
sh "${docker_run} ${docker_type} ./tests/scripts/task_clean.sh"
57+
sh "${docker_run} ${docker_type} ./tests/scripts/task_build.sh ${make_flag}"
58+
}
59+
}
60+
}
61+
62+
// pack libraries for later use
63+
def pack_lib(name, libs) {
64+
sh """
65+
echo "Packing ${libs} into ${name}"
66+
echo ${libs} | sed -e 's/,/ /g' | xargs md5sum
67+
"""
68+
stash includes: libs, name: name
69+
}
70+
71+
72+
// unpack libraries saved before
73+
def unpack_lib(name, libs) {
74+
unstash name
75+
sh """
76+
echo "Unpacked ${libs} from ${name}"
77+
echo ${libs} | sed -e 's/,/ /g' | xargs md5sum
78+
"""
79+
}
80+
81+
stage('Build') {
82+
timeout(time: max_time, unit: 'MINUTES') {
83+
node('linux') {
84+
ws('workspace/vta/build') {
85+
init_git()
86+
make('cpu', '-j2')
87+
pack_lib('cpu', vta_lib)
88+
}
89+
}
90+
}
91+
}
92+
93+
stage('Tests') {
94+
parallel 'python': {
95+
node('linux') {
96+
ws('workspace/vta/it-python') {
97+
init_git()
98+
unpack_lib('cpu', vta_lib)
99+
timeout(time: max_time, unit: 'MINUTES') {
100+
sh "${docker_run} cpu ./tests/scripts/task_python_test.sh"
101+
}
102+
}
103+
}
104+
},
105+
'docs': {
106+
node('linux') {
107+
ws('workspace/vta/docs-python') {
108+
init_git()
109+
unpack_lib('cpu', vta_lib)
110+
timeout(time: max_time, unit: 'MINUTES') {
111+
sh "${docker_run} cpu ./tests/scripts/task_python_docs.sh"
112+
}
113+
pack_lib('mydocs', 'docs.tgz')
114+
}
115+
}
116+
}
117+
}
118+
119+
stage('Deploy') {
120+
node('docker' && 'doc') {
121+
ws('workspace/vta/deploy-docs') {
122+
if (env.BRANCH_NAME == "master") {
123+
unpack_lib('mydocs', 'docs.tgz')
124+
sh "tar xf docs.tgz -C /var/vta-docs"
125+
}
126+
}
127+
}
128+
}

vta/docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import shlex
1717
import recommonmark
1818
import sphinx_gallery
19+
from tvm.contrib import rpc, graph_runtime
1920
from recommonmark.parser import CommonMarkParser
2021
from recommonmark.transform import AutoStructify
2122

vta/include/vta/driver.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
22
* Copyright (c) 2018 by Contributors
3-
* \file vta_driver.h
3+
* \file driver.h
44
* \brief Driver interface that is used by runtime.
55
*
66
* Driver's implementation is device specific.
@@ -46,7 +46,7 @@ void VTADeviceFree(VTADeviceHandle handle);
4646

4747
/*!
4848
* \brief Launch the instructions block until done.
49-
* \param The device handle.
49+
* \param device The device handle.
5050
* \param insn_phy_addr The physical address of instruction stream.
5151
* \param insn_count Instruction count.
5252
* \param wait_cycles The maximum of cycles to wait

vta/include/vta/hw_spec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
22
* Copyright (c) 2018 by Contributors
3-
* \file vta_defines.h
3+
* \file hw_spec.h
44
* \brief Preprocessor definitions for VTA HLS design and runtime.
55
*/
66

vta/include/vta/runtime.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,19 @@ extern "C" {
2525

2626
/*!
2727
* \brief Allocate data buffer.
28-
* \param cmd The VTA command handle.
2928
* \param size Buffer size.
3029
* \return A pointer to the allocated buffer.
3130
*/
3231
void* VTABufferAlloc(size_t size);
3332

3433
/*!
3534
* \brief Free data buffer.
36-
* \param cmd The VTA command handle.
3735
* \param buffer The data buffer to be freed.
3836
*/
3937
void VTABufferFree(void* buffer);
4038

4139
/*!
4240
* \brief Copy data buffer from one location to another.
43-
* \param cmd The VTA command handle.
4441
* \param from The source buffer base address.
4542
* \param from_offset The offset of the source buffer.
4643
* \param to The target buffer base address.
@@ -145,6 +142,7 @@ void VTALoadBuffer2D(VTACommandHandle cmd,
145142
* \param src_sram_index Source SRAM index.
146143
* \param src_memory_type Source memory type.
147144
* \param dst_dram_addr Destination DRAM address.
145+
* \param dst_elem_offset The destination DRAM offset in number of unit elements.
148146
* \param x_size The lowest dimension (x axis) size in number of unit elements.
149147
* \param y_size The number of rows.
150148
* \param x_stride The x axis stride.

vta/make/sim_sample.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"TARGET" : "sim",
3+
"LOG_INP_WIDTH" : 3,
4+
"LOG_WGT_WIDTH" : 3,
5+
"LOG_ACC_WIDTH" : 5,
6+
"LOG_OUT_WIDTH" : 3,
7+
"LOG_BATCH" : 0,
8+
"LOG_BLOCK_IN" : 4,
9+
"LOG_BLOCK_OUT" : 4,
10+
"LOG_UOP_BUFF_SIZE" : 15,
11+
"LOG_INP_BUFF_SIZE" : 15,
12+
"LOG_WGT_BUFF_SIZE" : 15,
13+
"LOG_ACC_BUFF_SIZE" : 17
14+
}

vta/python/vta/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""TVM-based VTA Compiler Toolchain"""
22
from __future__ import absolute_import as _abs
33

4+
__version__ = "0.1.0"
5+
46

57
from .environment import get_env, Environment
68
from .rpc_client import reconfig_runtime, program_fpga

vta/tests/ci_build/Dockerfile.cpu

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# For CPU
2+
FROM ubuntu:16.04
3+
4+
RUN apt-get update --fix-missing
5+
6+
COPY install/ubuntu_install_core.sh /install/ubuntu_install_core.sh
7+
RUN bash /install/ubuntu_install_core.sh
8+
9+
COPY install/ubuntu_install_llvm.sh /install/ubuntu_install_llvm.sh
10+
RUN bash /install/ubuntu_install_llvm.sh
11+
12+
COPY install/ubuntu_install_python.sh /install/ubuntu_install_python.sh
13+
RUN bash /install/ubuntu_install_python.sh
14+
15+
COPY install/ubuntu_install_python_package.sh /install/ubuntu_install_python_package.sh
16+
RUN bash /install/ubuntu_install_python_package.sh
17+
18+
COPY install/ubuntu_install_sphinx.sh /install/ubuntu_install_sphinx.sh
19+
RUN bash /install/ubuntu_install_sphinx.sh
20+
21+
# Fix recommonmark to latest version
22+
RUN git clone https://github.com/rtfd/recommonmark
23+
RUN cd recommonmark; python setup.py install
24+
25+
# Enable doxygen for c++ doc build
26+
RUN apt-get update && apt-get install -y doxygen graphviz

vta/tests/ci_build/Dockerfile.lint

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# For lint test
2+
FROM ubuntu:16.04
3+
4+
RUN apt-get update && apt-get install -y python-pip sudo
5+
RUN apt-get install -y doxygen graphviz
6+
RUN pip install cpplint pylint

vta/tests/ci_build/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# CI Build Scripts
2+
3+
This directory contains the files and setup instructions to run all tests.
4+
5+
## Run locally
6+
7+
To run locally, we need to first install
8+
[docker](https://docs.docker.com/engine/installation/)
9+
10+
Then we can run the tasks defined in the [Jenkinsfile](../../Jenkinsfile) by
11+
using (`ci_build.sh`)[./ci_build.sh]. For example
12+
13+
- lint the python codes
14+
15+
```bash
16+
./ci_build.sh lint make pylint
17+
```
18+
19+
- build codes with CUDA supports
20+
21+
```bash
22+
./ci_build.sh gpu tests/scripts/task_build.sh
23+
```
24+
25+
- do the python unittest
26+
27+
```bash
28+
./ci_build.sh gpu tests/scripts/task_python_test.sh
29+
```
30+
31+
- build the documents. The results will be available at `docs/_build/html`
32+
33+
```bash
34+
tests/ci_build/ci_build.sh gpu tests/scripts/task_python_docs.sh
35+
```

0 commit comments

Comments
 (0)