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

static stages for heterogeneous programming
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Static Stages
 for Heterogeneous Programming

Adrian Sampson, Cornell Kathryn S McKinley, Google Todd Mytkowicz, Microsoft Research

slide-2
SLIDE 2

Apple A9 techinsights.com

slide-3
SLIDE 3

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

slide-4
SLIDE 4

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

slide-5
SLIDE 5

accelerator A accelerator C accelerator B CPU C++ program program program program

slide-6
SLIDE 6

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

slide-7
SLIDE 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.

!<[]>

slide-8
SLIDE 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.

!<[]>

slide-9
SLIDE 9

CPU GPU Commands Pixels Display

slide-10
SLIDE 10

CPU Rendering Pipeline programmable & fixed-function stages GPU Display

slide-11
SLIDE 11

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

slide-12
SLIDE 12

Fragment Shader

in vec4 fragPos; void main() { gl_FragColor = abs(fragPos); }

Vertex Shader

in vec4 position; in float dist;

  • ut vec4 fragPos;

void main() { fragPos = position; gl_Position = position + dist; }

slide-13
SLIDE 13

static const char *vertex_shader =
 "in vec4 position; ...";
 static const char *fragment_shader =
 "in vec4 fragPos; ..."; 
 GLuint program = compileAndLink(vertex_shader,
 fragment_shader);
 // ... more boilerplate ... 
 GLuint loc_dist =
 glGetUniformLocation(program, "dist");

CPU “Host Code”

glUseProgram(program); glUniform1f(loc_dist, 4.0);
 // ... assign other "in" parameters ... glDrawArrays(...);

setup render a frame

"dits"

slide-14
SLIDE 14
slide-15
SLIDE 15

Übershader

#ifdef #endif #define #if #endif #ifndef

GPU shader specialization

slide-16
SLIDE 16

Heterogeneous programming today

Separate programs in separate languages Stringly typed communication Unscalable, unsafe specialization

slide-17
SLIDE 17
slide-18
SLIDE 18

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.

!<[]>

slide-19
SLIDE 19

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

slide-20
SLIDE 20

function genpow(x, n) { if (n == 1) { return x; } else { return x * pow(x, n - 1); } } genpow("2", 3) "2 * 2 * 2"

number expression (string)

Classic multi-stage programming:
 types for metaprogramming

slide-21
SLIDE 21

function genpow(x, n) { if (n == 1) { return x; } else { return x + " * " + pow(x, n - 1); } } genpow("2", 3) "2 * 2 * 2"

number

Classic multi-stage programming:
 types for metaprogramming

expression (string)

slide-22
SLIDE 22
slide-23
SLIDE 23

Specializing on a
 compile-time parameter

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

slide-24
SLIDE 24

Performance impact


  • f specialization in BraidGL

frame latency (ms)

2 4 6 8 10 12 14

  • riginal

GPU if specialized per-vertex

slide-25
SLIDE 25

frame latency (ms)

2 4 6 8 10 12 14

  • riginal

if static if vertex 2 4 6 8 10 12 14 16

  • rig

no bump 2 4 6 8 10 12 14 16 18 20

  • rig

s1 s2 s3 s4

phong head couch

Performance impact


  • f specialization in BraidGL
slide-26
SLIDE 26

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.

!<[]>

slide-27
SLIDE 27

braidgl.com