cornell-zhang / heterocl

HeteroCL: A Multi-Paradigm Programming Infrastructure for Software-Defined Heterogeneous Computing
https://cornell-zhang.github.io/heterocl/
Apache License 2.0
326 stars 92 forks source link

[API] Integrate AutoSA into HeteroCL #243

Closed hecmay closed 3 years ago

hecmay commented 4 years ago

This PR will integrate AutoSA and expose the

AutoSA integration

Installation:

AutoSA has a lot of dependencies. It will be hard to satisfy all of these requirements using conda. This PR provides a Dcokerfile to build an image containing pre-biult HeteroCL and AutoSA binaries. The users can pull back the docker image and run the code inside the docker container.

Implementation:

instead of introducing a new IR for AutoSA, I will reuse the ExternModule IR node. The stage to be offloaded to AutoSA will be wrapped inside the ExternModule node. In the VHLS CodeGen stage, the HeteroCL compiler should invoke AutoSA to generate optimized VHLS code from the ExternModule body. This optimized systolic array VHLS code block is then plugged into the original code as a soft IP.

User Interface:

As decribed in HeteroCL paper, users need to call the systolic() primitive to convert a compute stage to an optimized systolic array using AutoSA.

def test_systolic():
    A = hcl.placeholder((10, 10), "A")
    def kernel(A):
        B = hcl.compute((10, 8), lambda y, x: A[y, x] + A[y, x+1] + A[y, x+2], "B")
        C = hcl.compute((8, 8), lambda y, x: B[y, x] + B[y+1, x] + B[y+2, x], "C")
    s = hcl.create_schedule(A, kernel)
    s[kernel.B].systolic()
hecmay commented 4 years ago

Docker image with HeteroCL and AutoSA installed: https://hub.docker.com/repository/docker/cornellzhang/heterocl

$ docker pull cornellzhang/heterocl:autosa
$ docker run -it cornellzhang/heterocl:autosa bash

# activating conda env
$ source /opt/conda/etc/profile.d/conda.sh
$ conda activate hcl