JP4838756B2 - Multiple length arithmetic method, multiple length arithmetic device and program - Google Patents

Multiple length arithmetic method, multiple length arithmetic device and program Download PDF

Info

Publication number
JP4838756B2
JP4838756B2 JP2007131655A JP2007131655A JP4838756B2 JP 4838756 B2 JP4838756 B2 JP 4838756B2 JP 2007131655 A JP2007131655 A JP 2007131655A JP 2007131655 A JP2007131655 A JP 2007131655A JP 4838756 B2 JP4838756 B2 JP 4838756B2
Authority
JP
Japan
Prior art keywords
bit
unit
multiple length
product
sum
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.)
Expired - Fee Related
Application number
JP2007131655A
Other languages
Japanese (ja)
Other versions
JP2008287489A (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.)
Nippon Telegraph and Telephone Corp
Original Assignee
Nippon Telegraph and Telephone Corp
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 Nippon Telegraph and Telephone Corp filed Critical Nippon Telegraph and Telephone Corp
Priority to JP2007131655A priority Critical patent/JP4838756B2/en
Publication of JP2008287489A publication Critical patent/JP2008287489A/en
Application granted granted Critical
Publication of JP4838756B2 publication Critical patent/JP4838756B2/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Complex Calculations (AREA)

Description

本発明は、多倍長演算を行う技術に関し、特にサイズの大きいデータを対象とした多倍長演算を高速で行う技術に関する。   The present invention relates to a technique for performing multiple length arithmetic, and more particularly to a technique for performing multiple length arithmetic on large data at high speed.

CPU(Central Processing Unit)レジスタが扱うことができるデータのビット数には、32ビット,64ビットなどの制限がある。そのため、汎用CPUにおいてCPUレジスタが扱うことができるビット数を超える大きな整数の演算を行う場合、多倍長演算方式と呼ばれる演算方式が利用される。一般に多倍長演算方式では、大きな整数をCPUレジスタが扱うことができるビット長(ワード長)毎に区切った配列を用い、当該ワード長単位で演算を行う。   The number of data bits that can be handled by a CPU (Central Processing Unit) register is limited to 32 bits or 64 bits. Therefore, when performing a large integer operation exceeding the number of bits that can be handled by the CPU register in a general-purpose CPU, an operation method called a multiple-length operation method is used. In general, in the multiple length arithmetic method, an operation is performed in units of the word length using an array in which a large integer is divided for each bit length (word length) that can be handled by the CPU register.

通常、CPU上で演算に利用されるデータは、メインメモリからCPUレジスタにロードされ、CPU上で計算がなされた後、計算結果がメインメモリにストアされる。しかし、単純な演算にかかる時間に比べ、データをメインメモリからCPUレジスタにロードする時間のほうが大きい。そのため、一般的なCPUでは、キャッシュメモリと呼ばれる高速にアクセス可能なメモリにメインメモリのデータの一部を複製した後、当該キャッシュメモリからCPUレジスタにデータをロードする。そして、同一データを二回目以降にロードする際にキャッシュメモリのデータを用いることで、高速化を実現している。   Normally, data used for calculation on the CPU is loaded from the main memory into the CPU register, and after calculation is performed on the CPU, the calculation result is stored in the main memory. However, the time for loading data from the main memory to the CPU register is longer than the time required for simple calculation. Therefore, in a general CPU, after copying a part of the data in the main memory to a memory called a cache memory that can be accessed at high speed, the data is loaded from the cache memory to the CPU register. The speed is increased by using the data in the cache memory when the same data is loaded for the second time and thereafter.

また、データがすべてキャッシュメモリに存在する環境で多倍長演算を高速に行うアプローチとして、演算コスト(演算するために必要な時間)が大きい演算を演算コストの小さい演算の組み合わせに変換することによって全体の演算コストを低減させる方法が採られる。例えば、大きな整数同士の乗算を一般的なCPUで行う場合、乗算の演算コストが和算の演算コストよりも大きいため、Karatsuba法(非特許文献1)などのような、積演算を和演算に変換して高速化を図る方法が採られることが一般的である。
梅谷 武、“Karatsuba法”、[online]、平成13年2月14日、[平成19年5月8日検索]、インターネット〈URL http://homepage1.nifty.com/~umetani/ims/2001/20010214001/0.html〉
In addition, as an approach to perform multiple-precision operations at high speed in an environment where all data exists in the cache memory, by converting an operation with a large operation cost (time required for operation) into a combination of operations with a lower operation cost A method of reducing the overall calculation cost is employed. For example, when multiplying large integers with a general CPU, the operation cost of multiplication is larger than the operation cost of summation, so product operation such as Karatsuba method (Non-patent Document 1) is used for sum operation. Generally, a method of speeding up by converting is adopted.
Takeshi Umeya, “Karatsuba method”, [online], February 14, 2001, [May 8, 2007 search], Internet <URL http://homepage1.nifty.com/~umetani/ims/2001 /20010214001/0.html>

しかし、従来の方法では、データサイズが大きな整数xiに対し、多倍長演算によってR=x1・r1+…+xI・rI(Iは2以上の自然数、i∈{1,...,I}、riは整数)の演算を行う場合、十分高速に演算を行うことができないことがある。
xiのデータサイズが非常に大きな値(例えば1Mビット程度)であった場合、キャッシュメモリに読み込まれた各xiがキャッシュメモリを溢れ、CPUがxiを参照するたびにメインメモリにアクセスしなければならない状況となる。一般にキャッシュメモリは高速にアクセス可能なメモリであるが、その記憶容量はメインメモリに比べて非常に小さい。そのため、さらにメインメモリへのアクセス速度が計算速度に比べて遅くなるような環境では、演算コストではなく、メインメモリへのアクセス時間がボトルネックとなって演算速度が低下する。
However, in the conventional method, for an integer x i having a large data size, R = x 1 · r 1 +… + x I · r I (I is a natural number of 2 or more, i∈ {1, ..., I} and r i are integers), the computation may not be performed sufficiently fast.
If the data size of x i is a very large value (for example, about 1 Mbit), each x i read into the cache memory overflows the cache memory and the main memory is accessed each time the CPU refers to x i. It becomes a necessary situation. In general, the cache memory is a memory that can be accessed at high speed, but its storage capacity is very small compared to the main memory. Therefore, in an environment where the access speed to the main memory becomes slower than the calculation speed, the access speed to the main memory becomes a bottleneck, not the calculation cost, and the calculation speed decreases.

本発明はこのような点に鑑みてなされたものであり、データサイズが大きな整数xiに対し、多倍長演算によってR=x1・r1+…+xI・rIの演算を高速で行う技術を提供することを目的とする。 The present invention has been made in view of these points, with respect to the data size is large integer x i, fast calculation of R = x 1 · r 1 + ... + x I · r I by multiple length arithmetic The purpose is to provide technology performed in

本発明では上記課題を解決するために、ビット分割部が、xiを各ビット長がω(j)であるxi(j)毎〔j∈{1,...,J}, Jは2以上の自然数, xiはxi(J),…,xi(1)のビット結合xi=xi(J)|…|xi(1)〕に分割するビット分割過程と、演算制御部が、jに1を代入し、α(1)に0を代入する初期化過程と、積和演算部が、α(j)とキャッシュメモリに読み込まれたxi(j)およびriとを用い、T(j)=α(j)+x1(j)・r1+…+xI(j)・rIの演算を行う積和演算過程と、上記積和演算過程後、シフト部が、T(j)の下位ω(j)ビットをRjとし、T(j)のRj以外のビットを新たなα(j+1)とするシフト過程と、上記シフト過程後、演算制御部が、j=Jであるか否かを判定する判定過程と、上記判定過程でj≠Jと判定された場合、演算制御部が、j+1を新たなjとして処理を上記積和演算過程に戻すループ過程と、上記判定過程でj=Jと判定された場合、ビット結合部が、α(J),RJ,...,R1のビット結合R=α(J)|RJ|…|R1を算出し、Rを出力するビット結合過程と、を有する多倍長演算によってR=x1・r1+…+xI・rIの多倍長演算を行う。 In the present invention, in order to solve the above problems, the bit dividing portion is, x i for each (j) the bit length x i is omega (j) [j∈ {1, ..., J} , J is 2 or more natural numbers, x i is a bit-splitting process that divides into x i (J), ..., x i (1) bit combinations x i = x i (J) | ... | x i (1)] The control unit substitutes 1 for j and 0 for α (1), and the product-sum operation unit obtains α (j) and x i (j) and r i read into the cache memory. And a product-sum operation process for calculating T (j) = α (j) + x 1 (j) · r 1 +… + x I (j) · r I , and after the product-sum operation process, shift portion, the lower omega (j) bits of T (j) and R j, a shift process and T new bits other than R j in (j) α (j + 1 ), after the shift process, When the calculation control unit determines whether j = J or not and j ≠ J in the determination step, the calculation control unit performs processing with j + 1 as a new j. The loop process to return to the sum operation process and the above If j = J is determined in the fixed process, the bit combination unit calculates the bit combination R = α (J) | R J |… | R 1 of α (J), R J , ..., R 1 Then, a multiple length operation of R = x 1 · r 1 +... + X I · r I is performed by a multiple length operation having a bit combination process of outputting R.

ここで、積和演算部が取り扱うxi(j)はxiから分割されたデータであり、Jは2以上の自然数であるため、xi(j)のビット長はxiのビット長よりも短い。そのため、積和演算部がxiを取り扱う場合に比べ、データがキャッシュメモリから溢れてしまう頻度を低減させ、メインメモリへのアクセス回数を低減させることができる。その結果、全体として演算速度を向上させることができる。 Here, product-sum operation unit handled x i (j) is the data divided from x i, for J is a natural number of 2 or more, the bit length of x i (j) is the bit length of x i Also short. Therefore, compared to the case where the product-sum operation unit handles x i , the frequency at which data overflows from the cache memory can be reduced, and the number of accesses to the main memory can be reduced. As a result, the calculation speed can be improved as a whole.

また、本発明において好ましくは、上記キャッシュメモリの記憶容量は、何れか一つのxiのデータ量とすべてのriのデータ量との合計値よりも小さく、当該xiを分割して得られた一つのxi(j)のデータ量とすべてのriのデータ量との合計値よりも大きい。この場合、すべてのriをキャッシュメモリ上に格納して演算を行う環境において、データがキャッシュメモリから溢れてしまう頻度を確実に低減させることができる。 Preferably, in the present invention, the storage capacity of the cache memory is smaller than the total value of the data amount of any one x i and the data amount of all r i , and is obtained by dividing the x i. It is larger than the sum of the data amount of one x i (j) and the data amount of all r i . In this case, it is possible to reliably reduce the frequency at which data overflows from the cache memory in an environment where calculation is performed with all r i stored in the cache memory.

また、本発明において好ましくは、上記積和演算過程は、上記積和演算部が所定のビット長W単位で演算を行う過程であり、ω(h)は、上記所定のビット長Wよりも長く、xiのビット長よりも短い。この場合、積和演算部はxi(j)のデータを2回以上参照する必要があるため、本発明によってxi(j)がキャッシュメモリから溢れる頻度を低下させることにより、メインメモリへのアクセス回数を確実に低減させることができる。 Preferably, in the present invention, the product-sum operation process is a process in which the product-sum operation unit performs an operation in units of a predetermined bit length W, and ω (h) is longer than the predetermined bit length W. , Shorter than the bit length of x i . In this case, since the product-sum operation unit needs to refer to the data of x i (j) more than once, by reducing the frequency of x i (j) overflowing from the cache memory according to the present invention, The number of accesses can be reliably reduced.

また、本発明において好ましくは、ω(j)は、すべてのjについて一定である。これにより、積和演算部は各jについて同一の桁上げ処理を使用でき、全体として演算内容を簡略化できる。その効果の一例として、積和演算部を構成するためのプログラム長を短くすることができる。   In the present invention, preferably, ω (j) is constant for all j. Thereby, the product-sum operation unit can use the same carry processing for each j, and the operation content can be simplified as a whole. As an example of the effect, the program length for configuring the product-sum operation unit can be shortened.

また、本発明において好ましくは、上記積和演算過程は、上記積和演算部が、xi(j)をビット長W−a(W>a≧0)毎に分割したxi(j,p)〔p∈{1,...,P}, Pは1以上の自然数, xi(j)はxi(j,P),...,xi(j,1)のビット結合xi(j)=xi(j,P)|…|xi(j,1)〕と、riをビット長W−b(W>b≧0, I≦2a+b)毎に分割したri(q)〔q∈{1,...,Q}, Qは1以上の自然数, riはri(Q),...,ri(1)のビット結合ri=ri(Q)|…|ri(1)〕とを用い、ビット長W単位で演算を行って1組以上のp,qについてx1(j,p)・r1(q)+…+xI(j,p)・rI(q)を算出し、当該演算結果を用いてT(j)=α(j)+x1(j)・r1+…+xI(j)・rIを算出する過程である。 According to another embodiment of the present invention, the product sum calculation process, the product-sum operation unit, x i (j) a bit length W-a (W> a ≧ 0) divided x i (j for each, p ) [P∈ {1, ..., P}, P is a natural number greater than 1, x i (j) is a bit combination x of x i (j, P), ..., x i (j, 1) i (j) = x i (j, P) | ... | x i (j, 1)] and r i is divided into bit lengths W−b (W> b ≧ 0, I ≦ 2 a + b ) R i (q) [q∈ {1, ..., Q}, Q is a natural number greater than 1, r i is the bit combination r i = r i (Q), ..., r i (1) r i (Q) | ... | r i (1)], and the operation is performed in units of bit length W, and x 1 (j, p) · r 1 (q) + ... + x I (j, p) ・ r I (q) is calculated, and T (j) = α (j) + x 1 (j) ・ r 1 +… + x I (j) it is the process of calculating the · r I.

ここで、ビット長W−aのxi(j,p)とビット長W−bのri(q)との積xi(j,p)・ri(q)のビット長は必ず2・W以下となり、さらにI≦2a+bであるため、x1(j,p)・r1(q)+…+xI(j,p)・rI(q)のビット長も必ず2・W以下となる。この場合、x1(j,p)・r1(q)+…+xI(j,p)・rI(q)を算出する過程においてビット長2・W以上の桁上げ処理が不要となる。その結果、桁上げ処理数を削減でき、演算速度を向上させることができる。なお、x1(j,p)・r1(q)+…+xI(j,p)・rI(q)の演算結果を用いたT(j)=α(j)+x1(j)・r1+…+xI(j)・rIの算出は、例えば、公知の多倍長演算方法を用いて可能である。 Here, the bit length of the product x i (j, p) · r i (q) of x i (j, p) of the bit length W−a and r i (q) of the bit length W−b is always 2・ Below W and I ≦ 2 a + b , so the bit length of x 1 (j, p) ・ r 1 (q) +… + x I (j, p) ・ r I (q) must be 2 · W or less. In this case, carry processing with a bit length of 2 · W or more is unnecessary in the process of calculating x 1 (j, p) · r 1 (q) +… + x I (j, p) · r I (q) Become. As a result, the number of carry processing can be reduced and the calculation speed can be improved. Note that T (j) = α (j) + x 1 (using the calculation result of x 1 (j, p) ・ r 1 (q) +… + x I (j, p) ・ r I (q) j) · r 1 +... + x I (j) · r I can be calculated using, for example, a known multiple-length arithmetic method.

また、本発明において好ましくは、上記ビット分割部で分割された各xi(j)は、x1(1),...,xI(1),x1(2),...,xI(2),...,x1(J),...,xI(J)の順序でバースト転送可能にメモリに格納され、x1(1),...,xI(1),x1(2),...,xI(2),...,x1(J),...,xI(J)の順序で順次キャッシュメモリに読み込まれる。 Preferably, in the present invention, each x i (j) divided by the bit dividing unit is x 1 (1), ..., x I (1), x 1 (2), ..., x I (2), ..., x 1 (J), ..., x I (J) is stored in memory so that burst transfer is possible, and x 1 (1), ..., x I ( 1), x 1 (2), ..., x I (2), ..., x 1 (J), ..., x I (J) are sequentially read into the cache memory.

ここで、積和演算部は、j=1からj=JまでのT(j)=α(j)+x1(j)・r1+…+xI(j)・rIの演算を行うに際し、x1(1),...,xI(1),x1(2),...,xI(2),...,x1(J),...,xI(J)の順序でxi(j)を使用する。このようにx1(1),...,xI(1),x1(2),...,xI(2),...,x1(J),...,xI(J)の順序でバースト転送可能にこれらのデータをメモリに格納しておくことにより、ランダム転送よりバースト転送の方が効率がよい環境においてxi(j)の転送速度が向上し、全体として演算速度が向上する。 Here, the product-sum operation unit calculates T (j) = α (j) + x 1 (j) · r 1 +… + x I (j) · r I from j = 1 to j = J. In doing so, x 1 (1), ..., x I (1), x 1 (2), ..., x I (2), ..., x 1 (J), ..., x Use x i (j) in the order of I (J). X 1 (1), ..., x I (1), x 1 (2), ..., x I (2), ..., x 1 (J), ..., x By storing these data in memory so that burst transfer is possible in the order of I (J), the transfer speed of x i (j) is improved in an environment where burst transfer is more efficient than random transfer. As a result, the calculation speed is improved.

また、Iを2以上の自然数とし、i∈{1,...,I}とし、xiを0以上の整数とし、riを整数とした場合における、R=x1・r1+…+xI・rIの演算を行う多倍長演算方法であって、Hを2以上の整数とし、h∈{1,...,H}とし、S(h)を2以上の整数とし、s(h)∈{1,...,S(h)}とし、i(h,s(h))∈{i(h,1),...,i(h,S(h))}⊂{1,...,I}とし、{i(1,1),...,i(1,S(1)),...,i(H,1),...,i(H,S(H))}={1,...,I}とし、R(h)=xi(h,1)・ri(h,1)+…+xi(h,S(h))・ri(h,S(h))とし、J(h)を2以上の自然数とし、j∈{1,...,J(h)}とした場合における、(a)ビット分割部が、xi(h,s(h))を各ビット長がω(h,j)であるxi(h,s(h))(j)毎〔xi(h,s(h))はxi(h,s(h))(J(h)),…,xi(h,s(h))(1)のビット結合xi(h,s(h))=xi(h,s(h))(J(h))|…|xi(h,s(h))(1)〕に分割するビット分割過程と、(b)演算制御部が、jに1を代入し、α(h,1)に0を代入する初期化過程と、(c)hに対応するri(h,1),...,ri(h,S(h))をキャッシュメモリに読み込むキャッシュ過程と、(d)積和演算部が、α(h,j)とキャッシュメモリに読み込まれたxi(h,s(h))(j)およびri(h,s(h))とを用い、T(h,j)=α(h,j)+xi(h,1)(j)・ri(h,1)+…+xi(h,S(h))(j)・ri(h,S(h))の演算を行う積和演算過程と、(e)上記積和演算過程後、シフト部が、T(h,j)の下位ω(h,j)ビットをR(h,j)とし、T(h,j)のR(h,j)以外のビットを新たなα(h,j+1)とするシフト過程と、(f)上記シフト過程後、演算制御部が、j=J(h)であるか否かを判定する判定過程と、(g)上記判定過程でj≠J(h)と判定された場合、演算制御部が、j+1を新たなjとして処理を上記積和演算過程に戻すループ過程と、(h)上記判定過程でj=J(h)と判定された場合、ビット結合部が、α(h,J(h)),R(h,J(h)),...,R(h,1)のビット結合R(h)=α(h,J(h))|R(h,J(h))|…|R(h,1)を算出するビット結合過程と、を各hについて順次実行し、加算部が、R=R(1)+…+R(H)を算出し、Rを出力する加算過程と、を有する多倍長演算方法が提供される。 Further, when I is a natural number of 2 or more, i∈ {1,..., I}, x i is an integer of 0 or more, and r i is an integer, R = x 1 · r 1 +. + x I · r I is a multiple-precision arithmetic method in which H is an integer greater than or equal to 2, h∈ {1, ..., H}, and S (h) is an integer greater than or equal to 2. , S (h) ∈ {1, ..., S (h)} and i (h, s (h)) ∈ {i (h, 1), ..., i (h, S (h) )} ⊂ {1, ..., I} and {i (1,1), ..., i (1, S (1)), ..., i (H, 1), ... , i (H, S (H))} = {1, ..., I}, R (h) = x i (h, 1) · r i (h, 1) +… + x i (h , S (h)) · ri (h, S (h)) , J (h) is a natural number of 2 or more, and j∈ {1, ..., J (h)} a) The bit division unit converts x i (h, s (h)) to x i (h, s (h)) (j) each bit length is ω (h, j) (x i (h, s (h)) is the bit combination x i (h, s (h) ) of x i (h, s (h)) (J (h)), ..., x i (h, s (h)) (1 ) ) = x i (h, s (h)) (J (h)) |… | x i (h, s (h)) (1)] and (b) , J is assigned 1 and α (h, 1) is assigned 0, and (c) h corresponding to r i (h, 1) , ..., r i (h, S ( a h)) key A cache process to load into Sshumemori, (d) product-sum operation unit, α (h, j) and read into the cache memory the x i (h, s (h )) (j) and r i (h, s ( h)) and T (h, j) = α (h, j) + x i (h, 1) (j) ・ r i (h, 1) +… + x i (h, S (h )) A product-sum operation process for calculating (j) · r i (h, S (h)) , and (e) after the product-sum operation process, the shift unit is subordinate to T (h, j) ω ( (f, j) bits are R (h, j) and T (h, j) other than R (h, j) is a new α (h, j + 1) shift process, and (f) After the shift process, the calculation control unit determines whether or not j = J (h), and (g) if j ≠ J (h) is determined in the determination process, the calculation control unit Is a loop process that returns j + 1 as a new j and returns the process to the product-sum operation process, and (h) when j = J (h) is determined in the determination process, the bit combination unit , J (h)), R (h, J (h)), ..., R (h, 1) bit combination R (h) = α (h, J (h)) | R (h, J (h)) | ... | A bit combination process for calculating R (h, 1), and sequentially for each h And rows, the addition unit, R = R (1) + ... + calculates R (H), multiple length arithmetic method comprising an adding step of outputting the R, is provided.

この方法では、R=x1・r1+…+xI・rI=R(1)+…+R(H)とし、R(h)毎に本発明を適用してRを算出する。この方法は、iの値が大きく、すべてのr1,…,rIを一度にキャッシュメモリに格納できない場合に有効である。 In this method, R = x 1 · r 1 +... + X I · r I = R (1) +... + R (H), and R is calculated by applying the present invention every R (h). This method is effective when the value of i is large and all r 1 ,..., R I cannot be stored in the cache memory at once.

また、この場合、上記キャッシュメモリの記憶容量は、何れか一つのxi(h,s(h))のデータ量とすべてのriのデータ量との合計値よりも小さく、当該xi(h,s(h))を分割して得られた一つのxi(h,s(h))(j)のデータ量と当該hに対応するri(h,1),...,ri(h,S(h))のデータ量との合計値よりも大きいことが望ましい。積和演算部がR(h)を算出するために必要なri(h,1),...,ri(h,S(h))を一度にキャッシュメモリに格納できるからである。 In this case, the storage capacity of the cache memory is smaller than the total value of the data amount of any one x i (h, s (h)) and the data amount of all r i , and the x i ( h, s (h)) is obtained by dividing one x i (h, s (h)) (j) data amount and r i (h, 1) , ..., It is desirable to be larger than the total value of r i (h, S (h)) and the data amount. This is because r i (h, 1) ,..., R i (h, S (h)) necessary for the product-sum operation unit to calculate R (h) can be stored in the cache memory at a time.

以上のように、本発明により、データサイズが大きな整数xiに対し、多倍長演算によってR=x1・r1+…+xI・rIの演算を高速で行うことが可能となる。 As described above, according to the present invention, it is possible to perform the calculation of R = x 1 · r 1 +... + X I · r I at high speed for multiple integers x i with a large data size. .

以下、本発明を実施するための最良の形態を図面を参照して説明する。
〔第1の実施形態〕
まず、本発明の第1の実施形態について説明する。
<構成>
図1は、本形態の多倍長演算装置1の構成を示したブロック図であり、図2は、図1のレジスタファイル50及び積和演算部60の詳細構成を例示したブロック図である。なお、図1,2における矢印はデータの流れを示すが、演算制御部90に対するデータの入出力の流れ、および、レジスタファイル50へのデータの入出力の流れの一部については、記載を省略している。
The best mode for carrying out the present invention will be described below with reference to the drawings.
[First Embodiment]
First, a first embodiment of the present invention will be described.
<Configuration>
FIG. 1 is a block diagram showing the configuration of the multiple length arithmetic device 1 of this embodiment, and FIG. 2 is a block diagram illustrating the detailed configuration of the register file 50 and the product-sum operation unit 60 of FIG. The arrows in FIGS. 1 and 2 indicate the flow of data, but the description of the flow of data input / output to the arithmetic control unit 90 and part of the flow of data input / output to the register file 50 is omitted. is doing.

図1に例示するように、本形態の多倍長演算装置1は、メインメモリ10、ビット分割部20、キャッシュメモリ30、レジスタ格納部40、レジスタファイル50、積和演算部60、シフト部70、ビット結合部80および演算制御部90を有している。
本形態の多倍長演算装置1は、CPU、RAM(Random Access Memory)、ROM(Compact Disc Read Only Memory)、ハードディスク装置、バス等からなる公知のコンピュータに所定のプログラムが読みこまれ、CPUがそのプログラムを実行することにより構築されるものである。
As illustrated in FIG. 1, the multiple length arithmetic device 1 of this embodiment includes a main memory 10, a bit division unit 20, a cache memory 30, a register storage unit 40, a register file 50, a product-sum operation unit 60, and a shift unit 70. The bit combination unit 80 and the operation control unit 90 are provided.
The multiple length arithmetic device 1 of this embodiment is configured such that a predetermined program is read into a known computer including a CPU, a RAM (Random Access Memory), a ROM (Compact Disc Read Only Memory), a hard disk device, a bus, and the like. It is constructed by executing the program.

すなわち、メインメモリ10は、例えばRAMやハードディスク装置等に相当する。また、キャッシュメモリ30は、メインメモリ10よりも高速にアクセス可能なメモリであり、例えばCPU内に構成されたキャッシュメモリに相当する。また、図2に例示するようにレジスタファイル50は、例えばCPU内に構成され、記憶可能なデータのビット長(レジスタ長)がそれぞれWである複数のレジスタ51を有している。なお、Wは積和演算部60の演算処理単位であり、例えばワード長に相当する。また、Wの値としては32ビットや64ビットを例示できるが、本発明はこれに限定されるものではない。   That is, the main memory 10 corresponds to, for example, a RAM or a hard disk device. The cache memory 30 is a memory that can be accessed at a higher speed than the main memory 10, and corresponds to, for example, a cache memory configured in the CPU. Further, as illustrated in FIG. 2, the register file 50 is configured in, for example, a CPU, and includes a plurality of registers 51 each having a bit length (register length) of storable data of W. Note that W is a calculation processing unit of the product-sum calculation unit 60 and corresponds to, for example, a word length. The value of W can be exemplified by 32 bits and 64 bits, but the present invention is not limited to this.

また、ビット分割部20、積和演算部60、シフト部70、ビット結合部80および演算制御部90は、例えば所定のプログラムが読み込まれたCPUに相当する。ここで、図2に例示した積和演算部60はKaratsuba法(非特許文献1参照)によって多倍長の乗算を行う場合のブロック図であり、ビット長W単位で乗算を行う乗算部61、減算部62、加算部63および桁上げ部64を具備する。   In addition, the bit division unit 20, the product-sum operation unit 60, the shift unit 70, the bit combination unit 80, and the operation control unit 90 correspond to, for example, a CPU into which a predetermined program has been read. Here, the product-sum operation unit 60 illustrated in FIG. 2 is a block diagram in the case where multiple multiplication is performed by the Karatsuba method (see Non-Patent Document 1), and a multiplication unit 61 that performs multiplication in units of bit length W. A subtracting unit 62, an adding unit 63, and a carry unit 64 are provided.

