Developer Reference for Intel® oneAPI Math Kernel Library for Fortran

ID 766686
Date 12/16/2022
Public

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

Document Table of Contents

?gemm

Computes a matrix-matrix product with general matrices.

Syntax

call sgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)

call dgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)

call cgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)

call zgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)

call scgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)

call dzgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)

call gemm(a, b, c [,transa][,transb] [,alpha][,beta])

Include Files
  • mkl.fi, blas.f90
Description

The ?gemm routines compute a scalar-matrix-matrix product and add the result to a scalar-matrix product, with general matrices. The operation is defined as

C := alpha*op(A)*op(B) + beta*C

where:

op(X) is one of op(X) = X, or op(X) = XT, or op(X) = XH,

alpha and beta are scalars,

A, B and C are matrices:

op(A) is an m-by-k matrix,

op(B) is a k-by-n matrix,

C is an m-by-n matrix.

See also:

  • cblas_?gemm for the C language interface to this routine

  • ?gemm3m, BLAS-like extension routines, that use matrix multiplication for similar matrix-matrix operations

Input Parameters
transa

CHARACTER*1. Specifies the form of op(A) used in the matrix multiplication:

  • if transa = 'N' or 'n', then op(A) = A;

  • if transa = 'T' or 't', then op(A) = AT;

  • if transa = 'C' or 'c' , then op(A) = AH.

transb

CHARACTER*1. Specifies the form of op(B) used in the matrix multiplication:

  • if transb = 'N' or 'n', then op(B) = B;

  • if transb = 'T' or 't', then op(B) = BT;

  • if transb = 'C' or 'c' , then op(B) = BH.

m

INTEGER. Specifies the number of rows of the matrix op(A) and of the matrix C. The value of m must be at least zero.

n

INTEGER. Specifies the number of columns of the matrix op(B) and the number of columns of the matrix C. The value of n must be at least zero.

k

INTEGER. Specifies the number of columns of the matrix op(A) and the number of rows of the matrix op(B). The value of k must be at least zero.

alpha

REAL for sgemm

DOUBLE PRECISION for dgemm

COMPLEX for cgemm, scgemm

DOUBLE COMPLEX for zgemm, dzgemm

Specifies the scalar alpha.

a

REAL for sgemm, scgemm

DOUBLE PRECISION for dgemm, dzgemm

COMPLEX for cgemm

DOUBLE COMPLEX for zgemm

Array, size lda by ka, where ka is k when transa = 'N' or 'n', and is m otherwise. Before entry with transa = 'N' or 'n', the leading m-by-k part of the array a must contain the matrix A, otherwise the leading k-by-m part of the array a must contain the matrix A.

lda

INTEGER. Specifies the leading dimension of a as declared in the calling (sub)program.

When transa = 'N' or 'n', then lda must be at least max(1, m), otherwise lda must be at least max(1, k).

b

REAL for sgemm

DOUBLE PRECISION for dgemm

COMPLEX for cgemm, scgemm

DOUBLE COMPLEX for zgemm, dzgemm

Array, size ldb by kb, where kb is n when transa = 'N' or 'n', and is k otherwise. Before entry with transa = 'N' or 'n', the leading k-by-n part of the array b must contain the matrix B, otherwise the leading n-by-k part of the array b must contain the matrix B.

ldb

INTEGER. Specifies the leading dimension of b as declared in the calling (sub)program.

When transb = 'N' or 'n' , then ldb must be at least max(1, k), otherwise ldb must be at least max(1, n).

beta

REAL for sgemm

DOUBLE PRECISION for dgemm

COMPLEX for cgemm, scgemm

DOUBLE COMPLEX for zgemm, dzgemm

Specifies the scalar beta. When beta is equal to zero, then c need not be set on input.

c

REAL for sgemm

DOUBLE PRECISION for dgemm

COMPLEX for cgemm, scgemm

DOUBLE COMPLEX for zgemm, dzgemm

Array, size ldc by n. Before entry, the leading m-by-n part of the array c must contain the matrix C, except when beta is equal to zero, in which case c need not be set on entry.

ldc

INTEGER. Specifies the leading dimension of c as declared in the calling (sub)program.

The value of ldc must be at least max(1, m).

Output Parameters
c

Overwritten by the m-by-n matrix (alpha*op(A)*op(B) + beta*C).

Example

For examples of routine usage, see these code examples in the Intel® oneAPI Math Kernel Library installation directory:

  • sgemm: examples\blas\source\sgemmx.f

  • dgemm: examples\blas\source\dgemmx.f

  • cgemm: examples\blas\source\cgemmx.f

  • zgemm: examples\blas\source\zgemmx.f

BLAS 95 Interface Notes

Routines in Fortran 95 interface have fewer arguments in the calling sequence than their FORTRAN 77 counterparts. For general conventions applied to skip redundant or reconstructible arguments, see BLAS 95 Interface Conventions.

Specific details for the routine gemm interface are the following:

a

Holds the matrix A of size (ma,ka) where

ka = k if transa='N',

ka = m otherwise,

ma = m if transa='N',

ma = k otherwise.

b

Holds the matrix B of size (mb,kb) where

kb = n if transb = 'N',

kb = k otherwise,

mb = k if transb = 'N',

mb = n otherwise.

c

Holds the matrix C of size (m,n).

transa

Must be 'N', 'C', or 'T'.

The default value is 'N'.

transb

Must be 'N', 'C', or 'T'.

The default value is 'N'.

alpha

The default value is 1.

beta

The default value is 0.