implementing opencl support in gegl and gimp

Post on 12-May-2015

2.201 Views

Category:

Design

3 Downloads

Preview:

Click to see full reader

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

OpenCL in GEGL and GIMPVictor Oliveira

Libre Graphics Meeting 2012

The goats are finally running!

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.

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

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

(All to do with OpenCL)

But what is OpenCL?

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

• GPUs• Multi-core CPUs

✔ An API to control these OpenCL devices

✔ A specification

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

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; }

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

AMD, Intel and Nvidia proprietary implementations.

Mesa open-source implementation is progressing fast.

What I have done:

✔ Automatic data transference to the OpenCL Device when necessary

✔ Conversion between color spaces

✔ A simple API for writing OpenCL filters in GEGL

✔ Benchmarking

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

Sharing data in the OpenCL Device among many operations

Color conversion in the OpenCL Device

Point Operations API

Benchmarks

(GEGL single-threaded x GEGL w/ OpenCL)

Profiling is hard.

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

✔ There is a huge performance boost using GPUs.

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

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

What is left to be done:

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

✔ Porting more ops to OpenCL

✔ Multiple GPUs support

✔ OpenGL output node for GEGL

✔ The more GIMP uses GEGL, more performance gains

Thanks!

Victor Oliveira (victorm)victormatheus@gmail.com

top related