WO2008072334A1 - コンパイル方法及びコンパイラ - Google Patents

コンパイル方法及びコンパイラ Download PDF

Info

Publication number
WO2008072334A1
WO2008072334A1 PCT/JP2006/324966 JP2006324966W WO2008072334A1 WO 2008072334 A1 WO2008072334 A1 WO 2008072334A1 JP 2006324966 W JP2006324966 W JP 2006324966W WO 2008072334 A1 WO2008072334 A1 WO 2008072334A1
Authority
WO
WIPO (PCT)
Prior art keywords
processing block
processing
scheduler
statement
block
Prior art date
Application number
PCT/JP2006/324966
Other languages
English (en)
French (fr)
Inventor
Koichiro Yamashita
Original Assignee
Fujitsu Limited
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 Fujitsu Limited filed Critical Fujitsu Limited
Priority to EP06834720A priority Critical patent/EP2093667A4/en
Priority to JP2008549167A priority patent/JPWO2008072334A1/ja
Priority to KR1020097011902A priority patent/KR101085330B1/ko
Priority to PCT/JP2006/324966 priority patent/WO2008072334A1/ja
Priority to CNA2006800566376A priority patent/CN101563673A/zh
Publication of WO2008072334A1 publication Critical patent/WO2008072334A1/ja
Priority to US12/457,441 priority patent/US20090254892A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • 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
    • 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/458Synchronisation, e.g. post-wait, barriers, locks

Definitions

  • the present invention relates to a compiling method and a conoiler, and more particularly to a compiling method and a conoiler that automatically generates an execution code of software on an embedded device.
  • FIG. 1 is a diagram showing a configuration of a conventional compiler that generates an execution code of software on an embedded device.
  • the compiler shown in Fig. 1 optimizes the executable code in order to efficiently execute the embedded device software as a single application.
  • the compiler shown in FIG. 1 has a translation device (front end) 2, an optimization device (middle path) 4, and a code generation device (back end) 5.
  • Front end 2 generates intermediate language 3-1 from source code 1
  • middle path 4 generates intermediate language 3-2 from intermediate language 3-1.
  • Knock end 5 generates optimized execution code 6 from intermediate language 3-2.
  • simple restructuring restructuring
  • simple restructuring such as deletion of unnecessary variables, packing of instructions, and inline expansion of calling functions is performed in the middle path 4.
  • FIG. 2 is a diagram for explaining a delay in time series processing (sequential processing).
  • P1 to P4 indicate processes
  • tl is a start condition judgment time
  • t2 is a process
  • P 3 is the actual end time of process P
  • t4 is the actual end time of process P
  • t5 is the expected end time of process P3.
  • the actual end time t4 of the process P4 is later than the expected end time t3 of the process P4, and the delay D1 occurs.
  • FIG. 3 is a diagram for explaining avoidance of delay in time series processing.
  • P3y and P4y are the y-th processes
  • P4 and P4z are the z-th processes
  • P4 and t2y are the actual end times of the processes
  • P3 y and t3y is the expected end time of the processes
  • P4y T5y is the expected end time of process P3y.
  • FIG. 4 is a diagram showing an image of a conventional dynamic scheduler.
  • 11 is a task or thread
  • 12 is an execution information table reported from the task or thread
  • 13 is a dynamic scheduler that performs scheduling based on the information table
  • 14 is within the operating system (OS) 16.
  • Context switch of 'Process management function, 15 indicates a switch under the direction of the dynamic scheduler 13.
  • the dynamic scheduler 13 shown in FIG. 4 provides a dynamic profiling function to the application, so that memory and CPU Report usage to OS16 as needed.
  • the dynamic scheduler 13 dynamically defines the priority of the task or thread 11 with reference to the information table 12 of the constantly collected information, and the OS 16 context switch. I do.
  • the dynamic scheduler 13 for efficiently executing a plurality of tasks or threads 11 is software that operates differently from an application linked with the OS 16, that is, an external (or external) scheduler. It is. For this reason, from the viewpoint of the amount of CPU computation required by the target software, such a dynamic scheduler 13 is regarded as pure overhead.
  • the static scheduler focuses on branch instructions at the time of control, and uses branch instruction power to jump to dependent processing memory and CPU usage. Therefore, scheduling is determined at the time of connec- tion based on a probable information table multiplied by a branch prediction coefficient.
  • the static scheduler has a smaller overhead for execution scheduling than the dynamic scheduler that performs optimal processing dynamically, but has a structure in which the amount of computation and the amount of data handled change with each execution. With this software, scheduling accuracy is reduced and processing time is not always the shortest. For this reason, static schedulers are generally
  • Patent Document 1 and Patent Document 2 propose dynamic schedulers.
  • a multi-level scheduler is proposed in Patent Document 2, for example.
  • Patent Document 1 Japanese Patent Laid-Open No. 6-110688
  • Patent Document 2 Japanese Patent Laid-Open No. 2003-84989
  • Patent Document 3 Japanese Patent Laid-Open No. 8-212070
  • the scheduler is activated in the case of a software configuration in which a code optimization level without restructuring is activated, or a software configuration in which multiple tasks or threads are activated. Is done.
  • an object of the present invention is to realize a compiling method and a compiler that can efficiently generate an execution code of software even in a limited software execution environment.
  • the above-described problem is a compiling method for compiling software that outputs intermediate results at a predetermined timing and that is processed in a time series by a computer, and the source of the software by the computer
  • the above-described problem is a compiler that outputs intermediate results at a predetermined timing by a computer and compiles software that is processed in time series.
  • a front end that translates the source code of the software into a first intermediate language by a computer and stores it in a storage unit; and the source code based on the first intermediate language stored in the storage unit by the computer
  • a middle path that extracts processing blocks related to parallelism and conditional branching from the processing sequence included in the processing sequence, restructures the extracted processing blocks, generates a second intermediate language, and stores it in the storage unit; and
  • This can be achieved by a compiler comprising a back end that automatically generates an execution code based on the second intermediate language stored in the storage unit.
  • FIG. 1 is a diagram showing a configuration of a conventional compiler.
  • FIG. 2 is a diagram for explaining a delay in time series processing.
  • FIG. 3 is a diagram for explaining avoidance of delay in time series processing.
  • FIG. 4 is a diagram showing an image of a conventional dynamic scheduler.
  • FIG. 5 is a diagram showing a configuration of an embodiment of a compiler of the present invention.
  • FIG. 6 is a diagram for explaining the classification of source codes constituting software.
  • FIG. 7 is a diagram illustrating an example of a dependency graph expressing a dependency relationship between statements.
  • FIG. 8 is a diagram showing an example in which the processing order is changed based on the dependency graph of FIG.
  • FIG. 9 is a diagram showing an example of a software flow configuration.
  • FIG. 10 is a flowchart showing a first stage process of the embodiment.
  • FIG. 11 is a diagram for explaining redefinition of an unconditional jump and loop processing block as an operation substitution processing block.
  • FIG. 12 is a diagram for explaining redefinition between operation substitution processing blocks.
  • FIG. 13 is a diagram for explaining redefinition of a thread processing block and a scheduler processing block.
  • FIG. 14 is a diagram for explaining a thread processing block and a scheduler processing block.
  • FIG. 15 is a flowchart showing a second stage process of the embodiment.
  • FIG. 16 is a diagram for explaining a method for adding a statement to a thread processing block.
  • FIG. 17 is a diagram for explaining a method of adding a statement to a scheduler processing block
  • FIG. 18 is a diagram for explaining timer processing of the outermost scheduler processing block.
  • FIG. 20 is a diagram showing an image of a timing chart during operation of the example.
  • FIG. 21 is a diagram comparing timing chart images of the conventional method of FIG. 2 and an example.
  • FIG. 22 is a diagram illustrating an image of a scheduler processing block according to an embodiment.
  • FIG. 23 is a diagram showing the measurement results of resource utilization efficiency when compiling an actual program for the conventional method and the embodiment.
  • the source code that is the source of the execution target software can be analyzed and classified at the intermediate language level of the compiling process, and can be processed in parallel (simultaneously) from the extracted processing block modules.
  • unnecessary external statements (codes) can be deleted, and a dedicated scheduler for the target software can be realized by restructuring.
  • FIG. 5 is a diagram showing the configuration of an embodiment of the conoiler of the present invention.
  • This embodiment of the compiler employs an embodiment of the compiling method of the present invention.
  • the present invention is applied when generating an execution code of software on an embedded device.
  • the embedded device is a computer (or computer system) having a known hardware configuration that includes a processor such as a CPU and a storage unit such as a memory, and the processor executes a program stored in the storage unit.
  • the compiler shown in FIG. 5 optimizes the execution code in order to efficiently execute the software of the embedded device as a single application.
  • the compiler shown in FIG. 5 has a translation device (front end) 32, an optimization device (middle path) 34, and a code generation device (back end) 35.
  • the front end 32 generates the intermediate language 33-1 from the source code 31 and stores it in the storage unit
  • the middle path 34 generates the intermediate language 33-2 from the intermediate language 33-1 stored in the storage unit and stores it in the storage unit. save.
  • Backend 35 stored in storage
  • the optimized execution code 36 is generated from the intermediate language 33-2 and stored in the storage unit as necessary.
  • simple restructuring such as deleting unnecessary variables, packing instructions, and inline expansion of calling functions in the middle path 34 is performed.
  • the front end 32 and back end 35 are simple translation devices, and do not actively optimize execution code. If the execution code is not optimized, the middle path 34 is not used because the back end 35 directly decodes the intermediate language 33-1 generated by the front end 32 and generates the
  • the processing sequence indicated by the source code is converted into an execution code that can be interpreted by an arithmetic device (processor) such as a CPU.
  • processor arithmetic device
  • more efficient execution code is generated by general-purpose optimization methods such as deleting non-propagating variables and mathematical statements, inline expansion of subroutines, or unrolling processing that expands loops in units of iterations. To do.
  • the present embodiment is characterized by an efficient execution code generation method incorporated in the middle path 34.
  • the middle path 34 shown in Fig. 5 receives the intermediate language 33-1 as input, and performs restructuring according to the following procedure to generate the intermediate language 32-2. Restructuring at the intermediate language 33-1 level. For this reason, the front end 32 and the backend 35 can be used without modification, and the middle path 34 can be incorporated in an existing compiler for general use.
  • FIG. 6 is a diagram for explaining the classification of the source code 31 constituting the software.
  • Figure 6 shows the case where the source code 31 that composes the software is classified at the statement level.
  • the processing category psl indicates that the operation is an assignment process that assigns the result of the operation to a storage unit such as a memory or a register.
  • the process section P s2 indicates a loop process indicated by a jump instruction including a back edge, that is, a back edge jump.
  • Process category ps3 indicates that the branch process is indicated by a conditional branch or conditional jump instruction.
  • Processing category ps4 indicates a subroutine or function call, and indicates an unconditional jump instruction.
  • restructuring is performed by focusing on an intermediate language 33-1 having an arbitrary configuration. Therefore, it does not matter where general-purpose optimization processing is performed, but since the loop structure is used as it is, loop optimization methods such as unrolling methods are not applied before restructuring.
  • the compiler always has a variable table when generating the intermediate language 33-2, and each statement of the intermediate language 33-2 is numbered in ascending order, and the variable to be referenced (the right side of the expression) And a variable to define (the left side of the expression).
  • the set of reference variables of S X is expressed by (Expression 1)
  • the set of definition variables of Sx is expressed by (Expression 2).
  • Equation 1 and (Equation 2) also apply to the aggregated statement group SG, and define (Equation 3) and (Equation 4) in the same way for the yth statement group SGy.
  • empty set is used as an expression when there are no variables to be defined and referenced.
  • Equation 8 is defined as an expression expressing that Sm and Sn are positive direction dependent ⁇ .
  • Expression 11 is defined as an expression that expresses that Sm and Sn are output-dependent ⁇ 0.
  • Equation 8 (Equation 8), (Equation 9), and (Equation 11) are generally called dependency equations, and by deriving (Equation 1) and (Equation 2) for all statements, the dependency of each statement is determined.
  • a dependency graph can be created.
  • FIG. 7 is a diagram illustrating an example of a dependency graph expressing the dependency relationship of statements.
  • Sa to Sf indicate statements.
  • the statement Sd refers to the definition result of the statement Sa
  • the statement Sd refers to the definition of the variable defined by the statement Sf. Since the definition variable of statement Sb is redefined in statement Sf that will be used everywhere, (Equation 12) is deemed to hold, and statement Sb will be deleted from the code.
  • FIG. 8 is a diagram showing an example in which the processing order of statements is changed based on the dependency graph of FIG.
  • FIG. 9 is a diagram illustrating an example of a software flow configuration.
  • psl to ps4 indicate processing blocks corresponding to the processing of the processing sections psl to ps4 shown in FIG.
  • the sequence of statements developed in the intermediate language takes a form in which a processing block ps3 for conditional branching or a processing block ps4 for unconditional jump is sandwiched between processing blocks psl for multiple assignment processing.
  • the processing block ps3 for conditional branch and the processing block ps4 for unconditional jump indicate control structures, not data dependence, and the processing flow is considered to be interrupted. Therefore, the processing unit of the middle path 34 shown in FIG.
  • FIG. 10 is a flowchart showing the first stage of this embodiment.
  • the input is the intermediate language 33-1 and the output is the intermediate language 33-1.
  • step Stl the variables defined and referred to are extracted in step Stl, and the dependency graph is defined in step St2. Also unnecessary at step St3 Statement is deleted, and the statement based on the dependency graph is sorted in step St4.
  • statement groups are combined and redefined according to the method described later with respect to the statement strings arranged at the intermediate language level.
  • the processing blocks classified by the above processing divisions are combined, but general software includes nested loops, nested conditional branches, loops under subroutines, conditional branches, etc. It has a hierarchical structure. For this reason, the operation performed in the second stage of this embodiment is performed in the order of the processing block power of the innermost hierarchy in the nested or nested structure.
  • the innermost processing block of the nested or nested structure is always a processing block for arithmetic substitution processing. In the first stage, if a statement that exists in the innermost processing block is deleted by the solution of the dependency equation, the corresponding nested structure is also deleted.
  • the processing block of the caller When processing the innermost processing block of a nested or nested structure, the processing block of the caller must be accompanied by a control block such as a conditional branch in the loop processing block (back edge jump). If this is the body of a simple loop, Regroup and redefine as an operation substitution processing block.
  • a control block such as a conditional branch in the loop processing block (back edge jump). If this is the body of a simple loop, Regroup and redefine as an operation substitution processing block.
  • FIG. 11 is a diagram for explaining redefinition of an unconditional jump and loop processing (back edge jump) processing block as an operation substitution processing block.
  • the processing block of the call source is an unconditional jump processing block, it is combined with the unconditional jump processing block of the previous processing section, regrouped, and arithmetic substitution processing Redefine as a block.
  • the processing block of the caller is a loop processing (back edge jump) processing block, it is regrouped and redefined as an operation substitution processing block.
  • the operation substitution processing blocks may be arranged in a column in the same nested or nested hierarchy.
  • the operation substitution processing blocks arranged in a column are combined and redefined as an operation substitution processing block.
  • FIG. 12 is a diagram for explaining redefinition between operation substitution processing blocks.
  • “assignment operation” indicates an assignment operation processing block
  • processing blocks surrounded by a broken line indicate combined processing blocks.
  • the processing block of the caller is a processing block for conditional branch processing, that is, if it is true or false of a conditional branch or any subordinate clause, there is no need to perform processing for combining the processing blocks. Redefine this as a threaded processing block.
  • FIG. 13 is a diagram for explaining redefinition of the thread processing block and the scheduler processing block. Due to the hierarchical analysis of nested or nested structures, a threaded processing block component is not necessarily a single processing block, and a threaded processing block component is not necessarily an arithmetic substitution processing block.
  • the threading processing block and the scheduler processing block are closely related, and the threading processing block is a subordinate clause of the conditional branching force, the threading processing block always includes the scheduler processing block including the corresponding conditional branch. It will be linked.
  • FIG. 6 is a diagram for explaining a code processing block and a scheduler processing block.
  • 41 is a scheduler processing block that belongs to the highest level in FIG. 14, 42 is a thread processing block that is subordinate to the scheduler processing block 41, and 43 is one layer of the scheduler processing block 41.
  • the scheduler processing block included below, 44 is a thread processing block subordinate to the scheduler processing block 43, 45 is a scheduler processing block included one level below the thread processing block 42, and 46 is a scheduler
  • Each of the threading processing blocks subordinate to processing block 45 is shown.
  • FIG. 15 is a flowchart showing the second stage process of the present embodiment.
  • the input is the intermediate language 33-1 and the output is also the intermediate language 33-1.
  • step Stll starts processing in order of processing block power of the innermost hierarchy in a nested or nested structure for the code of the program targeted for processing block formation.
  • step Stl2 it is determined whether or not the calling process block is a conditional branch process. If the decision result power WES at step Stl2, step Stl3 redefines the subordinate clause of the conditional branch as a thready processing block, and the process returns to step Stll, where the innermost hierarchy in the nested or nested structure The processing block of the next level is started.
  • step Stl4 judges whether or not the subsequent processing block follows the conditional branch process, and if the judgment result power SNO, the process goes to step Stll. Return, start processing the processing block of the next layer of the innermost layer in the nested or nested structure. If the subsequent processing block is a conditional branch process and the determination result power is YES in step Stl4, step Stl5 combines these processing blocks and the subsequent processing blocks and redefines them as scheduler processing blocks. After step Stl5, the process returns to step Stll and starts processing the processing block of the next layer of the innermost layer in the nested or nested structure.
  • statement groups are combined and redefined according to the method described later with respect to the statement strings arranged at the intermediate language level.
  • the processing blocks classified by the above processing divisions are combined, but general software uses nested loops, nested conditional branches, subroutines, etc. It has a hierarchical structure such as loops and conditional branches. For this reason, the operation performed in the second stage of this embodiment is performed in the order of the processing block power of the innermost hierarchy in the nested or nested structure.
  • control statements are attached to the scheduler processing block and thread processing block that have been grouped in the second stage, so that the final intermediate between the thread and the scheduler is performed.
  • Generate language intermediate code
  • conditional branch and the calculation for calculating the condition and the calling of the processing block subordinate thereto are equivalent to the relationship between the dynamic scheduler and the scheduled thread.
  • a mechanism that operates in the same manner as the context switch function of a thread is provided in the structure of the scheduler processing block.
  • the threading processing block is provided with a mechanism that operates only when requested by the scheduler.
  • the following operation is performed on the scheduler processing block and the subordinate thread processing block.
  • FIG. 16 is a diagram for explaining a method for adding a statement to the thread processing block.
  • the threading processing block 55 is surrounded by a loop, and as shown by 52, a signal is waited for reception at the entrance part (first part) of the loop. Insert an OS service call, such as a wait mechanism to be released.
  • the processing blocks that are executed in parallel are expressed by (Equation 8), (Equation 9), and (Equation 11).
  • an exclusive control code by semaphore or mutex is inserted.
  • the exclusive lock is applied as indicated by 53 and the exclusive lock is released as indicated by 54.
  • FIG. 17 is a diagram for explaining a method of adding a statement to the scheduler processing block. is there.
  • the scheduler processing block includes conditional branch processing, and the timing at which the conditional branch occurs is considered to be the timing at which the event processing thread 59 is activated (scheduled). Therefore, a statement that issues a signal expected by the subordinate event processing thread 59 (that is, a signal for an event to be activated when the condition A or B is satisfied) as shown in 61 in FIG. Code) and define it as the scheduler processing block 69.
  • the scheduler processing block 65 when the scheduler processing block 65 is in a nested structure, the scheduler processing block 65 is activated by the scheduler processing block in its parent hierarchy.
  • the scheduling processing block inside the nesting indicated by 45 is the upper level scheduler processing processing block indicated by 41. It will be activated dynamically when the signal is sent from.
  • a program written in a general-purpose programming language that mainly outputs time-series processing, that is, an intermediate operation result at a predetermined timing is assumed.
  • Such a program generally has a loop structure at the highest level of the program.
  • FIG. 18 is a diagram for explaining timer processing of the outermost scheduler processing block.
  • the same parts as those in FIG. 17 are denoted by the same reference numerals, and the description thereof is omitted.
  • FIG. 19 is a flowchart for explaining the third stage of processing according to the present embodiment.
  • the input is the intermediate language 33-1 and the output is the intermediate language 32-2.
  • step St21 it is determined whether the processing block to be processed is a threading processing block or a scheduler processing block.
  • processing for adding a statement to the threaded processing block in steps St22 to St25 is performed.
  • processing for adding a statement to the scheduler processing block in steps St26 to St28 is performed.
  • step St22 the threading processing block 55 is surrounded by a loop as indicated by 51 in FIG.
  • Step St23 waits to receive a signal at the entrance of the loop as shown at 52 in FIG. 16, and inserts an OS service call such as a wait mechanism that releases (releases) the CPU until the signal is received.
  • OS service call such as a wait mechanism that releases (releases) the CPU until the signal is received.
  • step St24 processing blocks that are executed in parallel (simultaneously executed) are processed in consideration of the fact that the threaded processing blocks operate in parallel as shown by 53 and 54 in Fig. 16 (Equation 8) and (Equation 9). And based on the dependency equation derived from (Equation 11), it is analyzed to determine whether or not there is a dependency relationship.
  • step S25 inputs an exclusive control code by a semaphore or a mutex, and the process ends. On the other hand, the process ends if the decision result in the step St24 is NO.
  • Step St26 is a signal expected by the event processing thread 59 dependent on the subordinate clause after the conditional branch as shown by 61 in FIG. 17 (ie, a signal for the event to be operated when the condition A or B is satisfied). Insert a sending mechanism (statement) that issues, and define it as a scheduling block 69.
  • step St27 it is determined whether or not the scheduler processing block is the outermost scheduler processing block. If the determination result in step St27 is YES, step St28 incorporates a timer handler and the process ends. On the other hand, the process ends if the decision result power at step St27 is zero.
  • each processing block incorporates a mechanism that uses the CPU when necessary, that is, a mechanism that releases the CPU when processing operations are unnecessary, so that CPU resources can be used efficiently. become.
  • FIG. 20 is a diagram showing an image of a timing chart during operation of the present embodiment.
  • Figure 20 shows the timing of the periodic signal (timer signal) obtained by using the OS timer function, the dynamic scheduler realized by the scheduler processing block, and the event processing threads ET1 and ET2.
  • the idea of two-pass compilation can be introduced as an optimization method using a general coniler.
  • profiling is performed by actually operating an embedded device etc. based on the execution code generated by the first conn, and the second compilation is performed based on the profiling result. I do.
  • the middle path 34 is an intermediate language 33—decipherable by the back end 35 in FIG. 2 is generated, and the compiler generates execution code 36.
  • FIG. 21 is a diagram comparing the image of the timing chart of this example with the conventional method of FIG.
  • the upper part of FIG. 21 shows the operation timing of this embodiment, and the lower part shows the operation timing of the conventional method of FIG.
  • OH1 indicates the overhead caused by a plurality of threads in this embodiment
  • R1 indicates the CPU release period in this embodiment.
  • the actual end time of the process P3 is slightly later than the end time t2 in the conventional method.
  • the power process P4 can be surely ended by the expected end time t3.
  • FIG. 22 is a diagram showing an image of the scheduler processing block of this embodiment, that is, the dynamic scheduler.
  • 81 is a task or thread
  • 82 is an idle state of a CPU
  • 83 is a dynamic scheduler that has a context switch function and performs scheduling
  • the dynamic scheduler 83 shown in FIG. 22 dynamically performs tasks or threads based on signals from the OS86 timer function 88.
  • the priority of 81 is defined, and the switch 85 of the task or thread 81 is performed by the context switch function and the process management function 84 of OS86.
  • the source code 31 decomposed into a thread and a timer handler actively releases the CPU to enter the idle state 82, so that unnecessary CPU resources are not used.
  • the scheduler processing block constituting the dynamic scheduler 83 is a code originally existing in the source code 31, the overhead caused by a plurality of threads is very small.
  • FIG. 23 is a diagram showing measurement results of resource utilization efficiency when the actual program is compiled for the conventional method and the embodiment.
  • program PA is the video player software
  • program PB is the communication processing software. Air.
  • Programs PA and PB are both software based on time-series processing and outputting intermediate results at a predetermined timing.
  • Program PC is still image processing software
  • program PD is arithmetic operation software.
  • Program PC is software that decompresses XGA compressed images.
  • Program PD is fluid calculation software that has already been optimized at the source code level by programmers.
  • the amount of CPU and memory that is, the amount of resources used is 30 compared to the case of using the conventional method. It was confirmed that it was reduced by around%. In addition, as a secondary effect, it is possible to generate an idle state of the CPU, and it has been confirmed that there is an effect of reducing the power consumption of the CPU.
  • the present invention is applicable to various electronic devices having resources such as a CPU and a memory, and is particularly suitable for embedded devices with limited resources.

