JP6981223B2 - Sparse matrix vector product calculation device and sparse matrix vector product calculation method - Google Patents
Sparse matrix vector product calculation device and sparse matrix vector product calculation method Download PDFInfo
- Publication number
- JP6981223B2 JP6981223B2 JP2017241098A JP2017241098A JP6981223B2 JP 6981223 B2 JP6981223 B2 JP 6981223B2 JP 2017241098 A JP2017241098 A JP 2017241098A JP 2017241098 A JP2017241098 A JP 2017241098A JP 6981223 B2 JP6981223 B2 JP 6981223B2
- Authority
- JP
- Japan
- Prior art keywords
- unit
- sparse matrix
- arithmetic
- vector
- calculation
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Landscapes
- Complex Calculations (AREA)
Description
本発明は、疎行列ベクトル積演算装置及び疎行列ベクトル積演算方法に関する。 The present invention relates to a sparse matrix vector product calculation device and a sparse matrix vector product calculation method.
製品の設計に関するシミュレーションを、シミュレーションツールを使って計算機上で行う技術としてCAE(Computer Aided Engineering)が知られている。例えば、CAEは、構造解析や流体解析を目的として行われる場合がある。 CAE (Computer Aided Engineering) is known as a technique for performing simulations related to product design on a computer using a simulation tool. For example, CAE may be performed for the purpose of structural analysis or fluid analysis.
CAEにおけるシミュレーションで用いられる計算手法の1つに、共役勾配法(CG法:Conjugate Gradient Method)がある。また、CG法の実行時間の大部分は、疎行列ベクトル積の演算(SpMV:Sparse matrix-vector multiplication)によって占められている。 One of the calculation methods used in the simulation in CAE is the conjugate gradient method (CG method). In addition, most of the execution time of the CG method is occupied by the operation of the sparse matrix vector product (SpMV: Sparse matrix-vector multiplication).
また、SpMVを高速化する技術として、メモリを共有する複数の処理装置が、CSR(Compressed Sparse Row format)形式からJAD(Jagged Diagonal format)形式に変換された疎行列のデータを用いて、SpMVを行う技術が知られている。 Further, as a technology for speeding up SpMV, a plurality of processing devices sharing a memory use sparse matrix data converted from a CSR (Compressed Sparse Row format) format to a JAD (Jagged Diagonal format) format to perform SpMV. The techniques to do are known.
ところで、CG法におけるSpMVの計算対象の疎行列のサイズは、非常に大きい場合がある。また、CG法ではSpMVが反復して行われるため、SpMVの反復のたびにCPUとメモリとの間で疎行列の転送が行われる場合がある。しかし、上記技術では、CPUとメモリとの間で疎行列の転送時間を短縮し、CG法を高速化することが困難な場合がある。 By the way, the size of the sparse matrix for which SpMV is calculated in the CG method may be very large. Further, in the CG method, since SpMV is repeatedly performed, a sparse matrix transfer may be performed between the CPU and the memory each time the SpMV is repeated. However, with the above technique, it may be difficult to shorten the transfer time of a sparse matrix between the CPU and the memory and to speed up the CG method.
一つの側面では、共役勾配法を高速化できる疎行列ベクトル積演算装置及び疎行列ベクトル積演算方法を提供することを目的とする。 In one aspect, it is an object of the present invention to provide a sparse matrix vector product calculation device and a sparse matrix vector product calculation method capable of speeding up the conjugate gradient method.
一つの態様において、疎行列ベクトル積演算装置は、共役勾配法の制御を行う共役勾配法制御装置から入力された演算データを記憶する。演算データは、疎行列との積を計算可能なベクトルと、列指向形式で圧縮された疎行列とを含む。疎行列ベクトル積演算装置は、演算データ記憶部からベクトル及び疎行列を読み込む読込部を有する。疎行列ベクトル積演算装置は、読込部によって読み込まれたベクトル及び疎行列を用いて疎行列ベクトル積の演算を実行する演算部を有する。疎行列ベクトル積演算装置は、演算部による演算の結果を演算データ記憶部に書き込む書込部を有する。疎行列ベクトル積演算装置は、ベクトルの要素である第1の要素と、第1の要素に対応する疎行列の非零の要素である第2の要素とを、複数の演算部のうちの第2の要素の行と予め対応付けられた演算部に割り当てる割当部を有する。演算部は、複数の書き込みポートと、複数の書き込みポートのそれぞれに対応した読み取りポートとを備え、部分和を疎行列の行と対応付けて記憶するマルチポートメモリと、第1の要素及び第2の要素が割り当てられた場合、第1の要素と第2の要素とを乗じた値を出力する複数の乗算器と、複数の書き込みポートのうちのいずれかの書き込みポート及び当該書き込みポートに対応した読み取りポートと接続され、乗算器によって出力された値と、読み取りポートから読み取った第2の要素の行に対応する部分和とを足した値を書き込みポートからマルチポートメモリに書き込む複数の加算器と、を有する。 In one embodiment, the sparse matrix vector product arithmetic unit stores the arithmetic data input from the conjugate gradient method controller that controls the conjugate gradient method. The operational data includes a vector that can calculate the product of a sparse matrix and a sparse matrix compressed in a columnar format. The sparse matrix vector product arithmetic unit has a reading unit that reads a vector and a sparse matrix from an arithmetic data storage unit. The sparse matrix vector product calculation device has a calculation unit that executes a calculation of the sparse matrix vector product using the vector read by the reading unit and the sparse matrix. The sparse matrix vector product arithmetic unit has a writing unit that writes the result of the operation by the arithmetic unit to the arithmetic data storage unit. The sparse matrix vector product operation device uses a first element, which is an element of a vector, and a second element, which is a non-zero element of a sparse matrix corresponding to the first element, as a second element of a plurality of arithmetic units. It has an allocation unit that is assigned to a calculation unit that is previously associated with a row of two elements. The arithmetic unit includes a plurality of write ports and a read port corresponding to each of the plurality of write ports, and stores the partial sum in association with the rows of a sparse matrix, a multiport memory, a first element, and a second. When the element of is assigned, it corresponds to a plurality of multipliers that output a value obtained by multiplying the first element and the second element, and one of a plurality of write ports and the write port. With multiple adders connected to the read port, the value output by the multiplier plus the partial sum corresponding to the row of the second element read from the read port is written from the write port to the multiport memory. , Have.
一つの態様によれば、共役勾配法を高速化できる。 According to one embodiment, the conjugate gradient method can be accelerated.
以下に、本願の開示する疎行列ベクトル積演算装置及び疎行列ベクトル積演算方法の実施例を図面に基づいて詳細に説明する。なお、この実施例によりこの発明が限定されるものではない。また、以下に示す各実施例は、矛盾を起こさない範囲で適宜組み合わせても良い。 Hereinafter, examples of the sparse matrix vector product calculation device and the sparse matrix vector product calculation method disclosed in the present application will be described in detail with reference to the drawings. The present invention is not limited to this embodiment. In addition, the examples shown below may be appropriately combined as long as they do not cause a contradiction.
実施例1における、後に説明するシミュレーション装置10は、CG法を使ったシミュレーションを実行する。CG法は、SpMVの反復演算により、一次方程式の解を求める手法である。
The
なお、以下において、行列、ベクトル及び配列の各インデックスは0から始まるものとする。また、行列Mの行インデックスがi、列インデックスがjである要素をMijと表記する場合がある。また、ベクトルvのインデックスがiである要素をviと表記する場合がある。また、配列array[]のインデックスがiである要素をarray[i]と表記する場合がある。 In the following, it is assumed that each index of the matrix, vector and array starts from 0. Further, an element in which the row index of the matrix M is i and the column index is j may be expressed as Mij. Also, it may be referred to as the index is i component of vector v v i. Further, an element in which the index of the array array [] is i may be expressed as array [i].
また、行列の行方向は、行インデックスが増加していく方向であり、右方向と同意であることとする。行列の列方向は、列インデックスが増加していく方向であり、下方向と同意であることとする。 Further, the row direction of the matrix is the direction in which the row index increases, which is the same as the right direction. It is assumed that the column direction of the matrix is the direction in which the column index increases and is in agreement with the downward direction.
ここで、例として、シミュレーション装置10がCG法を用いてn元の一次方程式の解を求める場合の処理の流れを説明する。このとき、シミュレーション装置10は、n×nの行列A及び要素数nのベクトルyから、行列Aとの積がベクトルyとなるようなベクトルxを求める。なお、以下において、行列Aのような行列を係数行列と表記し、ベクトルxのようなベクトルを解ベクトルと表記し、ベクトルyのようなベクトルを定数ベクトルと表記する場合がある。また、係数行列及び定数ベクトルは既知であるが、解ベクトルの真値は未知である。
Here, as an example, the flow of processing when the
まず、シミュレーション装置10は、ベクトルxに任意の初期値を設定し、行列Aとベクトルxの積の計算、すなわちSpMVを実行する。そして、シミュレーション装置10は、行列AとベクトルxのSpMVの結果として得られるベクトルy´とベクトルyとの残差から計算した勾配を基に、ベクトルy´がベクトルyに近付くようにベクトルxを更新する。
First, the
さらに、シミュレーション装置10は、行列Aと更新したベクトルxとのSpMVを実行する。その後、シミュレーション装置10は、SpMV及びベクトルxの更新を所定の条件が満たされるまで繰り返し、そのときのベクトルxを一次方程式の解又は近似解として得ることができる。
Further, the
CG法を使って製品の設計に関するシミュレーションを行う場合、係数行列は疎行列である場合がある。疎行列とは、行列の要素の多くが0の行列である。ここで、図1を用いて、疎行列のSpMVについて説明する。図1は、SpMVの一例を示す図である。図1に示すように、行列Aは疎行列である。このとき、ベクトルyの要素y0は(1)式で計算される。 When simulating product design using the CG method, the coefficient matrix may be a sparse matrix. A sparse matrix is a matrix in which many of the elements of the matrix are zero. Here, a sparse matrix SpMV will be described with reference to FIG. FIG. 1 is a diagram showing an example of SpMV. As shown in FIG. 1, the matrix A is a sparse matrix. At this time, the element y 0 of the vector y is calculated by the equation (1).
y0=a00×x0+0×x1+0×x2+a03×x3+0×x4 ・・・(1) y 0 = a 00 x x 0 + 0 x x 1 + 0 x x 2 + a 03 x x 3 + 0 x x 4 ... (1)
ここで、(1)式の第2項、第3項及び第5項は必ず0になる。このため、プロセッサは(1)式の計算を行う場合、ベクトルxの要素x1、x2及びx4を参照する必要はない。 Here, the second term, the third term, and the fifth term of the equation (1) are always 0. Therefore, the processor does not need to refer to the elements x 1 , x 2 and x 4 of the vector x when performing the calculation of the equation (1).
しかしながら、CPUやGPU(Graphics Processing Unit)等のプロセッサはメモリからのバースト転送によってデータを取得する。このため、例えばCPUが1回の転送サイクルでメモリから取得可能なデータは、連続する一定量のデータに限られる。 However, processors such as CPUs and GPUs (Graphics Processing Units) acquire data by burst transfer from memory. Therefore, for example, the data that the CPU can acquire from the memory in one transfer cycle is limited to a continuous fixed amount of data.
ここで、1回の転送サイクルで取得可能なデータがベクトルxの連続する3要素分であるCPUが(1)式の計算を行う場合を考える。また、このとき、ベクトルxの各要素はインデックスの順に連続してメモリに格納されているものとする。 Here, consider a case where the CPU, in which the data that can be acquired in one transfer cycle is three consecutive elements of the vector x, performs the calculation of the equation (1). Further, at this time, it is assumed that each element of the vector x is continuously stored in the memory in the order of the index.
この場合、CPUは、まず、a00×x0を計算するために、1回目の転送サイクルでx0を取得する。そして、CPUは、a03×x3を計算するために、2回目の転送サイクルでx3を取得する。このように、CPUは、(1)式を計算するために、少なくとも2回の転送サイクルを要する。 In this case, the CPU first acquires x 0 in the first transfer cycle in order to calculate a 00 × x 0. Then, CPU to compute the a 03 × x 3, to obtain the x 3 in the second transfer cycle. As described above, the CPU needs at least two transfer cycles to calculate the equation (1).
仮に、CPUがベクトルxから取得する要素がx0、x1のように連続したものであれば、CPUは1回の転送サイクルで必要な要素を取得することができることになる。逆に、取得するベクトルの要素に連続性がない場合、すなわちベクトルへのアクセスがランダムな場合は、必要な転送サイクルが増加し、その結果SpMVの演算速度が低下する。 If the elements acquired by the CPU from the vector x are continuous such as x 0 and x 1 , the CPU can acquire the necessary elements in one transfer cycle. On the contrary, when the elements of the vector to be acquired are not continuous, that is, when the access to the vector is random, the required transfer cycle increases, and as a result, the calculation speed of SpMV decreases.
さらに、シミュレーションで用いられる一次方程式の元の数は数百万から1千万を超える大きな数になる場合がある。そのような場合、係数行列や解ベクトルのサイズは非常に大きくなり、取得するベクトルの要素に連続性がないことによるSpMVの演算速度への影響も大きくなる。 In addition, the original number of linear equations used in the simulation can be large, ranging from millions to over 10 million. In such a case, the size of the coefficient matrix and the solution vector becomes very large, and the influence on the calculation speed of SpMV due to the lack of continuity in the elements of the acquired vector also becomes large.
また、疎行列は、圧縮した形式で表される場合がある。疎行列の圧縮形式の1つにCSR形式がある。図2は、CSR形式の一例を示す図である。図2に示すようにCSR形式の疎行列は、row_off、col、valの3つの配列で表される。 Also, the sparse matrix may be represented in a compressed form. One of the sparse matrix compression formats is the CSR format. FIG. 2 is a diagram showing an example of the CSR format. As shown in FIG. 2, a sparse matrix in the CSR format is represented by three arrays of row_off, col, and val.
配列valには、疎行列の0でない要素(非零要素)が、疎行列における行インデックスが小さい順に格納される。また、行インデックスが同じ非零要素については、列インデックスが小さいものが配列valにおいて先の順番になる。 Non-zero elements (non-zero elements) of a sparse matrix are stored in the array val in ascending order of row index in the sparse matrix. For non-zero elements with the same row index, the one with the smaller column index is in the first order in the array val.
また、配列colには、配列valに格納された各非零要素の対応する位置に、各非零要素の列インデックスが格納される。また、配列row_offには、配列colのインデックスであって、疎行列の各行の非零要素のうち最も列インデックスが小さい非零要素の列インデックスが格納されたインデックスが、当該非零要素の行インデックスが小さい順に格納される。 Further, in the array col, the column index of each non-zero element is stored at the corresponding position of each non-zero element stored in the array val. In the array row_off, the index that is the index of the array col and stores the column index of the non-zero element with the smallest column index among the non-zero elements of each row of the sparse matrix is the row index of the non-zero element. Are stored in ascending order.
ここで、例えば、図1の行列Aの要素a00の行インデックス及び列インデックスは、いずれも0である。また、配列valにおける要素a00のインデックスは0である。このため配列colのインデックス0の要素は0である。また、配列colのインデックスであって、疎行列の1行目(行インデックスが0の行)の非零要素のうち最も列インデックスが小さい非零要素であるa00の列インデックスが格納されたインデックスは0である。このため、配列row_offのインデックス0の要素は0である。
Here, for example, row index and column index of an element a 00 of the matrix A in FIG. 1 are both 0. Further, the index of the element a 00 in the array val is 0. Therefore, the element of
また、例えば、図1の行列Aの要素a30の行インデックス及び列インデックスは、それぞれ3及び0である。また、配列valにおける要素a30のインデックスは6である。このため配列colのインデックス6の要素は0である。また、配列colのインデックスであって、疎行列の4行目(行インデックスが3の行)の非零要素のうち最も列インデックスが小さい非零要素であるa30の列インデックスが格納されたインデックスは6である。このため、配列row_offのインデックス3の要素は6である。
Further, for example, row index and column index of an element a 30 of the matrix A in FIG. 1, respectively is 3 and 0. Also, index of the element a 30 in the array val is 6. Therefore, the element of the
図3の疑似コードを用いて、図1の行列AがCSR形式で表されている場合の、CPUによるSpMVの処理について説明する。図3は、SpMVの処理の一例を示す図である。図3のiは、ベクトルyの要素のインデックスに対応している。また、jは、ベクトルxのインデックスに対応している。また、x[]及びy[]は、それぞれベクトルx及びベクトルyを格納した配列である。 Using the pseudo code of FIG. 3, the processing of SpMV by the CPU when the matrix A of FIG. 1 is represented in the CSR format will be described. FIG. 3 is a diagram showing an example of SpMV processing. I in FIG. 3 corresponds to the index of the element of the vector y. Further, j corresponds to the index of the vector x. Further, x [] and y [] are arrays storing the vector x and the vector y, respectively.
例えば、図2に示すように、row_off[0]は0であり、row_off[1]は2である。また、col[0]は0であり、col[1]は3である。このため、図3の3行目及び4行目に示すように、i=0の場合、CPUは、x[0]及びx[3]を取得し、取得したx[]の各要素と対応するval[]の要素との積をy[0]に足していく。つまり、i=0の場合、CPUは、(1)式の計算を行うことになる。この場合、取得するx[]の要素が連続でないことの影響を受けて、SpMVの演算速度が低下する。 For example, as shown in FIG. 2, row_off [0] is 0 and row_off [1] is 2. Further, col [0] is 0 and col [1] is 3. Therefore, as shown in the third and fourth rows of FIG. 3, when i = 0, the CPU acquires x [0] and x [3] and corresponds to each element of the acquired x []. Add the product with the elements of val [] to y [0]. That is, when i = 0, the CPU performs the calculation of the equation (1). In this case, the calculation speed of SpMV is reduced due to the influence of the fact that the elements of x [] to be acquired are not continuous.
実施例1のSpMV装置10eは、CG法によるシミュレーションを行う際の疎行列の転送を最小限に抑えつつ、ベクトルへのアクセスが連続でないことによるSpMVの演算速度の低下を抑制することを目的とするものである。 The purpose of the SpMV apparatus 10e of the first embodiment is to suppress a decrease in the calculation speed of the SpMV due to non-continuous access to the vector while minimizing the transfer of a sparse matrix when performing a simulation by the CG method. It is something to do.
[機能ブロック]
次に、本実施例における疎行列ベクトル積演算装置10bを有するシミュレーション装置10の一例について、図4を用いて説明する。図4は、実施例1におけるシミュレーション装置の一例を示す図である。図4に示すように、本実施例におけるシミュレーション装置10は、共役勾配法制御装置10aと、疎行列ベクトル積演算装置10bとを有する。共役勾配法制御装置10aは、例えばCPUによって実現される。一方、疎行列ベクトル積演算装置10bは、例えばFPGA(Field Programmable Gate Array)によって実現される。
[Function block]
Next, an example of the
共役勾配法制御装置10aは、変換部11及び更新部12を有する。また、疎行列ベクトル積演算装置10bは、演算データ記憶部13、前処理制御部14、前処理部15及び加速部16を有する。
The conjugate gradient
共役勾配法制御装置10aは、CG法の制御を行う。具体的には、共役勾配法制御装置10aは、ユーザから入力された設定等を基にCG法の実行し、その際、疎行列ベクトル積演算装置10bにSpMVを実行させる。なお、SpMVにおける係数行列に対する前処理は、疎行列ベクトル積演算装置10bによって行われる。
The conjugate gradient
変換部11は、SpMVで用いられる疎行列である係数行列を列指向形式で圧縮する。例えば、変換部11は、無圧縮又はCSR等の行指向形式で表された係数行列を、列指向形式であるCSC(Compressed Sparse Column format)形式、ELL(Ellpack-Itpack generalized diagonal format)形式、JAD形式等に変換する。
The
図5は、ELL形式及びJAD形式の一例を示す図である。図5に示すように、変換部11は、行列AをELL形式に変換する場合、行列Aの非零要素を左側に詰めた行列を仮定し、仮定した行列の列単位で要素を取得し、配列に格納していく。また、行列AをJAD形式に変換する場合、変換部11は、仮定した行列の行を要素数の順でソートした上で、ELL形式と同様に要素を配列に格納していく。
FIG. 5 is a diagram showing an example of the ELL format and the JAD format. As shown in FIG. 5, when converting the matrix A to the ELL format, the
本実施例、変換部11は、行列AをJAD形式に変換し、変換した係数行列を、演算データとして疎行列ベクトル積演算装置10bの演算データ記憶部13に格納するものとする。また、このとき、変換部11は、係数行列とともに、初期値を設定した解ベクトルを演算データ記憶部13に格納し、疎行列ベクトル積演算装置10bにSpMVを実行させる。
In this embodiment, the
図6は、実施例1における演算データの一例を示す図である。図6に示すようにJAD形式の係数行列である演算データは、colind、value、jdptr及びpermの4つの配列で表される。 FIG. 6 is a diagram showing an example of arithmetic data in the first embodiment. As shown in FIG. 6, the arithmetic data which is a coefficient matrix in JAD format is represented by four arrays of colond, value, jdptr and perm.
ここで、変換部11によるJAD形式の各配列の作成方法の一例を説明する。まず、変換部11は、行列Aの行インデックスを、各行の要素数順に配列permに格納する。次に、変換部11は、配列permに格納した行インデックスの順序に従って行列Aの行をフォーカスしていき、各行の配列valueに格納されていない要素のうち、最も左側にある要素を配列valueに格納する。変換部11は、フォーカスしている行の配列valueに要素を格納した場合、又はフォーカスしている行に格納する要素が存在しない場合は次の行に進む。
Here, an example of a method of creating each array in JAD format by the
さらに、変換部11は、配列valueに格納した要素の列インデックスを配列colindの対応する位置に格納する。また、変換部11は、配列permに格納した行インデックスの順序が最初である行の要素の配列valueにおける格納先のインデックスを配列jdptrに格納していく。
Further, the
更新部12は、CG法の手順に従い、疎行列ベクトル積演算装置10bによるSpMVの結果を基に解ベクトルを更新する。ここで、疎行列ベクトル積演算装置10bは、SpMVの結果として得られる定数ベクトルの計算値を演算データ記憶部13に格納するものとする。また、更新部12は、更新した解ベクトルをさらに演算データ記憶部13に格納し、疎行列ベクトル積演算装置10bにSpMVを実行させることができる。
The
演算データ記憶部13は、共役勾配法の制御を行う共役勾配法制御装置10aから入力された演算データであって、係数行列との積を計算可能な解ベクトルと、列指向形式で圧縮された係数行列とを含む演算データを記憶する。なお、係数行列は疎行列である。例えば、演算データ記憶部13は、ELL形式又はJAD形式で圧縮された係数行列を記憶することができる。ただし、本実施例では、演算データ記憶部13は、JAD形式で圧縮された係数行列を記憶するものとする。
The arithmetic
前処理部15は、予め設定された演算データに対する複数の前処理のそれぞれに対応した処理部を備え、指定された前処理に対応する処理部を用いて前処理を実行する。前処理制御部14は、共役勾配法制御装置10aによって指定された前処理を、前処理部15に対して指定する。なお、共役勾配法制御装置10aへの前処理の指定は、ユーザによって行われてもよい。
The pre-processing unit 15 includes a processing unit corresponding to each of a plurality of pre-processing for preset calculation data, and executes pre-processing using the processing unit corresponding to the designated pre-processing. The
図7を用いて、前処理部15について説明する。図7は、実施例1における前処理部の一例を示す図である。図7に示すように、前処理部15は、対角スケーリング処理部151と、SSOR処理部152と、ILU処理部153と、AMG処理部154とを有する。
The pretreatment unit 15 will be described with reference to FIG. 7. FIG. 7 is a diagram showing an example of the pretreatment unit in the first embodiment. As shown in FIG. 7, the pretreatment unit 15 includes a diagonal scaling processing unit 151, an STOR processing unit 152, an
対角スケーリング処理部151は、対角スケーリングによる前処理を行う。SSOR処理部152は、SSOR(Symmetric Successive Over-relaxation)による前処理を行う。ILU処理部153は、ILU(Incomplete LU Factorization)(0)、ILU(1)等による前処理を行う。AMG処理部154は、AMG(Algebraic Multigrid)による前処理を行う。なお、前処理部15に備えられる処理部は、図7に示すものに限られない。前処理部15は、行列に対する前処理を行う処理部を複数有していればよい。
The diagonal scaling processing unit 151 performs preprocessing by diagonal scaling. The STOR processing unit 152 performs preprocessing by STOR (Symmetric Successive Over-relaxation). The
前処理部15に含まれる各処理部は、回路の接続先の変更等により、再構成可能に配置されている。例えば、前処理制御部14によって指定された前処理が対角スケーリングであった場合、前処理部15は、演算データ記憶部13と対角スケーリング処理部151との接続を有効にする。また、そのとき、前処理部15は、演算データ記憶部13と、SSOR処理部152、ILU処理部153及びAMG処理部154との接続を無効にする。
Each processing unit included in the pre-processing unit 15 is arranged so as to be reconfigurable by changing the connection destination of the circuit or the like. For example, when the pre-processing designated by the
加速部16は、SpMVを実行する。また、加速部16によるSpMVの実行結果は、演算データ記憶部13に記憶される。なお、演算の結果は、例えば、定数ベクトルの計算値である。また、加速部16は、CG法を高速化するように構成されている。
The
ここで、前処理部15は、加速部16によるSpMVが完了するたびに前処理を実行することができる。また、加速部16は、前処理部15による前処理が完了するたびにSpMVを実行する。これにより、疎行列ベクトル積演算装置10bは、前処理及びSpMVを反復して行うことができる。
Here, the pre-processing unit 15 can execute the pre-processing every time the SpMV by the
その際、共役勾配法制御装置10aは、所定のタイミングで疎行列ベクトル積演算装置10bによる反復処理に割り込みを行い、定数ベクトルの計算値を取得する。共役勾配法制御装置10aは、取得した計算値と真値との残差から計算した勾配を基に、演算データ記憶部13に記憶された解ベクトルを更新する。
At that time, the conjugate gradient
図8を用いて、加速部16について説明する。図8は、実施例1における加速部の一例を示す図である。図8に示すように、加速部16は、ロード部161、割当部162及び複数の演算部163を有する。また、加速部16は、演算データ記憶部13と接続されている。また、ロード部161は、読込部161a及び書込部161bを有する。
The
読込部161aは、演算データ記憶部13から解ベクトル及び係数行列を読み込む。割当部162は、演算部163のそれぞれに、演算に必要なデータを割り当てる。演算部163は、読込部161aによって読み込まれた解ベクトル及び係数行列を用いてSpMVを実行する。書込部161bは、演算部163による演算の結果を演算データ記憶部13に書き込む。
The reading unit 161a reads the solution vector and the coefficient matrix from the arithmetic
具体的には、割当部162は、解ベクトルの要素と、解ベクトルの要素に対応する係数行列の要素とを、複数の演算部163のうちの当該係数行列の要素の行と予め対応付けられた演算部163に割り当てる。演算部163は、解ベクトルの要素及び係数行列の要素が割り当てられた場合、割り当てられた解ベクトルの要素と係数行列の要素との積及び積の和を求める演算を実行する。
Specifically, the allocation unit 162 associates the elements of the solution vector and the elements of the coefficient matrix corresponding to the elements of the solution vector with the rows of the elements of the coefficient matrix in the plurality of
ここで、演算データが図6に示すものである場合の例を挙げて、加速部16の処理について説明する。演算データ記憶部13は、解ベクトルであるベクトルxの要素を記憶する。また、演算データ記憶部13は、係数行列である行列Aの要素を格納した配列valueと、行列Aの要素の列を特定する配列colindと、行列Aの要素の行を特定する配列jdptr及び配列permとを少なくとも記憶する。各配列の内容は、図6に示す通りである。
Here, the processing of the
なお、ベクトルxの要素は、第1の要素の一例である。また、行列Aの要素は、第2の要素の一例である。また、配列valueは、第1のデータの一例である。また、配列colindは、第2のデータの一例である。また、配列jdptr及び配列permは、第3のデータの一例である。 The element of the vector x is an example of the first element. Further, the element of the matrix A is an example of the second element. The array value is an example of the first data. The array colond is an example of the second data. The array jdptr and the array perm are examples of the third data.
また、演算データ記憶部13は、少なくとも演算部163の数と同数のポートを備えているものとする。また、演算部163のそれぞれには、行列Aの行のいずれかが予め対応付けられているものとする。なお、行列Aの各行は、定数ベクトルであるベクトルyの各要素に対応している。また、演算部163のそれぞれは、演算データ記憶部13に備えられたポートのいずれかに対応しているものとする。
Further, it is assumed that the arithmetic
図9の疑似コードを用いて、加速部16によるSpMVの処理について説明する。図9は、実施例1におけるSpMVの処理の一例を示す図である。図9のrho_maxは、配列jdptrのインデックスの最大値である。また、x[]及びy[]は、それぞれベクトルx及びベクトルyを格納した配列である。
The processing of SpMV by the
例えば、jが0かつiがjdptr[0]すなわち0である場合、図9に示すように、読込部161aは、まずjdptr[0]、perm[0]、value[0]及びcolind[0]を読み込む。さらに、colind[0]は0なので、読込部161aは、バースト転送により、x[0]、x[1]及びx[2]を読み込む。そして、割当部162は、jdptr[0]、perm[0]、value[0]、colind[0]及びx[0]を対応する演算部163に割り当てる。このとき、演算部163は、y[perm[0]]にvalue[0]*x[0]を足す。
For example, when j is 0 and i is jdptr [0], that is, 0, as shown in FIG. 9, the reading unit 161a first uses jdptr [0], perm [0], value [0], and colond [0]. Is read. Further, since colond [0] is 0, the reading unit 161a reads x [0], x [1], and x [2] by burst transfer. Then, the allocation unit 162 allocates jdptr [0], perm [0], value [0], colond [0], and x [0] to the corresponding
次に、jが0のままiが1になった場合、読込部161aは、jdptr[0]、perm[0]、value[1]及びcolind[1]を読み込む。また、colind[1]は0であり、x[0]は読み込み済みであるため、読込部161aは、ここではx[0]を読み込まない。そして、割当部162は、jdptr[0]、perm[0]、value[1]、colind[1]及びx[0]を対応する演算部163に割り当てる。ここで、perm[0]=3なので、演算部163は、y[3]にvalue[1]*x[0]を足す。
Next, when j remains 0 and i becomes 1, the reading unit 161a reads jdptr [0], perm [0], value [1], and colond [1]. Further, since collind [1] is 0 and x [0] has already been read, the reading unit 161a does not read x [0] here. Then, the allocation unit 162 allocates jdptr [0], perm [0], value [1], colond [1], and x [0] to the corresponding
さらに処理が進み、jが1かつiがjdptr[1]、すなわち5になった場合、読込部161aは、jdptr[1]、perm[1]、value[5]及びcolind[5]を読み込む。また、colind[5]は1であり、x[1]は読み込み済みであるため、読込部161aは、ここではx[1]を読み込まない。そして、割当部162は、jdptr[1]、perm[1]、value[5]、colind[5]及びx[1]を対応する演算部163に割り当てる。ここで、perm[1]=1なので、演算部163は、y[1]にvalue[5]*x[1]を足す。
When the processing further progresses and j becomes 1 and i becomes jdptr [1], that is, 5, the reading unit 161a reads jdptr [1], perm [1], value [5], and cold [5]. Further, since colond [5] is 1 and x [1] has already been read, the reading unit 161a does not read x [1] here. Then, the allocation unit 162 allocates jdptr [1], perm [1], value [5], colond [5], and x [1] to the corresponding
さらに処理が進み、jが2かつiがjdptr[2]、すなわち10になった場合、読込部161aは、jdptr[2]、perm[2]、value[10]及びcolind[10]を読み込む。また、colind[10]は2であり、x[2]は読み込み済みであるため、読込部161aは、ここではx[2]を読み込まない。そして、割当部162は、jdptr[2]、perm[2]、value[10]、colind[10]及びx[2]を対応する演算部163に割り当てる。ここで、perm[2]=2なので、演算部163は、y[2]にvalue[10]*x[2]を足す。
When the processing further progresses and j becomes 2 and i becomes jdptr [2], that is, 10, the reading unit 161a reads jdptr [2], perm [2], value [10], and cold [10]. Further, since colond [10] is 2 and x [2] has already been read, the reading unit 161a does not read x [2] here. Then, the allocation unit 162 allocates jdptr [2], perm [2], value [10], colond [10], and x [2] to the corresponding
さらに処理が進み、jが2かつiがjdptr[2]+1、すなわち11になった場合、読込部161aは、value[11]及びcolind[11]を読み込む。また、colind[11]は3であり、x[3]は読み込み済みでないため、読込部161aは、ここでバースト転送により、x[3]、x[4]及びx[5]を読み込む。そして、割当部162は、jdptr[2]、perm[2]、value[11]、colind[11]及びx[3]を対応する演算部163に割り当てる。ここで、perm[2]=2なので、このとき、演算部163は、y[2]にvalue[11]*x[3]を足す。
When the processing further progresses and j becomes 2 and i becomes jdptr [2] + 1, that is, 11, the reading unit 161a reads the value [11] and the colond [11]. Further, since the colond [11] is 3 and the x [3] has not been read, the reading unit 161a reads x [3], x [4], and x [5] by burst transfer here. Then, the allocation unit 162 allocates jdptr [2], perm [2], value [11], colond [11], and x [3] to the corresponding
このように、加速部16は、連続的に読み込んだx[]の要素を使ってSpMVの演算を行うことができるため、ランダムアクセスを緩和し、CG法を高速化することができる。なお、1回の転送サイクルで読み取り取得可能な連続したx[]の要素を3つまでとし、演算データが図2のようなCRS形式である場合、x[]の要素の読み取りには、少なくとも8回の転送サイクルが必要になる。一方、1回の転送サイクルで読み取り取得可能な連続したx[]の要素を3つまでとし、演算データが図6のようなJAD形式である場合、x[]の要素の読み取りに必要な転送サイクルは2回である。
In this way, since the
割当部162は、配列valueに格納された行列Aの要素と、配列colindによって特定される当該行列Aの要素の列に対応したベクトルxの要素とを、配列jdptr及び配列permとともに演算部163に割り当てる。これにより、演算部163は、行列Aの各要素の、JAD形式におけるソート前の行インデックスを特定することができる。
The allocation unit 162 puts the elements of the matrix A stored in the array value and the elements of the vector x corresponding to the columns of the elements of the matrix A specified by the array colon into the
図10を用いて、演算部163について説明する。図10は、実施例1における演算部の一例を示す図である。図10に示すように、演算部163は、マルチポートメモリ163a、複数の乗算器163b及び複数の乗算器163bのそれぞれと接続された複数の加算器163cを有する。また、演算部163は、マルチポートメモリ163a及び複数の加算器163cのそれぞれと接続された複数のパイプラインレジスタ163dを有する。
The
マルチポートメモリ163aは、複数の書き込みポートと、複数の書き込みポートのそれぞれに対応した読み取りポートとを備え、部分和を係数行列の行と対応付けて記憶する。
The
マルチポートメモリ163aは、書き込みポート1w、2w、3w及び4wを有する。また、マルチポートメモリ163aは、読み取りポート1r、2r、3r及び4rを有する。書き込みポート1w、2w、3w及び4wは、それぞれ読み取りポート1r、2r、3r及び4rと対応している。なお、乗算器163b、加算器163c、パイプラインレジスタ163d、書き込みポート及び読み取りポートの数は図10に示すものに限られない。
The
乗算器163bは、ベクトルxの要素と行列Aの要素とを乗じた値を出力する。加算器163cは、複数の書き込みポートのうちのいずれかの書き込みポート及び当該書き込みポートに対応した読み取りポートと接続されている。加算器163cは、乗算器163bによって出力された値と、読み取りポートから読み取った第2の要素の行に対応する部分和とを足した値を書き込みポートからマルチポートメモリ163aに書き込む。
The
演算部163は、複数の乗算器163b、加算器163c、書き込みポート及び読み取りポートの組み合わせを用いて、ベクトルyの部分和の計算を並列して実行することができる。このため、割当部162は、各演算部163にベクトルyの要素を担当要素として設定しておき、各担当要素の演算データを各演算部163に割り当てていくことができる。
The
[処理の流れ]
次に、本実施例における処理について、図11を用いて説明する。図11は、実施例1におけるCG法による処理の一例を示すフローチャートである。まず、共役勾配法制御装置10aの変換部11は、係数行列を圧縮し列指向形式に変換する(ステップS10)。また、変換部11は、変換した係数行列を疎行列ベクトル積演算装置10bの演算データ記憶部13に格納する。
[Processing flow]
Next, the process in this embodiment will be described with reference to FIG. FIG. 11 is a flowchart showing an example of the processing by the CG method in the first embodiment. First, the
次に、疎行列ベクトル積演算装置10bの前処理部15は、演算データ記憶部13から疎行列を取得し、前処理を実行する(ステップS20)。このとき、前処理部15は、前処理制御部14から指定された前処理を実行するために予め各処理部の再構成を行っておく。また、前処理部15は、前処理済みの演算データを演算データ記憶部13に格納する。
Next, the preprocessing unit 15 of the sparse matrix vector product
次に、加速部16は、SpMVを実行する(ステップS30)。なお、加速部16によるSpMVの実行については後に説明する。ここで、予め設定されたCG法の終了条件が充足されていない場合(ステップS40:No)、疎行列ベクトル積演算装置10bは、S20に戻って処理を繰り返す。一方、予め設定されたCG法の終了条件が充足されている場合(ステップS40:Yes)、共役勾配法制御装置10a及び疎行列ベクトル積演算装置10bは処理を終了する。例えば、終了条件終了条件は、所定の回数だけ反復が行われたことであってもよいし、定数ベクトルの残差が収束したことであってもよい。
Next, the
図12を用いて、疎行列ベクトル積演算装置10bによるSpMVの処理について説明する。図12は、実施例1におけるSpMVの処理の一例を示すフローチャートである。まず、加速部16の読込部161aは、演算データ記憶部13から演算データを読み込む(ステップS310)。演算データには、列指向形式で表された係数行列及び解ベクトルの各要素が含まれる。
The processing of SpMV by the sparse matrix vector product
次に、割当部162は、演算データを各演算部163に割り当てる(ステップS320)。そして、演算部163は、割り当てられた演算データを使って演算を実行する(ステップS330)。なお、演算部163による演算処理については後に説明する。
Next, the allocation unit 162 allocates the calculation data to each calculation unit 163 (step S320). Then, the
ここで、演算データ記憶部13に未読み込みの演算データがある場合(ステップS340:Yes)、読込部161aは、S310に戻って処理を繰り返す。一方、演算データ記憶部13に未読み込みの演算データがない場合(ステップS340:No)、疎行列ベクトル積演算装置10bは処理を終了する。
Here, when there is unread arithmetic data in the arithmetic data storage unit 13 (step S340: Yes), the reading unit 161a returns to S310 and repeats the process. On the other hand, when there is no unread arithmetic data in the arithmetic data storage unit 13 (step S340: No), the sparse matrix vector product
図13を用いて、演算部163による演算処理について説明する。図13は、実施例1における演算処理の一例を示すフローチャートである。ここで、係数行列はJAD形式で表されているものとする。まず、演算部163には、演算データとして、value[i]、x[colind[i]]、jdptr、permが入力される(ステップS331)。このとき、value[i]及びx[colind[i]]は乗算器163bへ入力される。また、jdptr及びpermは、パイプラインレジスタ163dへ入力される。
The arithmetic processing by the
ここで、加算器163cは、パイプラインレジスタ163dに入力されたjdptr及びpermに従って、マルチポートメモリ163aの読み取りポートのいずれかからy[perm[j]]を読み取る(ステップS332)。次に、加算器163cは、y[perm[j]]に、value[i]*x[colind[i]]を足しこむ(ステップS333)。そして、加算器163cは、パイプラインレジスタ163dに入力されたjdptr及びpermに従って、y[perm[j]]を読み取った読み取りポートに対応する書き込みポートからy[perm[j]]を書き込む(ステップS334)。
Here, the
[効果]
以上説明したように、本実施例における疎行列ベクトル積演算装置の演算データ記憶部は、共役勾配法の制御を行う共役勾配法制御装置から入力された演算データを記憶する。演算データは、疎行列との積を計算可能なベクトルと、列指向形式で圧縮された疎行列とを含む。疎行列ベクトル積演算装置は、演算データ記憶部からベクトル及び疎行列を読み込む。疎行列ベクトル積演算装置は、読み込まれたベクトル及び疎行列を用いて疎行列ベクトル積の演算を実行する。疎行列ベクトル積演算装置は、演算の結果を演算データ記憶部に書き込む。このように、疎行列ベクトル積演算装置は、共役勾配法制御装置から演算データ記憶部に係数行列が入力された後は、当該疎行列の装置間の転送を行うことなくSpMVを反復して行うことができる。このため、疎行列ベクトル積演算装置は、CG法を高速化することができる。
[effect]
As described above, the arithmetic data storage unit of the sparse matrix vector product arithmetic unit in this embodiment stores the arithmetic data input from the conjugate gradient method control apparatus that controls the conjugate gradient method. The operational data includes a vector that can calculate the product of a sparse matrix and a sparse matrix compressed in a columnar format. The sparse matrix vector product arithmetic unit reads the vector and the sparse matrix from the arithmetic data storage unit. The sparse matrix vector product operation device performs the operation of the sparse matrix vector product using the read vector and the sparse matrix. The sparse matrix vector product arithmetic unit writes the arithmetic result in the arithmetic data storage unit. As described above, after the coefficient matrix is input from the conjugate gradient method control device to the arithmetic data storage unit, the sparse matrix vector product operation device repeatedly performs SpMV without performing transfer between the devices of the sparse matrix. be able to. Therefore, the sparse matrix vector product arithmetic unit can speed up the CG method.
また、疎行列ベクトル積演算装置は、ベクトルの要素である第1の要素と、第1の要素に対応する疎行列の非零の要素である第2の要素とを、複数の演算部のうちの第2の要素の行と予め対応付けられた演算部に割り当てる。演算部は、第1の要素及び第2の要素が割り当てられた場合、第1の要素と第2の要素との積及び積の和を求める演算を実行する。これにより、疎行列ベクトル積演算装置は、列指向形式で表された係数行列を使ったSpMVを実行することができる。 Further, the sparse matrix vector product arithmetic unit has a first element which is an element of a vector and a second element which is a non-zero element of a sparse matrix corresponding to the first element among a plurality of arithmetic units. It is assigned to the arithmetic unit previously associated with the line of the second element of. When the first element and the second element are assigned, the calculation unit executes an operation for obtaining the product of the first element and the second element and the sum of the products. Thereby, the sparse matrix vector product arithmetic unit can execute SpMV using the coefficient matrix represented in the column-oriented format.
また、演算データ記憶部は、演算データとして、第2の要素を格納した第1のデータと、第2の要素の列を特定する第2のデータと、第2の要素の行を特定する第3のデータとを少なくとも記憶してもよい。疎行列ベクトル積演算装置は、第1のデータに格納された第2の要素と、第2のデータによって特定される当該第2の要素の列に対応したベクトルの要素とを、第3のデータとともに演算部に割り当てる。これにより、疎行列ベクトル積演算装置は、係数行列を配列として扱うことができる。 Further, the arithmetic data storage unit specifies, as arithmetic data, the first data storing the second element, the second data specifying the column of the second element, and the row of the second element. At least the data of 3 may be stored. The sparse matrix vector product arithmetic unit uses the second element stored in the first data and the vector element corresponding to the column of the second element specified by the second data as the third data. And assign it to the arithmetic unit. As a result, the sparse matrix vector product arithmetic unit can handle the coefficient matrix as an array.
演算部のマルチポートメモリは、複数の書き込みポートと、複数の書き込みポートのそれぞれに対応した読み取りポートとを備え、部分和を疎行列の行と対応付けて記憶する。複数の乗算器は、第1の要素と第2の要素とを乗じた値を出力する。複数の加算器は、複数の書き込みポートのうちのいずれかの書き込みポート及び当該書き込みポートに対応した読み取りポートと接続され、乗算器によって出力された値と、読み取りポートから読み取った第2の要素の行に対応する部分和とを足した値を書き込みポートからマルチポートメモリに書き込む。これにより、疎行列ベクトル積演算装置は、各演算部の内部でさらに並列計算を行うことができる。 The multi-port memory of the arithmetic unit includes a plurality of write ports and read ports corresponding to each of the plurality of write ports, and stores the partial sum in association with the rows of a sparse matrix. The plurality of multipliers output a value obtained by multiplying the first element and the second element. The adder is connected to one of the write ports and the read port corresponding to that write port, the value output by the multiplier and the second element read from the read port. Write the value obtained by adding the partial sum corresponding to the line from the write port to the multiport memory. As a result, the sparse matrix vector product arithmetic unit can further perform parallel calculation inside each arithmetic unit.
演算データ記憶部は、少なくとも演算部の数と同数のポートを備えていてもよい。これにより、疎行列ベクトル積演算装置は、演算部ごとの演算データの並列した読み取り、及びSpMVの並列処理を行うことができる。 The arithmetic data storage unit may have at least the same number of ports as the number of arithmetic units. As a result, the sparse matrix vector product arithmetic unit can read the arithmetic data in parallel for each arithmetic unit and perform parallel processing of SpMV.
演算データ記憶部は、ELL形式又はJAD形式で圧縮された疎行列を記憶してもよい。これにより、疎行列ベクトル積演算装置は、列指向形式で表された係数行列を得ることができる。 The arithmetic data storage unit may store a sparse matrix compressed in ELL format or JAD format. As a result, the sparse matrix vector product arithmetic unit can obtain a coefficient matrix represented in a column-oriented format.
前処理部は、予め設定された演算データに対する複数の前処理のそれぞれに対応した処理部を備え、指定された前処理に対応する処理部を用いて前処理を実行してもよい。前処理制御部は、共役勾配法制御装置によって指定された前処理を、前処理部に対して指定する。これにより、ユーザが共役勾配法制御装置に対して指定した前処理を、疎行列ベクトル積演算装置に実行させることができる。 The pre-processing unit may include a processing unit corresponding to each of a plurality of pre-processing for preset arithmetic data, and may execute the pre-processing using the processing unit corresponding to the designated pre-processing. The pre-processing control unit designates the pre-processing specified by the conjugate gradient method control device for the pre-processing unit. As a result, the sparse matrix vector product arithmetic unit can be made to execute the preprocessing specified by the user for the conjugate gradient method controller.
前処理部は、演算部による疎行列ベクトル積の演算が完了するたびに前処理を実行してもよい。演算部は、前処理部による前処理が完了するたびに疎行列ベクトル積の演算を実行する。これにより、疎行列ベクトル積演算装置は、演算データの装置間での転送をともなうことなく、SpMVの反復を行うことができる。 The preprocessing unit may execute preprocessing each time the operation of the sparse matrix vector product by the arithmetic unit is completed. The arithmetic unit executes a sparse matrix vector product operation each time the preprocessing by the preprocessing unit is completed. As a result, the sparse matrix vector product arithmetic unit can repeat SpMV without transferring the arithmetic data between the apparatus.
[システム]
また、各実施例において説明した各処理のうち、自動的に行われるものとして説明した処理の一部を手動的に行うこともできる。あるいは、手動的に行われるものとして説明した処理の全部又は一部を公知の方法で自動的に行うこともできる。この他、上記文書中や図面中で示した処理手順、制御手順、具体的名称、各種のデータやパラメータを含む情報については、特記する場合を除いて任意に変更することができる。
[system]
Further, it is also possible to manually perform a part of the processes described as being automatically performed among the processes described in each embodiment. Alternatively, all or part of the process described as being performed manually can be automatically performed by a known method. In addition, the processing procedure, control procedure, specific name, and information including various data and parameters shown in the above document and drawings can be arbitrarily changed unless otherwise specified.
また、図示した各装置の各構成要素は機能概念的なものであり、必ずしも物理的に図示の如く構成されていることを要しない。すなわち、各装置の分散や統合の具体的形態は図示のものに限られない。つまり、その全部又は一部を、各種の負荷や使用状況などに応じて、任意の単位で機能的又は物理的に分散・統合して構成することができる。例えば、図4に示す前処理部15と加速部16とを統合してもよい。さらに、各装置にて行われる各処理機能は、その全部又は任意の一部が、所定のプロセッサ(CPU、GPU,FPGA等)及び当該プロセッサにて解析実行されるプログラムにて実現され、あるいは、ワイヤードロジックによるハードウェアとして実現され得る。
Further, each component of each of the illustrated devices is a functional concept, and does not necessarily have to be physically configured as shown in the figure. That is, the specific form of distribution or integration of each device is not limited to the one shown in the figure. That is, all or a part thereof can be functionally or physically distributed / integrated in any unit according to various loads, usage conditions, and the like. For example, the pretreatment unit 15 and the
[ハードウェア構成]
図14は、ハードウェア構成例を示す図である。図14に示すように、シミュレーション装置10は、通信インタフェース50a、HDD(Hard Disk Drive)50b、メモリ50c、CPU10d及びFPGA50eを有する。
[Hardware configuration]
FIG. 14 is a diagram showing a hardware configuration example. As shown in FIG. 14, the
通信インタフェース50aは、他の装置の通信を制御するネットワークインタフェースカードなどである。HDD50bは、プログラムやデータなどを記憶する記憶装置の一例である。メモリ50cの一例としては、SDRAM(Synchronous Dynamic Random Access Memory)等のRAM(Random Access Memory)、ROM(Read Only Memory)、フラッシュメモリ等が挙げられる。CPU50dは、共役勾配法制御装置10aとして機能する。また、FPGA50eは、疎行列ベクトル積演算装置10bとして機能する。
The
10 シミュレーション装置
10a 共役勾配法制御装置
10b 疎行列ベクトル積演算装置
11 変換部
12 更新部
13 演算データ記憶部
14 前処理制御部
15 前処理部
16 加速部
161 ロード部
161a 読込部
161b 書込部
162 割当部
163 演算部
163a マルチポートメモリ
163b 乗算器
163c 加算器
163d パイプラインレジスタ
10
Claims (7)
前記演算データ記憶部から前記ベクトル及び前記疎行列を読み込む読込部と、
前記読込部によって読み込まれた前記ベクトル及び前記疎行列を用いて疎行列ベクトル積の演算を実行する演算部と、
前記演算部による演算の結果を前記演算データ記憶部に書き込む書込部と、
前記ベクトルの要素である第1の要素と、前記第1の要素に対応する前記疎行列の非零の要素である第2の要素とを、複数の前記演算部のうちの前記第2の要素の行と予め対応付けられた演算部に割り当てる割当部とを有し、
前記演算部は、
複数の書き込みポートと、前記複数の書き込みポートのそれぞれに対応した読み取りポートとを備え、部分和を前記疎行列の行と対応付けて記憶するマルチポートメモリと、
前記第1の要素及び前記第2の要素が割り当てられた場合、前記第1の要素と前記第2の要素とを乗じた値を出力する複数の乗算器と、
前記複数の書き込みポートのうちのいずれかの書き込みポート及び当該書き込みポートに対応した読み取りポートと接続され、前記乗算器によって出力された値と、前記読み取りポートから読み取った前記第2の要素の行に対応する部分和とを足した値を前記書き込みポートから前記マルチポートメモリに書き込む複数の加算器と、
を有することを特徴とする疎行列ベクトル積演算装置。 Arithmetic data input from a conjugate gradient method controller that controls the conjugate gradient method, including a vector that can calculate the product of a sparse matrix and the sparse matrix compressed in a column-oriented format. Arithmetic data storage unit to store and
A reading unit that reads the vector and the sparse matrix from the arithmetic data storage unit,
An arithmetic unit that executes an operation of a sparse matrix vector product using the vector read by the reading unit and the sparse matrix.
A writing unit that writes the result of the calculation by the calculation unit to the calculation data storage unit, and a writing unit.
The first element, which is an element of the vector, and the second element, which is a non-zero element of the sparse matrix corresponding to the first element, are combined with the second element of the plurality of arithmetic units. It has a line of and an allocation unit to be assigned to the arithmetic unit associated in advance.
The calculation unit
A multi-port memory having a plurality of write ports and a read port corresponding to each of the plurality of write ports and storing the partial sum in association with the rows of the sparse matrix.
When the first element and the second element are assigned, a plurality of multipliers that output a value obtained by multiplying the first element and the second element, and a plurality of multipliers.
The value output by the multiplier and the row of the second element read from the read port connected to any one of the plurality of write ports and the read port corresponding to the write port. A plurality of adders that write the sum of the corresponding partial sums from the write port to the multiport memory, and
A sparse matrix vector product arithmetic unit characterized by having.
前記割当部は、前記第1のデータに格納された前記第2の要素と、前記第2のデータによって特定される当該第2の要素の列に対応した前記ベクトルの要素とを、前記第3のデータとともに前記演算部に割り当てることを特徴とする請求項1に記載の疎行列ベクトル積演算装置。 As the calculation data, the calculation data storage unit stores the first data in which the second element is stored, the second data for specifying the column of the second element, and the row of the second element. At least memorize the third data to be identified and
The allocation unit uses the second element stored in the first data and the element of the vector corresponding to the column of the second element specified by the second data as the third element. The sparse matrix vector product calculation device according to claim 1 , wherein the data is assigned to the calculation unit together with the data of the above.
前記共役勾配法制御装置によって指定された前処理を、前記前処理部に対して指定する前処理制御部と、
をさらに有することを特徴とする請求項1から4のいずれか1項に記載の疎行列ベクトル積演算装置。 A pre-processing unit that has a processing unit corresponding to each of a plurality of pre-processing for the arithmetic data set in advance and executes pre-processing using the processing unit corresponding to the specified pre-processing, and a pre-processing unit.
A pre-processing control unit that designates the pre-processing specified by the conjugate gradient method control device for the pre-processing unit,
The sparse matrix vector product arithmetic unit according to any one of claims 1 to 4, further comprising.
前記演算部は、前記前処理部による前処理が完了するたびに疎行列ベクトル積の演算を実行することを特徴とする請求項5に記載の疎行列ベクトル積演算装置。 The preprocessing unit executes preprocessing each time the calculation of the sparse matrix vector product by the calculation unit is completed.
The sparse matrix vector product arithmetic unit according to claim 5 , wherein the arithmetic unit executes an operation of a sparse matrix vector product each time the preprocessing by the preprocessing unit is completed.
前記演算データ記憶部から前記ベクトル及び前記疎行列を読み込み、
前記ベクトルの要素である第1の要素と、前記第1の要素に対応する前記疎行列の非零の要素である第2の要素とを、複数の演算部のうちの前記第2の要素の行と予め対応付けられた演算部に割り当て、
前記第1の要素及び前記第2の要素が割り当てられた演算部に、前記読み込む処理によって読み込まれた前記ベクトル及び前記疎行列を用いて疎行列ベクトル積の演算を実行させ、
演算の結果を前記演算データ記憶部に書き込む
処理を実行し、
前記演算を実行させる処理は、
複数の乗算器に、前記第1の要素と前記第2の要素とを乗じた値を出力させ、
部分和を前記疎行列の行と対応付けて記憶するマルチポートメモリの複数の書き込みポートのうちいずれかの書き込みポート及び当該書き込みポートに対応した前記マルチポートメモリの読み取りポートと接続された複数の加算器に、前記乗算器によって出力された値と、前記読み取りポートから読み取った前記第2の要素の行に対応する部分和とを足した値を前記書き込みポートから前記マルチポートメモリに書き込ませる
ことを特徴とする疎行列ベクトル積演算方法。 Arithmetic data input from a conjugate gradient method controller that controls the conjugate gradient method, including a vector that can calculate the product of a sparse matrix and the sparse matrix compressed in a column-oriented format. A sparse matrix vector product arithmetic unit having an arithmetic data storage unit to store
The vector and the sparse matrix are read from the arithmetic data storage unit, and the vector and the sparse matrix are read.
The first element, which is an element of the vector, and the second element, which is a non-zero element of the sparse matrix corresponding to the first element, are combined with the second element of the plurality of arithmetic units. Assign to the arithmetic unit associated with the line in advance,
The arithmetic unit to which the first element and the second element are assigned is made to execute the operation of the sparse matrix vector product using the vector and the sparse matrix read by the reading process.
Run the process of writing the result of arithmetic in the arithmetic data storage unit,
The process of executing the above operation is
A plurality of multipliers are made to output a value obtained by multiplying the first element and the second element.
Multiple additions connected to one of the write ports of the multiport memory that stores the partial sum in association with the rows of the sparse matrix and the read port of the multiport memory corresponding to the write port. The device is made to write the value output by the multiplier and the partial sum corresponding to the row of the second element read from the read port to the multiport memory from the write port. A characteristic sparse matrix vector product calculation method.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2017241098A JP6981223B2 (en) | 2017-12-15 | 2017-12-15 | Sparse matrix vector product calculation device and sparse matrix vector product calculation method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2017241098A JP6981223B2 (en) | 2017-12-15 | 2017-12-15 | Sparse matrix vector product calculation device and sparse matrix vector product calculation method |
Publications (2)
Publication Number | Publication Date |
---|---|
JP2019109626A JP2019109626A (en) | 2019-07-04 |
JP6981223B2 true JP6981223B2 (en) | 2021-12-15 |
Family
ID=67179785
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2017241098A Active JP6981223B2 (en) | 2017-12-15 | 2017-12-15 | Sparse matrix vector product calculation device and sparse matrix vector product calculation method |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP6981223B2 (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111079082B (en) * | 2019-12-20 | 2023-03-10 | 支付宝(杭州)信息技术有限公司 | Method and system for improving calculation rate related to sparse matrix |
Family Cites Families (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH0752748B2 (en) * | 1989-12-14 | 1995-06-05 | 株式会社グラフィカ | 3D device simulation device |
JP3697992B2 (en) * | 2000-01-25 | 2005-09-21 | 日本電気株式会社 | Matrix vector product operation system, matrix storage system used therefor, and method thereof |
JP3865247B2 (en) * | 2003-10-03 | 2007-01-10 | 日本電気株式会社 | Simultaneous linear equation iterative solution calculator and simultaneous linear equation iterative solution calculation method |
JP2010122850A (en) * | 2008-11-19 | 2010-06-03 | Muroran Institute Of Technology | Device and method for calculating matrix equation |
JP6550465B2 (en) * | 2015-08-20 | 2019-07-24 | 株式会社日立製作所 | Information processing circuit |
WO2017154946A1 (en) * | 2016-03-09 | 2017-09-14 | 日本電気株式会社 | Information processing device, information processing method, data structure, and program |
-
2017
- 2017-12-15 JP JP2017241098A patent/JP6981223B2/en active Active
Also Published As
Publication number | Publication date |
---|---|
JP2019109626A (en) | 2019-07-04 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP7374236B2 (en) | accelerated math engine | |
CN111465924B (en) | System and method for converting matrix input into vectorized input for matrix processor | |
CN111183452A (en) | Image pre-processing for generalized image processing | |
JP2020533691A (en) | Efficient direct convolution using SIMD instructions | |
Kulkarni et al. | Systolic processing and an implementation for signal and image processing | |
US10810281B2 (en) | Outer product multipler system and method | |
EP3093757B1 (en) | Multi-dimensional sliding window operation for a vector processor | |
US9244886B1 (en) | Minimum resource fast fourier transform | |
EP4095719A1 (en) | Sparse matrix multiplication in hardware | |
JP6981223B2 (en) | Sparse matrix vector product calculation device and sparse matrix vector product calculation method | |
US11409840B2 (en) | Dynamically adaptable arrays for vector and matrix operations | |
JP2023070746A (en) | Information processing program, information processing apparatus, and information processing method | |
US10282899B2 (en) | Systems, methods and, media for simulating deformations of nonlinear elastic bodies | |
JP7427001B2 (en) | Tiling algorithm for matrix math instruction set | |
Kapusta et al. | Acceleration of image reconstruction in 3D Electrical Capacitance Tomography in heterogeneous, multi-GPU system using sparse matrix computations and Finite Element Method | |
Chen et al. | Sparsity-oriented sparse solver design for circuit simulation | |
Sato et al. | GPU implementation of an incomplete Cholesky conjugate gradient solver for a FEM-generated system using full kernel consolidation | |
US8819086B2 (en) | Naming methodologies for a hierarchical system | |
Gupta | Implementation of the Deflated Preconditioned Conjugate Gradient Method for Bubbly Flow on the Graphical Processing Unit (GPU) | |
Basha | Fast Fourier transform on a 3D FPGA | |
Liu et al. | FPGA implementation of a 2-D discrete cosine transforms algorithm using systemC | |
Wessels | Benchmarking Dataflow for FPGA | |
Park et al. | Structural optimization of mechanical components using radial basis function and CAD-CAE integration approach |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20200901 |
|
A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20210729 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20210817 |
|
A711 | Notification of change in applicant |
Free format text: JAPANESE INTERMEDIATE CODE: A712 Effective date: 20210824 |
|
A521 | Written amendment |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20211006 |
|
TRDD | Decision of grant or rejection written | ||
A01 | Written decision to grant a patent or to grant a registration (utility model) |
Free format text: JAPANESE INTERMEDIATE CODE: A01 Effective date: 20211019 |
|
A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20211101 |
|
R150 | Certificate of patent or registration of utility model |
Ref document number: 6981223 Country of ref document: JP Free format text: JAPANESE INTERMEDIATE CODE: R150 |