From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ad4585f2971e47c5 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!feeder.news-service.com!216.196.110.144.MISMATCH!border3.nntp.ams.giganews.com!Xl.tags.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!local2.nntp.ams.giganews.com!nntp.bt.com!news.bt.com.POSTED!not-for-mail NNTP-Posting-Date: Sun, 20 Feb 2011 08:31:46 -0600 From: Brian Drummond Newsgroups: comp.lang.ada Subject: Re: Need some light on using Ada or not Date: Sun, 20 Feb 2011 14:34:35 +0000 Reply-To: brian@shapes.demon.co.uk Message-ID: References: <4d5ef836$0$23753$14726298@news.sunsite.dk> <7ibvl6tn4os3njo3p4kek9kop44nke3n7t@4ax.com> <4d5fd57d$0$6992$9b4e6d93@newsspool4.arcor-online.net> X-Newsreader: Forte Agent 1.7/32.534 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Usenet-Provider: http://www.giganews.com X-AuthenticatedUsername: NoAuthUser X-Trace: sv3-Y1kc6mogzej1v0mxtl1DgMJnTUSh0tB9fe5SzUG9JXsMCezY7QsswZu+9F6TdyYObZpFZxZFrPAOlo4!PdGUPp71OH9sTox9Uaca/LDVsT8pAMygObkbeQMArBpPMsajddNNbRoVtfVrMuWso9wse3CScm+J!ZNI= X-Complaints-To: abuse@btinternet.com X-DMCA-Complaints-To: abuse@btinternet.com X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 6537 Xref: g2news2.google.com comp.lang.ada:18457 Date: 2011-02-20T14:34:35+00:00 List-Id: On Sat, 19 Feb 2011 18:25:44 +0000, Brian Drummond wrote: >On Sat, 19 Feb 2011 15:36:45 +0100, Georg Bauhaus > wrote: > >>On 2/19/11 2:07 PM, Brian Drummond wrote: >>> On 18 Feb 2011 22:52:38 GMT, "Luis P. Mendes" 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. [using tasking for the binary_trees benchmark, which currently uses a single task...] >>I vaguely remember that it has been tried before, but so far there >>is no better solution. >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. Further odd results. I re-structured the tasking so that I could modify the number of tasks, from 1, 2, 4, etc. The "CPU" utilisation remains virtually identical, at 2 minutes; the elapsed time is 2 minutes with 1 task, or 1 minute with 2 or more (on a 2-core laptop. I'll report on a 4-core later). Moving from GCC4.5.0 (FSF) to Adacore Libre 2010 makes no significant difference. (OpenSuse 11.3, 64-bit, 2-core laptop) Doubling the CPU time with a single task is suspicious, so I tried the following experiment : source code below - main program only. For the rest, and the original version, see http://shootout.alioth.debian.org/u64q/performance.php?test=binarytrees I removed virtually the entire body of the program into a single task. This change alone doubles the "CPU" time. There appears to be a 100% penalty associated simply with running the original program from within a second task. Anyone see what I'm doing wrong? Any pitfalls to using tasking that I may have missed? I suspect storage [de]allocation since that's under stress in this test, and other benchmarks (e.g. Mandelbrot) don't see this penalty. Should the task have its own separate storage pool, to avoid difficulties synchronising with the main pool (even though the main program no longer uses it? ---------------------------------------------------------------- -- BinaryTrees experimental version -- -- Ada 95 (GNAT) -- -- Contributed by Jim Rogers -- Tasking experiment: Brian Drummond ---------------------------------------------------------------- with Treenodes; use Treenodes; with Ada.Text_Io; use Ada.Text_Io; with Ada.Integer_Text_Io; use Ada.Integer_Text_Io; with Ada.Command_Line; use Ada.Command_Line; with Ada.Characters.Latin_1; use Ada.Characters.Latin_1; procedure Binarytrees_tasktest is N : Natural := 1; task the_work is entry Start(Count :in Natural); entry Complete; end the_work; task body the_work is Min_Depth : constant Positive := 4; Stretch_Tree : TreeNode; Long_Lived_Tree : TreeNode; Short_Lived_Tree_1 : TreeNode; Short_Lived_Tree_2 : TreeNode; Max_Depth : Positive; Stretch_Depth : Positive; Check : Integer; Sum : Integer; Depth : Natural; Iterations : Positive; begin accept Start(Count :in Natural) do N := Count; end Start; Max_Depth := Positive'Max(Min_Depth + 2, N); Stretch_Depth := Max_Depth + 1; Stretch_Tree := Bottom_Up_Tree(0, Stretch_Depth); Item_Check(Stretch_Tree, Check); Put("stretch tree of depth "); Put(Item => Stretch_Depth, Width => 1); Put(Ht & " check: "); Put(Item => Check, Width => 1); New_Line; Long_Lived_Tree := Bottom_Up_Tree(0, Max_Depth); Depth := Min_Depth; while Depth <= Max_Depth loop Iterations := 2**(Max_Depth - Depth + Min_Depth); Check := 0; for I in 1..Iterations loop Short_Lived_Tree_1 := Bottom_Up_Tree(Item => I, Depth => Depth); Short_Lived_Tree_2 := Bottom_Up_Tree(Item =>-I, Depth => Depth); Item_Check(Short_Lived_Tree_1, Sum); Check := check + Sum; Item_Check(Short_Lived_Tree_2, Sum); Check := Check + Sum; end loop; Put(Item => Iterations * 2, Width => 0); Put(Ht & " trees of depth "); Put(Item => Depth, Width => 0); Put(Ht & " check: "); Put(Item => Check, Width => 0); New_Line; Depth := Depth + 2; end loop; Put("long lived tree of depth "); Put(Item => Max_Depth, Width => 0); Put(Ht & " check: "); Item_Check(Long_Lived_Tree, Check); Put(Item => Check, Width => 0); New_Line; accept Complete; end the_work; begin if Argument_Count > 0 then N := Positive'Value(Argument(1)); end if; the_work.start(N); the_work.complete; end BinaryTrees_tasktest; ------------------------------------------------------