Program conversion device, program conversion method, and program

The program conversion device automatically converts source code to run on different computing resources, addressing the need for manual rewriting and cost in existing technologies, and supports conversion of multi-resource programs to single-resource execution.

WO2026042241A1PCT designated stage Publication Date: 2026-02-26NT T INC
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
PCT/JP2024/029904
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Filing Date
2024-08-22
Publication Date
2026-02-26

AI Technical Summary

Technical Problem

Existing technologies require significant development costs and manual rewriting of source code to run application programs on different computing resources, and cannot convert programs that simultaneously use multiple computing resources into ones that use different or additional computing resources.

Method used

A program conversion device and method that analyzes source code to identify processing content and computing resources, using a conversion method database to automatically convert the source code to run on desired computing resources, including compilation to generate executable binary code.

Benefits of technology

Enables application programs to run on different computing resources without manual rewriting, reducing development costs and facilitating conversion of programs using multiple resources to a single resource type.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure JP2024029904_26022026_PF_FP_ABST
    Figure JP2024029904_26022026_PF_FP_ABST
Patent Text Reader

Abstract

This program conversion device (1, 2) comprises: a source code analysis unit (12) that analyzes a first source code before conversion and outputs, as an analysis result, a processing content and a type of computing resource to be used; a conversion method database (13) that stores, for each processing content, a source code conversion method corresponding to a combination of the type of computing resource used by the first source code before the conversion and the type of computing resource used by a second source code after the conversion; and a source code conversion unit (14) that refers to, on the basis of the analysis result passed from the source code analysis unit (12) and the type of computing resource used by the second source code after the conversion, the conversion method database (13), and acquires and applies, for each processing content, the source code conversion method for each processing content to convert the first source code into the second source code.
Need to check novelty before this filing date? Find Prior Art

Description

Program conversion device, program conversion method, and program

[0001] The present invention relates to a program conversion device, a program conversion method, and a program.

[0002] An application program (hereinafter sometimes simply referred to as an "application") that runs on a computer is first written as source code, and executable code is generated based on that source code. Modern computers use a variety of computing resources, including CPUs, GPUs, and FPGAs. When developers develop applications, they must write source code that allows them to use specific computing resources.

[0003] 17 is a schematic diagram illustrating an example of building an application program using conventional technology. In the diagram, a computer 601 includes a CPU 641, a GPU 642, and an FPGA 643. Note that the computer 601 may include only some of the CPU 641, the GPU 642, and the FPGA 643.

[0004] The application program A 611 is an application constructed to run using the CPU 641. The application program A 611 is constructed based on the CPU source code 621. It is sufficient for the application program A 611 to have executable code generated from the CPU source code 621, and it is not necessary for the application program A 611 to have the CPU source code 621 itself. The application program B 612 is an application constructed to run using the GPU 642. The application program B 612 is constructed based on the GPU source code 622. It is sufficient for the application program B 612 to have executable code generated from the GPU source code 622, and it is not necessary for the application program B 612 to have the GPU source code 622 itself. The application program C 613 is an application constructed to run using the FPGA 643. The application program C 613 is constructed based on the FPGA source code 623. It should be noted that the application program C·613 is sufficient as long as it has executable code generated from the FPGA source code 623, and does not necessarily have to have the FPGA source code 623 itself.

[0005] Application program A 611 can run on the CPU 641. Application program A 611 cannot run on the GPU 642 or FPGA 643. Application program B 612 can run on the GPU 642. Application program A 611 cannot run on the CPU 641 or FPGA 643. Application program C 613 can run on the FPGA 643. Application program C 613 cannot run on the CPU 641 or GPU 642.

[0006] In other words, the source code of an application program basically needs to be written so that it runs using specific computing resources (such as the CPU 641, the GPU 642, or the FPGA 643).

[0007] In the prior art, there are some applications that can be processed by different computing resources.

[0008] Non-Patent Document 1 describes a technology (CUDA Toolkit) that enables the use of a GPU as a computing resource.

[0009] Non-Patent Document 2 describes a technology (OpenCL) that enables the use of GPUs and FPGAs as computing resources.

[0010] Non-Patent Document 3 describes a technology (Intel High Level Synthesis Compiler) for converting between specific programming languages. The technology described in Non-Patent Document 3 generates Register Transfer Level (RTL) code for FPGAs based on source code written in C++.

[0011] Non-Patent Document 4 describes a high-level synthesis technique that synthesizes an RTL description based on source code written in C or C++. The RTL description is a description of the behavior of a logic circuit at a level that is one level more abstract than the gate level. The RTL description is also used to design ASICs and FPGAs.

[0012] CUDA Toolkit, NVIDIA Corporation, https: / / developer.nvidia.com / cuda-toolkit, downloaded August 13, 2024. OpenCL, Khronos Group, https: / / www.khronos.org / opencl / , downloaded August 13, 2024. Intel High Level Synthesis Compiler, Intel Corporation, https: / / www.intel.com / content / www / us / en / software / programmable / quartus-prime / hls-compiler.html, downloaded August 13, 2024. Kazutoshi WAKABAYASHI, Use of High-Level Synthesis to Generate Hardware from Software: Another Alternative General-Purpose Program-Executing Mechanism to the CPU, IEICE Fundamentals Review, Vol. 6, No. 1, pp. 37-50, 2012.

[0013] The above-mentioned conventional technology has the following problem. That is, with the conventional technology, after an application program has been developed, it is not possible to process it on a type of computing resource different from the computing resource targeted by the company. In other words, with the conventional technology, in order to run an application program that has already been developed on a different computing resource, for example, to improve the performance of the application program or to avoid usage restrictions on a specific computing resource, it was necessary to redevelop the source code. As a result, a large development cost was required to run an application program on a different computing resource.

[0014] Furthermore, high-level synthesis tools based on conventional technology (e.g., Non-Patent Document 4) can convert programs in a specific programming language, but cannot accommodate changes in the language. In other words, they have low versatility.

