comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: asynchronous task communication
Date: Wed, 2 Jan 2013 21:35:34 +0100
Date: 2013-01-02T21:35:34+01:00	[thread overview]
Message-ID: <z3r2nhneqyjc.1jwsybu7b5118$.dlg@40tude.net> (raw)
In-Reply-To: 6bqdndEYjoxeGHnNnZ2dnUVZ_sadnZ2d@earthlink.com

On Wed, 02 Jan 2013 11:02:54 -0800, Charles Hixson wrote:

> On 01/02/2013 01:55 AM, Dmitry A. Kazakov wrote:
>> On Tue, 01 Jan 2013 23:36:13 -0800, Charles Hixson wrote:
>>
>>> On 01/01/2013 10:54 AM, Robert A Duff wrote:
>>>> Charles Hixson<charleshixsn@earthlink.net>   writes:
>>>>
>>>>> ...I really preferred a language with a garbage collector,
>>>>
>>>> I have used the Boehm garbage collector successfully with Ada.
>>>>
>>>> You could also consider use-defined storage pools.
>>>> I don't know enough detail of what you're doing to know
>>>> if they would help.
>>>>
>>> I don't think storage pools would help, though I admit I don't
>>> understand them.
>>
>> Storage pools allow implementation of arenas and stacks which are extremely
>> useful when dealing with graphs. I don't know how many nodes you have, but
>> in my system a decision tree might have hundreds of thousands of nodes.
>> Merely finalization of such a structure would take a lot of time if nodes
>> are allocated in the standard memory pool.
>>
>>> Actually, for the current project the need for garbage collection is
>>> minimal...but I often do things where garbage collection really
>>> simplifies memory management.
>>
>> Not really. And for graphs seems just the opposite.
>>
>> Though you would need to carefully design for which graph edges the
>> references will be strong and which ones weak.
>>
>>> Even on this one I'm going to need to
>>> figure out how to recycle memory with Ada.Collections.Vectors attached,
>>> as different cells will connect to differing numbers of other cells.
>>
>> Variable structures like Ada.Containers usually allocate memory in advance
>> to speed up incremental insertions. For NN I would consider a custom
>> fixed-size structure.
>>
>> You might also consider refactoring subgraphs. Structures like that tend to
>> combinatorial explosion when the same graph pattern keeps on repeating
>> itself. Memory use and training/classification times could be reduced when
>> repeating subgraphs are shared rather than replicated. This is another
>> argument to consider a custom implementation.
>>
> A constant size container is not reasonable...though it would certainly 
> make things simpler if it was.

You make node a discriminated record type. Usually when a node is created
it is already known how many children and/or parents it will have. E.g.

   type Node;
   type Node_Ptr is access Node;
   for Node_Ptr'Storage_Pool use Arena;
   type Node_Ptr_Array is array (Positive range <>) of Node_Ptr;
   type Node (Children_Number : Positive) is record
       Successors : Node_Ptr_Array (1..Children_Number);
   end record;

> But I really can't see how storage pools 
> would help, as cells would not be freed in any predictable pattern, and 
> not en-mass.

You allocate all graph or a layer of in the storage pool. Nodes are usually
allocated in the LIFO order which makes allocation much more efficient then
allocation in a standard pool. Deallocation is usually all-at-once, e.g.
you drop the pool and that is.
 
> P.S.:  Is there any way to generate documentation for Ada, better than 
> robodoc?

By hands. I write docs manually. It is tedious, I admit. Consider it as an
extra code review step, helps finding inconsistencies and gaps which
otherwise slip through.

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



  reply	other threads:[~2013-01-02 20:35 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-31  0:16 asynchronous task communication Charles Hixson
2012-12-31  9:04 ` Simon Wright
2012-12-31 11:49   ` Simon Wright
2012-12-31 10:50 ` J-P. Rosen
2012-12-31 12:09 ` Georg Bauhaus
2012-12-31 18:52   ` Charles Hixson
2012-12-31 20:18     ` Shark8
2012-12-31 21:09     ` Niklas Holsti
2012-12-31 22:15       ` Randy Brukardt
2013-01-01  3:58         ` Charles Hixson
2013-01-01  4:48           ` tmoran
2013-01-01 17:59             ` Charles Hixson
2013-01-01  3:51       ` Charles Hixson
2013-01-01  9:59         ` Dmitry A. Kazakov
2013-01-01 10:38         ` Brian Drummond
2013-01-01 12:32         ` Jeffrey Carter
2013-01-01 18:21           ` Charles Hixson
2013-01-01 18:54             ` Robert A Duff
2013-01-02  7:36               ` Charles Hixson
2013-01-02  9:55                 ` Dmitry A. Kazakov
2013-01-02 19:02                   ` Charles Hixson
2013-01-02 20:35                     ` Dmitry A. Kazakov [this message]
2013-01-03  0:20                       ` Charles Hixson
2013-01-03  6:34                         ` Charles Hixson
2013-01-03  8:50                         ` Dmitry A. Kazakov
2013-01-03 19:01                           ` Charles Hixson
2013-01-03 10:01                         ` J-P. Rosen
2013-01-03 19:29                           ` Charles Hixson
2013-01-04  8:17                             ` J-P. Rosen
2013-01-05  4:31                               ` Charles Hixson
2013-01-09  8:34                                 ` Stephen Leake
2013-01-03 22:27                         ` Randy Brukardt
2013-01-05  5:18                           ` Charles Hixson
2013-01-05  8:48                             ` Niklas Holsti
2013-01-06 22:55                               ` Charles Hixson
2013-01-07  0:38                                 ` tmoran
2013-01-07  6:07                                 ` Shark8
2013-01-07 10:49                                 ` Brian Drummond
2013-01-07 18:27                                   ` Jeffrey Carter
2013-01-08 12:02                                     ` Brian Drummond
2013-01-08 17:12                                       ` Jeffrey Carter
2013-01-08 18:18                                         ` Simon Wright
2013-01-08 20:29                                           ` Dmitry A. Kazakov
2013-01-08 21:01                                           ` Jeffrey Carter
2013-01-08 21:14                                             ` Simon Wright
2013-01-08 22:11                                               ` Randy Brukardt
2013-01-08 22:52                                               ` Jeffrey Carter
2013-01-08 22:26                                         ` Brian Drummond
2013-01-08  2:41                             ` Randy Brukardt
2013-01-02 22:43         ` Niklas Holsti
2013-01-03  1:30           ` Charles Hixson
2013-01-03 12:11             ` Georg Bauhaus
2013-01-03 13:17               ` Dmitry A. Kazakov
2013-01-05 20:19               ` Charles Hixson
2013-01-07  4:01                 ` Shark8
2013-01-01 19:59     ` J-P. Rosen
replies disabled

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