<多倍長演算方法>
次に、本形態の多倍長演算方法を説明する。
[前提]
本形態では、L(Lは2以上の自然数)ビット長のビットデータX∈{0,1}を所定の手順に従いI(Iは2以上の自然数)個に分割した0以上の整数xi(i∈{1,...,I}、xiはビットデータ)と、与えられた整数ri(i∈{1,...,I}、riはビットデータ)とを用い、R=x1・r1+…+xI・rIの多倍長演算を行う。また、そのための前処理として、整数xiと整数riとがメインメモリ10に格納されているものとする。
<Multiple length calculation method>
Next, the multiple length calculation method of this embodiment will be described.
[Assumption]
In this embodiment, L (L is a natural number of 2 or more) bit-length bit data Xε {0,1} L is divided into I (I is a natural number of 2 or more) pieces of an integer x i of 0 or more according to a predetermined procedure. (I∈ {1, ..., I}, x i is bit data) and given integer r i (i∈ {1, ..., I}, r i is bit data), R = x 1 · r 1 + ... + x I · r I multiple length calculation is performed. Further, it is assumed that integer x i and integer r i are stored in the main memory 10 as preprocessing for that purpose.

[R=x1・r1+…+xI・rIの多倍長演算]
図4は、本形態の多倍長演算方法を説明するためのフローチャートである。以下、この図を用いて説明を行っていく。
[Multiple-length operation of R = x 1 · r 1 + ... + x I · r I ]
FIG. 4 is a flowchart for explaining the multiple length arithmetic method of this embodiment. Hereinafter, description will be made with reference to this figure.

まず、ビット分割部20が、メインメモリ10からxiを読み込み、xiを各ビット長がω(j)であるxi(j)毎に分割し、各xi(j)をメインメモリ10に格納する(ステップS1/ビット分割過程)。図3(a)は、各xiをxi(j)毎に分割した様子を示した概念図である。ここで、j∈{1,...,J}であり、 Jは2以上の自然数の定数であり、xi=xi(J)|…|xi(1)(xi(J)|…|xi(1)はxi(J),…,xi(1)のビット結合)の関係を満たす。また、ω(j)は、所定のビット長Wよりも長く、xiのビット長よりも短い。また、本形態のキャッシュメモリ30の記憶容量は、何れか一つのxiのデータ量とすべてのriのデータ量との合計値よりも小さく、当該xiを分割して得られた一つのxi(j)のデータ量とすべてのriのデータ量との合計値よりも大きいものとする。また、前述のように、演算の効率化のためには、ω(j)はすべてのjについて一定であることが望ましい。 First, the bit dividing section 20 reads the x i from the main memory 10, by dividing the x i x i every (j) is the bit length omega (j), a main memory 10 each x i (j) (Step S1 / bit division process). FIG. 3A is a conceptual diagram showing how each x i is divided for each x i (j). Where j∈ {1, ..., J}, J is a constant of a natural number of 2 or more, and x i = x i (J) |… | x i (1) (x i (J) | ... | x i (1) satisfies the relationship of x i (J), ..., bit combination of x i (1)). Further, ω (j) is longer than the predetermined bit length W and shorter than the bit length of x i . In addition, the storage capacity of the cache memory 30 of the present embodiment is smaller than the total value of the data amount of any one x i and the data amount of all r i , and one obtained by dividing the x i It is assumed that it is larger than the total value of the data amount of x i (j) and the data amount of all r i . Further, as described above, it is desirable for ω (j) to be constant for all j in order to improve the efficiency of computation.

ステップS1の後、演算制御部90が、jに1を代入し、α(1)に0を代入し、それらの結果をレジスタ51に格納する(ステップS2/初期化過程)。なお、演算制御部90は、レジスタ51に格納されたjおよびα(j)の値を用いて各処理を制御する。   After step S1, the arithmetic control unit 90 substitutes 1 for j, substitutes 0 for α (1), and stores the result in the register 51 (step S2 / initialization process). The arithmetic control unit 90 controls each process using the values of j and α (j) stored in the register 51.

次に、演算制御部90の制御のもと、メインメモリ10に格納されたすべてのriがキャッシュメモリ30に読み込まれる(ステップS3)。 Next, under the control of the arithmetic control unit 90, all r i stored in the main memory 10 are read into the cache memory 30 (step S3).

その後、積和演算部60が、メインメモリ10からキャッシュメモリ30にxi(j)を読み込みつつ、α(j)とキャッシュメモリ30に読み込まれたxi(j)およびriとを用い、ワード長Wの多倍長演算によってT(j)=α(j)+x1(j)・r1+…+xI(j)・rIの演算を行い、その演算結果T(j)を出力する(ステップS4/積和演算過程)。すなわち、レジスタ格納部40が、キャッシュメモリ30に格納されたxi(j)(図3(a))をビット長W毎に分割したxi(j,p)〔p∈{1,...,P}, P≧2, xi(j)=xi(j,P)|…|xi(j,1)〕(図3(b))と、キャッシュメモリ30に格納されたri(図3(c))をビット長W毎に分割したri(q)〔q∈{1,...,Q}, ri=ri(Q)|…|ri(1)〕(図3(d))とを、レジスタ長Wのレジスタ51に格納しつつ、積和演算部60、シフト部70およびビット結合部80が、ワード長Wの多倍長演算によってT(j)=α(j)+x1(j)・r1+…+xI(j)・rIの演算を行って出力する。以下、積和演算過程(ステップS4)の具体例を説明する。 Thereafter, the product-sum operation unit 60 reads α i (j) from the main memory 10 into the cache memory 30 and uses α i (j) and x i (j) and r i read into the cache memory 30. T (j) = α (j) + x 1 (j) · r 1 +… + x I (j) · r I is calculated by multiple length operation of word length W, and the operation result T (j) Is output (step S4 / product-sum operation process). That is, the register storage unit 40 divides x i (j) (FIG. 3A) stored in the cache memory 30 for each bit length W, x i (j, p) [p∈ {1,. ., P}, P ≧ 2, x i (j) = x i (j, P) | ... | x i (j, 1)] (FIG. 3B) and r stored in the cache memory 30 r i (q) [q∈ {1,..., Q}, r i = r i (Q) | ... | r i (1) obtained by dividing i (FIG. 3 (c)) for each bit length W (FIG. 3 (d)) is stored in the register 51 having the register length W, and the product-sum operation unit 60, the shift unit 70, and the bit combination unit 80 perform T (j ) = α (j) + x 1 (j) · r 1 +... + x I (j) · r I is calculated and output. Hereinafter, a specific example of the product-sum operation process (step S4) will be described.

[積和演算過程(ステップS4)の具体例]
図5は、図4の積和演算過程(ステップS4)の具体例を説明するためのフローチャートである。以下、この図に沿って説明を行う。なお、ここではKaratuba法(非特許文献1)を用いた処理を例示する。しかし、本発明はこれに限定されるものではなく、その他の公知の多倍長演算方法(よく知られた筆算のアルゴリズムや高速フーリエ変換を用いたアルゴリズム等)を使用してステップS4を実行してもよい。また、説明の簡略化のため、ここではxi(j)及びriのビット長ω(j)がそれぞれ2ワード(2・W)以下の場合を例示する。
[Specific example of product-sum operation process (step S4)]
FIG. 5 is a flowchart for explaining a specific example of the product-sum operation process (step S4) of FIG. Hereinafter, description will be made with reference to this figure. In addition, the process using Karatuba method (nonpatent literature 1) is illustrated here. However, the present invention is not limited to this, and step S4 is performed using another known multiple-length arithmetic method (such as a well-known writing algorithm or an algorithm using fast Fourier transform). May be. Further, for the sake of simplicity of explanation, here, a case where the bit length ω (j) of x i (j) and r i is 2 words (2 · W) or less is exemplified.

まず、演算制御部90がiに1を代入し、iをレジスタ51に格納する(ステップS4a)。なお、演算制御部90は、レジスタ51に格納されたiを用いて各処理を制御する。   First, the arithmetic control unit 90 substitutes 1 for i, and stores i in the register 51 (step S4a). Note that the arithmetic control unit 90 controls each process using i stored in the register 51.

次に、演算制御部90は、キャッシュメモリ30にxi(j)が存在するか否かを判断する(ステップS4b)。ここで、キャッシュメモリ30にxi(j)が格納されていた場合、演算制御部90は処理をステップS4dに移し、キャッシュメモリ30にxi(j)が格納されていなかった場合、メインメモリ10からキャッシュメモリ30にxi(j)を読み込んで処理をステップS4dに移す。 Next, the arithmetic control unit 90 determines whether x i (j) exists in the cache memory 30 (step S4b). Here, if x i (j) is stored in the cache memory 30, the arithmetic control unit 90 moves the process to step S4d. If x i (j) is not stored in the cache memory 30, the main memory 10 reads x i (j) into the cache memory 30 and moves the process to step S4d.

ステップS4dでは、xi(j)をビット長W毎に分割したxi(j,p)〔p∈{1,2}, xi(j)=xi(j,2)|xi(j,1)〕と、riをビット長W毎に分割したri(q)〔q∈{1,2}, ri=ri(2)|ri(1)〕とを用い、si(j,1)=xi(j,1)・ri(1), si(j,3)=xi(j,2)・ri(2), si(j,2)={xi(j,2)-xi(j,1)}・(ri(1)-ri(2))+si(j,1)+si(j,3)を算出する(ステップS4d)。具体的には、例えば、レジスタ格納部40が、xi(j,1)及びri(1)をキャッシュメモリ30から読み込んでレジスタ51に格納し、乗算部61(図2)が、格納されたxi(j,1)及びri(1)を用いてsi(j,1)=xi(j,1)・ri(1)を算出し、si(j,1)をレジスタ51に格納する。また、例えば、レジスタ格納部40が、xi(j,2)及びri(2)をキャッシュメモリ30から読み込んでレジスタ51に格納し、乗算部61が、格納されたxi(j,2)及びri(2)を用いてsi(j,3)=xi(j,2)・ri(2)を算出し、si(j,3)をレジスタ51に格納する。さらに、乗算部61,減算部62および加算部63が、レジスタ51に格納されたデータを用いてsi(j,2)={xi(j,2)-xi(j,1)}・(ri(1)-ri(2))+si(j,1)+si(j,3)を算出し、si(j,2) をレジスタ51に格納する。なお、本形態のキャッシュメモリ30の記憶容量は、一つのxi(j)のデータ量とすべてのriのデータ量との合計値よりも大きいため、キャッシュメモリ30にさらに他の演算やテンポラリ領域が確保できるのであれば、si(j,1)=xi(j,1)・ri(1), si(j,3)=xi(j,2)・ri(2), si(j,2)={xi(j,2)-xi(j,1)}・(ri(1)-ri(2))+si(j,1)+si(j,3)の演算に必要なxi(j)及びriはキャッシュメモリ30から溢れることはない。この場合、ステップS4dにおいてメインメモリ10へアクセスする必要はない(本形態の特徴)。 In step S4d, x i obtained by dividing x i a (j) for each bit length W (j, p) [p∈ {1,2}, x i ( j) = x i (j, 2) | x i ( j, 1)] and r i (q) [q∈ {1,2}, r i = r i (2) | r i (1)] obtained by dividing r i for each bit length W, s i (j, 1) = x i (j, 1) ・ r i (1), s i (j, 3) = x i (j, 2) ・ r i (2), s i (j, 2 ) = {x i (j, 2) -x i (j, 1)} ・ (r i (1) -r i (2)) + s i (j, 1) + s i (j, 3) Calculate (step S4d). Specifically, for example, the register storage unit 40 reads x i (j, 1) and r i (1) from the cache memory 30 and stores them in the register 51, and the multiplication unit 61 (FIG. 2) is stored. X i (j, 1) and r i (1) are used to calculate s i (j, 1) = x i (j, 1) ・ r i (1), and s i (j, 1) is calculated Store in the register 51. In addition, for example, the register storage unit 40 reads x i (j, 2) and r i (2) from the cache memory 30 and stores them in the register 51, and the multiplication unit 61 stores the stored x i (j, 2). ) And r i (2), s i (j, 3) = x i (j, 2) · r i (2) is calculated, and s i (j, 3) is stored in the register 51. Further, the multiplication unit 61, the subtraction unit 62, and the addition unit 63 use the data stored in the register 51, so that s i (j, 2) = {x i (j, 2) −x i (j, 1)} Calculate (r i (1) −r i (2)) + s i (j, 1) + s i (j, 3) and store s i (j, 2) in the register 51. Note that the storage capacity of the cache memory 30 of this embodiment is larger than the total value of the data amount of one x i (j) and the data amount of all r i , so that other operations and temporary operations are added to the cache memory 30. If the area can be secured, s i (j, 1) = x i (j, 1) ・ r i (1), s i (j, 3) = x i (j, 2) ・ r i (2 ), s i (j, 2) = {x i (j, 2) -x i (j, 1)} ・ (r i (1) -r i (2)) + s i (j, 1) + x i (j) and r i necessary for the calculation of s i (j, 3) do not overflow from the cache memory 30. In this case, it is not necessary to access the main memory 10 in step S4d (characteristic of this embodiment).

ステップS4dの後、演算制御部90がレジスタ51に格納されたiがIであるか否かの判断を行い(ステップS4e)、i=Iでなければi+1を新たなIとしてレジスタ51に格納した後(ステップS4f)、処理をステップS4bに戻す。一方、i=Iであれば、加算部63が、レジスタ51のデータを用いてs(j,1)=s1(j,1)+...+sI(j,1), s(j,2)=s1(j,2)+...+sI(j,2), s(j,3)=s1(j,3)+...+sI(j,3)を算出し、s(j,1), s(j,2), s(j,3)をレジスタ51に格納する(ステップS4g)。 After step S4d, the arithmetic control unit 90 determines whether i stored in the register 51 is I (step S4e). If i = I is not satisfied, i + 1 is set as a new I in the register 51. After storing (step S4f), the process returns to step S4b. On the other hand, if i = I, the adder 63 uses the data in the register 51 to s (j, 1) = s 1 (j, 1) + ... + s I (j, 1), s ( j, 2) = s 1 (j, 2) + ... + s I (j, 2), s (j, 3) = s 1 (j, 3) + ... + s I (j, 3 ) And s (j, 1), s (j, 2), s (j, 3) are stored in the register 51 (step S4g).

ステップS4gの後、加算部63が、レジスタ51のデータを用いてs(j,1)+α(j)を算出し、桁上げ部64が、その演算結果の下位WビットをT(j,1)とし、それ以外のビットをβ(j,2)とし、それらをレジスタ51に格納する(ステップS4h)。次に、加算部63が、レジスタ51のデータを用いてs(j,2)+β(j,2)を算出し、桁上げ部64が、その演算結果の下位WビットをT(j,2)とし、それ以外のビットをβ(j,3)とし、それらをレジスタ51に格納する(ステップS4i)。次に、加算部63が、レジスタ51のデータを用いてs(j,3)+β(j,3)を算出し、その演算結果をT(j,3)としてレジスタ51に格納する(ステップS4j)。   After step S4g, the adding unit 63 calculates s (j, 1) + α (j) using the data in the register 51, and the carry unit 64 calculates the lower W bits of the calculation result as T (j, 1), the other bits are set to β (j, 2), and they are stored in the register 51 (step S4h). Next, the adding unit 63 calculates s (j, 2) + β (j, 2) using the data in the register 51, and the carry unit 64 calculates the lower W bits of the calculation result as T (j, 2), the other bits are set to β (j, 3), and they are stored in the register 51 (step S4i). Next, the adder 63 calculates s (j, 3) + β (j, 3) using the data in the register 51, and stores the calculation result as T (j, 3) in the register 51 (step S4j).

その後、ビット結合部80がレジスタ51に格納されているT(j,3), T(j,2), T(j,1)のビット結合T(j)=T(j,3)|T(j,2)|T(j,1)を出力する(ステップS4k/[積和演算過程(ステップS4)の具体例]の説明終わり)。
積和演算過程(ステップS4)後、シフト部70が、T(j)の下位ω(j)ビットをRjとし、T(j)のRj以外のビットを新たなα(j+1)とし、これらを出力する(ステップS5/シフト過程)。
After that, the bit combination unit 80 stores the bit combination T (j) = T (j, 3) | T of T (j, 3), T (j, 2), T (j, 1) stored in the register 51. (j, 2) | T (j, 1) is output (end of description of step S4k / [specific example of product-sum operation process (step S4)]).
Product-sum operation process (step S4) after the shift unit 70, T lower (j) omega (j) bits as R j, T new bits other than R j in (j) α (j + 1 ) These are output (step S5 / shift process).

シフト過程(ステップS5)後、演算制御部90が、レジスタ51に格納したjを参照しj=Jであるか否かを判定する(ステップS6/判定過程)。ここで、j≠Jと判定された場合、演算制御部90は、j+1を新たなjとして新たなjをレジスタ51に格納し、処理を積和演算過程(ステップS4)に戻す(ステップS7/ループ過程)。一方、判定過程(ステップS6)でj=Jと判定された場合、ビット結合部80が、α(J),RJ,...,R1のビット結合R=α(J)|RJ|…|R1を算出し、Rを出力する(ステップS8/ビット結合過程)。 After the shift process (step S5), the arithmetic control unit 90 refers to j stored in the register 51 and determines whether j = J (step S6 / determination process). If it is determined that j ≠ J, the arithmetic control unit 90 stores j + 1 as a new j in the register 51 and returns the process to the product-sum operation process (step S4) (step S4). S7 / loop process). On the other hand, the determination process when it is determined that j = J in (step S6), and the bit coupling portion 80, α (J), R J , ..., bit combination of R 1 R = α (J) | R J | ... | calculates the R 1, and outputs the R (step S8 / bit binding process).

以上のように、本形態では、キャッシュメモリ30にさらに他の演算やテンポラリ領域が確保できるのであれば、ステップS4dにおいてメインメモリ10へアクセスする必要はないため、演算速度が向上する。   As described above, in this embodiment, if another calculation or a temporary area can be secured in the cache memory 30, it is not necessary to access the main memory 10 in step S4d, so that the calculation speed is improved.

〔第2の実施形態〕
次に、本発明の第2の実施形態について説明する。
本形態は、第1の実施形態の変形例であり、積和演算過程(ステップS4)において、積和演算部60が、xi(j)をビット長W−a(W>a≧0)毎に分割したxi(j,p)〔p∈{1,...,P}, Pは1以上の自然数, xi(j)はxi(j,P),...,xi(j,1)のビット結合xi(j)=xi(j,P)|…|xi(j,1)〕と、riをビット長W−b(W>b≧0, I≦2a+b)毎に分割したri(q)〔q∈{1,...,Q}, Qは1以上の自然数, riはri(Q),...,ri(1)のビット結合ri=ri(Q)|…|ri(1)〕とを用い、ビット長W単位で演算を行って1組以上のp,qについてx1(j,p)・r1(q)+…+xI(j,p)・rI(q)を算出し、当該演算結果を用いてT(j)=α(j)+x1(j)・r1+…+xI(j)・rIを算出する点のみが第1の実施形態と相違する。以下では、この相違点のみを説明する。
[Second Embodiment]
Next, a second embodiment of the present invention will be described.
The present embodiment is a modification of the first embodiment. In the product-sum operation process (step S4), the product-sum operation unit 60 sets x i (j) to a bit length W−a (W> a ≧ 0). X i (j, p) [p∈ {1, ..., P}, P is a natural number greater than 1, x i (j) is x i (j, P), ..., x i (j, 1) bit combination x i (j) = x i (j, P) | ... | x i (j, 1)], and r i is a bit length W−b (W> b ≧ 0, R i (q) [q∈ {1, ..., Q}, Q is a natural number of 1 or more, r i is r i (Q), ..., r divided every I ≦ 2 a + b ) i (1) bit combination r i = r i (Q) | ... | r i (1)], and the operation is performed in units of bit length W, and x 1 (j, p) ・ r 1 (q) +… + x I (j, p) ・ r I (q) is calculated and T (j) = α (j) + x 1 (j) ・Only the point of calculating r 1 +... + x I (j) · r I is different from the first embodiment. Only this difference will be described below.

<実施例1>
本形態の実施例1は、P=Q=2、b>aとし(図6(a),(b))、筆算のアルゴリズムによってビット長W単位の乗算を行う例である。
図7は、第2の実施形態の実施例1におけるステップS4の処理を説明するためのフローチャートである。以下、この図に沿って本実施例2におけるステップS4の処理を説明する。
<Example 1>
The first embodiment of the present embodiment is an example in which P = Q = 2 and b> a (FIGS. 6A and 6B), and multiplication is performed in units of bit length W by a writing algorithm.
FIG. 7 is a flowchart for explaining the processing in step S4 in Example 1 of the second embodiment. Hereinafter, the processing in step S4 in the second embodiment will be described with reference to FIG.

本実施例1のステップS4a〜4cは、第1の実施形態と同じであるため説明を省略する。本実施例1では、ステップS4bまたはS4cの後、キャッシュメモリ30に読み込まれた、xi(j)をビット長W-a毎に分割したxi(j,p)〔p∈{1,2}, xi(j)=xi(j,2)|xi(j,1)〕と、riをビット長W-b(b>a)毎に分割したri(q)〔q∈{1,2}, ri=ri(2)|ri(1)〕とを用い、si(j,1)=xi(j,1)・ri(1), si(j,2)=xi(j,1)・ri(2), si(j,3)=xi(j,2)・ri(1), si(j,4)=xi(j,2)・ri(2)を算出する(ステップS4m)。 Since Steps S4a to 4c of Example 1 are the same as those of the first embodiment, description thereof is omitted. In the first embodiment, after step S4b or S4c, loaded into the cache memory 30, x was divided x i a (j) for each bit length Wa i (j, p) [p∈ {1,2}, x i (j) = x i (j, 2) | x i (j, 1) ] and, r i (q) [q∈ {1 obtained by dividing the r i for each bit length Wb (b> a), 2}, r i = r i (2) | r i (1)] and s i (j, 1) = x i (j, 1) ・ r i (1), s i (j, 2 ) = x i (j, 1) ・ r i (2), s i (j, 3) = x i (j, 2) ・ r i (1), s i (j, 4) = x i (j , 2) · r i (2) is calculated (step S4m).

具体的には、例えば、レジスタ格納部40が、xi(j,1)及びri(1)をキャッシュメモリ30から読み込んでレジスタ51に格納し、乗算部61(図2)が、格納されたxi(j,1)及びri(1)を用いてsi(j,1)=xi(j,1)・ri(1)を算出し、si(j,1)をレジスタ51に格納する。また、例えば、レジスタ格納部40が、xi(j,2)及びri(2)をキャッシュメモリ30から読み込んでレジスタ51に格納し、乗算部61が、格納されたxi(j,2)及びri(2)を用いてsi(j,3)=xi(j,2)・ri(2)を算出し、si(j,3)をレジスタ51に格納する。さらに、乗算部61が、レジスタ51に格納されたデータを用いてsi(j,2)=xi(j,1)・ri(2)およびsi(j,3)=xi(j,2)・ri(1)を算出し、si(j,2)およびsi(j,3)をレジスタ51に格納する。なお、xi(j,p)のビット長はW-aであり、ri(q)のビット長はW-bであるため、si(j,1), si(j,2), si(j,3), si(j,4)は、何れも2・W-(a+b)〔=(W-a)+(W-b)〕ビットのビット列となる。 Specifically, for example, the register storage unit 40 reads x i (j, 1) and r i (1) from the cache memory 30 and stores them in the register 51, and the multiplication unit 61 (FIG. 2) is stored. X i (j, 1) and r i (1) are used to calculate s i (j, 1) = x i (j, 1) ・ r i (1), and s i (j, 1) is calculated Store in the register 51. In addition, for example, the register storage unit 40 reads x i (j, 2) and r i (2) from the cache memory 30 and stores them in the register 51, and the multiplication unit 61 stores the stored x i (j, 2). ) And r i (2), s i (j, 3) = x i (j, 2) · r i (2) is calculated, and s i (j, 3) is stored in the register 51. Further, the multiplication unit 61 uses the data stored in the register 51 to generate s i (j, 2) = x i (j, 1) · r i (2) and s i (j, 3) = x i ( j, 2) · r i (1) is calculated, and s i (j, 2) and s i (j, 3) are stored in the register 51. Since the bit length of x i (j, p) is Wa and the bit length of r i (q) is Wb, s i (j, 1), s i (j, 2), s i ( j, 3) and s i (j, 4) are all bit strings of 2 · W− (a + b) [= (Wa) + (Wb)] bits.

ステップS4mの後、演算制御部90がレジスタ51に格納されたiがIであるか否かの判断を行い(ステップS4e)、i=Iでなければi+1を新たなIとしてレジスタ51に格納した後(ステップS4f)、処理をステップS4bに戻す。一方、i=Iであれば、加算部63が、レジスタ51のデータを用いてs(j,1)=s1(j,1)+...+sI(j,1), s(j,2)=s1(j,2)+...+sI(j,2), s(j,3)=s1(j,3)+...+sI(j,3),s(j,4)=s1(j,4)+...+sI(j,4)を算出し、s(j,1), s(j,2), s(j,3) , s(j,4)をレジスタ51に格納する(ステップS4n)。なお、本形態では、si(j,1), si(j,2), si(j,3), si(j,4)は、何れも2・W-(a+b)〔=(W-a)+(W-b)〕ビットのビット列となり、I≦2a+bを満たすため、s(j,1), s(j,2), s(j,3) , s(j,4)は何れも2・Wビット以下のビット列となる。すなわち、ステップS4nの演算において2ワード以上の桁上がり処理は不要である(本形態の特徴)。 After step S4m, the arithmetic control unit 90 determines whether i stored in the register 51 is I (step S4e). If i = I is not satisfied, i + 1 is set as a new I in the register 51. After storing (step S4f), the process returns to step S4b. On the other hand, if i = I, the adder 63 uses the data in the register 51 to s (j, 1) = s 1 (j, 1) + ... + s I (j, 1), s ( j, 2) = s 1 (j, 2) + ... + s I (j, 2), s (j, 3) = s 1 (j, 3) + ... + s I (j, 3 ), s (j, 4) = s 1 (j, 4) + ... + s I (j, 4) is calculated and s (j, 1), s (j, 2), s (j, 3), s (j, 4) is stored in the register 51 (step S4n). In this embodiment, s i (j, 1), s i (j, 2), s i (j, 3), and s i (j, 4) are all 2 · W− (a + b) [= (Wa) + (Wb)] bit sequence and satisfy I ≦ 2 a + b , so s (j, 1), s (j, 2), s (j, 3), s (j, Each of 4) is a bit string of 2 · W bits or less. That is, carry processing of 2 words or more is unnecessary in the calculation of step S4n (characteristic of this embodiment).

ステップS4nの後、加算部63が、レジスタ51のデータを用いてs(j,1)+α(j)を算出し、桁上げ部64が、その演算結果の下位W-bビットをT(j,1)とし、それ以外のビットをβ(j,2)とし、それらをレジスタ51に格納する(ステップS4p)。次に、加算部63が、レジスタ51のデータを用いてs(j,2)+β(j,2)を算出し、桁上げ部64が、その演算結果の下位b-a〔=(W-a)-(W-b)〕ビットをT(j,2)とし、それ以外のビットをβ(j,3)とする(ステップS4q)。次に、加算部63が、レジスタ51のデータを用いてs(j,3)+β(j,3)を算出し、桁上げ部64が、その演算結果の下位(W-b)〔=(W-a)+(W-b)-(W-a)〕ビットをT(j,3)とし、それ以外のビットをβ(j,4)とする(ステップS4r)。次に、加算部63が、レジスタ51のデータを用いてs(j,4)+β(j,4)を算出し、その演算結果をT(j,4)としてレジスタ51に格納する(ステップS4s)。   After step S4n, the adding unit 63 calculates s (j, 1) + α (j) using the data in the register 51, and the carry unit 64 calculates the lower Wb bit of the operation result as T (j, 1), the other bits are set to β (j, 2), and they are stored in the register 51 (step S4p). Next, the adding unit 63 calculates s (j, 2) + β (j, 2) using the data in the register 51, and the carry unit 64 uses the lower-order ba [= (Wa) − (Wb)] The bits are set to T (j, 2), and the other bits are set to β (j, 3) (step S4q). Next, the adding unit 63 calculates s (j, 3) + β (j, 3) using the data in the register 51, and the carry unit 64 calculates the lower order (Wb) [= (Wa ) + (Wb)-(Wa)] bits are set to T (j, 3), and other bits are set to β (j, 4) (step S4r). Next, the adder 63 calculates s (j, 4) + β (j, 4) using the data in the register 51, and stores the calculation result as T (j, 4) in the register 51 (step S1). S4s).

その後、ビット結合部80が、レジスタ51に格納されているT(j,4),T(j,3), T(j,2), T(j,1)のビット結合T(j)=T(j,4)|T(j,3)|T(j,2)|T(j,1)を出力する(ステップS4t)。
<実施例2>
本形態の実施例2は、P=Q=2、b=aとし(図6(c),(d))、Karatsuba法(非特許文献1)によってビット長W単位の乗算を行う例である。
図8は、第2の実施形態の実施例2におけるステップS4の処理を説明するためのフローチャートである。以下、この図に沿って本実施例2におけるステップS4の処理を説明する。第1の実施形態と本実施例2との相違点は、ステップS4d(図5)がステップS4t(図8)に置換される点のみである。
After that, the bit combination unit 80 generates a bit combination T (j) = T (j, 4), T (j, 3), T (j, 2), T (j, 1) stored in the register 51. T (j, 4) | T (j, 3) | T (j, 2) | T (j, 1) is output (step S4t).
<Example 2>
Example 2 of the present embodiment is an example in which P = Q = 2 and b = a (FIGS. 6C and 6D), and multiplication is performed in units of bit length W by the Karatsuba method (Non-patent Document 1). .
FIG. 8 is a flowchart for explaining the processing in step S4 in Example 2 of the second embodiment. Hereinafter, the processing in step S4 in the second embodiment will be described with reference to FIG. The only difference between the first embodiment and the second embodiment is that step S4d (FIG. 5) is replaced with step S4t (FIG. 8).

本実施例のステップS4tでは、xi(j)をビット長W-a毎に分割したxi(j,p)〔p∈{1,2}, xi(j)=xi(j,2)|xi(j,1)〕と、riをビット長W-b毎に分割したri(q)〔q∈{1,2}, ri=ri(2)|ri(1)〕とを用い、si(j,1)=xi(j,1)・ri(1), si(j,3)=xi(j,2)・ri(2), si(j,2)={xi(j,2)-xi(j,1)}・(ri(1)-ri(2))+si(j,1)+si(j,3)を算出する(ステップS4t)。ここで、xi(j,p)のビット長はW-aであり、ri(q)のビット長はW-bであるため、si(j,1), si(j,2), si(j,3)は、何れも2・W-(a+b)〔=(W-a)+(W-b)〕ビットのビット列となる。また、I≦2a+bを満たすため、その後のステップS4gで算出されるs(j,1), s(j,2), s(j,3)は、何れも2・Wビット以下のビット列となる。すなわち、ステップS4gの演算において2ワード以上の桁上がり処理は不要である(本形態の特徴)。 In step S4t of this embodiment, x i (j, p) [pε {1,2}, x i (j) = x i (j, 2)) obtained by dividing x i (j) for each bit length Wa. | x i (j, 1) and], r i obtained by dividing the r i for each bit length Wb (q) [q∈ {1,2}, r i = r i (2) | r i (1) ] , S i (j, 1) = x i (j, 1) ・ r i (1), s i (j, 3) = x i (j, 2) ・ r i (2), s i (j, 2) = {x i (j, 2) -x i (j, 1)} ・ (r i (1) -r i (2)) + s i (j, 1) + s i (j , 3) is calculated (step S4t). Here, since the bit length of x i (j, p) is Wa and the bit length of r i (q) is Wb, s i (j, 1), s i (j, 2), s i (j, 3) is a bit string of 2 · W− (a + b) [= (Wa) + (Wb)] bits. In order to satisfy I ≦ 2 a + b , s (j, 1), s (j, 2), and s (j, 3) calculated in step S4g are all 2 · W bits or less. It becomes a bit string. That is, carry processing of 2 words or more is unnecessary in the calculation of step S4g (characteristic of this embodiment).

以上のように、本形態では、x1(j,p)・r1(q)+…+xI(j,p)・rI(q)は何れも2・Wビット以下のビット列となる。よって、x1(j,p)・r1(q)+…+xI(j,p)・rI(q)の演算において2ワード以上の桁上がり処理は不要となり、演算コストを低減させることができる。 As described above, in this embodiment, x 1 (j, p) · r 1 (q) + ... + x I (j, p) · r I (q) are all bit strings of 2 · W bits or less. . Therefore, it is not necessary to carry more than 2 words in the calculation of x 1 (j, p) · r 1 (q) +… + x I (j, p) · r I (q), reducing the operation cost. be able to.

〔第3の実施形態〕
本形態は、第1,2の実施形態の変形例である。第1,2の実施形態との相違点は、ビット分割部20で分割された各xi(j)が、x1(1),...,xI(1),x1(2),...,xI(2),...,x1(J),...,xI(J)の順序でバースト転送可能にメインメモリ10に格納され、x1(1),...,xI(1),x1(2),...,xI(2),...,x1(J),...,xI(J)の順序で順次キャッシュメモリ30に読み込まれる点である。
[Third Embodiment]
This embodiment is a modification of the first and second embodiments. The difference from the first and second embodiments is that each x i (j) divided by the bit dividing unit 20 is x 1 (1),..., X I (1), x 1 (2). , ..., x I (2), ..., x 1 (J), ..., x I (J) are stored in the main memory 10 so that burst transfer is possible, and x 1 (1), ..., x I (1), x 1 (2), ..., x I (2), ..., x 1 (J), ..., x I (J) It is a point read into the memory 30.

図9は、メインメモリ10に格納されたx1(1),...,xI(1),x1(2),...,xI(2),...,x1(J),...,xI(J)を例示した概念図である。図9に例示するように、本形態では、x1(1),...,xI(1),x1(2),...,xI(2),...,x1(J),...,xI(J)の順序で各xi(j)がメインメモリ10に格納される。これにより、メインメモリ10に格納されたx1(1)の先頭アドレスを指定するだけで、x1(1),...,xI(1),x1(2),...,xI(2),...,x1(J),...,xI(J)の順序でxi(j)を順次キャッシュメモリ30にバースト転送することができる。図4のステップS4では、x1(1),...,xI(1),x1(2),...,xI(2),...,x1(J),...,xI(J)の順序でxi(j)が必要となるため、各xi(j)をx1(1),...,xI(1),x1(2),...,xI(2),...,x1(J),...,xI(J)の順序でバースト転送可能にメインメモリ10に格納する構成は、本発明にとって好ましい。 FIG. 9 shows x 1 (1), ..., x I (1), x 1 (2), ..., x I (2), ..., x 1 ( It is the conceptual diagram which illustrated J), ..., x I (J). As illustrated in FIG. 9, in this embodiment, x 1 (1), ..., x I (1), x 1 (2), ..., x I (2), ..., x 1 Each x i (j) is stored in the main memory 10 in the order of (J),..., X I (J). Thus, only by specifying the head address of x 1 (1) stored in the main memory 10, x 1 (1), ..., x I (1), x 1 (2), ..., x I (2), ..., x 1 (J), ..., can be burst transfer x i a (j) sequentially into the cache memory 30 in the order of x I (J). In step S4 of FIG. 4, x 1 (1), ..., x I (1), x 1 (2), ..., x I (2), ..., x 1 (J) ,. .., x I for x i (j) is required in the order (J), each of x i and (j) x 1 (1) , ..., x I (1), x 1 (2) , ..., x I (2), ..., x 1 (J), ..., x I (J) are preferably stored in the main memory 10 so as to be capable of burst transfer. .

〔第4の実施形態〕
本形態は、第1,2の実施形態の変形例であり、R=x1・r1+…+xI・rI=R(1)+…+R(H)とし、R(h)(h∈{1,...,H},Hは2以上の整数の定数)毎に本発明の手法を適用するものである(本形態の特徴)。本形態は、Iの値が大きく、すべてのr1,...,rIを同時にキャッシュメモリ30上に格納できない場合にメインメモリ10へのアクセス回数を削減できる手法である。すなわち、キャッシュメモリ30の記憶容量が、何れか一つのxi(h,s(h))のデータ量とすべてのriのデータ量との合計値よりも小さく、当該xi(h,s(h))を分割して得られた一つのxi(h,s(h))(j)のデータ量と当該hに対応するri(h,1),...,ri(h,S(h))のデータ量との合計値よりも大きい場合に特に有効な手法である。ただし、S(h)は2以上の整数であり、s(h)∈{1,...,S(h)}であり、i(h,s(h))∈{i(h,1),...,i(h,S(h))}⊂{1,...,I}であり、{i(1,1),...,i(1,S(1)),...,i(H,1),...,i(H,S(H))}={1,...,I}であり、R(h)=xi(h,1)・ri(h,1)+…+xi(h,S(h))・ri(h,S(h))である。
[Fourth Embodiment]
The present embodiment is a modification of the first and second embodiments, and R = x 1 · r 1 + ... + x I · r I = R (1) + ... + R (H) and R (h) The method of the present invention is applied every time (h∈ {1,..., H}, H is an integer constant equal to or greater than 2) (feature of this embodiment). In this embodiment, the number of accesses to the main memory 10 can be reduced when the value of I is large and all r 1 ,..., R I cannot be stored in the cache memory 30 at the same time. That is, the storage capacity of the cache memory 30 is smaller than the total value of the data amount of any one of x i (h, s (h)) and the data amount of all r i , and the x i (h, s (h)) is obtained by dividing the data amount of one x i (h, s (h)) (j) and r i (h, 1) , ..., r i ( This is a particularly effective method when it is larger than the total value of the data amount of h, S (h)) . Where S (h) is an integer greater than or equal to 2, s (h) ∈ {1, ..., S (h)}, and i (h, s (h)) ∈ {i (h, 1 ), ..., i (h, S (h))} ⊂ {1, ..., I} and {i (1,1), ..., i (1, S (1)) , ..., i (H, 1), ..., i (H, S (H))} = {1, ..., I} and R (h) = x i (h, 1 ) · R i (h, 1) +... + X i (h, S (h)) · r i (h, S (h)) .

以下では、第1,2の実施形態との相違点を中心に説明を行い、第1,2の実施形態と共通する事項については説明を省略する。
<構成>
図10は、本形態の多倍長演算装置100の構成を示したブロック図である。なお、図10における矢印はデータの流れを示すが、演算制御部90に対するデータの入出力の流れ、および、レジスタファイル50へのデータの入出力の流れの一部については、記載を省略している。
Below, it demonstrates centering on difference with 1st, 2nd embodiment, and abbreviate | omits description about the matter which is common in 1st, 2nd embodiment.
<Configuration>
FIG. 10 is a block diagram showing a configuration of the multiple length arithmetic apparatus 100 of the present embodiment. The arrows in FIG. 10 indicate the flow of data, but the description of the flow of data input / output to the arithmetic control unit 90 and part of the flow of data input / output to the register file 50 is omitted. Yes.

図10に例示するように、本形態の多倍長演算装置100は、メインメモリ10、ビット分割部20、キャッシュメモリ30、レジスタ格納部40、レジスタファイル50、積和演算部60、シフト部70、ビット結合部80、演算制御部90および加算部110を有している。なお、図10において図1と処理機能が同一な部分については、図1と同じ符号を付している。   As illustrated in FIG. 10, the multiple length arithmetic device 100 according to this embodiment includes a main memory 10, a bit division unit 20, a cache memory 30, a register storage unit 40, a register file 50, a product-sum operation unit 60, and a shift unit 70. , A bit combination unit 80, an operation control unit 90, and an addition unit 110. 10 that have the same processing functions as those in FIG. 1 are denoted by the same reference numerals as those in FIG.

<多倍長演算方法>
次に、本形態の多倍長演算方法を説明する。
[前提]
第1の実施形態で説明したのと同じである。
[R=x1・r1+…+xI・rIの多倍長演算]
図11は、本形態の多倍長演算方法を説明するためのフローチャートである。以下、この図を用いて説明を行っていく。
まず、演算制御部90が、hに1を代入し、hをレジスタファイル50のレジスタ51に格納する(ステップS11)。演算制御部90は、レジスタ51に格納されたhを用いて各処理を制御する。
<Multiple length calculation method>
Next, the multiple length calculation method of this embodiment will be described.
[Assumption]
This is the same as described in the first embodiment.
[Multiple-length operation of R = x 1 · r 1 + ... + x I · r I ]
FIG. 11 is a flowchart for explaining the multiple length arithmetic method of this embodiment. Hereinafter, description will be made with reference to this figure.
First, the arithmetic control unit 90 substitutes 1 for h, and stores h in the register 51 of the register file 50 (step S11). The arithmetic control unit 90 controls each process using h stored in the register 51.

