Arithmetic device, arithmetic method, and program

The computing device optimally converts and executes source programs into intermediate representations, addressing execution challenges by determining conversion parts and including data format adjustments, enhancing efficiency and compatibility with existing libraries.

JP7754305B2Active Publication Date: 2025-10-15NEC CORP
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
JP2024524114
Authority / Receiving Office
JP · JP
Patent Type
Patents
Current Assignee / Owner
Filing Date
2022-06-02
Publication Date
2025-10-15
Estimated Expiration
2042-06-02

AI Technical Summary

Technical Problem

Existing systems face challenges in efficiently executing source programs by partially converting them into intermediate representations while minimizing the development burden, as many parts of the source program need to be converted for optimal execution.

Method used

A computing device and method that determines which parts of a source program to convert into an intermediate representation, generates the necessary intermediate representations, and includes data conversion instructions to ensure compatibility with different libraries, allowing both source program and intermediate representation execution using existing libraries.

Benefits of technology

Enables efficient execution of a large portion of the source program in intermediate representation, ensuring compatibility and optimal performance by leveraging existing libraries, even for unsupported data types and operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 0007754305000001
    Figure 0007754305000001
  • Figure 0007754305000002
    Figure 0007754305000002
  • Figure 0007754305000003
    Figure 0007754305000003
Patent Text Reader

Abstract

This computing device comprises: an intermediate representation determining means for determining, for each part of a source program, which is a program to be executed, whether the part is to be converted to an intermediate representation or is to be executed without conversion to an intermediate representation; an intermediate representation generating means for generating an intermediate representation of parts of the source program that have been determined to be converted to the intermediate representation, the intermediate representation generating means determining whether data obtained as a result of executing the intermediate representation include data requiring conversion to a data representation format of the source program, and if it is determined that there are corresponding data, generating the intermediate representation including an instruction to convert the data representation format of the data; a source program execution means for indicating execution of the intermediate representation, by executing the parts of the source program that have been determined not to be converted to the intermediate representation; and an intermediate representation execution means for executing the intermediate representation of which execution has been indicated.
Need to check novelty before this filing date? Find Prior Art

Description

[Technical Field]

[0001] The present invention relates to a computing device, a computing method, and program Regarding. [Background technology]

[0002] There are cases where a source program is partially converted and executed, such as when compiling a program at runtime. For example, Non-Patent Document 1 describes that a graph called an IR Graph is generated for a portion of a program, and the portion corresponding to the IR Graph calls a compiled program to execute an operation sequence. [Prior art documents] [Non-patent literature]

[0003] [Non-Patent Document 1] Alex Suhan, 6 others, "LazyTensor: combining eager execution with domain-specific compilers", arXiv:2102.13267, 2021 Summary of the Invention [Problem to be solved by the invention]

[0004] When a source program is partially converted into an intermediate representation (IR) and then executed, the burden on system development is expected to be relatively small by using existing libraries for both the execution of the source program and the execution of the converted intermediate representation. In this case, it is considered preferable to have as many parts of the source program as possible that can be converted into an intermediate representation and executed.

[0005] An example of the object of the present invention is to provide a calculation device, a calculation method, and program The purpose is to provide [Means for solving the problem]

[0006] According to a first aspect of the present invention, a computing device comprises: intermediate representation determination means for determining, for each portion of a source program that is a program to be executed, whether to convert that portion into an intermediate representation or execute the program without converting it into an intermediate representation; intermediate representation generation means for generating an intermediate representation of the portion of the source program that has been determined to be converted into an intermediate representation, the intermediate representation generation means determining whether any data obtained as a result of executing the intermediate representation needs to be converted into the data representation format of the source program, and if it is determined that such data exists, generating the intermediate representation including an instruction to convert the data representation format of that data; source program execution means for instructing the execution of the intermediate representation by executing the portion of the source program that has been determined not to be converted into an intermediate representation; and intermediate representation execution means for executing the intermediate representation that has been instructed to be executed.

[0007] According to a second aspect of the present invention, a calculation method includes a computer determining, for each portion of a source program that is a program to be executed, whether to convert that portion into an intermediate representation or to execute the program without converting it into an intermediate representation, generating an intermediate representation for the portion of the source program that has been determined to be converted into an intermediate representation, determining whether any data obtained as a result of executing the intermediate representation needs to be converted into the data representation format of the source program, and if it is determined that such data exists, generating the intermediate representation including an instruction to convert the data representation format of that data, executing the portion of the source program that has been determined not to be converted into an intermediate representation, thereby instructing the execution of the intermediate representation, and executing the intermediate representation that has been instructed to be executed.

[0008] According to a third aspect of the present invention, programa program for causing a computer to: determine, for each portion of a source program that is a program to be executed, whether to convert that portion into an intermediate representation or execute the program without converting it into an intermediate representation; generate an intermediate representation for the portion of the source program that has been determined to be converted into an intermediate representation; determine whether any data obtained as a result of executing the intermediate representation needs to be converted into a data representation format in the source program; and, if it is determined that such data exists, generate the intermediate representation including an instruction to convert the data representation format of the data; execute the portion of the source program that has been determined not to be converted into an intermediate representation, thereby instructing the execution of the intermediate representation; and execute the intermediate representation that has been instructed to be executed. In be. [Effects of the Invention]

[0009] According to the present invention, when a source program is partially converted into an intermediate representation and then executed, existing libraries can be used for both the execution of the source program and the execution of the converted intermediate representation, and there are relatively many portions of the source program that can be converted into an intermediate representation and executed. [Brief explanation of the drawings]

