|Publication number||US5265253 A|
|Application number||US 07/747,933|
|Publication date||Nov 23, 1993|
|Filing date||Aug 21, 1991|
|Priority date||Aug 22, 1990|
|Publication number||07747933, 747933, US 5265253 A, US 5265253A, US-A-5265253, US5265253 A, US5265253A|
|Original Assignee||Nec Corporation|
|Export Citation||BiBTeX, EndNote, RefMan|
|Patent Citations (1), Referenced by (26), Classifications (4), Legal Events (4)|
|External Links: USPTO, USPTO Assignment, Espacenet|
The present invention relates to a program compiler and, more particularly, to a method of unrolling/optimizing a repetitive loop.
In a conventional method of consecutive access to the same memory bank by means of a loop, the execution time is undesirably prolonged because of repetitive processing by the loop. In order to minimize the execution time, the loop is optimized. For example, unroll/optimization of a DO loop in a FORTRAN compiler is performed by changing the incrementation value of the DO loop.
If, however, a DO loop is optimized by changing its incrementation value as in the conventional method, contention between memory banks may occur, resulting in an increase in execution time.
It is an object of the present invention to provide a method of unrolling/optimizing a repetitive loop, which can shorten the execution time of a program.
It is another object of the present invention to provide a method of unrolling/optimizing a repetitive loop, which can prevent contention between memory banks.
In order to achieve the above objects, according to the present invention, there is provided a method of unrolling/optimizing a repetitive loop, in which a program compiler in a computer system unrolls and optimizes a repetitive loop instruction, comprising the steps of checking whether the number of times that a loop in an input source program is repeated is an even number, checking whether there are a definition and a reference which span the respective repetitions of the loop, if it is determined that the number of times of repetition is an even number, unrolling an instruction string in the loop a plurality of times in response to the loop instruction, if it is determined that there are neither definition nor reference, updating an index value of the newly unrolled instruction string by predetermined arithmetic processing including a calculation based on the initial, terminal, and incrementation values of the loop, and updating the terminal value of the loop by predetermined arithmetic processing including a calculation based on the initial, terminal, and incrementation values of the loop.
FIG. 1 is a block diagram showing an embodiment of the present invention;
FIG. 2 is a flow chart for explaining an operation of the present invention;
FIG. 3 is a view showing an instruction string of a source program; and
FIG. 4 is a view showing a new instruction string obtained by unrolling/optimizing the DO loop instruction string shown in FIG. 3.
The present invention will be described below with reference to the accompanying drawings.
FIG. 1 shows an embodiment of the present invention. In this embodiment, FORTRAN will be exemplified as a program language. A FORTRAN compiler 3 receives a source program from a FORTRAN source program file 1, and causes a DO loop unrolling permission determining section 31 to check whether the program satisfies predetermined conditions. With respect to a DO loop which satisfies the conditions, the FORTRAN compiler 3 causes a DO loop unrolling section 32 to perform an unrolling operation for optimization. In addition, the FORTRAN compiler 3 compiles a program which is optimized or to be optimized, and outputs the resultant program as a target program to a target program file 2.
FIG. 2 is a flow chart for explaining an operation of the present invention. FIG. 3 shows an instruction string of a source program. FIG. 4 shows a new instruction string obtained by unrolling/optimizing the DO loop instruction string shown in FIG. 3. The FORTRAN compiler 3 receives, for example, the instruction string of the source program shown in FIG. 3 from the FORTRAN program file 1, and checks (step 101) whether the number of times that a DO loop in the input instruction string is repeated is an even number. If it is an even number, it is checked (step 102) whether there are a definition and a reference which span the respective repetitions of the loop. If NO in step 102, the instruction string in the DO loop is unrolled a predetermined number of times, e.g., two times (step 103). The index variable of an instruction string unrolled after the second unrolling, i.e., a newly unrolled instruction string, is updated to become an index variable obtained by predetermined arithmetic processing including a calculation based on the initial, terminal, and incrementation values of the DO loop (step 104). For example, the index value is updated to become [index variable of first unrolling+(terminal value-initial value+incrementation value)/2].
Subsequently, the terminal value of the DO loop is updated to become a value obtained by predetermined arithmetic processing including a calculation based on the above-mentioned initial, terminal, and incrementation values of the DO loop (step 105). For example, the terminal value is updated to become [(terminal value+initial value-incrementation value)/2].
As a result of the optimization described above, the instruction string shown in FIG. 4 is obtained.
Subsequently, the flow returns to step 101 to perform similar processing. Note that since the number of times that the DO loop shown in FIG. 4 is repeated is not an even number, this loop cannot be unrolled any more.
If it is determined in step 101 that the number of times of repetition is not an even number, or if it is determined in step 102 that there are a definition and a reference which span the respective repetitions of the loop, the loop is terminated without unrolling/optimizing the loop, and control is transferred to normal compile processing.
In the embodiment, FORTRAN is used as a program language. However, it is apparent that the same effect as described above can be obtained with other languages.
According to the present invention, since loop unrolling is performed upon updating of the terminal value of a loop, no contention between memory banks occurs, and the execution of a program can be optimized, i.e., the execution time can be shortened, thus providing a remarkable effect.
|Cited Patent||Filing date||Publication date||Applicant||Title|
|US5121498 *||May 11, 1988||Jun 9, 1992||Massachusetts Institute Of Technology||Translator for translating source code for selective unrolling of loops in the source code|
|Citing Patent||Filing date||Publication date||Applicant||Title|
|US5404473 *||Mar 1, 1994||Apr 4, 1995||Intel Corporation||Apparatus and method for handling string operations in a pipelined processor|
|US5524223 *||Jun 12, 1995||Jun 4, 1996||Motorola, Inc.||Instruction accelerator for processing loop instructions with address generator using multiple stored increment values|
|US5606698 *||Mar 7, 1995||Feb 25, 1997||Cadence Design Systems, Inc.||Method for deriving optimal code schedule sequences from synchronous dataflow graphs|
|US5740419 *||Jul 22, 1996||Apr 14, 1998||International Business Machines Corporation||Processor and method for speculatively executing an instruction loop|
|US5797013 *||Nov 29, 1995||Aug 18, 1998||Hewlett-Packard Company||Intelligent loop unrolling|
|US5822602 *||Jul 23, 1996||Oct 13, 1998||S3 Incorporated||Pipelined processor for executing repeated string instructions by halting dispatch after comparision to pipeline capacity|
|US5828875 *||May 29, 1997||Oct 27, 1998||Telefonaktiebolaget Lm Ericsson||Unroll of instructions in a micro-controller|
|US5835776 *||Nov 17, 1995||Nov 10, 1998||Sun Microsystems, Inc.||Method and apparatus for instruction scheduling in an optimizing compiler for minimizing overhead instructions|
|US5854933 *||Aug 20, 1996||Dec 29, 1998||Intel Corporation||Method for optimizing a computer program by moving certain load and store instructions out of a loop|
|US5867711 *||Nov 17, 1995||Feb 2, 1999||Sun Microsystems, Inc.||Method and apparatus for time-reversed instruction scheduling with modulo constraints in an optimizing compiler|
|US5901318 *||May 6, 1996||May 4, 1999||Hewlett-Packard Company||Method and system for optimizing code|
|US5920724 *||Mar 28, 1996||Jul 6, 1999||Intel Corporation||Software pipelining a hyperblock loop|
|US5970244 *||Jun 30, 1995||Oct 19, 1999||Fujitsu Limited||Method of performing a reverse analysis of a program and its apparatus|
|US6016399 *||Dec 16, 1998||Jan 18, 2000||Intel Corporation||Software pipelining a hyperblock loop|
|US6247173||Sep 24, 1997||Jun 12, 2001||Hewlett-Packard Company||Computer compiler optimizer for reducing computer resource consumption during dependence analysis after loop unrolling|
|US6272676 *||Jan 13, 1998||Aug 7, 2001||Intel Corporation||Method and apparatus for finding loop— lever parallelism in a pointer based application|
|US6829702 *||Jul 26, 2000||Dec 7, 2004||International Business Machines Corporation||Branch target cache and method for efficiently obtaining target path instructions for tight program loops|
|US6993756 *||Mar 2, 2001||Jan 31, 2006||Matsushita Electric Industrial Co., Ltd.||Optimization apparatus that decreases delays in pipeline processing of loop and computer-readable storage medium storing optimization program|
|US7617396 *||Aug 16, 2002||Nov 10, 2009||Nvidia Corporation||Method and apparatus for watermarking binary computer code with modified compiler optimizations|
|US8336041 *||Sep 11, 2009||Dec 18, 2012||Samsung Electronics Co., Ltd.||Compiler and compiling method|
|US9235337||May 9, 2013||Jan 12, 2016||Mitutoyo Corporation||System, GUI and method for editing step and repeat operation instructions in a machine vision inspection system|
|US9733902||May 13, 2014||Aug 15, 2017||Mitutoyo Corporation||Machine vision system program editing environment including operating context aware copy and paste feature|
|US20010020294 *||Mar 2, 2001||Sep 6, 2001||Hajime Ogawa||Optimization apparatus that decreases delays in pipeline processing of loop and computer-readable storage medium storing optimization program|
|US20040034777 *||Aug 16, 2002||Feb 19, 2004||Quicksilver Technology, Inc.||Method and apparatus for watermarking binary computer code with modified compiler optimizations|
|US20100107147 *||Sep 11, 2009||Apr 29, 2010||Cha Byung-Chang||Compiler and compiling method|
|WO1997036228A1 *||Mar 13, 1997||Oct 2, 1997||Intel Corporation||Software pipelining a hyperblock loop|
|Aug 21, 1991||AS||Assignment|
Owner name: NEC CORPORATION, JAPAN
Free format text: OPTION;ASSIGNOR:YAMADA, SYOUICHIROU;REEL/FRAME:005823/0682
Effective date: 19910729
|Jul 1, 1997||REMI||Maintenance fee reminder mailed|
|Nov 23, 1997||LAPS||Lapse for failure to pay maintenance fees|
|Feb 3, 1998||FP||Expired due to failure to pay maintenance fee|
Effective date: 19971126