次に、ビット分割部20が、メインメモリ10からxi(h,s(h))を読み込み、xi(h,s(h))を各ビット長がω(h,j)であるxi(h,s(h))(j)毎に分割し、各xi(h,s(h))(j)をメインメモリ10に格納する(ステップS12/ビット分割過程)。なお、xi(h,s(h))はxi(h,s(h))(J(h)),…,xi(h,s(h))(1)のビット結合xi(h,s(h))=xi(h,s(h))(J(h))|…|xi(h,s(h))(1)であり、J(h)は2以上の自然数の定数であり、j∈{1,...,J(h)}である。
次に、演算制御部90が、jに1を代入し、α(h,1)に0を代入し、それらをレジスタファイル50のレジスタ51に格納する(ステップS13/初期化過程)。なお、演算制御部90は、レジスタ51に格納されたjおよびα(h,1)を用いて各処理を制御する。また、演算制御部90の制御のもと、hに対応するri(h,1),...,ri(h,S(h))がキャッシュメモリに読み込まれる(ステップS14/キャッシュ過程)。
Next, the bit dividing unit 20 reads x i (h, s (h)) from the main memory 10 and sets x i (h, s (h)) to x with each bit length being ω (h, j). Each i (h, s (h)) (j) is divided and each x i (h, s (h)) (j) is stored in the main memory 10 (step S12 / bit division process). X i (h, s (h)) is the bit combination x i of x i (h, s (h)) (J (h)), ..., x i (h, s (h)) (1) (h, s (h)) = x i (h, s (h)) (J (h)) |… | x i (h, s (h)) (1) where J (h) is 2 These are natural number constants, j∈ {1, ..., J (h)}.
Next, the arithmetic control unit 90 substitutes 1 for j, substitutes 0 for α (h, 1), and stores them in the register 51 of the register file 50 (step S13 / initialization process). The arithmetic control unit 90 controls each process using j and α (h, 1) stored in the register 51. Also, under the control of the arithmetic control unit 90, r i (h, 1) ,..., R i (h, S (h)) corresponding to h are read into the cache memory (step S14 / cache process) ).

その後、積和演算部60が、xi(h,s(h))(j)を順次キャッシュメモリ30に読み込みながら、α(h,j)とxi(h,s(h))(j)およびri(h,s(h))とを用い、T(h,j)=α(h,j)+xi(h,1)(j)・ri(h,1)+…+xi(h,S(h))(j)・ri(h,S(h))の演算を行い、T(h,j)を出力する(ステップS15/積和演算過程)。積和演算過程後(ステップS15)、シフト部70が、T(h,j)の下位ω(h,j)ビットをR(h,j)とし、T(h,j)のR(h,j)以外のビットを新たなα(h,j+1)とし、R(h,j)とα(h,j+1)とを出力する(ステップS16/シフト過程)。 Thereafter, the product-sum operation unit 60 sequentially reads x i (h, s (h)) (j) into the cache memory 30, while α (h, j) and x i (h, s (h)) (j ) And r i (h, s (h)) and T (h, j) = α (h, j) + x i (h, 1) (j) · r i (h, 1) +… + x i (h, S (h)) (j) · r i (h, S (h)) is calculated and T (h, j) is output (step S15 / product-sum operation process). After the product-sum operation process (step S15), the shift unit 70 sets the lower ω (h, j) bits of T (h, j) to R (h, j) and R (h, j) of T (h, j). Bits other than j) are set as new α (h, j + 1), and R (h, j) and α (h, j + 1) are output (step S16 / shift process).

シフト過程後(ステップS16)、演算制御部90が、レジスタファイル50のレジスタ51に格納されたjを参照し、j=J(h)であるか否かを判定する(ステップS17/判定過程)。ここで、j≠J(h)と判定された場合、演算制御部90が、j+1を新たなjとしてjをレジスタ51に格納し、処理をステップS15に戻す(ステップS18/ループ過程)。一方、判定過程(ステップS17)でj=J(h)と判定された場合、ビット結合部80が、α(h,J(h)),R(h,J(h)),...,R(h,1)のビット結合R(h)=α(h,J(h))|R(h,J(h))|…|R(h,1)を算出してR(h)を出力する(ステップS19/ビット結合過程)。   After the shifting process (step S16), the arithmetic control unit 90 refers to j stored in the register 51 of the register file 50 and determines whether j = J (h) (step S17 / determination process). . If it is determined that j ≠ J (h), the arithmetic control unit 90 stores j in the register 51 with j + 1 as a new j, and returns the process to step S15 (step S18 / loop process). . On the other hand, if it is determined that j = J (h) in the determination process (step S17), the bit combination unit 80 determines that α (h, J (h)), R (h, J (h)),. , R (h, 1) bit combination R (h) = α (h, J (h)) | R (h, J (h)) | ... | R (h, 1) ) Is output (step S19 / bit combination process).

次に、演算制御部90が、レジスタ51を参照してh=Hであるか否かを判定し、h=Hでなければ、h+1を新たなhとしてレジスタ51に格納し(ステップS21)、処理をステップS12に戻す。一方、h=Hであれば、加算部110が、R=R(1)+…+R(H)を算出し、Rを出力する(ステップS21/加算過程)。   Next, the arithmetic control unit 90 refers to the register 51 to determine whether h = H, and if not h = H, stores h + 1 as a new h in the register 51 (step S21). ), The process returns to step S12. On the other hand, if h = H, the adding unit 110 calculates R = R (1) +... + R (H) and outputs R (step S21 / addition process).

〔第5の実施形態〕
本形態は、第4の実施形態に第3の実施の形態を適用した形態である。すなわち、本形態では、h=1からh=Hまでの順序で、それぞれのhについて各xi(h,s(h))(j)が、xi(h,1)(1),...,xi(h,S(h))(1),xi(h,1)(2),...,xi(h,S(h))(2),...,xi(h,1)(J(h)),...,xi(h,S(h))(J(h))の順序でバースト転送可能にメインメモリ10に格納され、xi(h,1)(1),...,xi(h,S(h))(1),xi(h,1)(2),...,xi(h,S(h))(2),...,xi(h,1)(J(h)),...,xi(h,S(h))(J(h))の順序で順次キャッシュメモリ30に読み込まれる(本形態の特徴)。
[Fifth Embodiment]
In this embodiment, the third embodiment is applied to the fourth embodiment. That is, in this embodiment, in the order from h = 1 to h = H, each x i (h, s (h)) (j) for each h is x i (h, 1) (1),. .., x i (h, S (h)) (1), x i (h, 1) (2), ..., x i (h, S (h)) (2), ..., x i (h, 1) (J (h)), ..., x i (h, S (h)) (J (h)) are stored in the main memory 10 so as to be capable of burst transfer, and x i (h, 1) (1), ..., x i (h, S (h)) (1), x i (h, 1) (2), ..., x i (h, S (h )) (2), ..., x i (h, 1) (J (h)), ..., x i (h, S (h)) (J (h)) 30 is read (feature of this embodiment).

図12(a)(b)は、メインメモリ10に格納されたxi(h,1)(1),...,xi(h,S(h))(1),xi(h,1)(2),...,xi(h,S(h))(2),...,xi(h,1)(J(h)),...,xi(h,S(h))(J(h))を例示した概念図である。 12 (a) and 12 (b) show x i (h, 1) (1), ..., x i (h, S (h)) (1), x i (h ) stored in the main memory 10. , 1) (2), ..., x i (h, S (h)) (2), ..., x i (h, 1) (J (h)), ..., x i ( It is the conceptual diagram which illustrated h, S (h)) (J (h)).

図12(a)に例示するように、各xi(h,s(h))(j)は、xi(h,1)(1),...,xi(h,S(h))(1),xi(h,1)(2),...,xi(h,S(h))(2),...,xi(h,1)(J(h)),...,xi(h,S(h))(J(h))の順序でバースト転送可能にメインメモリ10に格納される。ここで、xi(h,1)(1),...,xi(h,S(h))(1),xi(h,1)(2),...,xi(h,S(h))(2),...,xi(h,1)(J(h)),...,xi(h,S(h))(J(h))が格納されたメインメモリ10の領域をブロック[h]と呼ぶ。また、ブロック[h]の先頭アドレスをAS(h)と表現し、終了アドレスをAE(h)と表現する。 As illustrated in FIG. 12A, each x i (h, s (h)) (j) is represented by x i (h, 1) (1), ..., x i (h, S (h )) (1), x i (h, 1) (2), ..., x i (h, S (h)) (2), ..., x i (h, 1) (J (h )), ..., x i (h, S (h)) (J (h)) are stored in the main memory 10 so as to be capable of burst transfer. Where x i (h, 1) (1), ..., x i (h, S (h)) (1), x i (h, 1) (2), ..., x i ( h, S (h)) (2), ..., x i (h, 1) (J (h)), ..., x i (h, S (h)) (J (h)) The stored area of the main memory 10 is referred to as a block [h]. Also, the start address of block [h] is expressed as AS (h), and the end address is expressed as AE (h).

また、図12(b)に示すように、各ブロック[h]は、ブロック[1], ブロック[2],..., ブロック[H]の順序でバースト転送可能にメインメモリ10に格納される。これにより、各xi(h,s(h))(j)は、xi(1,1)(1),...,xi(1,S(1))(1),xi(1,1)(2),...,xi(1,S(1))(2),...,xi(1,1)(J(1)),...,xi(1,S(1))(J(1)),...,xi(H,1)(1),...,xi(H,S(H))(1),xi(H,1)(2),...,xi(H,S(H))(2),...,xi(H,1)(J(H)),...,xi(H,S(H))(J(H))の順序でバースト転送可能にメインメモリ10に格納される。これにより、xi(1,1)(1)の先頭アドレスAS(h)を指定するのみで、メインメモリ10からキャッシュメモリ30にxi(1,1)(1),...,xi(1,S(1))(1),xi(1,1)(2),...,xi(1,S(1))(2),...,xi(1,1)(J(1)),...,xi(1,S(1))(J(1)),...,xi(H,1)(1),...,xi(H,S(H))(1),xi(H,1)(2),...,xi(H,S(H))(2),...,xi(H,1)(J(H)),...,xi(H,S(H))(J(H))の順序でバースト転送可能である。 As shown in FIG. 12B, each block [h] is stored in the main memory 10 so as to be capable of burst transfer in the order of block [1], block [2],..., Block [H]. The Thus, each x i (h, s (h)) (j) becomes x i (1,1) (1), ..., x i (1, S (1)) (1), x i (1,1) (2), ..., x i (1, S (1)) (2), ..., x i (1,1) (J (1)), ..., x i (1, S (1)) (J (1)), ..., x i (H, 1) (1), ..., x i (H, S (H)) (1), x i (H, 1) (2), ..., x i (H, S (H)) (2), ..., x i (H, 1) (J (H)), ..., It is stored in the main memory 10 so as to be capable of burst transfer in the order of x i (H, S (H)) (J (H)). As a result, x i (1,1) only to specify the start address AS (h) (1), from the main memory 10 in the cache memory 30 x i (1,1) (1 ), ..., x i (1, S (1)) (1), x i (1,1) (2), ..., x i (1, S (1)) (2), ..., x i (1 , 1) (J (1)), ..., x i (1, S (1)) (J (1)), ..., x i (H, 1) (1), ..., x i (H, S (H)) (1), x i (H, 1) (2), ..., x i (H, S (H)) (2), ..., x i ( Burst transfer is possible in the order of H, 1) (J (H)), ..., xi (H, S (H)) (J (H)).

図11のステップS15では、xi(1,1)(1),...,xi(1,S(1))(1),xi(1,1)(2),...,xi(1,S(1))(2),...,xi(1,1)(J(1)),...,xi(1,S(1))(J(1)),...,xi(H,1)(1),...,xi(H,S(H))(1),xi(H,1)(2),...,xi(H,S(H))(2),...,xi(H,1)(J(H)),...,xi(H,S(H))(J(H))の順序でxi(h,s(h))(j)が必要となるため、この順序でバースト転送可能にメインメモリ10に格納する構成は、本発明にとって好ましい。 In step S15 of FIG. 11, x i (1,1) (1), ..., x i (1, S (1)) (1), x i (1,1) (2), ... , x i (1, S (1)) (2), ..., x i (1,1) (J (1)), ..., x i (1, S (1)) (J ( 1)), ..., x i (H, 1) (1), ..., x i (H, S (H)) (1), x i (H, 1) (2), ... ., x i (H, S (H)) (2), ..., x i (H, 1) (J (H)), ..., x i (H, S (H)) (J Since x i (h, s (h)) (j) is required in the order of (H)), the configuration of storing in the main memory 10 so that burst transfer is possible in this order is preferable for the present invention.

〔実験結果〕
以上のように、上述の各形態では、キャッシュメモリ30の記憶容量(キャッシュサイズ)を他の演算や演算n途中のテンポラリ領域との合計で超えさせるようなxiと、キャッシュサイズよりもサイズの小さなriに対するR=x1・r1+…+xI・rIの多倍長演算の演算速度を向上させることができる。
〔Experimental result〕
As described above, in each of the above-described embodiments, x i that exceeds the storage capacity (cache size) of the cache memory 30 in total with other operations and the temporary area in the middle of the operation n, and a size larger than the cache size. It is possible to improve the calculation speed of the multiple length calculation of R = x 1 · r 1 + ... + x I · r I for small r i .

図13に、この効果を示すため実験結果を示す。図13では、Athlon64x2 2Ghzにおいて本発明を適用することなく「小田哲,山本剛,青木和麻呂,“高速データ検証”,SCIS, Jan.23-26 2007(「参考文献1」)」の演算を行った場合(従来方法)と、Athlon64x2 2Ghzにおいて第1の実施形態を適用して参考文献1の演算を行った場合(第1の実施形態)とでの演算速度の比較を示す。図13に示すように、従来方法での演算速度は12.5(Gbps)程度であるのに対し、第1の実施形態での演算速度は8(Gbps)程度である。   FIG. 13 shows the experimental results to show this effect. In FIG. 13, in Athlon64x2 2Ghz, the operation of “Tetsu Oda, Go Yamamoto, Kazuro Aoki,“ High-speed data verification ”, SCIS, Jan. 23-26 2007 (“ Reference 1 ”)) without applying the present invention. A comparison of the calculation speed between the case where the calculation is performed (conventional method) and the case where the calculation according to Reference 1 is performed by applying the first embodiment in Athlon64x2 2Ghz (first embodiment) is shown. As shown in FIG. 13, the computation speed in the conventional method is about 12.5 (Gbps), whereas the computation speed in the first embodiment is about 8 (Gbps).