[0015] Furthermore, in the prior art, it was not possible to convert an application program that simultaneously uses a plurality of different computing resources (for example, a GPU and an FPGA) into one that uses a different computing resource (one type of computing resource, or multiple types of computing resources different from the original combination). In other words, as an example, it was not possible to convert an application program that simultaneously uses a process written in source code for a GPU (referred to as "process 1") and a process written in source code for an FPGA (referred to as "process 2") into one that uses something other than the GPU for process 1, or to convert process 2 into one that uses something other than the FPGA.

[0016] The present invention has been made in consideration of the above circumstances, and aims to provide a program conversion device, a program conversion method, and a program that enable a developed application program to be run using computing resources different from the original target without the need to manually rewrite the source code.

[0017] An additional object of the present invention is to enable source code of an application program that simultaneously utilizes different computing resources to be converted to suit a specific type of computing resource.

[0018] [1] In order to solve the above problem, a program conversion device according to one aspect of the present invention includes: a source code analysis unit that reads first source code before conversion of an application program, analyzes the first source code, and outputs, as analysis results, the processing content of the first source code and the type of computing resource used by the first source code; a conversion method database that stores, for each of the processing content, a source code conversion method for the processing content corresponding to a combination of the type of computing resource used by the first source code before conversion and the type of computing resource used by the second source code after conversion; and a source code conversion unit that refers to the conversion method database based on the processing content of the first source code, the type of computing resource used by the first source code, and the type of computing resource used by the second source code after conversion, which are passed from the source code analysis unit, to obtain, for each of the processing content, a source code conversion method for the processing content, and applies the obtained conversion method for each of the processing content to convert the first source code to the second source code.

[0019] [2] In one aspect, the program conversion device according to [1] above further comprises a source code compiling unit that generates binary code by compiling the second source code.

[0020] [3] Also, in one aspect, in the program conversion device of [1] or [2] above, the source code analysis unit identifies the programming language of the first source code and outputs the programming language as the analysis result, the conversion method database stores the conversion method for each processing content and each programming language, and the source code conversion unit acquires the source code conversion method for each processing content by referring to the conversion method database based on the programming language passed from the source code analysis unit, and converts the first source code to the second source code by applying the conversion method acquired for each processing content.

[0021] [4] In one aspect, in the program conversion device according to any one of [1] to [3] above, the type of the computing resource can be identified by a combination of the name and model number of the computing resource.

[0022] [5] Also, in one aspect, in the program conversion device of any of [1] to [4] above, the first source code includes a plurality of partial source codes that each use a plurality of types of computing resources, and the source code analysis unit outputs, for each of the partial source codes, the type of computing resource used by the first source code as an analysis result, and the source code conversion unit refers to the conversion method database for each of the partial source codes to obtain a source code conversion method for each processing content, and converts the first source code to the second source code by applying the conversion method obtained for each processing content, and the second source code after conversion uses one or more types of computing resources, and for at least one of the plurality of partial source codes included in the first source code, the type of computing resource used by the first source code for that partial source code is different from the type of computing resource used by the second source code corresponding to that partial source code.

[0023] [6] Also, one aspect is a program conversion method in which a source code analysis unit reads a first source code of an application program before conversion, analyzes the first source code, and outputs a processing content of the first source code and a type of computing resource used by the first source code as an analysis result; a conversion method database stores, for each processing content, a source code conversion method for the processing content corresponding to a combination of a type of computing resource used by the first source code before conversion and a type of computing resource used by the second source code after conversion; a source code conversion unit refers to the conversion method database based on the processing content of the first source code, the type of computing resource used by the first source code, and the type of computing resource used by the second source code after conversion, which are passed from the source code analysis unit, to obtain a source code conversion method for the processing content for each processing content, and applies the obtained conversion method for each processing content to convert the first source code to the second source code.

[0024] [7] Another aspect is a program for causing a computer to function as the program conversion device of [1] above. Another aspect is a computer-readable recording medium having recorded thereon such a program.

[0025] According to the present invention, the source code conversion unit can automatically convert the first source code into the second source code using an appropriate conversion method based on the processing content of the first source code, the type of computing resource used by the first source code, and the type of computing resource (requested computing resource) used by the second source code after conversion.

[0026] FIG. 1 is a block diagram showing a schematic functional configuration of a program conversion device according to a first embodiment of the present invention. FIG. 1 is a schematic diagram showing an example of a pattern of source code conversion according to the first embodiment (where the source code before conversion uses one type of computing resource). FIG. 2 is a schematic diagram showing another example of a pattern of source code conversion according to the first embodiment (where the source code before conversion uses one type of computing resource). FIG. 3 is a schematic diagram showing an example of a pattern of requests accepted by the program conversion device according to the first embodiment. FIG. 4 is a schematic diagram showing an example of an analysis result by a source code analysis unit according to the first embodiment. FIG. 5 is a schematic diagram showing an example of information held by a conversion method database according to the first embodiment. FIG. 6 is a schematic diagram showing an example of a pattern of source code conversion according to the first embodiment (where the source code before conversion uses multiple types of computing resources and the source code before conversion uses one type of computing resource). FIG. 7 is a schematic diagram showing an example of a pattern of requests accepted by the program conversion device according to the first embodiment, corresponding to the conversion process of FIG. 7. FIG. 8 is a schematic diagram showing another example of a pattern of source code conversion according to the first embodiment (where the source code before conversion uses multiple types of computing resources and the source code before conversion uses one type of computing resource). 11 is a schematic diagram showing an example of a pattern of requests accepted by the program conversion device in the first embodiment, corresponding to the conversion process of FIG. 9. FIG. 12 is a schematic diagram showing an example of a pattern of source code conversion in the first embodiment (multiple types of computing resources used by the source code before conversion, and multiple types of computing resources used by the source code before conversion). FIG. 13 is a schematic diagram showing an example of a pattern of requests accepted by the program conversion device in the first embodiment, corresponding to the conversion process of FIG. 12. FIG. 14 is a schematic diagram showing another example of a pattern of source code conversion in the first embodiment (multiple types of computing resources used by the source code before conversion, and multiple types of computing resources used by the source code before conversion). FIG. 15 is a schematic diagram showing an example of a pattern of requests accepted by the program conversion device in the first embodiment, corresponding to the conversion process of FIG. 13.It is a block diagram showing an example of an internal configuration when the program conversion device according to the first embodiment is realized by a computer and a program. It is a block diagram showing a schematic functional configuration of each device in the second embodiment. It is a schematic diagram for explaining an example of a method for constructing an application program according to the prior art.

