6
6
# Vitis_INCLUDE_DIRS - Include directories for HLS.
7
7
# Vitis_LIBRARIES - Runtime libraries required for host side code.
8
8
# 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) .
10
10
# Vitis_FLOATING_POINT_LIBRARY - Library required for emulation of fp16.
11
11
# Vitis_VERSION - Version of Vitis/SDx/SDAccel installation.
12
12
# Vitis_VERSION_MAJOR - Major version of Vitis/SDx/SDAccel installation.
13
13
# Vitis_VERSION_MINOR - Minor version of Vitis/SDx/SDAccel installation.
14
14
# Vitis_IS_LEGACY - Set if using a pre-Vitis version (i.e., SDx or SDAccel)
15
15
#
16
16
# 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} )
25
37
endif ()
26
38
27
- if (NOT DEFINED VITIS_ROOT_DIR )
39
+ if (NOT DEFINED VITIS_ROOT )
28
40
29
41
find_path (VITIS_SEARCH_PATH v++ xocc
30
42
PATHS ENV XILINX_OPENCL ENV XILINX_VITIS ENV XILINX_SDACCEL
43
+ ENV XILINX_SDX
31
44
PATH_SUFFIXES bin )
32
- get_filename_component (VITIS_ROOT_DIR ${VITIS_SEARCH_PATH} DIRECTORY )
45
+ get_filename_component (VITIS_ROOT ${VITIS_SEARCH_PATH} DIRECTORY )
33
46
mark_as_advanced (VITIS_SEARCH_PATH )
34
47
35
48
else ()
36
49
37
- message (STATUS "Using user defined directory: ${VITIS_ROOT_DIR } " )
50
+ message (STATUS "Using user defined Vitis directory: ${VITIS_ROOT } " )
38
51
39
52
endif ()
40
53
41
54
# Check if all the necessary components are present. We want to ensure that we
42
55
# use the tools bundled together, so we restrict all further finds to only look
43
56
# in paths relative to the determined installation.
44
57
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 )
47
60
mark_as_advanced (Vitis_XOCC )
48
61
mark_as_advanced (Vitis_VPP )
49
62
if (Vitis_XOCC )
50
63
set (VITIS_COMPILER ${Vitis_XOCC} )
51
64
set (VITIS_IS_LEGACY TRUE )
65
+ add_definitions (-DVITIS_IS_LEGACY )
52
66
endif ()
53
67
# Prefer v++ over xocc executable
54
68
if (Vitis_VPP )
55
69
set (VITIS_COMPILER ${Vitis_VPP} )
56
70
set (VITIS_IS_LEGACY FALSE )
57
71
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 )
60
76
61
77
# Get version number string
62
- get_filename_component (VITIS_VERSION "${VITIS_ROOT_DIR } " NAME )
78
+ get_filename_component (VITIS_VERSION "${VITIS_ROOT } " NAME )
63
79
string (REGEX REPLACE "([0-9]+)\\ .[0-9]+" "\\ 1" VITIS_MAJOR_VERSION "${VITIS_VERSION} " )
64
80
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 )
75
110
76
111
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 )
79
114
80
115
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
84
119
NO_DEFAULT_PATH )
85
120
mark_as_advanced (Vitis_HLS_INCLUDE_DIR )
86
121
@@ -90,7 +125,7 @@ if(Vitis_VPP OR (Vitis_MAJOR_VERSION GREATER 2018) OR
90
125
else ()
91
126
set (VITIS_USE_XRT FALSE )
92
127
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 )
94
129
95
130
# Currently only x86 support
96
131
@@ -102,9 +137,9 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
102
137
103
138
find_library (Vitis_FLOATING_POINT_LIBRARY Ip_floating_point_v7_0_bitacc_cmodel
104
139
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 )
108
143
mark_as_advanced (Vitis_FLOATING_POINT_LIBRARY )
109
144
110
145
get_filename_component (VITIS_FP_DIR ${Vitis_FLOATING_POINT_LIBRARY}
@@ -130,7 +165,7 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
130
165
131
166
if (NOT Vitis_USE_XRT )
132
167
133
- set (VITIS_RUNTIME_DIR ${VITIS_ROOT_DIR } /runtime )
168
+ set (VITIS_RUNTIME_DIR ${VITIS_ROOT } /runtime )
134
169
135
170
# Older versions of SDAccel ship with their own OpenCL headers. Make sure
136
171
# to use them.
@@ -190,7 +225,7 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
190
225
# Only succeed if libraries were found
191
226
if (Vitis_LIBXILINXOPENCL )
192
227
set (Vitis_LIBRARIES ${OpenCL_LIBRARIES} ${Vitis_LIBXILINXOPENCL}
193
- CACHE STRING "OpenCL runtime libraries." )
228
+ CACHE STRING "OpenCL runtime libraries." FORCE )
194
229
endif ()
195
230
196
231
# 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)")
211
246
Vitis_OPENCL_EXTENSIONS_INCLUDE_DIR )
212
247
set (Vitis_INCLUDE_DIRS ${Vitis_HLS_INCLUDE_DIR}
213
248
${Vitis_OPENCL_INCLUDE_DIR} ${Vitis_OPENCL_EXTENSIONS_INCLUDE_DIR}
214
- CACHE STRING "Vitis include directories." )
249
+ CACHE STRING "Vitis include directories." FORCE )
215
250
endif ()
216
251
217
252
else ()
0 commit comments