superLU linking with intel fortran and MKL in Ubuntu 10.04

superLU linking with intel fortran and MKL in Ubuntu 10.04

Helo,

I'm running ubuntu 10.04 and I use intel fortran 11.1.069 with the latest MKL version. I want to use superLU library but I don't know how to link it with BLAS and how to call the routines in my programs. I have also installed superLU 3 which was in the ubuntu repositories but I don't think it is linked with intel fortran. I attach the readme and the make.inc file in order to make clearer what I ask.

Thanks in advance!!

README

SuperLU (Version 4.0)
=====================

Copyright (c) 2003, The Regents of the University of California, through
Lawrence Berkeley National Laboratory (subject to receipt of any required
approvals from U.S. Dept. of Energy)

All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

(1) Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
(2) Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
(3) Neither the name of Lawrence Berkeley National Laboratory, U.S. Dept. of
Energy nor the names of its contributors may be used to endorse or promote
products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

SuperLU contains a set of subroutines to solve a sparse linear system
A*X=B. It uses Gaussian elimination with partial pivoting (GEPP).
The columns of A may be preordered before factorization; the
preordering for sparsity is completely separate from the factorization.

SuperLU is implemented in ANSI C, and must be compiled with standard
ANSI C compilers. It provides functionality for both real and complex
matrices, in both single and double precision. The file names for the
single-precision real version start with letter "s" (such as sgstrf.c);
the file names for the double-precision real version start with letter "d"
(such as dgstrf.c); the file names for the single-precision complex
version start with letter "c" (such as cgstrf.c); the file names
for the double-precision complex version start with letter "z"
(such as zgstrf.c).

SuperLU contains the following directory structure:

SuperLU/README instructions on installation
SuperLU/CBLAS/ needed BLAS routines in C, not necessarily fast
SuperLU/DOC/ Users' Guide and documentation of source code
SuperLU/EXAMPLE/ example programs
SuperLU/FORTRAN/ Fortran interface
SuperLU/INSTALL/ test machine dependent parameters; the Users' Guide.
SuperLU/MAKE_INC/ sample machine-specific make.inc files
SuperLU/MATLAB/ Matlab mex-file interface
SuperLU/SRC/ C source code, to be compiled into the superlu.a library
SuperLU/TESTING/ driver routines to test correctness
SuperLU/Makefile top level Makefile that does installation and testing
SuperLU/make.inc compiler, compile flags, library definitions and C
preprocessor definitions, included in all Makefiles.
(You may need to edit it to be suitable for your system
before compiling the whole package.)

Before installing the package, please examine the three things dependent
on your system setup:

1. Edit the make.inc include file.
This make include file is referenced inside each of the Makefiles
in the various subdirectories. As a result, there is no need to
edit the Makefiles in the subdirectories. All information that is
machine specific has been defined in this include file.

Example machine-specific make.inc include files are provided
in the MAKE_INC/ directory for several systems, such as
IBM RS/6000, DEC Alpha, SunOS 4.x, SunOS 5.x (Solaris), HP-PA and
SGI Iris 4.x. When you have selected the machine to which you wish
to install SuperLU, copy the appropriate sample include file (if one
is present) into make.inc. For example, if you wish to run
SuperLU on an IBM RS/6000, you can do

cp MAKE_INC/make.rs6k make.inc

For the systems other than listed above, slight modifications to the
make.inc file will need to be made.

2. The BLAS library.
If there is BLAS library available on your machine, you may define
the following in the file SuperLU/make.inc:
BLASDEF = -DUSE_VENDOR_BLAS
BLASLIB =

The CBLAS/ subdirectory contains the part of the C BLAS needed by
SuperLU package. However, these codes are intended for use only if there
is no faster implementation of the BLAS already available on your machine.
In this case, you should do the following:

1) In SuperLU/make.inc, undefine (comment out) BLASDEF, and define:
BLASLIB = ../lib/blas$(PLAT).a

2) Go to the SuperLU/ directory, type:
make blaslib
to make the BLAS library from the routines in the CBLAS/ subdirectory.

