[Insight-developers] Some casting improvements.

Bradley Lowekamp blowekamp at mail.nih.gov
Wed May 8 08:37:37 EDT 2013


Hello,

I know the CastImageFilter is no the most exciting filter but, it's probably the most frequently used and should be as snappy as possible. And the lessons learn here should be applicable to many other places.

I am clamming that I have speed this guy up by 5-25X from ITK v4.3.2 when the following two patch are combined:

http://review.source.kitware.com/#/c/11174/
http://review.source.kitware.com/#/c/11163/

I have to thank Kent for motivating the use of using std:copy for conversion to get most of this gain, in ImageAlgorithm::Copy.

The following performance was measure by converting short to float,  with the following loop:

const unsigned int cnt = 5;

  for ( unsigned int j = 0; j < 10; ++j )
    {
    t.Start();
    for ( unsigned int i = 0; i < cnt; ++i )
      {
      inImage1->Modified();
      f->Update();
      }
    t.Stop();
    }

  std::cout << "\t+Add Average Time: " << t.GetMean()/cnt << t.GetUnit() << std::endl;


I hope the follow table get formatted OK over e-mail:

gcc 4.4.7	4.3.2	master	w/ std::copy			master speedup	incremental speedup	total speedup
[64, 64, 64]	0.0023021	0.0007273	0.0001291			3.16510482	5.633172757	17.82958224
[128, 128, 128]	0.0169621	0.0043321	0.0010102			3.915409013	4.28822854	16.79016867
[256, 256, 256]	0.1418440	0.0306757	0.0238598			4.623985761	1.285664591	5.94489476
[32, 32]	0.0000141	0.0000064	0.0000037			2.182823223	1.732051203	3.780761589
[64, 64]	0.0000364	0.0000116	0.0000034			3.12844542	3.417944909	10.6928541
[128, 128]	0.0001251	0.0000319	0.0000077			3.920922622	4.163037648	16.32294849
[256, 256]	0.0004688	0.0001040	0.0000190			4.50977299	5.469650176	24.66688063
gcc 4.7.1								
[64, 64, 64]	0.00162290	0.0004971	0.0001243			3.264998189	3.999420677	13.05810127
[128, 128, 128]	0.01117240	0.0022267	0.0009529			5.017424732	2.336883002	11.72513457
[256, 256, 256]	0.08918900	0.0228131	0.0236030			3.909551968	0.966533915	3.77871457
[32, 32]	0.00001120	0.0000058	0.0000036			1.916726871	1.631158459	3.126485249
[64, 64]	0.00002628	0.0000075	0.0000032			3.48356744	2.371815752	8.262380129
[128, 128]	0.00008760	0.0000140	0.0000074			6.257173266	1.891748001	11.83699502
[256, 256]	0.00031716	0.0000317	0.0000191			10.00511039	1.656612056	16.5745865
icc 13.0.1								
[64, 64, 64]	0.0018701	0.001209	0.000130162			1.546832093	9.288425193	14.36763418
[128, 128, 128]	0.0122367	0.007942	0.000991583			1.540827839	8.009052192	12.34057058
[256, 256, 256]	0.0965067	0.060345	0.0190372			1.599238716	3.169867417	5.069374698
[32, 32]	0.0000114	0.000009	3.28E-06			1.246741281	2.792150312	3.481089056
[64, 64]	0.0000301	0.000018	3.22E-06			1.715369954	5.444456527	9.339257142
[128, 128]	0.0001030	0.000062	9.04E-06			1.663153917	6.852245337	11.39633867
[256, 256]	0.0003961	0.000221	2.05E-05			1.794484058	10.75578251	19.30108025
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-developers/attachments/20130508/3d722416/attachment.htm>


More information about the Insight-developers mailing list