[0027] Next, several embodiments of the present invention will be described with reference to the drawings. The present embodiments provide a technology for running an application program on a computing resource of a different type than the original target computing resource, even after the application program has been developed. The present embodiments perform automatic conversion of source code.

[0028] Generally, when developing source code that realizes an application program, the source code is written in a format that corresponds to the specific computing resource so that it can be used. As mentioned above, conventional technology has a problem in that rewriting the source code to enable the use of a computing resource different from the original target requires a large development cost. In contrast, in this embodiment, the source code portions to be processed by the specific computing resource are identified by source code analysis, and a source code conversion method is determined based on the source code analysis results. In this way, the source code is converted so that it can be processed by the requested type of computing resource.

[0029] This embodiment automatically converts source code so that it can be processed using the requested type of computing resource. This eliminates the need for significant development costs for rewriting source code. It also makes it possible to convert source code to match requests, even for application programs that simultaneously use different computing resources.

[0030] That is, this embodiment automatically generates an application program that can be executed on hardware different from the hardware assumed by the original (pre-conversion) source code.

[0031] First Embodiment FIG. 1 is a block diagram showing a schematic functional configuration of a program conversion device according to this embodiment. As shown in the figure, the program conversion device 1 includes a source code storage unit 11, a source code analysis unit 12, a conversion method database 13, a source code conversion unit 14, a source code storage unit 15, a source code compilation unit 16, and a binary code storage unit 17. As will be described later, the program conversion device 1 can be realized, for example, by using a general-purpose computer. Furthermore, at least some of the functions of the program conversion device 1 may be realized by dedicated electronic circuits. Furthermore, the program conversion device 1 has a function for storing information. The function for storing information can be realized, for example, by using a magnetic hard disk drive, a semiconductor memory, or the like.

[0032] 1, the execution computer 31 includes a CPU 41. The execution computer 32 includes a GPU 42. The execution computer 33 includes an FPGA 43. CPU stands for "Central Processing Unit." GPU stands for "Graphics Processing Unit." FPGA stands for "Field Programmable Gate Array."

[0033] The source code storage unit 11 stores the source code before conversion. The source code stored in the source code storage unit 11 is the source code to be converted by the program conversion apparatus 1.

[0034] The source code analysis unit 12 analyzes the source code read from the source code storage unit 11. Specifically, the source code analysis unit 12 receives a request for a computing resource to be used and analyzes the source code to enable the computing resource to be used. That is, the source code analysis unit 12 analyzes the structure of the read source code and performs analysis to enable the source code to use the desired computing resource. As part of the analysis of the source code, the source code analysis unit 12 identifies a portion of the source code to be processed by a specific computing resource. This portion to be processed by the specific computing resource is identified as a portion to be converted by the source code conversion unit 14 below. The source code analysis unit 12 passes the results of the analysis to the source code conversion unit 14. Alternatively, the source code analysis unit 12 may pass the source code to be analyzed to the source code conversion unit 14.

[0035] That is, the source code analysis unit 12 reads the source code of the application program before conversion (for convenience, this will be referred to as the "first source code") and analyzes the first source code, thereby outputting the processing content of the first source code and the type of computing resource used by the first source code as analysis results. Note that the source code analysis unit 12 may identify the type of programming language in which the first source code is written (e.g., C language, C++ language, etc.) and output information on the type of programming language as analysis results.

[0036] The conversion method database 13 is a database that stores source code conversion methods. That is, the conversion method database 13 stores the description content of the source code to be converted, the required computing resources (computing resources to be used after conversion), and the specific conversion method in association with each other.

[0037] The conversion method database 13 stores (holds) a source code conversion method for each processing content, corresponding to a combination of the type of computing resource used by the first source code before conversion and the type of computing resource used by the converted source code (which may be conveniently referred to as the "second source code"). Note that the conversion method database 13 may store a conversion method for each processing content and for each programming language. An example of the configuration of the data stored in the conversion method database 13 will be described later with reference to another figure.

[0038] The source code conversion unit 14 converts the source code before conversion read from the source code storage unit 11 by referring to the information stored in the conversion method database 13. The source code converted by the source code conversion unit 14 is source code for using the desired computing resource. The source code conversion unit 14 writes the source code resulting from the conversion into the source code storage unit 15.

[0039] The source code conversion unit 14 refers to the conversion method database 13 based on the processing content of the first source code, the type of computing resource used by the first source code, and the type of computing resource used by the converted second source code, all of which are passed from the source code analysis unit 12. The source code conversion unit 14 then obtains a source code conversion method for each processing content from the conversion method database 13. The source code conversion unit 14 then converts the first source code to the second source code by applying the conversion method obtained for each processing content. The source code conversion unit 14 may also obtain a source code conversion method for each processing content by referring to the conversion method database 13 based on information on the type of programming language passed from the source code analysis unit 12, and convert the first source code to the second source code by applying the conversion method obtained for each processing content.

[0040] The source code storage unit 15 stores the source code converted by the source code conversion unit 14 .

[0041] The source code compiling unit 16 reads the source code converted by the source code converting unit 14 from the source code storage unit 15 and compiles the source code. The compiling process itself is a process using existing technology. The source code compiling unit 16 writes the binary code resulting from the compilation into the binary code storage unit 17. In other words, the source code compiling unit 16 generates the binary code by compiling the second source code.

[0042] After the source code compiling unit 16 has performed the compilation process, a linkage editor (linkage editing program) may perform linkage editing. The linkage editor is omitted from the configuration shown in Fig. 1. When linkage editing is performed, the linkage editor links multiple program modules to generate an executable program.

[0043] Regardless of whether a linkage editor is present or not, executable binary code is written to the binary code storage unit 17 .

[0044] The binary code storage unit 17 stores binary code that is the result of compilation processing performed by the source code compilation unit 16 (or may be the result of linkage editing processing performed by a linkage editor). In other words, the binary code storage unit 17 stores binary code that can be executed on a predetermined computing resource.

[0045] With the above configuration, the program conversion apparatus 1 converts a source program and generates executable binary code based on the converted source program. The binary program written to the binary code storage unit 17 can be loaded and executed on an appropriate computer, such as the execution computer 31, 32, or 33. That is, if the source code conversion unit 14 converts the original source code into source code for the CPU 41, the executable binary code stored in the binary code storage unit 17 can be executed by the CPU 41 of the execution computer 31. If the source code conversion unit 14 converts the original source code into source code for the GPU 42, the executable binary code stored in the binary code storage unit 17 can be executed by the GPU 42 of the execution computer 32. If the source code conversion unit 14 converts the original source code into source code for the FPGA 43, the executable binary code stored in the binary code storage unit 17 can be executed by the FPGA 43 of the execution computer 33. Furthermore, when the source code conversion unit 14 converts the original source code into source code for use with other computing resources, the executable binary code stored in the binary code storage unit 17 can be executed on an execution computer equipped with that computing resource.

[0046] Next, a detailed example of the process of analyzing and converting source code will be described. The example described in Figures 2, 3, 4, 5, and 6 converts an application program that uses a single type of computing resource (CPU, GPU, FPGA, etc.) to a different type of computing resource.

[0047] 2 is a schematic diagram showing an example of a source code conversion pattern. In the figure, a CPU source code storage unit 101 corresponds to the source code storage unit 11 in FIG. 1 . Furthermore, an FPGA source code storage unit 102 corresponds to the source code storage unit 15 in FIG. 1 . That is, the CPU source code storage unit 101 stores CPU source code before conversion. Furthermore, the FPGA source code storage unit 102 stores FPGA source code after conversion. That is, in the example shown in FIG. 2 , the source code conversion unit 14 reads the CPU source code from the CPU source code storage unit 101, automatically performs conversion processing, and writes the FPGA source code obtained as a result of the conversion into the FPGA source code storage unit 102.

[0048] 3 is a schematic diagram showing another example of a source code conversion pattern. In the diagram, the GPU source code storage unit 103 corresponds to the source code storage unit 11 in FIG. 1 . The CPU source code storage unit 104 corresponds to the source code storage unit 15 in FIG. 1 . That is, the GPU source code storage unit 103 stores the GPU source code before conversion. The CPU source code storage unit 104 stores the CPU source code after conversion. That is, in the example shown in FIG. 3 , the source code conversion unit 14 reads the GPU source code from the GPU source code storage unit 103, automatically performs conversion processing, and writes the CPU source code obtained as a result of the conversion to the CPU source code storage unit 104.

[0049] In addition to the examples shown in Figures 2 and 3, the source code conversion unit 14 automatically converts source code written for use with a specific type of computing resource into source code written for use with a different type of computing resource.

[0050] 4 is a schematic diagram showing an example of a request pattern accepted by the source code analysis unit 12. In the figure, a request is information identifying an individual request (request 1, request 2, etc.). An application source code (before conversion) is source code before conversion associated with an individual request. In other words, this source code is source code stored in the source code storage unit 11. A computing resource (conversion destination) is a computing resource that is desired to be used after conversion.

[0051] In the example shown in FIG. 4, request 1 is a request to convert source code 1 for use with a GPU with model number "123." Request 2 is a request to convert source code 2 for use with an FPGA with model number "987." Note that the model numbers of the GPU, FPGA, etc., are information for identifying specific models (types) of computing devices. The source code analysis unit 12 can accept one request such as the one shown here.

[0052] In other words, the type of the computing resource may be identified by a combination of the name and model number of the computing resource.

[0053] In the example of the request shown in Fig. 4, when specifying the computing resource to be used by the converted source code, information including a model number such as "GPU (model number: 123)" is specified, but the model number information is not necessarily required. If the computing resource can be specified without the model number information, the model number is not necessary.

[0054] FIG. 5 is a schematic diagram illustrating an example of an analysis result by the source code analysis unit 12. In FIG. 5, "source code" represents the source code analyzed by the source code analysis unit 12. For example, "source code 1" is the source code associated with request 1 in FIG. 4. Source code 2 is the source code associated with request 2 in FIG. 4. The "programming language" in FIG. 5 is information indicating the programming language in which each source code is written. That is, source code 1 is written in C, and source code 2 is written in C++. The source code analysis unit 12 can identify the programming language by, for example, determining the grammatical rules of the programming language in which given source code is written. The "processing content" in FIG. 5 is information indicating the processing content described in each source code. The source code analysis unit 12 analyzes the processing content and its configuration described in the source code by using static source code analysis techniques such as syntax analysis. The source code analysis unit 12 can also identify the type of library module called in each processing content. For example, information such as the fact that, among the processing contents shown in FIG. 5, processing content 1 calls library module A, processing content 2 calls library module B, and so on, is extracted from the source code. The processing content configuration in FIG. 5 is information that represents the information represented by the processing contents, for example, in a tree structure. Furthermore, the source code analysis unit 12 can identify the computing resources used by the source code before conversion based on the combination of the programming language and the library module. In the example shown in FIG. 5, source code 1 before conversion uses a CPU as a computing resource. Furthermore, source code 2 before conversion uses a CPU as a computing resource.

[0055] In other words, as illustrated in FIG. 5 , the source code analysis unit 12 analyzes each source code to extract information such as the programming language in which the source code is written, the processing content of the source code, the type of library module called by the source code, and the type of computing resource (CPU, GPU, FPGA, etc.) used by the source code. The processing content includes, for example, specific numerical calculation processing, specific image processing, etc. Examples of numerical calculation processing include calculating the product of matrices and calculating the inverse matrix. Examples of image processing include image compression processing, noise removal processing, and image recognition processing.

[0056] FIG. 6 is a schematic diagram showing an example of information held by the conversion method database 13. As shown in the figure, the conversion method database 13 holds data representing the interrelationships between the processing content expressed by the source code (column A), the programming language used to write the source code (column B), the computing resources used by the source code before conversion (column C), and the conversion methods for each computing resource that the converted source code will use (columns D, E, F, ...). In this example, the conversion method database 13 holds information on conversion methods for source code intended for GPUs in column D and information on conversion methods for source code intended for FPGAs in column E. The conversion method database 13 may also hold information on conversion methods for source code intended for other computing resources in columns F and after. Note that the format of the table shown in FIG. 6 is merely an example, and the conversion method database 13 may hold information equivalent to the table shown in FIG. 6 in a different representation format.

[0057] The table shown in FIG. 6 contains the following information. Rows 1 to 3 store information related to "Processing Content 1" as the processing content. Row 1 contains information for the case where the programming language used is C and the computing resource used by the source code before conversion is a CPU. Column D of row 1 contains information on a conversion method for converting such source code into source code for a GPU. Column E of row 1 contains information for converting such source code into source code for an FPGA. Columns F and subsequent columns of row 1 may also contain information for converting such source code into source code for other computing resources. Row 2 contains information for the case where the programming language used is C++ and the computing resource used by the source code before conversion is a GPU. Column D of row 2 is a storage location for information on a conversion method for converting such source code into source code for a GPU. However, if there is no case where source code for a GPU is converted into source code for a GPU, the information in column D of row 2 may be null. Furthermore, column E of the second row contains information for converting such source code into source code for FPGAs. Columns F and onward of the second row may also contain information for converting such source code into source code for other computing resources. Note that when the processing content is "processing content 1," the conversion method database 13 may further contain information (here, row 3) about combinations of programming languages ​​other than those mentioned above (column B) and pre-conversion computing resources (column C).

[0058] The fourth row of the table shown in Figure 6 contains information about "Processing Content 2" as the processing content. The fourth row holds information for the case where the programming language used is C and the computing resource used by the source code before conversion is a CPU. Column D of the fourth row holds information about a conversion method for converting such source code into source code for a GPU. Column E of the fourth row holds information for converting such source code into source code for an FPGA. Columns F and onward of the fourth row may also hold information for converting such source code into source code for other computing resources.

[0059] The fifth and subsequent rows of the table shown in FIG. 6 may further include information about processing contents other than "processing contents 1" and "processing contents 2."

[0060] The analysis result of the original source code shown in Figure 5 includes the programming language used, the processing content (which may be multiple processing content, and information on the relationships between them may be held in a tree structure, etc.), and information on the computing resources used by the source code before conversion. The request information shown in Figure 4 also includes information on the computing resources to be used after conversion. The source code conversion unit 14 compares this provided information with the table in the conversion method database 13, an example of which is shown in Figure 6, to obtain information on the conversion method corresponding to the desired computing resources. The source code conversion unit 14 then converts the source code using the conversion method information obtained from the conversion method database 13, and writes the converted source code to the source code storage unit 15.

[0061] Specific examples of conversion methods shown in FIG. 6 are as follows: The conversion method stored in column D of the first row of the table is to convert source code using the library conversion method when the GPU model number used by the converted source code is "456." The conversion method stored in column E of the first row is to convert source code using library conversion or language conversion 1 to convert source code for FPGAs when the FPGA model number used by the converted source code is "987." The conversion method stored in column E of the second row is to convert source code using library conversion or language conversion 2 to convert source code for FPGAs when the FPGA model number used by the converted source code is "555." The conversion method stored in column D of the fourth row is to convert source code using language conversion 3 to convert source code when the GPU model number used by the converted source code is "678." The conversion method stored in the fourth row, column E is to convert the source code using the language conversion 1 method.

[0062] In the above example of the conversion method, "library conversion" refers to changing the type of library being called. For example, in the Python language, there are two libraries for numerical calculations: NumPy, which is for CPUs, and CuPy, which is for GPUs. The numerical calculations performed by these two libraries are identical. In other words, by changing the library being called, it is possible to change the computing resources being used. Also, in the example of the conversion method, "language conversion 1," "language conversion 2," and "language conversion 3" refer to converting the text of source code between different programming languages ​​based on a predetermined pattern. For example, source code written in C can be converted to C++ source code through language conversion.

[0063] As described above, the conversion method database 13 holds information on an appropriate conversion method according to the processing content, the programming language used by the source code, the type of computing resource used before the conversion, and the type of computing resource to be used after the conversion. The source code conversion unit 14 obtains information on an appropriate conversion method by referring to the conversion method database 13, and converts the source code by applying that conversion method.

[0064] Next, another example of the process of analyzing and converting source code will be described. In the example described with reference to Figures 7, 8, 9, and 10, the source code of an application program that uses multiple types of computing resources is converted into source code that uses a single type of computing resource.

[0065] FIG. 7 is a schematic diagram showing an example of a source code conversion pattern. In the diagram, the CPU source code storage unit 105 and the GPU source code storage unit 106 each correspond to a part of the source code storage unit 11 in FIG. 1 . The FPGA source code storage unit 107 corresponds to the source code storage unit 15 in FIG. 1 . That is, the CPU source code storage unit 105 and the GPU source code storage unit 106 each store source code before conversion. The FPGA source code storage unit 107 stores converted source code for FPGAs. That is, in the example shown in FIG. 7 , the source code conversion unit 14 reads source code from the CPU source code storage unit 105 and the GPU source code storage unit 106, automatically performs conversion processing, and writes the FPGA source code obtained as a result of conversion to the FPGA source code storage unit 107.

[0066] FIG. 8 is a schematic diagram showing an example of a request pattern accepted by the source code analysis unit 12. The request shown in FIG. 8 corresponds to the conversion process described in FIG. 7. In other words, request 3 shown in FIG. 8 requests that pre-conversion source code 3 be converted into source code that uses an FPGA as a computing resource (conversion destination), and that pre-conversion source code 4 be converted into source code that uses an FPGA as a computing resource (conversion destination). Note that source code 3 is source code stored in the CPU source code storage unit 105 in FIG. 7. Source code 4 is source code stored in the GPU source code storage unit 106 in FIG. 7.

[0067] Upon receiving request 3 shown in FIG. 8 , the source code analysis unit 12 reads and analyzes source code 3 and source code 4. The analysis results are passed to the source code conversion unit 14. The source code conversion unit 14 converts the source code based on the request content, the analysis result information passed from the source code analysis unit 12, and the conversion method information obtained by referring to the conversion method database 13. The source code conversion unit 14 writes the converted source code to the source code storage unit 15. The converted source code uses an FPGA as a computing resource. The source code compilation unit 16 reads the converted source code from the source code storage unit 15 and performs compilation and other necessary processes. The source code compilation unit 16 writes executable binary code to the binary code storage unit 17. The binary code created here is passed to an execution computer and executed by the FPGA included in that computer.

