Debian Codegraph @

xor.go

raw symbols SCIP
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 (
9 "unsafescip-go gomod github.com/golang/go/src go1.19 unsafe/"
10
11 "github.com/templexxx/cpuscip-go gomod github.com/templexxx/cpu v0.1.1 `github.com/templexxx/cpu`/"
12 )
13
14 const wordSizescip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/wordSize. = int(unsafescip-go gomod github.com/golang/go/src go1.19 unsafe/.Sizeof(uintptr(0)))
15
16 // EnableAVX512 controls whether AVX-512 is considered during feature detection.
17 // Note: instruction-path selection is decided at package initialization, so
18 // changing this value afterwards does not refresh the selected backend.
19 var EnableAVX512scip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/EnableAVX512. = true
20
21 // cpuFeature indicates which instruction set will be used.
22 var cpuFeaturescip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/cpuFeature. = getCPUFeaturescip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/getCPUFeature().()
23
24 const (
25 avx512scip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/avx512. = iota
26 avx2scip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/avx2.
27 sse2scip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/sse2.
28 genericscip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/generic.
29 )
30
31 // TODO: Add ARM feature...
32
33 func hasAVX512scip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/hasAVX512().() (ok bool) {
34
35 return 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..HasAVX512VLscip-go gomod github.com/templexxx/cpu v0.1.1 `github.com/templexxx/cpu`/x86#HasAVX512VL. &&
36 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..HasAVX512BWscip-go gomod github.com/templexxx/cpu v0.1.1 `github.com/templexxx/cpu`/x86#HasAVX512BW. &&
37 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..HasAVX512Fscip-go gomod github.com/templexxx/cpu v0.1.1 `github.com/templexxx/cpu`/x86#HasAVX512F. &&
38 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..HasAVX512DQscip-go gomod github.com/templexxx/cpu v0.1.1 `github.com/templexxx/cpu`/x86#HasAVX512DQ.
39 }
40
41 // Encode XORs all source rows into dst.
42 // The source and destination may overlap.
43 //
44 // Encode returns the number of bytes processed, which is the minimum length of
45 // dst and every source row.
46 //
47 // Callers must provide at least one source row: len(src) >= 1.
48 func Encodescip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/Encode().(dst []byte, src [][]byte) (n int) {
49 n = checkLenscip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/checkLen().(dst, src)
50 if n == 0 {
51 return
52 }
53
54 dst = dst[:n]
55 for i := range src {
56 src[i] = src[i][:n]
57 }
58
59 if len(src) == 1 {
60 copy(dst, src[0])
61 return
62 }
63
64 encodescip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/encode().(dst, src)
65 return
66 }
67
68 func checkLenscip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/checkLen().(dst []byte, src [][]byte) int {
69 n := len(dst)
70 for i := range src {
71 if len(src[i]) < n {
72 n = len(src[i])
73 }
74 }
75
76 if n <= 0 {
77 return 0
78 }
79 return n
80 }
81
82 // Bytes XORs a and b into dst.
83 // The source and destination may overlap.
84 //
85 // Bytes returns the number of bytes processed, which is the minimum of
86 // len(dst), len(a), and len(b).
87 func Bytesscip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/Bytes().(dst, a, b []byte) int {
88 return Encodescip-go gomod github.com/templexxx/xorsimd . `github.com/templexxx/xorsimd`/Encode().(dst, [][]byte{a, b})
89 }