JP2010218178A - Sort processing apparatus and sort processing method - Google Patents

Sort processing apparatus and sort processing method Download PDF

Info

Publication number
JP2010218178A
JP2010218178A JP2009063714A JP2009063714A JP2010218178A JP 2010218178 A JP2010218178 A JP 2010218178A JP 2009063714 A JP2009063714 A JP 2009063714A JP 2009063714 A JP2009063714 A JP 2009063714A JP 2010218178 A JP2010218178 A JP 2010218178A
Authority
JP
Japan
Prior art keywords
data
comparison
exchange
sort
target data
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.)
Pending
Application number
JP2009063714A
Other languages
Japanese (ja)
Inventor
Takashi Hamabe
崇 浜辺
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.)
ASIP SOLUTIONS Inc
Original Assignee
ASIP SOLUTIONS Inc
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 ASIP SOLUTIONS Inc filed Critical ASIP SOLUTIONS Inc
Priority to JP2009063714A priority Critical patent/JP2010218178A/en
Publication of JP2010218178A publication Critical patent/JP2010218178A/en
Pending legal-status Critical Current

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

<P>PROBLEM TO BE SOLVED: To achieve sort processing whose processing speed is higher than conventional bubble sort when sort frequency is large, in a system in which area constraint is strict and the number of sort object data is small. <P>SOLUTION: This sort processing apparatus is configured to perform processing for determining the maximum value data to all sort object data by using a comparison/exchange means 103 configured of comparison/exchange arithmetic units 111 and 113 including comparison/exchange arithmetic units of binary to be executed in parallel for reading m pieces (m>2) comparison/exchange object data in sort object data from a storage means 101 and a register 112 for a pipe line, and to repeat the similar processing even to the residual sort object data by determining the sequence of the (m-1) pieces of data. <P>COPYRIGHT: (C)2010,JPO&INPIT

Description

本発明は、従来のバブルソートに比べて処理速度を大幅に向上できるソート処理装置およびソート処理方法に関するものである。       The present invention relates to a sort processing apparatus and a sort processing method capable of significantly improving the processing speed as compared with a conventional bubble sort.

バブルソートは,データの比較と交換を繰り返すことにより、最大または最小の数を1 つずつ確定していくソーティング方法である。バブルソートは、最悪計算時間がデータ数nに対して(n+・・・+2+1)回の比較交換が必要でデータ数2乗に比例するため,ソーティング方法としては遅い部類に分類されるが、アルゴリズムが単純であり、複雑な演算器を使用しないため、面積制約が厳しく、ソート対象のデータ数が少ないシステムに適している。     Bubble sort is a sorting method in which the maximum or minimum number is determined one by one by repeatedly comparing and exchanging data. Bubble sort is classified as a slow sorting method because the worst calculation time requires (n + ... + 2 + 1) comparisons and exchanges with the number of data n and is proportional to the square of the number of data. Is simple and does not use a complex arithmetic unit, and is therefore suitable for a system with a strict area restriction and a small number of data to be sorted.

バブルソートは2重のループで構成される。内側のループでは、順位が未確定のデータを順に2個ずつ選択、比較交換し、最小値を選び出す。内側のループは、最小値が1つ選択されるまで繰り返される。外側のループでは、順位が未確定のデータの範囲を更新し、内側のループに戻る。外側のループは全てのデータの順位が確定するまで繰り返される。   Bubble sort consists of double loops. In the inner loop, two pieces of data whose order is indefinite are sequentially selected, compared and exchanged, and the minimum value is selected. The inner loop is repeated until one minimum value is selected. In the outer loop, the range of data whose order is indefinite is updated, and the process returns to the inner loop. The outer loop is repeated until the ranking of all data is established.

特開2002−229772号公報Japanese Patent Application Laid-Open No. 2002-229772

しかしながら、面積制約が厳しく、ソート対象のデータ数が少ないシステムにおいてもソート回数が多大な場合には従来のバブルソートの方法では処理速度が遅いなどの課題があった。
本発明は、このような従来の課題を解決するため、バブルソートの方法を拡張かつ改善し、専用演算器を追加し、また、パイプライン化により従来のバブルソート装置より高速なソート装置及びソート方法を提供することを目的とする。
However, even in a system where the area restriction is strict and the number of data to be sorted is small, when the number of times of sorting is large, the conventional bubble sorting method has a problem that the processing speed is slow.
In order to solve such a conventional problem, the present invention expands and improves the bubble sort method, adds a dedicated arithmetic unit, and makes the sort apparatus and sort faster than the conventional bubble sort apparatus by pipelining. It aims to provide a method.

本発明に係るソート処理方法は、入力された複数のデータを初めのソート対象データとする第1のステップと、ソート対象データからm個(mは3以上の整数)のデータを初めの比較交換対象データとして比較交換し昇順のソートの場合は最大値のデータを降順のソートの場合は最小値のデータを決定データとして決める第2のステップと、比較交換対象データの内の決められた決定データを除くm−1個のデータとソート対象データの内の比較交換対象データとなったことがないデータの1つを合わせて新たな比較対象データとして比較交換し新たな決定データを決める処理を比較交換対象データとなる最後のm個のデータまで繰り返す第3のステップと、第3のステップで残ったm−1個のデータの順位を決めてソート対象データの内の残ったm−1個のデータを除くデータを新たなソート対象データとする第4のステップと、を備え、第2のステップと第3のステップと第4のステップを入力された複数のデータの全ての順位が確定するまで繰り返すようにしたものである。
本発明に係るソート処理装置は、入力された複数のデータを格納する記憶手段と、記憶手段のソート対象データの範囲の内のデータを比較交換対象データとして格納する第1のレジスタ群と、第1のレジスタ群に格納した各々のデータの比較交換演算を複数のステージでパイプライン処理し昇順のソートの場合は最大値のデータを降順のソートの場合は最小値のデータを決定データとして決める比較交換手段と、比較交換手段の各ステージでの比較交換演算の対象となるデータを各ステージに対応して格納する第2のレジスタ群と、記憶手段と第1のレジスタ群と比較交換手段と第2のレジスタ群を制御する制御部と、を備え、記憶手段からソート対象データの範囲の内のm個(mは3以上の整数)のデータを読み出し第1のレジスタ群に格納する第1の処理をした後、第1のレジスタ群から比較交換対象データを読み出して比較交換手段において比較交換対象データの内で昇順のソートの場合は最大値のデータを降順のソートの場合は最小値のデータを決定データとして決める処理と、比較交換手段で決められた決定データを記憶手段に書き戻す処理と、比較交換対象データの内の決められた決定データを除くm−1個のデータと記憶手段に格納されているソート対象データの範囲の内の比較交換対象データとなったことがないデータの1つを読み出し合わせて第1のレジスタ群に新たな比較対象データとして格納する処理と、を比較交換対象データとなる最後のm個のデータまで繰り返す第2の処理を行い、残ったm−1個のデータの順位を決める第3の処理を行い、ソート対象データの内の残ったm−1個のデータを除くデータを新たなソート対象データの範囲とする第4の処理を行い、入力された複数のデータの全ての順位が確定するまで第1の処理と第2の処理と第3の処理と第4の処理を繰り返すようにしたものである。
The sort processing method according to the present invention includes a first step in which a plurality of input data is used as the first sort target data, and m pieces of data (m is an integer of 3 or more) from the sort target data. The second step of determining the data to be compared and exchanged as the target data and the data of the maximum value in the case of sort in ascending order and the data of the minimum value in the case of sort in descending order as the decision data, and the determined decision data among the data to be compared and exchanged Compare the process of determining new decision data by comparing and exchanging m-1 data excluding, and one of the sort target data that has never been compared and replaced as new comparison data The third step that repeats up to the last m pieces of data to be exchanged data, and the order of the m-1 data remaining in the third step are determined, and the order of the sort target data A fourth step in which data excluding only m-1 data is set as new sort target data, and the second step, the third step, and the fourth step This is repeated until all rankings are finalized.
A sort processing apparatus according to the present invention includes a storage unit that stores a plurality of input data, a first register group that stores data within a range of sort target data in the storage unit as comparison / exchange target data, Comparison and exchange operations of each data stored in one register group are pipelined at multiple stages, and the maximum value data is selected as the decision data in the ascending order and the minimum value data is determined as the decision data in the descending order sort An exchange unit, a second register group for storing data to be subjected to a comparison / exchange operation at each stage of the comparison / exchange unit, corresponding to each stage, a storage unit, a first register group, a comparison / exchange unit, A control unit that controls the two register groups, and reads m pieces of data (m is an integer of 3 or more) within the range of data to be sorted from the storage means and stores them in the first register group After the first processing is performed, the comparison / exchange target data is read from the first register group, and the comparison / exchange unit selects the maximum value data in the descending order when the comparison / exchange data is sorted in the ascending order. A process for determining the minimum value data as decision data, a process for writing the decision data determined by the comparison / exchange means back to the storage means, and m−1 pieces of data excluding the determined decision data of the comparison / exchange target data And one of the data that has never become comparison / exchange target data within the range of the data to be sorted stored in the storage means, and stores the data as new comparison target data in the first register group; Are repeated until the last m pieces of data to be compared and exchanged, the third process for determining the rank of the remaining m-1 pieces of data is performed, and the sort pair A fourth process is performed in which data other than the remaining m−1 data among the data is set as a new range of data to be sorted, and the first process is performed until all ranks of the plurality of input data are determined. The second process, the third process, and the fourth process are repeated.

本願発明のソート処理方法(以下、拡張バブルソート方法という)は、最悪計算時間のオーダーは、バブルソートと同じく、データ数の2乗に比例するが、専用演算器との組み合わせにより、ループ回数を削減し、実行時間を短縮できる。
例えば、一度に比較するデータ数を4とすると、最悪時の比較交換回数はおよそ(n+・・・+2+1)/3となる。さらに、メモリアクセス回数の削減により実行サイクル数がより削減される。
In the sort processing method of the present invention (hereinafter referred to as the expanded bubble sort method), the worst calculation time order is proportional to the square of the number of data as in the bubble sort. Can reduce the execution time.
For example, if the number of data to be compared at a time is 4, the worst number of comparison exchanges is approximately (n +... + 2 + 1) / 3. Furthermore, the number of execution cycles is further reduced by reducing the number of memory accesses.

本願発明のソート処理装置は、ハードウェア量を従来のバブルソートより少しの増加に抑えることができ、従来のバブルソートを用いる演算器と同様に、面積制約の大きいシステムに適用できるだけではなく、より高速にソート処理することができる。   The sort processing apparatus of the present invention can suppress the amount of hardware to a slight increase compared to the conventional bubble sort, and can be applied not only to a system with a large area constraint, but also to a computing unit that uses the conventional bubble sort. Sorting can be performed at high speed.

本発明の実施の形態1によるソート処理装置の構成図Configuration diagram of sort processing apparatus according to Embodiment 1 of the present invention 本発明の実施の形態1によるソート処理装置の処理方法を示すフローチャートThe flowchart which shows the processing method of the sort processing apparatus by Embodiment 1 of this invention. 本発明の実施の形態1によるm=4の場合の実施例であるソート処理装置の構成図The block diagram of the sort processing apparatus which is an Example in the case of m = 4 by Embodiment 1 of this invention 図3のプロセッサを構成するブロックの表記とその種類と名称および内容または動作を示す図The figure which shows the description of the block which comprises the processor of FIG. 3, its kind and name, content, or operation | movement 本発明の実施例の比較交換手段の構成及び動作の説明図Explanatory drawing of a structure and operation | movement of the comparison exchange means of the Example of this invention 本発明の実施例におけるソート処理装置の処理方法を示すフローチャートThe flowchart which shows the processing method of the sort processing apparatus in the Example of this invention. 本発明の実施例におけるソート処理装置の評価実験の測定結果Measurement result of evaluation experiment of sort processing apparatus in an embodiment of the present invention

本発明の実施の一形態を説明する。   An embodiment of the present invention will be described.

図1は本発明の実施の形態1によるソート処理装置を示す構成図である。   FIG. 1 is a block diagram showing a sort processing apparatus according to Embodiment 1 of the present invention.

図1において、ソート処理装置は、入力された複数のデータを格納するデータメモリ101(記憶手段)と、データメモリ101のソート対象データの範囲の内のデータをm個(mは3以上の整数)読み出し比較交換対象データとして格納する専用レジスタ102(第1のレジスタ群)と、専用レジスタ102に格納した各々のデータの比較交換演算により昇順のソートの場合は最大値のデータを決め降順のソートの場合は最小値を決める比較交換手段103と、制御部104を備えている。また、比較交換手段103は、複数のステージの比較交換演算を行うため、専用レジスタ102から読み出したデータを比較演算する比較交換演算器111と、比較交換演算器111の出力で次のステージの比較演算の対象となるデータを格納するレジスタ112(第2のレジスタ群)、次のステージでレジスタ112から読み出したデータを比較演算する比較交換演算器112を備えている。制御部104は、データメモリ101と専用レジスタ102の入出力、比較交換手段の出力の専用レジスタ102及びデータメモリ101への出力を制御する。
なお、比較交換手段103が3以上のステージを持つ場合はステージ間にさらにレジスタを付け加えればよい。例えば、m>4のときは、比較交換手段103が、log(2)m (2を底とする対数をとり小数点以下切り上げ)個の比較交換演算器と、log(2)m−1個のレジスタで構成され、比較交換演算器間にレジスタが挟まれる構成になる。mが大きい場合、複数の比較交換演算を1サイクルで実現するために、全ての比較交換演算器の間にレジスタを挟むのではなく、他の演算器の遅延やシステムの遅延制約次第で、数個の比較交換演算器の間に1つのレジスタを挟むことにより、パイプライン段数の増加を抑えるという構成をとることもできる。
In FIG. 1, the sort processing apparatus includes a data memory 101 (storage means) for storing a plurality of input data, and m pieces of data within the range of data to be sorted in the data memory 101 (m is an integer of 3 or more). ) In the case of sorting in ascending order by comparison exchange operation of each data stored in the dedicated register 102 (first register group) stored as read comparison exchange target data, the maximum value data is determined and sorting in descending order In this case, a comparison / exchange unit 103 for determining a minimum value and a control unit 104 are provided. Further, the comparison / exchange unit 103 performs comparison / exchange operations of a plurality of stages, so that the comparison / exchange operation unit 111 that performs comparison operation on the data read from the dedicated register 102 and the comparison / output unit 111 output the comparison of the next stage. A register 112 (second register group) for storing data to be operated is provided, and a comparison / exchange operation unit 112 for performing a comparison operation on data read from the register 112 in the next stage. The control unit 104 controls input / output of the data memory 101 and the dedicated register 102 and output of the output of the comparison / exchange means to the dedicated register 102 and the data memory 101.
If the comparison / exchange means 103 has three or more stages, a register may be added between the stages. For example, when m> 4, the comparison / exchange means 103 has log (2) m (logarithm with base 2 and rounded up to the next decimal point) comparison / exchange arithmetic units and log (2) m−1 It is configured by a register, and the register is sandwiched between comparison / exchange arithmetic units. When m is large, in order to realize a plurality of comparison / exchange operations in one cycle, it is not necessary to put a register between all the comparison / exchange operations, but depending on the delay of other operation units and the delay constraint of the system. It is possible to adopt a configuration in which an increase in the number of pipeline stages is suppressed by interposing one register between the comparison / exchange operation units.

次に、ソート処理装置の動作を説明する。   Next, the operation of the sort processing device will be described.

