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

Possible bug in generated HLS #38

Open
wyanzhao opened this issue Aug 10, 2022 · 0 comments
Open

Possible bug in generated HLS #38

wyanzhao opened this issue Aug 10, 2022 · 0 comments

Comments

@wyanzhao
Copy link

Hi, I am trying to use Halide-HLS to write a simple HLS program. But I found in some cases, the tool will produce incorrect HLS results.
Here's the given Halide C++ code:

MyPipeline() : input(UInt(64), 1, "input"), A("A"), B("B"), C("C"), hw_output("hw_output")

{

    // define the algorithm

    A = BoundaryConditions::repeat_edge(input);

    Expr constant(((uint64_t)(274877906943)));

    output(x) =  A(x) & constant;

    // define common schedule: tile output

    args.push_back(input);

}

This program supposed to clear the 39th and 40th bit of A. However, in the generated HLS, the code will be:

 for (int _p2_output_s0_x = _21; _p2_output_s0_x < _21 + _137; _p2_output_s0_x++)

  {

   int32_t _138 = _14 + _15;

   int32_t _139 = _138 + -1;

   int32_t _140 = min(_p2_output_s0_x, _139);

   int32_t _141 = _140 - _14;

   int32_t _142 = max(_141, 0);

   uint64_t _143 = ((const uint64_t *)_input)[_142];

   uint64_t _144 = _143 & 63;

   int32_t _145 = _p2_output_s0_x - _21;

   ((uint64_t *)_p2_output)[_145] = _144;

  } // for _p2_output_s0_x

  int32_t _146 = _136 - _132;

  for (int _p2_output_s0_x = _132; _p2_output_s0_x < _132 + _146; _p2_output_s0_x++)

  {

   int32_t _147 = _p2_output_s0_x - _14;

   uint64_t _148 = ((const uint64_t *)_input)[_147];

   uint64_t _149 = _148 & 63;

   int32_t _150 = _p2_output_s0_x - _21;

   ((uint64_t *)_p2_output)[_150] = _149;

  } // for _p2_output_s0_x

Where the constant expr will become 63, instead of the original 274877906943. And this will produce incorrect results.

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

1 participant