Implementation of Decoders for LDPC Block Codes and LDPC Convolutional Codes Based on GPUs

In this paper, efficient LDPC block-code decoders/simulators which run on graphics processing units (GPUs) are proposed. We also implement the decoder for the LDPC convolutional code (LDPCCC). The LDPCCC is derived from a predesigned quasi-cyclic LDPC block code with good error performance. Compared to the decoder based on the randomly constructed LDPCCC code, the complexity of the proposed LDPCCC decoder is reduced due to the periodicity of the derived LDPCCC and the properties of the quasicyclic structure. In our proposed decoder architecture, Γ (Γ is a multiple of a warp) codewords are decoded together, and hence, the messages of Γ codewords are also processed together. Since all the Γ codewords share the same Tanner graph, messages of the Γ distinct codewords corresponding to the same edge can be grouped into one package and stored linearly. By optimizing the data structures of the messages used in the decoding process, both the read and write processes can be performed in a highly parallel manner by the GPUs. In addition, a thread hierarchy minimizing the divergence of the threads is deployed, and it can maximize the efficiency of the parallel execution. With the use of a large number of cores in the GPU to perform the simple computations simultaneously, our GPU-based LDPC decoder can obtain hundreds of times speedup compared with a serial CPU-based simulator and over 40 times speedup compared with an eight-thread CPU-based simulator.


I. INTRODUCTION
L OW-DENSITY parity-check (LDPC) codes were invented by Robert Gallager [1] but had been ignored for years until Mackay rediscovered them [2].They have attracted much attention recently because they can achieve excellent error correcting performance based on the belief propagation (BP) decoding algorithm.
However, the BP decoding algorithm requires intensive computations.For applications like optical communication [3], [4] which requires BERs down to 10 −15 , using CPU-based programs to simulate the LDPC decoder is impractical.Fortunately, the decoding algorithm possesses a high data-parallelism feature, i.e., the data used in the decoding process are manipulated in a very similar manner and can be processed separately from one another.Thus, practical decoders with low-latency and high-throughput can be implemented with dedicated hardware such as field programmable gate arrays (FPGAs) or application specific integrated circuits (ASICs) [5], [6], [7], [8], [9], [10], [11].However, high performance FPGAs and ASICs are very expensive and are non-affordable by most researchers.Such hardware solutions also cost a long time to develop.In addition, the hardware control and interconnection frame are always associated with a specific LDPC code.If one parameter of an LDPC code/decoder changes, the corresponding hardware design has to be changed accordingly, rendering the hardware-based solutions non-flexible and non-scalable.
Recently, graphics processing units (GPUs) used to process graphics only have been applied to support general purpose computations [12].In fact, GPUs are highly parallel structures with many processing units.
They support floating point arithmetics and can hence conduct computations with the same precision as CPUs.GPUs are particularly efficient in carrying out the same operations to a large amount of (different) Yue Zhao and Francis Lau are with the Department of Electronic and Information Engineering, The Hong Kong Polytechnic University.arXiv:1204.0334v2[cs.IT] 27 Jul 2012 data.Compared with modern CPUs, GPUs can also provide much higher data-parallelism and bandwidth.
Consequently, GPUs can provide a cheap, flexible and efficient solution of simulating an LDPC decoder.
Potentially, the simulation time can be reduced from months to weeks or days when GPUs, instead of CPUs, are used.In addition, the GPU programming codes can be re-used without much modification should more advanced GPUs be produced by manufacturers.
In [13], [14], a compressed parity-check matrix has been proposed to store the indices of the passing messages in a cyclic or quasi-cyclic LDPC code.Further, the matrix is stored in the constant cache memory on the GPU for fast access.The messages are stored in a compressed manner such that the global memory can be accessed in a coalesced way frequently.However, the coalesced memory access occurs only during the data-read process and is not always guaranteed due to a lack of data alignment.In [12], [15], [16], the sum-product LDPC decoder and the min-sum decoder have been implemented with GPUs.Moreover, by combining sixteen fixed-point 8-bit data to form one 128-bit data, the LDPC decoder in [12] decodes sixteen codewords simultaneously and achieves a high throughput.Although the method in [12] allows coalesced memory access in either the read or write process, coalesced memory access in both the read and write processes is yet to be achieved.Furthermore, the LDPC convolutional codes (LDPCCCs), first proposed in [17], have been shown to achieve a better error performance than the LDPC block code counterpart of similar decoding complexity.
There are many features of LDPCCC that make it suitable for real applications.First, the LDPCCC inherits the structure of the convolutional code, which allows continuous encoding and decoding of variablelength codes.Thus the transmission of codewords with varying code length is possible.Second, the LDPCCC adopts a pipelined decoding architecture -in the iterative decoding procedure, each iteration is processed by a separate processor and the procedure can be performed in parallel.So a high-throughput decoder architecture is possible.In [18], [19], the concepts and realization of highly parallelized decoder architectures have been presented and discussed.To the author's best knowledge, there is not any GPUbased implementation of the LDPCCC decoder yet.The reason may lie in the complexity structure of the LDPCCC compared to the LDPC block code, particularly the random time-varying LDPCCC.
As will be discussed in this paper, an LDPCCC derived from a well designed QC-LDPC code possesses not only the good BER performance, but also the regular structure that results in many advantages in practical implementations.Due to the structure inherited from the QC-LDPC code, the LDPCCC decoder enables an efficient and compact memory storage of the messages with a simple address controller.
In this paper, we develop flexible and highly parallel GPU-based decoders for the LDPC codes.We improve the efficiency by making (i) the threads of a warp follow the same execution path (except when deciding whether a bit is a "0" or a "1") and (ii) the memory accessed by a warp be of a certain size and be aligned.The results show that the decoders based on the GPUs achieve remarkable speed-up improvement -more than 100 times faster than the serial CPU-based decoder.
We also develop a GPU-based decoder for the LDPC convolutional codes.We propose a decoder architecture for LDPCCC derived from QC-LDPC block-code.By taking advantage of the homogeneous operations of the pipeline processors, we compress the index information of different processors into one lookup table.Combined with an efficient thread layout, the decoder is optimized in terms of thread execution and memory access.Simulation results show that compared with the serial CPU-based decoder, the GPU-based one can achieve as many as 200 times speed-up.The GPU-based decoder, moreover, outperforms a quad-core CPU-based decoder by almost 40 times in terms of simulation time.
The rest of the paper is organized as follows.Section II reviews the structure and decoding algorithm of the LDPC code.The same section also reviews the construction of LDPCCC based on QC-LDPC code as well as the decoding process for the LDPCCC.In Section III, the architecture of CUDA GPU and the CUDA programming model is introduced.Section IV describes the implementation of the LDPC decoder and LDPCCC decoder based on GPUs.Section V presents the simulation results of the LDPC decoder and LDPCCC decoder.The decoding times are compared when (i) a GPU is used, (ii) a quad-core CPU is used with a single thread, and (iii) a quad-core CPU is used with up to 8 threads.Finally, Section VI concludes the paper.

