Skip to content

Commit 95e1773

Browse files
committed
update the whole repo
1 parent 565fbd5 commit 95e1773

File tree

246 files changed

+16258
-64126
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

246 files changed

+16258
-64126
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
BSD 3-Clause License
22

3-
Copyright (c) 2022, xxx
3+
Copyright (c) 2022, Fudan University
44
All rights reserved.
55

66
Redistribution and use in source and binary forms, with or without

README.md

Lines changed: 96 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -17,104 +17,158 @@ Framework for a hybrid system with RISC-V and CGRA, including:
1717

1818
### Dependencies
1919

20-
##### Chipyard
2120

22-
##### LLVM-10.0.0 with Polly included
21+
#### Chipyard 1.5.0
2322

23+
1. install dependence tools
24+
25+
```sh
26+
sudo apt-get install -y build-essential bison flex software-properties-common curl
27+
sudo apt-get install -y libgmp-dev libmpfr-dev libmpc-dev zlib1g-dev vim default-jdk default-jre
28+
sudo apt-get install -y texinfo gengetopt
29+
sudo apt-get install -y libexpat1-dev libusb-dev libncurses5-dev cmake
30+
sudo apt-get install -y python3.8 patch diffstat texi2html texinfo subversion chrpath wget
31+
sudo apt-get install -y libgtk-3-dev gettext
32+
sudo apt-get install -y python3-pip python3.8-dev rsync libguestfs-tools expat ctags
33+
sudo apt-get install -y device-tree-compiler
34+
```
35+
36+
2. clone repo and build
37+
38+
```sh
39+
git clone https://github.com/ucb-bar/chipyard.git
40+
cd chipyard
41+
git checkout 1.5.0
42+
./scripts/init-submodules-no-riscv-tools.sh
43+
./scripts/build-toolchains.sh esp-tools --ignore-qemu
44+
```
45+
46+
47+
#### LLVM-10.0.0 with Polly included
48+
49+
50+
1. download llvm source codes from https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-10.0.0.tar.gz
51+
52+
extract and change directory name
53+
54+
```sh
55+
tar xvf llvmorg-10.0.0.tar.gz
56+
mv llvmorg-10.0.0 llvm-project-10.0.0
57+
```
58+
59+
2. build llvm
60+
61+
```sh
62+
mkdir llvm-10.0.0-built
63+
cd llvm-project-10.0.0
64+
mkdir build
65+
cd build
66+
cmake -DLLVM_ENABLE_PROJECTS='polly;clang' -G "Unix Makefiles" ../llvm
67+
# multi-thread consumes lots of memory, e.g. -j4 : 30G+
68+
make -j4
69+
# DESTDIR set install directory
70+
make install DESTDIR=/xxx/llvm/llvm-10.0.0-built
71+
```
72+
73+
3. set llvm env
74+
75+
```sh
76+
# add following env to .bashrc and then source ~/.bashrc.
77+
# or directly export the env
78+
export LLVM_HOME=/xxx/llvm/llvm-10.0.0-built/usr/local/bin
79+
export PATH=$LLVM_HOME:$PATH
80+
# or set the LLVM path in the CMakeLists.txt
81+
set(LLVM_INCLUDE_DIRS "/xxx/llvm-10.0.0-built/usr/local/include")
82+
set(LLVM_LIBRARY_DIRS "/xxx/llvm-10.0.0-built/usr/local/lib")
83+
```
2484

2585

2686
### CGRA-MG
2787

88+
2889
#### Setup
2990

91+
3092
1. copy this repo to the chipyard/generators/ directory
3193

3294
2. Add the following configuration in the chipyard/build.sbt file
3395

3496
```
35-
lazy val chipyard = (project in file("generators/chipyard"))
36-
.dependsOn(
37-
...
38-
fdra
39-
)
40-
41-
lazy val fdra = (project in file("generators/fdra/cgra-mg"))
42-
.dependsOn(testchipip, rocketchip)
43-
.settings(libraryDependencies ++= rocketLibDeps.value)
44-
.settings(chiselTestSettings)
45-
.settings(commonSettings)
46-
97+
lazy val chipyard = (project in file("generators/chipyard"))
98+
.dependsOn(
99+
...
100+
fdra
101+
)
102+
103+
lazy val fdra = (project in file("generators/fdra/cgra-mg"))
104+
.dependsOn(testchipip, rocketchip)
105+
.settings(libraryDependencies ++= rocketLibDeps.value)
106+
.settings(chiselTestSettings)
107+
.settings(commonSettings)
47108
```
48109

49110
3. copy config file to chipyard
50111

