Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Frank_M
Beginner
93 Views

error LNK2019 when calling BLAS95 from Fortran

Using VS2008 and IVF 11.1.067 I'm getting the error

Error1 error LNK2019: unresolved external symbol _DGEMV_F95 referenced in function _POLYMULT

[fortran]      INCLUDE 'blas.f90'
		
      SUBROUTINE POLYMULT(poly1, poly1len, poly2, poly2len, poly3, poly3len)
        USE mkl95_precision
        USE BLAS95, ONLY: GEMV
        IMPLICIT NONE
        INTEGER, INTENT(IN) :: poly1len, poly2len, poly3len
        REAL(8), DIMENSION(poly1len), INTENT(IN) :: poly1
        REAL(8), DIMENSION(poly2len), INTENT(IN) :: poly2
        REAL(8), DIMENSION(poly3len), INTENT(INOUT) :: poly3
        REAL(8), DIMENSION(:,:), ALLOCATABLE :: matrixA
        REAL(8) :: alpha, beta
        CHARACTER(len = 1) :: trans
        INTEGER :: i, j, status
        ALLOCATE(matrixA(poly2len,poly1len+poly2len-1), STAT = status)
        alpha = 1.0_8
        beta = 0.0_8
        trans = 'N'
        matrixA = 0.0_8
        FORALL(i = 1: poly2len, j = 1: poly1len) matrixA(j, j+i-1) = poly2(i)
        CALL GEMV(matrixA, poly1, poly3, alpha, beta, trans)
        DEALLOCATE(matrixA)
        RETURN
      END SUBROUTINE POLYMULT[/fortran]


The c++ version works.

[bash]#include "mkl.h"

void i_poly_mult(double* ppoly1, int poly1len, double* ppoly2, int poly2len, double* ppoly3)
{
	MKL_INT         incpoly;
    double          alpha, beta;
    CBLAS_ORDER     order;
    CBLAS_TRANSPOSE trans;

	order = CblasRowMajor;
	trans = CblasTrans;
	alpha = 1.0;
	beta = 0.0;
	incpoly = 1;
	
	int i,j;
	int poly3len;
	poly3len = poly1len + poly2len - 1;
	double* parray;
	parray = new double[poly3len * poly1len];
  
	j=0;
	for(i = 0; i < poly1len -1; i++)
	{
		iuni_copy(ppoly2,parray+j,poly2len);
		j = j + poly2len;
		iuni_assign(parray+j,0.0,poly1len);
		j = j + poly1len;
	}
	iuni_copy(ppoly2,parray+j,poly2len);
// call mkl 
	cblas_dgemv(order, trans, poly1len, poly3len, alpha, parray, poly3len, ppoly1, incpoly, beta, ppoly3, incpoly);
	delete [] parray;
	parray = 0;
}[/bash]

I must have something configured wrong but what? Fortran has no problem linking with other MKL functions.
I'm stumpt. Please help.
0 Kudos
4 Replies
mecej4
Black Belt
93 Views

The F95 BLAS routines are contained in mkl_blas95.lib. The CBLAS routines are contained in mkl_intel_c.lib.

You probably did not add the appropriate library to your Fortran build.

That the C++ version "worked" whereas the F95 version "failed" amounts to nothing, as there is no parity between the two builds.
Frank_M
Beginner
93 Views

My settings in Configuration Properties -> Fortran -> Libraries :

RunTime Library -> Debug Multithreaded (/libs:static /threads /dbglibs)
Use Common Windows Library -> No
Use Portlib Library -> No
Use Intel Math Kernel Library -> Sequential(/Qmkl:sequential)
Disable Default Library Search Rules -> No
Disable OBJCOMMENT Library Names in Object -> No

According to the fortran users manual, the above is all that is required to use the MKL library.

The MKLusers manualis a bit dfferent. It states that under Project-> Properties -> Linker -> General -> Additional Library Directories " Add the architecture specific lib folder."
and under Project-> Properties -> Linker -> Input -> Additional Dependicies
"Insertmkl_intel_c.lib mkl_intel_thread.lib mkl_core.lib libiomp5md.lib"

Fortran does not have a path Project-> Properties -> Linker -> General so I assume it means Configuration Properties -> Librarian -> General

Here the settings I've tried are: ( with and without Use Intel Math Kernel Library -> Sequential(/Qmkl:sequential) )

Output File -> $(OutDir)/$(ProjectName).libAdditional Dependencies -> mkl_intel_c.lib mkl_intel_thread.lib mkl_core.lib libiomp5md.lib
Additional Library Directories -> C:\Program Files\Intel\Compiler\11.1\067\mkl\ia32\libSuppress Startup Banner -> Yes(/NOLOGO)
Model Definition File Name -> empty
Ignore All Default Libraries -> No
Ignore Specific Library -> empty
Export Named Functions -> empty
Force Symbol Reference -> empty
Link Library Dependencies -> Yes

The above settings make no changes to the error, but they do increase compile time as the library has to be rebuilt at each compile. There is also a large warning list for second definitions.

Frank_M
Beginner
93 Views

Found the answer.

The user's manual lies in the table on page 5 - 5. The library mkl_blas95.lib is not in the library mkl_core.lib.

If I set

Use Intel Math Kernel Library -> Sequential(/Qmkl:sequential)

Additional Dependencies -> mkl_blas95.lib

Additional Library Directories -> C:\Program Files\Intel\Compiler\11.1\067\mkl\ia32

It links!!!

Gennady_F_Intel
Moderator
93 Views

Hello Frank,
I cannot find where user's manualcontainsis inconsistency. I am searching to the version of MKL 10.2 Update 6 ( the similar version is bundled with Compiler 11.1\067.
Could you indicate this in the userguide?
and one more noteregardingthe issue - we have the article:"Using MKL in Intel Compiler - mkl, Qmkl options"where the similar issue has been described.
--Gennady

Reply