Skip to content

Commit 753fd53

Browse files
authored
Merge pull request #23 from definelicht/vitis_hls
Support Vitis 2020.1
2 parents 78124d8 + 7be8470 commit 753fd53

36 files changed

+350
-472
lines changed

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
BSD 3-Clause License
22

3-
Copyright (c) 2019, Johannes de Fine Licht, Scalable Parallel Computing Lab, ETH Zurich
3+
Copyright (c) 2017-2020, Johannes de Fine Licht, Scalable Parallel Computing Lab (SPCL), Department of Computer Science, ETH Zurich
44

55
All rights reserved.
66

cmake/FindVitis.cmake

Lines changed: 74 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,81 +6,116 @@
66
# Vitis_INCLUDE_DIRS - Include directories for HLS.
77
# Vitis_LIBRARIES - Runtime libraries required for host side code.
88
# Vitis_COMPILER - Path to the compiler executable (v++ or xocc).
9-
# Vitis_HLS - Path to Vivado HLS executable.
9+
# Vitis_HLS - Path to HLS executable (vitis_hls or vivado_hls).
1010
# Vitis_FLOATING_POINT_LIBRARY - Library required for emulation of fp16.
1111
# Vitis_VERSION - Version of Vitis/SDx/SDAccel installation.
1212
# Vitis_VERSION_MAJOR - Major version of Vitis/SDx/SDAccel installation.
1313
# Vitis_VERSION_MINOR - Minor version of Vitis/SDx/SDAccel installation.
1414
# Vitis_IS_LEGACY - Set if using a pre-Vitis version (i.e., SDx or SDAccel)
1515
#
1616
# To specify the location of Vitis or SDAccel, or to force this script to use a
17-
# specific version, set the variable VITIS_ROOT_DIR or SDACCEL_ROOT_DIR to the
18-
# root directory of the desired Vitis or SDAccel installation, respectively.
19-
# For SDAccel 2018.3 or newer, Vitis/SDAccel relies on a separate Xilinx Runtime
20-
# (XRT). This script will search in the default installation location, but a
21-
# path can be specified with the XRT_ROOT_DIR variable.
22-
23-
if(DEFINED SDACCEL_ROOT_DIR AND NOT DEFINED VITIS_ROOT_DIR)
24-
set(VITIS_ROOT_DIR ${SDACCEL_ROOT_DIR})
17+
# specific version, set the variable VITIS_ROOT, SDX_ROOT, or SDACCEL_ROOT to
18+
# the root directory of the desired Vitis, SDx, or SDAccel installation,
19+
# respectively. For SDAccel 2018.3 or newer, Vitis/SDAccel relies on a separate
20+
# Xilinx Runtime (XRT). This script will search in the default installation
21+
# location, but a path can be specified with the XRT_ROOT variable.
22+
23+
if(DEFINED SDACCEL_ROOT_DIR AND NOT DEFINED SDACCEL_ROOT)
24+
set(SDACCEL_ROOT ${SDACCEL_ROOT_DIR})
25+
endif()
26+
if(DEFINED SDX_ROOT_DIR AND NOT DEFINED SDX_ROOT)
27+
set(SDX_ROOT ${SDX_ROOT_DIR})
28+
endif()
29+
if(DEFINED VITIS_ROOT_DIR AND NOT DEFINED VITIS_ROOT)
30+
set(VITIS_ROOT ${VITIS_ROOT_DIR})
31+
endif()
32+
if(DEFINED SDX_ROOT AND NOT DEFINED VITIS_ROOT)
33+
set(VITIS_ROOT ${SDX_ROOT})
34+
endif()
35+
if(DEFINED SDACCEL_ROOT AND NOT DEFINED VITIS_ROOT)
36+
set(VITIS_ROOT ${SDACCEL_ROOT})
2537
endif()
2638

27-
if(NOT DEFINED VITIS_ROOT_DIR)
39+
if(NOT DEFINED VITIS_ROOT)
2840