[0010] [Figure 1] FIG. 1 is a diagram illustrating an example of the configuration of a calculation device according to an embodiment. [Figure 2] 10A and 10B are diagrams illustrating examples of components of an intermediate representation generated by an intermediate representation generation unit according to the embodiment. [Figure 3] FIG. 10 is a diagram showing an example of a representation format of matrix data in a parent library according to the embodiment. [Figure 4] FIG. 10 is a diagram illustrating an example of a representation format of matrix data in a child library according to the embodiment. [Figure 5] FIG. 10 is a diagram illustrating an example of an intermediate representation including a data conversion instruction generated by an intermediate data conversion instruction generation unit according to the embodiment. [Figure 6]10 is a diagram illustrating an example of intermediate code including a data conversion instruction generated by an intermediate data conversion instruction generation unit according to the embodiment. FIG. [Figure 7] FIG. 1 is a diagram illustrating an example of a source program including a portion to be converted into an intermediate representation and a portion to be executed in the source program according to an embodiment. [Figure 8] 10 is a diagram illustrating an example of intermediate code including a data conversion instruction generated by an intermediate data conversion instruction generation unit according to the embodiment. FIG. [Figure 9] 10 is a diagram illustrating an example of intermediate code including a data conversion instruction generated by a source-oriented data conversion instruction generation unit according to the embodiment. FIG. [Figure 10] FIG. 4 is a diagram illustrating an example of a data flow in a control unit according to the embodiment. [Figure 11] FIG. 10 is a diagram illustrating another example of the configuration of a calculation device according to an embodiment. [Figure 12] FIG. 10 is a diagram illustrating an example of a processing procedure in a calculation method according to an embodiment. [Figure 13] FIG. 1 is a schematic block diagram illustrating the configuration of a computer according to at least one embodiment. DETAILED DESCRIPTION OF THE INVENTION

[0011] The following describes embodiments of the present invention, but the following embodiments do not limit the scope of the invention as claimed. Furthermore, not all of the combinations of features described in the embodiments are necessarily essential to the solution of the invention. Fig. 1 is a diagram showing an example of the configuration of a computing device according to an embodiment. In the configuration shown in Fig. 1, the computing device 100 includes a communication unit 110, a display unit 120, an operation input unit 130, a storage unit 180, and a control unit 190. The control unit 190 includes a front-end unit 210, a parent library 220, a back-end unit 230, and a child library 240. The front-end unit 210 includes an intermediate representation determination unit 211, an intermediate representation generation unit 212, an intermediate data conversion instruction generation unit 213, a source data conversion instruction generation unit 214, and a source program execution unit 215. The back-end unit 230 includes a data conversion unit 231.

[0012] The arithmetic device 100 partially converts a source program, which is a program to be executed such as a user program, into an intermediate representation and executes the converted source program. The arithmetic device 100 may also operate as a just-in-time compiler and partially convert the source program into an intermediate representation and execute the converted source program. Converting a source program into an intermediate representation is also called intermediate representation creation or intermediate representation generation. Generally, a program is not deleted when it is executed. It is also possible for the computing device 100 to leave the parts of the original source program that have been converted into an intermediate representation intact. However, the computing device 100 may also delete the parts of the original source program that have been converted into an intermediate representation. The arithmetic device 100 is configured using a computer such as a personal computer (PC).

[0013] The communication unit 110 communicates with other devices. For example, the communication unit 110 may communicate with another computer, such as a user's terminal device, to receive the source program. However, the method by which the arithmetic device 100 acquires the source program is not limited to a specific method.

[0014] The display unit 120 has a display screen such as a liquid crystal panel or an LED (Light Emitting Diode) panel, and acquires various images. For example, the display unit 120 displays data and the like in accordance with a display command in a source program. The operation input unit 130 includes input devices such as a keyboard and a mouse, and accepts user operations. For example, the operation input unit 130 may accept a user operation to instruct execution of a source program. Alternatively, the display unit 120 may display an editor screen for inputting and editing a source program, and the operation input unit 130 may accept a user operation to program the source program.

[0015] The storage unit 180 stores various types of data. For example, the storage unit 180 may store a source program acquired by the communication unit 110 or the operation input unit 130. The storage unit 180 is configured using a storage device included in the arithmetic device 100.

[0016] The control unit 190 controls each unit of the arithmetic device 100 to perform various processes. In particular, the control unit 190 executes a source program. As described above for the arithmetic device 100, the control unit 190 partially converts the source program into an intermediate representation and executes it. The functions of the control unit 190 are performed by, for example, a CPU (Central Processing Unit) included in the arithmetic device 100 reading out a program from the storage unit 180 and executing it.

[0017] The arithmetic device 100 may include an accelerator such as a GPU (Graphics Processing Unit) in addition to the CPU, and the functions of the control unit 190 may be executed using the accelerator in addition to the CPU. For example, the control unit 190 may convert a portion of the source program that can be executed by a GPU into an intermediate representation for a GPU and execute it on the GPU, and the remaining portion may be executed by the CPU when executing the source program.

[0018] The arithmetic device 100 executes both the source program and the intermediate representation using a library. Executing the intermediate representation here means executing operations and the like indicated in the intermediate representation format. In the configuration of FIG. 1, parent library 220 is an example of a library used to execute a source program, and child library 240 is an example of a library used to execute an intermediate representation.

[0019] The programming languages ​​of the parent library and the source program are not limited to any particular one, and the programming languages ​​of the child library and the intermediate representation are also not limited to any particular one. For example, the programming languages ​​of the parent library and the source program may be languages ​​that provide a relatively wide variety of operations, etc., to make it easier for users to write programs. Furthermore, the programming languages ​​of the child library and the intermediate representation may be languages ​​that provide fewer operations, etc., than the execution of the source program, but have some advantage, such as high speed execution. Furthermore, for example, the programming languages ​​of the child library and the intermediate representation may be domain-specific languages ​​(DSLs) specialized for devices that execute the intermediate representation, such as GPUs.

[0020] The front-end unit 210 converts part of the source program into an intermediate representation and causes the obtained intermediate representation to be executed by the back-end unit 230. In addition, the front-end unit 210 executes the part of the source program that is not converted into the intermediate representation by executing the source program.

[0021] The intermediate representation conversion determination unit 211 determines, for each part of the source program, whether or not to convert that part into an intermediate representation. For example, the intermediate representation conversion determination unit 211 determines, for each portion of the source program, whether that portion satisfies predetermined criteria for conversion to an intermediate representation. The intermediate representation conversion determination unit 211 determines that a portion determined to satisfy the criteria should be converted to an intermediate representation. On the other hand, the intermediate representation conversion determination unit 211 determines that a portion determined not to satisfy the criteria should be executed in the source program without being converted to an intermediate representation. The intermediate representation determination unit 211 corresponds to an example of intermediate representation determination means. The criteria for determining whether or not to convert a part of a source program into an intermediate representation are also referred to as intermediate representation conversion criteria.

