KMP_DUPLICATE_LIB_OK and omp_set_num_threads

KMP_DUPLICATE_LIB_OK and omp_set_num_threads

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

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

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.


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?

Leave a Comment

Please sign in to add a comment. Not a member? Join today