Mir Blog: Writing efficient numerical code in D

Relja Ljubobratovic via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Mon Dec 12 15:03:44 PST 2016


On Monday, 12 December 2016 at 22:34:32 UTC, Johan Engelen wrote:
> On Monday, 12 December 2016 at 21:58:23 UTC, Relja 
> Ljubobratovic wrote:
>> Hey guys,
>>
>> We have just published another post on "Writing efficient 
>> numerical code in D", to Mir's Blog[1].
>
> Nice :)

Thanks! :)

>
> Some comments:
> - You can make the numbers in the table more readable by adding 
> commas?
> For example, 1624687 --> 1,624,687. Probably even better is to 
> only show the most significant digits. 1624687 us --> 1.625 s 
> for example.

Great suggestion - I was focusing on the speedup, so I didn't pay 
attention to run time, but obviously other people will.

> - Add a sentence about the benchmarking set up. " The numbers 
> shown are the best times of 10 trials, with LDC commandline 
> options `ldc2 -O3 -release`" Something like that. Or add it to 
> the configuration table.

Thanks, will do. I agree there's an explanation missing on how 
benchmark is configured.

> - For the "convolution" example, could you elaborate on why the 
> Mir-based implementation is so much faster than the C-like 
> implementation? From the big table, I see that the speedup for 
> DCV's convolution algorithms is not as large as 10x.

DCV's convolution is parallelized, which I believe, could be the 
reason. Ilya is probably the best man to elaborate the speedup vs 
C implementation.

> - The "threshold" algorithm has a 19x speed up?! (I would 
> remove "threshold" from the average improvement calculation. 
> The numbers are already awesome, no need to oversell it!)

I agree. I was thrilled when I saw the comparison at first, but 
to be honest, I'm not sure what's the main reason. Here's the 
commit diff if anyone is interested to explain:
https://github.com/libmir/dcv/pull/58/commits/0c744a7bb7308f07bd45d041c6e88e906c905fcf

> - Overall, does this mean that DCV became more than twice as 
> fast? How does it stack up to other vision libs after this 
> massive speed boost?

I'm not sure. But I'm afraid we're not even close to opencv, 
since its base image processing (and other) algorithms have been 
intensively (manually) optimized with SIMD, but also have almost 
100% coverage with OpenCL (and CUDA from 3.x). Anyhow, I'd like 
not to bother with comparisons like this until we are satisfied 
with DCV - there's much work yet to be done, IMHO.

>
> cheers,
>   Johan

Thanks for the feedback Johan!



More information about the Digitalmars-d-announce mailing list