Skip to content
This repository has been archived by the owner on Nov 24, 2018. It is now read-only.

Adddtrtri #52

Merged
merged 4 commits into from
Sep 13, 2015
Merged

Adddtrtri #52

merged 4 commits into from
Sep 13, 2015

Conversation

btracey
Copy link
Member

@btracey btracey commented Sep 12, 2015

No description provided.

@btracey
Copy link
Member Author

btracey commented Sep 12, 2015

This very reliably crashed in cgo in Dlansy

brendan:~/Documents/mygo/src/github.com/gonum/lapack/cgo$ go test
--- FAIL: TestDlantr (0.04s)
    dlantr.go:77: Norm mismatch. norm = O, unitdiag = true, upper = true, m = 5, n = 10, lda = 11, Want -7, got 6.371521178048223.
    dlantr.go:77: Norm mismatch. norm = O, unitdiag = true, upper = true, m = 5, n = 10, lda = 11, Want -7, got 4.167894107105489.
fatal error: unexpected signal during runtime execution
[signal 0xb code=0x1 addr=0x0 pc=0x4f06aae]

runtime stack:
runtime.throw(0x4253460, 0x2a)
    /Users/brendan/gover/go/src/runtime/panic.go:527 +0x90
runtime.sigpanic()
    /Users/brendan/gover/go/src/runtime/sigpanic_unix.go:12 +0x5a

goroutine 1102 [syscall, locked to thread]:
runtime.cgocall(0x400ce60, 0xc82003c9d8, 0xc800000000)
    /Users/brendan/gover/go/src/runtime/cgocall.go:120 +0x11b fp=0xc82003c990 sp=0xc82003c960
github.com/gonum/lapack/cgo/clapack._Cfunc_LAPACKE_dlansy(0x554f00000065, 0x3, 0xc82141a910, 0x3, 0x0)
    github.com/gonum/lapack/cgo/clapack/_obj/_cgo_gotypes.go:6605 +0x3a fp=0xc82003c9d8 sp=0xc82003c990
github.com/gonum/lapack/cgo/clapack.Dlansy(0x4f, 0x55, 0x3, 0xc82141a910, 0x9, 0x9, 0x3, 0x1)
    /Users/brendan/Documents/mygo/src/github.com/gonum/lapack/cgo/clapack/clapack.go:3044 +0x72 fp=0xc82003ca18 sp=0xc82003c9d8
github.com/gonum/lapack/cgo.Implementation.Dlansy(0x4f, 0x79, 0x3, 0xc82141a910, 0x9, 0x9, 0x3, 0xc82141a960, 0x9, 0x9, ...)
    /Users/brendan/Documents/mygo/src/github.com/gonum/lapack/cgo/lapack.go:107 +0x12e fp=0xc82003ca70 sp=0xc82003ca18
github.com/gonum/lapack/cgo.(*Implementation).Dlansy(0x4316d00, 0x4f, 0x79, 0x3, 0xc82141a910, 0x9, 0x9, 0x3, 0xc82141a960, 0x9, ...)
    <autogenerated>:2 +0x10c fp=0xc82003cad0 sp=0xc82003ca70
github.com/gonum/lapack/testlapack.DpoconTest(0xc8200957a0, 0xe9816f8, 0x4316d00)
    /Users/brendan/Documents/mygo/src/github.com/gonum/lapack/testlapack/dpocon.go:54 +0x3de fp=0xc82003cf28 sp=0xc82003cad0
github.com/gonum/lapack/cgo.TestDpocon(0xc8200957a0)
    /Users/brendan/Documents/mygo/src/github.com/gonum/lapack/cgo/lapack_test.go:91 +0x76 fp=0xc82003cf68 sp=0xc82003cf28
testing.tRunner(0xc8200957a0, 0x4305e98)
    /Users/brendan/gover/go/src/testing/testing.go:456 +0x98 fp=0xc82003cfa0 sp=0xc82003cf68
runtime.goexit()
    /Users/brendan/gover/go/src/runtime/asm_amd64.s:1696 +0x1 fp=0xc82003cfa8 sp=0xc82003cfa0
created by testing.RunTests
    /Users/brendan/gover/go/src/testing/testing.go:561 +0x86d

goroutine 1 [chan receive]:
testing.RunTests(0x426ad38, 0x4305d60, 0x10, 0x10, 0x0)
    /Users/brendan/gover/go/src/testing/testing.go:562 +0x8ad
