Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
JP6984762B2 - Arithmetic processing unit and control method of arithmetic processing unit - Google Patents
[go: Go Back, main page]

JP6984762B2 - Arithmetic processing unit and control method of arithmetic processing unit - Google Patents

Arithmetic processing unit and control method of arithmetic processing unit Download PDF

Info

Publication number
JP6984762B2
JP6984762B2 JP2020551748A JP2020551748A JP6984762B2 JP 6984762 B2 JP6984762 B2 JP 6984762B2 JP 2020551748 A JP2020551748 A JP 2020551748A JP 2020551748 A JP2020551748 A JP 2020551748A JP 6984762 B2 JP6984762 B2 JP 6984762B2
Authority
JP
Japan
Prior art keywords
rounding
random number
unit
digit
output
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
Application number
JP2020551748A
Other languages
Japanese (ja)
Other versions
JPWO2020084692A1 (en
Inventor
洋征 和田
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Fujitsu Ltd
Original Assignee
Fujitsu Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Fujitsu Ltd filed Critical Fujitsu Ltd
Publication of JPWO2020084692A1 publication Critical patent/JPWO2020084692A1/en
Application granted granted Critical
Publication of JP6984762B2 publication Critical patent/JP6984762B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F7/00Methods or arrangements for processing data by operating upon the order or content of the data handled
    • G06F7/38Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation
    • G06F7/48Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation using non-contact-making devices, e.g. tube, solid state device; using unspecified devices
    • G06F7/499Denomination or exception handling, e.g. rounding or overflow

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computational Mathematics (AREA)
  • Computing Systems (AREA)
  • Mathematical Analysis (AREA)
  • Mathematical Optimization (AREA)
  • Pure & Applied Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Complex Calculations (AREA)

Description

本発明は、演算処理装置及び演算処理装置の制御方法に関する。 The present invention relates to an arithmetic processing unit and a control method for the arithmetic processing unit.

昨今重要性を増す深層学習(Deep Learning)は、計算量やメモリ消費量が莫大である。計算量やメモリ消費量が増加すると、計算負荷及びメモリ負荷などが増加し、学習時間が長くなる。そこで、計算量やメモリ消費量を削減して学習時間を短縮するため、学習及び推論能力を維持しつつ、できる限り低い精度で計算を行う手法を用いることが望ましい。このような手法においては、固定小数点を用いた演算が行われることが多い。 Deep learning, which is becoming more important these days, requires a huge amount of calculation and memory consumption. When the amount of calculation and the amount of memory consumed increase, the calculation load and the memory load increase, and the learning time becomes long. Therefore, in order to reduce the amount of calculation and memory consumption and shorten the learning time, it is desirable to use a method of performing calculation with the lowest possible accuracy while maintaining learning and inference ability. In such a method, an operation using a fixed point is often performed.

ただし、低精度で計算を行う場合に挙げられる問題として、演算結果を丸めた値が、低精度ではある決まった値に偏り易くなる。丸めた値が偏ると、その時点から学習が進みにくくなるという問題が存在する。 However, as a problem raised when the calculation is performed with low accuracy, the rounded value of the calculation result tends to be biased to a certain fixed value with low accuracy. If the rounded values are biased, there is a problem that learning does not proceed easily from that point.

そのような低精度における値の偏りを解消するために、確率的丸めを導入した従来技術がある。これは、丸める前の計算結果の丸めようとする桁より下位の値に応じた確率で、丸め値を丸め桁で打ち切った(truncated)値にするか、その値に1を加算した値にするかを選択して、丸め結果がとる期待値と丸め前の値とを同等にする技術である。例えば、演算結果1.8を整数に丸める場合、確率的丸めを用いると、丸め結果として80%の確率で2が得られ、20%の確率で1が得られる。これにより、丸め結果の期待値は、丸め前の値と同じ1.8となる。 In order to eliminate the value bias in such low accuracy, there is a conventional technique that introduces stochastic rounding. This is the probability according to the value lower than the digit to be rounded in the calculation result before rounding, and the rounded value is either a truncated value or a value obtained by adding 1 to the rounded value. It is a technique to make the expected value of the rounding result equal to the value before rounding by selecting. For example, when the calculation result 1.8 is rounded to an integer, if probabilistic rounding is used, 2 is obtained with a probability of 80% and 1 is obtained with a probability of 20% as the rounding result. As a result, the expected value of the rounding result is 1.8, which is the same as the value before rounding.

ここで、深層学習においては、行列の要素に対し積和累積演算が多用される。積和累積演算とは、C’=C+A×Bの形の演算であり、ある時点までの計算結果に次の要素の積を累積していく演算である。このとき累積演算を継続する間、累積結果は、乗算への入力数よりかなり高い精度を有する値で保持されることが一般的である。例えば、上述の式における乗算への入力数であるA及びBが16ビット幅であるとき、乗算結果であるA×Bは、32ビットとなる。このとき乗算結果の累積を格納する累積レジスタについては、32ビットの値の累積結果を格納する大きさを有することが好ましく、例えば、40ビット幅とされるような場合がある。 Here, in deep learning, product-sum accumulation operations are often used for matrix elements. The product-sum accumulation operation is an operation in the form of C'= C + A × B, and is an operation in which the product of the next element is accumulated in the calculation result up to a certain point in time. At this time, while the cumulative operation is continued, the cumulative result is generally held at a value having a accuracy considerably higher than the number of inputs to the multiplication. For example, when A and B, which are the number of inputs to multiplication in the above equation, are 16 bits wide, A × B, which is the result of multiplication, is 32 bits. At this time, the cumulative register that stores the cumulative result of the multiplication result is preferably large enough to store the cumulative result of the 32-bit value, and may be, for example, 40 bits wide.

以上のことから、乗算結果を丸めた場合、精度の低下が大きくなるおそれがある。そこで、深層学習を実行するハードウェアにおいては、乗算への入力数よりもビット数が多い積和累積演算の結果に対し、確率的丸めを行い低精度にした結果を出力するという処理が行われることが望ましい。 From the above, when the multiplication result is rounded, the accuracy may be significantly reduced. Therefore, in the hardware that executes deep learning, a process is performed in which the result of the product-sum cumulative operation, which has more bits than the number of inputs to multiplication, is probabilistically rounded and the result is output with low accuracy. Is desirable.

丸めを行う際、丸めにより捨てられることになる下位桁に、何らかの数を加算することで所望する場合に繰り上がりを発生させ、丸め位置により上位桁に所望の丸め結果を得るという手法が存在する。この手法は確率的丸めにおいても有効である。そこで、積和演算器内の加算回路を活用して下位桁に加算を行うことで確率的丸めを行う従来技術が提案されている。また、ランダムノイズ回路からの出力をデータの端数部に加算して丸め処理を実行する従来技術がある。さらに、累積レジスタの丸めを行う装置として、丸め回路が、乱数生成器から値を受け取り丸めの判断に用いる従来技術がある。 When performing rounding, there is a method of adding some number to the lower digit that will be discarded by rounding to generate a carry when desired, and obtaining the desired rounding result in the upper digit depending on the rounding position. .. This method is also effective in stochastic rounding. Therefore, a conventional technique has been proposed in which probabilistic rounding is performed by adding to the lower digits by utilizing the addition circuit in the product-sum calculator. Further, there is a conventional technique of adding the output from the random noise circuit to the fractional part of the data and executing the rounding process. Further, as a device for rounding the cumulative register, there is a conventional technique in which a rounding circuit receives a value from a random number generator and uses it for determining rounding.

米国特許出願公開第2017/0220341号明細書U.S. Patent Application Publication No. 2017/0220341 米国特許出願公開第2017/0102920号明細書U.S. Patent Application Publication No. 2017/01029220 特開平03−63722号公報Japanese Unexamined Patent Publication No. 03-63722 特表2004−506365号公報Japanese Patent Publication No. 2004-506365

しかしながら、確率的丸めに積和演算器内の加算回路を用いる従来技術では、乗算結果に対する丸めが行われる。先に述べたとおり、一般には、乗算結果への入力値のビット幅は、乗算結果の累積レジスタのビット幅よりはるかに狭い。そのため、乗算結果の丸めにより累積レジスタの値を低精度に丸めることは、丸め値が不適切な値になるおそれがある。また、丸め回路に乱数生成器から取得した値を用いて丸めを判断させる従来技術では、丸め回路への大規模な改造が加えられる。丸め回路による丸め処理は浮動小数点演算のクリティカルパスを有する。そのため、丸め回路に対して確率的丸めを行うための規模の大きな改造を加えた場合、既存演算のクリティカルパスのディレイ悪化要因となるおそれがある。すなわち、浮動小数点積和演算器に大規模な改造を加えることは困難である。 However, in the prior art using an adder circuit in a multiply-accumulate calculator for stochastic rounding, rounding is performed on the multiplication result. As mentioned earlier, the bit width of the input value to the multiplication result is generally much narrower than the bit width of the cumulative register of the multiplication result. Therefore, rounding the value of the cumulative register with low precision by rounding the multiplication result may result in an inappropriate rounding value. Further, in the conventional technique of making the rounding circuit judge the rounding by using the value obtained from the random number generator, a large-scale modification to the rounding circuit is added. Rounding by the rounding circuit has a critical path for floating point arithmetic. Therefore, if a large-scale modification is made to the rounding circuit for probabilistic rounding, it may cause a deterioration in the delay of the critical path of the existing operation. That is, it is difficult to make a large-scale modification to the floating-point multiply-accumulate unit.

開示の技術は、上記に鑑みてなされたものであって、簡易な構成で適切な確率的丸めを実行する演算処理装置及び演算処理装置の制御方法を提供することを目的とする。 The disclosed technique has been made in view of the above, and an object of the present invention is to provide an arithmetic processing unit and a control method of the arithmetic processing unit that execute appropriate stochastic rounding with a simple configuration.

本願の開示する演算処理装置及び演算処理装置の制御方法は、一つの態様において、乱数生成部は、乱数を生成する。乱数移動部は、丸め対象数が配置される位置及び出力データの小数点位置情報を基に、前記乱数の先頭が前記丸め対象数の丸め位置に一致するように前記乱数の位置を移動する。加算部は、前記乱数移動部により移動された前記乱数と前記所定位置に配置された前記丸め対象数とを加算する。出力部は、前記加算部による加算結果における前記丸め位置から所定桁の有効数字を含む所定範囲のデータを前記出力データとして出力する。 In one embodiment of the arithmetic processing unit and the control method of the arithmetic processing unit disclosed in the present application, the random number generation unit generates a random number. The random number moving unit moves the position of the random number so that the head of the random number coincides with the rounding position of the number of rounding targets based on the position where the number of rounding targets is arranged and the decimal point position information of the output data. The adding unit adds the random number moved by the random number moving unit and the number of rounding targets arranged at the predetermined positions. The output unit outputs data in a predetermined range including significant digits of a predetermined digit from the rounding position in the addition result by the addition unit as the output data.

1つの側面では、本発明は、簡易な構成で適切な確率的丸めを実行することができる。 In one aspect, the invention can perform appropriate stochastic rounding with a simple configuration.

図1は、情報処理装置の全体構成図を示す図である。FIG. 1 is a diagram showing an overall configuration diagram of an information processing apparatus. 図2は、積和演算器の回路図である。FIG. 2 is a circuit diagram of a product-sum calculator. 図3は、実施例に係る積和演算器による確率的丸め処理の計算の概要を表す図である。FIG. 3 is a diagram showing an outline of the calculation of the stochastic rounding process by the product-sum calculator according to the embodiment. 図4は、乱数の桁合わせシフトを説明するための図である。FIG. 4 is a diagram for explaining the digit alignment shift of random numbers. 図5は、正規化シフタによる加算値の位置合わせを説明するための図である。FIG. 5 is a diagram for explaining the alignment of the added value by the normalized shifter. 図6は、確率的丸め処理についての具体例を表す図である。FIG. 6 is a diagram showing a specific example of the stochastic rounding process. 図7は、積和演算部が実行する処理全体のフローチャートである。FIG. 7 is a flowchart of the entire process executed by the product-sum calculation unit. 図8は、実施例に係る積和演算器による確率的丸め処理のフローチャートである。FIG. 8 is a flowchart of the stochastic rounding process by the product-sum calculator according to the embodiment.

以下に、本願の開示する演算処理装置及び演算処理装置の制御方法の実施例を図面に基づいて詳細に説明する。なお、以下の実施例により本願の開示する演算処理装置及び演算処理装置の制御方法が限定されるものではない。 Hereinafter, examples of the arithmetic processing unit and the control method of the arithmetic processing unit disclosed in the present application will be described in detail with reference to the drawings. The following embodiments do not limit the arithmetic processing unit and the control method of the arithmetic processing unit disclosed in the present application.

図1は、情報処理装置の全体構成図である。情報処理装置50は、PCI(Peripheral Component Interconnect)カード1及びホストコンピュータ2を有する。PCIカード1とホストコンピュータ2とはPCIバスで接続され、互いにデータの送受信を行う。 FIG. 1 is an overall configuration diagram of an information processing device. The information processing apparatus 50 includes a PCI (Peripheral Component Interconnect) card 1 and a host computer 2. The PCI card 1 and the host computer 2 are connected by a PCI bus, and data is transmitted to and received from each other.

ホストコンピュータ2は、例えば、深層学習を実行する際の全体的な管理を行う。深層学習を実行する場合、ホストコンピュータ2は、PCIカード1に対して畳み込み演算などの深層学習における所定の演算の実行を指示する。 The host computer 2 performs overall management, for example, when performing deep learning. When executing deep learning, the host computer 2 instructs the PCI card 1 to execute a predetermined operation in deep learning such as a convolution operation.

PCIカード1は、ホストコンピュータ2からの指示を受けて演算を実行し、演算結果をホストコンピュータ2に出力する。PCIカード1は、図1に示すように、複数の処理ユニット10、全体命令制御部11、メモリコントローラ12、メモリ13及びPCI制御部14を有する。このPCIカード1が、「演算処理装置」の一例にあたる。 The PCI card 1 receives an instruction from the host computer 2, executes an operation, and outputs the operation result to the host computer 2. As shown in FIG. 1, the PCI card 1 has a plurality of processing units 10, an overall instruction control unit 11, a memory controller 12, a memory 13, and a PCI control unit 14. This PCI card 1 corresponds to an example of a "arithmetic processing unit".

PCI制御部14は、演算の実行を指示する演算命令や演算で使用する演算データの入力をホストコンピュータ2から受ける。そして、PCI制御部14は、取得した演算命令や演算データをメモリコントローラ12へ出力する。 The PCI control unit 14 receives from the host computer 2 an operation command instructing execution of an operation and an input of operation data used in the operation. Then, the PCI control unit 14 outputs the acquired calculation instruction and calculation data to the memory controller 12.

また、PCI制御部14は、指示された演算に対する演算結果の入力をメモリコントローラ12から受ける。そして、PCI制御部14は、演算結果をホストコンピュータ2へ出力する。具体的には、PCI制御部14は、メモリコントローラ12に、メモリ13内の演算結果を読み出す指示を出し、読み出したデータを、自信を経由させてホストコンピュータ2へ出力させる。 Further, the PCI control unit 14 receives the input of the calculation result for the instructed calculation from the memory controller 12. Then, the PCI control unit 14 outputs the calculation result to the host computer 2. Specifically, the PCI control unit 14 issues an instruction to read the calculation result in the memory 13 to the memory controller 12, and outputs the read data to the host computer 2 via self-confidence.

メモリコントローラ12は、演算命令や演算で使用する演算データの入力をPCI制御部14から受ける。そして、メモリコントローラ12は、取得した演算命令及び演算データをメモリ13へ格納する。 The memory controller 12 receives input of calculation instructions and calculation data used in the calculation from the PCI control unit 14. Then, the memory controller 12 stores the acquired calculation instruction and calculation data in the memory 13.

また、メモリコントローラ12は、演算を実行する際に用いる演算データのベクタレジスタ111への格納の指示を全体命令制御部11から受ける。そして、メモリコントローラ12は、指定された演算データを指定されたベクタレジスタ111へ格納する。ここで、メモリコントローラ12は、直列に並んだ処理ユニット10のうちの後段の処理ユニット10に対してデータを送信する場合、積和演算部100を迂回させてマルチプレクサ103へ演算データを出力する。 Further, the memory controller 12 receives an instruction from the general instruction control unit 11 to store the calculation data used when executing the calculation in the vector register 111. Then, the memory controller 12 stores the designated arithmetic data in the designated vector register 111. Here, when the memory controller 12 transmits data to the processing unit 10 in the subsequent stage among the processing units 10 arranged in series, the memory controller 12 bypasses the product-sum calculation unit 100 and outputs the calculation data to the multiplexer 103.

また、全体命令制御部11は、演算が完了すると、演算完了の通知を全体命令制御部11から受けるとともに、所定の命令によりメモリコントローラ12に指示することで、ベクタレジスタ111内の演算結果を直列に並んだ処理ユニット10のチェーン(連鎖)か引き出し、メモリ13に格納させる。 Further, when the operation is completed, the whole instruction control unit 11 receives a notification of the completion of the operation from the whole instruction control unit 11 and instructs the memory controller 12 by a predetermined instruction to serialize the operation result in the vector register 111. A chain of processing units 10 arranged in line with each other is pulled out and stored in the memory 13.

全体命令制御部11は、ホストコンピュータ2から実行が指示された演算の全体の統括管理を行う。全体命令制御部11は、ホストコンピュータ2からの指示をPCI制御部14経由で受け、メモリ13に格納された全体命令列を次々と読んでは実行する。全体命令には、メモリ13から演算命令バッファ102に演算命令列を転送する命令、メモリ13から演算データをベクタレジスタ111に格納する命令、演算命令バッファ102に格納された演算命令列を演算命令制御部101に実行開始させる命令、ベクタレジスタ111に格納された演算結果をメモリ13に格納する命令、命令列の実行を終了する命令などがある。 The general instruction control unit 11 manages the entire operation instructed to be executed by the host computer 2. The general instruction control unit 11 receives an instruction from the host computer 2 via the PCI control unit 14, reads the entire instruction sequence stored in the memory 13 one after another, and executes the instruction. The whole instruction includes an instruction to transfer an operation instruction sequence from the memory 13 to the operation instruction buffer 102, an instruction to store operation data from the memory 13 in the vector register 111, and an operation instruction sequence stored in the operation instruction buffer 102 to control the operation instruction. There are an instruction to start execution in the unit 101, an instruction to store the operation result stored in the vector register 111 in the memory 13, an instruction to end the execution of the instruction sequence, and the like.

全体命令制御部11は、演算命令列を処理ユニット10に実行させる。演算を処理ユニットに実行させる場合、全体命令制御部11は、演算を実行する際に用いる演算データの取得をメモリコントローラ12に指示する。また、処理ユニット10における演算が完了すると、全体命令制御部11は、演算結果の格納をメモリコントローラ12に指示する。さらに、実行が指示された演算の全ての処理が完了すると、全体命令制御部11は、演算完了をメモリコントローラ12へ通知する。 The general instruction control unit 11 causes the processing unit 10 to execute the operation instruction sequence. When the processing unit is made to execute the calculation, the general instruction control unit 11 instructs the memory controller 12 to acquire the calculation data used when executing the calculation. Further, when the calculation in the processing unit 10 is completed, the general instruction control unit 11 instructs the memory controller 12 to store the calculation result. Further, when all the processing of the operation instructed to be executed is completed, the general instruction control unit 11 notifies the memory controller 12 of the completion of the operation.

次に、処理ユニット10について説明する。処理ユニット10は、図1に示すように1つのPCIカード1に複数搭載される。各処理ユニット10は、並列及び直列に複数接続される。処理ユニット10の数は、ある太陽においては128個である。処理ユニット10は、積和演算部100、演算命令制御部101、演算命令バッファ102及びマルチプレクサ103を有する。 Next, the processing unit 10 will be described. As shown in FIG. 1, a plurality of processing units 10 are mounted on one PCI card 1. A plurality of each processing unit 10 are connected in parallel and in series. The number of processing units 10 is 128 in a certain sun. The processing unit 10 includes a product-sum calculation unit 100, a calculation instruction control unit 101, a calculation instruction buffer 102, and a multiplexer 103.

演算命令制御部101は、演算命令の実行処理を管理制御する。演算命令制御部101は、演算命令列の実行の指示を全体命令制御部11から受ける。ここで、処理ユニット10で実行できる命令を、全体命令と対比させて演算命令と呼んでいるが、命令には、積和演算部に演算を行わせる狭義の演算命令のほか、汎用レジスタ(図示しない)の操作命令、分岐命令、繰り返し命令、命令列の実行を停止する命令などが含まれる。 The arithmetic instruction control unit 101 manages and controls the execution processing of the arithmetic instruction. The arithmetic instruction control unit 101 receives an instruction to execute the arithmetic instruction sequence from the general instruction control unit 11. Here, the instruction that can be executed by the processing unit 10 is called an arithmetic instruction in comparison with the whole instruction. The instruction includes an arithmetic instruction in a narrow sense that causes the product-sum calculation unit to perform an operation, and a general-purpose register (illustrated). Operation instructions, branch instructions, repeat instructions, instructions to stop the execution of the instruction sequence, etc. are included.

そして、演算命令制御部101は、演算命令バッファ102に格納された演算命令を順次取得する。次に、演算命令制御部101は、取得した演算命令で指定された演算データの出力をベクタレジスタ111に指示する。また、演算命令制御部101は、取得した演算命令にしたがい、積和演算器112に演算実行の指示を積和演算器112へ出力する。その後、演算命令制御部101は、積和演算器112内で演算結果を用いた演算をループさせる。 Then, the arithmetic instruction control unit 101 sequentially acquires the arithmetic instructions stored in the arithmetic instruction buffer 102. Next, the operation instruction control unit 101 instructs the vector register 111 to output the operation data specified by the acquired operation instruction. Further, the arithmetic instruction control unit 101 outputs an instruction to execute the arithmetic to the multiply-accumulate arithmetic unit 112 according to the acquired arithmetic instruction. After that, the arithmetic instruction control unit 101 loops the arithmetic using the arithmetic result in the multiply-accumulate arithmetic unit 112.

そして、演算が完了すると、演算命令制御部101は、確率的丸め処理の実行の指示とともに、累積レジスタの第何ビットを出力の小数点位置とするかを示す情報である小数点位置情報を積和演算器112へ出力する。小数点位置情報は、ニューラルネットワークにおける各層の重みパラメータを、演算可能なビット幅の範囲でできるだけ有効な値に保つように学習結果から算出される小数点位置を表す。この値は深層学習のプログラムを実行していく過程で決まる値であり、情報処理装置50にとっては可変の値である。その後、メモリコントローラ12からの指示があると、ベクタレジスタ111に格納された確率的丸め処理が施された演算結果は、処理ユニットのチェーンとメモリコントローラ12を経由してメモリ13に格納される。 Then, when the operation is completed, the operation instruction control unit 101 performs a product-sum operation together with an instruction to execute the probabilistic rounding process and the decimal point position information which is information indicating which bit of the cumulative register is set as the output decimal point position. Output to the device 112. The decimal point position information represents the decimal point position calculated from the learning result so as to keep the weight parameter of each layer in the neural network as effective as possible within the range of the operable bit width. This value is a value determined in the process of executing the deep learning program, and is a variable value for the information processing apparatus 50. After that, when instructed by the memory controller 12, the calculation result of the stochastic rounding process stored in the vector register 111 is stored in the memory 13 via the chain of the processing unit and the memory controller 12.

演算命令制御部101は、例えば、VECTOR.h.accstrnd ELE#,QNUM,DST#といった命令を発行する。ここで、QNUMは、小数点位置情報を表す。また、ELE#は、積和演算器112内に複数要素のレジスタがある場合に、どの要素を確率的丸め対象とするかを示す番号である。DST#は、確率的丸めの結果を格納するレジスタの番号を表す。この命令が実行されると、ELE#で指定された固定小数点累積レジスタの要素のQNUMに応じたビット範囲について、指定範囲よりも下位の値に基づく確率的丸めが行われ、その結果が固定小数点値をDST#で指定されたレジスタに格納される。 The arithmetic instruction control unit 101 is, for example, VECTOR. h. Issue instructions such as accstrnd ELE #, QNUM, and DST #. Here, QNUM represents decimal point position information. Further, ELE # is a number indicating which element is to be stochastically rounded when there are registers of a plurality of elements in the multiply-accumulate arithmetic unit 112. DST # represents the number of the register that stores the result of stochastic rounding. When this instruction is executed, the bit range corresponding to the QNUM of the element of the fixed-point cumulative register specified by ELE # is probabilistically rounded based on the value lower than the specified range, and the result is fixed-point. The value is stored in the register specified by DST #.

演算命令バッファ102は、演算命令列を格納する記憶領域である。演算命令バッファ102は、メモリコントローラ12から入力された演算命令列を指示されたアドレスから入力順に格納する。その後、演算命令制御部101からの演算命令の取得要求を受けて、演算命令バッファ102は、演算命令制御部101に要求されたアドレスの演算命令を出力する。 The operation instruction buffer 102 is a storage area for storing an operation instruction sequence. The arithmetic instruction buffer 102 stores the arithmetic instruction sequence input from the memory controller 12 in the order of input from the instructed address. After that, in response to the operation instruction acquisition request from the operation instruction control unit 101, the operation instruction buffer 102 outputs the operation instruction of the requested address to the operation instruction control unit 101.

積和演算部100は、ベクタレジスタ111及び積和演算器112を有する。ただし、積和演算部100が有するベクタレジスタ111は、処理ユニット10に搭載されたベクタレジスタ全体の一部にあたる。 The product-sum calculation unit 100 has a vector register 111 and a product-sum calculation unit 112. However, the vector register 111 included in the product-sum calculation unit 100 corresponds to a part of the entire vector register mounted on the processing unit 10.

ベクタレジスタ111は、演算を実行する際に用いる演算データの入力をメモリコントローラ12から受けて、入力された演算データを格納する。その後、ベクタレジスタ111は、演算命令制御部101からの指示を受けて、演算で使用する演算データを積和演算器112に出力する。また、積和累積演算の場合、積和演算器112による演算のループ処理が完了後、ベクタレジスタ111は、確率的丸め処理が施された演算結果の入力を積和演算器112から受ける。そして、メモリ13への出力の指示をメモリコントローラ12から受けると、ベクタレジスタ111は、保持する確率的丸め処理が施された積和演算器112の演算結果をマルチプレクサ103へ出力する。 The vector register 111 receives the input of the calculation data used when executing the calculation from the memory controller 12, and stores the input calculation data. After that, the vector register 111 receives an instruction from the arithmetic instruction control unit 101 and outputs the arithmetic data used in the arithmetic to the multiply-accumulate arithmetic unit 112. Further, in the case of the product-sum accumulation operation, after the loop processing of the operation by the product-sum calculation unit 112 is completed, the vector register 111 receives the input of the calculation result subjected to the stochastic rounding processing from the product-sum calculation unit 112. Then, when an instruction to output to the memory 13 is received from the memory controller 12, the vector register 111 outputs the calculation result of the product-sum calculation unit 112 to which the stochastic rounding process is performed to the multiplexer 103.

積和演算器112は、演算命令制御部101からの演算実行の指示を受ける。そして、積和演算器112は、ベクタレジスタ111から入力された演算データを用いて積和演算を実行する。その後、積和演算器112は、演算結果をベクタレジスタ111へ出力する。命令により累積を指示された場合は、積和演算器112は、累積演算結果を演算器内のレジスタ(アキュムレータ)に保持し、後続の累積演算命令で使用する。積和演算器112は、積和累積演算が完了するまでベクタレジスタ111から入力された値に対する積和演算を繰返す。 The product-sum calculation unit 112 receives an instruction to execute a calculation from the calculation instruction control unit 101. Then, the product-sum calculation unit 112 executes the product-sum calculation using the calculation data input from the vector register 111. After that, the product-sum calculation unit 112 outputs the calculation result to the vector register 111. When the cumulative operation is instructed by the instruction, the multiply-accumulate operation unit 112 holds the cumulative operation result in a register (accumulator) in the operation unit and uses it in the subsequent cumulative operation instruction. The product-sum calculator 112 repeats the product-sum operation on the value input from the vector register 111 until the product-sum cumulative operation is completed.

その後、積和累積演算のループ処理が終了すると、積和演算器112は、確率的丸め処理の実行の指示を演算命令制御部101から受ける。そのとき、積和演算器112は、小数点位置情報の入力を演算命令制御部101から受ける。そして、積和演算器112は、内部のレジスタに保持している、ループ処理が完了した演算結果を確率的丸め対象数として、積和演算を行う回路を用いて確率的丸め対象数に対する確率的丸め処理を実行する。その後、積和演算器112は、確率的丸め処理を施した演算結果をベクタレジスタ111へ出力し、格納させる。 After that, when the loop processing of the product-sum accumulation operation is completed, the product-sum calculation unit 112 receives an instruction to execute the stochastic rounding process from the operation instruction control unit 101. At that time, the multiply-accumulate arithmetic unit 112 receives the input of the decimal point position information from the arithmetic instruction control unit 101. Then, the multiply-accumulate arithmetic unit 112 uses a circuit that performs the product-sum operation as the stochastic rounding target number, which is held in the internal register, as the calculation result for which the loop processing is completed. Perform rounding. After that, the product-sum calculation unit 112 outputs the calculation result after the stochastic rounding process to the vector register 111 and stores it.

ここで、図2を参照して、積和演算器112の確率的丸めを行う機能について詳細に説明する。図2は、積和演算器の回路図である。 Here, with reference to FIG. 2, the function of performing the stochastic rounding of the multiply-accumulate calculator 112 will be described in detail. FIG. 2 is a circuit diagram of a product-sum calculator.

積和演算器112は、乱数生成回路121、冪乗数生成部122、マルチプレクサ123及び124、乗算器125、指数符号演算部126、桁合シフタ127、マルチプレクサ128、加算器129を有する。さらに、積和演算器112は、固定小数点レジスタ130、桁落量予測部131、シフト量算出部132、マルチプレクサ133、正規化シフタ134及び丸め回路135を有する。ここで、積和演算器112は、畳み込みなどのホストコンピュータ2が要求した実際の演算処理と、演算結果の確率的丸め値を算出する処理との2つの処理を行う。そこで、実際の演算処理を実演算といい、演算結果の確率的丸め値を算出する処理を確率的丸め処理という。 The product-sum calculation unit 112 includes a random number generation circuit 121, a power generation unit 122, a multiplexer 123 and 124, a multiplier 125, an exponential code calculation unit 126, a digit shifter 127, a multiplexer 128, and an adder 129. Further, the multiply-accumulate arithmetic unit 112 includes a fixed-point register 130, a digit loss prediction unit 131, a shift amount calculation unit 132, a multiplexer 133, a normalized shifter 134, and a rounding circuit 135. Here, the multiply-accumulate calculator 112 performs two processes, that is, an actual arithmetic process requested by the host computer 2 such as convolution, and a process of calculating a stochastic rounding value of the arithmetic result. Therefore, the actual operation process is called an actual operation, and the process of calculating the stochastic rounding value of the operation result is called a stochastic rounding process.

実演算における各部の動作を説明する。実演算の場合、マルチプレクサ124は、乗算を行う一方の演算データの入力を受ける。また、マルチプレクサ123は、乗算を行う他方の演算データの入力を受ける。この場合、マルチプレクサ123及び124は、演算データを乗算器125へ出力する。乗算器125は、マルチプレクサ123及び124から入力された2つの演算データを乗算する。そして、乗算器125は、乗算結果を加算器129へ出力する。 The operation of each part in the actual calculation will be described. In the case of an actual operation, the multiplexer 124 receives an input of one of the operation data to be multiplied. Further, the multiplexer 123 receives the input of the other arithmetic data to be multiplied. In this case, the multiplexers 123 and 124 output the arithmetic data to the multiplier 125. The multiplier 125 multiplies the two arithmetic data input from the multiplexers 123 and 124. Then, the multiplier 125 outputs the multiplication result to the adder 129.

一方、指数符号演算部126は、実演算に用いる3つの演算データの入力をベクタレジスタ111から受ける。そして、指数符号演算部126は、演算命令が浮動小数点の積和演算である場合に、積と加数の仮数どうしを桁合わせするためのシフト量を算出する。固定小数点演算命令の場合は、指数符号演算部126は、桁合わせするためシフト量を算出する。固定小数点演算命令の場合は、指数符号演算部126は、乗算結果の桁に加数の桁が合うようハードウェアにあらかじめ組み込まれた定数を桁合シフタのシフト量とする。また、指数符号演算部126は、演算結果の符号を算出する。そして、指数符号演算部126は、マルチプレクサ123及び124に入力された演算データ以外の残りの演算データ及びその演算データ(加数)と乗算器125の乗算結果とを桁合わせするためのシフト量を桁合シフタ127へ出力する。 On the other hand, the exponential code calculation unit 126 receives inputs of three calculation data used for the actual calculation from the vector register 111. Then, the exponential code calculation unit 126 calculates a shift amount for digitizing the mantissa of the product and the addition when the operation instruction is a floating-point product-sum operation. In the case of a fixed-point arithmetic instruction, the exponential code arithmetic unit 126 calculates the shift amount for digit matching. In the case of a fixed-point arithmetic instruction, the exponential code arithmetic unit 126 sets a constant built in the hardware in advance so that the digit of the multiplication result matches the digit of the multiplication result as the shift amount of the digit shifter. Further, the exponential code calculation unit 126 calculates the code of the calculation result. Then, the exponential code calculation unit 126 performs a shift amount for digitizing the remaining calculation data other than the calculation data input to the multiplexers 123 and 124, the calculation data (addition), and the multiplication result of the multiplier 125. Output to the digit shifter 127.

また、指数符号演算部126は、演算命令が浮動小数点の積和演算である場合、桁落ち量の予測結果の入力を桁落量予測部131から受ける。そして、指数符号演算部126は、取得した桁落ち量から、演算結果の仮数の正規化に用いる左シフト量を算出する。仮数の正規化とは、仮数の最上位桁が1になるように仮数全体のビット位置を調整(シフト)させることである。その後、指数符号演算部126は、算出した左シフト量をマルチプレクサ133へ出力する。 Further, when the operation instruction is a floating-point product-sum operation, the exponential code calculation unit 126 receives an input of a digit loss amount prediction result from the digit loss amount prediction unit 131. Then, the exponential code calculation unit 126 calculates the left shift amount used for normalizing the mantissa of the calculation result from the acquired digit loss amount. Normalization of the mantissa is to adjust (shift) the bit position of the entire mantissa so that the most significant digit of the mantissa is 1. After that, the exponential code calculation unit 126 outputs the calculated left shift amount to the multiplexer 133.

桁落量予測部131が求める桁落ち量は、回路構成により、本当の桁落ち量から、決まった範囲内の誤差を含む場合がある。正規化シフタ134で、指定された量のシフトをおこなった結果が、仮数の正規化が正しくなされているか否かを見ることで、予測した桁落ち量の誤差の有無を知ることができる。正規化シフタ134は、桁落ち量に誤差があったと分かった場合、調整のための追加のシフトをおこなうとともに、指数符号演算部に、予測に誤差があったことを通知する。指数符号演算部126は、正規化シフタ134から誤差あり通知を受けた場合、誤差調整のための追加シフトを考慮に入れた指数を算出する。これに対して、正規化シフタ134から誤差あり通知を受けない場合、指数符号演算部126は、追加シフトのない場合の指数を算出する。また、指数符号演算部126は、仮数の丸めで桁上がりが発生した場合、丸め回路135から通知を受け、指数を調整する。指数符号演算部126は、最終的に求まった符号と指数を出力し、これを後述する丸め回路135から出力される仮数の丸め結果と連接することで、浮動小数点演算結果が完成する。演算結果は、ベクタレジスタ111に出力される。 The digit loss amount obtained by the digit loss amount prediction unit 131 may include an error within a fixed range from the true digit loss amount depending on the circuit configuration. By seeing whether or not the mantissa is normalized correctly as a result of shifting the specified amount in the normalized shifter 134, it is possible to know whether or not there is an error in the predicted loss amount. If the normalized shifter 134 finds that there is an error in the amount of loss of digits, it makes an additional shift for adjustment and notifies the exponential code calculation unit that there is an error in the prediction. When the index code calculation unit 126 receives the error notification from the normalization shifter 134, the exponential code calculation unit 126 calculates an exponent in consideration of an additional shift for error adjustment. On the other hand, when the normalization shifter 134 does not receive the notification with an error, the exponential code calculation unit 126 calculates the exponent when there is no additional shift. Further, the exponential code calculation unit 126 receives a notification from the rounding circuit 135 when a carry occurs due to rounding of the mantissa, and adjusts the exponent. The exponential code calculation unit 126 outputs the finally obtained code and exponent, and concatenates this with the rounding result of the mantissa output from the rounding circuit 135, which will be described later, to complete the floating-point arithmetic result. The calculation result is output to the vector register 111.

桁合シフタ127は、指数符号演算部126から指定されたシフト量だけ、指数符号演算部126から入力された演算データをシフトさせる。そして、桁合わせを行った演算データをマルチプレクサ128へ出力する。 The digit shifter 127 shifts the calculation data input from the exponential code calculation unit 126 by the shift amount specified by the exponential code calculation unit 126. Then, the calculated data obtained by digit matching is output to the multiplexer 128.

マルチプレクサ128は、浮動小数点の実演算の場合、桁合シフタ127からの入力を選択する。固定小数点の累積演算で、累積途中の場合、加算対象の数は桁合わせの必要はないので、固定小数点レジスタ130からの入力を選択する。固定小数点の累積演算で、累積の初回の場合は、ベクタレジスタ111から積和演算器112に入力された数を加数として選択するため、桁合シフタ127からの入力を選択する。そして、マルチプレクサ128は、桁合シフタ127からの入力された演算データを加算器129へ出力する。 The multiplexer 128 selects the input from the digit shifter 127 for floating point real operations. In the fixed-point cumulative operation, if the number is in the middle of accumulation, the number to be added does not need to be digit-adjusted, so the input from the fixed-point register 130 is selected. In the fixed-point cumulative operation, in the case of the first accumulation, the input from the digit shifter 127 is selected in order to select the number input to the multiply-accumulate unit 112 from the vector register 111 as an addition. Then, the multiplexer 128 outputs the arithmetic data input from the digit shifter 127 to the adder 129.

加算器129は、2つの演算データの乗算結果の入力を乗算器125から受ける。また、加算器129は、桁合わせされた残りの演算データ(加数)の入力をマルチプレクサ128から受ける。そして、加算器129は、2つの演算データの乗算結果と桁合わせされた残りの演算データ(加数)を加算する。そして、加算器129は、加算結果を正規化シフタ134及び桁落量予測部131へ出力する。ここで、実際には加算器129は加算結果信号及び桁上げ信号の2つの数を用いて、桁上げ保存加算と桁上げ伝搬加算という2段階の加算を行うが、本実施例では、この2段階の加算をまとめたものを単に加算とよぶ。そして、実際には、加算器129は、桁上げ保存加算の結果を桁落量予測部131へ出力する。 The adder 129 receives the input of the multiplication result of the two arithmetic data from the multiplier 125. Further, the adder 129 receives the input of the remaining arithmetic data (adder) digitized from the multiplexer 128. Then, the adder 129 adds the multiplication result of the two arithmetic data and the remaining arithmetic data (addition) digitized. Then, the adder 129 outputs the addition result to the normalized shifter 134 and the digit loss prediction unit 131. Here, the adder 129 actually uses two numbers of the addition result signal and the carry signal to perform a two-step addition of carry-save addition and carry propagation addition, but in this embodiment, this 2 is performed. The sum of the steps of addition is simply called addition. Then, in reality, the adder 129 outputs the result of the carry-save storage addition to the carry-down amount prediction unit 131.

桁落量予測部131は、加算途中結果の入力を加算器129から受ける。そして、桁落量予測部131は、取得した加算途中結果から桁落ち量を予測する。その後、桁落量予測部131は、予測した桁落ち量を指数符号演算部126へ出力する。 The digit loss prediction unit 131 receives the input of the result during addition from the adder 129. Then, the digit loss prediction unit 131 predicts the digit loss amount from the acquired addition intermediate result. After that, the digit loss prediction unit 131 outputs the predicted digit loss amount to the exponential code calculation unit 126.

マルチプレクサ133は、実演算の場合、指数符号演算部126からの入力を選択する。そして、マルチプレクサ133は、指数符号演算部126から入力された左シフト量を正規化シフタ134へ出力する。 In the case of an actual operation, the multiplexer 133 selects an input from the exponential code calculation unit 126. Then, the multiplexer 133 outputs the left shift amount input from the exponential code calculation unit 126 to the normalized shifter 134.

正規化シフタ134は、加算結果の入力を加算器129から受ける。また、正規化シフタ134は、左シフト量の入力をマルチプレクサ133から受ける。そして、正規化シフタ134は、入力された左シフト量に合わせて加算結果を左シフトさせて出力される位置を合わせる。その後、正規化シフタ134は、左シフトさせた演算結果を丸め回路135へ出力する。ここで、左シフトによる位置合わせで桁落ち量の予測に誤差があったと判明した場合、正規化シフタ134は、誤差調整のための追加シフトを行うとともに、誤差あり通知を指数符号演算部126に送信する。 The normalized shifter 134 receives an input of the addition result from the adder 129. Further, the normalized shifter 134 receives an input of a left shift amount from the multiplexer 133. Then, the normalized shifter 134 shifts the addition result to the left according to the input left shift amount and adjusts the output position. After that, the normalized shifter 134 outputs the operation result shifted to the left to the rounding circuit 135. Here, if it is found that there is an error in the prediction of the amount of digit loss due to the alignment by the left shift, the normalized shifter 134 performs an additional shift for error adjustment and notifies the exponential code calculation unit 126 of the error. Send.

丸め回路135は、演算結果の入力を正規化シフタ134から受ける。そして、丸め回路135は、所定の桁数における丸めを実行する。その後、丸め回路135は、所定の桁で丸められた演算結果をベクタレジスタ111へ出力する。 The rounding circuit 135 receives the input of the calculation result from the normalized shifter 134. Then, the rounding circuit 135 performs rounding in a predetermined number of digits. After that, the rounding circuit 135 outputs the calculation result rounded by a predetermined digit to the vector register 111.

次に、確率的丸め処理における各部の動作を説明する。確率的丸め処理の場合、乱数生成回路121が、nビットの一様乱数を生成する。そして、乱数生成回路121は、生成した乱数をマルチプレクサ123へ出力する。ここで、乱数生成回路121により生成される乱数は、真に一様な乱数でなくても、実用に耐え得る範囲の疑似乱数でよい。 Next, the operation of each part in the stochastic rounding process will be described. In the case of the stochastic rounding process, the random number generation circuit 121 generates an n-bit uniform random number. Then, the random number generation circuit 121 outputs the generated random number to the multiplexer 123. Here, the random number generated by the random number generation circuit 121 does not have to be a truly uniform random number, but may be a pseudo-random number within a range that can withstand practical use.

乱数生成回路121は、例えば、積和演算器112内に配置されたLFSR(Linear Feedback Shift Register)を利用する。例えば、LFSRを用いる場合、本実施例では、確率的丸め命令を実行する毎にLFSRの内部状態が更新され、次の確率的丸め命令の発行時には、LFSRは新しい乱数値を出力する。 The random number generation circuit 121 uses, for example, an LFSR (Linear Feedback Shift Register) arranged in the product-sum calculator 112. For example, when the LFSR is used, in this embodiment, the internal state of the LFSR is updated every time the stochastic rounding instruction is executed, and the LFSR outputs a new random number value when the next stochastic rounding instruction is issued.

ただし、乱数生成回路121は、LFSRに限らず、よりランダム性の高い疑似乱数発生回路でもよいし、環境の揺らぎからランダムビットを取得する回路でもよい。また、乱数生成回路121は、各積和演算器112に付随する回路であってもよいし、複数の積和演算器112で共有する回路であってもよい。この乱数生成回路121が、「乱数生成部」の一例にあたる。 However, the random number generation circuit 121 is not limited to the LFSR, and may be a pseudo-random number generation circuit having higher randomness, or a circuit that acquires random bits from fluctuations in the environment. Further, the random number generation circuit 121 may be a circuit attached to each product-sum calculation unit 112, or may be a circuit shared by a plurality of product-sum calculation units 112. This random number generation circuit 121 corresponds to an example of a “random number generation unit”.

ここで、乱数のビット数の選び方について説明する。確率的に丸めを行う場合、最終的に確率的丸め対象数において丸め位置より下位にあるビットの値が捨てられる。例えば、乱数のビット数をnとし、捨てられるビット数をmとした場合、乱数が一様であれば、nがmと同じもしくはそれ以上であれば、確率的丸め後の期待値を確率的丸め対象数と等しい値にすることができる。しかし、mが多い場合でも同様にn≧mの関係を維持しようとすると、演算するビット数が多くなり、それに応じて桁合わせや加算を行う回路が大きくなる。あまり回路が大きくなると、既存の積和演算器112のハードウェアでは、使用するビット数の演算回路が収納が困難となる。その場合、不足する部分について、確率的丸めのために演算回路を付加するなどの対処は回路量が増加するため好ましくない。 Here, how to select the number of bits of a random number will be described. When rounding is performed stochastically, the value of the bit lower than the rounding position in the number of stochastic rounding targets is finally discarded. For example, when the number of bits of a random number is n and the number of bits to be discarded is m, if the random number is uniform, and if n is the same as or more than m, the expected value after stochastic rounding is stochastic. The value can be equal to the number of rounding targets. However, even when m is large, if the relationship of n ≧ m is to be maintained, the number of bits to be calculated increases, and the circuit for performing digit matching and addition increases accordingly. If the circuit becomes too large, it becomes difficult to store the arithmetic circuit of the number of bits to be used in the hardware of the existing multiply-accumulate arithmetic unit 112. In that case, it is not preferable to take measures such as adding an arithmetic circuit for stochastic rounding to the insufficient part because the circuit amount increases.

そこで、n≧mの関係を維持せず、nの方がmより小さくてもよいとすれば、既存の積和演算器112に収納できるだけのビット数にnをとどめておく方法が考えられる。その場合、捨てられるmビットのうち、丸め位置から下位にnビットよりさらに下位のビットについては、乱数との加算が行われず、丸め後の結果に寄与しないことになる。丸め後の期待値は、その分丸め前の値から乖離する。しかし、nを1増やすごとに期待値のずれは半分程度に縮小するため、ある程度以上にnを大きくすれば、mが大きいことによるずれは十分小さくなり、実用上は問題にならない。そのため、nは実用上の要件と既存の演算回路量に応じて妥当な値が決定されることが好ましい。 Therefore, if the relationship of n ≧ m is not maintained and n may be smaller than m, a method of keeping n in the number of bits that can be stored in the existing multiply-accumulate unit 112 can be considered. In that case, among the m bits to be discarded, the bits lower than the n bits below the rounded position are not added to the random number and do not contribute to the result after rounding. The expected value after rounding deviates from the value before rounding by that amount. However, since the deviation of the expected value is reduced to about half each time n is increased by 1, if n is increased to some extent or more, the deviation due to the large m becomes sufficiently small, which does not pose a problem in practical use. Therefore, it is preferable that an appropriate value of n is determined according to practical requirements and the amount of existing arithmetic circuits.

確率的丸め処理の場合、マルチプレクサ123は、乱数生成回路121から入力されたnビットの一様乱数を選択する。そして、マルチプレクサ123は、nビットの一様乱数を乗算器125へ出力する。 In the case of stochastic rounding, the multiplexer 123 selects an n-bit uniform random number input from the random number generation circuit 121. Then, the multiplexer 123 outputs an n-bit uniform random number to the multiplier 125.

冪乗数生成部122は、確率的丸め命令の入力を演算命令制御部101から受ける。同時に、冪乗数生成部122は、確率的丸め命令に含まれるオペランドの小数点位置情報を取得する。そして、冪乗数生成部122は、小数点位置情報を用いて丸めたい位置に応じた2の冪乗数を生成する。ここで、丸めたい位置とは、その桁の1つ上の桁が有効数字の桁となる桁にあたる。その後、冪乗数生成部122は、生成した2の冪乗数をマルチプレクサ124へ出力する。 The exponentiation generation unit 122 receives an input of a stochastic rounding instruction from the arithmetic instruction control unit 101. At the same time, the power generation unit 122 acquires the decimal point position information of the operand included in the stochastic rounding instruction. Then, the power generation unit 122 generates a power of 2 according to the position to be rounded by using the decimal point position information. Here, the position to be rounded corresponds to a digit in which the digit one above the digit is a significant digit. After that, the power generation unit 122 outputs the generated power of 2 to the multiplexer 124.

確率的丸め処理の場合、マルチプレクサ124は、冪乗数生成部122から入力された2の冪乗数を選択する。そして、マルチプレクサ124は、2の冪乗数を乗算器125へ出力する。 In the case of stochastic rounding, the multiplexer 124 selects a power of 2 input from the power generation unit 122. Then, the multiplexer 124 outputs a power of 2 to the multiplier 125.

乗算器125は、nビットの一様乱数の入力をマルチプレクサ123から受ける。また、乗算器125は、丸めたい位置に応じた2の冪乗数の入力をマルチプレクサ124から受ける。そして、乗算器125は、取得した2の冪乗数を取得した乱数に乗算することで、乱数の先頭の桁を確率的丸め対象数における丸めたい位置に合わせる。 The multiplier 125 receives an input of an n-bit uniform random number from the multiplexer 123. Further, the multiplier 125 receives an input of a power of 2 according to the position to be rounded from the multiplexer 124. Then, the multiplier 125 multiplies the acquired power of 2 by the acquired random number to align the first digit of the random number with the position to be rounded in the stochastic rounding target number.

ここで、図3を参照して、本実施例に係る積和演算器112による確率的丸め処理の計算の概要を説明する。図3は、実施例に係る積和演算器による確率的丸め処理の計算の概要を表す図である。確率的丸め対象数200における位置Pは、丸め位置を表す。また、範囲Lは、演算結果として使用される範囲である。 Here, with reference to FIG. 3, the outline of the calculation of the stochastic rounding process by the product-sum calculator 112 according to the present embodiment will be described. FIG. 3 is a diagram showing an outline of the calculation of the stochastic rounding process by the product-sum calculator according to the embodiment. The position P in the number of stochastic rounding targets 200 represents the rounding position. Further, the range L is a range used as a calculation result.

まず、乱数生成回路121により、nビットの一様乱数である乱数201が生成される。そして、乱数201は、乗算器125により、2の冪乗数が乗算され、乱数201の先頭が確率的丸め対象数200の丸め位置Pに一致するように乱数201が左シフトされる。この時、乱数201は丸め位置から下位にnビットの桁を有する乱数となる。 First, the random number generation circuit 121 generates a random number 201, which is an n-bit uniform random number. Then, the random number 201 is multiplied by a power of 2 by the multiplier 125, and the random number 201 is left-shifted so that the head of the random number 201 coincides with the rounding position P of the stochastic rounding target number 200. At this time, the random number 201 is a random number having n-bit digits lower than the rounded position.

ここで、図4を参照して、乱数の桁合わせシフトをさらに詳細に説明する。図4は、乱数の桁合わせシフトを説明するための図である。ここでは、乱数201が12ビットの乱数で且つ小数点以下3ビットの乱数である場合で説明する。また、固定小数アキュムレータ211(確率的丸め対象数)の小数点位置が最下位ビットの直ぐ右である場合で説明する。 Here, with reference to FIG. 4, the digit alignment shift of the random number will be described in more detail. FIG. 4 is a diagram for explaining the digit alignment shift of random numbers. Here, the case where the random number 201 is a 12-bit random number and a random number having 3 bits after the decimal point will be described. Further, the case where the decimal point position of the fixed decimal accumulator 211 (stochastic rounding target number) is immediately to the right of the least significant bit will be described.

乗算器125は、乱数201に2の冪数である2^Eを乗算することで、乱数をシフトする。ここで、小数点位置情報をQNUMとして表し、E=QNUM−9とする。QNUM=0で、乱数の全桁が、固定小数アキュムレータ211の最下位ビットより下に埋没する。また、QNUM=12の時、乱数の最下位桁が固定小数アキュムレータ211の最下位に合う位置となる。この場合、位置Dが小数点位置を表す。 The multiplier 125 shifts the random number by multiplying the random number 201 by 2 ^ E, which is a power of 2. Here, the decimal point position information is represented as QNUM, and E = QNUM-9. When QNUM = 0, all the digits of the random number are buried below the least significant bit of the fixed decimal accumulator 211. Further, when QNUM = 12, the lowest digit of the random number is at the position corresponding to the lowest digit of the fixed decimal accumulator 211. In this case, the position D represents the decimal point position.

図4において枠210は、単精度で24ビット×24ビットの乗算を行う乗算器125による乱数201のシフトを表す。図4において、12ビット乱数201Aが、QNUM=0の場合の位置である。ここで、この場合の乗算器125の最下位桁は、16ビットの固定小数で考えると2^−8にあたる。QNUM=0のときはE=−9であり、乗算器125は2^−9を乗算する処理を行うことになるが、乗算器125その桁の回路を有さない。しかし、QNUM=0の場合、乱数全桁が固定小数アキュムレータ211の最下位ビットより下位に埋没し、丸めでは切り捨てとなるため、乱数を足さなくてもよい。そこで、QNUM=0の場合、乗算器125は、乗算する値である2^Eを0とする。 In FIG. 4, the frame 210 represents a shift of the random number 201 by the multiplier 125 that performs multiplication of 24 bits × 24 bits with single precision. In FIG. 4, the 12-bit random number 201A is the position when QNUM = 0. Here, the least significant digit of the multiplier 125 in this case corresponds to 2 ^ -8 in terms of a fixed decimal number of 16 bits. When QNUM = 0, E = -9, and the multiplier 125 performs a process of multiplying 2 ^ -9, but the multiplier 125 does not have a circuit of that digit. However, when QNUM = 0, all the digits of the random number are buried below the least significant bit of the fixed decimal accumulator 211, and rounding is rounded down, so it is not necessary to add the random numbers. Therefore, when QNUM = 0, the multiplier 125 sets 2 ^ E, which is the value to be multiplied, to 0.

QNUM=1の場合、E=−8となり、乗算器125は、12ビット乱数201Aに2^−8を乗算して、12ビット乱数201Aをシフトさせて12ビット乱数201Bとする。また、QNUM=8の場合、E=−1となり、乗算器125は、12ビット乱数201に2^−1を乗算して、12ビット乱数201Aをシフトさせて12ビット乱数201Cとする。また、QNUM=24の場合、E=15となり、乗算器125は、12ビット乱数201に2^15を乗算して、12ビット乱数201Aをシフトさせて12ビット乱数201Dとする。 When QNUM = 1, E = -8, and the multiplier 125 multiplies the 12-bit random number 201A by 2 ^ -8 and shifts the 12-bit random number 201A to obtain the 12-bit random number 201B. Further, when QNUM = 8, E = -1, and the multiplier 125 multiplies the 12-bit random number 201 by 2 ^ -1 and shifts the 12-bit random number 201A to obtain the 12-bit random number 201C. Further, when QNUM = 24, E = 15, and the multiplier 125 multiplies the 12-bit random number 201 by 2 ^ 15 and shifts the 12-bit random number 201A to obtain the 12-bit random number 201D.

すなわち、固定小数アキュムレータ211の最下位側の16ビットであるデータ213を出力結果とする場合、QNUM=0となる。また、固定小数アキュムレータ211の最上位側の16ビットであるデータ212を出力結果とする場合、QNUM=24となる。すなわち、命令により与えられるQNUMにより、固定小数アキュムレータ211におけるどの位置の桁以上を有効数字とするかが決定される。そして、図4の場合、乗算器125は、0〜24の間の値を採るQNUMから求められた2の冪乗数を乱数201に乗算することで、固定小数アキュムレータ211における有効数字の最下位の桁の1つ下の桁に乱数201の先頭の位置を合わせる。 That is, when the data 213 which is the lowest 16 bits of the fixed decimal accumulator 211 is used as the output result, QNUM = 0. Further, when the data 212 which is 16 bits on the uppermost side of the fixed decimal accumulator 211 is used as the output result, QNUM = 24. That is, the QNUM given by the instruction determines which position or more of the fixed decimal accumulator 211 is to be a significant digit. Then, in the case of FIG. 4, the multiplier 125 is the lowest significant digit in the fixed decimal accumulator 211 by multiplying the random number 201 by the power of 2 obtained from the QNUM having a value between 0 and 24. Align the first position of the random number 201 with the digit one digit below.

図2に戻って説明を続ける。乗算器125は、乗算結果である有効数字の最下位の桁の1つ下の桁に先頭の桁を合わせた乱数を加算器129へ出力する。この乗算器125が、「乱数移動部」の一例にあたる。 The explanation will be continued by returning to FIG. The multiplier 125 outputs a random number obtained by adding the first digit to the digit one below the lowest digit of the significant digit which is the multiplication result to the adder 129. This multiplier 125 corresponds to an example of a "random number moving unit".

固定小数点レジスタ130は、積和累積演算で用いられる累積レジスタ(アキュムレータ)である。固定小数点レジスタ130は、確率的丸めの対象となる確率的丸め対象数を格納する。確率的丸め対象数は、実演算において算出された算出結果である。累積演算では、累積レジスタの値に乗算結果を加算していくため、固定小数点レジスタ130は、累積レジスタの値をセットするのに十分なビット幅を有する。そして、確率的丸め処理の場合、固定小数点レジスタ130は、確率的丸め対象数をマルチプレクサ128へ出力する。 The fixed-point register 130 is a cumulative register (accumulator) used in the product-sum accumulation operation. The fixed-point register 130 stores the number of stochastic rounding targets to be stochastic rounded. The number of stochastic rounding targets is the calculation result calculated in the actual calculation. Since the multiplication result is added to the value of the cumulative register in the cumulative operation, the fixed-point register 130 has a bit width sufficient to set the value of the cumulative register. Then, in the case of the stochastic rounding process, the fixed-point register 130 outputs the number of stochastic rounding targets to the multiplexer 128.

確率的丸め処理の場合、マルチプレクサ128は、固定小数点レジスタ130から入力された確率的丸め対象数を選択する。そして、マルチプレクサ128は、確率的丸め対象数を加算器129へ出力する。 In the case of stochastic rounding, the multiplexer 128 selects the number of stochastic rounding targets input from the fixed-point register 130. Then, the multiplexer 128 outputs the number of stochastic rounding targets to the adder 129.

加算器129は、有効数字の最下位の桁の1つ下の桁に先頭の桁を合わせた乱数の入力を乗算器125から受ける。また、加算器129は、確率的丸め対象数の入力をマルチプレクサ128から受ける。そして、加算器129は、確率的丸め対象数に乱数を加算する。これにより、確率的丸め対象数のうち乱数の先頭より下の桁の数に応じて確率的に繰り上げが行われる。すなわち、加算器129は、確率的丸め対象数に乱数を加算することで確率的丸めを行う。その後、加算器129は、加算結果を正規化シフタ134へ出力する。この加算器129が、「加算部」の一例にあたる。 The adder 129 receives an input of a random number obtained by adding the first digit to the digit one below the least significant digit of the significant digit from the multiplier 125. Further, the adder 129 receives an input of the number of stochastic rounding targets from the multiplexer 128. Then, the adder 129 adds a random number to the number of stochastic rounding targets. As a result, the number of stochastic rounding targets is stochastically rounded up according to the number of digits below the beginning of the random number. That is, the adder 129 performs stochastic rounding by adding a random number to the number of stochastic rounding targets. After that, the adder 129 outputs the addition result to the normalized shifter 134. This adder 129 is an example of an "adder".

ここで、図3を参照して、加算器129による確率的丸めの処理をさらに説明する。確率的丸め対象数200は、固定小数点レジスタ130から提供される。そして、範囲Lが丸め処理の結果として使用したい数値の範囲を表す。加算器129は、乗算器125により先頭位置が丸め位置であるPにシフトされた乱数201を確率的丸め対象数200に加算する。ここで、確率的丸め対象数200の最下位桁が乱数201の最下位桁よりも高い場合、加算器129は、確率的丸め対象数200に0の値のビットを付加して最下位桁を一致させた上で加算を行う。この加算により、丸め位置P以下の値に応じて確率的に桁上がりM1が発生した加算値202が得られる。 Here, with reference to FIG. 3, the process of stochastic rounding by the adder 129 will be further described. The number of stochastic rounding targets 200 is provided by the fixed-point register 130. Then, the range L represents a range of numerical values to be used as a result of the rounding process. The adder 129 adds the random number 201 whose head position is shifted to P, which is the rounding position, to the stochastic rounding target number 200 by the multiplier 125. Here, when the lowest digit of the stochastic rounding target number 200 is higher than the least significant digit of the random number 201, the adder 129 adds a bit of a value of 0 to the stochastic rounding target number 200 to obtain the least significant digit. Add after matching. By this addition, an added value 202 in which a carry M1 is probabilistically generated according to the value below the rounding position P is obtained.

ここで、桁上がりはおおよそ下の値に応じて確率的に発生する。これは、前述の通り乱数のビット数nの選び方によっては、確率的丸め結果の期待値が、丸め前の値からずれることがあり、そのずれ量はnの値により異なる。本実施例では、既存の単精度浮動小数点用の積和演算器112に収納可能な乗加算ビット数と、深層学習の収束シミュレーションに基づいた実用性の判断によりn=12とした。この場合、丸め後の期待値のずれは、最大で0.00025程度である。ただし、乱数のビット数はこれに限らず、演算に期待される要件と、既存回路や許容できる追加回路量のバランスに応じて、1以上の任意の妥当なビット数が選択されることが好ましい。 Here, the carry occurs stochastically according to the value below. This is because, as described above, the expected value of the stochastic rounding result may deviate from the value before rounding depending on how the number of bits n of the random number is selected, and the deviation amount differs depending on the value of n. In this embodiment, n = 12 is determined based on the number of multiply-accumulate bits that can be stored in the existing multiply-accumulate unit 112 for single-precision floating point and the practicality based on the convergence simulation of deep learning. In this case, the deviation of the expected value after rounding is about 0.00025 at the maximum. However, the number of bits of the random number is not limited to this, and it is preferable that an arbitrary reasonable number of bits of 1 or more is selected according to the balance between the requirements expected for the calculation and the existing circuit and the allowable amount of additional circuits. ..

図2に戻って説明を続ける。シフト量算出部132は、小数点位置情報の入力を演算命令制御部101から受ける。そして、シフト量算出部132は、小数点位置情報に応じたシフト量を算出する。具体的には、シフト量算出部132は、加算器129から出力されるデータのうち有効とするデータが配置されている位置から、正規化シフタの出力における有効データの位置への移動に用いるシフト量を、QNUM算出する。その後、シフト量算出部132は、算出したシフト量をマルチプレクサ133へ出力する。 The explanation will be continued by returning to FIG. The shift amount calculation unit 132 receives the input of the decimal point position information from the operation instruction control unit 101. Then, the shift amount calculation unit 132 calculates the shift amount according to the decimal point position information. Specifically, the shift amount calculation unit 132 shifts from the position where the valid data is arranged among the data output from the adder 129 to the position of the valid data in the output of the normalized shifter. The amount is calculated as QNUM. After that, the shift amount calculation unit 132 outputs the calculated shift amount to the multiplexer 133.

確率的丸め処理の場合、マルチプレクサ133は、シフト量算出部132から入力されたシフト量を選択する。そして、マルチプレクサ133は、シフト量を正規化シフタ134へ出力する。 In the case of the stochastic rounding process, the multiplexer 133 selects the shift amount input from the shift amount calculation unit 132. Then, the multiplexer 133 outputs the shift amount to the normalized shifter 134.

正規化シフタ134は、確率的丸め処理が施された確率的丸め対象数の入力を加算器129から受ける。また、正規化シフタ134は、シフト量の入力をマルチプレクサ133から受ける。そして、正規化シフタ134は、確率的丸め対象数をシフト量に応じてシフトさせる。具体的には、正規化シフタ134は、入力された対象数のうち丸め位置のすぐ上の桁がちょうど積和演算器112から出力される有効な数の最下位桁に移動されるように左シフトをおこなう。正規化シフタ134は、左シフトを施した確率的丸め対象数を丸め回路135へ出力する。この正規化シフタ134が、「移動部」の一例にあたる。 The normalized shifter 134 receives an input of the number of stochastic rounding targets subjected to the stochastic rounding process from the adder 129. Further, the normalized shifter 134 receives an input of a shift amount from the multiplexer 133. Then, the normalized shifter 134 shifts the number of stochastic rounding targets according to the shift amount. Specifically, the normalized shifter 134 is left so that the digit immediately above the rounding position of the input target number is moved to the least significant digit of the valid number output from the multiply-accumulate unit 112. Make a shift. The normalized shifter 134 outputs the number of stochastic rounding targets subjected to the left shift to the rounding circuit 135. This normalized shifter 134 is an example of a "moving part".

例えば、図3において、正規化シフタ134は、加算値202において演算結果として使用する範囲Lの最下位桁が出力されるデータの最下位桁に一致するように加算値202をシフトさせてシフト値203とする。 For example, in FIG. 3, the normalized shifter 134 shifts the added value 202 so that the lowest digit of the range L used as the calculation result in the added value 202 matches the lowest digit of the output data, and shifts the shift value. It is set to 203.

ここで、図5を参照して正規化シフタ134による加算値の位置合わせについて説明する。図5は、正規化シフタによる加算値の位置合わせを説明するための図である。 Here, the alignment of the added value by the normalized shifter 134 will be described with reference to FIG. FIG. 5 is a diagram for explaining the alignment of the added value by the normalized shifter.

図5では、以下の条件の場合を例に記載した。加算器129から、40ビットの加算値202が出力される。そして、加算器129から出力された値は、正規化シフタ134の出力前の中間バスのビット16からビット55までの位置にあたる。さらに、値の内16ビットのデータが出力される。そして、正規化シフタ134からデータが出力される演算結果バスのビット48からビット63までがデータとして出力される。 In FIG. 5, the case of the following conditions is described as an example. A 40-bit addition value 202 is output from the adder 129. The value output from the adder 129 corresponds to the position from the bit 16 to the bit 55 of the intermediate bus before the output of the normalized shifter 134. Further, 16-bit data of the values is output. Then, bits 48 to 63 of the calculation result bus for which data is output from the normalized shifter 134 are output as data.

正規化シフタ134は、加算値202を左シフトする。これにより、正規化シフタ134は、加算値202の使用される16ビットを演算結果バスのビット48からビット63にあたる出力位置214に移動させる。 The normalized shifter 134 shifts the addition value 202 to the left. As a result, the normalized shifter 134 moves the 16 bits of the addition value 202 from the bit 48 of the calculation result bus to the output position 214 corresponding to the bit 63.

例えば、図5では、小数点位置情報を表す値をQNUMとしてQNUM=0の場合に、固定小数アキュムレータ211の最下位側の16ビットのデータ213が出力対象であるとする。この場合、QNUM=0であれば、正規化シフタ134は、中間結果バスのビット16からビット32までのデータ213を演算結果バスのビット48からビット63の出力位置214に移動させる。この場合、左シフト量は32である。また、QNUM=24の場合に、固定小数アキュムレータ211の最上位側の16ビットのデータ212が出力対象であるとする。この場合、QNUM=24であれば、正規化シフタ134は、中間結果バスのビット40からビット55までのデータ212を演算結果バスのビット48からビット63の出力位置214に移動させる。この場合、左シフト量は8である。すなわち、図5の例では、シフト量算出部132により「32−QNUM」として求められた左シフト量を用いて、正規化シフタ134は、左シフトを実行する。 For example, in FIG. 5, when the value representing the decimal point position information is QNUM and QNUM = 0, it is assumed that the 16-bit data 213 on the lowest side of the fixed decimal accumulator 211 is the output target. In this case, if QNUM = 0, the normalized shifter 134 moves the data 213 from bits 16 to 32 of the intermediate result bus from bit 48 of the operation result bus to the output position 214 of bit 63. In this case, the left shift amount is 32. Further, when QNUM = 24, it is assumed that the 16-bit data 212 on the uppermost side of the fixed decimal accumulator 211 is the output target. In this case, if QNUM = 24, the normalized shifter 134 moves the data 212 from the bits 40 to 55 of the intermediate result bus from the bit 48 of the operation result bus to the output position 214 of the bit 63. In this case, the left shift amount is 8. That is, in the example of FIG. 5, the normalized shifter 134 executes the left shift by using the left shift amount obtained as “32-QNUM” by the shift amount calculation unit 132.

図2に戻って説明を続ける。丸め回路135は、左シフトが施された確率的丸め対象数の入力を正規化シフタ134から受ける。そして、確率的丸め処理の場合、丸め回路135は、入力された確率的丸め対象数の所定桁より下の桁を打ち切る。そして、丸め回路135は、所定桁より下の桁を打ち切った確率的丸め対象数を出力する。丸め回路135からの出力が出力データとしてベクタレジスタ111に送られる。呼の丸め回路135が、「出力部」の一例にあたる。 The explanation will be continued by returning to FIG. The rounding circuit 135 receives an input of the number of stochastic rounding targets to which the left shift is applied from the normalized shifter 134. Then, in the case of the stochastic rounding process, the rounding circuit 135 cuts off the digits below the predetermined digit of the input stochastic rounding target number. Then, the rounding circuit 135 outputs the number of stochastic rounding targets in which the digits below the predetermined digit are cut off. The output from the rounding circuit 135 is sent to the vector register 111 as output data. The call rounding circuit 135 is an example of an “output unit”.

例えば、図3において、丸め回路135は、シフト値203のうち使用する範囲Lよりも下位の桁に対して打ち切りM2を行う。そして、丸め回路135から出力されたデータの、使用する範囲Lよりも上位の桁である範囲204は、出力データ205には含まれず破棄される。そして、出力データ205が、ベクタレジスタ111に送られる。 For example, in FIG. 3, the rounding circuit 135 performs a truncation M2 on a digit lower than the range L used in the shift value 203. Then, the range 204 of the data output from the rounding circuit 135, which is a digit higher than the range L to be used, is not included in the output data 205 and is discarded. Then, the output data 205 is sent to the vector register 111.

ここで、丸め回路135は、通常の浮動小数点演算の回路である。浮動小数点演算の通常の丸めでは、下位桁から得られる丸めビットやstickyビット、丸め最下位桁の値、演算結果の正負及び指定された丸めモードに基づき、丸め回路135は、入力値に対して以下の2処理のいずれかを行う。第1の処理は、丸め回路135は、入力値の丸め位置より下を打ち切った値をそのまま出力する処理である。第2の処理は、丸め回路135は、入力値の丸め位置より下を打ち切った値に1を加算して出力する処理である。確率的丸め処理を実行する場合、丸め回路135は、上述した第1の処理を常に選択するように論理が指定される。 Here, the rounding circuit 135 is a circuit for ordinary floating-point arithmetic. In normal rounding of floating-point operations, the rounding circuit 135 is based on the rounding bit or sticky bit obtained from the lower digit, the value of the least significant rounding digit, the positive or negative of the operation result, and the specified rounding mode. Perform one of the following two processes. The first process is a process in which the rounding circuit 135 outputs the value cut off below the rounding position of the input value as it is. The second process is a process in which the rounding circuit 135 adds 1 to the value cut off below the rounding position of the input value and outputs the input value. When performing the stochastic rounding process, the rounding circuit 135 is logically designated to always select the first process described above.

次に、図6を参照して、具体的なデータを用いて確率的丸め処理について説明する。図6は、確率的丸め処理についての具体例を表す図である。図6では、64ビットの幅のバスを用いて処理を行う場合で説明する。また、各データの位置を[x:y]と表し、xが最上位ビット、yが最下位ビットを表すものとして説明する。 Next, with reference to FIG. 6, the stochastic rounding process will be described using specific data. FIG. 6 is a diagram showing a specific example of the stochastic rounding process. FIG. 6 describes a case where processing is performed using a bus having a width of 64 bits. Further, the position of each data is represented as [x: y], where x represents the most significant bit and y represents the least significant bit.

この場合、演算命令制御部101は、小数点位置情報としてQNUM=16を出力する。固定小数点レジスタ130から出力された確率的丸め対象数300は、[55:16]に位置する。ここで、ビット15以下が、小数点以下にあたる。そして、確率的丸め対象数300のうちビット31以下は丸められ、[47:32]が使用される範囲である。 In this case, the arithmetic instruction control unit 101 outputs QNUM = 16 as the decimal point position information. The number of stochastic rounding targets 300 output from the fixed-point register 130 is located at [55:16]. Here, bit 15 or less corresponds to the decimal point. Then, out of the number of stochastic rounding targets 300, bits 31 or less are rounded, and [47:32] is the range in which [47:32] is used.

乱数生成回路121により生成された乱数301は、論理的には、小数点以下がビット15以下となるように配置され、破線で囲われた場所に位置する。実際には、乱数301は、QNUM=0の場合の位置に回路上の初期位置として配置される。QNUM=0の場合の位置は、具体的には、確率的丸め対象数300の最下位ビットの次のビットに乱数301の先頭のビットが来る位置である。そして、冪乗数生成部122は、QNUM=16に応じた2の冪乗数として2^7を求める。乗算器125は、乱数に2^7を乗算して乱数301を[31:20]の位置にシフトさせる。 The random number 301 generated by the random number generation circuit 121 is logically arranged so that the number after the decimal point is bit 15 or less, and is located at a place surrounded by a broken line. Actually, the random number 301 is arranged as an initial position on the circuit at the position when QNUM = 0. Specifically, the position when QNUM = 0 is the position where the first bit of the random number 301 comes to the bit next to the least significant bit of the stochastic rounding target number 300. Then, the power generation unit 122 obtains 2 ^ 7 as a power of 2 corresponding to QNUM = 16. The multiplier 125 multiplies the random number by 2 ^ 7 to shift the random number 301 to the position of [31:20].

加算器129は、[31:20]に位置する乱数301に確率的丸め対象数300と最下位ビットが一致するように0の値のビットを付加して、確率的丸め対象数300に加算し、加算値302を算出する。加算値302は、[55:16]に位置する。ここで、出力範囲303は[63:48]である。 The adder 129 adds a bit with a value of 0 to the random number 301 located at [31:20] so that the number of stochastic rounding targets 300 and the least significant bit match, and adds to the number of stochastic rounding targets 300. , The addition value 302 is calculated. The added value 302 is located at [55:16]. Here, the output range 303 is [63:48].

そこで、正規化シフタ134は、確率的丸め対象数300における使用される範囲[47:32]のデータが[63:48]に位置するように確率的丸め対象数300をシフトさせる。 Therefore, the normalized shifter 134 shifts the stochastic rounding target number 300 so that the data in the range [47:32] used in the stochastic rounding target number 300 is located at [63:48].

その後、丸め回路135により、シフト後の確率的丸め対象数300におけるビット49以下が打ち切られ破棄される。さらに、シフト後の確率的丸め対象数300におけるビット64以上が出力されず破棄される。これにより、残った16ビットの出力データ304が演算結果として出力される。 After that, the rounding circuit 135 cuts off and discards bits 49 or less in the stochastic rounding target number 300 after the shift. Further, the bits 64 or more in the stochastic rounding target number 300 after the shift are not output and are discarded. As a result, the remaining 16-bit output data 304 is output as a calculation result.

次に、図7を参照して、積和演算部100が実行する処理の全体的な流れを説明する。図7は、積和演算部が実行する処理全体のフローチャートである。 Next, with reference to FIG. 7, the overall flow of processing executed by the product-sum calculation unit 100 will be described. FIG. 7 is a flowchart of the entire process executed by the product-sum calculation unit.

積和演算部100は、積和演算器112を用いて実演算における積和演算を実行する(ステップS1)。 The product-sum calculation unit 100 executes the product-sum calculation in the actual calculation using the product-sum calculation device 112 (step S1).

そして、積和演算部100は、積和累積演算が完了したか否かを判定する(ステップS2)。積和累積演算が完了していない場合(ステップS2:否定)、積和演算部100は、ステップS1へ戻り積和演算を繰返す。 Then, the product-sum calculation unit 100 determines whether or not the product-sum cumulative operation has been completed (step S2). When the product-sum accumulation operation is not completed (step S2: negation), the product-sum calculation unit 100 returns to step S1 and repeats the product-sum operation.

これに対して、積和累積演算が完了した場合(ステップS2:肯定)、積和演算部100は、積和演算器112を用いて確率的丸め処理を実行する(ステップS3)。 On the other hand, when the product-sum accumulation calculation is completed (step S2: affirmative), the product-sum calculation unit 100 executes the stochastic rounding process using the product-sum calculation unit 112 (step S3).

その後、メモリコントローラ12からの指示にしたがい、ベクタレジスタ111に格納された演算結果は、処理ユニットのチェーンとメモリコントローラ12とを経由してメモリ13に出力される(ステップS4)。 After that, according to the instruction from the memory controller 12, the calculation result stored in the vector register 111 is output to the memory 13 via the chain of the processing unit and the memory controller 12 (step S4).

次に、図8を参照して、本実施例に係る積和演算器による確率的丸め処理の流れを説明する。図8は、実施例に係る積和演算器112による確率的丸め処理のフローチャートである。図8のフローチャートで示した処理は、図7のステップS3で行われる処理の一例にあたる。 Next, with reference to FIG. 8, the flow of the stochastic rounding process by the product-sum calculator according to the present embodiment will be described. FIG. 8 is a flowchart of the stochastic rounding process by the product-sum calculator 112 according to the embodiment. The process shown in the flowchart of FIG. 8 corresponds to an example of the process performed in step S3 of FIG.

乱数生成回路121は、n桁の一様な乱数を取得する(ステップS101)。そして、乱数生成回路121は、生成した乱数をマルチプレクサ123を介して乗算器125へ出力する。 The random number generation circuit 121 acquires a uniform random number of n digits (step S101). Then, the random number generation circuit 121 outputs the generated random number to the multiplier 125 via the multiplexer 123.

また、冪乗数生成部122は、QNUMに応じた2の冪乗数を生成する(ステップS102)。そして、乱数生成回路121は、生成した2の冪乗数をマルチプレクサ124を介して乗算器125へ出力する。 Further, the power generation unit 122 generates a power of 2 according to the QNUM (step S102). Then, the random number generation circuit 121 outputs the generated power of 2 to the multiplier 125 via the multiplexer 124.

乗算器125は、乱数の入力を乱数生成回路121から受ける。また、乗算器125は、QNUMに応じた2の冪乗数の入力をマルチプレクサ124から受ける。そして、乗算器125は、乱数と2の冪乗数とを乗算して乱数の先頭が丸め位置に位置するように乱数をシフトさせる(ステップS103)。その後、乗算器125は、乗算結果を加算器129へ出力する。 The multiplier 125 receives a random number input from the random number generation circuit 121. Further, the multiplier 125 receives an input of a power of 2 corresponding to the QNUM from the multiplexer 124. Then, the multiplier 125 multiplies the random number by a power of 2 and shifts the random number so that the head of the random number is located at the rounded position (step S103). After that, the multiplier 125 outputs the multiplication result to the adder 129.

加算器129は、マルチプレクサ128を介して、固定小数点レジスタ130に格納された確率的丸め対象数を取得する(ステップS104)。 The adder 129 acquires the number of stochastic rounding targets stored in the fixed-point register 130 via the multiplexer 128 (step S104).

また、加算器129は、乗算結果の入力を乗算器125から受ける。そして、加算器129は、確率的丸め対象数に乗算器125による乗算結果を加算して確率的丸めを実行する(ステップS105)。その後、加算器129は、確率的丸めの処理を施した確率的丸め対象数を表す加算結果を正規化シフタ134へ出力する。 Further, the adder 129 receives the input of the multiplication result from the multiplier 125. Then, the adder 129 adds the multiplication result by the multiplier 125 to the number of stochastic rounding targets and executes the probabilistic rounding (step S105). After that, the adder 129 outputs an addition result representing the number of stochastic rounding targets subjected to the stochastic rounding process to the normalized shifter 134.

シフト量算出部132は、演算命令制御部101から取得した小数点位置情報に応じたシフト量を算出する(ステップS106)。そして、シフト量算出部132は、算出したシフト量をマルチプレクサ133を介して正規化シフタ134へ出力する。 The shift amount calculation unit 132 calculates the shift amount according to the decimal point position information acquired from the operation instruction control unit 101 (step S106). Then, the shift amount calculation unit 132 outputs the calculated shift amount to the normalized shifter 134 via the multiplexer 133.

正規化シフタ134は、確率的丸めの処理を施した確率的丸め対象数を表す加算結果の入力を加算器129から受ける。また、正規化シフタ134は、シフト量の入力をシフト量算出部132から受ける。そして、加算結果をシフト量分左シフトする(ステップS107)。そして、正規化シフタ134は、左シフトした値を丸め回路135へ出力する。 The normalized shifter 134 receives an input of an addition result representing the number of stochastic rounding targets subjected to the stochastic rounding process from the adder 129. Further, the normalized shifter 134 receives an input of the shift amount from the shift amount calculation unit 132. Then, the addition result is shifted to the left by the shift amount (step S107). Then, the normalized shifter 134 rounds the left-shifted value and outputs it to the circuit 135.

丸め回路135は、左シフトされた値の入力を正規化シフタ134から受ける。そして、丸め回路135は、左シフトされた値の所定桁以下を打ち切り出力範囲以下のビットを破棄する(ステップS108)。 The rounding circuit 135 receives an input of a left-shifted value from the normalized shifter 134. Then, the rounding circuit 135 cuts off the predetermined digit or less of the left-shifted value and discards the bits of the output range or less (step S108).

その後、丸め回路135から、下位から所定のビット数が結果として出力される(ステップS109)。 After that, a predetermined number of bits is output as a result from the lower order from the rounding circuit 135 (step S109).

本実施例に係る積和演算器112は、浮動小数点の演算を行う回路に、乱数生成回路121、冪乗数生成回路122、シフト量算出部132、並びに、マルチプレクサ123、124及び133を追加することで、固定小数点を用いた確率的丸め処理を実行する。 The product-sum calculator 112 according to the present embodiment adds a random number generation circuit 121, a power generation circuit 122, a shift amount calculation unit 132, and multiplexers 123, 124, and 133 to a circuit that performs floating-point arithmetic. Then, the probabilistic rounding process using the fixed point is executed.

以上に説明したように、本実施例に係る積和演算器112は、浮動小数点の積和演算に用いる回路に対して少量の回路追加を行うことで、固定小数点の確率的丸めが実行可能となる。また、本実施例に係る積和演算器112は、乗算の累積演算結果に対する確率的丸めを実行する。したがって、簡易な構成で適切な確率的丸めを実行することができる。 As described above, the multiply-accumulate unit 112 according to the present embodiment can execute fixed-point stochastic rounding by adding a small amount of circuits to the circuit used for the floating-point product-sum operation. Become. Further, the multiply-accumulate calculator 112 according to the present embodiment performs stochastic rounding on the cumulative calculation result of multiplication. Therefore, an appropriate stochastic rounding can be performed with a simple configuration.

1 PCIカード
2 ホストコンピュータ
10 処理ユニット
11 全体命令制御部
12 メモリコントローラ
13 メモリ
14 PCI制御部
50 情報処理装置
100 積和演算部
101 演算命令制御部
102 演算命令バッファ
103 マルチプレクサ
111 ベクタレジスタ
112 積和演算器
121 乱数生成回路
122 冪乗数生成部
125 乗算器
126 指数符号演算部
127 桁合シフタ
129 加算器
130 固定小数点レジスタ
131 桁落量予測部
132 シフト量算出部
134 正規化シフタ
135 丸め回路
123,124,128,133 マルチプレクサ
1 PCI card 2 Host computer 10 Processing unit 11 Overall instruction control unit 12 Memory controller 13 Memory 14 PCI control unit 50 Information processing device 100 Multiply-accumulate operation unit 101 Operation instruction control unit 102 Operation instruction buffer 103 multiplexer 111 Vector register 112 Multiply-accumulate operation Instrument 121 Random generator circuit 122 Memory generator
125 Multiplier 126 Exponential sign calculation unit 127 Digit shifter 129 Adder 130 Fixed-point register 131 Digit drop amount prediction unit 132 Shift amount calculation unit 134 Normalization shifter 135 Rounding circuit 123, 124, 128, 133 Multiplexer

Claims (5)

乱数を生成する乱数生成部と、
丸め対象数が配置される所定位置及び出力データの小数点位置情報を基に、前記乱数の先頭が前記丸め対象数の丸め位置に一致するように前記乱数の位置を移動する乱数移動部と、
前記乱数移動部により移動された前記乱数と前記所定位置に配置された前記丸め対象数とを加算する加算部と、
前記加算部による加算結果における前記丸め位置から所定桁の有効数字を含む所定範囲のデータを前記出力データとして出力する出力部と
を備えたことを特徴とする演算処理装置。
A random number generator that generates random numbers, and a random number generator
A random number moving unit that moves the position of the random number so that the beginning of the random number matches the rounding position of the number of rounding targets based on the predetermined position where the number of rounding targets is arranged and the decimal point position information of the output data.
An addition unit that adds the random number moved by the random number movement unit and the number of rounding targets arranged at the predetermined positions, and an addition unit.
An arithmetic processing unit including an output unit that outputs data in a predetermined range including significant figures of a predetermined digit from the rounded position in the addition result by the addition unit as the output data.
前記加算部による加算結果における前記丸め位置から前記所定桁の前記有効数字が、予め決められた所定桁の出力位置に一致するように移動する移動部をさらに備え、
前記出力部は、前記丸め位置から前記所定桁の前記有効数字が前記出力位置に一致するように移動された前記加算結果の前記出力位置以外の値を破棄して出力する
ことを特徴とする請求項1に記載の演算処理装置。
Further provided is a moving unit that moves the significant digit of the predetermined digit from the rounding position in the addition result by the addition unit so as to match the output position of the predetermined digit.
The claim is characterized in that the output unit discards and outputs a value other than the output position of the addition result in which the significant digit of the predetermined digit is moved from the rounding position so as to match the output position. Item 1. The arithmetic processing unit according to item 1.
前記丸め対象数が配置される位置及び前記出力データの小数点位置情報を基に、前記乱数の先頭を前記丸め対象数の前記丸め位置に一致させるための2の冪乗数を求める冪乗数生成部をさらに備え、
前記乱数生成部は、2進数で表される乱数を生成し
前記乱数移動部は、前記冪乗数生成部により求められた前記冪乗数を前記乱数に乗算することで前記乱数の位置を移動する
ことを特徴とする請求項1に記載の演算処理装置。
A power generation unit for obtaining a power of 2 for matching the beginning of the random number with the rounding position of the rounding target number based on the position where the rounding target number is arranged and the decimal point position information of the output data. Further prepare,
The random number generation unit generates a random number represented by a binary number, and the random number moving unit moves the position of the random number by multiplying the random number by the power obtained by the power generation unit. The arithmetic processing apparatus according to claim 1.
前記乱数移動部は、2つの入力データを乗算して浮動小数点演算を行い、
前記加算部は、前記乱数移動部による乗算結果に対して入力されたデータを加算して浮動小数点演算を行う
ことを特徴とする請求項1に記載の演算処理装置。
The random number moving unit multiplies the two input data to perform a floating point operation.
The arithmetic processing apparatus according to claim 1, wherein the addition unit adds data input to a multiplication result by the random number movement unit to perform a floating-point operation.
乱数を生成し、
丸め対象数が配置される所定位置及び出力データの小数点位置情報を基に、前記乱数の先頭が前記丸め対象数の丸め位置に一致するように前記乱数の位置を移動し、
移動した前記乱数と前記所定位置に配置された前記丸め対象数とを加算し、
加算結果の前記丸め位置から所定桁の有効数字を含むデータを前記出力データとして出力する
ことを特徴とする演算処理装置の制御方法。
Generate random numbers,
Based on the predetermined position where the number of rounding targets is placed and the decimal point position information of the output data, the position of the random number is moved so that the beginning of the random number matches the rounding position of the number of rounding targets.
The moved random number and the number of rounding targets placed at the predetermined positions are added.
A control method of an arithmetic processing unit, characterized in that data including significant digits of a predetermined digit is output as the output data from the rounded position of the addition result.
JP2020551748A 2018-10-23 2018-10-23 Arithmetic processing unit and control method of arithmetic processing unit Active JP6984762B2 (en)

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/JP2018/039370 WO2020084692A1 (en) 2018-10-23 2018-10-23 Computation processing device and computation processing device control method

Publications (2)

Publication Number Publication Date
JPWO2020084692A1 JPWO2020084692A1 (en) 2021-09-02
JP6984762B2 true JP6984762B2 (en) 2021-12-22

Family

ID=70331786

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2020551748A Active JP6984762B2 (en) 2018-10-23 2018-10-23 Arithmetic processing unit and control method of arithmetic processing unit

Country Status (2)

Country Link
JP (1) JP6984762B2 (en)
WO (1) WO2020084692A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US12554489B2 (en) * 2021-03-25 2026-02-17 Intel Corporation Supporting 8-bit floating point format operands in a computing architecture

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS62260229A (en) * 1986-05-06 1987-11-12 Yamaha Corp Multiplying circuit
JP2009010489A (en) * 2007-06-26 2009-01-15 Fujifilm Corp Image processing apparatus and image processing method
US10552370B2 (en) * 2015-10-08 2020-02-04 Via Alliance Semiconductor Co., Ltd. Neural network unit with output buffer feedback for performing recurrent neural network computations

Also Published As

Publication number Publication date
WO2020084692A1 (en) 2020-04-30
JPWO2020084692A1 (en) 2021-09-02

Similar Documents

Publication Publication Date Title
Demmel et al. Parallel reproducible summation
TWI438678B (en) Method, system, and computer program product for large number multiplication
KR100323338B1 (en) Sticky bit calculation circuit for floating point division / square root operation
KR101533516B1 (en) Multiply add functional unit capable of executing scale, round, getexp, round, getmant, reduce, range and class instructions
KR102697307B1 (en) Stochastic rounding logic
JP2000347832A (en) Floating-point operation method, floating-point operation device, and semiconductor integrated circuit device having the same
CN109284827A (en) Neural network computing method, device, processor and computer-readable storage medium
JPH0969040A (en) Circuit for radix-2 square root operation / division by three overlapping stages with speculative operation
US20180217815A1 (en) Apparatus and method for processing input operand values
EP4231135A1 (en) Method and system for calculating dot products
JP6984762B2 (en) Arithmetic processing unit and control method of arithmetic processing unit
EP0550188A2 (en) Arithmetic system for performing integer power calculations
EP1335278A2 (en) Higher precision divide and square root approximations
US20200311545A1 (en) Information processor, information processing method, and storage medium
US5867413A (en) Fast method of floating-point multiplication and accumulation
US20200249942A1 (en) Anchored data element conversion
JP2022034897A (en) Information processing device, machine learning method and machine learning program
JP7036224B2 (en) Arithmetic processing unit and control method of arithmetic processing unit
EP4345600A1 (en) Multiplication hardware block with adaptive fidelity control system
US6529924B1 (en) Method and apparatus for generating shift amount signals for an alignment shifter
US20210224040A1 (en) Arithmetic processing apparatus and control method for arithmetic processing apparatus
JPWO2002029546A1 (en) Arithmetic unit and electronic circuit device using the same
JP7371499B2 (en) Arithmetic processing unit, control method for the arithmetic processing unit, and arithmetic processing program
US20240211211A1 (en) Mac apparatus using floating point unit and control method thereof
JP2002358196A (en) Method for calculating reciprocal of square root, calculating circuit and program

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20210224

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: 20211026

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20211108

R150 Certificate of patent or registration of utility model

Ref document number: 6984762

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150