WO2003091872A1 - Dispositif de tri par fusion en parallele, procede et programme y relatifs - Google Patents

Dispositif de tri par fusion en parallele, procede et programme y relatifs Download PDF

Info

Publication number
WO2003091872A1
WO2003091872A1 PCT/JP2003/005319 JP0305319W WO03091872A1 WO 2003091872 A1 WO2003091872 A1 WO 2003091872A1 JP 0305319 W JP0305319 W JP 0305319W WO 03091872 A1 WO03091872 A1 WO 03091872A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
data string
sorted
merge
value
Prior art date
Application number
PCT/JP2003/005319
Other languages
English (en)
French (fr)
Inventor
Noboru Yamamoto
Original Assignee
Nihon University School Juridical Person
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 Nihon University School Juridical Person filed Critical Nihon University School Juridical Person
Priority to US10/511,683 priority Critical patent/US7536432B2/en
Priority to AU2003231521A priority patent/AU2003231521A1/en
Priority to JP2004501962A priority patent/JP4171835B2/ja
Publication of WO2003091872A1 publication Critical patent/WO2003091872A1/ja

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F7/00Methods or arrangements for processing data by operating upon the order or content of the data handled
    • G06F7/22Arrangements for sorting or merging computer data on continuous record carriers, e.g. tape, drum, disc
    • G06F7/36Combined merging and sorting

