Code Monkey home page Code Monkey logo

hd-clustering's Introduction

This repository contains a Hetero-C++ port of the HD-Clustering code from UCSD. Here are the steps taken to port the Xilinx Vitis HLS C++ code to Hetero-C++:

  1. Remove all Vitis specific constructs. In this codebase, the primary Vitis constructs used were hls::stream and ap_int, where N is any number of bits.
  • To replace ap_int, convert any ap_int to the corresponding uintN_t, assuming N is 8, 16, 32, or 64 (this is the vast majority of cases)
  • For ap_int where N is large (in the code, the common case is N = 512), convert the ap_int to an array of uintN_t (in the HD-Classification code, I converted ap_int<512> to uint32_t[8], which is easy since most references to ap_int<512> were through pointers, so all that needs to change is some pointer math)
  • To replace hls::stream, code re-structuring is required - the FPGA code is structured as separate kernels that communicate in a streaming mannger, removing the hls::streams requires de-streaming the code
  • If each kernel has a common outer iteration, this can be achieved by moving the loop outside of the kernels (so in top, do for { kernel1(); kernel2(); } rather than kernel1 and kernel2 containing the for loop), then each kernel communicates through a shared buffer (input of one kernel, input to another)
  • In some cases, more aggressive code restructuring might be required (as in the HD-Classification code) - this was due to differing loop structures between the kernels, unfortunately the code restructuring in these cases is fairly case specific - the goal is to minimize the amount of data communicated between the kernels between invocations, as a whole buffer has to be allocated for that amount of data
  1. Add Hetero-C++ annotations, and launch from the host code.
  • This part is fairly straightforward, since the HD codes by-and-large don't contain task level parallelism, so the whole HD code can be modeled as a single HPVM leaf node
  • To run on FPGA, the leaf node needs a CPU internal node wrapper (see the hd function in hd.cpp for an example of our to set this up in Hetero-C++)
  • The inputs and outputs of the kernel should be annotated in hd.cpp, and should match up with how the DFG is launched in host.cpp
  • Mark all pointer arguments as restrict (if an argument was an array, convert to a restrict pointer) to get better performance

hd-clustering's People

Contributors

rarbore avatar bkhalegh avatar tycheyoung avatar j1morris avatar

Forkers

akothen

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.