Main Content

MATLAB Performance Improvements

Vector-Based Processing

  • When you use vector-based processing, the program processes multiple samples during a single execution call to a System object™. Consider using vectors from roughly 366 to several thousand. The default is 3660, which represents 10 Ethernet packets.

  • Use large vectors of data to minimize function call overhead.

MATLAB Code Generation

You can accelerate your MATLAB® algorithms by generating a MEX function using the MATLAB Coder™ function codegen (MATLAB Coder).

Performance analysis for SDRu Transmitter System object

This example generates a MEX file called sdruTransmitMex from the function sdruTransmitData. You can observe a speedup (in megasamples per second (MS/s)) with no underruns at 10000 samples per frame when you run the MEX file of this code.

Run this command to generate a MEX file called sdruTransmitMex from the function sdruTransmitData.

codegen sdruTransmitData -o sdruTransmitMex;

Run this MEX file to transmit data using the generated MEX, and observe the transmission time and number of underruns.

[transmitTime,underrunCount] = sdruTransmitMex()

Performance analysis for SDRu Receiver System object

This example generates a MEX file called sdruReceiveMex from the function sdruReceiveData. You can observe a speedup (in megasamples per second (MS/s)) with no overruns at 10000 samples per frame when you run the MEX file of this code.

Run this command to generate a MEX file called sdruReceiveMex from the function sdruReceiveData.

codegen sdruReceiveData -o sdruReceiveMex;

Run this MEX file to receive data using the generated MEX, and observe the reception time and number of overruns.

[ReceiveTime,overrunCount] = sdruReceiveMex()

Note

These codes were timed on a Windows® 10, Intel® Xeon® CPU E5-1650 v4 @ 3.60 GHz test system.

Improved Performance with 10GigE Interface

X3xx radios and N3xx radios provide 10GigE interface to communicate with the host computer. To use the 10GigE interface for optimizing the transfer speed between the host computer and the radio, you must set these configurations:

  • On Windows, configure the FastSendDatagramThreshold registry key with the value of 65536 (decimal).

  • On Linux systems, set the MTU size to 9000 bytes by using this command.

    $ sudo ifconfig eth1 mtu 9000

These examples shows improved performance with the 10GigE interface for comm.SDRuTransmitter and comm.SDRuReceiver System objects.

Performance Analysis for SDRu Transmitter System Object

Run this code to observe the speedup (with fewer underruns) at frame length of 1e5 and sample rate of 33.33 MHz.

tx = comm.SDRuTransmitter('Platform','X310','IPAddress','192.168.80.2', ...
                          'CenterFrequency',2.45e9, ...
                          'MasterClockRate',200e6,'InterpolationFactor',6);

SamplesPerFrame = 1e5;
sinGen =  dsp.SineWave('Frequency',100e3,'SampleRate',50e6, ...
                       'SamplesPerFrame',SamplesPerFrame,'ComplexOutput',true);
data = sinGen();
underrunCount = 0;
tx(data);
tic
for i = 1:4e3  
    underrun =  tx(data);
    if underrun
        underrunCount = underrunCount+1;
    end
end
transmitTime = toc;
disp(['Transmit Time = ', num2str(transmitTime)]);
disp(['underrun count = ', num2str(underrunCount)]);
release(tx);

Performance Analysis for SDRu Receiver System Object

Run this code to observe the speedup (with fewer overruns) at frame length of 1e5 and sample rate of 50 MHz.

rx = comm.SDRuReceiver('Platform','X310','IPAddress','192.168.80.2', ...
                       'CenterFrequency',2.45e9,'MasterClockRate',200e6,'DecimationFactor',4, ...
                       'TransportDataType','int16','OutputDataType','double', ...
                       'SamplesPerFrame',1e5);
overrunCount = 0;
data = rx();
tic
for i = 1:5e3  
    [data,dataLength,overrun] = rx();
    if overrun
        overrunCount = overrunCount+1;
    end
end
receiveTime = toc;
disp(['Receive Time = ',num2str(receiveTime)]);
disp(['Overrun count = ',num2str(overrunCount)]);
release(rx);

Related Topics