5.0

5.0 | 2 ratings Rate this file 58 downloads (last 30 days) File Size: 57.79 KB File ID: #23795

NVIDIA CUDA-based bilinear (2D) interpolation

by Gerald Buchgraber

 

15 Apr 2009 (Updated 30 Jun 2009)

Code covered by the BSD License  

Incredible speed boost in comparison to the Matlab implementation. (interp2)

Download Now | Watch this File

File Information
Description

This code was inspired by Alexander Huth's bilinear interpolation approach
( http://www.mathworks.com/matlabcentral/fileexchange/20248 )
also using the GPU's built-in bilinear texture interpolation capability, which is indeed very fast.

The speedup is depending on your CUDA enabled graphics hardware. The more multiprocessors, texture units, ... the better the results will be.

In comparison to Alexander's cudainterp2, I added some performance improvements and the capability to interpolate complex numbers too.

Feel free to write some feedback or a comment.

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
2D CUDA-based bilinear interpolation

MATLAB release MATLAB 7.6 (R2008a)
Other requirements CUDA enabled graphics hardware, NVIDIA CUDA Toolkit, NVIDIA CUDA SDK, only tested with Windows (XP,Vista)
Zip File Content  
Other Files
bilininterp/bilininterp.cu,
bilininterp/bilininterp.m,
bilininterp/bilininterp_complex_test.m,
bilininterp/bilininterp_defines.h,
bilininterp/bilininterp_kernel.cu,
bilininterp/bilininterp_speed_test.m,
bilininterp/bilininterp_trajectory_test.m,
bilininterp/bin/nvmex.pl,
bilininterp/build_mex.m,
bilininterp/cudainterp2/cudainterp2.cu,
bilininterp/cudainterp2/cudainterp2.m,
bilininterp/cudainterp2/README,
bilininterp/cudainterp2/testcudainterp2.m,
bilininterp/nvmex.m,
bilininterp/nvmex_helper.m,
bilininterp/nvmexopts_r2008a.bat,
bilininterp/README,
bilininterp/test_bilininterp_vs_cudainterp2.m,
bilininterp/test_results_bilininterp_vs_cudainterp2_GPU_8800_GTX.png,
bilininterp/test_results_bilininterp_vs_cudainterp2_GPU_9600M_GT.png,
license.txt
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (7)
21 Apr 2009 Yi Cao

The code works as described. On my GeForce 8400 GPU, it can achieve over 200 on relative speedup. The nvmex compiler also works smoothly on MATLAB R2009A. Excellent!

12 Jul 2009 Darius

Having trouble getting it running:

"Can't locate File/Temp.pm in @INC (@INC contains: C:/Program Files/MATLAB/R2007a...)"

How does one ensure valid "include" and "library" paths in "build_mex.m" ?

24 Jul 2009 Gerald Buchgraber

Dear Darius,
you can find all build params described in nvmex.m
For adding additional include or library paths just use (similar to gcc) the params: -I<pathname> (for include path), -L<directory> (for lib dir) and -l<name> (for lib file).

Hopefully this helps and you get it running!

25 Sep 2009 Oliver Woodford

Is this supposed to compile on linux, or only on Windows? I can't get it to compile on linux.

28 Sep 2009 Gerald Buchgraber

Well, I haven't tried it yet, but I'm sure it's possible. The included build tools are dedicated to MS Windows. Please leave a notice if you get it running.

29 Sep 2009 Oliver Woodford

I wrote my own compile script for linux. See:
http://www.mathworks.com/matlabcentral/newsreader/view_thread/261866

20 Jan 2010 Sven

I tried this on a XP64 machine with Matlab 64. I found one problem: If options are placed into an rsp file by the nvmex_helper script the nvmex compiler cannot parse them. So I added

    if (grep /\.rsp$/i, @ARGV) { # arg is a rsp file
my $fn = substr($ARGV[0],1);
my $holdNewline = $/;
undef $/;
my $inf;
open $inf, "<" . $fn;
my $buf = <$inf>;
close $inf;
$/ = $holdNewline;
$_ = $buf;
s/"(.*)\s(.*)"/"\"$1_!_$2\""/eg; # avoid splitting at spaces with quotes,e.g,. "Program Files/"
s/\s+/" "/eg; # collapse multiple spaces
$buf = $_;
@items = split / /, $buf; #split the input string into individual words
grep(s/_!_/" "/eg, @items);
@ARGV = @items;
    }

to nvmex.pl to allow that. Now I can pass -win32 as an option, and with some add'l tweaks (using win32 matlab and cuda libs, setting LINKER_OPTIONS to /MACHINE:X86 and esnuring that the 32-bit nvcc is called, I can now compile and run 32-bit mex executables from the 64-bit matlab command line.

Please login to add a comment or rating.
Updates
20 Apr 2009

description changed

22 Apr 2009

added another picture showing the test results on a GeForce 8800 GTX. Much better results in comparision to my mobile GeForce ;)

19 May 2009

License changed to BSD

30 Jun 2009

I fixed a typo and added tags.

Tag Activity for this File
Tag Applied By Date/Time
bilinear Gerald Buchgraber 16 Apr 2009 09:56:33
interpolation Gerald Buchgraber 16 Apr 2009 09:56:33
cuda Gerald Buchgraber 16 Apr 2009 09:56:33
image processing Gerald Buchgraber 16 Apr 2009 09:56:33
mex Gerald Buchgraber 16 Apr 2009 09:56:33
interp2 Gerald Buchgraber 30 Jun 2009 11:13:44
gpu Gerald Buchgraber 30 Jun 2009 11:13:45

Contact us at files@mathworks.com