static stages for heterogeneous programming
play

Static Stages for Heterogeneous Programming Adrian Sampson, Cornell - PowerPoint PPT Presentation

Static Stages for Heterogeneous Programming Adrian Sampson, Cornell Kathryn S McKinley, Google Todd Mytkowicz, Microsoft Research Apple A9 techinsights.com GPUs DSP ISP audio codecs video codecs modems CPUs Apple A9


  1. Static Stages 
 for Heterogeneous Programming Adrian Sampson, Cornell Kathryn S McKinley, Google Todd Mytkowicz, Microsoft Research

  2. – Apple A9 techinsights.com

  3. – GPUs DSP ISP audio codecs video codecs modems CPUs Apple A9 techinsights.com

  4. Datacenter Servers Mobile SoCs GPUs DSP ISP audio codecs Microsoft Catapult video codecs modems CPUs Google TPU

  5. program accelerator A C++ program CPU program program accelerator C accelerator B

  6. accelerator A code CPU code accelerator C code accelerator B code unified program

  7. Heterogeneous programming languages 
 need support for placement and specialization . With extensions, multi-stage programming 
 !<[]> can support both concepts. Current APIs for real-time graphics are especially 
 unsafe, verbose, and brittle. We can help.

  8. Heterogeneous programming languages 
 need support for placement and specialization . With extensions, multi-stage programming 
 !<[]> can support both concepts. Current APIs for real-time graphics are especially 
 unsafe, verbose, and brittle. We can help.

  9. Display Commands Pixels CPU GPU

  10. GPU Display CPU Rendering Pipeline programmable & fixed-function stages

  11. C, C++, JavaScript GLSL GLSL Vertex Fragment CPU Shader Shader vertex positions pixel colors

  12. Vertex Shader Fragment Shader in vec4 position; in float dist; in vec4 fragPos; out vec4 fragPos; void main() { void main() { gl_FragColor = fragPos = position; abs (fragPos); gl_Position = } position + dist; }

  13. 
 
 CPU “Host Code” static const char *vertex_shader = 
 "in vec4 position; ..."; 
 static const char *fragment_shader = 
 "in vec4 fragPos; ..."; setup GLuint program = compileAndLink(vertex_shader, 
 fragment_shader); 
 // ... more boilerplate ... "dits" GLuint loc_dist = 
 glGetUniformLocation(program, "dist"); render a frame glUseProgram(program); glUniform1f(loc_dist, 4.0); 
 // ... assign other "in" parameters ... glDrawArrays(...);

  14. GPU shader specialization Übershader #define #ifdef #ifndef #endif #endif #if

  15. Heterogeneous programming today Separate programs in separate languages Stringly typed communication Unscalable, unsafe specialization

  16. Heterogeneous programming languages 
 need support for placement and specialization . With extensions, multi-stage programming 
 !<[]> can support both concepts. Current APIs for real-time graphics are especially 
 unsafe, verbose, and brittle. We can help.

  17. Classic multi-stage programming: 
 types for metaprogramming function pow(x, n) { if (n == 1) { return x; } else { return x * pow(x, n - 1); } } pow(2, 3) 8 genpow("2", 3) "2 * 2 * 2" eval(genpow("2", 3)) 8

  18. Classic multi-stage programming: 
 types for metaprogramming number expression (string) function genpow(x, n) { if (n == 1) { return x; } else { return x * pow(x, n - 1); } } genpow("2", 3) "2 * 2 * 2"

  19. Classic multi-stage programming: 
 types for metaprogramming number expression (string) function genpow(x, n) { if (n == 1) { return x; } else { return x + " * " + pow(x, n - 1); } } genpow("2", 3) "2 * 2 * 2"

  20. Specializing on a 
 compile-time parameter render-time parameter gl_FragColor = if matte diffuse (diffuse + ...) condition on the GPU host-side parameter gl_FragColor = [ if matte <diffuse> <diffuse + ...> ] condition on the host

  21. Performance impact 
 of specialization in BraidGL 14 12 frame latency (ms) 10 8 6 4 2 0 original GPU if specialized per-vertex

  22. Performance impact 
 of specialization in BraidGL 14 16 20 18 14 12 16 12 frame latency (ms) 10 14 10 12 8 8 10 6 8 6 6 4 4 4 2 2 2 0 0 0 original if static if vertex orig no bump orig s1 s2 s3 s4 phong head couch

  23. Heterogeneous programming languages 
 need support for placement and specialization . With extensions, multi-stage programming 
 !<[]> can support both concepts. Current APIs for real-time graphics are especially 
 unsafe, verbose, and brittle. We can help.

  24. braidgl.com

Recommend


More recommend