5g ldpc block error rate simulation using the cloud or a cluster -凯发k8网页登录
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 [1]. 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
parallelization strategy
the 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 parallel pool with 4 workers. begin simulation for ebno = 1.25 using 4 workers ebno = 1.25 elapsed time = 00:01:24 number of blocks simulated = 4000 number of block errors found = 151 bler = 0.0377 snrdb = -0.9572 finalnumblockerrors = 151 finalnumblocks = 4000 executiontime = 84.5906 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 .
[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
sample results
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.
further exploration
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:
references
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. .
see also
functions
- (5g toolbox) | | |
parpool
(parallel computing toolbox)
related topics
- discover clusters and use cluster profiles (parallel computing toolbox)