WO2021161532A1 - ループアンローリング処理装置、方法およびプログラム - Google Patents

ループアンローリング処理装置、方法およびプログラム Download PDF

Info

Publication number
WO2021161532A1
WO2021161532A1 PCT/JP2020/005891 JP2020005891W WO2021161532A1 WO 2021161532 A1 WO2021161532 A1 WO 2021161532A1 JP 2020005891 W JP2020005891 W JP 2020005891W WO 2021161532 A1 WO2021161532 A1 WO 2021161532A1
Authority
WO
WIPO (PCT)
Prior art keywords
processing
loop
stages
unroll
arithmetic expression
Prior art date
Application number
PCT/JP2020/005891
Other languages
English (en)
French (fr)
Inventor
善之 大野
Original Assignee
日本電気株式会社
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 日本電気株式会社 filed Critical 日本電気株式会社
Priority to US17/795,952 priority Critical patent/US20230161590A1/en
Priority to JP2022500197A priority patent/JP7302728B2/ja
Priority to PCT/JP2020/005891 priority patent/WO2021161532A1/ja
Publication of WO2021161532A1 publication Critical patent/WO2021161532A1/ja

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/32Address formation of the next instruction, e.g. by incrementing the instruction counter
    • G06F9/322Address formation of the next instruction, e.g. by incrementing the instruction counter for non-sequential address
    • G06F9/325Address formation of the next instruction, e.g. by incrementing the instruction counter for non-sequential address for loops, e.g. loop detection or loop counter
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30003Arrangements for executing specific machine instructions
    • G06F9/30007Arrangements for executing specific machine instructions to perform operations on data operands
    • G06F9/3001Arithmetic instructions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding
    • G06F8/443Optimisation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding
    • G06F8/443Optimisation
    • G06F8/4441Reducing the execution time required by the program code
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/45Exploiting coarse grain parallelism in compilation, i.e. parallelism between groups of instructions
    • G06F8/451Code distribution
    • G06F8/452Loops

Definitions

  • the present invention relates to a loop unrolling processing apparatus that performs loop unrolling for loop processing described in a source program, a loop unrolling processing method, and a loop unrolling processing program.
  • Loop unrolling is to reduce the number of loops compared to the original loop processing by increasing the processing per loop in the loop processing.
  • the number of loops is reduced. Therefore, the number of determination processes for determining whether or not to end the loop processing is also reduced, and as a result, the overhead caused by the determination processing can be reduced.
  • the processing per loop is increased.
  • the value indicating how many times the processing per loop in the original loop processing corresponds to the processing per loop in the case where the processing is increased is referred to as the number of unroll stages.
  • FIG. 14 is a diagram showing an example of the original loop processing that is the target of loop unrolling.
  • the number of loops is 10,000.
  • the value in parentheses representing the array is not an integer, the value in parentheses is regarded as an integer by truncating the decimal point.
  • FIG. 15 is a diagram showing an example of the result of performing loop unrolling with the number of unroll stages set to 4 for the loop processing shown in FIG.
  • FIG. 17 is a schematic diagram showing a tendency of the relationship between the number of unrolling stages and the performance of the program when loop unrolling is performed.
  • this performance there is a processing time of loop processing when loop unrolling is performed. In this case, it can be said that the shorter the processing time of the loop processing is, the better the performance is, and the longer the processing time is, the worse the performance is.
  • Patent Document 1 describes a technique for separately developing a loop having a remainder obtained by dividing the number of loops of the original loop processing by the number of loop unrolling and a loop having the remaining number of loops.
  • the "unrolling" described in Patent Document 1 means loop unrolling
  • the "loop unrolling number” described in Patent Document 1 means the number of unrolling stages.
  • FIG. 1 A specific example of the above technique described in Patent Document 1 is shown in FIG.
  • the upper part shown in FIG. 18 shows the original loop processing, and the lower part shown in FIG. 18 shows the result of applying the above technique described in Patent Document 1 to the loop processing.
  • the arithmetic expression A1 shown in FIG. 18 represents a remainder repeating loop obtained by dividing the loop number N of the original loop processing by the loop unrolling number (that is, the number of unrolling stages, which is 4 in this example). “%” Included in the calculation formula A1 means an operation for deriving the remainder of division.
  • the arithmetic expression A2 shown in FIG. 18 represents the loop processing for the remaining number of times.
  • Patent Document 1 still has room for more efficient processing after loop unrolling.
  • the number of unroll stages is one. That is, in the loop processing represented by the calculation formula A1, the processing amount per loop is the same as the processing amount per loop in the original loop processing (see the upper part of FIG. 18), and the calculation formula A1 represents ". N% 4 ”loop processing causes the same overhead as the loop processing for the same number of times in the original loop processing.
  • an object of the present invention is to provide a loop unrolling processing apparatus, a loop unrolling processing method, and a loop unrolling processing program that can make the processing after loop unrolling more efficient.
  • the loop unrolling processing apparatus has a specific unit for specifying the description location of the arithmetic expression representing the loop processing from the input source program, and N is the number of loops of the loop processing, and the lower limit of the specified number of unroll stages is set. Is L, the upper limit of the specified number of unrolled stages is M, the quotient when N is divided by L is Q, and the remainder when N is divided by L is R, then RQ * (M). When ⁇ L)> 0, it is shown that the processing for one loop in the loop processing is performed RQ * (ML) times, and then the loop processing is performed with the number of unroll stages as M.
  • a generation unit that generates an arithmetic expression including an arithmetic expression indicating that loop processing is performed, and a replacement unit that replaces the arithmetic expression of the description portion specified by the specific unit with an arithmetic expression generated by the generation unit. It is characterized by having.
  • the description location of the arithmetic expression representing the loop processing is specified from the input source program, the number of loops of the loop processing is set to N, and the lower limit of the specified number of unroll stages is set to L.
  • the upper limit of the specified number of unrolled stages is M
  • the quotient when N is divided by L is Q
  • the remainder when N is divided by L is R, RQ * (ML).
  • an arithmetic expression indicating that the processing for one loop in the loop processing is performed RQ * (ML) times, and then the loop processing is performed with the number of unroll stages as M.
  • RQ * (ML)> 0 the number of unroll stages is M, and the loop processing of the number of quotients when R is divided by (ML) is performed, and then R is set to (M).
  • the processing for one loop in which the sum of the remainder and L is the number of unrolling stages is performed, and after that, the loop processing is performed in which the number of unrolling stages is L. It is characterized in that an arithmetic expression including an arithmetic expression indicating to be performed is generated, and the arithmetic expression in the description portion is replaced with the generated arithmetic expression.
  • the loop unrolling processing program is a specific processing that specifies a description location of an arithmetic expression representing a loop processing from a source program input to a computer, and the number of loops of the loop processing is N, and a specified number of unroll stages.
  • the lower limit of is L
  • the upper limit of the specified number of unrolled stages is M
  • the quotient when N is divided by L is Q
  • the remainder when N is divided by L is R
  • RQ * When (ML)> 0, the processing for one loop in the loop processing is performed RQ * (ML) times, and then the loop processing is performed with the number of unroll stages as M.
  • the processing after loop unrolling can be made more efficient.
  • FIG. 1 It is a block diagram which shows the outline of the loop unrolling processing apparatus of this invention. It is a figure which shows the example of the original loop processing which is the target of loop unrolling. It is a figure which shows an example of the result of performing loop unrolling with the number of unroll stages being 4 with respect to the loop processing shown in FIG. It is a figure which shows another example of the result of performing loop unrolling with the number of unroll stages being 4 with respect to the loop processing shown in FIG. It is a schematic diagram which shows the tendency of the relationship between the number of unrolling stages and the performance of a program when loop unrolling is performed. It is a figure which shows the specific example of the technique described in Patent Document 1. FIG.
  • a source program is input to the loop unrolling processing device of each embodiment of the present invention. Then, the loop unrolling processing apparatus of each embodiment generates an arithmetic expression representing the result of performing loop unrolling for the loop processing in the source program. Then, the loop unrolling processing apparatus of each embodiment replaces the arithmetic expression representing the loop processing in the source program with the generated arithmetic expression.
  • FIG. 1 is a block diagram showing an example of a loop unrolling processing apparatus according to the first embodiment of the present invention.
  • the loop unrolling processing device 1 of the first embodiment includes an input unit 2, a specific unit 3, a generation unit 4, and a replacement unit 5.
  • the input unit 2 is an input device for acquiring a source program.
  • the input unit 2 is a data reading device that reads a source program recorded on a data recording medium such as an optical disk, but the input unit 2 is not limited to such a data reading device.
  • the number of unroll stages may be specified in a predetermined format in the input source program.
  • the number of unroll stages may be specified separately from the input of the source program.
  • the number of unrolled stages may be specified by inputting the number of unrolled stages via an input device such as a keyboard (not shown in FIG. 1) separately from the input of the source program.
  • FIG. 2 is a diagram showing an example of an arithmetic expression representing the specification of the number of unroll stages and loop processing in the input source program.
  • the source program also includes arithmetic expressions other than those shown in FIG.
  • FIG. 2 is an example of a predetermined format for specifying the number of unroll stages.
  • FIG. 2 illustrates a case where “4” shown in parentheses in this format is specified as the number of unrolled stages.
  • the specified number of unroll stages is 4 will be described as an example.
  • the predetermined format for specifying the number of unroll stages is described immediately before the arithmetic expression representing the original loop processing.
  • the identification unit 3 specifies the description location of the arithmetic expression representing the loop processing from the input source program. Loop processing is described by rules according to the programming language.
  • the specifying unit 3 may specify an arithmetic expression that matches the loop processing from the source program, and specify the description location of the arithmetic expression. For example, in this example, it is assumed that the loop processing is described in the format of “for () ⁇ ”. In this case, since the arithmetic expressions from the second line to the fourth line shown in FIG. 2 conform to the format of “for () ⁇ ”, the specific part 3 is from the second line to the fourth line shown in FIG. It is determined that the arithmetic expression of is representing the loop processing, and the description location of the arithmetic expression is specified.
  • the specific unit 3 also specifies the description location of the character string for which the number of unrolled stages is specified.
  • the specific unit 3 specifies the description location of the arithmetic expression shown in FIG. 2 in the source program.
  • the generation unit 4 accepts the designation of the number of unroll stages by referring to the character string described in the description location in the source program specified by the specific unit 3. In this example, the generation unit 4 accepts the designation of the number of unroll stages "4" based on the character string in the predetermined format on the first line shown in FIG.
  • the generation unit 4 may accept the designation of the number of unrolled stages by acquiring the number of unrolled stages input via an input device such as a keyboard (not shown in FIG. 1).
  • the generation unit 4 loop unrolls with respect to the loop processing described in the input source program (in this example, the loop processing represented by the arithmetic expressions from the second line to the fourth line shown in FIG. 2). Generates an arithmetic expression that represents the result of performing.
  • FIG. 3 is a diagram showing an example of an arithmetic expression generated by the generation unit 4.
  • the arithmetic expression illustrated in FIG. 3 includes an arithmetic expression X1, an arithmetic expression X2, and an arithmetic expression X3.
  • the arithmetic expression X1 represents an exceptional case in which the loop count N (see FIG. 2) of the original loop processing described in the input source program is smaller than the specified number of unroll stages. Therefore, the processing represented by the arithmetic expression X1 will be described later.
  • the processing represented by the arithmetic expression X2 will be described.
  • the arithmetic expression X2 is a combination of the remainder and the specified number of unrolled stages when the remainder when the number of loops N of the original loop processing described in the source program is divided by the specified number of unrolled stages is other than 0. It means that the processing for one loop with the sum as the number of unrolling stages is performed.
  • the remainder when the number of loops N of the original loop processing is divided by the specified number of unroll stages (4 in this example) is expressed as "N% 4".
  • the remainder other than 0 is any of "1", "2", and "3".
  • the processing represented by the arithmetic expression X3 indicates that the loop processing is performed with the specified number of unroll stages.
  • FIG. 4 is a schematic diagram showing the process represented by the arithmetic expression X2 and the process represented by the arithmetic expression X3 executed thereafter.
  • the process 51 schematically shown in FIG. 4 is the process represented by the arithmetic expression X2 (see FIG. 3).
  • the process 51 is a process for one loop in which the sum of the remainder when the number of loops of the original loop process is divided by the specified number of unrolled stages and the specified number of unrolled stages is used as the number of unrolled stages.
  • the process 52 schematically shown in FIG. 4 is the process represented by the arithmetic expression X3 (see FIG. 3).
  • the process 52 is executed after the process 51.
  • the process 52 is a loop process with a specified number of unroll stages.
  • the process represented by the arithmetic expression X1 shown in FIG. 3 will be described.
  • the loop count N of the original loop processing (see FIG. 2) described in the input source program is smaller than the specified number of unroll stages, the arithmetic expression X1 performs the same loop processing as the original loop processing. It represents what to do.
  • Calculation formula X2 and later represent the processing to be executed when the number of loops of the original processing is equal to or greater than the specified number of unroll stages. Therefore, when the process represented by the arithmetic expression X1 is executed, the process represented by the arithmetic expression X2 and the process represented by the arithmetic expression X3 are not executed.
  • the arithmetic expressions X1, X2, X3 are examples, and the specific contents of the arithmetic expressions X1, X2, X3 change according to the original loop processing.
  • the generation unit 4 generates an arithmetic expression including an arithmetic expression corresponding to each of the arithmetic expressions X1, X2, and X3.
  • the generation unit 4 uses the arithmetic expression X1 instead of the arithmetic expression X1.
  • An arithmetic expression indicating that the processing for one loop is performed with the number of loops as the number of unroll stages may be defined, and an arithmetic expression including the arithmetic expression and the arithmetic expression corresponding to each of the arithmetic expressions X2 and X3 may be generated.
  • the replacement unit 5 replaces the arithmetic expression of the description part (that is, the description part of the original loop processing) in the source program specified by the specific unit 3 with the arithmetic expression generated by the generation unit 4.
  • the calculation formula generated by the generation unit 4 together with the character string. Replace with.
  • the specific unit 3, the generation unit 4, and the replacement unit 5 are realized by, for example, a computer CPU (Central Processing Unit) that operates according to a loop unrolling processing program.
  • the CPU may read a loop unrolling processing program from a program recording medium such as a program storage device of a computer, and operate as a specific unit 3, a generation unit 4, and a replacement unit 5 according to the loop unrolling processing program.
  • FIG. 5 is a flowchart showing an example of the processing progress of the first embodiment of the present invention.
  • the specific unit 3 specifies the description location of the arithmetic expression representing the loop processing from the input source program (step S1). If the specific unit 3 determines that the arithmetic expression representing the loop processing does not exist in the source program, the processing may be terminated at that point. This point is the same in the second embodiment described later.
  • step S1 the generation unit 4 accepts the designation of the number of unroll stages (step S2).
  • the generation unit 4 generates an arithmetic expression including the arithmetic expression corresponding to each of the arithmetic expressions X1, X2, X3 (see FIG. 3) (step S3).
  • the replacement unit 5 replaces the calculation formula of the description portion specified in step S1 with the calculation formula generated in step S3 (step S4). If a character string in a predetermined format for specifying the number of unroll stages is described immediately before the arithmetic expression representing the original loop processing, the replacement unit 5 is generated in step S3 together with the character string. Replace with an arithmetic expression.
  • steps S1 to S4 may be executed for each description place.
  • the processing based on the result of loop unrolling in the present embodiment the sum of the remainder when the number of loops of the original loop processing is divided by the specified number of unroll stages and the specified number of unroll stages. Is the number of unrolling stages, the processing 51 for one loop (see FIG. 4) is performed, and then the loop processing is performed with the specified number of unrolling stages. Except for the case where the exceptional processing shown by the arithmetic expression X1 (see FIG. 3) is performed and the case where 1 is specified as the number of unroll stages, the loop processing is not performed with the number of unroll stages set to 1. Therefore, according to the present embodiment, the processing after loop unrolling can be made more efficient.
  • Patent Document 1 The technique described in Patent Document 1 and the first embodiment of the present application are compared using specific numerical values. It is assumed that the processing time for one loop processing for each number of unrolling stages is the time shown in FIG. Further, it is assumed that the number of loops of the original process is 7 and the number of designated unroll stages is 4. In this case, the quotient when 7 is divided by 4 is 1 and the remainder is 3.
  • the value of the specified number of unroll stages is determined by, for example, the programmer who creates the source program.
  • the programmer applies various unrolling stages to a known loop unrolling (the technique described in Patent Document 1 may be used), specifies the number of unrolling stages when good performance can be obtained, and determines the number of unrolling stages. It may be specified for the loop unrolling processing device 1 of the present embodiment.
  • Embodiment 2 the processing for one loop in which the sum of the remainder when the number of loops of the original loop processing is divided by the specified number of unrolled stages and the specified number of unrolled stages is used as the number of unrolled stages is performed.
  • An arithmetic expression including the representative arithmetic expression (in the example shown in FIG. 3, the arithmetic expression X2) is generated.
  • the loop unrolling processing apparatus accepts the designation of the lower limit of the number of unroll stages and the upper limit of the number of unroll stages.
  • FIG. 1 the loop unrolling processing apparatus of the second embodiment of the present invention can be represented by the block diagram shown in FIG. 1 like the loop unrolling processing apparatus of the first embodiment, FIG. 1 is used. The second embodiment will be described.
  • the input unit 2 is the same as the input unit 2 in the first embodiment.
  • the lower limit of the number of unrolled stages and the upper limit of the number of unrolled stages may be specified by a predetermined format.
  • the lower limit of the number of unroll stages and the upper limit of the number of unroll stages may be specified separately from the input of the source program.
  • the lower limit of the number of unroll stages and the upper limit of the number of unroll stages are input via an input device such as a keyboard (not shown in FIG. 1) separately from the input of the source program, so that the lower limit of the number of unroll stages and the upper limit of the number of unroll stages are input. May be specified.
  • FIG. 7 is a diagram showing an example of an arithmetic expression representing the specification of the lower limit of the number of unroll stages and the upper limit of the number of unroll stages and the loop processing in the input source program.
  • the source program also includes arithmetic expressions other than those shown in FIG. 7.
  • “#Pragma unroll (,)” shown in FIG. 7 is an example of a predetermined format for designating the lower limit of the number of unroll stages and the upper limit of the number of unroll stages.
  • FIG. 7 illustrates a case where “8” and “11” shown in parentheses in this format are specified as the lower limit of the number of unrolled stages and the upper limit of the number of unrolled stages, respectively. Further, in the following description, it is assumed that the predetermined format for specifying the lower limit of the number of unroll stages and the upper limit of the number of unroll stages is described immediately before the arithmetic expression representing the original loop processing.
  • the identification unit 3 specifies the description location of the arithmetic expression representing the loop processing from the input source program. This operation is the same as the operation of the specific unit 3 in the first embodiment, and the description thereof will be omitted.
  • the specific unit 3 also specifies the specified description location.
  • the specific unit 3 specifies the description location of the arithmetic expression shown in FIG. 7 in the source program.
  • the generation unit 4 accepts the designation of the lower limit of the number of unroll stages and the upper limit of the number of unroll stages by referring to the character string described in the description location in the source program specified by the specific unit 3. In this example, the generation unit 4 accepts the designation of "8" as the lower limit of the number of unrolled stages and specifies "11" as the upper limit of the number of unrolled stages based on the character string in the predetermined format on the first line shown in FIG. Accept.
  • the generation unit 4 may accept the designation of the lower limit of the number of unroll stages and the upper limit of the number of unroll stages by acquiring the value input via an input device such as a keyboard (not shown in FIG. 1).
  • the generation unit 4 loop unrolls with respect to the loop processing described in the input source program (in this example, the loop processing represented by the arithmetic expressions from the second line to the fourth line shown in FIG. 7). Generates an arithmetic expression that represents the result of performing.
  • FIG. 8 is a diagram showing an example of an arithmetic expression generated by the generation unit 4 of the second embodiment.
  • the arithmetic expression illustrated in FIG. 8 includes the arithmetic expression Y0, the arithmetic expression Y1, and the arithmetic expression Y2.
  • the arithmetic expression Y1 includes the arithmetic expression Y11 and the arithmetic expression Y12.
  • the calculation formula Y2 includes a calculation formula Y21, a calculation formula Y22, and a calculation formula Y23.
  • the number of loops of the original loop processing described in the source program is N. Further, the lower limit of the designated number of unroll stages is L, and the upper limit of the designated number of unroll stages is M. Further, let Q be the quotient when N is divided by L, and let R be the remainder when N is divided by L.
  • the arithmetic expression Y0 represents a process of substituting the lower limit of the specified number of unrolled stages into L, a process of substituting the upper limit of the specified number of unrolled stages into M, and a process of calculating Q and R.
  • the calculation formula Y1 represents the processing when RQ * (ML)> 0, and the calculation formula Y2 represents the processing when RQ * (ML)> 0.
  • RQ * (ML) is represented by the variable S.
  • the arithmetic expression Y2 includes the arithmetic expression Y21, the arithmetic expression Y22, and the arithmetic expression Y23.
  • the processing represented by the arithmetic expression Y21 will be described.
  • the calculation formula Y21 performs loop processing for the number of quotients (in FIG. 8, described as R / (ML)) when R is divided by (ML), where M is the number of unroll stages. Represents.
  • the arithmetic expression Y2 shown in FIG. 8 indicates that the processing represented by the arithmetic expression Y22 is performed after the processing represented by the arithmetic expression Y21. Then, in the calculation formula Y22, when the remainder when R is divided by (ML) (in FIG. 8, it is described as R% (ML)) is other than 0, the remainder and L are used. Indicates that the processing for one loop is performed with the sum of the unroll stages as the number of unroll stages.
  • the calculation formula Y2 represents that the processing represented by the calculation formula Y23 is performed after the processing represented by the calculation formula Y22. Then, the arithmetic expression Y23 represents that the loop processing is performed with the number of unroll stages as L.
  • the processing indicated by the calculation formula Y22 indicates that the processing is not performed when the remainder (R% (ML)) when R is divided by (ML) is 0. In this case, the processing is not performed.
  • the process represented by the arithmetic expression Y21 the process represented by the arithmetic expression Y23 is performed.
  • FIG. 9 is a schematic diagram showing the processing represented by the arithmetic expression Y2.
  • the process 61 schematically shown in FIG. 9 is the process represented by the arithmetic expression Y21 (see FIG. 8) included in the arithmetic expression Y2.
  • the process 61 is an R / (M-L) loop process in which the number of unroll stages is M.
  • R / (M-L) is the quotient when R is divided by (ML) and is an integer.
  • the process 62 schematically shown in FIG. 9 is the process represented by the arithmetic expression Y22 (see FIG. 8) included in the arithmetic expression Y2.
  • the process 62 is a process for one loop in which the number of unroll stages is L + R% (M-L).
  • R% (ML) is the remainder when R is divided by (ML).
  • the process 63 schematically shown in FIG. 4 is the process represented by the arithmetic expression Y23 (see FIG. 8) included in the arithmetic expression Y2.
  • the process 63 is executed after the process 62.
  • the process 63 is a loop process at the lower limit L of the number of unroll stages.
  • the processing for the number of stages R is divided into the processing for the number of stages (ML), and the processing for the number of stages (ML) is loop processing. It can be said that it is distributed to each time. Further, the processing corresponding to the remainder when the processing for the number of stages R is divided into the processing for the number of stages (ML) (processing for the number of stages R% (ML)) is allocated to the processing for one loop of the processing 62. Will be done. Further, the process 63 is a loop process in which such allocation is not performed.
  • the arithmetic expression Y1 includes the arithmetic expression Y11 and the arithmetic expression Y12.
  • the arithmetic expression Y1 shows the processing when the remainder R when the loop number N of the original loop processing is divided by the lower limit L of the number of unroll stages is large and cannot be distributed to each loop processing.
  • the arithmetic expression Y11 (see FIG. 8) included in the arithmetic expression Y1 indicates that the processing for one loop in the original loop processing is performed RQ * (ML) times.
  • the arithmetic expression Y1 shown in FIG. 8 indicates that the processing represented by the arithmetic expression Y12 is performed after the processing represented by the arithmetic expression Y11. Then, the arithmetic expression Y12 represents that the loop processing is performed with the number of unroll stages as M. In the above example, when the number of unroll stages is M, the number of loops for loop processing is one.
  • the process 71 is a process in which the process for one loop in the original loop process is performed once by RQ * (ML).
  • the calculation formulas Y0, Y1, Y2 shown in FIG. 8 are examples, and the specific contents of the calculation formulas Y0, Y1, Y2 change according to the original loop processing.
  • the generation unit 4 of the second embodiment generates an arithmetic expression including the arithmetic expression corresponding to each of the arithmetic expressions Y0, Y1, and Y2.
  • the replacement unit 5 replaces the arithmetic expression of the description part (that is, the description part of the original loop processing) in the source program specified by the specific unit 3 with the arithmetic expression generated by the generation unit 4.
  • the character string is also generated. It is replaced with the arithmetic expression generated by the part 4.
  • FIG. 11 is a flowchart showing an example of the processing progress of the second embodiment of the present invention.
  • Step S1 is the same as step S1 (see FIG. 5) in the first embodiment.
  • step S1 the generation unit 4 accepts the designation of the lower limit of the number of unroll stages and the upper limit of the number of unroll stages (step S12).
  • the generation unit 4 generates an arithmetic expression including the arithmetic expression corresponding to each of the arithmetic expressions Y0, Y1, Y2 (see FIG. 8) (step S13).
  • the replacement unit 5 replaces the calculation formula of the description portion specified in step S1 with the calculation formula generated in step S13 (step S14). If a character string in a predetermined format for specifying the lower limit of the number of unroll stages and the upper limit of the number of unroll stages is described immediately before the arithmetic expression representing the original loop processing, the replacement unit 5 also includes the character string. Then, it is replaced with the arithmetic expression generated in step S13.
  • steps S1 to S14 may be executed for each description place.
  • loop processing is performed for the number of quotients when R is divided by (ML), where M is the number of unroll stages, and then loop processing is performed.
  • the sum of the remainder when R is divided by (ML) and the lower limit L of the number of unroll stages is used as the number of unroll stages for one loop, and then the loop processing is performed with the number of unroll stages as L. Therefore, the loop processing is not performed with the number of unroll stages set to 1, except in an exceptional case where the processing for the R stage cannot be distributed to each loop processing or when 1 is specified as the lower limit of the number of unroll stages. .. Therefore, according to the present embodiment, the processing after loop unrolling can be made more efficient.
  • the number of unroll stages does not become larger than the upper limit M. Therefore, it is possible to prevent the number of unroll stages from becoming too large and the performance of the execution program from deteriorating.
  • the loop unrolling processing apparatus 1 may record the rewritten source program on the data recording medium after step S4 (see FIG. 5) or after step S14 (see FIG. 11). good. Further, the loop unrolling processing device 1 may generate an execution program based on the rewritten source program.
  • FIG. 12 is a schematic block diagram showing a configuration example of a computer according to the loop unrolling processing device 1 according to each embodiment of the present invention.
  • the computer 1000 includes a CPU 1001, a main storage device 1002, an auxiliary storage device 1003, an interface 1004, and a data reading device 1005 that reads a source program recorded on a data recording medium.
  • the loop unrolling processing device 1 of each embodiment of the present invention is realized by the computer 1000.
  • the operation of the loop unrolling processing device 1 is stored in the auxiliary storage device 1003 in the form of a program (loop unrolling processing program).
  • the CPU 1001 reads a program from the auxiliary storage device 1003, deploys it to the main storage device 1002, and executes the processes described in each of the above embodiments according to the program.
  • the input unit 2 is realized by the data reading device 1005.
  • the specific unit 3, the generation unit 4, and the replacement unit 5 are realized by the CPU 1001.
  • Auxiliary storage 1003 is an example of a non-temporary tangible medium.
  • Other examples of non-temporary tangible media include magnetic disks, magneto-optical disks, CD-ROMs (Compact Disk Read Only Memory), DVD-ROMs (Digital Versatile Disk Read Only Memory), which are connected via interface 1004. Examples include semiconductor memory.
  • the distributed computer 1000 may expand the program to the main storage device 1002 and execute the process described in the above embodiment according to the program. ..
  • each component may be realized by a general-purpose or dedicated circuit (circuitry), a processor, or a combination thereof. These may be composed of a single chip or may be composed of a plurality of chips connected via a bus. A part or all of each component may be realized by a combination of the above-mentioned circuit or the like and a program.
  • the plurality of information processing devices and circuits may be centrally arranged or distributed.
  • the information processing device, the circuit, and the like may be realized as a form in which each is connected via a communication network, such as a client-and-server system and a cloud computing system.
  • FIG. 13 is a block diagram showing an outline of the loop unrolling processing apparatus of the present invention.
  • the loop unrolling processing apparatus includes a specific unit 3, a generation unit 4, and a replacement unit 5.
  • the identification unit 3 specifies the description location of the arithmetic expression representing the loop processing from the input source program.
  • the generation unit 4 sets the sum of the remainder and the specified number of unrolled stages as the number of unrolled stages when the remainder when the number of loops of the loop processing is divided by the specified number of unrolled stages is other than 0. Generates an arithmetic expression indicating that the processing for one time is performed and then the loop processing is performed with the specified number of unroll stages.
  • the replacement unit 5 replaces the arithmetic expression of the description portion specified by the specific unit 3 with the arithmetic expression generated by the generation unit 4.
  • the generation unit 4 uses an arithmetic expression indicating that the same loop processing as the loop processing is performed.
  • An arithmetic expression including may be generated.
  • the generation unit 4 performs processing for one loop with the number of loops as the number of unroll stages.
  • An arithmetic expression including an arithmetic expression indicating that may be generated.
  • the generation unit 4 may accept the designation of the number of unroll stages in a predetermined format described in the input source program.
  • the generation unit 4 shown in FIG. 13 may perform the following operations. That is, the generation unit 4 sets the number of loops of the original loop processing to N, sets the lower limit of the specified number of unroll stages to L, sets the upper limit of the specified number of unroll stages to M, and divides N by L to obtain the quotient.
  • Q is defined and the remainder when N is divided by L is R, and RQ * (ML)> 0, the processing for one loop in the original loop processing is RQ *.
  • An arithmetic expression indicating that the loop processing is performed (ML) times, and then the loop processing is performed with the number of unroll stages as M, and when RQ * (ML)> 0, the number of unroll stages is set as M.
  • the generation unit 4 may accept the designation of the lower limit of the number of unroll stages and the upper limit of the number of unroll stages in a predetermined format described in the input source program.
  • the present invention is suitably applicable to a loop unrolling processing apparatus, method and program that performs loop unrolling for the loop processing described in the source program.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Computational Mathematics (AREA)
  • Mathematical Analysis (AREA)
  • Mathematical Optimization (AREA)
  • Pure & Applied Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Complex Calculations (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

生成部4は、元のループ処理のループ回数をNとし、指定されたアンロール段数の下限をLとし、指定されたアンロール段数の上限をMとし、NをLで除算した際の商をQとし、NをLで除算した際の余りをRとしたときに、R-Q*(M-L)>0である場合に、元のループ処理におけるループ1回分の処理をR-Q*(M-L)回行うこと、および、その後に、アンロール段数をMとしてループ処理を行うことを示す演算式と、R-Q*(M-L)>0でない場合に、アンロール段数をMとして、Rを(M-L)で除算した際の商の回数のループ処理を行うこと、その後、Rを(M-L)で除算した際の余りが0以外である場合に当該余りとLとの和をアンロール段数とするループ1回分の処理を行うこと、および、その後に、アンロール段数をLとしてループ処理を行うことを示す演算式とを含む演算式を生成する。

Description

ループアンローリング処理装置、方法およびプログラム
 本発明は、ソースプログラム内に記述されたループ処理に対してループアンローリングを行うループアンローリング処理装置、ループアンローリング処理方法、および、ループアンローリング処理プログラムに関する。
 ループアンローリングとは、ループ処理におけるループ1回当たりの処理を増やすことによって、元のループ処理よりもループ回数を減少させることである。
 ループアンローリングを行うことによって、ループ回数が減少する。従って、ループ処理を終了するか否かを判定する判定処理の回数も減少し、その結果、その判定処理に起因するオーバヘッドを減少させることができる。
 上記のように、ループアンローリングでは、ループ1回当たりの処理を増やす。処理を増やした場合におけるループ1回当たりの処理が、元のループ処理におけるループ1回当たりの処理の何回分に相当するかを示す値をアンロール段数と称する。
 以下に、ループアンローリングの具体例を示す。図14は、ループアンローリングの対象となる元のループ処理の例を示す図である。図14に示すループ処理では、ループ回数は10000回である。
 また、配列を表す括弧内の値が整数でない場合には、小数点以下を切り捨てることによって、括弧内の値を整数とみなす。
 図15は、図14に示すループ処理に対して、アンロール段数を4としてループアンローリングを行った結果の一例を示す図である。図15に示す処理では、ループ1回当たりの処理を、図14に示すループ1回当たりの処理よりも増加させ、ループ回数を10000/4=2500回に減少させている。また、図15に示す例では、iの値を4ずつ増加させながら、ループ処理を実行する。
 ループアンローリングの結果は1種類に限定されるわけではない。図16は、図14に示すループ処理に対して、アンロール段数を4としてループアンローリングを行った結果の他の例を示す図である。図16に示す例でも、ループ回数を10000/4=2500回に減少させている。また、図16に示す例では、jの値を1ずつ増加させながら、ループ処理を実行する。
 図15および図16に示す例では、図14に示すループ処理に比べて、ループ回数を減少させているので、ループ処理を終了するか否かを判定する判定処理に起因するオーバヘッドを減少できる。
 また、前述のように、配列を表す括弧内の値が整数でない場合には、小数点以下を切り捨てることによって、括弧内の値を整数とみなす。従って、図16に示す例において、B[(4*j+0)/2]と、B[(4*j+1)/2]は同一の値となる。同様に、図16に示す例において、B[(4*j+2)/2]と、B[(4*j+3)/2]は同一の値となる。従って、例えば、B[(4*j+0)/2]およびC[4*j+0]の値を読み込んで、A[4*j+0] = B[(4*j+0)/2] + C[4*j+0]の計算を行った後、A[4*j+1]
= B[(4*j+1)/2] + C[4*j+1]の計算を行う際には、B[(4*j+1)/2]の値を読み込む必要はない。
 図17は、アンロール段数と、ループアンローリングを行った場合のプログラムの性能との関係の傾向を示す模式図である。この性能の具体例の1つとして、ループアンローリングを行った場合のループ処理の処理時間が挙げられる。この場合、ループ処理の処理時間が短いほど性能が良いと言え、処理時間が長いほど性能が悪いと言える。
 図17に示すように、一般的に、アンロール段数を増加させるにつれ、性能も上昇する。しかし、アンロール段数を増加させ過ぎると、性能が悪化する。アンロール段数を増加させ過ぎると性能が悪化する理由は、ループ1回分の処理量が多くなり過ぎて、レジスタの容量が不足する状態となり、レジスタからメモリに移動するデータが増えるためであると考えられる。
 特許文献1には、元のループ処理のループ回数をループ展開回数で割った余りの繰り返しループと、残りの回数分のループとを分けて展開する技術が記載されている。なお、特許文献1に記載の「展開」とは、ループアンローリングのことであり、特許文献1に記載の「ループ展開回数」とは、アンロール段数のことである。特許文献1に記載された上記の技術の具体例を、図18に示す。
 図18に示す上段は、元のループ処理を表し、図18に示す下段はそのループ処理に対して特許文献1に記載された上記の技術を適用した結果を表す。図18に示す演算式A1は、元のループ処理のループ回数Nをループ展開回数(すなわち、アンロール段数。本例では4とする。)で割った余りの繰り返しループを表す。演算式A1に含まれる“% ”は、除算の余りを導出する演算を意味する。図18に示す演算式A2は、残りの回数分のループ処理を表す。
特開平4-344535号公報
 特許文献1に記載された上記の技術には、ループアンローリング後の処理をより効率的にする余地がまだある。図18に示す演算式A1が示すループ処理では、アンロール段数が1段となっている。すなわち、演算式A1が示すループ処理では、ループ1回当たりの処理量が、元のループ処理(図18の上段を参照)におけるループ1回当たりの処理量と変わらず、演算式A1が表す“N%4 ”回分のループ処理では、元のループ処理における同じ回数分のループ処理と同様のオーバヘッドが生じる。
 そこで、本発明は、ループアンローリング後の処理をより効率化することができるループアンローリング処理装置、ループアンローリング処理方法、および、ループアンローリング処理プログラムを提供することを目的とする。
 本発明によるループアンローリング処理装置は、入力されたソースプログラムから、ループ処理を表す演算式の記述箇所を特定する特定部と、前記ループ処理のループ回数をNとし、指定されたアンロール段数の下限をLとし、指定されたアンロール段数の上限をMとし、NをLで除算した際の商をQとし、NをLで除算した際の余りをRとしたときに、R-Q*(M-L)>0である場合に、前記ループ処理におけるループ1回分の処理をR-Q*(M-L)回行うこと、および、その後に、アンロール段数をMとしてループ処理を行うことを示す演算式と、R-Q*(M-L)>0でない場合に、アンロール段数をMとして、Rを(M-L)で除算した際の商の回数のループ処理を行うこと、その後、Rを(M-L)で除算した際の余りが0以外である場合に当該余りとLとの和をアンロール段数とするループ1回分の処理を行うこと、および、その後に、アンロール段数をLとしてループ処理を行うことを示す演算式とを含む演算式を生成する生成部と、前記特定部によって特定された前記記述箇所の演算式を、前記生成部によって生成された演算式に置き換える置き換え部とを備えることを特徴とする。
 本発明によるループアンローリング処理方法は、入力されたソースプログラムから、ループ処理を表す演算式の記述箇所を特定し、前記ループ処理のループ回数をNとし、指定されたアンロール段数の下限をLとし、指定されたアンロール段数の上限をMとし、NをLで除算した際の商をQとし、NをLで除算した際の余りをRとしたときに、R-Q*(M-L)>0である場合に、前記ループ処理におけるループ1回分の処理をR-Q*(M-L)回行うこと、および、その後に、アンロール段数をMとしてループ処理を行うことを示す演算式と、R-Q*(M-L)>0でない場合に、アンロール段数をMとして、Rを(M-L)で除算した際の商の回数のループ処理を行うこと、その後、Rを(M-L)で除算した際の余りが0以外である場合に当該余りとLとの和をアンロール段数とするループ1回分の処理を行うこと、および、その後に、アンロール段数をLとしてループ処理を行うことを示す演算式とを含む演算式を生成し、前記記述箇所の演算式を、生成した演算式に置き換えることを特徴とする。
 本発明によるループアンローリング処理プログラムは、コンピュータに、入力されたソースプログラムから、ループ処理を表す演算式の記述箇所を特定する特定処理、前記ループ処理のループ回数をNとし、指定されたアンロール段数の下限をLとし、指定されたアンロール段数の上限をMとし、NをLで除算した際の商をQとし、NをLで除算した際の余りをRとしたときに、R-Q*(M-L)>0である場合に、前記ループ処理におけるループ1回分の処理をR-Q*(M-L)回行うこと、および、その後に、アンロール段数をMとしてループ処理を行うことを示す演算式と、R-Q*(M-L)>0でない場合に、アンロール段数をMとして、Rを(M-L)で除算した際の商の回数のループ処理を行うこと、その後、Rを(M-L)で除算した際の余りが0以外である場合に当該余りとLとの和をアンロール段数とするループ1回分の処理を行うこと、および、その後に、アンロール段数をLとしてループ処理を行うことを示す演算式とを含む演算式を生成する生成処理、および、前記特定処理で特定された前記記述箇所の演算式を、前記生成処理で生成された演算式に置き換える置き換え処理を実行させることを特徴とする。
 本発明によれば、ループアンローリング後の処理をより効率化することができる。
本発明の第1の実施形態のループアンローリング処理装置の例を表すブロック図である。 入力されるソースプログラム内における、アンロール段数の指定およびループ処理を表す演算式の例を示す図である。 生成部が生成する演算式の例を示す図である。 演算式X2が表す処理、および、その後に実行される演算式X3が表す処理を示す模式図である。 本発明の第1の実施形態の処理経過の例を示すフローチャートである。 アンロール段数毎のループ処理1回分の処理時間の例を示す図である。 入力されるソースプログラム内における、アンロール段数の下限およびアンロール段数の上限の指定並びにループ処理を表す演算式の例を示す図である。 第2の実施形態の生成部が生成する演算式の例を示す図である。 演算式Y2が表す処理を示す模式図である。 演算式Y1が表す処理の一例を示す模式図である。 本発明の第2の実施形態の処理経過の例を示すフローチャートである。 本発明の各実施形態のループアンローリング処理装置に係るコンピュータの構成例を示す概略ブロック図である。 本発明のループアンローリング処理装置の概要を示すブロック図である。 ループアンローリングの対象となる元のループ処理の例を示す図である。 図14に示すループ処理に対して、アンロール段数を4としてループアンローリングを行った結果の一例を示す図である。 図14に示すループ処理に対して、アンロール段数を4としてループアンローリングを行った結果の他の例を示す図である。 アンロール段数と、ループアンローリングを行った場合のプログラムの性能との関係の傾向を示す模式図である。 特許文献1に記載された技術の具体例を示す図である。
 以下、本発明の実施形態を図面を参照して説明する。
 本発明の各実施形態のループアンローリング処理装置には、ソースプログラムが入力される。そして、各実施形態のループアンローリング処理装置は、ソースプログラム内のループ処理に対してループアンローリングを行った結果を表す演算式を生成する。そして、各実施形態のループアンローリング処理装置は、ソースプログラム内のループ処理を表す演算式を、生成した演算式に置き換える。
実施形態1.
 図1は、本発明の第1の実施形態のループアンローリング処理装置の例を表すブロック図である。第1の実施形態のループアンローリング処理装置1は、入力部2と、特定部3と、生成部4と、置き換え部5とを備える。
 入力部2は、ソースプログラムを取得するための入力装置である。入力部2は、例えば、光学ディスク等のデータ記録媒体に記録されたソースプログラムを読み込むデータ読み込み装置であるが、入力部2は、このようなデータ読み込み装置に限定されない。
 入力部2を介してループアンローリング処理装置1に入力されるソースプログラムは、ループ処理を含んでいるものとする。
 また、入力されるソースプログラム内で、所定の書式によって、アンロール段数が指定されていてもよい。
 アンロール段数の指定は、ソースプログラムの入力とは別に行われてもよい。例えば、ソースプログラムの入力とは別に、キーボード等の入力デバイス(図1において図示略)を介してアンロール段数が入力されることによって、アンロール段数が指定されてもよい。
 以下に示す例では、入力されるソースプログラム内で、所定の書式によって、アンロール段数が指定されていている場合を例にして説明する。
 図2は、入力されるソースプログラム内における、アンロール段数の指定およびループ処理を表す演算式の例を示す図である。ソースプログラムには、図2に示す演算式以外の演算式も含まれている。
 図2に示す“#pragma unroll()”は、アンロール段数を指定するための所定の書式の一例である。図2では、この書式の括弧内に示された“4”がアンロール段数として指定された場合を例示している。以下、指定されたアンロール段数が4である場合を例にして説明する。また、以下の説明では、アンロール段数を指定するための所定の書式は、元のループ処理を表す演算式の直前に記述されるものとする。
 特定部3は、入力されたソースプログラムから、ループ処理を表す演算式の記述箇所を特定する。ループ処理は、プログラム言語に応じた規則で記述されている。特定部3は、ループ処理に合致する演算式を、ソースプログラム中から特定し、その演算式の記述箇所を特定すればよい。例えば、本例では、ループ処理が“for () {}”という書式で記述されるものとする。この場合、図2に示す2行目から4行目までの演算式が“for () {}”という書式に適合するので、特定部3は、図2に示す2行目から4行目までの演算式がループ処理を表していると判定し、その演算式の記述箇所を特定する。
 さらに、ソースプログラム内でアンロール段数が指定されている場合には、特定部3は、アンロール段数を指定している文字列の記述箇所も特定する。
 本例では、特定部3は、ソースプログラム内で、図2に示す演算式の記述箇所を特定する。
 生成部4は、特定部3が特定したソースプログラム内の記述箇所に記述された文字列を参照することによって、アンロール段数の指定を受け付ける。本例では、生成部4は、図2に示す1行目の所定の書式の文字列に基づいて、アンロール段数“4”の指定を受け付ける。
 なお、生成部4は、キーボード等の入力デバイス(図1において図示略)を介して入力されたアンロール段数を取得することによって、アンロール段数の指定を受け付けてもよい。
 また、生成部4は、入力されたソースプログラム内に記述されたループ処理(本例では、図2に示す2行目から4行目までの演算式が表すループ処理)に対してループアンローリングを行った結果を表す演算式を生成する。
 図3は、生成部4が生成する演算式の例を示す図である。図3に例示する演算式は演算式X1と、演算式X2と、演算式X3とを含む。
 演算式X1は、入力されたソースプログラムに記述された元のループ処理のループ回数N(図2参照)が指定されたアンロール段数よりも小さいという例外的な場合の処理を表す。そのため、演算式X1が表す処理については後述する。
 演算式X2が表す処理について説明する。演算式X2は、ソースプログラムに記述された元のループ処理のループ回数Nを、指定されたアンロール段数で除算した際の余りが0以外である場合に、その余りと指定されたアンロール段数との和をアンロール段数とするループ1回分の処理を行うことを表している。
 演算式X2において、元のループ処理のループ回数Nを、指定されたアンロール段数(本例では4)で除算した際の余りは、“N%4 ”と表される。この場合、0以外の余りは、“1”,“2”,“3”のいずれかである。余りが1の場合を例にして説明すると、余りと、指定されたアンロール段数“4”との和は、1+4=5となる。従って、この場合には以下に示すアンロール段数が5のループ1回分の処理を行うことを、演算式X2は表している。
{
  A[i+0]
= B[i+0] + C[i+0];
  A[i+1]
= B[i+1] + C[i+1];
  A[i+2]
= B[i+2] + C[i+2];
  A[i+3]
= B[i+3] + C[i+3];
  A[i+4]
= B[i+4] + C[i+4];
 
i+=5
}
 同様に、演算式X2は、余りが2である場合にはアンロール段数が6のループ1回分の処理を行い、余りが3である場合にはアンロール段数が7のループ1回分の処理を行うことを表している。
 そして、図3に示す演算式は、演算式X2が表す処理の後に、演算式X3が表す処理を行うことを表している。また、演算式X2は、N%4=0 である場合には(すなわち、元のループ処理のループ回数Nを、指定されたアンロール段数で除算した余りが0である場合には)、処理を行わないことを表し、次の演算式X3が表す処理を行うことになる。
 演算式X3が表す処理は、指定されたアンロール段数でループ処理を行うことを表している。
 図4は、演算式X2が表す処理、および、その後に実行される演算式X3が表す処理を示す模式図である。
 図4に模式的に示す処理51は、演算式X2(図3参照)が表す処理である。処理51は、元のループ処理のループ回数を、指定されたアンロール段数で除算した際の余りと、その指定されたアンロール段数の和をアンロール段数とするループ1回分の処理である。
 図4に模式的に示す処理52は、演算式X3(図3参照)が表す処理である。処理52は、処理51の後に実行される。処理52は、指定されたアンロール段数でのループ処理である。
 なお、元のループ処理のループ回数を、指定されたアンロール段数で除算した際の余りが0である場合には、処理51は実行されずに、処理52が実行されることになる。
 次に、図3に示す演算式X1が表す処理について説明する。演算式X1は、入力されたソースプログラムに記述された元のループ処理(図2参照)のループ回数Nが、指定されたアンロール段数よりも小さい場合には、元のループ処理と同じループ処理を行うことを表している。
 演算式X2以降は、元の処理のループ回数が指定されたアンロール段数以上の場合に実行される処理を表している。従って、演算式X1が表す処理が実行される場合には、演算式X2が表す処理および演算式X3が表す処理は実行されない。
 演算式X1,X2,X3(図3参照)は例示であり、演算式X1,X2,X3の具体的な内容は、元のループ処理に応じて変わる。ただし、生成部4は、演算式X1,X2,X3のそれぞれに相当する演算式を含む演算式を生成する。
 なお、生成部4は、演算式X1に相当する演算式の代わりに、入力されたソースプログラムに記述された元のループ処理のループ回数が、指定されたアンロール段数よりも小さい場合には、そのループ回数をアンロール段数とするループ1回分の処理を行うことを表す演算式を定め、その演算式と、演算式X2,X3のそれぞれに相当する演算式を含む演算式を生成してもよい。
 置き換え部5は、特定部3によって特定されたソースプログラム内の記述箇所(すなわち、元のループ処理の記述箇所)の演算式を、生成部4が生成した演算式に置き換える。また、元のループ処理を表す演算式の直前にアンロール段数を指定するための所定の書式の文字列が記述されている場合には、その文字列も併せて、生成部4が生成した演算式に置き換える。
 特定部3、生成部4および置き換え部5は、例えば、ループアンローリング処理プログラムに従って動作するコンピュータのCPU(Central Processing Unit )によって実現される。例えば、CPUが、コンピュータのプログラム記憶装置等のプログラム記録媒体からループアンローリング処理プログラムを読み込み、そのループアンローリング処理プログラムに従って、特定部3、生成部4および置き換え部5として動作すればよい。
 次に、本発明の第1の実施形態の処理経過について説明する。既に説明した事項については、適宜、説明を省略する。図5は、本発明の第1の実施形態の処理経過の例を示すフローチャートである。
 入力部2を介してソースプログラムが入力されると、特定部3は、入力されたソースプログラムから、ループ処理を表す演算式の記述箇所を特定する(ステップS1)。なお、特定部3が、ループ処理を表す演算式がソースプログラム内に存在しないと判定した場合には、その時点で処理を終了してよい。この点は、後述の第2の実施形態でも同様である。
 ステップS1の後、生成部4は、アンロール段数の指定を受け付ける(ステップS2)。
 次に、生成部4は、演算式X1,X2,X3(図3参照)のそれぞれに相当する演算式を含む演算式を生成する(ステップS3)。
 次に、置き換え部5は、ステップS1で特定された記述箇所の演算式を、ステップS3で生成された演算式に置き換える(ステップS4)。元のループ処理を表す演算式の直前にアンロール段数を指定するための所定の書式の文字列が記述されている場合には、置き換え部5は、その文字列も併せて、ステップS3で生成された演算式に置き換える。
 なお、入力されたソースプログラム内に、ループ処理を表す演算式の記述箇所が複数存在する場合には、その記述箇所毎に、ステップS1~S4を実行すればよい。
 図4に示すように、本実施形態におけるループアンローリングの結果に基づく処理では、元のループ処理のループ回数を指定されたアンロール段数で除算した際の余りと、指定されたアンロール段数との和をアンロール段数とするループ1回分の処理51(図4参照)を行い、その後、指定されたアンロール段数でループ処理を行う。演算式X1(図3参照)が示す例外的な処理を行う場合や、アンロール段数として1が指定される場合を除けば、アンロール段数を1としてループ処理を行うことがない。よって、本実施形態によれば、ループアンローリング後の処理をより効率化することができる。
 特許文献1に記載の技術と、本願の第1の実施形態とを具体的な数値を用いて比較する。アンロール段数毎のループ処理1回分の処理時間が、図6に示す時間であるとする。また、元の処理のループ回数が7回であり、指定されるアンロール段数が4であるとする。この場合、7を4で除算した際の商は1であり、余りは3である。
 上記の例を特許文献1の技術に適用した場合、アンロール段数“1”でループ3回分の処理を行い、アンロール段数“4”でループ1回分の処理を行うことになる。この場合の処理時間は、4*3+4*1=16となる。
 また、上記の例を本発明の第1の実施形態に適用したとする。この場合、3+4=7をアンロール段数とするループ1回分の処理を行う。この例では、この処理で元のループ処理に相当する処理が終了するので、演算式X3(図3)が表す処理は実行されない。この場合の処理時間は、7*1=7となる。
 従って、特許文献1の技術と、本発明の第1の実施形態とを比較すると、ループアンローリング結果の処理を実行する際の処理時間は、後者の方が短い。よって、本実施形態によれば、ループアンローリング後の処理をより効率化できていると言える。
 また、指定されるアンロール段数の値は、例えば、ソースプログラムを作成するプログラマによって決定される。この場合、プログラマは、種々のアンロール段数を公知のループアンローリング(特許文献1に記載された技術でもよい。)に適用し、良い性能が得られる場合のアンロール段数を特定し、そのアンロール段数を本実施形態のループアンローリング処理装置1に対して指定すればよい。
実施形態2.
 第1の実施形態では、元のループ処理のループ回数を指定されたアンロール段数で除算した際の余りと、指定されたアンロール段数との和をアンロール段数とするループ1回分の処理を行うことを表す演算式(図3に示す例では、演算式X2)を含む演算式を生成する。
 前述のように、アンロール段数を増加させ過ぎると性能が悪化する傾向がある。従って、元のループ処理のループ回数を指定されたアンロール段数で除算した際の余りと、指定されたアンロール段数との和が大きすぎると、その和をアンロール段数とするループ1回分の処理に時間がかかってしまうことも考えられる。
 そこで、本発明の第2の実施形態では、ループアンローリング処理装置は、アンロール段数の下限、および、アンロール段数の上限の指定を受け付ける。
 また、本発明の第2の実施形態のループアンローリング処理装置は、第1の実施形態のループアンローリング処理装置と同様に、図1に示すブロック図で表すことができるので、図1を用いて第2の実施形態を説明する。
 入力部2は、第1の実施形態における入力部2と同様である。
 入力部2を介して入力されるソースプログラム内で、所定の書式によって、アンロール段数の下限およびアンロール段数の上限が指定されていてもよい。
 アンロール段数の下限およびアンロール段数の上限の指定は、ソースプログラムの入力とは別に行われてもよい。例えば、ソースプログラムの入力とは別に、キーボード等の入力デバイス(図1において図示略)を介してアンロール段数の下限およびアンロール段数の上限が入力されることによって、アンロール段数の下限およびアンロール段数の上限が指定されてもよい。
 以下に示す例では、入力されるソースプログラム内で、所定の書式によって、アンロール段数の下限およびアンロール段数の上限が指定されていている場合を例にして説明する。
 図7は、入力されるソースプログラム内における、アンロール段数の下限およびアンロール段数の上限の指定並びにループ処理を表す演算式の例を示す図である。ソースプログラムには、図7に示す演算式以外の演算式も含まれている。
 図7に示す“#pragma unroll( , ) ”は、アンロール段数の下限およびアンロール段数の上限を指定するための所定の書式の一例である。図7では、この書式の括弧内に示された“8”,“11”がそれぞれアンロール段数の下限、アンロール段数の上限として指定された場合を例示している。また、以下の説明では、アンロール段数の下限およびアンロール段数の上限を指定するための所定の書式は、元のループ処理を表す演算式の直前に記述されるものとする。
 特定部3は、入力されたソースプログラムから、ループ処理を表す演算式の記述箇所を特定する。この動作は、第1の実施形態における特定部3の動作と同様であり、説明を省略する。
 さらに、ソースプログラム内でアンロール段数の下限およびアンロール段数の上限が指定されている場合には、特定部3は、その指定の記述箇所も特定する。
 本例では、特定部3は、ソースプログラム内で、図7に示す演算式の記述箇所を特定する。
 生成部4は、特定部3が特定したソースプログラム内の記述箇所に記述された文字列を参照することによって、アンロール段数の下限およびアンロール段数の上限の指定を受け付ける。本例では、生成部4は、図7に示す1行目の所定の書式の文字列に基づいて、アンロール段数の下限として“8”の指定を受け付け、アンロール段数の上限として“11”の指定を受け付ける。
 なお、生成部4は、キーボード等の入力デバイス(図1において図示略)を介して入力された値を取得することによって、アンロール段数の下限およびアンロール段数の上限の指定を受け付けてもよい。
 また、生成部4は、入力されたソースプログラム内に記述されたループ処理(本例では、図7に示す2行目から4行目までの演算式が表すループ処理)に対してループアンローリングを行った結果を表す演算式を生成する。
 図8は、第2の実施形態の生成部4が生成する演算式の例を示す図である。図8では、演算式の一部を省略している。図8に例示する演算式は、演算式Y0と、演算式Y1と、演算式Y2をと含む。さらに、演算式Y1は、演算式Y11と、演算式Y12とを含む。演算式Y2は、演算式Y21と、演算式Y22と、演算式Y23とを含む。
 以下の説明では、ソースプログラム内に記述された元のループ処理のループ回数をNとする。また、指定されたアンロール段数の下限をLとし、指定されたアンロール段数の上限をMとする。さらに、NをLで除算した際の商をQとし、NをLで除算した際の余りをRとする。
 演算式Y0は、Lに、指定されたアンロール段数の下限を代入する処理、Mに、指定されたアンロール段数の上限を代入する処理、および、Q,Rを計算する処理を表している。
 演算式Y1は、R-Q*(M-L)>0である場合の処理を表し、演算式Y2は、R-Q*(M-L)>0でない場合の処理を表す。なお、図8では、R-Q*(M-L)を変数Sで表している。
 まず、演算式Y2が表す処理を先に説明する。前述のように、演算式Y2は、演算式Y21と、演算式Y22と、演算式Y23とを含む。
 演算式Y21が表す処理について説明する。演算式Y21は、アンロール段数をMとして、Rを(M-L)で除算した際の商(図8では、R/(M-L) と記述している。)の回数のループ処理を行うことを表している。
 図8に示す演算式Y2は、演算式Y21が表す処理の後に、演算式Y22が表す処理を行うことを表している。そして、演算式Y22は、Rを(M-L)で除算した際の余り(図8では、R % (M-L) と記述している。)が0以外である場合に、その余りとLとの和をアンロール段数とするループ1回分の処理を行うことを表している。
 演算式Y2は、演算式Y22が表す処理の後に、演算式Y23が表す処理を行うことを表している。そして、演算式Y23は、アンロール段数をLとしてループ処理を行うことを表している。
 なお、演算式Y22が示す処理は、Rを(M-L)で除算した際の余り(R % (M-L) )が0である場合には、処理を行わないことを表し、この場合には、演算式Y21が示す処理の後に、演算式Y23が表す処理を行うことになる。
 図9は、演算式Y2が表す処理を示す模式図である。
 図9に模式的に示す処理61は、演算式Y2に含まれる演算式Y21(図8参照)が表す処理である。処理61は、アンロール段数をMとする、R/(M-L) 回のループ処理である。R/(M-L) は、Rを(M-L)で除算した際の商であり、整数である。
 図9に模式的に示す処理62は、演算式Y2に含まれる演算式Y22(図8参照)が表す処理である。処理62は、アンロール段数をL+R%(M-L) とするループ1回分の処理である。R%(M-L) は、Rを(M-L)で除算した際の余りである。
 図4に模式的に示す処理63は、演算式Y2に含まれる演算式Y23(図8参照)が表す処理である。処理63は、処理62の後に実行される。処理63は、アンロール段数の下限Lでのループ処理である。
 なお、R%(M-L) が0である場合には、処理61の後に、処理62は実行されずに、処理63が実行される。
 演算式Y2が表す処理(図8、図9を参照)では、段数R分の処理を、段数(M-L)分の処理に分割し、その段数(M-L)分の処理をループ処理の各回に配分していると言える。また、段数R分の処理を、段数(M-L)分の処理に分割した場合の余りに該当する処理(段数R%(M-L) 分の処理)は、処理62のループ1回分の処理に配分される。また、処理63は、そのような配分が行われない回のループ処理である。
 次に、演算式Y1(図8参照)が表す処理について説明する。前述のように、演算式Y1は、演算式Y11と、演算式Y12とを含む。
 演算式Y1は、元のループ処理のループ回数Nをアンロール段数の下限Lで除算した際の余りRが大きく、ループ処理の各回に配分しきれない場合の処理を示している。
 例えば、N=7、L=4、M=6であるとする。この場合Q=7/4=1であり、R=7%4=3である。Q=1であるということは、ループ回数が1回であることを意味する。従って、(M-L)段分(すなわち、2段分)の処理を、ループ1回分の処理にしか配分できず、R=3段分の処理を全て配分できるわけではない。演算式Y1は、本例のような状態になった場合の例外的な処理を表している。
 演算式Y1に含まれる演算式Y11(図8参照)は、元のループ処理におけるループ1回分の処理を、R-Q*(M-L)回行うことを示している。上記の例のような、N=7、L=4、M=6、Q=1、R=3の場合には、R-Q*(M-L)=3-1*(6-4)=1となる。従って、上記の例の場合、元のループ処理におけるループ1回分の処理を1回行うことになる。
 図8に示す演算式Y1は、演算式Y11が表す処理の後に、演算式Y12が表す処理行うことを表している。そして、演算式Y12は、アンロール段数をMとしてループ処理を行うことを表している。上記の例において、アンロール段数をMとした場合のループ処理のループ回数は1回である。
 従って、上記の例の場合における演算式Y1が表す処理は、図10のように表される。処理71は、元のループ処理におけるループ1回分の処理を、R-Q*(M-L)=1回行う処理である。処理72は、アンロール段数をM=6とした場合のループ処理である。ただし、本例では、処理72におけるループ回数は1回である。
 図8に示す演算式Y0,Y1,Y2は例示であり、演算式Y0,Y1,Y2の具体的な内容は、元のループ処理に応じて変わる。ただし、第2の実施形態の生成部4は、演算式Y0,Y1,Y2のそれぞれに相当する演算式を含む演算式を生成する。
 置き換え部5は、特定部3によって特定されたソースプログラム内の記述箇所(すなわち、元のループ処理の記述箇所)の演算式を、生成部4が生成した演算式に置き換える。また、元のループ処理を表す演算式の直前にアンロール段数の下限およびアンロール段数の上限を指定するための所定の書式の文字列が記述されている場合には、その文字列も併せて、生成部4が生成した演算式に置き換える。
 次に、本発明の第2の実施形態の処理経過について説明する。既に説明した事項については、適宜、説明を省略する。図11は、本発明の第2の実施形態の処理経過の例を示すフローチャートである。
 入力部2を介してソースプログラムが入力されると、特定部3は、入力されたソースプログラムから、ループ処理を表す演算式の記述箇所を特定する(ステップS1)。ステップS1は、第1の実施形態におけるステップS1(図5参照)と同様である。
 ステップS1の後、生成部4は、アンロール段数の下限およびアンロール段数の上限の指定を受け付ける(ステップS12)。
 次に、生成部4は、演算式Y0,Y1,Y2(図8参照)のそれぞれに相当する演算式を含む演算式を生成する(ステップS13)。
 次に、置き換え部5は、ステップS1で特定された記述箇所の演算式を、ステップS13で生成された演算式に置き換える(ステップS14)。元のループ処理を表す演算式の直前にアンロール段数の下限およびアンロール段数の上限を指定するための所定の書式の文字列が記述されている場合には、置き換え部5は、その文字列も併せて、ステップS13で生成された演算式に置き換える。
 なお、入力されたソースプログラム内に、ループ処理を表す演算式の記述箇所が複数存在する場合には、その記述箇所毎に、ステップS1~S14を実行すればよい。
 図9に示すように、本実施形態におけるループアンローリングの結果に基づく処理では、アンロール段数をMとして、Rを(M-L)で除算した際の商の回数のループ処理を行い、その後、Rを(M-L)で除算した際の余りと、アンロール段数の下限Lとの和をアンロール段数とするループ1回分の処理を行い、さらにその後、アンロール段数をLとしてループ処理を行う。従って、R段分の処理をループ処理の各回に配分できないような例外的な場合や、アンロール段数の下限として1が指定される場合を除けば、アンロール段数を1としてループ処理を行うことがない。よって、本実施形態によれば、ループアンローリング後の処理をより効率化することができる。
 さらに、本実施形態では、アンロール段数が上限のMより大きくなることはない。従って、アンロール段数が大きくなり過ぎて、実行プログラムの性能が悪化することを防止できる。
 なお、各実施形態において、ループアンローリング処理装置1は、ステップS4(図5参照)の後や、ステップS14(図11参照)の後に、書き換え後のソースプログラムをデータ記録媒体に記録してもよい。また、ループアンローリング処理装置1は、書き換え後のソースプログラムに基づいて、実行プログラムを生成してもよい。
 図12は、本発明の各実施形態のループアンローリング処理装置1に係るコンピュータの構成例を示す概略ブロック図である。例えば、コンピュータ1000は、CPU1001と、主記憶装置1002と、補助記憶装置1003と、インタフェース1004と、データ記録媒体に記録されたソースプログラムを読み込むデータ読み込み装置1005とを備える。
 本発明の各実施形態のループアンローリング処理装置1は、コンピュータ1000によって実現される。ループアンローリング処理装置1の動作は、プログラム(ループアンローリング処理プログラム)の形式で、補助記憶装置1003に記憶されている。CPU1001は、プログラムを補助記憶装置1003から読み出して主記憶装置1002に展開し、そのプログラムに従って、上記の各実施形態で説明した処理を実行する。この場合、入力部2は、データ読み込み装置1005によって実現される。特定部3、生成部4および置き換え部5は、CPU1001によって実現される。
 補助記憶装置1003は、一時的でない有形の媒体の例である。一時的でない有形の媒体の他の例として、インタフェース1004を介して接続される磁気ディスク、光磁気ディスク、CD-ROM(Compact Disk Read Only Memory )、DVD-ROM(Digital Versatile Disk Read Only Memory )、半導体メモリ等が挙げられる。また、プログラムが通信回線によってコンピュータ1000に配信される場合、配信を受けたコンピュータ1000がそのプログラムを主記憶装置1002に展開し、そのプログラムに従って上記の実施形態で説明した処理を実行してもよい。
 また、各構成要素の一部または全部は、汎用または専用の回路(circuitry )、プロセッサ等やこれらの組合せによって実現されてもよい。これらは、単一のチップによって構成されてもよいし、バスを介して接続される複数のチップによって構成されてもよい。各構成要素の一部または全部は、上述した回路等とプログラムとの組合せによって実現されてもよい。
 各構成要素の一部または全部が複数の情報処理装置や回路等により実現される場合には、複数の情報処理装置や回路等は集中配置されてもよいし、分散配置されてもよい。例えば、情報処理装置や回路等は、クライアントアンドサーバシステム、クラウドコンピューティングシステム等、各々が通信ネットワークを介して接続される形態として実現されてもよい。
 次に、本発明の概要について説明する。図13は、本発明のループアンローリング処理装置の概要を示すブロック図である。ループアンローリング処理装置は、特定部3と、生成部4と、置き換え部5とを備える。
 特定部3は、入力されたソースプログラムから、ループ処理を表す演算式の記述箇所を特定する。
 生成部4は、そのループ処理のループ回数を、指定されたアンロール段数で除算した際の余りが0以外である場合に、当該余りと指定されたアンロール段数との和をアンロール段数とするループ1回分の処理を行うこと、および、その後に、指定されたアンロール段数でループ処理を行うことを表す演算式を生成する。
 置き換え部5は、特定部3によって特定された記述箇所の演算式を、生成部4によって生成された演算式に置き換える。
 そのような構成により、ループアンローリング後の処理をより効率化することができる。
 また、生成部4が、入力されたソースプログラムに記述されたループ処理のループ回数が、指定されたアンロール段数よりも小さい場合には、そのループ処理と同じループ処理を行うことを表す演算式を含む演算式を生成してもよい。
 また、生成部4が、入力されたソースプログラムに記述されたループ処理のループ回数が、指定されたアンロール段数よりも小さい場合には、そのループ回数をアンロール段数とするループ1回分の処理を行うことを表す演算式を含む演算式を生成してもよい。
 また、生成部4が、入力されたソースプログラムに記述された所定の書式によって、アンロール段数の指定を受け付けてもよい。
 また、図13に示す生成部4は、以下の動作を行ってもよい。すなわち、生成部4は、元のループ処理のループ回数をNとし、指定されたアンロール段数の下限をLとし、指定されたアンロール段数の上限をMとし、NをLで除算した際の商をQとし、NをLで除算した際の余りをRとしたときに、R-Q*(M-L)>0である場合に、元のループ処理におけるループ1回分の処理をR-Q*(M-L)回行うこと、および、その後に、アンロール段数をMとしてループ処理を行うことを示す演算式と、R-Q*(M-L)>0でない場合に、アンロール段数をMとして、Rを(M-L)で除算した際の商の回数のループ処理を行うこと、その後、Rを(M-L)で除算した際の余りが0以外である場合に当該余りとLとの和をアンロール段数とするループ1回分の処理を行うこと、および、その後に、アンロール段数をLとしてループ処理を行うことを示す演算式とを含む演算式を生成してもよい。
 この場合、生成部4が、入力されたソースプログラムに記述された所定の書式によって、アンロール段数の下限およびアンロール段数の上限の指定を受け付けてもよい。
 以上、実施形態を参照して本願発明を説明したが、本願発明は上記の実施形態に限定されるものではない。本願発明の構成や詳細には、本願発明のスコープ内で当業者が理解し得る様々な変更をすることができる。
産業上の利用の可能性
 本発明は、ソースプログラム内に記述されたループ処理に対してループアンローリングを行うループアンローリング処理装置、方法およびプログラムに好適に適用可能である。
 1 ループアンローリング処理装置
 2 入力部
 3 特定部
 4 生成部
 5 置き換え部

Claims (4)

  1.  入力されたソースプログラムから、ループ処理を表す演算式の記述箇所を特定する特定部と、
     前記ループ処理のループ回数をNとし、指定されたアンロール段数の下限をLとし、指定されたアンロール段数の上限をMとし、NをLで除算した際の商をQとし、NをLで除算した際の余りをRとしたときに、
     R-Q*(M-L)>0である場合に、前記ループ処理におけるループ1回分の処理をR-Q*(M-L)回行うこと、および、その後に、アンロール段数をMとしてループ処理を行うことを示す演算式と、
     R-Q*(M-L)>0でない場合に、アンロール段数をMとして、Rを(M-L)で除算した際の商の回数のループ処理を行うこと、その後、Rを(M-L)で除算した際の余りが0以外である場合に当該余りとLとの和をアンロール段数とするループ1回分の処理を行うこと、および、その後に、アンロール段数をLとしてループ処理を行うことを示す演算式と
     を含む演算式を生成する生成部と、
     前記特定部によって特定された前記記述箇所の演算式を、前記生成部によって生成された演算式に置き換える置き換え部とを備える
     ことを特徴とするループアンローリング処理装置。
  2.  前記生成部は、
     入力された前記ソースプログラムに記述された所定の書式によって、アンロール段数の下限およびアンロール段数の上限の指定を受け付ける
     請求項5に記載のループアンローリング処理装置。
  3.  入力されたソースプログラムから、ループ処理を表す演算式の記述箇所を特定し、
     前記ループ処理のループ回数をNとし、指定されたアンロール段数の下限をLとし、指定されたアンロール段数の上限をMとし、NをLで除算した際の商をQとし、NをLで除算した際の余りをRとしたときに、
     R-Q*(M-L)>0である場合に、前記ループ処理におけるループ1回分の処理をR-Q*(M-L)回行うこと、および、その後に、アンロール段数をMとしてループ処理を行うことを示す演算式と、
     R-Q*(M-L)>0でない場合に、アンロール段数をMとして、Rを(M-L)で除算した際の商の回数のループ処理を行うこと、その後、Rを(M-L)で除算した際の余りが0以外である場合に当該余りとLとの和をアンロール段数とするループ1回分の処理を行うこと、および、その後に、アンロール段数をLとしてループ処理を行うことを示す演算式と
     を含む演算式を生成し、
     前記記述箇所の演算式を、生成した演算式に置き換える
     ことを特徴とするループアンローリング処理方法。
  4.  コンピュータに、
     入力されたソースプログラムから、ループ処理を表す演算式の記述箇所を特定する特定処理、
     前記ループ処理のループ回数をNとし、指定されたアンロール段数の下限をLとし、指定されたアンロール段数の上限をMとし、NをLで除算した際の商をQとし、NをLで除算した際の余りをRとしたときに、
     R-Q*(M-L)>0である場合に、前記ループ処理におけるループ1回分の処理をR-Q*(M-L)回行うこと、および、その後に、アンロール段数をMとしてループ処理を行うことを示す演算式と、
     R-Q*(M-L)>0でない場合に、アンロール段数をMとして、Rを(M-L)で除算した際の商の回数のループ処理を行うこと、その後、Rを(M-L)で除算した際の余りが0以外である場合に当該余りとLとの和をアンロール段数とするループ1回分の処理を行うこと、および、その後に、アンロール段数をLとしてループ処理を行うことを示す演算式と
     を含む演算式を生成する生成処理、および、
     前記特定処理で特定された前記記述箇所の演算式を、前記生成処理で生成された演算式に置き換える置き換え処理
     を実行させるためのループアンローリング処理プログラム。
PCT/JP2020/005891 2020-02-14 2020-02-14 ループアンローリング処理装置、方法およびプログラム WO2021161532A1 (ja)

Priority Applications (3)

Application Number Priority Date Filing Date Title
US17/795,952 US20230161590A1 (en) 2020-02-14 2020-02-14 Loop unrolling processing apparatus, method, and program
JP2022500197A JP7302728B2 (ja) 2020-02-14 2020-02-14 ループアンローリング処理装置、方法およびプログラム
PCT/JP2020/005891 WO2021161532A1 (ja) 2020-02-14 2020-02-14 ループアンローリング処理装置、方法およびプログラム

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/JP2020/005891 WO2021161532A1 (ja) 2020-02-14 2020-02-14 ループアンローリング処理装置、方法およびプログラム

Publications (1)

Publication Number Publication Date
WO2021161532A1 true WO2021161532A1 (ja) 2021-08-19

Family

ID=77293020

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2020/005891 WO2021161532A1 (ja) 2020-02-14 2020-02-14 ループアンローリング処理装置、方法およびプログラム

Country Status (3)

Country Link
US (1) US20230161590A1 (ja)
JP (1) JP7302728B2 (ja)
WO (1) WO2021161532A1 (ja)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH04344535A (ja) * 1991-05-22 1992-12-01 Nec Software Ltd ループの展開装置
JP2017041085A (ja) * 2015-08-19 2017-02-23 株式会社東芝 プログラム仕様推定装置、推定方法、および推定プログラム

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6035125A (en) * 1997-07-25 2000-03-07 International Business Machines Corporation Method and system for generating compact code for the loop unrolling transformation
US20110238948A1 (en) * 2002-08-07 2011-09-29 Martin Vorbach Method and device for coupling a data processing unit and a data processing array
US20060048122A1 (en) * 2004-08-30 2006-03-02 International Business Machines Corporation Method, system and computer program product for hierarchical loop optimization of machine executable code
US8966457B2 (en) * 2011-11-15 2015-02-24 Global Supercomputing Corporation Method and system for converting a single-threaded software program into an application-specific supercomputer
US9038042B2 (en) * 2012-06-29 2015-05-19 Analog Devices, Inc. Staged loop instructions

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH04344535A (ja) * 1991-05-22 1992-12-01 Nec Software Ltd ループの展開装置
JP2017041085A (ja) * 2015-08-19 2017-02-23 株式会社東芝 プログラム仕様推定装置、推定方法、および推定プログラム

Also Published As

Publication number Publication date
JPWO2021161532A1 (ja) 2021-08-19
JP7302728B2 (ja) 2023-07-04
US20230161590A1 (en) 2023-05-25

Similar Documents

Publication Publication Date Title
JP2665111B2 (ja) ベクトル処理装置
JP6666554B2 (ja) 情報処理装置、変換プログラム、及び変換方法
KR101379556B1 (ko) 바이-엔디언 컴파일러를 사용한 코드 최적화
WO2021161532A1 (ja) ループアンローリング処理装置、方法およびプログラム
WO2021161531A1 (ja) ループアンローリング処理装置、方法およびプログラム
JP5405684B1 (ja) ソースプログラムのプログラミング言語変換装置
CN108389153A (zh) 一种视图加载的方法及终端设备
JP2021192187A (ja) 出現頻度算出プログラム、グラフィックス プロセッシング ユニット、情報処理装置、及び出現頻度算出方法
CN116560629A (zh) 一种数据传输对象的序列化方法、装置、介质和设备
JP2002269162A (ja) 動作合成方法
JP7025104B2 (ja) 情報処理装置、方法およびプログラム
JP7447529B2 (ja) 情報処理装置、情報処理方法、および、プログラム
JP5648559B2 (ja) 帳票出力装置、帳票出力方法および帳票出力プログラム
JP2020201530A (ja) コンパイル装置、コンパイル方法、及びプログラム
JP6583033B2 (ja) ドライバ生成プログラム、装置、及び方法
JP2002312176A (ja) 変換プログラム、コンパイラ、コンピュータ装置、プログラム変換方法及び記憶媒体
JP3019922B2 (ja) トレースデータ削減方式
JP2000200202A (ja) アプリケ―ションプログラムのデバッグにおけるリンク処理方法及びそのシステム並びに情報記録媒体
JPH07129408A (ja) 言語処理プログラムの実行方式
JP3237591B2 (ja) コンパイル装置、コンパイル方法およびコンパイラを記録した記録媒体
JP2022174775A (ja) 情報処理装置、情報処理方法、及びプログラム
JP2016177652A (ja) コンパイラプログラム、システム、方法、及び装置
JP3722854B2 (ja) データ編集装置
JPH08212083A (ja) 割り込み処理装置
JP2000242531A (ja) 有向グラフ入出力システム及び入出力方法

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20918235

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2022500197

Country of ref document: JP

Kind code of ref document: A

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20918235

Country of ref document: EP

Kind code of ref document: A1