CN103116513B - A kind of heterogeneous multi-nucleus processor compiler - Google Patents
A kind of heterogeneous multi-nucleus processor compiler Download PDFInfo
- Publication number
- CN103116513B CN103116513B CN201210243789.4A CN201210243789A CN103116513B CN 103116513 B CN103116513 B CN 103116513B CN 201210243789 A CN201210243789 A CN 201210243789A CN 103116513 B CN103116513 B CN 103116513B
- Authority
- CN
- China
- Prior art keywords
- code
- compiler
- core
- compiled
- main core
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Abstract
The invention discloses a kind of heterogeneous multi-nucleus processor compiler, comprise pretreater (101), pre-service code (107) is obtained with the merging that continues for carrying out macro expansion to source code, also comprise: program analyzer (102), data splitter (103), monokaryon compiler collection (104), data combiner (105) and main core compiler (106), described program analyzer (102) adds pragma for described pre-service code (107) and obtains code to be compiled (108), adopt the present invention that existing compiling system can be used to achieve being suitable for heterogeneous multi-nucleus processor.
Description
Technical field
The present invention relates to a kind of heterogeneous multi-nucleus processor compiler.
Background technology
Current most of processor is all polycaryon processor, and polycaryon processor is divided into isomorphism polycaryon processor and heterogeneous multi-nucleus processor according to the framework of each core or the whether identical of function.Heterogeneous multi-nucleus processor is because of its low cost, restructural, high performance feature and having a wide range of applications in embedded system and aerospace field.
Heterogeneous multi-nucleus processor usually comprise one or more perfect in shape and function main core and multiple have specific function from core.In the performance history of heterogeneous multi-nucleus processor hardware, verify and expand to have a corresponding compiling system to assist to its function.But, due to isomery and multiple core, make the design of heterogeneous polynuclear compiling system more complicated and difficult relative to the design of traditional monokaryon compiler and isomorphism multinuclear compiling system.
From the beginning existing heterogeneous polynuclear compiling system normally carries out brand-new design, and wherein some compiler has also carried out grammer expansion to conventional language.From the beginning the compiling system construction cycle that design one is such is very long, and does not have compiling system just can not carry out complete test and checking to hardware capability.Therefore, the tempo of development that heterogeneous polynuclear compiling system can have a strong impact on processor hardware is from the beginning designed.In addition, if carry out grammer expansion to conventional language, the grammer needing compiler to support these new, adds the design difficulty of compiler, and these new grammers need user to relearn use, adds the use difficulty of user.
Summary of the invention
Technology of the present invention is dealt with problems and is: for the deficiencies in the prior art, provides a kind of heterogeneous multi-nucleus processor compiler, uses existing compiling system to achieve being suitable for heterogeneous multi-nucleus processor.
Technical solution of the present invention is:
The present invention, when not changing programming language grammer, makes source code can utilize the individual single core processor adapting to heterogeneous multi-nucleus processor by processing source code, thus existing monokaryon compiler can be used to compile source code.To the heterogeneous multi-nucleus processor compiler that described source code processes, comprise pretreater, program analyzer, data splitter, monokaryon compiler collection, data combiner and main core compiler.
Described program analyzer is that described pre-service code interpolation pragma obtains code to be compiled;
Described data splitter by described code division to be compiled for being used for main core code block to be compiled and from core code block to be compiled;
The master that described monokaryon compiler collection calls described heterogeneous multi-nucleus processor checks described main core code block to be compiled and carries out compiling and obtain and main endorse run time version; Call described carry out compiling from core code block to be compiled from checking and obtain from endorsing run time version of described heterogeneous multi-nucleus processor;
Described data combiner is converted into the discernible form of described main core by described from endorsing run time version; And described master is endorsed run time version and main core is discernible merges form final pre-service code from endorsing run time version;
Described main core compiler carries out compiling to described final pre-service code and forms executable code.
Described pre-service code division is code module by described program analyzer, and according to the call relation in described code module, adds pragma and obtain described code to be compiled in described pre-service code.
The present invention compared with prior art tool has the following advantages:
The invention provides a kind of design heterogeneous polynuclear compiling system, thus it is slow to overcome heterogeneous polynuclear compiler development speed, uses the problem of difficulty.And this compiler can use all functions of each monokaryon compiler, ensure that compile efficiency.The present invention, owing to not carrying out grammer expansion to source code language used, reduces use difficulty, directly uses existing monokaryon compiler, decreases design and compilation device workload, accelerate compiler development speed, ensure that the compiler quality designed.Meanwhile, the present invention retains all functions of monokaryon compiler, can use original compile optimization function, ensure that the operational efficiency of the executable code of generation when each core code compiles respectively.Whole compiler is made up of multiple stand-alone assembly, without coupling between each several part, as improved compiler based on the design, can be easy to add or cutting compiler assembly, be convenient to carry out Function Extension.Further employing the present invention has good compatibility to each programming language, as long as the change definition of decomposing module, dependency analysis method and monokaryon compiler collection, can allow the programming language supporting other.Such as to support C Plus Plus, as long as decomposing module is defined as class sum functions, and according to characteristic of speech sounds, dependency analysis method being improved, monokaryon compiler being changed into the compiler supporting C Plus Plus.
Accompanying drawing explanation
Fig. 1 is schematic diagram of the present invention;
Fig. 2 is embodiment process flow diagram.
Embodiment
As shown in Figure 1, the present invention is made up of pretreater 101, program analyzer 102, data splitter 103, monokaryon compiler collection 104, data combiner 105 and main core compiler 106.Each assembly all processes the result that a upper assembly generates.Source code, by resolving source code, is resolved into multiple sub-blocks that monokaryon in heterogeneous multi-nucleus processor can compile by the present invention, achieves being suitable for existing single core processor compiler.
With regard to process shown in composition graphs 2, the present invention is introduced below.First pretreater 101 carries out pre-service to source code original.c, comprises and the macro expansion in source code, merging is continued and add basic pragma information, obtain pre-service code original.i107.By pre-service, reduce the difficulty of subsequent module code analysis.
Program analyzer 102 pairs of pre-service codes 107 carry out dependency analysis and add pragma information obtaining original_add.i.Corresponding pragma information to be added before each code module in pre-service code 107, to ensure to be associated with initial source code containing enough pragma information in the code module after decomposing, least unit when described code module is code decomposition, in C language, module refers to function.Program analyzer also carries out dependence (i.e. function calling relationship) analysis to the code module in source code, obtains the Dependency Specification between each code module.Program analyzer 102 marks the privately owned code module of each processor core and shared code module.Described privately owned module refer to only in the code of a core by the module used, described sharing module refers in multiple core code by the module used.For privately owned module, decomposed in the file of corresponding core during decomposition, for sharing module, be detected it and by which processor core shared, decomposed during decomposition in each core code using this sharing module.
Data splitter 103 decomposes the code that with the addition of pragma according to the Dependency Specification between each code module.In order to the code block that data splitter 103 can be allowed to identify each core, require that user's (to C language top layer function) in the top-level module that each core is corresponding uses the name of regulation here, the top layer function as main core is called main.i; Pe_0.i is respectively, pe_1.i, pe_2.i......pe_x.i from core top layer function name, etc., No. 0, correspondence is from core respectively, and No. 1 from core etc.Non-top layer functions name does not specify.So can obtain main core code block to be compiled and from core code block to be compiled.Employ regular expression during decomposition, because regular expression has superpower structure descriptive power, can analyze text accurately, development efficiency and program quality can be improved significantly.
Monokaryon compiler collection 104 contain heterogeneous multi-nucleus processor main core compiler and from core compiler.Compile main core code block to be compiled with main core compiler, error detection is only used to the object of main core code compilation, to obtain correct grammatical form.With from the compiling of core compiler from core code block to be compiled, to the compiling from core code except error detection, also its executable code to be retained.If there is multiple core architecture identical here, these cores can use same set of monokaryon compiler.
Data combiner 105 will from endorsing run time version (pe_0.bin, pe_1.bin, pe_2.bin......pe_x.bin,) convert the form that main core compiler can identify to, as its contents extraction is become array or chained list, so that main core is dispatched, afterwards data combiner 105 by after changing from endorsing run time version and main core pre-service Code synthesis is final pre-service code final.i109.
Final pre-service code 109 is compiled into the final executable code final.bin that final heterogeneous multi-nucleus processor can perform by main core compiler 106
Embodiment
For following example code, the specific embodiment of the invention is described further.
For the code in example, the Dependency Specification that program analyzer obtains following 202:
Main kernel function main () relies on function f unc1 (), func2 (), func3 ().The reason comprising func3 () is that func1 () have invoked func3 ().No matter have how many layers of nesting allocation, program analyzer 102 can obtain dependence wherein.
No. 0 depends on func2 () from kernel function pe_0 (), and func2 () is sharing module, because it is called from kernel function pe_0 () by main core and No. 0 simultaneously.Func1 () and func3 () is privately owned module, because they are only called by main kernel function main ().
When code in data splitter 103 pairs of examples decomposes, the Dependency Specification that can obtain according to program analyzer 102 analysis, decomposes source code.After decomposition, in main core code block except top-level module, also should comprise func1 (), func2 () and func3 ().No. 0 from the code block of core except top-level module, also should comprise func2 ().
The main core code block to be compiled that marks off and call corresponding core from core code block to be compiled and compile after monokaryon compiler collection 104 decomposes according to data splitter 103, thus obtain respectively and mainly endorse run time version and from endorsing run time version.
All the other main run time versions of endorsing are carried out the final pre-service code 109 of synthesis formation to from endorsing after run time version carries out format conversion by data combiner 105.
Final pre-service code 109 carries out compiling by main core compiler 106 and forms executable code.
The unspecified part of the present invention belongs to general knowledge as well known to those skilled in the art.
Claims (1)
1. a heterogeneous multi-nucleus processor compiler, comprise pretreater (101), pre-service code (107) is obtained with the merging that continues for carrying out macro expansion to source code, characterized by further comprising: program analyzer (102), data splitter (103), monokaryon compiler collection (104), data combiner (105) and main core compiler (106)
Described program analyzer (102) adds pragma for described pre-service code (107) and obtains code to be compiled (108), simultaneously program analyzer (102) also carries out dependency analysis to the code module in source code, obtains Dependency Specification between each code module and program analyzer (102) marks the privately owned code module of each processor core and shared code module; Described code to be compiled (108) is divided into for main core code block to be compiled with from core code block to be compiled by described data splitter (103);
The master that described monokaryon compiler collection (104) calls described heterogeneous multi-nucleus processor checks described main core code block to be compiled and carries out compiling and obtain and main endorse run time version; Call described carry out compiling from core code block to be compiled from checking and obtain from endorsing run time version of described heterogeneous multi-nucleus processor;
Described data combiner (105) is converted into the discernible form of described main core by described from endorsing run time version; And described master is endorsed run time version and main core is discernible merges form final pre-service code (109) from endorsing run time version;
Described main core compiler (106) is carried out compiling to described final pre-service code (109) and is formed executable code;
Described pre-service code (107) is divided into code module by described program analyzer (102), and according to the call relation in described code module, in described pre-service code (107), add pragma obtain described code to be compiled (108).
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201210243789.4A CN103116513B (en) | 2012-07-13 | 2012-07-13 | A kind of heterogeneous multi-nucleus processor compiler |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201210243789.4A CN103116513B (en) | 2012-07-13 | 2012-07-13 | A kind of heterogeneous multi-nucleus processor compiler |
Publications (2)
Publication Number | Publication Date |
---|---|
CN103116513A CN103116513A (en) | 2013-05-22 |
CN103116513B true CN103116513B (en) | 2016-03-23 |
Family
ID=48414898
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201210243789.4A Active CN103116513B (en) | 2012-07-13 | 2012-07-13 | A kind of heterogeneous multi-nucleus processor compiler |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN103116513B (en) |
Families Citing this family (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104423994B (en) | 2013-09-03 | 2018-05-11 | 华为技术有限公司 | A kind of code generating method, compiler, dispatching method, device and scheduling system |
US9710245B2 (en) * | 2014-04-04 | 2017-07-18 | Qualcomm Incorporated | Memory reference metadata for compiler optimization |
CN107851002A (en) * | 2015-08-31 | 2018-03-27 | 华为技术有限公司 | A kind of code compiling method and code encoder |
CN105426226B (en) * | 2015-11-24 | 2018-07-06 | 无锡江南计算技术研究所 | A kind of compiling of isomery code fusion and generation method |
CN107992307B (en) * | 2017-12-11 | 2021-04-13 | 北京奇虎科技有限公司 | Function compiling method and device |
CN108874727B (en) * | 2018-05-29 | 2019-09-10 | 中国人民解放军国防科技大学 | GPDSP-oriented multi-core parallel computing implementation method |
CN112445488B (en) * | 2019-09-04 | 2022-11-15 | 无锡江南计算技术研究所 | Compiling processing method and device for width asymmetric vector compatibility under heterogeneous platform |
CN113692572A (en) * | 2020-01-21 | 2021-11-23 | 深圳元戎启行科技有限公司 | Compiling method and device, computer equipment and computer readable storage medium |
CN111475152B (en) * | 2020-04-14 | 2023-03-14 | 中国人民解放军战略支援部队信息工程大学 | Code processing method and device |
Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102135904A (en) * | 2011-03-11 | 2011-07-27 | 华为技术有限公司 | Multi-core target system oriented mapping method and device |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8281295B2 (en) * | 2008-05-23 | 2012-10-02 | International Business Machines Corporation | Computer analysis and runtime coherency checking |
-
2012
- 2012-07-13 CN CN201210243789.4A patent/CN103116513B/en active Active
Patent Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102135904A (en) * | 2011-03-11 | 2011-07-27 | 华为技术有限公司 | Multi-core target system oriented mapping method and device |
Non-Patent Citations (1)
Title |
---|
面向多核处理器的并行编译及优化关键技术研究;王淼;《中国博士学位论文全文数据库》;20110415(第4期);正文第6页,第16页,第22页、附图1.4,附图2.2 * |
Also Published As
Publication number | Publication date |
---|---|
CN103116513A (en) | 2013-05-22 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN103116513B (en) | A kind of heterogeneous multi-nucleus processor compiler | |
CN101697125B (en) | Method and device for development environment conversion | |
CN110825384A (en) | ST language compiling method, system and compiler based on LLVM | |
CN107861728B (en) | Method and system for converting traditional program language into modern program language | |
CN102609451A (en) | SQL (structured query language) query plan generation method oriented to streaming data processing | |
CN103077064B (en) | A kind of parsing also executive language method and interpreting means | |
EP1918812A1 (en) | A software development system | |
JPH08202545A (en) | Object-oriented system and method for generation of target language code | |
JP2005018777A5 (en) | ||
CN102193811B (en) | Compiling device for eliminating memory access conflict and realizing method thereof | |
Hong et al. | The application guide of mixed programming between MATLAB and other programming languages | |
CN102622470A (en) | General car code conversion method | |
CN101408849A (en) | Method and system for compiling and executing TTCN-3 language | |
CN110149800A (en) | It is a kind of for handling the device of abstract syntax tree associated with the source code of source program | |
CN101604241A (en) | A kind of code generating method of embedded system | |
Narayanan et al. | ADIC2: Development of a component source transformation system for differentiating C and C++ | |
CN101344855A (en) | Control method and apparatus based on specific object in compiled tracing code | |
CN106126564A (en) | A kind of method rendered based on dynamic template language | |
Metcalf | The seven ages of fortran | |
CN104820393A (en) | Ladder diagram matrix compiling and interpreting method based on PLC | |
Larsen et al. | Tensorflow graph optimizations | |
US8117604B2 (en) | Architecture cloning for power PC processors | |
CN102541614A (en) | Code analysis-based method for automatically analyzing input-output data of calculation module | |
CN102231118A (en) | Compilation optimization method for loongson-based 3A vector memory access | |
CN106681781A (en) | Implementation method and system for real-time computing service |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant |