github.com/Bytom/bytom@v1.1.2-0.20210127130405-ae40204c0b09/mining/tensority/cgo_algorithm/algorithm_simd.go (about) 1 // +build simd 2 3 package cgo_algorithm 4 5 // #cgo !darwin CFLAGS: -I. 6 // #cgo !darwin LDFLAGS: -L. -l:./lib/cSimdTs.o -lstdc++ -lgomp -lpthread 7 // #cgo darwin CFLAGS: -I. -I/usr/local/opt/llvm/include 8 // #cgo darwin LDFLAGS: -L. -l./lib/cSimdTs.o -lstdc++ -lomp -L/usr/local/opt/llvm/lib 9 // #include "./lib/cSimdTs.h" 10 import "C" 11 12 import ( 13 "unsafe" 14 15 "github.com/bytom/bytom/protocol/bc" 16 ) 17 18 func SimdAlgorithm(bh, seed *bc.Hash) *bc.Hash { 19 bhBytes := bh.Bytes() 20 sdBytes := seed.Bytes() 21 bhPtr := (*C.uint8_t)(unsafe.Pointer(&bhBytes[0])) 22 seedPtr := (*C.uint8_t)(unsafe.Pointer(&sdBytes[0])) 23 24 resPtr := C.SimdTs(bhPtr, seedPtr) 25 resHash := bc.NewHash(*(*[32]byte)(unsafe.Pointer(resPtr))) 26 27 return &resHash 28 }