[Mesa-dev] [PATCH] glsl: Optimize certain if-statements to just casts from the condition
Kenneth Graunke
kenneth at whitecape.org
Thu Jan 15 20:39:10 PST 2015
On Friday, January 16, 2015 04:54:44 PM Ian Romanick wrote:
> On 01/16/2015 04:25 PM, Matt Turner wrote:
> > On Thu, Jan 15, 2015 at 6:46 PM, Ian Romanick <idr at freedesktop.org> wrote:
> >> On 01/16/2015 08:15 AM, Matt Turner wrote:
> >>> From: Ian Romanick <ian.d.romanick at intel.com>
> >>>
> >>> Some shaders end up with code that looks something like:
> >>>
> >>> if (some_condition)
> >>> result = 1.0;
> >>> else
> >>> result = 0.0;
> >>>
> >>> This pass converts those if-statements to
> >>>
> >>> result = float(some_condition);
> >>>
> >>> total instructions in shared programs: 5934568 -> 5921818 (-0.21%)
> >>> instructions in affected programs: 723433 -> 710683 (-1.76%)
> >>> GAINED: 26
> >>> LOST: 7
> >>
> >> I was getting really different results here... on my more recent version
> >> (that should produce the same IR), I was getting basically the reverse
> >> lost / gained. The other results were about the same.
> >>
> >> I updated both Mesa and shader-db, and I'm not able to do a full
> >> shader-db run now. At semi-arbitrary points in the run I get
> >>
> >> Exception: Only shader 0 found.
> >> shaders/closed/unreal4/sun-temple/180.shader_test
> >
> > You need commit f0aec4ee1e3 to avoid an assertion failure.
> >
> >> If I run that shader_test by hand, I get multiple shader emitted. I'm
> >> using the older run.py... is it possible that's broken?
> >
> > It's been working for me in occasional usage to generate *.out files.
>
> Trivial. :p
>
> diff --git a/run.py b/run.py
> index 4fc366e..d57da21 100755
> --- a/run.py
> +++ b/run.py
> @@ -57,7 +57,7 @@ def run_test(filename):
> raise Exception('Only shader 0 found. {}'.format(filename))
>
> re_search = re.compile(
> - r'(?P<stage>[A-Za-z0-9]+) shader\: (?P<count>\d+) instructions.')
> + r'(?P<stage>[A-Za-z0-9 ]+) shader\: (?P<count>\d+) instructions.')
> for line in lines:
> match = re_search.match(line)
> if match is not None:
FYI, I broke report.py support with run.py the other day. You want to use
Matt's new C-based multithreaded runner, which takes literally 1/3 of the
time of the old Python script.
$ make
$ ./run shaders | tee results/foobarquux
or for even faster runs:
$ LD_PRELOAD=/usr/lib64/libjemalloc.so.1 INTEL_NO_HW=1 ./run shaders
--Ken
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150115/d70ad6be/attachment.sig>
More information about the mesa-dev
mailing list