Developer Reference for Intel® oneAPI Math Kernel Library for C

ID 766684
Date 3/22/2024
Public

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

Document Table of Contents

mkl_jit_create_?gemm

Create a GEMM kernel that computes a scalar-matrix-matrix product and adds the result to a scalar-matrix product.

Syntax

mkl_jit_status_t mkl_jit_create_sgemm(void** jitter, const MKL_LAYOUT layout, const MKL_TRANPOSE transa, const MKL_TRANSPOSE transb, const MKL_INT m, const MKL_INT n, const MKL_INT k, const float alpha, const MKL_INT lda, const MKL_INT ldb, const float beta, const MKL_INT ldc);

mkl_jit_status_t mkl_jit_create_dgemm(void** jitter, const MKL_LAYOUT layout, const MKL_TRANPOSE transa, const MKL_TRANSPOSE transb, const MKL_INT m, const MKL_INT n, const MKL_INT k, const double alpha, const MKL_INT lda, const MKL_INT ldb, const double beta, const MKL_INT ldc);

mkl_jit_status_t mkl_jit_create_cgemm(void** jitter, const MKL_LAYOUT layout, const MKL_TRANPOSE transa, const MKL_TRANSPOSE transb, const MKL_INT m, const MKL_INT n, const MKL_INT k, const void* alpha, const MKL_INT lda, const MKL_INT ldb, const void* beta, const MKL_INT ldc);

mkl_jit_status_t mkl_jit_create_zgemm(void** jitter, const MKL_LAYOUT layout, const MKL_TRANPOSE transa, const MKL_TRANSPOSE transb, const MKL_INT m, const MKL_INT n, const MKL_INT k, const void* alpha, const MKL_INT lda, const MKL_INT ldb, const void* beta, const MKL_INT ldc);

Include Files

  • mkl.h

Description

The mkl_jit_create_?gemm functions belong to a set of related routines that enable use of just-in-time code generation.

The mkl_jit_create_?gemm functions create a handle to a just-in-time code generator (a jitter) and generate a GEMM kernel that computes a scalar-matrix-matrix product and adds the result to a scalar-matrix product, with general matrices. The operation of the generated GEMM kernel is defined as follows:

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

Where:

  • op(X) is either 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
NOTE:

Generating a new kernel with mkl_jit_create_?gemm involves moderate runtime overhead. To benefit from JIT code generation, use this feature when you need to call the generated kernel many times (for example, several hundred calls).

Input Parameters

layout

Specifies whether two-dimensional array storage is row-major (MKL_ROW_MAJOR) or column-major (MKL_COL_MAJOR).

transa

Specifies the form of op(A) used in the generated matrix multiplication:

  • if transa = MKL_NOTRANS, then op(A) = A
  • if transa = MKL_TRANS, then op(A) = AT
  • if transa = MKL_CONJTRANS, then op(A) = AH

transb

Specifies the form of op(B) used in the generated matrix multiplication:

  • if transb = MKL_NOTRANS, then op(B) = B
  • if transb = MKL_TRANS, then op(B) = BT
  • if transb = MKL_CONJTRANS, then op(B) = BH

m

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

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

k

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

Specifies the scalar alpha.

NOTE:

alpha is passed by pointer for mkl_jit_create_cgemm and mkl_jit_create_zgemm.

lda

Specifies the leading dimension of a.

  transa=MKL_NOTRANS transa=MKL_TRANS or transa=MKL_CONJTRANS
layout=MKL_ROW_MAJOR

lda must be at least max(1,k)

lda must be at least max(1,m)

layout=MKL_COL_MAJOR

lda must be at least max(1,m)

lda must be at least max(1,k)

ldb

Specifies the leading dimension of b:

  transb=MKL_NOTRANS transb=MKL_TRANS or transb=MKL_CONJTRANS
layout=MKL_ROW_MAJOR

ldb must be at least max(1,n)

ldb must be at least max(1,k)

layout=MKL_COL_MAJOR

ldb must be at least max(1,k)

ldb must be at least max(1,n)

beta

Specifies the scalar beta.

NOTE:

beta is passed by pointer for mkl_jit_create_cgemm and mkl_jit_create_zgemm.

ldc

Specifies the leading dimension of c.

layout=MKL_ROW_MAJOR

ldc must be at least max(1,n)

layout=MKL_COL_MAJOR

ldc must be at least max(1,m)

Output Parameters

jitter

Pointer to a handle to the newly created code generator.

Return Values

status

Returns one of the following:

  • MKL_JIT_ERROR if the handle cannot be created (no memory)

    —or—

  • MKL_JIT_SUCCESS if the jitter has been created and the GEMM kernel was successfully created

    —or—

  • MKL_NO_JIT if the jitter has been created, but a JIT GEMM kernel was not created because JIT is not beneficial for the given input parameters. The function pointer returned by mkl_jit_get_?gemm_ptr will call standard (non-JIT) GEMM.