Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vitis deletes LLVM code? #7

Closed
SerenaC94 opened this issue Apr 5, 2022 · 3 comments
Closed

Vitis deletes LLVM code? #7

SerenaC94 opened this issue Apr 5, 2022 · 3 comments

Comments

@SerenaC94
Copy link

Hi,

I am observing unexpected behavior when passing an LLVM IR to Vitis. The synthesis process arrives to the end with no errors, but in the reports everything is zero (0 cycles, 0 DSP, etc). So I traced back in the log to the first pass that is applied to the custom LLVM input, and found this:

INFO: [HLS 200-1022] Running custom LLVM hook 'HLS_HOOKS::opt'
//// get_config commands
INFO-FLOW: Doing LTO.
Execute       ap_eval exec -ignorestderr /opt/Xilinx/Vitis_HLS/2021.1/lnx64/tools/clang-3.9-csynth/bin/clang 
//// rest of the options
-o proj/solution1/.autopilot/db/a.g.lto.bc

Then I disassembled a.g.lto.bc, and it looks like all the input code has disappeared (it was >1800 lines in the LLVM IR):

; ModuleID = 'a.g.lto.bc'
source_filename = "a.g.lto.bc"
target datalayout = "e-m:e-i64:64-i128:128-i256:256-i512:512-i1024:1024-i2048:2048-i4096:4096-n8:16:32:64-S128-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
target triple = "fpga64-xilinx-none"

@0 = private unnamed_addr constant [8 x i8] c"ap_auto\00"
@1 = private unnamed_addr constant [1 x i8] zeroinitializer
@2 = private unnamed_addr constant [15 x i8] c"atax_16_kernel\00"

define void @atax_16_kernel(i32* noalias nocapture %arg_2, i32* noalias nocapture %arg_3, i32* noalias %arg_4, i32* noalias nocapture %arg_5) {
bb_0:
  call void (...) @_ssdm_op_SpecTopModule([15 x i8]* @2)
  call void (...) @_ssdm_op_SpecBitsMap(i32* %arg_2), !map !2
  call void (...) @_ssdm_op_SpecInterface(i32* %arg_2, [8 x i8]* @0, i32 0, i32 0, [1 x i8]* @1, i32 0, i32 0, [1 x i8]* @1, [1 x i8]* @1, [1 x i8]* @1, i32 0, i32 0, i32 0, i32 0, [1 x i8]* @1, [1 x i8]* @1)
  call void (...) @_ssdm_op_SpecBitsMap(i32* %arg_3), !map !2
  call void (...) @_ssdm_op_SpecInterface(i32* %arg_3, [8 x i8]* @0, i32 0, i32 0, [1 x i8]* @1, i32 0, i32 0, [1 x i8]* @1, [1 x i8]* @1, [1 x i8]* @1, i32 0, i32 0, i32 0, i32 0, [1 x i8]* @1, [1 x i8]* @1)
  call void (...) @_ssdm_op_SpecBitsMap(i32* %arg_4), !map !2
  call void (...) @_ssdm_op_SpecInterface(i32* %arg_4, [8 x i8]* @0, i32 0, i32 0, [1 x i8]* @1, i32 0, i32 0, [1 x i8]* @1, [1 x i8]* @1, [1 x i8]* @1, i32 0, i32 0, i32 0, i32 0, [1 x i8]* @1, [1 x i8]* @1)
  call void (...) @_ssdm_op_SpecBitsMap(i32* %arg_5), !map !2
  call void (...) @_ssdm_op_SpecInterface(i32* %arg_5, [8 x i8]* @0, i32 0, i32 0, [1 x i8]* @1, i32 0, i32 0, [1 x i8]* @1, [1 x i8]* @1, [1 x i8]* @1, i32 0, i32 0, i32 0, i32 0, [1 x i8]* @1, [1 x i8]* @1)
  store i32 0, i32* %arg_3, align 4
  store i32 0, i32* %arg_2, align 4
  ret void
}

declare void @_ssdm_op_SpecBitsMap(...)

declare void @_ssdm_op_SpecInterface(...)

declare void @_ssdm_op_SpecTopModule(...)

!blackbox_cfg = !{!0}
!llvm.module.flags = !{!1}

!0 = !{}
!1 = !{i32 7, !"reflow.full.lowering", i32 1}
!2 = !{!0}

I am attaching all the code needed to reproduce the issue in atax_issue.zip. I have no clues as to what is happening here, any help is appreciated.

@SerenaC94
Copy link
Author

I am using Vitis HLS 2021.1 (both the frontend from this repo and the backend) on Ubuntu 20.04. This error happens on various different input codes, and what they have in common is that I unrolled some loops in the LLVM IR before passing it to Vitis.

@yu810226
Copy link

yu810226 commented Apr 6, 2022

Hello @SerenaC94 , it's probably auto optimized out depends on the interface setting. I'll suggest to try with assigning array compatible interface in your IR to see if it brings your expected IR in mind.

@SerenaC94
Copy link
Author

I think I have solved the issue by making sure that instead of pointers I can see arrays in the input IR. So moving from something like this

define void @atax_16_kernel(float* %0, float* %1, float* %2, float* %3)

to something like this

define void @atax_16_kernel([16 x float]* %arg_5, [16 x float]* %arg_6, [16 x [16 x float]]* %arg_7, [16 x float]* %arg_8)

Thanks for the pointer!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants