Compiler assisted optimization for graphics
Download
1 / 12

compiler-assisted optimization for graphics - PowerPoint PPT Presentation


  • 177 Views
  • Updated On :

Compiler-Assisted Optimization for Graphics. Paul Arthur Navrátil The University of Texas at Austin. Motivation: OpenGL Extensions. Hardware manufacturers create acceleration features for market advantage Not all extensions supported on all hardware

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'compiler-assisted optimization for graphics' - Anita


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Compiler assisted optimization for graphics l.jpg

Compiler-Assisted Optimization for Graphics

Paul Arthur Navrátil

The University of Texas at Austin


Motivation opengl extensions l.jpg
Motivation: OpenGL Extensions

  • Hardware manufacturers create acceleration features for market advantage

  • Not all extensions supported on all hardware

    • 300+ extensions in OpenGL Extension registry

    • ~90 extensions supported by NVIDIA NV3x

    • ~75 extensions supported by ATI RADEON 9x00

  • Programmers won’t become an expert on each implementation of each extension

  • Extension pragmatics are not documented

Navrátil - UT Austin


Current compilers are dumb l.jpg
Current Compilers Are Dumb

  • Current compilers understand only syntax

  • Incorrect use of library abstractions are allowed

float * vtx = func_023(200*func_041(float));

func_174(2, 0x1406, 0, vtx);

func_288(0x8074);

func_075(vtx);

GLfloat *vtx = malloc(200*sizeof(GLfloat));

glVertexPointer(2, GL_FLOAT, 0, vtx);

glEnableClientState(GL_VERTEX_ARRAY);

free(vtx);

GLfloat *vtx = glXAllocateMemoryNV(200*sizeof(GLfloat),0.0,0.0,1.0);

glVertexPointer(2, GL_FLOAT, 0, vtx);

glEnableClientState(GL_VERTEX_ARRAY_RANGE_NV);

glEnableClientState(GL_VERTEX_ARRAY);

glXFreeMemoryNV(vtx);

[Adapted from Sam Guyer]

Navrátil - UT Austin


Solution library annotations l.jpg
Solution: Library Annotations

  • Expert annotates extension definition

    • Makes programmer knowledge explicit

      • Relationships among functions (e.g. malloc and free)

      • Function arguments, e.g.: glBegin(…), glEnable(…)

      • Specializations, e.g.: GL_VERTEX_ARRAY, GL_VERTEX_ARRAY_RANGE_NV

  • Compiler applies expert knowledge to user code

  • Effort amortized across use of library

  • Need a complete system to perform all opts

Navrátil - UT Austin


System broadway guyer lin 2000 2003 guyer 2003 l.jpg
System: Broadway [Guyer, Lin; 2000, 2003] [Guyer 2003]

  • Library meta-interface to describe:

    • Domain-specific analysis

    • Domain-specific transformations

  • Client-driven: adaptive analysis strength

    • [ Flow | Context ] [ Insensitive | Sensitive ]

    • Provides powerful analysis at cheap cost

  • Pointer analysis important too

    • Need accurate picture of memory

Navrátil - UT Austin


Example vertex arrays l.jpg
Example: Vertex Arrays

%{

// Mesa GL types

#include "pnav_enum.h"

#include <malloc.h>

/* these OpenGL functions use vertex and color arrays */

void glVertexPointer( int size, int type, int stride, int ptr );

void glColorPointer( int size, int type, int stride, int ptr );

void glTexCoordPointer( int size, int type, int stride, int ptr );

/* this is called to enable the use of the arrays */

/* vals are GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY */

void glEnableClientState( int type );

}%

property MemoryType : { Normal, Vector, Color, Texture }

initially Normal

Navrátil - UT Austin


Example vertex arrays7 l.jpg
Example: Vertex Arrays

procedure glVertexPointer( size, type, stride, ptr )

{

on_entry { ptr --> memory_chunk }

analyze MemoryType { memory_chunk <- Vector }

when (1==1) replace with %{ {

glVertexArrayRangeNV( ${size}, ${ptr} );

glVertexPointer( ${size}, ${type}, ${stride}, ${ptr} );

} }%

}

procedure glEnableClientState( type )

{

when (type == GL_VERTEX_ARRAY) replace-with %{ {

glEnableClientState(GL_VERTEX_ARRAY_RANGE_NV);

glEnableClientState(GL_VERTEX_ARRAY);

} }%

}

Navrátil - UT Austin


Example vertex arrays8 l.jpg
Example: Vertex Arrays

procedure malloc( size )

{

on_exit { return --> new memory_chunk }

modify { memory_chunk }

when (MemoryType : memory_chunk is-exactly Vector ||

replace-with %{ glAllocateMemoryNV(${size}, 0.0, 0.0, 0.75); }%

}

procedure free( ptr )

{

on_entry { ptr --> memory_chunk }

modify { memory_chunk }

when (MemoryType : memory_chunk is-exactly Vector)

replace-with %{ glXFreeMemoryNV( ${ptr} ); }%

}

Navrátil - UT Austin


Initial results gfxbench l.jpg
Initial Results: gfxbench

  • Adaptation of class project code [Ian Buck]

    • Originally designed to test rasterization pattern

    • Triangle strip: 100 triangles, 202 vertices

    • Strip rotated 360º in 5º increments

    • Strip repeatedly rendered for one second of clock time per orientation (~ 3 sec)

Navrátil - UT Austin


Initial results gfxbench10 l.jpg
Initial Results: gfxbench

Navrátil - UT Austin


Issues gfxbench and beyond l.jpg
Issues: gfxbench and beyond

  • Is the extension used correctly?

    • Are vertices getting flushed prematurely?

    • Is the vertex declaration in the right place to capitalize on the benefits of the extension?

  • GLUT windowing callback structure

    • Broadway’s analysis cannot reach into function specified by glutDisplayFunc()

    • Annotation of glutMainLoop() may fix this

  • Do we even need Broadway?

    • Implemented gfxbench optimization in perl

    • More complex programs will need pointer analysis

  • How many others can be inserted automatically?

Navrátil - UT Austin


Future work l.jpg
Future Work

  • More complex models

    • Tessellated spheres – 13k, 130k triangles

    • Texture mapped surfaces

    • Suggest opportunities to use subjective extensions

  • Expand to errors

    • OpenGL

      • Matching glBegin(), glEnd() pairs

      • Invalid command between glBegin(), glEnd()

    • Windowing libraries (GLUT, X, MFC)

      • No glutPostRedisplay() call in function marked with glutReshapeFunc()

      • glutKeyboardFunc() vs. glutSpecialFunc()

Navrátil - UT Austin


ad