Abstract

 コンピュータにより、予め決められたタイミングで途中結果を出力すると共に時系列的に処理されるソフトウェアのコンパイルを行うコンパイル方法は、ソフトウェアのソースコードに含まれる処理シーケンスから並列性及び条件分岐に関する処理ブロックを抽出する抽出ステップと、抽出された処理ブロックのリストラクチャリングを行い実行コードを自動的に生成する生成ステップとを含む。

Description

明 細 書
コンパイル方法及びコンパイラ
技術分野
[0001] 本発明は、コンパイル方法及びコンノイラに係り、特に組み込み機器上におけるソ フトウェアの実行コードを自動的に生成するコンパイル方法及びコンノイラに関する。 背景技術
[0002] 図 1は、組み込み機器上におけるソフトウェアの実行コードを生成する従来のコンパ イラの構成を示す図である。図 1に示すコンパイラは、組み込み機器のソフトウェアを 単一のアプリケーションとして効率的に実行するために、実行コードの最適化を行う。 図 1に示すコンパイラは、翻訳装置 (フロントエンド) 2、最適化装置 (ミドルパス) 4及 びコード生成装置(バックエンド) 5を有する。フロントエンド 2はソースコード 1から中 間言語 3— 1を生成し、ミドルパス 4は中間言語 3— 1から中間言語 3— 2を生成する。 ノ ックエンド 5は、中間言語 3— 2から最適化された実行コード 6を生成する。コンパィ ルによる翻訳作業の過程で、ミドルパス 4にお 、て不要な変数の削除や命令のパッ キング、呼び出し関数のインライン展開等の単純な再構築(リストラクチャリング)を行
[0003] このような実行コードの最適化のためのリストラクチャリングでは、命令コードの削除 や単純置換を行い、ソースコード 1に記述された処理シーケンスの構造そのものを変 更するようなリストラクチャリングは行わな 、。
[0004] 動画処理や通信処理等の処理の実行を開始した後は、 CPUの処理能力に関係な く予め決められた時刻において周期的に途中の演算結果を出力するような時系列処 理のソフトウェアがある。このような時系列的(シーケンシャル)に記述されたソフトゥェ ァを図 1に示すコンパイラでコンパイルして実行コードを生成した場合、処理の開始 力も終了までのトータルの演算量力 SCPUの処理能力に見合ってる場合にぉ 、ても、 図 2に示す例のように処理 P3,P4が開始される順番によっては、処理が間に合わず遅 延を生じることがある。図 2は、時系列処理 (シーケンシャル処理)の遅延を説明する 図である。図 2において、 P1〜P4は処理を示し、 tlは開始条件判断時刻、 t2は処理 P 3の実際の終了時刻、 t3は処理 P4の期待終了時刻、 t4は処理 P4の実際の終了時刻 、 t5は処理 P3の期待終了時刻を示す。この場合、処理 P4の実際の終了時刻 t4は、処 理 P4の期待終了時刻 t3より遅く、遅延 D 1が生じて 、る。
[0005] 一般的には、上記のように平均的な CPUの処理能力が十分であっても、局所的な 処理の観点では CPUの処理能力が不十分な状態が起こり得ると想定される場合、ソ フトウェアは図 3で示すように設計段階でバッファ 8を定義することにより処理遅延の 問題を回避する。図 3は、時系列処理の遅延の回避を説明する図である。図 3中、図 2と同一部分には同一符号を付し、その説明は省略する。図 3において、 P3y,P4yは 夫々 y番目に実行される処理 P3,P4、 P4zは z番目に実行される処理 P4、 t2yは処理 P3 yの実際の終了時刻、 t3yは処理 P4yの期待終了時刻、 t5yは処理 P3yの期待終了時 刻である。
[0006] 図 4は、従来の動的スケジューラのイメージを示す図である。同図中、 11はタスク又 はスレッド、 12はタスク又はスレッド 11から報告される実行情報テーブル、 13は情報 テーブルに基づ 、てスケジューリングを行う動的スケジューラ、 14はオペレーティン グシステム(OS) 16内のコンテキストスィッチ 'プロセス管理機能、 15は動的スケジュ ーラ 13の指示によるスィッチを示す。従来の組み込み機器で効率的に複数のタスク 又はスレッド 11を並列(同時)に実行する場合、図 4に示す動的スケジューラ 13では 、アプリケーションに動的なプロフアイリング機能を持たせ、メモリや CPU使用量を随 時 OS16に報告する。動的スケジューラ 13は、常時収集された情報の情報テーブル 12を参照して動的にタスク又はスレッド 11の優先度を定義し、 OS16のコンテキスト スィッチ.プロセス管理機能 14によりタスク又はスレッド 11のスィッチ 15を行う。
[0007] このように複数のタスク又はスレッド 11を効率的に実行するための動的スケジューラ 13は、 OS16と連動したアプリケーションとは別動作をするソフトウェア、即ち、外部( 又は、外付けの)スケジューラである。このため、対象とするソフトウェアが必要とする CPUの演算量の観点からは、このような動的スケジューラ 13は純粋なオーバーヘッド とみなされる。
[0008] そこで、情報テーブル 12を参照して優先度を定義する動的スケジューラ 13による オーバーヘッドを発生させないために、一般的にはラウンドロビン、或いは、予め固 定的に設定された優先度に従って能動的に動作しな 、オーバーヘッドの小さ 、スケ ジユーラを用いる手法がある力 全てのソフトウェアを効率的に実行することはできな い。
[0009] 処理時間を最短にする実行コードを生成し、且つ、動的スケジューラ 13によるォー バーヘッドを回避するためには、実行コード中に実行開始を定義する静的スケジュ ーラ機構を埋め込む手法が用いられることがある。
[0010] 静的スケジューラは、メモリや CPUの使用量を動的に報告しない代替手段として、コ ンノィル時に分岐命令に着目し、分岐命令力 ジャンプする従属処理のメモリや CP uの使用量に対して、分岐予測の係数を乗じた見込みの情報テーブルに基づいてコ ンノ ィル時にスケジューリングを決定する。
[0011] 静的スケジューラは、動的に最適な処理を行う動的スケジューラに対して、実行時 のスケジューリングに対するオーバーヘッドは小さいが、特に実行毎に演算量や取り 扱うデータ量が変化するような構造のソフトウェアでは、スケジューリング精度が落ち、 処理時間を最短に行えるとは限らない。このため、静的スケジューラは、一般的には
CPU上で処理を行 、た!/、演算量が予めわかって!/、るソフトウェアに用いられる。
[0012] 従来のコンパイラは、コードレベルの最適化や時系列的に記述されたソースコード のコンパイル時にデータ依存や制御依存の解析を行 ヽ、並列実行可能な処理を分 割し、並列に配置された CPUに対する実行コードを生成する。このようにして、時系列 的に記述されたソースコードからより多くの並列性を抽出し、実行開始から終了まで の処理時間を最短に行える実行コードを生成する。
[0013] 動的スケジューラは、例えば特許文献 1や特許文献 2にて提案されている。又、多 重レベルスケジューラは、例えば特許文献 2にて提案されて 、る。
特許文献 1:特開平 6— 110688号公報
特許文献 2:特開 2003 - 84989号公報
特許文献 3:特開平 8— 212070号公報
発明の開示
発明が解決しょうとする課題
[0014] 組み込み機器のソフトウェア実行環境は、高度化する OSやコンパイル環境により 変化しており、パーソナルコンピュータ(PC)やワークステーション等で動作していた 汎用のソフトウェアが組み込み機器で動作するようになってきている。一方、組み込 み機器では、 CPUやメモリ等の限られたリソースを用いて、対象とするソフトウェアを効 率的に実行することが望まれている。
[0015] 従来の組み込み機器では、リストラクチャリングを伴わないコード最適化レベルのコ ンノイラが起動される力、或いは、複数のタスク又はスレッドが起動するようなソフトゥ エア構成の場合にはスケジューラが起動される。
[0016] 一方で、ソフトウェアをより効率的に動作させためには、ソフトウェアの実装者により 対象となる組み込み機器に適した移植作業を手動で行う必要があった。
[0017] このように、組み込み機器の限られたソフトウェア実行環境では、ソフトウェア、特に 時系列的に記述されたソースコードで、且つ、予め決められた時刻に周期的に途中 の演算結果を出力するような時系列処理を行うアプリケーションを実行する際に、低 いオーバーヘッド、高いスケジューリング精度、 CPUやメモリ等のリソースの効率的な 利用を可能とする実行コードをコンノイラにより自動的に生成することが求められてい る。
[0018] そこで、本発明は、限られたソフトウェア実行環境でもソフトウェアの実行コードを効 率的に生成することが可能なコンパイル方法及びコンパイラを実現することを目的と する。
課題を解決するための手段
[0019] 上記の課題は、コンピュータにより、予め決められたタイミングで途中結果を出力す ると共に時系列的に処理されるソフトウェアのコンパイルを行うコンパイル方法であつ て、該コンピュータにより、該ソフトウェアのソースコードに含まれる処理シーケンスか ら並列性及び条件分岐に関する処理ブロックを抽出する抽出ステップと、該コンビュ ータにより、抽出された処理ブロックのリストラクチャリングを行い実行コードを自動的 に生成する生成ステップとを含むことを特徴とするコンパイル方法によって達成できる
[0020] 上記の課題は、コンピュータにより、予め決められたタイミングで途中結果を出力す ると共に時系列的に処理されるソフトウェアのコンパイルを行うコンパイラであって、該 コンピュータにより、該ソフトウェアのソースコードを第 1の中間言語に翻訳して記憶部 に保存するフロントエンドと、該コンピュータにより、該記憶部に保存された該第 1の 中間言語に基づいて該ソースコードに含まれる処理シーケンスから並列性及び条件 分岐に関する処理ブロックを抽出し、抽出された処理ブロックのリストラクチャリングを 行い第 2の中間言語を生成して記憶部に保存するミドルパスと、該コンピュータにより 、該記憶部に保存された該第 2の中間言語に基づいて実行コードを自動的に生成す るバックエンドとを備えたことを特徴とするコンパイラによって達成できる。 発明の効果
[0021] 本発明によれば、限られたソフトウェア実行環境でもソフトウェアの実行コードを効 率的に生成することが可能なコンパイル方法及びコンパイラを実現することができる。 図面の簡単な説明
[0022] [図 1]従来のコンパイラの構成を示す図である。
[図 2]時系列処理の遅延を説明する図である。
[図 3]時系列処理の遅延の回避を説明する図である。
[図 4]従来の動的スケジューラのイメージを示す図である。
[図 5]本発明のコンパイラの一実施例の構成を示す図である。
[図 6]ソフトウェアを構成するソースコードの分類を説明する図である。
[図 7]ステートメントの依存関係を表現した依存グラフの一例を示す図である。
[図 8]図 7の依存グラフを元に処理順序を入れ替えた例を示す図である。
[図 9]ソフトウェアのフロー構成例を示す図である。
[図 10]実施例の第一段階の処理を示すフローチャートである。
[図 11]無条件ジャンプ及びループ処理のブロックの演算代入処理ブロックとしての再 定義を説明する図である。
[図 12]演算代入処理ブロック同士の再定義を説明する図である。
[図 13]スレッドィ匕処理ブロック及びスケジューラ化処理ブロックの再定義を説明する図 である。
[図 14]スレッドィ匕処理ブロック及びスケジューラ化処理ブロックを説明する図である。
[図 15]実施例の第二段階の処理を示すフローチャートである。 [図 16]スレッドィ匕処理ブロックへのステートメントの追加方法を説明する図である。
[図 17]スケジューラ化処理ブロックへのステートメントの追加方法を説明する図である
[図 18]最外郭スケジューラ化処理ブロックのタイマ処理を説明する図である。
圆 19]実施例の第三段階の処理を説明するフローチャートである。
[図 20]実施例の動作時のタイミングチャートのイメージを示す図である。
[図 21]図 2の従来手法と実施例のタイミングチャートのイメージを比較する図である。
[図 22]実施例のスケジューラ化処理ブロックのイメージを示す図である。
[図 23]実際のプログラムに対してコンパイルを行った場合のリソースの利用効率の測 定結果を従来手法と実施例につ 、て示す図である。
符号の説明
[0023] 31 ソースコード
32 フロントエンド
33 - 1, 33- 2 中間言語
34 ミドノレパス
35 ノ ックエンド
36 実行コード
81 タスク又はスレッド
83 動的スケジューラ
84 コンテキストスィッチ ·プロセス管理機能
86 OS
88 タイマ機能
発明を実施するための最良の形態
[0024] 本発明のコンパイル方法及びコンパイラでは、組み込み機器上で動作するソフトゥ エアのうち、時系列的に記述されたソフトウェアのソースコードを、コンパイル時におけ る中間言語のプリプロセッシングでタスク又はスレッド化し、スケジューリングコードを 生成するリストラクチャリングを行うことにより、小さいオーバーヘッドの実現と CPU等 のリソースの利用効率の向上を可能とすることができる実行コードを生成する。 [0025] つまり、 み込み機器上で動作するアプリケーションのうち、動画処理や通信処理 等の時系列処理を行うようなループ構成のアプリケーションにおいて、コンパイルの 初期段階で構造解析の終わった中間言語(中間コード)上でステートメントレベルで 分類された処理ブロックから、条件分岐の処理ブロックで構成されるスケジューラの 構築、タイマハンドラ化、及び条件分岐後に実行される演算代入処理の処理ブロック の抽出、スレッド化を行い、ウェイトによる CPUの解放 (リリース)、シグナルに応答する ウェイクアップ (Wake- Up)機構を挿入するような再構築(リストラクチャリング)を行うこ とで、実行時に必要なタイミングで必要な演算処理を行い、不要なときは CPUを解放 するような仕組みにより CPUを含むリソースの利用効率を向上させる。
[0026] このように、本発明では、実行対象のソフトウェアの元となるソースコードをコンパィ ル過程の中間言語レベルで解析、分類し、抽出された処理ブロックカゝら並列(同時) に処理可能な処理ブロック及び、スケジューリングに関する処理ブロックとして再定義 し、必要最低限のステートメントを挿入する。これにより、不要な外部ステートメント(コ ード)を削除し、対象とするソフトウェアの専用スケジューラをリストラクチャリングにより 実現することができる。
実施例
[0027] 図 5は、本発明のコンノイラの一実施例の構成を示す図である。コンパイラの本実 施例は、本発明のコンパイル方法の一実施例を採用する。本実施例では、本発明が 組み込み機器上におけるソフトウェアの実行コードを生成する場合に適用されている 。組み込み機器は、 CPU等のプロセッサとメモリ等の記憶部を備え、プロセッサが記 憶部に格納されたプログラムを実行する周知のハードウェア構成を有するコンビユー タ(又はコンピュータシステム)である。
[0028] 図 5に示すコンパイラは、組み込み機器のソフトウェアを単一のアプリケーションとし て効率的に実行するために、実行コードの最適化を行う。図 5に示すコンパイラは、 翻訳装置 (フロントエンド) 32、最適化装置 (ミドルパス) 34及びコード生成装置 (バッ クエンド) 35を有する。フロントエンド 32はソースコード 31から中間言語 33— 1を生成 して記憶部に保存し、ミドルパス 34は記憶部に保存された中間言語 33— 1から中間 言語 33— 2を生成して記憶部に保存する。バックエンド 35は、記憶部に保存された 中間言語 33— 2から最適化された実行コード 36を生成し、必要に応じて記憶部に保 存する。コンパイルによる翻訳作業の過程で、ミドルパス 34において不要な変数の削 除や命令のパッキング、呼び出し関数のインライン展開等の単純なリストラクチャリン グを行う。フロントエンド 32やバックエンド 35は単純な翻訳装置であり、能動的に実 行コードの最適化を行うことはない。実行コードの最適化を行わない場合には、フロ ントエンド 32が生成した中間言語 33— 1を直接バックエンド 35が解読し、実行コード を生成するため、ミドルパス 34は使用されない。
[0029] 一般的に、コンパイル処理は、ソースコードで示された処理シーケンスを対象とする CPU等の演算装置 (プロセッサ)が解読できる実行コードに変換する。又、ミドルパス では、伝播しない変数及び数式文の削除やサブルーチンのインライン展開、或いは 、ループをイタレーシヨン単位で展開するアンローリング処理等の汎用的な最適化手 法により、より効率的な実行コードを生成する。
[0030] これに対し、本実施例は、ミドルパス 34に組み込まれる効率的な実行コードの生成 手法に特徴がある。図 5に示すミドルパス 34は、中間言語 33— 1を入力とし、以下に 示す手順によりリストラクチャリングを行い、中間言語 33— 2を生成する。中間言語 33 —1のレベルでリストラクチャリングを行う。このため、フロントエンド 32及びバックェン ド 35については従来と同様のものを変更することなく使用可能であり、ミドルパス 34 は既存のコンパイラに汎用的に組み込むことが可能である。
[0031] 図 6は、ソフトウェアを構成するソースコード 31の分類を説明する図である。図 6は、 ソフトウェアを構成するソースコード 31をステートメントレベルで分類した場合を示し、 全てのソースコード 31は中間言語 33— 1に翻訳された後、以下の 、ずれかの処理 区分 psl〜ps4に分類することができる。処理区分 pslは、演算及びメモリやレジスタ 等の記憶部に演算結果の代入を行う演算代入処理であることを示す。処理区分 Ps2 は、バックエッジを含むジャンプ命令で示されるループ処理、即ち、バックエッジジャ ンプであることを示す。処理区分 ps3は、条件分岐或いは条件付きジャンプ命令で示 される分岐処理であることを示す。処理区分 ps4は、サブルーチンや関数コール等を 示し、無条件ジャンプ命令であることを示す。
[0032] 本実施例では、任意の構成の中間言語 33— 1に着目してリストラクチャリングを行う ので、汎用的な最適化処理がどこで行われても構わないが、ループ構造をそのまま 使用するため、リストラクチャリングを行う前にアンローリング手法等のループ最適化 手法は適用しないものとする。
[0033] コンパイラは、中間言語 33— 2を生成する際に必ず変数テーブルを内部に持ち、 中間言語 33— 2の各ステートメントは昇順で採番されており、参照する変数 (式の右 辺)と、定義する変数 (式の左辺)を持つ。 X番目のステートメントを Sxで表した場合、 S Xの参照変数の集合体を (式 1)、 Sxの定義変数の集合を (式 2)で表す。
Use(Sx) (式 1)
DeKSx) (式 2)
(式 1)及び (式 2)は、集合ィ匕されたステートメントグループ SGにも適用され、 y番目 のステートメントグループ SGyに対して同様に(式 3)及び (式 4)を定義する。
Use(SGx) (式 3)
DeKSGx) (式 4)
又、定義及び参照される変数が存在しない場合の表現として、空集合を Φ用いる。
[0034] ステートメント Sxが条件分岐文の場合、条件を判定するための参照変数のみが存 在するため、(式 5)が成立する。
DeKSx) = Φ、 Use(Sx)≠ Φ (式 5)
ステートメント Sxがサブルーチンコールに因る無条件ジャンプ文の場合、(式 6)が成 立する。
DeKSx) = Use(Sy) = Φ (式 6)
ステートメント間の依存関係は、互いに定義及び参照する変数集合に対して同一の 要素が含まれる力否かで定義される。 m番目及び n番目のステートメントに関して、(式 1)及び (式 2)力 導かれる変数の集合体にぉ 、て、 mく nの関係で (式 7)が成立する 場合、正方向依存が存在する。
DeKSm) ΓΊ Use(Sn)≠ Φ (式 7)
ここで、 Smと Snが正方向依存 δであることを表現する式として(式 8)を定義する。
Sm δ Sn (式 8)
m〉nの関係で (式 7)が成立する場合、逆方向依存が存在する。 Smと Snが逆方向依 存 δ iであることを表現する式として、(式 9)を定義する。
¾m δ l Sn (式 9)
又、(式 10)が成立する場合、出力依存が存在する。
DeKSm) = DeKSn) (式 10)
Smと Snが出力依存 δ 0であることを表現する式として、(式 11)を定義する。
¾m δ 0 ¾η (式 l lj
(式 11)が成立する Sm, Snについて、 m〈k〈nの関係を満たす任意の kに対して(式 12)が成り立つ場合、 Smで定義される変数はどこでも参照されることなぐ Snにおいて 上書きされることから、 Smを削除することが可能である。
(DeKSm) = DeKSn)) ΓΊ Use(Sk) = Φ (式 12)
(式 8)、(式 9)及び (式 11)を一般的には依存方程式と呼び、全てのステートメント に対して (式 1)及び (式 2)を導くことで、各ステートメントの依存関係を表現した依存 グラフを作成することができる。
[0035] 図 7は、ステートメントの依存関係を表現した依存グラフの一例を示す図である。同 図中、 Sa〜Sfは、ステートメントを示す。図 7に示す例では、ステートメント Saの定義結 果をステートメント Sdが参照し、ステートメント Sdが参照して 、る変数をステートメント Sf で定義することを表している。又、ステートメント Sbの定義変数はどこでも使用されるこ となぐステートメント Sfにおいて再定義されることから (式 12)が成立するとみなされ、 ステートメント Sbはコード中から削除されることになる。
[0036] 原則として(式 8)、(式 9)及び (式 11)の関係にあるステートメントは、何らかの依存 関係にあるステートメントであり、処理順序を入れ替えることはできない。言い換えると 、(式 8)、(式 9)及び (式 11)のいずれの関係も成立しないステートメント同士は、処 理順序の入れ替えを行うことができる。
[0037] 上記の観点から、図 7において、(式 13)に示すようにステートメント Saとステートメン ト Sdから構成されるグループを SGx、ステートメント Scとステートメント Seから構成される グループを SGyとした場合、これらは(式 14)から依存関係にないため、互いに処理 順序を入れ替えることが可能である。(式 14)において、「 δ」は依存関係がないこ とを示す。又、上述のようにステートメント Sbは削除可能なため、図 7で示す依存ダラ フは図 8に示すグラフと等価となる。図 8は、図 7の依存グラフを元にステートメントの 処理順序を入れ替えた、即ち、ソートされた例を示す図である。
SGx = (Sa, Sd), SGy = (Sc, Se) (式 13)
つまり、
DeKSGx) = DeKSa) U DeKSd), Use(SGx) = Use(Sa) U Use(Sd) DeKSGy) = DeKSc) U DeKSe), Use(SGy) = Use(Sc) U Use(Se)
且つ、
(DeKSa)或いは DeKSd) ΓΊ (Use(Se)或いは Use(Se)) = Φ
(Use(Sa)或いは Use(Sd) ΓΊ (DeKSe) 或いは DeKSe)) = Φ
(DeKSa)或いは DeKSd) ΓΊ (DeKSe) 或いは DeKSe)) = Φ
が成立するため、(式 14)が得られる。
SGx ^ S SGy (式 14)
図 9は、ソフトウェアのフロー構成例を示す図である。図 9中、 psl〜ps4は、夫々図 6に示す処理区分 psl〜ps4の処理に対応する処理ブロックを示す。中間言語に展 開されたステートメントの列は、図 9で示すように、複数代入処理の処理ブロック psl の間に条件分岐の処理ブロック ps3或いは無条件ジャンプの処理ブロック ps4が挟ま つた形態を取る。条件分岐の処理ブロック ps3及び無条件ジャンプの処理ブロック ps 4は、データ依存ではなく制御構造を示すものであり、処理フローがー且途切れると みなされるため、図 5に示すミドルパス 34の処理単位を、条件分岐の処理ブロック ps 3及び無条件ジャンプの処理ブロック ps4のステートメントで区切られた演算代入処理 の処理ブロック psl、即ち、代入ステートメントの集合と考える。
[0038] 本実施例では、第一段階の処理として、図 9に示す演算代入処理の処理ブロック p siに対して、上記ステートメント間の依存方程式に基づく並べ替えを行うものとする。 図 10は、本実施例の第一段階を示すフローチャートである。図 10において、入力は 中間言語 33— 1であり、出力も中間言語 33— 1である。
[0039] 図 10に示す第一段階は、全ての制御ステートメントで区切られた演算代入ステート メントのグループに対して行われる。先ず、ステップ Stlで定義及び参照される変数の 抽出が行われ、ステップ St2で依存グラフの定義が行われる。又、ステップ St3で不要 なステートメントの削除が行われ、ステップ St4で依存グラフに基づくステートメントのソ ートが行われる。
[0040] 第一段階の依存解析において、従来はコンパイル段階でポインタ変数等の依存関 係を明確に抽出できない場合があった。本実施例の第一段階は、第二段階以降の 操作をより簡便に行うための前処理であるため、必ずしも全ての依存関係を抽出でき る必要はない。
[0041] 本実施例の第二段階では、上記の中間言語レベルで整理されたステートメント列に 対し、後述する方式に従ってステートメントのグループの結合及び再定義を行う。又、 第二段階では、上記処理区分で分類された処理ブロックを結合する作業を行うが、 一般的なソフトウェアは、ネスト構造のループ、入れ子構成の条件分岐、サブルーチ ン配下のループ、条件分岐等の階層構造を有する。このため、本実施例の第二段階 で行う操作は、ネスト又は入れ子構造にある最も内側の階層の処理ブロック力 順に 行っていくものとする。
[0042] ネスト又は入れ子構造の最も内側の処理ブロックは、必ず演算代入処理の処理ブ ロックになっている。第一段階において、最も内側の処理ブロックに存在したステート メントが依存方程式の解により削除された場合には、該当する入れ子構造も削除され る。
[0043] ネスト又は入れ子構造の最も内側の処理ブロックの処理にあたっては、呼び出し元 の処理ブロックが無条件ジャンプ、即ち、コールされるサブルーチンの本体である場 合には、これを前段処理区分の無条件ジャンプの処理ブロックと結合して再グルー プ化し、演算代入処理ブロックとして再定義する。
[0044] 一般的なコード最適化において、ステートメントがインライン展開されていれば、この 操作は第一段階の処理において通常の演算代入処理ブロックの整理と共に処理さ れるが、本実施例においては、ステートメントがインライン展開される必要はなぐ単に ステートメントのグループィ匕が行われるだけで良い。
[0045] ネスト又は入れ子構造の最も内側の処理ブロックの処理にあたっては、呼び出し元 の処理ブロックがループ処理(バックエッジジャンプ)の処理ブロック、即ち、ループ内 部に条件分岐等の制御構造を伴わな 、単純ループの本体である場合には、これを 再グループィ匕し、演算代入処理ブロックとして再定義する。
[0046] 図 11は、無条件ジャンプ及びループ処理(バックエッジジャンプ)の処理ブロックの 演算代入処理ブロックとしての再定義を説明する図である。図 11に示すように、呼び 出し元の処理ブロックが無条件ジャンプの処理ブロックである場合には、これを前段 処理区分の無条件ジャンプの処理ブロックと結合して再グループ化し、演算代入処 理ブロックとして再定義する。又、図 11に示すように、呼び出し元の処理ブロックがル ープ処理(バックエッジジャンプ)の処理ブロックである場合には、これを再グループ 化し、演算代入処理ブロックとして再定義する。
[0047] 上記の如き演算代入処理ブロックの再定義を行った結果、ネスト又は入れ子の同 一階層に演算代入処理ブロックが縦列に並ぶことがある。この場合、縦列に並んだ 演算代入処理ブロックは結合され、再び演算代入処理ブロックとして再定義される。
[0048] 図 12は、演算代入処理ブロック同士の再定義を説明する図である。図 12において 、「代入演算」は代入演算処理ブロックを示し、破線で囲まれた処理ブロックは結合さ れた処理ブロックを示す。
[0049] 次に、呼び出し元の処理ブロックが条件分岐処理の処理ブロックの場合、即ち、条 件分岐の真偽 、ずれかの従属節にあたる場合、特に処理ブロック間の結合処理を行 うことなく、これをスレッド化処理ブロックとして再定義する。
[0050] 図 13は、スレッドィ匕処理ブロック及びスケジューラ化処理ブロックの再定義を説明 する図である。ネスト又は入れ子構造の階層的な解析により、スレッド化処理ブロック の構成要素は必ずしも 1つの処理ブロックとは限らず、又、スレッド化処理ブロックの 構成要素は演算代入処理ブロックだけとは限らない。
[0051] 又、ある処理ブロックの後続の処理ブロックが条件分岐処理である場合、これらの 処理ブロックを結合し、スケジューラ化処理ブロックとして再定義する。
[0052] スレッド化処理ブロックとスケジューラ化処理ブロックには密接な関係があり、スレツ ド化処理ブロックは条件分岐力 の従属節であるため、必ず該当する条件分岐を含 んだスケジューラ化処理ブロックと連携することになる。
[0053] 上記の処理ブロック化を対象とするコードに対して、ネストや入れ子構造も考慮して スレッド化処理ブロック及びスケジューラ化処理ブロックを再定義する。図 14は、スレ ッド化処理ブロック及びスケジューラ化処理ブロックを説明する図である。図 14に示 すプログラム中、 41は図 14において階層の最も上位に属するスケジューラ化処理ブ ロック、 42はスケジューラ化処理ブロック 41に従属するスレッド化処理ブロック、 43は スケジューラ化処理ブロック 41の一階層下に含まれるスケジューラ化処理ブロック、 4 4はスケジューラ化処理ブロック 43に従属するスレッド化処理ブロック、 45はスレッド 化処理ブロック 42の一階層下に含まれるスケジューラ化処理ブロック、 46はスケジュ ーラ化処理ブロック 45に従属するスレッド化処理ブロックを夫々示す。
[0054] 図 15は、本実施例の第二段階の処理を示すフローチャートである。図 15において 、入力は中間言語 33— 1であり、出力も中間言語 33— 1である。
[0055] 図 15に示す第二段階は、上記第一段階で行った依存グラフに基づくステートメント のソートの結果に対して行われる。先ず、ステップ Stllは、処理ブロック化を対象とす るプログラムのコードに対して、ネスト又は入れ子構造にある最も内側の階層の処理 ブロック力 順に処理を開始する。ステップ Stl2は、呼び出し元の処理ブロックが条件 分岐処理であるか否かを判定する。ステップ Stl2の判定結果力 WESであると、ステツ プ Stl3は、条件分岐の従属節をスレッドィ匕処理ブロックとして再定義し、処理はステツ プ Stllへ戻り、ネスト又は入れ子構造にある最も内側の階層の次の階層の処理プロ ックの処理を開始する。他方、ステップ Stl2の判定結果力 NOであると、ステップ Stl4 は、後続の処理ブロックが条件分岐処理に続くものであるか否かを判定し、判定結果 力 SNOであると、処理はステップ Stllへ戻り、ネスト又は入れ子構造にある最も内側の 階層の更に次の階層の処理ブロックの処理を開始する。又、後続の処理ブロックが 条件分岐処理でありステップ Stl4の判定結果力YESであると、ステップ Stl5は、これら の処理ブロックと後続の処理ブロックを結合してスケジューラ化処理ブロックとして再 定義する。ステップ Stl5の後、処理はステップ Stllへ戻り、ネスト又は入れ子構造に ある最も内側の階層の次の階層の処理ブロックの処理を開始する。
[0056] 本実施例の第二段階では、上記の中間言語レベルで整理されたステートメント列に 対し、後述する方式に従ってステートメントのグループの結合及び再定義を行う。又、 第二段階では、上記処理区分で分類された処理ブロックを結合する作業を行うが、 一般的なソフトウェアは、ネスト構造のループ、入れ子構成の条件分岐、サブルーチ ン配下のループ、条件分岐等の階層構造を有する。このため、本実施例の第二段階 で行う操作は、ネスト又は入れ子構造にある最も内側の階層の処理ブロック力 順に 行っていくものとする。
[0057] 本実施例の第三段階では、第二段階でグループィ匕を行ったスケジューラ化処理ブ ロック及びスレッド化処理ブロックに制御ステートメントを付カ卩し、スレッドとスケジユー ラとして最終的な中間言語(中間コード)を生成する。
[0058] 条件分岐及び条件を算出する演算と、それに従属する処理ブロックの呼び出しは、 動的スケジューラとスケジューリングされるスレッドの関係と等価である。本実施例で は、外部 (又は、外付けの)スケジューラを使用しない構造とするため、スケジューラ化 処理ブロックの構造にスレッドのコンテキストスィッチ機能と同様の動きをする仕組み を設ける。又、スレッド化処理ブロックには、スケジューラの要求時にのみ動作する仕 組みを設ける。
[0059] そこで、本実施例の第三段階では、スケジューラ化処理ブロックとそれに従属する スレッドィ匕処理ブロックに対して次のような操作を行う。
[0060] 図 16は、スレッドィ匕処理ブロックへのステートメントの追加方法を説明する図である 。先ず、図 16に 51で示すようにスレッド化処理ブロック 55をループで囲み、 52で示 すようにループの入口部分 (先頭部分)にシグナルを受信待ちし、シグナルを受信す るまでは CPUを解放(リリース)するウェイト (wait)機構のような OSのサービスコールを 挿入する。又、 53, 54で示すように、スレッドィ匕された処理ブロック同士が並列動作 することも考慮し、並列実行(同時実行)する処理ブロックを (式 8)、(式 9)及び (式 11 )で導かれる依存方程式に基づいて解析し、依存関係にある場合、セマフォ (Semaph ore)やミューテックス(Mutex)による排他制御コードを挿入する。つまり、 53で示すよ うに排他ロックをかけると共に、 54で示すように排他ロックを解除する。上記の操作に より、構造を変更されたスレッド化処理ブロック 55をイベント処理スレッド 59として定義 して起動するようなコードをプログラム本体に追加することができる。
[0061] 上記の操作により、処理動作を行わなくても良いタイミングでは、イベント処理スレツ ド 59は CPUを解放しているため、不要な CPUリソースを使用することがない。
[0062] 図 17は、スケジューラ化処理ブロックへのステートメントの追加方法を説明する図で ある。スケジューラ化処理ブロックには条件分岐処理が含まれており、その条件分岐 が発生するタイミングが上記のイベント処理スレッド 59を起動するタイミング (スケジュ 一リングする)であると考えられる。そこで、条件分岐後の従属節に、図 17に 61で示 すように従属するイベント処理スレッド 59が期待するシグナル (即ち、条件 A又は Bが 成立すると動作させるイベントに対するシグナル)を発行するステートメント(コード)を 挿入し、これをスケジューラ化処理ブロック 69として定義する。
[0063] 元となるソースコード 31中、スケジューラ化処理ブロック 65が入れ子構造の内部に ある場合、そのスケジューラ化処理ブロック 65を起動するのはその親階層にあるスケ ジユーラ化処理ブロックである。図 14の例では、シグナルに応答するウェイクアップ機 構が挿入されたようなリストラクチャリングにより、 45で示す入れ子の内側のスケジュ ーラ化処理ブロックは、 41で示す上位階層のスケジューラ化処理ブロックからのシグ ナル発信を契機に、ダイナミックに起動されることになる。
[0064] 本実施例では、主に時系列処理、即ち、予め決められたタイミングで途中の演算結 果を出力するような汎用的なプログラミング言語で記述されたプログラムを想定してお り、このようなプログラムは、一般的にはプログラムの最も上位の階層でループ構造を 取る。本実施例の第二段階の処理を行うと、必ず最外郭ループに囲まれたスケジュ ーラ化処理ブロック、即ち、最外郭スケジューラ化処理ブロックが存在することになる
[0065] 上記最外郭スケジューラ化処理ブロックを起動する動的シグナル発生装置はな!/、 ため、最外郭スケジューラ化処理ブロックについては、図 18に示すように、 OSのタイ マ機能を用い、周期的に OSからシグナル (タイマ信号)を送信し、自動起動させるよ うなタイマハンドラのような仕組みを組み込む。図 18は、最外郭スケジューラ化処理 ブロックのタイマ処理を説明する図である。図 18中、図 17と同一部分には同一符号 を付し、その説明は省略する。図 18において、 64は OSから周期的に送信されるシ グナル(タイマ信号)、 65Aは最外郭スケジューラ化処理ブロック、 69Aは 61で示すよ うに従属するイベント処理スレッド 59が期待するシグナル (即ち、条件 A又は Bが成立 すると動作させるイベントに対するシグナル)を発行するステートメント(コード)が挿入 されて定義されたスケジューラ化処理ブロックを示す。 [0066] 図 19は、本実施例の第三段階の処理を説明するフローチャートである。図 19にお いて、入力は中間言語 33— 1であり、出力は中間言語 33— 2である。
[0067] 図 19に示す第三段階は、上記第二段階でグループィ匕を行ったスケジューラ化処 理ブロック及びスレッド化処理ブロックに対して行われる。先ず、ステップ St21は、処 理の対象となる処理ブロックがスレッド化処理ブロックである力、或いは、スケジューラ 化処理ブロックであるかを判定する。処理対象となる処理ブロックがスレッド化処理ブ ロックの場合、ステップ St22〜St25のスレッド化処理ブロックへステートメントを追加す る処理が行われる。他方、処理対象となる処理ブロックがスケジュール化処理ブロック の場合、ステップ St26〜St28のスケジューラ化処理ブロックへステートメントを追加す る処理が行われる。
[0068] ステップ St22は、図 16に 51で示すようにスレッド化処理ブロック 55をループで囲む 。ステップ St23は、図 16に 52で示すようにループの入口部分にシグナルを受信待ち し、シグナルを受信するまでは CPUを解放 (リリース)するウェイト (wait)機構のような O Sのサービスコールを挿入する。ステップ St24は、図 16に 53, 54で示すようにスレッド ィ匕された処理ブロック同士が並列動作することも考慮し、並列実行(同時実行)する 処理ブロックを (式 8)、(式 9)及び (式 11)で導かれる依存方程式に基づ!/、て解析し 、依存関係にあるか否かを判定する。ステップ S24の判定結果力 WESの場合、ステツ プ S25は、セマフォ(Semaphore)やミューテックス(Mutex)による排他制御コードを揷 入し、処理は終了する。他方、ステップ St24の判定結果が NOであると処理は終了す る。
[0069] ステップ St26は、条件分岐後の従属節に図 17に 61で示すように従属するイベント 処理スレッド 59が期待するシグナル (即ち、条件 A又は Bが成立すると動作させるィべ ントに対するシグナル)を発行する送信機構 (ステートメント)を挿入し、これをスケジュ ーラ化処理ブロック 69として定義する。ステップ St27は、スケジューラ化処理ブロック が最外郭スケジューラ化処理ブロックである力否かを判定する。ステップ St27の判定 結果力YESであると、ステップ St28は、タイマハンドラを組み込み、処理は終了する。 他方、ステップ St27の判定結果力 0であると、処理は終了する。
[0070] 上記第三段階の操作を行うことにより、ソースコード 31中に含まれた処理シーケン スカも動的スケジューラ機能を導き出すことができ、外部スケジューラを用いる場合の ようなオーバーヘッドが発生しない。又、不要なバッファリングを行う必要がないため、 メモリの利用効率が高くなる。更に、各処理ブロックは、必要時に CPUを使用するよう な仕組み、即ち、処理動作が不要な時には CPUを解放する仕組みも同時に組み込 まれるため、 CPUのリソースも効率的に使用することが可能になる。
[0071] 図 20は、本実施例の動作時のタイミングチャートのイメージを示す図である。図 20 は、 OSのタイマ機能を用いて得られる周期的なシグナル (タイマ信号)、スケジューラ 化処理ブロックにより実現される動的スケジューラ、及びイベント処理スレッド ET1, ET 2のタイミングを示す。
[0072] ネスト又は入れ子構造になっているコードのうち、同一階層にあるスケジューラがあ り、且つ、上記 (式 14)で導出されるステートメント(又は処理ブロック)の順序の入れ 替えが可能な場合、スケジューラ化処理ブロックの処理順序を入れ替えることで、動 的スケジューリングにおける割付優先度の制御の考え方を導入することが可能である 。一般的に、動的スケジューラの割付優先度の決定は、ヒューリスティック (heuristic) なアルゴリズムに従って行われ、 CPUの使用量(処理ブロックのクリティカルパス)、メ モリの使用量 (データ使用量)等をアルゴリズムが判断に用いるパラメータ (又は係数 )として使用する。優先度のソートの鍵となるパラメータを決定するに当たり、最良の解 を得るには対象とするソフトウェアの性質に依存することが大き 、。
[0073] 本実施例では、上記第一段階〜第三段階の処理をコンパイラのミドルパス 34に組 み込むため、一般的なコンノイラによる最適化の手法として 2パスコンパイルの考え を導入することができる。一般的な 2パスコンノ《イラでは、 1回目のコンノィルで生成さ れた実行コードに基づいて実際に組み込み機器等を動作させてプロフアイリングを 行い、プロフアイリングの結果に基づいて 2回目のコンパイルを行う。
[0074] プロフアイリングを用いる 2パスコンパイルを許すコンノイラに本実施例を適用した 場合、スケジューラ化処理ブロックの優先度によるソートを、このプロフアイリング結果 に基づいて行うことが可能である。従って、本手法を用いることで、より精度の高いス ケジユーリング結果を得ることが可能になる。
[0075] このようにして、ミドルパス 34は、図 5のバックエンド 35が解読可能な中間言語 33— 2を生成し、コンパイラは実行コード 36を生成する。
[0076] 図 21は、図 2の従来手法と本実施例のタイミングチャートのイメージを比較する図で ある。図 21中、図 2及び図 20と同一部分には同一符号を付し、その説明は省略する 。図 21の上部は本実施例の動作タイミングを示し、下部は図 2の従来手法の動作タ イミングを示す。図 21において、 OH1は本実施例における複数スレッドィ匕により生じ るオーバーヘッドを示し、 R1は本実施例における CPU解放期間を示す。本実施例に よれば、処理 P3の実際の終了時間は従来手法における終了時間 t2より多少遅くなる 力 処理 P4を確実に期待終了時間 t3までに終了することができる。このため、本実施 例では、時系列処理することで定期的に途中演算結果を出力するようなソフトウェア にお 、て、従来手法にぉ 、て生じて 、た分岐タイミングの逸脱による処理完了時間 の遅延を回避することができる。又、本実施例では、図 3の従来手法のようなバッファ リングを行う必要がないため、メモリの利用効率が高くなる。
[0077] 図 22は、本実施例のスケジューラ化処理ブロック、即ち、動的スケジューラのィメー ジを示す図である。同図中、 81はタスク又はスレッド、 82は CPUのアイドル状態、 83 はコンテキストスィッチ機能を有すると共にスケジューリングを行う動的スケジューラ、
84は OS86内のプロセス管理機能、 85は動的スケジューラ 83の指示によるスィッチ 、 88は OS86内のタイマ機能を示す。組み込み機器で効率的に複数のタスク又はス レッド 81を並列(同時)に実行する場合、図 22に示す動的スケジューラ 83は、 OS86 のタイマ機能 88からのシグナルに基づいて動的にタスク又はスレッド 81の優先度を 定義すると共に、そのコンテキストスィッチ機能及び OS86のプロセス管理機能 84に よりタスク又はスレッド 81のスィッチ 85を行う。本実施例によれば、スレッドとタイマハ ンドラに分解されたソースコード 31は、能動的に CPUを解放しアイドル状態 82にする ため、不要な CPUのリソースを使用することがない。又、動的スケジューラ 83を構成 するスケジューラ化処理ブロックは、元々ソースコード 31中に存在するコードであるた め、複数スレッドィ匕により生じるオーバーヘッドも極めて小さい。
[0078] 図 23は、実際のプログラムに対してコンパイルを行った場合のリソースの利用効率 の測定結果を上記従来手法と実施例について示す図である。図 23に示すように、プ ログラム PAは動画プレーヤのソフトウェアであり、プログラム PBは通信処理のソフトゥ エアである。プログラム PA, PBは、いずれも時系列処理を基本とし、予め決められたタ イミングで途中結果を出力するソフトウェアである。プログラム PCは静止画処理のソフ トウエアであり、プログラム PDは算術演算のソフトウェアである。プログラム PCは、 XGA の圧縮画像の伸張を行うソフトウェアである。プログラム PDは、既にプログラマによりソ ースコードレベルで最適化が行われた流体計算用のソフトウェアである。
[0079] 図 23からもわ力るように、本実施例によれば、全てのプログラム PA〜PDについて、 CPU負荷が上記従来手法の場合と比べて低減されることが確認された。又、本実施 例によれば、プログラム PA, PB, PCについては、メモリ使用量が上記従来手法の場 合と比べて低減されることが確認された。更に、本実施例によれば、プログラム PA, P B, PCについては、 CPUの消費電力をピーク時の消費電力より低減できることが確認 された。尚、本実施例によれば、プログラム PCについては、スレッドィ匕の効果は少な いものの、第一段階のステートメント調整による効果が見られた。
[0080] このように、主に時系列処理型のプログラムの完成度にもよる力 本実施例によれ ば、 CPU及びメモリ、即ち、リソースの使用量は、従来手法を用いる場合と比べて 30 %前後低減することが確認できた。又、副次効果として CPUのアイドル状態を生成す ることができるため、 CPUの消費電力を低減する効果もあることが確認された。
産業上の利用可能性
[0081] 本発明は、 CPUやメモリ等のリソースを有する各種電子機器に適用可能であり、特 にリソースが限られた組み込み機器に好適である。
[0082] 以上、本発明を実施例により説明したが、本発明は上記実施例に限定されるもので はなぐ本発明の範囲内で種々の変形及び改良が可能であることは言うまでもない。

