Page 1 of 1

C wrapper for ScaLapack (SOS)

PostPosted: Wed Feb 15, 2006 7:36 pm
by w30279
Could someone show me one simple example of C program using Scalapack routine, say pdgesvd? I have desperately searched the web but no success yet.

Are there additional libraries I would need to link other than the scalapack, F77blacs, Cblacs, blacs, and blas, and in what order?

I am not a fortran guy. I am learning MPI and want to use some scalapack routines in my class.

thanks,
Nadeem

PostPosted: Thu Feb 16, 2006 3:44 pm
by Julien Langou
Hello,

so we are working for better C support for LAPACK and ScaLAPACK right now. Some of the files I will give away now are to be considered as temporary and just to help you.
Just be ready to discard this in the future.

You can find a demo code (it is just one of our scalapack tester that I have cleaned) at:
test_pdgesvd.c
it needs some header files, you can find (highly temporary) them at:
blas.h lapack.h blacs.h scalapack.h

you compile the .c file with the regular mpicc
then you link with mpif77 using the scalapack/blacs/blas libraries

this gives on my machine:

mpicc -O3 -Wall -c test_pdgesvd.c -o test_pdgesvd.o
mpif77 test_pdgesvd.o pdgesvd.o -lscalapack -lblacsF77init -lblacs -lf77blas -latlas -o test_pdgesvd


So I will certainly erase this post in a near future since we are writing all this in a more consistent manner but basically it should help you running using scalapack.

So for the SVD: you need to use on scalapack-1.7.1 at least, otherwise it is not going to work. You can have the new version at:
scalapack-1.7.1.tgz

Julien

PostPosted: Thu Feb 16, 2006 4:50 pm
by w30279
Thanks a lot Julien. I am posting this before testing so as to let you know that I have downloaded all the files and packages in case you wanted to remove those.

Thanks,
Nadeem

Linking error!!

PostPosted: Mon Feb 27, 2006 7:20 pm
by w30279
Linking gives me the following error:

-------------------------------
mpif77 -o test_pdgesvd test_pdgesvd.o \
-L$SCALAPACK/LIB -lscalapack \
-L$BLACS/LIB -lblacsF77init \
-L$BLACS/LIB -lblacs
-L$BLACS/LIB -lblacsF77init \
-L$BLAS/LIB -lblas
test_pdgesvd.o(.text+0x50): In function `main':
: multiple definition of `main'
/export/usr/pgi/linux86/6.0/lib/pgfmain.o(.text+0x10): first defined here
/usr/bin/ld: Warning: size of symbol `main' changed from 122 in /export/usr/pgi/linux86/6.0/lib/pgfmain.o to 2445 in test_pdgesvd.o
/export/usr/pgi/linux86/6.0/lib/pgfmain.o(.text+0x69): In function `main':
: undefined reference to `MAIN_'
make: *** [test_pdgesvd] Error 2
-------------------------------

PLATFORM: Intel running linux 2.4.19, MPICH 1.2.7, pgf77 6.0-8 32-bit target on x86 Linux.

Googling the eroor, I was able to find some explanations as to why this error occurs, but could not find a solution for this to work.

Thanks,
Nadeem

PostPosted: Tue Feb 28, 2006 12:48 pm
by Julien Langou
Yep, this is a classic problem with Portland Group Fortran compiler and other Fortran compilers as well. It happens when you are using pgf for example, when you have the main of your code written in C (test_pdgesvd.c) and you are using Fortran routines beneath (ScaLAPACK), so you want to use the Fortran compiler to do the link. (I guess this is our case here...) The problem is that some Fortran linker have their own main and since there is already a main coming from the C source, there is conflict.

For the pgf compiler, the workaround is to add the “-Mnomain” flag during link time, I think. (Never tried it though, let me know if this works for you, please.)

Julien

PostPosted: Tue Feb 28, 2006 5:51 pm
by w30279
Thanks again Julian.

The -Monmain option solved the problem, and the program worked fine. :)

Nadeem

PostPosted: Tue Feb 28, 2006 5:52 pm
by w30279
Sorry for the name spellings, Julien.

scalapack1.7.1 psgesvd.f compilation error

PostPosted: Sat Apr 08, 2006 5:26 pm
by w30279
Hi again,
Recently, I was trying to install the scalapack1.7.1 on my local linux box (FC4). I am getting the following compilation (SLmake) error:
#----------------------------------------
$ gfortran -c psgesvd.f
In file psgesvd.f:431
+ MAX(WSBDSQR,MAX(WANTU*WPSORMBRQLN,
1
Error: Generic function 'max' at (1) is not consistent with a specific intrinsic interface
#----------------------------------------
Your suggestion would be appreciated.
Thanks,
Nadeem

P.S. Previously, I had compiled it succesfully on grid at the Wayne State University.

PostPosted: Mon Apr 17, 2006 3:43 pm
by Julien Langou
Hello, yes this is normal, please do not use 1.7.1, this has been fixed in 1.7.2, Julien

PostPosted: Mon Apr 17, 2006 3:53 pm
by w30279
Thanks for the update.

Nadeem