gonum.org/v1/gonum@v0.14.0/blas/testblas/dgemmbench.go (about) 1 // Copyright ©2014 The Gonum 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 package testblas 6 7 import ( 8 "testing" 9 10 "golang.org/x/exp/rand" 11 12 "gonum.org/v1/gonum/blas" 13 ) 14 15 func DgemmBenchmark(b *testing.B, dgemm Dgemmer, m, n, k int, tA, tB blas.Transpose) { 16 a := make([]float64, m*k) 17 for i := range a { 18 a[i] = rand.Float64() 19 } 20 bv := make([]float64, k*n) 21 for i := range bv { 22 bv[i] = rand.Float64() 23 } 24 c := make([]float64, m*n) 25 for i := range c { 26 c[i] = rand.Float64() 27 } 28 var lda, ldb int 29 if tA == blas.Trans { 30 lda = m 31 } else { 32 lda = k 33 } 34 if tB == blas.Trans { 35 ldb = k 36 } else { 37 ldb = n 38 } 39 ldc := n 40 b.ResetTimer() 41 for i := 0; i < b.N; i++ { 42 dgemm.Dgemm(tA, tB, m, n, k, 3.0, a, lda, bv, ldb, 1.0, c, ldc) 43 } 44 }