Giter VIP home page Giter VIP logo

stencilflow's Introduction

Introduction

This repository implements an end-to-end stack that compiles a high-level description of a stencil program to hardware. Dependencies between stencil operators are resolved by streaming fine-grained results directly between processing elements on the chip.

Prerequisites

To run the code, the following software must be available:

  • Python 3.6.x or newer.
  • The virtualenv module (installed with pip install virtualenv).
  • A C++17-capable compiler (e.g., GCC 7.x or Clang 6.x).
  • One or both FPGA compilers:
    • Intel FPGA OpenCL SDK (tested with 18.1.1 and 19.1)
    • Xilinx Vitis (tested with 2020.2)

Setup

Sourcing the script setup_virtualenv.sh will setup a virtualenv with all the modules required to run StencilFlow, including the relevant version of DaCe:

source setup_virtualenv.sh

Running

To run the end-to-end flow on an input JSON file, the executable bin/run_program.py can be used. Example usage:

bin/run_program.py test/stencils/jacobi3d_32x32x32_8itr_8vec.json emulation -compare-to-reference

This will compile the FPGA kernel for Intel's emulation flow, execute it, build a reference CPU program, run both, and verify that the results match.

The generated program will be located in .dacecache/<kernel name>, with the kernel source files themselves in:

.dacecache/<kernel name>/src/intel_fpga/device

Verification

For programs using the "shrink" boundary conditions, the borders will intentionally have invalid results in them. To do validation in this scenario, use the -halo=3 flag to specify how large of a halo should be ignored in validation in each dimension.

Program description

Examples of program descriptions are located in test/stencils, including for 2D and 3D stencils, vectorization, and lower dimensional inputs.

Executables

All executables are included in the bin subfolder, and have documented command line interfaces.

Tests

The repository ships with a number of tests that verify various aspects of functionality. These can be run with:

test/test_stencil.py

It is a known issue that launching multiple Intel FPGA kernels in quick succession (such as is done in the tests) can sometimes fail sporadically, seemingly due to file I/O issues. Running individual programs should never fail.

stencilflow's People

Contributors

andreaskuster avatar definelicht avatar tbennun avatar tizianodematteis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stencilflow's Issues

Using StencilFlow with Python source code

Hi there,
I am interested in optimising a stencil code written in Python using StencilFlow. From what I see in the repository and from what I read on your paper it is possible to do so by generating the SDFG from DACE and then transforming this into a JSON StencilFlow file with the tool bin/sdfg_to_stencilflow.py. Unfortunately, I haven't been able to do so, as I'm getting the error ValueError: Program has no outputs. Here a small code to reproduce:

import dace
import numpy as np

DIM = 10

@dace.program
def jacobi(a: dace.float64[DIM,DIM], b: dace.float64[DIM,DIM]):
    for i in range(1,DIM-1):
        for j in range(1,DIM-1):
            b[i] = b[i] + 2*a[-1,0] - 2*a[1,0] + 2*a[0,-1] - 2*a[0,1]

if __name__ == "__main__":
    a = np.array([[0 for j in range(DIM)] for i in range(DIM)], dtype=np.double)
    b = np.array([[0 for j in range(DIM)] for i in range(DIM)], dtype=np.double)
    jacobi(a,b)

I just fed the .sdfg file in .dacecache/jacobi to bin/sdfg_to_stencilflow.py. Is there any fundamental annotation that's missing? I wouldn't want to modify the source code, is it possible to run StencilFlow on this code as-is other than some basic annotations?

Note: I am using the DACE version that is frozen as submodule in this repository.

Thanks,
Gabriel

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.