WO2012004972A1 - プログラム生成装置、プログラム生産方法及びプログラム - Google Patents

プログラム生成装置、プログラム生産方法及びプログラム Download PDF

Info

Publication number
WO2012004972A1
WO2012004972A1 PCT/JP2011/003812 JP2011003812W WO2012004972A1 WO 2012004972 A1 WO2012004972 A1 WO 2012004972A1 JP 2011003812 W JP2011003812 W JP 2011003812W WO 2012004972 A1 WO2012004972 A1 WO 2012004972A1
Authority
WO
WIPO (PCT)
Prior art keywords
program
variable
dependency
notation
variables
Prior art date
Application number
PCT/JP2011/003812
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 JP2012523520A priority Critical patent/JP5580416B2/ja
Priority to CN201180003692XA priority patent/CN102483701A/zh
Priority to US13/393,992 priority patent/US8806466B2/en
Publication of WO2012004972A1 publication Critical patent/WO2012004972A1/ja

Links

Images

Classifications

    • 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
    • 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/456Parallelism detection

Definitions

  • the present invention relates to a technique for generating a new program with reference to a source program including loop processing.
  • a compiler or the like which generates a new program for causing a plurality of processors to share and execute predetermined processing realized by the loop processing with reference to a source program including the loop processing (for example, patent documents 1).
  • the loop processing is to repeatedly process a block consisting of one or more command statements N (N ⁇ 2) times.
  • a loop processing for N times is divided into two partial loop processes for processing N / 2 times, and is newly configured to be independently executed in parallel by two processors. Program can be generated. Therefore, according to the technique of Patent Document 1, N times of loop processing can be executed at high speed.
  • a variable defined by an instruction statement in a block related to the i (1 ⁇ i ⁇ N) execution is a block related to the j (i ⁇ j ⁇ N) execution
  • the method of Patent Document 1 can not cope with it. That is, according to the method of Patent Document 1, it is impossible to generate a program for executing loop processing at high speed using a plurality of processors from a source program including loop processing having such a dependency.
  • An object of the present invention is to provide a program generation device useful for generation.
  • a program generation device is a loop process that repeatedly processes a block consisting of one or more command statements N times (N ⁇ 2), and i (1 ⁇ i ⁇ N).
  • the dependence is based on the calculation means for calculating the equivalence relation of the variable notation in the target block and the equivalence relation of the variable notation calculated by the calculation means.
  • Specifying means for specifying the representation of the other variable having no dependency relation equivalent to the representation of the target variable with respect to the representations of all the target variables involved, and M times of the loop processing (M ⁇ N
  • a generation unit for generating a program including an instruction sentence including a representation of another variable identified by the identification unit.
  • the program generation apparatus having the above configuration can generate a program for executing the loop process at high speed using a plurality of processors by referring to the source program including the loop process having the dependency. .
  • FIG. 1 is a block diagram showing a configuration of a compiler system 1000 including a program generation device 100 according to an embodiment. It is a figure showing partial program P1 including loop processing R1 and partial program P4 including loop processing R4. It is a figure for demonstrating the dependency of data. It is a figure for demonstrating the dependency of the data in loop process R1. It is a flowchart which shows the program production
  • FIG. 2 is a view showing equivalent partial programs P1 and P4 capable of obtaining the same processing result for the array b [k] (0 ⁇ k ⁇ 99) when the processing is completed.
  • the program generation apparatus is an improvement of a conventional compiler, and the conventional compiler refers to a source program including a partial program P4 shown in FIG. 2 (b), generated in advance by a programmer.
  • An assembler program similar to the assembler program obtained by the above is generated by referring to the source program including the partial program P1 shown in FIG. 2A.
  • the partial program P1 includes loop processing R1 having a true dependency relationship.
  • the true dependency relationship will be described in detail later, but the variable defined in the statement in the block B1 executed when the loop control variable k is i (0 ⁇ i ⁇ 99) is a loop control variable. It refers to a relation that is referred to in a statement in block B1 that is executed when k is i + 1.
  • This loop processing R1 increases the loop control variable k by one because the correct result can not be obtained if the execution order between the statements having a true dependency relationship is reversed to the original execution order. It is common to execute them one after the other.
  • loop processing R4 included in the partial program P4 does not have the true dependency relationship as described above. Therefore, it is possible to execute using multiple processors.
  • loop processing R4 is divided into partial loop processing with a loop control variable k of 0 to 49 and partial loop processing with a loop control variable k of 50 to 99, and two processors are independently executed in parallel It is possible. This makes it possible to execute loop processing at a higher speed as compared to the case where loop processing R1 for loop control variable k from 0 to 99 is sequentially executed by one processor.
  • the program generation apparatus refers to the source program including the partial program P1 shown in FIG. 2A, whereby the conventional compiler generates the partial program P4 shown in FIG.
  • An assembler program similar to an assembler program generated by referring to a source program including the above can be generated.
  • the program generation apparatus is effective in that an assembler program suitable for parallel execution can be generated without regenerating.
  • partial program P1 includes loop processing R1 having a true dependency as described above, it is a program suitable for high-speed execution with a single processor as compared to partial program P4 for the reasons described below. It can be said that there is.
  • the program can be executed at higher speed by allocating variables in the program to registers as much as possible. This is because the access to the register can be extremely fast compared to the memory.
  • FIG. 3 is a diagram for explaining the dependency of data.
  • variable a defined in the command statement ST100 is in a relation to be referred to in the command statement ST200 executed after the command statement ST100. In such a relationship, it is said that there is a "true dependency" from the command statement ST100 to the command statement ST200.
  • variable a referred to in the command statement ST200 is in a relationship defined by the command statement ST300 to be executed after the command statement ST200. In such a relationship, there is an "inverse dependency" from the imperative sentence ST200 to the imperative sentence ST300.
  • variable a defined in the command statement ST100 is in a relationship redefined in the command statement ST300. In such a relationship, it is said that there is an "output dependency" from the command statement ST100 to the command statement ST300.
  • variable causing true dependency a variable causing true dependency, reverse dependency and output dependency
  • variable a the variable that causes the dependency
  • inverse dependency and output dependency it is known that the dependency can be deleted by replacing the representation of the variable causing the dependency with different ones in each instruction statement that has a dependency relationship. (See, for example, page 120 of Non-Patent Document 1). Therefore, "inverse dependency” and “output dependency” may be referred to as “mistake dependency”.
  • FIG. 4 is a diagram for explaining the dependency of data in the loop processing R1 shown in FIG. 2 (a).
  • the block in the loop that is executed when the loop control variable is m (m is any value that the loop control variable can take) is called “iteration m”, and an iteration m is generated. That is called “Iteration expansion about m”, and this m is called “Iteration number”.
  • FIG. 4 (a) shows a block B1 executed when the loop control variable k in the loop process R1 shown in FIG. 2 (a) is 0, that is, iteration 0, and FIG. 4 (b) shows an iteration. 1 is shown.
  • variables a0, a1, and a2 defined in the statement ST12, ST13, and ST14 of the iteration 0 shown in FIG. 4A are the same as the statement ST21 of the iteration 1 shown in FIG. 4B. It is in a relationship to be referenced.
  • variables a1 and a2 defined in the instruction statements ST13 and ST14 of the iteration 0 shown in FIG. 4A are referred to in the instruction statements ST22 and ST23 of the iteration 1 shown in FIG. 4B. It is related.
  • variable a0 defined by the instruction sentence ST12 of the iteration 0 shown in FIG. 4A is in a relation redefined by the instruction sentence ST22 of the iteration 1 shown in FIG. 4B.
  • variables a0, a1, a2 referred to in the instruction sentence ST21 of the iteration 1 shown in FIG. 4B are in a relationship defined by the instruction sentences ST22 to ST24. That is, there is an inverse dependency from the instruction statement ST21 to ST22 with the variable a0 as the cause of the dependency, and an inverse dependency from the instruction statement ST21 to ST23 with the variable a1 as the cause of the dependency. There is an inverse dependency from the command statement ST21 to ST24.
  • FIG. 1 is a block diagram showing the configuration of a compiler system 1000 including a program generation apparatus 100 according to the embodiment.
  • the compiler system 1000 is a target program capable of parallel execution of loop processing by a plurality of processors by referring to the source program 11 including loop processing having a true dependency between iterations like the partial program P1 described above. 14 is generated.
  • the compiler system 1000 is realized by a computer (for example, PC (Personal Computer)) including a processor (not shown), a memory (not shown), and a storage device 10 such as a hard disk.
  • a computer for example, PC (Personal Computer)
  • PC Personal Computer
  • memory not shown
  • storage device 10 such as a hard disk.
  • the compiler system 1000 is configured to include a storage device 10, a program generation device 100, an assembler 210, and a linker 220, as shown in the figure.
  • the functions of the program generation device 100, the assembler 210, and the linker 220 are realized by the processor reading a not-shown program stored in the storage device 10 into the memory and executing the read program.
  • the program generation device 100 is an improvement of a conventional compiler, and is referred to a source program 11 stored in the storage device 10 and described in a high-level language such as C language or C ++ language, and the like. It has a function of generating the program 12.
  • the program generation device 100 stores the generated assembler program 12 in the storage device 10.
  • the program generation device 100 executes an assembler program 12 for executing the loop processing in which the true dependency is eliminated.
  • the assembler 210 also has a function of generating a relocatable binary program 13 described in machine language with reference to the assembler program 12 stored in the storage device 10 by the program generation device 100.
  • the assembler 210 stores the generated relocatable binary program 13 in the storage device 10.
  • the linker 220 determines the address arrangement and the like of unresolved data in the relocatable binary program 13 stored in the storage device 10 by the assembler 210, and can be executed by a computer by linking with necessary libraries and the like. It has a function of generating a target program 14. The linker 220 stores the generated target program 14 in the storage device 10.
  • the program generation device 100 includes a storage unit 110, an acquisition unit 120, a calculation unit 130, a specification unit 140, and a generation unit 150.
  • the storage unit 110 is a memory area for storing processing results of the source program 11, the calculation unit 130, the identification unit 140, and the generation unit 150.
  • exchange of processing results among the calculation unit 130, the identification unit 140, and the generation unit 150 is performed via the storage unit 110.
  • the acquisition unit 120 also has a function of reading the source program 11 from the storage device 10 and storing the source program 11 in the storage unit 110.
  • the calculating unit 130 has a function of calculating the equivalence relation of variable notation for a certain iteration and one or more other iterations in the loop process included in the source program 11 stored in the storage unit 110 by the acquiring unit 120.
  • the calculation unit 130 includes an iteration development unit 131, an appearance dependency deletion unit 132, and an equivalence relation calculation unit 133.
  • the iteration expansion unit 131 has a function of performing iteration expansion based on loop processing included in the source program 11.
  • the misuse dependency removal unit 132 has a function of removing the shame dependency (that is, output dependency and reverse dependency) existing between two successive iterations of successive iteration numbers, which the iteration unfolding unit 131 performs the iteration expansion. .
  • the equivalence relation calculation unit 133 has a function of calculating the equivalence relation of variable notation for each statement of the two iterations after the apparent dependence is deleted by the apparent dependence deletion unit 132.
  • the calculation of the equivalence relation of variable notation is performed using a method similar to the method described in Patent Document 2.
  • the specifying unit 140 does not have all the variables that cause true dependence existing between the two iterations have equivalent dependence relations. It has a function to determine whether all true dependencies can be deleted by replacing with other variables or expressions.
  • the identifying unit 140 has a function of controlling the calculation of the equivalence relation of the variable notation by the calculating unit 130 and a function of performing the determination described below. That is, this determination is to determine whether or not the block in the loop processing included in the source program 11 can be replaced with the iteration deformation candidate generated by the generation unit 150 described below.
  • the generating unit 150 When the identifying unit 140 determines that all the true dependencies existing between the above two iterations can be deleted, the generating unit 150 generates iteration iteration candidates based on the iterations in which all the true dependencies are eliminated. Have a function to
  • the iteration modification candidate can apply an iteration with all of the above true dependencies removed to iterations subsequent to the iteration number. It is a generalization.
  • the generation unit 150 also has a function of generating the assembler program 12 when the identification unit 140 determines that the block in the loop processing included in the source program 11 can be replaced with the iteration transformation candidate.
  • the assembler program 12 is based on a source program in which blocks in the loop processing included in the source program 11 are replaced with iteration modification candidates.
  • 5 to 7 are flowcharts showing program generation processing by the program generation device 100.
  • the acquisition unit 120 of the program generation apparatus 100 reads the source program 11 from the storage device 10 and stores the source program 11 in the storage unit 110.
  • the iteration expansion unit 131 of the calculation unit 130 performs iteration expansion for i indicating any value of a loop control variable in loop processing included in the source program 11 and i + 1 (step S1 in FIG. 5).
  • the calculation unit 130 identifies the dependency between the statements of the iteration i and the iteration i + 1 (step S2). Further, the apparent dependence removing unit 132 deletes the apparent dependence by changing the notation of the variable causing the apparent dependence (that is, the output dependence and the inverse dependence) (step S3).
  • the equivalence relation calculation unit 133 of the calculation unit 130 calculates the equivalence relation of the variable notation for each statement of the iteration i and iteration i + 1 from which the appearance dependency is deleted (step S4).
  • the equivalence relation calculating unit 133 performs the following process on each of the instruction sentences of iteration i and iteration i + 1 one by one in order.
  • the equivalence relation calculation unit 133 determines whether an equivalent expression including a variable or an expression described in the right side or the left side of the instruction statement to be processed is already included in the equivalent expression set.
  • step S4 determines whether all true dependencies can be deleted based on the equivalence relation of the variable notation calculated by the equivalence relation calculating unit 133 (step S5). .
  • step S4 based on the equivalence relation of the variable notation calculated in step S4, the notation of all variables causing true dependence is the variable causing the dependence specified in step S2 and the apparent dependence in step S3. If it is possible to replace with equivalent variables or expressions other than the variables introduced for deletion, it is determined that all true dependencies can be deleted (step S5: YES).
  • variable that causes the dependency specified in step S2 and the variable introduced in step S3 to delete the apparent dependency are not replaced, such variables are new dependencies in other iterations.
  • the reason is that there is a possibility of That is, even if it substitutes for such a variable notation, it may not end up removing the dependency between iterations.
  • step S5 If it is determined that all true dependencies can be deleted (step S5: YES), "1" is set as the value of m in the iteration i + m where all true dependencies can be deleted (step S6) The process proceeds to step S15 of FIG.
  • step S5 When it is determined that all true dependencies can not be deleted (step S5: NO), the specifying unit 140 sets the value of m to “2” (step S7 in FIG. 6).
  • the identifying unit 140 determines that the value of m is the minimum value that the loop control variable can take from the maximum value that the loop control variable included in the source program 11 can take (hereinafter referred to as “kmax”). It is determined whether it is smaller than a value obtained by subtracting “kmin” (step S8).
  • step S8 NO
  • the program generation apparatus 100 ends the program generation processing on the assumption that true dependency can not be deleted (see FIG. 7). ).
  • step S8 when the value of m is smaller than the value obtained by subtracting kmin from kmax (step S8: YES), the identifying unit 140 instructs the processing unit 130 to notify the value of m.
  • the iteration expansion unit 131 of the calculation unit 130 which has been instructed to perform the process, performs an iteration expansion for i + m as in the process of step S1 (step S9).
  • the appearance dependence deletion unit 132 specifies the dependency between the iterations i + m-1 and the iteration i + m as in the process of step S2 (step S10), and, similarly to the process of step S3, The fake dependency is deleted (step S11).
  • the equivalence relation calculating unit 133 calculates the equivalence relation of the variable notation for each statement of iteration i + m-1 and iteration i + m from which the apparent dependence has been deleted, as in the process of step S4 (step S12).
  • step S5 the identifying unit 140 determines whether all true dependencies can be deleted based on the equivalence relation of the variable notation calculated by the equivalence relation calculating unit 133 in step S12. It determines (step S13).
  • the identifying unit 140 is a variable that causes the dependence specified in steps S2 and S10, and a variable that is introduced to delete the apparent dependence in steps S3 and S11. Do not use the notation for replacement.
  • step S13 If it is determined that all true dependencies can not be deleted (step S13: NO), the identifying unit 140 increments the value of m by one (step S14), and performs the process from step S8 again.
  • step S13 when the identifying unit 140 determines that all true dependencies can be deleted (step S13: YES), the generating unit 150 performs iteration based on the iteration i + m from which all true dependencies are deleted. A transformation candidate is generated (step S15).
  • i indicates an arbitrary value of a loop control variable in loop processing included in the source program 11. Therefore, in the iteration i + m, the fact that all true dependencies can be deleted means that iterations after the kmin + m iteration can delete all true dependencies.
  • the generation unit 150 generates generalized iteration modification candidates so that the iteration number can be applied to iterations from kmin + m to kmax.
  • the specifying unit 140 instructs the calculation unit 130 to perform processing by notifying the values of kmin and m ⁇ 1.
  • the iteration expansion unit 131 of the calculation unit 130 which has been instructed to perform the process, performs the iteration expansion for each of kmin to m-1 as in the process of step S1 (step S16 in FIG. 7).
  • step S2 the apparent dependence removing unit 132 specifies the dependency between the instruction sentences (step S17), and the process of step S3. In the same manner as in step S18, the appearance dependency is deleted (step S18).
  • the equivalence relation calculation unit 133 calculates the equivalence relation of the variable notation for each instruction statement from the iteration kmin to the iteration m-1 for which the apparent dependency has been deleted, as in the process of step S4 (step S19).
  • the identifying unit 140 determines whether all true dependencies can be deleted based on the equivalence relation of the variable notation calculated by the equivalence relation calculating unit 133 in step S19. It determines (step S20).
  • step S20 If the identifying unit 140 determines that all true dependencies can not be deleted (step S20: NO), the loop control variable can not delete true dependencies in the range from kmin to m-1 The program creation apparatus 100 ends the program creation process.
  • step S20 determines that all true dependencies can be deleted (step S20: YES)
  • the iteration m-1 to the iteration m-1 from step k1 in which all true dependencies are deleted are steps S15.
  • Whether or not the iteration m-1 is isomorphic to the iteration mkm in the iteration transformation candidate generated in step S2 is determined (step S21).
  • step S21: NO the program generation device 100 ends the program generation process. In this case, loop processing in which the loop control variable is applicable to the range from kmin to m-1 is deleted, and loop processing in which the loop control variable is applicable to the range from m to kmax is deleted. Because it can not be combined into one loop process.
  • the generation unit 150 performs assembler as follows.
  • the program 12 is generated (step S22). That is, the generation unit 150 generates the assembler program 12 after performing optimization and parallelization on a program in which a block in the loop processing of the source program 11 is replaced with an iteration modification candidate.
  • the generation unit 150 stores the generated assembler program 12 in the storage device 10, and the program generation device 100 ends the program generation process.
  • the acquisition unit 120 of the program generation apparatus 100 reads the source program 11 from the storage device 10 and stores the source program 11 in the storage unit 110.
  • the iteration expansion unit 131 of the calculation unit 130 is for i and i + 1 indicating an arbitrary value of the loop control variable (k in this example) in the loop process (R1 in this example) included in the source program 11. Iteration expansion is performed (step S1 in FIG. 5).
  • FIG. 8 (a) is a diagram showing an iteration i in the loop processing R1 shown in FIG. 2 (a), and FIG. 8 (b) is a diagram showing an iteration i + 1.
  • the calculation unit 130 identifies the dependency between the statements of the iteration i and the iteration i + 1 (step S2). Further, the apparent dependence removing unit 132 deletes the apparent dependence by changing the notation of the variable causing the apparent dependence (that is, the output dependence and the inverse dependence) (step S3).
  • variable a1 as the cause of dependency, true dependency from the instruction statement ST43 to the instruction statement ST51, output dependency from the instruction statement ST43 to the instruction statement ST53, reverse dependency from the instruction statement ST41 to the instruction statement ST43, and an instruction There is an inverse dependency from the sentence ST51 to ST53.
  • variable a2 as the cause of dependence, true dependency from the instruction statement ST44 to the instruction statement ST51, output dependency from the instruction statement ST44 to the instruction statement ST54, reverse dependency from the instruction statement ST41 to the instruction statement ST44, and instruction There is an inverse dependency from statement ST51 to ST54.
  • the cause of the dependence of the variable a1 by changing the notation of the variable a1 in the imperative sentence ST43 to "a1_i” and changing the notation of the variable a1 in the imperative sentence ST53 to "a1_i1". It is possible to remove the misunderstanding dependency.
  • the notation of the variable a2 in the imperative sentence ST44 to "a2_i” and changing the notation of the variable a2 in the imperative sentence ST54 to "a2_i1 it is possible to delete the misuse dependence which makes the variable a2 the cause of the dependence. Can.
  • FIG. 9 (a) is a diagram showing an iteration i in which the appearance dependency is deleted from the iteration i shown in FIG. 8 (a), and FIG. 9 (b) is a diagram from the iteration i + 1 shown in FIG. It is a figure which shows iteration i + 1 which eliminated the false dependence.
  • step S3 since only the apparent dependency is deleted, the true dependency continues to exist. That is, in the example shown in FIGS. 9A and 9B, the true dependency with the variables a0_i, a1_i and a2_i from the command statement ST46, ST47, ST48 to the command statement ST55 as the cause of the dependency, and the command statement ST47, ST48. There is a true dependency from the variables a1_i and a2_i to the imperative statements ST56 and ST57 due to the dependency.
  • the equivalence relation calculation unit 133 of the calculation unit 130 calculates the equivalence relation of the variable notation for each statement of the iteration i and iteration i + 1 from which the appearance dependency is deleted (step S4).
  • variable notation is calculated as follows for each statement (ST45 to ST48, ST55 to ST58) of iteration i and iteration i + 1 from which the mock dependence shown in FIGS. 9 (a) and 9 (b) is deleted. Obviously.
  • the equivalent expression set including the variables and expressions described on the right and left sides of the instruction statement ST45 is not included in the equivalent expression set. Therefore, as in the equivalent expression set E45 shown in FIG. 10A, the equivalent expression for the command statement ST45 is added to the equivalent expression set.
  • the equivalent expression set E45 indicates that the variable “b [i]” and the expression “a0 + a1 + a2” have an equivalent relationship immediately after the instruction statement ST45 is executed.
  • an equivalent expression in this example, (A in this example, (A in this example) includes a variable (in this example, “a1_i”) described on the right side of the instruction statement ST56). a1_i, a2)) is already included in the equivalent expression set E55. Therefore, a variable ("a0_i1" in this example) described on the left side of the command statement ST56 is added to the equivalent expression (see the equivalent expression set E56 in FIG. 10B).
  • the identifying unit 140 determines whether all true dependencies can be deleted based on the equivalence relation of the variable notation calculated by the equivalence relation calculating unit 133 in step S4 (step S5).
  • variable “a2_i” that causes the true dependency is equivalent to the variable “a [i + 3]”. Also, this variable “a [i + 3]” is not the variable that is the cause of the dependency specified in step S 2 and the variable that is introduced in order to delete the apparent dependency in step S 3. Therefore, the notation of the variable “a2_i” can be replaced with the notation of the variable “a [i + 3]”.
  • variable “a0_i” causing true dependency is equivalent to the variable “a1”
  • variable “a1_i” causing true dependency is equivalent to the variable “a2”.
  • the variable “a1” and the variable “a2” are variables causing the dependence specified in step S2
  • the respective representations of the variable “a0_i” and the variable “a1_i” causing the true dependence can not be replaced. .
  • the identifying unit 140 determines that all true dependencies can not be deleted (step S5: NO).
  • the identifying unit 140 sets the value of m to “2” (step S7 in FIG. 6), and in this example, the value of m is kmax (“99” in this example) to kmin (“0” in this example) Is smaller than the value obtained by subtracting (step S8: YES), the value of m ("2" in this example) is notified, and the process is instructed to the calculation unit 130.
  • the iteration expansion unit 131 performs iteration expansion on i + m (in this example, “i + 2”) as in the process of step S1 (step S9).
  • the hash dependency dependency deletion unit 132 in the calculation unit 130 deletes the shadow dependency in the same manner as the processing in step S3 (step S11). ).
  • the equivalence relation calculation unit 133 of the calculation unit 130 calculates the equivalence relation of the variable notation for each statement statement of iteration i + m-1 and iteration i + m from which the appearance dependency is deleted as in the process of step S4 ( Step S12).
  • FIG. 11 (a) is a diagram showing an iteration i + 2 in which the sham dependency is deleted
  • FIG. 11 (b) is a diagram showing the equivalent relation of variable notation for each statement of the iteration i + 2 in which the sham dependency is deleted. It is a figure which shows a result.
  • the equivalent expression set E65 shown in FIG. 11B is based on the instruction statement ST65 shown in FIG. 11A, and the equivalent expression “(b [i + 2], a0_i1 + a1_a1 + a2_i1)” is shown in FIG. It is added to the set of equivalent expressions E58 shown.
  • the identifying unit 140 determines whether all true dependencies can be deleted based on the equivalence relation of the variable notation calculated by the equivalence relation calculating unit 133 in step S12, as in the process of step S5 (step S12). Step S13).
  • variable “a2_i1” causing true dependency is equivalent to the variable “a [i + 4]”
  • variable “a1_i1” causing true dependency is , Equivalent to the variable "a [i + 3]”.
  • the variable “a [i + 4]” and the variable “a [i + 3]” are not the variables causing the dependence specified in steps S2 and S10 and the variables introduced for deleting the apparent dependence in steps S3 and S7. .
  • the notation of the variable “a2_i1” can be replaced with the notation of the variable “a [i + 4]” and the notation of the variable “a1_i1” can be replaced with the notation of the variable “a [i + 3]”.
  • variable “a0_i1” that causes true dependency is equivalent to the variable “a1_i” and the variable “a2”.
  • the variable “a1_i” is a variable used to delete the apparent dependence in step S3
  • the variable “a2” is a variable that causes the dependence specified in step S2. Therefore, the representation of the variable “a0_i1” that causes true dependence can not be replaced. Therefore, the identifying unit 140 determines that all true dependencies can not be deleted (step S13: NO).
  • the identifying unit 140 increments the value of m by 1 to “3” (step S14), and the value of m is kmax (“99” in this example) to kmin (“0” in this example). “) Is smaller than the value obtained by subtracting“) ”(step S 8: YES), the value of m is notified, and the process is instructed to the calculation unit 130.
  • the calculation unit 130 instructed to perform the process performs the process of steps S9 to S12 as described above.
  • FIG. 12 (a) is a diagram showing the iteration i + 3 with the seeming dependency removed
  • FIG. 12 (b) is a diagram showing the equivalence relation of variable notation for each statement of the iteration i + 3 with the seeming dependency removed. It is a figure which shows a result.
  • variable “a2_i2” causing true dependency is equivalent to the variable “a [i + 5]”
  • variable “a1_i2” causing true dependency is equivalent to the variable “a [i + 3]”.
  • variables “a [i + 5]”, “a [i + 4]” and “a [i + 3]” delete the variables that cause the dependence specified in steps S2 and S10 and the apparent dependence in steps S3 and S7. It is not a variable introduced to
  • the notation of the variable “a2_i2” is the notation of the variable “a [i + 5]
  • the notation of the variable “a1_i2” is the notation of the variable “a [i + 4]
  • the notation of the variable “a0_i2” is the variable “a [i + 3] It can be replaced with the notation of]].
  • the identifying unit 140 determines that all true dependencies can be deleted (step S13: YES), and the generating unit 150 generates an iteration i + m (in this example, “i + 3”) in which all true dependencies can be deleted. Iteration candidate is generated on the basis of) (step S15).
  • FIG. 13A is a diagram showing an iteration i + 3 in which all true dependencies are deleted.
  • the generation unit 150 sets “i + 3” to k and sets the notation of the variable “a0_i3” to the notation of the variable “a0_k” and the notation of the variable “a1_i3” to the variable “a1_k”.
  • iteration candidate candidates are generated by replacing the notation of the variable "a2_i3" with the notation of the variable "a2_k”.
  • FIG. 13 (b) is a diagram showing the iteration deformation candidates generated by the generation unit 150.
  • This iteration modification candidate is applicable to iterations in which k is from kmin + m ("3" in this example) to kmax ("99" in this example). That is, in the range of at least 3 ⁇ k ⁇ kmax, the block B1 of the loop processing R1 shown in FIG. 2A can be replaced with an equivalent block having no dependency between iterations.
  • the specifying unit 140 notifies the calculation unit 130 of processing by notifying the values of kmin (“0” in this example) and m ⁇ 1 (“2” in this example).
  • the iteration expansion unit 131 of the calculation unit 130 which has been instructed to perform the process, performs the iteration expansion for each of kmin to m-1 as in the process of step S1 (step S16 in FIG. 7).
  • the apparent dependence deletion unit 132 specifies the dependency between each instruction statement for the iteration kmin to the iteration m-1 in the same manner as in step S2 (step S17 in FIG. 7), and the same as the process in step S3. To remove the sham dependency (step S18).
  • the iterations I1 to I3 shown in FIG. 14 (a) indicate iterations 0 to 2 in the loop processing R1 shown in FIG. 2 (a).
  • iterations I10 to I30 shown in FIG. 14B indicate iterations 0 to 2 in which the appearance dependency is deleted from the iterations 0 to 2 shown in FIG. 14A.
  • the instruction sentences ST1 to ST3 shown in FIG. 14 (b) are the instruction sentences ST1 to ST3 immediately before the loop processing R1 shown in FIG. 2 (a).
  • the equivalence relation calculation unit 133 calculates the equivalence relation of the variable notation for each instruction statement from the iteration kmin to the iteration m-1 for which the apparent dependence has been deleted, as in the process of step S4 (step S19). .
  • FIG. 15 is a diagram showing the result of calculating the equivalence relation of variable notation for each of the instruction sentences ST1 to ST3 shown in FIG. 14 (b) and the instruction sentences of iteration 0 to 1 from which the appearance dependency is deleted.
  • FIG. 16 is a diagram showing the result of calculating the equivalence relation of variable notation for each statement of iteration 2 from which the sham dependency shown in FIG. 14 (b) has been deleted.
  • the identifying unit 140 determines whether all true dependencies can be deleted based on the equivalence relation of the variable notation calculated by the equivalence relation calculating unit 133 in step S19. It determines (step S20).
  • variable "a0” causing true dependency is equivalent to the variable "a [0]”
  • variable "a1” causing true dependency is a variable
  • the variable “a2” that is equivalent to a [1] "and causes true dependence is equivalent to the variable” a [2] ".
  • the variables “a [0]”, “a“ 1 ”and“ a [2] ” are introduced to delete the dependency causing cause of the dependency specified in step S17 and the apparent dependency in step S18. Not a variable.
  • the notation of the variable “a0” of the command statement ST15 shown in FIG. 14B is the notation of the variable “a [0]” and the notation of the variable “a1” is the notation of the variable “a [1]”.
  • the notation of "a2" can be replaced by the notation of variable "a [2]”.
  • the representation of the variable “a1” of the command statement ST16 shown in FIG. 14B can be replaced with the representation of the variable “a [1]”.
  • the notation of the variable “a2” of the instruction sentence ST17 shown in FIG. 14B can be replaced with the notation of the variable “a [2]”.
  • the identifying unit 140 determines that all true dependencies can be deleted (step S20: YES), and iterates from the iteration kmin (“0” in this example) from which all true dependencies are deleted. It is determined whether or not 1 ("2" in this example) is isomorphic to the iteration m-1 based on the iteration kmin in the iteration deformation candidate generated in step S15 (step S21).
  • the iterations I11, I21, and I31 shown in FIG. 17A indicate iterations in which true dependencies have been removed from iterations 0 to 2 (I10, I20, and I30) in which the spurious dependencies shown in FIG. ing.
  • the identifying unit 140 determines that the shape is the same (step S21: YES), and the generating unit 150 replaces block B1 of the loop processing R1 of the source program 11 with an iteration deformation candidate for optimization. And an assembler program 12 based on the parallelized program is generated (step S22).
  • FIG. 17B shows a partial program P2 in which the block B1 of the partial program P1 shown in FIG. 2A is replaced with an iteration modification candidate shown in FIG. 13B.
  • An optimized partial program P3 (see FIG. 18) in which the sentence ST4 and the instruction sentences ST92 to ST94 are deleted can be generated.
  • the generation unit 150 also generates a partial program P4 (see FIG. 2B) in which the partial program P3 is parallelized. Further, the generation unit 150 stores the assembler program 12 generated based on the source program including the partial program P4 in the storage device 10, and the program generation device 100 ends the program generation process.
  • the description for instructing parallelization in the partial program P4 shown in FIG. 2B conforms to the OpenMP description format.
  • the program generation apparatus 100 is an example of generating an assembler program 12 from a source program 11 including a loop process having a true dependency between two iterations of successive iteration numbers.
  • loop processing having a true dependency between two iterations in which iteration numbers are not consecutive for example, loop processing R5 shown in FIG. 19A and loop processing R7 shown in FIG. 19C
  • the assembler program 12 may be generated from the source program 11.
  • FIG. 19B shows a loop processing R6 which does not have the true dependence relationship equivalent to the loop processing R5.
  • FIG. 19 (d) shows a loop processing R8 which does not have the true dependency relationship equivalent to the loop processing R7.
  • iteration expansion is performed for the iteration number s (i + 2 ⁇ s ⁇ N), and the dependency between each statement of iteration i and iteration s is specified. If there is no true dependency relationship, the iteration expansion and the specification of the dependency relationship are repeated while increasing s one by one, and if there is a true dependency relationship, iterations i + 1 in steps S3 and S4 Are replaced with the iteration s, and the processes of steps S3 and S4 are performed.
  • step S6 is changed to be set to s
  • m in step S7 of FIG. 6 is set to be set to s + 1
  • step S8 and subsequent steps can be processed in the same manner as described in the embodiment. .
  • the compiler can generate an assembler program similar to an assembler program generated by referring to a source program including the loop processing R6 shown in FIG. 19 (b) and the loop processing R8 shown in FIG. 19 (d).
  • step S21 of FIG. 7 the iteration m-1 from the iteration kmin from which all true dependencies have been deleted, the iteration modification generated in step S15 of FIG.
  • step S21: NO it has been described that the program generation processing is ended without generating the assembler program 12.
  • the loop processing is divided into partial loop processing X in which the loop control variable is in the range from kmin to m-1, and partial loop processing Y in which the loop control variable is in the range from m to kmax.
  • An assembler program 12 configured to be capable of parallel execution may be generated by the processor of FIG.
  • the program generation apparatus 100 has been described as generating the assembler program 12 by referring to the source program 11.
  • the program generation apparatus may be modified to include the assembler 210 and the linker 220, and the program generation apparatus according to this modification may generate the target program 14 by referring to the source program 11.
  • linker 220 has been described as linking the relocatable binary program 13 for which the address assignment and the like of the unresolved data has been determined with the necessary library and the like, naturally, a plurality of relocations are possible
  • the binary programs 13 may be connected to each other.
  • the equivalence relation calculation unit 133 of the calculation unit 130 in the program generation apparatus 100 calculates the equivalence relation of variable notation using a method similar to the method described in Patent Document 2. Although this is described as an example, this is an example, and may be calculated by another method.
  • the program for causing the processor to execute the program generation process (see FIGS. 5 to 7) described in the embodiment can be recorded on a recording medium or distributed and distributed via various communication paths and the like.
  • Such recording media include an IC card, an optical disc, a flexible disc, a ROM, a flash memory and the like.
  • the distributed and distributed programs are used by being stored in a processor-readable memory or the like of the device, and the processors execute the programs to execute the programs.
  • Each function of the program generation device described in the embodiment Is realized.
  • the program generation apparatus 100 may be applied with a combination of some or all of the above (1) to (5).
  • a program generation device is a loop processing that repeatedly processes a block consisting of one or more command statements N times (N ⁇ 2), and i (1 ⁇ i ⁇ N) A target including a loop process in which a variable defined in an instruction statement in the block related to the first execution has a dependency referred to in an instruction statement in the block related to the jth execution (i ⁇ j ⁇ N)
  • a program generating apparatus for generating a new program by referring to a source program, wherein the block involved in the i-th execution and one or more blocks involved in the execution other than the i-th execution are regarded as target blocks.
  • the dependence relationship may be calculated based on an equivalence relation of the variable notation calculated by the calculation means and a calculation means for calculating the equivalence relation of the variable notation in the target block.
  • a so-called true statement is generated between the statement in the block relating to the i-th execution and the statement in the block relating to the j-th execution.
  • processing of M times of loop processing can be independently executed in parallel by a plurality of processors, and loop processing can be executed at high speed.
  • the program generation apparatus is useful for generating a program for executing loop processing at high speed using a plurality of processors by referring to a source program including loop processing having a true dependency relationship.
  • the representation of the other variable having no dependency relation equivalent to the representation of the target variable specified by the specifying means may be a representation of a variable different from the representation of any target variable.
  • this program generation apparatus performs high-speed processing by independently performing processing for M times of loop processing independently and in parallel by referring to a target source program including loop processing having a true dependency relationship. It can create programs that can be run.
  • the calculation means performs the calculation process with the block relating to the i-th execution and the block relating to the i + 1-th execution as the target block, and the identification means determines the calculation means
  • the notations of all the target variables are notations of other variables not having the dependency relation equivalent to the notation of the target variables, It is determined whether or not the expression of a variable different from the expression of any target variable can be specified, and while the result of the determination process is negative, the calculation process is performed by the calculation means while increasing i by one. It may be repeated.
  • this program generation device when i is n (n ⁇ N), with respect to the representations of all the target variables in the true dependency relation, there is no other true dependency relation equivalent to the representation of the target variables. If it is possible to specify the notation of the variable of, the true dependence relationship equivalent to the expression of all target variables in the true dependence relationship to perform at least n to N loop processing for Nn times You can create programs that contain statements that contain representations of other variables.
  • the program referred to by the program generation device is a program for execution by a single processor
  • the program generated by the generation means is a program for parallel execution by a plurality of processors. It may be
  • this program generation device by referring to a program to be executed by a single processor, it is possible to generate a program for parallel execution by a plurality of processors. Therefore, for example, when a program created by a programmer for executing on a single processor already exists, it is not necessary to re-create a program for parallel execution on multiple processors. Therefore, it is possible to save time and effort for creating a program.
  • the generation unit changes the generated program so as to execute N-M times of the loop processing when M ⁇ N, the processing of the program after the change, and the target source It may be determined whether or not the processing of the program is equivalent, and if it is equivalent, the generated program may be replaced with the program after the change.
  • the program for performing N times of processing of this loop processing includes, for the representation of all object variables in a true dependency relationship, the representations of other variables having no true dependency relationship equivalent to the representation of the object variable. Is a program that contains an imperative statement. Therefore, it becomes possible to execute the loop processing for N times at high speed by independently executing in parallel on a plurality of processors.
  • a program generation apparatus is a new program for performing predetermined processing realized by the loop processing with a plurality of processors in parallel, with reference to a source program including the loop processing having a so-called true dependency relationship. Is used to generate various programs.

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

 プログラム生成装置は、ブロックを繰り返しN回(N≧2)処理する、i(1≦i<N)回目の実行に係る前記ブロック内で定義された変数が、j(i<j≦N)回目の実行に係る前記ブロック内で参照される依存関係にあるループ処理を含むソースプログラムを参照し、i回目の実行に係る前記ブロック及びi回目以外の実行に係る1以上の前記ブロックにおける変数表記の等価関係を算出し、前記依存関係にある全ての対象変数の表記について、当該対象変数の表記と等価な前記依存関係のない他の変数の表記を特定し、前記ループ処理のM回分(M≦N)の処理を行うための、特定した他の変数の表記を含んだ命令文を含むプログラムを生成する。

