Source file src/simd/midway_amd64_test.go

     1  // Copyright 2026 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build goexperiment.simdstable && amd64
     6  
     7  package simd
     8  
     9  import (
    10  	"internal/cpu"
    11  	"simd/archsimd"
    12  	"testing"
    13  )
    14  
    15  func TestAMD64WithoutFMA(t *testing.T) {
    16  	if !archsimd.X86.AVX() {
    17  		t.Skip("requires AVX")
    18  	}
    19  	saved := cpu.X86.HasFMA
    20  	cpu.X86.HasFMA = false
    21  	defer func() { cpu.X86.HasFMA = saved }()
    22  	if archsimd.X86.FMA() {
    23  		t.Skip("FMA is guaranteed by GOAMD64")
    24  	}
    25  	// Without FMA, no GODEBUG=simd setting selects hardware SIMD.
    26  	for _, gosimd := range []string{"", "1", "128", "256", "512"} {
    27  		if _, emulated := configure(archMaxVectorSize(), gosimd); !emulated {
    28  			t.Errorf("hardware SIMD selected without FMA with GODEBUG=simd=%s", gosimd)
    29  		}
    30  	}
    31  }
    32  

View as plain text