Hi,
I’m using curvatureAnisotropicDiffusionFilter class. I get correct result after filtering, but In macOS is much more slower than Linux or Windows.
Can someone tell the reason, or how can I fix this?
Thank you
Hi,
I’m using curvatureAnisotropicDiffusionFilter class. I get correct result after filtering, but In macOS is much more slower than Linux or Windows.
Can someone tell the reason, or how can I fix this?
Thank you
Make sure you compile your program in Release mode, not Debug. Also, if your Mac machine is a lot older (having fewer cores) it would run the code slower.
Program is in Release mode, and I’m using 16 core Mac.
The same implementation works much more slower in Mac.
For example MinMaxCurvatureFlowFilter works fine.
Maybe try a different version of the compiler? Are you sure you are not setting any of the environment variables which limit number of threads?
I did not touch any of it.
itk::MultiThreaderBase::GetGlobalDefaultNumberOfThreads(); returns 8
itk::MultiThreaderBase::GetGlobalMaximumNumberOfThreads(); return 128
If you have a 16 core Mac, GetGlobalDefaultNumberOfThreads()
should return 16. Can you step through GetGlobalDefaultNumberOfThreads()
using a debugger and find out why 8 gets chosen?
I have tested for 2 different macs. 8 core Mac workes even slower than 16 core mac.
Incomprehensible is that the same code for 8 core linux or 8 core windows workes 3 or 4 times faster than on 16 core mac.(Just to inform: I didn’t use any #ifdef
)
Here is the code.
using ImageType = itk::Image<double, 2>;
using OutputImageType = itk::Image<double, 2>;
using ScalarImageType = itk::Image<float, 2>;
using ToType = itk::CastImageFilter<ImageType, ScalarImageType>;
using FromType = itk::CastImageFilter<ScalarImageType, OutputImageType>;
using FilterType = itk::CurvatureAnisotropicDiffusionImageFilter<typename ITKType::ScalarImageType, typename ITKType::ScalarImageType>;
typename ToType::Pointer toCastor = ToType::New();
typename FromType::Pointer fromCastor = FromType::New();
typename FilterType::Pointer filter = FilterType::New();
toCastor->SetInput(/*ITK image*/);
filter->SetInput(toCastor->GetOutput());
filter->SetTimeStep(timeStep);
filter->SetNumberOfIterations(iters);
filter->SetConductanceParameter(cond);
fromCastor->SetInput(filter->GetOutput());
fromCastor->Update();
With same compiler/version and same hardware, it should matter very little for ITK which operating system is running. MacOS, Linux and Windows should all provide about the same performance. There must be something different about your Macs, besides just thinking differently