3. C preprocessor definition CDEFS.
In the header file SRC/slu_Cnames.h, we use macros to determine how
C routines should be named so that they are callable by Fortran.
(Some vendor-supplied BLAS libraries do not have C interface. So the
re-naming is needed in order for the SuperLU BLAS calls (in C) to
interface with the Fortran-style BLAS.)
The possible options for CDEFS are:

o -DAdd_: Fortran expects a C routine to have an underscore
postfixed to the name;
o -DNoChange: Fortran expects a C routine name to be identical to
that compiled by C;
o -DUpCase: Fortran expects a C routine name to be all uppercase.

4. The Matlab MEX-file interface.
The MATLAB/ subdirectory includes Matlab C MEX-files, so that
our factor and solve routines can be called as alternatives to those
built into Matlab. In the file SuperLU/make.inc, define MATLAB to be the
directory in which Matlab is installed on your system, for example:

MATLAB = /usr/local/matlab

At the SuperLU/ directory, type "make matlabmex" to build the MEX-file
interface. After you have built the interface, you may go to the MATLAB/
directory to test the correctness by typing (in Matlab):
trysuperlu
trylusolve

A Makefile is provided in each subdirectory. The installation can be done
completely automatically by simply typing "make" at the top level.
The test results are in the files below:
INSTALL/install.out
TESTING/stest.out
TESTING/dtest.out
TESTING/ctest.out
TESTING/ztest.out

--------------------
| RELEASE VERSIONS |
--------------------
February 4, 1997 Version 1.0
November 15, 1997 Version 1.1
September 1, 1999 Version 2.0
October 15, 2003 Version 3.0
August 1, 2008 Version 3.1
June 30, 2009 Version 4.0


MAKE.INC

############################################################################
#
# Program: SuperLU
#
# Module: make.inc
#
# Purpose: Top-level Definitions
#
# Creation date: October 2, 1995
#
# Modified: February 4, 1997 Version 1.0
# November 15, 1997 Version 1.1
# September 1, 1999 Version 2.0
#
############################################################################
#
# The machine (platform) identifier to append to the library names
#
PLAT = _linux

#
# The name of the libraries to be created/linked to
#
SuperLUroot = $(HOME)/Codes/SuperLU_4.0
SUPERLULIB = $(SuperLUroot)/lib/libsuperlu_4.0.a

#BLASLIB = $(SuperLUroot)/lib/libblas.a

## ATLAS BLAS causes single-precision to fail
#BLASDEF = -DUSE_VENDOR_BLAS
#BLASLIB = -L/usr/lib/atlas -lblas

## This BLAS causes single-precision to fail the test in SuperLU
BLASDEF = -DUSE_VENDOR_BLAS
BLASLIB = -L/opt/intel/Compiler/11.1/069/mkl/include

TMGLIB = libtmglib.a
LIBS = $(SUPERLULIB) $(BLASLIB)

#
# The archiver and the flag(s) to use when building archive (library)
# If your system has no ranlib, set RANLIB = echo.
#
ARCH = ar
ARCHFLAGS = cr
RANLIB = ranlib

CC = gcc
CFLAGS = -O3
FORTRAN = g77
FFLAGS = -O2
LOADER = $(FORTRAN)
LOADOPTS =

#
# C preprocessor defs for compilation for the Fortran interface
# (-DNoChange, -DAdd_, -DAdd__, or -DUpCase)
#
CDEFS = -DAdd_
#
# The directory in which Matlab is installed
#
MATLAB = /usr/sww/matlab

23 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hello,Please try to use whole MKL link line as the BLASLIB value. For instance, in the case of static linking of sequential libraries you may define this variable like this:BLASDEF = -DUSE_VENDOR_BLASMKLLIB = /opt/intel/Compiler/11.1/069/mkl/lib/ia32 # or /em64t, depending on the architecture of your # systemBLASLIB =-Wl,--start-group $(MKLLIB)/libmkl_intel.a $(MKLLIB)/libmkl_sequential.a $(MKLLIB)/libmkl_core.a -Wl,--end-groupThis KB article may be useful for the determining of link line most suitable for you.Best regards,Artem

Thank you very much for your responce.
I hope it will work.

Panayotis

Hello,

