From: Tuukka Toivonen <tuukka.toivonen@intel.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>,
"sakari.ailus@linux.intel.com" <sakari.ailus@linux.intel.com>
Cc: "Zhi, Yong" <yong.zhi@intel.com>,
Linux Media Mailing List <linux-media@vger.kernel.org>,
"Zheng, Jian Xu" <jian.xu.zheng@intel.com>,
"tfiga@chromium.org" <tfiga@chromium.org>,
"Mani, Rajmohan" <rajmohan.mani@intel.com>
Subject: Re: [PATCH v2 08/12] intel-ipu3: params: compute and program ccs
Date: Wed, 11 Oct 2017 17:01:24 +0300 [thread overview]
Message-ID: <1507730484.18241.17.camel@intel.com> (raw)
In-Reply-To: <CAHp75VfTZ5GhNCgSbD2_d99Yq-32hDy06ZyRpNJTwo3PFKG=Uw@mail.gmail.com>
On Wed, 2017-10-11 at 16:31 +0300, Andy Shevchenko wrote:
> On Wed, Oct 11, 2017 at 10:29 AM, sakari.ailus@linux.intel.com
> <sakari.ailus@linux.intel.com> wrote:
> > On Wed, Oct 11, 2017 at 04:14:37AM +0000, Zhi, Yong wrote:
> > > > > +static unsigned int ipu3_css_scaler_get_exp(unsigned int
> > > > > counter,
> > > > > + unsigned int
> > > > > divider) {
> > > > > + unsigned int i = 0;
> > > > > +
> > > > > + while (counter <= divider / 2) {
> > > > > + divider /= 2;
> > > > > + i++;
> > > > > + }
> > > > > +
> > > > > + return i;
> > return (!counter || divider < counter) ?
> > 0 : fls(divider / counter) - 1;
>
> Extra division is here (I dunno if counter is always power of 2 but
> it
> doesn't matter for compiler).
>
> Basically above calculates how much bits we need to shift divider to
> get it less than counter.
>
> I would consider to use something from log2.h.
>
> Roughly like
>
> if (!counter || divider < counter)
> return 0;
> return order_base_2(divider) - order_base_2(counter);
The original loop is typical ran just couple of times, so I think
that fls or division are probably slower than the original loop.
Furthermore, these "optimizations" are also harder to read, so in
my opinion there's no advantage in using them.
- Tuukka
next prev parent reply other threads:[~2017-10-11 14:01 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-14 22:19 [PATCH v2 00/12] Intel IPU3 ImgU patchset Yong Zhi
2017-06-14 22:19 ` [PATCH v2 01/12] videodev2.h, v4l2-ioctl: add IPU3 meta buffer format Yong Zhi
2017-06-14 22:19 ` [PATCH v2 02/12] intel-ipu3: mmu: implement driver Yong Zhi
2017-06-14 22:19 ` [PATCH v2 03/12] intel-ipu3: Add DMA API implementation Yong Zhi
2017-06-14 22:19 ` [PATCH v2 04/12] intel-ipu3: Add user space ABI definitions Yong Zhi
2017-06-14 22:19 ` [PATCH v2 06/12] intel-ipu3: css: imgu dma buff pool Yong Zhi
2017-06-14 22:19 ` [PATCH v2 07/12] intel-ipu3: css: firmware management Yong Zhi
2017-07-12 18:33 ` [v2,07/12] " Matthias Kaehlcke
2017-07-12 18:46 ` Zhi, Yong
2017-06-14 22:19 ` [PATCH v2 08/12] intel-ipu3: params: compute and program ccs Yong Zhi
2017-06-16 22:52 ` Andy Shevchenko
2017-10-11 4:14 ` Zhi, Yong
2017-10-11 7:29 ` sakari.ailus
2017-10-11 13:31 ` Andy Shevchenko
2017-10-11 14:01 ` Tuukka Toivonen [this message]
2017-10-11 14:27 ` Andy Shevchenko
2017-10-13 23:08 ` Sakari Ailus
2017-06-14 22:19 ` [PATCH v2 09/12] intel-ipu3: css hardware setup Yong Zhi
2017-06-16 22:54 ` Andy Shevchenko
2017-06-17 18:43 ` Sakari Ailus
2017-06-17 19:06 ` Andy Shevchenko
2017-10-11 2:02 ` Zhi, Yong
2017-06-14 22:19 ` [PATCH v2 10/12] intel-ipu3: css pipeline Yong Zhi
2017-06-14 22:19 ` [PATCH v2 11/12] intel-ipu3: Add imgu v4l2 driver Yong Zhi
2017-06-16 14:50 ` Sakari Ailus
2017-06-14 22:19 ` [PATCH v2 12/12] intel-ipu3: imgu top level pci device Yong Zhi
2017-06-16 22:58 ` Andy Shevchenko
2017-06-17 0:00 ` Zhi, Yong
2017-06-17 6:32 ` Tomasz Figa
2017-06-17 8:37 ` Andy Shevchenko
2017-06-17 18:45 ` Sakari Ailus
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=1507730484.18241.17.camel@intel.com \
--to=tuukka.toivonen@intel.com \
--cc=andy.shevchenko@gmail.com \
--cc=jian.xu.zheng@intel.com \
--cc=linux-media@vger.kernel.org \
--cc=rajmohan.mani@intel.com \
--cc=sakari.ailus@linux.intel.com \
--cc=tfiga@chromium.org \
--cc=yong.zhi@intel.com \
/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 NNTP newsgroup(s).