How to Build an Intel® oneAPI Math Kernel Library (oneMKL) Application with Intel® Fortran Compiler Classic

ID 标签 762333
已更新 12/7/2020
版本 Latest
公共

author-image

作者

This document describes the steps to build an Intel® oneAPI Math Kernel Library (oneMKL) application with Intel® Fortran Compiler Classic for Windows* OS integrated with Microsoft Visual Studio* 2017.

Software Requirement:

1. Intel® Fortran Compiler Classic 2021.1 for Windows* OS
    The compiler must be installed and integrated correctly with Microsoft Visual Studio* 2017.

2. oneMKL 2021.1 or a later version
    oneMKL is included in the Intel® oneAPI Base Toolkit.

3. Microsoft* Visual Studio 2017 

Step 1:  Select whether you are building  IA-32 or Intel® 64 application
Based on the target machine your application will run on, select:

IA32: 32-bit application for IA-32 architecture
Intel 64: 64-bit application for Intel® 64 architecture

For more information about IA-32 and Intel® 64 architectures, see this article.

When building 32bit or 64bit application within Microsoft VS* environment, check the Build→Configuration manager→ Active solution platform setting. It should be either “X86"  (which corresponds to 32bit application). or "X64" (which corresponds to 64bit application).

Step 2: Create oneMKL Visual Studio project 

The oneMKL package includes much of code examples (C and Fortran file), located in the examples subdirectory of the install directory. i.e C:\Program Files (x86)\Intel\oneAPI\mkl\latest\examples.

User can build one Intel® Fortran Project based on one of sample Fortran files. See the way of build project in the article: 
https://software.intel.com/en-us/get-started-with-fortran-for-windows

The attached zip file at the end of the article contains a Microsoft VS* 2017 project for your reference.

Step 3: Link to oneMKL in your project automatically - quick option /Qmkl:[parallel|sequential|cluster]

Note: Step 3 and the Step 4 (optional) are equivalent in most cases. Be sure to use only one of these options, don’t mix them. 

The latest oneMKL versions have a single 'Build' menu in Microsoft VS* environment. Refer to the Microsoft VS* screenshot below. Open Project → Property Pages →Fortran → Libraries →Use Intel oneAPI Math Kernel Library. Select the desired option, such as /Qmkl:parallel or /Qmkl:sequential. Once selected all of environment settings and required libraries are ready for your project. Proceed to build and run the application.

Then click OK and build the project. In most of case, the setting should be enough for building a Fortran application based on oneMKL. But if you have some customized requirement  to link oneMKL, then please refer to below manual step.

Step 4: How to link to oneMKL in your project manually (Optional)

Step 4.1: Select the wanted libraries to link from oneMKL 
Use the on-line oneMKL Link Line Advisor to determine which libraries your application needs to link to, based on your platform settings.

oneMKL Link Line Advisor will list the libraries you need to link to from oneMKL.

Step 4.2: link to oneMKL manually in your project
Follow these steps to add the include path, library path and oneMKL libraries listed by the oneMKL Link Line Advisor.  

1. To add the include path manually refer to the Microsoft VS* screenshot below. Open Project → Property Pages →Fortran →General. Type/Paste the library directory in the 'Additional Include Directories' field.



2. To add the library path manually refer to the Microsoft VS* screenshot below. Open Project → Property Pages → Linker →General. Type/Paste the library directory in the 'Additional Library Directories' field.

Make sure to check the library path and enter the correct directory:

<MKL install dir>\ia32,  for IA-32 application
<MKL install dir>\intel64, for x64 application                                                                                                                                              

3. To add  the required libraries manually refer to the Microsoft VS* screenshot below. Open Project → Property Pages → Linker → Additional Dependencies. Paste the libraries from the oneMKL Link Line Advisor.

Code Sample:

The attached zip file contains a Microsoft VS* 2017 project for your reference. DFT_VF_sample.zip does Real 1d DFT.

Notes:

Some interface libraries (i.e. mkl_lapack95.lib mkl_blas95.lib fftw3xc_ms) may not be part of oneMKL package, as such "Step 2 - quick option" does not support them. You can add those libraries manually if you need to use them.

Troubleshooting:


You may encounter the following errors when building the project:

1. "fatal error LNK1104: cannot open file 'mkl_xxx.lib'"
    Make sure the library is included in the library path and the path you enter in step 3 or step 4 is correct.

2. "error #7002: Error opening the compiled module file.  Check INCLUDE paths. [MKL_DFTI]."                                                        Add the header file mkl_dfti.f90 in your code, for example:

! Include to build module MKL_DFTI
INCLUDE 'mkl_dfti.f90'

before the code line
USE MKL_DFTI

Alternatively, copy the mkl_dfti.f90 file to your project's source directory and include it in your project. 

Step 4.3. Can't run exe as lack of some *.dll run-time library 

If you link with dynamic library, the execute file will ask the *.dll at run time.  So you have to make sure the all of DLL exist in your running environment.

In most of cases, the installer will add the path of Intel software tools to system environment.  But if no, please add it manually.

Notices & Disclaimers Intel technologies may require enabled hardware, software or service activation. No product or component can be absolutely secure.  Your costs and results may vary.  © Intel Corporation.  Intel, the Intel logo, and other Intel marks are trademarks of Intel Corporation or its subsidiaries.  Other names and brands may be claimed as the property of others.   
"