minio / blake2b-simd

Fast hashing using pure Go implementation of BLAKE2b with SIMD instructions
Apache License 2.0
254 stars 31 forks source link

How is Go not building everything? #27

Closed mimoo closed 7 years ago

mimoo commented 7 years ago

Hello!

Thanks for your library :) it's awesome. I had two questions on the code and I couldn't find a way to contact you beside github issues:

  1. how can you run a function outside of the body here (I usually see that in an init() function)
  2. how will all the files build if the instructions are not supported/missing? The following files are all built on amd64 architectures:
    • compressAvx2_amd64.s
    • compressAvx_amd64.s
    • compressSse_amd64.s

EDIT: For 2. I think I see an answer. Correct me if I'm wrong, but since you do not call the instructions directly but with BYTE (ex. BYTE $0xc4; BYTE $0xc1; BYTE $0x1d; BYTE $0x6c; BYTE $0xe5) then the compiler is fine. Although I'm guessing Go's compiler is fine with any instructions anyway, as long as you don't call them in your running code if your architecture doesn't support these instructions.

harshavardhana commented 7 years ago

how can you run a function outside of the body here (I usually see that in an init() function)

This is a Go feature

how will all the files build if the instructions are not supported/missing? The following files are all built on amd64 architectures: compressAvx2_amd64.s compressAvx_amd64.s compressSse_amd64.s

This is a go compiler feature.

mimoo commented 7 years ago

This is a Go feature

I see, is this the same as writing them in an init() function? The official golang blake2 implementation uses init

harshavardhana commented 7 years ago

I see, is this the same as writing them in an init() function? The official golang blake2 implementation uses init

Yes that is correct @mimoo

mimoo commented 7 years ago

Awesome! Thanks for the answer.