Claims

請求の範囲
[1] コンピュータにより、予め決められたタイミングで途中結果を出力すると共に時系列 的に処理されるソフトウェアのコンパイルを行うコンパイル方法であって、
該コンピュータにより、該ソフトウェアのソースコードに含まれる処理シーケンスから 並列性及び条件分岐に関する処理ブロックを抽出する抽出ステップと、
該コンピュータにより、抽出された処理ブロックのリストラクチャリングを行い実行コー ドを自動的に生成する生成ステップとを含むことを特徴とする、コンパイル方法。
[2] 該抽出ステップは、演算及び該コンピュータのメモリ及びレジスタに演算結果の代 入を行う演算代入処理の処理ブロックに対して、ステートメント間の依存方程式に基 づく並べ替えを行い中間言語レベルで整理されたステートメント列を求める第一段階 と、該整理されたステートメント列に対してステートメントのグループの結合及び再定 義を行う第二段階を有することを特徴とする、請求項 1記載のコンパイル方法。
[3] 該生成ステップは、該第二段階でグループィ匕を行ったスケジューラ化処理ブロック 及びスレッドィ匕処理ブロックに制御ステートメントを付カ卩し、スレッドとスケジューラとし て最終的な中間言語を生成する第三段階を有し、
該スケジューラ化処理ブロックは、後続の処理ブロックが条件分岐処理であると処 理ブロックと結合されて再定義されたものであり、
該スレッドィ匕処理ブロックは、呼び出し元の処理ブロックが条件分岐処理であると条 件分岐の従属節が再定義されたものであることを特徴とする、請求項 2記載のコンパ ィル方法。
[4] 該第一段階は、全ての制御ステートメントで区切られた演算代入ステートメントのグ ループに対して行われ、定義及び参照される変数の抽出、各ステートメントの依存関 係を表現した依存グラフの定義、不要なステートメントの削除、及び該依存グラフに 基づくステートメントのソートからなることを特徴とする、請求項 2又は 3記載のコンパィ ル方法。
[5] 該第二段階は、ネスト又は入れ子構造にある最も内側の階層の処理ブロックから順 に該ステートメントのグループの結合及び再定義を行うことを特徴とする、請求項 2〜 4の!、ずれ力 1項記載のコンパイル方法。
[6] 該第二段階は、該第一段階のソートの結果に対して行われ、処理ブロック化を対象 とするプログラムのコードに対して、呼び出し元の処理ブロックが条件分岐処理であ ると条件分岐の従属節をスレッドィヒ処理ブロックとして再定義し、該条件分岐処理で はなぐ且つ、後続の処理ブロックが条件分岐処理に続くものであるとこれらの処理 ブロックを結合してスケジューラ化処理ブロックとして再定義することを特徴とする、請 求項 5記載のコンパイル方法。
[7] 該第三段階は、該第二段階でグループィ匕を行ったスケジューラ化処理ブロック及 びスレッド化処理ブロックに対して行われ、
処理の対象となる処理ブロックがスレッド化処理ブロックの場合はスレッド化処理ブ ロックへステートメントを追加する処理を行 、、
処理対象となる処理ブロックがスケジュール化処理ブロックの場合はスケジューラ化 処理ブロックへステートメントを追加する処理を行うことを特徴とする、請求項 3〜6の V、ずれか 1項記載のコンパイル方法。
[8] 該スケジューラ化処理ブロックはスレッドのコンテキストスィッチ機能を有し、該スレツ ド化処理ブロックはスケジューラの要求時にのみ動作する仕^ aみを有することを特徴 とする、請求項 3記載のコンパイル方法。
[9] 該第三段階は、最外郭ループに囲まれたスケジューラ化処理ブロックについては、 該コンピュータの OSのタイマ機能を用いて周期的にシグナルを送信して自動起動さ せるタイマハンドラの仕組みを組み込むことを特徴とする、請求項 3記載のコンノィル 方法。
[10] 該第三段階は、演算処理が不要な期間において該コンピュータを解放する機構を 有する制御ステートメントを付加することを特徴とする、請求項 3記載のコンノィル方 法。
[11] コンピュータにより、予め決められたタイミングで途中結果を出力すると共に時系列 的に処理されるソフトウェアのコンパイルを行うコンパイラであって、
該コンピュータにより、該ソフトウェアのソースコードを第 1の中間言語に翻訳して記 憶部に保存するフロントエンドと、
該コンピュータにより、該記憶部に保存された該第 1の中間言語に基づ 、て該ソー スコードに含まれる処理シーケンスから並列性及び条件分岐に関する処理ブロックを 抽出し、抽出された処理ブロックのリストラクチャリングを行い第 2の中間言語を生成し て記憶部に保存するミドルパスと、
該コンピュータにより、該記憶部に保存された該第 2の中間言語に基づいて実行コ ードを自動的に生成するバックエンドとを備えたことを特徴とする、コンパイラ。
[12] 該ミドルパスは、演算及び該記憶部に演算結果の代入を行う演算代入処理の処理 ブロックに対して、ステートメント間の依存方程式に基づく並べ替えを行 、該第 1の中 間言語レベルで整理されたステートメント列を求める第一段階と、該整理されたステ 一トメント列に対してステートメントのグループの結合及び再定義を行う第二段階を有 することを特徴とする、請求項 11記載のコンパイラ。
[13] 該ミドルパスは、該第二段階でグループィ匕を行ったスケジューラ化処理ブロック及 びスレッド化処理ブロックに制御ステートメントを付カ卩し、スレッドとスケジューラとして 該第 2の中間言語を生成する第三段階を有し、
該スケジューラ化処理ブロックは、後続の処理ブロックが条件分岐処理であると処 理ブロックと結合されて再定義されたものであり、
該スレッドィ匕処理ブロックは、呼び出し元の処理ブロックが条件分岐処理であると条 件分岐の従属節が再定義されたものであることを特徴とする、請求項 12記載のコン パイラ。
[14] 該第一段階は、全ての制御ステートメントで区切られた演算代入ステートメントのグ ループに対して行われ、定義及び参照される変数の抽出、各ステートメントの依存関 係を表現した依存グラフの定義、不要なステートメントの削除、及び該依存グラフに 基づくステートメントのソートからなることを特徴とする、請求項 12又は 13記載のコン パイラ。
[15] 該第二段階は、ネスト又は入れ子構造にある最も内側の階層の処理ブロック力 順 に該ステートメントのグループの結合及び再定義を行うことを特徴とする、請求項 12 〜 14のいずれ力 1項記載のコンパイラ。
[16] 該第二段階は、該第一段階のソートの結果に対して行われ、処理ブロック化を対象 とするプログラムのコードに対して、呼び出し元の処理ブロックが条件分岐処理であ ると条件分岐の従属節をスレッドィヒ処理ブロックとして再定義し、該条件分岐処理で はなぐ且つ、後続の処理ブロックが条件分岐処理に続くものであるとこれらの処理 ブロックを結合してスケジューラ化処理ブロックとして再定義することを特徴とする、請 求項 15記載のコンパイラ。
[17] 該第三段階は、該第二段階でグループィ匕を行ったスケジューラ化処理ブロック及 びスレッド化処理ブロックに対して行われ、
処理の対象となる処理ブロックがスレッド化処理ブロックの場合はスレッド化処理ブ ロックへステートメントを追加する処理を行 、、
処理対象となる処理ブロックがスケジュール化処理ブロックの場合はスケジューラ化 処理ブロックへステートメントを追加する処理を行うことを特徴とする、請求項 13〜16 の!、ずれ力 1項記載のコンパイラ。
[18] 該スケジューラ化処理ブロックはスレッドのコンテキストスィッチ機能を有し、該スレツ ド化処理ブロックはスケジューラの要求時にのみ動作する仕^ aみを有することを特徴 とする、請求項 13記載のコンパイラ。
[19] 該第三段階は、最外郭ループに囲まれたスケジューラ化処理ブロックについては、 該コンピュータの OSのタイマ機能を用いて周期的にシグナルを送信して自動起動さ せるタイマハンドラの仕組みを組み込むことを特徴とする、請求項 13記載のコンノ ィ
[20] 該第三段階は、演算処理が不要な期間において該コンピュータを解放する機構を 有する制御ステートメントを付加することを特徴とする、請求項 13記載のコンノイラ。
PCT/JP2006/324966 2006-12-14 2006-12-14 コンパイル方法及びコンパイラ WO2008072334A1 (ja)

