gitee.com/quant1x/num@v0.3.2/asm/floats_avx_test.go (about)

     1  package asm
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  	"unsafe"
     7  )
     8  
     9  func TestFloats(t *testing.T) {
    10  	//a := []float32{1, 1, 1, 1, 1, 1, 1, 1}
    11  	a := []float32{3, 3, 3, 3, 3, 3, 3, 3}
    12  	b := []float32{2, 2, 2, 2, 2, 2, 2, 2}
    13  	c := make([]float32, len(a))
    14  	n := len(a)
    15  	fmt.Println(n)
    16  	fmt.Printf("a: %p\n", &a)
    17  	fmt.Printf("b: %p\n", &b)
    18  	fmt.Printf("c: %p\n", &c)
    19  	fmt.Printf("n: %p\n", &n)
    20  	ptrA := unsafe.Pointer(&a[0])
    21  	ptrB := unsafe.Pointer(&b[0])
    22  	ptrC := unsafe.Pointer(&c[0])
    23  	ptrN := unsafe.Pointer(uintptr(n))
    24  	___mm256_mul_to(ptrA, ptrB, ptrC, ptrN)
    25  	fmt.Println(c)
    26  }