minio / sha256-simd

Accelerate SHA256 computations in pure Go using AVX512, SHA Extensions for x86 and ARM64 for ARM. On AVX512 it provides an up to 8x improvement (over 3 GB/s per core). SHA Extensions give a performance boost of close to 4x over native.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SIGILL: illegal instruction

tomwilkie opened this issue · comments

Not sure what I'm doing wrong? Running on macOS Mojave on a 2018 macbook pro, go version go1.11.2 darwin/amd64, revision 5197645.

SIGILL: illegal instruction
PC=0x11a5da8 m=5 sigcode=1

goroutine 19 [running]:
github.com/tomwilkie/dedupe/vendor/github.com/minio/sha256-simd.sha256_x16_avx512(0xc00018a000, 0xc0000ccf38, 0x13be9e0, 0xc000184000, 0x60, 0x60, 0x0, 0x0, 0x0, 0xc000154000, ...)
	/Users/twilkie/Documents/src/github.com/tomwilkie/dedupe/vendor/github.com/minio/sha256-simd/sha256blockAvx512_amd64.s:7 +0x18 fp=0xc0000ccd60 sp=0xc0000ccd58 pc=0x11a5da8
github.com/tomwilkie/dedupe/vendor/github.com/minio/sha256-simd.blockAvx512(0xc00018a000, 0x0, 0x0, 0x0, 0xc000154000, 0x1800, 0x8000, 0xc00014a010, 0x40, 0x40, ...)
	/Users/twilkie/Documents/src/github.com/tomwilkie/dedupe/vendor/github.com/minio/sha256-simd/sha256blockAvx512_amd64.go:265 +0xdc fp=0xc0000cd348 sp=0xc0000ccd60 pc=0x11a41ec
github.com/tomwilkie/dedupe/vendor/github.com/minio/sha256-simd.(*Avx512Server).blocks(0xc0000b8580, 0xc0000f8c00, 0x2)
	/Users/twilkie/Documents/src/github.com/tomwilkie/dedupe/vendor/github.com/minio/sha256-simd/sha256blockAvx512_amd64.go:384 +0x1a2 fp=0xc0000cdbd8 sp=0xc0000cd348 pc=0x11a4b62
github.com/tomwilkie/dedupe/vendor/github.com/minio/sha256-simd.(*Avx512Server).Process(0xc0000b8580)
	/Users/twilkie/Documents/src/github.com/tomwilkie/dedupe/vendor/github.com/minio/sha256-simd/sha256blockAvx512_amd64.go:350 +0x396 fp=0xc0000cdfd8 sp=0xc0000cdbd8 pc=0x11a4836
runtime.goexit()
	/usr/local/Cellar/go/1.11.2/libexec/src/runtime/asm_amd64.s:1333 +0x1 fp=0xc0000cdfe0 sp=0xc0000cdfd8 pc=0x1057171
created by github.com/tomwilkie/dedupe/vendor/github.com/minio/sha256-simd.NewAvx512Server
	/Users/twilkie/Documents/src/github.com/tomwilkie/dedupe/vendor/github.com/minio/sha256-simd/sha256blockAvx512_amd64.go:315 +0xa5

This happened when I shared a sha256.Avx512Server amongst multiple go routines, all doing sha256.NewAvx512(server); when I started to use sha256.New() it went away.

You need to run the AVX512 version on a CPU that has the AVX512 instructons. I call tell for sure your laptop does not have that (my laptop neither...). So if you still run the code you will indeed get an illegal instruction error.
Please use the regular AVX2 version and you are good.