A. Structure of LDPC Codes and QC-LDPC Codes
A binary (N, K) LDPC code is a linear block code specified by a sparse M × N parity-check matrix H, where M = N − K.The code rate of such an LDPC code is R ≥ K/N = 1 − M/N .The equality holds when H is full rank.
The H matrix contains mostly 0 s and relatively a small number of 1 s.Such a sparsity structure is the key characteristic that guarantees good performance of LDPC codes.A regular LDPC code is a linear block code with H containing a constant number w c of 1's in each column and a constant number w r of 1's in each row.Moreover, w r and w c satisfy the equation w r = w c × N M .Otherwise the code is defined as an irregular LDPC code.Example 1.The parity-check matrix H in (1) shows an example of an irregular LDPC code.
A bipartite graph called Tanner graph [20] can be used to represent the codes and to visualize the message-passing algorithm.Figure 1 is the underlying Tanner graph of the H in (1).The N upper nodes are called the message nodes or the variable nodes and the M nodes in the lower part of Fig. 1 are called the check nodes.An edge in the Tanner graph represents the adjacency of the variable node i and the check node j.It corresponds to a nonzero (i, j)-th entry in the H matrix. QC-LDPC codes form a subclass of LDPC codes with the parity-check matrix consisting of circulant permutation matrices [21], [22].The parity-check matrix of a regular (J, L) QC-LDPC code is represented by where J denotes the number of block rows, L is the number of block columns, P is the identity matrix of size p × p, and P a j,l (1 ≤ j ≤ J; 1 ≤ l ≤ L) is a circulant matrix formed by shifting the columns of P cyclically to the right a j,l times with a j,l 's being non-negative integers less than p.The code rate R of H is lower bounded by R ≥ 1 − J/L.If one or more of the sub-matrix(matrices) is/are substituted by the zero matrix rendering non-uniform distributions of the check-node degrees or variable-node degrees, the QC-LDPC code becomes an irregular code.
Referring to the Tanner graph shown in Fig. 1, the variable nodes and the check nodes exchange soft messages iteratively based on the connections and according to a two-phase schedule.
Given a binary (N, K) LDPC code with a parity-check matrix H, we define C as the set of binary codewords c that satisfy the equation cH T = 0.At the transmitter side, a binary codeword c = (c 0 , c 1 , . . ., c N −1 ) is mapped into the sequence x = (x 0 , x 1 , . . ., x N −1 ) according to x n = 1 − 2c n .We assume that x is then transmitted over an additive white Gaussian noise (AWGN) channel and the received signal vector is then given by y = (y 0 , y 1 , . . ., y N −1 ) = x + g, where g = (g 0 , g 1 , . . ., g N −1 ) consists of independent Gaussian random variables with zero mean and variance σ 2 = N 0 /2.
Let µ n be the initial log-likelihood ratio (LLR) that the variable node n is a "0" to that it is a "1", i.e., Initially, µ n is calculated by µ n = (4/N 0 ) • y n = 2yn σ 2 [25].Define N (m) as the set of variable nodes that participate in check node m and M(n) as the set of check nodes connected to variable node n.At iteration i, let β (i) mn be the LLR messages passed from variable node n to check node m; α (i) mn be the LLR messages passed from check node m to variable node n; and β (i) n be the a posteriori LLR of variable node n.Then the standard BP algorithm can be described in Algorithm 1 [2], [26].
Note that the decoding algorithm consists of 4 main procedures: initialization, horizontal step, vertical step and making hard decisions.For each of these procedures, multiple threads can be used in executing the computations in parallel and all the threads will follow the same instructions with no divergence occurring, except when making hard decisions.

