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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,76ec5d55630beb71 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-06-07 14:16:31 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!small1.nntp.aus1.giganews.com!nntp.giganews.com!nntp3.aus1.giganews.com!nntp.clear.net.nz!news.clear.net.nz.POSTED!not-for-mail NNTP-Posting-Date: Sat, 07 Jun 2003 16:16:34 -0500 From: Craig Carey Newsgroups: comp.lang.ada Subject: Re: Ada 200X Date: Sun, 08 Jun 2003 09:16:32 +1200 Message-ID: References: <3EDC0BE6.42300129@somewhere.nil> X-Newsreader: Forte Agent 1.92/32.572 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Organization: Customer of Mercury Telecommunications Ltd Cache-Post-Path: drone5.qsi.net.nz!unknown@tnt1-53.quicksilver.net.nz X-Cache: nntpcache 2.4.0b5 (see http://www.nntpcache.org/) X-Original-NNTP-Posting-Host: drone5-svc-skyt.qsi.net.nz X-Original-Trace: 8 Jun 2003 09:16:26 +1200, drone5-svc-skyt.qsi.net.nz NNTP-Posting-Host: 203.97.37.6 X-Trace: sv3-nHVR2KmFgvDrdgySCClXmo/hLFnK1aR6leC5+3GmCLGZsEC/Gg2TT829evkzxt7/eDZKrAk4YGDiWjU!nvipymn1HIbfCX85RVh6oL828JNRXA2JCvY6mdmoYbtZSmVxsF/k3CdHXZS5xbQaOUqJzRQgHZWZ!PSa01JE= X-Complaints-To: Complaints to abuse@clear.net.nz X-DMCA-Complaints-To: Complaints to abuse@clear.net.nz 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.1 Xref: archiver1.google.com comp.lang.ada:38793 Date: 2003-06-08T09:16:32+12:00 List-Id: On Tue, 3 Jun 2003 12:14:43 +0000 (UTC), Lutz Donnerhacke wrote: >* Preben Randhol wrote: >> Well I wouldn't say Ada is slow. I think C would be just as slow if it >> *had* bounds checking. > >No. C has to do much more checks, because the compiler can not deduce when >the checks are not necessary. GCC seemed faster in my tests where checking was disabled narrowly and it was on by default. The speed difference can be under 12%. But without the disabling of checking, GNAT Ada can easily be 30% slower. In GNAT, checks can be enabled with the '-gnato -gnata' compiler option. Then they can be turned off as desired using "pragma Suppress (...);", ref RM 11-5: http://www.adaic.org/standards/95aarm/html/AA-11-5.html --- Some sample techniques for speeding up some Ada 95 programs: * Suppressing the 'Index_Check' and 'Range_Check' checks can produce speed ups in numerical code. E.g. >20% speed improvement. * Changing the types of variables from "Integer" to, say, "Positive", "Natural", can speed up code if it reduces checking on bounds. * Use of the "renames" statement (to rename variables) is often worthwhile. It seems to me that use of "renames" does not slow down GNAT code. "pragma Suppress" can slow code down. If optimizing is disabled then "pragma Inline" can slow the final code down (but it seems unlikely to slow down optimized GNAT code). * I used the REDLOG Quantifier Eliminator to permit the safe adding of "pragma Suppress()" to a procedure that implemented a "Replace_Slice()" for a strings package. A problem I had was the the string code in the Charles package of Mr Heaney was too fast in comparison, which was resolved by suppressing range checking. pragma Suppress (Index_Check); pragma Suppress (Length_Check); pragma Suppress (Range_Check); pragma Suppress (Access_Check); -- Already fast ... <> declare pragma Suppress (Overflow_Check); Str : Vs_String renames Source.Str.all; begin if Str'Length < New_Len then -- Lengthen the string and alter the pointer, Source.Str goto REDO_RENAME; -- Guarantee correct and rename again end if; * The GNAT low level routines to process strings tend to be much faster than user-side "for" loops subject to pragma Suppress (Index_Check, Range_Check). Note: GNAT's slicing of strings is not perfected; i.e. adding "if .. then .. else" code to convert "S (P .. Q) := T;" and S := T (U .. V);", into "S := T;" can be produce a decent speed up for a String "Assign (L, R) procedure. (Definitely can't use ":=" due to unexplained historic inefficiency encouraged by RM 7.6's spec having the missing Assign () procedure be implemented with Finalize() and Adjust(). * Turning off tag checking if tagged types are used. E.g. if dispatching on procedures is avoided and instead "if" (or "case") statements are used: if X.all'Tag = A_Rec'Tag then -- A & no B fields X.all.Value := not X.all.Value; else declare -- B_Rec case. Make visible the 2 B_Rec fields pragma Suppress (Tag_Check); B : B_Rec renames B_Rec (X.all); -- Both A & B fields begin * Adding "pragma Inline" if optimizing enabled. * Having arrays be on the stack and not on the heap ("... is array (Positive range <>) of ...") can be perhaps >=3% faster. * When multiplying two matrices, "pragma Suppress (Index_Check);" can be added, and the code to check the sizes of the arrays can be explicit. Also "for K in X'Range (2) loop" could be faster than "for K in 1 .. X'Last (2) loop". Craig Carey The latest ARG considerations on reforming Ada 95: http://www.ada-auth.org/ai-files/REST_AIS.ZIP