[0068] FIG. 9 is a schematic diagram illustrating another example of a source code conversion pattern. In the diagram, the GPU-oriented source code storage unit 108 and the FPGA-oriented source code storage unit 109 each correspond to a part of the source code storage unit 11 in FIG. 1 . The GPU-oriented source code storage unit 110 corresponds to the source code storage unit 15 in FIG. 1 . That is, the GPU-oriented source code storage unit 108 and the FPGA-oriented source code storage unit 109 each store source code before conversion. The GPU-oriented source code storage unit 110 stores converted GPU-oriented source code. In other words, in the example shown in FIG. 9 , the source code conversion unit 14 reads source code from the GPU-oriented source code storage unit 108 and the FPGA-oriented source code storage unit 109, automatically performs conversion processing, and writes the GPU-oriented source code obtained as a result of conversion to the GPU-oriented source code storage unit 110.

[0069] FIG. 10 is a schematic diagram showing an example of a request pattern accepted by the source code analysis unit 12. The request shown in FIG. 10 corresponds to the conversion process described in FIG. 9. In other words, request 4 shown in FIG. 10 requests that pre-conversion source code 5 be converted into source code that uses an FPGA as a computing resource (conversion destination), and that pre-conversion source code 6 be converted into source code that uses an FPGA as a computing resource (conversion destination). Note that source code 5 is source code stored in the GPU-oriented source code storage unit 108 in FIG. 7. Source code 6 is source code stored in the FPGA-oriented source code storage unit 109 in FIG. 7.

[0070] In this example, both the source code 5 stored in the GPU-oriented source code storage unit 108 and the converted source code are source codes for using a GPU. Therefore, if there is no particular need to convert the source code 5, the source code conversion unit 14 may include the source code 5 as is in the converted source code without changing it.

[0071] Upon receiving request 4 shown in FIG. 10 , the source code analysis unit 12 reads and analyzes source code 5 and source code 6. The analysis results are passed to the source code conversion unit 14. The source code conversion unit 14 converts the source code based on the request content, the analysis result information passed from the source code analysis unit 12, and conversion method information obtained by referring to the conversion method database 13. The source code conversion unit 14 writes the converted source code to the source code storage unit 15. The converted source code utilizes a GPU as a computing resource. The source code compilation unit 16 reads the converted source code from the source code storage unit 15 and performs compilation and other necessary processes. The source code compilation unit 16 writes executable binary code to the binary code storage unit 17. The binary code created here is passed to an execution computer and executed by the GPU included in that computer.

[0072] That is, as described with reference to Figures 7, 8, 9, and 10, the source code before conversion (first source code) may include multiple partial source code segments that each use multiple types of computing resources. In this case, an application program written in the source code before conversion may be processed simultaneously and in parallel by multiple different types of computing resources. In this case, the source code analysis unit 12 outputs, for each partial source code segment, the type of computing resource used by the first source code as an analysis result. Then, the source code conversion unit 14 may refer to the conversion method database 13 for each partial source code segment to obtain a source code conversion method for each processing content, and convert the first source code into the second source code by applying the obtained conversion method for each processing content. In this case, the second source code after conversion uses only one type of computing resource. For at least one of the plurality of partial source codes included in the first source code, the type of computing resource used by the first source code for that partial source code may be different from the type of computing resource used by the second source code corresponding to that partial source code.

[0073] Next, another example of the process of analyzing and converting source code will be described. In this example, which will be described with reference to Figures 11, 12, 13, and 14, the source code of an application program that uses multiple types of computing resources is converted into source code that uses multiple different types of computing resources.

[0074] 11 is a schematic diagram showing an example of a source code conversion pattern. In the diagram, a CPU-oriented source code storage unit 111 and a GPU-oriented source code storage unit 112 each correspond to a part of the source code storage unit 11 in FIG. 1. Furthermore, an FPGA-oriented source code storage unit 113 and a CPU-oriented source code storage unit 114 each correspond to a part of the source code storage unit 15 in FIG. 1. In other words, the CPU-oriented source code storage unit 111 and the GPU-oriented source code storage unit 112 each store source code before conversion. Furthermore, the FPGA-oriented source code storage unit 113 and the CPU-oriented source code storage unit 114 each store source code after conversion. That is, in the example shown in FIG. 11 , the source code conversion unit 14 reads source code from each of the CPU source code storage unit 111 and the GPU source code storage unit 112, automatically performs conversion processing, and writes the source code obtained as the conversion result into the FPGA source code storage unit 113 and the CPU source code storage unit 114, respectively.

[0075] FIG. 12 is a schematic diagram showing an example of a request pattern accepted by the source code analysis unit 12. The request shown in FIG. 12 corresponds to the conversion process described in FIG. 11. In other words, request 5 shown in FIG. 12 requests that pre-conversion source code 7 be converted into source code that uses an FPGA as a computing resource (conversion destination), and that pre-conversion source code 8 be converted into source code that uses a CPU as a computing resource (conversion destination). Note that source code 7 is source code stored in the CPU-oriented source code storage unit 111 in FIG. 11. Source code 8 is source code stored in the GPU-oriented source code storage unit 112 in FIG. 11.

[0076] Upon receiving request 5 illustrated in FIG. 12 , the source code analysis unit 12 reads and analyzes source code 7 and source code 8. The analysis results are passed to the source code conversion unit 14. The source code conversion unit 14 converts the source code based on the request content, information on the analysis results passed from the source code analysis unit 12, and information on the conversion method obtained by referring to the conversion method database 13. The source code conversion unit 14 writes the converted source code to the source code storage unit 15. That is, the source code conversion unit 14 converts source code 7 read from the CPU source code storage unit 111 into FPGA-oriented source code, and writes the converted source code into the FPGA source code storage unit 113. The source code conversion unit 14 also converts source code 8 read from the GPU source code storage unit 112 into CPU-oriented source code, and writes the converted source code into the CPU source code storage unit 114. The source code compiling unit 16 reads each converted source code from the source code storage unit 15 and performs compilation and other necessary processes. The source code compiling unit 16 writes executable binary code to the binary code storage unit 17. The binary code created here is passed to an execution computer and executed. In other words, the binary code created based on the source code for FPGA obtained as a result of the conversion is executed by the FPGA. Also, the binary code created based on the source code for CPU obtained as a result of the conversion is executed by the CPU.

