Rename fpu to asm package

This commit is contained in:
DataHoarder 2024-04-11 15:48:11 +02:00
parent bbd84ccde0
commit 252d9ed9d3
Signed by: DataHoarder
SSH key fingerprint: SHA256:OLTRf6Fl87G52SiR7sWLGNzlJt4WOX+tfI2yxo0z7xk
11 changed files with 13 additions and 11 deletions

View file

@ -8,4 +8,4 @@ This package implements RandomX without CGO, using only Golang code, pure float6
All test cases pass properly.
Supports `386` `amd64` `arm64` platforms due to rounding mode set via assembly. More can be added with supporting rounding mode under _fpu_.
Supports `386` `amd64` `arm64` platforms due to rounding mode set via assembly. More can be added with supporting rounding mode under _asm_.

View file

@ -1,4 +1,4 @@
package fpu
package asm
type RoundingMode uint8

View file

@ -1,6 +1,6 @@
//go:build 386
package fpu
package asm
// stmxcsr reads the MXCSR control and status register.
//

View file

@ -1,6 +1,6 @@
//go:build amd64
package fpu
package asm
// stmxcsr reads the MXCSR control and status register.
//

View file

@ -1,6 +1,6 @@
//go:build arm64
package fpu
package asm
// GetFPCR returns the value of FPCR register.
func getFPCR() (value uint32)

View file

@ -1,6 +1,6 @@
//go:build !arm64 && !amd64 && !386
package fpu
package asm
func setRoundingMode(mode uint8) {
panic("not implemented")

8
vm.go
View file

@ -30,7 +30,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package randomx
import (
"git.gammaspectra.live/P2Pool/go-randomx/fpu"
"git.gammaspectra.live/P2Pool/go-randomx/asm"
"math"
"runtime"
)
@ -60,6 +60,8 @@ type VM struct {
config Config // configuration
datasetOffset uint64
Dataset Randomx_Dataset
Cache *Randomx_Cache // randomx cache
}
@ -231,10 +233,10 @@ func (vm *VM) CalculateHash(input []byte, output []byte) {
runtime.LockOSThread()
defer runtime.UnlockOSThread()
//restore rounding mode to golang expected one
defer fpu.SetRoundingMode(fpu.RoundingModeToNearest)
defer asm.SetRoundingMode(asm.RoundingModeToNearest)
// reset rounding mode if new hash being calculated
fpu.SetRoundingMode(fpu.RoundingModeToNearest)
asm.SetRoundingMode(asm.RoundingModeToNearest)
input_hash := blake2b.Sum512(input)

View file

@ -31,7 +31,7 @@ package randomx
import (
"fmt"
"git.gammaspectra.live/P2Pool/go-randomx/fpu"
"git.gammaspectra.live/P2Pool/go-randomx/asm"
)
import "math"
import "math/bits"
@ -714,7 +714,7 @@ func (vm *VM) InterpretByteCode() {
case VM_CFROUND:
tmp := (bits.RotateLeft64(*ibc.isrc, 0-int(ibc.imm))) % 4 // rotate right
fpu.SetRoundingMode(fpu.RoundingMode(tmp))
asm.SetRoundingMode(asm.RoundingMode(tmp))
//panic("round not implemented")
//panic("VM_CFROUND")