2941
find_path(VITIS_SEARCH_PATH v++ xocc
3042
PATHS ENV XILINX_OPENCL ENV XILINX_VITIS ENV XILINX_SDACCEL
43+
ENV XILINX_SDX
3144
PATH_SUFFIXES bin)
32-
get_filename_component(VITIS_ROOT_DIR ${VITIS_SEARCH_PATH} DIRECTORY)
45+
get_filename_component(VITIS_ROOT ${VITIS_SEARCH_PATH} DIRECTORY)
3346
mark_as_advanced(VITIS_SEARCH_PATH)
3447

3548
else()
3649

37-
message(STATUS "Using user defined directory: ${VITIS_ROOT_DIR}")
50+
message(STATUS "Using user defined Vitis directory: ${VITIS_ROOT}")
3851

3952
endif()
4053

4154
# Check if all the necessary components are present. We want to ensure that we
4255
# use the tools bundled together, so we restrict all further finds to only look
4356
# in paths relative to the determined installation.
4457

45-
find_program(Vitis_XOCC xocc PATHS ${VITIS_ROOT_DIR}/bin NO_DEFAULT_PATH)
46-
find_program(Vitis_VPP v++ PATHS ${VITIS_ROOT_DIR}/bin NO_DEFAULT_PATH)
58+
find_program(Vitis_XOCC xocc PATHS ${VITIS_ROOT}/bin NO_DEFAULT_PATH)
59+
find_program(Vitis_VPP v++ PATHS ${VITIS_ROOT}/bin NO_DEFAULT_PATH)
4760
mark_as_advanced(Vitis_XOCC)
4861
mark_as_advanced(Vitis_VPP)
4962
if(Vitis_XOCC)
5063
set(VITIS_COMPILER ${Vitis_XOCC})
5164
set(VITIS_IS_LEGACY TRUE)
65+
add_definitions(-DVITIS_IS_LEGACY)
5266
endif()
5367
# Prefer v++ over xocc executable
5468
if(Vitis_VPP)
5569
set(VITIS_COMPILER ${Vitis_VPP})
5670
set(VITIS_IS_LEGACY FALSE)
5771
endif()
58-
set(Vitis_COMPILER ${VITIS_COMPILER} CACHE STRING "Compiler used to build FPGA kernels.")
59-
set(Vitis_IS_LEGACY ${VITIS_IS_LEGACY} CACHE STRING "Using legacy version of toolchain (pre-Vitis).")
72+
unset(Vitis_XOCC)
73+
unset(Vitis_VPP)
74+
set(Vitis_COMPILER ${VITIS_COMPILER} CACHE STRING "Compiler used to build FPGA kernels." FORCE)
75+
set(Vitis_IS_LEGACY ${VITIS_IS_LEGACY} CACHE STRING "Using legacy version of toolchain (pre-Vitis)." FORCE)
6076

6177
# Get version number string
62-
get_filename_component(VITIS_VERSION "${VITIS_ROOT_DIR}" NAME)
78+
get_filename_component(VITIS_VERSION "${VITIS_ROOT}" NAME)
6379
string(REGEX REPLACE "([0-9]+)\\.[0-9]+" "\\1" VITIS_MAJOR_VERSION "${VITIS_VERSION}")
6480
string(REGEX REPLACE "[0-9]+\\.([0-9]+)" "\\1" VITIS_MINOR_VERSION "${VITIS_VERSION}")
65-
set(Vitis_VERSION ${VITIS_VERSION} CACHE STRING "Version of Vitis found")
66-
set(Vitis_MAJOR_VERSION ${VITIS_MAJOR_VERSION} CACHE STRING "Major version of Vitis found")
67-
set(Vitis_MINOR_VERSION ${VITIS_MINOR_VERSION} CACHE STRING "Minor version of Vitis found")
68-
69-
# vitis_hls is still in beta as of 2019.2 and breaks some functionality, so
70-
# prefer vivado_hls for now (subject to change).
71-
find_program(Vitis_HLS NAMES vivado_hls vitis_hls PATHS
72-
${VITIS_ROOT_DIR}/bin
73-
${VITIS_ROOT_DIR}/../../Vivado/${Vitis_VERSION}/bin
74-
${VITIS_ROOT_DIR}/Vivado_HLS/bin NO_DEFAULT_PATH)
81+
set(Vitis_VERSION ${VITIS_VERSION} CACHE STRING "Version of Vitis found" FORCE)
82+
set(Vitis_MAJOR_VERSION ${VITIS_MAJOR_VERSION} CACHE STRING "Major version of Vitis found" FORCE)
83+
set(Vitis_MINOR_VERSION ${VITIS_MINOR_VERSION} CACHE STRING "Minor version of Vitis found" FORCE)
84+
add_definitions(-DVITIS_VERSION=${Vitis_VERSION} -DVITIS_MAJOR_VERSION=${Vitis_MAJOR_VERSION} -DVITIS_MINOR_VERSION=${Vitis_MINOR_VERSION})
85+
86+
find_program(Vitis_VIVADO_HLS NAMES vivado_hls PATHS
87+
${VITIS_ROOT}/bin
88+
${VITIS_ROOT}/../../Vivado/${Vitis_VERSION}/bin
89+
${VITIS_ROOT}/Vivado_HLS/bin NO_DEFAULT_PATH DOC
90+
"Vivado HLS compiler associated with this version of the tools.")
91+
92+
# Check if we should use vivado_hls or vitis_hls
93+
if(Vitis_MAJOR_VERSION GREATER_EQUAL 2020)
94+
# vitis_hls is used internally for building kernels starting from 2020.1.
95+
set(Vitis_USE_VITIS_HLS ON CACHE BOOL "Use vitis_hls instead of vivado_hls." FORCE)
96+
find_program(VITIS_HLS NAMES vitis_hls vivado_hls PATHS
97+
${VITIS_ROOT}/bin
98+
${VITIS_ROOT}/../../Vivado/${Vitis_VERSION}/bin
99+
${VITIS_ROOT}/Vivado_HLS/bin NO_DEFAULT_PATH)
100+
else()
101+
if(NOT DEFINED Vitis_USE_VITIS_HLS OR Vitis_USE_VITIS_HLS)
102+
message(WARNING "Vitis 2020.1 introduced breaking changes to hls::stream. Please pass -DVIVADO_MAJOR_VERSION=${VITIS_MAJOR_VERSION} in your synthesis script to always use the correct implementation.")
103+
endif()
104+
# Prior to 2020.1, vivado_hls from the Vivado installation is used.
105+
set(Vitis_USE_VITIS_HLS OFF CACHE BOOL "Use vitis_hls instead of vivado_hls." FORCE)
106+
set(VITIS_HLS ${Vitis_VIVADO_HLS})
107+
endif()
108+
mark_as_advanced(VITIS_HLS)
109+
set(Vitis_HLS ${VITIS_HLS} CACHE STRING "Path to HLS executable." FORCE)
75110

76111
find_program(Vitis_VIVADO vivado PATHS
77-
${VITIS_ROOT_DIR}/../../Vivado/${Vitis_VERSION}/bin
78-
${VITIS_ROOT_DIR}/Vivado/bin NO_DEFAULT_PATH)
112+
${VITIS_ROOT}/../../Vivado/${Vitis_VERSION}/bin
113+
${VITIS_ROOT}/Vivado/bin NO_DEFAULT_PATH)
79114

80115
find_path(Vitis_HLS_INCLUDE_DIR hls_stream.h PATHS
81-
${VITIS_ROOT_DIR}/../../Vivado/${Vitis_VERSION}/include
82-
${VITIS_ROOT_DIR}/include
83-
${VITIS_ROOT_DIR}/Vivado_HLS/include
116+
${VITIS_ROOT}/../../Vivado/${Vitis_VERSION}/include
117+
${VITIS_ROOT}/include
118+
${VITIS_ROOT}/Vivado_HLS/include
84119
NO_DEFAULT_PATH)
85120
mark_as_advanced(Vitis_HLS_INCLUDE_DIR)
86121