[0022] The following describes an example in which the intermediate representation determination unit 211 determines, for each instruction or operation in a source program, whether or not to convert that instruction or operation into an intermediate representation. However, the unit in which the intermediate representation determination unit 211 determines whether or not to convert a portion of a source program into an intermediate representation is not limited to a specific unit such as each instruction or operation. In the following, there may be cases where no distinction is made between instructions and operations.

[0023] The intermediate representation determination criteria used by the intermediate representation determination unit 211 may include a criterion as to whether or not the instruction or operation to be determined is supported by the library used to execute the intermediate representation. For example, consider a case where the library used to execute the source program allows the use of addition, subtraction, multiplication, and division operations, while the library used to execute the intermediate representation does not allow division. In this case, the criteria for determining whether to generate an intermediate representation may include a criterion for determining whether the target is division. Based on this criterion, the intermediate representation generation determination unit 211 may determine that the division included in the source program should be executed in the source program without being converted to an intermediate representation.

[0024] The intermediate representation determination criteria used by the intermediate representation determination unit 211 may include a criterion as to whether or not the data type used in the determination target is supported by the library used to execute the intermediate representation. For example, consider a case where a library used to execute a source program can define complex number type data, but a library used to execute an intermediate representation cannot handle complex number type data. In this case, the criteria for determining whether to convert to an intermediate representation may include a criterion for whether or not the target handles complex number type data. Based on this criterion, the intermediate representation determination unit 211 may determine that the part of the source program that handles complex number type data should be executed as the source program without being converted to an intermediate representation.

[0025] Furthermore, the intermediate representation determination unit 211 determines that, among the instructions included in the source program, a predetermined instruction that is scheduled to be executed in the source program is to be executed in the source program. For example, the intermediate representation determination unit 211 determines that a display instruction (e.g., a "print" statement) included in the source program is to be executed in the source program. The intermediate representation determination criteria may include a criterion that a predetermined instruction that is scheduled to be executed in the source program is to be executed in the source program.

[0026] The intermediate representation generation unit 212 generates an intermediate representation of the part of the source program that is determined to be converted into an intermediate representation by the intermediate representation generation determination unit 211. The intermediate representation generation unit 212 corresponds to an example of intermediate representation generation means. The intermediate representation generated by the intermediate representation generation unit 212 is not executed immediately upon generation, but is executed when the need arises. Execution of the intermediate representation in this case is also called delayed execution.

[0027] For example, consider a case where a source program includes a sequence (a series of instructions) for calculating the value of a variable f and an instruction "print(f)" for displaying the value of the variable f. In this case, the intermediate representation generation unit 212 generates an intermediate representation of the sequence for calculating the value of the variable f, but the intermediate representation is not executed when the intermediate representation is generated. Then, during execution of the source program, at the timing when the instruction for displaying the value of the variable f is executed, the back-end unit 230 executes the intermediate representation of the sequence for calculating the value of the variable f using the child library 240.

[0028] Determining the value of a variable, operation, etc. is called evaluating the variable, operation, etc. The intermediate representation generation unit 212 may generate intermediate representations in a representation format that indicates the reference relationships of operations so that the intermediate representation generation unit 212 can select an intermediate representation for calculating the value to be evaluated.

[0029] Fig. 2 is a diagram showing examples of components of an intermediate representation generated by the intermediate representation generation unit 212. The components of the intermediate representation shown in Fig. 2 are also referred to as operation information. 2 shows an example of operation information generated by the intermediate representation generation unit 212 for the operation "c = mat_mul(a, b)" in the source program. "mat_mul(a, b)" is a matrix operation that multiplies matrix a by matrix b, and the operation "mat_mul" corresponds to the operation "mul" in the intermediate representation.

[0030] The information d11 is information indicating an instruction code that indicates the type of instruction. In the example of Fig. 2, the operation name "mul" is indicated as the instruction code. Information d12 indicates an input data reference, which is information indicating the reference destination of input data given to the instruction. Figure 2 shows an example where input data "a" and "b" are both calculated by calculation, and the input data references show a link to the calculation information for "a" and a link to the calculation information for "b".

[0031] A combination of an instruction code and an input data reference corresponds to an example of operation information. In the example of Fig. 2, information d10, which is a combination of information d11 and information d12, corresponds to an example of operation information of "c". In Figure 2, links are established from the operation information of "c" to the operation information of "a" and to the operation information of "b," and information that links operation information together is an example of an intermediate representation. Intermediate representations can also be expressed as sequences (instruction sequences). An intermediate representation expressed as a sequence is also called intermediate code or intermediate program.

[0032] Based on the example of FIG. 2, the intermediate representation generation unit 212 can generate intermediate code for calculating "c" that calculates "a" and "b" and then multiplies "a" and "b" to calculate "c." An instruction for multiplying "a" and "b" to calculate "c" is expressed as, for example, "%c = mul(%a, %b)." "%a" corresponds to "a" in the source program. "%b" corresponds to "b" in the source program. "%c" corresponds to "c" in the source program.

[0033] The intermediate data conversion instruction generation unit 213 determines whether or not there is any data that needs to be converted into a data representation format in the intermediate representation among the data referenced by the part of the source program that the intermediate representation determination unit 211 has decided to convert into an intermediate representation. Here, when both the parent library 220 and the child library 240 use existing libraries, there may arise a case where the data representation formats of the parent library 220 and the child library 240 differ.

[0034] Fig. 3 is a diagram showing an example of the representation format of matrix data in the parent library 220. In the example of Fig. 3, the matrix data is configured in the order of the number of rows, the number of columns, the data type, and the actual data from the top of the diagram.

[0035] Fig. 4 is a diagram showing an example of the representation format of matrix data in the child library 240. In the example of Fig. 4, the matrix data is configured in the order of data type, number of rows, number of columns, and actual data from the top of the diagram. Comparing the example of FIG. 3 with the example of FIG. 4, in FIG. 3 the number of rows and columns is followed by the data type, whereas in FIG. 4 the data type is shown first, followed by the number of rows and columns.

[0036] In this way, if the data representation formats differ between the parent library 220 and the child library 240, it is possible that the data obtained by executing the source program will not operate correctly even if it is directly applied to the intermediate representation. Therefore, the intermediate data conversion instruction generation unit 213 generates a data conversion instruction for converting the data representation format and includes it in the intermediate representation.

[0037] The intermediate data conversion instruction generation unit 213 determines whether or not there is any data that needs to be converted into the data representation format in the intermediate representation (the data representation format in the child library 240) among the data referenced when the intermediate representation is executed. If it determines that such data exists, the intermediate data conversion instruction generation unit 213 generates a conversion instruction for changing the data representation format of the data and includes it in the intermediate representation. Specifically, the intermediate data conversion instruction generation unit 213 generates a data conversion instruction for converting from the data representation format in the parent library 220 to the data representation format in the child library 240 and includes it in the intermediate representation.

[0038] For example, when matrix data in the data representation format of Figure 3 is obtained by executing a source program, the intermediate data conversion instruction generation unit 213 generates a data conversion instruction to convert that data into matrix data in the data representation format of Figure 4 and includes it in the intermediate representation. As a result, even if the source program contains data in a data representation format different from that of the child library 240, it is expected that the arithmetic device 100 will be able to execute the part of the program contained in that data in the intermediate representation.

[0039] The intermediate data conversion instruction generation unit 213 makes such determinations, creates data conversion instructions, and inserts them into the intermediate representation at any timing between the time when the intermediate representation generation unit 212 converts a portion of the source program into the intermediate representation and before the execution of "evaluation" by the source program execution unit 215. The timing when the source program execution unit 215 executes "evaluation" is the timing when the execution result of the intermediate representation is requested.

[0040] FIG. 5 is a diagram showing an example of an intermediate representation including a data conversion instruction generated by the intermediate data conversion instruction generation unit 213. FIG. 5 shows an example of an intermediate representation generated by the intermediate representation generation unit 212 for the operation "c = mat_mul(a, b)" in the source program. As in the example of FIG. 2, in the example of FIG. 5, "mat_mul(a, b)" is a matrix operation that multiplies matrix a by matrix b, and this operation "mat_mul" corresponds to the operation "mul" in the intermediate representation. Also, as in the example of FIG. 2, in the example of FIG. 5, input data "a" is calculated by an operation. On the other hand, unlike the example of FIG. 2, in the example of FIG. 5, input data "b" is actual data represented in the data representation format in the parent library 220.

[0041] 5, the intermediate data conversion instruction generator 213 generates a data conversion instruction by the operation "convert" and includes it in the intermediate representation. In the example of Fig. 5, the operation "convert" receives input of actual data "b" and converts it into data in the data representation format of the child library 240.

[0042] Fig. 6 is a diagram showing an example of intermediate code including a data conversion instruction generated by the intermediate data conversion instruction generation unit 213. In Fig. 6, the intermediate representation shown in Fig. 5 is shown in the form of a sequence (a series of instructions). In the example in Figure 6, "%a" corresponds to "a" in the source program. "%b" corresponds to "b" in the source program. "%t" indicates the execution result of "convert." In the intermediate code shown in Figure 6, after calculating "a," the actual data of "b" is converted using "convert," and then "c" is calculated by multiplying the calculated "a" by the data ("%t") obtained by data conversion of "b."

[0043] When it is necessary to convert the data representation format of data obtained as a result of executing the intermediate representation, the source-oriented data conversion instruction generator 214 generates a data conversion instruction for converting the data representation format and includes it in the intermediate representation. 3 and 4, if matrix data in the data representation format of Figure 4 is obtained by executing the intermediate representation, this data cannot be used as is for executing the source program. Therefore, the source-oriented data conversion instruction generation unit 214 generates a data conversion instruction that converts the matrix data in the data representation format of Figure 4 into matrix data in the data representation format of Figure 3, and includes this in the intermediate representation. As a result, it is expected that the matrix data in the data representation format shown in Figure 4 obtained by executing the intermediate representation will be converted into matrix data in the data representation format shown in Figure 3, and the converted data can be used to execute the source program.

[0044] The source-oriented data conversion instruction generation unit 214 determines whether any data obtained as a result of executing the intermediate representation includes data that needs to be converted into the data representation format of the source program (the data representation format of the parent library 220). If it determines that such data exists, the source-oriented data conversion instruction generation unit 214 generates a conversion instruction for the data representation format of the data and includes it in the intermediate representation. Specifically, the source-oriented data conversion instruction generation unit 214 generates a data conversion instruction for converting from the data representation format of the child library 240 to the data representation format of the parent library 220 and includes it in the intermediate representation.

[0045] The source-oriented data conversion instruction generation unit 214 makes such determinations, creates data conversion instructions, and inserts them into the intermediate representation at any timing from the time when the intermediate representation generation unit 212 converts a portion of the source program into the intermediate representation to before the source program execution unit 215 executes "evaluation." The source program execution unit 215 executes "evaluation" when the execution result of the intermediate representation is requested.

[0046] FIG. 7 is a diagram showing an example of a source program including a portion converted into an intermediate representation and a portion executed by the source program. In the example of Figure 7, "mat_add" indicates matrix addition, "mat_mul" indicates matrix multiplication, and "mat_div" indicates matrix division. Also, "a", "b", "c", and "d" are all assumed to be actual data in the data representation format of the parent library 220.

[0047] Here, it is assumed that matrix division is defined in parent library 220, whereas matrix division is not defined in child library 240. The intermediate representation determination unit 211 decides to convert "x = mat_add(a, b)" and "y = mat_mul(x, c)" into an intermediate representation and execute them, and decides to execute "z = mat_div(y, d)" in the source program (without converting it into an intermediate representation).

[0048] Fig. 8 is a diagram showing an example of intermediate code including a data conversion instruction generated by the intermediate data conversion instruction generation unit 213. Fig. 8 shows an example of intermediate code for executing "x = mat_add(a, b)" and "y = mat_mul(x, c)" from the source program shown in Fig. 7. As described above, "convert" is an operation indicating a data conversion instruction generated by the intermediate data conversion instruction generation unit 213. "add" corresponds to "mat_add" in the source program. "mul" corresponds to "mat_mul" in the source program.

[0049] "%a" corresponds to "a" in the source program. "%b" corresponds to "b" in the source program. "%c" corresponds to "c" in the source program. "%x" corresponds to "x" in the source program. "%y" corresponds to "y" in the source program. "%aa" indicates the result of executing "convert(%a)". "%bb" indicates the result of executing "convert(%b)". "%cc" indicates the result of executing "convert(%c)".

