linking to MKL

Having trouble compiling the Yambo source? Using an unusual architecture? Problems with the "configure" script? Problems in GPU architectures? This is the place to look.

Moderators: Davide Sangalli, andrea.ferretti, myrta gruning, andrea marini, Daniele Varsano, Conor Hogan, Nicola Spallanzani

Forum rules
If you have trouble compiling Yambo, please make sure to list:
(1) the compiler (vendor and release: e.g. intel 10.1)
(2) the architecture (e.g. 64-bit IBM SP5)
(3) if the problems occur compiling in serial/in parallel
(4) the version of Yambo (revision number/major release version)
(5) the relevant compiler error message
cantele
Posts: 21
Joined: Wed Dec 23, 2009 2:58 pm
Contact:

Re: linking to MKL

Post by cantele » Mon Sep 13, 2010 11:25 am

Hi,

it's the third time I'm trying to post a message but when I go back to the forum I cannot find my message, I'm making some mistake but I cannot understand which.......could you please reply to this just to be sure that you were able to read it????

Well, I think that the "specific" names of the libraries should not be so important because they do depend on the library you ar using. I set:

Code: Select all

BLACS_LIBS="$MKL_PATH/libmkl_solver_lp64_sequential.a $MKL_PATH/libmkl_intel_lp64.a $MKL_PATH/libmkl_sequential.a $MKL_PATH/libmkl_core.a $MKL_PATH/libmkl_blacs_openmpi_lp64.a -lpthread"
and

Code: Select all

SCALAPACK_LIBS="$MKL_PATH/libmkl_scalapack_lp64.a"
because this is enough for MKL. In this case, as you can see, you must also call other libraries, that have nothing to do with blacs and scalapack, just to prevent from unresolved link to MKL calls!

Currently, the options for blas and lapack just do the same job, because they require the specification of the library and do not look for any specific name. For example, I successfully compiled the code using:

Code: Select all

--with-blas="-L$MKL_PATH -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread"                                                                 \
--with-lapack="-L$MKL_PATH -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread"  
Another strategy would be to use LIBS and LDFLAGS variables also, that means that I can specify LDFLAGS or LIBS="$MKL_PATH/libmkl_scalapack_lp64.a MKL_PATH/libmkl_solver_lp64_sequential.a $MKL_PATH/libmkl_intel_lp64.a $MKL_PATH/libmkl_sequential.a $MKL_PATH/libmkl_core.a $MKL_PATH/libmkl_blacs_openmpi_lp64.a -lpthread". If the options --with-blacs and/or --with-scalapack are not set, the configure might try to compile a dummy program containing a call to a routine of a given library like (this is an example for lapack)

Code: Select all

      program main
      call dgemm
      end
and then decide if that library is available or not depending on whether the link procedure found or not unresolved calls.

Giovanni
Dr. Giovanni Cantele
CNR-SPIN and Univ. di Napoli "Federico II"
Phone: +39 081 676910
E-mail: giovanni.cantele@cnr.it
giovanni.cantele@na.infn.it
Web: http://people.na.infn.it/cantele
Skype: giocan74

User avatar
myrta gruning
Posts: 240
Joined: Tue Mar 17, 2009 11:38 am
Contact:

Re: linking to MKL

Post by myrta gruning » Mon Sep 13, 2010 2:07 pm

Hallo Giovanni

your message is posted

m
Dr Myrta Grüning
School of Mathematics and Physics
Queen's University Belfast - Northern Ireland

http://www.researcherid.com/rid/B-1515-2009

cantele
Posts: 21
Joined: Wed Dec 23, 2009 2:58 pm
Contact:

Re: linking to MKL

Post by cantele » Thu Feb 03, 2011 11:54 am

maybe I never replied to this request (just browsing across my posts I found it!).

What I presently do also with the last 3.2.3-rev11 version is to modify by hand configure adding

Code: Select all

