Quantcast
Channel: Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1616

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

$
0
0

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[i]=(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[h]);
 }
 delete[] flag;
 DeleteCriticalSection(&mcsOS);

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

     The above function OSGeoWorker is not over, When the program execution to image[i]=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 !

 

 

 


Viewing all articles
Browse latest Browse all 1616

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>