Results 1 to 2 of 2

Thread: if and while loops better on gpu or cpu

  1. #1
    Junior Member
    Join Date
    Aug 2011
    Posts
    10

    if and while loops better on gpu or cpu

    what is the effect of if and while loop in a kernel will it better on gpu or cpu

    regards
    megharaj

  2. #2
    Junior Member
    Join Date
    Aug 2011
    Posts
    20

    Re: if and while loops better on gpu or cpu

    I think it depends. If all workthreads' control flows are the same, then running on gpu can be faster. For example, if the number of iteration of the loop is the same acroos all the workthread. If not, the workthreads that have less iteration will finish first, and those threads will wait until other threads are done without doing anything. However, it might still run faster on gpu in the latter scenario depending on how big the difference between numbers of iteration is.

    In the case that the control flow of the code has so many branches, and it is possible to reach all those branches, this is very bad on gpu.

    I've tried running loop (with the same number of iteration across workthreads) on gpu, and it's a lot faster than running on cpu, but I haven't tried complicated if statements code.

Similar Threads

  1. different time of cpu and gpu
    By prince in forum OpenCL
    Replies: 15
    Last Post: 11-16-2012, 12:45 AM
  2. CPU vs GPU optimizations
    By akhal in forum OpenCL
    Replies: 6
    Last Post: 07-31-2011, 11:01 AM

Posting Permissions

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