File Exchange Pick of the Week

Our best user submissions

2D Wave Equation

Sean's pick this week is2D Wave EquationbyDaniel Armyr.

GPUs

MATLAB'sParallel Computing Toolboxhas 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 aTesla K40 GPUin 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 thecode comparison:

Just the commandsgpuArrayandgatherto 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 themhere. This list grows bigger with every release of MATLAB. My personal favorite isiradonwhich was a big bottleneck in my previous life working with CT images.

我想看看丹尼尔做的一件事是不同的我们uld 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.

ifgpuDeviceCount == 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 thinkhereor leave acommentfor Daniel.




Published with MATLAB® R2015b

|
  • print
  • send email

Comments

To leave a comment, please clickhereto sign in to your MathWorks Account or create a new one.