図2は、本発明の実施の形態1によるソート処理装置の処理方法を昇順のソートについて示すフローチャートである。まず、データメモリ101のソート対象データの範囲を初期設定する(ステップS1)。次に、ソート対象のデータが存在するかを判断し(ステップS2)、無ければ全ての順位づけが終わったとして終了し、あれば次のステップS3に進む。ステップS3では、データメモリ101からソート対象データの範囲の内の所定のm個(mは3以上の整数)のデータを比較交換対象データとして読み出す。次に、比較交換対象データを専用レジスタ102に書き込み(ステップS4)、比較交換手段103で比較交換対象データの最大値のデータを決め(ステップS5)、決められた最大値のデータをデータメモリ101に書き戻す(ステップS6)。次に、ソート対象の全てのデータが比較交換済みかを判断する(ステップS7)。済んでいない場合は、比較交換対象データの内の決められた最大値のデータを除くm−1個のデータとデータメモリ101に格納されているソート対象データの範囲の内で比較交換対象データとなったことがないデータの1つを読み出し合わせて新たな比較対象データとし(ステップS8)、ステップS4に戻る。ステップS4〜S8の繰り返しを内側ループと呼ぶ。ソート対象データの範囲の比較交換対象データとなる最後のm個のデータまで内側ループの処理が終わりソート対象の全てのデータが比較交換済みとなったとき、残ったm−1個のデータの順位を決めデータメモリ101に書き戻す(ステップS9)、ここでこれまでの内側ループの処理とステップS9で交換が行われたかどうかについて例えば交換発生フラグで保持して置き一度も交換が発生しないかどうかを見ることによって、処理の途中でソートが完了したかを判断する(ステップS10)。一度も交換が発生しなかった時は、ソートが完了したとして終了する。一度でも交換が発生したときは、ソート対象データのうちで内側ループの最後で残ったm−1個のデータ以外のデータを新たなソート対象データの範囲とし(ステップ11)、ステップS2に戻り新たな比較交換を実行していく。このループを外側ループと呼ぶ。   FIG. 2 is a flowchart showing the processing method of the sort processing apparatus according to the first embodiment of the present invention for sorting in ascending order. First, the range of data to be sorted in the data memory 101 is initialized (step S1). Next, it is determined whether or not there is data to be sorted (step S2). If there is no data to be sorted, the process ends with all the rankings being completed. In step S3, predetermined m pieces of data (m is an integer of 3 or more) within the range of the sort target data are read from the data memory 101 as comparison exchange target data. Next, the comparison / exchange target data is written to the dedicated register 102 (step S4), the comparison / exchange means 103 determines the maximum value of the comparison / exchange target data (step S5), and the determined maximum value data is stored in the data memory 101. (Step S6). Next, it is determined whether all data to be sorted have been compared and exchanged (step S7). If not, the comparison / exchange target data within the range of the m−1 data excluding the determined maximum value data of the comparison / exchange target data and the sort target data stored in the data memory 101 One of the data that has never been read is read out and used as new comparison target data (step S8), and the process returns to step S4. The repetition of steps S4 to S8 is called an inner loop. When the processing of the inner loop is completed up to the last m pieces of data to be compared and exchanged in the range of sort target data, and all the data to be sorted has been compared and exchanged, the rank of the remaining m-1 data Is determined and written back to the data memory 101 (step S9). Here, whether the processing of the inner loop so far and whether or not the exchange has been performed in step S9 is held in the exchange occurrence flag, for example, whether or not the exchange has never occurred. It is determined whether sorting is completed during the process (step S10). If no exchange has occurred, the process ends as the sorting is completed. When the exchange occurs even once, the data other than the m-1 data remaining at the end of the inner loop among the sort target data is set as a new sort target data range (step 11), and the process returns to step S2 to newly Will carry out a comparative exchange. This loop is called the outer loop.

なお、ここでソートを小さい値から行う場合(昇順)としたが、大きいほうから行う場合(降順)は、上述したート処理装置の処理方法の説明で「最大値」を「最小値」と読み替えればよい。   Here, the sort is performed from a small value (ascending order), but when the sort is performed from the large value (descending order), “maximum value” is referred to as “minimum value” in the above description of the processing method of the route processing apparatus. You can replace it.

図3は、本発明の実施の形態1のm=4の場合の実施例で、プロセッサに組み込まれたソート処理装置を示す。プロセッサを構成するブロックの図3中の表記とその種類と名称及び内容または動作について、図4に示す。   FIG. 3 shows an example of the case of m = 4 according to the first embodiment of the present invention, and shows a sort processing device incorporated in a processor. FIG. 4 shows the notation of the blocks constituting the processor in FIG. 3, their types, names, contents, and operations.

