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-Thread: 103376,2c498d4a35691643 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newscon06.news.prodigy.com!prodigy.net!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Allocated aligned arrays Date: 27 Nov 2005 15:49:30 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <1132349753.719540.119910@g44g2000cwa.googlegroups.com> <1132756111.751623.309350@g14g2000cwa.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1133124570 25915 192.74.137.71 (27 Nov 2005 20:49:30 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Sun, 27 Nov 2005 20:49:30 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news1.google.com comp.lang.ada:6652 Date: 2005-11-27T15:49:30-05:00 List-Id: "ldb" writes: > Thanks for all the responses. I have looked into user-defined storage > pools, but they appear to have two very large limitations: > > Can they be dynamically sized? Yes. A storage pool can contain anything you like. For example, it could have a discriminant that controls the size of an array of bytes, and you allocate out of that array. Or it could contain a linked list of chunks of memory. The chunks could be allocated from some lower-level pool. You could use mmap to allocate the chunks. You can control their size however you like. You can make a storage pool type that always allocates on page-aligned boundaries, if you like. This is not a problem. > Can I only associate entire types with storage pools.. or can I > associate individual instances of a type with different pools? This is a problem for some applications. You say "for T'Storage_Pool use ..." and _all_ allocators that return type T will use that pool. It would be more flexible to specify the pool on each "new", but Ada does not directly support that. Various workarounds are possible. It's tricky to make them task-safe. But I thought you just wanted to make sure all objects of a certain type are allocated at some aligned boundary. If so, you don't need a different pool for each object. Just make a storage pool that always allocates on the boundary you want, and specify that pool via "for T'Storage_Pool use ...". I'm not sure I understand your requirements -- why wouldn't that work? > In other words, I'd like to be able to allocate the storage-pool size > at run-time, after I know the dimensions of the input. Why do you care about the size of the pool? It seems to me you care about the size (and alignment) of each allocated object, and that info is passed to the Allocate procedure. The pool itself can be programmed to use however much memory is required, up to the available address space. >... I can't really > seem to figure out if this is even possible. And furthermore, I'd only > like certain instances of a particular class to use that storage pool, > not all of them (I don't want every instance of a particular variable > in a large structure to have to use my storage pool). Heh? Only objects allocated with "new" will use the storage pool. Components of a record will not -- they're just part of the record. To align components of a record, you can use a record rep clause, and also make sure the whole record is properly aligned. > Perhaps, then, using subtypes, there is a way around the second issue? > But, again, the entire purpose of requesting aligned arrays is to > improve the speed of the run, so any rigorous conversion function is > essentially a killer, also. - Bob