Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[API][Backend] Streaming and OpenCL Backends #140

Merged
merged 107 commits into from
Dec 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
2b3b2b0
add sdaccel, aocl for heterocl
ybai62868 Jul 25, 2019
86525fc
fpga
ybai62868 Jul 25, 2019
1d8115f
Create codeanalys_openclc.cc
ybai62868 Jul 25, 2019
47026fe
Update target.py
ybai62868 Jul 25, 2019
5fba7cc
run
ybai62868 Jul 26, 2019
31d00e3
can run successfully
ybai62868 Jul 26, 2019
e0dc81f
Create codegen_opencl.cc
ybai62868 Jul 29, 2019
8c010da
now
ybai62868 Jul 29, 2019
843b6f4
all done
ybai62868 Jul 30, 2019
f0ac7a7
Update codegen_sdaccel.cc
ybai62868 Jul 30, 2019
8713bda
Update codegen_sdaccel.cc
ybai62868 Jul 30, 2019
e687bfb
modified: python/heterocl/tvm/target.py
hgyhungry Aug 7, 2019
b091758
new file: samples/ppac/gemm/csrcPrint.py
hgyhungry Aug 7, 2019
8e12d35
all
ybai62868 Aug 7, 2019
416ca43
remove tvm check code from kernel
hgyhungry Aug 9, 2019
e9a0a1c
opencl-backend
ybai62868 Aug 14, 2019
5695f2c
all
ybai62868 Aug 14, 2019
568555d
fix ppac module build
hgyhungry Aug 15, 2019
2518aeb
support ppac MVPb pragma
hgyhungry Aug 15, 2019
314994e
fix ignoring ppac pragma in cpu backend
hgyhungry Aug 16, 2019
a06f97b
opencl-backend
ybai62868 Aug 18, 2019
3f03b41
aocl-backend
ybai62868 Aug 18, 2019
ffb8673
move ppac codegen to ppac folder; fix argument name with merlinc anal…
hgyhungry Sep 2, 2019
8afdea8
discard the new for-loop type; include ppac in hlib
hgyhungry Sep 2, 2019
819eae8
discard some previous changes
hgyhungry Sep 2, 2019
4ee0a93
Use int64_t as return type of GeMM on ppac
hgyhungry Sep 3, 2019
66851f0
[add] codegenc kernedef + stream init
hecmay Sep 3, 2019
63833c2
[add] var_shape_map
Sep 4, 2019
69fd36f
[update] kerneldef struct shape
hecmay Sep 5, 2019
32a522d
[update] use noderef and restore
hecmay Sep 5, 2019
171699c
[fix] return op
Sep 6, 2019
2cd15d2
[add] hcl device & kernelstmt printer
Sep 7, 2019
adb5af1
[fix] def workaround
Sep 9, 2019
3457773
[update] stream example
hecmay Sep 12, 2019
2330ea3
[add] stream expr & stmt ir
hecmay Sep 13, 2019
ae7bebf
[fix] kernel arg location for stream
hecmay Sep 14, 2019
c2dbf4c
Merge branch 'master' of https://github.com/Hecmay/heterocl
hecmay Sep 14, 2019
83e4d7e
opt1
ybai62868 Aug 18, 2019
df48ef9
opencl-general
ybai62868 Aug 18, 2019
d51970a
new-version
ybai62868 Aug 18, 2019
530ce5d
no bug
ybai62868 Aug 18, 2019
64d91e5
a
ybai62868 Aug 18, 2019
e123363
test+unroll+pipeline
ybai62868 Aug 19, 2019
0cdceb8
pragma
ybai62868 Aug 21, 2019
4fba56c
new
ybai62868 Aug 21, 2019
ccd58fd
type has fixed
ybai62868 Aug 22, 2019
1832760
new_test
ybai62868 Aug 23, 2019
c3d8f3c
test_reorder_split_fuse
ybai62868 Aug 23, 2019
ad27bcc
target
ybai62868 Aug 23, 2019
337db9a
order
ybai62868 Aug 23, 2019
3cb38bf
simplified by rui
ybai62868 Aug 23, 2019
c4562e5
analysis
ybai62868 Aug 23, 2019
51a4f77
bug fixed
ybai62868 Aug 27, 2019
6fe29d5
[delete] all of the code about opencl
ybai62868 Aug 27, 2019
a0611c6
[ADD] new opencl back-end including xilinx & intel
ybai62868 Aug 27, 2019
4852b98
fixed __local
ybai62868 Aug 28, 2019
ea0771f
fixed data_type for xilinx opencl
ybai62868 Sep 2, 2019
4ebdfb7
add makefile for SDAccel_runtime
ybai62868 Sep 2, 2019
05ff646
add the runtime for sdaccel
ybai62868 Sep 3, 2019
fa30a01
create the sdaccel host
ybai62868 Sep 3, 2019
51584e4
fixed the indent problem partly
ybai62868 Sep 3, 2019
c5239bf
test the zhang-05 server
ybai62868 Sep 4, 2019
7991a81
add indent to the host.cpp
ybai62868 Sep 4, 2019
104e5e6
automatically generate makefile
ybai62868 Sep 5, 2019
dad3e75
delete common folder from opencl
ybai62868 Sep 5, 2019
59f5f7e
add shmat to sdaccel runtime
ybai62868 Sep 5, 2019
e2dd3a2
fixed bug for sdaccel runtime seg fault
ybai62868 Sep 5, 2019
f405ec3
fixed the bug of host.cpp multiple
ybai62868 Sep 5, 2019
edfa9ce
fixed host.cpp multiple bug
ybai62868 Sep 5, 2019
4bb58fa
fixed endif for makefile
ybai62868 Sep 5, 2019
edf784f
modify sdaccel_sw_emu -> sdaccel_csim
ybai62868 Sep 6, 2019
aa67e48
fix the __local and __global for intel opencl back-end
ybai62868 Sep 12, 2019
c46b932
Fix the arbitrary integer precision for aocl
ybai62868 Sep 13, 2019
879da3c
[add] ir visitor & functor for codegen
Sep 15, 2019
245bffa
[add] aocl stream codegen
hecmay Sep 16, 2019
cc65e5d
[add] aocl stream support
hecmay Sep 18, 2019
786ccb7
[fix] aocl type conversion
hecmay Sep 18, 2019
1ec3fcd
[fix] aocl channel syntax
hecmay Sep 18, 2019
1ab0c8c
[add] sch.stream_to
hecmay Oct 1, 2019
8b8dea9
[fix] add stream annotation
hecmay Oct 4, 2019
23fa599
[add] host device codegen
hecmay Oct 6, 2019
2d59e40
[API] Enable building a function directly from IR (#133)
seanlatias Oct 8, 2019
a3f168a
[add] stream ir mutator
hecmay Oct 15, 2019
5a3112e
[Add] Interface prag,a for SDx sim
hecmay Oct 16, 2019
52ffe80
[add] host xcel codegen
hecmay Oct 22, 2019
c5907cf
[update] build interface
hecmay Oct 22, 2019
99fe2b7
[update] new build interface
hecmay Oct 31, 2019
a18f24f
[fix] temp update
hecmay Oct 31, 2019
955974c
[add] ppac hlib & riscv codegen
hecmay Oct 31, 2019
76dec95
Merge branch 'ppac' into opencl
hecmay Oct 31, 2019
ed31f99
[update] stream example
hecmay Nov 8, 2019
73daf28
[add] rocc-ppac sim
hecmay Nov 10, 2019
e8fe221
[rm] submodule
hecmay Nov 13, 2019
c98d859
[update] rocc ppac hlib
hecmay Nov 13, 2019
6d9780a
[add] unified sim & kernel updater
hecmay Nov 25, 2019
046048e
[API] Enable select API to accept Python expressions
seanlatias Nov 26, 2019
c124eb9
[API] Fixed incorrect casting for select in CastRemover
seanlatias Nov 27, 2019
85db48d
re-organize build common util
hecmay Nov 28, 2019
f85cfdd
merge with upstream
hecmay Nov 28, 2019
8c72a7a
[update] stream in codegen c
hecmay Dec 4, 2019
280ae2f
[update] codegen construct for streaming
hecmay Dec 7, 2019
96e388f
[update] code post-processing
hecmay Dec 8, 2019
1aabf4e
[fix] test cases
hecmay Dec 9, 2019
dd3e2a8
[fix] python compatibility
hecmay Dec 9, 2019
eefae89
[update] future
hecmay Dec 10, 2019
e53cb1e
[fix] metaclass
hecmay Dec 10, 2019
378069f
[fix] test import issue
hecmay Dec 10, 2019
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
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ test: &test
key: v1.03-libhcl-
- run: make build-python
- run: pip install --user pytest
- run: pip install --user future
- run: python -m pytest tests
- run: pip install --user mxnet
- run: python -m pytest samples
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ tags
docs/source/samples
docs/source/tutorials
soda_*
*.cpp
*.h
out

# Downloaded files
Expand Down
11 changes: 11 additions & 0 deletions HISTORY
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
### 2019-12-09
* fixed issue of zc706 simulation
* remove kernel-name variable allocation before KernelDef
* change multi-dimension array access to row-major single-dimension access
* create local buffer for each on-device variable
* updated the `KernelUpdater` class (using position index instead of name)
* added `stream_arg_pos` map in `CodeGenC` to facilitate codegen with streaming
* fixed test cases
* changed tvm `build` function to support legacy string type target
* fixed opencl aocl data type mismatching issue
* fixed kernel def data type conversion issue
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ build-tvm: build-pkgs

build-hcl: build-tvm
cd python; \
python setup.py install --user; \
python setup.py develop --user; \
cd ../hlib/python; \
python setup.py install --user;
python setup.py develop --user;

build-python:
cd python; \
python setup.py install --user; \
python setup.py develop --user; \
cd ../hlib/python; \
python setup.py install --user;
python setup.py develop --user;

clean:
rm -rf build
Expand Down
3 changes: 3 additions & 0 deletions Makefile.config
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ CMAKE_OK = no
# set whether to use vivado hls runtime
USE_VIVADO_HLS = 1

# set whether to use sdaccel opencl runtime
USE_SDACCEL_HLS = 1

# Specify current directory level with respect to CLAY_ROOT
ifndef LEVEL
LEVEL := .
Expand Down
11 changes: 11 additions & 0 deletions hlib/python/hlib/nn.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ def _pad(*indices):
return data[tuple(index_tuple)]
return hcl.compute(out_shape, _pad, name='pad')

def conv2d_nchw_imp(Input, Filter, Output, stride=[1,1], padding=[[0,0],[0,0]]):
with hcl.for_(0,Output.shape[0]) as n:
with hcl.for_(0,Output.shape[1]) as c:
with hcl.for_(0,Output.shape[2]) as h:
with hcl.for_(0,Output.shape[3]) as w:
partial = hcl.scalar(0)
with hcl.for_(0,Filter.shape[-2]) as x:
with hcl.for_(0,Filter.shape[-1]) as y:
partial.v += Input[n][c][h+x][w+y] * Filter[0][0][x][y]
Output[n,c,h,w] = partial

def conv2d_nchw(Input, Filter, name="conv2d", stride=[1,1], padding=[[0,0],[0,0]]):
out_dtype = Input.dtype
batch, in_channel, in_height, in_width = Input.shape
Expand Down
1 change: 1 addition & 0 deletions hlib/rocc-ppac
Submodule rocc-ppac added at 40d323
1 change: 1 addition & 0 deletions python/heterocl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from .compute_api import *
from .dsl import *
from .types import *
from .devices import *
from .nparray import *
from .debug import hcl_excepthook
from .tvm.intrin import *
Expand Down
28 changes: 22 additions & 6 deletions python/heterocl/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
#pylint: disable=no-member
from ordered_set import OrderedSet
from .tvm.build_module import build as _build, lower as _lower
from .tvm.api import convert
from .tvm import _api_internal as tvm_api
from .tvm import schedule as _schedule
from .tvm import make as _make
from .tvm import call_intrin
from .tensor import Scalar, Tensor
from .schedule import Stage, Schedule
from .scheme import Scheme
Expand Down Expand Up @@ -51,7 +53,7 @@ def app2(A, B, C):
# execute f2
"""
# set the configurations
config.init_dtype = init_dtype
config.init_dtype = init_dtype
# initialize global variables
Schedule.stage_ops = []
Schedule.last_stages = OrderedSet([])
Expand Down Expand Up @@ -88,7 +90,7 @@ def placeholder(shape, name=None, dtype=None):
"""
name = util.get_name("placeholder", name)
dtype = util.get_dtype(dtype)

if shape == ():
return Scalar(tvm_api._Var(name, dtype))
tensor = Tensor(shape, dtype, name)
Expand Down Expand Up @@ -268,10 +270,11 @@ def lower(schedule):
new_inputs.append(i.var)
return _lower(schedule.sch, new_inputs, simple_mode=True)

def build(schedule, target=None, name="default_function"):
def build(schedule, target=None, name="default_function", stmt=None):
"""Build the executable according to the schedule and target.

The default target is `llvm` (i.e., CPU execution).
The default target is `llvm` (i.e., CPU execution). If stmt is specified,
the statements created by HeteroCL APIs will be ignored.

Parameters
----------
Expand All @@ -284,6 +287,9 @@ def build(schedule, target=None, name="default_function"):
name : str, optional
The name of the generated function

stmt : Stmt, optional
The built statement

Returns
-------
tvm.module.Module
Expand All @@ -294,7 +300,17 @@ def build(schedule, target=None, name="default_function"):
new_inputs.append(i.tensor.op.output(0))
else:
new_inputs.append(i.var)
return _build(schedule.sch, new_inputs, target=target, name=name)
if stmt is not None:
for i in schedule.inputs:
if isinstance(i, Tensor):
shapes = []
for s in i.shape:
shapes.append(0)
shapes.append(s)
tpl = tuple(shapes)
stmt = _make.AttrStmt([i.buf, i.tensor], "buffer_bind_scope",
call_intrin('handle', 'tvm_tuple', *tpl), stmt)
return _build(schedule.sch, new_inputs, target=target, name=name, stmt=stmt)

##############################################################################
# Other useful APIs
Expand Down Expand Up @@ -342,4 +358,4 @@ def select(cond, true, false):
-------
Expr
"""
return _make.Select(cond, true, false)
return _make.Select(convert(cond), convert(true), convert(false))
5 changes: 5 additions & 0 deletions python/heterocl/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ class TensorError(HCLError):
def __init__(self, msg):
HCLError.__init__(self, msg, "\33[1;31m[Tensor]\33[0m ")

class DeviceError(HCLError):
"""A subclass for specifying device related exception"""
def __init__(self, msg):
HCLError.__init__(self, msg, "\33[1;31m[Device]\33[0m ")

def hcl_excepthook(etype, value, tb):
"""Customized excepthook

Expand Down
Loading