Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

Error compiling sample FFT

Christoph_R_
Beginner
777 Views

Hi all,

I am quite new to intel MKL, so please correct me if I am posting this to the wrong forum etc.
I want to use the intel MKL FFT library in Fortran 95. I am working with the eclipse IDE with a gfortran compiler on windows 10 with cygwin.
 

Following the instructions of this http://tx.technion.ac.il/doc/intel/mkl/mkl_userguide/GUID-CECACEC6-8B3A-459C-9F5F-FED0563E69F4.htm
page (I know its for c/c++) I included the "include" and "lib\intel64_win" directory to the "Project Properties->Fortran General->Paths and Symbols->Includes->Fortran Source File" list.
In the "...->Paths and Symbols->Libraries", the libraries "mkl_intel_lp64", "mkl_intel_thread" and "mkl_core" are listed.

The Source code is copied from here https://software.intel.com/en-us/node/471390#D8463A93-CC5F-4E8C-82C7-9A2E8E713EC4 ;
the only change I made, was writing "implicit none" after "USE MKL_DFTI":

program InteltestFFT


    ! Fortran example.
! 1D complex to complex, and real to conjugate-even
Use MKL_DFTI
    implicit none
Complex :: X(32)
Real :: Y(34)
type(DFTI_DESCRIPTOR), POINTER :: My_Desc1_Handle, My_Desc2_Handle
Integer :: Status
!...put input data into X(1),...,X(32); Y(1),...,Y(32)

! Perform a complex to complex transform
Status = DftiCreateDescriptor( My_Desc1_Handle, DFTI_SINGLE,&
  DFTI_COMPLEX, 1, 32 )
Status = DftiCommitDescriptor( My_Desc1_Handle )
Status = DftiComputeForward( My_Desc1_Handle, X )
Status = DftiFreeDescriptor(My_Desc1_Handle)
! result is given by {X(1),X(2),...,X(32)}

! Perform a real to complex conjugate-even transform
Status = DftiCreateDescriptor(My_Desc2_Handle, DFTI_SINGLE,&
   DFTI_REAL, 1, 32)
Status = DftiCommitDescriptor(My_Desc2_Handle)
Status = DftiComputeForward(My_Desc2_Handle, Y)
Status = DftiFreeDescriptor(My_Desc2_Handle)
! result is given in CCS format.

end program InteltestFFT

 

Compiling this program gives the following error (198 errors, slightly differing in the parenthesis after mkl_core.lib):

Description    Resource    Path    Location    Type
undefined reference to `__GSHandlerCheck'    TestMklFFT2D        line 0, external location: C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2017.1.143\windows\mkl\lib\intel64_win\mkl_core.lib(_avx2_bkd1_c.obj)    C/C++ Problem

 

In a userguide http://www.physics.udel.edu/~bnikolic/QTTG/shared/docs/MKL_linux.pdf (unfortunately for Linux) on page 5-7 it is mentioned, that the -lm command should be used for linking. However, doing this leads to another error which gives no information:

Description    Resource    Path    Location    Type
TestMklFFT2D] Error 1    TestMklFFT2D        line 31    C/C++ Problem

Line 31 is the line after the "end program InteltestFFT" command.

 

Does somebody know the reason for this error or did encounter the same error?

Best regards
Christoph
 

0 Kudos
7 Replies
Shaojuan_Z_Intel
Employee
777 Views

Hi Christoph,

You may take a look at the online link tool https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor to check the needed libraries and compiler options. Or, you may run C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_*.*.*\windows\mkl\tools\mkl_link_tool.exe to see what libraries are needed for your application.

0 Kudos
Gennady_F_Intel
Moderator
777 Views

pls pay attention - you use gfortran, therefore select -lmkl_gf_lp64 instead of mkl_intel_lp64

 

0 Kudos
Christoph_R_
Beginner
777 Views

Thank you for the fast answers :)
I tried both, the online link tool which recommends the following:

"Use this link line:
mkl_intel_lp64.lib mkl_sequential.lib mkl_core.lib"

"Compiler options:
 -I"%MKLROOT%"\include"

The options I used were MKL 2017.0->Windows->None->PGI Fortran(as no gfortran was available)->Intel 64->Static->32 Bit integer->Sequential. No other options were chosen.

Using the installed linking tool "mkl_link_tool.exe" (as it supports the gfortran compiler option) does result in the following output

C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2017.1.143\windows\mkl\tools>mkl_link_tool -opts gfortran

       Intel(R) Math Kernel Library (Intel(R) MKL) Link Tool v4.3
       ==========================================================

Not supported compiler for current configuration:gnu_f. Supported values for compiler: intel_c|intel_f|ms_c|pgi_f|pgi_c

Configuration
=============

MKL version:            2017.1
OS:                     win
Architecture:           intel64
Compiler:               gnu_f
Linking:                dynamic
Interface layer:        lp64
Parallel:               yes
OpenMP library:         iomp5

Does this mean that gfortran is not supported at all?

I also tried to substitute the mkl_intel_lp64 by mkl_gf_lp64. However, there is no such file in my lib directory.

I'm also a bit confused about the mkl_dfti.mod, mkl_dfti.o and mkl_dft_type.mod files that were generated by compiling mkl_dfti.f90.
Previously I have always been linking to .a libraries. Is there any difference on how the libraries need to be passed to the compiler? Just indicating it as library results in the following errors (above mentioned libraries mkl_intel_lp64.lib mkl_sequential.lib mkl_core.lib were used):

Description    Resource    Path    Location    Type
cannot find -lmkl_dfti    TestMklFFT2D             C/C++ Problem
TestMklFFT2D] Error 1    TestMklFFT2D        line 31    C/C++ Problem


The paths to the libraries are specified in environment variables and the photran IDE. (->Properties->Fortran Build->Settings->Tool Settings->GNU Fortran Linker->Libraries->library search path(-L).
 

Does a switch to the intel compiler make things easier? Can the intel compiler be used with other IDEs than VS?

0 Kudos
Ying_H_Intel
Employee
777 Views

Hi Christoph, 

I think the problem is your special environment :  gfortran compiler on windows 10 with cygwin, which we don't support.   Also we don't support gfortran under Windows, 

Regarding the `__GSHandlerCheck' itself, there is some information in internet, it may be defined from libcmt.lib, which is supposed to link with MSVC library.  If your cygwin system have that, you may add it. But i guess there will have following errors as unsupported system.  

So i may suggest, if possible, use supported compiler and developer environment. for example,  If you install Intel fortran Compiler for windows version, you are supposed to build the fortran 95 application directly (don't need Cygwin). 

FYI, MKL system requirements: https://software.intel.com/en-us/articles/intel-math-kernel-library-intel-mkl-2017-system-requirements

Best Regards,

Ying 

 

 

0 Kudos
薛_清_
Beginner
777 Views

 Hi,i am a new student .

can you tell me how to find a  FFT example coded by C or C++?  

 

0 Kudos
Christoph_R_
Beginner
777 Views

Hi Ying,

Thank you for your comment.
I was switching to VS with the ifort compiler right after my comment on the 29th of november. This solved my problem instantaneously.

Best Regards
Christoph
 

0 Kudos
Ying_H_Intel
Employee
777 Views

Hi Christoph,

Glad to know you work around it.  thanks for the sharing.

Hi Qing,

You may find MKL example in MKL install folder or search in the forum:  for example, some in  https://software.intel.com/en-us/forums/intel-math-kernel-library/topic/517579

Best Regards,

Ying

0 Kudos
Reply