Skip to content

Commit

Permalink
Update to support Vitis 2020.1 and 2018.2 simultaneously
Browse files Browse the repository at this point in the history
  • Loading branch information
definelicht committed Sep 11, 2020
1 parent 7634356 commit 71bf094
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 114 deletions.
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,14 @@ add_test(TestSimulation TestSimulation)
enable_testing()

# Synthesis flags
set(MM_SYNTHESIS_FLAGS "${MM_SYNTHESIS_FLAGS} -std=c++11 -O3 -DMM_SYNTHESIS -DHLSLIB_SYNTHESIS -DVITIS_MAJOR_VERSION=${Vitis_MAJOR_VERSION}")
set(MM_SYNTHESIS_FLAGS "${MM_SYNTHESIS_FLAGS} -std=c++11 -O3 -DMM_SYNTHESIS -DHLSLIB_SYNTHESIS -DVITIS_MAJOR_VERSION=${Vitis_MAJOR_VERSION} -DVITIS_MINOR_VERSION=${Vitis_MINOR_VERSION} -DVITIS_VERSION=${Vitis_VERSION}")
# Vitis 2020.1 introduces breaking changes to hls::stream
if(NOT Vitis_USE_VITIS_HLS)
set(MM_SYNTHESIS_FLAGS "${MM_SYNTHESIS_FLAGS} -D__VIVADO_HLS__")
else()
set(MM_SYNTHESIS_FLAGS "${MM_SYNTHESIS_FLAGS} -D__VITIS_HLS__")
endif()

if(MM_ADD_RESOURCE)
set(MM_SYNTHESIS_FLAGS "${MM_SYNTHESIS_FLAGS} -DMM_ADD_RESOURCE=${MM_ADD_RESOURCE}")
endif()
Expand Down
2 changes: 1 addition & 1 deletion hlslib
8 changes: 4 additions & 4 deletions include/Compute.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

#include "MatrixMultiplication.h"

