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

Only specific coding style can pass compilation #12

Open
chhzh123 opened this issue Feb 5, 2022 · 4 comments
Open

Only specific coding style can pass compilation #12

chhzh123 opened this issue Feb 5, 2022 · 4 comments

Comments

@chhzh123
Copy link

chhzh123 commented Feb 5, 2022

Hi,

I just installed AutoSA and tried to make some code generation for systolic arrays. It seems AutoSA has a very strict coding style. I wonder why in the following GEMM example. Only the second can work, but the first way cannot.

#include <algorithm>
#include <ap_axi_sdata.h>
#include <ap_fixed.h>
#include <ap_int.h>
#include <hls_math.h>
#include <hls_stream.h>
#include <math.h>
#include <stdint.h>
using namespace std;
void Stage_C(
  int32_t A0[32][32],
  int32_t B1[32][32],
  int32_t C2[32][32]
) {	// L13
#pragma scop
  l_i3: for (int i3 = 0; i3 < 32; i3 += 1) {	// L14
    l_j4: for (int j4 = 0; j4 < 32; j4 += 1) {	// L15
      l_k6: for (int k6 = 0; k6 < 32; k6 += 1) {	// L20
        // 1st
        int32_t v7 = A0[i3][k6];	// L21
        int32_t v8 = B1[k6][j4];	// L22
        C2[i3][j4] += v7 * v8;	// L26
        // 2nd
        // C2[i3][j4] += A0[i3][k6] * B1[k6][j4];	// L26
      }
    }
  }
#pragma endscop
}

If I use the first way, the compiler gives the following error.

$./autosa test.cpp -I"$(dirname "$(which vivado_hls)")"/../include --config=./autosa_config/autosa_config.json --target=autosa_hls_c --output-dir=./autosa.tmp/output --sa-sizes="{kernel[]->space_time[3];}"
lt-autosa: /work/shared/common/usr/local/include/clang/AST/Decl.h:276: llvm::StringRef clang::NamedDecl::getName() const: Assertion `Name.isIdentifier() && "Name is not a simple identifier"' failed.
[AutoSA] Error: Exit abnormally!

Is this a limitation of AutoSA or are there something wrong with my code? Thanks!

@whbldhwj
Copy link
Collaborator

whbldhwj commented Feb 5, 2022

Hi,

Right now AutoSA did has a rigid requirement for the coding style. I don't think local variable definition is allowed. That should be the reason that caused the error you encountered.

@chhzh123
Copy link
Author

chhzh123 commented Feb 6, 2022

Okay. Thanks for your reply! Do you have plans to fix this limitation?

@whbldhwj
Copy link
Collaborator

whbldhwj commented Feb 6, 2022

It will take some time, probably will not be fixed in a short time. You probably could consider doing some quick fix on your generated code (e.g., replace v7 and v8 with array references) to get around this limitation?

@chhzh123
Copy link
Author

chhzh123 commented Feb 6, 2022

Yeah, since we are working on MLIR which has a strict SSA format, plugging v7 and v8 into the multiplication is impossible at the IR level. Actually, this piece of code has already been simplified manually, the original generated code also introduces an intermediate summation variable for C2, which I think is even harder to analyze.

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