Priority Applications (6)

Application Number Priority Date Filing Date Title
EP06834720A EP2093667A4 (en) 2006-12-14 2006-12-14 COMPILATION METHOD AND COMPILER
JP2008549167A JPWO2008072334A1 (ja) 2006-12-14 2006-12-14 コンパイル方法及びコンパイラ
KR1020097011902A KR101085330B1 (ko) 2006-12-14 2006-12-14 컴파일 방법 및 컴파일러
PCT/JP2006/324966 WO2008072334A1 (ja) 2006-12-14 2006-12-14 コンパイル方法及びコンパイラ
CNA2006800566376A CN101563673A (zh) 2006-12-14 2006-12-14 编译方法以及编译器
US12/457,441 US20090254892A1 (en) 2006-12-14 2009-06-10 Compiling method and compiler

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/JP2006/324966 WO2008072334A1 (ja) 2006-12-14 2006-12-14 コンパイル方法及びコンパイラ

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US12/457,441 Continuation US20090254892A1 (en) 2006-12-14 2009-06-10 Compiling method and compiler

Publications (1)

Publication Number Publication Date
WO2008072334A1 true WO2008072334A1 (ja) 2008-06-19

Family

ID=39511366

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2006/324966 WO2008072334A1 (ja) 2006-12-14 2006-12-14 コンパイル方法及びコンパイラ

Country Status (6)

Country Link
US (1) US20090254892A1 (ja)
EP (1) EP2093667A4 (ja)
JP (1) JPWO2008072334A1 (ja)
KR (1) KR101085330B1 (ja)
CN (1) CN101563673A (ja)
WO (1) WO2008072334A1 (ja)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10089088B2 (en) 2015-06-16 2018-10-02 Fujitsu Limited Computer that performs compiling, compiler program, and link program
US10540156B2 (en) 2016-06-21 2020-01-21 Denso Corporation Parallelization method, parallelization tool, and in-vehicle device

Families Citing this family (23)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP5209059B2 (ja) * 2008-10-24 2013-06-12 インターナショナル・ビジネス・マシーンズ・コーポレーション ソース・コード処理方法、システム、及びプログラム
US8875111B2 (en) * 2009-04-23 2014-10-28 Microsoft Corporation Intermediate language representation and modification
US8689191B2 (en) * 2010-03-05 2014-04-01 International Business Machines Corporation Correct refactoring of concurrent software
US8863128B2 (en) * 2010-09-30 2014-10-14 Autodesk, Inc System and method for optimizing the evaluation of task dependency graphs
US9430204B2 (en) 2010-11-19 2016-08-30 Microsoft Technology Licensing, Llc Read-only communication operator
US9507568B2 (en) 2010-12-09 2016-11-29 Microsoft Technology Licensing, Llc Nested communication operator
US9395957B2 (en) * 2010-12-22 2016-07-19 Microsoft Technology Licensing, Llc Agile communication operator
US8464232B2 (en) * 2010-12-27 2013-06-11 Aleksandr F. Urakhchin Compiler compiler system with syntax-controlled runtime and binary application programming interfaces
US9239732B2 (en) * 2011-02-16 2016-01-19 Microsoft Technology Licensing Llc Unrolling aggregation operations in asynchronous programming code having multiple levels in hierarchy
CN102193812B (zh) * 2011-06-03 2014-03-26 深圳市茁壮网络股份有限公司 一种代码编译方法、主机及系统
KR101277145B1 (ko) * 2011-12-07 2013-06-20 한국과학기술연구원 공통 표현을 이용한 중간 언어 변환 방법과 그를 위한 시스템 및 컴퓨터로 읽을 수 있는 기록매체
US9286040B2 (en) * 2012-01-18 2016-03-15 Mobilesmith, Inc. Software builder
US9251554B2 (en) 2012-12-26 2016-02-02 Analog Devices, Inc. Block-based signal processing
KR101449657B1 (ko) * 2013-03-05 2014-10-13 한국과학기술연구원 연산자의 값의 범위를 이용한 중간 언어 변환 방법과 그를 위한 시스템 및 컴퓨터로 읽을 수 있는 기록매체
US9298433B2 (en) * 2013-05-02 2016-03-29 Facebook, Inc. Optimizing intermediate representation of script code for fast path execution
JP6287018B2 (ja) * 2013-10-04 2018-03-07 富士通株式会社 可視化方法、表示方法、情報処理装置、可視化プログラム及び表示プログラム
CN103699377B (zh) * 2013-12-04 2017-02-01 国家电网公司 一种对程序代码进行重构操作组合的方法
US8978010B1 (en) * 2013-12-18 2015-03-10 Sap Ag Pruning compilation dependency graphs
US20150193358A1 (en) * 2014-01-06 2015-07-09 Nvidia Corporation Prioritized Memory Reads
CN104391733B (zh) * 2014-12-10 2017-11-24 华中科技大学 一种依据依赖关系动态编译软件包的方法
US9830134B2 (en) * 2015-06-15 2017-11-28 Qualcomm Incorporated Generating object code from intermediate code that includes hierarchical sub-routine information
US10558441B2 (en) * 2018-03-12 2020-02-11 International Business Machines Corporation Compiler for restructuring code using iteration-point algebraic difference analysis
US11416228B2 (en) 2018-09-13 2022-08-16 The University Of Chicago System and method of optimizing instructions for quantum computers

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH06110688A (ja) 1991-06-13 1994-04-22 Internatl Business Mach Corp <Ibm> 複数の順序外れ命令を並行処理するためのコンピュータ・システム
JPH08212070A (ja) 1994-11-14 1996-08-20 Sun Microsyst Inc プロセッサ・アーキテクチャにおける分散制御のための装置および方法
JP2001282549A (ja) * 2000-03-30 2001-10-12 Nec Corp プログラム変換装置及び方法並びに記録媒体
JP2003084989A (ja) 2001-09-12 2003-03-20 Nec Corp プライオリティ動的制御方式、プライオリティ動的制御方法およびプライオリティ動的制御用プログラム