@@ -90,7 +125,7 @@ if(Vitis_VPP OR (Vitis_MAJOR_VERSION GREATER 2018) OR
90125
else()
91126
set(VITIS_USE_XRT FALSE)
92127
endif()
93-
set(Vitis_USE_XRT ${VITIS_USE_XRT} CACHE STRING "Use XRT as runtime. Otherwise, use SDAccel/SDx OpenCL runtime.")
128+
set(Vitis_USE_XRT ${VITIS_USE_XRT} CACHE STRING "Use XRT as runtime. Otherwise, use SDAccel/SDx OpenCL runtime." FORCE)
94129

95130
# Currently only x86 support
96131

@@ -102,9 +137,9 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
102137

103138
find_library(Vitis_FLOATING_POINT_LIBRARY Ip_floating_point_v7_0_bitacc_cmodel
104139
PATHS
105-
${VITIS_ROOT_DIR}/lnx64/tools/fpo_v7_0
106-
${VITIS_ROOT_DIR}/../../Vivado/${Vitis_VERSION}/lnx64/tools/fpo_v7_0
107-
${VITIS_ROOT_DIR}/Vivado_HLS/lnx64/tools/fpo_v7_0)
140+
${VITIS_ROOT}/lnx64/tools/fpo_v7_0
141+
${VITIS_ROOT}/../../Vivado/${Vitis_VERSION}/lnx64/tools/fpo_v7_0
142+
${VITIS_ROOT}/Vivado_HLS/lnx64/tools/fpo_v7_0)
108143
mark_as_advanced(Vitis_FLOATING_POINT_LIBRARY)
109144

110145
get_filename_component(VITIS_FP_DIR ${Vitis_FLOATING_POINT_LIBRARY}
@@ -130,7 +165,7 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
130165

131166
if(NOT Vitis_USE_XRT)
132167

133-
set(VITIS_RUNTIME_DIR ${VITIS_ROOT_DIR}/runtime)
168+
set(VITIS_RUNTIME_DIR ${VITIS_ROOT}/runtime)
134169

135170
# Older versions of SDAccel ship with their own OpenCL headers. Make sure
136171
# to use them.
@@ -190,7 +225,7 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
190225
# Only succeed if libraries were found
191226
if(Vitis_LIBXILINXOPENCL)
192227
set(Vitis_LIBRARIES ${OpenCL_LIBRARIES} ${Vitis_LIBXILINXOPENCL}
193-
CACHE STRING "OpenCL runtime libraries.")
228+
CACHE STRING "OpenCL runtime libraries." FORCE)
194229
endif()
195230

196231
# For some reason, the executable finds the floating point library on the
@@ -211,7 +246,7 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
211246
Vitis_OPENCL_EXTENSIONS_INCLUDE_DIR)
212247
set(Vitis_INCLUDE_DIRS ${Vitis_HLS_INCLUDE_DIR}
213248
${Vitis_OPENCL_INCLUDE_DIR} ${Vitis_OPENCL_EXTENSIONS_INCLUDE_DIR}
214-
CACHE STRING "Vitis include directories.")
249+
CACHE STRING "Vitis include directories." FORCE)
215250
endif()
216251

217252
else()

include/hlslib/intel/OpenCL.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/// @author Johannes de Fine Licht (definelicht@inf.ethz.ch)
2-
/// @date February 2019
32
/// @copyright This software is copyrighted under the BSD 3-Clause License.
43

54
#pragma once

include/hlslib/xilinx/Accumulate.h

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/// @author Johannes de Fine Licht (definelicht@inf.ethz.ch)
2-
/// @date June 2017
32
/// @copyright This software is copyrighted under the BSD 3-Clause License.
43

