public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Chung-Lin Tang <cltang@codesourcery.com>
Cc: Andrew Stubbs <ams@codesourcery.com>,
	gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH, v2, OpenMP 5.0, libgomp] Structure element mapping for OpenMP 5.0
Date: Tue, 19 Jan 2021 10:22:27 +0100	[thread overview]
Message-ID: <20210119092227.GC1034503@tucnak> (raw)
In-Reply-To: <d277213b-cc8e-4193-d4ec-8df2264a549b@codesourcery.com>

On Tue, Jan 19, 2021 at 04:46:36PM +0800, Chung-Lin Tang wrote:
> > > +       into the (above) structelem_refcount field of the _FIRST splay_tree_key,
> > > +       the first key in the created sequence. All structure element siblings
> > > +       share a single refcount in this manner. Since these two fields won't be
> > > +       used at the same time, they are stashed in a union.  */
> > > +    uintptr_t *structelem_refcount_ptr;
> > > +  };
> > >     struct splay_tree_aux *aux;
> > >   };
> > >   /* The comparison function.  */
> > 
> > Anyway, most of the patch looks good, but I'd like to understand the
> > rationale for choosing a htab over what I've been trying to suggest, which
> > was essentially instead of incrementing or decrementing refcounts push them
> > into a vector for later incrementing/decrementing, then qsort the vector
> > (by the pointers to refcounts) and increment what the elements point to unless
> > the same address has been incremented/decremented already.
> > 
> > 	Jakub
> 
> Essentially the requirement is to increment/decrement a refcount only once per construct,
> so using a pointer-set (implemented by htab_t here) to track the processing status
> seemed to be more intuitive in code, and probably faster than sorting a vector I think
> (at least in most cases).

I agree about the more intuitive, but think it will be actually slower, and
performance is what we care about most here, the mapping is already too
slow.
The common case is only a few mappings and no repeated mappings (e.g. the
compiler ought to help there and just remove mappings that are provably
duplicate if possible).  E.g. with one mapping, no qsort is needed at all,
and generally should be O(n log n).  The hash set needs larger memory
allocation than the vector and needs it cleared, plus it is a hash table
without chains, so there is some cost on collisions and if ever the hash
table needs to be expanded.  But I'll be happy to be proven wrong.

	Jakub


  reply	other threads:[~2021-01-19  9:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-04 14:15 Chung-Lin Tang
2020-12-14 10:32 ` Chung-Lin Tang
2021-01-13 15:25   ` Chung-Lin Tang
2021-01-16  9:45 ` Jakub Jelinek
2021-01-19  8:46   ` Chung-Lin Tang
2021-01-19  9:22     ` Jakub Jelinek [this message]
2023-03-24 15:36 ` [og12] In 'libgomp/target.c:gomp_unmap_vars_internal', defer 'gomp_remove_var' (was: [PATCH, v2, OpenMP 5.0, libgomp] Structure element mapping for OpenMP 5.0) Thomas Schwinge

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=20210119092227.GC1034503@tucnak \
    --to=jakub@redhat.com \
    --cc=ams@codesourcery.com \
    --cc=cltang@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.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).