WO2011096016A1 - コンパイラ装置 - Google Patents

コンパイラ装置 Download PDF

Info

Publication number
WO2011096016A1
WO2011096016A1 PCT/JP2010/000710 JP2010000710W WO2011096016A1 WO 2011096016 A1 WO2011096016 A1 WO 2011096016A1 JP 2010000710 W JP2010000710 W JP 2010000710W WO 2011096016 A1 WO2011096016 A1 WO 2011096016A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
node
edge
unit
range
Prior art date
Application number
PCT/JP2010/000710
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 JP2011552581A priority Critical patent/JPWO2011096016A1/ja
Priority to PCT/JP2010/000710 priority patent/WO2011096016A1/ja
Publication of WO2011096016A1 publication Critical patent/WO2011096016A1/ja
Priority to US13/419,657 priority patent/US20120192168A1/en

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/43Checking; Contextual analysis
    • G06F8/433Dependency analysis; Data or control flow analysis

Definitions

  • the present invention relates to the field of compilation, and in particular to operation mapping.
  • Compilation is a technology for converting source code created by humans using a programming language into a form (object code) that can be executed on a computer.
  • Patent Document 1 There is a technique of Patent Document 1 as a technique for achieving the processing efficiency of a computer.
  • the processing of the computer is made more efficient by optimizing the expression of the object code.
  • the operation is uniquely assigned to the instruction with the smallest operation accuracy within the range in which the operation result does not overflow, and the memory utilization efficiency is optimized.
  • the stack machine such as Java (registered trademark)
  • the accuracy of the operation and the stack size the amount of used memory used by the operation are proportional to each other.
  • the stack machine such as Java (registered trademark)
  • Non-Patent Document 1 There is a technique of Non-Patent Document 1 as a technique for achieving the processing efficiency of a computer.
  • the processing of a computer is made more efficient by optimizing the expression of object code.
  • This technology optimizes the execution efficiency of operations by combining certain instruction groups into SIMD instructions with small operation accuracy within the range that allows the accuracy of the operation result when realizing a certain operation group with single instruction multiple data (SIMD) instructions. It is.
  • SIMD instructions with smaller operation precision have more operations that can be operated simultaneously.
  • there is a problem that reducing the number of instructions does not necessarily lead to the improvement of the processing efficiency of the computer.
  • the compiler apparatus of the present invention it is an object to efficiently use hardware resources without losing data accuracy.
  • the compiler apparatus includes: a data flow graph including a set of nodes and edges; an input unit for inputting information indicating a range of possible values of data flowing to each edge; and a type of first node Hardware resources to which the first node can be assigned among a plurality of hardware resources of different types based on information indicating the range of possible values of data flowing to the first edge connected to the first node And a determination unit that determines the
  • FIG. 1 shows an example of the configuration of a compiler system according to an embodiment.
  • FIG. 1 is a view showing a schematic configuration of a compiler apparatus according to an embodiment as functional components.
  • the flowchart which shows operation of the compiler device. 6 is a flowchart showing an operation of a determination unit.
  • the figure which shows the example of a hardware resource Correspondence table of the hardware resource which the 1st storage part memorizes, the kind of operation, and the data range.
  • FIG. 1 is a diagram showing an example of the configuration of a compiler system according to the embodiment.
  • the compiler system includes a compiler device 10, an input device 15, and an output device 17.
  • the compiler 10 compiles a source program and generates and outputs an object code.
  • the input device 15 is a device capable of inputting information, and is, for example, a mouse or a keyboard.
  • the output device 17 is, for example, a monitor.
  • the hardware resource 16 is a device that executes object code that the compiler device 10 compiles and outputs a source program.
  • the compiler device 10, the input device 15, the hardware resource 16, and the output device 17 may be integrated devices, and may not be separate devices.
  • the compiler 10 includes an arithmetic processing unit (CPU 11), a main memory (RAM 12), and a read only memory.
  • the arithmetic processing unit (CPU 11), the main memory (RAM 12), and the read only memory (ROM 13) are connected so as to be able to exchange data with one another via a bus 14.
  • a program for causing the arithmetic processing unit (CPU 11) to function as the compiler device 10 is stored in the ROM 13.
  • the program is loaded on the main memory (RAM 12) and executed by the CPU 11 to realize the compiler device 10 Be done.
  • FIG. 2 shows a schematic configuration of the compiler 10 in functional blocks.
  • the compiler apparatus 10 includes a source program input unit 101, a data dependency analysis unit 102, a data range analysis unit 103, a determination unit 104, and an allocation unit 105.
  • FIG. 3 is a flowchart showing the operation of the compiler 10.
  • the compiler 10 first inputs a source program to the source program input unit 101 (S101).
  • the data dependency analysis unit 102 generates a data flow graph from the source program (S102).
  • a data flow graph is a graph that includes nodes and edges connecting between nodes as elements.
  • the data range analysis unit 103 analyzes and obtains the data range of the data flowing to the edge (S103).
  • the determination unit 104 compares the type of node with the type of process that can be processed by the hardware resource, and can process the range of data that can be taken by the edge connected to that node and the hardware resource.
  • the hardware resource that can be associated (allocated) with the node is determined using the comparison result with the appropriate data range (S104).
  • the allocating unit 105 allocates at least one hardware resource to the node from the hardware resources determined by the determining unit 104 to be able to correspond to the node (S105).
  • each functional block in the most basic embodiment in which each functional component of the compiler 10 is connected in series in the order of FIG. 2 will be described.
  • the embodiment is not limited to this.
  • a configuration in which a plurality of functional blocks operate in cooperation a configuration in which the order of some functional blocks is switched, a configuration in which a certain functional block is divided into a plurality of functional blocks, a configuration combining the above three modes, etc. It can also be done.
  • the functional block can be divided into a plurality of modules and implemented.
  • the source program input unit 101 inputs a source program to the compiler 10.
  • FIG. 5 shows an example of a source program.
  • “# pragma value_bound (a,” [-10, 10] ")" of the source program indicates that the possible data range of a is [-10, 10].
  • “#pragma value_bound (b,” [5, 10] ”)” indicates that the possible data range of b is [5, 10].
  • “#pragma value_bound (c,” [-5, 10] ”)” indicates that the possible data range of c is [-5, 10].
  • the source program is, for example, a programming language such as C language or Java (registered trademark). It may be a programming language unique to the compiler device.
  • the source program may be a data structure in which operations and dependencies are simply arranged as data.
  • the source program does not have to be a text file that can be easily viewed by a person and can be a binary file.
  • the source program does not have to contain all the information in one file, and the information may be divided into a plurality of files.
  • the input method of the source program input unit 101 uses, for example, a method from a file system which is generally widely used. Also, it may be a method of inputting what has already been read into the memory via the network. Further, as other methods, for example, a method of incorporating a source program into the compiler 10, a method of interactively inputting using a GUI (Graphical User Interface), and various sensors outside the apparatus are used. There is a method to make it input interactively.
  • a method from a file system which is generally widely used. Also, it may be a method of inputting what has already been read into the memory via the network. Further, as other methods, for example, a method of incorporating a source program into the compiler 10, a method of interactively inputting using a GUI (Graphical User Interface), and various sensors outside the apparatus are used. There is a method to make it input interactively.
  • GUI Graphic User Interface
  • the data dependency analysis unit 102 analyzes the source program and generates a data flow graph. Generate a graph consisting of a set of nodes (nodes, vertices) and a set of edges (branches, edges) and clarify how nodes are connected by edges. An example of the data flow graph is shown in FIG.
  • the data dependency analysis unit 102 outputs the data range of the edge together with the data flow graph by analyzing the source program.
  • FIG. 7 shows data flow graphs output by the data dependency analysis unit and information including data ranges of edges. Further, FIG. 8 shows information equivalent to FIG. 7 in a table.
  • the data dependency analysis unit 102 analyzes the source program of FIG. 5 and outputs information obtained by combining the data flow graph of FIG. 7 and the data range of the edge.
  • the data flow graph of FIG. 6 includes a plurality of nodes (node “a”, node “b”, node “+”, node “c”, node “-”, node “d”) and a plurality of edges (edge “a” “ ⁇ ” “+”, edge “b” ⁇ “+”, edge “+” ⁇ “-”, edge “c” ⁇ “-”, edge “-” ⁇ “d”).
  • edge “a” ⁇ “+” is described as an edge connecting between the node “a” and the node “+”.
  • the source program indicates that the possible data range of a is [ ⁇ 10, 10]. It also indicates that the possible data range of b is [5, 10]. It also indicates that the possible data range of c is [-5, 10]. Therefore, the data dependency analysis unit 102 determines the data range [ ⁇ 10, 10] of data flowing in the edge “a” ⁇ “+” and the data flowing in the edge “b” ⁇ “+” in combination with the data flow graph. A data range [5, 10] and a data range [-5, 10] of data flowing from edge "c" to "-” are output.
  • [ ⁇ 10, 10] indicates that the range of ⁇ 10 to 10 can be taken. Conversely, it indicates that the value is not out of the range.
  • nodes are calculated as "+” and "-".
  • edge has been described as a dependency between operations.
  • the dataflow graph may hold other information.
  • the portion analyzed by the data dependency analysis unit 102 may not be the entire source program.
  • the data dependence analysis unit 102 may analyze only in the specified function.
  • the portion to be analyzed by the data dependency analysis unit 102 may be automatically selected.
  • the data dependency analysis unit 102 may analyze only the designated code portion.
  • the data range analysis unit 103 analyzes and outputs a range of possible values of data flowing to each edge of the data flow graph generated by the data dependency analysis unit 102.
  • the data range analysis unit 103 may output the range of possible values of data flowing to each edge, using information indicating the range of possible values of data flowing to each edge input by the input unit.
  • the information indicating the range of possible values of data flowing to each edge may be any information as long as it can indicate the range of possible values of data flowing to each edge. For example, It may be a range of values, or a width of bits representing data that can flow to an edge.
  • the data range analysis unit 103 may obtain a data range of data flowing to an edge other than the input edge.
  • FIG. 9 is information obtained by combining the data flow graph and the data range of all the edges, which is output as a result of analysis performed by the data range analysis unit 103.
  • FIG. 10 is a table representing information equivalent to the information of FIG. Comparing FIG. 8 with FIG. 10, the data range analysis unit 103 outputs the data range of edge “+” ⁇ “ ⁇ ” and the data range of edge “ ⁇ ” ⁇ “d” in addition to the information of FIG. I know what to do.
  • the data range of edge “ ⁇ ” ⁇ “d” has already been assigned as [ ⁇ 100, 200].
  • the data range analysis unit 103 obtains the edge “ ⁇ ” ⁇ “d” by analysis, it can be understood that the data range of the edge is [ ⁇ 15, 25].
  • the data range of edge “ ⁇ ” ⁇ “d” has already been given as [ ⁇ 1, 5].
  • the data range analysis unit 103 finds that the data range of the given edge is smaller than the data range of the edge obtained by analysis by obtaining [-15, 20] by analysis. It can be seen that the data range conflicts with the data range obtained by analysis.
  • the data range of the assigned edge is a data range larger than the data range of the edge obtained as a result of analysis, it may be possible to specify whether to update with the data range of the edge obtained as a result of analysis.
  • the data range of the assigned edge When the data range of the assigned edge is assigned a value of a range smaller than the data range of the edge obtained as a result of analysis, for example, the data of the edge obtained as a result of analysis from the data range of the assigned edge It is not necessary to update to the range. Also, the user may be warned that the results are inconsistent. Also, the data range of the assigned edge may be updated to the data range of the edge of the analysis result. The data range of the edge may be prioritized in case the data range of the assigned edge contradicts the determined data range.
  • whether or not the data range of the analysis result can be updated from the data range to which the data range of the edge is allocated may be optionally specified.
  • the data range analysis unit may not perform analysis at all, and updating or contradiction of the data range of the edge. Analysis may be performed in anticipation of discovery.
  • the data range of the edge is analyzed from top to bottom of the data flow graph, but analysis may be performed in any order.
  • the data range of the edges does not have to be all edge-analyzable as shown in FIG. 9, and there may be edges that can not be analyzed or not.
  • a warning may be issued to the compiler apparatus user. Not only may it convey that it can not be analyzed, but it may indicate detailed information that which edge of the data flow graph can not be analyzed for whatever reason.
  • the cause that can not be analyzed may be removed by some input of the data flow graph, or the analysis may be advanced without analysis. In the subsequent processing, how to process an edge that could not be analyzed will be described later.
  • the data range of the edge may not correspond directly to the edge as shown in FIG. 5 as long as it is information that can be the data range of the edge.
  • linking each node's input / output data range is equivalent to linking an edge to an edge data range.
  • one or more edges having a data range of the edge to be an analysis starting point are required.
  • the data specified by the pragma of FIG. 5 is the starting point. That is, in the pragma shown in FIG. 5, the data ranges of node a, node b and node c are designated as [-10, 10], [5, 10] and [-5, 10], respectively.
  • the start point information may be embedded in the source program or may be input separately from the source program.
  • the data range analysis unit 103 may automatically determine the data range of the edge to be the starting point.
  • a method using variable type such as 16 bit integer type or 32 bit integer type
  • a method of including the data range description method in the naming convention of variables direct data range of edge Method that uses description methods that can be described as a method
  • a method that describes and analyzes data range of edge as pragma a method that describes data range of edge on existing description method and processes at preprocessing time
  • binary There is a method of recording edge data range in a file.
  • the data range of the edge is described in another file and inputted, and the data range of the edge is interactively presented to the user through GUI (Graphical User Interface) There is a way to make it specified.
  • GUI Graphic User Interface
  • a method of automatically determining by the data range analysis unit 103 there is a method of deciding from the feature of the hardware resource that all the input units from the memory are 16 bits, and the data range of the edge is limited when a certain operation is performed. There are a method of presuming that it is estimated, and a method of looking at and determining the dependency of a plurality of operations.
  • the determination unit 104 can receive information (a data flow graph and a possible range of data flowing through an edge) input from the data range analysis unit 103, and can associate elements (nodes or edges) of the data flow graph from the information Hardware resources.
  • the determination unit 104 includes a first storage unit 104A as shown in FIG. As shown in FIG. 12, the first storage unit 104A stores hardware resources for executing the object code generated by the compiler 10, types of operations of the hardware resources, and data ranges in which the operations can be performed.
  • FIG. 11 shows an example of a hardware resource group that causes an object code generated by the compiler 10 to be executed.
  • the determination unit 104 matches the data type of the operation of the node of the data flow graph, and the data range of the edge input to the node and the data range of the edge output from the node
  • a hardware resource that can process a data range that includes all is determined as a hardware resource that can be associated with a node.
  • the determination unit 104 determines that all hardware resources that can be associated with each element of the data flow graph can be associated. Therefore, it is not necessary to assign one hardware resource to each element of the data flow graph.
  • Whether or not to determine the correspondence depends on the nature of the hardware resource and the requirement of the compiler 10. For example, if the computing unit is heterogeneous and the data path is homogeneous, it may be possible to perform only the determination of the computing unit without performing the data path determination.
  • the determination of whether elements of the data flow graph can be mapped to hardware resources is determined by whether the hardware resources can correctly execute the elements of each data flow graph. In order to be able to execute the elements of each data flow graph correctly, for example, it is a condition that the target operation can be realized and the operation is performed without losing the accuracy of the data. What can achieve the target operation is that, for example, when the node is “+” (an operator that performs addition), hardware resources need to be allocated to an arithmetic unit including an adder.
  • the data range in which the calculation of the hardware resource can be calculated the data range of the edge data input to the node, and the edge data output from the node Range All data ranges need to be included.
  • the condition for the adder corresponding to the operation node “+” in FIG. 9 not to lose the accuracy of the data is the data range of edge “a” ⁇ “+” input to the operation node “+” [-10 , 10] and edge “b” ⁇ “+” data range [5, 10] can be input, and an edge “+” ⁇ “—
  • the adder needs to be able to output the data range [-5, 20] of ".
  • an arithmetic unit capable of calculating without losing the accuracy of data is, for example, an arithmetic unit having higher accuracy (number of bits higher than 32 bits) if it is necessary for the node to perform addition at 32 bits. It is good.
  • losing the accuracy of the data does not mean that the result is not mathematically correct, but it may be within the required accuracy. For example, even if 0.005 / 100 is 0, if the property is that it should be correct to the third decimal place, the result is that the calculation can be performed with the correct precision.
  • the hardware resource group of FIG. 11 includes operation unit groups A to D in which adders and subtractors are integrated. Also, in this hardware resource group, four computing unit groups and a Load / Store computing unit are interconnected. It is assumed that the data path from the Load / Store computing unit and the data path between the computing units are connected to both of the computing units in the computing unit group.
  • the arithmetic unit group A is a hardware resource A1 whose type of operation is “+” (addition) and the processable data range is [ ⁇ 105, 105], and the type of operation is “ ⁇ ” (subtraction) And a hardware resource A2 which has a processable data range of [ ⁇ 105, 105].
  • the arithmetic unit group B is a hardware resource B1 whose type of operation is "+” (addition) and the processable data range is [-100, 100], and the type of operation is "-" (subtraction) And a hardware resource B2 having a processable data range of [-1, 2].
  • the arithmetic unit group C is a hardware resource C1 whose type of operation is “+” (addition) and the processable data range is [ ⁇ 1, 2], and the type of operation is “ ⁇ ” (subtraction) And a hardware resource C2 having a processable data range of [-1, 2].
  • the arithmetic unit group D is a hardware resource D1 whose type of operation is "+" (addition) and the processable data range is [-1, 2], and the type of operation is "-" (subtraction) And a hardware resource D2 having a data range of [-100, 100] which can be processed.
  • the Load / Store computing unit is a hardware resource E.
  • the data range of the hardware resource E is [-128, 127].
  • each data path can pass data of any size. That is, in the present embodiment, it is not necessary to select a data path from the data range of data flowing to each edge. If there is a limitation on the data size that can be passed through the data path, the determination unit 104 may be provided with a function of determining a data path through which the data size of the data range can be passed from the data range of the edge.
  • an arithmetic unit group expresses a set of arithmetic units capable of transferring data in a short time.
  • the computing unit group does not have to have a special mechanism as a hardware resource. For example, it is assumed that data paths between hardware resources can transfer data in one clock in the operation unit group. On the other hand, it is assumed that the data path between the arithmetic unit groups involves, for example, 5 clocks for data transfer.
  • each computing unit can execute an operation in one clock. It is assumed that the Load / Store computing unit can transfer data to another hardware resource in 10 clocks by combining the memory access time and the data transfer time.
  • FIG. 12 shows an example of a method of determining to which hardware resource in the hardware resource group of FIG. 11 each element of the data flow graph of FIG. 11 can be associated.
  • FIG. 12 shows an example of a method of determining to which hardware resource in the hardware resource group of FIG. 11 each element of the data flow graph of FIG. 11 can be associated.
  • it since it is assumed that any data can be passed through each data path, it is not necessary to determine whether the data path of the edge of the data flow graph can be associated or not.
  • the determination is made based on whether two conditions of realization of the target calculation of each node and calculation without losing data accuracy are satisfied.
  • the accuracy of the data is determined based on whether the processable data range of the hardware resource includes the data range of the edge inputted to the node and the edge outputted. For example, the determination is made in the steps as shown in FIG. That is, each hardware is selected by selecting a node to be determined (S1401) and then comparing the information of FIG. 10 input from the data range analysis unit 103 with the information of FIG. 12 stored by the first storage unit 104A.
  • the wear resource determines whether the target computation of the node can be realized (S1402), and then it is determined whether the hardware resource can perform computation without losing the accuracy of data (S1403).
  • the operation nodes a, b, c, d of the memory access in FIG. 9 can realize the operation by the hardware resource E which is a Load / Store operation unit. Also, the data range of the edge output from the nodes a, b, c and the data range of the edge input to the node d are included in the read / write data range [-128, 127 of the Load / Store operator, respectively. . Therefore, it is determined that the nodes a, b, c, d can be associated with the Load / Store computing unit.
  • the node “+” in FIG. 9 is an operator that performs addition. Therefore, it is determined from the table of FIG. 12 that the operation can be realized by the hardware resources A1, B1, C1, and D1. Also, the edges input to the node “+” are “a” ⁇ "+” (data range is [-10, 10]) and “b” ⁇ "+” (data range is [5, 10]) . The edge output from the node “+” is “ ⁇ ” ⁇ “d” (data range is [ ⁇ 5, 20]). Therefore, the hardware resource needs to be an operator capable of processing the data range [-10, 20]. Therefore, it can be determined from Table 12 that the hardware resources A1 and B1 can be associated with each other.
  • FIG. 13 shows information including the nodes that are determined and output by the determination unit 104 and the hardware resources that can be associated with each of the nodes.
  • the types of nodes are not limited to variable nodes and addition.
  • node types include a combination of addition and multiplication, FFT (Fast Fourier Transform), H.264 decoding, and other low-level operations to high-level operations.
  • the data flow graph may include low level operations and high level operations in one data flow graph.
  • the type of node may be not only arithmetic operation, but also logical operation, memory operation, conditional branch, complex operation, stack operation, data transfer, function call, function return, and the like.
  • Hardware resources are not limited to adders.
  • the hardware resources are, for example, a multiplier, an arithmetic unit that adds a plurality of data by SIMD (Single Instruction Multiple Data), each adder in an arithmetic unit that adds a plurality of data by SIMD, an ALU (Arithmetic)
  • a logic unit capable of multiple types of operations and capable of selecting operations, an operation unit such as an ALU array in which a plurality of ALUs are coupled, a specific operation such as FFT (Fast Fourier Transform)
  • There are a computing unit that performs a computing unit that performs H.264 decoding, a multi-core in which a plurality of processor cores are coupled, and a multiprocessor in which a plurality of processors are coupled.
  • the hardware resources may be low level computing units or high level computing units.
  • the hardware resources may be a mix of hardware resources from low level computing units to high level computing units. Further, not only the computing units but also data paths connecting
  • Hardware resources may be viewed hierarchically from the compiler device. For example, information that a low level computing element is included in the high level computing element may be held and used for determination. For example, when the arithmetic unit to be added and then subtracted is regarded as one arithmetic unit, the fact that there is an adder and a subtractor in the arithmetic unit may be used, and 10 should be added when 10 is desired to be added. Since the same thing can be realized by performing zero subtraction, it may be determined that the correspondence is possible. By doing this, the number of computing units determined to be mappable increases.
  • the determination of the correspondence possibility is performed on one or more hardware resources. If the determination of the correspondence possibility of the hardware resource is performed for one hardware resource, the result of the determination indicates whether the correspondence is possible.
  • various methods can be considered for selecting one hardware resource to make the determination. For example, a method of randomly selecting one place, a method of preferentially selecting hardware resources close to memory, a method of selecting according to an algorithm, a method of selecting hardware resources close to existing hardware resources if there is already allocated, strong To select hardware resources that can perform various operations, select hardware resources close to thick data paths, and select hardware resources close to logical centers so that paths to each hardware resource can be minimized. A method, a method combining them, etc. can be considered. If the determination is performed on one or more hardware resources, the determination result may be a set of hardware resources that can be mapped, a subset of hardware resources that can be mapped, or the like.
  • the determination unit 104 may receive, from the outside, information indicating that a node of a data flow graph can be associated with a specific hardware resource. For example, when information from the outside that wants to use a certain hardware resource for processing different from the operation of a node of the data flow graph is received, the determination unit 104 determines the hardware of all the nodes of the data flow graph. It is not determined that the wear resource can be associated.
  • the determination unit may receive information from the outside, for example, a method input from an external file, a method interactively specified as a property of a node from a graphical user interface (GUI), or the like.
  • the information from the outside may specify the relationship between all nodes in the data flow graph and hardware resources, or may specify the relationship between some nodes and hardware resources.
  • the determining unit 104 may warn the user of the compiler apparatus 10 or another apparatus when there is no hardware resource that can be determined that the association is possible. For example, information on nodes and edges to which hardware resources can not be allocated may be displayed on the console or notified using inter-process communication. You may optionally specify whether to issue an alert, or specify the level of information detail of the alert.
  • the determination unit 104 can not proceed with the process as an error, a method of determining that the hardware resource having the largest processable data range among the hardware resources capable of realizing the operation can be associated with the node, the node And a method of determining that it is possible to correspond at random among the hardware resources that can realize the computation of the above, and among the hardware resources that can realize the computation of the node, the hardware resources having a certain data range or more can be associated There is a method of judging.
  • the assignment unit 105 assigns at least one hardware resource among the hardware resources determined by the determination unit 104 to be able to be associated with each element of the data flow graph.
  • the allocation unit 105 includes a second storage unit 105A that stores hardware resource management information.
  • One example of the hardware resource management information stored in the second storage unit 105A is shown in FIG. As shown in FIG. 14, the second storage unit 105A stores, as hardware resource management information, to which computing unit group the hardware resource belongs.
  • the allocation unit 105 performs hardware resource allocation to each element of the data flow graph based on the data flow graph dependency and hardware resource management information.
  • the dependency of the data flow graph is, for example, a dependency between each node.
  • node "+” has a dependency that performs processing before node "-”.
  • the dependency may include a dependency on hardware resources that can be mapped to each node.
  • FIG. 15 is a table showing hardware resources allocated by the allocating unit 105 to each node.
  • the nodes a, b, c, and d are determined by the determination unit 104 to be able to correspond to one Load / Store computing unit (hardware resource E). Therefore, the assignment unit 105 assigns the Load / Store computing unit (hardware resource E) to the nodes a, b, c, and d.
  • the determination unit 104 determines that the node “+” can be associated with the hardware resource A1 and the hardware resource B1. As shown in FIG. 13, the node “-” is determined by the determination unit 104 to be able to correspond to the hardware resources A2 and D2.
  • the hardware resource management information in FIG. 14 shows that the hardware resources A1 and A2 belong to the same computing unit group. Also, as can be seen from the data flow graph, there is a dependency that the processing of the node "+" is performed before the processing of the node "-".
  • the allocating unit 105 when allocating hardware resources to a node, allocates hardware resources based on the fact that processing execution time can be quick.
  • the assignment unit 105 assigns hardware resources to a node based on information of the computing unit group to which the hardware resource belongs and the dependency of the node.
  • the data path between the hardware resources can be moved in one clock.
  • the data path between hardware resources is moved in 5 clocks.
  • the number of clocks necessary for the operation is 10 clocks for reading the memory into the adder, 1 clock for addition, 1 clock for subtraction, and 10 clocks for writing the memory from the subtractor.
  • the assignment unit 105 assigns the hardware resource A1 to the node “+”, and assigns the hardware resource A2 to the node “ ⁇ ”.
  • the allocation unit 105 allocates the hardware resource with the earliest execution time, using the information of the computing unit group to which the hardware resource belongs as the hardware resource management information.
  • hardware resource management information is not limited to computing units.
  • the allocation of hardware resources to nodes is not limited to the case of allocating hardware resources, which is the fastest.
  • Hardware resource management information includes various types of information. For example, connection status of hardware resources, information on nodes and hardware resources already allocated by algorithm, information on hardware resources that can be mapped to nodes and nodes to be allocated by algorithm from now on, data path between hardware resources Information on allocation algorithm such as allocation status in addition to information on hardware resource itself such as information on delay of hardware resource, information on execution time of hardware resource, information on power consumption of hardware resource, information on heat distribution of hardware resource And so on.
  • the assignment unit 105 may externally receive designation of assignment of hardware resources and assign the hardware resources to the nodes. For example, when it is desired to assign a certain node "+" to a specific adder, the information may be input from the outside.
  • the input method may be, for example, a method of inputting from an external file, or a method of interactively specifying as a property of a node from a graphical user interface (GUI).
  • GUI graphical user interface
  • the specification from outside of hardware resource allocation does not have to be the specification of allocation to one hardware resource to a node, and that one of a plurality of candidate hardware resources is allocated to a node It may be specified. Also, it may be designated as any of the computing units in the lower hierarchy of a certain computing unit.
  • external hardware resource allocation can be specified forcibly, or can be specified as desired.
  • the allocation unit 105 tries to allocate to the hardware resources as much as possible, but may allocate to other hardware resources when it is not allocated or when it can not satisfy the required effect.
  • the allocating unit 105 may warn when there is no hardware resource to be allocated. For example, the information indicates that the node “+” performing addition between data widths [200, 300] can not be allocated to the hardware resource of FIG. At this time, the allocating unit 105 may execute processing as an error, may allocate to a hardware resource having a large processable data width, or may randomly select and allocate a hardware resource.
  • the allocating unit 105 may create hardware resources that can be allocated on the programmable device. For example, when a dedicated hardware resource such as an adder and a programmable device such as an FPGA are combined, the FPGA can be operated when the operational range of the adder existing as the dedicated hardware resource is insufficient. An adder satisfying the above-described operable range may be created. The allocating unit 105 may create new hardware resources even when there are hardware resources to be allocated. In the above-mentioned hardware resource example, the adder of the dedicated hardware resource prepared is sufficient, but when the adder of the dedicated hardware resource is desired to be used for other additions, or with another operation There are various possible reasons, such as when assigning to an FPGA close to the previous operation from dependency relationships and hardware resource management information.
  • the determination unit 104 may always transmit to the allocation unit 105 that it can be mapped to the programmable device, or since it can freely create an arithmetic unit, it does not explicitly transmit it to the allocation unit 105. Good.
  • the compiler 10 of the present embodiment when there are a plurality of hardware resources for executing object code, it is possible to efficiently use the hardware resources without losing the accuracy of data.
  • the hardware resource group executing the object code output by the compiler 10 includes hardware resources having a single instruction multiple data (SIMD) computing unit.
  • SIMD single instruction multiple data
  • the assignment unit 105 collectively assigns the plurality of nodes to the SIMD computing unit.
  • the allocation unit 105 may perform hardware resource allocation for the purpose of reducing the object size, for example.
  • the hardware resources A1 and A2 require 32 bits to specify an operation in order to support various operations. It is assumed that other hardware resources require 1 bit to specify an operation in order to support only addition and subtraction.
  • the hardware resource A1 is assigned to the node "+” and the computing unit A2 is assigned to the node "-"
  • a total of 64 bits are used to designate the computation.
  • the hardware resource B1 is allocated to the node "+” and the hardware resource D2 is allocated to the node "-”
  • a total of 2 bits is sufficient. In this case, a reduction in object size can be achieved.
  • the allocation unit 105 may perform hardware resource allocation, for example, for the purpose of reducing the amount of used memory.
  • hardware resources A1 and A2 are stack machines, and it is assumed that data necessary for operation needs to be stored in a memory.
  • Other hardware resources have registers, and it is assumed that data necessary for operations can be taken from the registers.
  • the hardware resource B1 is allocated to the node "+” and the hardware resource D2 is allocated to the node "-"
  • the amount of used memory can be reduced compared to the case where the hardware resources A1 and A2 are allocated.
  • the allocation unit 105 may perform hardware resource allocation, for example, for the purpose of reducing current consumption.
  • hardware resources A1 and A2 are powerful computing units and power consumption is large.
  • other hardware resources consume less power than hardware resources A1 and A2.
  • power consumption can be reduced by using a technology such as clock gating for hardware resources A1 and A2.
  • the allocation unit 105 may perform hardware resource allocation, for example, for the purpose of reducing heat generation. For example, heat may be concentrated by using various hardware resources, while heat may be concentrated if only specific hardware resources are used. Therefore, the allocation unit 105 can achieve the reduction of heat, for example, by allocating various hardware resources.
  • the allocation unit 105 may perform allocation, for example, for the purpose of reducing the amount of hardware resources used. For example, when there are a plurality of processes, it is assumed that the processes should be performed simultaneously. If these processes are time-divided, the time constraints required for the process can not be met. In this case, the allocation unit 105 differs by allocating the processing of the node + and the node ⁇ of the data flow graph to only the hardware resources A1 and A2 and leaving other hardware resources for other processing. It is possible that processing can be performed simultaneously.
  • the determination unit 104 may determine that each element of the data flow graph can be allocated to a plurality of hardware resources.
  • the determination unit 104 determines that allocation is possible to two 32-bit data paths. good.
  • the determination unit 104 can determine that each element of the data flow graph can be allocated to a plurality of hardware resources. This is applicable not only to the data path but also to the computing unit. For example, when calculating the logical sum of the bit units of two 64-bit data, it may be determined that the upper 32 bits and the lower 32 bits can be assigned to two different 32-bit computing elements.
  • the assigning unit 105 assigns the assignment method as a candidate.
  • Information indicating the possible range of data flowing to the edge is not limited to information indicating one data range.
  • the information indicating the possible range of data flowing to the edge may be represented by a set of values that can flow to the edge.
  • values that can flow to edges may be expressed as (1, 2, 5, 8).
  • the edge represents that it can take one, two, five or eight values.
  • Information indicating a possible range of data flowing to an edge may be represented by a set of multiple data ranges. For example, it is represented as [12, 20] [50, 75]. In this case, the values flowing to the edge are in the range of 12 to 20 or in the range of 50 to 75.
  • values flowing to the edges are all shown as integers in FIG. 7, they may be other than integers. For example, they may be represented by decimals, matrices, complex numbers, etc.
  • the value flowing to the edge may be expressed using a bit width. Below, the case where the value which flows into an edge is represented by bit width is demonstrated.
  • the variables a, b, c, d in the source code of FIG. 5 are not data ranges, but are represented by bit widths. Also, as the values flowing to the edges in FIGS. 7, 8, 9 and 10, bit widths are used instead of data ranges. In addition, the amount of processing of hardware resources is not represented by a data range, but is represented by a bit width.
  • the first storage unit 104A of the determination unit 104 stores, for each hardware resource, a correspondence table with bit widths as shown in FIG. Further, FIG. 16 shows a correspondence table between elements of the data flow graph and bit widths of edges in the case where values flowing to each edge are represented by bit widths in the data flow graph of FIG.
  • the judging unit 104 compares the bit width of the input, the bit width of the output, and the processable bit width of each hardware resource for each node, and when the processable bit width of the hardware resource is large, the hardware It is determined that hardware resources can be associated with hardware resources. For example, in FIG. 16, “a” ⁇ “+” which is the edge of the output of node a, “b” ⁇ “+” which is the edge of the output of node b, “c” which is the edge of the output of node c The bit width of the edge “ ⁇ ” ⁇ “d” which is the edge of the input of the node “d” is 16, 16, 16 and 18, respectively.
  • the hardware resource E is 64 bits wide.
  • the determination unit 104 determines that the nodes a, b, c, and d can be associated with each other by the hardware resource E. Further, the bit width of each of “a” ⁇ “+” and “b” ⁇ “+”, which are the edges of the input of the node “+”, is 16. Further, the bit width of “+” ⁇ “ ⁇ ” which is an edge of the output of the node “+” is 17. Therefore, the determination unit 104 determines from FIG. 17 that the node “+” can be associated with the hardware resource A1 and the hardware resource B1. In addition, the bit width of “c” ⁇ “ ⁇ ” which is the edge of the input of the node “ ⁇ ” is 16 bits.
  • the determination unit 104 determines that the node "-" can be associated with the hardware resources A2 and D2 from FIG.
  • the present embodiment may be configured as the determination device 20 that does not include the source program input unit 101, the data dependency analysis unit 102, the data range analysis unit 103, and the allocation unit 105 in the compiler 10.
  • the determination device 20 is configured to include an input unit 201 and a determination unit 104.
  • the input unit 201 inputs a data flow graph (nodes and edges) and a data range flowing to an edge.
  • the determination unit 104 is the same as the operation of the determination unit 104 of the compiler device 10.
  • the determination apparatus 20 may be configured to include each of the source program input unit 101, the data dependency analysis unit 102, the data range analysis unit 103, and the determination unit 104.
  • the allocation apparatus 30 may be configured not to include the source program input unit 101, the data dependency analysis unit 102, and the data range analysis unit 103 in the compiler 10.
  • the allocation device 30 is configured to include an input unit 201, a determination unit 104, and an allocation unit 105.
  • the input unit 201 is the same as the operation of the determination apparatus 20.
  • the determination unit 104 and the assignment unit 105 are the same as the operations of the determination unit 104 and the assignment unit 105 of the compiler 10.
  • the compiler device 10 can also be realized, for example, by using a general-purpose computer device as a basic hardware resource. That is, the source program input unit 101, the data dependency analysis unit 102, the data range analysis unit 103, the determination unit 104, and the assignment unit 105 can be realized by causing a processor incorporated in the above computer device to execute a program. .
  • the compiler device 10 may be realized by installing the above program into a computer device in advance, or may be stored in a storage medium such as a CD-ROM, or distributed through a network. The program may be implemented by installing this program on a computer device as appropriate.
  • the first storage unit 104A and the second storage unit 105A may be a memory built in or externally attached to the above-mentioned computer apparatus, a hard disk, or a storage medium such as a CD-R, a CD-RW, a DVD-RAM, a DVD-R, etc. It can be realized by utilizing appropriately.
  • the present invention is not limited to the above embodiment as it is, and at the implementation stage, the constituent elements can be modified and embodied without departing from the scope of the invention.
  • various inventions can be formed by appropriate combinations of a plurality of constituent elements disclosed in the above embodiment. For example, some components may be deleted from all the components shown in the embodiment. Furthermore, components in different embodiments may be combined as appropriate.
  • DESCRIPTION OF SYMBOLS 10 ... Compiler apparatus, 11 ... CPU, 12 ... RAM, 13 ... ROM, 14 ... Bus, 15 ... Input device, 16 ... Hardware resource, 17 ...
  • Output device 101 source program input unit 102: data dependency analysis unit 103: data range analysis unit 104: determination unit 104A: first storage unit 105: Allocation unit, 105A: second storage unit, 20: determination device, 30: allocation device, 201: input unit

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

 コンパイラ装置10は、ノードとエッジの集合を含むデータフローグラフと、各エッジに流れるデータが取り得る値の範囲を示す情報とを入力する入力部と、第1ノードの種類と、前記第1ノードと接続する第1エッジに流れるデータが取り得る値の範囲を示す情報とに基づいて、種類の異なる複数のハードウェア資源のうち、前記第1ノードを割り当て可能なハードウェア資源を判定する判定部とを備える。コンパイラ装置10によれば、データの精度を失うことなしに、ハードウェア資源の効率的な利用ができる。

Description

コンパイラ装置
 本発明は、コンパイルの分野に関し、特に演算マッピングに関する。
 コンパイルは、人間がプログラミング言語を用いて作成したソースコードを計算機上で実行可能な形式(オブジェクトコード)に変換する技術である。
 計算機の処理の効率化を達成する技術として特許文献1の技術がある。特許文献1の技術では、オブジェクトコードの表現を最適化することにより計算機の処理の効率化を図っている。この技術は、演算を演算結果が桁あふれしない範囲で演算精度の最も小さな命令に一意に割り当てを行い、メモリ利用効率を最適化するものである。この技術の背景には、Java(登録商標)のようなスタックマシンを利用したとき、演算の精度と演算の利用するスタックサイズ(利用メモリ量)が比例関係にあるという事実が存在する。しかしながら、異なる特徴を持つハードウェア資源が複数存在していると、演算精度の小さなハードウェア資源に割り当てることが計算機の処理の効率化に結び付くとは限らない等の問題があった。
 計算機の処理の効率化を達成する技術として非特許文献1の技術がある。非特許文献1の技術では、オブジェクトコードの表現を最適化することにより計算機の処理の効率化を図っている。この技術は、ある演算群をSIMD(Single Instruction Multiple Data)命令で実現する時、演算結果の精度を許容できる範囲で演算精度の小さなSIMD命令にまとめることにより、演算の実行効率を最適化するものである。この技術の背景には、演算精度の小さなSIMD命令の方が同時に演算可能な演算数が多いという事実が存在する。しかしながら、異なる特徴を持つハードウェア資源が複数存在していると、命令数を削減することが計算機の処理の効率化に結び付くとは限らない等の問題があった。
国際公開 WO01/035201号公報
Aart J.C. Bik. The Software Vectorization Handbook, Chapter 5, Intel Press, 2004.
 本発明のコンパイラ装置によれば、データの精度を失うことなしに、ハードウェア資源の効率的な利用をすることを目的とする。
 本発明の一観点のコンパイラ装置は、ノードとエッジの集合を含むデータフローグラフと、各エッジに流れるデータが取り得る値の範囲を示す情報とを入力する入力部と、第1ノードの種類と、前記第1ノードと接続する第1エッジに流れるデータが取り得る値の範囲を示す情報とに基づいて、種類の異なる複数のハードウェア資源のうち、前記第1ノードを割り当て可能なハードウェア資源を判定する判定部とを備える。
 本発明によれば、データの精度を失うことなしに、ハードウェア資源の効率的な利用ができる。
実施形態に係るコンパイラシステムの構成例を示す図。 実施形態に係るコンパイラ装置の概略構成を機能部品で示した図。 コンパイラ装置の動作を示すフローチャート。 判定部の動作を示すフローチャート。 ソースプログラムの一例を示す図。 データフローグラフの一例を示す図。 データフローグラフとデータフローグラフの一部のエッジのデータ範囲を示す図。 データ依存解析部が出力する情報の例を示す図。 データフローグラフとデータフローグラフの全てのエッジのデータ範囲を示す図。 データ範囲解析部が出力する情報の例を示す図。 ハードウェア資源の例を示す図。 第1記憶部が記憶するハードウェア資源と演算の種類とデータ範囲の対応表。 判定部が出力する情報を示す図。 第2記憶部が記憶するハードウェア資源管理情報の例を示す図。 割当部が出力する情報を示す図。 判定部に入力される情報の一例を示す図。 第1記憶部が記憶するハードウェア資源と演算の種類とビット幅の対応表。 実施形態に係る判定装置を示す図。 実施形態に係る割当装置を示す図。
 以下、本発明の実施形態について、図面を参照して説明する。
 図1は、実施形態に係るコンパイラシステムの構成例を示す図である。コンパイラシステムは、コンパイラ装置10と入力装置15と出力装置17とを備える。コンパイラ装置10は、ソースプログラムのコンパイルを行い、オブジェクトコードを生成、出力する。入力装置15は、情報を入力できる装置であって、例えば、マウスやキーボードである。出力装置17は、例えばモニタである。ハードウェア資源16は、コンパイラ装置10がソースプログラムをコンパイルして出力するオブジェクトコードを実行する装置である。コンパイラ装置10と入力装置15とハードウェア資源16と出力装置17とは、一体の装置であってもよく、それぞれ別個の装置でなくともよい。
 コンパイラ装置10は、演算処理装置(CPU11)と、主メモリ(RAM12)と、読み出し専用メモリとを具備している。演算処理装置(CPU11)、主メモリ(RAM12)、及び読み出し専用メモリ(ROM13)はバス14を介して互いにデータの受け渡しが可能に接続されている。ROM13に、演算処理装置(CPU11)をコンパイラ装置10として機能させるためのプログラムが記憶されており、このプログラムを主メモリ(RAM12)上に載せ、CPU11がこれを実行することによりコンパイラ装置10が実現される。
 次に、以上のように構成されたコンパイラ装置10の機能構成を説明する。図2は、コンパイラ装置10の概略構成を機能ブロックで示したものである。コンパイラ装置10は、ソースプログラム入力部101、データ依存解析部102、データ範囲解析部103、判定部104、割当部105を備える。
 コンパイラ装置10の動作の概略を説明する。図3は、コンパイラ装置10の動作を示すフローチャートである。
 コンパイラ装置10は、まず、ソースプログラム入力部101にソースプログラムを入力する(S101)。次に、データ依存解析部102が、ソースプログラムからデータフローグラフを生成する(S102)。データフローグラフは、ノードとノード間を接続するエッジを要素として含むグラフである。次に、データ範囲解析部103が、エッジに流れるデータのデータ範囲を解析して求める(S103)。次に、判定部104が、ノードの種類とハードウェア資源が処理可能なプロセスの種類との比較結果、および、そのノードに接続されたエッジに流れるデータが取り得る範囲とハードウェア資源の処理可能なデータ範囲との比較結果とを用いて、ノードに対応付け(割り当て)可能なハードウェア資源を判定する(S104)。各ノードに対応付け可能なハードウェア資源は複数あっても良い。次に、割当部105が、判定部104がノードに対応付け可能と判定したハードウェア資源から少なくとも1つのハードウェア資源をノードに対して割り当てる(S105)。
 以下の説明では、コンパイラ装置10の各機能部品を図2の順番で直列に接続した最も基本的な実施の形態での各機能ブロックの説明を行っていく。しかしながら、実施の形態はこれに限られない。例えば、複数の機能ブロックが協調しながら動作を行う構成、一部の機能ブロックの順番を入れ替える構成、ある機能ブロックを複数の機能ブロックに分割する構成、前記3つの形態を組み合わせる構成等で実施することもできる。また、機能ブロックを複数のモジュールに分割して実施することもできる。
 ソースプログラム入力部101は、ソースプログラムをコンパイラ装置10に入力する。図5にソースプログラムの例を示す。図5のソースプログラムはvalue “a”、“b”、“c”、“d”が“d=a+b-c”の関係にあることを示す。また、ソースプログラムの「#pragma value_bound(a,“[-10、10]”)」は、aの取り得るデータ範囲が[-10、10]であることを示す。また、「#pragma value_bound(b,“[5、10]”)」は、bの取り得るデータ範囲が[5、10]であることを示す。また、また、「#pragma value_bound(c,“[-5、10]”)」は、cの取り得るデータ範囲が[-5、10]であることを示す。
 ソースプログラムは、例えば、C言語やJava(登録商標)のようなプログラミング言語である。コンパイラ装置独自のプログラミング言語であってもよい。ソースプログラムは、単に演算や依存関係をデータとして並べたデータ構造であってもよい。また、ソースプログラムは、人が見て構造を容易に理解できるテキストファイルである必要はなく、バイナリファイルであってもよい。また、ソースプログラムは、1つのファイルに全ての情報が入っている必要はなく、情報が分割されて複数のファイルになっているものであっても良い。
 ソースプログラム入力部101の入力の方法は、例えば、一般に広く行われているファイルシステムからの方法を用いる。また、ネットワークを介して既にメモリに読み込んだものを入力する方法であってもよい。また、そのほかの方法としては、例えば、コンパイラ装置10にソースプログラムを組み込んでおく方法、GUI(Graphical User Interface)を利用してインタラクティブに入力させる方法、装置の外部にある様々なセンサを利用してインタラクティブに入力させる方法などがある。
 データ依存解析部102は、ソースプログラムを解析してデータフローグラフを生成する。ノード(節点、頂点)の集合とエッジ(枝、辺)の集合で構成されるグラフを生成し、ノードがどのようにエッジで結ばれているかを明らかにする。データフローグラフの一例を図6に示す。
 データ依存解析部102は、ソースプログラムを解析することにより、データフローグラフと合わせてエッジのデータ範囲を出力する。図7に、データ依存解析部が出力するデータフローグラフとエッジのデータ範囲を含む情報を示す。また、図8に、図7と等価の情報を表にして示す。
 以下では、データ依存解析部102が、図5のソースプログラムを解析して図7のデータフローグラフとエッジのデータ範囲を合わせた情報を出力する方法を説明する。
 データ依存解析部102が、図5のソースプログラムから図6のデータフローグラフを生成する例を説明する。ここで、図5のソースプログラムの演算“+”と演算”-”の優先順位が等しく左結合であり、かつ演算“=”の優先順位は他の演算子(演算“+”と演算”-”)よりも低いとする。この場合、図5のソースプログラムから図6のデータフローグラフを生成することができる。図6のデータフローグラフは、まず、ノード“a”の値とノード“b”の値をノード“+”で加算する。また、ノード“+”の加算の結果からノード“c”の値をノード“-”で減算する。次に、その結果を“d”に代入する。
 図6のデータフローグラフは、複数のノード(ノード“a”、ノード“b”、ノード“+”、ノード“c”、ノード”-”、ノード“d”)と複数のエッジ(エッジ“a”→“+”、エッジ“b”→“+”、エッジ“+”→“-”、エッジ“c”→“-”、エッジ“-”→“d”)を含む情報である。ここで、エッジ“a”→“+”とは、ノード“a”とノード“+”との間を接続するエッジであるとして説明する。
 次に、データ依存解析部102が、図7のエッジのデータ範囲を出力する方法を説明する。前述したように、ソースプログラムは、aの取り得るデータ範囲が[-10、10]であることを示している。また、bの取り得るデータ範囲が[5、10]であることを示している。また、cの取り得るデータ範囲が[-5、10]であることを示している。したがって、データ依存解析部102は、データフローグラフと合わせて、エッジ“a”→“+”に流れるデータのデータ範囲[-10、10]と、エッジ“b”→“+”に流れるデータのデータ範囲[5、10]と、エッジ“c”→“-”に流れるデータのデータ範囲[-5、10]とを出力する。ここで、例えば[-10、10]とは、-10から10の範囲を取り得るということを表している。逆にその範囲外の値となることはないことを示している。
 以上より、データ依存解析部102が、図5のソースプログラムから図7のデータフローグラフとエッジのデータ範囲を合わせた情報を出力する方法を説明した。
 なお、本実施例では、ノードを演算“+”、“-”とする例を説明した。また、エッジを演算間の依存関係として説明した。しかしながら、データフローグラフは、他の情報を保持してもよい。
 データ依存解析部102が解析する部分は、ソースプログラム全体でなくてもよい。例えば、データ依存解析部102は、指定された関数の中だけを解析してもよい。また、データ依存解析部102が解析する部分を自動で選択してもよい。データ依存解析部102は、指定されたコードの部分だけを解析してもよい。これらの方法を組み合わせてもよい。
 データ範囲解析部103は、データ依存解析部102が生成したデータフローグラフの各エッジに流れるデータが取り得る値の範囲を解析して出力する。データ範囲解析部103は、入力部によって入力された各エッジに流れるデータの取り得る値の範囲を示す情報を用いて、各エッジに流れるデータが取り得る値の範囲を出力しても良い。
各エッジに流れるデータの取り得る値の範囲を示す情報は、各エッジに流れるデータの取り得る値の範囲を示すことができればどのような情報であってもよく、たとえば、エッジに流れうるデータの値の範囲や、エッジに流れうるデータを表現するビットの幅であっても良い。データ範囲解析部103は、データ依存解析部102からエッジに流れるデータのデータ範囲が入力された場合、入力されたエッジ以外のエッジに流れるデータのデータ範囲を求めても良い。
 以下では、データ依存解析部102が、図7に示すデータフローグラフとエッジのデータ範囲を含む情報を出力した場合に、データ範囲解析部103が、その情報を解析することにより、全てのエッジのデータ範囲を求める例を説明する。図9は、データ範囲解析部103が解析を行った結果出力する、データフローグラフと全てのエッジのデータ範囲とを合わせた情報である。図10は、図9の情報と等価な情報を表で表した。図8と図10を比較すると、データ範囲解析部103は、図8の情報に加えて、エッジ“+”→“-”のデータ範囲と、エッジ“-”→“d”のデータ範囲を出力することがわかる。
 以下では、図7の情報から図9の情報を出力するために行ったデータ範囲解析部103の解析方法について説明する。
 図7の情報から、エッジ“+”→“-”に流れるデータのデータ範囲は、[-10、10]と[5、10]を足したときの小値-10+5=-5、最大値10+10=20となる。また、エッジ“-”→“d”に流れるデータのデータ範囲は、[-5、20]から[-5、10]を引いたときの最小値-5-10=-15、最大値20-(-5)=25となる。したがって、図9及び図10に示すように、エッジ“+”→“-”がデータ範囲[-5、20]であり、エッジ“-”→“d”がデータ範囲[-15、25]であることを求めることができる。
 なお、この例では、エッジのデータ範囲が割当てられていない部分のみを解析したが、既にエッジのデータ範囲が割当てられている部分を解析してもよい。
 例えば、図7のデータフローグラフにおいて、すでにエッジ“-”→“d”のデータ範囲を[-100, 200]として割り当てられていたとする。この場合、データ範囲解析部103が、解析によりエッジ“-”→“d”を求めることにより、エッジのデータ範囲は[-15、25]で十分であることが分かる。一方、図7のデータフローグラフにおいて、すでにエッジ“-”→“d”のデータ範囲が[-1、5]として与えられていたとする。この場合、データ範囲解析部103が、解析により[-15、20]と求めることにより、与えられていたエッジのデータ範囲が解析により求めたエッジのデータ範囲より小さいことがわかり、割り当てられていたデータ範囲と解析により求めたデータ範囲とが矛盾することがわかる。
 割り当てられていたエッジのデータ範囲が解析の結果求めたエッジのデータ範囲より大きなデータ範囲である場合、解析の結果求めたエッジのデータ範囲で更新するかしないかを指定できるとしても良い。
 割り当てられていたエッジのデータ範囲が解析の結果求めたエッジのデータ範囲より小さな範囲の値が割り当てられていたときは、例えば、割り当てられていたエッジのデータ範囲から解析の結果求めたエッジのデータ範囲へと更新を行わなくても良い。また、結果が矛盾することをユーザに警告を発してもよい。また、割り当てられていたエッジのデータ範囲から解析結果のエッジのデータ範囲に更新するとしても良い。割り当てられていたエッジのデータ範囲と求めたデータ範囲とが矛盾する場合に備えて、エッジのデータ範囲に優先順位をつけてもよい。
 また、エッジのデータ範囲を割り当てられていたデータ範囲から解析結果のデータ範囲に更新をできるか否かオプションで指定できるようにしてもよい。
 また、データ範囲解析部に入力されたデータフローグラフのエッジのデータ範囲が全て予め指定されている場合、データ範囲解析部は全く解析を行わなくても良いし、エッジのデータ範囲の更新や矛盾発見を期待して解析を行っても良い。
 以上の例では、データフローグラフの上から下に向かってエッジのデータ範囲を解析したが、任意の順序で解析してもよい。
 エッジのデータ範囲は、図9のように全てエッジについて解析できる必要はなく、解析できないエッジや解析しないエッジがあってもよい。エッジのデータ範囲を解析できないときや解析しないときは、コンパイラ装置利用者に対して警告を発してもよい。単に解析できないということを伝えるだけではなく、データフローグラフのどのエッジがどのような原因で解析できないという詳細な情報を示してもよい。エッジのデータ範囲を解析できないとき、データフローグラフのどこかの入力で解析できない原因を取り除いてもよいし、解析しないまま先に進めてもよい。以降の処理において、解析できなかったエッジをどのように処理するかは、後述する。
 エッジのデータ範囲は、エッジのデータ範囲になりうる情報であれば、図5のようにエッジに直接対応していなくても良い。例えば、各ノードにノードの入出力のデータ範囲を結びつけることは、エッジにエッジのデータ範囲を結び付けていることと等価である。
 エッジの解析を行うためには解析の起点となるエッジのデータ範囲を持った1つ以上のエッジを必要とする。図7の例では,図5のプラグマで指定されたデータを起点としている。すなわち、図5のプラグマでは、ノードa、ノードb、ノードcそれぞれのデータ範囲をそれぞれ[-10、10]、[5、10]、[-5、10]と指定している。尚、起点の情報は、ソースプログラムに埋め込んでも良いし、ソースプログラムとは別に入力しても良い。
 また、起点となるエッジのデータ範囲は、データ範囲解析部103が自動的に決定しても良い。
 エッジのデータ範囲をソースプログラムに埋め込む方法としては、16bit整数型や32bit整数型などの変数の型を利用した方法、変数の命名規則にデータ範囲の記述方法を含める方法、エッジのデータ範囲を直接的に記述できる記述方法を利用する方法、プラグマとしてエッジのデータ範囲を記述しておいて解析する方法、既存の記述方法の上にエッジのデータ範囲を記述してプリプロセス時に処理する方法、バイナリファイル中にエッジのデータ範囲を記録しておく方法などがある。
 エッジのデータ範囲をソースプログラムとは別に入力する方法としては、エッジのデータ範囲を別のファイルに記述しておいて入力する方法、GUI(Graphical User Interface)を通してユーザにエッジのデータ範囲をインタラクティブに指定させる方法などがある。
 データ範囲解析部103が自動的に決定する方法としては、メモリからの入力部は全て16bitであるとハードウェア資源の特徴から決めておく方法、ある演算を行ったときはエッジのデータ範囲が限定されると推定する方法、複数の演算の依存関係を見て決める方法などがある。
 判定部104は、データ範囲解析部103から入力された情報(データフローグラフとエッジを流れるデータの取り得る範囲)を受け取り、その情報からデータフローグラフの要素(ノード、又はエッジ)を対応付け可能なハードウェア資源を判定する。判定部104は、図2に示すように第1記憶部104Aを備える。第1記憶部104Aは、図12に示すように、コンパイラ装置10が生成するオブジェクトコードを実行させるハードウェア資源と当該ハードウェア資源の演算の種類と当該演算の演算可能なデータ範囲を記憶する。図11に、コンパイラ装置10が生成するオブジェクトコードを実行させるハードウェア資源群の例を示す。判定部104は、ハードウェア資源群のハードウェア資源のうち、データフローグラフのノードの演算の種類と一致し、かつノードに入力されるエッジのデータ範囲とノードから出力されるエッジのデータ範囲を全て含むデータ範囲を処理可能なハードウェア資源をノードと対応付け可能なハードウェア資源と判定する。判定部104は、データフローグラフの各要素に対応付け可能なハードウェア資源を全て対応付け可能と判定する。したがって、データフローグラフの各要素に対して対応付けるハードウェア資源は1つである必要はない。
 どの要素について対応付けの判定を行うか否かは、ハードウェア資源の性質やコンパイラ装置10への要求によって異なる。例えば、演算器はヘテロジニアスでデータパスはホモジニアスであるならば、データパスの判定は行わずに演算器の判定のみを行うということもできる。
 データフローグラフの要素をハードウェア資源に対応付けられるかどうかの判定は、ハードウェア資源が、各データフローグラフの要素を正しく実行できるかによって判断される。各データフローグラフの要素を正しく実行できるためには、例えば、目的の演算を実現できること、データの精度を失うことなく演算することが条件となる。目的の演算を実現できることは、例えば、ノードが“+”(足し算を行う演算子)であるときは、ハードウェア資源は加算器を含む演算器に割当てる必要があることである。
 また、データの精度を失うことなく演算することとは、例えば、ハードウェア資源の演算の演算可能なデータ範囲が、ノードに入力されるエッジのデータのデータ範囲と、ノードが出力するエッジのデータ範囲すべてのデータ範囲を含むデータ範囲であることが必要である。例えば、図9の演算ノード“+”に対応する加算器がデータの精度を失わないための条件は、演算ノード“+”に入力されるエッジ“a”→“+”のデータ範囲[-10、10]とエッジ“b”→“+”のデータ範囲[5、10]のデータを入力することができて、かつこの入力に対する演算を行った結果の出力であるエッジ“+”→“-”のデータ範囲[-5、20]を出力とすることができる加算器である必要がある。すなわち、加算器は、データ範囲[-10、20]が演算可能である必要がある。また、データの精度を失うことなく演算することができる演算器とは、例えば、ノードが32bitでの足し算を行う必要があればそれ以上の精度(32bitより高いbit数)をもつ演算器であっても良い。
 ここで、データの精度を失うとは、結果が数学的に正しくないという意味ではなく、求められた精度に収まればよい。例えば、0.005/100が0になってしまっていても、小数点第三位まで正しければよいという性質であるならば、この結果は正しい精度で演算を行えているということである。
 エッジをデータパスに割当てる際には、エッジに流れるデータのデータ範囲をデータパスで流せることが必要である。
 図9と図10と図11と図12とを利用して判定部104の動作を説明する。
 図11のハードウェア資源群は、加算器と減算器がまとまった演算器群AからDを含む。また、このハードウェア資源群は、4つの演算器群とLoad/Store演算器が相互接続されている。Load/Store演算器からのデータパスと演算器群間のデータパスは、演算器群内の演算器のどちらにも接続されているとする。演算器群Aは、演算の種類が“+”(加算)でありかつ処理可能なデータ範囲が[-105、105]であるハードウェア資源A1と、演算の種類が”-”(減算)でありかつ処理可能なデータ範囲が[-105、105]であるハードウェア資源A2とを備える。演算器群Bは、演算の種類が“+”(加算)でありかつ処理可能なデータ範囲が[-100、100]であるハードウェア資源B1と、演算の種類が”-”(減算)でありかつ処理可能なデータ範囲が[-1、2]であるハードウェア資源B2とを備える。演算器群Cは、演算の種類が“+”(加算)でありかつ処理可能なデータ範囲が[-1、2]であるハードウェア資源C1と、演算の種類が”-”(減算)でありかつ処理可能なデータ範囲が[-1、2]であるハードウェア資源C2とを備える。演算器群Dは、演算の種類が“+”(加算)でありかつ処理可能なデータ範囲が[-1、2]であるハードウェア資源D1と、演算の種類が”-”(減算)でありかつ処理可能なデータ範囲が[-100、100]であるハードウェア資源D2とを備える。また、Load/Store演算器はハードウェア資源Eである。ハードウェア資源Eのデータ範囲は、[-128、127]である。
 尚、本実施形態では各データパスは、どのようなサイズのデータも通すことができることとする。すなわち、本実施形態では、各エッジに流れるデータのデータ範囲からデータパスを選ぶ必要がない。なお、データパスに通すことができるデータサイズに制限がある場合、判定部104は、エッジのデータ範囲から当該データ範囲のデータサイズを通すことができるデータパスを判定する機能を設けても良い。
 ここで、演算器群という概念は、短い時間でデータ転送可能な演算器の集合を表現するものである。演算器群とは、ハードウェア資源として特別な機構を備えている必要は無い。たとえば、演算器群内においてハードウェア資源間のデータパスは1クロックでデータを転送できるとする。一方、演算器群間のデータパスは、例えばデータ転送に5クロック係るものとする。
 各演算器は1クロックで演算を実行することが可能であるとする。Load/Store演算器は、メモリアクセス時間とデータ転送時間を合わせて10クロックでデータを他のハードウェア資源へ転送できるとする。
 図9のデータフローグラフの各要素が図11のハードウェア資源群のうちどのハードウェア資源に対応付け可能かを判定する方法の例を示す。本実施形態では、各データパスにはどのようなデータも通すことができると仮定したため、データフローグラフのエッジのデータパスの対応付け可能か否かの判定を行う必要はない。
 判定は、各ノードの目的の演算を実現できること、データの精度を失うことなく演算することの2つの条件を満たすか否かで判定する。本実施形態では、データの精度は、ハードウェア資源の処理可能なデータ範囲が、ノードに入力されるエッジと出力されるエッジのデータ範囲を含むか否かで判定する。例えば、図4のようなステップで判定する。すなわち、判定するノードを選択し(S1401)、次に、データ範囲解析部103から入力された図10の情報と第1記憶部104Aが記憶する図12の情報とを比較することにより、各ハードウェア資源が、ノードの目的の演算を実現可能かを判定し(S1402)、次に、ハードウェア資源が、データの精度を失わない演算をすることが可能か否かを判定する(S1403)。
 図9のメモリアクセスの演算ノードa、b、c、dは、Load/Store演算器であるハードウェア資源Eによって演算を実現可能である。また、ノードa、b、cから出力されるエッジのデータ範囲及びノードdに入力されるエッジのデータ範囲は、それぞれLoad/Store演算器の読み書き可能データ範囲[-128、127に含まれている。したがって、ノードa、b、c、dは、Load/Store演算器に対応付け可能であると判定される。
 図9のノード“+”は、足し算を行う演算子である。したがって、図12の表からハードウェア資源A1、B1、C1、D1で演算を実現可能であると判定する。また、ノード“+”に入力されるエッジは“a”→“+”(データ範囲は[-10、10])と“b”→“+”(データ範囲は[5、10])である。ノード“+”から出力されるエッジは、“-”→“d”(データ範囲は[-5、20])である。したがって、ハードウェア資源は、データ範囲[-10、20]の処理可能な演算器である必要がある。したがって、表12から、ハードウェア資源A1、B1を対応付け可能なハードウェア資源であることと判定することができる。また、同様に、図9のノード“-”に対応付け可能なハードウェア資源は、ハードウェア資源A2とハードウェア資源D2であると判定する。判定部104が判定して出力する各ノードと各ノードそれぞれに対応する対応付け可能なハードウェア資源を含む情報を図13に示す
 なお、ノードの種類は、変数ノード、足し算には限られない。例えば、ノードの種類は、足し算と掛け算の複合、FFT(Fast Fourier Transform)、H.264デコードなど、低レベルの演算から高レベルの演算がある。データフローグラフは、低レベルの演算と高レベルの演算を1つのデータフローグラフに含んでいても良い。また、ノードの種類は、算術演算だけではなく、論理演算、メモリ操作、条件分岐、複素演算、スタック操作、データ転送、関数呼び出し、関数リターンなどでも良い。
 ハードウェア資源も、加算器に限られない。ハードウェア資源は、例えば、乗算器、SIMD(Single Instruction Multiple Data)で複数のデータの足し算を行う演算器、SIMDで複数のデータの足し算を行う演算器の中にある各加算器、ALU(Arithmetic Logic Unit)のように複数種類の演算が可能で演算を選択可能な演算器、複数のALUが結合しているALUアレイのような演算器、FFT(Fast Fourier Transform)のような特定の演算を行う演算器、H.264デコードを行う演算器、複数のプロセッサコアが結合するマルチコア、複数のプロセッサが結合するマルチプロセッサなどがある。ハードウェア資源は、低レベルの演算器であっても高レベルの演算器であっても良い。ハードウェア資源は、1まとまりのハードウェア資源の中に低レベルの演算器から高レベルの演算器が入り混じってもよい。また、演算器だけではなく演算器間を結ぶデータパスもハードウェア資源に含まれる。
 ハードウェア資源は、コンパイラ装置から階層的に見えていてもよい。例えば、高レベルの演算器の中に低レベルの演算器が含まれるという情報を保持して判定に利用してもよい。例えば、加算してから減算する演算器を1つの演算器としてみるとき、その演算器の中に加算器と減算器があるということを利用してもよく、10を足したいときに10加算して0減算するということを行えば同じことを実現できるため、対応付け可能と判定してもよい。このようにすることにより、対応付け可能と判定される演算器の数が増える。
 対応付け可能性の判定は、1箇所もしくは1箇所以上のハードウェア資源に対して行う。ハードウェア資源の対応付け可能性の判定を1箇所のハードウェア資源に対して行うのであれば、判定結果は対応付け可能か否かということになる。1箇所のハードウェア資源に対して判定を行うとき、判定を行う1箇所のハードウェア資源の選択することには様々な方法が考えられる。例えば、ランダムに1箇所を選ぶ方法、メモリに近いハードウェア資源を優先的に選ぶ方法、アルゴリズムに従って選ぶ方法、既に割当てられているハードウェア資源があるならそこに近いハードウェア資源を選ぶ方法、強力な演算を行えるハードウェア資源を優先的に選ぶ方法、太いデータパスに近いハードウェア資源を選ぶ方法、各ハードウェア資源へのパスを最小化できるように論理的に中心に近いハードウェア資源を選ぶ方法、それらを組み合わせた方法などが考えられる。1箇所以上のハードウェア資源に対して行うのであれば、判定結果は対応付け可能なハードウェア資源の集合、対応付け可能なハードウェア資源の部分集合などが考えられる。
 判定部104は、外部からあるデータフローグラフのノードを特定のハードウェア資源に対応付け可能もしくは不可能という情報を受け取ってもよい。例えば、外部から、あるハードウェア資源をデータフローグラフのノードの演算とは異なる処理のために利用したいとの情報を受け取った場合、判定部104は、データフローグラフのノード全てに対してそのハードウェア資源を対応付け可能と判定しない。判定部が外部から情報を受け取る方法は、例えば、外部のファイルから入力される方法、GUI(Graphical User Interface)からノードのプロパティとしてインタラクティブに指定される方法などがある。尚、外部からの情報は、データフローグラフの全てのノードとハードウェア資源の関係を指定するものであっても、一部のノードとハードウェア資源の関係を指定するものであっても良い。
 尚、判定部104は、対応付け可能と判定できるハードウェア資源がなかったときには、コンパイラ装置10利用者や他の装置に対して警告を行ってもよい。例えば、ハードウェア資源を割当てられないノードやエッジの情報をコンソールに表示したり、プロセス間通信を利用して通知したりしてもよい。警告を行うかどうかをオプションで指定したり、警告の情報詳細度を指定したりしてもよい。
 判定部104に入力される情報として、エッジのデータ範囲を与えられていない部分がある場合、判定部104での対応には様々な方法が考えられる。例えば、判定部104は、エラーとして処理を進めない方法、ノードに対して演算を実現可能なハードウェア資源のうち最も処理可能なデータ範囲が大きいハードウェア資源を対応付け可能と判定する方法、ノードの演算を実現可能なハードウェア資源の中からランダムに対応付け可能と判定する方法、ノードの演算を実現可能なハードウェア資源の中から一定以上のデータ範囲を持つハードウェア資源を対応付け可能と判定する方法などがある。
 割当部105は、データフローグラフの各要素に判定部104が対応付け可能と判断したハードウェア資源のうち少なくとも一つのハードウェア資源を割り当てる。割当部105は、ハードウェア資源管理情報を記憶する第2記憶部105Aを有する。第2記憶部105Aが記憶するハードウェア資源管理情報の1例を図14に示す。図14に示すように、第2記憶部105Aは、ハードウェア資源管理情報としてハードウェア資源がどの演算器群に属するかを記憶する。
 割当部105は、データフローグラフの各要素にハードウェア資源の割り当てを行う際に、データフローグラフの依存関係とハードウェア資源管理情報を基に行う。
 データフローグラフの依存関係とは、例えば、各ノード間の依存関係である。例えば、図7において、ノード“+”は、ノード“-”の前に処理を行う依存関係がある。また、依存関係とは、各ノードに対応付け可能なハードウェア資源に関する依存関係を含んでもよい。
 図13と図14と図15を利用して割当部105の動作を説明する。図15は、割当部105が各ノードに対して割り当てるハードウェア資源を示す表である。
 ノードaとbとcとdは、図13に示すとおり、判定部104によって1つのLoad/Store演算器(ハードウェア資源E)に対応付け可能であると判定されている。したがって、割当部105は、ノードaとbとcとdに対してLoad/Store演算器(ハードウェア資源E)を割当てる。
 図13に示すとおり、ノード“+”は、判定部104によってハードウェア資源A1とハードウェア資源B1に対応付け可能と判定されている。ノード“-”は、図13に示すとおり、判定部104によってハードウェア資源A2、D2と対応付け可能と判定されている。そして、図14のハードウェア資源管理情報からハードウェア資源A1とA2は同じ演算器群に属することがわかる。また、データフローグラフからわかるようにノード“+”の処理はノード“-”の処理の前に行うという依存関係がある。
 本実施形態では、割当部105は、ノードに対するハードウェア資源を割り当てる際に、処理の実行時間が早くできることを基準として割り当てる。割当部105は、ハードウェア資源の属する演算器群の情報と、ノードの依存関係を基に、ノードに対するハードウェア資源を割り当てる。ここで、ハードウェア資源が同じ演算器群内であればハードウェア資源間のデータパスを1クロックで移動できる。また、ハードウェア資源が異なる演算器群にある場合、ハードウェア資源間のデータパスを5クロックで移動する。
 前述したとおり、演算に必要なクロック数は、加算器へのメモリ読み込みに10クロックであり、加算に1クロック、減算に1クロック、減算器からのメモリの書き込みに10クロック必要である。
 したがって、ノード“+”とノード“-”を同一の演算器群内にあるハードウェア資源に割り当てた場合、データフローグラフ全体を処理するためには、合計23クロックかかる。
 一方、ノード“+”とノード“-”を異なる演算器群にあるハードウェア資源を割り当てた場合、例えば、ノード“+”にハードウェア資源B1を割り当てて、ノード“-”にハードウェア資源D2を割り当てた場合、ハードウェア資源B1からハードウェア資源D2へのデータ受け渡しに5クロック必要となるため、データフローグラフ全体を処理するためには、合計27クロックかかる。
 割当部105は、ノード“+”にはハードウェア資源A1を割り当て、ノード“-”にはハードウェア資源A2を割り当てる。
 尚、本実施形態では、ハードウェア資源管理情報としてハードウェア資源の属する演算器群の情報を用いて、割当部105は、最も実行時間が早いハードウェア資源を割り当てた。しかしながら、ハードウェア資源管理情報は演算器群に限られない。また、ノードに対するハードウェア資源の割当も最も早くなるハードウェア資源を割り当てる場合に限られない。
 ハードウェア資源管理情報には様々な種類の情報がある。例えば、ハードウェア資源の接続状況、アルゴリズムによって既に割当てられているノードとハードウェア資源の情報、アルゴリズムによってこれから割当てられるノードとノードに対応付け可能なハードウェア資源の情報、ハードウェア資源間のデータパスの遅延に関する情報、ハードウェア資源の実行時間に関する情報、ハードウェア資源の消費電力に関する情報、ハードウェア資源の熱分布に関する情報など、ハードウェア資源そのものの情報に加えて割当状況などの割当アルゴリズムに関する情報などを幅広く含んだ情報である。
 割当部105は、ハードウェア資源の割当の指定を外部から受け取って、ノードに対するハードウェア資源の割当を行っても良い。例えば、あるノード“+”を特定の加算器に割当てたいとき、その情報を外部から入力してもよい。入力の方法は、例えば、外部のファイルから入力する方法、GUI(Graphical User Interface)からノードのプロパティとしてインタラクティブに指定する方法がある。また、ハードウェア資源割当の外部からの指定は、ノードに対して1つのハードウェア資源への割当ての指定である必要はなく、ノードに対して複数のハードウェア資源の候補のどれかを割り当てるという指定であってもよい。また、ある演算器の下位階層にある演算器のどれかという指定でもよい。また、外部からのハードウェア資源割当の指定に強制力を持たせることもできるし、希望という指定を行うこともできる。希望という指定を行ったとき、割当部105は可能な限りそのハードウェア資源に割り当てようとするが、割当てられないときや求める効果を満たせないときには他のハードウェア資源に割当を行ってもよい。
 割当部105は、割当てられるハードウェア資源がないときに警告を行ってもよい。例えば、データ幅[200, 300]同士の加算を行うノード“+”を図11のハードウェア資源に割当てることはできないという情報を示す。このとき、割当部105は、エラーとして処理を実行しても良いし、処理可能なデータ幅の大きいハードウェア資源に割当ててもよいし、ランダムにハードウェア資源を選択して割り当ててもよい。
 割当部105は、割当てられるようなハードウェア資源をプログラマブルデバイス上に作成してもよい。例えば、加算器のような専用ハードウェア資源とFPGAのようなプログラマブルデバイスが結合しているとき、専用ハードウェア資源として存在している加算器の演算可能な範囲が不十分であるときは、FPGA上に演算可能な範囲を満たす加算器を作成してもよい。割当部105は、割当てられるハードウェア資源があるときにでも新しいハードウェア資源を作成してもよい。前述のハードウェア資源の例では、用意されている専用ハードウェア資源の加算器でも十分であるが、専用ハードウェア資源の加算器を他の加算のために利用したい場合や、他の演算との依存関係やハードウェア資源管理情報から前の演算に近いFPGAに割当てたい場合など、様々な理由が考えられる。プログラマブルデバイスがあるとき、判定部104は常にプログラマブルデバイスに対応付け可能と割当部105に伝達してもよいし、自由に演算器を作れるのだから明示的に割当部105に伝達しないという手段をとってもよい。
 本実施形態のコンパイラ装置10によれば、オブジェクトコードを実行するハードウェア資源が複数ある場合に、データの精度を失うことなくハードウェア資源の効率的な利用を行うことができる。
 尚、割当部105が、ノードに対してハード資源の割当を行うその他の方法として、下記の方法がある。
 コンパイラ装置10が出力するオブジェクトコードを実行するハードウェア資源群がSIMD(Single Instruction Multiple Data)の演算器を有するハードウェア資源を含む場合を説明する。この場合、判定部104が、複数のノードをSIMDユニットに対応付け可能と判定した場合、割当部105は、それらノードを複数まとめてSIMDの演算器に割当を行う。これにより、複数のデータをまとめて処理できるため、別々に演算を行ったときよりも処理時間を短縮できる。
 また、割当部105は、例えばオブジェクトサイズの削減を目的としてハードウェア資源割当を行ってもよい。例えば、ハードウェア資源A1、A2は、様々な演算をサポートするため、演算の指定に32bit必要であったとする。それ以外のハードウェア資源は、加算と減算のみをサポートするため、演算の指定に1bit必要であったとする。この場合、ノード“+”にハードウェア資源A1を割り当てて、ノード“-”に演算器A2を割り当てた場合、合計64bitを演算の指定に利用する。一方、ノード“+”にハードウェア資源B1を割り当てて、ノード“-”にハードウェア資源D2を割り当てた場合、合計2bitで十分である。この場合、オブジェクトサイズの削減を達成することができる。
 また、割当部105は、例えば利用メモリ量の削減を目的としてハードウェア資源割り当てを行っても良い。例えば、ハードウェア資源A1、A2はスタックマシンであり、演算に必要なデータをメモリに格納する必要があるとする。それ以外のハードウェア資源は、レジスタを有しており、演算に必要なデータをレジスタから持ってくることができるとする。この場合、ノード“+”にハードウェア資源B1を割り当てて、ノード“-”にハードウェア資源D2を割り当てた場合、ハードウェア資源A1、A2を割り当てた場合と比べて利用メモリ量を削減できる。
 また、割当部105は、例えば消費現力の削減を目的としてハードウェア資源割り当てを行っても良い。例えば、ハードウェア資源A1、A2は強力な演算器であり消費電力が大きいとする。一方、他のハードウェア資源はハードウェア資源A1、A2よりも消費電力が小さいとする。この場合、ハードウェア資源A1、A2に割当てないことにより、ハードウェア資源A1、A2に対してクロックゲーティングなどの技術を使って消費電力を削減することができる可能性がある。
 また、割当部105は、例えば発生する熱の低減を目的としてハードウェア資源割当てを行ってもよい。例えば、特定のハードウェア資源ばかりを利用していると熱が集中するのに対して、色々なハードウェア資源を利用することにより、熱を分散することができる可能性がある。したがって、割当部105は、例えば、いろいろなハードウェア資源を割り当てることにより、熱の低減を達成することができる。
 また、割当部105は、例えば利用ハードウェア資源量の削減を目的として割当てを行ってもよい。例えば、複数の処理があったときに、それらの処理を同時に行いたいという状況を想定する。それらの処理を時分割すると、処理に求められている時間制約を満たせない場合などである。この場合、割当部105は、データフローグラフのノード+とノード-の処理をハードウェア資源A1とA2のみに割当てて、他のハードウェア資源を他の処理のために空けておくことにより、異なる処理を同時に実行することができる可能性がある。
 また、データフローグラフの各要素が1つのハードウェア資源に割り当てられる例を説明したが、判定部104は、データフローグラフの各要素を複数のハードウェア資源に割り当て可能と判定しても良い。
 例えば、64bitの精度が必要なデータフローグラフのエッジをハードウェア資源のデータパスに割り当てることを考える。ここで、判定部104は、このデータフローグラフのエッジが表現する64bitのデータの上位32bitと下位32bitのデータを別のエッジと考えることによって、2つの32bitデータパスに割り当て可能と判定しても良い。
 このように、データフローグラフの1つのエッジを、複数のエッジと考えることで、判定部104は、データフローグラフの各要素を複数のハードウェア資源に割り当て可能と判定することができる。これは、データパスだけではなく演算器の場合にも適用可能である。たとえば、2つの64bitのデータ同士のビット単位の論理和を計算するとき、上位32bitと下位32bitとを異なる2つの32bit演算器に割り当て可能と判定してもよい。割当部105は、判定部104によってデータフローグラフの一つの要素が複数のハードウェア資源に割り当て可能と判定されたとき、その割り当て方法も候補に含め、割り当てを行う。
 本発明は、上記実施形態に限られない。エッジに流れるデータの取り得る範囲を示す情報は、1つのデータ範囲を示す情報に限られない。たとえば、エッジに流れるデータの取り得る範囲を示す情報は、エッジに流れうる値の集合で表しても良い。例えば、エッジに流れうる値を(1, 2, 5, 8)と表現してもよい。この場合、エッジは、1か2か5か8の値を取り得ることを表す。エッジに流れるデータの取り得る範囲を示す情報は、複数のデータ範囲の集合で表現されても良い。例えば、[12, 20][50, 75]と表す。この場合、エッジに流れる値は、12から20の範囲又は50から75の範囲にある。
 エッジに流れる値は、図7では全て整数として示したが、整数以外でも良い。例えば、小数や行列や複素数などで表現しても良い。
 また、エッジに流れる値はビット幅を用いて表現しても良い。以下では、エッジに流れる値をビット幅で表現する場合について説明する。
 この場合、図5のソースコードの変数a、b、c、dはデータ範囲でなく、ビット幅で表す。また、図7、図8、図9、図10のエッジに流れる値として、データ範囲の代わりにビット幅を用いる。また、ハードウェア資源の処理量もデータ範囲でなく、ビット幅で表す。このとき、判定部104の第1記憶部104Aは、各ハードウェア資源について、図17のようなビット幅との対応表を記憶している。また、図16に、図9のデータフローグラフにおいて、各エッジに流れる値をビット幅で表した場合のデータフローグラフの要素とエッジのビット幅との対応表を示す。
 判定部104は、各ノードについて入力のビット幅と出力のビット幅と各ハードウェア資源の処理可能なビット幅とを比較して、ハードウェア資源の処理可能なビット幅が大きい場合に、当該ハードウェア資源を対応付け可能なハードウェア資源と判定する。例えば、図16においては、ノードaの出力のエッジである“a”→“+”、ノードbの出力のエッジである“b”→“+”、ノードcの出力のエッジである“c”→“-”、ノードdの入力のエッジであるエッジ“-”→“d”のビット幅がそれぞれ、16、16、16、18である。またハードウェア資源Eは、ビット幅64である。したがって、判定部104は、ノードa、b、c、dは、ハードウェア資源Eで対応付け可能と判定する。また、ノード“+”の入力のエッジである“a”→“+”と“b”→“+”は、それぞれのビット幅が16である。また、ノード“+”の出力のエッジである“+”→“-”のビット幅は、17である。したがって、判定部104は、図17よりノード“+”は、ハードウェア資源A1とハードウェア資源B1と対応付け可能と判定する。また、ノード“-”の入力のエッジである“c”→“-”のビット幅とは16ビットである。また、ノード“-”の入力のエッジである“+”→“-”のビット幅は、17である。また、ノード“-”の出力のエッジである“-”→“d”のビット幅は18である。したがって、判定部104は、ノード“-”は、図17よりハードウェア資源A2、D2と対応付け可能であると判定する。
 尚、本実施形態は、コンパイラ装置10のうちソースプログラム入力部101、データ依存解析部102、データ範囲解析部103、割当部105を備えない構成である判定装置20としても良い。判定装置20は、入力部201と判定部104を備える構成である。入力部201は、データフローグラフ(ノードとエッジ)とエッジに流れるデータ範囲を入力する。判定部104は、コンパイラ装置10の判定部104の動作と同じである。尚、判定装置20は、ソースプログラム入力部101、データ依存解析部102、データ範囲解析部103、判定部104それぞれを備える構成であってもよい。
 また、本実施形態は、コンパイラ装置10のうちソースプログラム入力部101、データ依存解析部102、データ範囲解析部103を備えない構成である割当装置30としても良い。割当装置30は、入力部201と判定部104と割当部105を備える構成である。入力部201は、判定装置20の動作と同じである。判定部104、割当部105は、コンパイラ装置10の判定部104、割当部105の動作と同じである。
 判定装置20、割当装置30によれば、データの精度を失わない範囲で効率的にハードウェア資源を利用することができる。
 なお、コンパイラ装置10は、例えば、汎用のコンピュータ装置を基本ハードウェア資源として用いることでも実現することが可能である。すなわち、ソースプログラム入力部101、データ依存解析部102、データ範囲解析部103、判定部104、割当部105は、上記のコンピュータ装置に搭載されたプロセッサにプログラムを実行させることにより実現することができる。このとき、コンパイラ装置10は、上記のプログラムをコンピュータ装置にあらかじめインストールすることで実現してもよいし、CD-ROMなどの記憶媒体に記憶して、あるいはネットワークを介して上記のプログラムを配布して、このプログラムをコンピュータ装置に適宜インストールすることで実現してもよい。また第1記憶部104A、第2記憶部105Aは、上記のコンピュータ装置に内蔵あるいは外付けされたメモリ、ハードディスクもしくはCD-R、CD-RW、DVD-RAM、DVD-Rなどの記憶媒体などを適宜利用して実現することができる。
 なお、本発明は上記実施形態そのままに限定されるものではなく、実施段階ではその要旨を逸脱しない範囲で構成要素を変形して具体化できる。また、上記実施形態に開示されている複数の構成要素の適宜な組み合わせにより、種々の発明を形成できる。例えば、実施形態に示される全構成要素から幾つかの構成要素を削除してもよい。さらに、異なる実施形態にわたる構成要素を適宜組み合わせてもよい。
 10・・・コンパイラ装置、11・・・CPU、12・・・RAM、13・・・ROM、14・・・バス、15・・・入力装置、16・・・ハードウェア資源、17・・・出力装置、101・・・ソースプログラム入力部、102・・・データ依存解析部、103・・・データ範囲解析部、104・・・判定部、104A・・・第1記憶部、105・・・割当部、105A・・・第2記憶部、20・・・判定装置、30・・・割当装置、201・・・入力部

Claims (5)

  1.  ノードとエッジの集合を含むデータフローグラフと、各エッジに流れるデータが取り得る値の範囲を示す情報とを入力する入力部と、
     第1ノードの種類と、前記第1ノードと接続する第1エッジに流れるデータが取り得る値の範囲を示す情報とに基づいて、種類の異なる複数のハードウェア資源のうち、前記第1ノードを割り当て可能なハードウェア資源を判定する判定部とを備える
     コンパイラ装置。
  2.  前記判定部は、各ハードウェア資源が実行可能なプロセスの種類と、前記各ハードウェア資源が処理可能なデータの値の範囲とを記憶する記憶部を備え、
     前記判定部は、前記第1ノードに対応するプロセスの種類を処理可能であって、かつ、処理可能なデータ範囲が前記第1エッジに流れるデータが取り得る値の範囲を包含するハードウェア資源を、前記第1ノードに割り当て可能なハードウェア資源と判定することを特徴とする
     請求項1記載のコンパイラ装置。
  3.  前記判定部によって、前記第1ノードに割り当て可能と判定されたハードウェア資源のうち、ノード間の依存関係とハードウェア資源間のデータの受け渡しにかかる時間とを用いて、前記第1ノードを割り当てるハードウェア資源を決定し、前記第1ノードを割り当てる割当部とを備えることを特徴とする
     請求項2記載のコンパイラ装置。
  4.  前記エッジに流れるデータが取り得る値の範囲と前記ハードウェア資源の処理可能なデータの範囲とは、ビット幅で表現されることを特徴とする
     請求項1記載のコンパイラ装置。
  5.  ソースプログラムを入力するソースプログラム入力部と、
     前記ソースプログラムをノードとエッジの集合を含むデータフローグラフで解析する第1解析部と、
     前記エッジに流れるデータが取り得る値の範囲を解析する第2解析部と、
     第1ノードの種類と、前記第1ノードと接続する第1エッジに流れるデータが取り得る値の範囲を示す情報とに基づいて、前記第1ノードに割り当て可能なハードウェア資源を判定する判定部と、
     前記第1ノードを割り当て可能なハードウェア資源を、前記第1ノードに割り当てる割当部とを備えることを特徴とする
     コンパイラ装置。
PCT/JP2010/000710 2010-02-05 2010-02-05 コンパイラ装置 WO2011096016A1 (ja)

Priority Applications (3)

Application Number Priority Date Filing Date Title
JP2011552581A JPWO2011096016A1 (ja) 2010-02-05 2010-02-05 コンパイラ装置
PCT/JP2010/000710 WO2011096016A1 (ja) 2010-02-05 2010-02-05 コンパイラ装置
US13/419,657 US20120192168A1 (en) 2010-02-05 2012-03-14 Compiler device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/JP2010/000710 WO2011096016A1 (ja) 2010-02-05 2010-02-05 コンパイラ装置

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US13/419,657 Continuation US20120192168A1 (en) 2010-02-05 2012-03-14 Compiler device

Publications (1)

Publication Number Publication Date
WO2011096016A1 true WO2011096016A1 (ja) 2011-08-11

Family

ID=44355046

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2010/000710 WO2011096016A1 (ja) 2010-02-05 2010-02-05 コンパイラ装置

Country Status (3)

Country Link
US (1) US20120192168A1 (ja)
JP (1) JPWO2011096016A1 (ja)
WO (1) WO2011096016A1 (ja)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2015118609A (ja) * 2013-12-19 2015-06-25 インターナショナル・ビジネス・マシーンズ・コーポレーションInternational Business Machines Corporation 予め決められた複数のビット幅のデータに対して操作を行う命令を使用してツリーの検索を行うための方法、並びに、当該命令を使用してツリーの検索を行うためのコンピュータ及びそのコンピュータ・プログラム
JP7449963B2 (ja) 2019-05-23 2024-03-14 ザイリンクス インコーポレイテッド ヘテロジニアス処理システムのためのデータフローグラフプログラミング環境

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20200057645A1 (en) * 2018-08-16 2020-02-20 Tachyum Ltd. System and method for location aware processing
US11023273B2 (en) * 2019-03-21 2021-06-01 International Business Machines Corporation Multi-threaded programming
CN113094030A (zh) * 2021-02-09 2021-07-09 北京清微智能科技有限公司 一种可重构芯片的易编译方法及系统

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH04257928A (ja) * 1991-02-13 1992-09-14 Hitachi Ltd 並列計算機におけるプロセッサ割り当て方法、及び装置
JP2000339172A (ja) * 1999-05-28 2000-12-08 Toshiba Corp メモリ効率化方法
JP2001175619A (ja) * 1999-12-22 2001-06-29 Univ Waseda シングルチップマルチプロセッサ
JP2003067195A (ja) * 2001-08-28 2003-03-07 Nec Microsystems Ltd 最適化コンパイル方法及び最適化コンパイル装置
JP2003150386A (ja) * 2001-11-14 2003-05-23 Matsushita Electric Ind Co Ltd コンパイラ装置及びコンパイル方法
JP2005078518A (ja) * 2003-09-02 2005-03-24 Renesas Technology Corp マイクロコントローラユニットおよびそのコンパイラ
JP2006243838A (ja) * 2005-02-28 2006-09-14 Toshiba Corp プログラム開発装置

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH04257928A (ja) * 1991-02-13 1992-09-14 Hitachi Ltd 並列計算機におけるプロセッサ割り当て方法、及び装置
JP2000339172A (ja) * 1999-05-28 2000-12-08 Toshiba Corp メモリ効率化方法
JP2001175619A (ja) * 1999-12-22 2001-06-29 Univ Waseda シングルチップマルチプロセッサ
JP2003067195A (ja) * 2001-08-28 2003-03-07 Nec Microsystems Ltd 最適化コンパイル方法及び最適化コンパイル装置
JP2003150386A (ja) * 2001-11-14 2003-05-23 Matsushita Electric Ind Co Ltd コンパイラ装置及びコンパイル方法
JP2005078518A (ja) * 2003-09-02 2005-03-24 Renesas Technology Corp マイクロコントローラユニットおよびそのコンパイラ
JP2006243838A (ja) * 2005-02-28 2006-09-14 Toshiba Corp プログラム開発装置

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2015118609A (ja) * 2013-12-19 2015-06-25 インターナショナル・ビジネス・マシーンズ・コーポレーションInternational Business Machines Corporation 予め決められた複数のビット幅のデータに対して操作を行う命令を使用してツリーの検索を行うための方法、並びに、当該命令を使用してツリーの検索を行うためのコンピュータ及びそのコンピュータ・プログラム
JP7449963B2 (ja) 2019-05-23 2024-03-14 ザイリンクス インコーポレイテッド ヘテロジニアス処理システムのためのデータフローグラフプログラミング環境

Also Published As

Publication number Publication date
JPWO2011096016A1 (ja) 2013-06-06
US20120192168A1 (en) 2012-07-26

Similar Documents

Publication Publication Date Title
JP6939132B2 (ja) アプリケーション・プロファイリング・ジョブ管理システム、プログラム、及び方法
CN106406812B (zh) 微处理器和微处理器内的执行融合复合算术运算的方法
WO2011096016A1 (ja) コンパイラ装置
US8799858B2 (en) Efficient execution of human machine interface applications in a heterogeneous multiprocessor environment
Dinh et al. Extending the nested parallel model to the nested dataflow model with provably efficient schedulers
Lehmann et al. How workflow engines should talk to resource managers: A proposal for a common workflow scheduling interface
CN113031954A (zh) 代码编译方法、装置、电子设备、存储介质及异构系统
Shepovalov et al. FPGA and GPU-based acceleration of ML workloads on Amazon cloud-A case study using gradient boosted decision tree library
JP2007034888A (ja) 機能ユニットにおいて不必要な電力消費を最小限に抑えるためのデータ経路の割振りのための方法および装置
JP2007172569A (ja) 演算処理装置、演算処理装置の内部構成決定方法および演算処理システム
US7568193B2 (en) Method and apparatus for static single assignment form dead code elimination
Corporaal et al. Code generation for transport triggered architectures
Andrade et al. Efficient execution of microscopy image analysis on CPU, GPU, and MIC equipped cluster systems
Legaux et al. Development effort and performance trade-off in high-level parallel programming
Chandraiah et al. Code and data structure partitioning for parallel and flexible MPSoC specification using designer-controlled recoding
Wernsing et al. The RACECAR heuristic for automatic function specialization on multi-core heterogeneous systems
CN108885546B (zh) 一种基于异构系统的程序处理方法和装置
CN111656323B (zh) 应用运行时确定的异构计算资源的动态分配
Soldavini et al. Platform-Aware FPGA System Architecture Generation based on MLIR
Choi et al. Biologic data analysis platform based on the cloud
Han et al. Genetic algorithm based parallelization planning for legacy real-time embedded programs
KR20130099351A (ko) 디스크 캐쉬 효과를 극대화하는 워크플로우 작업 스케줄링 장치 및 방법
KR102512704B1 (ko) 매트릭스 연산 방법 및 그 장치
Cattaneo et al. A framework for effective exploitation of partial reconfiguration in dataflow computing
EP4227795A1 (en) A computer-implemented method and a computer-readable medium

Legal Events

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

Ref document number: 10845154

Country of ref document: EP

Kind code of ref document: A1

WWE Wipo information: entry into national phase

Ref document number: 2011552581

Country of ref document: JP

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 10845154

Country of ref document: EP

Kind code of ref document: A1