tactcomplabs / rev

RISC-V SST CPU Component
Other
17 stars 21 forks source link

missing thread execution for RV32I #216

Open kpgriesser opened 9 months ago

kpgriesser commented 9 months ago

Describe the bug A thread is never executed when attempting 3 threads on 2 harts using RV32I ISA. The test passes when there are 4 harts or when using 64-bit ISA.

To Reproduce

cd threading/pthreads/permute make clean && make -j

All issues must be accompanied by:

Expected behavior No assertions

Trace

Passing case on RV64G

RevCPU[cpu0:ECALL_pthread_create:26000]: ECALL: pthread_create called by thread 1 on hart 0 RevCPU[cpu0:CreateThread:26000]: Creating new thread with PC = 0x14cf4 RevCPU[cpu0:ECALL_pthread_create:50000]: ECALL: pthread_create called by thread 1 on hart 0 RevCPU[cpu0:CreateThread:50000]: Creating new thread with PC = 0x14d4c RevCPU[cpu0:ECALL_pthread_create:73000]: ECALL: pthread_create called by thread 1 on hart 0 RevCPU[cpu0:CreateThread:73000]: Creating new thread with PC = 0x14da4 RevCPU[cpu0:ECALL_pthread_join:89000]: ECALL: pthread_join called by thread 1 on hart 0

enter void *thread2()

RevCPU[cpu0:Render:91000]: Core 0; Hart 0; Thread 1857172069; *I 0x14d4c:fe010113 addi sp, sp, -32 0x3fdbeff7<-sp sp<-0x3fdbefd7

enter void *thread3()

RevCPU[cpu0:Render:226000]: Core 0; Hart 0; Thread 2961362521; *I 0x14da4:fe010113 addi sp, sp, -32 0x3fc7eff6<-sp sp<-0x3fc7efd6

enter void *thread1() <- GOOD (missing from failing case)

RevCPU[cpu0:Render:362000]: Core 0; Hart 1; Thread 2197699622; *I 0x14cf4:fe010113 addi sp, sp, -32 0x3fefeff8<-sp sp<-0x3fefefd8

wrote 0xa

RevCPU[cpu0:Render:484000]: Core 0; Hart 1; Thread 2197699622; I 0x14d18:f6e1a023 sw a4, -160(gp) 0x193f0<-gp 0xa<-a4 [0x19350,4]<-0x0000000a RevCPU[cpu0:ECALL_pthread_join:514000]: ECALL: pthread_join called by thread 1 on hart 0 RevCPU[cpu0:ECALL_pthread_join:530000]: ECALL: pthread_join called by thread 1 on hart 0 ### Read 0xa ok RevCPU[cpu0:Render:539000]: Core 0; Hart 0; Thread 1; I 0x14e98:f601a783 lw a5, -160(gp) 0x193f0<-gp 0x0000000a<-[0x19350,4] a5<-0xa

PASSES

Failing case on RV32I

Notice that we never call the function 'void *thread1()'

RevCPU[cpu0:ECALL_pthread_create:25000]: ECALL: pthread_create called by thread 1 on hart 0 RevCPU[cpu0:CreateThread:25000]: Creating new thread with PC = 0x1462c RevCPU[cpu0:ECALL_pthread_create:49000]: ECALL: pthread_create called by thread 1 on hart 0 RevCPU[cpu0:CreateThread:49000]: Creating new thread with PC = 0x14678 RevCPU[cpu0:ECALL_pthread_create:72000]: ECALL: pthread_create called by thread 1 on hart 0 RevCPU[cpu0:CreateThread:72000]: Creating new thread with PC = 0x146c4 RevCPU[cpu0:ECALL_pthread_join:88000]: ECALL: pthread_join called by thread 1 on hart 0

enter void *thread2()

RevCPU[cpu0:Render:90000]: Core 0; Hart 0; Thread 501234749; *I 0x14678:fe010113 addi sp, sp, -32 0x3fdbeff7<-sp sp<-0x3fdbefd7

enter void *thread3()

RevCPU[cpu0:Render:193000]: Core 0; Hart 0; Thread 331638285; I 0x146c4:fe010113 addi sp, sp, -32 0x3fc7eff6<-sp sp<-0x3fc7efd6 RevCPU[cpu0:ECALL_pthread_join:312000]: ECALL: pthread_join called by thread 1 on hart 0 RevCPU[cpu0:ECALL_pthread_join:328000]: ECALL: pthread_join called by thread 1 on hart 0 ### FAILS HERE ### read 0 instead of 0xa RevCPU[cpu0:Render:337000]: Core 0; Hart 0; Thread 1; I 0x147a8:c341a783 lw a5, -972(gp) 0x181f0<-gp 0x00000000<-[0x17e24,4] a5<-0x0

Additional context Add any other context about the problem here.

kpgriesser commented 9 months ago

not sure if this is really just a 32-bit thing. The other 32-bit test cases pass so it may be exposing an edge case