| 1 | // Copyright (c) 2019. Temple3x ([email protected]) |
| 2 | // |
| 3 | // Use of this source code is governed by the MIT License |
| 4 | // that can be found in the LICENSE file. |
| 5 | |
| 6 | package xorsimdscip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/ |
| 7 | |
| 8 | import "github.com/templexxx/cpuscip-go gomod github.com/templexxx/cpu v0.1.1 `github.com/templexxx/cpu`/" |
| 9 | |
| 10 | func encodescip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/encode().(dst []byte, src [][]byte) { |
| 11 | |
| 12 | switch cpuFeaturescip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/cpuFeature. { |
| 13 | case avx512scip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/avx512.: |
| 14 | encodeAVX512scip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/encodeAVX512().(dst, src) |
| 15 | case avx2scip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/avx2.: |
| 16 | encodeAVX2scip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/encodeAVX2().(dst, src) |
| 17 | default: |
| 18 | encodeSSE2scip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/encodeSSE2().(dst, src) |
| 19 | } |
| 20 | return |
| 21 | } |
| 22 | |
| 23 | func getCPUFeaturescip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/getCPUFeature().() int { |
| 24 | if hasAVX512scip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/hasAVX512().() && EnableAVX512scip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/EnableAVX512. { |
| 25 | return avx512scip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/avx512. |
| 26 | } else if cpuscip-go gomod github.com/templexxx/cpu v0.1.1 `github.com/templexxx/cpu`/.X86scip-go gomod github.com/templexxx/cpu v0.1.1 `github.com/templexxx/cpu`/X86..HasAVX2scip-go gomod github.com/templexxx/cpu v0.1.1 `github.com/templexxx/cpu`/x86#HasAVX2. { |
| 27 | return avx2scip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/avx2. |
| 28 | } else { |
| 29 | return sse2scip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/sse2. // amd64 must have sse2 |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | // Bytes8 XORs exactly 8 bytes from a and b into dst. |
| 34 | // Each slice must have length >= 8, otherwise it panics. |
| 35 | func Bytes8scip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/Bytes8().(dst, a, b []byte) { |
| 36 | |
| 37 | bytes8scip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/bytes8().(&dst[0], &a[0], &b[0]) |
| 38 | } |
| 39 | |
| 40 | // Bytes16 XORs exactly 16 bytes from a and b into dst. |
| 41 | // Each slice must have length >= 16, otherwise it panics. |
| 42 | func Bytes16scip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/Bytes16().(dst, a, b []byte) { |
| 43 | |
| 44 | bytes16scip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/bytes16().(&dst[0], &a[0], &b[0]) |
| 45 | } |
| 46 | |
| 47 | // Bytes8Align XORs exactly 8 bytes from a and b into dst. |
| 48 | // Each slice must have length >= 8, otherwise it panics. |
| 49 | // On amd64, explicit alignment is not required; this function exists for API |
| 50 | // compatibility with non-amd64 implementations. |
| 51 | func Bytes8Alignscip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/Bytes8Align().(dst, a, b []byte) { |
| 52 | |
| 53 | bytes8scip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/bytes8().(&dst[0], &a[0], &b[0]) |
| 54 | } |
| 55 | |
| 56 | // Bytes16Align XORs exactly 16 bytes from a and b into dst. |
| 57 | // Each slice must have length >= 16, otherwise it panics. |
| 58 | // On amd64, explicit alignment is not required; this function exists for API |
| 59 | // compatibility with non-amd64 implementations. |
| 60 | func Bytes16Alignscip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/Bytes16Align().(dst, a, b []byte) { |
| 61 | |
| 62 | bytes16scip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/bytes16().(&dst[0], &a[0], &b[0]) |
| 63 | } |
| 64 | |
| 65 | // BytesA XORs len(a) bytes from a and b into dst. |
| 66 | // Callers must ensure len(dst) >= len(a) and len(b) >= len(a). |
| 67 | // |
| 68 | // This helper is intended for small slices where setup overhead dominates. |
| 69 | // For larger slices, Bytes is usually faster. |
| 70 | func BytesAscip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/BytesA().(dst, a, b []byte) { |
| 71 | |
| 72 | bytesNscip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/bytesN().(&dst[0], &a[0], &b[0], len(a)) |
| 73 | } |
| 74 | |
| 75 | // BytesB XORs len(b) bytes from a and b into dst. |
| 76 | // Callers must ensure len(dst) >= len(b) and len(a) >= len(b). |
| 77 | // |
| 78 | // This helper is intended for small slices where setup overhead dominates. |
| 79 | // For larger slices, Bytes is usually faster. |
| 80 | func BytesBscip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/BytesB().(dst, a, b []byte) { |
| 81 | |
| 82 | bytesNscip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/bytesN().(&dst[0], &a[0], &b[0], len(b)) |
| 83 | } |
| 84 | |
| 85 | //go:noescape |
| 86 | func encodeAVX512scip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/encodeAVX512().(dst []byte, src [][]byte) |
| 87 | |
| 88 | //go:noescape |
| 89 | func encodeAVX2scip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/encodeAVX2().(dst []byte, src [][]byte) |
| 90 | |
| 91 | //go:noescape |
| 92 | func encodeSSE2scip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/encodeSSE2().(dst []byte, src [][]byte) |
| 93 | |
| 94 | //go:noescape |
| 95 | func bytesNscip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/bytesN().(dst, a, b *byte, n int) |
| 96 | |
| 97 | //go:noescape |
| 98 | func bytes8scip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/bytes8().(dst, a, b *byte) |
| 99 | |
| 100 | //go:noescape |
| 101 | func bytes16scip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/bytes16().(dst, a, b *byte) |