Documentation Center

  • Trial Software
  • Product Updates

DVB-S.2 System Simulation Using a GPU-Based LDPC Decoder System Object

This example shows how to use a GPU-based LDPC Decoder System object to increase the speed of a communications system simulation. This example illustrates the performance increase by modeling part of the ETSI (European Telecommunications Standards Institute) EN 302 307 standard for Broadcasting, Interactive Services, News Gathering and other broadband satellite applications (DVB-S.2) [ 1]. For further information on using System objects to simulate the DVB-S.2 system see this example. You must have a Parallel Computing Toolbox™ user license to use the GPU-based LDPC Decoder.

Introduction

The LDPC Decoding algorithm is computationally expensive and constitutes the vast majority of the time spent in a DVB-S.2 simulation. Using the comm.gpu.LDPCDecoder System object to execute the decoding algorithm on a GPU dramatically improves simulation run time. The example simulates the DVB-S.2 system, obtaining a benchmark for speed (run time), once with a CPU-based LDPC Decoder (comm.LDPCDecodercomm.LDPCDecoder) and once with a GPU-based LDPC Decoder (comm.gpu.LDPCDecodercomm.gpu.LDPCDecoder). The example captures the bit error rate for both versions, to show there is no loss in decoding performance using the GPU.

fprintf(...
  'DVB-S.2 Digital Video Broadcast Standard Bit Error Rate Simulation\n\n');

fprintf(...
  'Performance comparison of CPU- and GPU- accelerated decoders.\n');
DVB-S.2 Digital Video Broadcast Standard Bit Error Rate Simulation

Performance comparison of CPU- and GPU- accelerated decoders.

GPU Presence Detection

The example attempts to query the GPU to detect a Parallel Computing Toolbox user license and the presence of a supported GPU. If the GPU or the Parallel Computing Toolbox is unavailable, a CPU-only simulation can be performed.

try
  %Query the GPU
  dev = parallel.gpu.GPUDevice.current;

  %Print out information about the GPU that was found
  fprintf(...
    'GPU detected (%s, %d multiprocessors, Compute Capability %s)\n',...
    dev.Name, dev.MultiprocessorCount, dev.ComputeCapability);

  %Include a GPU-based simulation.
  doGPU = true;

catch %#ok<CTCH>

  %The GPU is not supported or not present, or the Parallel Computing
  %Toolbox was not present and licensed. Consider a CPU-only simulation.

  inp = input(['***NOTE: GPU not detected. ', ...
               'Continue with CPU-only simulation? [Y]/N '], 's');
  if strcmpi(inp, 'y') || isempty(inp)
    doGPU = false;
  else
    return;
  end

end
GPU detected (Tesla C2075, 14 multiprocessors, Compute Capability 2.0)

Initialization

The getParamsDVBS2Demo.mgetParamsDVBS2Demo.m function generates a structure, dvb, which holds the configuration information for the DVB-S.2 system given the parameters below. Subsequently, the example includes creating and configuring System objects, based on the dvb structure.

The createSimObjDVBS2Demo.mcreateSimObjDVBS2Demo.m script constructs most of the System objects used in DVB-S.2 and configures them based on the dvb structure.

Then both CPU- and GPU-based LDPC Decoder System objects are created and configured identically.

%DVB-S.2 System Parameters
subsystemType = 'QPSK 1/2';    % Constellation and LDPC code rate
EsNodB        = 0.75;          % Energy per symbol to noise PSD ratio in dB
numFrames     = 10;            % Number of frames to simulate
maxNumLDPCIterations = 50;     % LDPC Decoder iterations

dvb = getParamsDVBS2Demo(subsystemType, EsNodB, maxNumLDPCIterations);


%Create and configure the BCH Encoder and Decoder, Interleaver,
%Deinterleaver, Modulator, Demodulator, AWGN Channel.

createSimObjDVBS2Demo;

%Construct the LDPC Encoder
hLDPCEnc = comm.LDPCEncoder(dvb.LDPCParityCheckMatrix);

%Construct the LDPC Decoder System objects

%LDPC Decoder Configuration
ldpcPropertyValuePairs = { ...
    'MaximumIterationCount' , dvb.LDPCNumIterations, ...
    'ParityCheckMatrix' , dvb.LDPCParityCheckMatrix, ...
    'DecisionMethod' , 'Hard Decision', ...
    'IterationTerminationCondition' , 'Maximum iteration count', ...
    'OutputValue' , 'Information part'};

%Construct the LDPC Decoder System objects (CPU and GPU versions)
hLDPCDecoder        = comm.LDPCDecoder(ldpcPropertyValuePairs{:});
if doGPU
    hgpuLDPCDecoder   = comm.gpu.LDPCDecoder(ldpcPropertyValuePairs{:});
end

%Create an ErrorRate object to analyze the differences in bit error rate
%between the CPU and GPU.

hBER           = comm.ErrorRate;

CPU and GPU Performance Comparison