C. Structure of LDPC Convolutional Codes
A (time-varying) semi-infinite LDPC convolutional code can be represented by its parity check matrix in (3).where m s is referred to as the syndrome former memory of the parity-check matrix.Besides, the sub-matrices H i (t), i = 0, 1, ..., m s , are binary (c − b) × c matrices given by .
If H i (t) are full rank for all time instant t, the matrix H in (3) defines a rate R = b/c convolutional code ignoring the irregularity at the beginning.
Definition 1.A LDPC convolutional code is called a regular (m s , J, K)-LDPC convolutional code if the parity-check matrix H [0,∞] has exactly K ones in each row and J ones in each column starting from the where i , v i , ..., v i ) and H T [0,∞] is the syndrome-former (transposed parity-check) matrix of

D. Deriving LDPC Convolutional codes from QC-LDPC block codes
There are several methods to construct LDPC convolutional codes from LDPC block codes.One method is to derive time-varying LDPCCC by unwrapping randomly constructed LDPC block codes [17] and another is by unwrapping the QC-LDPC codes [27], [28].We now consider a construction method by unwrapping a class of QC-LDPC block code.
Suppose we have created a (J, L) QC-LDPC block code H QC with J block-rows and L block-columns.
The size of its circulant matrices is p×p.We can derive the parity-check matrix for a LDPC convolutional code using the following steps.
2) Divide H QC along the diagonal into two portions: the strictly upper-triangular portion QC and the lower-triangular portion H (L) QC as follows: 3) Unwrap the parity-check matrix of the block code to obtain the parity-check matrix of LPDCCC.
First paste the strictly upper-triangular portion below the lower-triangular portion.Then repeat the resulting diagonally-shaped matrix infinitely, i.e., .
The resulting time-varying LDPCCC has a period of T = Λ and the memory m s equals Λ − 1.The girth of the derived LPDCCC is at least as large as the girth of the QC-LDPC code [29].A convenient feature of this time-varying unwrapping is that a family of LDPC convolutional codes can be derived by choosing different circulant size p of the QC-LDPC block code.
It is first divided into 4×4 equally sized sub-blocks1 , i.e., Λ = 4. Then the parity-check matrix of LDPCCC is derived.The construction process is shown in Fig. 2.

E. Decoding Algorithm for LDPCCC
In H [0,∞] , two different variable nodes connected to the same check node cannot be distant from each other more than m s time units.This allows a decoding window that operates on a fixed number of nodes at one time.Since any two variable nodes that are at least m s + 1 units apart can be decoded independently, parallel implementation is feasible.The LDPCCC can therefore be decoded with pipelined BP decoding algorithm [17].Specifically, for a maximum iteration number of I, I independent processors will be employed working on different variable nodes corresponding to different time.In each processor, the variable nodes and the check nodes exchange soft messages iteratively based on the connections and according to a two-phase schedule.Then every processor will update the c variables which are leaving this processor.
The computations of the check-node updating and variable-node updating are based on the standard t , . . ., v is an AWGN with zero mean and variance Using the same notation as in Sect.II-B, the pipelined BP decoding algorithm applying to LDPCCC is illustrated in Algorithm 2. Same as the LDPC decoding algorithm, the LDPCCC decoding algorithm consists of 4 main procedures: initialization, horizontal step, vertical step and making hard decisions.
Moreover, for each of these procedures, multiple threads can be used in executing the computations in parallel and all the threads will follow the same instructions with no divergence occurring, except when making hard decisions.

