[Insight-developers] fill

Bradley Lowekamp blowekamp at mail.nih.gov
Thu Apr 11 09:12:16 EDT 2013


Bill,

I made some changes to the array size in the test, cranked up the repeats to 2 bill.

--Current ITK Array Fill--

Array size = 2, repetitions = 2000000000
The elapsed time for a C++ fill_n 12540000 ms.
The elapsed time for a itk.Fill   10030000 ms.
The elapsed time for a C   fill   21710000 ms.

Array size = 3, repetitions = 2000000000
The elapsed time for a C++ fill_n 15480000 ms.
The elapsed time for a itk.Fill   11700000 ms.
The elapsed time for a C   fill   7520000 ms.

Array size = 4, repetitions = 2000000000
The elapsed time for a C++ fill_n 10870000 ms.
The elapsed time for a itk.Fill   13370000 ms.
The elapsed time for a C   fill   9200000 ms.

Array size = 5, repetitions = 2000000000
The elapsed time for a C++ fill_n 13380000 ms.
The elapsed time for a itk.Fill   15040000 ms.
The elapsed time for a C   fill   11270000 ms.

Array size = 6, repetitions = 2000000000
The elapsed time for a C++ fill_n 14230000 ms.
The elapsed time for a itk.Fill   16780000 ms.
The elapsed time for a C   fill   13320000 ms.

Array size = 7, repetitions = 2000000000
The elapsed time for a C++ fill_n 15910000 ms.
The elapsed time for a itk.Fill   18410000 ms.
The elapsed time for a C   fill   15190000 ms.

--STL fill in ITK Array Fill--

Array size = 2, repetitions = 2000000000
The elapsed time for a C++ fill_n 14210000 ms.
The elapsed time for a itk.Fill   12540000 ms.
The elapsed time for a C   fill   21870000 ms.

Array size = 3, repetitions = 2000000000
The elapsed time for a C++ fill_n 16590000 ms.
The elapsed time for a itk.Fill   15310000 ms.
The elapsed time for a C   fill   8700000 ms.

Array size = 4, repetitions = 2000000000
The elapsed time for a C++ fill_n 10880000 ms.
The elapsed time for a itk.Fill   10860000 ms.
The elapsed time for a C   fill   11460000 ms.

Array size = 5, repetitions = 2000000000
The elapsed time for a C++ fill_n 12540000 ms.
The elapsed time for a itk.Fill   11700000 ms.
The elapsed time for a C   fill   14770000 ms.

Array size = 6, repetitions = 2000000000
The elapsed time for a C++ fill_n 13380000 ms.
The elapsed time for a itk.Fill   12540000 ms.
The elapsed time for a C   fill   17270000 ms.

Array size = 7, repetitions = 2000000000
The elapsed time for a C++ fill_n 15890000 ms.
The elapsed time for a itk.Fill   15050000 ms.
The elapsed time for a C   fill   20480000 ms.

For this test with my gcc it appears the is a benefit for arrays of 4+. However it does appear that 2,3 may be a little slower...

I have been pondering the need to exploit the partial specialization we not have available to optimize some of our core types...

Brad

On Apr 11, 2013, at 8:27 AM, Bill Lorensen <bill.lorensen at gmail.com> wrote:

> What do the timings look like for small array size, e.g. 3, 4... ITK uses Fill() to initialize sizes, indexes, points, etc. which are small.
> 
> 
> 
> On Wed, Apr 10, 2013 at 12:07 PM, Bradley Lowekamp <blowekamp at mail.nih.gov> wrote:
> I was able to get quite similar numbers on RH w/ gcc 4.4.7 in standard release mode:
> 
> Array size = 100, repetitions = 20000000
> The elapsed time for a C++ fill_n 690000 ms.
> The elapsed time for a itk.Fill   1910000 ms.
> The elapsed time for a C   fill   2620000 ms.
> 
> Array size = 1000, repetitions = 2000000
> The elapsed time for a C++ fill_n 460000 ms.
> The elapsed time for a itk.Fill   1700000 ms.
> The elapsed time for a C   fill   2520000 ms.
> 
> Array size = 10000, repetitions = 200000
> The elapsed time for a C++ fill_n 420000 ms.
> The elapsed time for a itk.Fill   1680000 ms.
> The elapsed time for a C   fill   2510000 ms.
> 
> Array size = 100000, repetitions = 20000
> The elapsed time for a C++ fill_n 570000 ms.
> The elapsed time for a itk.Fill   1670000 ms.
> The elapsed time for a C   fill   2510000 ms.
> 
> Array size = 1000000, repetitions = 2000
> The elapsed time for a C++ fill_n 600000 ms.
> The elapsed time for a itk.Fill   1680000 ms.
> The elapsed time for a C   fill   2510000 ms.
> 
> Array size = 10000000, repetitions = 200
> The elapsed time for a C++ fill_n 1510000 ms.
> The elapsed time for a itk.Fill   1820000 ms.
> The elapsed time for a C   fill   2540000 ms.
> 
> I did modify the test to set the value to 3.14, instead of 0, because other optimization may happen with a zero value...
> 
> Brad
> 
> On Apr 10, 2013, at 11:33 AM, Bill Lorensen <bill.lorensen at gmail.com> wrote:
> 
>> Or maybe Ubuntu is milliseconds and windows is seconds?
>> 
>> 
>> 
>> On Wed, Apr 10, 2013 at 11:28 AM, Bill Lorensen <bill.lorensen at gmail.com> wrote:
>> The Ubuntu timings are much longer than windows. Was that expected?
>> 
>> 
>> 
>> On Wed, Apr 10, 2013 at 10:42 AM, <M.Staring at lumc.nl> wrote:
>> 
>> 
>> -----Original Message-----
>> From: Staring, M. (LKEB)
>> Sent: woensdag 10 april 2013 16:28
>> To: Insight Developers (insight-developers at itk.org)
>> Subject: FW: fill
>> 
>> Forgot to include the maliing list
>> 
>> -----Original Message-----
>> From: Staring, M. (LKEB)
>> Sent: woensdag 10 april 2013 16:24
>> To: 'Williams, Norman K'; blowekamp at mail.nih.gov
>> Cc: matt.mccormick at kitware.com
>> Subject: RE: fill
>> 
>> Hi,
>> 
>> Attached you can find some timings for different POD types, I tested for short, int, float and double. std::fill_n is always faster, but less so for longer types.
>> 
>> I simply modified itk::Array::Fill to use std::fill_n instead of referring to the vnl_vector::fill which uses a simple loop over the data. Not sure if this is the way to go, but my experimental looks green:
>> 
>>         http://open.cdash.org/buildSummary.php?buildid=2871413
>> 
>> The patch I just submitted to gerrit:
>> 
>>         http://review.source.kitware.com/#/c/10801/
>> 
>> Curious to your comments,
>> 
>> Regards, Marius
>> 
>> -----Original Message-----
>> 
>> 
>> _______________________________________________
>> Powered by www.kitware.com
>> 
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>> 
>> Kitware offers ITK Training Courses, for more information visit:
>> http://kitware.com/products/protraining.php
>> 
>> Please keep messages on-topic and check the ITK FAQ at:
>> http://www.itk.org/Wiki/ITK_FAQ
>> 
>> Follow this link to subscribe/unsubscribe:
>> http://www.itk.org/mailman/listinfo/insight-developers
>> 
>> 
>> 
>> 
>> -- 
>> Unpaid intern in BillsBasement at noware dot com
>> 
>> 
>> 
>> -- 
>> Unpaid intern in BillsBasement at noware dot com
>> _______________________________________________
>> Powered by www.kitware.com
>> 
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>> 
>> Kitware offers ITK Training Courses, for more information visit:
>> http://kitware.com/products/protraining.php
>> 
>> Please keep messages on-topic and check the ITK FAQ at:
>> http://www.itk.org/Wiki/ITK_FAQ
>> 
>> Follow this link to subscribe/unsubscribe:
>> http://www.itk.org/mailman/listinfo/insight-developers
> 
> 
> 
> 
> -- 
> Unpaid intern in BillsBasement at noware dot com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-developers/attachments/20130411/2db98f41/attachment.htm>


More information about the Insight-developers mailing list