The LAPACK forum has moved to https://github.com/Reference-LAPACK/lapack/discussions.

how to get eigenvalues of symetric matrix

Open discussion regarding features, bugs, issues, vendors, etc.

Postby benndamann33 » Fri Oct 20, 2006 1:36 pm

I am using lapack-3 which is optimized for debian. It's in fortran. I'm using blas-3 which I believe is from the refblas package and says it's fro c/fortran interfaces. I am now using the following code to compile

g++ internet.cpp -o who.out /usr/lib/liblapack-3.a /usr/lib/libblas-3.a -lg2c -lm


But am recieved identical errors. If I sued g77, same error occurs about the cc1plus directory not found.
benndamann33
 
Posts: 11
Joined: Mon Oct 16, 2006 12:32 pm

Postby Julie » Sun Oct 22, 2006 4:14 pm

Hello,

your problem is that your application code is in C++ and LAPACK is in Fortran. A code in C++ requires to have the C++ runtime libraries. A code in F77 requires to have the F77 runtime libraries.

By default the linker g++ will include the C++ runtime libraries but not the Fortran runtime libraries.
Vice versa, the linker g77 will include the Fortran runtime libraries but not the C++ runtime libraries.

So if you want to link with g77, you will at least need to add -lstdc++ that is to say provide manually the runtime libraries from C++.
If you want to link with g++, you will need to add -lg2c and -lm in order to provide the Fortran runtime libraries

This gives something like:

LINKER G77
Code:

g++ -c internet.cpp
g77 internet.o -o exe /usr/lib/liblapack.a /usr/lib/sse/libf77blas.a /usr/lib/sse/libatlas.a -lstdc++


LINKER G++
Code:

g++ -c internet.cpp
g++ internet.o -o exe /usr/lib/liblapack.a /usr/lib/sse/libf77blas.a /usr/lib/sse/libatlas.a -lg2c -lm


LINKER GCC
Code:

g++ -c internet.cpp
gcc internet.o -o exe /usr/lib/liblapack.a /usr/lib/sse/libf77blas.a /usr/lib/sse/libatlas.a -lg2c -lm -lstdc++


If you want to know what libraries a given linker add by default, a nice option with GCC, G77, G++ is the -v option, try:
Code:

gcc -v internet.o -o exe /usr/lib/liblapack.a /usr/lib/sse/libf77blas.a /usr/lib/sse/libatlas.a -lg2c -lm

This will give you exactly what the compiler is doing. Useful if you want to really understand what's going on when you link with g++ (for example).

Hope this will work this time for you,

Julie
Julie
 
Posts: 299
Joined: Wed Feb 23, 2005 12:32 am
Location: ICL, Denver. Colorado

Postby bruce » Thu Nov 09, 2006 11:43 am

Hi, Julie

Here is the compilation and link setting when I compile the code.

g77 -O3 test_pdsyev.o /home/xiaofeng/SCALAPACK/libscalapack.a /home/xiaofeng/BLACS/LIB/blacsCinit_MPI-LINUX-1.a
/home/xiaofeng/BLACS/LIB/blacsF77init_MPI-LINUX-1.a
/home/xiaofeng/BLACS/LIB/blacs_MPI-LINUX-1.a
/home/xiaofeng/ATLAS/lib/linux_x8664sse2/libf77blas.a /home/xiaofeng/ATLAS/lib/linux_x8664sse2/libatlas.a /opt/MPICH2/lib/libmpich.a -o test_pdsyev

I got some errors like this:

