Results 1 to 2 of 2

Thread: Should I cache get_global_id(0)?

  1. #1

    Should I cache get_global_id(0)?

    Hi,

    Should I cache get_global_id(0) to a private integer like that:

    Code :
    size_t idx = get_global_id(0)

    or should I call get_global_id(0) several times?

    I want to reduce the number of registers if it does mean high penalty on some (popular) platforms.

  2. #2
    Senior Member
    Join Date
    May 2010
    Location
    Toronto, Canada
    Posts
    845

    Re: Should I cache get_global_id(0)?

    Choose the option that is easiest to read and maintain. It probably won't make a difference in terms of performance. Compilers have optimizations such as Common Subexpression Elimination that will make both options effectively the same.
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

Similar Threads

  1. get_global_id is undefined
    By mtpurger in forum OpenCL
    Replies: 4
    Last Post: 04-13-2013, 08:59 AM
  2. basic question regarding get_global_id
    By prince in forum OpenCL
    Replies: 6
    Last Post: 12-01-2012, 02:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •