Intel® Math Kernel Library for Windows OS ® User's Guide
Total Page:16
File Type:pdf, Size:1020Kb
Intel® Math Kernel Library for Windows* Developer Guide Intel® MKL 2018 - Windows* Revision: 061 Legal Information Intel® Math Kernel Library for Windows* Developer Guide Contents Legal Information ................................................................................ 6 Getting Help and Support..................................................................... 7 Introducing the Intel® Math Kernel Library .......................................... 8 What's New ....................................................................................... 10 Notational Conventions...................................................................... 11 Related Information .......................................................................... 12 Chapter 1: Getting Started Checking Your Installation ........................................................................ 13 Setting Environment Variables................................................................... 13 Compiler Support .................................................................................... 14 Using Code Examples............................................................................... 15 Before You Begin Using the Intel(R) Math Kernel Library ............................... 15 Chapter 2: Structure of the Intel(R) Math Kernel Library Architecture Support................................................................................ 17 High-level Directory Structure ................................................................... 17 Layered Model Concept ............................................................................ 19 Chapter 3: Linking Your Application with the Intel(R) Math Kernel Library Linking Quick Start .................................................................................. 20 Using the /Qmkl Compiler Option ...................................................... 20 Automatically Linking a Project in the Visual Studio* Integrated Development Environment with Intel(R) MKL .................................. 21 Automatically Linking Your Microsoft Visual C/C++* Project with Intel® MKL.......................................................................... 21 Automatically Linking Your Intel® Visual Fortran Project with Intel® MKL.......................................................................... 21 Using the Single Dynamic Library ...................................................... 22 Selecting Libraries to Link with.......................................................... 22 Using the Link-line Advisor ............................................................... 23 Using the Command-line Link Tool..................................................... 23 Linking Examples .................................................................................... 23 Linking on IA-32 Architecture Systems............................................... 23 Linking on Intel(R) 64 Architecture Systems ....................................... 24 Linking in Detail ...................................................................................... 25 Dynamically Selecting the Interface and Threading Layer...................... 25 Linking with Interface Libraries ......................................................... 27 Using the cdecl and stdcall Interfaces ........................................ 27 Using the ILP64 Interface vs. LP64 Interface .............................. 28 Linking with Fortran 95 Interface Libraries.................................. 30 Linking with Threading Libraries ........................................................ 30 Linking with Computational Libraries.................................................. 31 Linking with Compiler Run-time Libraries............................................ 32 Linking with System Libraries............................................................ 33 Building Custom Dynamic-link Libraries ...................................................... 33 Using the Custom Dynamic-link Library Builder in the Command-line Mode ......................................................................................... 33 2 Contents Composing a List of Functions .......................................................... 35 Specifying Function Names............................................................... 35 Building a Custom Dynamic-link Library in the Visual Studio* Development System................................................................... 36 Distributing Your Custom Dynamic-link Library .................................... 37 Chapter 4: Managing Performance and Memory Improving Performance with Threading ...................................................... 38 OpenMP* Threaded Functions and Problems ....................................... 38 Functions Threaded with Intel® Threading Building Blocks ..................... 40 Avoiding Conflicts in the Execution Environment .................................. 41 Techniques to Set the Number of Threads........................................... 42 Setting the Number of Threads Using an OpenMP* Environment Variable ..................................................................................... 42 Changing the Number of OpenMP* Threads at Run Time....................... 43 Using Additional Threading Control .................................................... 45 Intel MKL-specific Environment Variables for OpenMP Threading Control .............................................................................. 45 MKL_DYNAMIC ....................................................................... 46 MKL_DOMAIN_NUM_THREADS.................................................. 47 MKL_NUM_STRIPES .................................................................... 48 Setting the Environment Variables for Threading Control .............. 49 Calling Intel MKL Functions from Multi-threaded Applications ................ 49 Using Intel® Hyper-Threading Technology ........................................... 51 Managing Multi-core Performance...................................................... 51 Improving Performance for Small Size Problems ......................................... 52 Using MKL_DIRECT_CALL in C Applications ......................................... 53 Using MKL_DIRECT_CALL in Fortran Applications ................................. 53 Limitations of the Direct Call ............................................................ 54 Other Tips and Techniques to Improve Performance ..................................... 54 Coding Techniques .......................................................................... 54 Improving Intel(R) MKL Performance on Specific Processors.................. 55 Operating on Denormals .................................................................. 55 Using Memory Functions........................................................................... 56 Memory Leaks in Intel MKL............................................................... 56 Redefining Memory Functions ........................................................... 56 Chapter 5: Language-specific Usage Options Using Language-Specific Interfaces with Intel(R) Math Kernel Library ............. 58 Interface Libraries and Modules......................................................... 58 Fortran 95 Interfaces to LAPACK and BLAS ......................................... 60 Compiler-dependent Functions and Fortran 90 Modules ........................ 60 Using the stdcall Calling Convention in C/C++..................................... 61 Compiling an Application that Calls the Intel(R) Math Kernel Library and Uses the CVF Calling Conventions............................................ 61 Mixed-language Programming with the Intel Math Kernel Library ................... 62 Calling LAPACK, BLAS, and CBLAS Routines from C/C++ Language Environments ............................................................................. 62 Using Complex Types in C/C++......................................................... 63 Calling BLAS Functions that Return the Complex Values in C/C++ Code.. 64 Chapter 6: Obtaining Numerically Reproducible Results Getting Started with Conditional Numerical Reproducibility ........................... 68 Specifying Code Branches......................................................................... 69 Reproducibility Conditions......................................................................... 70 3 Intel® Math Kernel Library for Windows* Developer Guide Setting the Environment Variable for Conditional Numerical Reproducibility ..... 71 Code Examples ....................................................................................... 71 Chapter 7: Coding Tips Example of Data Alignment....................................................................... 74 Using Predefined Preprocessor Symbols for Intel® MKL Version-Dependent Compilation ........................................................................................ 75 Chapter 8: Managing Output Using Intel MKL Verbose Mode .................................................................. 77 Version Information Line .................................................................. 77 Call Description Line ........................................................................ 78 Chapter 9: Working with the Intel® Math Kernel Library Cluster Software Message-Passing Interface Support............................................................ 80 Linking with Intel MKL Cluster Software.....................................................