- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 !
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The optimization levels of two compilers are same.Has been checked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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;
})
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So the function did not terminate.
I think that my advise is still valid. You should check what is happening inside OSGeoWorker function.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Qingkong
Can you post source code of OSGeoWorker function?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page