JPH08171479A - Sort device - Google Patents
Sort deviceInfo
- Publication number
- JPH08171479A JPH08171479A JP6313151A JP31315194A JPH08171479A JP H08171479 A JPH08171479 A JP H08171479A JP 6313151 A JP6313151 A JP 6313151A JP 31315194 A JP31315194 A JP 31315194A JP H08171479 A JPH08171479 A JP H08171479A
- Authority
- JP
- Japan
- Prior art keywords
- data
- mode
- address
- output
- sort
- 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.)
- Granted
Links
Landscapes
- Complex Calculations (AREA)
Abstract
(57)【要約】
【目的】 並列演算器に適した高速ソート装置を提供す
る。
【構成】 モード信号D2によって決定された2つのモ
ードに応じた分配方法を持つデータ分配手段20と、デ
ータ分配手段20で選択された2つのデータをソートし
て出力する2入力ソート手段30と、前記ソートされた
データを、モード信号D2を受けてデータ分配手段20
によって決められた位置に切り換え、データ格納手段1
0に格納する出力データ切換え手段60とを備え、条件
分岐を持たない部分ソートを行うソート演算器を構成す
る。
【効果】 条件分岐を持たない部分ソートを行うことに
より、演算時間が一定で、且つ高速なソート処理が可能
となる。
(57) [Abstract] [Purpose] To provide a high-speed sorting device suitable for a parallel computing unit. A data distribution means 20 having a distribution method according to two modes determined by a mode signal D2, a two-input sorting means 30 for sorting and outputting two data selected by the data distribution means 20, Upon receiving the mode signal D2, the data distribution means 20 receives the sorted data.
The data storage means 1 is switched to the position determined by
An output data switching means 60 for storing in 0 is provided, and a sort calculator for partial sort having no conditional branch is configured. [Effect] By performing a partial sort having no conditional branch, it is possible to perform a high-speed sort process with a constant calculation time.
Description
【0001】[0001]
【産業上の利用分野】本発明は、集積回路上に構成する
ソート回路として用いるものであり、特に並列演算に好
適なソート装置に関する。BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a sort device which is used as a sort circuit formed on an integrated circuit and is particularly suitable for parallel operation.
【0002】[0002]
【従来の技術】従来、ソートを高速化する方式について
関しては、多くの手法が考えられた。それらの多くはソ
ートの中で用いられる比較の回数を少なくする事により
高速化を実現しているものである。高速ソートを使って
n個の数配列a(n)をソートする上で、行われる比較
の回数の平均値の最小は、理論上nlogn回(nは2
のべき乗)である。理論上の平均比較回数が最小です
み、計算機上で実現しやすいソートの中で最も多く使用
されているのが併合ソートである。2. Description of the Related Art Conventionally, many methods have been considered for a method of speeding up sorting. Most of them achieve high speed by reducing the number of comparisons used in sorting. In order to sort the n number array a (n) using the fast sort, the minimum average value of the number of comparisons performed is theoretically nlogn times (n is 2).
Power of). The smallest number of theoretical average comparisons is required, and the most commonly used sort that is easy to implement on a computer is the merge sort.
【0003】併合ソートは、まずn個の配列a(n)を
n/2組のグループに分ける。各グループの構成要素の
数は2個である。次に各グループ毎に比較を行いソート
を行う。こうしてソートされたn/2個のグループの中
から任意の2組を選び出し、その2組についてソートを
行う。この場合ソートに必要な比較の回数はたかだか3
回である。残りのグループについても同様の事を行な
う。その結果、4個のソートされた配列をもつn/4組
のグループができる。同様の操作をグループの数が1個
になるまで繰り返す。こうすると最終的にn個のソート
された要素を持つ配列ができあがる事になる。このソー
トは、配列をグループに分割し少数の数によるソートを
行った後に、そのグループ同士でソートを行うことによ
り、比較の回数を減らすことに利点がある。In the merge sort, first, n arrays a (n) are divided into n / 2 groups. The number of constituent elements in each group is two. Next, each group is compared and sorted. Two arbitrary sets are selected from the n / 2 groups thus sorted, and the two sets are sorted. In this case, the number of comparisons required for sorting is at most 3
Times. Do the same for the remaining groups. The result is n / 4 groups with 4 sorted arrays. The same operation is repeated until the number of groups becomes one. This will ultimately result in an array with n sorted elements. This sorting is advantageous in that the number of comparisons is reduced by dividing the array into groups, sorting by a small number, and then sorting between the groups.
【0004】併合ソートを含め、2分木法やクイックソ
ート等の他の高速ソートに共通している事は、以下の事
である。それは予め部分ソートを行うことにより、次の
ステップにおける比較の回数を減らすことである。ここ
でソートを計算機上で行う上で、時間がかかる部分が比
較であることから、比較の回数の減少は、ソートの高速
化に直接つながることになる。また従来のソート方式に
関する特許公報のほとんどは部分ソートの方法に関する
ものである。Common to other high-speed sorts such as the binary tree method and the quick sort, including the merge sort, are as follows. That is to reduce the number of comparisons in the next step by performing partial sorting in advance. Here, when sorting is performed on a computer, since the time-consuming part is comparison, the reduction in the number of comparisons directly leads to speeding up of sorting. Further, most of the patent publications related to the conventional sorting method relate to the partial sorting method.
【0005】[0005]
【発明が解決しようとする課題】併合ソートや2分木法
を用いると、全体の比較の回数を減らすことができ、高
速なソートを行うことが可能になる。しかしこれらのソ
ートでは、1回の比較を行い、その結果を見ながら次の
比較を行わなければならない。つまり比較の回数は減少
するものの、それぞれの部分ソートはシーケンシャルに
行わなければならない事になる。この事は併合ソートや
クイックソートの場合、特に顕著に言えることである。
さらに部分ソートの大きさや個数が、ソートの各段階の
条件によって変化する。つまり並列計算機を使って部分
ソートを行う場合、各段階ごとにグループの数が異なる
ため、動作が休止する部分がででくる。例えば、8個の
数配列を4組のグループに分けて、4個の計算機を持つ
並列計算機を用いて併合ソートを行う場合を考える。最
初の段のソートにおいて、4個の計算機は各グループの
ソートに振り分けられ全て動作する。その後2つのグル
ープを併合して2個のグループで比較を行う。しかし各
グループ内では1回の比較を行い、その結果を見ながら
次の比較を行うため、1回ずつしか比較を行えない。故
に併合後の2つのグループの比較を行うときは、2個の
計算機しか用いることが出ない。よって残りの2個の計
算機は休止状態になる。そして次の段の比較において、
使用する計算機は、同じ理由により1個になる。よって
残りの3個の計算機は休止状態となる。つまり並列計算
機を用いても、機能を生かし切れないという問題があ
る。When the merge sort or the binary tree method is used, the number of comparisons as a whole can be reduced, and high-speed sort can be performed. However, in these sorts, one comparison must be performed and the next comparison must be performed while observing the result. In other words, although the number of comparisons decreases, each partial sort must be performed sequentially. This is especially true for merge sorts and quick sorts.
Furthermore, the size and number of partial sorts change depending on the conditions of each stage of sorting. In other words, when a partial sort is performed using a parallel computer, the number of groups differs for each stage, so there are some parts where the operation stops. For example, consider a case where the eight number arrays are divided into four groups and the merge sort is performed using a parallel computer having four computers. In the first sort, the four computers are allotted to the sorts of each group. After that, the two groups are merged and the two groups are compared. However, in each group, one comparison is performed, and the next comparison is performed while observing the result, so the comparison can be performed only once. Therefore, when comparing two groups after merging, only two computers can be used. Therefore, the remaining two computers are in the dormant state. And in the next comparison,
For the same reason, only one computer will be used. Therefore, the remaining three computers are in a dormant state. In other words, there is a problem in that even if a parallel computer is used, the functions cannot be fully utilized.
【0006】以上述べたように、計算機上でソート回路
を実現する上において、従来のソートを用いると、各グ
ループ内のソートがシーケンシャルであるため、部分ソ
ートに時間がかかり、全体のソート時間が低下するとい
う欠点がある。ゆえに並列計算機でソート回路を実現し
ようとした場合、使用しない回路が出てくるため演算効
率が低下するという欠点がある。さらに条件判断を行い
ながらソートをするため、演算時間が一定でない。よっ
て演算器として機器に組み込む場合、パイプラインが組
みにくいという欠点がある。As described above, when a conventional sort is used to implement a sort circuit on a computer, since the sorts within each group are sequential, partial sorts take time, and the total sort time is long. It has the drawback of decreasing. Therefore, when trying to realize a sorting circuit on a parallel computer, there is a drawback that the efficiency of operation is lowered because some circuits are not used. Further, since the sorting is performed while the condition is judged, the calculation time is not constant. Therefore, when incorporated in a device as an arithmetic unit, there is a drawback that the pipeline is difficult to assemble.
【0007】本発明の目的は、各段において、部分ソー
トの大きさを終始一定にし、グループ内のソートがシー
ケンシャルにならないソートの方法を与えることによ
り、並列計算に適した高速ソートを実現するソート装置
を提供することにある。An object of the present invention is to realize a high-speed sort suitable for parallel computation by providing a sort method in which the size of partial sorts is fixed from beginning to end and sorting within groups is not sequential in each stage. To provide a device.
【0008】[0008]
【課題を解決するための手段】本発明のソート装置は、
データ格納手段とモード切換え手段とN個のデータ分配
手段(N:自然数)とN個の2入力ソート手段と出力デ
ータ切換え手段とを備えた2N個のデータをソートする
ソート装置であって、前記データ格納手段は2N個の入
力データを格納し、2N個のデータを出力し、その入力
データは前記出力データ切換え手段に接続され、出力デ
ータは前記データ分配手段に接続され、前記モード切換
え手段はモード信号を作り、そのモード信号は前記デー
タ分配手段と前記出力データ切換え手段に接続され、m
番目の前記データ分配手段(m:1からNまでの自然
数)は、前記モード信号を受取り、第1モードならば前
記データ格納手段の2N個のデータの中から2m−1番
目と2m番目のデータを選択し、第2モードならば前記
データ格納手段の2N個のデータの中から2m番目と2
m+1番目のデータを選択し、そのデータはm番目の前
記2入力ソート手段に接続され、N番目の前記データ分
配手段は、前記モード信号を受取り、第1モードならば
前記データ格納手段の2N個のデータの中から2N−1
番目と2N番目のデータを選択し、第2モードならば前
記データ格納手段の2N個のデータの中から1番目と2
N番目のデータを選択し、そのデータはN番目の前記2
入力ソート手段に接続され、前記2入力ソート手段は前
記データ分配手段で選択された2つのデータをソートし
て出力し、その出力は前記出力データ切換え手段に接続
され、前記出力データ切換え手段は前記ソートされたデ
ータを、前記モード信号を受けて前記データ分配手段に
よって決められた位置に切り換え、前記データ格納手段
に格納し、前記出力データ切換え手段は全てのデータの
格納が終わると、前記モード切換え手段はモード切換え
信号を受けてモードを切換え、以上の動作を前記モード
切換え手段の切換え回数が2N−1になるまで繰り返す
ことを特徴とするものである。A sorting device according to the present invention comprises:
A sorting device for sorting 2N data, comprising data storage means, mode switching means, N data distribution means (N: natural number), N 2-input sorting means, and output data switching means, The data storage means stores 2N pieces of input data, outputs 2N pieces of data, the input data is connected to the output data switching means, the output data is connected to the data distribution means, and the mode switching means is A mode signal is generated, and the mode signal is connected to the data distribution means and the output data switching means, m
The second data distribution means (m: a natural number from 1 to N) receives the mode signal, and in the first mode, 2m−1th and 2mth data from the 2N pieces of data in the data storage means. If the second mode is selected, the 2mth and 2th data from the 2N pieces of data in the data storage means are selected.
The m + 1st data is selected, and the data is connected to the mth two-input sorting means, the Nth data distributing means receives the mode signal, and if the first mode, 2N pieces of the data storing means are received. 2N-1 from the data of
If the second mode is selected, the 1st and 2Nth data are selected and the 1st and 2Nth data are selected from the 2N pieces of data in the data storage means.
Select the Nth data, and the data is the Nth 2
The two-input sorting means are connected to the input sorting means, and the two data selected by the data distributing means are sorted and output, and the output is connected to the output data switching means, and the output data switching means is connected to the output data switching means. Upon receiving the mode signal, the sorted data is switched to a position determined by the data distribution means and stored in the data storage means, and the output data switching means switches the mode when all the data are stored. The means switches the mode in response to the mode switching signal, and repeats the above operation until the number of switching times of the mode switching means reaches 2N-1.
【0009】また本発明の他のソート装置は、データ格
納手段とモード切換え手段とN個のデータ分配手段
(N:自然数)とN個の2入力ソート手段とアドレス保
持手段とN個のアドレス交換手段とを備えた2N個のデ
ータをソートするソート装置であって、前記データ格納
手段は2N個の入力データを格納し、2N個のデータを
前記データ分配手段に出力し、前記モード切換え手段は
モード信号を作り、そのモード信号は前記データ分配手
段と前記アドレス交換手段に接続され、前記アドレス保
持手段は前記データ格納手段のデータのアドレスを保持
し、その出力は前記データ分配手段に接続され、m番目
の前記データ分配手段(m:1からN−1までの自然
数)は、前記モード信号を受取り、第1モードならば前
記アドレス保持手段の2m−1番目と2m番目に書かれ
ているアドレスのデータを前記データ格納手段の2N個
のデータの中から選択し、第2モードならば前記アドレ
ス保持手段の2m番目と2m+1番目に書かれているア
ドレスのデータを前記データ格納手段の2N個のデータ
の中から選択し、そのデータはm番目の前記2入力ソー
ト手段に接続され、N番目の前記データ分配手段は、前
記モード信号を受取り、第1モードならば前記アドレス
保持手段の2N−1番目と2N番目に書かれているアド
レスのデータを前記データ格納手段の2N個のデータの
中から選択し、第2モードならば前記アドレス保持手段
の1番目と2N番目に書かれているアドレスのデータを
前記データ格納手段の2N個のデータの中から選択し、
そのデータはN番目の前記2入力ソート手段に接続さ
れ、前記2入力ソート手段は前記データ分配手段で選択
されたデータを比較しデータを入れ替える必要がある時
にソート信号を出力し、その出力は前記アドレス交換手
段に接続され、m番目の前記アドレス交換手段は、アド
レスの入出力が前記アドレス保持手段に接続され、前記
モード信号が第1モードで且つソート信号が発生されて
いればアドレス保持手段の2m−1番目の位置のアドレ
スと2m番目の位置のアドレスを交換し、前記モード信
号が第2モードで且つソート信号が発生されていればア
ドレス保持手段の2m番目の位置のアドレスと2m+1
番目の位置のアドレスを交換し、N番目の前記2入力ソ
ート手段の出力は、アドレスの入出力が前記アドレス保
持手段に接続され、前記モード信号が第1モードで且つ
ソート信号が発生されていればアドレス保持手段の2N
−1番目の位置のアドレスと2N番目の位置のアドレス
を交換し、前記モード信号が第2モードで且つソート信
号が発生されていればアドレス保持手段の1番目の位置
のアドレスと2N番目の位置のアドレスを交換し、前記
アドレス保持手段はアドレスの全てのアドレスの交換が
終わると、前記モード切換え手段はモード切換え信号を
値を受けてモードを切換え、以上の動作を前記モード切
換え手段の切換え回数が2N−1になるまで繰り返すこ
とを特徴とするものである。Another sort device of the present invention is a data storage means, a mode switching means, N data distribution means (N: natural number), N 2-input sort means, address holding means, and N address exchanges. And a means for sorting 2N data, wherein said data storage means stores 2N input data, outputs 2N data to said data distribution means, and said mode switching means A mode signal is generated, the mode signal is connected to the data distributing means and the address exchanging means, the address holding means holds the address of the data in the data storing means, and the output is connected to the data distributing means, The m-th data distribution means (m: a natural number from 1 to N-1) receives the mode signal, and if the first mode, 2 of the address holding means. The data of the addresses written at the -1st and 2mth are selected from the 2N pieces of data in the data storage means, and in the second mode, the data are written at the 2mth and 2m + 1th addresses of the address holding means. The address data is selected from the 2N pieces of data in the data storage means, the data is connected to the m-th two-input sorting means, and the N-th data distribution means receives the mode signal, In the 1st mode, the data at the 2N-1th and 2Nth addresses of the address holding means is selected from the 2N pieces of data in the data storing means. In the second mode, the address holding means of the address holding means is selected. The data at the first and 2Nth written addresses are selected from the 2N pieces of data in the data storage means,
The data is connected to the N-th two-input sort means, and the two-input sort means compares the data selected by the data distribution means and outputs a sort signal when it is necessary to replace the data, and the output is the above-mentioned. If the input / output of the address of the m-th address exchanging means is connected to the address holding means, the mode signal is in the first mode, and the sort signal is generated, the address holding means of the address holding means is connected. If the address of the 2m-1th position and the address of the 2mth position are exchanged, and the mode signal is in the second mode and a sort signal is generated, the address of the 2mth position of the address holding means and 2m + 1.
The address of the second position is exchanged, and the output of the N-th two-input sort means is such that the input / output of the address is connected to the address holding means, the mode signal is the first mode, and the sort signal is generated. 2N of address holding means
-If the address at the 1st position and the address at the 2Nth position are exchanged, and the mode signal is in the second mode and the sort signal is generated, the address at the 1st position and the 2Nth position of the address holding means. When the address holding means completes the exchange of all the addresses, the mode switching means receives the value of the mode switching signal to switch the mode, and the above operation is performed by the number of times of switching of the mode switching means. Is repeated until becomes 2N-1.
【0010】[0010]
【作用】本発明を用いたソートを、2N個のデータ列 a
(1), a(2), a(3)....a(2N−1), a(2N)(N:自
然数)を昇べき順にソートする場合を例にして説明す
る。このソートは以下に示す、ある一定のステップ(第
1モードと第2モード)を交互に2N−1回繰り返すこ
とにより実現される。Operation: Sorting using the present invention is performed with 2N data strings a
An example will be described in which (1), a (2), a (3) .... a (2N-1), a (2N) (N: natural number) are sorted in ascending order. This sorting is realized by alternately repeating certain steps (first mode and second mode) shown below, 2N-1 times.
【0011】データ格納手段は初めのステップは第1モ
ードとして例えば、2種類のデータ分配手段の1つによ
り2N個のデータ列をa(1)とa(2)、a(3)とa(4)、a
(2m−1)とa(2m)(m:1からNまでの自然数)と
いう具合にグループを作る。するとN個のグループがで
き上がる。The first step of the data storage means is the first mode, for example, 2N data strings a (1) and a (2), a (3) and a (are generated by one of the two kinds of data distribution means. 4), a
Create a group such as (2m-1) and a (2m) (m: natural number from 1 to N). Then, N groups are completed.
【0012】次にそれぞれのグループ内でソートを行
う。ここでソートとはa(2m−1)とa(2m)の大きさを
比較して、a(2m−1)が大きければa(2m−1)とa(2
m)の値をいれかえ、a(2m)が大きければそのままにす
る。これらの2NグループのソートをN個の2入力ソー
ト手段を使って処理をする。ここまでが初めのステップ
であり、ここでモード切換え手段のモードを切換える。Next, sorting is performed within each group. Here, the sorting means comparing the sizes of a (2m-1) and a (2m), and if a (2m-1) is large, a (2m-1) and a (2
Replace the value of m) and keep it if a (2m) is large. These 2N groups are sorted using N 2-input sorting means. Up to this point is the first step, and the mode of the mode switching means is switched here.
【0013】次のステップは残りのデータ分配手段によ
りa(2)とa(3)、a(4)とa(5)、a(2m)とa(2m+1)
(m:1からN−1までの自然数)という具合にグルー
プを作る。ここでm=Nの時はa(1)とa(2N)をグルー
プにする。でき上がるグループの数はN個である。これ
についても同様にN個の2入力ソート手段を使ってソー
トを行い、モード切換え手段のモードを切換える。以上
までの2ステップをステップ数が2N−1になるまで、
すなわちモード切換え回数が2N−1になるまで順々に
繰り返して行く。これでソートが完了する。ここで第1
モードと第2モードはどちらから初めても良いが、必ず
交互に行なう。The next step is a (2) and a (3), a (4) and a (5), a (2m) and a (2m + 1) by the remaining data distribution means.
Create a group such as (m: natural number from 1 to N-1). Here, when m = N, a (1) and a (2N) are grouped. The number of created groups is N. Similarly, N two-input sorting means are used for sorting, and the mode of the mode switching means is switched. Repeat the above two steps until the number of steps becomes 2N-1
That is, the mode switching is repeated in sequence until the number of switching times becomes 2N-1. This completes the sort. Here first
Either the mode or the second mode may be started for the first time, but they are always performed alternately.
【0014】この方法では比較に必要な回数はN*(2N
−1)回である。このような構成を用いてソートを行う
と、各ステップでの部分ソートを行うグループの数は常
にN個であり、部分ソートの要素の数は常に2個であ
る。つまりN個の部分ソートは互いに独立であり、シー
ケンシャルな動作を行う必要がない。つまり、各ステッ
プでN個の2入力ソート手段は全て稼働することにな
る。In this method, the number of times required for comparison is N * (2N
-1) times. When sorting is performed using such a configuration, the number of groups in which partial sorting is performed in each step is always N, and the number of elements in partial sorting is always 2. That is, the N partial sorts are independent of each other, and it is not necessary to perform sequential operations. That is, at each step, the N two-input sorting means all operate.
【0015】そのため比較の回数は2分木法などの2N
*log(2N)回に比べてN*(2N−1)回と増えるもの
の、ソートに必要なステップ数は2分木法の平均ステッ
プ2N*log(2N)回に比べて2N−1ステップと短かな
ステップになり、2分木法等より高速なソートを実現で
きる。また上記の構成であると、部分ソートの分割方法
はソート全体を通じて常に一定であり、前のステップの
演算結果に依存しない。よって条件分岐の回路を必要と
しないので、高速にソート分割を実現できる。またソー
トが常に一定の回数で行われるため、専用演算器としハ
ードに組み込みやすくなる。Therefore, the number of comparisons is 2N such as the binary tree method.
Although the number of steps required for sorting increases by N * (2N-1) times compared with * log (2N) times, the number of steps required for sorting is 2N-1 steps compared with the average step 2N * log (2N) times of the binary tree method. It becomes a short step, and a faster sort can be realized than the binary tree method. Also, with the above configuration, the division method of the partial sort is always constant throughout the sort, and does not depend on the calculation result of the previous step. Therefore, since a conditional branch circuit is not required, sort division can be realized at high speed. Also, since sorting is always performed a fixed number of times, it becomes easy to incorporate it into a hardware as a dedicated arithmetic unit.
【0016】[0016]
(実施例1)本発明の請求項1に基づく実施例の構成を
図1を用いて説明する。2N個のデータを降ベキにソー
トする場合を考える。(Embodiment 1) The construction of an embodiment according to claim 1 of the present invention will be described with reference to FIG. Consider a case where 2N pieces of data are sorted in descending power.
【0017】10はデータ格納手段である。20はN個
のデータ分配手段である。30は2入力ソート手段であ
る。90はモード切換え手段であり、カウンタ50と偶
奇判定手段40から成る。60は出力データ切換え手段
である。本実施例のソート方法には2つのモードを有
し、第1モードをカウンタ50値が偶数、第2モードを
カウンタ50値が奇数と定義する。100はタイマであ
り、第1モード,第2モードの何れかのモードが終了し
た時に、ステップ終了信号(モード切換え信号)D6を
発生するようにセットしている。データ格納手段10は
2N個のデータを格納しており、N個のデータ分配手段
20に、それぞれ2N個のデータの値D1を同時に転送
する。N個のデータ分配手段20各々は、偶数段データ
分配手段21と奇数段データ分配手段22から構成され
る。Reference numeral 10 is a data storage means. Reference numeral 20 denotes N data distribution means. Reference numeral 30 is a 2-input sort means. Reference numeral 90 denotes a mode switching means, which includes a counter 50 and an even / odd determination means 40. Reference numeral 60 is an output data switching means. The sorting method of the present embodiment has two modes. The first mode is defined as the counter 50 value is even, and the second mode is defined as the counter 50 value is odd. A timer 100 is set to generate a step end signal (mode switching signal) D6 when either the first mode or the second mode ends. The data storage means 10 stores 2N pieces of data, and simultaneously transfers the 2N pieces of data value D1 to the N pieces of data distribution means 20, respectively. Each of the N data distribution units 20 includes an even-stage data distribution unit 21 and an odd-stage data distribution unit 22.
【0018】m番目の偶数段データ分配手段21−m
(mは1からNまでの整数)はデータ格納手段10から
送られる2N個のデータの中から2m−1番目の数と2
m番目のデータを選択し、m番目の2入力ソート手段3
0−mへ送る。同様にm番目の奇数段データ分配手段2
2−mは2N個のデータから2m番目の数と2m+1番
目のデータを選択し、m番目の2入力ソート手段30−
mへ送る。但しm=Nの時は奇数段データ分配手段22
−NはデータD1の中の1番目のデータとN番目のデー
タを選択し、N番目の2入力ソート手段に送る。M-th even-numbered stage data distribution means 21-m
(M is an integer from 1 to N) is the 2m-1th number and 2 out of the 2N pieces of data sent from the data storage means 10.
The m-th data is selected and the m-th two-input sorting means 3 is selected.
Send to 0-m. Similarly, the m-th odd stage data distribution means 2
2-m selects the 2m-th number and the 2m + 1-th data from the 2N pieces of data, and the m-th 2-input sort means 30-
send to m. However, when m = N, the odd number stage data distribution means 22
-N selects the first data and the Nth data in the data D1 and sends them to the Nth two-input sorting means.
【0019】N個の2入力ソート手段30は与えられた
2つのデータを比較して降ベキにソートする。すなわち
m番目の2入力ソート手段30−mはm番目のデータ分
配手段20−mから送られる2つのデータD3を降ベキ
にソートし、出力データ切換え手段60へ、ソート後の
データD4−mを送る。The N 2-input sorting means 30 compare the given two data and sort them in descending power. That is, the m-th two-input sorting means 30-m sorts the two pieces of data D3 sent from the m-th data distributing means 20-m in descending order, and outputs the sorted data D4-m to the output data switching means 60. send.
【0020】偶寄判定手段40はカウンタ50のデータ
から偶寄判定信号(モード信号)D2を送る。すなわち
カウンタ50のデータが奇数ならば、偶寄判定信号D2
により、データ分配手段20の中の奇数段データ分配手
段22が選択される。カウンタ50のデータが偶数なら
ば偶数段データ分配手段21が選択される。ただしカウ
ンタ50のデータが偶数ならばデータ分配手段20の中
の奇数段データ分配手段22を選択し、奇数ならば偶数
段データ分配手段21を選択するという動作をしてもよ
い。カウンタ50は初期値に1が設定されており、タイ
マ100からのステップ終了信号(モード切換え信号)
D6を受けると、カウンタの値を1ずつ増加させる。出
力データ切換え手段60はN個の2入力ソート手段30
からデータD4を受けとり、2N個のデータD5にし
て、データ格納手段10へ送る。The accidental judgment means 40 sends a accidental judgment signal (mode signal) D2 from the data of the counter 50. That is, if the data of the counter 50 is an odd number, the evenness determination signal D2
Thereby, the odd-numbered stage data distributing means 22 in the data distributing means 20 is selected. If the data of the counter 50 is an even number, the even number stage data distribution means 21 is selected. However, if the data of the counter 50 is even, the operation of selecting the odd-numbered data distribution means 22 in the data distribution means 20 and selecting the number of even-numbered data distribution means 21 may be performed. The counter 50 has an initial value set to 1, and a step end signal (mode switching signal) from the timer 100.
When receiving D6, the counter value is incremented by one. The output data switching means 60 includes N 2-input sorting means 30.
The data D4 is received from the data storage device 10 and converted into 2N data D5 and sent to the data storage means 10.
【0021】図5に出力データ切換え手段60の詳細を
示し、(表1)に2N=4の時の降べきにソートする場
合を示し、第1モードと第2モード時のセレクタS1〜
S3の出力を示す。2入力ソート30−1,30−2各
々は降べきにソートし、大きい方の値をE1,E3、小
さい方の値をE2,E4として出力する。出力データ切
換え手段60は内部にセレクタS1〜S3を有し、偶寄
判定信号D2により、データD5の内容が変えて出力す
る。(表1)に示すように偶寄判定信号D2が偶数(第
1モード)の時、m番目の2入力ソート手段30−mの
データD4−mは、大きい方がデータ格納手段10の2
m−1番目に、小さい方が2m番目の位置に格納される
ように出力データD5が出力される。偶寄判定信号D2
が奇数(第2モード)の時、m番目の2入力ソート手段
30−mのデータD4−mは、大きい方がデータ格納手
段10の2m番目に、小さい方が2m+1番目の位置に
格納され、かつD4−Nのデータは大きい方が1番目の
位置に、小さい方が2N番目の位置に格納されるように
出力データD5が出力される。以上の動作をカウンタ5
0の値がN−1まで繰り返す。この動作が終了すると、
データ格納手段10にはソートが完了した値が入ってい
る。FIG. 5 shows the details of the output data switching means 60, and (Table 1) shows the case of sorting to the descending power when 2N = 4. The selectors S1 to S1 in the first mode and the second mode are shown.
The output of S3 is shown. Each of the 2-input sorts 30-1 and 30-2 sorts into a descending power and outputs the larger value as E1 and E3 and the smaller value as E2 and E4. The output data switching means 60 has selectors S1 to S3 inside, and changes the contents of the data D5 in response to the evenness judgment signal D2 and outputs the data. As shown in (Table 1), when the evenness determination signal D2 is an even number (first mode), the larger one of the data D4-m of the m-th two-input sorting means 30-m is 2 of the data storage means 10.
The output data D5 is output such that the smaller one is stored in the 2m-th position at the (m-1) th position. Accidental judgment signal D2
Is an odd number (second mode), the larger one of the data D4-m of the m-th two-input sort means 30-m is stored at the 2m-th position of the data storage means 10, and the smaller one is stored at the 2m + 1-th position, The output data D5 is output so that the larger data of D4-N is stored in the first position and the smaller data of the D4-N is stored in the 2Nth position. The above operation is performed by the counter 5
The value of 0 repeats until N-1. When this operation ends,
The data storage means 10 contains values for which sorting has been completed.
【0022】なお、本実施例では降べきにソートする場
合について説明したが、昇べきにソートする場合は、2
入力ソート30が昇べきにソートし、小さい方の値をE
1,E3、大きい方の値をE2,E4として出力すれば、
(表1)に示した動作を偶寄判定信号D2に応じて行な
えばよい。In the present embodiment, the case of sorting in descending power was explained, but in the case of sorting in ascending power, 2
Input sort 30 sorts into ascending powers, and the smaller value is E
If you output 1, E3 and the larger value as E2, E4,
The operation shown in (Table 1) may be performed in accordance with the accidental decision signal D2.
【0023】[0023]
【表1】 [Table 1]
【0024】図2はa3 > a2 > a1の大きさを持つ4
数がa1,a2,a3,a1の順に並べられている場合を例
に、図1の構成を持つソート方式で降べきにソートする
方法を示している。FIG. 2 shows 4 having a size of a3>a2> a1.
A case where the numbers are arranged in the order of a1, a2, a3, a1 is shown as an example to show a method of sorting in descending power by the sorting method having the configuration of FIG.
【0025】始めにカウンタ50に1をセットする。a
1,a2,a3,a1はこの順番でデータ格納手段10に格納
されている。データ格納手段10はデータ分配手段20
に送るデータD1をこの順で送っている。偶寄判定手段
40はカウンタ50の値が1なので偶寄判定信号D2を
奇数として出力する。N個のデータ分配手段20は偶寄
判定信号D2が奇数なので、奇数段データ分配手段22
が選択される。1番目の奇数段データ分配手段22−1
はデータ格納手段10の2番目のアドレスと3番目のア
ドレスに格納されているデータのa2とa3のデータを選
択し、2入力ソート手段30−1に選択データD3−1
として送る。2番目の奇数段データ分配手段22−2は
データ格納手段10の1番目のアドレスと4番目のアド
レスに格納されているデータであるa1とa1のデータを
選択し、選択データD3−2として2入力ソート手段3
0−2に送る。First, the counter 50 is set to 1. a
1, a2, a3, a1 are stored in the data storage means 10 in this order. The data storage means 10 is the data distribution means 20.
The data D1 to be sent to is sent in this order. Since the value of the counter 50 is 1, the advent determination unit 40 outputs the adjacency determination signal D2 as an odd number. Since the even number determination signal D2 of the N data distribution units 20 is an odd number, the odd number stage data distribution unit 22 is included.
Is selected. First odd-stage data distribution means 22-1
Selects the data a2 and a3 of the data stored at the second address and the third address of the data storage means 10, and selects the selected data D3-1 to the 2-input sort means 30-1.
Send as. The second odd-stage data distribution means 22-2 selects the data of a1 and a1 which are the data stored at the first address and the fourth address of the data storage means 10, and selects 2 as the selection data D3-2. Input sort means 3
Send to 0-2.
【0026】2入力ソート手段30−1は入力されたa
2,a3のデータを比較してa3の方が大きければa2とa
3のデータを入れ替えた後、出力データD4−1として
出力データ切換え手段60へ送る。同様の動作を2入力
ソート手段30−2でも行い、a1,a1の内容を持つ出
力データD4−2として出力データ切換え手段60へ送
られる。出力データ切換え手段60は2つの部分ソート
の出力をまとめて、出力データD5としてデータ格納手
段10へ出力した後、タイマ100がステップ終了信号
D6をカウンタ50へ送る。The 2-input sort means 30-1 receives the input a
Compare the data of 2, a3, and if a3 is larger, then a2 and a
After exchanging the data of No. 3, it is sent to the output data switching means 60 as the output data D4-1. The same operation is performed in the 2-input sort means 30-2, and the output data D4-2 having the contents of a1 and a1 is sent to the output data switching means 60. The output data switching means 60 combines the outputs of the two partial sorts and outputs them as the output data D5 to the data storage means 10, and then the timer 100 sends a step end signal D6 to the counter 50.
【0027】出力データ切換え手段60は(表1)に示
すように偶寄判定信号D2が奇数(第2モード)である
ことから、D4−1データの大きい方の数をデータ格納
手段10の2番目に格納し、小さい方のデータをデータ
格納手段10の3番目に格納する。つまりa3とa2のデ
ータはそれぞれデータ格納手段10の2番目の位置と3
番目の位置に格納される。同様にD4−2のデータの大
きい方はデータ格納手段10の1番目の位置に、小さい
方のデータはデータ格納手段10の4番目の位置に格納
される。ここまでが1つのステップである。ステップの
終了後、データ格納手段10にはa1,a3,a2,a1の順
番にデータが格納されている。As shown in (Table 1), the output data switching means 60 determines that the larger number of D4-1 data is 2 in the data storage means 10 since the evenness judgment signal D2 is an odd number (second mode). The third data is stored in the data storage means 10 and the smaller data is stored in the third data storage means 10. That is, the data of a3 and a2 are respectively the second position and 3 of the data storage means 10.
Stored in the th position. Similarly, the larger data of D4-2 is stored in the first position of the data storage means 10, and the smaller data of D4-2 is stored in the fourth position of the data storage means 10. This is one step. After the step is completed, the data storage means 10 stores data in the order of a1, a3, a2, a1.
【0028】2番目のステップはカウンタ50に1を加
えて2になることから始まる。偶寄判定手段40からの
偶寄判定信号D2が偶数なので、偶数段データ分配手段
21が選択される。偶数段データ分配手段21−1はデ
ータ格納手段10の1番目のデータと2番目のデータを
選択する。偶数段データ分配手段21−2はデータ格納
手段10の3番目のデータと4番目のデータを選択す
る。すると選択データD3−1の値はa1,a3であり、
選択データD3−2の値はa2,a1である。これを2つ
の2入力ソート手段30でソートすると、D4−1のデ
ータはa3,a1となり、D4−2のデータはa2,a1とな
る。出力データ切換え手段60により、D5のデータは
a3,a1,a2,a1となり、この順でデータ格納手段10
に格納される。その後タイマ100はステップ終了信号
をカウンタ50に送る。以上が第2のステップである。The second step begins with the addition of 1 to the counter 50 to reach 2. Since the evenness determination signal D2 from the evenness determination means 40 is an even number, the even number stage data distribution means 21 is selected. The even number stage data distribution means 21-1 selects the first data and the second data of the data storage means 10. The even number stage data distribution means 21-2 selects the third data and the fourth data of the data storage means 10. Then, the values of the selection data D3-1 are a1 and a3,
The values of the selection data D3-2 are a2 and a1. When this is sorted by the two 2-input sorting means 30, the data of D4-1 becomes a3, a1 and the data of D4-2 becomes a2, a1. By the output data switching means 60, the data of D5
a3, a1, a2, a1, and the data storage means 10 in this order
Stored in. After that, the timer 100 sends a step end signal to the counter 50. The above is the second step.
【0029】同様にステップを進めていき、3つ目のス
テップが終了した時点でソートが完了する。ここで2入
力ソート手段30−1と30−2は互いに独立に動作さ
せることが可能である。故にN個の2入力ソート手段を
構成する並列計算機を使用すると、入力ソート手段30
−1と30−2は同時に計算することができる。つまり
2入力ソート手段で行うN個の部分ソートが同時に行わ
れることになる。しかも部分ソートの分配方法が偶数段
データ分配手段21と奇数段データ分配手段22の2つ
しかなく、ソート演算結果に依存する条件分岐が存在し
ない。よって従来のソート方式よりも単純な構造のデー
タ分配手段になり、回路で実現する場合、小さな回路で
高速な分配手段を実現できる。ゆえに並列計算機では2
分岐法等のソートよりも高速なソート演算が実現でき
る。しかも部分ソートにかかる時間と全体のソートにか
かる時間が同じであるため、専用演算器として機器へ組
み込みやすくなる。Similarly, the steps are advanced, and the sorting is completed when the third step is completed. Here, the 2-input sorting means 30-1 and 30-2 can be operated independently of each other. Therefore, if a parallel computer forming N 2-input sorting means is used, the input sorting means 30
-1 and 30-2 can be calculated simultaneously. That is, the N partial sorts performed by the 2-input sort means are simultaneously performed. Moreover, there are only two distribution methods for partial sorting: the even-numbered stage data distribution means 21 and the odd-numbered stage data distribution means 22, and there is no conditional branch depending on the sort operation result. Therefore, the data distributing means has a simpler structure than the conventional sorting method, and when realized by a circuit, a high-speed distributing means can be realized by a small circuit. Therefore, in a parallel computer, 2
It is possible to realize a sort operation that is faster than the sort method such as the branch method. Moreover, since the time required for partial sorting is the same as the time required for overall sorting, it becomes easy to incorporate the device into a device as a dedicated computing unit.
【0030】(実施例2)図3は本発明の請求項2に基
づく実施例の構成である。図1の出力データ切換え手段
60がなくなり、代わりにN個のアドレス交換手段70
と1個のアドレス保持手段80が接続されている。2入
力ソート手段30の出力はデータではなく大小の判定信
号になり、それがそれぞれN個のアドレス交換手段70
に接続されている。またアドレス保持手段80から出力
されているアドレス信号D8はデータ分配手段20に接
続されている。(Embodiment 2) FIG. 3 shows the construction of an embodiment according to claim 2 of the present invention. The output data switching means 60 of FIG. 1 is eliminated, and instead N address exchange means 70 are used.
And one address holding means 80 are connected. The output of the 2-input sort means 30 is not a data but a large or small decision signal, which is N number of address exchange means 70.
It is connected to the. The address signal D8 output from the address holding means 80 is connected to the data distribution means 20.
【0031】アドレス保持手段80には、2N個のデー
タがデータ格納手段10の中で格納されている位置を示
すアドレスが、2N個分保持してある。データ選択手段
20はアドレス保持手段80の中の指し示すアドレスD
8のデータをデータ格納手段10から選択し2入力ソー
ト手段30へ出力する。すなわち、カウンタ10の値が
奇数で1番目のデータ分配手段20−1は、図1の場
合、データ格納手段10の1番目と2番目のデータを選
択するが、図3の場合、データ格納手段10からアドレ
ス保持手段の1番目に書かれているアドレスと2番目に
書かれているアドレスを選択する。2入力ソート手段3
0はデータ分配手段20からデータD3を与えられ比較
を行う。比較の結果、ソートをするために2数を入れ替
えなければならない時、2入力ソート手段30は、ソー
ト信号D7を発行する。The address holding means 80 holds 2N addresses indicating the positions where 2N pieces of data are stored in the data storage means 10. The data selecting means 20 indicates the address D in the address holding means 80.
8 data are selected from the data storage means 10 and output to the 2-input sort means 30. That is, the first data distribution means 20-1 with an odd value of the counter 10 selects the first and second data of the data storage means 10 in the case of FIG. 1, but in the case of FIG. 3, the data storage means 20-1. From 10, the first written address and the second written address of the address holding means are selected. 2 Input sort means 3
0 is given the data D3 from the data distribution means 20 and makes a comparison. As a result of the comparison, when two numbers have to be exchanged for sorting, the two-input sorting means 30 issues the sort signal D7.
【0032】アドレス交換手段70はm番目の2入力ソ
ート手段30−mからソート信号70−mを受けると、
偶寄判定信号D2が偶数(第1モード)の時は、アドレ
ス保持手段80の2m−1番目に書かれているアドレス
と2m番目に書かれているアドレスを交換し、奇数(第
2モード)の時は、アドレス保持手段80の2m番目に
書かれているアドレスと2m+1番目のに書かれている
アドレスを交換する。図6にアドレス交換手段70の詳
細を示し、(表2)に2N=4の時の降べきにソートす
る場合を示し、第1モードと第2モード時のセレクタS
1〜S4の出力を示す。アドレス交換手段70は内部に
セレクタS1〜S8を有し、偶寄判定信号D2により、
S1〜S4を制御し、D7−1,D7−2によりS5〜
S8を制御する。即ち(表2)より、偶寄判定信号D2
により、第1モードであればS1〜S4はE2を出力
し、第2モードであればS1〜S4はE1を出力する。
またソート信号D7が発せられた場合はS5〜S8は各
々S1〜S4の出力を選択し、そうでない場合は、S5
〜S8は各々アドレス保持手段からの出力D9を選択す
る。ただし、偶寄判定信号D2が奇数でm=Nの時は1
番目に書かれているアドレスとN番目に書かれているア
ドレスを交換する。アドレス保持手段はすべてのアドレ
スの交換が終了すると、タイマ100はステップ終了信
号D6をカウンタ50に出力する。その他の部分の動作
は図1の構成の動作と同じである。以上の動作が終了す
ると、アドレス保持手段80のm番目の位置にはm番目
に大きなデータのデータ格納手段10におけるアドレス
が書かれている。When the address exchanging means 70 receives the sort signal 70-m from the m-th two-input sorting means 30-m,
When the even-number determination signal D2 is an even number (first mode), the 2m-1th address and the 2mth address written in the address holding means 80 are exchanged, and an odd number (second mode). In the case of, the address written in the 2m-th address of the address holding means 80 and the address written in the 2m + 1-th address are exchanged. FIG. 6 shows the details of the address exchanging means 70, and (Table 2) shows the case of sorting to the descending power when 2N = 4. The selector S in the first mode and the second mode is shown.
The outputs of 1 to S4 are shown. The address exchanging means 70 has selectors S1 to S8 therein, and by the evenness judgment signal D2,
S1 to S4 are controlled, and S5 to S7 are controlled by D7-1 and D7-2.
Control S8. That is, from Table 2
Thus, in the first mode, S1 to S4 output E2, and in the second mode, S1 to S4 output E1.
When the sort signal D7 is issued, S5 to S8 select the outputs of S1 to S4, respectively, otherwise, S5.
.About.S8 select the output D9 from the address holding means. However, it is 1 when the contingency determination signal D2 is odd and m = N.
Exchange the address written in the th and the address written in the Nth. When the address holding means completes the exchange of all addresses, the timer 100 outputs the step end signal D6 to the counter 50. The operation of the other parts is the same as the operation of the configuration of FIG. When the above operation is completed, the address in the data storing means 10 of the mth largest data is written in the mth position of the address holding means 80.
【0033】[0033]
【表2】 [Table 2]
【0034】図4はa3 > a2 > a1の大きさを持つ4
数がa1,a2,a3,a1の順に並べられている場合を例
に、図3の構成を持つソート方式で降べきにソートする
方法を示している。FIG. 4 shows 4 having a size of a3>a2> a1.
A case where numbers are arranged in the order of a1, a2, a3, a1 is shown as an example to show a method of descending to the power in the sorting method having the configuration of FIG.
【0035】始めにカウンタ50に1をセットする。a
1,a2,a3,a1はこの順番でデータ格納手段10に格納
されている。データ格納手段10はデータ分配手段20
に送るデータD1をこの順で送っている。アドレス保持
手段80は初めはアドレスの位置とアドレスの番号が一
致している。偶寄判定手段40はカウンタ50の値が1
なので偶寄判定信号D2を奇数として出力する。N個の
データ分配手段20は偶寄判定信号D2が奇数なので、
奇数段データ分配手段22が選択し、選択データD3−
1として2入力ソート手段30−1に送る。1番目の奇
数段データ分配手段22−1はアドレス保持手段80の
2番目のアドレスの差し示すデータである2の差し示す
データであるa2とアドレス保持手段80の3番目のア
ドレスの差し示すデータである3の差し示すデータであ
るa3をデータ格納手段10から選択し、選択データD
3−1として2入力ソート手段30−1に送る。First, the counter 50 is set to 1. a
1, a2, a3, a1 are stored in the data storage means 10 in this order. The data storage means 10 is the data distribution means 20.
The data D1 to be sent to is sent in this order. In the address holding means 80, the address position and the address number initially match. The value of the counter 50 of the contingency judgment means 40 is 1
Therefore, the side-by-side determination signal D2 is output as an odd number. Since the even number determination signal D2 is an odd number in the N data distribution units 20,
The odd-numbered data distribution means 22 selects the selected data D3-
1 is sent to the 2-input sort means 30-1. The first odd-numbered data distribution means 22-1 is composed of data a2, which is the data indicating the second address of the address holding means 80, and a2, which is the data indicating the third address of the address holding means 80. Select a3, which is the data indicating a certain 3, from the data storage means 10, and select data D3.
It is sent to the 2-input sort means 30-1 as 3-1.
【0036】2番目の奇数段データ分配手段22−2は
アドレス保持手段80の1番目のアドレスの差し示すデ
ータである1の差し示すデータであるa1とアドレス保
持手段80の4番目のアドレスの差し示すデータである
4の差し示すデータであるa1をデータ格納手段10から
選択し、選択データD3−2として2入力ソート手段3
0−2に送る。2入力ソート手段30−1は入力された
a2,a3のデータを比較してa3の方が大きければ、ソー
ト信号D7−1をアドレス交換手段70−1へ発行す
る。この場合a3の方が大きいのでソート信号D7−1
が発行されることになる。同様の動作を2入力ソート手
段30−2でも行う。この場合2入力ソート手段30−
2で比較される2数a1,a1は同じ大きさを持つので、
ソート信号D7−2は発行されない。The second odd-numbered data distribution means 22-2 inserts the data a1 indicating the first address of the address holding means 80 and the fourth address of the address holding means 80. Is the data shown
The data a1 indicated by 4 is selected from the data storage means 10 and the 2-input sort means 3 is selected as the selected data D3-2.
Send to 0-2. 2-input sort means 30-1 is input
When the data of a2 and a3 are compared and a3 is larger, the sort signal D7-1 is issued to the address exchanging means 70-1. In this case, since a3 is larger, the sort signal D7-1
Will be issued. The same operation is performed by the 2-input sort means 30-2. In this case, the 2-input sort means 30-
Since the two numbers a1 and a1 compared in 2 have the same size,
The sort signal D7-2 is not issued.
【0037】アドレス交換手段70は(表2)に示すよ
うに、ソート信号D7を受けるとアドレス保持手段80
のアドレスを交換する。この場合、アドレス交換手段7
0−1はソート信号D7−1を受けているので、a2とa
3のアドレスである2と3を入れ替える。アドレス交換
手段70−2はソート信号D7−2を受けていないの
で、a1とa1のアドレスである1と4は入れ替えない。
アドレスの交換の終わった後に、アドレス保持手段はス
テップ終了信号D6をカウンタ50へ送る。ここまでが
1つのステップである。ステップの終了後、アドレス保
持手段80には1,3,2,4の順番にアドレスが格納され
ている。As shown in (Table 2), the address exchanging means 70 receives the sort signal D7 and holds the address holding means 80.
Exchange addresses. In this case, the address exchange means 7
Since 0-1 receives the sort signal D7-1, a2 and a
Swap 2 and 3, which are the addresses of 3. Since the address exchanging means 70-2 has not received the sort signal D7-2, the addresses 1 and 4 of a1 and a1 are not interchanged.
After the address exchange is completed, the address holding means sends the step end signal D6 to the counter 50. This is one step. After the end of the step, the address holding means 80 stores the addresses in the order of 1, 3, 2, 4.
【0038】2番目のステップはカウンタ50に1を加
えて2になることから始まる。偶寄判定手段40からの
偶寄判定信号D2が偶数なので、偶数段データ分配手段
21が選択される。偶数段データ分配手段21−1はア
ドレス保持手段80の1番目のアドレスの差し示すデー
タである1の差し示すデータとアドレス保持手段80の
2番目のアドレスの差し示すデータである3の差し示す
データをデータ格納手段10から選択する。2番目の偶
数段データ分配手段22−2はアドレス保持手段80の
3番目のアドレスの差し示すデータである2の差し示す
データとアドレス保持手段80の4番目のアドレスの差
し示すデータである4の差し示すデータでをデータ格納
手段10から選択する。この場合D3−1のデータはa
1,a3であり、D3−2のデータはa2,a1である。こ
こで2入力ソート手段30でソートすると、ソート信号
D7−1が発行され、ソート信号D7−2は発行されな
い。よってアドレス交換手段70−1でアドレスの交換
が行われ、アドレス保持手段80に格納されているアド
レスは3,1,2,1となる。その後アドレス保持手段8
0はステップ終了信号をカウンタ50に送る。以上が第
2のステップである。The second step begins with the addition of 1 to the counter 50 to reach 2. Since the evenness determination signal D2 from the evenness determination means 40 is an even number, the even number stage data distribution means 21 is selected. The even-numbered stage data distribution unit 21-1 indicates the data indicated by 1 which is the data indicated by the first address of the address holding unit 80 and the data indicated by 3 which is the data indicated by the second address of the address holding unit 80. From the data storage means 10. The second even-numbered data distribution means 22-2 is the data indicated by 2, which is the data indicated by the third address of the address holding means 80, and the data indicated by 4, which is the data indicated by the fourth address of the address holding means 80. The data shown is selected from the data storage means 10. In this case, the data of D3-1 is a
1, a3, and the data of D3-2 are a2, a1. Here, when sorting is performed by the 2-input sort means 30, the sort signal D7-1 is issued and the sort signal D7-2 is not issued. Therefore, the address exchange means 70-1 exchanges the addresses, and the addresses stored in the address holding means 80 become 3,1,2,1. After that, the address holding means 8
0 sends a step end signal to the counter 50. The above is the second step.
【0039】同様にステップを進めていき、3つ目のス
テップが終了した時点でソートが完了する。このような
構成をとることにより、データ格納手段10のデータを
書き換えることなくソートを行うことができる。データ
格納手段10のデータは全く書き変わらないので、回路
でこの装置を実現する場合、データ格納手段10は低速
で小型の機器が使用できる。アドレスを記述する時の情
報のデータ量はデータ格納手段のデータ量よりもはるか
に小さいため、装置全体を小型化することができる事
と、毎回すべてのデータを書き換えることがない事か
ら、ソート回路を駆動させる消費電力を減少させること
ができる。Similarly, the steps are advanced, and the sorting is completed when the third step is completed. With such a configuration, sorting can be performed without rewriting the data in the data storage unit 10. Since the data in the data storage means 10 is not rewritten at all, when the circuit is used to implement this device, the data storage means 10 can be used as a low speed and small device. Since the data amount of information when describing an address is much smaller than the data amount of the data storage means, it is possible to downsize the entire device and not to rewrite all the data every time. It is possible to reduce the power consumption for driving the.
【0040】[0040]
【発明の効果】このような本発明の構成を用いてソート
を行うと、各ステップでの部分ソートを行うグループの
数は常にN個であり、N個が2入力ソート手段は効率よ
く稼働することになる。そのため比較の回数は2分木法
などの2N*log(2N)回に比べてN*(2N−1)回と増
えるものの、ソートに必要なステップ数は2分木法の平
均ステップ2N*log(2N)回に比べて2N−1ステップ
と短かなステップになり、2分木法等より高速なソート
を実現できる。When sorting is performed using such a configuration of the present invention, the number of groups for which partial sorting is performed at each step is always N, and N is a 2-input sort means that operates efficiently. It will be. Therefore, the number of comparisons increases to N * (2N-1) times compared to 2N * log (2N) times such as the binary tree method, but the number of steps required for sorting is the average step 2N * log of the binary tree method. The number of steps is as short as 2N-1 steps compared to (2N) times, and a faster sorting than the binary tree method can be realized.
【0041】また上記の構成であると、部分ソートの分
割方法はソート全体を通じて常に一定であり、ソートが
常に一定のサイクルで行われるため、専用演算器としハ
ードに組み込みやすくなる。Further, with the above configuration, the division method of the partial sort is always constant throughout the sort, and the sorting is always performed in a constant cycle, so that it can be easily incorporated into a hardware as a dedicated arithmetic unit.
【図1】本発明の実施例1に於けるソート装置の構成図FIG. 1 is a configuration diagram of a sorting device according to a first embodiment of the present invention.
【図2】同実施例のソート装置のデータの流れを示す図FIG. 2 is a diagram showing a data flow of the sorting apparatus of the embodiment.
【図3】本発明の実施例2におけるソート装置の構成図FIG. 3 is a configuration diagram of a sorting device according to a second embodiment of the present invention.
【図4】同実施例のソート装置のデータの流れを示す図FIG. 4 is a diagram showing a data flow of the sorting apparatus of the embodiment.
【図5】図1の出力データ切換え手段の詳細図5 is a detailed diagram of the output data switching means of FIG.
【図6】図3のアドレス交換手段の詳細図FIG. 6 is a detailed diagram of the address exchange means of FIG.
10 データ格納手段 20 データ分配手段 21 偶数段データ分配手段 22 奇数段データ分配手段 30 2入力ソート手段 40 偶奇判定手段 50 カウンタ 60 出力データ切換え手段 70 アドレス交換手段 80 アドレス保持手段 90 モード切換え手段 100 タイマ 10 data storage means 20 data distribution means 21 even-numbered data distribution means 22 odd-numbered data distribution means 30 2 input sort means 40 even / odd determination means 50 counter 60 output data switching means 70 address exchanging means 80 address holding means 90 mode switching means 100 timer
Claims (7)
のデータ分配手段(N:自然数)とN個の2入力ソート
手段と出力データ切換え手段とを備えた2N個のデータ
をソートするソート装置であって、 前記データ格納手段は2N個の入力データを格納し、2
N個のデータを出力し、その入力データは前記出力デー
タ切換え手段に接続され、出力データは前記データ分配
手段に接続され、 前記モード切換え手段はモード信号を作り、そのモード
信号は前記データ分配手段と前記出力データ切換え手段
に接続され、 m番目の前記データ分配手段(m:1からNまでの自然
数)は、前記モード信号を受取り、第1モードならば前
記データ格納手段の2N個のデータの中から2m−1番
目と2m番目のデータを選択し、第2モードならば前記
データ格納手段の2N個のデータの中から2m番目と2
m+1番目のデータを選択し、そのデータはm番目の前
記2入力ソート手段に接続され、 N番目の前記データ分配手段は、前記モード信号を受取
り、第1モードならば前記データ格納手段の2N個のデ
ータの中から2N−1番目と2N番目のデータを選択
し、第2モードならば前記データ格納手段の2N個のデ
ータの中から1番目と2N番目のデータを選択し、その
データはN番目の前記2入力ソート手段に接続され、 前記2入力ソート手段は前記データ分配手段で選択され
た2つのデータをソートして出力し、その出力は前記出
力データ切換え手段に接続され、 前記出力データ切換え手段は前記ソートされたデータ
を、前記モード信号を受けて前記データ分配手段によっ
て決められた位置に切り換え、前記データ格納手段に格
納し、 前記出力データ切換え手段は全てのデータの格納が終わ
ると、前記モード切換え手段はモード切換え信号を受け
てモードを切換え、 以上の動作を前記モード切換え手段の切換え回数が2N
−1になるまで繰り返すことを特徴とするソート装置。1. A sorting device for sorting 2N data, comprising data storage means, mode switching means, N data distribution means (N: natural number), N 2-input sorting means and output data switching means. And the data storage means stores 2N pieces of input data,
N pieces of data are output, the input data are connected to the output data switching means, the output data are connected to the data distribution means, the mode switching means creates a mode signal, and the mode signal is the data distribution means. And the output data switching means, the m-th data distribution means (m: natural number from 1 to N) receives the mode signal, and in the first mode, outputs 2N data of the data storage means. The 2m-1st and 2mth data are selected from the inside, and in the second mode, the 2mth and 2mth data are selected from the 2N pieces of data in the data storage means.
The m + 1st data is selected, the data is connected to the mth two-input sort means, the Nth data distribution means receives the mode signal, and if the first mode, 2N pieces of the data storage means 2N-1th and 2Nth data are selected from among the 2N data, and in the second mode, the 1st and 2Nth data are selected from the 2N data in the data storage means, and the data are N The second input sort means is connected to the second input sort means, the two input sort means sorts and outputs the two data selected by the data distribution means, and the output is connected to the output data switching means, The switching means receives the mode signal, switches the sorted data to a position determined by the data distribution means, and stores the sorted data in the data storage means, When all the data are stored in the output data switching means, the mode switching means receives the mode switching signal to switch the mode, and the above operation is performed when the number of switching times of the mode switching means is 2N.
A sorting device characterized by repeating until it becomes -1.
ウンタに接続された偶奇判定手段を有し、前記カウンタ
はモード切換え信号を値を受けて1増加し、前記偶奇判
定手段は前記カウンタの値の偶奇の判断信号を作成する
ことを特徴とする請求項1記載のソート装置。2. The mode switching means includes a counter and an even / odd determination means connected to the counter, the counter receives a mode switching signal and increments by 1, and the even / odd determination means determines the value of the counter. The sorting device according to claim 1, wherein an even-odd judgment signal is generated.
段はN個同時に動作することを特徴とする請求項1記載
のソート装置。3. The sorting apparatus according to claim 1, wherein N pieces of said two-input sort means and said data distribution means operate simultaneously.
データ切換え部を有し、m番目の前記出力データ切換え
部は、前記モード信号を受取り、 第1モードならば、 m番目の前記2入力ソート手段の出力の内、大きい方の
データを前記データ格納手段の2m−1番目の位置に格
納し、小さい方のデータを前記データ格納手段の2m番
目の位置に格納し、 N番目の前記2入力ソート手段の出力の大きい方のデー
タを前記データ格納手段の2N−1番目の位置に格納
し、小さい方のデータを前記データ格納手段の2N番目
の位置に格納し、 第2モードならば、 m番目の前記2入力ソート手段の出力の内、大きい方の
データを前記データ格納手段の2m番目の位置に格納
し、小さい方のデータを前記データ格納手段の2m+1
番目の位置に格納し、 N番目の前記2入力ソート手段の出力の大きい方のデー
タを前記データ格納手段の1番目の位置に格納し、小さ
い方のデータを前記データ格納手段の2N番目の位置に
格納することを特徴とする請求項1記載のソート装置。4. The output data switching means has N output data switching units, and the m-th output data switching unit receives the mode signal. In the first mode, the m-th output data switching unit receives the mode signal. Out of the output of the input sort means, the larger data is stored in the 2m-1th position of the data storage means, and the smaller data is stored in the 2mth position of the data storage means, and the Nth data is stored. The data with the larger output of the 2-input sort means is stored in the 2N-1th position of the data storage means, and the data with the smaller output is stored in the 2Nth position of the data storage means. Of the output of the m-th two-input sort means, the larger data is stored in the 2m-th position of the data storage means, and the smaller data is stored in the data storage means of 2m + 1.
The second data of the output of the N-th two-input sort means is stored in the first position of the data storage means, and the data of the smaller output is stored in the second position of the data storage means. 2. The sorting device according to claim 1, wherein the sorting device is stored in.
のデータ分配手段(N:自然数)とN個の2入力ソート
手段とアドレス保持手段とN個のアドレス交換手段とを
備えた2N個のデータをソートするソート装置であっ
て、 前記データ格納手段は2N個の入力データを格納し、2
N個のデータを前記データ分配手段に出力し、 前記モード切換え手段はモード信号を作り、そのモード
信号は前記データ分配手段と前記アドレス交換手段に接
続され、 前記アドレス保持手段は前記データ格納手段のデータの
アドレスを保持し、その出力は前記データ分配手段に接
続され、 m番目の前記データ分配手段(m:1からN−1までの
自然数)は、前記モード信号を受取り、第1モードなら
ば前記アドレス保持手段の2m−1番目と2m番目に書
かれているアドレスのデータを前記データ格納手段の2
N個のデータの中から選択し、第2モードならば前記ア
ドレス保持手段の2m番目と2m+1番目に書かれてい
るアドレスのデータを前記データ格納手段の2N個のデ
ータの中から選択し、そのデータはm番目の前記2入力
ソート手段に接続され、 N番目の前記データ分配手段は、前記モード信号を受取
り、第1モードならば前記アドレス保持手段の2N−1
番目と2N番目に書かれているアドレスのデータを前記
データ格納手段の2N個のデータの中から選択し、第2
モードならば前記アドレス保持手段の1番目と2N番目
に書かれているアドレスのデータを前記データ格納手段
の2N個のデータの中から選択し、そのデータはN番目
の前記2入力ソート手段に接続され、 前記2入力ソート手段は前記データ分配手段で選択され
たデータを比較しデータを入れ替える必要がある時にソ
ート信号を出力し、その出力は前記アドレス交換手段に
接続され、 m番目の前記アドレス交換手段は、アドレスの入出力が
前記アドレス保持手段に接続され、前記モード信号が第
1モードで且つソート信号が発生されていればアドレス
保持手段の2m−1番目の位置のアドレスと2m番目の
位置のアドレスを交換し、前記モード信号が第2モード
で且つソート信号が発生されていればアドレス保持手段
の2m番目の位置のアドレスと2m+1番目の位置のア
ドレスを交換し、N番目の前記2入力ソート手段の出力
は、アドレスの入出力が前記アドレス保持手段に接続さ
れ、前記モード信号が第1モードで且つソート信号が発
生されていればアドレス保持手段の2N−1番目の位置
のアドレスと2N番目の位置のアドレスを交換し、前記
モード信号が第2モードで且つソート信号が発生されて
いればアドレス保持手段の1番目の位置のアドレスと2
N番目の位置のアドレスを交換し、 前記アドレス保持手段はアドレスの全てのアドレスの交
換が終わると、前記モード切換え手段はモード切換え信
号を値を受けてモードを切換え、 以上の動作を前記モード切換え手段の切換え回数が2N
−1になるまで繰り返すことを特徴とするソート装置。5. A 2N number of data storage means, a mode switching means, N data distribution means (N: natural number), N 2-input sort means, address holding means, and N address exchanging means. A sorting device for sorting data, wherein the data storage means stores 2N pieces of input data,
The N pieces of data are output to the data distribution means, the mode switching means produces a mode signal, the mode signal is connected to the data distribution means and the address exchange means, and the address holding means of the data storage means. Holds the address of the data, the output of which is connected to the data distribution means, and the m-th data distribution means (m: a natural number from 1 to N-1) receives the mode signal, and if the first mode The data of the addresses 2m-1th and 2mth of the address holding means are stored in the data storage means 2
If the second mode is selected from the N pieces of data, the data of the addresses 2m and 2m + 1 of the address holding means are selected from the 2N pieces of data of the data storage means, The data is connected to the m-th two-input sorting means, the N-th data distributing means receives the mode signal, and in the first mode, 2N-1 of the address holding means.
The data of the addresses written in the 2nd and 2Nth addresses are selected from the 2N pieces of data in the data storage means, and the second data is selected.
In the mode, the data of the first and 2Nth addresses of the address holding means is selected from the 2N pieces of data of the data storage means, and the data is connected to the Nth two-input sort means. The 2-input sort means outputs the sort signal when it is necessary to compare the data selected by the data distributing means and replace the data, and the output is connected to the address exchanging means, and the m-th address exchanging means is exchanged. The input / output of the address is connected to the address holding means, and if the mode signal is in the first mode and a sort signal is generated, the address of the (2m-1) th position and the 2mth position of the address holding means. If the mode signal is in the second mode and the sort signal is generated, the address of the 2mth position of the address holding means is exchanged. The address at the 2m + 1th position is exchanged with the address, and the output of the N-th two-input sort means is connected to the address holding means for input / output of the address, the mode signal is in the first mode, and the sort signal is generated. If the address signal is stored in the address holding means, the address at the (2N-1) th position and the address at the 2Nth position are exchanged. Location address and 2
The address at the Nth position is exchanged, and when all the addresses of the addresses are exchanged by the address holding means, the mode switching means receives the value of the mode switching signal to switch the mode, and the above operation is performed by the mode switching. The number of switching means is 2N
A sorting device characterized by repeating until it becomes -1.
ウンタに接続された偶奇判定手段を有し、前記カウンタ
はモード切換え信号を値を受けて1増加し、前記偶奇判
定手段は前記カウンタの値の偶奇の判断信号を作成する
ことを特徴とする請求項5記載のソート装置。6. The mode switching means has a counter and an even / odd determination means connected to the counter, the counter receives a value of the mode switching signal and increments by 1, and the even / odd determination means determines the value of the counter. The sorting apparatus according to claim 5, wherein an even-odd determination signal is generated.
段と前記アドレス交換手段はN個同時に動作することを
特徴とする請求項5記載のソート装置。7. The sorting apparatus according to claim 5, wherein the two-input sorting means, the data distributing means, and the address exchanging means operate N at the same time.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP31315194A JP3264114B2 (en) | 1994-12-16 | 1994-12-16 | Sorting device |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP31315194A JP3264114B2 (en) | 1994-12-16 | 1994-12-16 | Sorting device |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| JPH08171479A true JPH08171479A (en) | 1996-07-02 |
| JP3264114B2 JP3264114B2 (en) | 2002-03-11 |
Family
ID=18037729
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| JP31315194A Expired - Fee Related JP3264114B2 (en) | 1994-12-16 | 1994-12-16 | Sorting device |
Country Status (1)
| Country | Link |
|---|---|
| JP (1) | JP3264114B2 (en) |
-
1994
- 1994-12-16 JP JP31315194A patent/JP3264114B2/en not_active Expired - Fee Related
Also Published As
| Publication number | Publication date |
|---|---|
| JP3264114B2 (en) | 2002-03-11 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US5410727A (en) | Input/output system for a massively parallel, single instruction, multiple data (SIMD) computer providing for the simultaneous transfer of data between a host computer input/output system and all SIMD memory devices | |
| JP7241470B2 (en) | Vector processor array sorting method | |
| CN109445752B (en) | A parallel computing system | |
| US7120903B2 (en) | Data processing apparatus and method for generating the data of an object program for a parallel operation apparatus | |
| JPH0728624A (en) | Sorting apparatus and sorting method | |
| EP3963462A1 (en) | Efficient archtectures for deep learning algorithms | |
| WO2003091872A1 (en) | Parallel merge/sort processing device, method, and program | |
| JP5549442B2 (en) | FFT arithmetic unit | |
| CN114528111A (en) | FPGA chip for data recall and data recall method | |
| US6598061B1 (en) | System and method for performing modular multiplication | |
| JPH07191832A (en) | Binary square circuit | |
| JP2752634B2 (en) | Sorting device | |
| US5727200A (en) | Parallel merge sorting apparatus with an accelerated section | |
| US7370046B2 (en) | Sort processing method and sort processing apparatus | |
| JP3264114B2 (en) | Sorting device | |
| JP3333779B2 (en) | Matrix arithmetic unit | |
| US8117507B2 (en) | Decompressing method and device for matrices | |
| JP5208080B2 (en) | Sequence control circuit and control circuit | |
| JPH08212168A (en) | Array processor | |
| JP3525960B2 (en) | Parallel sort method | |
| JP4158264B2 (en) | Sort / merge processing device and sort / merge circuit | |
| JPH1063647A (en) | Matrix arithmetic unit | |
| JP3320767B2 (en) | Data processing apparatus and control method thereof | |
| JP3447180B2 (en) | Data operation circuit | |
| JPH07325805A (en) | Vector processor |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| LAPS | Cancellation because of no payment of annual fees |