Implementation of atomic instructions using LR/SC pair

185 views
Skip to first unread message

Sreenadh S

unread,
Jan 31, 2022, 5:03:10 AM1/31/22
to hw-...@groups.riscv.org, li...@cdac.in

In our 
rv64imafd multi-core  implementation, we had implemented Atomic instructions as a combination of lr and  sc instruction. Is
this implementation complaint to the risc-v specification? Will it make any
issues when running programs compiled for riscv?
Also is there any chance of following type of assembly code generated by the compiler:

lr.d x11, 0(X5)
amoadd.d X2, 0(X6)
sc.d X7, 0(x5)
[In our implementation the above sc.d will always fail]

Dan Petrisko

unread,
Jan 31, 2022, 5:24:28 AM1/31/22
to Sreenadh S, hw-...@groups.riscv.org, li...@cdac.in
I can't speak to the general compiler case, but our rv64imafd multicore used to emulate AMO using LR/SC pairs and we were able to boot full SMP Linux (and all multicore benchmarks we tried). We wrote https://github.com/black-parrot-sdk/perch/blob/master/atomics.S for the routines if it's of interest to you.

Best,
Dan


--
You received this message because you are subscribed to the Google Groups "RISC-V HW Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hw-dev+un...@groups.riscv.org.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/hw-dev/CAAurGAo_00qgr3VDdCJ%2BSMCDuEN67BXZBZZXoKKipxQvDazQVw%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages