public inbox for gsl-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Gerard Jungman <jungman@lanl.gov>
To: gsl-discuss@sourceware.org
Subject: Re: switched sparse format to binary trees
Date: Mon, 28 Apr 2014 22:35:00 -0000	[thread overview]
Message-ID: <535ED7A5.7020309@lanl.gov> (raw)
In-Reply-To: <535DAFC0.8090402@colorado.edu>


On 04/27/2014 07:32 PM, Patrick Alken wrote:

> This actually makes a huge speed improvement in duplicate detection and
> element retrieval for large sparse matrices. There may however be a
> performance hit since a new tree node must be allocated each time an
> element is added to the matrix. But I believe the tradeoff is worth it.


For what it's worth, the right thing to do is probably
to expose the avl allocation strategy to the GSL client
in some way. It could be as simple as an extra argument
to gsl_spmatrix_alloc(), which could be a pointer to a
generic allocator strategy struct (similar or identical
to 'struct libavl_allocator'). This is the most general
solution, which requires that clients who care be able
to write their own allocator.

As an aid, GSL could also supply a replacement allocator
strategy object, maybe based on a pool allocator with
a variable amortization size. This would be in addition
to the default (and now implicit by design) malloc/free
strategy.


This opens a generic issue regarding GSL containers,
which is one of the many reasons I avoid them.
That is, the allocation strategy is not exposed. You can
trace the allocations down to the gsl_block level, where
there is a hard-coded malloc(). Very sad.

This could all be fixed by adding gsl container allocation
functions (parallel to the current xxx_alloc functions)
which take an extra argument (something like pointer to
a struct of function pointers) for the allocation
strategy. The extra argument could be passed down
to the gsl_block level where it is invoked.

On the other hand, all this needs to be studied a bit.
My understanding is that modern linux implementations
will use mmap() for large enough allocations. This
will change the tradeoffs. I have no idea what
other platforms do. It's not just your old
malloc anymore...

--
G. Jungman

  reply	other threads:[~2014-04-28 22:35 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-28  1:32 Patrick Alken
2014-04-28 22:35 ` Gerard Jungman [this message]
2014-04-29  1:13   ` Patrick Alken
2014-04-29  8:40     ` Frank Reininghaus
2014-04-29 19:15       ` Gerard Jungman
2014-04-29 19:52         ` Patrick Alken
2014-04-29 22:07           ` Gerard Jungman
2014-05-01 18:46             ` Patrick Alken
2014-05-01 23:21               ` Gerard Jungman
2014-05-02  1:48                 ` GSL containers (switched sparse format to binary trees) Gerard Jungman
2014-05-02  1:56                   ` Gerard Jungman
2014-05-02  8:29                     ` Rhys Ulerich
2014-05-02  8:33                       ` Rhys Ulerich
2014-05-02  8:52                         ` Rhys Ulerich
2014-05-02 15:02                     ` Patrick Alken
2014-05-13 21:59                       ` Gerard Jungman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=535ED7A5.7020309@lanl.gov \
    --to=jungman@lanl.gov \
    --cc=gsl-discuss@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).