III. GRAPHICS PROCESSING UNIT AND CUDA PROGRAMMING
A graphics processing unit (GPU) consists of multi-threaded, multi-core processors.GPUs follow the single-instruction multiple-data (SIMD) paradigm.That is to say, given a set of data (regarded as a stream), the same operation or function is applied to each element in the stream by different processing units in the GPUs simultaneously.Figure 4 shows a simplified architecture of the latest GPU device.It contains a number of multiprocessors called streaming multiprocessors (or SMs).Each SM contains a group of stream processors or cores and several types of memory including registers, on-chip memory, L2 cache and the most plentiful dynamic random-access memory (DRAM).The L1 cache is dedicated to each multiprocessor and the L2 cache is shared by all multiprocessors.Both caches are used to cache accesses to local or global memory.The on-chip memory has a small capacity (tens of KB) but it has a low latency [30].
In our work, the GPU used is a GTX460, which has 7 SMs and 768 MB global memory.Each SM contains 48 cores [31].Moreover, the 64 KB on-chip memory is configured as 48 KB shared memory and 16 KB L1 cache for each SM because the more shared memory is utilized, the better.CUDA (Compute Unified Device Architecture) is a parallel computing architecture developed by Nvidia.
In a CUDA program, computations are performed as a sequence of functions called parallel kernels.Each kernel is typically invoked on a massive number of threads.Threads are first grouped into thread blocks In an abstract level, the CUDA devices use different memory spaces, which have different characteristics.
These memory spaces includes global memory, local memory, shared memory, constant memory, texture memory, and registers.The global memory and texture memory are the most plentiful but have the largest access latency followed by constant memory, registers, and shared memory.
CUDA's hierarchy of threads map to a hierarchy of processors on the GPU.A GPU executes one or more kernel grids and a SM executes one or more thread blocks.In current GPUs with compute capability 2.x, the SM creates, manages, schedules, and executes threads in groups of 32 parallel threads called warps.A warp is the execution unit and executes one common instruction at a time.So full efficiency is realized when threads of a warp take the same execution path.
In CUDA programming, the first important consideration is the coalescing global memory accesses.
Global memory resides in the device memory and is accessed via 32-, 64-, or 128-byte memory transactions.These memory transactions must be naturally aligned (i.e. the first address is a multiple of their size).
When a warp executes an instruction that accesses the global memory, it coalesces the memory accesses of the threads within the warp into one or more of these memory transactions depending on the size of the word accessed by each thread and the distribution of the memory addresses across the threads.

A. GPU-based LDPC Decoder
We implement our decoders using the standard BP decoding algorithm.According to the CUDA programming model, the granularity of a thread execution and a coalesced memory access is a warp.
Full efficiency is realized when all threads in a warp take the same execution path and the coalesced memory access requirement is satisfied.Thus, we propose to decode Γ codewords simultaneously, where Γ is an integer multiple of a warp (i.e., multiple of 32).For each decoding cycle, Γ codewords will be input, decoded, and ouput together and in parallel.
Recall that an LDPC code can be represented by its parity-check matrix or a Tanner graph.A non-zero element in the parity-check matrix corresponds to an edge in the Tanner graph.
In the LDPC decoder, messages are bound to the edges in the Tanner graph (or the 1's in the parity-check matrix H).So we store the messages according to the positions of 1's.Besides, the channel messages corresponding to the variable nodes are required.To reuse the notation, we denote the data structure storing the messages between the variable nodes and the check nodes as H while the the data structure storing the channel messages as V.The difficulty of the CUDA memory arrangement lies on the fact that for practical LDPC codes with good performance, the positions of the 1's are scattered in the parity-check matrix.
First, in the BP decoding procedure, although there are two kinds of messages, namely, the variable-tocheck messages and the check-to-variable messages, at every step of the iteration, only one kind of message is needed to be stored, i.e., after the check-node updating step, only the check-to-variable messages α's are stored in the H and after the variable-node updating step, only the variable-to-check messages β's are stored in the H. Second, in our new decoder architecture, Γ (Γ is a multiple of a warp) codewords are decoded together and hence the messages of Γ codewords are also processed together.We number the distinct codewords as 0, 1, ..., Γ − 1 and we use the same notations for the messages as before, i.e., β mn (γ) is the message from variable node n to check node m corresponding to the γ-th codeword and α mn (γ) is the message from check node m to variable node n corresponding to the γ-th codeword.Since all the Γ codewords messages share the same Tanner graph, messages of the Γ distinct codewords corresponding to the same edge can be grouped into one package and stored linearly.Let p mn denote the package corresponding to the edge connecting variable node n and check node m.Then in package p mn , β mn (0), β mn (1), ..., β mn (Γ − 1) or α mn (0), α mn (1), ..., α mn (Γ − 1) are stored contiguously.This is shown in Figure 5. Different packages p mn 's are aligned linearly according to their corresponding positions in the parity-check matrix -row-by-row, and left to right for each row.That implies the messages associated to one check node are stored contiguously.
Remark.To be consistent with the use of memory locations in computer programming, all the indices of the data structures in this paper starts from 0.
The advantage of this arrangement is obvious.Since Γ is a multiple of 32, the memory segment for every package is naturally aligned when the data type belongs to one of the required data types (i.e., with variable node n word size of 1-, 2-, 4-, or 8-byte).In addition, the structure of the parity-check matrix H is shared by the Γ codewords.As these Γ data elements are processed together, they can be accessed by Γ contiguous threads and hence the global memory is always accessed in a coalesced way.We also ensure that the threads within a warp always follow the same execution path with no divergence occurring (except when making hard decisions on the received bits).Then both the memory access and the thread execution are optimal and efficient.
We also need to store the details of the parity-check matrix.The LU T c and LU T v lookup tables are stored in the constant or texture memory in the CUDA device so as to be cached to reduce the access time.
A separate thread is assigned to process each check node or each variable node in the updating kernel.
Hence, Γ threads can be assigned to process the data of Γ codewords simultaneously.So, a two dimensional thread hierarchy is launched.The first dimension is for identifying the different codewords while the second dimension is for processing different check nodes or variable nodes.The thread layout is illustrated in Fig. 6.For each thread block, we allocate Γ threads in the threadIdx.xdimension2 , and BL y threads in the threadIdx.ydimension.Each thread-block contains BL y × Γ threads, which should be within the thread-block size limit (1024 for the current device).The total number of thread-blocks is determined by the number of check nodes M or the number of variable nodes N .We denote BL y in the check-node updating kernel as BL y,cnu and the one in the variable-node updating kernel as BL y,vnu .Then the numbers of thread blocks are given by M/BL y,cnu and N/BL y,vnu , respectively.In Fig. 6, the threads marked by the vertical rectangular are processing the same codeword.
In the check-node updating kernel and the variable-node updating kernel, the forward-and-backward calculation is adopted as in [32].The shared memory is used to cache the involved data so as to avoid re-accessing the global memory.Due to the limited size of the shared memory, the size of the threadblock should not be too large.Consider a (J, L) QC-LDPC code.For each check node, there are 2L data elements to be stored.Denote the shared memory size by Z shared and the size of each data by Z data .
Consequently in the check-node updating kernel, the thread-block size, denoted by Ω cnu , is limited by In addition, With such a thread layout, the threads access the memory in a straightforward pattern.For example, for the check-node updating kernel, a two-dimensional thread hierarchy with a total size of M BLy,cnu × BL y,cnu × Γ is launched.During the memory access, every Γ threads are one-to-one mapped to Γ data in a message package.Hence, coalesced memory access is guaranteed.

B. GPU-based LDPCCC Decoder
The decoding algorithm and the pipelined LDPCCC decoder architecture have been introduced in Section II-E.The LDPCCCs studied in our work are derived from QC-LDPC codes as described in Section II-D.So our LDPCCC decoder is confined to the LDPCCCs with the parity-check matrix H [0,∞] of this kind of structure.
1) Data Structure: The LDPC convolutional codes are decoded continuously.We will thus refer to an as a code stream and v i , i = 0, 1, . . ., ∞ as a code frame or variable frame.A code stream is constrained with the parity-check matrix The parity-check matrix of the LDPCCC is shown in The H [0,∞] of the derived LDPCCC is a repetition of H base .Denotingthe number of edges in H base by In designing the LDPCCC decoder, the first thing to consider is the amount of memory required to store the messages.Like the LDPC decoder, we store the messages according to the edges in the parity-check matrix.Let I denote the number of iterations in the LDPCCC decoding.Then I processors are required in the pipelined decoder.Although the parity-check matrix of the LDPCCC is semi-infinite, the decoder only needs to allocate memory for I processors.Hence the total size of the memory required for storing the messages passing between the variable nodes and check nodes is I × E units.And the total size of the memory required for storing these channel messages is I × c.
Next, we will describe the hierarchical data structure for the LDPCCC decoder memory space.To reuse the notation, we use H to denote the memory space for the messages on the edges and V to denote the memory space for the channel messages.The H is a multi-dimensional array with two hierarchies.First, we divide the entire memory space into I groups corresponding to the I processors and we use the first hierarchy of H as the data structure for each group.That is H[i], i = 0, 1, ..., I −1 denote the data structure for the I processors, respectively.Second, recall that the parity-check matrix in Figure 7 is derived from H base which is divided into 16 non-zero sub-blocks and each sub-block has a size of (pJ/Λ) × (pL/Λ).
Thus in each group, H[i] is also divided into 16 sub-blocks, denoted by the second hierarchy of H,
On the other hand, the memory for the channel messages is simpler: V[i], i = 0, 1, ..., I • (m s + 1) − 1 will be allocated.Finally, to optimize the thread execution and memory access, Γ LDPC convolutional code streams are decoded simultaneously, where Γ is a multiple of a warp.Thus every Γ data are combined into one package and take up one memory unit.
An LDPCCC decoder uses the BP algorithm to update the check nodes and variable nodes.The BP decoding procedures are based on the parity-check matrix H [0,∞] .With the data structure to store the messages, the decoder also needs the structure information of H [0,∞] for understanding the connections between the check nodes and the variable nodes.This information can be used to calculate the index of the data being accessed during the updating.Due to the periodic property of the constructed LDPCCC, the structure of H base is shared by all the processors.We label the 16 sub-blocks in H base with the numbers 0, 1, . . ., 15.
In addition, in the decoder, the I check-node layers or I variable-node frames being updated simultaneously in the I processors are separated by an interval of m s + 1.Since H [0,∞] also has a period of T = m s + 1, at any time slot, the I processors require the same structure information in updating the check nodes or the variable nodes, as seen in Figure 7.The lookup tables used in check-node updating and variable-node updating are denoted as LU T c and LU T v , respectively.The two lookup tables will then store the labels of the sub-blocks in H base that are involved in the updating process.Besides, another lookup table LU T sub will be used to store the "shift numbers 4 " of the sub-matrices in each sub-block.
Example 4. The LU T c and LU T v for the LDPCCC in Figure 7 are and 2) Decoding Procedures: Based on the discussion in Section II-E, the detailed decoding procedures are as follows.
1) At time slot 0, the first code frame v 0 enters Processor 1.This means the corresponding memory space V[0] will be filled with the channel messages of v 0 .Then the channel messages will be propagated to the corresponding check nodes.Hence, referring to Fig. 7 and (18), H[0] [8] and H[0] [12] will be filled with the same channel messages V[0].
Next, the first check layer of v 0 , i.e., c 0 , will be updated based on the messages from v 0 , namely, the messages stored in H[0][0] (they are the only messages available to c 0 ).
2) At time slot 1, the second code frame v 1 enters Processor 1. Hence the memory space [13] and H[0][1] will be filled with the messages of v 1 .Then, the check layer c 1 are updated in a similar way as the check layer c 0 .However, both the messages from v 0 and v 1 , i.e., messages stored in H[0] [4] and H[0] [5], are used in the updating of c 1 based on the index information in LU T c [1].The procedure at time slot 1 is shown in Figure 8a.
The procedure goes on.When v 3 has been input and check layer c 3 has been updated, all the checkto-variable messages needed to update the variable layer v 0 are available.So v 0 will be updated with the channel messages in V[0] and the check-to-variable messages in and [12].Now, v 0 is at the end of Processor 1 and is about to be shifted to Processor 2. Instead of copying the memory from one location to another, all we need to do is to specify that the memory v 0 "belongs" to Processor 2.
3) At the next time slot, i.e., time slot 4 (time slot m s +1), the new code frame v 4 comes.The messages will be stored in v [4] and This insufficient updating of check nodes only occurs to the first m s code frames.After the updating of the check nodes, the code frame v 1 is at the end of Processor 1 and will be updated.There is no code frame arriving at the end of Processor 2 yet.Remark.In our GPU-based decoder, all the check nodes (variable nodes) needed to be updated in the I processors are processed in parallel by multiple threads.
5) Note that the LDPCCC matrix has a period of T = m s +1 (4 here).Hence, at time slot t ≥ I•(m s +1), v t enters the decoder and reuses the memory space of v τ where τ = t mod (I • (m s + 1)).
Furthermore, we let κ = t mod (m s + 1).Then the check layer c κ+(i−1)•(ms+1) in Processor i (i = 1, 2, . . ., I) will be updated followed by the updating of the code frame v κ+i•(ms+1)−ms .Moreover, the "oldest" code frame residing in the decoder -v t−I•(ms+1) -is about to leave the decoder and hard decisions will be made on it.
So the entire LDPCCC decoder possesses a circulant structure, as shown in Figure 9.The memory is not shifted except for the one associated with the code frame which is leaving the decoder.Instead, the processor are "moving" by changing the processor label of each code frame.Correspondingly, the "entrance" and "exit" are moving along the data structure.This circulant structure reduces the time for memory manipulation and simplifies the decoder.
3) Parallel Thread Hierarchy: As described in Sect.IV-B1, the memory associated with each entry in the H matrix is a message package containing Γ messages from Γ code streams.So there is a straightforward mapping between the thread hierarchy and the data structure.In the check-node-

