f2py mkl

f2py mkl

Hi,

I have searched the forums and cannot find any good assistance.  I am trying to build a python module from a F77 source file. Have sourced my intel environment variables with:

call "C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2017\windows\bin\compilervars.bat" -arch intel64
 

And I am trying to compile with:

f2py --fcompiler=intelvem -L"C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2017\windows\mkl\lib\intel64_win" -lmkl_lapack95_ilp64 -lmkl_blas95_ilp64 -c matmul2.pyf matmul2.f90

I am getting a failed with exit status 1120 and a error LNK2001: unresolved external symbol dgemm_

Can anyone point me in a fruitful direction to make some progress?

Thank you

Leon

 

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

Which link.exe do you use? Linkage between ifort Windows and mkl normally is handled with Microsoft link as back end and Linux style command line options aren't supported.

I don't know anything about f2py, but it seems to me that your Fortran code is calling GEMM through the F77 interface (note the name "dgemm_"), and that you are using a Fortran compiler other than IFort. If so, you need to use compiler options to get the name mangling done right.

If your Fortran code explicitly calls dgemm(), you do not need the *95* libraries in your link line at all. Regardless of that, you will need to link with the appropriate MKL libraries. Use the MKL Link Line Advisor, https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor/ .

mecej4,

I think you may be correct with the F77 interface. Why did the name "dgemm_" suggest this as an issue?  I am on Windows and don't know much about how to use Microsoft link. I am using f2py to create python modules from Fortran modules, hence the command line usage. I did see the link advisor which works for straight Fortran compilations but does not get me all the way to the python modules.

Thanks,

Leon

 

Leon Adams
Best Reply

In Fortran 90 and later, one can have a generic interface name such as gemm(). Depending on the types (and number) of arguments, the call to a generic name will get resolved into a call to the appropriate specific routine from the list sgemm(), dgemm(), cgemm(), zgemm(), szgemm and dzgemm(), as you can see from the manual page https://software.intel.com/en-us/mkl-developer-reference-fortran-gemm . The BLAS-95 library contains only the "wrapper" routines that do this resolving of the generic to the specifics. The codes for the actual specific functions are not in the BLAS-95 library, but in one of the several MKL libraries whose names do not contain "95" in them.

By default, the Ifort compiler on Windows generates a reference to DGEMM in 64-bit object files, and to _DGEMM in 32-bit object files. If you use the Gfortran compiler, instead, the name gets decorated to dgemm_ .

I agree with the suspicion that you are calling dgemm from gfortran, which makes the use of mkl on Windows difficult (unsupported).

Thanks everyone. It looks like f2py is not passing through my compiler selection and environment variables. I will check to see if I can more insights into the internal of how f2py works.

Thanks for all the comments.

Leon

 

 

 

 

 

Leon Adams

Hi Leon, 

What exact function are you writing in matmul.f  DGEMM or GEMM?   But as MKL had included BLAS95 interface supports in library,  you can use MKL libraries directly; 

please refer MKL  link advisor  https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor/,  for example, you will get required link command line as below 

 -L${MKLROOT}/lib/intel64 -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl

 -i8 -I${MKLROOT}/include  (if you use 64bit long integer,  then use it). 

If the problem insists , please submit your issue to  Online Service Center

Best Regards,

Ying 

Leave a Comment

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