Developer Reference for Intel® oneAPI Math Kernel Library for C

ID 766684
Date 6/24/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_domain_get_max_threads

Gets the number of OpenMP* threads targeted for parallelism for a particular function domain.

Syntax

int mkl_domain_get_max_threads (int domain);

Include Files

  • mkl.h

Input Parameters

Name

Type

Description

domain

int

The named constant that defines the targeted domain.

Description

Computational functions of the Intel® oneAPI Math Kernel Library (oneMKL) function domain defined by thedomain parameter use the value returned by this function as a limit of the number of OpenMP threads they should request for parallel computations. The mkl_domain_get_max_threads function returns the thread-local number of threads or, if that value is zero or not set, the global number of threads. To determine this number, the function inspects the environment settings and return values of the function calls below in the order they are listed until it finds a non-zero value:

  • A call to mkl_set_num_threads_local

  • The last of the calls to mkl_set_num_threads or mkl_domain_set_num_threads( …, MKL_DOMAIN_ALL)

  • A call to mkl_domain_set_num_threads( …, domain)

  • The MKL_DOMAIN_NUM_THREADS environment variable with the MKL_DOMAIN_ALL tag

  • The MKL_DOMAIN_NUM_THREADS environment variable (with the specific domain tag)

  • The MKL_NUM_THREADS environment variable

  • A call to omp_set_num_threads

  • The OMP_NUM_THREADS environment variable

Actual number of threads used by the Intel® oneAPI Math Kernel Library (oneMKL) computational functions may vary depending on the problem size and on whether dynamic adjustment of the number of threads is enabled (see the description ofmkl_set_dynamic). For a list of supported values of the domain argument, see Table "Intel MKL Function Domains".

Return Values

Name

Type

Description

nt

int

The maximum number of threads for Intel® oneAPI Math Kernel Library (oneMKL) functions from a given domain to use in internal parallel regions.

If an invalid value of domain is supplied, the function returns the number of threads for MKL_DOMAIN_ALL

Example

#include "mkl.h"
…
if (1 < mkl_domain_get_max_threads(MKL_DOMAIN_BLAS)) 
puts("Intel MKL BLAS functions employ threading");