Description

プログラム生成装置、プログラム生産方法及びプログラム
 本発明は、ループ処理を含むソースプログラムを参照して、新たなプログラムを生成する技術に関する。
 ループ処理を含むソースプログラムを参照して、そのループ処理により実現される所定処理を複数のプロセッサにより分担して実行させるための新たなプログラムを生成するコンパイラ等が知られている(例えば、特許文献1)。
 ここで、ループ処理とは、1以上の命令文からなるブロックを繰り返しN(N≧2)回処理するものである。
 特許文献1の技術によれば、例えば、N回分のループ処理を、N/2回分ずつ処理する2個の部分ループ処理に分割し、2個のプロセッサで独立して並列実行させるよう構成した新たなプログラムを生成することができる。従って、特許文献1の技術によれば、N回のループ処理を高速に実行することができるようになる。
 しかしながら、ソースプログラムに含まれるループ処理において、i(1≦i<N)回目の実行に係るブロック内の命令文で定義された変数を、j(i<j≦N)回目の実行に係るブロック内の命令文で参照するような依存関係が存在する場合には、特許文献1の方法では対応できない。つまり、特許文献1の方法では、このような依存関係を有するループ処理を含むソースプログラムからは、複数のプロセッサを用いてループ処理を高速に実行するためのプログラムを生成することはできない。
 そこで、本発明は係る問題に鑑みてなされたものであり、上記依存関係を有するループ処理を含むソースプログラムを参照することにより、複数のプロセッサを用いてループ処理を高速に実行するためのプログラムの生成に有用なプログラム生成装置を提供することを目的とする。
 上記課題を解決するために、本発明に係るプログラム生成装置は、1つ以上の命令文からなるブロックを繰り返しN回(N≧2)処理するループ処理であって、i(1≦i<N)回目の実行に係る前記ブロック内の命令文で定義された変数が、j(i<j≦N)回目の実行に係る前記ブロック内の命令文で参照される依存関係にあるループ処理を含む対象ソースプログラムを参照することにより、新たなプログラムを生成するプログラム生成装置であって、i回目の実行に係る前記ブロックと、i回目以外の実行に係る1以上の前記ブロックとを対象ブロックとして、当該対象ブロックにおける変数表記の等価関係を算出する算出処理を行う算出手段と、前記算出手段が算出した変数表記の等価関係に基づいて、前記変数のうち、前記依存関係にある全ての対象変数の表記について、当該対象変数の表記と等価な前記依存関係のない他の変数の表記を特定する特定処理を行う特定手段と、前記ループ処理のM回分(M≦N)の処理を行うための、前記特定手段が特定した他の変数の表記を含んだ命令文を含むプログラムを生成する生成手段とを備えることを特徴とする。
 上記構成を備える本発明に係るプログラム生成装置は、上記依存関係を有するループ処理を含むソースプログラムを参照することにより、複数のプロセッサを用いてループ処理を高速に実行するためのプログラムを生成し得る。