図3のプロセッサは、遅延時間の削減のため、4段のパイプラインを持ち、3つのパイプラインレジスタ320、312、322で分けられている。パイプラインステージは命令フェッチを行うパイプラインレジスタ320の前までのIFステージ、 命令のデコードを行うパイプラインレジスタ312の前までのIDステージ、 演算を実行するパイプラインレジスタ322の前までのEXEステージ、パイプラインレジスタ322の後のデータメモリの読み書きやレジスタへの書き込みを行うWBステージの4個で構成される。比較交換演算器311は図1の比較交換演算器111に対応し、IDステージに含まれる。比較交換演算器313は図1の比較交換演算器113に対応し、EXEステージに含まれる。比較交換演算器311、比較交換演算器313及びパイプラインレジスタ312は、比較交換演算により昇順のソートの場合は最大値のデータを決める比較交換手段103を構成する。データメモリ301は図1のデータメモリ101に対応し、入力された複数のデータを格納し、また処理途中のデータの入出力および最終の全ての順位づけが終わったデータの格納が行われる。専用レジスタ302は図1の専用レジスタ102に対応し、4個の比較交換対象データを格納するSPR0,SPR1,SPR2,SPR3に加えて、IDステージ及びEXEステージの比較交換演算器311または比較交換演算器313で一度でも交換が発生したかどうかを示す交換発生フラグを格納する交換フラグレジスタXFからなる。   The processor shown in FIG. 3 has a four-stage pipeline and is divided into three pipeline registers 320, 312, and 322 in order to reduce delay time. The pipeline stage includes an IF stage up to the pipeline register 320 that performs instruction fetch, an ID stage up to the pipeline register 312 that decodes the instruction, an EXE stage up to the pipeline register 322 that executes the operation, It consists of four WB stages that read and write data memory after the pipeline register 322 and write to the register. The comparison exchange calculator 311 corresponds to the comparison exchange calculator 111 of FIG. 1 and is included in the ID stage. The comparison exchange calculator 313 corresponds to the comparison exchange calculator 113 of FIG. 1 and is included in the EXE stage. The comparison exchange calculator 311, the comparison exchange calculator 313, and the pipeline register 312 constitute a comparison exchange unit 103 that determines the maximum value data in the case of sorting in ascending order by comparison exchange operation. The data memory 301 corresponds to the data memory 101 of FIG. 1, stores a plurality of input data, and inputs / outputs data in the middle of processing and stores data after all ranking has been completed. The dedicated register 302 corresponds to the dedicated register 102 in FIG. 1, and in addition to the SPR0, SPR1, SPR2 and SPR3 for storing the four comparison exchange target data, the ID stage and EXE stage comparison exchange calculator 311 or the comparison exchange operation It comprises an exchange flag register XF for storing an exchange occurrence flag indicating whether or not exchange has occurred even once in the device 313.

図5は、比較交換手段103の詳細な説明図である。4個の比較交換対象データが専用レジスタ102のSPR0〜3から比較交換演算器311に読み込まれる。比較交換演算器311は、入力された2値を比較し大きい方の値と小さい方の値に分けて出力する2個の比較交換演算器CMPX0,CMPX1からなる。比較交換演算器313も同様に、入力された2値を比較し大きい方の値と小さい方の値に分けて出力する2個の比較交換演算器CMPX2,CMPX3からなるが、比較交換演算器CMPX2では比較交換演算器311で出力されパイプラインレジスタ312に格納された2個の大きい方の値を入力し比較交換し、比較交換演算器CMPX3では比較交換演算器311で出力されパイプラインレジスタ412に格納された2個の小さい方の値を入力し比較交換する。従って、4個の比較交換対象データの内、最大値を持つデータと最小値を持つデータが決定され、それぞれ専用レジスタ102のSPR3とSPR2に格納される。一方、比較交換演算器CMPX0,CMPX1でそれぞれ交換が起こった場合に1を出力するようにして交換フラグレジスタXFの値とOR演算器501で論理和をとりパイプラインレジスタ412に出力し、その値と比較交換演算器CMPX2,CMPX3でそれぞれ交換が起こった場合に1を出力するようにしてOR演算器501で論理和をとり交換フラグレジスタXFに出力することにより、比較交換手段103の比較交換演算器CMPX0,CMPX1,CMPX2,CMPX3どれか1つでもデータの交換が成立したときに交換フラグレジスタXF1が1にセットされるようにすることができる。   FIG. 5 is a detailed explanatory diagram of the comparison / exchange means 103. Four comparison / exchange target data are read from the SPR 0 to 3 of the dedicated register 102 into the comparison / exchange arithmetic unit 311. The comparison / exchange operation unit 311 is composed of two comparison / exchange operation units CMPX0 and CMPX1 that compare the input binary values and output the divided values as a larger value and a smaller value. Similarly, the comparison / exchange operation unit 313 is composed of two comparison / exchange operation units CMPX2 and CMPX3 that compare the input two values and output the divided value as a larger value and a smaller value. In the comparison and exchange computing unit 311, the two larger values stored in the pipeline register 312 are input and compared and exchanged. In the comparison and exchange computing unit CMPX3, the comparison and exchange computing unit 311 outputs and enters the pipeline register 412. The two smaller values stored are input and compared. Accordingly, the data having the maximum value and the data having the minimum value among the four comparison exchange target data are determined and stored in SPR3 and SPR2 of the dedicated register 102, respectively. On the other hand, when exchange occurs in the comparison exchange arithmetic units CMPX0 and CMPX1, 1 is output so that the value of the exchange flag register XF is ORed with the OR arithmetic unit 501, and is output to the pipeline register 412. And the comparison / exchange arithmetic units CMPX2 and CMPX3 output the logical OR in the OR arithmetic unit 501 so as to output 1 when the exchange occurs, and output the result to the exchange flag register XF. The exchange flag register XF1 can be set to 1 when any one of the devices CMPX0, CMPX1, CMPX2, and CMPX3 has exchanged data.