BLACS_LIBS="$MKL_PATH/libmkl_solver_lp64_sequential.a $MKL_PATH/libmkl_intel_lp64.a $MKL_PATH/libmkl_sequential.a $MKL_PATH/libmkl_core.a $MKL_PATH/libmkl_blacs_openmpi_lp64.a -lpthread"
immediately after

Code: Select all

# { $as_echo "$as_me:$LINENO: checking the BLACS library" >&5
$as_echo_n "checking the BLACS library... " >&6; }
 cinit_lib=`find $with_blacs -name '*blacsCinit*.a'`
 blacs_lib=`find $with_blacs -name '*blacs.a'`
 if ! test "$cinit_lib" = "" && ! test "$blacs_lib" = "" ; then
   BLACS_LIBS="$cinit_lib $blacs_lib"
   { $as_echo "$as_me:$LINENO: result: yes" >&5
$as_echo "yes" >&6; }
 else
   { $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
 fi
and

Code: Select all

SCALAPACK_LIBS="$MKL_PATH/libmkl_scalapack_lp64.a"
just after

Code: Select all

#
# then SLPK if BLACS has been found
#
  { $as_echo "$as_me:$LINENO: checking the SCALAPACK library" >&5
$as_echo_n "checking the SCALAPACK library... " >&6; }
  SCALAPACK_LIBS=`find $with_scalapack -name '*scalapack.a'`
  if ! test "$SCALAPACK_LIBS" = "" ; then
   enable_scalapack="yes"
   { $as_echo "$as_me:$LINENO: result: yes" >&5
$as_echo "yes" >&6; }
  else
   BLACS_LIBS=""
   enable_scalapack="no"
   { $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
  fi
 fi
fi
As you may see, the present configure just searches for SPECIFIC library names, just preventing from accepting libraries with non-standard names.

What should be done, in my opinion, is that the --with-blacs and --with-scalapack configure options should be set (if specified) to the set of needed libraries
(e.g. --with-blacs="BLACS_LIBS="$MKL_PATH/libmkl_solver_lp64_sequential.a $MKL_PATH/libmkl_intel_lp64.a $MKL_PATH/libmkl_sequential.a $MKL_PATH/libmkl_core.a $MKL_PATH/libmkl_blacs_openmpi_lp64.a -lpthread") instead of (as it is at the moment) to the path of the library directory. The configure should then enable BLACS/SCALAPACK provided the --with-blacs/--with-scalapack options are given in input (so just set BLACS_LIBS="$with_blacs" if $with_blacs is not empty). A more complete code would try to compile a dummy code containing a call to BLACS using BLACS_LIBS to link.
Dr. Giovanni Cantele
CNR-SPIN and Univ. di Napoli "Federico II"
Phone: +39 081 676910
E-mail: giovanni.cantele@cnr.it
giovanni.cantele@na.infn.it
Web: http://people.na.infn.it/cantele
Skype: giocan74

User avatar
myrta gruning
Posts: 240
Joined: Tue Mar 17, 2009 11:38 am
Contact:

Re: linking to MKL

Post by myrta gruning » Tue Feb 08, 2011 10:27 am

Thanks Giovanni,

I hope to have the time to look into that.

m
Dr Myrta Grüning
School of Mathematics and Physics
Queen's University Belfast - Northern Ireland

http://www.researcherid.com/rid/B-1515-2009

cantele
Posts: 21
Joined: Wed Dec 23, 2009 2:58 pm
Contact:

Re: linking to MKL

Post by cantele » Tue Feb 08, 2011 11:55 am

myrta gruning wrote:Thanks Giovanni,

I hope to have the time to look into that.

m

No problem! I just (re)posted to share my experience with the latest version I compiled few weeks ago!

Thanks,

Giovanni
Dr. Giovanni Cantele
CNR-SPIN and Univ. di Napoli "Federico II"
Phone: +39 081 676910
E-mail: giovanni.cantele@cnr.it
giovanni.cantele@na.infn.it
Web: http://people.na.infn.it/cantele
Skype: giocan74

Post Reply