Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 10. General coding principles > Global size and local size

10.1. Global size and local size

One of the primary advantages of using OpenCL is that you can execute applications using thousands and thousands of threads, called work-items. The upper limit on the number of work-items you can generate is the maximum value of size_t (see SIZE_MAX in stdint.h), so it’s usually a good idea to generate one for each data point you need to process. For example, if a kernel needs to sort 216 integers and you want to process them using int4 vectors, set the total number of work-items to 216/4, or 214. This total number of work-items is called the global size.

Another rule of thumb to follow when generating work-items is that the global size should be a multiple of the maximum work-group size. Chapters 3 and 4 discussed work-groups in detail, but for this chapter, there are five main points to keep in mind:


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial