Altera_Forum
Honored Contributor
8 years agowhy did clFinish cause a shorter execution time for collaborative computing
Hi,
:( So sorry... I am new and I do not know why I can not reply to @HRZ on this thread: https://alteraforum.com/forum/showthread.php?t=57651 So sorry I have to post a new thread here... what i want to reply to hrz is: Thanks HRZ, I did not use OpenCL for CPU, I used thread in C++11. Now I just want to , after clEnqueueNDRangeKernel(), let CPU start its thread WITHOUT synchronizing... And if I use clFinish between clEnqueueNDRangeKernel() and cpu_thread.join(), I think, CPU thread will not start until FPGA process have been completed. I think it will WAIT , to be synchronized. And without clFinish, I think, it will NOT WAIT. However I can not understand why the execution time without clFinish will be longer than the time with clFinish... Is my understanding wrong? In other words, I just want the total execution time for CPU and FPGA is not simply the sum of the time for CPU and the time for FPGA... Thanks again. and here are my previous problem posted in https://alteraforum.com/forum/showthread.php?t=57651: --- Quote Start --- Hi, I think clEnqueueNDRangeKernel() is a non-blocking function. But I met a more specific problem. I want to implement collaborative computing on CPU-FPGA using OpenCL. For RANSAC algorithem I used data partitioning and the process of CPU and FPGA is independent. Now I want CPU and FPGA to execute RANSAC in parallel. How can I realize it? If I use:......
clStatus = clEnqueueNDRangeKernel(clCommandQueue,......);
clFinish(clCommandQueue);
cpu_thread.join();
...... then I think, it will be blocking. Is it right? Because clFinish dose not return until all queued commands in clCommandQueue have been processed and completed. But I want CPU and FPGA to execute RANSAC in parallel, then I tried to remove the clFinish, but I got a more longer total execution time of CPU and FPGA (than using clFinish). And I also tried to use clFlush instead of clFinish, and I also got a more longer total execution time. I mean, I got the shortest execution time using clFinish but I do not know why. And How can I realize paralleled processing? Who can help me? Thanks in advance. ps: The execution time is just refers to the time of processing RANSAC, not including other time such as transmission time. The results of all the three implementations mentioned above are right and now I just focus on the time. --- Quote End --- and hrz told me: --- Quote Start --- @Jasmine-J, assuming that you are programming both the CPU and FPGA using OpenCL, you can create two separate queues, one for each device, and run your kernels in parallel on the different queues and use events to synchronize them. Either way, clEnqueueNDRangeKernel() is NOT a blocking call and the best way to synchronize kernels or code segments that are supposed to run in parallel is to use events. --- Quote End --- Thanks in advance.