51112
```sh
52-
cd chipyard/generators/fdra
53-
./scripts/setup-paths.sh
113+
cd chipyard/generators/fdra
114+
./scripts/setup-paths.sh
54115
```
55116

56117
#### Build and run
57118

58119
1. build verilog
59120

60121
```sh
61-
source env.sh
62-
cd generators/fdra
63-
./scripts/build-verilog.sh
122+
source env.sh
123+
cd generators/fdra
124+
./scripts/build-verilog.sh
64125
```
65126

66127
2. build simulator based on Verilator
67128

68129
```sh
69-
./scripts/build-verilator.sh
130+
./scripts/build-verilator.sh
70131
```
71132

72133
### App-Compiler
73134

74135
#### Setup
75-
76-
Download LLVM-10.0.0 and build
77-
78-
Set LLVM env
136+
Download LLVM-10.0.0 and build
137+
Set LLVM env
79138

80139
#### Build and Run
81-
82-
Using the script build.sh in this app-compiler directory. The internal path should be changed.
140+
Using the script build.sh in this app-compiler directory. The internal path should be changed.
83141

84142
```sh
85-
./build.sh
143+
./build.sh
86144
```
87145

88146

89147
### CGRA-Compiler
90148

91149
#### Build
92-
93-
Using the script build.sh
150+
Using the script build.sh
94151
```sh
95-
cd cgra-compiler
96-
./build.sh
152+
cd cgra-compiler
153+
./build.sh
97154
```
98155

99156
#### Run
100-
101-
Using the script run.sh
157+
Using the script run.sh
102158
```sh
103-
./run.sh
159+
./run.sh
104160
```
105161

106-
Change the benchmark file path as you need.
107-
The generated result files are in the same directory as the benchmark.
162+
Change the benchmark file path as you need.
163+
The generated result files are in the same directory as the benchmark.
108164

109165

110166

111167
### Build & Run Application on SoC
112168

113169
#### SoC application code generation
114-
115-
Automatically generate with CGRA Compiler, or
116-
117-
Manually replace the target loop kernel with CGRA call function and binding codes generated by CGRA Mapper
170+
Automatically generate with CGRA Compiler, or
171+
Manually replace the target loop kernel with CGRA call function and binding codes generated by CGRA Mapper
118172

119173

120174
#### Compile SoC application code with RISC-V toolchain
@@ -129,6 +183,6 @@ Manually replace the target loop kernel with CGRA call function and binding code
129183
#### Run SoC application with simulator
130184

131185
```sh
132-
cd generators/fdra
133-
./scripts/run-verilator.sh app-name
186+
cd generators/fdra
187+
./scripts/run-verilator.sh app-name
134188
```

app-compiler/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ project(${PROJECT_NAME} VERSION 0.1.0)
55
set(CMAKE_CXX_STANDARD 14)
66
# set(CMAKE_BUILD_TYPE "Release")
77

8-
set(LLVM_INCLUDE_DIRS "/home/xxx/llvm-10.0.0-built/usr/local/include")
9-
set(LLVM_LIBRARY_DIRS "/home/xxx/llvm-10.0.0-built/usr/local/lib")
8+
set(LLVM_INCLUDE_DIRS "/xxx/llvm/llvm-10.0.0-built/usr/local/include")
9+
set(LLVM_LIBRARY_DIRS "/xxx/llvm/llvm-10.0.0-built/usr/local/lib")
1010
#find_package(LLVM 10 REQUIRED)
1111
# add_definitions(${LLVM_DEFINITIONS})
1212
include_directories(${LLVM_INCLUDE_DIRS})

app-compiler/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# set env for built LLVM
2-
export LLVM_HOME=/xxx/llvm-10.0.0-built/usr/local/bin
2+
export LLVM_HOME=/xxx/llvm/llvm-10.0.0-built/usr/local/bin
33
export PATH=$LLVM_HOME:$PATH
44

55
# cmake & make

app-compiler/llvm-pass/CGRA_test.cpp

Lines changed: 0 additions & 10 deletions
This file was deleted.

app-compiler/llvm-pass/include/llvm_cdfg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef __LLVM_CDFG_H__
22
#define __LLVM_CDFG_H__
33

4-
#define BITWIDTH 8
4+
#define BITWIDTH 16
55

66

77
#include "llvm/Analysis/ScalarEvolution.h"

benchmarks/test4/Makefile

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

2-
all: conv2d_3x3 fft fir_unroll4 gemm-ncubed_unroll4 md-knn pedometer stencil2d
2+
all: conv2d_3x3 fft fir gemm md-knn pedometer stencil2d
33