unfortunately I did not manage to install SuperLU and link it with mkl. Is there any chance that I should change something in the following sector of the make.inc file?

ARCH = ar
ARCHFLAGS = cr
RANLIB = ranlib

CC = gcc
CFLAGS = -O3
FORTRAN = g77
FFLAGS = -O2
LOADER = $(FORTRAN)
LOADOPTS =

Should I link the fortran compiler instead of gcc?

Thanks
Panayotis

Hello,

I would like test the results of PARDISO and DSS with the results of SuperLU. Does anybody know how to link the code with superlu?
I tried: ifort my_code.f90 -L /usr/lib/ -lsuperlu.but I receive ld: cannot find -lsuperlu.a. The SuperLU is installed from the ubuntu repositories. Any ideas please?

thanks
Panayotis

It is quite difficult to recognize what you have done and what you seek to do, please describe your work more carefully and precisely.

You say that you have installed SuperLU. In what form? Source? Objects? Static library? Shared Library? Which directory was it installed into? Which compiler was it compiled with?

Objects and libraries compiled by different compilers may not work correctly together. Unless there are pressing reasons to do otherwise, use a single compiler.

Hello,

Fisrtsy, I installed SuperLU 4.0 for sequential machines from its webpage. I followed the readme instructions and used the make.inc file that I attach. The library was installed in the following directory: /home/panayotis/Codes/SuperLU_4.0/lib which contains blas_linux.a and libsuperlu_4.0.a. Since I was not sure that the parameters I used in the make.inc file were the correct ones, I also installed the version that is available in the ubuntu 10.04 repositories (version 3.0). This was installed in /usr/lib folder and the files that are related to superlu are: libsuperlu.a, libsuperlu.so, libsuperlu.so.3, libsuperlu.3.0.0.

I do not know whether the libraries are shared or static. I'm not familiar with this stuff. I think that in the first case it was compiled with gfortan (does this information appear in the make.inc file?). In the case where the installation was done from the ubuntu repositories I don't know at all. Is it possible that g77 which is the default was used?

I would like to use intel fortran 11.1.069 since Im more familiar with it. Is this possible? In the case I have to use gfortran or g77 do you know how the link line should look like?

Thanks a lot for your time

Panayotis

P.S I attach the make.inc. The readme file which has the instructions I followed is shown above in the thread.

Attachments: 

AttachmentSize
Download make.inc1.7 KB

From the README, it is clear that SuperLU is written in C, but partially completed wrappers are available for calling from Fortran.

The Intel Fortran User's Guide has a chapter on mixed-language programming. You should probably read through it at least to recognize the issues that you may face.

Shared libraries have names that end with .so or .so followed by version numbers. Static libraries have names that end with .a.

My recommendation would be that you get your application running with SuperLU using GFortran and the default BLAS libraries first, since this would require the least amount of reconfiguration, if at all. Then, you can (i) replace the default BLAS with MKL, and then (ii) replace GFortran by IFort. If most of the computation is in SuperLU and BLAS, you can stop after Step (i).

G77 is obsolete, but most of the time using GFortran in its place works without a hitch.

Hi,

I followed your advice and I tried to compile my application using the following lines in the console:

gfortran my_code.f90 -L/usr/lib -lsuperlu -lblas and I received

