From: Paul Eggert <eggert@cs.ucla.edu>
To: Adhemerval Zanella <adhemerval.zanella@linaro.org>,
libc-alpha@sourceware.org
Subject: Re: [PATCH 6/7] stdlib: Optimization qsort{_r} swap implementation
Date: Mon, 22 Jan 2018 18:29:00 -0000 [thread overview]
Message-ID: <3404a331-2832-4bf6-703f-25e3d6255d32@cs.ucla.edu> (raw)
In-Reply-To: <514e9f52-a06b-eaed-5cb8-3bd165e1305f@linaro.org>
On 01/22/2018 09:48 AM, Adhemerval Zanella wrote:
> One option I have not
> tested, and which will trade code side for performance; would parametrize
> the qsort creation (as for the 7/7 patch in this set) to have qsort_uint32_t,
> qsort_uint64_t, and qsort_generic for instance (which calls the swap inline).
>
> So we will have something as:
>
> void qsort (void *pbase, size_t total_elems, size_t size)
> {
> if (size == sizeof (uint32_t)
> && check_alignment (base, sizeof (uint32_t)))
> return qsort_uint32_t (pbase, total_elems, size);
> else if (size == sizeof (uint64_t)
> && check_alignment (base, sizeof (uint64_t)))
> return qsort_uint64_t (pbase, total_elems, size);
> return qsort_generic (pbase, total_elems, size);
> }
Yes, that's the option I was thinking of, except I was thinking that the
first test should be "if (size == sizeof (void *) && check_alignment
(base, alignof (void *))) return qsort_voidptr (pbase, total_elems,
size);" because sorting arrays of pointers is the most common. (Also,
check_alignment's argument should use alignof not sizeof.)
next prev parent reply other threads:[~2018-01-22 18:29 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-18 17:53 [PATCH 0/7] Refactor qsort implementation Adhemerval Zanella
2018-01-18 17:53 ` [PATCH 5/7] stdlib: Remove use of mergesort on qsort Adhemerval Zanella
2018-01-18 17:53 ` [PATCH 4/7] stdlib: Add more qsort{_r} coverage Adhemerval Zanella
2018-01-18 17:53 ` [PATCH 2/7] support: Add Mersenne Twister pseudo-random number generator Adhemerval Zanella
2018-01-18 17:53 ` [PATCH 3/7] benchtests: Add bench-qsort Adhemerval Zanella
2018-01-18 17:53 ` [PATCH 7/7] stdlib: Remove undefined behavior from qsort implementation Adhemerval Zanella
2018-01-18 17:53 ` [PATCH 6/7] stdlib: Optimization qsort{_r} swap implementation Adhemerval Zanella
2018-01-22 8:27 ` Paul Eggert
2018-01-22 10:55 ` Adhemerval Zanella
2018-01-22 13:46 ` Alexander Monakov
2018-01-22 15:23 ` Adhemerval Zanella
2018-01-22 17:15 ` Paul Eggert
2018-01-22 17:48 ` Adhemerval Zanella
2018-01-22 18:29 ` Paul Eggert [this message]
2018-01-22 19:33 ` Adhemerval Zanella
2018-01-23 6:04 ` Paul Eggert
2018-01-23 18:28 ` Adhemerval Zanella
2018-01-23 23:37 ` Paul Eggert
2018-01-24 10:47 ` Adhemerval Zanella
2018-01-18 17:53 ` [PATCH 1/7] stdlib: Adjust tst-qsort{2} to libsupport Adhemerval Zanella
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=3404a331-2832-4bf6-703f-25e3d6255d32@cs.ucla.edu \
--to=eggert@cs.ucla.edu \
--cc=adhemerval.zanella@linaro.org \
--cc=libc-alpha@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).