[0050] For example, the intermediate representation generation unit 212 may generate the intermediate code shown in FIG. 8 or an intermediate representation equivalent to this intermediate code in a format that uses operation information by the time the intermediate representation determination unit 211 decides to execute "z = mat_div(y, d)" in the source program.

[0051] The intermediate code shown in FIG. 8 includes a data conversion instruction for converting data in the data representation format of the parent library 220 into data in the data representation format of the child library 240, and the back-end unit 230 can execute this intermediate code. However, the matrix data resulting from the execution of the intermediate code shown in Fig. 8 is expressed in a data representation format in the child library 240, which differs from the data representation format in the parent library 220. For this reason, the execution result of the intermediate code shown in Fig. 8 cannot be used as is to execute "z = mat_div(y, d)" in the source program.

[0052] Fig. 9 is a diagram showing an example of intermediate code including a data conversion instruction generated by the source-oriented data conversion instruction generation unit 214. Fig. 9 shows an example of intermediate code in which the data conversion instruction generated by the source-oriented data conversion instruction generation unit 214 is added to the intermediate code shown in Fig. 9. 9, the source-oriented data conversion instruction generator 214 generates a data conversion instruction by the operation "rev_convert" and includes it in the intermediate representation. In the example of Fig. 9, the operation "rev_convert" converts matrix data in the data representation format of the child library 240, obtained as a result of executing the intermediate representation, into data in the data representation format of the parent library 220. This allows the execution results of the intermediate representation to be obtained in a format that can be used to execute the source program.

[0053] For example, the source-oriented data conversion instruction generation unit 214 may generate the data conversion instruction shown in FIG. 9 and include it in the intermediate representation at a timing between when the intermediate representation determination unit 211 decides to execute "z = mat_div(y, d)" in the source program and before the source program execution unit 215 executes "evaluation."

[0054] The source program execution unit 215 executes the source program as a source program (without converting it into an intermediate representation). Executing the source program as a source program without converting it into an intermediate representation by the source program execution unit 215 is also called fallback (degenerate operation). The source program execution unit 215 is an example of a source program execution means. The parent library 220 is a library that corresponds to the programming language of the source program. The source program execution unit 215 performs fallback using the parent library 220. For example, the computing device 100 accepts a source program that uses operations provided by the parent library 220. The source program execution unit 215 then executes the source program by calling the operations of the parent library 220. It is also assumed that commands that involve evaluation, such as the "print" command, are not converted into an intermediate representation but are instead defined to be executed by the source program execution unit 215 in the source program.

[0055] The intermediate representation is executed by the back-end unit 230. The intermediate representation generation unit 212 may output the intermediate representation in the form of intermediate code to the back-end unit 230, and the back-end unit 230 may execute the intermediate code. The data conversion unit 231 of the backend unit 230 executes the data conversion instructions generated by the intermediate data conversion instruction generation unit 213 and the data conversion instructions generated by the source data conversion instruction generation unit 214, out of the intermediate representation generated by the intermediate representation generation unit 212. These data conversion instructions correspond to the parts of the intermediate representation generated by the intermediate representation generation unit 212 other than the parts supported by the child library 240.

[0056] Of the intermediate representation generated by the intermediate representation generation unit 212, the part other than the data conversion instructions executed by the data conversion unit 231 is executed by the backend unit 230. In other words, of the intermediate representation generated by the intermediate representation generation unit 212, the part supported by the child library 240 is executed by the backend unit 230. The back-end unit 230 is an example of an intermediate representation execution means. The child library 240 is a library that corresponds to the programming language of the intermediate representation. The back-end unit 230 executes the portion of the intermediate representation generated by the intermediate representation generation unit 212 other than the data conversion instructions executed by the data conversion unit 231 using the child library 240. For example, the back-end unit 230 executes the operations indicated in the intermediate representation by calling the operations of the child library 240.

[0057] The combination of the front-end unit 210 and the back-end unit 230 is also referred to as an intermediate representation library. The intermediate representation library provides an execution environment for the calculations provided by the parent library 220. The intermediate representation library converts part of a source program into an intermediate representation and executes it, thereby executing the source program, for example, faster than when the parent library 220 is used.

[0058] The intermediate representation library may further have a function for optimizing the intermediate representation. For example, when the intermediate representation generation unit 212 generates an intermediate representation specialized for a specific domain such as matrix operations, the intermediate representation library may optimize the intermediate representation based on knowledge specific to that domain.

[0059] FIG. 10 is a diagram showing an example of the flow of data in the control unit 190. In the example of FIG. 10, the intermediate representation determination unit 211 acquires a source program and determines for each part of the acquired source program whether to convert it into an intermediate representation or to execute it as a source program without converting it into an intermediate representation.

[0060] For example, the intermediate representation determination unit 211 analyzes the source program in the order in which it is written, and extracts portions of the source program such as instructions or operations. Then, for each extracted portion of the source program, the intermediate representation determination unit 211 determines whether or not to convert that portion into an intermediate representation. The intermediate representation determination unit 211 outputs the part of the source program that has been determined to be converted into an intermediate representation to the intermediate representation generation unit 212. In addition, the intermediate representation determination unit 211 outputs the part of the source program that has been determined to be executed as a source program without being converted into an intermediate representation to the source program execution unit 215.

[0061] The intermediate representation generation unit 212 converts into an intermediate representation the part of the source program acquired from the intermediate representation determination unit 211. For example, the intermediate representation generation unit 212 generates operation information such as those exemplified in FIGS. 2 and 5 based on the source program acquired from the intermediate representation determination unit 211. As described above, the intermediate representation generated by the intermediate representation generation unit 212 is not executed immediately, but is executed when the need arises during the execution of the source program.

[0062] As described above, when both parent library 220 and child library 240 use existing libraries, the data representation format in parent library 220 may differ from the data representation format in child library 240. Therefore, intermediate data conversion instruction generator 213 and source data conversion instruction generator 214 each generate data conversion instructions and include them in the intermediate representation.

[0063] The source program execution unit 215 executes the part of the source program acquired from the intermediate representation determination unit 211 . As described above, the source program execution unit 215 executes the source program using the parent library 220, such as by calling the operations provided by the parent library 220.

[0064] Furthermore, the source program execution unit 215 executes commands that involve evaluation, such as a "print" command, in the source program. If it becomes necessary to execute an intermediate representation when executing a command that involves evaluation, the source program execution unit 215 presents data whose value is required to the intermediate representation generation unit 212, and requests that the intermediate representation be executed.

