[Piglit] refactor and optimize OpenGL test generators

Dylan Baker baker.dylan.c at gmail.com
Wed Nov 12 15:45:42 PST 2014


This rather lengthy series takes a strong stab at cleaning up the python
generators, particularly the OpenGL generators, with the exception of
the generators that rely on the builtin_function.py and
builtin_funciton_fp64.py (I have another series underway to deal with
those, but one thing at a time).

There are 4 goals for each generator in this series:
1) Use mako:
   There on generator (gen_interpolation_tests) that didn't use mako
   before this series. There are also several generators that nominally
   use mako, but don't take advantage of it's features, instead relying
   on python functions and blocks when mako is better equipped to handle
   the problem itself
2) Make it fast:
   Mako is faster than string concatenation, but there are also some
   really stupid things going on in these generators. For example Some
   of them loop over the same very large container several times when
   they could be combined.
3) Make it clean:
   The style of these ranges from pretty good, to pretty bad. There is a
   lot of C-in-python code here, and a lot of use of sub-optimal
   functions, like range instead of xrange, dict.items() instead of
   dict.iteritems(), etc
4) Split the templates:
   This both helps with speed and cleanliness. It makes it clean because
   the templates don't clutter the python scripts, in some cases the
   templates are as long as the script itself. It also means we can use
   a module_directory, which will speed up rebuilds significantly.

Finally, as a bonus, the last patch splits the generators targets for
the generators so that the OpenGL and OpenCL generators aren't linked by
default. This allows OpenGL developers and OpenCL developers to save
time with generated tests they aren't going to run.

Despite all of the work this ends up being a was for LOC, in 45 patches
we gain ~100 lines.

I noticed on my system ~2 second decrease for OpenGL test generation,
and about a ~5 second decrease for OpenGL test regeneration (using
cached templates)

This is available at my github:
https://github.com/dcbaker/piglit submit/generator-cleanups



More information about the Piglit mailing list