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