Family Cites Families (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5255385A (en) * 1990-02-26 1993-10-19 Hitachi, Ltd. Method of testing program, and compiler and program testing tool for the method
US5347654A (en) * 1992-02-03 1994-09-13 Thinking Machines Corporation System and method for optimizing and generating computer-based code in a parallel processing environment
JPH0736680A (ja) 1993-07-23 1995-02-07 Omron Corp 並列化プログラム開発支援装置
JP2882475B2 (ja) * 1996-07-12 1999-04-12 日本電気株式会社 スレッド実行方法
JPH10228382A (ja) * 1997-02-14 1998-08-25 Nec Corp コンパイル方式
JPH11259437A (ja) * 1998-03-12 1999-09-24 Hitachi Ltd 不要バリア命令の削減方式
JP2000207223A (ja) * 1999-01-12 2000-07-28 Matsushita Electric Ind Co Ltd 並列処理向けのプログラム処理方法および装置、並びに並列処理向けのプログラム処理を実行するプログラムを記録した記録媒体および並列処理向けの命令列を記録した記録媒体
JP2002007364A (ja) * 2000-06-22 2002-01-11 Fujitsu Ltd 並列計算機システムのジョブスケジューリングを行うスケジューリング装置
JP3664473B2 (ja) * 2000-10-04 2005-06-29 インターナショナル・ビジネス・マシーンズ・コーポレーション プログラムの最適化方法及びこれを用いたコンパイラ
US7089557B2 (en) * 2001-04-10 2006-08-08 Rusty Shawn Lee Data processing system and method for high-efficiency multitasking
JP4783005B2 (ja) * 2004-11-25 2011-09-28 パナソニック株式会社 プログラム変換装置、プログラム変換実行装置およびプログラム変換方法、プログラム変換実行方法。
US8010956B1 (en) * 2005-01-28 2011-08-30 Oracle America, Inc. Control transfer table structuring
US7613595B2 (en) * 2005-03-01 2009-11-03 The Math Works, Inc. Execution and real-time implementation of a temporary overrun scheduler
US7966610B2 (en) * 2005-11-17 2011-06-21 The Mathworks, Inc. Application of optimization techniques to intermediate representations for code generation
JP4923240B2 (ja) * 2006-01-17 2012-04-25 国立大学法人東京工業大学 プログラム処理装置、並列処理プログラム、プログラム処理方法、並列処理コンパイラ、並列処理コンパイラを格納した記録媒体およびマルチプロセッサシステム
US8146066B2 (en) * 2006-06-20 2012-03-27 Google Inc. Systems and methods for caching compute kernels for an application running on a parallel-processing computer system
JP2009048252A (ja) * 2007-08-14 2009-03-05 Oki Electric Ind Co Ltd プログラム変換装置及びコンパイラプログラム

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH06110688A (ja) 1991-06-13 1994-04-22 Internatl Business Mach Corp <Ibm> 複数の順序外れ命令を並行処理するためのコンピュータ・システム
JPH08212070A (ja) 1994-11-14 1996-08-20 Sun Microsyst Inc プロセッサ・アーキテクチャにおける分散制御のための装置および方法
JP2001282549A (ja) * 2000-03-30 2001-10-12 Nec Corp プログラム変換装置及び方法並びに記録媒体
JP2003084989A (ja) 2001-09-12 2003-03-20 Nec Corp プライオリティ動的制御方式、プライオリティ動的制御方法およびプライオリティ動的制御用プログラム

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP2093667A4 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10089088B2 (en) 2015-06-16 2018-10-02 Fujitsu Limited Computer that performs compiling, compiler program, and link program
US10540156B2 (en) 2016-06-21 2020-01-21 Denso Corporation Parallelization method, parallelization tool, and in-vehicle device

Also Published As

Publication number Publication date
CN101563673A (zh) 2009-10-21
EP2093667A4 (en) 2012-03-28
EP2093667A1 (en) 2009-08-26
KR20090089382A (ko) 2009-08-21
KR101085330B1 (ko) 2011-11-23
US20090254892A1 (en) 2009-10-08
JPWO2008072334A1 (ja) 2010-03-25

Similar Documents

Publication Publication Date Title
WO2008072334A1 (ja) コンパイル方法及びコンパイラ
US8893080B2 (en) Parallelization of dataflow actors with local state
US5828886A (en) Compiling apparatus and method for promoting an optimization effect of a program
Raman et al. Parcae: a system for flexible parallel execution
Buck et al. The token flow model
WO2010140883A4 (en) Improvements in embedded system development
US6675380B1 (en) Path speculating instruction scheduler
JP5036523B2 (ja) プログラム並列化装置
Ha et al. Decidable dataflow models for signal processing: Synchronous dataflow and its extensions
Muller et al. Competitive parallelism: Getting your priorities right
Geilen et al. Kahn process networks and a reactive extension
Benkner et al. High-level support for pipeline parallelism on many-core architectures
US20080271041A1 (en) Program processing method and information processing apparatus
Lee et al. Dynamic scheduling of stream programs on embedded multi-core processors
JP2016143378A (ja) 並列化コンパイル方法、並列化コンパイラ、及び、電子装置
JP4946323B2 (ja) 並列化プログラム生成方法、並列化プログラム生成装置、及び並列化プログラム生成プログラム
Ha et al. Decidable signal processing dataflow graphs
Dooley et al. Detecting and using critical paths at runtime in message driven parallel programs
Castrillon et al. Dataflow Models of computation for programming heterogeneous multicores
Dooley Intelligent runtime tuning of parallel applications with control points
Nobre et al. Bounded Stream Scheduling in Polyhedral OpenStream
JP2016143377A (ja) 並列化コンパイル方法、並列化コンパイラ、及び、電子装置
Schuele Efficient parallel execution of streaming applications on multi-core processors
Tendulkar et al. A runtime environment for real-time streaming applications on clustered multi-cores
Schuele A coordination language for programming embedded multi-core systems

Legal Events

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

Ref document number: 200680056637.6

Country of ref document: CN

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

Ref document number: 06834720

Country of ref document: EP

Kind code of ref document: A1

WWE Wipo information: entry into national phase

Ref document number: 2008549167

Country of ref document: JP

WWE Wipo information: entry into national phase

Ref document number: 1020097011902

Country of ref document: KR

WWE Wipo information: entry into national phase

Ref document number: 2006834720

Country of ref document: EP

NENP Non-entry into the national phase

Ref country code: DE