54
#pragma once
@@ -51,7 +50,7 @@
5150
namespace hlslib {
5251

5352
template <typename T, class Operator, int latency>
54-
void AccumulateIterate(Stream<T> &input, Stream<T> &fromFeedback,
53+
void AccumulateIterate(Stream<T> &input, Stream<T, latency> &fromFeedback,
5554
Stream<T> &toFeedback, int size, int iterations) {
5655
AccumulateIterate_Iterations:
5756
for (int i = 0; i < iterations; ++i) {
@@ -61,22 +60,22 @@ void AccumulateIterate(Stream<T> &input, Stream<T> &fromFeedback,
6160
for (int k = 0; k < latency; ++k) {
6261
#pragma HLS PIPELINE
6362
#pragma HLS LOOP_FLATTEN
64-
const T a = hlslib::ReadBlocking(input);
63+
const T a = input.Pop();
6564
T b;
6665
if (j > 0) {
67-
b = hlslib::ReadOptimistic(fromFeedback);
66+
b = fromFeedback.ReadOptimistic();
6867
} else {
6968
b = Operator::identity();
7069
}
7170
const auto result = Operator::Apply(a, b);
72-
hlslib::WriteBlocking(toFeedback, result, 1);
71+
toFeedback.Push(result);
7372
}
7473
}
7574
}
7675
}
7776

7877
template <typename T, int latency>
79-
void AccumulateFeedback(Stream<T> &toFeedback, Stream<T> &fromFeedback,
78+
void AccumulateFeedback(Stream<T> &toFeedback, Stream<T, latency> &fromFeedback,
8079
Stream<T> &toReduce, int size, int iterations) {
8180
AccumulateFeedback_Iterations:
8281
for (int i = 0; i < iterations; ++i) {
@@ -86,13 +85,13 @@ void AccumulateFeedback(Stream<T> &toFeedback, Stream<T> &fromFeedback,
8685
for (int k = 0; k < latency; ++k) {
8786
#pragma HLS PIPELINE
8887
#pragma HLS LOOP_FLATTEN
89-
const auto read = hlslib::ReadBlocking(toFeedback);
88+
const auto read = toFeedback.Pop();
9089
if (j < size / latency - 1) {
9190
// Feedback back
92-
hlslib::WriteBlocking(fromFeedback, read, latency);
91+
fromFeedback.Push(read);
9392
} else {
9493
// Write to output
95-
hlslib::WriteBlocking(toReduce, read, 1);
94+
toReduce.Push(read);
9695
}
9796
}
9897
}
@@ -108,10 +107,10 @@ void AccumulateReduce(Stream<T> &toReduce, Stream<T> &output, int size,
108107
T result(Operator::identity());
109108
AccumulateReduce_Latency:
110109
for (int j = 0; j < latency; ++j) {
111-
const auto read = hlslib::ReadBlocking(toReduce);
110+
const auto read = toReduce.Pop();
112111
result = Operator::Apply(result, read);
113112
}
114-
hlslib::WriteBlocking(output, result, 1);
113+
output.Push(result);
115114
}
116115
}
117116

@@ -125,11 +124,11 @@ void AccumulateSimple(Stream<T> &in, Stream<T> &out, int size, int iterations) {
125124
for (int j = 0; j < size; ++j) {
126125
#pragma HLS LOOP_FLATTEN
127126
#pragma HLS PIPELINE
128-
const auto a = hlslib::ReadBlocking(in);
127+
const auto a = in.Pop();
129128
const auto b = (j > 0) ? acc : T(Operator::identity());
130129
acc = Operator::Apply(a, b);
131130
if (j == size - 1) {
132-
hlslib::WriteBlocking(out, acc, 1);
131+
out.Push(acc);
133132
}
134133
}
135134
}

include/hlslib/xilinx/Axi.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/// @author Johannes de Fine Licht (definelicht@inf.ethz.ch)
2-
/// @date October 2017
32
/// @copyright This software is copyrighted under the BSD 3-Clause License.
43

54
#pragma once

include/hlslib/xilinx/DataPack.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/// @author Johannes de Fine Licht (definelicht@inf.ethz.ch)
2-
/// @date April 2016
32
/// @copyright This software is copyrighted under the BSD 3-Clause License.
43

54
#pragma once

include/hlslib/xilinx/Flatten.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/// @author Johannes de Fine Licht (definelicht@inf.ethz.ch)
2-
/// @date July 2018
32
/// @copyright This software is copyrighted under the BSD 3-Clause License.
43

54
#pragma once

include/hlslib/xilinx/Operators.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/// @author Johannes de Fine Licht (definelicht@inf.ethz.ch)
2-
/// @date June 2017
32
/// @copyright This software is copyrighted under the BSD 3-Clause License.
43

54
#pragma once

include/hlslib/xilinx/Resource.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/// @author Johannes de Fine Licht (definelicht@inf.ethz.ch)
2-
/// @date August 2017
32
/// @copyright This software is copyrighted under the BSD 3-Clause License.
43

54
#pragma once

include/hlslib/xilinx/SDAccel.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/// @author Johannes de Fine Licht (definelicht@inf.ethz.ch)
2-
/// @date February 2019
32
/// @copyright This software is copyrighted under the BSD 3-Clause License.
43

54
#pragma once

0 commit comments

Comments
 (0)