Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,12 @@ projects/*
!projects/Makefile
runtimes/*
!runtimes/*.*
# Clang, which is tracked independently.
tools/clang
# LLDB, which is tracked independently.
tools/lldb
# lld, which is tracked independently.
tools/lld
# llgo, which is tracked independently.
tools/llgo
# Polly, which is tracked independently.
tools/polly
# avrlit, which is tracked independently.
tools/avrlit
# Sphinx build tree, if building in-source dir.
Expand Down
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "tools/polly"]
path = tools/polly
url = git@github.com:PolyArch/ss-polly.git
[submodule "tools/clang"]
path = tools/clang
url = git@github.com:PolyArch/ss-clang.git
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
The Stream-Specialized LLVM Compiler Infrastructure
===================================================

LLVM compiler infrastructure for stream-specialzed architecture family.
Much stuff is still in working in progress.

Installation
------------

Stream-specialized architectures are all RISCV ISA based, so cross-platform
compilation is required. Thus, the compilation options are slightly different.

```sh
$ git clone --recursive [this repo]
$ cd /path/to/this/repo; mkdir build; cd build
$ cmake -G "Unix Makefiles" \
-DBUILD_SHARED_LIBS=ON -DLLVM_USE_SPLIT_DWARF=ON \
-DCMAKE_INSTALL_PREFIX=$SS_TOOLS -DLLVM_OPTIMIZED_TABLEGEN=ON \
-DLLVM_BUILD_TESTS=False -DLLVM_TARGETS_TO_BUILD="" \
-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="RISCV" \
-DLLVM_DEFAULT_TARGET_TRIPLE=riscv64-unknown-elf \
-DCMAKE_CROSSCOMPILING=True ..
$ make -j9
```

Hollo world!
------------
It is a little bit tricky to build RISCV binaries with the current LLVM toolchain:
LLVM toolchain so far can only generate codes, but linking is not perfectly supported
yet. Thus, we need to borrow linker from the gnu toolchain.

Clang can only, by default, generate hard-float (floats goes to its specialized
register file) programs, and GNU toolchain, by default, is built with soft-float
library. This may cause an ABI mismatch. Thus, we need to add `--enable-multilib`
when configuring GNU-RISCV build.

Because RISCV is not the native host ISA, when compiling with Clang, `--sysroot` should
be specified to support C/C++ standard libraries.


```C
// main.c
#include <stdio.h>
int main() {
puts("Hello world!\n");
return 0;
}
```

```sh
$ clang main.c -O -c --sysroot=/where/riscv/gnu/toolchain/installed
$ riscv-gnu-unknown-elf-gcc main.o -o main -march=rv64imac -mabi=lp64
# Using RISCV emulator or simulator to verify the binary
```
18 changes: 0 additions & 18 deletions README.txt

This file was deleted.

12 changes: 12 additions & 0 deletions examples/SSVecadd/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
*.s
*.o
*.exe

*.bc
*.ll

dfg*.dfg
*.dfg.h
sched/*
verif/*
viz/*
24 changes: 24 additions & 0 deletions examples/SSVecadd/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
CLANG = clang
LLC = llc
RV_ROOT = $(SS_TOOLS)/riscv64-unknown-elf
INCLUDE = -I $(SS_TOOLS)/include

ifndef SSCONFIG
$(warning SSCONFIG is undefined, using default)
SSCONFIG=$(SS)"/ss-scheduler/configs/revel-1x1.sbmodel"
endif

vecadd.dfg.h: vecadd.dfg
ss_sched -a sa --max-iters 20000 -d --verbose $(SSCONFIG) $<

main.bc: main.c vecadd.dfg.h
$(CLANG) $< -o $@ -emit-llvm -O -c -O2 --sysroot=$(RV_ROOT) $(INCLUDE)

auto-main.bc: main.c vecadd.dfg.h
$(CLANG) -DAUTO $< -o $@ -emit-llvm -O -c -O2 --sysroot=$(RV_ROOT) $(INCLUDE)

main.s: main.bc
$(LLC) $<

clean:
rm -f *.bc *.ll *.o *.exe *.s *.dfg.h dfg*.dfg
27 changes: 27 additions & 0 deletions examples/SSVecadd/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <stdio.h>
#include <ss-intrin/ss_insts.h>
#include "./vecadd.dfg.h"

#define N 128

double a[N];
double b[N];
double c[N];

int main() {

#ifndef AUTO
SS_DMA_READ(a, 0, 8 * N, 1, P_vecadd_a);
SS_DMA_READ(b, 0, 8 * N, 1, P_vecadd_b);
SS_DMA_WRITE(P_vecadd_c, 0, 8 * N, 1, c);
SS_WAIT_ALL();
#else
#pragma ss config
#pragma ss stream
#pragma ss dfg dedicated
for (int i = 0; i < N; ++i) {
c[i] = a[i] + b[i];
}
#endif

}
6 changes: 6 additions & 0 deletions examples/SSVecadd/vecadd.dfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Input: a
Input: b

c = FAdd64(a, b)

Output: c
1 change: 1 addition & 0 deletions lib/Transforms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ add_subdirectory(Vectorize)
add_subdirectory(Hello)
add_subdirectory(ObjCARC)
add_subdirectory(Coroutines)
add_subdirectory(StreamSpecialize)
20 changes: 20 additions & 0 deletions lib/Transforms/StreamSpecialize/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# If we don't need RTTI or EH, there's no reason to export anything
# from the hello plugin.
if( NOT LLVM_REQUIRES_RTTI )
if( NOT LLVM_REQUIRES_EH )
set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/StreamSpecialize.exports)
endif()
endif()

if(WIN32 OR CYGWIN)
set(LLVM_LINK_COMPONENTS Core Support)
endif()

add_llvm_loadable_module( LLVMOffloadDFG
OffloadDFG.cpp

DEPENDS
intrinsics_gen
PLUGIN_TOOL
opt
)
Loading