Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
7294 Discussions

LAPACKE_dgeqrf hangs with omp dynamic enabled

JohhnyEnglish
Beginner
71 Views

I've been having an issue where scipy's svd hangs in mkl. My investigation seems to suggest its an issue where mkl is assuming it has 4 workers and is stuck waiting for them when it only has 1, due to me setting OMP_DYNAMIC=TRUE and omp reducing the number of workers when the machine is busy. 

 

Repro which was using the python `mkl-devel==2026.1.0` package:

#define _GNU_SOURCE

#include <mkl.h>
#include <omp.h>
#include <sched.h>
#include <stdio.h>


static double a[3000 * 128];
static double tau[128]


int main(void) {
    cpu_set_t cpus;

    /*
    We pin to one CPU to simulate OMP's behaviour when the load average on the machine is high.
    In dynamic mode this causes it to lower the maximum threading.
    */
    CPU_ZERO(&cpus);
    CPU_SET(sched_getcpu(), &cpus);
    if (sched_setaffinity(0, sizeof(cpus), &cpus) != 0) {
        perror("sched_setaffinity");
        return 1;
    }

    omp_set_dynamic(1);
    mkl_set_dynamic(0);
    mkl_set_num_threads_local(4);

    puts("starting DGEQRF");
    fflush(stdout);
    return LAPACKE_dgeqrf(LAPACK_COL_MAJOR, 3000, 128, a, 3000, tau)
}

Let me know if any more information would be useful

0 Kudos
0 Replies
Reply