From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: igt-dev@lists.freedesktop.org
Subject: Re: [igt-dev] [PATCH i-g-t 3/3] lib: Add roundup_power_of_two()
Date: Mon, 10 Sep 2018 18:55:47 +0300 [thread overview]
Message-ID: <20180910155547.GU5565@intel.com> (raw)
In-Reply-To: <153659413285.4253.13469319217982591605@skylake-alporthouse-com>
On Mon, Sep 10, 2018 at 04:42:12PM +0100, Chris Wilson wrote:
> Quoting Ville Syrjala (2018-09-10 16:34:07)
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > Add a helper to round a value to the next power of two size.
> >
> > And since we need fls() to implement that, reuse that elsewhere
> > as well.
> >
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Looks reasonable. There should be a few more fls around, it tends to be
> useful.
Right. There were some under tools IIRC, implemented in inline asm.
Didn't bother figuring out what they're used for so I just changed
the name in igt_aux.h to igt_fls() to avoid the clash and moved on.
> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
>
> > ---
> > lib/igt_aux.h | 6 ++++++
> > lib/igt_fb.c | 12 ++++--------
> > tests/gem_exec_reuse.c | 12 +-----------
> > 3 files changed, 11 insertions(+), 19 deletions(-)
> >
> > diff --git a/lib/igt_aux.h b/lib/igt_aux.h
> > index ef89faa9bd30..192c3ad88658 100644
> > --- a/lib/igt_aux.h
> > +++ b/lib/igt_aux.h
> > @@ -287,4 +287,10 @@ void igt_lsof(const char *dpath);
> >
> > #define is_power_of_two(x) (((x) & ((x)-1)) == 0)
> >
> > +#define igt_fls(x) ((x) ? __builtin_choose_expr(sizeof(x) == 8, \
> > + 64 - __builtin_clzll(x), \
> > + 32 - __builtin_clz(x)) : 0)
>
> Though I wonder if __builtin_types_compatible_p(typeof(x), long long)
> would be better (then we could have the long long; long; int cascade).
> I've failed every time I tried to use types_compatible, maybe you'll
> have better luck :)
> -Chris
--
Ville Syrjälä
Intel
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2018-09-10 15:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-10 15:34 [igt-dev] [PATCH i-g-t 1/3] lib/igt_fb: Make fb size 64bit Ville Syrjala
2018-09-10 15:34 ` [igt-dev] [PATCH i-g-t 2/3] lib/igt_fb: Don't use blitter for large buffers Ville Syrjala
2018-09-10 15:45 ` Chris Wilson
2018-09-10 15:34 ` [igt-dev] [PATCH i-g-t 3/3] lib: Add roundup_power_of_two() Ville Syrjala
2018-09-10 15:42 ` Chris Wilson
2018-09-10 15:55 ` Ville Syrjälä [this message]
2018-09-10 16:32 ` [igt-dev] [PATCH i-g-t 1/3] lib/igt_fb: Make fb size 64bit Chris Wilson
2018-09-10 17:25 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/3] " Patchwork
2018-09-10 19:56 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
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=20180910155547.GU5565@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=chris@chris-wilson.co.uk \
--cc=igt-dev@lists.freedesktop.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.