Intel(R) - Computational and Systems Biology at MIT
Intel(R) - Computational and Systems Biology at MIT
Intel(R) - Computational and Systems Biology at MIT
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
7 <strong>Intel</strong>® M<strong>at</strong>h Kernel Library User’s GuideCBLAS is a C-style interface to the BLAS routines. You can call CBLAS routines usingregular C-style calls. When using the CBLAS interface, the header file mkl.h will simplifythe program development as it specifies enumer<strong>at</strong>ed values as well as prototypes of all thefunctions. The header determines if the program is being compiled with a C++ compiler,<strong>and</strong> if it is, the included file will be correct for use with C++ compil<strong>at</strong>ion. Example 7-3illustr<strong>at</strong>es the use of CBLAS interface.Calling BLAS Functions Th<strong>at</strong> Return the Complex Values inC/C++ CodeYou must be careful when h<strong>and</strong>ling a call from C to a BLAS function th<strong>at</strong> returns complexvalues. The problem arises because these are Fortran functions <strong>and</strong> complex return valuesare h<strong>and</strong>led quite differently for C <strong>and</strong> Fortran. However, in addition to normal functioncalls, Fortran enables calling functions as though they were subroutines, which provides amechanism for returning the complex value correctly when the function is called from a Cprogram. When a Fortran function is called as a subroutine, the return value shows up asthe first parameter in the calling sequence. This fe<strong>at</strong>ure can be exploited by the Cprogrammer.The following example shows how this works.Normal Fortran function call: result = cdotc( n, x, 1, y, 1 ).A call to the function as asubroutine: call cdotc( result, n, x, 1, y, 1).A call to the function from C(notice th<strong>at</strong> the hiddenparameter gets exposed): cdotc( &result, &n, x, &one, y, &one ).NOTE. <strong>Intel</strong> MKL has both upper-case <strong>and</strong> lower-case entry points inBLAS, with trailing underscore or not. So, all these names are acceptable:cdotc, CDOTC, cdotc_, CDOTC_.Using the above example, you can call from C, <strong>and</strong> thus, from C++, several level 1 BLASfunctions th<strong>at</strong> return complex values. However, it is still easier to use the CBLAS interface.For instance, you can call the same function using the CBLAS interface as follows:cblas_cdotu( n, x, 1, y, 1, &result )7-6