GPU progress?


#1

What is the current status of GPU support in Gnu Radio? In particular,
a GPUed FFT implementation would be peachy keen.


Marcus L.
Principal Investigator, Shirleys Bay Radio Astronomy Consortium
http://www.sbrac.org


#2

On Sat, 2008-11-15 at 10:30 -0500, Marcus D. Leech wrote:

What is the current status of GPU support in Gnu Radio? In particular,
a GPUed FFT implementation would be peachy keen.

I have been working on this for quite some time now.
I did a glsl implementation a few years back but it didn’t perform that
well and had some severe limitations.

So I started over this year and have reimplemented major part of
GnuRadio using CUDA.
It is a one to one implementation.
(every gr_something block is replaced with a cuda_something block)

My work-in-progress code is at:
http://gnuradio.org/trac/browser/gnuradio/branches/developers/nldudok1/gpgpu-wip

Make sure you read
http://gnuradio.org/trac/browser/gnuradio/branches/developers/nldudok1/gpgpu-wip/README.cuda

Caleb P. made a wiki about my code, you can find it at:
http://www.smallwhitecube.com/php/dokuwiki/doku.php?id=howto:gnuradio-with-cuda

The majority of the gnuradio-core code is a unmodified gnuradio checkout
of a few
moths back.

There are some important changes in gnuradio_core/src/lib/runtime
to support CUDA device memory as an emulated circular buffer.

I also implemented a gr.check_compare block which expects two input
streams and checks if they are outputting the same data.
I use this to check if my cuda blocks do exactly the same as the gr
blocks.

All the rest of the CUDA code is in gr_cuda.
gr_cuda has to be configured and build seperately.
gr_cuda is where the cuda reimplementations of some gnuradio blocks
are.

Then there are also a few new blocks cuda_to_host and host_to_cuda which
copy memory from and to the GPU device memory.

All python scripts to test and use the code are in /testbed.

The code in testbed is changing on a day-by-day basis.

There are several issues to be well aware of when doing SDR on a GPU.

-overhead
-call overhead
-copying data from and to the GPU
You need to do a lot of work on the GPU in one call to have any
benefit.
-circular buffers
-GPU memory cant’t be mmapped into a circular buffer
-solution 1: use copying to emulate a circular buffer
-solution 2: keep track of all the processing and make
your own
intelligent scheduler which does not need a circular buffer.

-threads: with CUDA you can’t access GPU device memory from different
host-threads. So make sure you create use and destroy all device memory
from the same thread. (The standard GnuRadio scheduler does not do it
like this)

-debugging: Debugging is hard and works quite different from normal
debugging.

-parallel: The GPU is good in doing calculations in parallel which are
not dependant on each other. For this reason a FIR will perform well,
while an IIR will perform bad. An IIR can only use one processing block
of the GPU, in stead of 128.
It can still be benificial to do the IIR on the GPU when all your other
blocks are running on the GPU because you don’t have to copy all samples
to the CPU, do the IIR on the CPU and copy everything back to the GPU.

All that said. I do have a complete WFM receiver which is running
completely on the GPU.
(using FIR and/or FFT filters, quadrature_demod, fm-deemph)

The FFT filters use the cuda provided FFT.
It shouldn’t be too hard to use the FFT for other things
(just look at the code of gr_cuda/src/lib/cuda_fft_*)

At the moment the complete wfm receiver is not running faster then on
the CPU with my 9600GT card, mainly because of the call overhead. (too
little work items done per call)
And the extra copying done to emulate circular buffers.

I can increase the amount of work done per call by using
output_multiple. But with the current scheduling code the flow-graph can
hang. This needs work.
So the performance will change in the future.
First I want to make sure everything is working as expected.

If I benchmark a single block with a big output_multiple then I do see
performance increases.

Greetings,
Martin