testing.(*M).Run(0xc83735fef8, 0x4023188)
    /Users/brendan/gover/go/src/testing/testing.go:494 +0x70
main.main()
    github.com/gonum/lapack/cgo/_test/_testmain.go:84 +0x116

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
    /Users/brendan/gover/go/src/runtime/asm_amd64.s:1696 +0x1
exit status 2
FAIL    github.com/gonum/lapack/cgo 4.132s
''''

Presumably these code modifications are not the cause.

@btracey
Copy link
Member Author

btracey commented Sep 12, 2015

Checking I have up to date OpenBLAS

@btracey
Copy link
Member Author

btracey commented Sep 12, 2015

After updating, the crashes are intermittant, and look like they may have Dlantr as the root cause.

@kortschak
Copy link
Member

Try making the minor change I have here to see if the fault goes away.

@kortschak
Copy link
Member

I don't see faults here in either state of OpenBLAS, but I do see this:

$ go test -cpu 2,2,2,2,2,2,2,2,2,2,2,2,2 -run Dtrtri -v github.com/gonum/lapack/cgo
=== RUN   TestDtrtri
--- PASS: TestDtrtri (0.06s)
=== RUN   TestDtrtri
--- PASS: TestDtrtri (0.05s)
=== RUN   TestDtrtri
--- PASS: TestDtrtri (0.06s)
=== RUN   TestDtrtri
--- FAIL: TestDtrtri (0.05s)
    dtrtri.go:84: inv(A) * A != I. Upper = true, unit = true, n = 200, lda = 205
=== RUN   TestDtrtri
--- PASS: TestDtrtri (0.06s)
=== RUN   TestDtrtri
--- PASS: TestDtrtri (0.06s)
=== RUN   TestDtrtri
--- PASS: TestDtrtri (0.05s)
=== RUN   TestDtrtri
--- PASS: TestDtrtri (0.06s)
=== RUN   TestDtrtri
--- PASS: TestDtrtri (0.06s)
=== RUN   TestDtrtri
--- PASS: TestDtrtri (0.06s)
=== RUN   TestDtrtri
--- PASS: TestDtrtri (0.06s)
=== RUN   TestDtrtri
--- FAIL: TestDtrtri (0.06s)
    dtrtri.go:84: inv(A) * A != I. Upper = true, unit = true, n = 200, lda = 200
    dtrtri.go:84: inv(A) * A != I. Upper = true, unit = true, n = 200, lda = 205
=== RUN   TestDtrtri
--- PASS: TestDtrtri (0.06s)

The pattern of success/failure is consistent over runs which suggests to me that it's a function of the PRNG and so the failures are matrix element dependent.

@btracey btracey mentioned this pull request Sep 13, 2015
@kortschak
Copy link
Member

Do you have any idea about the failures above?

// Dtrtri computes the inverse of a triangular matrix, storing the result in place
// into a. This is the BLAS level 3 version of the algorithm.
//
// Dtrti returns whether the matrix a is singular.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returns whether it's singular or whether it's not singular; ok is ambiguous here. I think we have words elsewhere that dealt with this better.

It's worth explaining briefly the difference here between the BLAS level 3 and 2 algorithms.

@kortschak
Copy link
Member

LGTM, except minor comments and I'd like to now about the failures in cgo.

@btracey
Copy link
Member Author

btracey commented Sep 13, 2015

Do the failures go away when you decrease the tolerance (make it closer to 1)? The condition number of these randomly generated matrices is often pretty bad, so the error in the final solution can be high even when the algorithm is correct. You can see how high it has to be in Dgetri, so maybe it needs to be higher here as well.

@btracey
Copy link
Member Author

btracey commented Sep 13, 2015

(The failures don't happen on my machine)

@kortschak
Copy link
Member

They go away at 1e-4.

btracey added a commit that referenced this pull request Sep 13, 2015
@btracey btracey merged commit 06e6694 into master Sep 13, 2015
@btracey btracey deleted the adddtrtri branch September 13, 2015 05:52
// into a. This is the BLAS level 3 version of the algorithm which builds upon
// Dtrti2 to operate on matrix blocks instead of only individual columns.
//
// Dtrti returns whether the matrix a is singular or whether it's not singular.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could be better: "Dtrtri will not perform the inversion if the matrix is singular, and returns a boolean indicating whether the inversion was successful."

I think that covers the behaviour.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants