MKL Link to Fortran

MKL Link to Fortran

Program Mult
        
        real a(3,3)
        real b(3,3)
        real c(3,3)
        integer i, j
        
        
        Write(*,*)'Here'
        do 100 i = 1,3
            do 200 j = 1,3
                a(i,j) = i
                b(i,j) = j
                write(*,*)a(i,j),b(i,j)
200         end do
100     end do    

        call gemm(a, b, c, 'N','N',1,1)



    end Program

I have linked to the mkl library, I have tried several variations on the gemm routine and I have tried the samples.

 

Unresolved external symbol

 

I realize it is easy but at the moment it appears hard

JMN

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
mecej4's picture

GEMM is only an interface name, not the name of a symbol that exists in the MKL libraries. This interface contains some optional arguments and, consequently, you must provide the interface to GEMM.

If you wish to use this interface name and Fortran-95 (and later) style linkage, you should have a USE MKL95_BLAS statement after the first line, and your call to GEMM must have arguments that match one of the allowed combinations: change the last two arguments from "1" to "1.0". You should also specify that the MKL libraries and the MKL BLAS-95 library be used in the link step.

If, on the other hand, you wish to make a Fortran-77-style call, you need to call the specific subroutine SGEMM, and supply it with the proper list of arguments (it takes thirteen arguments and in a specific order).

Program Mult
        
            USE BLAS95
        
            double precision a(3,3)
            double precision b(3,3)
            double precision c(3,3)
            double precision alpha,beta
            integer i, j, im,jm,km,lda
            character*1 name
        
        
            Write(*,*)' Matrix Multiplication     A        B'
            do 100 i = 1,3
                do 200 j = 1,3
                    a(i,j) = i
                    b(i,j) = j
200             end do
                write(*,600)i, (a(i,j), j=1,3),(b(i,j),j=1,3)
100         end do    
            alpha = 1
            im = 3
            jm = 3
            km = 3
            name = "N"
            lda = 1
            beta = 0.0

            call dgemm(name, name, im, jm, km, alpha, a, im, b, jm, beta, c, km)

            Write(*,500)
500         format(' Results is : ')        
            do 300 i = 1,3
                write(*,400)i, (c(i,j), j=1,3)
400             Format('Row :' I3, ' Values : ' 3F10.3)       
600             Format('Row :' I3, ' Values : ' 3F10.3 '  |' 3F10.3)      
300         end do    
            
    end Program

------------------------------------------------------------------------------------------------------------------------------------------------------

I got this program to run after a few hours of playing and reading the notes on the web.

MECEJ4's advise to use the USE MKL95_BLAS appears to have changed with the 2015 compiler and the 11.2 MKL.  I used Steve's note on another reply and used #x on a command line version of the program.  I found out what was included in all the variables and then hunted out the blas95.mod files.  Once I had that I and the include MKL in the properties it found the routines. 

 

I was using the double precision version, but the program would not find the gemm version at all.

            call gemm(a, b, c, name, name, alpha, beta)

Error 1  error LNK2019: unresolved external symbol _DGEMM_F95 referenced in function _MAIN__ Source1.obj 

 

Although now that I understand the interesting combination of variables in dgemm it is not a problem. 

Question 1:  Have you changed from MKL95_blas in the old versions and 2015 used blas95 as the use?

Question 2: How do I get the program to find the gemm interface?

Thanks

JMN

 

 

mecej4's picture

The program in #3 can be compiled an run with the 15.0 beta compiler. In that program, the USE statement is neither needed nor does it have any effect other than to slightly slow down the compilation.

If you use the F95 interface and call GEMM(), you must add to the link step the library MKL_BLAS95.lib (when targeting IA32) or the appropriate one of the pair mkl_blas95_lp64.lib, mkl_blas95_ilp64.lib (when targeting X64).

Login to leave a comment.