CGRA-Flow icon indicating copy to clipboard operation
CGRA-Flow copied to clipboard

Weird RecMII generated by the framework.

Open halfmanli opened this issue 1 year ago • 1 comments

I use the docker image. Here's my code:

int a[10], b[10], c[10];
__attribute__((noinline)) void test() {
    for (int i = 0; i < 10; i++) {
        c[i] = a[i] * b[i];
    }
}

int main() { test(); }

And the output says:

...
==================================
[ResMII: 1]
... number of cycles: 2 ...
==================================
[RecMII: 4]
==================================
...

That's weird because there's no dependency between the i-th iteration and (i+1)-th iteration. Could you please explain the reason why RecMII is 4 here? I really appreciate that.

halfmanli avatar Jun 16 '23 14:06 halfmanli

Hi halfmanli, Thanks for your interest in the toolchain. That's a good question! Though in the C code you might not see dependency in the computation of c = a + b, there is actually dependency in i (i.e., i++ or i = i + 1). And you can see the cycle (length of 4 including phi, add, comp, br) in the generated DFG. If your purpose is to decrease the RecMII, the mapper can do DFG node fusion to fuse at most two nodes together. You can write up your own code to replace a set of nodes with a single new node. In this way, the RecMII can be lowered. But note that the new node needs to be executed by a functional unit in the hardware, which means we also need to provide a special functional unit in the CGRA RTL to enable single cycle execution of the fused operations.

tancheng avatar Jun 16 '23 17:06 tancheng