Community
cancel
Showing results for 
Search instead for 
Did you mean: 
qingkong_y_
Beginner
146 Views

Intel c + + compiler multithreading, out-of-order execution loop

Hi,

     When I use MVC++ compiler running normally, using Intel c++ compiler the loop execution out-of-order(thread = 1).

The following code:

mNumberOfWorkers=1;

 HANDLE *flag = new HANDLE[mNumberOfWorkers];
 InitializeCriticalSection(&mcsOS);
 for(int i=0; i<mNumberOfWorkers; i++)
 {
  flag=(HANDLE)_beginthreadex(0,0,(unsigned int(__stdcall*)(void*))OSGeoWorker,this,0,0);
 }
 WaitForMultipleObjects(mNumberOfWorkers, flag, true, INFINITE);
 for (int h = 0; h < mNumberOfWorkers; h++)
 {
  CloseHandle(flag);
 }
 delete[] flag;
 DeleteCriticalSection(&mcsOS);

for (int i=0, imax=Size; i<imax; i++)
 {
  image=0.0f;
 }

     The above function OSGeoWorker is not over, When the program execution to image=0.

     The function OSGeoWorker and loop(for (int i=0, imax=Size; i<imax; i++)) run alternately.

     how can I find the error in the program?

     Thank you !

 

 

 

0 Kudos
8 Replies
TimP
Black Belt
146 Views

Do you use equivalent compiler optimization levels for the 2 compilers, e.g.

/Ox /fp:precise for both

or

/Ox /fp:fast for MSVC++ and /Ox /fp:source for ICL?

MSVC has no optimization as aggressive as the ICL defaults.

qingkong_y_
Beginner
146 Views

  The optimization levels of two compilers are same.Has been checked.

Bernard
Black Belt
146 Views

Do you mean that single thread which is executing OSGeoWorker did not terminate? Did you check any terminating conditions inside aferementioned function like: infinite loops?

qingkong_y_
Beginner
146 Views

OSGeoWorker did not terminate.  And the loop executes only 2 or 3 times, than jump to the following loop.

(for (int i=0, imax=Size; i<imax; i++)
 {
  image=0.0f;
 })

Yuan_C_Intel
Employee
146 Views

Hi, Qingkong

I seems cannot reproduce this with a simple test case using your code snippet.

What's the Intel compiler version you are using? And how about the compiler options?

A reproducible test case is preferred to root cause the problem.

Thanks.

Bernard
Black Belt
146 Views

So the function did not terminate.

I think that my advise is still valid. You should check what is happening inside OSGeoWorker function.

Bernard
Black Belt
146 Views

@Qingkong

Can you post source code of OSGeoWorker function?

qingkong_y_
Beginner
146 Views

I found the error. INFINITE set error. Function OSGeoWorker didn't work. Still thank you for your help!
Reply