We have a program that we for various reasons we on rare occasion need to link statically. When we do, we encounter the following problem with a parallel for loop. The conditions are
A. Program linked statically with libiomp5mt.lib
B. The number of threads are set different than the default number of threads, i.e., the number of threads that would be used if OMP_NUM_THREADS is not set or omp_set_num_threads() is not used.
C. The schedule(dynamic), schedule(dynamic,X) or schedule(static,X) is used in the for loop. 'schedule(static)' or no schedule does not exhibit the problem.
Under these conditions, the for loop will only execute the first loop of the iteration and then exit.
Our platform is MS Vista 64, MS Visual Studio 2008, MS C++ compiler, Intel MKL 10.0.5.025. I have attached a visual studio project that exhibits the problem.
If VCOMP is used instead of libiomp, the problem does not occur.
We are wondering if this is an MKL problem or a MS VS problem, or possibly something we are unaware of with OpenMP?
Not sure if it is still intrested. The libiomp5 is Intel OpenMP runtime library, which is from Intel Compiler. MKL use it. I just try the library from MKL 10.1.0.018 (the old version installed on my machine, the latest one is MKL 11.0 update 4) .. The problem does not exhibited.
for example, the code is
int imax = 50;
#pragma omp parallel for schedule(dynamic) // this does not work for threads != default
// #pragma omp parallel for // this works properly for threads != default
the result is like
1 44 0.894755
0 45 -0.105245
1 46 0.894755
0 47 -0.105245
1 48 0.894755
0 49 -0.105245.
It starts 2 threads.
On the other hands, Intel Compiler have removed the libiomp5mt.lib because some reason. please see http://software.intel.com/en-us/articles/openmp-support-change and http://software.intel.com/en-us/forums/topic/328168
So I guess it may be a bug of libiomp5, but have been fixed in later version.