gpuArray takes more time than CPU - imrotate

조회 수: 2 (최근 30일)
Dhivya
Dhivya 2014년 2월 15일
댓글: Anand 2014년 2월 18일
Hi.. This is my first experiment with gpuArray on image processing. When I tried to compare the time taken to execute 'imrotate' between CPU array and GPU array, it is seen that GPUarray takes more time. I hope the command imrotate is supported on GPU. Any help would be appreciated. Thanks in advance.

답변 (1개)

Anand
Anand 2014년 2월 18일
A couple of questions in helping you answer the question:
1. Which graphics card do you have? GPU performance is highly dependent on how good a graphics card you have. You can use the following command to find out:
>> gpuDevice
2. How big is the image and what data type is it?
3. Could you add the following line of code on line 9 and report back?
>> wait(gpuDevice)
  댓글 수: 2
Dhivya
Dhivya 2014년 2월 18일
1. This is what I got through the command 'gpuDevice'
2. Original image size is 1200x1600x3 uint8 After rotation, its size is 1949x1997x3 uint8
3. I have added the line and here is the profiler's screenshot
The time has come down surprisingly. Though, CPU time is lesser than the GPU's time. Could you please tell me the significance of this line 'wait(gpuDevice)'
Anand
Anand 2014년 2월 18일
As I mentioned before, GPU performance is highly dependent on the GPU card you have. I tried an image of the same size and datatype on my machine and got a 10x speedup over the CPU.
Also, there is usually a start up cost for the first time you execute a GPU function. So, you will find that the first call to a function is considerably slower than the rest. I'm guessing your second run of the script is faster.
Look at some of the pointers regarding performance at the end of this post:
GPU functions tend to execute asynchronously from the CPU in that a command is sent to the GPU and MATLAB execution moves forward without waiting. The wait function waits till the GPU returns before moving ahead. Hence for performance measurements, this is important for GPU code.
Furthermore, I would suggest using the gputimeit function if you have R2014a for performance measurements and comparing that to the results from timeit.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 GPU Computing에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by