westerndigitalcorporation / swerv-ISS

Western Digital’s Open Source RISC-V SweRV Instruction Set Simulator
200 stars 41 forks source link

Turning on --log changes instruction count #3

Closed scottj97 closed 5 years ago

scottj97 commented 5 years ago

I'm running test2.c from the README. When I add --log for an instruction trace, the count of retired instructions increases by 1.

I can't imagine any good reason why turning on tracing should change the number of retired instructions. It should be running the exact same thing in either case.

sjohnson@tyrone:/d1/proj/sjohnson/swerv-ISS$ ./whisper test2
Successful stop: write to to-host
Retired 27 instructions in 0.00s  177631 inst/s
sjohnson@tyrone:/d1/proj/sjohnson/swerv-ISS$ ./whisper --log test2
#1 0 000100a8     1141 r 02         fffffff0  c.addi   x2, -0x10
#2 0 000100aa     c606 m fffffffc   00000000  c.swsp   x1, 0xc
#3 0 000100ac     c422 m fffffff8   00000000  c.swsp   x8, 0x8
#4 0 000100ae     0800 r 08         00000000  c.addi4spn x8, 0x4
#5 0 000100b0     4581 r 0b         00000000  c.li     x11, 0x0
#6 0 000100b2     4501 r 0a         00000000  c.li     x10, 0x0
#7 0 000100b4     37c1 r 01         000100b6  c.jal    . - 0x40
#8 0 00010074     7179 r 02         ffffffc0  c.addi16sp -0x3
#9 0 00010076     d622 m ffffffec   00000000  c.swsp   x8, 0x2c
#10 0 00010078     1800 r 08         fffffff0  c.addi4spn x8, 0xc
#11 0 0001007a fca42e23 m ffffffcc   00000000  sw       x10, -0x24(x8)
#12 0 0001007e fcb42c23 m ffffffc8   00000000  sw       x11, -0x28(x8)
#13 0 00010082     4785 r 0f         00000001  c.li     x15, 0x1
#14 0 00010084 fef42623 m ffffffdc   00000001  sw       x15, -0x14(x8)
#15 0 00010088     4789 r 0f         00000002  c.li     x15, 0x2
#16 0 0001008a fef42423 m ffffffd8   00000002  sw       x15, -0x18(x8)
#17 0 0001008e fec42703 r 0e         00000001  lw       x14, -0x14(x8)
#18 0 00010092 fe842783 r 0f         00000002  lw       x15, -0x18(x8)
#19 0 00010096     97ba r 0f         00000003  c.add    x15, x14
#20 0 00010098 fef42223 m ffffffd4   00000003  sw       x15, -0x1c(x8)
#21 0 0001009c fe442783 r 0f         00000003  lw       x15, -0x1c(x8)
#22 0 000100a0     853e r 0a         00000003  c.mv     x10, x15
#23 0 000100a2     5432 r 08         00000000  c.lwsp   x8, 0x2c
#24 0 000100a4     6145 r 02         fffffff0  c.addi16sp 0x3
#25 0 000100a6     8082 r 00         00000000  c.jr     x1
#26 0 000100b6     67c5 r 0f         00011000  c.lui    x15, 0x11
#27 0 000100b8     4705 r 0e         00000001  c.li     x14, 0x1
#28 0 000100ba 0ce7a423 m 000110c8   00000001  sw       x14, 0xc8(x15)
Successful stop: write to to-host
Retired 28 instructions in 0.00s  22047 inst/s
sjohnson@tyrone:/d1/proj/sjohnson/swerv-ISS$
scottj97 commented 5 years ago

My system is CentOS 7 with GCC 8.2.0 and Boost 1.67.0. I built from 239bec28373c9180b5b626cfb75953b6bed0716d.

jrahmeh commented 5 years ago

Hi Scott,

Thanks for reporting this issue. I will fix it and release new code (hopefully today).

Joe

On Mon, Feb 18, 2019 at 12:49 AM Scott Johnson notifications@github.com wrote:

I'm running test2.c from the README. When I add --log for an instruction trace, the count of retired instructions increases by 1.

I can't imagine any good reason why turning on tracing should change the number of retired instructions. It should be running the exact same thing in either case.

