func MMTestMult(m, n, p int) (fnc func(), A, B, C *matrix.FloatMatrix) { A = matrix.FloatNormal(m, p) B = matrix.FloatNormal(p, n) C = matrix.FloatZeros(m, n) fnc = func() { matops.Mult(C, A, B, 1.0, 1.0, matops.NOTRANS) } return }
func MMTestMultTransAB(m, n, p int) (fnc func(), A, B, C *matrix.FloatMatrix) { A = matrix.FloatNormal(p, m) B = matrix.FloatNormal(n, p) C = matrix.FloatZeros(m, n) fnc = func() { matops.Mult(C, A, B, 1.0, 1.0, matops.TRANSA|matops.TRANSB) } return }
// create a new matrix. func newMatrix(N int) *matrix.FloatMatrix { uplo := matrix.Lower if testUpper { uplo = matrix.Upper } generator := &matrix.NormalFloat{0.0, 2.0} A0 := matrix.FloatZeros(N, N) if !noSPD { A0.SetFrom(generator) A := matrix.FloatZeros(N, N) // A*A.T is positive definite matops.Mult(A, A0, A0, 1.0, 0.0, matops.TRANSB) return A } A0.SetFromTrm(generator, uplo) return A0 }
func main() { flag.Parse() runtime.GOMAXPROCS(nWorker) matops.NumWorkers(nWorker) rand.Seed(time.Now().UnixNano()) matops.BlockingParams(MB, NB, VPsize) uplo := matrix.Lower if testUpper { uplo = matrix.Upper } _ = uplo randNormal := &matrix.NormalFloat{0.0, 2.0} var ok bool var reftm, tm time.Duration if singleTest { A0 := matrix.FloatZeros(N, N) A0.SetFrom(randNormal) A := matrix.FloatZeros(N, N) matops.Mult(A, A0, A0, 1.0, 0.0, matops.TRANSB) Ac := A.Copy() if check { ok, tm, reftm = runCheck(A, KB) if verbose { fmt.Fprintf(os.Stderr, "%s: %v\n", testName, tm) fmt.Fprintf(os.Stderr, "Reference: [%v] %v (%.2f) \n", ok, reftm, tm.Seconds()/reftm.Seconds()) if !ok { fmt.Fprintf(os.Stderr, "ERRlapack: %v\n", ERRlapack) fmt.Fprintf(os.Stderr, "ERRmatops: %v\n", ERRmatops) } } if asGflops { fmt.Printf("%.4f Gflops [ref: %.4f]\n", gFlops(N, tm.Seconds()), gFlops(N, reftm.Seconds())) } if !ok { //fmt.Printf("A orig:\n%v\n", Ac) saveData(Ac) } return } if refTest { tm = runRefTest(A, testCount, KB) } else { tm = runTest(A, testCount, KB) } if asGflops { fmt.Printf("%.4f Gflops\n", gFlops(N, tm.Seconds())) } else { fmt.Printf("%vs\n", tm.Seconds()) } return } if len(sizeList) > 0 { sizes = parseSizeList(sizeList) } var times map[int]float64 if refTest { times = runTestsForSizes(runRefTest, sizes) } else { times = runTestsForSizes(runTest, sizes) } if asGflops { if verbose { fmt.Printf("calculating Gflops ...\n") } for sz := range times { times[sz] = gFlops(sz, times[sz]) } } // print out as python dictionary fmt.Printf("{") i := 0 for sz := range times { if i > 0 { fmt.Printf(", ") } fmt.Printf("%d: %v", sz, times[sz]) i++ } fmt.Printf("}\n") }