Closed michael-platzer closed 2 years ago
Thank you for checking this out! Very bad :-( Would it be possible to do the same test with the Chisel 2 version of Patmos. So we can see if this is a regression due to the port from Chisel 2 to 3.
Commit f50e132, which seems to predate most of the Chisel 3 work, is not affected. Here the function fib
is only fetched once, and the main function is not fetched again when returning to it.
Thanks for checking this out! This actually gives some hope, as the method cache is not broken (in general), but during the port there was a bug introduced. I guess it has to do with the tag memory and/or a valid item.
Thank you very much for this super detailed description of how to reproduce the issue! This is an excellent description. I am trying to reproduce this on my side to get started with debugging. However, I am running into trouble with the Scala compiler (Wolfgang did some tricks to use the Scala compiler at runtime). Did you have the same issue and could you solve it? This is the error I get:
[init] error: error while loading Object, Missing dependency 'object scala in compiler mirror', required by /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/rt.jar(java/lang/Object.class)
Failed to initialize compiler: object scala in compiler mirror not found.
** Note that as of 2.8 scala does not assume use of the java classpath.
** For the old behavior pass -usejavacp to scala, or if using a Settings
** object programmatically, settings.usejavacp.value = true.
[error] (run-main-0) scala.reflect.internal.MissingRequirementError: object scala in compiler mirror not found.
[error] scala.reflect.internal.MissingRequirementError: object scala in compiler mirror not found.
Never mind, I found a later version that does just a single cache load and does not depend on the compiler at runtime. However, it is irritating that I cannot build an older version of Patmos. I tried two different Ubuntu versions (16.04 and 20.04), no chance.
I also had issues when trying to build older versions but I happened to have a build of commit f50e132 on another computer.
This is still good (Chisel 2) and compiles: 86c1c4503de
This has the error: 8241f0ad6f
Inbetween are commits that don't compile.
If I interpret the OCP port signals correctly, it appears that Patmos is filling the method cache on every call and return instruction, regardless of whether the fetched method is already cached.
Steps to observe this behavior:
test.c
:int fib(int n) { if (n < 2) { return n; } return fib(n-1) + fib(n-2); }
int main() { volatile _SPM int led = (volatile _SPM int ) 0xF0090000; led = 1; int res = fib(3); led = 0; return 0; }
patmos-clang test.c patemu -v a.out
patmos-llvm-objdump -d a.out > dump.S