========================
/opt/MPICH2/lib/libmpich.a(info_getnth.o)(.text+0x320): In function `PMPI_Info_get_nthkey':
: undefined reference to `pthread_setspecific'
/opt/MPICH2/lib/libmpich.a(info_getvallen.o)(.text+0x5d): In function `PMPI_Info_get_valuelen':
: undefined reference to `pthread_getspecific'
/opt/MPICH2/lib/libmpich.a(info_getvallen.o)(.text+0x8a): In function `PMPI_Info_get_valuelen':
: undefined reference to `pthread_setspecific'
/opt/MPICH2/lib/libmpich.a(info_getvallen.o)(.text+0x3e4): In function `PMPI_Info_get_valuelen':
: undefined reference to `pthread_getspecific'
/opt/MPICH2/lib/libmpich.a(info_getvallen.o)(.text+0x411): In function `PMPI_Info_get_valuelen':
: undefined reference to `pthread_setspecific'
/opt/MPICH2/lib/libmpich.a(comm_create_keyval.o)(.text+0x55): In function `PMPI_Comm_create_keyval':
: undefined reference to `pthread_getspecific'
/opt/MPICH2/lib/libmpich.a(comm_create_keyval.o)(.text+0x82): In function `PMPI_Comm_create_keyval':
: undefined reference to `pthread_setspecific'
/opt/MPICH2/lib/libmpich.a(comm_create_keyval.o)(.text+0x1fc): In function `PMPI_Comm_create_keyval':
: undefined reference to `pthread_getspecific'
/opt/MPICH2/lib/libmpich.a(comm_create_keyval.o)(.text+0x229): In function `PMPI_Comm_create_keyval':
: undefined reference to `pthread_setspecific'
/opt/MPICH2/lib/libmpich.a(gather.o)(.text+0x1039): In function `PMPI_Gather':
: undefined reference to `pthread_getspecific'
/opt/MPICH2/lib/libmpich.a(gather.o)(.text+0x1066): In function `PMPI_Gather':
: undefined reference to `pthread_setspecific'
/opt/MPICH2/lib/libmpich.a(gather.o)(.text+0x24ae): In function `PMPI_Gather':
: undefined reference to `pthread_getspecific'
/opt/MPICH2/lib/libmpich.a(gather.o)(.text+0x24db): In function `PMPI_Gather':
: undefined reference to `pthread_setspecific'
/opt/MPICH2/lib/libmpich.a(gather.o)(.text+0x25b1): In function `PMPI_Gather':
: undefined reference to `pthread_getspecific'
/opt/MPICH2/lib/libmpich.a(gather.o)(.text+0x25de): In function `PMPI_Gather':
: undefined reference to `pthread_setspecific

==============================

I am not sure if I should link it with gcc

gcc test_pdsyev.c -o test_pdsyev -L//home/xiaofeng/SCALAPACK/libscalapack.a /home/xiaofeng/BLACS/LIB/blacsCinit_MPI-LINUX-1.a /home/xiaofeng/BLACS/LIB/blacsF77init_MPI-LINUX-1.a /home/xiaofeng/BLACS/LIB/blacs_MPI-LINUX-1.a /home/xiaofeng/ATLAS/lib/linux_x8664sse2/libf77blas.a /home/xiaofeng/ATLAS/lib/linux_x8664sse2/libatlas.a /opt/MPICH2/lib/libmpich.a

Thanks.

Bruce
bruce
 
Posts: 36
Joined: Mon Sep 25, 2006 5:11 am

Postby Julien Langou » Thu Nov 09, 2006 12:07 pm

Hello Bruce,

you are missing the pthread library a priori or something like this in your link.
You might want to try simply adding -lpthread at the end of the line for the link.

Although using g77 as a linker and adding all the libraries that you will need to create an MPI application will eventually work, this is not the recommended way to do it. MPI developers (and the MPI standard) clearly recommend to link with mpif77. mpif77 will call g77 for you but moreover all the libraries that the MPI layer needs, this avoid you the problem you just metionned. Linking with MPI can become quite complex. With MPICH-1 in general you are fine by simply linking with "g77 {your .o} {your .a} libmpich.a" but this is not a general rule.

The ScaLAPACK default Makefile works on the not-recommended model, it has been done a long time ago and we might want to change it at a point.

Julien.
Julien Langou
 
Posts: 835
Joined: Thu Dec 09, 2004 12:32 pm
Location: Denver, CO, USA

Postby bruce » Thu Nov 09, 2006 2:44 pm

Hi, Julien

Thanks for your reply. so you mean I 'd better use MPIF77 compiler and it will take care of the multi-thread lirary thing and the way of compiling with g77 by adding -lpthread at the end of the line for the link is a lagacy way.

Ok. I will try. And I am curious. Since the main file is written in c. Shall I use mpicc instead of mpif77?

Are there any manuals for testing the scalapack routines in C or even with MPI C? Since the goal of designing the routine is for parallel computing and there are great demand in calling these routines from C, especially in linux or unix.(I do not know windows). I once did write some simple fortran routine and put the object in archived format .a file to call it from C but this time I find it is too much for me to know the inside of the mechnism in scalapack.

