comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Efficient Sequential Access to Arrays
Date: Tue, 17 Jul 2012 08:31:11 +0200
Date: 2012-07-17T08:31:11+02:00	[thread overview]
Message-ID: <n5f2c468x3m3.11so2phokj0ze$.dlg@40tude.net> (raw)
In-Reply-To: ca3e1b59-5bcc-4359-a6da-8ef3235502af@googlegroups.com

On Mon, 16 Jul 2012 12:12:48 -0700 (PDT), Keean Schupke wrote:

> On Monday, 16 July 2012 19:48:22 UTC+1, Dmitry A. Kazakov  wrote:
>> On Mon, 16 Jul 2012 09:39:45 -0700 (PDT), Keean Schupke wrote:
>> 
>> &gt; On Monday, 16 July 2012 15:57:04 UTC+1, Dmitry A. Kazakov  wrote:
>> 
>> &gt;&gt; Which itself looks like a problem. It takes no less than 25% of overall
>> &gt;&gt; performance for mere shuffling data in a task unrelated to stuff like
>> &gt;&gt; recoding etc. This looks wrong to me. I would look for a better
>> &gt;&gt; algorithm/structure.
>> &gt; 
>> &gt; I find this comment puzzling and does not match my experience.
>> 
>> It is just an observation that more than 25% of CPU load is spent to heat
>> the atmosphere rather than doing something useful.
>> 
>> &gt; What algorithm for disjoint-set do you suggest I use?
>> 
>> I would try to avoid using such things if the problem is large.
> 
> Perhaps you would like to outline your methodology for algorithm
> development?

I don't develop algorithms I apply them.

25% overhead on indexing is too much.

> How would you go about designing an efficient algorithm to
> solve these kind of problems:
> 
> 嚙瘟 Network connectivity.

1. Open amazon site
2. Search "netwok adapter" 
3. Choose 5 different with minimal price
4. Among them select one with maximal positive customer reports
5. Buy it

(Network connectivity is not an algorithmic problem)

>> No idea what you are trying to do. But indexing *must* be faster than
>> indirection. You should make your data structures straight.
> 
> Straight data structures require copying data. If we were to use an array
> instead of a linked list then every state change would require copying
> stuff.

In Ada you rename array elements. This lets the compiler to choose between
copying and handling it in-place. BTW copying might turn more effective
depending on the architecture.

>> &gt;&gt; If you have performance problems with arrays, which are built-in and
>> &gt;&gt; subject of tailored optimization, you cannot expect situation improved by
>> &gt;&gt; puzzling the compiler with more abstract types. That could only disable
>> &gt;&gt; optimization.
>> &gt; 
>> &gt; Maybe you are thinking of something more complex than I am. An ADT is just
>> &gt; a private type with associated functions in a package.
>> 
>> It is difficult for the compiler to optimize wrappers of array operations
>> like indexing. You said you failed to make GCC to optimize raw array
>> access. Why wrapping that into functions should do any better?
> 
> It doesn't do any worse... the functions are mostly single line and get
> inlined before the optimisation pass.

Did you verify that?

> On the whole many positives, and no negatives (because its just as fast in my tests).

But you said you failed to optimize multiplication away.

>> &gt; Element&#39;s is different from the STL. It includes native &#39;concepts&#39; that
>> &gt; define axiomatic constraints on software modules.
>> 
>> I have no idea what &quot;axiomatic constraints on software modules&quot; could mean.
> 
> See:
> 
> http://akrzemi1.wordpress.com/2012/01/11/concept-axioms-what-for/

Ah, you meant invariants, propositions regarding program semantics
maintained true during code transformations, e.g. for optimization.

In more complex cases user could help the compiler giving some advices. But
for low-level optimizations like ones of indexing this stuff is buried in
the compiler guts.

However, yes, Ada should have interfaces of integer types, interfaces of
index types, interfaces of array types etc, annotated by
pre-/post-conditions and invariants. Unfortunately, presently interfaces
are tied with by-reference types. It is unclear when Ada will provide
interfaces for all types. Otherwise, regarding program correctness stuff
there is SPARK and some in Ada 2012.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2012-07-25  0:18 UTC|newest]

Thread overview: 88+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-15 18:40 Efficient Sequential Access to Arrays Keean Schupke
2012-07-15 19:48 ` Dmitry A. Kazakov
2012-07-15 20:03   ` Keean Schupke
2012-07-15 20:56     ` Keean Schupke
2012-07-16 11:34       ` Jacob Sparre Andersen
2012-07-15 21:05     ` tmoran
2012-07-15 21:08       ` Keean Schupke
2012-07-16  1:19         ` tmoran
2012-07-15 21:44     ` Georg Bauhaus
2012-07-16  7:47     ` Dmitry A. Kazakov
2012-07-16 10:16       ` Keean Schupke
2012-07-16 14:57         ` Dmitry A. Kazakov
2012-07-16 16:39           ` Keean Schupke
2012-07-16 17:02             ` Georg Bauhaus
2012-07-16 18:48             ` Dmitry A. Kazakov
2012-07-16 19:12               ` Keean Schupke
2012-07-17  6:31                 ` Dmitry A. Kazakov [this message]
2012-07-17  6:50                   ` Georg Bauhaus
2012-07-17  8:42                     ` Dmitry A. Kazakov
2012-07-17  7:24                   ` Keean Schupke
2012-07-16 19:43             ` John B. Matthews
2012-07-16 20:44               ` Keean Schupke
2012-07-16 22:23             ` tmoran
2012-07-17  6:40               ` Keean Schupke
2012-07-17  9:01                 ` Dmitry A. Kazakov
2012-07-18  8:10                   ` Keean Schupke
2012-07-18 18:11                     ` tmoran
2012-07-19 10:41                       ` Keean Schupke
2012-07-19 11:18                         ` Georg Bauhaus
2012-07-19 19:58                           ` Keean Schupke
2012-07-21  8:24                             ` Keean Schupke
2012-07-21 11:52                               ` Georg Bauhaus
2012-07-21 16:14                                 ` Keean Schupke
2012-07-21 17:09                                   ` Keean Schupke
     [not found]                                   ` <i78m081tccmp078spmsei1l5vnj3k0kbkj@invalid.netcom.com>
2012-07-22 15:50                                     ` Keean Schupke
2012-07-22  5:13                               ` Shark8
2012-07-15 21:35   ` J-P. Rosen
2012-07-15 19:52 ` Shark8
2012-07-15 20:16   ` Keean Schupke
2012-07-15 21:33     ` Georg Bauhaus
2012-07-17 18:16 ` Florian Weimer
2012-07-22 10:01 ` robin.vowels
2012-07-30  6:31   ` Jacob Sparre Andersen
2012-07-30  7:16     ` Keean Schupke
2012-07-30  9:20     ` Georg Bauhaus
2012-07-30 14:04       ` Keean Schupke
2012-07-22 10:09 ` robin.vowels
2012-07-22 16:02   ` Keean Schupke
2012-07-22 16:21 ` Florian Weimer
2012-07-22 16:46   ` Keean Schupke
2012-07-22 18:41     ` Florian Weimer
2012-07-24  8:21       ` Keean Schupke
2012-07-22 17:34   ` Niklas Holsti
2012-07-22 18:21     ` Keean Schupke
2012-07-30 14:18       ` Jacob Sparre Andersen
2012-07-24 16:00     ` robin.vowels
2012-07-25  7:09       ` Niklas Holsti
2012-07-25  9:03         ` Keean Schupke
2012-07-26  0:15           ` Randy Brukardt
2012-07-26  8:38             ` Keean Schupke
2012-07-26 10:10               ` Brian Drummond
2012-07-26 12:32                 ` Keean Schupke
2012-07-26 13:46                   ` Dmitry A. Kazakov
2012-07-26 17:40                     ` Shark8
2012-07-26 18:56                       ` Dmitry A. Kazakov
2012-07-27  5:25                         ` Shark8
2012-07-27  6:28                           ` Dmitry A. Kazakov
2012-07-27  7:01                             ` Vasiliy Molostov
2012-07-27  8:48                               ` Dmitry A. Kazakov
2012-07-27 12:01                                 ` Georg Bauhaus
2012-07-27 16:49                                 ` Vasiliy Molostov
2012-07-27 19:38                                   ` Dmitry A. Kazakov
2012-07-28  5:32                             ` Shark8
2012-07-28  7:37                               ` Dmitry A. Kazakov
2012-07-28 18:32                                 ` Shark8
     [not found]                     ` <6ov218tnkbqu3vpkuo4t77rd7de0a3aesf@invalid.netcom.com>
2012-07-26 18:49                       ` Dmitry A. Kazakov
     [not found]                         ` <86d31898ne39maimbl24knds7rf38qg7vc@invalid.netcom.com>
2012-07-27  6:45                           ` Dmitry A. Kazakov
2012-07-27  8:21                   ` Keean Schupke
2012-07-27  8:50                     ` Dmitry A. Kazakov
2012-07-27  9:17                       ` Keean Schupke
2013-02-25 21:18                     ` Eryndlia Mavourneen
2012-07-26 13:08               ` Georg Bauhaus
2012-07-26 19:37                 ` stefan-lucks
2012-07-26 19:21               ` stefan-lucks
2012-07-31  3:12               ` Randy Brukardt
2012-07-26  7:11           ` Markus Schöpflin
2012-07-26 14:47         ` Robin Vowels
2012-07-26 15:18           ` Martin
replies disabled

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