Definitions

  • the core technology of the present invention is that two sorted data string pairs ( ⁇ ⁇ ) are keyed so that merge sort processing using two sorted data strings as input can be performed with an arbitrary number of parallelisms. This is a technology that subdivides into multiple ordered partial data string pairs in consideration of the size.
  • the parallel binary tree merge sort method is taken up as an example using it.
  • the unsorted data string is divided into a number corresponding to the number of available processors, and a sort operation is performed in parallel to generate as many sorted partial data strings as there are parallel numbers.
  • the merge operation is performed by pairing two sets of sorted partial data strings.
  • the input data string pairs are subdivided into as many data string pairs as necessary, and Perform a merge operation on The output area is specified by the runtime parameter of each merge operation so that this output has the same result as one merge operation without subdivision.
  • the present invention relates to a parallel merge sort processing apparatus, method, and program characterized by repeating this operation until a single aligned data string is obtained. -: 'Background art
  • Arrangement (sort) processing and merge (merging) processing is a series of data strings arranged in ascending order (from small to large) or descending order (from large to small) with respect to the field information of the input data string. Is the operation to get.
  • the merge operation receives two or more sequences of data (generic name of data or records to be sorted) arranged in ascending order (or descending order) and outputs a series of data sequences sorted in ascending or descending order.
  • the number of input sequences can be various, such as 2, 3, 4 ..., but in the case of 2 in particular, it is efficient because the alignment position of one unit of data is determined by one comparison.
  • FIG. 13 is a schematic flowchart
  • FIG. 14 is an explanatory diagram of processing when the number of processors is eight.
  • the p sets of unsorted data strings that have been divided can be sorted independently and in parallel by, for example, the quick sort method (S 1 0 1).
  • S 1 0 2 the quick sort method
  • S 1 0 3 By performing q-stage merge processing on the p partial data sequences that have been arranged (S 1 0 2), it is possible to finally obtain one set of data sequences that have been arranged as a whole (S 1 0 3).
  • the circle indicates the processor
  • the square indicates the area where the data string or data string (D) is stored.
  • the symbol in the circle indicates the content of the processing performed by the processor, S is the sort processing, M is the merge processing, and V is the transfer processing to other storage areas that are performed as necessary. To do.
  • the unaligned data string placed in the input area is divided into eight partial data strings.
  • the eight processors P 1 to P 8 simultaneously perform the processing of these parts simultaneously. These processing results are placed in the areas D 1 1 to D 1 8.
  • Data stream D 1 1 and D 1 2 are merged by processor P 1 and placed in area D 2 1
  • data stream D 1 3 and D 1 4 are merged by processor P 3 and placed in area D 2 2
  • Data stream D 15 and D 16 are merged by processor P5 and placed in area D23
  • data string D17 and D18 are merged by processor P7 and placed in area D24. It is burned.
  • the processors P 2, P 4, P 6, and P 8 are not used in the first stage (the assignment of processors is for convenience. The same applies hereinafter).
  • the second merge sort is performed.
  • Data stream D 2 1 and D 2 2 are merged by processor P 1 and placed in area D 3 1, and data stream D 2 3 and D 2 4 are merged by processor P 5 and placed in area D 3 2 .
  • the processors P 2, P 3, P 4, P 6, P 7 and P 8 are not used.
  • Data stream D 3 1 and D 3 2 are merged by processor P 1 and placed in area D 4. This completes the merge sort.
  • the processors P 2, P 3, P 4, P 5, P 6, P 7 and P 8 are not used.
  • the result D4 is transferred to the final output area by eight processors if necessary.
  • the processor capacity is wasted because the number of processors that are not used increases as the merge processing stage progresses.
  • the processor usage rate in the second-stage merge process is 25%
  • the processor usage rate in the third-stage merge process is 1 2.5%
  • the number of unused processors increases as the processing stage advances. This is because the number of sorted partial data strings is halved as the merge processing stage proceeds.
  • the number of data to be merged by one processor doubles as it becomes later, which increases processing time.
  • the problem is an increase in processing time due to an increase in the amount of data handled by a single processor, beyond the problem of reduced processor usage.
  • the present invention has been made in order to solve the above-described problems, and provides a parallel merge soot processing apparatus and method capable of improving the use efficiency of a processor and shortening the processing time in the merge soot processing using a parallel processor, and The purpose is to provide a program. Disclosure of the invention
  • unsorted input data strings are divided into multiple sets, and the sorted partial data strings are created by performing saw row processing for each set.
  • the merge process is performed by pairing two existing sorted partial data strings, and the number of output data strings is changed to output one set of sorted partial data strings. It repeats until it is united.
  • merge processing is performed in parallel as long as there are multiple input data string pairs.
  • multiple pairs of two sets of sorted partial data strings (partial sorted data strings obtained by the sort process and merge process shown in FIG. 14) that are input to the merge process are arranged.
  • By subdividing the data into pairs of already processed partial data strings it is possible to use as many processors as the number of subdivisions, thereby reducing the time required for the alignment process.
  • the method described below can be applied to increase the degree of parallelism.
  • start from the side with the larger key value (start) and output the results in descending order from the start of the output area.
  • Forward merge or forward merge and the merge operation starting from the end of the key value (end) and starting from the end of the output area in ascending order (reverse merge or reverse merge) It executes in parallel.
  • the parallel merger processing apparatus includes a mechanism that divides a pair of two series of input data strings into a plurality of sets of two series of input data string pairs in a conventional merge operation, and a set of those groups.
  • the basic element is a mechanism that performs merge operations in parallel.
  • each merge operation must be the same as if one merge operation was performed. For this reason, in each merge operation that operates in parallel, it is necessary to output the results to an area corresponding to the size of the key value of the input data string pair as a whole.
  • the processor group to which the partial data string pair is assigned performs merge processing and outputs the result of the merge processing to a previously designated area. For this purpose, for example, input of merge processing
  • the management processor only needs to specify the pair of the first memory address of the area where the data string pair is stored, the number of data to be processed, and the head address of the output area.
  • Two processors are assigned to each of the partial data string pairs, and the first processor performs a merging process in order from the one end of the partial data string (the side with the largest key value).
  • the processor simultaneously performs merge processing in reverse order from the other end of the same partial data string (side with the smallest key value), and the first processor writes the result of merge processing in order from one end of the partial data string.
  • the second processor writes the result of the merge processing in order from the other end of the area portion.
  • Paragraph 001 Subdivide one data column pair into multiple data column pairs as described in 4. Subdivision starts from the start point of the specified data column pair. The operation that divides the data into the data sequence in which there exists and the remaining data sequence can be broken down into operations that are repeated by changing X.
  • the basic of subdivision is the binary operation of the data sequence, but the conditions to be satisfied by the two sorted partial data sequence pairs obtained as a result are formulated as follows.
  • An ordered data string D consisting of n data is represented by (D, n), and a pair of two data strings is represented by ⁇ (DL n), (D 2 , n) ⁇ .
  • Pair of sorted data strings ⁇ (D !, n), (D 2 , n) ⁇ force Two partial data strings ⁇ (D 11 ( nn), (D 21 , ⁇ 21 ) ⁇ and partial data strings Is divided into ⁇ (D 12 , n 12 ), (D 22 , n 22 ) ⁇ , and they are used for merge processing to produce consistent output of key values as a whole. must be established. substrings and smaller keys value of the last data D 21
  • the parallel merge sort processing method is a method for performing parallel merge sort processing using a parallel processor including a plurality of processors. Because
  • steps 4 to 7 ends when the merged sorted partial data string becomes one data string.
  • steps 4 to 7 are performed only once and do not need to be repeated.
  • two processors are assigned to the pair of partial data strings, and in the seventh step, the first processor starts from one end of the partial data string (the side with the larger key value).
  • the forward merging process is performed, and the second processor simultaneously performs the reverse merging process from the other end of the same partial data string (the lower value side of the key value).
  • this process determines the head of the second half of the data sequence pair ⁇ (D 1 2 , n 1 2 ), (D 2 2 , n 2 2 ) ⁇ , in other words, the start point of the normal order merge. Used for.
  • the data sequence D 1 and D sets the X- 1 to the index variables i and j that specifies the individual data of 2 as the initial value of the index value of the boundary (1 0 0 0 0 each data string pairs
  • X as the number is 1 0 0 0, and the initial position index is 9 9 9, 1 9 9 9,-. 8 9 9 Set 9)
  • This process is used to determine the tail of the half- divided data string pair ⁇ (D n, nil ), (D 2 1 , n 2 1 ) ⁇ , in other words, to determine the start point of reverse merging.
  • This invention is a merge sort with an arbitrary degree of parallelism by subdividing two pairs of sorted data strings, which are input to the merger, into a plurality of data string pairs in consideration of the magnitude distribution of key values.
  • a parallel merge saw processing method that enables processing,
  • the present invention is a program for performing parallel merge sort processing using a parallel processor including a plurality of processors,
  • the data string is divided to obtain a plurality of unaligned partial data strings
  • the first to third steps are necessary only when the input data string is not aligned.
  • the repetition of the fourth step to the seventh step ends when the merged sorted partial data string becomes one data string.
  • steps 4 to 7 are performed only once and do not need to be repeated.
  • the program according to the present invention is recorded on a recording medium, for example.
  • Media include, for example, EPROM devices, flash memory devices, flexible disks, hard disks, magnetic tapes, magneto-optical disks, CDs (including CD-ROM, Video—CD) DVDs (DVD—Video, DVD- ROM, DVD—includes RAM), ROM memory, RAM memory cartridge with battery backup, flash memory cartridge, non-volatile RAM cartridge, etc.
  • a medium is a medium in which information (mainly digital data, a program) is recorded by some physical means, and allows a processing device such as a computer or a dedicated processor to perform a predetermined function. is there.
  • a processing device such as a computer or a dedicated processor to perform a predetermined function.
  • any program that downloads a program to a computer and executes a predetermined function by any means may be used.
  • FIG. 1 is a diagram showing an overview of a parallel merge sort processing apparatus according to an embodiment of the invention.
  • FIG. 2 is a process flow chart according to the first embodiment of the invention.
  • FIG. 3 is an explanatory diagram of the entire processing according to the embodiment of the invention.
  • FIG. 4 is an explanatory diagram of processing according to the embodiment of the invention.
  • FIG. 5 is an explanatory diagram of processing according to the embodiment of the invention.
  • FIG. 6 is an explanatory diagram of processing according to the embodiment of the invention.
  • FIG. 7 is an explanatory diagram of a part of the processing according to the embodiment of the invention.
  • FIG. 8 is a flowchart of region division according to the embodiment of the invention (normal order merge).
  • FIG. 9 is a flowchart of region division according to the embodiment of the invention (reverse order merge).
  • FIG. 10 is an explanatory diagram of area division according to the embodiment of the invention.
  • FIG. 11 is a diagram showing an example of area division according to the embodiment of the present invention.
  • FIG. 12 is a process flowchart according to the second embodiment of the present invention.
  • Fig. 13 is a flowchart of the conventional parallel merge sort process.
  • Fig. 14 is an explanatory diagram of the conventional parallel merge sort process. BEST MODE FOR CARRYING OUT THE INVENTION
  • Fig. 1 shows the schematic configuration of this device.
  • 1 is a parallel processor for merge processing that includes multiple processors and can execute multiple tasks concurrently.
  • Reference numeral 2 denotes a parallel processor for area division, which divides two pairs of sorted data strings into a predetermined number of partial data string pairs and returns them to the management processor 4.
  • 3 is a parallel processor for sort processing that sorts unsorted data strings existing in the specified area.
  • the management processor 4 is responsible for overall control, and receives information 6 such as the location and number of input / output data received from the outside when starting a job, as well as editing the information required for the tasks to be performed by the group of parallel processors. It is in charge of processing such as starting tasks and accepting task completion reports.
  • 5 is a data storage area containing the data to be sorted.
  • the same parallel processor can be used for 1 and 3 depending on the implementation, and the same applies to the parallel processor for splitting data pairs in 2.
  • the parallelism is improved by dividing two sorted data string pairs, which are handled only for one merge process in the prior art, into a plurality of partial data string pairs.
  • the merge input By dividing the pair of data strings D 2 1 and D 2 2 into two, two pairs of input data strings are obtained, and processors P 1 to P 4 are obtained by performing forward-order merging and reverse-order merging, respectively. Can be processed at the same time, by dividing the pair of data strings D 3 1 and D 3 2 into 4 parts to obtain 4 pairs of input data strings, and by performing forward merge and reverse merge for each. Processors P1 to P8 can be processed simultaneously. Details will be described later.
  • S 1 to S 3 are procedures for dividing the input data string into a plurality of data strings and causing p processors to perform the simultaneous processing in parallel. After that, q-stage merge sort is repeated as shown below, and finally one set of data strings is obtained.
  • a variable a representing the merge stage used for convenience of description is initialized to zero.
  • S 6 obtain a forward order merging and simultaneously performs 2 11 one a pair of aligned reverse merged partial data string by using two processors respectively, for each set.
  • a circle indicates a processor
  • a square indicates an area where a data string or data string (D) is stored.
  • the symbol in the circle indicates the contents of the processing performed by the processor, S means sort processing, M means merge processing, and V means transfer processing.
  • Data placed in the input area is divided into 8 unaligned data strings.
  • the eight processors P 1 to P 8 perform sort processing on these partial data strings in parallel. These processing results are placed in areas D 11 to D 18.
  • Processors P 1 and P 2 merge data strings D 1 1 and D 12 and place them in D 21.
  • Processors P 3 and P 4 merge data strings D 13 and D 14 and place them in D 22.
  • P6 merges data strings D15 and D16 and places them in D23.
  • Processors P7 and P8 merge data strings D17 and D18 and puts them in D24. Since the forward merging and reverse merging are performed simultaneously in the first stage, eight processors are used without division (the assignment of processors is for convenience; the same applies hereinafter).
  • the data strings D21-1 and D22-1 are merged by the processors P1 and P2 and placed on one side of D31 (the side with the larger key value), and the data strings D21-2 are obtained by the processors P3 and P4.
  • D 22 — 2 is merged and placed on the other side of D 31 (the side with the lower key value).
  • the data strings D23 and D24 are merged by the processors P5 to P8 and placed in D32.
  • the division is performed as in the second stage.
  • the data columns D 31 and D 32 are paired and divided into four considering the key value, 031-1 and 032-1, D 31-2 and D32_2, D32-3 and D32-3, Create each partial data string pair of D31-4 and D32-4.
  • Data strings D 31— 1 and D 32— 1 are merged by processors P 1 and P 2 and placed in a predetermined position in D 4, and data strings D 31 — 2 and D 32 — 2 are merged by processors P 3 and P 4.
  • the data strings D31-3 and D32-3 are merged by the processor P 5 P6 and placed in a predetermined position in the region D 4, and then by the processor P 7 P 8 Data strings D 31-4 and D 32-4 are merged and placed in a predetermined position in region D4. This completes the merge saw.
  • the result D4 is transferred to the output area by eight processors if necessary. All eight processors are used at each stage of the process in FIG.
  • FIG. 3 The process of FIG. 3 will be schematically described with reference to FIGS.
  • Figure 7 is an explanatory diagram. Assume that a pair of input data strings in the input domain (D ⁇ n) and (D 2 n) is given. Here, (D!, N) and (D 2 n) mean a data string consisting of n data and D 2 . In each area of Fig. 7, the values are sorted so that the key value increases toward the left and decreases toward the right.
  • 2 x is the number of data that the data string pair ⁇ (Du, nn), (D 2 n n 21 ) ⁇ has.
  • the processor P 1 performs normal order merging and the processor P 2 performs reverse order merging.
  • the processor P 3 performs forward-order merging and the processor P 4 performs reverse-order merging on the sorted data string (D 12 , n 12 ) and (D 22 , n 22 ) pairs.
  • the result is sequentially output to (D 32 , n 32 ), which is a part of the output region (D 3 , 2 ⁇ ).
  • n 31 + n 32 2 n.
  • a method of splitting sorted data string pairs that satisfies the above conditions will be described.
  • division method for forward-order merging division method for reverse-order merging, or both methods, division into data string pairs that satisfy the above conditions can be realized.
  • both data strings are equally divided into k data string pairs containing (n / k) data sets.
  • Each data string is specified by a data string number from 0 to k-1.
  • the position of each data is specified by an index value that increases by 1 for each data, with 0 at the beginning of the data string.
  • the position specification method 1 ⁇ , D 2 addition to the total data position specification is used to locate in each data sequence divided. Also, the head or tail of the data string specifies the data position of the end or the end of the data string.
  • the beginning of the remaining data string, that is, the index value is (n / k) (i).
  • a starting end or et respective D 2 (n / k) ( i + 1) sets of the end of the data string data is present, in other words, the index value is (n / k) (i + l) points -l and To do.
  • the starting point (division point) that satisfies the above condition is obtained by the following procedure.
  • Two data columns of n data respectively aligned there is a Di and D 2.
  • the number of data from the beginning of the data string is 2 (n / k) +2, 4 (n / k) +2 considering the condition of paragraph 0048 and considering the key value from the beginning of both data strings , 6 (n / k) +2,...
  • the index value of the boundary initial value determined in S1 0 is set to the work index variables i and j in the areas S 1 1 and D 2 .
  • 51 3 b Compares the large key values among the comparison target data immediately before and after the change of the magnitude relationship, and sets the smaller one as the boundary data. For the boundary data of the other area, select the first comparison partner of the data just obtained.
  • S 2 1 and to the working index variables i and j D 2 range sets the index value of the boundary initial value determined in S 20.
  • S 22 Repeat the following procedure until the magnitude relationship is reversed. However, if the key values are equal, including the first comparison, it is considered to be reversed.
  • S 23 b Compares the small key values among the comparison target data immediately before and after the change of the magnitude relationship, and sets the larger one as the boundary data. Also, for the data at the boundary of the other area, the initial comparison partner of the data obtained above is selected.
  • Figure 10 shows the following two data sequences, each containing 10 numbers, arranged in descending order.
  • Fig. 10 (a) is an explanatory diagram of the procedure for determining the start point of forward-order merging
  • Fig. 10 (b) is an illustration of the procedure for determining the start point of reverse-order merging
  • Fig. 10 (c) shows the result of region segmentation.
  • FIG. 11 (a) and (b) Another example is shown in Fig. 11 (a) and (b).
  • the number of partitions to be divided can be arbitrarily determined according to the number of usable processing apparatuses.
  • the ratio of the time required to divide the sorted partial data string pair, which is the input of the merger bowl, into a plurality of data string pairs is reduced, so that the larger the number of data, the greater the effect. large.
  • the processor to which the merge sort work is assigned executes the part that determines the actual merging start point, a more complete parallel processing becomes possible. It is possible to reduce the ratio of the time taken for region pairing to time.
  • the partition number of the target data string pair is close to k / 2, and in this case, the head or tail of D i or D 2 , in other words, near the end of the data string. If the magnitude relationship is finally reversed, It takes time to reverse the relationship. Distribution of keys occurs when there is a bias in the preparative D 2, but think it is rare that such cases are frequent.
  • the number of data of the data string and D 2 were assumed the same number.
  • the present invention is not limited to this. If the number of data is different from the DJ and D 2 data, it can be applied to the merge task as long as the number of data is specified in the merge task.
  • the present invention is a general-purpose technology, and is particularly suitable for a general-purpose parallel processor computer that shares main memory. However, it can be applied regardless of the system configuration and processing mode in an environment where the data group to be arranged can be accessed in common.
  • the present invention is considered to be realized as one of programs incorporated in software (OS) of a parallel processor type computer.
  • OS software
  • the device Z method of the first embodiment of the invention uses both forward-order merging and reverse-order merging simultaneously as shown in FIG.
  • the present invention can also be applied to cases where only one of the forward order merge and the reverse order merge is used.
  • Figure 12 is a flowchart when applied to the parallel binary tree merge sort method. In this case, since the first merge is divided into two, p processors always operate. A parallel processor that performs merge processing can be realized simply because it has only to be equipped with either a forward or reverse merge function.
  • Fig. 12 Since the processing contents of the second embodiment are the same as those of the first embodiment, the description thereof is omitted.
  • the parts of Fig. 12 that differ from Fig. 2 are S 4 b, S 5 b, and S 6 b.
  • means does not necessarily mean physical means, but includes cases where the functions of each means are realized by software.
  • the function of one means may be realized by two or more physical means, or the functions of two or more means may be realized by one physical means.

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Multi Processors (AREA)
  • Devices For Executing Special Programs (AREA)

Description

明 細 書 並列マ一ジソ一卜処理装置及び方法並びにプログラム 技術分野
この発明の核心となる技術は、 2つの整列済デ一タ列を入力とするマージソート処理を任意数 の並列度でできるように、 2つの整列済データ列対 (つい) をキ一値の大小を考慮して複数の整 列済部分データ列対に細分割する技術である。
それを用いた実施例として並列 2分木マ一ジソート法を取り上げる。 まず未整列データ列を利 用可能なプロセッサの数に対応する数に分割し並列にソ一ト操作を行い、 並列数だけの整列済部 分データ列を生成する。 次に、 2組の整列済部分データ列を対にしてマージ操作を行うのだが、 処理速度を高めるために、 入力データ列対を必要な数だけのデータ列対に細分割し、 それぞれ並 列にマージ操作を行う。 この出力は細分割せずに 1つのマージ操作をした時と同じ結果になるよ うに各マージ操作の実行時パラメータで出力域を指定する。 本発明は、 この操作を整列された単 一のデータ列を得る迄繰り返し行うことを特徴とする並列マージソート処理装置及ぴ方法並びに プログラムに関するものである。 -:' 背景技術
コンピュータを用いた基本的な処理の 1つにデータの整列がある。 整列 (ソート) 処理及び併 合 (マージ) 処理は、 入力されたデータ列を着目するフィールドの情報に関して昇順 (小から大 へ) 又は降順 (大から小へ) に整列して 1系列のデータ列を得る操作である。 併合操作は昇順(ま たは降順)に整列された 2系列以上のデータ(整列対象のデータまたはレコードの総称)列を受けて、 昇順または降順に整列された 1系列のデータ列を出力する。
入力系列の数は、 2、 3、 4 · · · と種々の場合が考えられるが、 特に 2の場合は 1回の比較で 1単位のデータの整列位置が確定するため効率が良い。
併合 (マージ) 処理に係る所要時間のオーダはデータ数 (ti)に比例するため、 n2または nlog2n に比例するソート操作に比べ有利である。 しかしデータ数の増大と共に所要時間も增すので、 よ り高速なアルゴリズム(算法)が求められている。 また性能の高いアルゴリズムの開発により、 マ ージソートの適用範囲がさらに広まる可能性もある。 だが 2つのキ一値の比較という単純な操作 であるため、 時間短縮の要因が潜在する可能性は低い。 本発明は従来技術ではなし得なかった 2 つの整列済部分データ列対を入力とするマージ処理の並列化を可能とするものである。
並列プロセッサを用いることにより多数のデータに対して同時並行的にマージ処理を行い、 処 理時間を短縮することが提案されている。 しかしプロセッサ間の接続ネッ卜ワークに特殊なトポ ロジ一を要するものや特殊な機能'構造のプロセッサを要するものが多く、 主記憶を共有する密 結合マルチプロセッサのような汎用的な計算機システムでは実現が困難である。 本発明は構成や 接続に特殊性を持たなレ、汎用的な並列プ口セッサで高レ、並列性をもつマ一ジソート法を実現する ものだが、 そのような方法を用いないと非常に効率が低い処理方式の例を以下に示す。
汎用的な並列プロセッサシステムに適用可能な並列マ—ジソート方法の一例として並列 2分木 マージソート算法をあげる。 図 1 3はその概略フローチャートであり、 図 1 4はプロセッサ数が 8の場合の処理説明図である。
図 1 3を参照すると、 処理対象の未整列データ列 (入力データ) をプロセッサの数に対応する p組のデータ列 (ただし、 = 2 <>、 qは整数) に分割する (S 1 0 0 ) 。 p個のプロセッサを用 レ、、 分割された p組の未整列データ列を例えばクイックソート法によりそれぞれ独立かつ並行し て整列する (S 1 0 1 ) ことができる。 整列された p組の部分データ列に対して q段のマージ処 理を施す (S 1 0 2 ) ことにより、 最終的に全体として整列された 1組のデータ列を得ることが できる (S 1 0 3 ) 。
図 1 4を参照してプロセッサの数が 8の場合の処理について説明する。 図中、 丸はプロセッサ を示し、 四角はデータ列あるいはデータ列 (D) が記憶される領域を示す。 丸の中の記号はプロ セッサが行う処理の内容を示し、 Sは整列 (ソート) 処理、 Mは併合 (マージ) 処理、 Vは必要 に応じてなされる他の記憶領域への転送処理を意味する。
入力領域に置かれた未整列のデータ列は 8つの部分データ列に分割される。 8つのプロセッサ P 1〜P 8によりこれら部分について同時並行的にソ一卜処理を行う。 これらの処理結果は領域 D 1 1〜D 1 8に置かれる。
次に、 第 1段のマージ処理を行う。 プロセッサ P 1によりデータ列 D 1 1と D 1 2が併合され て領域 D 2 1に置かれ、 プロセッサ P 3によりデータ列 D 1 3と D 1 4が併合されて領域 D 2 2 に置かれ、 プロセッサ P 5によりデータ列 D 1 5と D 1 6が併合されて領域 D 2 3に置かれ、 プ 口セッサ P 7によりデータ列 D 1 7と D 1 8が併合されて領域 D 2 4に置かれる。 なお、 第 1段 においてプロセッサ P 2 , P 4 , P 6 , P 8は使用されない (プロセッサの割り当ては便宜上の ものである。 以下同じ) 。 次に、 第 2段のマージソートを行う。 プロセッサ P 1によりデータ列 D 2 1と D 2 2が併合さ れて領域 D 3 1に置かれ、 プロセッサ P 5によりデータ列 D 2 3と D 2 4が併合されて領域 D 3 2に置かれる。 なお、 第 2段においてプロセッサ P 2 , P 3 , P 4 , P 6 , P 7 , P 8は使用さ れない。
次に、 第 3段のマージソートを行う。 プロセッサ P 1によりデータ列 D 3 1と D 3 2が併合さ れて領域 D 4に置かれる。 これでマージソートが完了する。 なお、 第 3段においてプロセッサ P 2 , P 3 , P 4 , P 5 , P 6 , P 7 , P 8は使用されなレ、。 得られた結果 D 4は必要なら 8つの プロセッサにより最終出力領域に転送される。
上述した従来の手法では、 マージ処理段が進行につれ使われなくなるプロセッサが増加するた めプロセッサの処理能力が無駄になっていた。 上記の例では第 1段のマージ処理ではプロセッサ の 5 0 %しか使用されず、 第 2段のマージ処理のプロセッサ使用率は 2 5 %、 第 3段のマ一ジ処 理ではプロセッサ使用率は 1 2 . 5 %となり、 処理段が進むにつれて使用されないプロセッサの 数が増える。 これはマージ処理段がすすむにつれて整列済部分データ列の数が半減していくため である。
また、 1台のプロセッサでマージするデータ数は後段になるに従って倍增するため、 処理時間 が増大する。 高速処理を優先するシステムでは、 プロセッサの使用率低下の問題以上に、 1台の プロセッサが扱うデータ量の增大による処理時間の増大が問題となる。
この発明は、 係る課題を解決するためになされたもので、 並列プロセッサを用いたマ一ジソ一 卜処理においてプロセッサの使用効率を高め、 処理時間を短縮可能な並列マージソ一卜処理装置 及び方法並びにプログラムを提供することを目的とする。 発明の開示
(段落 0 0 1 4 ) 本発明ではマージ処理の入力となる 2つの整列済部分データ列の対を任意数 のデータ列対に細分割して並列にマージ処理をすることにより、 マージ処理の所要時間を短縮す るものである。 複数のプロセッサから共通にデータ群が参照されることから、 主記憶を共有する 複数のプロセッサを接続した並列プロセッサにおいて特に有効であるが、 データ群が各プロセッ サから参照できる環境にある如何なる並列プロセッサにも適用可能である。
並列 2分木マージソート処理では、 未整列の入力データ列を複数組に分割し、 それぞれについ てソー卜処理を行って整列済部分データ列を作る。 以後は存在する整列済部分データ列を 2組ず つ対にしてマージ処理を行い 1組の整列済部分データ列を出力する処理段を、 出力データ列の数 が 1つにまとまる迄繰り返すものである。 各マージ処理段では入力となるデ一タ列対が複数ある 限りマージ処理は並列に行われる。
1単位のジヨブあるいはタスクであるマージ処理の並列化は従来技術では不可能なため、 マー ジ処理段の進行と共に並列度は半減し処理時間は倍増する。
本発明によれば、 マージ処理の入力となる 2組の整列済部分データ列 (図 1 4に示したソート 処理やマージ処理によって得られた部分的な整列済データ列) の対を複数の整列済部分データ列 の対に細分割することにより細分割した数だけのプロセッサを使用することができ、 整列処理に 要する時間を短縮できる。
また、 並列度を高めるため以下に記載する方法を適用することもできる。 すなわち、 入力とな る 2組の整列済データ列の対に対し、 2つのプロセッサを用いて、 キー値の大きい側(始端)から マージ操作を始めて結果を出力域の始端から降順に出力する方法 (正順併合または正順マージ) と、 キー値の小さい側(終端)からマージ操作を始めて出力域の終端から昇順に出力する方法 (逆 順併合または逆順マ一ジ) の両方のマージ操作を同時平行的に実行するのである。
この方式自体に起因する制約はないため、 複数のタスクが並行に動作できる環境下では容易に 実現できる。
以下の説明においては、 説明の便宜上『一つのキ一による降順の整列』 に限定する。 整列に関 連する用語には原則として 『整列』 と 『併合』 を用いるが、 同義語的に 『ソート』 や『マージ』 を用いることがある。
本発明に係る並列マ一ジソ一卜処理装置は、 従来方式のマージ操作における 2系列の入力デー タ列の対を複数組の 2系列の入力データ列対に分割する機構と、 それらの組に対して並列にマ一 ジ操作を行う機構を基本要素とする。
両機構に対しどのようにプロセッサ群を割り付けるかは任意である。 すなわち、 データ列対の 細分割を複数のプロセッサにさせた後、 マージ処理では改めてプロセッサを割り当て直すことも できるし、 データ列の細分割操作とその後のマージ操作を同一プロセッサに担当させることもで きる。
それぞれのマージ操作の出力はあたかも 1つのマージ操作を行った場合と同じ結果でなければ ならない。 このため、 並行に動作する各マージ操作では、 細分割した入力データ列対全体のキー 値の大小に対応した領域に結果を出力する必要がある。
部分データ列の対を割り当てられた前記プロセッサ群は、 それぞれマージ処理を行うと共に当 該マージ処理の結果を予め指示された領域に出力する。 このためには、 例えばマージ処理の入力 データ列対が格納されてレ、る領域の先頭メモリアドレスの対と処理すべきデータ数と出力域の先 頭ァドレスが管理プロセッサから指定されればよい。
前記部分データ列の対それぞれに対して 2つのプロセッサが割り当てられ、 第 1のプロセッサ は前記部分データ列の一方の端 (キ一値の大きい側) 力 ら正順にマージ処理を行い、 第 2のプロ セッサは同じ部分データ列の他方の端 (キ一値の小さい側) から逆順にマージ処理を同時に行い、 前記第 1のプロセッサは前記部分データ列の一方の端から順にマージ処理の結果を書き込み、 前 記第 2のプロセッサは前記領域の部分の他方の端から順にマージ処理の結果を書き込む。
(段落 0020) 段落 001 4に記述したように 1つのデータ列対を複数のデータ列対に細分 割するが、 細分割は指定されたデ一タ列対の始点から始めて指定数 Xのデータ数が存在するデ一 タ列と残りのデータ列とに 2分する操作を Xを変化させて反復する操作に分解できる。
従って細分割の基本はデータ列の 2分操作であるが、 その結果得られる 2つの整列済部分デー タ列対が満たすべき条件は以下のように定式化される。
n個のデータからなる整列 データ列 Dを (D, n) で表わし、 2つのデータ列を対にしたも のを { (D L n) , (D2, n) } と表記する。
整列済のデータ列の対: { (D!, n) , (D2, n) } 力 2つの部分データ列 { (D11( n n) , (D21, η21) } と、 部分データ列 { (D12, n12) , (D22, n22) } に分割され、 それらがマ一ジ処理に使われて全体としてキー値の大小に矛盾のない出力をするためには下式が 成立しなければならない。 部分データ列 と D21の末尾のデータのキ一値の小さい方
≥ 部分デ一タ列 D12と D22の頭部のデータのキー値の大きい方
n t i + n 2 i = 2分した上位データ列対に含まれるべきデータ数 この発明に係る並列マージソ一ト処理方法は、 複数のプロセッサを含む並列プロセッサを用い て並列マージソート処理を行うための方法であって、
入力として、 未整列の 1つのデータ列、 または 2つの整列済部分データ列、 あるいは 3つ以上 の整列済部分データ列のいずれかとその属性情報 (種別 .データの所在情報や個数など) を受け 入れ、
整列対象が未整列デ一タ列の場合はそのデ一タ列を分割して複数の未整列部分データ列を得る 第 1ステップと、 前記複数のソ一卜用部分デ一タ列にそれぞれプ口セッサを割り当てる第 2ステップと、 割り当てられたプロセッサにより前記複数の部分データ列につレ、てそれぞれ独立にソート処理 を行い降順に整列された部分データ列を出力する第 3ステップと、
第 3ステップまたは第 7ステップで得たか初期データとして入力された、 任意の 2つの整列済 部分デ一タ列でマージソート用の入力データ列の対をつく り、 所定の分割条件の下でそれぞれ要 求された数の細分された部分データ列の対に分割する第 4ステップと、
細分した部分データ列対に対してマージ処理をするために必要なジョブ情報を編集する第 5ス テツプと、
各マージ処理に対してプロセッサを割り当てる第 6ステップと、
割り当てられたプロセッサによりマージ処理を行レ、整列された部分デ一タ列を出力する第 7ス テツプと、
出力データ列の数が 1つになる迄前記第 4ステップ乃至前記第 7ステップを繰り返すステップ とを備えるものである。
但し、 以上は 1つの未整列データ列が与えられる場合に適用されるもので、 2つ以上の整列済 データ列が与えられる場合は第 1ステップから第 3ステップ迄は不要である。
また第 4ステップ乃至前記第 7ステップの繰り返しはマージ処理された整列済部分データ列が 1つのデータ列になった段階で終わる。 特に 2つの整列済データ列が与えられる場合は第 4ステ ップから第 7ステップは 1回だけ行われ繰り返しは必要としなレ、。
好ましくは、
前記第 6ステップにおいて、 前記部分データ列の対に対して 2つのプロセッサが割り当てられ、 前記第 7ステップにおいて、 第 1のプロセッサは前記部分データ列の一方の端 (キー値の大き い側) から正順マージ処理を行い、 第 2のプロセッサは同じ部分データ列の他方の端 (キー値の 小さレヽ側) から逆順マージ処理を同時に行う。
( 2分した下位データ列対の頭部の位置決定)
段落 0 0 2 0に記したデータ列対の 2分方法を以下に記述する。
令前記データ列 と D 2内の個々のデータを指定する指標変数 iと jを設け、 それらへの初期 値として前記 Xを設定 (1 0 0 0 0個ずつのデータ列対を 1 0 0 0個ずつのデータ列対 1 0区画 に分割する場合、 個数としての X = 1 0 0 0、 分割位置の初期指標には 1 0 0 0 , . . 9 0 0 0 を設定) するステップと、 ♦デ一タ列 D iの指標変数 iが指すデ一タのキ一値とデ一タ列 D 2の指標変数 jが指すデータの キー値を比較する比較ステップと、
♦最初の比較で の指標変数 iが指すデータのキー値と D 2の指標変数 jが指すデータのキー 値が等しくない場合、 キー値の大きい方の指標変数に 1を加え、 小さい方の指標変数から 1を引 いた後、 前記比較ステップに分岐するステップと、
♦ 2回目以降の比較で D jの指標変数 iが指すデータのキー値と D 2の指標変数 jが指すデータ のキ一値との大小関係に変化がない場合、 大きい方の指標変数に 1を加え、 小さい方の指標変数 から 1を引いた後、 前記比較ステップに分岐するステップと、
令最初の比較で の指標変数 iが指すデータのキ一値と D 2の指標変数]'が指すデータのキー 値とが等しいとき、 指標変数 iが指すデータと指標 jが指すデータをそれぞれ分割境界とするス テツプと、
♦ D tの指標変数 iが指すデータのキー値と D 2の指標変数〗が指すデータのキー値との間の大 小関係が前回の大小関係から反転 (2回目以降の比較では等しい場合も反転とみなす) したとき、 前回の比較操作における D iのキ一値と D 2のキー値のうちの大きい方と、 今回の比較操作におけ る のキ一値と D 2のキ一値の内の大きい方とを比較して、 小さい方のキ一値をもつデータを分 割境界とすると共に、 当該データの当初の比較相手を他方の境界とするステップ
とを実行する。 なおこの処理は 2分した後半のデータ列対 { (D 1 2, n 1 2 ) , (D 2 2 , n 2 2 ) } の頭部の決定、 換言すれば正順併合の開始点の決定に使われる。
( 2分した上位データ列対の尾部の位置決定)
段落 0 0 2 0に記したように 2分する方法を以下に記述する。
♦前記データ列 D 1と D 2の個々のデータを指定する指標変数 i と jとに境界の指標値の初期値 として前記 X— 1を設定 (1 0 0 0 0個ずつのデータ列対を 1 0 0 0個ずつのデータ列対 1 0区 画に分割する場合、個数としての Xには 1 0 0 0、分割位置の初期指標には 9 9 9 , 1 9 9 9 , - . 8 9 9 9を設定する) するステップと、
♦データ列 D〗の指標変数 iが指すデータのキー値とデータ列 D 2の指標変数 jが指すデータの キー値を比較する比較ステップと、
♦最初の比較で D の指標変数 iが指すデータのキー値と D 2の指標変数 jが指すデータのキー 値が等しくない場合、 キー値の大きい方の指標変数に 1を加え、 小さい方の指標変数から 1を引 いた後、 前記比較ステップに分岐するステップと、 ♦2回目以降の比較で の指標変数 iが指すデータのキー値と D 2の指標変数 jが指すデータ のキー値との大小関係に変化がない場合、 大きい方の指標変数に 1を加え、 小さい方の指標変数 から 1を引いた後、 前記比較ステップに分岐するステップと、
♦最初の比較で の指標変数 iが指すデータのキー値と D 2の指標変数〗が指すデータのキー 値とが等しいとき、 指標変数 iが指すデータと指標 jが指すデータをそれぞれ分割境界とするス テツプと、
♦ D iの指標変数 iが指すデータのキー値と領域 D 2の指標変数 jが指すデータのキ一値との間 の大小関係が前回の大小関係から逆転 (2回目以降の比較では等しい場合も反転とみなす) した とき、 前回の比較操作における のキ一値と D 2のキ一値のうちの小さい方と、 今回の比較操作 における のキ一値と D 2のキー値の内の小さい方とを比較して、 大きい方のキー値をもつデ一 タを分割境界とすると共に、 当該データの当初の比較相手を他方の境界とするステップ
とを実行する。 なおこの処理は 2分した前半のデータ列対 { (D n , n i l ) , (D 2 1 , n 2 1 ) } の尾部の決定、 換言すれば逆順併合の開始点の決定に用いる。
この発明は、 マ一ジソー卜の入力となる 2組の整列済データ列の対をキー値の大小分布を考慮 して複数のデータ列対に細分割することにより、 任意の並列度のマージソート処理を可能とする 並列マージソー卜処理方法であって、
整列されたデータからなる第 1のデ一タ列と第 2のデータ列を用意するステップと、 要求される並列度に応じて前記第 1のデータ列及び前記第 2のデータ列の対を両デ一タ列の頭 部からのキー値の大小を考慮して複数の整列済部分データ列対に細分割するステップと、 分割さ れた整列済部分データ列対を入力として並列にマージ処理を行うステップとを備えるものである。 この発明は、 複数のプロセッサを含む並列プロセッサを用いて並列マージソート処理を行うた めのプログラムであって、
入力として、 未整列の 1つのデータ列、 または 2つの整列済部分データ列、 あるいは 3つ以上 の整列済部分データ列のいずれかとその属性情報 (種別'データの所在情報や個数など) を受け 入れ、
整列対象が未整列データ列の場合はそのデ一タ列を分割して複数の未整列部分データ列を得る 第 1ステップと、
前記複数のソ一ト用部分データ列にそれぞれプ口セッサを割り当てる第 2ステップと、 割り当てられたプロセッサにより前記複数の部分データ列についてそれぞれ独立にソ一ト処理 を行い降順に整列された部分データ列を出力する第 3ステップと、 第 3ステップまたは第 7ステップで得たか初期データとして入力された、 任意の 2つの整列済 部分データ列でマージソート用の入力データ列の対をつくり、 所定の分割条件の下でそれぞれ要 求された数の細分された部分データ列の対に分割する第 4ステップと、
細分した部分データ列対に対してマージ処理をするために必要なジョブ情報を編集する第 5ス テツプと、
各マージ処理に対してプロセッサを割り当てる第 6ステップと、
割り当てられたプロセッサによりマージ処理を行い降順に整列された部分データ列を 各マージ処理に対してプロセッサを割り当てる第 6ステップと、
割り当てられたプロセッサによりマージ処理を行い降順に整列された部分データ列を出力する 第 7ステップと、
マージ処理されたデータ列を前記部分データ列として前記第 4ステップ乃至前記第 7ステップ を出力データ列の数が 1つになる迄繰り返すステップとを備えるものである。
但し第 1ステップから第 3ステツプ迄は入力データ列が未整列の場合にのみ必要なものである。 また第 4ステツプ乃至前記第 7ステツプの繰り返しはマージ処理された整列済部分データ列が 1 つのデータ列になつた段階で終わる。 特に 2つの整列済データ列が与えられる場合は第 4ステツ プから第 7ステップは 1回だけ行われ繰り返しは必要としなレ、。
この発明に係るプログラムは、 例えば、 記録媒体に記録される。
媒体には、 例えば、 EPROMデバイス、 フラッシュメモリデバイス、 フレキシブルディスク、 ハ一ドディスク、 磁気テープ、 光磁気ディスク、 CD (CD-ROM, V i d e o— CDを含む) DVD (DVD— V i d e o、 DVD-ROM, DVD— RAMを含む) 、 ROM力一卜リッジ、 バッテリバックアップ付きの RAMメモリカートリッジ、 フラッシュメモリカートリッジ、 不揮 発性 RAMカートリッジ等を含む。
また、 電話回線等の有線通信媒体、 マイクロ波回線等の無線通信媒体等の通信媒体を含む。 ィ ンタ一ネッ卜もここでいう通信媒体に含まれる。
媒体とは、 何等かの物理的手段により情報 (主にデジタルデータ、 プログラム) が記録されて いるものであって、 コンピュータ、 専用プロセッサ等の処理装置に所定の機能を行わせることが できるものである。 要するに、 何等かの手段でもってコンピュータにプログラムをダウンロード し、 所定の機能を実行させるものであればよい。 図面の簡単な説明 図 1は、 発明の実施の形態に係る並列マージソート処理装置の概要を示す図である。
図 2は、 発明の実施の形態 1に係る処理フローチヤ一卜である。
図 3は、 発明の実施の形態に係る処理全体の説明図である。
図 4は、 発明の実施の形態に係る処理の説明図である。
図 5は、 発明の実施の形態に係る処理の説明図である。
図 6は、 発明の実施の形態に係る処理の説明図である。
図 7は、 発明の実施の形態に係る処理の一部の説明図である。
図 8は、 発明の実施の形態に係る領域分割のフローチャートである (正順併合) 。
図 9は、 発明の実施の形態に係る領域分割のフロ一チャートである (逆順併合) 。
図 1 0は、 発明の実施の形態に係る領域分割の説明図である。
図 1 1は、 発明の実施の形態に係る領域分割の例を示す図である。
図 1 2は、 発明の実施の形態 2に係る処理フローチャートである。
図 1 3は、 従来の並列マージソート処理のフローチャートである。
図 1 4は、 従来の並列マ一ジソート処理の説明図である。 発明を実施するための最良の形態
発明の実施の形態 1 .
発明の実施の形態に係る装置 Z方法について図面を参照して説明する。
図 1は本装置の概略構成を示すものである。 1は複数のプロセッサを含み、 複数のタスクを同 時並行的に実行可能なマージ処理用並列プロセッサである。 2は 2組の整列済データ列の対を所 定数の部分データ列対に分割して管理用プロセッサ 4に返す領域分割用並列プロセッサである。 3は指定された領域に存在する未整列のデ一タ列をソー卜するソート処理用並列プロセッサであ る。 また 4は全体の制御を担当する管理プロセッサで、 ジョブ開始に際して外部から受ける入出 力データの場所やデータ数などの情報 6を受けるほか、 前記並列プロセッサ群に行わせるタス クに必要な情報の編集やタスクの起動、 タスク終了報告の受け付けなどの処理を担当する。 5は 整列対象のデータを含むデータ記憶域である。
1と 3は実装によっては同じ並列プロセッサを用いることもできるし、 2のデータ列対分割用 並列プロセッサについても同様である。
従来技術では一つのマージ処理用としてしか扱われない 2つの整列済データ列の対を複数の部 分データ列の対に分割することにより並列度を向上させる。 後述の図 3の例では、 マージの入力 となるデータ列 D 2 1と D 2 2の対を 2分割することにより 2組の入力データ列対を得て、 それ ぞれを正順マージと逆順マージを行うことによりプロセッサ P 1〜P 4に同時に処理をさせるこ とができ、 データ列 D 3 1、 D 3 2の対を 4分割することにより 4組の入力データ列対を得て、 それぞれを正順マージと逆順マージを行うことによりプロセッサ P 1〜P 8に同時に処理をさせ ることができる。 詳しくは後述する。
図 2の概略フロ一チヤ一卜で示す並列 2分木マージソート法では、 整列の対象であるデータ列 を p = 2 qの関係をもつ p組の未整列のデータ列に分割し、 それぞれを独立に、 例えばクイックソ 一ト法により整列させる。
S 1〜S 3は入力データ列を複数のデータ列に分割し p個のプロセッサに同時並行的にソ一卜 処理を行わせるための手順である。 その後、 以下のように q段のマージソートを繰り返し、 最終 的に全体として整列された 1組のデータ列を得る。
S 1 :整列処理の対象である未整列のデータ列を p組の未整列データ列に分割する。 ここで、 P = 2。で、 動員可能なプロセッサの数に相当し、 qはマージの段数を表す数である。 短い処理時間 を望む場合は Pを大きくするが、 1 o g 2 pの関係で qも増加する。
また説明の便宜上用いるマ一ジ段を表す変数 aを 0に初期化する。
S 2 : p個のプロセッサを分割された p区画に割り当てる。
S 3 :それぞれ独立にソ一卜する。
S 4 :マージ操作の入力となる整列済部分データ列の対を分割する。
( 1 ) a = a + 1
( 2 ) 2 11 _ a + 1組の整列済部分データ列を 2つずつ組み合わせた 2 q _ a組の入力データ列対を作 る。
各入力データ列対のそれぞれを 2 a1組の細分化されたデータ列対に分割する。 データ列対の 分割の仕方については後述する。
S 5 : ( 2 " - a ) X ( 2 a1 ) = 2 a一1組の細分されたデータ列対のそれぞれに正順併合と逆順併 合用のプロセッサを割り当てる。
S 6 :各組についてそれぞれ 2つのプロセッサを用いて正順併合と逆順併合を同時に行い 2 11a 組の整列された部分データ列を得る。
S 7 :次に、 a≠qなら aに 1を加え、 S 4〜 S 7の処理を繰り返す。
S 8 :以上の手順により、 最終的に全体として整列された 1組のデータ列を得ることができる。 図 2の方法は、 1段目のマージでは分割しないが、 2段目において 2分割し、 3段目において 4分割し、 4段目において 8分割し、 · · ·、 q段目において領域を 2 o 1分割し、 それぞれの 領域に正順併合と逆順併合を適用する。 図 2の整列済データ列分割法を適用した並列 2分木マ一 ジソ一ト法では常に p並列の併合操作を行うことができる。
図 3を参照してプロセッサの数が 8の場合における並列 2分木マ一ジソ一ト法の処理について 説明する。 図中、 丸はプロセッサを示し、 四角はデータ列あるいはデータ列 (D) が記憶される 領域を示す。 丸の中の記号はプロセッサが行う処理の内容を示し、 Sは整列 (ソート) 処理、 M は併合 (マージ) 処理、 Vは転送処理を意味する。
入力領域に置かれたデータは 8組の未整列データ列に分割する。 8つのプロセッサ P 1〜P 8 によりこれら部分データ列について同時並行的にソ一ト処理を行う。 これらの処理結果は領域 D 1 1〜D 18に置かれる。
次に、 第 1段目のマ一ジソ一卜を行う。 プロセッサ P 1、 P 2によりデータ列 D 1 1と D 12 が併合されて D 21に置かれ、 プロセッサ P 3、 P 4によりデータ列 D 13と D 14が併合され て D22に置かれ、 プロセッサ P 5、 P 6によりデータ列 D 1 5と D 16が併合されて D23に 置かれ、 プロセッサ P 7、 P 8によりデ一タ列 D1 7と D 18が併合されて D 24に置力、れる。 なお第 1段目では正順併合と逆順併合が同時に行われるので、 分割を行わなくても 8台のプロ セッサが使用される (プロセッサの割り当ては便宜上のものである。 以下同じ) 。
次に、 第 2段目のマージソ一卜を行う。 全てのプロセッサを使用するためにデータ列対を 2分 割する。 すなわち、 部分データ列 D 21と D 22の対に対しキー値の大小を考慮して 2分割し、 D 21— 1と D 22— 1の対と D 21— 2と D 22— 2の対を作る。 データ列 D 23と D 24の 対についても同様である。
そして、 プロセッサ P l、 P 2によりデータ列 D21— 1と D22— 1が併合されて D31の 一方 (キー値の大きい側) に置かれ、 プロセッサ P 3、 P 4によりデータ列 D 21— 2と D 22 — 2が併合されて D 31の他方 (キー値の小さい側) に置かれる。 同様に、 プロセッサ P 5〜P 8によりデータ列 D 23と D24が併合されて D 32に置かれる。
次に、 第 3段目のマージソ一卜を行う。 第 2段階目と同様に分割が行われる。 すなわち、 デ一 タ列 D 31と D 32を対にし、 キー値の大小を考慮して 4分割し、 031—1と032—1、 D 31— 2と D32_2、 D32— 3と D32— 3、 D31— 4と D32— 4の各部分データ列対 を作る。 プロセッサ P l、 P 2によりデータ列 D 31— 1と D 32— 1が併合されて D4内の所 定の位置に置かれ、 プロセッサ P 3、 P4によりデータ列 D31— 2と D32— 2が併合されて 領域 D 4内の所定の位置に置かれ、 プロセッサ P 5 P6によりデータ列 D31— 3と D32— 3が併合されて領域 D 4内の所定の位置に置かれ、 そして、 プロセッサ P 7 P 8によりデータ 列 D 31—4と D 32— 4が併合されて領域 D 4内の所定の位置に置かれる。 これでマージソー 卜が完了する。 得られた結果 D 4は必要なら 8台のプロセッサにより出力領域に転送される。 図 3の処理の各段階において 8つのプロセッサの全てが使用される。
図 4〜図 6を参照して図 3の処理を模式的に説明する。
dl0 dl3 d20 d23の 8つの部分データ列 (各ブロックのデータ数 = 380個) の合計 304 0組のデータをソ一卜することを考える。
(1) dl0 d 23のそれぞれを 8台のプロセッサを使いソートする。 ソ一卜された状態は図 4の 中段のようにキー値が降順に並べられたものになる。 図中、 三角形は各ブロックのおけるキー値 の大きさの分布を示す。
(2) 別に一組の作業領域 el0 el3 d20 d23を設けて図 4の中段のように並列マージを実行す る。 その結果、 下段のような結果が得られる。
(3) 次に 2段目のマージソ一卜を行う。 (el0 e 11) と ( e 20 e 21) を組み合わせ、 キ一 値の大小を考慮して 2分割して 2組のマージ入力用データ列の対を作り 4並列のマージ操作を実 行する (図 5上段) 。 同時に、 (el2 el3) と ( e 22 e 23) を組み合わせ、 キー値の大小を 考慮して 2分割して 2組のマージ入力用データ列対を作り 4並列のマージ操作を実行する (図 5 下段) 。 結局、 4並列のマージが 2系統並列に実行される。
(4) 次に 3段目のマージソートを行う。 dl0 dl3と d20 d23を組み合わせてキ一値の大小 を考慮して 4分割して 4組のマージ入力対を作り、 e 10 e23 出力する。 各領域は 4分割され、 それぞれ正順 ·逆順の処理がされるので、 8つの処理が並列に実行される。
図 3の各段階におけるマージソート処理についてさらに詳しく説明する。 図 7はその説明図で ある。 入力領域 (D^ n) と (D2 n) の入力データ列の対が与えられたとする。 ここで (D !, n) と (D2 n) は n個のデータからなるデータ列 と D2を意味する。 図 7の各領域にお いて左側ほどキー値が大きく、 右側ほどキー値が小さくなるようにソ一トされている。
(段落 0048) 図 1に示すデータ列対分割部 2により n) と (D2 n) の整列済 部分データ列対がキー値の大小を考慮して分割 (図 7では 2分割) され、 (D„ ηι α) と (D 2い η21) の対と (D12 n12) と (D22 n22) の対とに分けられたとする。
この分割では下記の式を満足しなければならない。
の末尾のデータのキー値と D 2 Jの末尾のデータのキ一値の小さい方 ≥D12の頭部のデータのキ一値と D 22の頭部のデ一タのキー値の大きレ、方 n!! + n 21 =2 x、 n12 + n22=2 、n— x)
ここで 2 xは、 データ列対 { (Du、 n n) , (D2い n21) } がもつデータ数である。 マージ操作の入力であるデータ列対 (Du, n 1 :) と (D21, n21) に対して、 プロセッサ P 1で正順併合を行うとともに、 プロセッサ P 2で逆順併合を行う。
図中の点線は併合の順序を示す。 その結果を出力領域 (D3, 2 n) の部分である (D31, n3 !) に順次出力する。
同様に、 整列済データ列 (D12, n12) と (D22, n22) の対に対して、 プロセッサ P 3で 正順併合を行うと共にプロセッサ P 4で逆順併合を行う。 その結果を出力領域 (D3, 2 η) の部 分である (D32, n32) に順次出力する。
ここで、 (D 3 の末尾のデータのキー値) ≥ (D 32の頭部のデータのキー値) 、
n31 + n32=2 nである。
以上のように入力データ列対を分割すると共に、 分割されたデータ列対それぞれにプロセッサ を割り当てることにより、 複数のプロセッサによる同時並行処理が可能になる。 なお、 以上の説 明はあくまで一例であり、 本発明はこれに限定されない。
次に整列済データ列対への分割手順について説明する。 図 7の例からも明らかなように、 マ一 ジソ一卜が正しく行われるためには、 (D 3 iの末尾のデータのキー値) ≥ (D32の頭部のデータ のキ一値) でなければならない。 D31は Dn、 D21のマージソート結果であり、 D32は D12、 D22のマージソート結果である。 したがって、 (Duまたは D21に含まれるデータのキー値の最 小値) ≥ (D12または D22に含まれるデータのキー値の最大値) ということである。 このことか ら本発明の領域分割の条件は次のようなものである。
前記分割条件では、 予め整列された 2つのデータ列の対 (D^ n) と (D2, n) I 部分デ —タ列 (Dl lt n X 1) と (D21, n21) の対と、
部分データ列 (D12, n 12) と (D22, n22) の対に 2分割されたとき、
(部分データ列 と D21の末尾のデータのキー値の小さい方)
≥ (部分データ列 D i 2と D 22の頭部のデータのキー値の大きレ、方)
が成立すると共に、
Figure imgf000016_0001
が成立しなければならない。 ここで Xは と D2の頭部から数えたデータ列対のデータ数の半 分の数である。 例えば、 1000個の整列済データ列対に対し、 x = 300と x = 600の 2回の分割操作を すると、 各データ列対の合計データ数が 600, 600, 800の 3つのデータ列対 { (D: 1, n il) , (ひ 2 ΐ, η 2 } { (D12) n 12) , (D22, n 22) } { (D 13, n 13) , (D23, n23) } に分割される。 この場合、 両データ列を合わせ、 先頭から 600番目のデータのキー値 (Dl tと D21の末尾のデ一タキ一値の小さい方) と 60 1番目のデータのキ一値 (D12と D22 の頭部のキー値の大きい方) 、 1 200番目のデータのキ一値と 1 20 1番目のデータのキー値 に前記の大小関係が満たされねばならない。
以上の条件を満たす整列済データ列対分割の手法を説明する。 以下の正順併合用の分割手法ま たは逆順併合用の分割手法、 あるいは両方の手法を用いることにより、 上記条件を満たすデータ 列対への分割が実現できる。
整列済データ列対の分割手法の具体的な手順の説明の前に、前提となる事項について説明する。 それぞれ n個のデ一タからなる 2つの整列済データ列 と D2を仮定し、 両データ列を(n/k)組の データを含む k組のデータ列対に均等に分割する。
個々のデータ列は 0から k-1のデータ列番号で指定する。 また各データの位置は、 データ列頭 部を 0としデータ毎に 1ずつ増加する指標値で指定する。 この位置指定法は 1^、 D2全体のデー タ位置指定のほか、 分割した各データ列内の位置指定にも用いる。 また、 データ列の頭部あるい は尾部という表現で始端あるレ、は終端のデータ位置を指定する。
前述した均等分割後の と D2の部分データ列中、 同一データ列番号のデータ列同志を仮の併 合対象データ列対とする。
すなわち、 データ列番号 i(i=0〜k- 1)のデータ列対を対象とする正順併合の始点は、 D iと D2 の始端から k) (i)組のデ一タを除いた残りのデータ列の始端、 すなわち指標値が(n/k) (i)の点 とする。
またデータ列番号 i (i=0〜k-l)のデータ列を対象とする逆順併合の始点は、 D!と D 2の始端か らそれぞれ (n/k) (i+1)組のデータが存在するデータ列の末尾、 換言すれば指標値が(n/k) (i+l)-l の点とする。
と D2内のキ一値の分布は互いに独立である。 このため、 それぞれのデータ列内で整列済で あっても、 仮の開始点から併合操作をしたのでは、 全体としてキ一値の分布に矛盾のない整列結 果を得ることはできなレ、。 そこで以下の手順により前記条件を満たす開始点 (分割点) を求める。 ぐ正順併合の場合 > それぞれ整列された n個のデータからなる 2つのデータ列、 Diと D2とがある。 段落 0048 の条件を満たし、 かつ、 両データ列の先頭からのキー値の大小を考慮してデータ列の先頭からの データ数が 2 (n/k) +2、 4 (n/k) +2, 6 (n/k) +2, · · · 2(k- 1) (n/k)+2となるデータ列対を識別する。 この境界はデータ数が 2 (n/k)、 4 (n/k), 6 (n/k), · · · 2(k_l) (n/k)のデータ列対を除いた残り のデータ列対の頭部の指標である。
図 8を参照する。
S 10 :境界初期値 (あるいは仮の境界値) として(n/k)、 2 (n/k), 3(n/k)、 · · · (k_l) (n/k)の 指標値をもつ点を選ぶ。
S 1 1 : と D2域の作業用指標変数 iと jとに、 S 1 0で定めた境界初期値の指標値を設定す る。
S 1 2 :下記の手順を大小関係が反転する迄繰り返す。 ただし最初の比較を含め、 キー値が等し い場合も反転とみなす。
S 1 2 a : D i)と D2(j)のキー値を比較する。
51 2 b :大小関係を判別する。
(1) 最初の比較で両者が等しいなら S 1 3 aに分岐する。
(2) 大小関係が逆転したら S 1 3 bに分岐する。
(3) 最初の比較で両者が等しくない場合、 または 2回目以降の比較で大小関係が反転しない場 合、 キー値の大きい方の指標値に 1を加え、 小さい方の指標値から 1を引いた後、 S 1 2に分岐 する (S 1 2 c) 。
S 1 3 a : iと jを境界点の指標とし処理を終わる。
51 3 b :大小関係が変化する直前と直後の比較操作の対象データ中、 大きいキー値同志を比較 し、 その小さい方を境界のデータとする。 他方の領域の境界データには今求めたデータの当初の 比較相手を選ぶ。
ぐ逆順併合の場合 >
それぞれ n個のデータを収容した 2つのデータ歹【J、 と D2とがある。 段落 0048の条件を 満たし、 かつ、 両データ列のキー値の大小分布を考慮してデータ列先頭からのデータ数が 2(n/k)、 4 (n/k), 6 (n/k), · · · 2 (k-1) (n/k)となるデータ列の末尾を求める。 以下では図 9を参照する。 S 20:境界初期値(仮の境界値)として、それぞれ (n/k)- l、2(n/k)-l、3(n/k)-l、 · · ·(k- 1) (n/k)- 1 の指標値をもつ点を選ぶ。
S 2 1 : と D2域の作業用指標変数 iと jとに S 20で定めた境界初期値の指標値を設定する。 S 22 :下記の手順を大小関係が反転する迄繰り返す。 ただし最初の比較を含め、 キー値が等し い場合も反転とみなす。
S 22 a : D!(i)と D2(j)のキー値を比較する。
S 22 b :大小関係を判別する。
(1) 最初の比較で両者が等しいなら S 23 aに分岐する。
(2) 大小関係が反転したら S 23 bに分岐する。
(3) 最初の比較で両者が等しくない場合、 または 2回目以降の比較で大小関係が反転しない場 合、 キー値の大きい方の指標値に 1を加え、 小さい方の指標値から 1を引いて S 22に分岐する。 S 23 a : iと jを境界点の指標とし処理を終わる。
S 23 b :大小関係が変化する直前と直後の比較操作の対象データ中、 小さいキー値同志を比較 し、 その大きい方を境界のデータとする。 また、 他方の領域の境界のデータには上で求めたデー タの当初の比較相手を選ぶ。
上記手順によるデータ列対の分割例について説明する。
図 10は降順に整列された、 それぞれ 10個の数値を含む下記の 2つのデータ列を示す。 図 10 (a) は正順併合の始点の決定手順の説明図、 図 10 (b) は逆順併合の始点の決定手順の説明 図、 図 10 (c) は領域の分割結果を示す。
D 1 : (1948, 1868, 1862, 1148, 740, 620, 588, 256, 112, 100)
D 2 : (1996, 1992, 1966, 1694, 1544, 1448, 1182, 432, 254, 30)
(段落 0059) <正順併合の始点の決定 >
(1) データ列頭部から 5組のデータを除いたデータ列の頭部が仮の分割点となる。 作業用指標 i , j にこの値を設定する。 i=j=5となる。
(2) D1(i=5)=620と D2(j=5)=1466を比較する。 1466が大きいので、 i=i - 1=4, j=j+l=6とする
(3)
Figure imgf000019_0001
- 1=3, j=j+l=7とする。
(4)
Figure imgf000019_0002
を比較する。 1148が大きいので、 ここで大小関係の反転を 認識する。
(1) 反転前後の比較で値の大きい 11 と 1182を比較し、 その小さい方である 1148の点を一方 の境界とする。 他方の境界は 1148の当初の比較相手である 432を得る。 なお、 一方の境界が判明 すれば、 次式(1)を用い 2x5-3=7として他方の境界指標値を求めることもできる。
他方の開始点の指標値 = 仮併合開始点の指標 x2 - 既知の開始点の指標
<逆順併合の始点の決定 > (1) データ列頭部から 5組のデータがある点が仮の分割点となる。 作業用指標 i , jにこの値 を設定する。 i=j=4とする。
(2) 0 1=4)=740と D2(j=4)=1544とを比較すると、 1544が大きいので、 i=i_l=3, j=j+l=5と する。
(3) D1(i=3)=1148と D2(j=5)=1446とを比較すると、 1446が大きいので i=i - 1=2, j=j+l=6と する。
(4) D1(i=2)=1862と D2(j=6)=1182とを比較すると、 1862が大きいので大小関係が反転したこ とになる。
(5) 反転前後の比較で値の小さい 1148と 1182を比較し、 大きい方の 1182を一方の境界とする。 他方の境界は 1182の当初の比較相手のデータ 1862を得る。 段落 0059の式を用レ、、 2x4-6=2 として他方の境界の指標値を求めることもできる。
他の例を図 1 1 (a) (b) に示す。 図 1 1 (a) は、 n = 1 2, k = 4, n/k = 3の場合 である。 図 1 1 (b) は、 n= 1 0, k = 5, n/k = 2の場合である。 この例のように、 分割 後の部分データ列により併合する場合の出力データが または D 2の一方にのみ存在する場合 (両 方のデータ列にまたがつていない場合) であっても、 前記条件を満たすことがわかる。
本発明の実施の形態に係る装置/方法において、 分割する区画の数は使用可能な処理装置の数 に応じて任意に決めることができる。
本発明に係る装置 方法において、 マ一ジソー卜の入力となる整列済部分データ列対を複数の データ列対に分割する時間の全時間に占める割合を小さくするため、 データ数が大きいほど効果 も大きい。 なお、 複数のデータ列対に分割する処理のうち、 実質的な併合開始点を決定する部分 をマージソート作業を割り当てられたプロセッサ自身が実行すれば、 より充実した並列処理が可 能となり全処理時間に占める領域対分割にかかる時間の割合を削減できる。
( 1) 効果の大きい場合
データ列 D!と D 2のキー値の分布がほぼ同じ場合は短時間に大小関係が反転する。 このためマ —ジ入力となるデータ境界の決定に多くの時間を要しない。
(2) 分割に時間のかかる場合
下記のケースが考えられる。
(a) 分割対の確定に時間のかかる場合
k区画に分割する場合で対象となるデ タ列対の区画番号が k / 2に近レ、場合で、 D iまたは D 2の頭部や尾部、 換言すればデータ列の端部近辺になってようやく大小関係が反転する場合、 大小 関係の反転までに時間がかかる。 キーの分布が と D 2とで偏りがある場合に発生するが、 この ようなケースが頻発することは少ないと考える。
( b ) キー値の価域に重複がない場合と大小関係が反転しない場合
大小関係の反転を求めて比較を続け、領域の頭部または端部に至っても反転しない場合である。 このときは次のように扱うことができる。 すなわち、 頭部に達しても反転しない場合は頭部の外 側に無限大のキ一を仮定して強制的に反転させ、 尾部に至っても反転しない場合は尾部の外に無 限小のキーを仮定して反転させる。
なお、 上記例ではデータ列 と D 2のデータ数は同数を仮定していた。 本発明はこれに限定さ れなレ、。 整列タスクゃ併合タスクにおレ、てデータ数を指定しさえすれば D Jと D 2のデータの数が 異なる場合にも適用できる。
本発明は汎用的な技術であり、 主記憶を共有する汎用的な並列プロセッサ方式の電子計算機に 特に適合性が高い。 しかし整列対象のデ一タ群が共通にアクセスできる環境にあればシステムの 構成や処理形態を問わず適用できると考えられる。 本発明は、 並列プロセッサ方式の電子計算機 のソフトウェア (O S ) に組み込まれるプログラムのひとつとして実現されると考えられる。 発明の実施の形態 2 .
発明の実施の形態 1の装置 Z方法は、 図 2に示すように正順併合と逆順併合を同時に用いるも のであった。 この発明は正順併合と逆順併合のレ、ずれか一方しか用いなレ、場合にも適用できる。 図 1 2は並列 2分木マージソート法に適用した場合のフローチャートである。 この場合は初段の マージから 2分割するので常に p個のプロセッサが動作する。 マ一ジ処理を行う並列プロセッサ も正順併合か逆順併合のいずれかの機能を装備するだけでよいので実現は簡単になる。
実施形態 2の処理内容は発明の実施の形態 1の場合と同様であるので、 その説明を省略する。 なお、 図 1 2が図 2と異なる部分は S 4 bと S 5 bと S 6 bである。
本発明は、 以上の実施の形態に限定されることなく、 特許請求の範囲に記載された発明の範囲 内で、 種々の変更が可能であり、 それらも本発明の範囲内に包含されるものであることは言うま でもない。
また、 本明細書において、 手段とは必ずしも物理的手段を意味するものではなく、 各手段の機 能が、 ソフトウェアによって実現される場合も包含する。 さらに、 一つの手段の機能が、 二つ以 上の物理的手段により実現されても、 若しくは、 二つ以上の手段の機能が、 一つの物理的手段に より実現されてもよい。

Claims

請 求 の 範 囲
1. 複数のプロセッサを含み、 2つの入力データ列に対してマージソート処理を行うマージ ソート用並列プロセッサと、 マージソート処理の入力となる 2つの整列済データ列対 (つい) を 指定された組数の部分データ列対に細分割するデータ列対分割用並列プロセッサのほか、 全体を 制御する管理用プロセッサを備え、 前記管理用プロセッサは前記分割用並列プロセッサ群から受 けた複数の部分データ列対を前記マージソート用並列プロセッサにそれぞれ割り当て、 並列にマ ージ処理を行わせることを特^:とする並列マージソート処理装置。
2. 部分データ列の対を割り当てられた前記マージソート用並列プロセッサはそれぞれ独立 にマージ処理を行いその結果を予め指示された出力域に出力する。 これらの出力域の全体が最終 マ一ジ結果となる力 \ あるいは中間マージ結果として次段の並列マ一ジに使われるように出力さ れることを特徴とする請求項 1記載の並列マージソート処理装置。
3. 前記部分データ列対それぞれに対して 2つのプロセッサが割り当てられ、 第 1のプロセ ッサは正順併合 (前記部分データ列対のキー値の大きレ、側の端から小さ!/、方に向かってマ一ジ処 理を行い、 前記出力領域のキ一値の大きい側の端から小さい方に向かって順に出力を書き込む) を行レ、、 第 2のプロセッサは逆順併合 (前記部分データ列対のキ一値の小さレ、側の端から大きい 方に向かってマージ処理を行い、 前記出力領域のキ一値の小さい側の端から大きい方に向かって 順に出力を書き込む) を行うことを特徴とする請求項 2記載の並列マージソート処理装置。
4. 前記分割条件として、 下記の項目を満たすことを特徴とする請求項 1記載の並列マージ ソート処理装置。
♦以下では n個のデータからなる整列済データ列 Dを (D, n) で表し、 2つのデータ列を対に したものを { (D ) n) , (D2, n) } と表記する。
♦整列済データ列対: { (D1; n) , (D2, n) } 力 部分データ列対: { (D11; ηι ) , (D21) n21) } と { (D12, n12) , (D22, n22) } に 2分割されたとき、
(部分データ列 と D21の末尾のデータのキー値の小さい方)
≥ (部分データ列 D 2と D 22の頭部のデータのキー値の大きい方)
が成立すると共に、 n 1 1 + n 2 i = 2 x , n 1 2 + n 2 2 = 2 ( n— x )
が成立する。 ここで xは と D 2の頭部から数えた領域対のデータ数の半分である。
5 . 並列プロセッサを用いて並列マ一ジソ一ト処理を行うための方法であって、 入力として、 未整列の 1つのデータ列、 または 2つの整列済部分データ列、 あるいは 3つ以上の 整列済部分データ列のいずれかとその属性情報 (種別 ·データの所在情報や個数など) を受け入 れ、
整列対象が未整列データ列の場合はそのデータ列を分割して複数の未整列部分データ列を得る 第 1ステップと、
前記複数の部分データ列にそれぞれプ口セッサを割り当てる第 2ステップと、
割り当てられたプロセッサにより前記複数の部分データ列をそれぞれ独立に任意のァルゴリズ ム例えばクイックソ一ト法で整列し、 整列された部分データ列を得る第 3ステップと、
第 3ステップまたは第 7ステツプで得たか初期データとして入力された、 任意の 2つの整列済 部分データ列でマージソート用入力データ列の対をつくり、 その対を所定の分割条件のもとでそ れぞれ要求された組数の部分デ一タ列の対に分割する第 4ステップと、
分割された複数の部分データ列対から並列マージソート用のジョブ情報を編集する第 5ステツ プと、
得られた並列マージソー卜用ジョブにマージソート用プロセッサ群を割り当てる第 6ステップ と、
割り当てられたプロセッサによりマージ処理を行う第 7ステップと、
マ一ジ処理された整列済部分デ一タ列を前記整列済部分データ列として前記第 4ステツプ乃至 前記第 7ステップを繰り返すステツプとを備える並列マージソート処理方法。
但し、 以上は 1つの未整列データ列が与えられる場合に適用されるもので、 2つ以上の整列済 デ一タ列が与えられる場合は第 1ステップから第 3ステツプ迄は不要である。
また第 4ステツプ乃至前記第 7ステツプの繰り返しはマージ処理された整列済部分デ一タ列が 1つのデータ列になつた段階で終る。 特に 2つの整列済データ列が与えられる場合は第 4ステツ プから第 7ステップは 1回だけ行われ繰り返しは必要としない。
6 . 前記第 6ステップにおいて前記部分データ列の対に対して 2つのプロセッサが割り当て られ、 前記第 7ステップにおいて第 1のプロセッサは前記部分データ列のキー値の大きい側から の正順併合処理を、 第 2のプロセッサは同じ部分データ列のキー値の小さレ、側の端からの逆順併 合処理を、 それぞれ同時に行われるように第 5ステップでジョブ制御情報を編集することを特徴 とする請求項 5記載の並列マージソ一ト処理方法。
7. 前記第 4ステップの分割条件として下記の項目を満たす機能をもつことを特徴とする請 求項 5記載の並列マ一ジソート処理方法。
データ列の対 (D n) と (D2, n) 、 部分データ列対 { (D^, n i l:) , (D21, n2 x) } と、 部分データ列: { (D12, n 12) , (D22, n22) } に 2分割されたとき、
(部分デ一タ列 D i と D 2 の末尾のデ一タのキ一値の小さレ、方)
≥ (部分データ列 2と D22の頭部のデータのキー値の大きい方)
が成立すると共に、 nu + n S x, η 12 + η 22 = 2 (η-χ) が成立する。
ここで Xは部分データ列対 { (Di a, n i l) , (D21, n21) } のデータ数の半分の値であ り、 n„ = 1121の場合の Duと D21のデータ数でもある。
8. 前記第 4ステップとして下記の機能を備えることを特徴とする請求項 5記載の並列マー ジソ一ト処理方法。
(1) 整列済データ列の対: { (D1; n) , (D2, n) } を k組の区画対に分割する操作は、 両データ列のキ—値の大小を考慮して D lと D2の頭部から数えたデ一タ数の合計が 2 Xとなる 2 分割操作を、 Xの値を変えて k _ 1通り行うことと等価となる。
この場合、 整列済データ列対: { (D L n) , (D2, n) } の k組の区画対への細分割問題は、 前述した請求項 7を満たすデータ列の 2分割問題に置き換えられる。
( 2 ) データ列中のデータ位置は指標値で指定する。 この値はデータ列 D または D 2の先頭デー タの指標値を 0とし、 順次 1、 2、 · · · と増加する番号をつける。
また、 請求項 7の Xはデータの個数を表すものだが、 Xの値自体を指標値と見なすとデータ列 の先頭から 1, 2, 3と数えて x + 1番目のデータを指すことになる。
さらに請求項 7で n i = n 2 の場合、 データ数を表す式 n i = n 2 = Xは先頭から数えて x 番目のデ一タ、 指標値で言えば X— 1のデータ位置が D iと D 2の分割境界であることを表してい ると解釈することもできる。
(3) 領域の分割機能 ♦前記データ列 と D 2内の個々のデータを指定する指標変数 i と jに境界指標値の初期値と して前記 Xを設定 (例えば 1 0 0 0 0個ずつのデータ列対を 1 0 0 0個ずつのデータ列対 1 0区 画に分割する場合、 個数としての X = 1 0 0 0、 分割位置の初期指標には 1 0 0 0 , · · 9 0 0 0を設定) するステップと、
♦データ列 D jの指標変数 iが指すデ一タのキー値とデータ列 D 2の指標変数 jが指すデ一タの キー値を比較する比較ステツプと、
♦最初の比較で の指標変数 iが指すデータのキー値と D 2の指標変数 jが指すデータのキー 値が等しくない場合、 キー値の大きい方の指標変数に 1を加え、 小さい方の指標変数から 1を引 いた後、 前記比較ステップに分岐するステップと、
♦ 2回目以降の比較で の指標変数 iが指すデータのキー値と D 2の指標変数 jが指すデータ のキ一値との大小関係に変化がない場合、 大きい方の指標変数に 1を加え、 小さい方の指標変数 から 1を引いた後、 前記比較ステップに分岐するステップと、
♦最初の比較で の指標変数 iが指すデータのキ一値と D 2の指標変数 jが指すデータのキ一 値とが等しいとき、 指標変数 iが指すデータと指標変数 jが指すデ一タをそれぞれ分割境界とす るステップと、
♦ D 1の指標変数 iが指すデータのキー値と D 2の指標変数 jが指すデータのキー値との間の大 小関係が前回の大小関係から反転 (2回目以降の比較では等しい場合も反転とみなす) したとき、 前回の比較操作における D のキー値と D 2のキ一値のうちの大きい方と、 今回の比較操作におけ る D iのキー値と D 2のキー値の内の大きい方とを比較して、 小さレ、方のキー値をもっデ一タを分 割境界とすると共に、 当該データの当初の比較相手を他方の境界とするステップ
とを備えることを特徴とする請求項 5記載の並列マージソート処理方法。 これは 2分した下位 デ一タ列対の頭部の位置の決定に用レゝる。
9 . 前記第 4ステップとして下記の機能を備えることを特¾! [とする請求項 5記載の並列マ一 ジソ一ト処理方法。
( 1 ) 整列済データ列の対: { (D i , n ) , (D 2, n ) } を k組の区画対に分割する操作は、 両データ列のキー値の大小を考慮して D lと D 2の頭部から数えたデータ数の合計が 2 Xとなる 2 分割操作を、 Xの値を変えて k一 1通り行うことと等価となる。
このように見なすと、 整列済データ列の対: { (D i , n ) , (D 2, n ) } の k組の区画対への 細分割問題は、 前述した請求項 7の条件を満たすデータ列の 2分割問題に置き換えられる。 ( 2 ) データ列中のデータ位置は指標値で指定する。 この値は または D 2の先頭データの指標 値を 0とし、 順次 1、 2、 · · · と増加する。
また請求項 7の Xはデータの個数だが、 Xの値自体を指標値と見なすとデータ列の先頭から 1, 2 , 3と数えて x + 1番目のデ一タを指すことになる。
さらに請求項 7で n u n の場合、 n i l = n 2 1 = xは先頭から数えて X番目のデータ、 指 標値で言えば X— 1のデ一タ位置に D と D 2の分割境界があることを表している。
( 3 ) 領域の分割機能
♦前記データ列 と D 2の個々のデータを指定する指標変数 iと jとに境界の指標値の初期値 として前記 X— 1を設定 (例えば 1 0 0 0 0個ずつのデータ列対を 1 0 0 0個ずつのデータ列対 1 0区画に分割する場合、 個数としての Xには 1 0 0 0、 分割位置の初期指標には 9 9 9, 1 9 9 9 , · · 8 9 9 9を設定) するステップと、
データ列 の指標変数 iが指すデータのキー値とデータ列 D 2の指標変数 jが指すデータのキ 一値を比較する比較ステップと、
♦最初の比較で D の指標変数 iが指すデータのキー値と D 2の指標変数 jが指すデータのキー 値が等しくない場合、 キ一値の大きい方の指標変数に 1を加え、 小さい方の指標変数から 1を引 いた後、 前記比較ステップに分岐するステップと、
♦2回目以降の比較で の指標変数 iが指すデータのキー値と D 2の指標変数 jが指すデータ のキ一値との大小関係に変化がない場合、 大きい方の指標変数に 1を加え、 小さい方の指標変数 から 1を引いた後、 前記比較ステップに分岐するステップと、
♦最初の比較で D iの指標変数 iが指すデータのキー値と D 2の指標変数 jが指すデータのキ一 値とが等しいとき、 指標変数 iが指すデータと指標 jが指すデータをそれぞれ分割境界とするス テツプと、
♦ D!の指標変数 iが指すデ一タのキー値と領域 D 2の指標変数 jが指すデータのキ一値との間 の大小関係が前回の大小関係から逆転 (2回目の比較以降では等しい場合も反転とみなす) した とき、 前回の比較操作における のキ一値と D 2のキー値のうちの小さい方と、 今回の比較操作 における D のキ一値と D 2のキー値の内の小さい方とを比較して、 大きい方のキ一値をもつデー タを分割境界とすると共に、 当該データの当初の比較相手を他方の境界とするステップ
とを備えることを特徴とする請求項 5記載の並列マージソート処理方法。 これは 2分した上位 デ一タ列対の末尾の決定に用いる。
1 0 . 2組の整列済データ列の対を複数の整列済データ列対に細分割して任意の並列度のマ一 ジソート操作で整列させる並列マ一ジソ一ト処理方法であって、
整列された第 1のデ一タ列及び第 2のデータ列の対を用意するステップと、
要求される並列度に応じて前記第 1のデータ列及び第 2のデータ列の対を複数の整列済部分デ —タ列対に細分割する分割ステップと、
細分割された整列済部分データ列の対を並列にマージするステップとを備え、
細分割した整列済部分データ列の対数に関係なく全体としてキーの並びに矛盾の無いデータ列の 出力が可能な並列マージソ一ト処理方法。
1 1 . 複数のプロセッサを含む並列プロセッサを用いて並列マージソート処理を行うためのプ ログラムであって、
入力として、 未整列の 1つのデータ列、 または 2つの整列済部分データ列、 あるいは 3つ以上 の整列済部分データ列のいずれかとその属性情報 (種別 ·データの所在情報や個数など) を受け 入れ、
整列対象が未整列データ列の場合はそのデータ列を分割して複数の未整列部分データ列を得る 第 1ステップと、
前記複数の部分デ一タ列にそれぞれプ口セッサを割り当てる第 2ステップと、
割り当てられたプロセッサにより前記複数の部分データ列についてそれぞれ独立に任意のアル ゴリズム、 例えばクイックソート法で整列処理を行う第 3ステップと、
第 3ステップまたは第 7ステップで得たか初期データとして入力された、 任意の 2つの整列済 部分データ列でマージソート用の入力データ列の対をつく り、 所定の分割条件のもとでそれぞれ 要求された分割数の部分データ列対に細分割する第 4ステップと、
分割された部分データ列対をマージソートするためのジョブ情報を編集する第 5ステップと、 得られたマージソートジョブに対してプロセッサ群を割り当てる第 6ステップと、 割り当てられたプロセッサにより並列にマージ処理を行う第 7ステップと、
マ一ジ処理されたデ一タ列を前記部分デ一タ歹 IJとして前記第 4ステツプ乃至前記第 7ステップ を繰り返すステップと、 を実行させるためのプログラム。
伹し、 以上は 1つの未整列データ列が与えられる場合に適用されるもので、 2つ以上の整列済 データ列が与えられる場合は第 1ステップから第 3ステツプ迄は不要である。 また第 4ステップ乃至前記第 7ステップの繰り返しはマージ処理された整列済部分データ列が 1 つのデータ列になった段階で終る。 特に 2つの整列済デ一タ列が与えられる場合は第 4ステップ から第 7ステップは 1回だけ行われ繰り返しは必要としなレ、。
PCT/JP2003/005319 2002-04-26 2003-04-25 Dispositif de tri par fusion en parallele, procede et programme y relatifs WO2003091872A1 (fr)

Priority Applications (3)

Application Number Priority Date Filing Date Title
US10/511,683 US7536432B2 (en) 2002-04-26 2003-04-25 Parallel merge/sort processing device, method, and program for sorting data strings
AU2003231521A AU2003231521A1 (en) 2002-04-26 2003-04-25 Parallel merge/sort processing device, method, and program
JP2004501962A JP4171835B2 (ja) 2002-04-26 2003-04-25 並列マージソート処理装置及び方法並びにプログラム

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
JP2002125838 2002-04-26
JP2002-125838 2002-04-26

Publications (1)

Publication Number Publication Date
WO2003091872A1 true WO2003091872A1 (fr) 2003-11-06

Family

ID=29267579

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2003/005319 WO2003091872A1 (fr) 2002-04-26 2003-04-25 Dispositif de tri par fusion en parallele, procede et programme y relatifs

Country Status (4)

Country Link
US (1) US7536432B2 (ja)
JP (1) JP4171835B2 (ja)
AU (1) AU2003231521A1 (ja)
WO (1) WO2003091872A1 (ja)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9063944B2 (en) 2013-02-21 2015-06-23 International Business Machines Corporation Match window size for matching multi-level transactions between log files
US9135289B2 (en) 2012-05-30 2015-09-15 International Business Machines Corporation Matching transactions in multi-level records
US11200056B2 (en) 2018-02-08 2021-12-14 Nec Corporation Parallel union control device, parallel union control method, and storage medium
WO2023207832A1 (zh) * 2022-04-26 2023-11-02 华为技术有限公司 数据处理装置的控制方法与装置

Families Citing this family (20)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP5304251B2 (ja) * 2006-12-22 2013-10-02 日本電気株式会社 並列ソート装置、方法、およびプログラム
US8074219B2 (en) * 2007-06-27 2011-12-06 Microsoft Corporation Order preservation in data parallel operations
US20090007128A1 (en) * 2007-06-28 2009-01-01 International Business Machines Corporation method and system for orchestrating system resources with energy consumption monitoring
US7945529B2 (en) * 2007-12-27 2011-05-17 Business Objects, S.A. Apparatus and method for performing table comparisons
US8676865B2 (en) * 2008-05-20 2014-03-18 International Business Machines Corporation Adaptive lazy merging
US8250384B2 (en) * 2009-01-05 2012-08-21 International Business Machines Corporation Optimizer mechanism to increase battery length for mobile devices
US20110264993A1 (en) * 2010-04-23 2011-10-27 Microsoft Corporation Multi-Threaded Sort of Data Items in Spreadsheet Tables
US8527866B2 (en) 2010-04-30 2013-09-03 Microsoft Corporation Multi-threaded sort of data items in spreadsheet tables
US8959522B2 (en) 2012-01-30 2015-02-17 International Business Machines Corporation Full exploitation of parallel processors for data processing
JP2015035006A (ja) * 2012-04-26 2015-02-19 インターナショナル・ビジネス・マシーンズ・コーポレーションInternational Business Machines Corporation 複数の要素の結合結果を識別する情報処理装置、プログラムおよび方法
US9092469B2 (en) 2012-08-22 2015-07-28 Empire Technology Development Llc Partitioning sorted data sets
CN104123304B (zh) 2013-04-28 2018-05-29 国际商业机器公司 数据驱动的并行排序系统和方法
US9418089B2 (en) * 2013-05-13 2016-08-16 Microsoft Technology Licensing, Llc Merging of sorted lists using array pair
US9116953B2 (en) 2013-05-17 2015-08-25 Sap Se Calculation engine with dynamic partitioning of intermediate results
CN103530084A (zh) * 2013-09-26 2014-01-22 北京奇虎科技有限公司 一种数据并行排序方法和系统
RU2667385C2 (ru) 2014-05-30 2018-09-19 Хуавей Текнолоджиз Ко., Лтд. Параллельная сортировка слиянием
CN104320382B (zh) * 2014-09-30 2018-04-20 华为技术有限公司 分布式的实时流处理装置、方法和单元
CN105303058B (zh) * 2015-11-17 2018-09-18 沈阳东软医疗系统有限公司 一种符合事件判定方法和装置
US10210207B2 (en) 2015-12-31 2019-02-19 International Business Machines Corporation Parallel execution of merge operations
CN112861145B (zh) * 2021-01-06 2023-12-12 华控清交信息科技(北京)有限公司 一种数据处理方法、装置和用于数据处理的装置

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH01288920A (ja) * 1988-05-16 1989-11-21 Nec Corp データソート装置
US5924093A (en) * 1997-05-29 1999-07-13 Ncr Corporation Virtual processor buffered merge sort for parallel applications
JP2000003342A (ja) * 1998-06-16 2000-01-07 Nec Corp ネットワークファイル分散ソート方法およびネットワークファイル分散ソートシステム

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6036350A (en) * 1995-12-20 2000-03-14 Intel Corporation Method of sorting signed numbers and solving absolute differences using packed instructions
US5852826A (en) * 1996-01-26 1998-12-22 Sequent Computer Systems, Inc. Parallel merge sort method and apparatus
JP3196637B2 (ja) * 1996-04-26 2001-08-06 三菱電機株式会社 ソートプロセッサおよびソート処理装置
US5721957A (en) * 1996-06-03 1998-02-24 International Business Machines Corporation Method and system for storing data in cache and retrieving data from cache in a selected one of multiple data formats
US6144986A (en) * 1997-03-27 2000-11-07 Cybersales, Inc. System for sorting in a multiprocessor environment
JP3774324B2 (ja) * 1998-08-03 2006-05-10 株式会社日立製作所 ソート処理システムおよびソート処理の方法
US7047395B2 (en) * 2001-11-13 2006-05-16 Intel Corporation Reordering serial data in a system with parallel processing flows

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH01288920A (ja) * 1988-05-16 1989-11-21 Nec Corp データソート装置
US5924093A (en) * 1997-05-29 1999-07-13 Ncr Corporation Virtual processor buffered merge sort for parallel applications
JP2000003342A (ja) * 1998-06-16 2000-01-07 Nec Corp ネットワークファイル分散ソート方法およびネットワークファイル分散ソートシステム

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9135289B2 (en) 2012-05-30 2015-09-15 International Business Machines Corporation Matching transactions in multi-level records
US9063944B2 (en) 2013-02-21 2015-06-23 International Business Machines Corporation Match window size for matching multi-level transactions between log files
US11200056B2 (en) 2018-02-08 2021-12-14 Nec Corporation Parallel union control device, parallel union control method, and storage medium
WO2023207832A1 (zh) * 2022-04-26 2023-11-02 华为技术有限公司 数据处理装置的控制方法与装置

Also Published As

Publication number Publication date
US20050144167A1 (en) 2005-06-30
JP4171835B2 (ja) 2008-10-29
US7536432B2 (en) 2009-05-19
AU2003231521A1 (en) 2003-11-10
JPWO2003091872A1 (ja) 2005-09-02

Similar Documents

Publication Publication Date Title
WO2003091872A1 (fr) Dispositif de tri par fusion en parallele, procede et programme y relatifs
Davidson et al. Efficient parallel merge sort for fixed and variable length keys
US5487164A (en) Distribution-based replacement selection sorting system
US4575798A (en) External sorting using key value distribution and range formation
CN111292805B (zh) 一种三代测序数据重叠检测方法及系统
CN110837584B (zh) 一种分块并行构造后缀数组的方法及系统
WO2009002750A2 (en) Order preservation in data parallel operations
US20020065793A1 (en) Sorting system and method executed by plural computers for sorting and distributing data to selected output nodes
CN105264488A (zh) 使用数组对来合并有序列表
CN112015366A (zh) 数据排序方法、数据排序装置及数据库系统
Rajasekaran et al. On parallel integer sorting
CN111028897A (zh) 一种基于Hadoop的基因组索引构建的分布式并行计算方法
CN106802787A (zh) 基于GPU排序的MapReduce优化方法
CN115809243A (zh) 基于b树的重叠社区发现方法、装置、设备及存储介质
WO2015143708A1 (zh) 后缀数组的构造方法及装置
JP2009037590A (ja) 信号処理
US20220050664A1 (en) Systems, methods, and devices for the sorting of digital lists
CN112069135A (zh) 一种海量地震数据可视化存储方法
Sibeyn External selection
Martínez Palau Two-way replacement selection
CN116821559B (zh) 用于快速获取一组大数据集中趋势的方法、系统及终端
JP5354606B2 (ja) データ蓄積装置及び方法及びプログラム及びデータ検索装置及び方法及びプログラム
JPH08221254A (ja) マージソート方法及びマージソート装置
Thonangi et al. Permuting data on random-access block storage
Sibeyn External selection

Legal Events

Date Code Title Description
AK Designated states

Kind code of ref document: A1

Designated state(s): AE AG AL AM AT AU AZ BA BB BG BR BY BZ CA CH CN CO CR CU CZ DE DK DM DZ EC EE ES FI GB GD GE GH GM HR HU ID IL IN IS JP KE KG KP KR KZ LC LK LR LS LT LU LV MA MD MG MK MN MW MX MZ NI NO NZ OM PH PL PT RO RU SC SD SE SG SK SL TJ TM TN TR TT TZ UA UG US UZ VC VN YU ZA ZM ZW

AL Designated countries for regional patents

Kind code of ref document: A1

Designated state(s): GH GM KE LS MW MZ SD SL SZ TZ UG ZM ZW AM AZ BY KG KZ MD RU TJ TM AT BE BG CH CY CZ DE DK EE ES FI FR GB GR HU IE IT LU MC NL PT RO SE SI SK TR BF BJ CF CG CI CM GA GN GQ GW ML MR NE SN TD TG

DFPE Request for preliminary examination filed prior to expiration of 19th month from priority date (pct application filed before 20040101)
121 Ep: the epo has been informed by wipo that ep was designated in this application
WWE Wipo information: entry into national phase

Ref document number: 2004501962

Country of ref document: JP

WWE Wipo information: entry into national phase

Ref document number: 10511683

Country of ref document: US

122 Ep: pct application non-entry in european phase