This example simulates the DVB-S.2 system using the CPU-based LDPC Decoder System object first, and then the GPU-based LDPC Decoder System object. The example obtains system benchmarks for each LDPC Decoder by passing several frames of data through the system and measuring the total system simulation time. The first frame of data incurs a large simulation initialization time, and so, it is excluded from the benchmark calculations. The per frame and average system simulation times are printed to the Command Window. The bit error rate (BER) of the system is also printed to the Command Window to illustrate that both CPU-based and GPU-based LDPC Decoders achieve the same BER.

if doGPU
    architectures = 2;
else
    architectures = 1;
end

%Initialize run time results vectors
runtime = zeros(architectures, numFrames);
avgtime = zeros(1, architectures);

%Seed the random number generator used for the channel and message
%creation.  This will allow a fair BER comparison between CPU and GPU.
%Cache the original random stream to restore later.

original_rs = RandStream.getGlobalStream;
rs = RandStream.create('mrg32k3a', 'seed', 25);
RandStream.setGlobalStream(rs);

%Loop for each processing unit - CPU and GPU
for ii=1:architectures,

    %Do some initial setup for the execution loop
    if (ii==1)
        arch = 'CPU';
        dec = hLDPCDecoder; %Use CPU LDPC Decoder
    else
        arch = 'GPU';
        dec = hgpuLDPCDecoder;%Use GPU LDPC Decoder
    end


    %Reset the Error Rate object
    reset(hBER);

    %Reset the random stream
    rs.reset;

    %Notice to the user that DVB-S.2 simulation is beginning.
    fprintf(['\nUsing ' arch '-based LDPC Decoder:\n']);
    dels = repmat('\b', 1, fprintf('  Initializing ...'));


    %Main simulation loop.
    %Run numFrames+1 times and ignore the first frame (which has
    %initialization overhead) for the run time calculation. Use the first
    %run for the BER
    %calculation.
    for rr=1:(numFrames+1)

        %Start timer
        ts = tic;

        %***Create an input Message***%
        msg = zeros(hBCHEnc.MessageLength, 1);
        msg(1:dvb.NumInfoBitsPerCodeword) = ...
            logical(randi([0 1], dvb.NumInfoBitsPerCodeword, 1));

        %***Transmit***%
        bchencOut   = step(hBCHEnc, msg);
        ldpcencOut  = step(hLDPCEnc, bchencOut);
        xlvrOut     = step(hIntrlv, ldpcencOut);
        modOut      = step(hMod, xlvrOut);

        %***Corrupt with noise***%
        chanOut     = step(hChan, modOut);

        %***Receive***%
        demodOut    = step(hDemod, chanOut);
        dexlvrOut   = step(hDeintrlv, demodOut);

        %Use whichever LDPC Decoder was set above.
        ldpcdecOut  = step(dec, dexlvrOut);

        bchdecOut   = step(hBCHDec, ldpcdecOut);

        %***Compute BER ***%
        %Calculate BER at output of LDPC, not BCH.
        ber         = step(hBER, logical(bchencOut), ldpcdecOut);

        %Stop timer
        runtime(ii, rr) = toc(ts);

        %Don't report the first frame with the initialization overhead.
        if (rr > 1),
            fprintf(dels);
            newCharsToDelete = fprintf('  Frame %d decode : %.2f sec', ...
                rr-1, runtime(ii,rr));
            dels = repmat('\b', 1, newCharsToDelete);
        end

    end %end of running a frame through the DVB-S.2 system.


    %Report the run time results to the Command Window.
    fprintf(dels); % Delete the last line printed out.

    %Calculate the average run time. Don't include frame 1 because it
    %includes some System object initialization time.
    avgtime(ii) = mean(runtime(ii, 2:end));

    fprintf('  %d frames decoded, %.2f sec/frame\n', numFrames, avgtime(ii));
    fprintf('  Bit error rate: %g \n', ber(1) );

end %architecture loop

%Reset the random stream to the cached object
RandStream.setGlobalStream(original_rs);
Using CPU-based LDPC Decoder:
  10 frames decoded, 0.90 sec/frame
  Bit error rate: 0.00785634 

Using GPU-based LDPC Decoder:
  10 frames decoded, 0.15 sec/frame
  Bit error rate: 0.00785634 

Using code similar to what is shown above, a bit error rate measurement was made offline. The bit error rate performance of the GPU- and CPU-based LDPC Decoders are identical as seen in this plot.

Summary

If a GPU was used, show the speedup based on the average run time of a DVB-S.2 system using a GPU LDPC Decoder vs a CPU LDPC Decoder.

if ~doGPU
    fprintf('\n*** GPU not present ***\n\n');
else
    %Calculate system-wide speedup
    fprintf(['\nFull system simulation runs %.2f times faster using ' ...
        'the GPU-based LDPC Decoder.\n\n'], avgtime(1)/avgtime(2));

end
Full system simulation runs 6.00 times faster using the GPU-based LDPC Decoder.

Appendix

This example uses the following script and helper function:

Selected Bibliography

  1. ETSI Standard EN 302 307 V1.1.1: Digital Video Broadcasting (DVB); Second generation framing structure, channel coding and modulation systems for Broadcasting, Interactive Services, New Gathering and other broadband satellite applications (DVB-S.2), European Telecommunications Standards Institute, Valbonne, France, 2005-03.

Was this topic helpful?