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

Static Linking of a program with MKL and OpenMp's schedule()

John_Young
New Contributor I
266 Views

Hi,

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?

Thanks,
John

0 Kudos
3 Replies
Ying_H_Intel
Employee
266 Views

Hi Jonh,

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;
   omp_set_num_threads(2);

#ifdef _OPENMP
         #pragma omp parallel for schedule(dynamic)  // this does not work for threads != default
   //      #pragma omp parallel for  // this works properly for threads != default
#endif

 link libiomp5mt.lib. 

the result is like

    42   -0.105245
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.

Best Regards,

Ying

0 Kudos
SergeyKostrov
Valued Contributor II
266 Views
>>...Under these conditions, the for loop will only execute the first loop of the iteration and then exit. Did you use option /O2 of the Microsoft C++ compiler? If Yes, it looks like the for loop was optimized out and in order to resolve that issue a volatile variable ( with some initialization / assignment ) of any type needs to be added. A verification with Intel C++ compiler would also help to understand what is wrong.
0 Kudos
SergeyKostrov
Valued Contributor II
266 Views
Jonh, please don't pay attention with regard to my statement about '...the for loop was optimized out...'. I'll also take a look at the test project.
0 Kudos
Reply