UCLA-VAST / tapa

TAPA is a dataflow HLS framework that features fast compilation, expressive programming model and generates high-frequency FPGA accelerators.
https://tapa.rtfd.io
MIT License
144 stars 27 forks source link

Why does introducing "apt_int.h" cause an error during co-simulation? #155

Open fan-sun opened 3 months ago

fan-sun commented 3 months ago

When compiling the VecAdd project, I encountered an issue with TAPA. I was testing with the VecAdd example provided by TAPA, and I found that when I added #include in vadd.cpp, TAPA couldn't compile properly. However, everything went back to normal once I removed #include . Why is that?

sun@seu-ubuntu:~/FPGA/tapa/apps/vadd$ sh ./run_tapa.sh I0407 17:09:50.171 tapa.util:184] logging level set to INFO I0407 17:09:50.171 tapa.tapac:400] Executing all steps of tapac W0407 17:09:50.171 tapa.tapac:422] The floorplan option is automatically enabled because a floorplan output file is provided I0407 17:09:50.171 tapa.tapac:514] running translated command: tapa --work-dir=run analyze --input=vadd.cpp --top=VecAdd synth --part-num=xcu250-figd2104-2L-e --clock-period=3.33 optimize-floorplan --connectivity=link_config.ini link --floorplan-output=run/VecAdd_floorplan.tcl pack --output=run/VecAdd.xo --bitstream-script=run/VecAdd_generate_bitstream.sh I0407 17:09:50.172 tapa.util:184] logging level set to INFO I0407 17:09:50.172 tapa.tapa:54] tapa version: 0.0.20240301.1 I0407 17:09:50.172 tapa.tapa:58] Python recursion limit set to 3000 I0407 17:09:50.250 tapa.steps.analyze:151] added vendor include path /home/sun/Xilinx/Vitis_HLS/2023.1/include I0407 17:09:50.251 tapa.steps.analyze:248] Running tapacc command: /usr/local/bin/tapacc run/flatten/flatten-dfc95920-vadd.cpp -top VecAdd -- -std=c++17 -I /home/sun/.local/lib/python3.10/site-packages/tapa/../../../src -isystem /home/sun/Xilinx/Vitis_HLS/2023.1/include -stdlib=libc++ -isystem /usr/lib/llvm-17/include/c++/v1/ -isystem /usr/include/clang/17/include/ -isystem /usr/lib/clang/17/include/ /home/sun/FPGA/tapa/apps/vadd/run/flatten/flatten-dfc95920-vadd.cpp:141:30: warning: unknown attribute 'bitwidth' ignored [-Wunknown-attributes] 141 | typedef int attribute((bitwidth(_AP_N))) DataType; | ^~~~~~~ /home/sun/FPGA/tapa/apps/vadd/run/flatten/flatten-dfc95920-vadd.cpp:142:24: warning: unknown attribute 'bitwidth' ignored [-Wunknown-attributes] 142 | int V attribute((bitwidth(_AP_N))); | ^~~~~~~ /home/sun/FPGA/tapa/apps/vadd/run/flatten/flatten-dfc95920-vadd.cpp:144:98: warning: unknown attribute 'bitwidth' ignored [-Wunknown-attributes] 144 | inline attribute((always_inline)) ssdm_int<_AP_N, true>(int o attribute((bitwidth(_AP_N)))):V(o){}; | ^~~~~~~ /home/sun/FPGA/tapa/apps/vadd/run/flatten/flatten-dfc95920-vadd.cpp:148:35: warning: unknown attribute 'bitwidth' ignored [-Wunknown-attributes] 148 | typedef unsigned attribute((bitwidth(_AP_N))) DataType; | ^~~~~~~ /home/sun/FPGA/tapa/apps/vadd/run/flatten/flatten-dfc95920-vadd.cpp:149:29: warning: unknown attribute 'bitwidth' ignored [-Wunknown-attributes] 149 | unsigned V attribute((bitwidth(_AP_N))); | ^~~~~~~ /home/sun/FPGA/tapa/apps/vadd/run/flatten/flatten-dfc95920-vadd.cpp:151:104: warning: unknown attribute 'bitwidth' ignored [-Wunknown-attributes] 151 | inline attribute((always_inline)) ssdm_int<_AP_N, false>(unsigned o attribute((bitwidth(_AP_N)))):V(o){}; | ^~~~~~~ /home/sun/FPGA/tapa/apps/vadd/run/flatten/flatten-dfc95920-vadd.cpp:224:73: error: parameters cannot have fp16 type; did you forget * ? 224 | inline attribute((always_inline)) unsigned short halfToRawBits(half pf) { | ^ /home/sun/FPGA/tapa/apps/vadd/run/flatten/flatten-dfc95920-vadd.cpp:251:44: error: function return value cannot have fp16 type; did you forget * ? 251 | inline attribute__((always_inline)) half rawBitsToHalf(unsigned short pi) { | ^ /home/sun/FPGA/tapa/apps/vadd/run/flatten/flatten-dfc95920-vadd.cpp:423:83: error: parameters cannot have fp16 type; did you forget ? 423 | inline attribute((always_inline)) attribute((nodebug)) ap_int_base(half op) { | ^ /home/sun/FPGA/tapa/apps/vadd/run/flatten/flatten-dfc95920-vadd.cpp:672:71: error: function return value cannot have __fp16 type; did you forget ? 672 | inline attribute((always_inline)) attribute((nodebug)) half to_half() const { return (float)(Base::V); } | ^ /home/sun/FPGA/tapa/apps/vadd/run/flatten/flatten-dfc95920-vadd.cpp:432:76: error: use of undeclared identifier 'builtin_bit_select'; did you mean 'builtin_rotateleft8'? 432 | bool is_neg = ({ typeof(reg.V) Val2 = reg.V; bool Result = builtin_bit_select((void*)(&Val2), BITS - 1); Result; }); | ^~~~~~~~ | builtin_rotateleft8 /home/sun/FPGA/tapa/apps/vadd/run/flatten/flatten-dfc95920-vadd.cpp:432:76: note: 'builtin_rotateleft8' declared here /home/sun/FPGA/tapa/apps/vadd/run/flatten/flatten-dfc95920-vadd.cpp:432:97: error: cannot initialize a parameter of type 'unsigned char' with an rvalue of type 'void *' 432 | bool is_neg = ({ typeof(reg.V) Val2 = reg.V; bool Result = builtin_bit_select((void)(&Val2), BITS - 1); Result; }); | ^~~~~~ /home/sun/FPGA/tapa/apps/vadd/run/flatten/flatten-dfc95920-vadd.cpp:434:125: error: use of undeclared identifier 'builtin_bit_part_select' 434 | exp.V = ({ typename _ap_type::remove_const<typeof(reg.V)>::type Result = 0; typeof(reg.V) Val2 = reg.V; builtin_bit_part_select((void)(&Result), (void)(&Val2), 23, BITS - 2); Result; }); | ^ /home/sun/FPGA/tapa/apps/vadd/run/flatten/flatten-dfc95920-vadd.cpp:437:125: error: use of undeclared identifier 'builtin_bit_part_select' 437 | man.V = ({ typename _ap_type::remove_const<typeof(reg.V)>::type Result = 0; typeof(reg.V) Val2 = reg.V; builtin_bit_part_select((void)(&Result), (void)(&Val2), 0, 23 - 1); Result; }); | ^ /home/sun/FPGA/tapa/apps/vadd/run/flatten/flatten-dfc95920-vadd.cpp:441:156: error: use of undeclared identifier 'builtin_bit_part_set' 441 | man.V = ({ typename _ap_type::remove_const<typeof(man.V)>::type Result = 0; typeof(man.V) Val2 = man.V; typeof(1) Repl2 = !!1; builtin_bit_part_set((void)(&Result), (void)(&Val2), (void)(&Repl2), 23, 23); Result; }); | ^ /home/sun/FPGA/tapa/apps/vadd/run/flatten/flatten-dfc95920-vadd.cpp:474:76: error: use of undeclared identifier 'builtin_bit_select'; did you mean 'builtin_rotateleft8'? 474 | bool is_neg = ({ typeof(reg.V) Val2 = reg.V; bool Result = builtin_bit_select((void*)(&Val2), BITS - 1); Result; }); | ^~~~~~~~ | builtin_rotateleft8 /home/sun/FPGA/tapa/apps/vadd/run/flatten/flatten-dfc95920-vadd.cpp:432:76: note: 'builtin_rotateleft8' declared here 432 | bool is_neg = ({ typeof(reg.V) Val2 = reg.V; bool Result = builtin_bit_select((void)(&Val2), BITS - 1); Result; }); | ^ /home/sun/FPGA/tapa/apps/vadd/run/flatten/flatten-dfc95920-vadd.cpp:474:97: error: cannot initialize a parameter of type 'unsigned char' with an rvalue of type 'void ' 474 | bool is_neg = ({ typeof(reg.V) Val2 = reg.V; bool Result = builtin_bit_select((void*)(&Val2), BITS - 1); Result; }); | ^~~~~~ /home/sun/FPGA/tapa/apps/vadd/run/flatten/flatten-dfc95920-vadd.cpp:476:125: error: use of undeclared identifier 'builtin_bit_part_select' 476 | exp.V = ({ typename _ap_type::remove_const<typeof(reg.V)>::type Result = 0; typeof(reg.V) Val2 = reg.V; builtin_bit_part_select((void)(&Result), (void)(&Val2), 52, BITS - 2); Result; }); | ^ /home/sun/FPGA/tapa/apps/vadd/run/flatten/flatten-dfc95920-vadd.cpp:479:125: error: use of undeclared identifier 'builtin_bit_part_select' 479 | man.V = ({ typename _ap_type::remove_const<typeof(reg.V)>::type Result = 0; typeof(reg.V) Val2 = reg.V; builtin_bit_part_select((void*)(&Result), (void*)(&Val2), 0, 52 - 1); Result; }); | ^ /home/sun/FPGA/tapa/apps/vadd/run/flatten/flatten-dfc95920-vadd.cpp:483:156: error: use of undeclared identifier 'builtin_bit_part_set' 483 | man.V = ({ typename _ap_type::remove_const<typeof(man.V)>::type Result = 0; typeof(man.V) Val2 = man.V; typeof(1) Repl2 = !!1; builtin_bit_part_set((void)(&Result), (void)(&Val2), (void*)(&Repl2), 52, 52); Result; }); | ^ /home/sun/FPGA/tapa/apps/vadd/run/flatten/flatten-dfc95920-vadd.cpp:692:70: error: use of undeclared identifier 'builtin_bit_select'; did you mean 'builtin_rotateleft8'? 692 | ({ typeof(Base::V) Val2 = Base::V; bool Result = builtin_bit_select((void)(&Val2), _AP_W - 1); Result; })) | ^~~~~~~~ | __builtin_rotateleft8 /home/sun/FPGA/tapa/apps/vadd/run/flatten/flatten-dfc95920-vadd.cpp:432:76: note: 'builtin_rotateleft8' declared here 432 | bool is_neg = ({ typeof(reg.V) Val2 = reg.V; bool Result = builtin_bit_select((void)(&Val2), BITS - 1); Result; }); | ^ /home/sun/FPGA/tapa/apps/vadd/run/flatten/flatten-dfc95920-vadd.cpp:692:91: error: cannot initialize a parameter of type 'unsigned char' with an rvalue of type 'void ' 692 | ({ typeof(Base::V) Val2 = Base::V; bool Result = __builtin_bit_select((void)(&Val2), _AP_W - 1); Result; })) | ^~~~~~ /home/sun/FPGA/tapa/apps/vadd/run/flatten/flatten-dfc95920-vadd.cpp:700:164: error: use of undeclared identifier 'builtin_bit_part_set' 700 | Base::V = ({ typename _ap_type::remove_const<typeof(Base::V)>::type Result = 0; typeof(Base::V) Val2 = Base::V; typeof(0) Repl2 = !!0; builtin_bit_part_set((void)(&Result), (void)(&Val2), (void)(&Repl2), i, i); Result; }); | ^ /home/sun/FPGA/tapa/apps/vadd/run/flatten/flatten-dfc95920-vadd.cpp:705:77: error: use of undeclared identifier 'builtin_bit_select'; did you mean 'builtin_rotateleft8'? 705 | bool val = ({ typeof(Base::V) Val2 = Base::V; bool Result = __builtin_bit_select((void)(&Val2), i); Result; }); | ^~~~~~~~ | __builtin_rotateleft8 /home/sun/FPGA/tapa/apps/vadd/run/flatten/flatten-dfc95920-vadd.cpp:432:76: note: 'builtin_rotateleft8' declared here 432 | bool is_neg = ({ typeof(reg.V) Val2 = reg.V; bool Result = builtin_bit_select((void)(&Val2), BITS - 1); Result; }); | ^ /home/sun/FPGA/tapa/apps/vadd/run/flatten/flatten-dfc95920-vadd.cpp:705:98: error: cannot initialize a parameter of type 'unsigned char' with an rvalue of type 'void ' 705 | bool val = ({ typeof(Base::V) Val2 = Base::V; bool Result = builtin_bit_select((void*)(&Val2), i); Result__; }); | ^~~~~~ fatal error: too many errors emitted, stopping now [-ferror-limit=] 6 warnings and 20 errors generated. Error while processing /home/sun/FPGA/tapa/apps/vadd/run/flatten/flatten-dfc95920-vadd.cpp. E0407 17:09:51.774 tapa.steps.analyze:179] command ('/usr/local/bin/tapacc', 'run/flatten/flatten-dfc95920-vadd.cpp', '-top', 'VecAdd', '--', '-std=c++17', '-I', '/home/sun/.local/lib/python3.10/site-packages/tapa/../../../src', '-isystem', '/home/sun/Xilinx/Vitis_HLS/2023.1/include', '-stdlib=libc++', '-isystem', '/usr/lib/llvm-17/include/c++/v1/', '-isystem', '/usr/include/clang/17/include/', '-isystem', '/usr/lib/clang/17/include/') failed with exit code 1

fan-sun commented 3 months ago

The installation method I used is to install using the following command: "curl -L https://git.io/JnERa | bash"

fan-sun commented 3 months ago

I attempted to install TAPA from source. For the vadd project that did not use "#include", it was able to compile successfully. However, once "#include" was added, the vadd project would throw an error with the same error message. I tried executing "sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)\" 17 all", but the error still persists.

fan-sun commented 3 months ago

I tried compiling other examples provided by the official documentation. Any that include "#include" result in an error, while those that do not include "#include" compile successfully.

Blaok commented 3 months ago

@fan-sun Which OS did you use?

fan-sun commented 3 months ago

@fan-sun Which OS did you use?

Ubuntu 22.04.4 LTS

Blaok commented 3 months ago

I wasn't able to reproduce the same issue under Ubuntu 22.04 and Vitis 2023.1. Would you like to try the docker based workflow: https://github.com/UCLA-VAST/tapa/tree/release/docker?

fan-sun commented 3 months ago

I wasn't able to reproduce the same issue under Ubuntu 22.04 and Vitis 2023.1. Would you like to try the docker based workflow: https://github.com/UCLA-VAST/tapa/tree/release/docker?

OK, I'll give it a try. Also, can you remotely check what exactly is wrong with my issue?