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_domain_set_num_threads

Specifies the number of OpenMP* threads for a particular function domain.

Syntax

int mkl_domain_set_num_threads (int nt, int domain);

Include Files

  • mkl.h

Input Parameters

Name

Type

Description

nt

int

nt > 0 - The number of threads suggested by the user.

nt = 0 - The default number of threads for the OpenMP run-time library.

nt < 0 - Invalid value, which is ignored.

domain

int

The named constant that defines the targeted domain.

Description

This function specifies how many OpenMP threads a particular function domain of Intel® oneAPI Math Kernel Library (oneMKL) should use. If this number is not set (default) or if it is set to zero in a call to this function, Intel® oneAPI Math Kernel Library (oneMKL) uses the default number of threads for the OpenMP run-time library. The number of threads specified applies to the specified function domain on all execution threads except the threads where the number of threads is set withmkl_set_num_threads_local. For a list of supported values of the domain argument, see Table "Intel MKL Function Domains".

The number of threads specified is only a hint, and Intel® oneAPI Math Kernel Library (oneMKL) may actually use a smaller number.

NOTE:

This function takes precedence over the MKL_DOMAIN_NUM_THREADS environment variable.

Return Values

Name

Type

Description

ierr

int

1 - Indicates no error, execution is successful.

0 - Indicates a failure, possibly because of invalid input parameters.

Example

#include "mkl.h"
…
mkl_domain_set_num_threads(4, MKL_DOMAIN_BLAS);
my_compute_using_mkl_blas();	// Intel MKL BLAS functions use up to 4 threads
my_compute_using_mkl_dft();	 // Intel MKL FFT functions use the default number of threads