[0065] When the intermediate representation generation unit 212 receives an execution request for an intermediate representation from the source program execution unit 215, it selects an intermediate representation for calculating the value of the requested data. Then, the intermediate representation generation unit 212 outputs the selected intermediate representation to the back-end unit 230 in the form of intermediate code as exemplified in Fig. 6, and causes it to be executed.

[0066] The back-end unit 230 executes the intermediate representation obtained from the intermediate representation generation unit 212. Specifically, the data conversion unit 231 executes, from the intermediate representation, the data conversion instructions generated by the intermediate-directed data conversion instruction generation unit 213 and the data conversion instructions generated by the source-directed data conversion instruction generation unit 214. The back-end unit 230 executes, using the child library 240, the parts of the intermediate representation other than the data conversion instructions executed by the data conversion unit 231.

[0067] It is conceivable that the data conversion instructions generated by the intermediate data conversion instruction generation unit 213 and the data conversion instructions generated by the source data conversion instruction generation unit 214 are not included in the child library 240. Therefore, the back-end unit 230 includes a data conversion unit 231 as a functional unit that executes these data conversion instructions.

[0068] The back-end unit 230 outputs data obtained as a result of executing the intermediate representation to the source program execution unit 215. As described above, when it is necessary to convert the data representation format of the data obtained as a result of executing the intermediate result, the data conversion unit 231 converts the data representation format in accordance with a data conversion command included in the intermediate representation. Then, the back-end unit 230 outputs the data converted by the data conversion unit 231 to the source program execution unit 215.

[0069] As described above, the intermediate representation determination unit 211 determines, for each portion of the source program to be executed, whether to convert that portion into an intermediate representation or execute the program without converting it into an intermediate representation. The intermediate representation generation unit 212 generates an intermediate representation for the portion of the source program determined to be converted into an intermediate representation. The intermediate representation generation unit 212 determines whether any data obtained as a result of executing the intermediate representation needs to be converted into the data representation format of the source program, and if it determines that such data exists, generates the intermediate representation including an instruction to convert the data representation format of that data. The source program execution unit 215 instructs the execution of the intermediate representation by executing the portion of the source program determined not to be converted into an intermediate representation. The back-end unit 230 executes the intermediate representation instructed to be executed.

[0070] According to the arithmetic device 100, when a source program is partially converted into an intermediate representation and then executed, existing libraries can be used for both the execution of the source program and the execution of the converted intermediate representation, and a relatively large portion of the source program can be converted into an intermediate representation and executed.

[0071] In particular, even if the data representation format of the data obtained as a result of executing the intermediate representation cannot be used in the execution of the source program as is, the intermediate representation can be converted into a data representation format that can be used in the source program by the data conversion instructions included in the intermediate representation by the intermediate representation generation unit 212. In this respect, according to the arithmetic device 100, a relatively large portion of the source program can be converted into an intermediate representation and executed, and the execution results can be used in the execution of the source program.

[0072] In addition, the intermediate representation determination unit 211 decides to execute a part of the source program that is determined to contain data of a data type that is not supported by the child library 240, which is the library used to execute the intermediate representation, without converting it into an intermediate representation.

[0073] According to the computing device 100, when a source program is partially converted into an intermediate representation and then executed, existing libraries can be used for both the execution of the source program and the execution of the converted intermediate representation, and it is also possible to execute a source program that includes data of a data type that is not supported by the library used to execute the intermediate representation.

[0074] In addition, the intermediate representation generation unit 212 determines whether or not there is any data referenced by the part of the source program that has been decided to be converted into an intermediate representation that needs to be converted into a data representation format in the intermediate representation, and if it determines that such data exists, it generates an intermediate representation that includes a conversion instruction for the data representation format of that data.

[0075] According to the arithmetic device 100, when a source program is partially converted into an intermediate representation and then executed, existing libraries can be used for both the execution of the source program and the execution of the converted intermediate representation, and a relatively large portion of the source program can be converted into an intermediate representation and executed.

[0076] In particular, even if a portion of the source program references data in a data representation format that cannot be used in execution of the intermediate representation as is, the data representation format of that data can be converted into a data representation format that can be used in execution of the intermediate representation by the data conversion instructions included in the intermediate representation by the intermediate representation generation unit 212. In this respect, according to the computing device 100, there are relatively many portions of the source program that can be converted into an intermediate representation and executed, and the execution results can be used in execution of the source program.

[0077] In addition, the intermediate representation determination unit 211 decides to execute a part of the source program that is determined to include an operation that is not supported by the child library 240, which is the library used to execute the intermediate representation, without converting it into an intermediate representation.

[0078] According to the computing device 100, when a source program is partially converted into an intermediate representation and then executed, existing libraries can be used for both the execution of the source program and the execution of the converted intermediate representation, and it is also possible to execute a source program that includes operations that are not supported by the libraries used to execute the intermediate representation.

[0079] 11 is a diagram showing another example of the configuration of a arithmetic device according to an embodiment. In the configuration shown in Fig. 11, a arithmetic device 610 includes an intermediate representation determination unit 611, an intermediate representation generation unit 612, a source program execution unit 613, and an intermediate representation execution unit 614.

[0080] With this configuration, the intermediate representation determination unit 611 determines, for each portion of the source program to be executed, whether to convert that portion into an intermediate representation or execute the program without converting it into an intermediate representation. The intermediate representation generation unit 612 generates an intermediate representation for the portion of the source program determined to be converted into an intermediate representation. The intermediate representation generation unit 612 determines whether any data obtained as a result of executing the intermediate representation needs to be converted into the data representation format of the source program, and if it determines that such data exists, generates an intermediate representation including a conversion instruction for the data representation format of that data. The source program execution unit 613 instructs the execution of the intermediate representation by executing the portion of the source program determined not to be converted into an intermediate representation. The intermediate representation execution unit 614 executes the intermediate representation instructed to be executed.

[0081] The intermediate representation determination unit 611 corresponds to an example of an intermediate representation determination means. The intermediate representation generation unit 612 corresponds to an example of an intermediate representation generation means. The source program execution unit 613 corresponds to an example of a source program execution means. The intermediate representation execution unit 614 corresponds to an example of an intermediate representation execution means.

