## 4 SpMV and Gauss-Seidel on Matrix-DSP
### Data Division Method  
The SpMV of the block and the Gauss-Seidel of the same color within the block are completely data independent and suitable for data parallelism. Considering that each row of the matrix has the same number of nonzero elements with no load imbalance, the matrix is partitioned by a one-dimensional static method. As shown at the bottom of Figures 6 and 7, the matrix \(K\) and \(Local\_idx\) are equally distributed to each DSP core that is used. In the SpMV, \(core\_row=block\_row/core\_n\), and in the Gauss  
Figure 7: Description of Gauss–Seidel data division and transmission.  
Seidel, \(core\_row=color\_row/core\_n\), where \(core\_n\) denotes the number of DSP cores used, \(core\_row\) denotes the number of matrix rows assigned to one DSP core, \(block\_row\) denotes the number of matrix rows in one block, and \(color\_row\) denotes the number of matrix rows of one color in one block. Specifically, row ID of \([0,core\_row-1]\) is assigned to the \(core0\), while row ID of \([core\_row,core\_row*2-1]\) is assigned to the \(core1\), and so on.  
However, the AM space has a capacity of only 768 KB, and it may not be possible to calculate \(core\_row\) matrix rows at once, so the \(core\_row\) needs to be further divided. We define the \(AM\_row\) as the maximum number of matrix rows that the AM space can calculate at one time, and we define the \(AM\_n\) as the number of loops that need to be calculated, which can be calculated as \(AM\_n=core\_row/AM\_row\). Specifically in the SpMV, the AM space needs to store the product vector \(Vector\_ax\) of size \(AM\_row\), the coefficient matrix vector \(Vector\_K\), and the index addressing vector \(Vector\_xi\) of size \(AM\_row\times nnz\_row\). The Gauss-Seidel additionally needs to store the iteration vector \(Vector\_x\), the right-hand term vector \(Vector\_F\), and the diagonal element vector \(Vector\_diag\) of size \(AM\_row\). Therefore, the SpMV needs to satisfy the \(AM\_row\times(nnz\_row\times 2+1)\times sizeof(double)\leq 768\) KB, and the Gauss-Seidel needs to satisfy the \(AM\_row\times(nnz\_row\times 2+4)\times sizeof(double)\leq 768\) KB. Theoretically, the higher the utilization of the AM memory, the lower the consumption of DMA transfers, and the higher the utilization of the bandwidth.  
In AM space, data are stored as vectors, where \(vec\_length\) denotes the vector length that an SIMD instruction can calculate, which can be computed by \(vec\_length=1024/sizeof(data\_type)\), and \(vec\_n\) denotes the number of vectors in the \(AM\_row\), which can be computed by \(vec\_n=AM\_row/vec\_length\). Therefore, the \(AM\_row\) also needs to satisfy the condition to be a multiple of \(vec\_length\).  
As shown in Figures 6 and 7, in each AM loop, the \(Vector\_K\) of length \(AM\_row\times nnz\_row\) is transferred from the DDR to the AM through the DMA_p2p, and the \(Vector\_xi\) of length \(AM\_row\times nnz\_row\) is transferred from the GSM to the AM through the DMA_SG. For the Gauss-Seidel, it is additionally necessary to transfer the \(Vector\_diag\), the \(Vector\_F\), and the \(Vector\_x\) of length \(AM\_row\) to the AM. After completing the data transfer, the SpMV and Gauss-Seidel are performed. Finally, the \(Vector\_ax\) and \(Vector\_x\) are returned to the DDR and GSM, respectively.