comp.lang.ada
 help / color / mirror / Atom feed
From: Brian Drummond <brian_drummond@btconnect.com>
Subject: Re: Need some light on using Ada or not
Date: Sat, 19 Feb 2011 18:25:44 +0000
Date: 2011-02-19T18:25:44+00:00	[thread overview]
Message-ID: <kf10m69ihv8g49n8j5pemnu8fajo1r8l6k@4ax.com> (raw)
In-Reply-To: 4d5fd57d$0$6992$9b4e6d93@newsspool4.arcor-online.net

On Sat, 19 Feb 2011 15:36:45 +0100, Georg Bauhaus
<rm-host.bauhaus@maps.futureapps.de> wrote:

>On 2/19/11 2:07 PM, Brian Drummond wrote:
>> On 18 Feb 2011 22:52:38 GMT, "Luis P. Mendes"<luislupeXXX@gmailXXX.com>  wrote:
>
>>> I have some questions, however, that I'd like to be answered:
>>> 1. If Ada is more type safe and restricted than C++, how can it be
>>> significantly slower?

>> Two possible reasons; both come down to the relative number of people developing
>> for both languages.
>
>Some reasons are pretty simple: when the results are due
>to specialized libraries used, rather than a consequence
>of the properties of the respective language (built in
>storage management features in this test).  (Also interesting:
>The Java versions vary widely, and some are fast even though
>the solutions uses plain Java.)  The leading C and C++
>entries win by making these choices:
>
>C #includes <apr_pool.h>, that is, it exercises the Apache memory pool,
>not what is available with plain C.
>
>C++ #includes a similar thing from the Boost libraries.
>
>This is allowed by the test's rules and authorities, 

even though you are not allowed to supply your own pool.
Possibly harsh, but I can see the logic behind it.

>> Single processor, the Ada version is just 38% slower, with half the memory
>> footprint; probably a damn good compromise between footprint and speed.
>> However the C++ version exploits 4 cores. Given Ada's support for concurrent
>> tasks, that suggests some room for improvement...

Actually there is more to this ... I was erroneously confusing the "cpu time"
for the 4-processor code with the single-processor result which is actually
presented on another page.

4-core:  http://shootout.alioth.debian.org/u64q/performance.php?test=binarytrees
C++: 26.99s CPU time, 8.40s elapsed.
Ada: 37.45s CPU time, 37.47s elapsed.

1-core: http://shootout.alioth.debian.org/u64/performance.php?test=binarytrees
C++: 17.29s CPU time, 17.31s elapsed.
Ada: 37.42s CPU time, 37.44s elapsed.

So 
(a) even single-core, there is 2:1 between them.
(b) performance scales poorly; I would guess the multicore version is thrashing
the cache, and memory bandwidth is the limitation.

>I vaguely remember that it has been tried before, but so far there
>is no better solution.

That makes me feel better... 

I have broken down and finally started to learn Ada's tasking. So far I have
gone from 56s (CPU) 56s (elapsed) with one task, to 120s (CPU), 64s(elapsed)
with multiple tasks (on a smallish 2-core laptop)... 

Disappointing.

(If anybody's interested, I am using 9 tasks, one per "Depth" value in the main
while loop. The basic pattern is shown on p.488 of Barnes, Ada 2005. Iterate
over the tasks, providing their start values. Iterate again, collecting results.
I think the next step will be to collect results asynchronously when each task
finishes, using a protected object.).

But I believe you are correct that a better storage pool is probably the answer.

Maybe we need an Ada binding to Boost? :-)

- Brian



  reply	other threads:[~2011-02-19 18:25 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-18 22:52 Need some light on using Ada or not Luis P. Mendes
2011-02-18 23:58 ` Georg Bauhaus
2011-02-19 14:25   ` Simon Wright
2011-02-19  0:20 ` Edward Fish
2011-02-20  0:13   ` Luis P. Mendes
2011-02-20  1:36     ` Marc A. Criley
2011-02-20  9:59     ` mockturtle
2011-02-20 10:37     ` Brian Drummond
2011-02-20 11:08     ` Ludovic Brenta
2011-03-01  8:10     ` Adrian Hoe
2011-03-01  8:29       ` Thomas Løcke
2011-03-04 13:34         ` Adrian Hoe
2011-02-19  8:43 ` Vadim Godunko
2011-02-19 13:07 ` Brian Drummond
2011-02-19 14:17   ` Simon Wright
2011-02-19 18:02     ` Brian Drummond
2011-02-19 18:07       ` Bill Findlay
2011-02-20 10:42         ` Brian Drummond
2011-02-19 14:36   ` Georg Bauhaus
2011-02-19 18:25     ` Brian Drummond [this message]
2011-02-20 14:34       ` Brian Drummond
2011-02-20 15:45         ` jonathan
2011-02-20 16:18           ` Brian Drummond
2011-02-20 19:49           ` Pascal Obry
2011-02-20 19:57             ` Brian Drummond
2011-02-20 20:10               ` jonathan
2011-02-20 21:15                 ` Pascal Obry
2011-02-20 21:26                   ` Vinzent Hoefler
2011-02-20 21:33                     ` Vinzent Hoefler
2011-02-20 21:36                     ` Pascal Obry
2011-02-20 21:50                       ` Vinzent Hoefler
2011-02-20 22:18                   ` jonathan
2011-02-20 22:47               ` Simon Wright
2011-02-21 12:52                 ` Brian Drummond
2011-02-21 13:44                   ` Simon Wright
2011-02-24  0:19                     ` Brian Drummond
2011-02-24  7:41                       ` Jacob Sparre Andersen
2011-02-22  2:15                   ` Shark8
2011-02-20 16:42       ` jonathan
2011-02-20 20:02         ` Brian Drummond
2011-02-20  0:20   ` Luis P. Mendes
2011-02-20 10:50     ` Brian Drummond
2011-02-20 19:54     ` Brian Drummond
2011-02-23 22:19       ` Luis P. Mendes
2011-02-24 17:06         ` Brian Drummond
2011-02-27 17:51           ` Luis P. Mendes
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox