OpenCL support
This discussion is connected to the gegl-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.
This is a read-only list on gimpusers.com so this discussion thread is read-only, too.
OpenCL support | Adel Johar | 13 Oct 17:14 |
OpenCL support | Victor Oliveira | 19 Oct 23:05 |
OpenCL support | Adel Johar | 20 Oct 13:36 |
OpenCL support
Hi Victor,
I’m currently trying to help Vincent out with the development of the tutorial, though I’ve hit a bit of a snag. Based on what I’ve seen from an old blog post of yours (and from code snippets from the current source codes), I understand that an iterator is used to iterate through the GEGL buffer to extract tiles and to run the OpenCL kernel on each tile. Do correct me if I’m wrong, but at this point it seems that an OpenCL kernel is called to operate on one tile at a time as the iterator moves the buffer from one tile to another.
As part of the tutorial, rather than integrating the kernels directly into the GEGL library, I believe it would be more beneficial if those who partake in the tutorial to write their own host code as well. I was hoping to inquire on a more detailed explanation on how the image data can be extracted from the GEGL Buffer as a whole rather than as tiles through an iterator; whereby participants can then look at improving the tiling process and see how such improvements can be integrated into the GEGL library. While it would certainly be easier to integrate the kernels directly into the GEGL library, as a starting step it would be good if the users of the tutorial can learn both the kernel and host side of OpenCL.
Thank you,
And Best Regards,
Adel
OpenCL support
Hi Adel,
GEGL is a tiled engine and there's reasons for that, such as being able to manipulate large images that would use too much memory otherwise. Because of that, tiles are not contiguous in memory so there's no way of accessing this data without an extra copy.
For that, you would use:
- gegl_buffer_get (http://www.gegl.org/api.html#gegl_buffer_get) to copy
the geglbuffer image data to a contiguous memory chunk of yours
- do your processing
- gegl_buffer_set to update the buffer with the new data
Because that is an expensive copying operation we prefer that filters use the iterator unless global access to the image data is required in the filter.
If you give a look at motion-blur-zoom.c, it does something like that (though it doesn't use CL).
Hope that clears it up, let me know if you have any more questions. Victor
On Tue, Oct 13, 2015 at 10:14 AM, Adel Johar wrote:
Hi Victor,
I’m currently trying to help Vincent out with the development of the tutorial, though I’ve hit a bit of a snag. Based on what I’ve seen from an old blog post of yours (and from code snippets from the current source codes), I understand that an iterator is used to iterate through the GEGL buffer to extract tiles and to run the OpenCL kernel on each tile. Do correct me if I’m wrong, but at this point it seems that an OpenCL kernel is called to operate on one tile at a time as the iterator moves the buffer from one tile to another.
As part of the tutorial, rather than integrating the kernels directly into the GEGL library, I believe it would be more beneficial if those who partake in the tutorial to write their own host code as well. I was hoping to inquire on a more detailed explanation on how the image data can be extracted from the GEGL Buffer as a whole rather than as tiles through an iterator; whereby participants can then look at improving the tiling process and see how such improvements can be integrated into the GEGL library. While it would certainly be easier to integrate the kernels directly into the GEGL library, as a starting step it would be good if the users of the tutorial can learn both the kernel and host side of OpenCL.
Thank you,
And Best Regards,
Adel
OpenCL support
Hi Victor,
Thank you for clarifying, I was on the right track but didn't have a good example to compare against when using the gegl_buffer_get and gegl_buffer_set functions. I now have the desired results I need.
As for the tiling, I understand the reasoning behind the need for such an architecture, but for the purposes of this tutorial it would be better to have the participants work on a whole contiguous chunk first, and let them understand the need for tiling as they advance and how they could perhaps optimize the tiling operations in GEGL for OpenCL. Once the tutorial is underway, and we have a better understanding of the operations, we can certainly discuss on such improvements for the OpenCL side.
Thank you,
And Best Regards,
Adel
From: victormatheus@gmail.com
Date: Mon, 19 Oct 2015 16:05:49 -0700
Subject: Re: [Gegl-developer] OpenCL support
To: adeljo@hotmail.com
CC: gegl-developer-list@gnome.org
Hi Adel,
GEGL is a tiled engine and there's reasons for that, such as being able to manipulate large images that would use too much memory otherwise. Because of that, tiles are not contiguous in memory so there's no way of accessing this data without an extra copy.
For that, you would use:
- gegl_buffer_get (http://www.gegl.org/api.html#gegl_buffer_get) to copy the geglbuffer image data to a contiguous memory chunk of yours- do your processing- gegl_buffer_set to update the buffer with the new data
Because that is an expensive copying operation we prefer that filters use the iterator unless global access to the image data is required in the filter.
If you give a look at motion-blur-zoom.c, it does something like that (though it doesn't use CL).
Hope that clears it up, let me know if you have any more questions.Victor
On Tue, Oct 13, 2015 at 10:14 AM, Adel Johar wrote:
Hi Victor,
I’m currently trying to help Vincent out with the development of the tutorial, though I’ve hit a bit of a snag. Based on what I’ve seen from an old blog post of yours (and from code snippets from the current source codes), I understand that an iterator is used to iterate through the GEGL buffer to extract tiles and to run the OpenCL kernel on each tile. Do correct me if I’m wrong, but at this point it seems that an OpenCL kernel is called to operate on one tile at a time as the iterator moves the buffer from one tile to another.
As part of the tutorial, rather than integrating the kernels directly into the GEGL library, I believe it would be more beneficial if those who partake in the tutorial to write their own host code as well. I was hoping to inquire on a more detailed explanation on how the image data can be extracted from the GEGL Buffer as a whole rather than as tiles through an iterator; whereby participants can then look at improving the tiling process and see how such improvements can be integrated into the GEGL library. While it would certainly be easier to integrate the kernels directly into the GEGL library, as a starting step it would be good if the users of the tutorial can learn both the kernel and host side of OpenCL.
Thank you,
And Best Regards,
Adel