Xilinx / HLS

Vitis HLS LLVM source code and examples
Other
376 stars 55 forks source link

Compilation with HLS streams fails #12

Closed gabrielrodcanal closed 11 months ago

gabrielrodcanal commented 1 year ago

Hi, I am working on a project with the Xilinx's LLVM frontend. At this point I was testing the generation of LLVM IR with HLS streams. It turns out the compilation with Xilinx's clang fails. The error message says: clang-7.0: /home/nx08/nx08/s2081362-2/HPE/HLS/hls-llvm-project/clang/lib/CodeGen/CGCall.cpp:2561: void clang::CodeGen::CodeGenFunction::EmitFunctionProlog(const clang::CodeGen::CGFunctionInfo&, llvm::Function*, const clang::CodeGen::FunctionArgList&): Assertion `NumIRArgs == 1 && "AST argument and LLVM IR arg is not one to one mapping, can not handle it "' failed.

I am getting this error even with the minimal example:

#include <hls_stream.h>

void kernel() {
      hls::stream<int> inStream1;
}

This only happens when I enable the option -fhls (which I take it is necessary, as otherwise HLS pragmas are ignored).

The compile command used was: /home/nx08/nx08/s2081362-2/HPE/HLS/hls-build/bin/clang stream.cpp -c -emit-llvm -I/home/nx08/shared/fpga/xilinx/2021.2/Vitis_HLS/2021.2/include/ -fhls

wansheg commented 1 year ago

hi, @gabrielrodcanal , I can not replay your error with vitis_hls 2022.2 :

my test case : $ cat a.cpp

include

void dut() {

pragma HLS top

hls::stream dd; }

$ cat run_hls.tcl open_project -reset proj

set_top dut add_files a.cpp

open_solution -reset solution1 set_part virtex7 create_clock -period 4 csynth_design

can you provide the complete case ? what version vitis_hls did you use ?

gabrielrodcanal commented 1 year ago

Hi @wansheg, I am using Vitis 2021.2.

The case is

$ cat stream.cpp
#include <hls_stream.h>

void my_kernel() {
      hls::stream<int> inStream1;
}

You have to process it with Xilinx's clang for it to appear, not with vitis_hls. Note that I am including the stream headers from the Vitis HLS install directory. The full command is: /home/nx08/nx08/s2081362-2/HPE/HLS/hls-build/bin/clang stream.cpp -c -emit-llvm -I/home/nx08/shared/fpga/xilinx/2021.2/Vitis_HLS/2021.2/include/ -fhls

Note: by running your run_hls.tcl script with vitis_hls the kernel is processed fine.

wansheg commented 1 year ago

hi, @gabrielrodcanal , I think your commandline option is wrong , without '-triple=fpga64-xilinx-linux-gnu' option, clang will use host machine as target machine , and cause this strange error .

you should use following command line :

$BLD1/bin/clang -cc1 a.cpp -I/proj/xcohdstaff2/shengw/Rodin1/HEAD/prep/rdi/vitis_hls/common/technology/autopilot -fhls -S -emit-llvm -triple=fpga64-xilinx-linux-gnu -hls-platform-db-name=/proj/xcohdstaff2/shengw/Rodin1/HEAD/prep/rdi/vitis_hls/common/technology/xilinx/common/platform.db -hls-platform-name=zynq_slow with abov command line , the error doesn't appear ( BTW , I used debug building version also )

you can find above command from any hls project's ${your_simple_hls_application}/project/solution/.db/autopilote/autopilote.flow.log file for example , in my local machine , there is one simple project 'top_arg_error' and I have 'autopilote.flow.log' file in top_arg_error/proj/solution1/.autopilot/db]$ vi autopilot.flow.log

there are the following explain in the command line:

  1. you need '-cc1' option , this option means clang run in stanalone mode, some other options can take effect only when '-cc1' option show
  2. -triple =fpga64-xilinx-linux-gnu can assure that clang run for linux platform target
  3. -hls-platform-db-name and -hls-platform-name option are needed when source code in your case contains 'bind_op' or 'bind_storage' pragma , this file define 'platform' feature, and clang assess if the 'bind_op' or 'bind_storage' is valid or not .
  4. don't use "/home/nx08/shared/fpga/xilinx/2021.2/Vitis_HLS/2021.2/include/" , it is used only for 'csim' , it contains a lot non-synthesisable source code

all the above knowledge is from 'autopilote.flow.log' file, this file show clearly the HLS flow .

wansheg commented 1 year ago

@gabrielrodcanal , hi, I suggest you should use latest hls clang to hack , because, before 22.2 , there were a lot changes on clang : such as :

  1. use intrinsic inst for 'interface' pragma instead of 'attribute/metadata'
  2. debug info enhancement for hls pragma
  3. encoding format change for some 'hls pragma '
gabrielrodcanal commented 1 year ago

@wansheg hi, that solved the error, indeed. Thank you!

The latest clang release in the repository is 2021.2. Where can I get 2022.2?