RSS/Atom feed Twitter
Site is read-only, email is disabled

using C99/gcc built-in math intrinsics within GEGL on gfloats

This discussion is connected to the gimp-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

2 of 3 messages available
Toggle history

Please log in to manage your subscriptions.

15444414.51841221236232751.... 07 Oct 20:26
  using C99/gcc built-in math intrinsics within GEGL on gfloats Nicolas Robidoux 12 Sep 18:26
   using C99/gcc built-in math intrinsics within GEGL on gfloats Sven Neumann 12 Sep 18:38
Nicolas Robidoux
2008-09-12 18:26:34 UTC (over 16 years ago)

using C99/gcc built-in math intrinsics within GEGL on gfloats

--------
CONTEXT:
--------

I have completely changed the gegl/buffer/gegl-sampler-yafr.c code.

Before I put together the patch to the new yafr, I would like to see if I could make the code even faster by using C99/gcc built-in math intrinsics. I have not tried this yet.

The method used by the updated code is different from the first generation yafr (at once softer and more pervasive; yes I know this is vague: what I mean is that the nonlinear correction is "on" throughout more of the image, but that its effect is never as extreme).

The code also runs even faster than before: on my current vintage laptop, yafr scales up about 10% slower than gegl-sampler-linear, and about 10% faster than gegl-sampler-cubic.

Regarding further speed-up: Using abs, fmin and copysign I could make my code branch-free (assuming of course that these operations are translated to assembly built-ins by the compiler on the machine on which the code is compiled). That is: the code, which right now contains no "if," no "for," no "do" and no "while," would now contain no ?. I suspect that using arithmetic branching could make my code run noticeably faster.

--------- QUESTION:
---------

I noticed that fabs, fmin and copysign, or similar C99/gcc built-ins, are not found anywhere in the gegl source.

Is there a preferred/tolerated way of using such math functions in gegl?

Can I assume that gfloats are floats?

Can I assume that gdoubles are doubles?

Must I program with the possibility that gfloats be doubles?

Must I program with the possibility that gdoubles be floats?

Could gfloats or gdoubles be anything else than floats or doubles?

Some ideas:

Idea 0:

It may be that I can use the type-generic fabs, fmin and copysign on gfloats without a speed hit. Hopefully, gcc can use the correct one based on the fact that it acts on gfloats. If not, it may be that using the double versions on gfloats is still faster than the alternatives.

Idea 1:

If I KNEW for a fact that gfloat = float, I could simply use fabsf, fminf, and copysignf.

Idea 2:

I could do the necessary parts of the computation with doubles (or gdoubles) and then use the double versions. Hopefully, this will not slow down gegl when run on hardware which is faster on floats than doubles (like some GPUs).

Idea 3:

Is there a smarter way, which picks the right one?

Idea 4:

Change compilation flags to include C99 built-ins?

Idea 5:

You have another idea?

Idea 6:

Or should I just stick to C90 gcc built-ins?

Nicolas Robidoux Laurentian University/Universite Laurentienne

Sven Neumann
2008-09-12 18:38:26 UTC (over 16 years ago)

using C99/gcc built-in math intrinsics within GEGL on gfloats

Hi,

may I ask why you are not using the gegl-developer mailing-list for these questions? They seem to be very GEGL specific and are probably of much interest to the GEGL developers.

I will try to answer some of your questions if you resend your mail to the gegl-developer list.

Sven