[Insight-developers] Some casting improvements.

Williams, Norman K norman-k-williams at uiowa.edu
Thu May 9 16:12:33 EDT 2013


That's pretty sweet.

I wondered about this the other day:  You can't use std::copy directly on
types that could in theory benefit from it.  For example:

#include <algorithm>
#include <iostream>
#include "itkVector.h"

int main(int argc, char *argv[])
{
  typedef itk::Vector<double, 32> VecType;
  VecType a, b;
  // this won't work
  std::copy(a,a.end(),b);
  // this works but is fugly
  std::copy(a.GetDataPointer(),
            a.GetDataPointer()+VecType::Dimension,
            b.GetDataPointer());
}


Would it add unacceptable ugliness to support std::algorithm copy
semantics?
--
Kent Williams norman-k-williams at uiowa.edu






On 5/8/13 7:37 AM, "Bradley Lowekamp" <blowekamp at mail.nih.gov> wrote:

>
>
>
>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.74.3.2masterw/ std::copymaster speedupincremental speeduptotal
>speedup[64, 64,
>64]0.00230210.00072730.00012913.165104825.63317275717.82958224[128, 128,
>128]0.01696210.00433210.00101023.9154090134.2882285416.79016867[256, 256,
>256]0.14184400.03067570.02385984.6239857611.2856645915.94489476[32,
>32]0.00001410.00000640.00000372.1828232231.7320512033.780761589[64,
>64]0.00003640.00001160.00000343.128445423.41794490910.6928541[128,
>128]0.00012510.00003190.00000773.9209226224.16303764816.32294849[256,
>256]0.00046880.00010400.00001904.509772995.46965017624.66688063gcc
>4.7.1[64, 64,
>64]0.001622900.00049710.00012433.2649981893.99942067713.05810127[128,
>128,
>128]0.011172400.00222670.00095295.0174247322.33688300211.72513457[256,
>256, 256]0.089189000.02281310.02360303.9095519680.9665339153.77871457[32,
>32]0.000011200.00000580.00000361.9167268711.6311584593.126485249[64,
>64]0.000026280.00000750.00000323.483567442.3718157528.262380129[128,
>128]0.000087600.00001400.00000746.2571732661.89174800111.83699502[256,
>256]0.000317160.00003170.000019110.005110391.65661205616.5745865icc
>13.0.1[64, 64,
>64]0.00187010.0012090.0001301621.5468320939.28842519314.36763418[128,
>128,
>128]0.01223670.0079420.0009915831.5408278398.00905219212.34057058[256,
>256, 256]0.09650670.0603450.01903721.5992387163.1698674175.069374698[32,
>32]0.00001140.0000093.28E-061.2467412812.7921503123.481089056[64,
>64]0.00003010.0000183.22E-061.7153699545.4444565279.339257142[128,
>128]0.00010300.0000629.04E-061.6631539176.85224533711.39633867[256,
>256]0.00039610.0002212.05E-051.79448405810.7557825119.30108025



________________________________
Notice: This UI Health Care e-mail (including attachments) is covered by the Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is confidential and may be legally privileged.  If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, or copying of this communication is strictly prohibited.  Please reply to the sender that you have received the message in error, then delete it.  Thank you.
________________________________


More information about the Insight-developers mailing list