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

KMP_DUPLICATE_LIB_OK and omp_set_num_threads

Deleted_U_Intel
Employee
2,499 Views
Hi all:
I need to dynamically control whether to use multi-threading in MKL at runtime. According to intel doc, it seems quite trivial: just include "omp.h" and call omp_set_num_threads.

Since I'm using VC6 and MKL6.1, not intel C++ compiler, I don't have access to omp.h. However, because omp_set_num_threads is exported by libguide, I declare extern "C" void omp_set_num_threads (int) and call it from my code (though I'm not sure whether I miss any preprocessor declarations).

Now my code is linked with libguide.lib OK, but when it comes to calling omp_set_num_threads(1), the code aborted with message:
"
abort: Initializing libguide.lib, but found libguide4
0.lib already initialized.
This can cause performance degradation.
Set environment variable KMP_DUPLICATE_LIB_OK=TRUE if you want your program to continue in this case.
"

Even if I set KMP_DUPLICATE_LIB_OK=TRUE in the shell, somehow it's always removed during the execution, that is, I always got getenv("KMP_DUPLICATE_LIB_OK") == NULL, and the code always aborts with this message.

Thanks very much in advance
XW
0 Kudos
2 Replies
Intel_C_Intel
Employee
2,499 Views
Unfortunately MKL currently has an older version of libguide with it that has some problems. Despite that this should work just fine. I will ask the libguide developers to comment on this.
Bruce
0 Kudos
Jay_H_Intel
Employee
2,499 Views

We need more information about how you are using libguide. The warning message indicates that you have started two separate copies of libguide in your program, but your description of what you did doesn't indicate you should have two copies. Please include as much detail as you can. For instance, the exact compile command and link command you are using will help greatly.

We need detail about what the program does, as well. Is the program using a "fork" or other similar system call?

0 Kudos
Reply