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.0 required=5.0 tests=BAYES_00,DATE_IN_PAST_24_48, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,56525db28240414a X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.224.33.148 with SMTP id h20mr1569319qad.3.1342552153658; Tue, 17 Jul 2012 12:09:13 -0700 (PDT) Received: by 10.68.219.170 with SMTP id pp10mr550726pbc.1.1342552136413; Tue, 17 Jul 2012 12:08:56 -0700 (PDT) Path: a15ni6630447qag.0!nntp.google.com!x2no2983604qaj.0!news-out.google.com!p10ni157991820pbh.1!nntp.google.com!border1.nntp.dca.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!news-out.octanews.net!mauve.octanews.net!news.astraweb.com!border5.newsrouter.astraweb.com!feed.news.qwest.net!mpls-nntp-02.inet.qwest.net!83.149.209.203.MISMATCH!news.mi.ras.ru!goblin1!goblin.stu.neva.ru!fdn.fr!gegeweb.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Efficient Sequential Access to Arrays Date: Sun, 15 Jul 2012 21:48:35 +0200 Organization: cbb software GmbH Message-ID: References: <01983f1c-f842-4b1f-a180-bcef531dad4c@googlegroups.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: 9A8bJrx4NhDLcSmbrb6AdA.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2012-07-15T21:48:35+02:00 List-Id: On Sun, 15 Jul 2012 11:40:08 -0700 (PDT), Keean Schupke wrote: > However in order to achieve this performance I needed to rework the arrays > as the use of Indexes was too slow. You have to measure it in order to know. Write two variants and compare their performance. > An example of this is lets say we are > accessing element 5 from array A "A(5)" this requires a multiplication to > access (base_address + index * record_size). It does not, because 5 is constant. > To access the neighbour A(6) > also requires a multiplication. Accessing the array sequentially requires > a multiplication per step. That depends on loop optimizations. I would expect GCC to optimize access to array elements per the loop's index. > So assuming we need this level of performance, what would be the best (and > most idiomatic Ada) Indexing is unlikely to have a significant (>5%) influence on overall performance. Usually it is other things. > way to package this type of usage pattern as an > abstract datatype? Array of aliased elements, to ensure elements independently addressable. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de