4-
clean-all: clean-testaffine clean-conv2d_3x3 clean-fft clean-fir_unroll4 clean-gemm-ncubed_unroll4 clean-md-knn clean-pedometer clean-stencil2d
4+
clean-all: clean-testaffine clean-conv2d_3x3 clean-fft clean-fir clean-gemm clean-md-knn clean-pedometer clean-stencil2d
55

66

77
# application: conv2d_3x3
@@ -28,29 +28,29 @@ fft:
2828
clean-fft:
2929
cd ./fft; rm -f ./*.ll ./*.dot
3030

31-
# application: fir_unroll4
32-
.PHONY : fir_unroll4
33-
fir_unroll4:
34-
@echo "============================ fir_unroll4 =================================="
35-
cd ./fir_unroll4; bash ../compile.sh kernel kernel
36-
@echo "============================ fir_unroll4 =================================="
31+
# application: fir
32+
.PHONY : fir
33+
fir:
34+
@echo "============================ fir =================================="
35+
cd ./fir; bash ../compile.sh kernel kernel
36+
@echo "============================ fir =================================="
3737
@echo
3838
@echo
3939

40-
clean-fir_unroll4:
41-
cd ./fir_unroll4; rm -f ./*.ll ./*.dot
40+
clean-fir:
41+
cd ./fir; rm -f ./*.ll ./*.dot
4242

43-
# application: gemm-ncubed_unroll4
44-
.PHONY : gemm-ncubed_unroll4
45-
gemm-ncubed_unroll4:
46-
@echo "============================ gemm-ncubed_unroll4 =================================="
47-
cd ./gemm-ncubed_unroll4; bash ../compile.sh gemm gemm
48-
@echo "============================ gemm-ncubed_unroll4 =================================="
43+
# application: gemm
44+
.PHONY : gemm
45+
gemm:
46+
@echo "============================ gemm =================================="
47+
cd ./gemm; bash ../compile.sh gemm gemm
48+
@echo "============================ gemm =================================="
4949
@echo
5050
@echo
5151

52-
clean-gemm-ncubed_unroll4:
53-
cd ./gemm-ncubed_unroll4; rm -f ./*.ll ./*.dot
52+
clean-gemm:
53+
cd ./gemm; rm -f ./*.ll ./*.dot
5454

5555
# application: md-knn
5656
.PHONY : md-knn
@@ -68,7 +68,7 @@ clean-md-knn:
6868
.PHONY : pedometer
6969
pedometer:
7070
@echo "============================ pedometer =================================="
71-
cd ./pedometer; bash ../compile.sh adapt_pedometer_step_is_array pedometer
71+
cd ./pedometer; bash ../compile.sh pedometer pedometer
7272
@echo "============================ pedometer =================================="
7373
@echo
7474
@echo

benchmarks/test4/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
### Run to generate CDFGs for benchmarks
22

3+
#### 1. Setup path
4+
5+
change paths of the LLVM library and the generated Pass library in compile.sh
6+
7+
8+
#### 2. Generate DFGs
9+
310
Using the Makefile in the fdra/benchmarks/test4 directory
411

512
The generated CDFG files are in the same dirrectory as the benchmark.

benchmarks/test4/compile.sh

100644100755
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# ./compile.sh c-file-name function-name
22

3-
# -fno-inline -fno-unroll-loops
4-
export LLVM_HOME=/home/tallanlong/llvm-10.0.0-built/usr/local/bin
3+
export LLVM_HOME=/xxx/llvm/llvm-10.0.0-built/usr/local/bin
54
export PATH=$LLVM_HOME:$PATH
65

7-
clang -I /home/tallanlong/app-compiler-decouple/app-compiler-pattern/applications/MachSuite/common -D CGRA_COMPILER -target i386-unknown-linux-gnu -c -emit-llvm -O2 -fno-tree-vectorize -fno-unroll-loops $1.c -S -o $1.ll
6+
clang -D CGRA_COMPILER -target i386-unknown-linux-gnu -c -emit-llvm -O1 -fno-tree-vectorize -fno-unroll-loops $1.c -S -o $1.ll
87

98
opt -gvn -mem2reg -memdep -memcpyopt -lcssa -loop-simplify -licm -loop-deletion -indvars -simplifycfg -mergereturn -indvars $1.ll -S -o $1_gvn.ll
109

11-
opt -load ../../../app-compiler/build/llvm-pass/libCDFGPass.so -fn $2 -cdfg $1_gvn.ll -S -o $1_cdfg.ll
10+
opt -load /xxx/fdra/app-compiler/build/llvm-pass/libCDFGPass.so -fn $2 -cdfg $1_gvn.ll -S -o $1_cdfg.ll
1211

12+
dot -Tdot_json affine.dot -o affine.json

0 commit comments

Comments
 (0)