Code covered by the BSD License  

Highlights from
NVIDIA CUDA-based bilinear (2D) interpolation

5.0

5.0 | 2 ratings Rate this file 38 Downloads (last 30 days) File Size: 57.8 KB File ID: #23795
image thumbnail

NVIDIA CUDA-based bilinear (2D) interpolation

by

 

15 Apr 2009 (Updated )

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

| 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

2 D Cuda Based Bilinear Interpolation inspired this file.

MATLAB release MATLAB 7.6 (R2008a)
Other requirements CUDA enabled graphics hardware, NVIDIA CUDA Toolkit, NVIDIA CUDA SDK, only tested with Windows (XP,Vista)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (11)
14 Sep 2014 Matthias

Could anybody help me to get this to run on a more current version of MATLAB, e.g. 2013b?

I copied the nvmex.pl file as instructed but then get this error (clearly, the "options file" is outdated):

Error: Using options file:
nvmexopts_r2008a.bat
You cannot use this file with the UNKNOWN architecture because it enables a compiler for a different architecture.
Choose a file that is compatible with the UNKNOWN architecture.

22 Aug 2013 Emil Entchev

Hi,
When I try to compile the mex file I am getting "\bilininterp_kernel.cu(26): error: taking reference of texture/surface variable not allowed in __device__/__global__ functions".

Any solution?

06 Mar 2012 kailas

hi how could we calculate exact speed up .... i mean in the comments section it has been given that relative speed up of 5 means approx 1/10 th of performance improvement for GPU....

could some one explain it..

23 Aug 2011 Qi Wang

Please correct me if I am wrong.

In "bilininterp_speed_test.m", cudainterp2 and matlab's interp2 generate a output matrix, however bilininterp only interpolate one point in each loop. That is why it gets faster when the matrix getting bigger.

The input to bilininterp should be same like interp2 to have the same output dimension. And if it is done correctly, bilininterp's speedup is ~5 compared to cudainterp2's speedup of ~8 on my GTX460.

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.

29 Sep 2009 Oliver Woodford

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

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.

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.

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!

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" ?

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!

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.

Contact us