implementing opencl support in gegl and gimp

45
OpenCL in GEGL and GIMP Victor Oliveira Libre Graphics Meeting 2012

Upload: lgworld

Post on 12-May-2015

2.199 views

Category:

Design


3 download

DESCRIPTION

"In this session I'm going to describe some efforts to bring OpenCL acceleration to the General Graphics Library (GEGL) and the GNU Image Manipulation Program (GIMP). I intend to show the current state of the project, some implementations techniques used and performance comparisons among common GPUs."

TRANSCRIPT

Page 1: Implementing OpenCL support in GEGL and GIMP

OpenCL in GEGL and GIMPVictor Oliveira

Libre Graphics Meeting 2012

Page 2: Implementing OpenCL support in GEGL and GIMP

The goats are finally running!

Page 3: Implementing OpenCL support in GEGL and GIMP

GIMP was designed to process images with 8-bits per channel.• Artifacts• Noise

GEGL is optimized to do it in high-depth formats, like floating-point.

Page 4: Implementing OpenCL support in GEGL and GIMP

Processing images in floating-point is intensive.How can we improve GEGL performance?

Page 5: Implementing OpenCL support in GEGL and GIMP

The solution: making floating-poing processingfaster using GPUs, multi-threading and vectorization!

(All to do with OpenCL)

Page 6: Implementing OpenCL support in GEGL and GIMP

But what is OpenCL?

Page 7: Implementing OpenCL support in GEGL and GIMP

✔ A language for writing functions that execute in OpenCL devices:

• GPUs• Multi-core CPUs

Page 8: Implementing OpenCL support in GEGL and GIMP

✔ An API to control these OpenCL devices

Page 9: Implementing OpenCL support in GEGL and GIMP

✔ A specification

Page 10: Implementing OpenCL support in GEGL and GIMP

✔ A shared library (you can use it in your C/C++ code)

Page 11: Implementing OpenCL support in GEGL and GIMP

for (i=0; i<n_pixels; i++) { out_pixel[0] = (in_pixel[0] - 0.5f) * contrast + brightness + 0.5; out_pixel[1] = (in_pixel[1] - 0.5f) * contrast + brightness + 0.5; out_pixel[2] = (in_pixel[2] - 0.5f) * contrast + brightness + 0.5; out_pixel[3] = in_pixel[3]; /* copy the alpha */ in_pixel += 4; out_pixel += 4; }

__kernel void gegl_brightness_contrast(__global const float4 *in, __global float4 *out, float contrast, float brightness) { int gid = get_global_id(0); float4 in_v = in[gid]; float4 out_v; out_v.xyz = (in_v.xyz - 0.5f) * contrast + brightness + 0.5f; out_v.w = in_v.w; out[gid] = out_v; }

Page 12: Implementing OpenCL support in GEGL and GIMP

Common flow in a OpenCL program:

➡ Write code in the OpenCL language ➡ Detect the device ➡ Build your code ➡ Transfer data to the device ➡ Run your OpenCL program ➡ Transfer data back from device

Page 13: Implementing OpenCL support in GEGL and GIMP

AMD, Intel and Nvidia proprietary implementations.

Mesa open-source implementation is progressing fast.

Page 14: Implementing OpenCL support in GEGL and GIMP

What I have done:

Page 15: Implementing OpenCL support in GEGL and GIMP

✔ Automatic data transference to the OpenCL Device when necessary

Page 16: Implementing OpenCL support in GEGL and GIMP

✔ Conversion between color spaces

Page 17: Implementing OpenCL support in GEGL and GIMP

✔ A simple API for writing OpenCL filters in GEGL

Page 18: Implementing OpenCL support in GEGL and GIMP

✔ Benchmarking

Page 19: Implementing OpenCL support in GEGL and GIMP

✔ Integrating this work in the next release of GIMP (2.8)

Page 20: Implementing OpenCL support in GEGL and GIMP

Sharing data in the OpenCL Device among many operations

Page 21: Implementing OpenCL support in GEGL and GIMP
Page 22: Implementing OpenCL support in GEGL and GIMP
Page 23: Implementing OpenCL support in GEGL and GIMP
Page 24: Implementing OpenCL support in GEGL and GIMP
Page 25: Implementing OpenCL support in GEGL and GIMP

Color conversion in the OpenCL Device

Page 26: Implementing OpenCL support in GEGL and GIMP
Page 27: Implementing OpenCL support in GEGL and GIMP

Point Operations API

Page 28: Implementing OpenCL support in GEGL and GIMP
Page 29: Implementing OpenCL support in GEGL and GIMP

Benchmarks

(GEGL single-threaded x GEGL w/ OpenCL)

Page 30: Implementing OpenCL support in GEGL and GIMP
Page 31: Implementing OpenCL support in GEGL and GIMP

Profiling is hard.

Page 32: Implementing OpenCL support in GEGL and GIMP
Page 33: Implementing OpenCL support in GEGL and GIMP
Page 34: Implementing OpenCL support in GEGL and GIMP
Page 35: Implementing OpenCL support in GEGL and GIMP

✔ OpenCL is a portable and efficient way to write filters in GEGL/GIMP.

Page 36: Implementing OpenCL support in GEGL and GIMP

✔ There is a huge performance boost using GPUs.

Page 37: Implementing OpenCL support in GEGL and GIMP

✔ On CPUs, we gained multi-core support for free.

Page 38: Implementing OpenCL support in GEGL and GIMP

✔ 91 commits - 14,161 lines changed, code in GEGL 0.20, which is required by GIMP 2.8.

Page 39: Implementing OpenCL support in GEGL and GIMP

What is left to be done:

Page 40: Implementing OpenCL support in GEGL and GIMP

✔ Testing by users on different cards/drivers/cpus and feedback

Page 41: Implementing OpenCL support in GEGL and GIMP

✔ Porting more ops to OpenCL

Page 42: Implementing OpenCL support in GEGL and GIMP

✔ Multiple GPUs support

Page 43: Implementing OpenCL support in GEGL and GIMP

✔ OpenGL output node for GEGL

Page 44: Implementing OpenCL support in GEGL and GIMP

✔ The more GIMP uses GEGL, more performance gains

Page 45: Implementing OpenCL support in GEGL and GIMP

Thanks!

Victor Oliveira (victorm)[email protected]