File Exchange

image thumbnail

A CUDA accelerated Beam Propagation Method [BPM] Solver using the Parallel Computing Toolbox

version (5.89 KB) by Patrick Kano
A beam propagation method solver using the CUDA capabilities in the parallel computing toolbox.

1 Download

Updated 23 Oct 2010

View License

The parallel computing toolbox version 5.0 for MATLAB 2010b includes an initial capability for NVIDIA CUDA use. This entry provides a simple paraxial beam propagation method [BPM] solver that utilizes the added GPU capability. A script is also provided that runs the BPM with standard MATLAB Fourier transforms and the GPU implemented transforms. For smaller matrices, the standard MATLAB approach appears to be faster, while at larger matrices above 512x512 elements, the CUDA approach is more than twice as fast.

An effort has been made to make the program so that it will run on a computer without the parallel computing toolbox or an NVIDIA GPU. However, a comparison with standard MATLAB is only possible with those two components.


The script ScrTimeBPM.m
contains an example of how one may run the main function CUDAparaxbpm.m.
The additional files
initialize the field, update the refractive index profile, and create plots.

2) A. Weideman, Linear Dispersive Wave Equations,
3) Okamoto, K. Fundamentals of optical waveguides, Academic Press, 2000.

Comments and Ratings (3)

Thanks for posting this code, very cool algorithm. We've enabled it to run with Jacket and posted the results and modified code here:


Hello David,
Thank you for your comments. My coworkers and I are interested in GPU acceleration. I was intrigued by the inclusion of CUDA capability into the MATLAB 2010b parallel computing toolbox.
The motivation for using MATLAB+CUDA was primarily my own curiosity. The choice of the beam propagation equation was based simply on my past experience with it.

From on the MathWorks website,
I do not believe that the 2009b version is adequate to run the CUDA additions.

A list of functions, like fft2, that support the GPU capability use can be found here:

Finally, a related example from the company website of fft2 being used is at:

I am glad to hear of our common interest.

Hello, Patrick. It is quite a coincidence that I am working in this same subject (kind of). I do not have, however, the latest Parallel Computing Toolbox (PCTB) and I would like to do some questions. Do you choose to use CUDA over standard parallel computing (multicore) by any particular reason? Is the FFT2 parallelized in the new version of PCTB (as far as I know, I'm my version it is only parallelized 1D FFT)? I am using 2009b, by the way. Thanks!


We slightly modified the description to explain more about the functions.

MATLAB Release Compatibility
Created with R2010b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.

Learn About Live Editor