-
Notifications
You must be signed in to change notification settings - Fork 8
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
Cannot pass views to functions #189
Comments
To expand on my suggestion, it was inspired by what the actual hardware would do: we'd generate a small hardware gadget at the point where the |
This example passes synthesis with the attached report: #define I 4
#define J 4
#define K 4
int add_slice(int* a, int* b) {
int x = 0;
for (int i = 0; i < 2; i++) {
x += a[i] + b[i];
}
return x;
}
void test(int m1[8], int m2[8], int res[4]) {
for (int i = 0; i < 4; i++) {
res[i] = add_slice(&m1[2 * i], &m2[2 * i]);
}
} Command:
Report: sds_test.txt |
Would you mind explaining what's the expected hardware here? And why not simply pass the view array itself? |
Since functions have inlining semantics, there should be no additional hardware. We might choose to have a small gadget as adrian mentioned above but that's a cost associated with views, not functions. If Fuse was doing function inlining automatically, it would copy the function body into call and replace the parameters with the view. Once we have that, the compiler can rewrite view accesses as normal.
There is no "views array". Accesses on views are rewritten to accesses on the underlying array. |
I don't think the first suggestion of using
would get compiled to:
Here, A naive solution to the problem would be to start flattening arrays again, but that would conflict with #175.... |
Aha, indeed—that would be a problem! And flattening arrays wouldn't really fix it either; a 2x2 window of a larger two-dimensional array won't be continuous in the flattened representation. Fundamentally, it seems like this is a situation where our language is more expressive than the HLS tools we're using as a backend—which means anything we do here will necessarily be a hack. For example, we could try generating little array-lookup functions to encapsulate the index arithmetic (and to represent the hardware gadget that implements the view), but it seems dicey that Vivado would do the right thing with that… |
Views implementation doesn't allow us to pass views into arrays. The core issue is that for something like:
the codegen phase needs to rewrite it to something of the form:
it's unclear what Vivado will do if we pass it something of this form.
@sampsyo suggested doing one of two things:
def
s.Before committing to a strategy, we need to try both of them on Vivado and see what happens.
The text was updated successfully, but these errors were encountered: