File Exchange Pick of the Week

Our best user submissions

2D Wave Equation

Sean's pick this week is 2D Wave Equation by Daniel Armyr.

GPUs

MATLAB's Parallel Computing Toolbox has direct support for Graphics Processing Units (GPUs or GPGPUs) for many different computations. Since most laptops, with the exception of high-end gaming ones, don't have powerful enough GPUs for scientific computing, I usually don't get to take advantage of this.

However, I've been lucky enough over the last month or so to have access to a fancy portable desktop with a Tesla K40 GPU in it. Daniel's app allows me to make waves and then compute the propagation on the cpu or gpu while measuring the difference in computational speed. (I switch to the GPU at 28s)

What did it take to switch over to the GPU from the CPU? Here's the code comparison:

Just the commands gpuArray and gather to move the arrays back and forth between the CPU and GPU. There are quite a few commands that run directly on the GPU, you can find them here. This list grows bigger with every release of MATLAB. My personal favorite is iradon which was a big bottleneck in my previous life working with CT images.

One thing I'd like to see Daniel do differently would be to check if a GPU is available. If you don't have a supported GPU, the app errors rather than failing gracefully or just disabling the GPU option. There's a convenient function, gpuDeviceCount, that you can use to see how many supported GPUs are on the machine.

if gpuDeviceCount == 0
    warndlg(sprintf('You don''t have a supported GPU!\nGo talk to your IT department :)'),'No GPU Found')
end

Comments

Do you use a GPU with MATLAB or have interest in trying one?

Give it a try and let us know what you think here or leave a comment for Daniel.




Published with MATLAB® R2015b

|
  • print

댓글

댓글을 남기려면 링크 를 클릭하여 MathWorks 계정에 로그인하거나 계정을 새로 만드십시오.