/tmp/ccospda0.o: In function `MAIN__':
N_delta_exact_static_SUPERLU.f90:(.text+0x6d2b): undefined reference to `hbcode1__'
N_delta_exact_static_SUPERLU.f90:(.text+0x6da1): undefined reference to `c_fortran_zgssv__'
N_delta_exact_static_SUPERLU.f90:(.text+0x6e1d): undefined reference to `c_fortran_zgssv__'
N_delta_exact_static_SUPERLU.f90:(.text+0x6e97): undefined reference to `c_fortran_zgssv__'
collect2: ld returned 1 exit status

I also tried
gfortran my_code.f90 /usr/lib/libsuperlu.a /usr/lib/libblas.a and the same thing happens.

I don't know what am I doing wrong. Any advice?

Panayotis

Please post 'my_code.f90' (or a small extract from it just large enough to duplicate the errors). I suspect that you have trailing underscores after external names in your Fortran sources.

The double appended underscores would be an artififact of forgetting to change the configuration from g77 to the more usual single appended underscore, such as ifort and gfortran use by default, or using gfortran without the corresponding g77 compatibility options. If you want to use the double appended underscores in C, you still have some options on the Fortran side, the only standard one being iso_c_binding.

Since I' m not very sure what exactly I have to do, I tried to run the example that the SuperLU has in the downloaded file. I supposed that this one should work. But it gave me the same output (I also removed the extra underscores). Does this mean that I miss something much more crucial than correct linking?

I attach the whole folder with the example of SuperLU.

Thank u very much for your time!

Panayotis

Attachments: 

AttachmentSize
Download FORTRAN.tar.gz359.74 KB

Instead of using the files that you attached, which were a subset of those in the SuperLU distribution, I downloaded the complete distribution from the SuperLU site and built it.

The attached file make.inc, which I constructed from the file make.linux in the distribution by following the instructions, is suitable for use with Intel Fortran 11.1 and the bundled MKL that comes with it. The customizations:

SuperLURoot =
MKLPATH =
BLASLIB =
FORTRAN = ifort -nofor-main
CDEFS = -DAdd_

After modifying make.inc as above, do 'make'. Then 'cd' into the FORTRAN directory, do 'make' again, and run the example:

~/ALGO/SuperLU_4.0/FORTRAN> ./f77exm < ../EXAMPLE/g10
No of nonzeros in factor L = 835
No of nonzeros in factor U = 978
No of nonzeros in L+U = 1813
L\U MB 0.020 total MB needed 0.040
Factorization succeeded
Solve succeeded
188.456815745931 133.967986954678 -470.238799286096
-278.803395269114 19.9173073615258 272.772682328658
-247.806634747205 -313.997658809831 -91.2772118820614
99.7594964600219

Attachments: 

AttachmentSize
Download make.inc1.7 KB

Thank you so much for your help and your time.
Things seem to be fine now!

Panayotis

I am interested also in SUPERLU on Ubuntu 10.04.Are there any chances to restore the files?

>>...I am interested also in SUPERLU on Ubuntu 10.04.Are there any chances to restore the files?

Do you mean attached files to some posts? I did a quick verification and here are results:

- A web-link to download FORTRAN.tar.gz looks good ( but it doesn't have any mak.inc in it )
- Two web-links to mak.inc are broken ( impossible to download )

Any comments from Intel software engineers?

No comments so far,yes I am interestd in mecej4s web-link to make.inc

Milenko, are you specifically interested in whatever version of SuperLU was the latest in 2010, or would you be better served by a make.inc for IFort/Icc for building the latest version of SuperLU -- 4.3 ? Do you want the SuperLU library as a single-thread, multi-threaded, or MPI library? I ask because I spent a few minutes working with the current version of SuperLU and found it fairly easy to build a SuperLU 4.3 DLL on Windows by customizing the makefiles. The customization should be even simpler on Linux.

I am interested in SuperLU library as a single-thread,yes lateest version 4.3,on linux.

Thanks.

I have attached the modified file make.inc (renamed to make.inc.txt for satisfying the rule on allowable file extensions for attachments) for building the serial version of SuperLU 4.3 using Intel Fortran and C++ on Linux. After replacing the make.inc that gets extracted from the SuperLU download, change to the top directory of your SuperLU installation and do 'make superlulib'. Then, change to the FORTRAN directory and do 'make', then run the example by entering ./f77exm < ../EXAMPLE/g20.rua. The output that I received (on OpenSuse 12.3, with Intel Fortran and C compilers version 13.1.3) was

No of nonzeros in factor L = 5677
No of nonzeros in factor U = 5677
No of nonzeros in L+U = 11354
LU MB 0.120    total MB needed 0.211
 Factorization succeeded
 Solve succeeded
   31.8064997935680        30.7966287081976        30.7966287081976     
   31.3163708789384        31.8064997935680        32.3064997935680     
   32.3064997935680        31.8064997935680        31.8064997935680     
   28.8163434808750     

The -nofor-main option is really needed only for examples in which the main program is in C, but seemingly it does no harm for examples with a Fortran main program.

Attachments: 

AttachmentSize
Download make.inc.txt1.38 KB

I still have problems,when I go to FORTRAN after make

milenko@milenkons:~/superlu/SuperLU_4.3/FORTRAN$ make
ifort -nofor-main -mkl -ftz f77_main.o hbcode1.o c_fortran_dgssv.o /home/milenko/superlu/SuperLU_4.3/lib/libsuperlu.a -Wl,--start-group /opt/intel/composerxe-2011.1.107/mkl/lib/ia32/libmkl_intel.a /opt/intel/composerxe-2011.1.107/mkl/lib/ia32/libmkl_sequential.a /opt/intel/composerxe-2011.1.107/mkl/lib/ia32/libmkl_core.a -Wl,--end-group  -lm -o f77exm
f77_main.o: In function `MAIN__':
f77_main.f:(.text+0xbb): undefined reference to `c_fortran_dgssv__'
f77_main.f:(.text+0xd2): undefined reference to `s_wsle'
f77_main.f:(.text+0xf6): undefined reference to `do_lio'
f77_main.f:(.text+0xfb): undefined reference to `e_wsle'
f77_main.f:(.text+0x154): undefined reference to `c_fortran_dgssv__'
f77_main.f:(.text+0x170): undefined reference to `s_wsle'
f77_main.f:(.text+0x199): undefined reference to `do_lio'
f77_main.f:(.text+0x19e): undefined reference to `e_wsle'
f77_main.f:(.text+0x1aa): undefined reference to `s_wsle'
f77_main.f:(.text+0x1cd): undefined reference to `do_lio'
f77_main.f:(.text+0x1e3): undefined reference to `s_wsle'
f77_main.f:(.text+0x207): undefined reference to `do_lio'
f77_main.f:(.text+0x233): undefined reference to `s_wsle'
f77_main.f:(.text+0x257): undefined reference to `do_lio'
f77_main.f:(.text+0x277): undefined reference to `do_lio'
f77_main.f:(.text+0x27c): undefined reference to `e_wsle'
f77_main.f:(.text+0x2d5): undefined reference to `c_fortran_dgssv__'
f77_main.f:(.text+0x2e9): undefined reference to `s_stop'
hbcode1.o: In function `hbcode1_':
hbcode1.f:(.text+0x3d): undefined reference to `s_rsfe'
hbcode1.f:(.text+0x58): undefined reference to `do_fio'
hbcode1.f:(.text+0x76): undefined reference to `do_fio'
hbcode1.f:(.text+0x94): undefined reference to `do_fio'
hbcode1.f:(.text+0xb2): undefined reference to `do_fio'
hbcode1.f:(.text+0xd0): undefined reference to `do_fio'
hbcode1.o:hbcode1.f:(.text+0xee): more undefined references to `do_fio' follow
hbcode1.o: In function `hbcode1_':
hbcode1.f:(.text+0x20d): undefined reference to `e_rsfe'
hbcode1.f:(.text+0x21f): undefined reference to `s_rsfe'
hbcode1.f:(.text+0x255): undefined reference to `do_fio'
hbcode1.f:(.text+0x25f): undefined reference to `e_rsfe'
hbcode1.f:(.text+0x276): undefined reference to `s_rsfe'
hbcode1.f:(.text+0x2b8): undefined reference to `do_fio'
hbcode1.f:(.text+0x2c2): undefined reference to `e_rsfe'
hbcode1.f:(.text+0x2e3): undefined reference to `s_rsfe'
hbcode1.f:(.text+0x30e): undefined reference to `do_fio'
hbcode1.f:(.text+0x318): undefined reference to `e_rsfe'

I am attaching my make.inc.txt

Attachments: 

AttachmentSize
Download newmake.inc.txt1.61 KB

The references to the G77 I/O routines (do_fio, etc.) and the double underscore after "c_fortran_dgssv" in hbcode1.o and f77main.o indicate that you have some left-over object files that were compiled with a different compiler than Intel Fortran. Please delete the object files, and do "make" again.

Works fine now,I got the same results.

Leave a Comment

Please sign in to add a comment. Not a member? Join today