sjohnson@tyrone:/d1/proj/sjohnson/swerv-ISS$ ./whisper test2 Successful stop: write to to-host Retired 27 instructions in 0.00s 177631 inst/s sjohnson@tyrone:/d1/proj/sjohnson/swerv-ISS$ ./whisper --log test2

1 0 000100a8 1141 r 02 fffffff0 c.addi x2, -0x10

2 0 000100aa c606 m fffffffc 00000000 c.swsp x1, 0xc

3 0 000100ac c422 m fffffff8 00000000 c.swsp x8, 0x8

4 0 000100ae 0800 r 08 00000000 c.addi4spn x8, 0x4

5 0 000100b0 4581 r 0b 00000000 c.li x11, 0x0

6 0 000100b2 4501 r 0a 00000000 c.li x10, 0x0

7 0 000100b4 37c1 r 01 000100b6 c.jal . - 0x40

8 0 00010074 7179 r 02 ffffffc0 c.addi16sp -0x3

9 0 00010076 d622 m ffffffec 00000000 c.swsp x8, 0x2c

10 0 00010078 1800 r 08 fffffff0 c.addi4spn x8, 0xc

11 0 0001007a fca42e23 m ffffffcc 00000000 sw x10, -0x24(x8)

12 0 0001007e fcb42c23 m ffffffc8 00000000 sw x11, -0x28(x8)

13 0 00010082 4785 r 0f 00000001 c.li x15, 0x1

14 0 00010084 fef42623 m ffffffdc 00000001 sw x15, -0x14(x8)

15 0 00010088 4789 r 0f 00000002 c.li x15, 0x2

16 0 0001008a fef42423 m ffffffd8 00000002 sw x15, -0x18(x8)

17 0 0001008e fec42703 r 0e 00000001 lw x14, -0x14(x8)

18 0 00010092 fe842783 r 0f 00000002 lw x15, -0x18(x8)

19 0 00010096 97ba r 0f 00000003 c.add x15, x14

20 0 00010098 fef42223 m ffffffd4 00000003 sw x15, -0x1c(x8)

21 0 0001009c fe442783 r 0f 00000003 lw x15, -0x1c(x8)

22 0 000100a0 853e r 0a 00000003 c.mv x10, x15

23 0 000100a2 5432 r 08 00000000 c.lwsp x8, 0x2c

24 0 000100a4 6145 r 02 fffffff0 c.addi16sp 0x3

25 0 000100a6 8082 r 00 00000000 c.jr x1

26 0 000100b6 67c5 r 0f 00011000 c.lui x15, 0x11

27 0 000100b8 4705 r 0e 00000001 c.li x14, 0x1

28 0 000100ba 0ce7a423 m 000110c8 00000001 sw x14, 0xc8(x15)

Successful stop: write to to-host Retired 28 instructions in 0.00s 22047 inst/s sjohnson@tyrone:/d1/proj/sjohnson/swerv-ISS$

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/westerndigitalcorporation/swerv-ISS/issues/3, or mute the thread https://github.com/notifications/unsubscribe-auth/ACR4X8PQiMgI0UE3UfbppMSyTrkwtC3aks5vOk0OgaJpZM4bAMwd .

jrahmeh commented 5 years ago

Now fixed.

scottj97 commented 5 years ago

I confirm that f3e8ffd3f9bbb810d2bb8373c35add7960c38115 fixes this, but I'm curious about the implementation. Adding a new line to increment retiredInsts_, as this change did, seems odd...why would --log cause it to take a different path through this code in the first place?

jrahmeh commented 5 years ago

Hi Scott,

If there is no logging or no triggers or no stop on a particular address, then we choose a path that is optimized for speed. Otherwise, we choose a path that has all the features.

Joe

On Mon, Feb 18, 2019 at 12:31 PM Scott Johnson notifications@github.com wrote:

I confirm that f3e8ffd https://github.com/westerndigitalcorporation/swerv-ISS/commit/f3e8ffd3f9bbb810d2bb8373c35add7960c38115 fixes this, but I'm curious about the implementation. Adding a new line to increment retiredInsts_, as this change did, seems odd...why would --log cause it to take a different path through this code in the first place?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/westerndigitalcorporation/swerv-ISS/issues/3#issuecomment-464837090, or mute the thread https://github.com/notifications/unsubscribe-auth/ACR4X9Re50-3Qq1pZwpTJPRqLSXMcANnks5vOvFvgaJpZM4bAMwd .