C. CPU-based LDPC and LDPCCC Decoders
We implement both the serial CPU-based LDPC decoder and LDPCCC decoder using the C language.
As CPUs with multiple cores are very common nowadays, we further implement a multi-thread CPUbased LDPCCC decoder using OpenMP.OpenMP [33] is a portable, scalable programming interface for shared-memory parallel computers.It can be used to explicitly direct multi-threaded, shared memory parallelism.A straightforward application of the OpenMP is to parallize the intensive loop-based code with the #pragma omp parallel for directive.Then the executing threads will be automatically allocated to different cores on a multi-core CPU.
The horizontal step and the vertical step in Algorithm 2 involve intensive computing.On a single-core CPU, the updating of the different nodes are processed with a serial for loop.Since the updating of different nodes can be performed independent of one another, it is ideal to parallelize the for loop with the #pragma omp parallel for directive in the OpenMP execution on a multicore CPU.Hence, in our implementation, we issue multiple threads to both the updating of the check nodes (9) and the updating of the variable nodes (10) in the multi-thread CPU-based LDPCCC decoder.

A. The Experimental Environment
The

B. The Decoding Time Comparison
In order to optimize the speed and to minimize the data transfer between the CPU (host) and the GPU (device), we generate and process the data, including the codeword and the AWGN noise, directly on the GPU.After hard decisions have been made on the received bits, the decoded bits are transferred to the CPU which counts the number of error bits.Since the data transfer occurs only at the end of the iterative decoding process, the transfer time (overhead) is almost negligible compared with time spent in the whole decoding process.
In the following, we fix the number of decoding iterations and the simulation terminates after 100 block/frame errors are received.By recording the total number of blocks/frames decoded and the total time taken5 , we can compute the average time taken to decode one block/frame.