[0077] 13 is a schematic diagram showing an example of a source code conversion pattern. In the diagram, the GPU source code storage unit 115 and the FPGA source code storage unit 116 each correspond to a part of the source code storage unit 11 in FIG. 1. Also, the CPU source code storage unit 117 and the GPU source code storage unit 118 each correspond to a part of the source code storage unit 15 in FIG. 1. In other words, the GPU source code storage unit 115 and the FPGA source code storage unit 116 each store source code before conversion. Also, the CPU source code storage unit 117 and the GPU source code storage unit 118 each store source code after conversion. That is, in the example shown in FIG. 13, source code is read from each of the GPU source code storage unit 115 and the FPGA source code storage unit 116, and conversion processing is automatically performed. The source code obtained as a result of the conversion is written to the CPU source code storage unit 117 and the GPU source code storage unit 118, respectively.

[0078] FIG. 14 is a schematic diagram showing an example of a request pattern accepted by the source code analysis unit 12. The request shown in FIG. 14 corresponds to the conversion process described in FIG. 13. In other words, request 6 shown in FIG. 14 requests that pre-conversion source code 9 be converted into source code that uses a CPU as a computing resource (conversion destination), and that pre-conversion source code 10 be converted into source code that uses a GPU as a computing resource (conversion destination). Note that source code 9 is source code stored in the GPU-oriented source code storage unit 115 in FIG. 13. Source code 10 is source code stored in the FPGA-oriented source code storage unit 116 in FIG. 13.

[0079] Upon receiving request 5 illustrated in FIG. 14 , the source code analysis unit 12 reads and analyzes source code 9 and source code 10. The analysis results are passed to the source code conversion unit 14. The source code conversion unit 14 converts the source code based on the request content, information on the analysis results passed from the source code analysis unit 12, and information on the conversion method obtained by referring to the conversion method database 13. The source code conversion unit 14 writes the converted source code to the source code storage unit 15. That is, the source code conversion unit 14 converts source code 9 read from the GPU-oriented source code storage unit 115 into a source code for the CPU, and writes the resulting CPU source code into the CPU-oriented source code storage unit 117. The source code conversion unit 14 also converts source code 10 read from the FPGA-oriented source code storage unit 116 into a source code for the GPU, and writes the resulting GPU source code into the GPU-oriented source code storage unit 118. The source code compiling unit 16 reads each converted source code from the source code storage unit 15 and performs compilation and other necessary processes. The source code compiling unit 16 writes executable binary code to the binary code storage unit 17. The binary code created here is passed to an execution computer and executed. In other words, the binary code created based on the source code for the CPU obtained as a result of the conversion is executed by the CPU. Also, the binary code created based on the source code for the GPU obtained as a result of the conversion is executed by the GPU.

[0080] That is, as described with reference to Figures 11, 12, 13, and 14, the source code before conversion (first source code) may include multiple partial source code segments that each utilize multiple types of computing resources. In this case, an application program written in the source code before conversion may be processed simultaneously and in parallel by multiple different types of computing resources. In this case, the source code analysis unit 12 outputs, for each partial source code segment, the type of computing resource utilized by the first source code as an analysis result. The source code conversion unit 14 may then refer to the conversion method database 13 for each partial source code segment to obtain a source code conversion method for each processing content, and apply the obtained conversion method to convert the first source code into the second source code. In this case, the second source code after conversion utilizes multiple types of computing resources. For at least one of the plurality of partial source codes included in the first source code, the type of computing resource used by the first source code for that partial source code may be different from the type of computing resource used by the second source code corresponding to that partial source code.

[0081] [Implementation by Computer and Program] The program conversion apparatus 1 can also be implemented by a computer and a program. The program can also be recorded on a recording medium or provided via a network.

[0082] FIG. 15 is a block diagram showing an example of the internal configuration of the program conversion apparatus 1 of the first embodiment when implemented by a computer. As shown in the figure, the computer includes a CPU 901, a RAM 902, an input / output port 903, input / output devices 904 and 905, and a bus 906. The computer itself can be implemented using existing technology. The CPU 901 executes instructions included in a program read from the RAM 902 or the like. The CPU 901 writes data to the RAM 902, reads data from the RAM 902, and performs arithmetic and logical operations in accordance with the instructions. The RAM 902 stores data and programs. Each element included in the RAM 902 has an address and can be accessed using the address. RAM is an abbreviation for "random access memory." The input / output port 903 is a port through which the CPU 901 exchanges data with external input / output devices. The input / output devices 904 and 905 exchange data with the CPU 901 via the input / output port 903. The bus 906 is a common communication path used within the computer. For example, the CPU 901 reads and writes data from and to the RAM 902 via the bus 906. The CPU 901 also accesses the input / output port 903 via the bus 906.

[0083] At least some of the functions of the program conversion device 1 of the first embodiment can be realized by a computer and a program. In this case, the functions can be realized by recording a program for realizing the functions on a computer-readable recording medium and loading and executing the program recorded on the recording medium into a computer system. Note that the term "computer system" here includes hardware such as an OS and peripheral devices. Furthermore, "computer-readable recording medium" refers to portable media such as flexible disks, optical magnetic disks, ROMs, CD-ROMs, DVD-ROMs, and USB memory, as well as storage devices such as hard disks built into computer systems. In other words, a "computer-readable recording medium" may be a non-transitory computer-readable recording medium. Furthermore, the term "computer-readable recording medium" may also include media that temporarily and dynamically store programs, such as communication lines used when transmitting programs over networks like the Internet or over communication lines like telephone lines, or media that store programs for a certain period of time, such as volatile memory within the computer systems that serve as the server or client in such cases. The program may also be designed to realize some of the functions described above, or may be capable of realizing the functions described above in combination with a program already stored in the computer system.

