12

What is the difference between Buffer object and image buffer object in opencl? It is evident that image buffer is faster but to what extent? Where they must be used?

dgw
  • 13,418
  • 11
  • 56
  • 54
Megharaj
  • 1,589
  • 2
  • 20
  • 32

1 Answers1

21

An OpenCL Buffer is a 1D or 2D or 3D array in global memory. Its an abstract object that can be addressed thru a pointer. Buffers are Read-Only or Write_only or Read-Write. An Image buffer represents GPU Texture memory. It represents an array of pixels that can be access via functions specifying pixel x,y,z coordinates. There is no pointer access to Image Pixels on the GPU.

The hardware treats these two type of buffers differently. A OpenCL Buffer is either in Host RAM or GPU RAM and transferred between the two. A OpenCL Image Buffer has analogous characteristics of a OpenCL Buffer. But the differences are Image Buffer are either Read-only or Write-only. For Read-only Image buffers, the GPU can cache copies of the image pixels in every compute unit (= 32 or 64 ALU ). Typical the cache size is 8K (bytes or pixels?). Also, since image pixels cannot be accessed via a pointer on the GPU. Their mapping from x,y,z coordinates to physical address can be mapped in several ways. One way is to a Z-ordering. This clusters pixels in two dimensions so that neighboring pixels in x,y directions are store linearly. This helps speed access neighboring pixels in image filters.

OpenCL Buffers are used for general arrays and especially for arrays that are read-write, or double precision. OpenCL Image Buffers are used for image processing or other signal processing algos where the input image/signal can treated as read-only.

Tim Child
  • 2,994
  • 1
  • 26
  • 25
  • thanks a lot for your replay. Learnt a lot , but also wanted to know which one is faster and by what percentage – Megharaj Mar 29 '12 at 05:10
  • There is no generic answer to the which is faster and by what %. It depends on how your code accesses memory and what device you run on. – Tim Child Apr 01 '12 at 02:47
  • I think I can do the image processing without using Image buffers at all, can I? They are helpfull but not necessary as cl API. – eral Nov 21 '19 at 11:33