840 likes | 976 Views
Pixel Bender. A DSL for image processing Bob Archer Chuck Rose Adobe Systems Inc. The problem. Processors are not getting any faster. The problem. Processors are not getting any faster “The free lunch is over” Herb Sutter. The solution – look it up in Knuth.
E N D
Pixel Bender A DSL for image processing Bob Archer Chuck Rose Adobe Systems Inc.
The problem Processors are not getting any faster
The problem Processors are not getting any faster “The free lunch is over” Herb Sutter
The solution – look it up in Knuth “… it looks more or less like the hardware designers have run out of ideas, and that they’re trying to pass the blame for the future demise of Moore’s Law to the software writers by giving us machines that work faster only on a few key benchmarks!” Donald Knuth
The solution Moore’s law
The solution Intel 8-core Xeon processor : 2.3 billion transistors
The solution Parallel processing
The (new) problem How?
The (new) problem POSIX Threads MPI SHMEM PVM TBB Ada Cilk Charm++ UPC Co-array Fortran Titanium HPF Haskell Occam Ease Erlang Linda coordination language Oz CUDA OpenCL Jacket OpenMP Global Arrays Intel Ct Pervasive DataRush ProActive Parallel Random Access Machine Stream processing Structural Object Programming Model Pipelining ZPL Chapel Fortress X10 Dataflow
The (new) solution Restrict the domain – focus on image processing
The (new) solution Restrict the domain – focus on image processing Use an explicitly parallel programming model
The (new) solution Restrict the domain – focus on image processing Use an explicitly parallel programming model Use the GPU
Demo Pixel Bender Toolkit
Pixel Bender Language not that interesting (C based)
Pixel Bender Language not that interesting (C based) Programming model is interesting
Pixel Bender programming model Write a function that produces a single output pixel
Code walkthrough <languageVersion : 1.0;> kernel FadeToBlack < namespace : "AIF test"; vendor : "Adobe"; version : 1; description : "Fade out the image"; > { parameter float fade < minValue : 0.0; maxValue: 1.0; defaultValue : 1.0; >; input image4 src; output pixel4 dst; void evaluatePixel() { dst = sampleNearest(src,outCoord()); dst.rgb *= fade; } }
Code walkthrough kernel FadeToBlack { parameter float fade; input image4 src; output pixel4 dst; void evaluatePixel() { dst = sampleNearest( src, outCoord() ); dst.rgb *= fade; } }
Code walkthrough kernel FadeToBlack { parameter float fade; input image4 src; output pixel4 dst; void evaluatePixel() { dst = sampleNearest( src, outCoord() ); dst.rgb *= fade; } }
Code walkthrough kernel FadeToBlack { parameter float fade; input image4 src; output pixel4 dst; void evaluatePixel() { dst = sampleNearest( src, outCoord() ); dst.rgb *= fade; } }
Code walkthrough kernel FadeToBlack { parameter float fade; input image4 src; output pixel4 dst; void evaluatePixel() { dst = sampleNearest( src, outCoord() ); dst.rgb *= fade; } }
Code walkthrough kernel FadeToBlack { parameter float fade; input image4 src; output pixel4 dst; void evaluatePixel() { dst = sampleNearest( src, outCoord() ); dst.rgb *= fade; } }
Code walkthrough kernel FadeToBlack { parameter float fade; input image4 src; output pixel4 dst; void evaluatePixel() { dst = sampleNearest( src, outCoord() ); dst.rgb *= fade; } }
Code walkthrough kernel FadeToBlack { parameter float fade; input image4 src; output pixel4 dst; void evaluatePixel() { dst = sampleNearest( src, outCoord() ); dst.rgb *= fade; } }
Code walkthrough kernel FadeToBlack { parameter float fade; input image4 src; output pixel4 dst; void evaluatePixel() { dst = sampleNearest( src, outCoord() ); dst.rgb *= fade; } }
Code walkthrough kernel FadeToBlack { parameter float fade; input image4 src; output pixel4 dst; void evaluatePixel() { dst = sampleNearest( src, outCoord() ); dst.rgb *= fade; } }
Code walkthrough kernel FadeToBlack { parameter float fade; input image4 src; output pixel4 dst; void evaluatePixel() { dst = sampleNearest( src, outCoord() ); dst.rgb *= fade; } }
Code walkthrough – polka dot filter kernel PinkPolkaDots { parameter int radius; parameter int offset; input image4 src; output pixel4 dst; void evaluatePixel() { float2 width = float2(float( radius + offset ) * 2.0); float2 center = floor( outCoord() / width ) * width + (width/2.0); float dist = distance(center, outCoord()); pixel4 pink = pixel4(1.0,0.75,0.8,1.0); pixel4 orig = sampleNearest(src, outCoord()); dst = dist < float(radius) ? pink : orig; } }
Code walkthrough – polka dot filter kernel PinkPolkaDots { parameter int radius; parameter int offset; input image4 src; output pixel4 dst; void evaluatePixel() { float2 width = float2(float( radius + offset ) * 2.0); float2 center = floor( outCoord() / width ) * width + (width/2.0); float dist = distance(center, outCoord()); pixel4 pink = pixel4(1.0,0.75,0.8,1.0); pixel4 orig = sampleNearest(src, outCoord()); dst = dist < float(radius) ? pink : orig; } }
Code walkthrough – polka dot filter kernel PinkPolkaDots { parameter int radius; parameter int offset; input image4 src; output pixel4 dst; void evaluatePixel() { float2 width = float2(float( radius + offset ) * 2.0); float2 center = floor( outCoord() / width ) * width + (width/2.0); float dist = distance(center, outCoord()); pixel4 pink = pixel4(1.0,0.75,0.8,1.0); pixel4 orig = sampleNearest(src, outCoord()); dst = dist < float(radius) ? pink : orig; } }
Code walkthrough – polka dot filter kernel PinkPolkaDots { parameter int radius; parameter int offset; input image4 src; output pixel4 dst; void evaluatePixel() { float2 width = float2(float( radius + offset ) * 2.0); float2 center = floor( outCoord() / width ) * width + (width/2.0); float dist = distance(center, outCoord()); pixel4 pink = pixel4(1.0,0.75,0.8,1.0); pixel4 orig = sampleNearest(src, outCoord()); dst = dist < float(radius) ? pink : orig; } }
Code walkthrough – polka dot filter kernel PinkPolkaDots { parameter int radius; parameter int offset; input image4 src; output pixel4 dst; void evaluatePixel() { float2 width = float2(float( radius + offset ) * 2.0); float2 center = floor( outCoord() / width ) * width + (width/2.0); float dist = distance(center, outCoord()); pixel4 pink = pixel4(1.0,0.75,0.8,1.0); pixel4 orig = sampleNearest(src, outCoord()); dst = dist < float(radius) ? pink : orig; } }
Sample filters *(1) Tubeview Petri Leskinen, Jan 2008 (2) Fuzz by Tyler Glaiel (3) Julia Set by Luca Deltodesco (4) Radial Mario Klingemann