scalehls icon indicating copy to clipboard operation
scalehls copied to clipboard

interface name changed after scalehls?

Open eeriecl opened this issue 4 years ago • 5 comments

image

The left is original code, and the port name C,A,B is translated to v0,v1,v2 what's the purpose?

eeriecl avatar Dec 14 '21 14:12 eeriecl

For now, we don't have a mechanism to represent the "name" of C variables in the IR. One possible approach is retaining them as string attributes attached to function operations.

hanchenye avatar Dec 14 '21 16:12 hanchenye

" retaining them as string attributes" how-to? is there an example?

eeriecl avatar Dec 14 '21 16:12 eeriecl

For example, see the following IR:

func @test_gemm(%arg0: f32 {hlscpp.var_name = "alpha"}, %arg1: f32 {hlscpp.var_name = "beta"}, %arg2: memref<32x32xf32> {hlscpp.var_name = "A"}, %arg3: memref<32x32xf32> {hlscpp.var_name = "B"}, %arg4: memref<32x32xf32> {hlscpp.var_name = "C"}) {
  affine.for %arg5 = 0 to 32 {
... ...
  }
  return
}

This feature requires at least two PRs:

  1. In mlir-clang during parsing the C program, store the variable name as an attribute attached to the defining operation of the variable.
  2. In emit-hlscpp, support to parse the "var_name" attribute and emit it as the name of an variable rather than a auto-generated name like v0, v1, v2, etc.

hanchenye avatar Dec 14 '21 16:12 hanchenye

so complex for ordinary developer :- ( it will be hard for people to use it

Oxygen-Chu avatar Dec 15 '21 07:12 Oxygen-Chu

@Oxygen-Chu MLIR itself is complex, but powerful 😄 Based on my understanding, the C/C++ emission is just for the integration with downstream tools, such as Vivado HLS. From the IR point of view, we have the "mlir::Value" structure to represent and manipulate variables in the program -- which can support any desired program transformation and analysis for us.

hanchenye avatar Dec 15 '21 09:12 hanchenye