Developer Reference for Intel® oneAPI Math Kernel Library for Fortran

ID 766686
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

mkl_set_num_threads

Specifies the number of OpenMP* threads to use.

Syntax

call mkl_set_num_threads( nt )

Fortran Include Files/Modules

  • Include file: mkl.fi
  • Module (compiled): mkl_service.mod
  • Module (source): mkl_service.f90

Input Parameters

Name

Type

Description

nt

INTEGER

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

nt 0 - Invalid value, which is ignored.

Description

This function enables you to specify how many OpenMP threads Intel® oneAPI Math Kernel Library (oneMKL) should use for internal parallel regions. If this number is not set (default), Intel® oneAPI Math Kernel Library (oneMKL) functions use the default number of threads for the OpenMP run-time library. The specified number of threads applies:

  • To all Intel® oneAPI Math Kernel Library (oneMKL) functions except the functions from the domains where the number of threads is set withmkl_domain_set_num_threads

  • To all execution threads except the threads where the number of threads is set with mkl_set_num_threads_local

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

NOTE:

This function takes precedence over the MKL_NUM_THREADS environment variable.

Example

use mkl_service
…
call mkl_set_num_threads(4)
call my_compute_using_mkl  !Intel MKL uses up to 4 OpenMP threads