Developer Reference for Intel® oneAPI Math Kernel Library for C

ID 766684
Date 11/07/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

C Interface Conventions for BLAS Routines

CBLAS, the C interface to the Basic Linear Algebra Subprograms (BLAS), provides a C language interface to BLAS routines for Intel® oneAPI Math Kernel Library (oneMKL). While you can call the Fortran implementation of BLAS, for coding in C the CBLAS interface has some advantages such as allowing you to specify column-major or row-major ordering with thelayout parameter.

For more information about calling Fortran routines from C in general, and specifically about calling BLAS and CBLAS routines, see " Mixed-language Programming with the Intel® oneAPI Math Kernel Library" in theIntel® oneAPI Math Kernel Library Developer Guide.

NOTE:

This reference contains syntax in C for both the CBLAS interface and the Fortran BLAS routines.

In CBLAS, the Fortran routine names are prefixed with cblas_ (for example, dasum becomes cblas_dasum). Names of all CBLAS functions are in lowercase letters. Like BLAS routines, Intel® oneAPI Math Kernel Library provides CBLAS routines with the _64 suffix (for example, cblas_dasum_64) to support large data arrays in the LP64 interface library on 64-bit platforms. For more interface library details, see "Using the ILP64 Interface vs. LP64 Interface" in the developer guide.

Complex functions ?dotc and ?dotu become CBLAS subroutines (void functions); they return the complex result via a void pointer, added as the last parameter. CBLAS names of these functions are suffixed with _sub. For example, the BLAS function cdotc corresponds to cblas_cdotc_sub.

warning:

Users of the CBLAS interface should be aware that the CBLAS are just a C interface to the BLAS, which is based on the FORTRAN standard and subject to the FORTRAN standard restrictions. In particular, the output parameters should not be referenced through more than one argument.

NOTE:

This interface is not implemented in the Sparse BLAS Level 2 and Level 3 routines.

The arguments of CBLAS functions comply with the following rules:

  • Input arguments are declared with the const modifier.

  • Non-complex scalar input arguments are passed by value.

  • Complex scalar input arguments are passed as void pointers.

  • Array arguments are passed by address.

  • BLAS character arguments are replaced by the appropriate enumerated type.

  • Level 2 and Level 3 routines acquire an additional parameter of type CBLAS_LAYOUT as their first argument. This parameter specifies whether two-dimensional arrays are row-major (CblasRowMajor) or column-major (CblasColMajor).

Enumerated Types

The CBLAS interface uses the following enumerated types:

enum CBLAS_LAYOUT {
   CblasRowMajor=101,  /* row-major arrays */
   CblasColMajor=102};   /* column-major arrays */
enum CBLAS_TRANSPOSE {
   CblasNoTrans=111,     /* trans='N' */
   CblasTrans=112,       /* trans='T' */
   CblasConjTrans=113};  /* trans='C' */
enum CBLAS_UPLO {
   CblasUpper=121,        /* uplo ='U' */
   CblasLower=122};       /* uplo ='L' */
enum CBLAS_DIAG {
   CblasNonUnit=131,      /* diag ='N' */
   CblasUnit=132};        /* diag ='U' */
enum CBLAS_SIDE {
   CblasLeft=141,         /* side ='L' */
   CblasRight=142};       /* side ='R' */