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. 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 type RoundingMode uint8

View file

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

View file

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

View file

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

View file

@ -1,6 +1,6 @@
//go:build !arm64 && !amd64 && !386 //go:build !arm64 && !amd64 && !386
package fpu package asm
func setRoundingMode(mode uint8) { func setRoundingMode(mode uint8) {
panic("not implemented") 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 package randomx
import ( import (
"git.gammaspectra.live/P2Pool/go-randomx/fpu" "git.gammaspectra.live/P2Pool/go-randomx/asm"
"math" "math"
"runtime" "runtime"
) )
@ -60,6 +60,8 @@ type VM struct {
config Config // configuration config Config // configuration
datasetOffset uint64 datasetOffset uint64
Dataset Randomx_Dataset
Cache *Randomx_Cache // randomx cache Cache *Randomx_Cache // randomx cache
} }
@ -231,10 +233,10 @@ func (vm *VM) CalculateHash(input []byte, output []byte) {
runtime.LockOSThread() runtime.LockOSThread()
defer runtime.UnlockOSThread() defer runtime.UnlockOSThread()
//restore rounding mode to golang expected one //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 // reset rounding mode if new hash being calculated
fpu.SetRoundingMode(fpu.RoundingModeToNearest) asm.SetRoundingMode(asm.RoundingModeToNearest)
input_hash := blake2b.Sum512(input) input_hash := blake2b.Sum512(input)

View file

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