〔変形例等〕
なお、本発明は上述の実施の形態に限定されるものではない。例えば、各実施形態の構成を適宜組み合わせて本発明を実施してもよい。また、上述の各種の処理は、記載に従って時系列に実行されるのみならず、処理を実行する装置の処理能力あるいは必要に応じて並列的にあるいは個別に実行されてもよい。その他、本発明の趣旨を逸脱しない範囲で適宜変更が可能であることはいうまでもない。
[Modifications, etc.]
The present invention is not limited to the embodiment described above. For example, you may implement this invention combining the structure of each embodiment suitably. In addition, the various processes described above are not only executed in time series according to the description, but may be executed in parallel or individually according to the processing capability of the apparatus that executes the processes or as necessary. Needless to say, other modifications are possible without departing from the spirit of the present invention.

また、上述の構成をコンピュータによって実現する場合、各装置が有すべき機能の処理内容はプログラムによって記述される。そして、このプログラムをコンピュータで実行することにより、上記処理機能がコンピュータ上で実現される。   Further, when the above-described configuration is realized by a computer, processing contents of functions that each device should have are described by a program. The processing functions are realized on the computer by executing the program on the computer.

この処理内容を記述したプログラムは、コンピュータで読み取り可能な記録媒体に記録しておくことができる。コンピュータで読み取り可能な記録媒体としては、例えば、磁気記録装置、光ディスク、光磁気記録媒体、半導体メモリ等どのようなものでもよいが、具体的には、例えば、磁気記録装置として、ハードディスク装置、フレキシブルディスク、磁気テープ等を、光ディスクとして、DVD(Digital Versatile Disc)、DVD−RAM(Random Access Memory)、CD−ROM(Compact Disc Read Only Memory)、CD−R(Recordable)/RW(ReWritable)等を、光磁気記録媒体として、MO(Magneto-Optical disc)等を、半導体メモリとしてEEP−ROM(Electronically Erasable and Programmable-Read Only Memory)等を用いることができる。   The program describing the processing contents can be recorded on a computer-readable recording medium. The computer-readable recording medium may be any medium such as a magnetic recording device, an optical disk, a magneto-optical recording medium, or a semiconductor memory. Specifically, for example, the magnetic recording device may be a hard disk device or a flexible Discs, magnetic tapes, etc. as optical disks, DVD (Digital Versatile Disc), DVD-RAM (Random Access Memory), CD-ROM (Compact Disc Read Only Memory), CD-R (Recordable) / RW (ReWritable), etc. As the magneto-optical recording medium, MO (Magneto-Optical disc) or the like can be used, and as the semiconductor memory, EEP-ROM (Electronically Erasable and Programmable-Read Only Memory) or the like can be used.

また、このプログラムの流通は、例えば、そのプログラムを記録したDVD、CD−ROM等の可搬型記録媒体を販売、譲渡、貸与等することによって行う。さらに、このプログラムをサーバコンピュータの記憶装置に格納しておき、ネットワークを介して、サーバコンピュータから他のコンピュータにそのプログラムを転送することにより、このプログラムを流通させる構成としてもよい。   The program is distributed by selling, transferring, or lending a portable recording medium such as a DVD or CD-ROM in which the program is recorded. Furthermore, the program may be distributed by storing the program in a storage device of the server computer and transferring the program from the server computer to another computer via a network.

このようなプログラムを実行するコンピュータは、例えば、まず、可搬型記録媒体に記録されたプログラムもしくはサーバコンピュータから転送されたプログラムを、一旦、自己の記憶装置に格納する。そして、処理の実行時、このコンピュータは、自己の記録媒体に格納されたプログラムを読み取り、読み取ったプログラムに従った処理を実行する。また、このプログラムの別の実行形態として、コンピュータが可搬型記録媒体から直接プログラムを読み取り、そのプログラムに従った処理を実行することとしてもよく、さらに、このコンピュータにサーバコンピュータからプログラムが転送されるたびに、逐次、受け取ったプログラムに従った処理を実行することとしてもよい。また、サーバコンピュータから、このコンピュータへのプログラムの転送は行わず、その実行指示と結果取得のみによって処理機能を実現する、いわゆるASP(Application Service Provider)型のサービスによって、上述の処理を実行する構成としてもよい。なお、本形態におけるプログラムには、電子計算機による処理の用に供する情報であってプログラムに準ずるもの(コンピュータに対する直接の指令ではないがコンピュータの処理を規定する性質を有するデータ等)を含むものとする。   A computer that executes such a program first stores, for example, a program recorded on a portable recording medium or a program transferred from a server computer in its own storage device. When executing the process, the computer reads a program stored in its own recording medium and executes a process according to the read program. As another execution form of the program, the computer may directly read the program from a portable recording medium and execute processing according to the program, and the program is transferred from the server computer to the computer. Each time, the processing according to the received program may be executed sequentially. Also, the program is not transferred from the server computer to the computer, and the above-described processing is executed by a so-called ASP (Application Service Provider) type service that realizes the processing function only by the execution instruction and result acquisition. It is good. Note that the program in this embodiment includes information that is used for processing by an electronic computer and that conforms to the program (data that is not a direct command to the computer but has a property that defines the processing of the computer).

また、この形態では、コンピュータ上で所定のプログラムを実行させることにより、本装置を構成することとしたが、これらの処理内容の少なくとも一部をハードウェア的に実現することとしてもよい。   In this embodiment, the present apparatus is configured by executing a predetermined program on a computer. However, at least a part of these processing contents may be realized by hardware.

本発明の産業上の利用分野としては、例えば、参考文献1のデータ検証処理等を例示できる。    As an industrial application field of the present invention, for example, the data verification processing of Reference 1 can be exemplified.

図1は、第1の実施形態の多倍長演算装置の構成を示したブロック図である。FIG. 1 is a block diagram illustrating a configuration of a multiple length arithmetic apparatus according to the first embodiment. 図2は、図1のレジスタファイル及び積和演算部の詳細構成を例示したブロック図である。FIG. 2 is a block diagram illustrating a detailed configuration of the register file and the product-sum operation unit of FIG. 図3は、データ構成を説明するための概念図である。FIG. 3 is a conceptual diagram for explaining the data structure. 図4は、第1の実施形態の多倍長演算方法を説明するためのフローチャートである。FIG. 4 is a flowchart for explaining the multiple length arithmetic method according to the first embodiment. 図5は、図4の積和演算過程(ステップS4)の具体例を説明するためのフローチャートであるFIG. 5 is a flowchart for explaining a specific example of the product-sum operation process (step S4) of FIG. 図6は、データ構成を説明するための概念図である。FIG. 6 is a conceptual diagram for explaining the data configuration. 図7は、第2の実施形態の実施例1におけるステップS4の処理を説明するためのフローチャートである。FIG. 7 is a flowchart for explaining the processing in step S4 in Example 1 of the second embodiment. 図8は、第2の実施形態の実施例2におけるステップS4の処理を説明するためのフローチャートである。FIG. 8 is a flowchart for explaining the processing in step S4 in Example 2 of the second embodiment. 図9は、メインメモリに格納されたx1(1),...,xI(1),x1(2),...,xI(2),...,x1(J),...,xI(J)を例示した概念図である。FIG. 9 shows x 1 (1), ..., x I (1), x 1 (2), ..., x I (2), ..., x 1 (J ), ..., x I (J). 図10は、第4の実施形態の多倍長演算装置の構成を示したブロック図である。FIG. 10 is a block diagram showing the configuration of the multiple length arithmetic device of the fourth embodiment. 図11は、第4の実施形態の多倍長演算方法を説明するためのフローチャートである。FIG. 11 is a flowchart for explaining the multiple length arithmetic method of the fourth embodiment. 図12は、メインメモリに格納されたxi(h,1)(1),...,xi(h,S(h))(1),xi(h,1)(2),...,xi(h,S(h))(2),...,xi(h,1)(J(h)),...,xi(h,S(h))(J(h))を例示した概念図である。FIG. 12 shows x i (h, 1) (1), ..., x i (h, S (h)) (1), x i (h, 1) (2), stored in the main memory. ..., x i (h, S (h)) (2), ..., x i (h, 1) (J (h)), ..., x i (h, S (h)) It is the conceptual diagram which illustrated (J (h)). 図13は、本形態の効果を示すため実験結果を示した図である。FIG. 13 is a diagram showing experimental results to show the effect of this embodiment.

符号の説明Explanation of symbols

1,100 多倍長演算装置 1,100 multiple length arithmetic unit

Claims (10)