実施の形態に係るプログラム生成装置100を含むコンパイラシステム1000の構成を示すブロック図である。 ループ処理R1を含む部分プログラムP1及びループ処理R4を含む部分プログラムP4を示す図である。 データの依存関係を説明するための図である。 ループ処理R1におけるデータの依存関係を説明するための図である。 プログラム生成装置100によるプログラム生成処理を示すフローチャートであり、図6へ続く。 プログラム生成装置100によるプログラム生成処理を示すフローチャートであり、図5から続き、図7へ続く。 プログラム生成装置100によるプログラム生成処理を示すフローチャートであり、図6から続く。 ループ処理R1におけるイタレーションi及びイタレーションi+1を示す図である。 みせかけ依存を削除したイタレーションi及びイタレーションi+1を示す図である。 みせかけ依存を削除したイタレーションi及びイタレーションi+1の各命令文についての変数表記の等価関係を算出した結果を示す図である。 みせかけ依存を削除したイタレーションi+2及びみせかけ依存を削除したイタレーションi+2の各命令文についての変数表記の等価関係を算出した結果を示す図である。 みせかけ依存を削除したイタレーションi+3及びみせかけ依存を削除したイタレーションi+3の各命令文についての変数表記の等価関係を算出した結果を示す図である。 全ての真依存を削除したイタレーションi+3及びイタレーション変形候補を示す図である。 ループ処理R1におけるイタレーション0~2及びみせかけ依存を削除したイタレーション0~2を示す図である。 みせかけ依存を削除したイタレーション0及び1の各命令文についての変数表記の等価関係を算出した結果を示す図である。 みせかけ依存を削除したイタレーション2の各命令文についての変数表記の等価関係を算出した結果を示す図である。 真依存を削除したイタレーション0~2及び部分プログラムP2を示す図である。 部分プログラムP3を示す図である。 ループ処理R5~R8を示す図である。 変数表記の等価関係の算出を行う他の方法の例を説明するための図である。
 以下、本発明の実施の形態について、図面を参照しながら説明する。
 ≪実施の形態≫
 <概要>
 図2は、処理完了時において、配列b[k](0≦k≦99)について、同一の処理結果を得ることが可能な等価な部分プログラムP1とP4とを示す図である。
 実施の形態に係るプログラム生成装置は、従来のコンパイラを改良したものであり、従来のコンパイラが、プログラマにより予め生成された、図2(b)に示す部分プログラムP4を含むソースプログラムを参照することにより生成し得たアセンブラプログラムと同様のアセンブラプログラムを、図2(a)に示す部分プログラムP1を含むソースプログラムを参照することにより生成するものである。
 ここで、部分プログラムP1は、真依存の関係を有するループ処理R1を含むものである。真依存の関係については、後に詳細に説明するが、ループ制御変数kがi(0≦i<99)である場合に実行されるブロックB1内の命令文で定義された変数が、ループ制御変数kがi+1である場合に実行されるブロックB1内の命令文で参照されるような関係をいう。
 真依存の関係を有する命令文間の実行順序が、本来の実行順序と逆転してしまうと、正しい結果が得られないことになるため、このループ処理R1は、ループ制御変数kを1ずつ増加させながら、逐次実行されるのが一般的である。
 一方、部分プログラムP4に含まれるループ処理R4は、上述のような真依存の関係を有しないものである。従って、複数のプロセッサを用いて実行することが可能になる。例えば、ループ処理R4を、ループ制御変数kが0から49までの部分ループ処理と、ループ制御変数kが50から99までの部分ループ処理とに分けて、2つのプロセッサに独立して並列実行させることが可能である。これにより、1つのプロセッサでループ制御変数kが0から99までについてのループ処理R1を逐次実行する場合と比較し、より高速にループ処理を実行することができる。
 上述のように、実施の形態に係るプログラム生成装置は、図2(a)に示す部分プログラムP1を含むソースプログラムを参照することにより、従来のコンパイラが、図2(b)に示す部分プログラムP4を含むソースプログラムを参照することにより生成し得たアセンブラプログラムと同様のアセンブラプログラムを生成できる。
 従って、部分プログラムP1のように、真依存の関係を有するループ処理を含むソースプログラムが既に生成されている場合に、部分プログラムP4のように、真依存の関係を有しないループ処理を含むソースプログラムを生成しなおすことなく、並列実行に適したアセンブラプログラムを生成することができる点で、実施の形態に係るプログラム生成装置は有効である。
 なお、部分プログラムP1は、上述のように真依存の関係を有するループ処理R1を含むものの、以下説明する理由から、部分プログラムP4と比べて、単一のプロセッサでの高速実行に適したプログラムであるといえる。
 ここで、プログラム内の変数をなるべくレジスタに割り当てるようにすることで、プログラムをより高速に実行できることが一般的に知られている。これは、メモリと比較し、レジスタへのアクセスは、きわめて高速に行えるためである。
 一般的なコンパイラにおいては、部分プログラムP1に含まれるa0、a1、a2のような単純変数には、特定のレジスタが割り当てられる可能性が高い。従って、部分プログラムP1を実行する場合には、部分プログラムP4を実行する場合より、メモリへのアクセス回数を減らすことができる。つまり、単一のプロセッサを用いた場合、部分プログラムP1は、部分プログラムP4より高速に実行することができる。
 <データの依存関係>
 上記真依存をはじめとするデータの依存関係について、図3を用いて説明する。
 図3は、データの依存関係を説明するための図である。
 同図に示すように、命令文ST100で定義された変数aは、この命令文ST100より後に実行される命令文ST200で参照される関係にある。このような関係にある場合に、命令文ST100から命令文ST200への「真依存」があるという。
 また、同図に示すように、命令文ST200で参照された変数aは、この命令文ST200より後に実行される命令文ST300で定義される関係にある。このような関係にある場合に、命令文ST200から命令文ST300への「逆依存」があるという。
 また、同図に示すように、命令文ST100で定義された変数aは、命令文ST300で再定義される関係にある。このような関係にある場合に、命令文ST100から命令文ST300への「出力依存」があるという。
 また、以下では、真依存、逆依存及び出力依存の発生原因となっている変数を「依存の原因となる変数」という。図3では、変数aが、「依存の原因となる変数」である。
 なお、「逆依存」と「出力依存」については、依存関係にある各命令文において、依存の原因となる変数の表記を、相互に異なるものに置き換えることで、その依存が削除できることが知られている(例えば、非特許文献1の120ページ参照)。そのため、「逆依存」及び「出力依存」は、「みせかけ依存」と呼ばれることがある。
 上記部分プログラムP1におけるループ処理R1を例に、データの依存関係を具体的に説明する。
 図4は、図2(a)に示すループ処理R1におけるデータの依存関係を説明するための図である。
 以下では、ループ制御変数がm(mはループ制御変数が取りうる任意の値)である場合に実行されるループ内のブロックのことを、「イタレーションm」といい、イタレーションmを生成することを、「mについてのイタレーション展開」といい、このmのことを、「イタレーション番号」という。
 図4(a)は、図2(a)に示すループ処理R1におけるループ制御変数kが0である場合に実行されるブロックB1、つまり、イタレーション0を、図4(b)は、イタレーション1を示している。
 ここで、図4(a)に示すイタレーション0の命令文ST12、ST13、ST14でそれぞれ定義されている変数a0、a1、a2は、図4(b)に示すイタレーション1の命令文ST21で参照される関係にある。
 また、図4(a)に示すイタレーション0の命令文ST13、ST14でそれぞれ定義されている変数a1、a2は、図4(b)に示すイタレーション1の命令文ST22、ST23で参照される関係にある。
 即ち、変数a0を依存の原因とした、命令文ST12からST21への真依存がある。また、変数a1を依存の原因とした、命令文ST13からST21への真依存及び命令文ST13からST22への真依存がある。また、変数a2を依存の原因とした、命令文ST14からST21への真依存及び命令文ST14からST23への真依存がある。
 また、図4(a)に示すイタレーション0の命令文ST12で定義された変数a0は、図4(b)に示すイタレーション1の命令文ST22で再定義される関係にある。
 即ち、変数a0を依存の原因とした、命令文ST12からST22への出力依存がある。同様に、変数a1を依存の原因とした、命令文ST13からST23への出力依存があり、変数a2を依存の原因とした、命令文ST14からST24への出力依存がある。
 また、図4(b)に示すイタレーション1の命令文ST21で参照された変数a0、a1、a2は、命令文ST22~ST24でそれぞれ定義される関係にある。即ち、変数a0を依存の原因とした、命令文ST21からST22への逆依存があり、変数a1を依存の原因とした、命令文ST21からST23への逆依存があり、変数a2を依存の原因とした、命令文ST21からST24への逆依存がある。
 また、イタレーション0においても同様に、変数a0、変数a1、変数a2を依存の原因とした逆依存がある。
 なお、以下では、ループ処理における、あるイタレーション内の命令文から他のイタレーション内の命令文への依存があることを、「イタレーション間に依存関係を有する」ともいう。
 <構成>
 図1は、実施の形態に係るプログラム生成装置100を含むコンパイラシステム1000の構成を示すブロック図である。
 コンパイラシステム1000は、上記部分プログラムP1のように、イタレーション間に真依存の関係を有するループ処理を含むソースプログラム11を参照することにより、複数のプロセッサによるループ処理の並列実行が可能な目的プログラム14を生成するものである。
 コンパイラシステム1000は、プロセッサ(不図示)と、メモリ(不図示)と、ハードディスク等の記憶装置10とを含むコンピュータ(例えば、PC(Personal Computer))により実現される。
 コンパイラシステム1000は、同図に示すように、記憶装置10と、プログラム生成装置100と、アセンブラ210と、リンカ220とを含んで構成される。なお、プログラム生成装置100、アセンブラ210及びリンカ220の各機能は、上記プロセッサが、記憶装置10に記憶されている図示しないプログラムを上記メモリに読み込み、読み込んだプログラムを実行することによって実現される。
 ここで、プログラム生成装置100は、従来のコンパイラを改良したものであり、記憶装置10に記憶されている、C言語やC++言語等の高級言語で記述されたソースプログラム11を参照して、アセンブラプログラム12を生成する機能を有する。プログラム生成装置100は、生成したアセンブラプログラム12を記憶装置10へ格納する。
 即ち、プログラム生成装置100は、イタレーション間に真依存の関係を有するループ処理を含むソースプログラム11を参照することにより、この真依存の関係が解消されたループ処理を実行するためのアセンブラプログラム12を生成する。
 また、アセンブラ210は、プログラム生成装置100により記憶装置10へ格納されたアセンブラプログラム12を参照して、機械語で記述された再配置可能バイナリプログラム13を生成する機能を有する。アセンブラ210は、生成した再配置可能バイナリプログラム13を記憶装置10へ格納する。
 また、リンカ220は、アセンブラ210により記憶装置10へ格納された再配置可能バイナリプログラム13において未解決なデータのアドレス配置等を決定し、必要なライブラリ等と連結することで、コンピュータが実行可能な目的プログラム14を生成する機能を有する。リンカ220は、生成した目的プログラム14を記憶装置10へ格納する。
 以下では、プログラム生成装置100の構成について、図1を用いて、より詳しく説明する。
 同図に示すように、プログラム生成装置100は、記憶部110と、取得部120と、算出部130と、特定部140と、生成部150とを備える。
 ここで、記憶部110は、ソースプログラム11や、算出部130、特定部140及び生成部150による処理結果を格納するためのメモリ領域である。
 即ち、以下では特に明記しないが、算出部130、特定部140及び生成部150間における処理結果のやり取りは、記憶部110を介して行われることとする。
 また、取得部120は、記憶装置10からソースプログラム11を読み出し、記憶部110に格納する機能を有する。
 算出部130は、取得部120により記憶部110に格納されたソースプログラム11に含まれているループ処理における、あるイタレーション及び他の1以上のイタレーションについての変数表記の等価関係を算出する機能を有する。算出部130は、イタレーション展開部131と、みせかけ依存削除部132と、等価関係算出部133とを含む。
 ここで、イタレーション展開部131は、ソースプログラム11に含まれているループ処理に基づいて、イタレーション展開を行う機能を有する。
 みせかけ依存削除部132は、イタレーション展開部131がイタレーション展開を行った、イタレーション番号が連続する2つのイタレーション間に存在するみせかけ依存(即ち出力依存及び逆依存)を削除する機能を有する。
 ここでは、依存関係にある2つの命令文における依存の原因となる変数の表記を相互に異なるものに置き換えるという従来から行われている方法と同様の方法を用いて、みせかけ依存の削除を行うこととする。
 等価関係算出部133は、みせかけ依存削除部132によりみせかけ依存が削除された後の上記2つのイタレーションの各命令文についての変数表記の等価関係を算出する機能を有する。ここでは、特許文献2において説明されている方法と同様の方法を用いて、変数表記の等価関係の算出を行うこととする。
 また、特定部140は、等価関係算出部133が算出した変数表記の等価関係に基づいて、上記2つのイタレーション間に存在する真依存の原因となる全ての変数を、等価な依存関係のない他の変数や式に置き換えることで、全ての真依存を削除できるか否かを判定する機能を有する。
 また、この判定結果に基づいて、特定部140は、算出部130による変数表記の等価関係の算出の実行を制御する機能及び以下説明する判定を行う機能を有する。即ち、この判定は、ソースプログラム11に含まれているループ処理内のブロックを、以下説明する生成部150により生成されたイタレーション変形候補で置き換えることができるか否かを判定するものである。
 生成部150は、特定部140が上記2つのイタレーション間に存在する全ての真依存を削除できると判定した際に、全ての真依存を削除したイタレーションに基づいて、イタレーション変形候補を生成する機能を有する。
 詳しくは後述するが(図13(a)及び(b)参照)、イタレーション変形候補は、上記全ての真依存を削除したイタレーションを、そのイタレーション番号以降のイタレーションにも適用できるように一般化したものである。
 また、生成部150は、特定部140がソースプログラム11に含まれているループ処理内のブロックをイタレーション変形候補で置き換えることができると判定した際に、アセンブラプログラム12を生成する機能を有する。このアセンブラプログラム12は、ソースプログラム11に含まれているループ処理内のブロックを、イタレーション変形候補で置き換えたソースプログラムに基づくものである。
 <動作>
 以下では、プログラム生成装置100の動作を説明する。
 図5~7は、プログラム生成装置100によるプログラム生成処理を示すフローチャートである。
 プログラム生成装置100の取得部120が、記憶装置10からソースプログラム11を読み出し、記憶部110に格納する。算出部130のイタレーション展開部131は、ソースプログラム11に含まれるループ処理におけるループ制御変数の任意の値を示すiと、i+1とについてのイタレーション展開を行う(図5のステップS1)。
 算出部130のみせかけ依存削除部132は、イタレーションi及びイタレーションi+1の各命令文間の依存関係を特定する(ステップS2)。また、みせかけ依存削除部132は、みせかけ依存(即ち、出力依存と逆依存)の原因となる変数の表記を変更することで、みせかけ依存を削除する(ステップS3)。
 算出部130の等価関係算出部133は、みせかけ依存を削除したイタレーションi及びイタレーションi+1の各命令文についての変数表記の等価関係を算出する(ステップS4)。
 この変数表記の等価関係の算出方法は、上述のように、特許文献2において説明されている方法と同様の方法であるため、以下、簡単に説明するが、結果として、図10に示すような等価式集合が得られることになる。
 ここで、図10(a)及び(b)に示す“{”と“}”とで括られたものを「等価式集合」といい、等価式集合の中に記載されている“(”と“)”とで括られたものを「等価式」という。また、等価式の中に記載されている“,”で区切られた各要素は等価であることを示していることとする。
 まず、等価関係算出部133は、イタレーションi及びイタレーションi+1の各命令文を1つずつ順に処理対象として、以下の処理を行う。
 即ち、等価関係算出部133は、処理対象である命令文の右辺又は左辺に記述されている変数や式を含む等価式が、既に等価式集合に含まれているかを判定する。
 該当の等価式が等価式集合に含まれていないと判定した場合には、処理対象である命令文についての新たな等価式を等価式集合に追加する。
 また、処理対象である命令文の右辺に記述されている変数や式を含む等価式が、既に等価式集合に含まれていると判定した場合には、その等価式の要素として、その処理対象である命令文の左辺に記述されている変数や式を追加する。
 また、処理対象である命令文の左辺に記述されている変数や式を含む等価式が、既に等価式集合に含まれていると判定した場合には、その等価式に代えて、処理対象である命令文についての新たな等価式を等価式集合に追加する。
 プログラム生成処理の続きを説明する(図5参照)。
 ステップS4の処理が完了すると、特定部140は、等価関係算出部133が算出した変数表記の等価関係に基づいて、全ての真依存を削除することができるか否かを判定する(ステップS5)。
 より詳細には、真依存の原因となる全ての変数の表記を、ステップS4で算出した変数表記の等価関係に基づいて、ステップS2で特定した依存の原因となる変数及びステップS3でみせかけ依存を削除するために導入した変数以外の等価な変数や式の表記に置き換えることができる場合には、全ての真依存を削除することができると判定する(ステップS5:YES)。
 ここで、ステップS2で特定した依存の原因となる変数及びステップS3でみせかけ依存を削除するために導入した変数の表記に置き換えないのは、このような変数は、他のイタレーションにおいて新たな依存の原因となる可能性があるためである。即ち、このような変数の表記に置き換えても、結局のところ、イタレーション間の依存を削除することにならない可能性があるためである。
 全ての真依存を削除することができると判定した場合には(ステップS5:YES)、全ての真依存が削除できたイタレーションi+mにおけるmの値として、「1」を設定し(ステップS6)、図6のステップS15の処理に進む。
 また、全ての真依存を削除することができないと判定した場合には(ステップS5:NO)、特定部140は、上記mの値を「2」に設定する(図6のステップS7)。
 また、特定部140は、mの値が、ソースプログラム11に含まれるループ制御変数が取り得る最大値(以下、「kmax」と表記する)から、そのループ制御変数が取り得る最小値(以下、「kmin」と表記する)を引いた値より小さいか否かを判定する(ステップS8)。
 mの値がkmaxからkminを引いた値以上である場合には(ステップS8:NO)、真依存が削除できなかったものとして、プログラム生成装置100は、プログラム生成処理を終了する(図7参照)。
 一方、mの値がkmaxからkminを引いた値より小さい場合には(ステップS8:YES)、特定部140は、mの値を通知することで、算出部130に処理を指示する。処理を指示された算出部130のイタレーション展開部131は、ステップS1の処理と同様に、i+mについてのイタレーション展開を行う(ステップS9)。
 また、みせかけ依存削除部132は、ステップS2の処理と同様に、イタレーションi+m-1及びイタレーションi+mの各命令文間の依存関係を特定し(ステップS10)、ステップS3の処理と同様に、みせかけ依存を削除する(ステップS11)。
 また、等価関係算出部133は、ステップS4の処理と同様に、みせかけ依存を削除したイタレーションi+m-1及びイタレーションi+mの各命令文についての変数表記の等価関係を算出する(ステップS12)。
 続いて、特定部140は、ステップS5の処理と同様に、ステップS12で等価関係算出部133が算出した変数表記の等価関係に基づいて、全ての真依存を削除することができるか否かを判定する(ステップS13)。
 ここで、特定部140は、ステップS5で説明したものと同様の理由により、ステップS2及びS10で特定した依存の原因となる変数及びステップS3及びS11でみせかけ依存を削除するために導入した変数の表記を、置き換えに用いない。
 全ての真依存を削除することができないと判定した場合には(ステップS13:NO)、特定部140は、mの値を1つ増加させて(ステップS14)、再びステップS8から処理を行う。
 一方、特定部140が、全ての真依存を削除することができると判定した場合には(ステップS13:YES)、生成部150は、全ての真依存を削除したイタレーションi+mに基づいてイタレーション変形候補を生成する(ステップS15)。
 ここで、iは、ソースプログラム11に含まれるループ処理におけるループ制御変数の任意の値を示す。従って、イタレーションi+mにおいて、全ての真依存が削除できるということは、イタレーションkmin+m以降のイタレーションで全ての真依存を削除できることを意味する。
 そこで、生成部150は、イタレーション番号が、kmin+mからkmaxまでのイタレーションにも適用できるように一般化したイタレーション変形候補を生成する。
 続いて、特定部140は、kmin及びm-1の値を通知することで、算出部130に処理を指示する。処理を指示された算出部130のイタレーション展開部131は、ステップS1の処理と同様に、kminからm-1までそれぞれについてのイタレーション展開を行う(図7のステップS16)。
 また、みせかけ依存削除部132は、イタレーションkminからイタレーションm-1までのそれぞれについて、ステップS2の処理と同様に、各命令文間の依存関係を特定し(ステップS17)、ステップS3の処理と同様に、みせかけ依存を削除する(ステップS18)。
 また、等価関係算出部133は、ステップS4の処理と同様に、みせかけ依存を削除したイタレーションkminからイタレーションm-1までのそれぞれの各命令文についての変数表記の等価関係を算出する(ステップS19)。
 続いて、特定部140は、ステップS5の処理と同様に、ステップS19で等価関係算出部133が算出した変数表記の等価関係に基づいて、全ての真依存を削除することができるか否かを判定する(ステップS20)。
 特定部140が、全ての真依存を削除することができないと判定した場合には(ステップS20:NO)、ループ制御変数が、kminからm-1の範囲では、真依存を削除できなかったものとして、プログラム生成装置100は、プログラム生成処理を終了する。
 また、特定部140が、全ての真依存を削除することができると判定した場合には(ステップS20:YES)、全ての真依存を削除したイタレーションkminからイタレーションm-1が、ステップS15で生成したイタレーション変形候補におけるイタレーションkminからイタレーションm-1と同形であるか否かを判定する(ステップS21)。
 特定部140が、同形でないと判定した場合には(ステップS21:NO)、プログラム生成装置100は、プログラム生成処理を終了する。この場合、ループ制御変数がkminからm-1までの範囲に適用可能な真依存を削除したループ処理と、ループ制御変数がmからkmaxまでの範囲に適用可能な真依存を削除したループ処理とを1つのループ処理にまとめることはできないためである。
 一方、特定部140が、イタレーション変形候補におけるイタレーションkminからイタレーションm-1までと同形であると判定した場合には(ステップS21:YES)、生成部150は、以下のようにしてアセンブラプログラム12を生成する(ステップS22)。即ち、生成部150は、ソースプログラム11のループ処理内のブロックを、イタレーション変形候補に置き換えたプログラムに、最適化や並列化を行った上で、アセンブラプログラム12を生成する。
 なお、最適化や並列化は、従来から行われている方法で実現できるため、ここでは、詳細な説明は省略し、最適化や並列化が行われた後のプログラムの具体例について後述する(図18参照)。
 生成部150は、生成したアセンブラプログラム12を、記憶装置10に格納し、プログラム生成装置100は、プログラム生成処理を終了する。
 <具体例>
 以下では、ソースプログラム11を、図2(a)に示す部分プログラムP1を含むものとした場合を例に、プログラム生成装置100の動作を、図5~7に示すフローチャートに即して説明する。
 プログラム生成装置100の取得部120が、記憶装置10からソースプログラム11を読み出し、記憶部110に格納する。算出部130のイタレーション展開部131は、ソースプログラム11に含まれるループ処理(この例では、R1)におけるループ制御変数(この例では、k)の任意の値を示すiと、i+1とについてのイタレーション展開を行う(図5のステップS1)。
 図8(a)は、図2(a)に示すループ処理R1におけるイタレーションiを示す図であり、図8(b)は、イタレーションi+1を示す図である。
 算出部130のみせかけ依存削除部132は、イタレーションi及びイタレーションi+1の各命令文間の依存関係を特定する(ステップS2)。また、みせかけ依存削除部132は、みせかけ依存(即ち、出力依存と逆依存)の原因となる変数の表記を変更することで、みせかけ依存を削除する(ステップS3)。
 図8(a)及び(b)に示す例では、変数a0を依存の原因として、命令文ST42から命令文ST51への真依存と、命令文ST42から命令文ST52への出力依存と、命令文ST41から命令文ST42への逆依存と、命令文ST51からST52への逆依存とが存在する。
 また、変数a1を依存の原因として、命令文ST43から命令文ST51への真依存と、命令文ST43から命令文ST53への出力依存と、命令文ST41から命令文ST43への逆依存と、命令文ST51からST53への逆依存とが存在する。
 また、変数a2を依存の原因として、命令文ST44から命令文ST51への真依存と、命令文ST44から命令文ST54への出力依存と、命令文ST41から命令文ST44への逆依存と、命令文ST51からST54への逆依存が存在する。
 命令文ST42における変数a0の表記を「a0_i」に変更し、命令文ST52における変数a0の表記を「a0_i1」に変更することで、変数a0を依存の原因としたみせかけ依存を削除することができる。
 また、変数a0の場合と同様に、命令文ST43における変数a1の表記を「a1_i」に変更し、命令文ST53における変数a1の表記を「a1_i1」に変更することで、変数a1を依存の原因としたみせかけ依存を削除することができる。また、命令文ST44における変数a2の表記を「a2_i」に変更し、命令文ST54における変数a2の表記を「a2_i1」に変更することで、変数a2を依存の原因としたみせかけ依存を削除することができる。
 図9(a)は、図8(a)に示すイタレーションiからみせかけ依存を削除したイタレーションiを示す図であり、図9(b)は、図8(b)に示すイタレーションi+1からみせかけ依存を削除したイタレーションi+1を示す図である。
 なお、ステップS3の処理では、みせかけ依存を削除しただけなので、真依存は引き続き存在することになる。即ち、図9(a)及び(b)に示す例では、命令文ST46、ST47、ST48から命令文ST55への変数a0_i、a1_i、a2_iを依存の原因とした真依存と、命令文ST47、ST48から命令文ST56、ST57への変数a1_i、a2_iを依存の原因とした真依存が存在することになる。
 算出部130の等価関係算出部133は、みせかけ依存を削除したイタレーションi及びイタレーションi+1の各命令文についての変数表記の等価関係を算出する(ステップS4)。
 図9(a)及び(b)に示すみせかけ依存を削除したイタレーションi及びイタレーションi+1の各命令文(ST45~ST48、ST55~ST58)について、変数表記の等価関係を算出すると以下のようになる。
 なお、以下の説明開始時点において、等価式集合にはいずれの等価式も含まれていないとする。
 まず、図9(a)に示す命令文ST45を処理対象とした場合には、命令文ST45の右辺及び左辺に記述されている変数や式を含む等価式が、等価式集合に含まれていないので、図10(a)に示す等価式集合E45のように、命令文ST45についての等価式が等価式集合に追加される。
 即ち、等価式集合E45は、命令文ST45が実行された直後では、変数「b[i]」と式「a0+a1+a2」が等価な関係にあることを示している。
 図9(a)に示す命令文ST46~ST48及び図9(b)の命令文ST55を処理対象とした場合にも、命令文ST45の場合と同様に処理される(図10(a)の等価式集合E46~E48及び図10(b)の等価式集合E55参照)。
 また、図9(b)に示す命令文ST56を処理対象とした場合には、命令文ST56の右辺に記述されている変数(この例では「a1_i」)を含む等価式(この例では、(a1_i,a2))が、既に等価式集合E55に含まれている。従って、その等価式に、命令文ST56の左辺に記述されている変数(この例では、「a0_i1」)が追加される(図10(b)の等価式集合E56参照)。
 図9(b)に示す命令文ST57を処理対象とした場合も、命令文ST56の場合と同様に処理される(図10(b)の等価式集合E57参照)。
 また、図9(b)に示す命令文ST58を処理対象とした場合には、命令文ST45の場合と同様に、命令文ST58についての等価式が、等価式集合E57に追加される(図10(b)の等価式集合E58参照)。
 続いて、特定部140は、ステップS4で等価関係算出部133が算出した変数表記の等価関係に基づいて、全ての真依存を削除することができるか否かを判定する(ステップS5)。
 上述のように、図9(a)及び(b)に示す例では、変数a0_i、a1_i、a2_iを依存の原因とした真依存が存在する。
 図10(a)に示す等価式集合E48によれば、真依存の原因となる変数「a2_i」は、変数「a[i+3]」と等価である。また、この変数「a[i+3]」は、ステップS2で特定した依存の原因となる変数及びステップS3でみせかけ依存を削除するために導入した変数ではない。従って、変数「a2_i」の表記を、変数「a[i+3]」の表記に置き換えることができる。
 また、等価式集合E48によれば、真依存の原因となる変数「a0_i」は、変数「a1」と等価であり、真依存の原因となる変数「a1_i」は、変数「a2」と等価である。しかしながら、変数「a1」及び変数「a2」は、ステップS2で特定した依存の原因となる変数であるため、真依存の原因となる変数「a0_i」及び変数「a1_i」の各表記の置き換えはできない。
 従って、特定部140は、全ての真依存を削除することができないと判定する(ステップS5:NO)。
 特定部140は、mの値を「2」に設定し(図6のステップS7)、この例では、mの値がkmax(この例では「99」)からkmin(この例では「0」)を引いた値より小さいので(ステップS8:YES)、mの値(この例では「2」)を通知し、算出部130に処理を指示する。
 イタレーション展開部131は、ステップS1の処理と同様に、i+m(この例では「i+2」)についてのイタレーション展開を行う(ステップS9)。
 また、算出部130のみせかけ依存削除部132は、イタレーションi+m-1(この例では「i+1」)と、イタレーションi+mとについて、ステップS3の処理と同様に、みせかけ依存を削除する(ステップS11)。
 また、算出部130の等価関係算出部133は、ステップS4の処理と同様に、みせかけ依存を削除したイタレーションi+m-1及びイタレーションi+mの各命令文についての変数表記の等価関係を算出する(ステップS12)。
 図11(a)は、みせかけ依存を削除したイタレーションi+2を示す図であり、図11(b)は、みせかけ依存を削除したイタレーションi+2の各命令文についての変数表記の等価関係を算出した結果を示す図である。
 ここで、図11(b)に示す等価式集合E65は、図11(a)に示す命令文ST65に基づいて、等価式「(b[i+2],a0_i1+a1_i1+a2_i1)」を、図10(b)に示す等価式集合E58に追加したものになっている。
 特定部140は、ステップS5の処理と同様に、ステップS12で等価関係算出部133が算出した変数表記の等価関係に基づいて、全ての真依存を削除することができるか否かを判定する(ステップS13)。
 図9(b)及び図11(a)に示す例では、変数a0_i1、a1_i1、a2_i1を依存の原因とした真依存が存在することになる。
 図10(b)に示す等価式集合E58によれば、真依存の原因となる変数「a2_i1」は、変数「a[i+4]」と等価であり、真依存の原因となる変数「a1_i1」は、変数「a[i+3]」と等価である。また、変数「a[i+4]」及び変数「a[i+3]」は、ステップS2及びS10で特定した依存の原因となる変数及びステップS3及びS7でみせかけ依存を削除するために導入した変数ではない。
 従って、変数「a2_i1」の表記を変数「a[i+4]」の表記に、変数「a1_i1」の表記を変数「a[i+3]」の表記に置き換えることができる。
 また、等価式集合E58によれば、真依存の原因となる変数「a0_i1」は、変数「a1_i」及び変数「a2」と等価である。しかしながら、変数「a1_i」は、ステップS3でみせかけ依存を削除するために用いた変数であり、変数「a2」は、ステップS2で特定した依存の原因となる変数である。従って、真依存の原因となる変数「a0_i1」の表記の置き換えはできない。よって、特定部140は、全ての真依存を削除することができないと判定する(ステップS13:NO)。
 この例では、特定部140は、mの値を1つ増加させて「3」とし(ステップS14)、mの値がkmax(この例では、「99」)からkmin(この例では、「0」)を引いた値より小さいので(ステップS8:YES)、mの値を通知して算出部130に処理を指示する。処理を指示された算出部130は、上記同様、ステップS9~ステップS12の処理を行う。
 図12(a)は、みせかけ依存を削除したイタレーションi+3を示す図であり、図12(b)は、みせかけ依存を削除したイタレーションi+3の各命令文についての変数表記の等価関係を算出した結果を示す図である。
 図11(a)及び図12(a)に示す例では、変数a0_i2、a1_i2、a2_i2を依存の原因とした真依存が存在することになる。
 図11(b)に示す等価式集合E68によれば、真依存の原因となる変数「a2_i2」は、変数「a[i+5]」と等価であり、真依存の原因となる変数「a1_i2」は、変数「a[i+4]」と等価であり、真依存の原因となる変数「a0_i2」は、変数「a[i+3]」と等価である。また、変数「a[i+5]」、変数「a[i+4]」及び変数「a[i+3]」は、ステップS2及びS10で特定した依存の原因となる変数及びステップS3及びS7でみせかけ依存を削除するために導入した変数ではない。
 従って、変数「a2_i2」の表記を変数「a[i+5]」の表記に、変数「a1_i2」の表記を変数「a[i+4]」の表記に、変数「a0_i2」の表記を変数「a[i+3]」の表記に置き換えることができる。
 よって、特定部140は、全ての真依存を削除することができると判定し(ステップS13:YES)、生成部150は、全ての真依存が削除できたイタレーションi+m(この例では「i+3」)に基づいてイタレーション変形候補を生成する(ステップS15)。
 図13(a)は、全ての真依存を削除したイタレーションi+3を示す図である。
 図13(a)に示す例では、生成部150は、「i+3」をkとおいて、変数「a0_i3」の表記を変数「a0_k」の表記に、変数「a1_i3」の表記を変数「a1_k」の表記に、変数「a2_i3」の表記を変数「a2_k」の表記に置き換えたイタレーション変形候補を生成する。
 図13(b)は、生成部150が生成したイタレーション変形候補を示す図である。
 このイタレーション変形候補は、kが、kmin+m(この例では「3」)からkmax(この例では「99」)までのイタレーションに適用できるものである。即ち、少なくとも3≦k<kmaxの範囲においては、図2(a)に示すループ処理R1のブロックB1を、イタレーション間に依存がない等価なブロックに置き換えることができることになる。
 続いて、特定部140は、kmin(この例では「0」)及びm-1(この例では「2」)の値を通知して、算出部130に処理を指示する。処理を指示された算出部130のイタレーション展開部131は、ステップS1の処理と同様に、kminからm-1までそれぞれについてのイタレーション展開を行う(図7のステップS16)。
 また、みせかけ依存削除部132は、イタレーションkminからイタレーションm-1について、ステップS2と同様に、各命令文間の依存関係を特定し(図7のステップS17)、ステップS3の処理と同様に、みせかけ依存を削除する(ステップS18)。
 図14(a)に示すイタレーションI1~I3は、図2(a)に示すループ処理R1におけるイタレーション0~2を示している。
 また、図14(b)に示すイタレーションI10~I30は、図14(a)に示すイタレーション0~2からみせかけ依存を削除したイタレーション0~2を示している。また、図14(b)に示す命令文ST1~ST3は、図2(a)に示すループ処理R1の直前にある命令文ST1~ST3である。
 等価関係算出部133は、ステップS4の処理と同様に、みせかけ依存を削除したイタレーションkminからイタレーションm-1までのそれぞれの各命令文についての変数表記の等価関係を算出する(ステップS19)。
 図15は、図14(b)に示す命令文ST1~ST3及びみせかけ依存を削除したイタレーション0~1の各命令文についての変数表記の等価関係を算出した結果を示す図である。
 また、図16は、図14(b)に示すみせかけ依存を削除したイタレーション2の各命令文についての変数表記の等価関係を算出した結果を示す図である。
 続いて、特定部140は、ステップS5の処理と同様に、ステップS19で等価関係算出部133が算出した変数表記の等価関係に基づいて、全ての真依存を削除することができるか否かを判定する(ステップS20)。
 図15に示す等価式集合E3によれば、真依存の原因となる変数「a0」は、変数「a[0]」と等価であり、真依存の原因となる変数「a1」は、変数「a[1]」と等価であり、真依存の原因となる変数「a2」は、変数「a[2]」と等価である。また、変数「a[0]」、変数「a「1」」及び変数「a[2]」は、ステップS17で特定した依存の原因となる変数及びステップS18でみせかけ依存を削除するために導入した変数ではない。
 従って、図14(b)に示す命令文ST15の変数「a0」の表記を変数「a[0]」の表記に、変数「a1」の表記を変数「a[1]」の表記に、変数「a2」の表記を変数「a[2]」の表記に置き換えることができる。
 同様にして、図15に示す等価式集合E15に基づいて、図14(b)に示す命令文ST16の変数「a1」の表記を変数「a[1]」の表記に置き換えることができる。また、図15に示す等価式集合E16に基づいて、図14(b)に示す命令文ST17の変数「a2」の表記を変数「a[2]」の表記に置き換えることができる。
 同様にして、図15に示す等価式集合E18~E26に基づいて、図14(b)に示す命令文ST25~ST27の変数「a0_0」、変数「a1_0」及び変数「a2_0」の表記を置き換えることができる。また、図15に示す等価式集合E28及び図16に示す等価式集合E35、E36に基づいて、命令文ST35~ST37の変数「a0_1」、変数「a1_1」及び変数「a2_1」の表記を置き換えることができる。
 従って、特定部140は、全ての真依存を削除することができると判定し(ステップS20:YES)、全ての真依存を削除したイタレーションkmin(この例では「0」)からイタレーションm-1(この例では「2」)が、ステップS15で生成したイタレーション変形候補におけるイタレーションkminからイタレーションm-1と同形であるか否かを判定する(ステップS21)。
 図17(a)に示すイタレーションI11、I21、I31は、図14(b)に示すみせかけ依存を削除したイタレーション0~2(I10、I20、I30)から真依存を削除したイタレーションを示している。
 図13(b)に示すイタレーション変形候補についてのイタレーション0、イタレーション1、イタレーション3は、図17(a)に示すイタレーションI11、I21、I31と一致する。従って、この例では、特定部140は、同形であると判定し(ステップS21:YES)、生成部150は、ソースプログラム11のループ処理R1のブロックB1を、イタレーション変形候補に置き換えて最適化や並列化したプログラムに基づくアセンブラプログラム12を生成する(ステップS22)。
 図17(b)は、図2(a)に示す部分プログラムP1のブロックB1を、図13(b)に示すイタレーション変形候補に置き換えた部分プログラムP2を示している。
 この部分プログラムP2において、命令文ST1~ST3で定義される変数「a0」、変数「a1」及び変数「a2」と、命令文ST92~ST94で定義される変数「a0_k」、変数「a1_k」及び変数「a2_k」は、部分プログラムP2内の命令文では参照されない。従って、ソースプログラム11における、部分プログラムP2以外の部分でもこれらの変数が参照されないことを条件に、命令文ST1~ST3と、変数「a0」、変数「a1」及び変数「a2」を宣言する命令文ST4と、命令文ST92~ST94とを削除した最適化された部分プログラムP3(図18参照)を生成することができる。
 また、生成部150は、部分プログラムP3を並列化した部分プログラムP4(図2(b)参照)を生成する。また、生成部150は、この部分プログラムP4を含むソースプログラムに基づいて生成したアセンブラプログラム12を、記憶装置10に格納し、プログラム生成装置100は、プログラム生成処理を終了する。
 なお、図2(b)に示す部分プログラムP4における並列化を指示するための記述は、OpenMPの記述形式に沿ったものである。
 ≪補足≫
 以上、本発明に係るプログラム生成装置を、実施の形態に基づいて説明したが、以下のように変形することも可能であり、本発明は上述した実施の形態で示した通りのプログラム生成装置に限られないことは勿論である。
 (1)実施の形態に係るプログラム生成装置100は、イタレーション番号が連続する2つのイタレーション間に真依存の関係を有するループ処理を含むソースプログラム11からアセンブラプログラム12を生成する場合を例に説明した。しかしながら、イタレーション番号が連続しない2つのイタレーション間に真依存の関係を有するループ処理(例えば、図19(a)に示すループ処理R5や、図19(c)に示すループ処理R7)を含むソースプログラム11からアセンブラプログラム12を生成するようにしてもよい。なお、図19(b)は、ループ処理R5と等価な上記真依存の関係を有しないループ処理R6を示している。また、図19(d)は、ループ処理R7と等価な上記真依存の関係を有しないループ処理R8を示している。
 そのためには、図5のステップS2の処理で依存関係を特定した結果、真依存の関係が存在しない場合には、真依存の関係を有する2つのイタレーションを特定する処理を行う。
 即ち、イタレーション番号s(i+2≦s<N)についてイタレーション展開を行い、イタレーションi及びイタレーションsの各命令文間の依存関係を特定する。真依存の関係が存在しない場合には、sを1つずつ増やしながら、上記イタレーション展開及び依存関係の特定を繰り返し、真依存の関係が存在する場合には、ステップS3、S4におけるイタレーションi+1を、イタレーションsに置き換えて、ステップS3、S4の処理を行う。
 また、ステップS6のmをsに設定するように変更し、図6のステップS7のmをs+1に設定するように変更し、ステップS8以降は、実施の形態で説明したのと同様に処理できる。
 このように、この変形に係るプログラム生成装置によれば、例えば、図19(a)に示すループ処理R5や、図19(c)に示すループ処理R7を含むソースプログラムを参照することにより、従来のコンパイラが、図19(b)に示すループ処理R6や図19(d)に示すループ処理R8を含むソースプログラムを参照することにより生成し得たアセンブラプログラムと同様のアセンブラプログラムを生成できる。
 (2)実施の形態に係るプログラム生成装置100は、図7のステップS21において、全ての真依存を削除したイタレーションkminからイタレーションm-1が、図6のステップS15で生成したイタレーション変形候補におけるイタレーションkminからイタレーションm-1と同形でない場合には(ステップS21:NO)、アセンブラプログラム12を生成せずプログラム生成処理を終了するものとして説明した。しかしながら、ループ処理を、ループ制御変数がkminからm-1までの範囲の部分ループ処理Xと、ループ制御変数がmからkmaxまでの範囲の部分ループ処理Yとに分けて、ループ処理Yを複数のプロセッサにより並列実行可能に構成したアセンブラプログラム12を生成するようにしてもよい。
 (3)実施の形態に係るプログラム生成装置100は、ソースプログラム11を参照することにより、アセンブラプログラム12を生成するものとして説明した。しかしながら、プログラム生成装置が、アセンブラ210及びリンカ220を備えるように変形し、この変形に係るプログラム生成装置は、ソースプログラム11を参照することにより、目的プログラム14を生成するようにしてもよい。
 また、実施の形態に係るリンカ220は、未解決なデータのアドレス配置等を決定した再配置可能バイナリプログラム13と、必要なライブラリ等を連結するものとして説明したが、当然、複数の再配置可能バイナリプログラム13同士を連結するようにしてもよい。
 (4)実施の形態に係るプログラム生成装置100における算出部130の等価関係算出部133は、特許文献2において説明されている方法と同様の方法を用いて、変数表記の等価関係の算出を行うものとして説明したが、これは一例であり、他の方法により算出するようにしてもよい。
 例えば、命令文「x=y」における、xにyと同じ値が格納されているという関係、つまり、xとyとが等価であるという関係を利用して、命令文の表記を置き換えていくこと(以下、「コピー伝播」という)を繰り返し行う方法により算出するようにしてもよい。
 以下、この方法を簡単に説明する。
 例えば、図8(a)に示すイタレーションiの命令文ST44「a2=a[i+3]」についてコピー伝播を行うことで、図8(b)に示すイタレーションi+1の命令文ST51の表記は「b[i+1]=a0+a1+a[i+3]」に、命令文ST53の表記は「a1=a[i+3]」に置き換えられる。
 また、この置き換えた後の命令文ST53と、命令文ST54とについてコピー伝播を行うことで、図20(a)に示すイタレーションi+2の命令文ST61の表記は「b[i+2]=a0+a[i+3]+a[i+4]」に置き換えられる。また、命令文ST62の表記は「a0=a[i+3]」に、命令文ST63の表記は「a1=a[i+4]」に置き換えられる。
 また、この置き換えた後の命令文ST62及びST63と、命令文ST64とについてコピー伝播を行うことで、図20(b)に示すイタレーションi+3の命令文ST71の表記は「b[i+3]=a[i+3]+a[i+4]+a[i+5]」、命令文ST72の表記は「a0=a[i+4]」に、命令文ST73の表記は「a1=a[i+5]」に置き換えられる(図20(c)参照)。
 (5)実施の形態において説明したプログラム生成処理(図5~7参照)をプロセッサに実行させるためのプログラムを、記録媒体に記録し又は各種通信路等を介して、流通させ頒布することもできる。このような記録媒体には、ICカード、光ディスク、フレキシブルディスク、ROM、フラッシュメモリ等がある。流通、頒布されたプログラムは、機器におけるプロセッサで読み取り可能なメモリ等に格納されることにより利用に供され、そのプロセッサがそのプログラムを実行することにより実施の形態で示したプログラム生成装置の各機能が実現される。
 (6)実施の形態に係るプログラム生成装置100に、上記(1)~(5)の一部又は全部の変形を組み合わせて適用してもよい。
 (7)以下、更に本発明の一実施形態に係るプログラム生成装置の構成及びその変形例と各効果について説明する。
 (a)本発明の一実施形態に係るプログラム生成装置は、1つ以上の命令文からなるブロックを繰り返しN回(N≧2)処理するループ処理であって、i(1≦i<N)回目の実行に係る前記ブロック内の命令文で定義された変数が、j(i<j≦N)回目の実行に係る前記ブロック内の命令文で参照される依存関係にあるループ処理を含む対象ソースプログラムを参照することにより、新たなプログラムを生成するプログラム生成装置であって、i回目の実行に係る前記ブロックと、i回目以外の実行に係る1以上の前記ブロックとを対象ブロックとして、当該対象ブロックにおける変数表記の等価関係を算出する算出処理を行う算出手段と、前記算出手段が算出した変数表記の等価関係に基づいて、前記変数のうち、前記依存関係にある全ての対象変数の表記について、当該対象変数の表記と等価な前記依存関係のない他の変数の表記を特定する特定処理を行う特定手段と、前記ループ処理のM回分(M≦N)の処理を行うための、前記特定手段が特定した他の変数の表記を含んだ命令文を含むプログラムを生成する生成手段とを備える。
 上記構成を備える本発明の一実施形態に係るプログラム生成装置によれば、i回目の実行に係るブロック内の命令文と、j回目の実行に係るブロック内の命令文との間に、いわゆる真依存の関係を有するループ処理を含む対象ソースプログラムを参照することにより、そのループ処理のM回分の処理を行うための、真依存の関係にある全ての対象変数の表記について、当該対象変数の表記と等価な真依存の関係のない他の変数の表記を含んだ命令文を含むプログラムを生成できる。
 この生成したプログラムによれば、ループ処理のM回分の処理を、複数のプロセッサにより独立して並列実行し、ループ処理を高速に実行し得る。
 従って、このプログラム生成装置は、真依存の関係を有するループ処理を含むソースプログラムを参照することにより、複数のプロセッサを用いてループ処理を高速に実行するためのプログラムの生成に有用である。
 (b)また、前記特定手段が特定する前記対象変数の表記と等価な前記依存関係のない他の変数の表記は、いずれの対象変数の表記とも異なる変数の表記であることとしてもよい。
 このプログラム生成装置によれば、真依存の関係を有するループ処理を含む対象ソースプログラムを参照することにより、そのループ処理のM回分の処理を行うための、真依存の関係にある全ての対象変数の表記と等価な真依存の関係のない他の変数の表記を含んだ命令文を含むプログラムを生成できる。
 つまり、このプログラム生成装置は、真依存の関係を有するループ処理を含む対象ソースプログラムを参照することにより、ループ処理のM回分の処理を、複数のプロセッサで独立して並列実行することで高速に実行することが可能なプログラムを生成できる。
 (c)また、前記算出手段は、i回目の実行に係る前記ブロックと、i+1回目の実行に係る前記ブロックとを前記対象ブロックとして前記算出処理を行い、前記特定手段は、前記算出手段が前記算出処理を行う毎に、算出済みの各変数表記の等価関係に基づいて、全ての対象変数の表記について、当該対象変数の表記と等価な前記依存関係のない他の変数の表記であって、いずれの対象変数の表記とも異なる変数の表記を特定できるか否かの判定を行い、当該判定処理の結果が否定的である間、iを1ずつ増加させながら、前記算出手段に前記算出処理を繰り返し行わせることとしてもよい。
 このプログラム生成装置によれば、iがn(n<N)である場合に、真依存の関係にある全ての対象変数の表記について、当該対象変数の表記と等価な真依存の関係のない他の変数の表記を特定できた場合には、少なくともnからNまでのN-n回分のループ処理を行うための、真依存の関係にある全ての対象変数の表記と等価な真依存の関係のない他の変数の表記を含んだ命令文を含むプログラムを生成できる。
 従って、少なくとも、このN-n回分のループ処理を、複数のプロセッサで独立して並列実行することで高速に実行することが可能になる。
 (d)また、前記プログラム生成装置が参照するプログラムは、単一のプロセッサで実行するためのプログラムであり、前記生成手段が生成するプログラムは、複数のプロセッサで並列実行するためのプログラムであることとしてもよい。
 このプログラム生成装置によれば、単一のプロセッサで実行するためのプログラムを参照することで、複数のプロセッサで並列実行するためのプログラムを生成できる。従って、例えばプログラマが作成した、単一のプロセッサで実行するためのプログラムが既にある場合に、わざわざ複数のプロセッサで並列実行するためのプログラムを作成しなおさなくてもよい。よって、プログラムを作成するための手間を省くことができる。
 (e)また、前記生成手段は、M<Nの場合に、生成したプログラムを前記ループ処理のN-M回分の処理をも行うように変更し、変更後のプログラムの処理と、前記対象ソースプログラムの処理とが、等価になるか否かを判定し、等価になる場合には、前記生成したプログラムを、当該変更後のプログラムに置き換えることとしてもよい。
 このプログラム生成装置によれば、一旦生成した、ループ処理のM(M<N)回分の処理を行うためのプログラムを、ループ処理のN回分の処理を行うプログラムに変更しても、その処理が、対象ソースプログラムの処理と等価であることを条件に、最終的に、ループ処理のN回分の処理を行うためのプログラムを生成する。
 このループ処理のN回分の処理を行うためのプログラムは、真依存の関係にある全ての対象変数の表記について、当該対象変数の表記と等価な真依存の関係のない他の変数の表記を含んだ命令文を含むプログラムである。従って、N回分のループ処理を、複数のプロセッサで独立して並列実行することで高速に実行することが可能になる。
 本発明に係るプログラム生成装置は、いわゆる真依存の関係を有するループ処理を含むソースプログラムを参照して、そのループ処理により実現される所定処理を複数のプロセッサで分担して並列実行するための新たなプログラムを生成するために利用される。
  10  記憶装置
  11  ソースプログラム
  12  アセンブラプログラム
  13  再配置可能バイナリプログラム
  14  目的プログラム
  100  プログラム生成装置
  110  記憶部
  120  取得部
  130  算出部
  131  イタレーション展開部
  132  みせかけ依存削除部
  133  等価関係算出部
  140  特定部
  150  生成部
  210  アセンブラ
  220  リンカ
  1000  コンパイラシステム

Claims (7)

  1.  1つ以上の命令文からなるブロックを繰り返しN回(N≧2)処理するループ処理であって、i(1≦i<N)回目の実行に係る前記ブロック内の命令文で定義された変数が、j(i<j≦N)回目の実行に係る前記ブロック内の命令文で参照される依存関係にあるループ処理を含む対象ソースプログラムを参照することにより、新たなプログラムを生成するプログラム生成装置であって、
     i回目の実行に係る前記ブロックと、i回目以外の実行に係る1以上の前記ブロックとを対象ブロックとして、当該対象ブロックにおける変数表記の等価関係を算出する算出処理を行う算出手段と、
     前記算出手段が算出した変数表記の等価関係に基づいて、前記変数のうち、前記依存関係にある全ての対象変数の表記について、当該対象変数の表記と等価な前記依存関係のない他の変数の表記を特定する特定処理を行う特定手段と、
     前記ループ処理のM回分(M≦N)の処理を行うための、前記特定手段が特定した他の変数の表記を含んだ命令文を含むプログラムを生成する生成手段とを備える
     ことを特徴とするプログラム生成装置。
  2.  前記特定手段が特定する前記対象変数の表記と等価な前記依存関係のない他の変数の表記は、いずれの対象変数の表記とも異なる変数の表記である
     ことを特徴とする請求項1記載のプログラム生成装置。
  3.  前記算出手段は、
     i回目の実行に係る前記ブロックと、i+1回目の実行に係る前記ブロックとを前記対象ブロックとして前記算出処理を行い、
     前記特定手段は、
     前記算出手段が前記算出処理を行う毎に、算出済みの各変数表記の等価関係に基づいて、全ての対象変数の表記について、当該対象変数の表記と等価な前記依存関係のない他の変数の表記であって、いずれの対象変数の表記とも異なる変数の表記を特定できるか否かの判定を行い、
     当該判定処理の結果が否定的である間、iを1ずつ増加させながら、前記算出手段に前記算出処理を繰り返し行わせる
     ことを特徴とする請求項2記載のプログラム生成装置。
  4.  前記プログラム生成装置が参照するプログラムは、単一のプロセッサで実行するためのプログラムであり、
     前記生成手段が生成するプログラムは、複数のプロセッサで並列実行するためのプログラムである
     ことを特徴とする請求項2記載のプログラム生成装置。
  5.  前記生成手段は、
     M<Nの場合に、生成したプログラムを前記ループ処理のN-M回分の処理をも行うように変更し、変更後のプログラムの処理と、前記対象ソースプログラムの処理とが、等価になるか否かを判定し、等価になる場合には、前記生成したプログラムを、当該変更後のプログラムに置き換える
     ことを特徴とする請求項2記載のプログラム生成装置。
  6.  1つ以上の命令文からなるブロックを繰り返しN回(N≧2)処理するループ処理であって、i(1≦i<N)回目の実行に係る前記ブロック内の命令文で定義された変数が、j(i<j≦N)回目の実行に係る前記ブロック内の命令文で参照される依存関係にあるループ処理を含む対象ソースプログラムを参照することにより、新たなプログラムを生産するプログラム生産方法であって、
     i回目の実行に係る前記ブロックと、i回目以外の実行に係る1以上の前記ブロックとを対象ブロックとして、当該対象ブロックにおける変数表記の等価関係を算出する算出処理を行う算出ステップと、
     前記算出ステップが算出した変数表記の等価関係に基づいて、前記変数のうち、前記依存関係にある全ての対象変数の表記について、当該対象変数の表記と等価な前記依存関係のない他の変数の表記を特定する特定処理を行う特定ステップと、
     前記ループ処理のM回分(M≦N)の処理を行うための、前記特定ステップが特定した他の変数の表記を含んだ命令文を含むプログラムを生成する生成ステップとを含む
     ことを特徴とするプログラム生産方法。
  7.  1つ以上の命令文からなるブロックを繰り返しN回(N≧2)処理するループ処理であって、i(1≦i<N)回目の実行に係る前記ブロック内の命令文で定義された変数が、j(i<j≦N)回目の実行に係る前記ブロック内の命令文で参照される依存関係にあるループ処理を含む対象ソースプログラムを参照することにより、新たなプログラムを生成するプログラム生成装置におけるプロセッサに、プログラム生成処理を行わせるためのプログラムであって、
     前記プログラム生成処理は、
     i回目の実行に係る前記ブロックと、i回目以外の実行に係る1以上の前記ブロックとを対象ブロックとして、当該対象ブロックにおける変数表記の等価関係を算出する算出処理を行う算出ステップと、
     前記算出ステップが算出した変数表記の等価関係に基づいて、前記変数のうち、前記依存関係にある全ての対象変数の表記について、当該対象変数の表記と等価な前記依存関係のない他の変数の表記を特定する特定処理を行う特定ステップと、
     前記ループ処理のM回分(M≦N)の処理を行うための、前記特定ステップが特定した他の変数の表記を含んだ命令文を含むプログラムを生成する生成ステップとを含む
     ことを特徴とするプログラム。
PCT/JP2011/003812 2010-07-05 2011-07-04 プログラム生成装置、プログラム生産方法及びプログラム WO2012004972A1 (ja)

Priority Applications (3)

Application Number Priority Date Filing Date Title
JP2012523520A JP5580416B2 (ja) 2010-07-05 2011-07-04 プログラム生成装置、プログラム生産方法及びプログラム
CN201180003692XA CN102483701A (zh) 2010-07-05 2011-07-04 程序生成装置、程序生产方法及程序
US13/393,992 US8806466B2 (en) 2010-07-05 2011-07-04 Program generation device, program production method, and program

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
JP2010153325 2010-07-05
JP2010-153325 2010-07-05

Publications (1)

Publication Number Publication Date
WO2012004972A1 true WO2012004972A1 (ja) 2012-01-12

Family

ID=45440963

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2011/003812 WO2012004972A1 (ja) 2010-07-05 2011-07-04 プログラム生成装置、プログラム生産方法及びプログラム

Country Status (4)

Country Link
US (1) US8806466B2 (ja)
JP (1) JP5580416B2 (ja)
CN (1) CN102483701A (ja)
WO (1) WO2012004972A1 (ja)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2022249236A1 (ja) * 2021-05-24 2022-12-01 三菱電機株式会社 ソフトウェア設計支援システム、ソフトウェア設計支援方法およびソフトウェア設計支援プログラム

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9710263B2 (en) * 2013-09-26 2017-07-18 International Business Machines Corporation Understanding computer code with human language assistance
CN108021360B (zh) * 2016-11-04 2021-03-05 华为技术有限公司 规则处理方法、代码处理方法及相关设备
US10496402B1 (en) * 2017-09-28 2019-12-03 Amdocs Development Limited System, method, and computer program for defining and utilizing minimal testable values for software project development and operations

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS63304325A (ja) * 1987-06-05 1988-12-12 Hitachi Ltd 並列化コンパイル方法
JPH0328821B2 (ja) * 1981-10-22 1991-04-22 Nippon Electric Co
JP3234552B2 (ja) * 1997-09-30 2001-12-04 松下電器産業株式会社 最適化装置及びコンピュータ読取可能な記録媒体

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2792546B2 (ja) 1989-06-26 1998-09-03 河口湖精密株式会社 液晶注入機の液晶注入機構
JP3028821B2 (ja) * 1989-09-04 2000-04-04 株式会社日立製作所 並列化コンパイル方法
JP2929115B2 (ja) 1990-02-09 1999-08-03 カシオ計算機株式会社 サーマル印字ヘッド
JPH0475139A (ja) * 1990-07-18 1992-03-10 Toshiba Corp ループ並列化装置
JPH05250341A (ja) * 1991-11-11 1993-09-28 Matsushita Electric Ind Co Ltd 並列可能性判定装置、及び並列可能性判定方法、並びにそれを用いたプログラム変換装置
JPH07110800A (ja) * 1993-10-13 1995-04-25 Matsushita Electric Ind Co Ltd 最適化並列コンパイル装置及び最適化並列コンパイル方法
JP2669603B2 (ja) * 1994-12-15 1997-10-29 インターナショナル・ビジネス・マシーンズ・コーポレイション コンパイラにおけるコード生成方法及びコンパイラ

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH0328821B2 (ja) * 1981-10-22 1991-04-22 Nippon Electric Co
JPS63304325A (ja) * 1987-06-05 1988-12-12 Hitachi Ltd 並列化コンパイル方法
JP3234552B2 (ja) * 1997-09-30 2001-12-04 松下電器産業株式会社 最適化装置及びコンピュータ読取可能な記録媒体

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
IKUO MIYOSHI ET AL.: "A Parallelizing Compiler for message-Passing Multiprocessor", IPSJ SIG NOTES, vol. 94, no. 65, 22 July 1994 (1994-07-22), pages 35 - 36 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2022249236A1 (ja) * 2021-05-24 2022-12-01 三菱電機株式会社 ソフトウェア設計支援システム、ソフトウェア設計支援方法およびソフトウェア設計支援プログラム
JPWO2022249236A1 (ja) * 2021-05-24 2022-12-01
JP7333889B2 (ja) 2021-05-24 2023-08-25 三菱電機株式会社 ソフトウェア設計支援システム、ソフトウェア設計支援方法およびソフトウェア設計支援プログラム