VI. CONCLUSION
In this paper, efficient decoders for LDPC codes and LDPC convolutional codes based on the GPU parallel architecture are implemented.By using efficient data structure and thread layout, the thread divergence is minimized and the memory can be accessed in a coalesced way.All decoders are flexible and scalable.First, they can decode different codes by changing the parameters.Hence, the programs need very little modification.Second, they should be to run on the latest or even future generations of GPUs which possess more hardware resources.For example, if there are more cores/memory in the GPU,

Fig. 3
Fig. 3 shows a decoder on the Tanner graph.It is based on the LDPCCC structure shown in Example 2. The code has a rate of R = 5/6 and a syndrome former memory of m s = 3.We refer the c incoming

Fig. 4 :
Fig. 4: Hardware architecture of a typical GPU.Each large rectangle denotes a streaming multiprocessor (SM) and each small square in a SM represents a stream processor or core.

Fig. 5 :
Fig. 5: Data Structure for an LDPC code.Each gray square denotes a non-zero entry in the parity-check matrix.Γ is a multiple of a warp (i.e., multiple of 32).
Two lookup tables denoted by LU T c and LU T v will be kept.LU T c is used in the check-node updating process and LU T v is used in the variablenode updating process.The two tables store the indices of the data accessed in the two updating processes and both are two-dimensional.The first dimension is to distinguish different check nodes, i.e., LU T c [m] is associated with the m-th check node or the m-th row.Each LU T c [m] records the indices of the messages related to the m-th check node.The two lookup tables are shared by all Γ codewords.

Example 3 .
Consider the parity-check matrix in(13).The corresponding data structure begins with the package p 01 , which is followed by p 03 , p 04 , p 07 , p 10 , p 11 , ..., p 30 , ..., p 36 .The subscripts of the nonzero entries indicate the sequences (or positions) of the associated data in the entire data structure, starting from 0. The LU T c and LU T v are shown in (14) and (15).It is seen that the size of LU T c can be reduced by only storing the first address of the data in each row, namely, LU T c [0] only store 0, LU T c [1] only store 4 and so on for all m = 0, 1, ..., M − 1. Particularly, for regular LDPC codes with a unique row weight d c , the indices in LU T c [m] for the m-th check node are from m • d c to m • d c + d c − 1.As for the LU T v , the indices are normally irregular and random.Hence a full-indexed lookup table is required for LU T v .

Figure 7 .
It is seen that the check nodes are grouped into layers.Each variable-node frame is connected to m s + 1 (4 here) check layers in the parity-check matrix.Let c denote the size of v i , i = 0, 1, ..., ∞ and c − b denote the size of each check layer.Thus the code rate is b/c.We will use the same notations as in Section II-D.The LDPCCC is derived from a (J, L) QC-LDPC base code H QC which has J × L sub-matrices and the size of each sub-matrix is p × p. H QC is first divided into Λ × Λ sub-blocks 3 (Λ = 4 in Figure7) and each sub-block contains several sub-matrices.We have c = L/Λ × p and c − b = J/Λ × p. Referring to Section II-D, we denote the unwrapped parity-check matrix of the QC-LDPC code as and H[1][12].Now there are two check layers to update, c 0 and c 4 .It is noted that c 4 are updated based on all the available messages in H[0][1], H[0][2], H[0][3], and H[1][0] while c 0 are updated based on the updated messages only in H[0][0].

4 )
At time slot I • (m s + 1) − 1, the entire memory space of V and H are filled with messages.v 0 and its associated messages are at the end of Processor I (as being labeled) while v i•(ms+1)−1 is the latest code frame input into Processor 1. Next, the check nodes in the I check layers of the I processors will be updated in parallel.After the updating of the check nodes, all the variable nodes which are leaving Processor i (i = 1, 2, ..., I) are updated.Specifically, the variable nodes v i•(ms+1)−1 , i = 1, 2, . . ., I are to be updated.Furthermore, v 0 is about to leave the decoder.Hard decision will be made based on the a posteriori LLR of v 0 .Then the memory space of v 0 , V[0],H[0][0], H[0][4], H[0][8] and H[0][12] are cleared for reuse.At the next time slot I • (m s + 1), the new code frame v I•(ms+1) comes in the decoder and these memory space will be filled with the messages of v I•(ms+1) .
updating kernel (or variable-updating-kernel), a two dimensional thread hierarchy of size I •(c−b)×Γ(or I • c × Γ) is launched, where (c − b) (orc) is mapped to the total number of check nodes (or variable nodes) being updated in I processors.The size of one of the dimensions (i.e., Γ) is mapped to the number of code streams.Like LDPC decoder, Γ will be configured as the threadIdx.xdimension and (c − b) (or c) will be the threadIdx.ydimension in the CUDA thread hierarchy.The Γ threads in the threadIdx.xdimension is contiguous and will access the Γ data in each message package for coalesced access.

