-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsimd_kernels_test.go
More file actions
46 lines (42 loc) · 1.89 KB
/
Copy pathsimd_kernels_test.go
File metadata and controls
46 lines (42 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// SPDX-License-Identifier: LGPL-2.1-or-later
package aac
import (
"testing"
"github.com/tphakala/go-aac/internal/coder"
"github.com/tphakala/go-aac/internal/dsp"
)
// TestSIMDEnabledMatchesKernels asserts that what SIMDEnabled reports is what
// the kernel packages actually compiled.
//
// internal/simdbuild derives its answer from the build tag on its own files,
// never from the dispatch files, so nothing else stops the two from drifting.
// Moving a kernel pair to a different tag, a per-kernel tag for instance, would
// still compile and would still pass every equivalence and oracle test, because
// a scalar kernel matches the scalar reference trivially. The accessor would
// then disagree with the kernel actually in the binary. This assertion is what
// catches that.
//
// It checks which dispatch file each package compiled, not that the compiled
// dispatch reaches github.com/tphakala/simd, and it knows only the three kernels
// named below. So every dispatch pair gated on noasm owes this file a
// <Kernel>IsSIMD constant and a line here; a third pair that skips both is
// invisible to it.
//
// This file carries no build tag on purpose, so the assertion runs in both
// builds rather than only in the one the tag selects. It does not subsume the
// tagged pair in simd_noasm_test.go and simd_simd_test.go: those are each gated
// by a literal build tag (noasm / !noasm) that this file never carries.
func TestSIMDEnabledMatchesKernels(t *testing.T) {
if dsp.AbsPow34IsSIMD != SIMDEnabled() {
t.Errorf("dsp.AbsPow34IsSIMD = %v, SIMDEnabled() = %v",
dsp.AbsPow34IsSIMD, SIMDEnabled())
}
if dsp.QuantizeBandsIsSIMD != SIMDEnabled() {
t.Errorf("dsp.QuantizeBandsIsSIMD = %v, SIMDEnabled() = %v",
dsp.QuantizeBandsIsSIMD, SIMDEnabled())
}
if coder.NMRTrellisIsSIMD != SIMDEnabled() {
t.Errorf("coder.NMRTrellisIsSIMD = %v, SIMDEnabled() = %v",
coder.NMRTrellisIsSIMD, SIMDEnabled())
}
}