Also Published As

Publication number Publication date
JP5580416B2 (ja) 2014-08-27
CN102483701A (zh) 2012-05-30
JPWO2012004972A1 (ja) 2013-09-02
US8806466B2 (en) 2014-08-12
US20120167036A1 (en) 2012-06-28

Similar Documents

Publication Publication Date Title
JP4042604B2 (ja) プログラム並列化装置,プログラム並列化方法およびプログラム並列化プログラム
JP3901180B2 (ja) プログラム並列化装置及びその方法並びにプログラム
US20050060696A1 (en) Method and a system for constructing control flows graphs of binary executable programs at post-link time
WO2012004972A1 (ja) プログラム生成装置、プログラム生産方法及びプログラム
JP4041248B2 (ja) コンパイラ装置、コンパイルプログラムが記録されたコンピュータ読み取り可能な記録媒体及びコンパイル方法
JP5966509B2 (ja) プログラム、コード生成方法および情報処理装置
US5923883A (en) Optimization apparatus which removes transfer instructions by a global analysis of equivalence relations
US20060048122A1 (en) Method, system and computer program product for hierarchical loop optimization of machine executable code
JP2015194881A (ja) コンパイル装置、コンパイラプログラム、コンパイル方法
JP5392689B2 (ja) バイ・エンディアンコンパイラを用いたコードの最適化
Mendis et al. Revec: program rejuvenation through revectorization
US7979853B2 (en) Compiler device, method, program and recording medium
US11635947B2 (en) Instruction translation support method and information processing apparatus
Giesemann et al. Using a genetic algorithm approach to reduce register file pressure during instruction scheduling
JP2012014526A (ja) プログラムコードの構造変換装置、並びにコード構造変換プログラム
JP6138701B2 (ja) 分散計算方法及び分散計算システム
JP7035751B2 (ja) コード変換装置、コード変換方法、及びコード変換プログラム
JP4761808B2 (ja) マイクロプロセッサおよびその制御方法
Xiao et al. Automatic custom instruction identification for application-specific instruction set processors
CN107562430A (zh) 一种针对移动π演算语言的文件处理功能的编译方法
JP4311327B2 (ja) ソースコード自動生成装置、ソースコード自動生成方法、プログラムおよび記録媒体
CN103049302A (zh) 由程序生成优化的strcpy标准库函数汇编代码的方法
US11915135B2 (en) Graph optimization method and apparatus for neural network computation
Kirovski et al. Engineering change protocols for behavioral and system synthesis
JP6898556B2 (ja) 情報処理装置、コンパイル方法及びコンパイルプログラム

Legal Events

Date Code Title Description
WWE Wipo information: entry into national phase

Ref document number: 201180003692.X

Country of ref document: CN

WWE Wipo information: entry into national phase

Ref document number: 2012523520

Country of ref document: JP

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

Ref document number: 11803310

Country of ref document: EP

Kind code of ref document: A1

WWE Wipo information: entry into national phase

Ref document number: 13393992

Country of ref document: US

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 11803310

Country of ref document: EP

Kind code of ref document: A1