circt / arc-tests

A collection of tests and benchmarks for the Arc simulation backend of CIRCT
24 stars 2 forks source link

how dhrystone maked? #6

Closed albertethon closed 4 months ago

albertethon commented 4 months ago

I compiled Dhrystone benchmark using my own RISC-V toolchain. However, I faced an issue when running Boom with Dhrystone.

Output is confusing

When I used the Dhrystone version from the Git repository and executed it with Boom, I observed the following behavior:

old_dhrystone

On the other hand, after compiling Dhrystone and running it with Boom, I encountered the following behavior: new_arctest The output of boom seems wrong.

Also I encountered some warnings when compiling dhrystone:

riscv64-unknown-elf-gcc -I./common -I./dhrystone -DPREALLOCATE=1 -mcmodel=medany -static -std=gnu99 -O2 -ffast-math -fno-common -fno-builtin-printf -fno-tree-loop-distribute-patterns -march=rv64gcv -mabi=lp64d -o dhrystone.riscv dhrystone/dhrystone.c dhrystone/dhrystone_main.c common/syscalls.c common/crt.S -static -nostdlib -nostartfiles -lm -lgcc -T ./common/test.ld
dhrystone/dhrystone.c:20:1: warning: return type defaults to 'int' [-Wimplicit-int]
   20 | Proc_6 (Enum_Val_Par, Enum_Ref_Par)
      | ^~~~~~
dhrystone/dhrystone.c: In function 'Proc_6':
dhrystone/dhrystone.c:29:9: warning: implicit declaration of function 'Func_3' [-Wimplicit-function-declaration]
   29 |   if (! Func_3 (Enum_Val_Par))
      |         ^~~~~~
dhrystone/dhrystone.c: At top level:
dhrystone/dhrystone.c:54:1: warning: return type defaults to 'int' [-Wimplicit-int]
   54 | Proc_7 (Int_1_Par_Val, Int_2_Par_Val, Int_Par_Ref)
      | ^~~~~~
dhrystone/dhrystone.c:74:1: warning: return type defaults to 'int' [-Wimplicit-int]
   74 | Proc_8 (Arr_1_Par_Ref, Arr_2_Par_Ref, Int_1_Par_Val, Int_2_Par_Val)
      | ^~~~~~
dhrystone/dhrystone_main.c: In function 'main':
dhrystone/dhrystone_main.c:120:7: warning: implicit declaration of function 'Proc_5' [-Wimplicit-function-declaration]
  120 |       Proc_5();
      |       ^~~~~~
dhrystone/dhrystone_main.c:121:7: warning: implicit declaration of function 'Proc_4' [-Wimplicit-function-declaration]
  121 |       Proc_4();
      |       ^~~~~~
dhrystone/dhrystone_main.c:127:21: warning: implicit declaration of function 'Func_2'; did you mean 'Func_1'? [-Wimplicit-function-declaration]
  127 |       Bool_Glob = ! Func_2 (Str_1_Loc, Str_2_Loc);
      |                     ^~~~~~
      |                     Func_1
dhrystone/dhrystone_main.c:133:9: warning: implicit declaration of function 'Proc_7' [-Wimplicit-function-declaration]
  133 |         Proc_7 (Int_1_Loc, Int_2_Loc, &Int_3_Loc);
      |         ^~~~~~
dhrystone/dhrystone_main.c:138:7: warning: implicit declaration of function 'Proc_8' [-Wimplicit-function-declaration]
  138 |       Proc_8 (Arr_1_Glob, Arr_2_Glob, Int_1_Loc, Int_3_Loc);
      |       ^~~~~~
dhrystone/dhrystone_main.c:140:7: warning: implicit declaration of function 'Proc_1' [-Wimplicit-function-declaration]
  140 |       Proc_1 (Ptr_Glob);
      |       ^~~~~~
dhrystone/dhrystone_main.c:147:11: warning: implicit declaration of function 'Proc_6' [-Wimplicit-function-declaration]
  147 |           Proc_6 (Ident_1, &Enum_Loc);
      |           ^~~~~~
dhrystone/dhrystone_main.c:158:7: warning: implicit declaration of function 'Proc_2' [-Wimplicit-function-declaration]
  158 |       Proc_2 (&Int_1_Loc);
      |       ^~~~~~
dhrystone/dhrystone_main.c: At top level:
dhrystone/dhrystone_main.c:242:1: warning: return type defaults to 'int' [-Wimplicit-int]
  242 | Proc_1 (Ptr_Val_Par)
      | ^~~~~~
dhrystone/dhrystone_main.c: In function 'Proc_1':
dhrystone/dhrystone_main.c:258:3: warning: implicit declaration of function 'Proc_3'; did you mean 'Proc_1'? [-Wimplicit-function-declaration]
  258 |   Proc_3 (&Next_Record->Ptr_Comp);
      |   ^~~~~~
      |   Proc_1
dhrystone/dhrystone_main.c: At top level:
dhrystone/dhrystone_main.c:276:1: warning: return type defaults to 'int' [-Wimplicit-int]
  276 | Proc_2 (Int_Par_Ref)
      | ^~~~~~
dhrystone/dhrystone_main.c:299:1: warning: return type defaults to 'int' [-Wimplicit-int]
  299 | Proc_3 (Ptr_Ref_Par)
      | ^~~~~~
dhrystone/dhrystone_main.c:314:1: warning: return type defaults to 'int' [-Wimplicit-int]
  314 | Proc_4 () /* without parameters */
      | ^~~~~~
dhrystone/dhrystone_main.c:326:1: warning: return type defaults to 'int' [-Wimplicit-int]
  326 | Proc_5 () /* without parameters */
      | ^~~~~~
common/crt.S: Assembler messages:
common/crt.S:228: warning: value 0x100 truncated to 0x0
/home/wissy/Downloads/riscv/bin/../lib/gcc/riscv64-unknown-elf/13.2.0/../../../../riscv64-unknown-elf/bin/ld: warning: dhrystone.riscv has a LOAD segment with RWX permissions
riscv64-unknown-elf-objdump --disassemble-all --disassemble-zeroes --section=.tohost --section=.text --section=.text.startup --section=.text.init --section=.data dhrystone.riscv > dhrystone.riscv.dump

Configure Information

fabianschuiki commented 4 months ago

I think @maerhart did the dhrystone build and setup here. Martin, do you have any hunch why the Dhrystone benchmark prints corrupted text on Boom? I think you had to make a few changes to Dhrystone since we don't support the full RISC-V fesvr setup that dhrystone used.

maerhart commented 4 months ago

Thanks @albertethon for reporting this issue!

Yes, I made a few changes to benchmarks/common/syscalls.c in the syscall function to write the data printed in Dhrystone to a memory-mapped region we can access in the testbench. The testbench just starts printing char by char from the tohost_data buffer declared in benchmarks/common/crt.S and stops at the first \0 char or when the end of the buffer is reached. At some point, we should replace this hack with a proper implementation.

I've pushed a fix to main (551c5326f99fa0540ca51367bb61a4471785936c). Please let me know if it works for you now.

albertethon commented 4 months ago

Thanks, it worked