[0084] Second Embodiment Next, a second embodiment of the present invention will be described. Note that the description of the matters already described in the previous embodiment may be omitted. Here, the description will focus on matters unique to this embodiment.

[0085] 16 is a block diagram showing the schematic functional configuration of each device in this embodiment. As shown in the figure, the program conversion device 2 includes a source code storage unit 11, a source code analysis unit 12, a conversion method database 13, a source code conversion unit 14, and a source code storage unit 15. The binary code generation device 3 includes a source code compilation unit 16 and a binary code storage unit 17.

[0086] In this embodiment, the functions of the source code storage unit 11, source code analysis unit 12, conversion method database 13, source code conversion unit 14, source code storage unit 15, source code compilation unit 16, and binary code storage unit 17 are the same as those described in the first embodiment. In this embodiment, the program conversion device 2 does not have the source code compilation unit 16 or the binary code storage unit 17. In other words, the program conversion device 2 only converts pre-conversion source code into converted source code. In this embodiment, the process of generating executable binary code based on the converted source code is performed by the binary code generation device 3.

[0087] In this embodiment, the source code resulting from the conversion by the program conversion device 2 becomes the basis for executable binary code generated by the binary code generation device 3. The converted application binary code can be loaded into any one of the execution computers 31, 32, and 33, which has appropriate computing resources, and executed on that computing resource.

[0088] The program conversion device 2 and the binary code generation device 3 in this embodiment can be realized using a computer and a program. The method for realizing the device using a computer and a program is as described in the previous embodiment.

[0089] As described above, according to any of the embodiments, source code can be automatically converted so that it can be processed on a new target computing resource. Furthermore, binary code can be generated using the converted source code. The binary code can be executed on a computer having the target computing resource (e.g., a CPU, a GPU, an FPGA, etc.). In other words, it becomes possible to run an application program on a computing resource different from the originally targeted computing resource without requiring significant development effort.

[0090] Although several embodiments of the present invention have been described in detail above with reference to the drawings, the specific configurations are not limited to these embodiments, and designs within the scope of the present invention that do not deviate from the gist of the present invention are also included.

[0091] The present invention can be used, for example, in the development or porting of application programs, etc. However, the scope of application of the present invention is not limited to the examples given here.

[0092] 1 Program conversion device 2 Program conversion device 3 Binary code generation device 11 Source code storage unit 11 Source code storage unit 12 Source code analysis unit 12 Source code analysis unit 13 Conversion method database 13 Conversion method database 14 Source code conversion unit 15 Source code storage unit 16 Source code compilation unit 17 Binary code storage unit 31, 32, 33 Execution computer 41 CPU 42 GPU 43 FPGA 101 Source code storage unit for CPU 102 Source code storage unit for FPGA 103 Source code storage unit for GPU 104 Source code storage unit for CPU 105 Source code storage unit for CPU 106 Source code storage unit for GPU 107 Source code storage unit for FPGA 108 Source code storage unit for GPU 109 Source code storage unit for FPGA 110 GPU source code storage unit 111 CPU source code storage unit 112 GPU source code storage unit 113 FPGA source code storage unit 114 CPU source code storage unit 115 GPU source code storage unit 116 FPGA source code storage unit 117 CPU source code storage unit 118 GPU source code storage unit 901 CPU (Central Processing Unit) 902 RAM 903 Input / output ports 904, 905 Input / output devices 906 Bus

Claims

1. A program conversion device comprising: a source code analysis unit that reads first source code before conversion of an application program, analyzes the first source code, and outputs the processing content of the first source code and the type of computing resource used by the first source code as analysis results; a conversion method database that stores, for each of the processing content, a source code conversion method for the processing content corresponding to a combination of the type of computing resource used by the first source code before conversion and the type of computing resource used by the second source code after conversion; and a source code conversion unit that refers to the conversion method database based on the processing content of the first source code, the type of computing resource used by the first source code, and the type of computing resource used by the second source code after conversion, which are passed from the source code analysis unit, to obtain a source code conversion method for each of the processing content, and applies the obtained conversion method for each of the processing content to convert the first source code to the second source code.

2. The program conversion device according to claim 1, further comprising: a source code compiling unit that generates binary code by compiling the second source code.

3. The program conversion device according to claim 1, wherein the source code analysis unit identifies the programming language of the first source code and outputs the programming language as the analysis result; the conversion method database stores the conversion method for each processing content and each programming language; and the source code conversion unit obtains a source code conversion method for each processing content by referring to the conversion method database based on the programming language passed from the source code analysis unit, and converts the first source code into the second source code by applying the conversion method obtained for each processing content.

4. The program conversion device according to claim 1, wherein the type of the computing resource can be identified by a combination of the name and model number of the computing resource.

5. The program conversion device described in claim 1, wherein: the first source code includes a plurality of partial source codes each using a plurality of types of computing resources; the source code analysis unit outputs, for each of the partial source codes, the type of computing resource used by the first source code as an analysis result; the source code conversion unit, for each of the partial source codes, refers to the conversion method database to obtain a source code conversion method for each processing content, and converts the first source code to the second source code by applying the conversion method obtained for each processing content; the second source code after conversion uses one or more types of computing resources; and for at least one of the plurality of partial source codes included in the first source code, the type of computing resource used by the first source code for that partial source code is different from the type of computing resource used by the second source code corresponding to that partial source code.

6. A program conversion method in which a source code analysis unit reads a first source code of an application program before conversion, analyzes the first source code, and outputs the processing content of the first source code and the type of computing resource used by the first source code as analysis results; a conversion method database stores, for each processing content, a source code conversion method for the processing content corresponding to a combination of the type of computing resource used by the first source code before conversion and the type of computing resource used by the second source code after conversion; a source code conversion unit obtains a source code conversion method for each processing content by referring to the conversion method database based on the processing content of the first source code, the type of computing resource used by the first source code, and the type of computing resource used by the second source code after conversion, which are passed from the source code analysis unit, and applies the conversion method obtained for each processing content to convert the first source code to the second source code.

7. A program for causing a computer to function as the program conversion device according to claim 1.

Citation Information

Patent Citations

  • Setting server, setting method, and setting program

    JP2017204213A

  • Conversion program and conversion processing method

    JP2023180315A