2 )
LDPCCC decoders: We decode the LDPC convolutional codes A' to D' at a E b /N 0 of 3.1 dB with I = 20.First, we show the average decoding times for Code A' and Code C' when different numbers of threads are used in the CPU-based decoders.The results are shown in TableIV.The serial CPU-based decoder corresponds to the case with a single thread.We observe that the decoding time is approximately inversely proportional to the number of threads used -up to 4 threads.However, the time does not improve much when the number of threads increases to 6 or 8.The reason is as follows.The CPU being used has 4 cores, which can execute up to 4 tasks in fully parallel.Hence, compared with using a single thread, there is an almost 4 times improvement when 4 threads are used.As the number of threads increases beyond 4, however, all the threads cannot really be executed at the same time by the 4 cores.Consequently, further time improvement is small when more than 4 threads are used.Next, we compare the decoding times of the LDPCCC decoders when GPU-based and CPU-based decoders are used to decode Code A' to Code D'.For the CPU-based decoders, we consider the cases where a single thread and 8 threads are used, respectively.TableVshows the results.As explained above, limited by the number of cores (4 only) in the CPU, the CPU-based decoder can only improve the speed by about 4 times even when the number of threads increases from 1 to 8. We also observe that compared with the serial CPU-based decoder, the GPU-based LDPCCC decoder can achieve 170 to 200 times speedup improvement.Compared with the 8-thread CPU-based decoder, the GPU-based LDPCCC decoder can also accomplish 39 to 46 times speedup improvement.

Fig. 6 :
Fig. 6: Two dimensional thread layout of the check-node/variable-node updating kernel.

Fig. 7 :
Fig. 7: The periodic structure of the parity-check matrix of the LDPCCCs.
(a) Updating at time slot 1.(b) Updating at time slot 4.

Fig. 8 :Fig. 9 :
Fig. 8: Illustration of the procedures of a LPDCCC decoder.The horizontal line denotes the updating of the row.The vertical line denotes the updating of a column.

TABLE I :
CPU being used is an Intel Xeon containing 4 cores.Moreover, it can handle up to 8 threads at a time.The serial CPU-based decoders are developed using C and the multi-threaded CPU-based LDPCCC Simulation environments.

TABLE II :
Parity-check matrices of the QC-LDPC codes used in the LDPC decoder.They are also used to derive the LDPCCCs A' to D'. decoder is developed using OpenMP.Note that for the serial CPU-based decoders, only one of the 4 cores in the CPU will be utilized.The GPU used in this paper is a GTX460 containing 336 cores and the GPU-based decoders are developed using CUDA C. Furthermore, in our simulations, 32 codewords are decoded simultaneously in the GPU decoders, i.e., Γ = 32.Details of the CPU and GPU used in our simulations are presented in TableI.TableIIshows the characteristics of the QC-LDPC codes under test.For Code A to code D, J = 4 and L = 24 thus giving the same code rate of (24 − 4)/24 = 5/6.These codes are further used to derived regular LDPCCCs.In order to avoid confusion, we denote the derived LDPCCCs as Code A' to Code D'.It can be readily shown that the (3, 4, 24)-LDPCCCs A' to D' have the same code rate of 5/6.Remark.Note that although QC-LDPC codes are adopted in the simulation, the new GPU-based LDPC decoder is able to decode other LDPC codes like randomly-constructed regular or irregular codes.

TABLE III :
Decoding time for the GPU-based LDPC decoder and the serial CPU-based decoder at E b /N 0 =3.2 dB.30 iterations are used.C represents the total number of decoded codewords; T denotes the total simulation time and t is the average simulation time per codeword.
The GPU-based decoder and the serial CPU-based decoder are tested with 30 iterations at a E b /N 0 of 3.2 dB.TableIIIshows the number of transmitted codewords and the simulation times for different codes.We consider the average time for decoding one codeword for the serial CPU-based decoder, i.e., t CPU .We observe that t CPU increases from Code A to Code D due to an increasing number of edges in the codeword.Further, we consider the average time for decoding one codeword for the GPU-based decoder, i.e., t GPU .Similar to the serial CPU-based decoder, t GPU increases from Code A to Code D.Finally, we compare the simulation times of the serial CPU-based decoder and the GPU-based decoders by taking the ratio t CPU /t GPU .The results in TableIIIindicate that the GPU-based decoder accomplishes speedup improvements from 148 times to 162 times compared with the serial CPU-based decoder.

TABLE IV :
Average decoding time (ms) per code frame for the quad-core CPU-based decoder when different numbers of threads are used.