Number of threads of Intel MKL functions inside OMP parallel regions

后端 未结 2 594
谎友^
谎友^ 2021-01-27 05:00

I have a multithreaded code in C, using OpenMP and Intel MKL functions. I have the following code:

    omp_set_num_threads(nth);
#pragma omp parallel for private         


        
2条回答
  •  萌比男神i
    2021-01-27 05:23

    The Intel MKL Library uses OPENMP threading software for multithreading. The number of threads created will be based on the enviornment variable "OMP_NUM_THREADS". The default value for OMP_NUM_THREADS depends on the Intel MKL version and OPENMP libraries.

    But in your case, you are doing a nested parallelism. But by default the nested parallelism is turn off. Hence the number of threads used by mkl_ddot function will be ONE (which means no parallelism at mkl_ddot function level).

    You can enable the nested parallelism by invoking omp_set_nested(1). By this way, in your case, the nested parallelism will be enabled and more than one thread will be used by mkl_ddot function.

提交回复
热议问题