Thank you for all your help.

Bruce
bruce
 
Posts: 36
Joined: Mon Sep 25, 2006 5:11 am

Postby bruce » Thu Nov 09, 2006 4:01 pm

Hi,

This is a new update. I use the following command to compile the code. It can be sucessfully compiled. However, I have errors in running the executables. I hope you can help.

mpif77 test_pdsyev.c /home/xiaofeng/SCALAPACK/libscalapack.a /home/xiaofeng/BLACS/LIB/blacsCinit_MPI-LINUX-1.a /home/xiaofeng/BLACS/LIB/blacsF77init_MPI-LINUX-1.a /home/xiaofeng/BLACS/LIB/blacs_MPI-LINUX-1.a /home/xiaofeng/ATLAS/lib/linux_x8664sse2/libf77blas.a /home/xiaofeng/ATLAS/lib/linux_x8664sse2/libatlas.a /opt/MPICH2/lib/libmpich.a -o test_pdsyev

I am using MPICH2.

Here are some information of my startup of nodes for MPI.

[xiaofeng@athena ~]$ mpdboot -n 8
[xiaofeng@athena ~]$ mpdtrace
athena
oscarnode4
oscarnode1
oscarnode3
oscarnode2
oscarnode7
oscarnode6
oscarnode5

[xiaofeng@athena s_code]$ ls
blacs.h blas.h error1.log error.log lagacy_makefile Makefile Makefile.opts result scalapack.h test_pdsyev.c
[xiaofeng@athena s_code]$ mpif77 test_pdsyev.c /home/xiaofeng/SCALAPACK/libscalapack.a /home/xiaofeng/BLACS/LIB/blacsCinit_MPI-LINUX-1.a /home/xiaofeng/BLACS/LIB/blacsF77init_MPI-LINUX-1.a /home/xiaofeng/BLACS/LIB/blacs_MPI-LINUX-1.a /home/xiaofeng/ATLAS/lib/linux_x8664sse2/libf77blas.a /home/xiaofeng/ATLAS/lib/linux_x8664sse2/libatlas.a /opt/MPICH2/lib/libmpich.a -o test_pdsyev

[xiaofeng@athena s_code]$ ls
blacs.h blas.h error1.log error.log lagacy_makefile Makefile Makefile.opts result scalapack.h test_pdsyev test_pdsyev.c

I successfully get the executable test_pdsyev.
Then I run it. I got errors like this:

==============================
[xiaofeng@athena s_code]$ mpiexec -n 8 ./test_pdsyev
rank 7 in job 1 athena.cs.siu.edu_44953 caused collective abort of all ranks
exit status of rank 7: return code 1
BLACS ERROR 'Invalid context handle: 0'
from {-1,-1}, pnum=2, Contxt=-1, on line 38 of file 'BI_BlacsErr.c'.

[cli_2]: aborting job:
application called MPI_Abort(MPI_COMM_WORLD, 1) - process 2
BLACS ERROR 'Invalid context handle: 0'
from {-1,-1}, pnum=6, Contxt=-1, on line 38 of file 'BI_BlacsErr.c'.

[cli_6]: aborting job:
application called MPI_Abort(MPI_COMM_WORLD, 1) - process 6
BLACS ERROR 'Invalid context handle: 0'
from {-1,-1}, pnum=5, Contxt=-1, on line 38 of file 'BI_BlacsErr.c'.

[cli_5]: aborting job:
application called MPI_Abort(MPI_COMM_WORLD, 1) - process 5
BLACS ERROR 'Invalid context handle: 0'
from {-1,-1}, pnum=1, Contxt=-1, on line 38 of file 'BI_BlacsErr.c'.

[cli_1]: aborting job:
application called MPI_Abort(MPI_COMM_WORLD, 1) - process 1
BLACS ERROR 'Invalid context handle: 0'
from {-1,-1}, pnum=3, Contxt=-1, on line 38 of file 'BI_BlacsErr.c'.

[cli_3]: aborting job:
application called MPI_Abort(MPI_COMM_WORLD, 1) - process 3
BLACS ERROR 'Invalid context handle: 0'
from {-1,-1}, pnum=
4, Contxt=-1, on line 38 of file 'BI_BlacsErr.c'.

