5G LDPC Block Error Rate Simulation Using the Cloud or a Cluster
This example shows how to use the cloud or a cluster for block error rate (BLER) simulation of low-density parity-check (LDPC) coding for the 5G NR downlink shared transport channel (DL-SCH).
For ultra-reliable low-latency communication in 5G systems, some use cases require a BLER as low as 1e-6 . In this low BLER region, obtaining accurate results requires simulating many millions of blocks. On a single desktop computer, this simulation can take days. You can use the cloud or a cluster to reduce simulation time. For example, a 256-worker cluster on AWS is about 42 times as fast as a 6-core desktop in one test scenario. For more details, see Sample Results.
In this example, you first calculate one point on a BLER curve by using a single desktop computer. You then use MATLAB Parallel Server in the cloud or on a cluster on your local network to calculate the BLER curve across a range of signal-to-noise ratios.
DL-SCH with LDPC Coding
First, simulate one transport block for the 5G NR DL-SCH with LDPC coding. This code is the basis of the
helperLDPCBLERSim function which uses
parfor to simulate many transport blocks in parallel.
% Set up DL-SCH coding parameters TBS = 3816; % Transport block size, a positive integer codeRate = 308/1024; % Target code rate, a real number between 0 and 1 rv = 0; % Redundancy version, 0-3 modulation = 'QPSK'; % Modulation scheme, QPSK, 16QAM, 64QAM, 256QAM nlayers = 1; % Number of layers, 1-4 for a transport block cbsInfo = nrDLSCHInfo(TBS,codeRate); disp('DL-SCH coding parameters') disp(cbsInfo) switch modulation case 'QPSK' bitsPerSymbol = 2; case '16QAM' bitsPerSymbol = 4; case '64QAM' bitsPerSymbol = 6; case '256QAM' bitsPerSymbol = 8; end % Set up AWGN channel EbNo = 1.25; % in dB outlen = ceil(TBS/codeRate); snrdB = convertSNR(EbNo,"ebno",... BitsPerSymbol=bitsPerSymbol,CodingRate=TBS/outlen); % Random transport block data generation in = randi([0 1],TBS,1,'int8'); % Transport block CRC attachment tbIn = nrCRCEncode(in,cbsInfo.CRC); % Code block segmentation and CRC attachment cbsIn = nrCodeBlockSegmentLDPC(tbIn,cbsInfo.BGN); % LDPC encoding enc = nrLDPCEncode(cbsIn,cbsInfo.BGN); % Rate matching and code block concatenation chIn = nrRateMatchLDPC(enc,outlen,rv,modulation,nlayers); % Symbol mapping symOut = nrSymbolModulate(chIn,modulation); % AWGN channel [rxSig, noiseVar] = awgn(symOut,snrdB); % Symbol demapping rxllr = nrSymbolDemodulate(rxSig,modulation,noiseVar); % Rate recovery raterec = nrRateRecoverLDPC(rxllr,TBS,codeRate,rv,modulation,nlayers); % LDPC decoding, with early termination and at most 12 iterations decBits = nrLDPCDecode(raterec,cbsInfo.BGN,12); % Code block desegmentation and CRC decoding [blk,~] = nrCodeBlockDesegmentLDPC(decBits,cbsInfo.BGN,TBS+cbsInfo.L); % Transport block CRC decoding [out,~] = nrCRCDecode(blk,cbsInfo.CRC); % Compare blockError = any(out~=in)
DL-SCH coding parameters CRC: '16' L: 16 BGN: 2 C: 1 Lcb: 0 F: 8 Zc: 384 K: 3840 N: 19200 blockError = logical 0
helperLDPCBLERSim function uses the current parallel pool to calculate the LDPC BLER in parallel. For each
EbNo value, the function simulates blocks by successive
parfor calls until a target number of block errors is achieved or each worker on a cluster has simulated a specified maximum number of blocks. In each
parfor call, all workers on the cluster work in parallel for the same
EbNo value and simulate the same number of blocks, so all workers are expected to finish their computation at roughly the same time.
Preventing some workers from finishing earlier than other workers is crucial to the efficient use of a cluster, and minimizing overall execution time.
Use Desktop Computer to Get One Point on BLER Curve
delete(gcp('nocreate')); % If a parpool exists, shut it down first pool = parpool('local'); % Create a local parpool for helperLDPCBLERSim targetNumBlockErrors = 100; numBlocksInsideParfor = 1000; % Number of blocks to simulate per worker in one parfor loop maxNumBlocksPerWorker = 1e9; [BLER, snrdB, finalNumBlockErrors, finalNumBlocks, executionTime] = ... helperLDPCBLERSim(TBS, codeRate, EbNo, targetNumBlockErrors, ... maxNumBlocksPerWorker, numBlocksInsideParfor) delete(pool);
Starting parallel pool (parpool) using the 'Processes' profile ... Connected to the parallel pool (number of workers: 4). Begin simulation for EbNo = 1.25 using 4 workers EbNo = 1.25 Elapsed time = 00:00:52 Number of blocks simulated = 4000 Number of block errors found = 151 BLER = 0.0377 snrdB = -0.9572 finalNumBlockErrors = 151 finalNumBlocks = 4000 executionTime = 52.2893 Parallel pool using the 'Processes' profile is shutting down.
Set up Your Cluster
Before you can run the next sections, you must get access to a cluster. On the MATLAB Home tab, go to Parallel > Discover Clusters to find out if you already have access to a cluster with MATLAB Parallel Server™. For more information, see Discover Clusters (Parallel Computing Toolbox).
Use Cluster on Your Local Network to Generate One BLER Curve
Check whether this MATLAB session has access to a MATLAB Parallel Server cluster on your local network. If so, create a parpool to use all workers on the cluster and then generate a BLER curve.
[pool, cluster] = helperCreateParpool("Cluster"); EbNo = -0.5:0.25:2.25; if ~isempty(cluster) disp('Found MATLAB Parallel Server cluster on your local network') [BLER, snrdB, finalNumBlockErrors, finalNumBlocks, executionTime] = ... helperLDPCBLERSim(TBS, codeRate, EbNo, targetNumBlockErrors*ones(size(EbNo)), ... maxNumBlocksPerWorker*ones(size(EbNo)), numBlocksInsideParfor*ones(size(EbNo))); figure semilogy(snrdB,BLER,'x-') xlabel('SNR (dB)'); ylabel('BLER') grid on delete(pool); end
Use the Cloud to Generate One BLER Curve
Check whether this MATLAB session has access to a MATLAB Parallel Server cluster running in AWS managed by MathWorks Cloud Center. If so, create a parpool to use all workers on the cluster and then generate a BLER curve.
To learn how to start and test your first cluster on the cloud, see Start and Test MATLAB Parallel Server Cluster in Cloud Center.
[pool, cluster] = helperCreateParpool("Cloud"); if ~isempty(cluster) disp('Found MATLAB Parallel Server cluster on the cloud') if strcmpi(cluster.State,'online') [BLER, snrdB, finalNumBlockErrors, finalNumBlocks, executionTime] = ... helperLDPCBLERSim(TBS, codeRate, EbNo, targetNumBlockErrors*ones(size(EbNo)), ... maxNumBlocksPerWorker*ones(size(EbNo)), numBlocksInsideParfor*ones(size(EbNo))); figure semilogy(snrdB,BLER,'x-') xlabel('SNR (dB)'); ylabel('BLER') grid on delete(pool); disp("If you do not need to use the cluster, go to https://cloudcenter.mathworks.com and shut it down.") else disp("The cluster " + cluster.Name + " is not online. Go to https://cloudcenter.mathworks.com, start it, and then run this example again.") end end
This example compares running on a 6-core desktop, a 128-worker cluster on a local network, and a 256-worker cluster on AWS Cloud to generate three BLER curves. The desktop has a 6-core Intel Xeon W-2133 processor. The 128-worker cluster has eight 16-core Intel Xeon E5-2683 v4 processors. The 256-worker cluster has sixteen m5.8xlarge AWS EC2 machines (16 cores per machine). In 16 hours and 20 minutes, the 256-worker cluster completed 12 points, down to BLER = 2.80823e-7. In the same period of time, the 128-worker cluster completed 11 points (down to BLER = 2.69305e-6) and the 6-core desktop completed 10 points (down to BLER = 3.27497e-5).
blerFig = openfig('LDPCBLERcurves.fig');
To compare the relative speeds of the three platforms, the execution times for simulating 768,000 blocks at two SNR values were logged.
--------------------------------------------------------------------------- SNR | 6-core desktop | 128-worker cluster | 256-worker cluster --------------------------------------------------------------------------- -0.457 dB | 5455 seconds | 407 seconds | 129 seconds --------------------------------------------------------------------------- -0.207 dB | 5006 seconds | 381 seconds | 120 seconds ---------------------------------------------------------------------------
At SNR = -0.457 dB, the 256-worker cluster is about 5455/129 = 42.287 times as fast as the 6-core desktop, and about 407/129 = 3.155 times as fast as the 128-worker cluster.
At SNR = -0.207 dB, the 256-worker cluster is about 5006/120 = 41.717 times as fast as the 6-core desktop, and about 381/120 = 3.175 times as fast as the 128-worker cluster.
Hence, the 256-worker cluster is generally about 42 times as fast as the 6-core desktop and about 3.16 times as fast as the 128-worker cluster.
You can use the framework of this example to generate BLER curves for other transport block sizes and code rates. The speedup achievable by a sufficiently large cluster makes it practical to find LDPC error floors (probably below BLER = 1e-7) at high SNR values.
You can also explore the helper functions for creating a parallel pool and running an LDPC BLER simulation:
Sybis, Michal, Krzysztof Wesolowski, Keeth Jayasinghe, Venkatkumar Venkatasubramanian, and Vladimir Vukadinovic. "Channel Coding for Ultra-Reliable Low-Latency Communication in 5G Systems." In 2016 IEEE 84th Vehicular Technology Conference (VTC-Fall), 1-5. Montreal, QC, Canada: IEEE, 2016. https://doi.org/10.1109/VTCFall.2016.7880930.