void ProcessingElement(Stream<ComputePackN_t, kPipeDepth> &aIn,
Stream<ComputePackN_t, kPipeDepth> &aOut,
Stream<ComputePackM_t, kPipeDepth> &bIn,
Stream<ComputePackM_t, kPipeDepth> &bOut,
void ProcessingElement(Stream<ComputePackN_t> &aIn,
Stream<ComputePackN_t> &aOut,
Stream<ComputePackM_t> &bIn,
Stream<ComputePackM_t> &bOut,
Stream<ComputePackM_t> &cOut,
Stream<ComputePackM_t> &cIn, const unsigned locationN,
const unsigned size_n, const unsigned size_k,
Expand Down
50 changes: 20 additions & 30 deletions include/Memory.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/// @author Johannes de Fine Licht ([email protected])
/// @date August 2017
/// @copyright This software is copyrighted under the BSD 3-Clause License.

#pragma once
Expand All @@ -11,68 +10,59 @@

// Read wide bursts from memory, then distribute it into separate column
// buffers, which will be read out in column-major order and sent to the kernel
void ReadA(MemoryPackK_t const a[],
Stream<Data_t, 2 * kOuterTileSizeN> aSplit[kTransposeWidth],
void ReadA(MemoryPackK_t const a[], Stream<Data_t> aSplit[kTransposeWidth],
unsigned n, unsigned k, unsigned m);

// We pop from the column buffers in column-major order, funneling the
// transposed data to the kernel
#ifdef MM_CONVERT_A

void TransposeA(Stream<Data_t, 2 * kOuterTileSizeN> aSplit[kTransposeWidth],
Stream<Data_t, kPipeDepth> &toKernel,
unsigned n, unsigned k, unsigned m);
void TransposeA(Stream<Data_t> aSplit[kTransposeWidth],
Stream<Data_t> &toKernel, unsigned n, unsigned k, unsigned m);

void ConvertWidthA(Stream<Data_t, kPipeDepth> &narrow,
Stream<ComputePackN_t, kPipeDepth> &wide,
void ConvertWidthA(Stream<Data_t> &narrow, Stream<ComputePackN_t> &wide,
unsigned, unsigned k, unsigned m);

#else

void TransposeA(Stream<Data_t, 2 * kOuterTileSizeN> aSplit[kTransposeWidth],
Stream<ComputePackN_t, kPipeDepth> &toKernel,
unsigned n, unsigned k, unsigned m);
void TransposeA(Stream<Data_t> aSplit[kTransposeWidth],
Stream<ComputePackN_t> &toKernel, unsigned n, unsigned k,
unsigned m);
#endif

#else // MM_TRANSPOSED_A
#else // MM_TRANSPOSED_A

void ReadATransposed(MemoryPackN_t const memory[],
Stream<MemoryPackN_t, 2 * kOuterTileSizeNMemory> &pipe,
void ReadATransposed(MemoryPackN_t const memory[], Stream<MemoryPackN_t> &pipe,
const unsigned size_n, const unsigned size_k,
const unsigned size_m);

void ConvertWidthATransposed(
Stream<MemoryPackN_t, 2 * kOuterTileSizeNMemory> &pipe_in,
Stream<ComputePackN_t, kPipeDepth> &pipe_out, const unsigned size_n,
const unsigned size_k, const unsigned size_m);
void ConvertWidthATransposed(Stream<MemoryPackN_t> &pipe_in,
Stream<ComputePackN_t> &pipe_out,
const unsigned size_n, const unsigned size_k,
const unsigned size_m);

#endif

void ReadB(MemoryPackM_t const memory[],
Stream<MemoryPackM_t, 2 * kOuterTileSizeMMemory> &pipe,
void ReadB(MemoryPackM_t const memory[], Stream<MemoryPackM_t> &pipe,
unsigned n, unsigned k, unsigned m);

#ifdef MM_CONVERT_B

void ConvertWidthB(Stream<MemoryPackM_t, 2 * kOuterTileSizeMMemory> &wide,
Stream<ComputePackM_t> &narrow,
void ConvertWidthB(Stream<MemoryPackM_t> &wide, Stream<ComputePackM_t> &narrow,
unsigned n, unsigned k, unsigned m);

void FeedB(Stream<ComputePackM_t> &converted,
Stream<ComputePackM_t, kPipeDepth> &toKernel,
void FeedB(Stream<ComputePackM_t> &converted, Stream<ComputePackM_t> &toKernel,
unsigned n, unsigned k, unsigned m);

#else

void FeedB(Stream<ComputePackM_t, 2 * kOuterTileSizeMMemory> &fromMemory,
Stream<ComputePackM_t, kPipeDepth> &toKernel,
void FeedB(Stream<ComputePackM_t> &fromMemory, Stream<ComputePackM_t> &toKernel,
unsigned n, unsigned k, unsigned m);

#endif

void ConvertWidthC(Stream<OutputPack_t> &narrow,
Stream<MemoryPackM_t, 2 * kOuterTileSizeMMemory> &wide,
void ConvertWidthC(Stream<OutputPack_t> &narrow, Stream<MemoryPackM_t> &wide,
unsigned n, unsigned k, unsigned m);

void WriteC(Stream<MemoryPackM_t, 2 * kOuterTileSizeMMemory> &pipe,
MemoryPackM_t memory[], unsigned n, unsigned k, unsigned m);
void WriteC(Stream<MemoryPackM_t> &pipe, MemoryPackM_t memory[], unsigned n,
unsigned k, unsigned m);
9 changes: 4 additions & 5 deletions kernel/Compute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@
#include "Memory.h"
#include <cassert>

void ProcessingElement(Stream<ComputePackN_t, kPipeDepth> &aIn,
Stream<ComputePackN_t, kPipeDepth> &aOut,
Stream<ComputePackM_t, kPipeDepth> &bIn,
Stream<ComputePackM_t, kPipeDepth> &bOut,
void ProcessingElement(Stream<ComputePackN_t> &aIn,
Stream<ComputePackN_t> &aOut,
Stream<ComputePackM_t> &bIn,
Stream<ComputePackM_t> &bOut,
Stream<ComputePackM_t> &cOut,
Stream<ComputePackM_t> &cIn, const unsigned locationN,
const unsigned size_n, const unsigned size_k,
const unsigned size_m) {

// A is double-buffered, such that new values can be read while the
// previous outer product is being computed. This is required to achieve
// a perfect pipeline across the K-dimension, which is necessary for
Expand Down
Loading

0 comments on commit 71bf094

Please sign in to comment.