[cli_4]: aborting job:
application called MPI_Abort(MPI_COMM_WORLD, 1) - process 4
BLACS ERROR 'Invalid context handle: 0'
from {-1,-1}, pnum=7, Contxt=-1, on line 38 of file 'BI_BlacsErr.c'.

[cli_7]: aborting job:
application called MPI_Abort(MPI_COMM_WORLD, 1) - process 7
rank 6 in job 1 athena.cs.siu.edu_44953 caused collective abort of all ranks
exit status of rank 6: return code 1
rank 5 in job 1 athena.cs.siu.edu_44953 caused collective abort of all ranks
exit status of rank 5: return code 1
rank 4 in job 1 athena.cs.siu.edu_44953 caused collective abort of all ranks
exit status of rank 4: return code 1
rank 3 in job 1 athena.cs.siu.edu_44953 caused collective abort of all ranks
exit status of rank 3: return code 1
rank 2 in job 1 athena.cs.siu.edu_44953 caused collective abort of all ranks
exit status of rank 2: return code 1
rank 1 in job 1 athena.cs.siu.edu_44953 caused collective abort of all ranks
exit status of rank 1: return code 1

Hope you can help>

Thanks

Bruce
bruce
 
Posts: 36
Joined: Mon Sep 25, 2006 5:11 am

advice just fine to my problem, but..

Postby gortiz » Wed Feb 27, 2008 4:38 pm

[quote="Julien Langou"]Hello Bruce,

you are missing the pthread library a priori or something like this in your link.
You might want to try simply adding -lpthread at the end of the line for the link.

I have the same linking problem with AMD extension for scalapack and just
like Julien said above, this work.

But, I have still get a llinking problem with an unknow for me, it is:

pxerbla.f:(.text+0x36): undefined reference to `_gfortran_filename'

Could you help me again?

thanks a lot

g
gortiz
 
Posts: 29
Joined: Fri Aug 17, 2007 8:23 pm
Location: Corrientes, Arg.

Postby Julien Langou » Wed Feb 27, 2008 5:05 pm

I am not sure I will be able to be that helpful on this one.
Obviously you are missing a gfortran library. Here are some fixes, I am
not sure anyone would do the trick but that what I would try myself.
0- Try to rebuild everything (by cleaning up first!) and then use only one
mpif90. Cross your fingers because if that removes the problem that was the
easy way to go. You might also need to use a LAPACK compiled with the
same compiler.
1- At link time, use an mpif90 that relies on gfortran
2- go and find where this _gfortran_filename function is defined on your
system and hard give the location when you build the executables. You can
for example add the location of the library containing _gfortran_filename
Julien.
Julien Langou
 
Posts: 835
Joined: Thu Dec 09, 2004 12:32 pm
Location: Denver, CO, USA

_gfortran_x

Postby gortiz » Wed Feb 27, 2008 6:00 pm

Thank a lot for so quickly response !

Yes, I need think about it a lot. But let me say
that I'm trying to use prebuilted libs of scalapack provided by AMD.
And I needed to build mpich2 library first of all. I mean, actually I'm
building libs of mpi such as libmpich, etc. Then, when trying to compile with
gfortran-4.1 a test example, I get the undefined reference error message.

OK, fine, thank very much, your posted message save the day for me!
saludos,
g.

Julien Langou wrote:I am not sure I will be able to be that helpful on this one.
Obviously you are missing a gfortran library. Here are some fixes, I am
not sure anyone would do the trick but that what I would try myself.
0- Try to rebuild everything (by cleaning up first!) and then use only one
mpif90. Cross your fingers because if that removes the problem that was the
easy way to go. You might also need to use a LAPACK compiled with the
same compiler.
1- At link time, use an mpif90 that relies on gfortran
2- go and find where this _gfortran_filename function is defined on your
system and hard give the location when you build the executables. You can
for example add the location of the library containing _gfortran_filename
Julien.
gortiz
 
Posts: 29
Joined: Fri Aug 17, 2007 8:23 pm
Location: Corrientes, Arg.

Previous

Return to User Discussion

Who is online

Users browsing this forum: No registered users and 4 guests