[0082] According to the arithmetic device 610, when a source program is partially converted into an intermediate representation and then executed, existing libraries can be used for both the execution of the source program and the execution of the converted intermediate representation, and a relatively large portion of the source program can be converted into an intermediate representation and executed.

[0083] In particular, even if the data representation format of the data obtained as a result of executing the intermediate representation cannot be used in executing the source program as is, the intermediate representation can be converted into a data representation format that can be used in executing the source program by the data conversion instructions included in the intermediate representation by the intermediate representation generation unit 612. In this respect, according to the arithmetic device 610, a relatively large portion of the source program can be converted into an intermediate representation and executed, and the execution results can be used in executing the source program.

[0084] Fig. 12 is a diagram showing an example of a processing procedure in a calculation method according to an embodiment. The calculation method shown in Fig. 12 includes determining whether to generate an intermediate representation (step S611), generating an intermediate representation (step S612), executing a source program (step S613), and executing the intermediate representation (step S614).

[0085] In determining whether to convert to an intermediate representation (step S611), the computer determines for each part of the source program, which is the program to be executed, whether to convert that part to an intermediate representation or to execute it without converting it to an intermediate representation. In generating an intermediate representation (step S612), the computer generates an intermediate representation of the part of the source program that has been decided to be converted into an intermediate representation, determines whether any of the data obtained as a result of executing the intermediate representation needs to be converted into the data representation format of the source program, and if it determines that such data exists, generates an intermediate representation that includes instructions for converting the data representation format of that data.

[0086] In executing the source program (step S613), the computer executes the part of the source program that has been determined not to be converted into an intermediate representation, thereby instructing the execution of the intermediate representation. In executing the intermediate representation (step S614), the computer executes the intermediate representation that it has been instructed to execute.

[0087] According to the calculation method shown in FIG. 12, when a source program is partially converted into an intermediate representation and then executed, existing libraries can be used for both the execution of the source program and the execution of the converted intermediate representation, and a relatively large portion of the source program can be converted into an intermediate representation and executed.

[0088] In particular, even if the data representation format of the data obtained as a result of executing the intermediate representation cannot be used in the execution of the source program as is, the data conversion instructions included in the intermediate representation can be used to convert the data into a data representation format that can be used in the execution of the source program. In this respect, according to the calculation method shown in Figure 12, a relatively large portion of the source program can be converted into an intermediate representation and executed, and the execution results can be used in the execution of the source program.

[0089] FIG. 13 is a schematic block diagram illustrating the configuration of a computer according to at least one embodiment. In the configuration shown in FIG. 13, a computer 700 includes a CPU 710 , a main memory device 720 , an auxiliary memory device 730 , an interface 740 , a non-volatile recording medium 750 , and an accelerator 760 .

[0090] One or more of the above-described arithmetic device 100 and arithmetic device 610, or a part thereof, may be implemented in a computer 700. In this case, the operation of each of the above-described processing units is stored in the auxiliary storage device 730 in the form of a program. The CPU 710 and accelerator 760 read the program from the auxiliary storage device 730, load the program into the main storage device 720, and execute the above-described processing in accordance with the program. The CPU 710 also allocates storage areas in the main storage device 720 corresponding to each of the above-described storage units in accordance with the program. Communication between each device and other devices is performed by an interface 740 having a communication function and performing communication under the control of the CPU 710.

[0091] When the arithmetic device 100 is implemented in a computer 700, the operations of the control unit 190 and each of its units are stored in the form of a program in an auxiliary storage device 730. The CPU 710 and the accelerator 760 read the program from the auxiliary storage device 730, load it into the main storage device 720, and execute the above-described processing in accordance with the program.

[0092] Furthermore, the CPU 710 allocates a storage area for the storage unit 180 in the main storage device 720 in accordance with the program. Communication between the arithmetic device 100 and other devices is performed by the interface 740, which has a communication function and operates under the control of the CPU 710. Interaction between the arithmetic device 100 and a user is performed by the interface 740, which has a display device and an input device, displaying various images under the control of the CPU 710 and accepting user operations.

[0093] When the arithmetic unit 610 is implemented in the computer 700, the operations of the intermediate representation determination unit 611, the intermediate representation generation unit 612, the source program execution unit 613, and the intermediate representation execution unit 614 are stored in the form of programs in the auxiliary storage device 730. The CPU 710 and the accelerator 760 read the programs from the auxiliary storage device 730, load them into the main storage device 720, and execute the above-mentioned processes in accordance with the programs.

[0094] Furthermore, the CPU 710 allocates a storage area in the main memory device 720 for the arithmetic device 610 to perform processing in accordance with the program. Communication between the arithmetic device 610 and other devices is performed by an interface 740 having a communication function and operating under the control of the CPU 710. Interaction between the arithmetic device 610 and a user is performed by the interface 740 having a display device and an input device, which displays various images under the control of the CPU 710 and accepts user operations.

[0095] One or more of the above-described programs may be recorded on nonvolatile recording medium 750. In this case, interface 740 may read the programs from nonvolatile recording medium 750. Then, CPU 710 and accelerator 760 may directly execute the programs read by interface 740, or may temporarily store the programs in main memory device 720 or auxiliary memory device 730 and then execute them.

[0096] Note that a program for executing all or part of the processing performed by arithmetic device 100 and arithmetic device 610 may be recorded on a computer-readable recording medium, and the program recorded on this recording medium may be read into a computer system and executed to perform the processing of each unit. Note that the term "computer system" here includes an OS (Operating System) and hardware such as peripheral devices. Furthermore, "computer-readable recording media" refers to portable media such as flexible disks, optical magnetic disks, ROMs (Read Only Memory), and CD-ROMs (Compact Disc Read Only Memory), as well as storage devices such as hard disks built into computer systems. The program may be one that realizes part of the aforementioned functions, or may be one that can realize the aforementioned functions in combination with a program already stored in the computer system.

[0097] Although an embodiment of the present invention has been described in detail above with reference to the drawings, the specific configuration is not limited to this embodiment, and includes designs within the scope of the gist of the present invention.

[0098] A part or all of the above-described embodiments can be described as, but not limited to, the following supplementary notes.

