LAPACK problems

73 views
Skip to first unread message

Dave Mazzoni

unread,
Jan 13, 2017, 12:35:38 PM1/13/17
to gonum-dev
Hi all - I'm trying to get go running with the OpenBLAS library. I just installed 1.8rc1 in case it matters. Here is what I'm doing:

After several seconds, I get many errors of this sort:
...
/tmp/go-build240658416/github.com/gonum/lapack/cgo/lapacke/_obj/lapacke.cgo2.o: In function `_cgo_8ea242716dd6_Cfunc_LAPACKE_zupgtr_work':
gonum/lapack/cgo/lapacke/cgo-gcc-prolog:32780: undefined reference to `LAPACKE_zupgtr_work'
/tmp/go-build240658416/github.com/gonum/lapack/cgo/lapacke/_obj/lapacke.cgo2.o: In function `_cgo_8ea242716dd6_Cfunc_LAPACKE_zupmtr_work':
gonum/lapack/cgo/lapacke/cgo-gcc-prolog:32810: undefined reference to `LAPACKE_zupmtr_work'
collect2: error: ld returned 1 exit status

What am I doing wrong?
Dave

Dave Mazzoni

unread,
Jan 13, 2017, 1:40:10 PM1/13/17
to gonum-dev
 I was not RTFMing. After reading and executing the install as specified in the README.md, this works:
CGO_LDFLAGS="-L/opt/Downloads/OpenBLAS -lopenblas" go get -u github.com/gonum/lapack
without any errors.

Is it necessary to go into each of the gonum component directories and do, for example CGO_LDFLAGS="-L/path/to/OpenBLAS -lopenblas" go install github.com/gonum/lapack/cgo ?

Dave Mazzoni

unread,
Jan 13, 2017, 5:19:57 PM1/13/17
to gonum-dev
Now I'm having trouble with clapack. I've installed it properly, but at compile time I get this:
 CGO_LDFLAGS="-L/opt/Downloads/OpenBLAS -lopenblas" go build cgeev.go
cgeev.go:10:2: cannot find package "github.com/gonum/lapack/cgo/clapack" in any of:
/usr/local/go/src/github.com/gonum/lapack/cgo/clapack (from $GOROOT)
/opt/Projects/Golang/src/github.com/gonum/lapack/cgo/clapack (from $GOPATH)

Has something changed with lapack? This used to work...

On Friday, January 13, 2017 at 12:35:38 PM UTC-5, Dave Mazzoni wrote:

Brendan Tracey

unread,
Jan 15, 2017, 11:45:13 AM1/15/17
to gonum-dev
Do you have a reproducer? That seems like a Go error, not a C one.

From what I understand, the compilation knows the value of CGO_LDFLAGS, so if you want to change that value, you have to recompile.

Vladimír Chalupecký

unread,
Jan 15, 2017, 3:09:38 PM1/15/17
to gonum-dev
We renamed the clapack package to lapacke some time ago. I guess that renaming the import path in your could will fix the issue.

Dave Mazzoni

unread,
Jan 17, 2017, 11:24:56 AM1/17/17
to gonum-dev
That was it!  Here's my code:
--------------------------------------
// Simple Eigenvalue calculation using LAPACK/CGO functions
// Built with:
// CGO_LDFLAGS="-L/opt/Downloads/OpenBLAS -lopenblas" go build cgeev.go
package main

import (
"fmt"

)

func main() {
jobvl := lapack.Job('V')
jobvr := lapack.Job('V')
n, lda, ldvl, lvdr, lwork := 2, 2, 2, 2, 4
a := []complex128{1 + 1i, 2 - 1i, 2 + 1i, 1 - 1i}
showMatrix("Working matrix:", a)
w := make([]complex128, 2)
vl := make([]complex128, 4)
vr := make([]complex128, 4)
work := make([]complex128, 4)
rwork := make([]float64, 4)
lapacke.Zgeev(jobvl, jobvr, n, a, lda, w, vl, ldvl, vr, lvdr,
work, lwork, rwork)
showMatrix("Left Eigenvectors:", vl)
showMatrix("Right Eigenvectors:", vr)
showMatrix("Eigenvalues:", w)
}

func showMatrix(label string, m []complex128) {
fmt.Printf("\n%s:\n", label)
for i := range m {
fmt.Printf("%4.2f\t", m[i])
if i%2 != 0 {
fmt.Printf("\n")
}
}
}
---------------------------------------
go build zgeev.go  (runs without any errors and produces zgeev executable)
./zgeev
Working matrix::
(1.00+1.00i) (2.00-1.00i)
(2.00+1.00i) (1.00-1.00i)

Left Eigenvectors::
(0.71+0.00i) (0.71+0.00i)
(0.42+0.57i) (-0.71-0.00i)

Right Eigenvectors::
(0.71-0.00i) (0.71+0.00i)
(0.71+0.00i) (-0.42-0.57i)

Eigenvalues::
(3.00-0.00i) (-1.00+0.00i)

Thanks for the help!
Dave
Reply all
Reply to author
Forward
0 new messages