GPU ベースの LDPC 復号化器 System object を使用した DVB-S.2 システム シミュレーション
この例では、GPU ベースの LDPC 復号化器 System object™ を使用して通信システム シミュレーションを高速化する方法を示します。パフォーマンスの向上は、ブロードキャスティング、双方向サービス、ニュース ギャザリングおよびその他のブロードバンド衛星活用 (DVB-S.2) のための ETSI (欧州電気通信標準化機構) EN 302 307 規格の一部をモデル化することで示されます [1]。DVB-S.2 システムのシミュレートで System object を使用する場合の詳細については、DVB-S.2 リンク (Simulink での LDPC 符号化を含む)を参照してください。GPU ベースの LDPC 復号化器を使用するには、Parallel Computing Toolbox™ のユーザー ライセンスが必要です。
はじめに
LDPC 復号化アルゴリズムは計算に時間がかかり、DVB-S.2 シミュレーションで費やされる大部分を占めます。comm.gpu.LDPCDecoder System object を使用して GPU で復号化アルゴリズムを実行すると、シミュレーションの実行時間が著しく短縮されます。この例では、CPU ベースの LDPC 復号化器関数 (ldpcDecode
) と GPU ベースの LDPC 復号化器 (comm.gpu.LDPCDecoder
) をそれぞれ 1 度使用し、DVB-S.2 システムをシミュレートして速度 (実行時間) のベンチマークを得ます。また、GPU を使用する場合の復号化の性能に低下がないことを示すために、両方のバージョンのビット誤り率を求めます。
fprintf(... 'DVB-S.2 Digital Video Broadcast Standard Bit Error Rate Simulation\n\n');
DVB-S.2 Digital Video Broadcast Standard Bit Error Rate Simulation
fprintf(... 'Performance comparison of CPU- and GPU- accelerated decoders.\n');
Performance comparison of CPU- and GPU- accelerated decoders.
GPU 存在検知
この例では、GPU を照会して、Parallel Computing Toolbox のユーザー ライセンスとサポート対象 GPU の存在を検出します。GPU または Parallel Computing Toolbox が使用不可能な場合は、CPU のみのシミュレーションを実行できます。
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 V100-PCIE-32GB, 80 multiprocessors, Compute Capability 7.0)
初期化
関数 getParamsDVBS2Demo.m は、以下のパラメーターが指定されている DVB-S.2 システムのコンフィギュレーション情報を保持する構造体 dvb を生成します。続いて、dvb 構造体に基づき、System object の作成と構成を行います。
createSimObjDVBS2Demo.m スクリプトは DVB-S.2 システムで使用される大部分の System object を構築し、dvb 構造体に基づいて System object を構成します。
次に、LDPC 復号化器構成オブジェクトと GPU ベースの LDPC 復号化器 System object を作成します。LDPC 復号化器構成オブジェクトは CPU ベースの関数ldpcDecode
に渡され、そこで GPU ベースの LDPC 復号化器 System object が使用する同等のオプションが使用されます。
% 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, Modulator, Demodulator, % AWGN Channel. createSimObjDVBS2Demo; % Construct an LDPC Encoder configuration object encoderCfg = ldpcEncoderConfig(dvb.LDPCParityCheckMatrix); % LDPC Decoder Configuration ldpcPropertyValuePairs = { ... 'MaximumIterationCount',dvb.LDPCNumIterations, ... 'ParityCheckMatrix',dvb.LDPCParityCheckMatrix, ... 'DecisionMethod','Hard Decision', ... 'IterationTerminationCondition','Maximum iteration count', ... 'OutputValue','Information part'}; % Construct an LDPC Decoder configuration object decoderCfg = ldpcDecoderConfig(dvb.LDPCParityCheckMatrix); if doGPU % Construct a GPU-based LDPC Decoder System object gpuLDPCDecoder = comm.gpu.LDPCDecoder(ldpcPropertyValuePairs{:}); end % Create an ErrorRate object to analyze the differences in bit error rate % between the CPU and GPU. BER = comm.ErrorRate;
CPU と GPU の性能比較
この例では、最初に CPU ベースの LDPC 復号化器関数を使用し、次に GPU ベースの LDPC 復号化器 System object を使用して DVB-S.2 システムをシミュレートします。システムからいくつかのデータ フレームを渡してシステムの総シミュレーション時間を測定し、LDPC 復号化器ごとのシステム ベンチマークを得ます。最初のデータ フレームはシミュレーション初期化時間が長くかかるため、ベンチマークの計算から除外されます。フレームごとおよび平均のシステム シミュレーション時間はコマンド ウィンドウに表示されます。システムのビット誤り率 (BER) もコマンド ウィンドウに表示され、CPU ベースと GPU ベースの両方の LDPC 復号化器で同じ 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'; % Use CPU LDPC Decoder else arch = 'GPU'; decoder = gpuLDPCDecoder;% Use GPU LDPC Decoder end % Reset the Error Rate object reset(BER); % Reset the random stream reset(rs); % 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(encbch.MessageLength, 1); msg(1:dvb.NumInfoBitsPerCodeword) = ... logical(randi([0 1],dvb.NumInfoBitsPerCodeword,1)); % ***Transmit*** % bchencOut = encbch(msg); ldpcencOut = ldpcEncode(bchencOut,encoderCfg); xlvrOut = intrlv(ldpcencOut,dvb.InterleaveOrder); modOut = pskModulator(xlvrOut); % ***Corrupt with noise*** % chanOut = chan(modOut); % ***Receive*** %y demodOut = pskDemodulator(chanOut); dexlvrOut = deintrlv(demodOut,dvb.InterleaveOrder); % Use the appropriate LDPC Decoder. if strcmp(arch,'CPU') ldpcdecOut = logical(ldpcDecode(dexlvrOut,decoderCfg,dvb.LDPCNumIterations,'DecisionType','hard','Termination','max','OutputFormat','info')); else ldpcdecOut = decoder(dexlvrOut); end bchdecOut = decbch(ldpcdecOut); % ***Compute BER *** % Calculate BER at output of LDPC, not BCH. ber = BER(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
Using CPU-based LDPC Decoder:
Initializing ...
Frame 1 decode : 0.29 sec Frame 2 decode : 0.30 sec Frame 3 decode : 0.32 sec Frame 4 decode : 0.29 sec Frame 5 decode : 0.25 sec Frame 6 decode : 0.29 sec Frame 7 decode : 0.26 sec Frame 8 decode : 0.29 sec Frame 9 decode : 0.28 sec Frame 10 decode : 0.26 sec
10 frames decoded, 0.28 sec/frame
Bit error rate: 0.00785634
Using GPU-based LDPC Decoder:
Initializing ...
Frame 1 decode : 0.12 sec Frame 2 decode : 0.12 sec Frame 3 decode : 0.12 sec Frame 4 decode : 0.11 sec Frame 5 decode : 0.09 sec Frame 6 decode : 0.12 sec Frame 7 decode : 0.09 sec Frame 8 decode : 0.12 sec Frame 9 decode : 0.12 sec Frame 10 decode : 0.09 sec
10 frames decoded, 0.11 sec/frame
Bit error rate: 0.00785634
% Reset the random stream to the cached object
RandStream.setGlobalStream(original_rs);
前述のコードと類似したコードを使用してビット誤り率の測定がオフラインで行われました。GPU および CPU ベースの LDPC 復号化器のビット誤り率性能は、このプロットで確認できるように等しくなります。
まとめ
GPU を使用した場合、GPU LDPC 復号化器では、CPU LDPC 復号化器を使用する DVB-S.2 システムに比べ平均的な実行時間に応じた高速化が示されました。
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 2.60 times faster using the GPU-based LDPC Decoder.
付録
この例では、createSimObjDVBS2Demo.m スクリプトと補助関数 getParamsDVBS2Demo.m が使用されています。
参考文献
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.