[0099] (Appendix 1) an intermediate representation determination means for determining, for each portion of a source program to be executed, whether to convert that portion into an intermediate representation or to execute that portion without converting it into an intermediate representation; an intermediate representation generation means for generating an intermediate representation of a portion of the source program that has been determined to be converted into an intermediate representation, the intermediate representation generation means determining whether or not any data obtained as a result of executing the intermediate representation needs to be converted into a data representation format in the source program, and if it determines that such data exists, generating the intermediate representation including an instruction to convert the data representation format of that data; a source program execution means for executing a part of the source program that has been determined not to be converted into an intermediate representation, thereby instructing execution of the intermediate representation; an intermediate representation execution means for executing the intermediate representation instructed to be executed; A computing device comprising:

[0100] (Appendix 2) The intermediate representation determination means determines that a portion of the source program that is determined to include data of a data type that is not supported by a library used to execute the intermediate representation is to be executed without being converted into an intermediate representation. 10. The computing device of claim 1.

[0101] (Appendix 3) the intermediate representation generation means determines whether or not there is data that needs to be converted into a data representation format in the intermediate representation among the data referenced by the part of the source program that has been decided to be converted into an intermediate representation, and if it determines that such data exists, generates the intermediate representation including an instruction to convert the data representation format of the data. 10. The computing device of claim 1 or 2.

[0102] (Appendix 4) The intermediate representation determination means determines that a portion of the source program that is determined to include an operation that is not supported by a library used to execute the intermediate representation is to be executed without being converted into an intermediate representation. 4. The computing device of claim 1.

[0103] (Appendix 5) The computer For each portion of the source program to be executed, determine whether to convert that portion into an intermediate representation or execute it without converting it into an intermediate representation; generating an intermediate representation of a portion of the source program that has been determined to be converted into an intermediate representation, determining whether or not any data obtained as a result of executing the intermediate representation needs to be converted into a data representation format in the source program, and if it is determined that such data exists, generating the intermediate representation including a conversion instruction for the data representation format of the data; instructing execution of the intermediate representation by executing a portion of the source program that has been determined not to be converted into an intermediate representation; Execute the intermediate representation that is instructed to be executed. A calculation method including:

[0104] (Appendix 6) On the computer, determining, for each portion of a source program to be executed, whether to convert that portion into an intermediate representation or to execute that portion without converting it into an intermediate representation; generating an intermediate representation of a portion of the source program that has been determined to be converted into an intermediate representation, determining whether or not any data obtained as a result of executing the intermediate representation needs to be converted into a data representation format in the source program, and if it is determined that such data exists, generating the intermediate representation including a conversion instruction for the data representation format of the data; directing execution of the intermediate representation by executing a portion of the source program that has been determined not to be converted into an intermediate representation; executing the intermediate representation that has been instructed to be executed; A recording medium that records a program for executing the program. [Industrial Applicability]

[0105] The present invention may be applied to a computing device, a computing method, and a recording medium. [Explanation of symbols]

[0106] 100, 610 arithmetic unit 110 Communications Department 120 Display section 130 Operation input section 180 Storage section 190 Control Unit 210 Front end 211, 611 Intermediate representation determination unit 212, 612 Intermediate representation generator 213 Intermediate data conversion command generation unit 214 Source-oriented data conversion instruction generator 215, 613 Source program execution unit 220 Parent Library 230 Back-end section 231 Data Conversion Unit 240 Child Libraries 614 Intermediate Representation Execution Unit

Claims

1. an intermediate representation determination means for determining, for each portion of a source program to be executed, whether to convert that portion into an intermediate representation or to execute that portion without converting it into an intermediate representation; an intermediate representation generation means for generating an intermediate representation of a portion of the source program that has been determined to be converted into an intermediate representation, the intermediate representation generation means determining whether or not any data obtained as a result of executing the intermediate representation needs to be converted into a data representation format in the source program, and if it determines that such data exists, generating the intermediate representation including an instruction to convert the data representation format of that data; a source program execution means for executing a part of the source program that has been determined not to be converted into an intermediate representation, thereby instructing execution of the intermediate representation; an intermediate representation execution means for executing the intermediate representation instructed to be executed; A computing device comprising:

2. The intermediate representation determination means determines that a portion of the source program that is determined to include data of a data type that is not supported by a library used to execute the intermediate representation is to be executed without being converted into an intermediate representation. The computing device of claim 1 .

3. the intermediate representation generation means determines whether or not there is data that needs to be converted into a data representation format in the intermediate representation among the data referenced by the part of the source program that has been decided to be converted into an intermediate representation, and if it determines that such data exists, generates the intermediate representation including an instruction to convert the data representation format of the data. The computing device of claim 1 .

4. The intermediate representation determination means determines that a portion of the source program that is determined to include an operation that is not supported by a library used to execute the intermediate representation is to be executed without being converted into an intermediate representation. The computing device of claim 1 .

5. The computer For each portion of the source program to be executed, determine whether to convert that portion into an intermediate representation or execute it without converting it into an intermediate representation; generating an intermediate representation of a portion of the source program that has been determined to be converted into an intermediate representation, determining whether or not any data obtained as a result of executing the intermediate representation needs to be converted into a data representation format in the source program, and if it is determined that such data exists, generating the intermediate representation including a conversion instruction for the data representation format of the data; instructing execution of the intermediate representation by executing a portion of the source program that has been determined not to be converted into an intermediate representation; Execute the intermediate representation that is instructed to be executed. A calculation method including:

6. On the computer, determining, for each portion of a source program to be executed, whether to convert that portion into an intermediate representation or to execute that portion without converting it into an intermediate representation; generating an intermediate representation of a portion of the source program that has been determined to be converted into an intermediate representation, determining whether or not any data obtained as a result of executing the intermediate representation needs to be converted into a data representation format in the source program, and if it is determined that such data exists, generating the intermediate representation including a conversion instruction for the data representation format of the data; directing execution of the intermediate representation by executing a portion of the source program that has been determined not to be converted into an intermediate representation; executing the intermediate representation that has been instructed to be executed; A program to execute.

Citation Information

Patent Citations

  • Execution time calculating device, execution time calculating method, and program

    JP2014099108A

  • Processing execution program, processing execution method, and information processing device

    JP2015219637A

  • Setting server, setting method, and setting program

    JP2017204213A

  • Compiling domain-specific language code to generate executable code targeting an appropriate type of processor of a network device

    US20210357194A1