mirror of
https://github.com/gonum/gonum.git
synced 2025-10-22 22:59:24 +08:00
testlapack,native,cgo: build Dgeev benchmark conditioned on go1.7 tag
This commit is contained in:
15
cgo/bench_test.go
Normal file
15
cgo/bench_test.go
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
// Copyright ©2016 The gonum Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build go1.7
|
||||||
|
|
||||||
|
package cgo
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/gonum/lapack/testlapack"
|
||||||
|
)
|
||||||
|
|
||||||
|
func BenchmarkDgeev(b *testing.B) { testlapack.DgeevBenchmark(b, impl) }
|
@@ -217,7 +217,3 @@ func TestDtrcon(t *testing.T) {
|
|||||||
func TestDtrtri(t *testing.T) {
|
func TestDtrtri(t *testing.T) {
|
||||||
testlapack.DtrtriTest(t, impl)
|
testlapack.DtrtriTest(t, impl)
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkDgeev(b *testing.B) {
|
|
||||||
testlapack.DgeevBenchmark(b, impl)
|
|
||||||
}
|
|
||||||
|
15
native/bench_test.go
Normal file
15
native/bench_test.go
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
// Copyright ©2016 The gonum Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build go1.7
|
||||||
|
|
||||||
|
package native
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/gonum/lapack/testlapack"
|
||||||
|
)
|
||||||
|
|
||||||
|
func BenchmarkDgeev(b *testing.B) { testlapack.DgeevBenchmark(b, impl) }
|
@@ -351,7 +351,3 @@ func TestIladlc(t *testing.T) {
|
|||||||
func TestIladlr(t *testing.T) {
|
func TestIladlr(t *testing.T) {
|
||||||
testlapack.IladlrTest(t, impl)
|
testlapack.IladlrTest(t, impl)
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkDgeev(b *testing.B) {
|
|
||||||
testlapack.DgeevBenchmark(b, impl)
|
|
||||||
}
|
|
||||||
|
@@ -733,51 +733,3 @@ func dgeevTestForAntisymRandom(n int, rnd *rand.Rand) dgeevTest {
|
|||||||
evWant: a.Eigenvalues(),
|
evWant: a.Eigenvalues(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var resultGeneral blas64.General
|
|
||||||
|
|
||||||
func DgeevBenchmark(b *testing.B, impl Dgeever) {
|
|
||||||
rnd := rand.New(rand.NewSource(1))
|
|
||||||
benchmarks := []struct {
|
|
||||||
name string
|
|
||||||
a blas64.General
|
|
||||||
}{
|
|
||||||
{"AntisymRandom3", NewAntisymRandom(3, rnd).Matrix()},
|
|
||||||
{"AntisymRandom4", NewAntisymRandom(4, rnd).Matrix()},
|
|
||||||
{"AntisymRandom5", NewAntisymRandom(5, rnd).Matrix()},
|
|
||||||
{"AntisymRandom10", NewAntisymRandom(10, rnd).Matrix()},
|
|
||||||
{"AntisymRandom50", NewAntisymRandom(50, rnd).Matrix()},
|
|
||||||
{"AntisymRandom100", NewAntisymRandom(100, rnd).Matrix()},
|
|
||||||
{"AntisymRandom200", NewAntisymRandom(200, rnd).Matrix()},
|
|
||||||
{"AntisymRandom500", NewAntisymRandom(500, rnd).Matrix()},
|
|
||||||
{"Circulant3", Circulant(3).Matrix()},
|
|
||||||
{"Circulant4", Circulant(4).Matrix()},
|
|
||||||
{"Circulant5", Circulant(5).Matrix()},
|
|
||||||
{"Circulant10", Circulant(10).Matrix()},
|
|
||||||
{"Circulant50", Circulant(50).Matrix()},
|
|
||||||
{"Circulant100", Circulant(100).Matrix()},
|
|
||||||
{"Circulant200", Circulant(200).Matrix()},
|
|
||||||
{"Circulant500", Circulant(500).Matrix()},
|
|
||||||
}
|
|
||||||
for _, bm := range benchmarks {
|
|
||||||
n := bm.a.Rows
|
|
||||||
a := zeros(n, n, n)
|
|
||||||
vl := zeros(n, n, n)
|
|
||||||
vr := zeros(n, n, n)
|
|
||||||
wr := make([]float64, n)
|
|
||||||
wi := make([]float64, n)
|
|
||||||
work := make([]float64, 1)
|
|
||||||
impl.Dgeev(lapack.ComputeLeftEV, lapack.ComputeRightEV, n, nil, n, nil, nil, nil, n, nil, n, work, -1)
|
|
||||||
work = make([]float64, int(work[0]))
|
|
||||||
b.Run(bm.name, func(b *testing.B) {
|
|
||||||
for i := 0; i < b.N; i++ {
|
|
||||||
b.StopTimer()
|
|
||||||
copyGeneral(a, bm.a)
|
|
||||||
b.StartTimer()
|
|
||||||
impl.Dgeev(lapack.ComputeLeftEV, lapack.ComputeRightEV, n, a.Data, a.Stride, wr, wi,
|
|
||||||
vl.Data, vl.Stride, vr.Data, vr.Stride, work, len(work))
|
|
||||||
}
|
|
||||||
resultGeneral = a
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
63
testlapack/dgeev_bench.go
Normal file
63
testlapack/dgeev_bench.go
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
// Copyright ©2016 The gonum Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build go1.7
|
||||||
|
|
||||||
|
package testlapack
|
||||||
|
|
||||||
|
import (
|
||||||
|
"math/rand"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/gonum/blas/blas64"
|
||||||
|
"github.com/gonum/lapack"
|
||||||
|
)
|
||||||
|
|
||||||
|
var resultGeneral blas64.General
|
||||||
|
|
||||||
|
func DgeevBenchmark(b *testing.B, impl Dgeever) {
|
||||||
|
rnd := rand.New(rand.NewSource(1))
|
||||||
|
benchmarks := []struct {
|
||||||
|
name string
|
||||||
|
a blas64.General
|
||||||
|
}{
|
||||||
|
{"AntisymRandom3", NewAntisymRandom(3, rnd).Matrix()},
|
||||||
|
{"AntisymRandom4", NewAntisymRandom(4, rnd).Matrix()},
|
||||||
|
{"AntisymRandom5", NewAntisymRandom(5, rnd).Matrix()},
|
||||||
|
{"AntisymRandom10", NewAntisymRandom(10, rnd).Matrix()},
|
||||||
|
{"AntisymRandom50", NewAntisymRandom(50, rnd).Matrix()},
|
||||||
|
{"AntisymRandom100", NewAntisymRandom(100, rnd).Matrix()},
|
||||||
|
{"AntisymRandom200", NewAntisymRandom(200, rnd).Matrix()},
|
||||||
|
{"AntisymRandom500", NewAntisymRandom(500, rnd).Matrix()},
|
||||||
|
{"Circulant3", Circulant(3).Matrix()},
|
||||||
|
{"Circulant4", Circulant(4).Matrix()},
|
||||||
|
{"Circulant5", Circulant(5).Matrix()},
|
||||||
|
{"Circulant10", Circulant(10).Matrix()},
|
||||||
|
{"Circulant50", Circulant(50).Matrix()},
|
||||||
|
{"Circulant100", Circulant(100).Matrix()},
|
||||||
|
{"Circulant200", Circulant(200).Matrix()},
|
||||||
|
{"Circulant500", Circulant(500).Matrix()},
|
||||||
|
}
|
||||||
|
for _, bm := range benchmarks {
|
||||||
|
n := bm.a.Rows
|
||||||
|
a := zeros(n, n, n)
|
||||||
|
vl := zeros(n, n, n)
|
||||||
|
vr := zeros(n, n, n)
|
||||||
|
wr := make([]float64, n)
|
||||||
|
wi := make([]float64, n)
|
||||||
|
work := make([]float64, 1)
|
||||||
|
impl.Dgeev(lapack.ComputeLeftEV, lapack.ComputeRightEV, n, nil, n, nil, nil, nil, n, nil, n, work, -1)
|
||||||
|
work = make([]float64, int(work[0]))
|
||||||
|
b.Run(bm.name, func(b *testing.B) {
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
b.StopTimer()
|
||||||
|
copyGeneral(a, bm.a)
|
||||||
|
b.StartTimer()
|
||||||
|
impl.Dgeev(lapack.ComputeLeftEV, lapack.ComputeRightEV, n, a.Data, a.Stride, wr, wi,
|
||||||
|
vl.Data, vl.Stride, vr.Data, vr.Stride, work, len(work))
|
||||||
|
}
|
||||||
|
resultGeneral = a
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user