[Insight-developers] MinGW and threads

Bill Hoffman bill.hoffman at kitware.com
Thu Apr 28 11:34:43 EDT 2005


Hi,

One of the new MinGW dashboards was failing a bunch of tests.
By setting the max number of threads to 1 the tests started to pass.
So, I think there is a problem with MinGW and threads.   To fix
it I can do this:

In itkMultiThreader.cxx:

#if defined(_WIN32)
    {
  SYSTEM_INFO sysInfo;
  GetSystemInfo(&sysInfo);
  num = sysInfo.dwNumberOfProcessors;
    }
// force the number of threads to 1 for mingw since it is broken
#if defined(__MINGW32__)
   num = 1;
#endif
#endif


On a related note, it would seem that the old SGI has a similar problem.  
However, the fix is not done in itkMultiThreader.cxx but rather in
itkTestMain.h:

// On some sgi machines, threads and stl don't mix.
#if defined(__sgi) && defined(_COMPILER_VERSION) && _COMPILER_VERSION <= 730
   itk::MultiThreader::SetGlobalDefaultNumberOfThreads(1);
#endif

While this will make all the tests pass, if a user actually wrote an ITK application
on that platform, it would use a greater number of threads and potentially not work.
So, I propose changing itkMultiThreader.cxx to force the number of threads to 1 for
the old SGI and MinGW.


-Bill



More information about the Insight-developers mailing list