Iを2以上の自然数とし、i∈{1,...,I}とし、xiを0以上の整数とし、riを整数とした場合における、R=x1・r1+…+xI・rIの演算を行う多倍長演算方法であって、
ビット分割部が、xiを各ビット長がω(j)であるxi(j)毎〔j∈{1,...,J}, Jは2以上の自然数, xiはxi(J),…,xi(1)のビット結合xi=xi(J)|…|xi(1)〕に分割するビット分割過程と、
演算制御部が、jに1を代入し、α(1)に0を代入する初期化過程と、
積和演算部が、α(j)とキャッシュメモリに読み込まれたxi(j)およびriとを用い、T(j)=α(j)+x1(j)・r1+…+xI(j)・rIの演算を行う積和演算過程と、
上記積和演算過程後、シフト部が、T(j)の下位ω(j)ビットをRjとし、T(j)のRj以外のビットを新たなα(j+1)とするシフト過程と、
上記シフト過程後、演算制御部が、j=Jであるか否かを判定する判定過程と、
上記判定過程でj≠Jと判定された場合、演算制御部が、j+1を新たなjとして処理を上記積和演算過程に戻すループ過程と、
上記判定過程でj=Jと判定された場合、ビット結合部が、α(J),RJ,...,R1のビット結合R=α(J)|RJ|…|R1を算出し、Rを出力するビット結合過程と、
を有することを特徴とする多倍長演算方法。
R = x 1 · r 1 +… + x where I is a natural number of 2 or more, i∈ {1, ..., I}, x i is an integer of 0 or more, and r i is an integer A multiple length arithmetic method for calculating I · r I ,
The bit dividing unit is configured such that x i is a natural number greater than or equal to 2 for each x i (j) where each bit length is ω (j), and x i is x i ( J), ..., x i (1) bit combination x i = x i (J) | ... | x i (1)]
An initialization process in which the arithmetic control unit substitutes 1 for j and 0 for α (1),
The product-sum operation unit uses α (j) and x i (j) and r i read into the cache memory, and T (j) = α (j) + x 1 (j) · r 1 +… + a sum-of-products operation for calculating x I (j) · r I ;
After the product-sum operation process, a shift process of shifting part, the lower omega (j) bits of T (j) and R j, and T new bits other than R j in (j) α (j + 1 ) When,
After the shifting process, the calculation control unit determines whether or not j = J,
When it is determined that j ≠ J in the determination process, the calculation control unit sets a new j as j + 1 and a loop process that returns the process to the product-sum calculation process;
If it is determined that j = J above determination process, the bit coupling portion, α (J), R J , ..., bit combination of R 1 R = α (J) | a R 1 | R J | ... A bit combination process to calculate and output R;
A multiple length arithmetic method characterized by comprising:
請求項1に記載の多倍長演算方法であって、
上記キャッシュメモリの記憶容量は、
何れか一つのxiのデータ量とすべてのriのデータ量との合計値よりも小さく、当該xiを分割して得られた一つのxi(j)のデータ量とすべてのriのデータ量との合計値よりも大きい、
ことを特徴とする多倍長演算方法。
The multiple length arithmetic method according to claim 1,
The storage capacity of the cache memory is
Smaller than the sum of the amount of data amount and all r i of any one of the x i, data volume and all r i of the one obtained by dividing the x i x i (j) Larger than the total amount of data with
A multiple length arithmetic method characterized by the above.
請求項1または2に記載の多倍長演算方法であって、
上記積和演算過程は、上記積和演算部が所定のビット長W単位で演算を行う過程であり、
ω(j)は、上記所定のビット長Wよりも長く、xiのビット長よりも短い、
ことを特徴とする多倍長演算方法。
The multiple length arithmetic method according to claim 1 or 2,
The product-sum operation process is a process in which the product-sum operation unit performs an operation in units of a predetermined bit length W.
ω (j) is longer than the predetermined bit length W and shorter than the bit length of x i ,
A multiple length arithmetic method characterized by the above.
請求項1に記載の多倍長演算方法であって、
ω(j)は、すべてのjについて一定である、
ことを特徴とする多倍長演算方法。
The multiple length arithmetic method according to claim 1,
ω (j) is constant for all j,
A multiple length arithmetic method characterized by the above.
請求項1に記載の多倍長演算方法であって、
上記積和演算過程は、
上記積和演算部が、xi(j)をビット長W−a(W>a≧0)毎に分割したxi(j,p)〔p∈{1,...,P}, Pは1以上の自然数, xi(j)はxi(j,P),...,xi(j,1)のビット結合xi(j)=xi(j,P)|…|xi(j,1)〕と、riをビット長W−b(W>b≧0, I≦2a+b)毎に分割したri(q)〔q∈{1,...,Q}, Qは1以上の自然数, riはri(Q),...,ri(1)のビット結合ri=ri(Q)|…|ri(1)〕とを用い、ビット長W単位で演算を行って1組以上のp,qについてx1(j,p)・r1(q)+…+xI(j,p)・rI(q)を算出し、当該演算結果を用いてT(j)=α(j)+x1(j)・r1+…+xI(j)・rIを算出する過程である、
ことを特徴とする多倍長演算方法。
The multiple length arithmetic method according to claim 1,
The product-sum operation process is
The product-sum operation unit divides x i (j) into bit lengths W−a (W> a ≧ 0), where x i (j, p) [p∈ {1, ..., P}, P Is a natural number greater than 1, x i (j) is the bit combination of x i (j, P), ..., x i (j, 1) x i (j) = x i (j, P) |… | x i (j, 1)] and r i (q) [q∈ {1, ...] obtained by dividing r i into bit lengths W−b (W> b ≧ 0, I ≦ 2 a + b ). , Q}, Q is a natural number of 1 or more, r i is a bit combination of r i (Q), ..., r i (1) r i = r i (Q) |… | r i (1)] To calculate x 1 (j, p) · r 1 (q) +… + x I (j, p) · r I (q) for one or more sets of p and q Is a process of calculating T (j) = α (j) + x 1 (j) · r 1 + ... + x I (j) · r I using the calculation result,
A multiple length arithmetic method characterized by the above.
請求項1に記載の多倍長演算方法であって、
上記ビット分割部で分割された各xi(j)は、
x1(1),...,xI(1),x1(2),...,xI(2),...,x1(J),...,xI(J)の順序でバースト転送可能にメモリに格納され、x1(1),...,xI(1),x1(2),...,xI(2),...,x1(J),...,xI(J)の順序で順次キャッシュメモリに読み込まれる、
ことを特徴とする多倍長演算方法。
The multiple length arithmetic method according to claim 1,
Each x i (j) divided by the bit dividing unit is
x 1 (1), ..., x I (1), x 1 (2), ..., x I (2), ..., x 1 (J), ..., x I (J ) Stored in memory so that burst transfer is possible in the order of x 1 (1), ..., x I (1), x 1 (2), ..., x I (2), ..., x 1 (J), ..., x I Read sequentially into cache memory in the order of (J).
A multiple length arithmetic method characterized by the above.
Iを2以上の自然数とし、i∈{1,...,I}とし、xiを0以上の整数とし、riを整数とした場合における、R=x1・r1+…+xI・rIの演算を行う多倍長演算方法であって、
Hを2以上の整数とし、h∈{1,...,H}とし、S(h)を2以上の整数とし、s(h)∈{1,...,S(h)}とし、i(h,s(h))∈{i(h,1),...,i(h,S(h))}⊂{1,...,I}とし、{i(1,1),...,i(1,S(1)),...,i(H,1),...,i(H,S(H))}={1,...,I}とし、R(h)=xi(h,1)・ri(h,1)+…+xi(h,S(h))・ri(h,S(h))とし、J(h)を2以上の自然数とし、j∈{1,...,J(h)}とした場合における、
(a)ビット分割部が、xi(h,s(h))を各ビット長がω(h,j)であるxi(h,s(h))(j)毎〔xi(h,s(h))はxi(h,s(h))(J(h)),…,xi(h,s(h))(1)のビット結合xi(h,s(h))=xi(h,s(h))(J(h))|…|xi(h,s(h))(1)〕に分割するビット分割過程と、
(b)演算制御部が、jに1を代入し、α(h,1)に0を代入する初期化過程と、
(c)hに対応するri(h,1),...,ri(h,S(h))をキャッシュメモリに読み込むキャッシュ過程と、
(d)積和演算部が、α(h,j)とキャッシュメモリに読み込まれたxi(h,s(h))(j)およびri(h,s(h))とを用い、T(h,j)=α(h,j)+xi(h,1)(j)・ri(h,1)+…+xi(h,S(h))(j)・ri(h,S(h))の演算を行う積和演算過程と、
(e)上記積和演算過程後、シフト部が、T(h,j)の下位ω(h,j)ビットをR(h,j)とし、T(h,j)のR(h,j)以外のビットを新たなα(h,j+1)とするシフト過程と、
(f)上記シフト過程後、演算制御部が、j=J(h)であるか否かを判定する判定過程と、
(g)上記判定過程でj≠J(h)と判定された場合、演算制御部が、j+1を新たなjとして処理を上記積和演算過程に戻すループ過程と、
(h)上記判定過程でj=J(h)と判定された場合、ビット結合部が、α(h,J(h)),R(h,J(h)),...,R(h,1)のビット結合R(h)=α(h,J(h))|R(h,J(h))|…|R(h,1)を算出するビット結合過程と、
を各hについて順次実行し、
加算部が、R=R(1)+…+R(H)を算出し、Rを出力する加算過程と、
を有することを特徴とする多倍長演算方法。
R = x 1 · r 1 +… + x where I is a natural number of 2 or more, i∈ {1, ..., I}, x i is an integer of 0 or more, and r i is an integer A multiple length arithmetic method for calculating I · r I ,
Let H be an integer greater than or equal to 2, h∈ {1, ..., H}, S (h) be an integer greater than or equal to 2, and s (h) ∈ {1, ..., S (h)} , I (h, s (h)) ∈ {i (h, 1), ..., i (h, S (h))} ⊂ {1, ..., I} and {i (1, 1), ..., i (1, S (1)), ..., i (H, 1), ..., i (H, S (H))} = {1, ..., I} and R (h) = x i (h, 1) · r i (h, 1) +… + x i (h, S (h)) · r i (h, S (h)) When J (h) is a natural number of 2 or more and j∈ {1, ..., J (h)},
(a) The bit division unit converts x i (h, s (h)) to each x i (h, s (h)) (j) whose bit length is ω (h, j) (x i (h , s (h)) is x i (h, s (h)) (J (h)), ..., x i (h, s (h)) (1) bit combination x i (h, s (h )) = x i (h, s (h)) (J (h)) |… | x i (h, s (h)) (1)]
(b) an initialization process in which the arithmetic control unit substitutes 1 for j and 0 for α (h, 1);
(c) a cache process for reading r i (h, 1) , ..., r i (h, S (h)) corresponding to h into cache memory;
(d) The product-sum operation unit uses α (h, j) and x i (h, s (h)) (j) and r i (h, s (h)) read into the cache memory, T (h, j) = α (h, j) + x i (h, 1) (j) ・ r i (h, 1) +… + x i (h, S (h)) (j) ・ r a product-sum operation process for calculating i (h, S (h)) ;
(e) After the above product-sum operation process, the shift unit sets R (h, j) as the lower ω (h, j) bits of T (h, j) and R (h, j) of T (h, j) ) And a shift process that sets bits other than) as a new α (h, j + 1),
(f) After the shifting process, the calculation control unit determines whether j = J (h),
(g) When it is determined that j ≠ J (h) in the determination process, the calculation control unit sets a new j to j + 1 and returns the process to the product-sum calculation process.
(h) If it is determined that j = J (h) in the above determination process, the bit combination part is α (h, J (h)), R (h, J (h)), ..., R ( bit combination process of calculating bit combination R (h) = α (h, J (h)) | R (h, J (h)) | ... | R (h, 1) of h, 1);
Sequentially for each h,
An adding unit calculates R = R (1) +... + R (H) and outputs R; and
A multiple length arithmetic method characterized by comprising:
請求項7に記載の多倍長演算方法であって、
上記キャッシュメモリの記憶容量は、
何れか一つのxi(h,s(h))のデータ量とすべてのriのデータ量との合計値よりも小さく、当該xi(h,s(h))を分割して得られた一つのxi(h,s(h))(j)のデータ量と当該hに対応するri(h,1),...,ri(h,S(h))のデータ量との合計値よりも大きい、
ことを特徴とする多倍長演算方法。
The multiple length arithmetic method according to claim 7,
The storage capacity of the cache memory is
It is smaller than the sum of the data amount of any one x i (h, s (h)) and the data amount of all r i , and is obtained by dividing x i (h, s (h)). A single x i (h, s (h)) (j) data amount and r i (h, 1) , ..., r i (h, S (h)) data amount corresponding to h Greater than the sum of
A multiple length arithmetic method characterized by the above.
Iを2以上の自然数とし、i∈{1,...,I}とし、xiを0以上の整数とし、riを整数とした場合における、R=x1・r1+…+xI・rIの演算を行う多倍長演算装置であって、
xiを各ビット長がω(j)であるxi(j)毎〔j∈{1,...,J}, Jは2以上の自然数, xiはxi(J),…,xi(1)のビット結合xi=xi(J)|…|xi(1)〕に分割するビット分割部と、
α(j)とキャッシュメモリに読み込まれたxi(j)およびriとを用い、T(j)=α(j)+x1(j)・r1+…+xI(j)・rIの演算を行う積和演算部と、
T(j)の下位ω(j)ビットをRjとし、T(j)のRj以外のビットを新たなα(j+1)とするシフト部と、
j=1およびα=0を初期値とし、j=1からjを1ずつ増加させながらj=Jまで、上記積和演算部と上記シフト部との処理を実行させる演算制御部と、
α(J),RJ,...,R1のビット結合R=α(J)|RJ|…|R1を算出し、Rを出力するビット結合部と、
を有することを特徴とする多倍長演算装置。
R = x 1 · r 1 +… + x where I is a natural number of 2 or more, i∈ {1, ..., I}, x i is an integer of 0 or more, and r i is an integer A multiple length arithmetic unit that performs the operation of I · r I ,
x i for each (j) the bit length x i is omega (j) [j∈ {1, ..., J} , J is a natural number of 2 or more, x i is x i (J), ..., x i (1) bit combination x i = x i (J) | ... | x i (1)],
Using α (j) and x i (j) and r i read into the cache memory, T (j) = α (j) + x 1 (j) · r 1 +… + x I (j) · a sum-of-products operation unit that performs r I operation;
Lower omega (j) bits of T (j) and R j, a shift unit for a T new bits other than R j in (j) α (j + 1 ),
An arithmetic control unit that executes processing of the product-sum operation unit and the shift unit up to j = J while increasing j by 1 from j = 1 and j = 0 as initial values,
Bit combination R of α (J), R J , ..., R 1 R = α (J) | R J | ... | R 1 and a bit combination unit for outputting R;
A multiple length arithmetic device characterized by comprising:
請求項1から8の何れかに記載の多倍長演算方法の各過程をコンピュータに実行させるためのプログラム。   The program for making a computer perform each process of the multiple length arithmetic method in any one of Claim 1 to 8.
JP2007131655A 2007-05-17 2007-05-17 Multiple length arithmetic method, multiple length arithmetic device and program Expired - Fee Related JP4838756B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2007131655A JP4838756B2 (en) 2007-05-17 2007-05-17 Multiple length arithmetic method, multiple length arithmetic device and program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2007131655A JP4838756B2 (en) 2007-05-17 2007-05-17 Multiple length arithmetic method, multiple length arithmetic device and program

Publications (2)

Publication Number Publication Date
JP2008287489A JP2008287489A (en) 2008-11-27
JP4838756B2 true JP4838756B2 (en) 2011-12-14

Family

ID=40147148

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2007131655A Expired - Fee Related JP4838756B2 (en) 2007-05-17 2007-05-17 Multiple length arithmetic method, multiple length arithmetic device and program

Country Status (1)

Country Link
JP (1) JP4838756B2 (en)

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2000353077A (en) * 1999-04-07 2000-12-19 Matsushita Electric Ind Co Ltd Mutifold length arithmetic unit
JP2002149396A (en) * 2000-11-07 2002-05-24 Hitachi Ltd Data processor, semiconductor integrated circuit and cpu
JP4399280B2 (en) * 2004-01-22 2010-01-13 日本電信電話株式会社 Surplus device, surplus method, program, and recording medium

Also Published As

Publication number Publication date
JP2008287489A (en) 2008-11-27

Similar Documents

Publication Publication Date Title
CN111213125B (en) Efficient direct convolution using SIMD instructions
EP3575952B1 (en) Arithmetic processing device, information processing device, method and program
Erbe et al. Asymptotic behavior of solutions of a third-order nonlinear dynamic equation on time scales
CN103460287B (en) The coding method of acoustic signal, coding/decoding method, code device, decoding device
US20160291977A1 (en) Adaptive map-reduce pipeline with dynamic thread allocations
BRPI0306094B1 (en) Apparatus, method, and system for performing a signal operation that multiplies the execution of a multi-signaling operation
JPWO2003091872A1 (en) Parallel merge sort processing apparatus and method, and program
JP4838756B2 (en) Multiple length arithmetic method, multiple length arithmetic device and program
US20230075348A1 (en) Computing device and method using multiplier-accumulator
CN115713104A (en) Data processing circuit for neural network, neural network circuit and processor
JP4856599B2 (en) Pairing arithmetic device, program
JP4399280B2 (en) Surplus device, surplus method, program, and recording medium
JP7205623B2 (en) Secret conjugate gradient method calculation system, secret calculation device, conjugate gradient method calculation device, secret conjugate gradient method calculation method, conjugate gradient method calculation method, and program
JP7485067B2 (en) Secret shift system, secret shift device, secret shift method, and program
JP4612698B2 (en) Polynomial multiplier, polynomial multiplication method and program
KR100976232B1 (en) Fast bit-parellel polynomial multipier and method thereof
Mazur et al. Boys function evaluation on graphical processing units
US7278090B2 (en) Correction parameter determination system
JP5835103B2 (en) Method for calculating satisfiability problem, calculation system and program for satisfiability problem
AU2020472387B2 (en) Secure shift system, secure shift apparatus, secure shift method, and program
CN111753949B (en) Data block processing method and device and electronic equipment
US11528013B2 (en) Systems and method for a low power correlator architecture using distributed arithmetic
WO2023233516A1 (en) Secure computation device, secure computation method, and program
EP4343535A1 (en) Method and apparatus for operating memory processor
WO2023058151A1 (en) Subgraph matching device, subgraph matching method, and program

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20090729

RD03 Notification of appointment of power of attorney

Free format text: JAPANESE INTERMEDIATE CODE: A7423

Effective date: 20110810

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

A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20110930

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20141007

Year of fee payment: 3

R150 Certificate of patent or registration of utility model

Free format text: JAPANESE INTERMEDIATE CODE: R150

S531 Written request for registration of change of domicile

Free format text: JAPANESE INTERMEDIATE CODE: R313531

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350

LAPS Cancellation because of no payment of annual fees