次に、本実施例におけるソート処理装置の動作を説明する。
図6は、本実施例におけるソート処理装置の処理方法を昇順のソートについて示すフローチャートである。まず、交換フラグレジスタXFの値を0クリアしてまたデータメモリ301におけるソート対象データの先頭アドレスxと末尾アドレスyを設定しソート対象データの範囲を初期設定する(ステップS61)。次に、xの値とyの値を比較することによりソート対象のデータが存在するかを判断し(ステップS62)、x>yの時はデータが存在するとして次のステップに移り、それ以外は終了する。データがあるときは未ソートのデータの先頭アドレスを表すtにxを代入し(ステップS63)、データメモリ301のアドレスのtからt+2番地の3値のデータを選択しデータメモリ301から読み出し(ステップS64)、選択した3値のデータを専用レジスタ102のSPR0〜2に読み込む(ステップS65)。次に、データメモリ301のアドレスのt+3番地のデータの値をSPR3に読み込み(ステップS66)、SPR0〜3のデータの値の4値を比較交換手段103により比較交換し最大値を持つデータと最小値を持つデータと交換フラグレジスタXFの値を決定し(ステップS67)、最大値が格納されたSPR3のデータの値をアドレスのt番地に書き込み(ステップS68)、ソート対象データの範囲のすべてのデータを比較交換済みかどうかをt+3の値とyを比較することにより判断し(ステップS69)、t+3>yの時は比較交換済みでないとしてt+1を新たにtの値としてステップS66に戻り(ステップS70)、t+3=yとなった時は比較交換済みとして次のステップS71に進む。ソート対象データの範囲のすべてのデータを比較交換済みとなり、ソート対象データの範囲の内の値の小さい方から3個が確定し、3個のうち最小値はSPR2に格納されているため、ステップS71では、順位が未確定なSPR0とSPR1のデータの値を2値比較交換器CMPX0,CMPX1,CMPX2,CMPX3のいずれかを使用して比較交換し小さい方をSPR1に格納し大きい方をSPR0に格納しまた交換フラグレジスタXFの値を決定する。次に、SPR0,SPR1,SPR2のデータをデータメモリ301のアドレスのそれぞれt+1,t+2,t+3番地に保存し(ステップS72)、交換フラグレジスタXFの値が0かどうかでソート対象データの範囲のすべてのデータに対して一度も交換が発生しないかどうかを判断し(ステップS73)、交換フラグレジスタXFの値が0の時は処理の途中でソートが完了したとして終了し、交換フラグレジスタXFの値が1の時は順位が確定したデータを除くためy−3の値を新たにyとしてまた交換フラグレジスタXFの値を0クリアして((ステップS74)、次にステップS62に戻る。
なお、ここでソートを小さい値から行う場合(昇順)とし説明したが、大きいほうから行う場合(降順)は、上述した図5のソート処理装置で最大値を持つデータと最小値を持つデータが決定された後、それぞれ専用レジスタ102のSPR2とSPR3に格納されるとし、ソート処理装置の処理方法の説明で「最大値」を「最小値」と、「最大値」を「最小値」をそれぞれと読み替え、ステップS71で「小さい方」を「大きい方」と、「大きい方」を「小さい方」とそれぞれ読み替えればよい。
Next, the operation of the sort processing apparatus in the present embodiment will be described.
FIG. 6 is a flowchart showing the processing method of the sort processing apparatus according to the present embodiment for sorting in ascending order. First, the value of the exchange flag register XF is cleared to 0, and the start address x and the end address y of the sort target data in the data memory 301 are set to initialize the range of the sort target data (step S61). Next, it is determined whether or not the data to be sorted exists by comparing the value of x and the value of y (step S62). If x> y, the process proceeds to the next step assuming that the data exists, otherwise Ends. When there is data, x is substituted for t representing the start address of unsorted data (step S63), and ternary data from address t to address t + 2 is selected and read from the data memory 301 (step S63). In step S64, the selected ternary data is read into SPR0 to SPR2 of the dedicated register 102 (step S65). Next, the value of the data at address t + 3 of the address of the data memory 301 is read into SPR3 (step S66), and the four values of the data values of SPR0 to SPR3 are compared and exchanged by the comparison and exchange means 103, and the data having the maximum value and the minimum value are compared. The data having a value and the value of the exchange flag register XF are determined (step S67), the value of the SPR3 data in which the maximum value is stored is written to the address t (step S68), and all the data in the range to be sorted are included. Whether or not the data has been compared and exchanged is determined by comparing the value of t + 3 with y (step S69). If t + 3> y, the comparison exchange is not completed and t + 1 is newly set as the value of t and the process returns to step S66. (Step S70) When t + 3 = y, it is determined that the comparison has been exchanged and the process proceeds to the next Step S71. Since all the data in the range of the data to be sorted has been compared and exchanged, three of the values in the range of the data to be sorted are determined from the smaller value, and the minimum value of the three is stored in SPR2. In S71, the data values of SPR0 and SPR1 whose order is indeterminate are compared and exchanged using one of the binary comparison exchanges CMPX0, CMPX1, CMPX2, and CMPX3, the smaller one is stored in SPR1, and the larger one is stored in SPR0. Store and determine the value of the exchange flag register XF. Next, the data of SPR0, SPR1 and SPR2 are stored at the addresses t + 1, t + 2 and t + 3 of the address of the data memory 301 (step S72), and all of the range of data to be sorted depends on whether the value of the exchange flag register XF is 0 or not. It is determined whether or not the data has never been exchanged (step S73). When the value of the exchange flag register XF is 0, the process is terminated as the sorting is completed during the process, and the value of the exchange flag register XF is determined. When 1 is 1, in order to exclude data whose order has been determined, the value of y-3 is newly set to y, and the value of the exchange flag register XF is cleared to 0 (step S74), and then the process returns to step S62.
Here, the case where the sorting is performed from a small value (ascending order) has been described. However, when the sorting is performed from the larger value (descending order), the data having the maximum value and the data having the minimum value in the sort processing device of FIG. After the determination, it is assumed that they are stored in SPR2 and SPR3 of the dedicated register 102, respectively. In the explanation of the processing method of the sort processing device, “maximum value” is “minimum value” and “maximum value” is “minimum value”. In step S71, “smaller” should be read as “larger” and “larger” should be read as “smaller”.

(評価実験)
本実施例のプロセッサで、従来のバブルソート方法と本発明の拡張バブルソート方法を比較した。ソート対象のデータ数nは8,16,32の3種類で、ハードウェア記述言語(HDL)のシミュレーションにより、それぞれの方法による動作終了までのサイクル数を測定した。測定結果を図7に示す。拡張バブルソート方法により、従来のバブルソート方法の1/4程度の実行サイクル数でソートが完了した。
(Evaluation experiment)
In the processor of the present embodiment, the conventional bubble sort method and the extended bubble sort method of the present invention were compared. The number n of data to be sorted is 8, 16, and 32, and the number of cycles until the end of the operation by each method was measured by simulation of hardware description language (HDL). The measurement results are shown in FIG. By the extended bubble sort method, the sort is completed in about one-fourth the number of execution cycles of the conventional bubble sort method.

また、TSMC0.18ミクロンのデザインルールで遅延優先の条件でHDLより回路を合成した結果、回路規模として拡張バブルソート用に追加した比較交換器、専用レジスタ及び追加のパイプラインレジスタの面積比率は全体の13%程度となった。   Also, as a result of synthesizing the circuit from HDL under delay priority conditions with the TSMC 0.18 micron design rule, the area ratio of the comparison switch, dedicated register and additional pipeline register added for expanded bubble sort as the circuit scale is the whole Of 13%.

従って、従来のバブルソート方法に比べて顕著な処理速度の向上が得られかつハードウェア量の増加は13%程度に抑えることができることがわかった。   Therefore, it has been found that a significant improvement in processing speed can be obtained as compared with the conventional bubble sorting method, and an increase in the amount of hardware can be suppressed to about 13%.

101 データメモリ
102 専用レジスタ
103 比較交換手段
104 制御部
111 比較交換演算器
112 レジスタ
113 比較交換演算器
101 Data Memory 102 Dedicated Register 103 Comparison Exchange Means 104 Control Unit 111 Comparison Exchange Calculator 112 Register 113 Comparison Exchange Calculator

Claims (2)

入力された複数のデータを昇順または降順に並べ替えるソート処理方法であって、前記入力された複数のデータを初めのソート対象データとする第1のステップと、前記ソート対象データからm個(mは3以上の整数)のデータを初めの比較交換対象データとして比較交換し昇順のソートの場合は最大値のデータを降順のソートの場合は最小値のデータを決定データとして決める第2のステップと、前記比較交換対象データの内の決められた前記決定データを除くm−1個のデータと前記ソート対象データの内の比較交換対象データとなったことがないデータの1つを合わせて新たな比較対象データとして比較交換し新たな決定データを決める処理を前記比較交換対象データとなる最後のm個のデータまで繰り返す第3のステップと、前記第3のステップで残ったm−1個のデータの順位を決めて前記ソート対象データの内の前記残ったm−1個のデータを除くデータを新たなソート対象データとする第4のステップと、を備え、前記第2のステップと前記第3のステップと前記第4のステップを前記入力された複数のデータの全ての順位が確定するまで繰り返すことを特徴とするソート処理方法。
A sorting method for rearranging a plurality of input data in ascending or descending order, wherein the first plurality of input data is used as the first sort target data, and m (m Is a second step of comparing and exchanging data as the first comparison exchange target data, and determining the maximum value data in the ascending order and the minimum value data in the descending order as the decision data. , M-1 data excluding the determined decision data in the comparison exchange target data and one of the data that has never become comparison exchange target data in the sort target data are newly added. A third step of repeating the process of comparing and exchanging as comparison object data and determining new decision data up to the last m pieces of data to be compared and exchanged data; A fourth step of determining the rank of the remaining m−1 data in the step and setting the data other than the remaining m−1 data in the sorting target data as new sorting target data. A sort processing method comprising: repeating the second step, the third step, and the fourth step until all ranks of the plurality of input data are determined.
入力された複数のデータを昇順または降順に並べ替えるソート処理装置であって、前記入力された複数のデータを格納する記憶手段と、前記記憶手段のソート対象データの範囲の内のデータを比較交換対象データとして格納する第1のレジスタ群と、前記第1のレジスタ群に格納した各々のデータの比較交換演算を複数のステージでパイプライン処理し昇順のソートの場合は最大値のデータを降順のソートの場合は最小値のデータを決定データとして決める比較交換手段と、前記比較交換手段の各ステージでの比較交換演算の対象となるデータを各ステージに対応して格納する第2のレジスタ群と、前記記憶手段と前記第1のレジスタ群と前記比較交換手段と第2のレジスタ群を制御する制御部と、を備え、前記記憶手段からソート対象データの範囲の内のm個(mは3以上の整数)のデータを読み出し第1のレジスタ群に格納する第1の処理をした後、前記第1のレジスタ群から比較交換対象データを読み出して前記比較交換手段において前記比較交換対象データの内で昇順のソートの場合は最大値のデータを降順のソートの場合は最小値のデータを決定データとして決める処理と、前記比較交換手段で決められた前記決定データを前記記憶手段に書き戻す処理と、前記比較交換対象データの内の決められた前記決定データを除くm−1個のデータと前記記憶手段に格納されている前記ソート対象データの範囲の内の比較交換対象データとなったことがないデータの1つを読み出し合わせて第1のレジスタ群に新たな比較対象データとして格納する処理と、を前記比較交換対象データとなる最後のm個のデータまで繰り返す第2の処理を行い、残ったm−1個のデータの順位を決める第3の処理を行い、前記ソート対象データの内の前記残ったm−1個のデータを除くデータを新たなソート対象データの範囲とする第4の処理を行い、前記入力された複数のデータの全ての順位が確定するまで前記第1の処理と前記第2の処理と前記第3の処理と前記第4の処理を繰り返すことを特徴とするソート処理装置。


A sort processing device for rearranging a plurality of input data in ascending or descending order, wherein the storage means for storing the plurality of input data and the data within the range of data to be sorted in the storage means are compared and exchanged The first register group to be stored as target data and the comparison / exchange operation of each data stored in the first register group are pipeline-processed in a plurality of stages, and in the case of ascending order sorting, the maximum value data is in descending order. In the case of sorting, comparison exchange means for determining the minimum value data as decision data, and a second register group for storing data to be subjected to comparison exchange operation at each stage of the comparison exchange means corresponding to each stage; And a control unit for controlling the storage means, the first register group, the comparison / exchange means, and the second register group. After the first processing of reading out m pieces of data (m is an integer of 3 or more) within the range and storing the data in the first register group, the comparison / exchange target data is read out from the first register group, and In the comparison and exchange means, in the case of sort in ascending order among the data to be compared and exchanged, the process of determining the maximum value data as the decision data in the case of sort in descending order, and the above-mentioned data determined by the comparison and exchange means A process of writing the decision data back to the storage means, a range of m-1 data excluding the decided decision data in the comparison exchange target data, and a range of the sort target data stored in the storage means Processing for reading out one of the data that has never become comparison / exchange target data and storing it as new comparison target data in the first register group. A second process that repeats up to the last m pieces of data, and a third process for determining the rank of the remaining m-1 pieces of data, and the remaining m-1 of the sort target data. Performing a fourth process in which data other than the number of data is set as a range of new data to be sorted, and the first process and the second process until all ranks of the plurality of input data are determined. A sort processing apparatus that repeats the third process and the fourth process.


JP2009063714A 2009-03-17 2009-03-17 Sort processing apparatus and sort processing method Pending JP2010218178A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2009063714A JP2010218178A (en) 2009-03-17 2009-03-17 Sort processing apparatus and sort processing method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2009063714A JP2010218178A (en) 2009-03-17 2009-03-17 Sort processing apparatus and sort processing method

Publications (1)

Publication Number Publication Date
JP2010218178A true JP2010218178A (en) 2010-09-30

Family

ID=42976968

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2009063714A Pending JP2010218178A (en) 2009-03-17 2009-03-17 Sort processing apparatus and sort processing method

Country Status (1)

Country Link
JP (1) JP2010218178A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112067880A (en) * 2020-08-20 2020-12-11 广西柳州特种变压器有限责任公司 Grouping matching method of iron cakes for self-saturable reactor iron cores of silicon rectifying devices

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112067880A (en) * 2020-08-20 2020-12-11 广西柳州特种变压器有限责任公司 Grouping matching method of iron cakes for self-saturable reactor iron cores of silicon rectifying devices
CN112067880B (en) * 2020-08-20 2023-04-07 广西柳州特种变压器有限责任公司 Grouping matching method of iron cakes for self-saturable reactor iron cores of silicon rectifying devices

Similar Documents

Publication Publication Date Title
JP5500652B2 (en) Parallel comparison / selection operation device, processor, and parallel comparison / selection operation method
TWI486810B (en) Counter operation in a state machine lattice
CN108959179B (en) Sequence alignment method of vector processor
CN117724763A (en) Apparatus, method and system for matrix operation accelerator instruction
KR101524450B1 (en) Method and apparatus for universal logical operations
JP5178346B2 (en) Semiconductor device and data processing method using semiconductor device
US10884736B1 (en) Method and apparatus for a low energy programmable vector processing unit for neural networks backend processing
US20200090051A1 (en) Optimization problem operation method and apparatus
US20230051237A1 (en) Determining material properties based on machine learning models
KR20210156860A (en) TRUE/FALSE vector index register
US9570125B1 (en) Apparatuses and methods for shifting data during a masked write to a buffer
JP4310500B2 (en) Important component priority calculation method and equipment
US11200056B2 (en) Parallel union control device, parallel union control method, and storage medium
CN111459548B (en) Dual load instruction
JP2010218178A (en) Sort processing apparatus and sort processing method
US11886780B2 (en) Optimization device, optimization device control method, and computer-readable recording medium recording optimization device control program
JPS5814257A (en) Data processor for logical simulation
TWI801601B (en) Database processing system and method for offloading database operations
JP6473023B2 (en) Performance evaluation module and semiconductor integrated circuit incorporating the same
CN112149050A (en) Apparatus, method and system for enhanced matrix multiplier architecture
JP5206385B2 (en) Boundary execution control system, boundary execution control method, and boundary execution control program
EP4148628A1 (en) Data processing apparatus, data processing method, and data processing program
CN116168765B (en) Gene sequence generation method and system based on improved stroboemer
JP7207423B2 (en) WORKING SET SELECTOR, WORKING SET SELECTION METHOD AND WORKING SET SELECTION PROGRAM
JP5382503B2 (en) Branching program machine and parallel processor