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
KMP_DUPLICATE_LIB_OK and omp_set_num_threads