CN114443046A - A graph computing method and system based on dynamic code generation - Google Patents
A graph computing method and system based on dynamic code generation Download PDFInfo
- Publication number
- CN114443046A CN114443046A CN202111610217.0A CN202111610217A CN114443046A CN 114443046 A CN114443046 A CN 114443046A CN 202111610217 A CN202111610217 A CN 202111610217A CN 114443046 A CN114443046 A CN 114443046A
- Authority
- CN
- China
- Prior art keywords
- graph
- code
- algorithm
- main body
- system based
- 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.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/44—Encoding
- G06F8/443—Optimisation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/37—Compiler construction; Parser generation
Landscapes
- Engineering & Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Devices For Executing Special Programs (AREA)
Abstract
Description
技术领域technical field
本发明涉及计算机技术领域,更具体地说,本发明涉及一种基于动态代码生成的图计算方法及系统。The present invention relates to the field of computer technology, and more particularly, the present invention relates to a graph computing method and system based on dynamic code generation.
背景技术Background technique
图计算是分析挖掘数据中关联关系的重要技术.由于图结构的非线性特点使得图算法开发难度高,同时性能较差,代码不易优化.为了能够支撑高效的图计算需求,相应的计算框架应运而生.图计算框架将图封装成统一的数据结构,并提供基础算子以辅助图算法研发。Graph computing is an important technology for analyzing and mining associations in data. Due to the nonlinear characteristics of graph structure, the development of graph algorithms is difficult, the performance is poor, and the code is not easy to optimize. In order to support the needs of efficient graph computing, the corresponding computing framework should be used. Andsheng.Graph computing framework encapsulates graphs into a unified data structure, and provides basic operators to assist the development of graph algorithms.
现有的图计算框架主要分为两类:第一类是提供固定的图算子库并使用解释型语言组合算子,实现通用的图计算操作,如graphkit;该类框架算法开发成本低,使用灵活,但性能较差;第二类是使用并发库如OpenMP或Cilk实现编译型图计算API,支撑图算法开发,如Ligra;该类框架性能较好,在一定程度上降低了图算法的开发门槛,但算法实现难度仍然很高,且代码修改困难。随着图数据的爆炸式增长,以灵活的方式实现高性能图算法成为了当前图计算领域的一大热点需求。因此,使用动态代码生成技术来开发图计算框架成为了当前一大趋势。动态代码生成是结合解释型语言与编译型语言二者优势的经典方法。用户通过交互式界面提交算法描述,对应的图计算系统即时进行编译、运行,在不损失运行效率的同时,极大地提高了图算法开发的灵活性。The existing graph computing frameworks are mainly divided into two categories: the first category is to provide a fixed graph operator library and use an interpreted language to combine operators to implement general graph computing operations, such as graphkit; this kind of framework algorithm has low development cost, Flexible use, but poor performance; the second type is to use concurrent libraries such as OpenMP or Cilk to implement compiled graph computing APIs to support graph algorithm development, such as Ligra; this type of framework has better performance and reduces the complexity of graph algorithms to a certain extent. The development threshold is high, but the algorithm implementation is still very difficult, and the code modification is difficult. With the explosive growth of graph data, implementing high-performance graph algorithms in a flexible manner has become a hot demand in the current graph computing field. Therefore, the use of dynamic code generation techniques to develop graph computing frameworks has become a major trend. Dynamic code generation is a classic way to combine the advantages of both interpreted and compiled languages. The user submits the algorithm description through the interactive interface, and the corresponding graph computing system compiles and runs in real time, which greatly improves the flexibility of graph algorithm development without losing operational efficiency.
但现有的动态代码生成的图框架依旧具有一些缺陷,如图1所示,现有的基于代码生成的图计算框架使用解释型代码开发,形成了外部代码空间,只对核心的图计算代码进行动态生成,这导致部分数据需要通过拆箱传递至本地代码空间,并通过装箱返回,增加了数据的装拆箱开销。However, the existing graph framework for dynamic code generation still has some defects. As shown in Figure 1, the existing graph computing framework based on code generation is developed using interpreted code, which forms an external code space, and only calculates the core graph code. For dynamic generation, some data needs to be passed to the local code space through unboxing and returned through boxing, which increases the overhead of data packing and unboxing.
发明内容SUMMARY OF THE INVENTION
为了克服现有技术的上述缺陷,本发明的实施例提供一种基于动态代码生成的图计算方法及系统,以解决上述背景技术中提出的问题。In order to overcome the above-mentioned defects of the prior art, the embodiments of the present invention provide a graph computing method and system based on dynamic code generation, so as to solve the problems raised in the above-mentioned background art.
为实现上述目的,本发明提供如下技术方案:To achieve the above object, the present invention provides the following technical solutions:
一种基于动态代码生成的图计算方法及系统,包括图计算框架主体,其设置在本地代码空间,所述图计算框架主体包括与外部编辑台连接的代码生成器,所述代码生成器用于接收外部编辑台输出的图算法代码并在本地代码空间中直接注入生成图算法代码,实现了使用本地语言实现图计算系统的主体。A graph computing method and system based on dynamic code generation, comprising a graph computing framework main body, which is set in a local code space, the graph computing framework main body including a code generator connected to an external editing desk, and the code generator is used for receiving The graph algorithm code output by the external editing platform is directly injected into the local code space to generate the graph algorithm code, which realizes the main body of the graph computing system using the local language.
在一个优选地实施方式中,所述图计算框架主体还包括中间图编译器、图构建模块与图缓存器;In a preferred embodiment, the graph computing framework body further includes an intermediate graph compiler, a graph building module, and a graph buffer;
所述图构建模块,用于将数据源转换成图数据,并将图数据结合基础算子代码输出至中间图编译器;The graph building module is used to convert the data source into graph data, and output the graph data in combination with the basic operator code to the intermediate graph compiler;
所述中间图编译器,用于获取图构建模块发送的代码构建对象,将该对象使用代码生成原语组装成可编译的本地代码结构,并将该结构输出至图缓存器保存;The intermediate graph compiler is used to obtain the code construction object sent by the graph construction module, assemble the object into a compilable local code structure using code generation primitives, and output the structure to the graph buffer for storage;
所述图缓存器,用于接收并保存中间图编译器输出的本地代码结构。The graph buffer is used to receive and save the native code structure output by the intermediate graph compiler.
在一个优选地实施方式中,所述图计算框架主体基于该中间图结构设置有通用的图算法开发API。In a preferred embodiment, the graph computing framework main body is provided with a general graph algorithm development API based on the intermediate graph structure.
在一个优选地实施方式中,所述编辑台提供图算法模板,包括图算法签名,基础图操作算子API与图数据访问API。In a preferred embodiment, the editing platform provides a graph algorithm template, including a graph algorithm signature, a basic graph operation operator API and a graph data access API.
在一个优选地实施方式中,所述图计算框架主体内部还包括代码执行器,In a preferred embodiment, the graph computing framework main body further includes a code executor,
所述代码执行器负责接收用户的连接请求,生成执行台;The code executor is responsible for receiving the user's connection request and generating an execution platform;
所述执行台,用于解析图算法名称,从代码执行器中读取相应的本地代码并注入,并从图缓存器中查找对应的中间图代码,结合图算法本地代码生成最终代码并执行。The execution platform is used for parsing the graph algorithm name, reading the corresponding native code from the code executor and injecting it, searching for the corresponding intermediate graph code from the graph cache, and generating the final code in combination with the graph algorithm native code and executing it.
本发明的技术效果和优点:Technical effects and advantages of the present invention:
本发明通过在本地代码空间中直接注入生成代码,消除了数据交换的开销;构建了可二次编译的中间图结构,使得图数据的访问代码可进行编译优化;同时增加了中间图结构缓存,规避了图算法的预处理开销。The invention eliminates the overhead of data exchange by directly injecting the generated code into the local code space; constructs an intermediate graph structure that can be compiled twice, so that the access code of the graph data can be compiled and optimized; at the same time, the intermediate graph structure cache is added, The preprocessing overhead of graph algorithms is avoided.
附图说明Description of drawings
图1为现有动态代码生成的图计算框架结构示意图;1 is a schematic diagram of a graph computing framework structure generated by an existing dynamic code;
图2为本发明动态代码生成的图计算框架结构示意图;2 is a schematic diagram of a graph computing framework structure generated by dynamic code of the present invention;
图3为本发明动态代码生成的图计算框架内部结构示意图;3 is a schematic diagram of the internal structure of the graph computing framework generated by the dynamic code of the present invention;
图4为本发明图计算框架预生成代码示意图;Fig. 4 is a schematic diagram of the pre-generated code of the graph computing framework of the present invention;
图5为本发明图算法服用同一图数据示意图。FIG. 5 is a schematic diagram of the graph algorithm of the present invention taking the same graph data.
具体实施方式Detailed ways
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, but not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
实施例1Example 1
本发明一种基于动态代码生成的图计算方法及系统,如图2、图3所示,包括本地代码空间和外部编辑台;所述本地代码空间包括图计算框架主体,通过将图计算框架主体由现有技术中外部代码空间转移至本地代码空间,并注入生成代码,解决了数据交换开销;所述外部编辑台提供有图算法模板,所述图计算框架主体包括与外部编辑台连接的代码生成器,用于接收外部编辑台代码并监听代码变化,在本地代码空间中直接注入生成图算法代码。实现了使用本地语言实现图计算系统的主体,将图数据以其原始的结构存储,并通过内存共享机制,传递至动态生成的代码空间,实现了数据的零拷贝,规避了数据的交换开销。A graph computing method and system based on dynamic code generation of the present invention, as shown in Figures 2 and 3, includes a local code space and an external editing platform; the local code space includes a graph computing framework body, and the graph computing framework body is The external code space in the prior art is transferred to the local code space, and the generated code is injected to solve the data exchange overhead; the external editing desk is provided with a graph algorithm template, and the graph computing framework body includes the code connected to the external editing desk The generator is used to receive external editing desk code and monitor code changes, and directly inject the generated graph algorithm code into the local code space. It realizes the main body of the graph computing system using local language, stores the graph data in its original structure, and transfers it to the dynamically generated code space through the memory sharing mechanism, realizing zero copy of data and avoiding data exchange overhead.
实施例2Example 2
作为进一步的优化改进,在上述实施例1中,我们通过将图计算框架主体由现有技术中外部代码空间转移至本地代码空间,并注入生成代码,解决了数据交换开销;在此基础上为了提供更充分地编译优化,解决了函数调用开销,如图3所示,所述图计算框架主体还包括中间图编译器、图构建模块与图缓存器;所述图构建模块用于将数据源转换成图数据,并将图数据结合基础算子代码输出至中间图编译器;所述中间图编译器获取图构建模块发送的代码构建对象,将该对象使用代码生成原语组装成可编译的本地代码结构,并将该结构输出至图缓存器保存;所述图缓存器用于接收并保存中间图编译器输出的本地代码结构。As a further optimization improvement, in the above embodiment 1, we solve the data exchange overhead by transferring the main body of the graph computing framework from the external code space in the prior art to the local code space, and injecting the generated code; Provide more sufficient compilation optimization and solve the function call overhead. As shown in Figure 3, the main body of the graph computing framework also includes an intermediate graph compiler, a graph building module and a graph buffer; the graph building module is used to convert the data source Convert the graph data into graph data, and output the graph data in combination with the basic operator code to the intermediate graph compiler; the intermediate graph compiler obtains the code construction object sent by the graph construction module, and assembles the object into a compilable code using the code generation primitives the native code structure, and output the structure to the graph buffer for saving; the graph buffer is used to receive and save the native code structure output by the intermediate graph compiler.
如图4所示,这样设置由于预编译了图的基础操作代码,形成可二次编译的中间图结构,并将其与图算法结合进行二次编译,消除了外部调用的开销。As shown in Figure 4, the basic operation code of the graph is precompiled in this way, forming an intermediate graph structure that can be recompiled, and combined with the graph algorithm for recompilation, eliminating the overhead of external calls.
如图5所示,这样设置本专利还能够通过图缓存器使得不同的图算法可以复用同一图数据,降低了算法的预处理时间。As shown in FIG. 5 , this patent also enables different graph algorithms to reuse the same graph data through the graph buffer, which reduces the preprocessing time of the algorithm.
实施例3Example 3
作为进一步的优化改进,为了提高图计算框架主体的易用性,提高用户的开发效率,所述图计算框架主体基于该中间图结构设计了通用的图算法开发API。本发明用户连接编辑台进行图算法开发,编辑台提供图算法模板,包括图算法签名,基础图操作算子API与图数据访问API,编辑台向代码生成器提交图算法。As a further optimization improvement, in order to improve the usability of the graph computing framework main body and improve the user's development efficiency, the graph computing framework main body designs a general graph algorithm development API based on the intermediate graph structure. In the present invention, the user connects to the editing platform for graph algorithm development, the editing platform provides the graph algorithm template, including the graph algorithm signature, the basic graph operation operator API and the graph data access API, and the editing platform submits the graph algorithm to the code generator.
进一步的,为了有效利用API接口,如图3所示,所述图计算框架主体内部还包括代码执行器,所述代码执行器负责接收用户的连接请求,生成执行台,用户向执行台提交图算法执行请求,执行台解析图算法名称,从代码执行器中读取相应的本地代码并注入,执行台从图缓存器中查找对应的中间图代码,结合图算法本地代码生成最终代码并执行,输出结果。Further, in order to effectively utilize the API interface, as shown in FIG. 3 , the main body of the graph computing framework also includes a code executor, and the code executor is responsible for receiving the connection request from the user, generating an execution table, and the user submits the graph to the execution table. The algorithm execution request, the execution station parses the name of the graph algorithm, reads the corresponding local code from the code executor and injects it, the execution station searches for the corresponding intermediate graph code from the graph cache, and generates the final code combined with the graph algorithm local code and executes it. Output the result.
最后应说明的几点是:首先,在本申请的描述中,需要说明的是,除非另有规定和限定,术语“安装”、“相连”、“连接”应做广义理解,可以是机械连接或电连接,也可以是两个元件内部的连通,可以是直接相连,“上”、“下”、“左”、“右”等仅用于表示相对位置关系,当被描述对象的绝对位置改变,则相对位置关系可能发生改变;The last points to be noted are: First of all, in the description of this application, it should be noted that, unless otherwise specified and limited, the terms "installation", "connection" and "connection" should be understood in a broad sense, and may be mechanical connection. or electrical connection, or internal communication between two components, or direct connection, "up", "down", "left", "right", etc. are only used to indicate relative positional relationship, when the absolute position of the object being described changes, the relative positional relationship may change;
其次:本发明公开实施例附图中,只涉及到与本公开实施例涉及到的结构,其他结构可参考通常设计,在不冲突情况下,本发明同一实施例及不同实施例可以相互组合;Secondly: in the drawings of the disclosed embodiments of the present invention, only the structures involved in the embodiments of the present disclosure are involved, other structures may refer to the general design, and the same embodiment and different embodiments of the present invention can be combined with each other under the condition of no conflict;
最后:以上所述仅为本发明的优选实施例而已,并不用于限制本发明,凡在本发明的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。Finally: the above is only the preferred embodiment of the present invention, and is not intended to limit the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the present invention. within the scope of protection.
Claims (5)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111610217.0A CN114443046A (en) | 2021-12-27 | 2021-12-27 | A graph computing method and system based on dynamic code generation |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111610217.0A CN114443046A (en) | 2021-12-27 | 2021-12-27 | A graph computing method and system based on dynamic code generation |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114443046A true CN114443046A (en) | 2022-05-06 |
Family
ID=81364727
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111610217.0A Pending CN114443046A (en) | 2021-12-27 | 2021-12-27 | A graph computing method and system based on dynamic code generation |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114443046A (en) |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US9600767B1 (en) * | 2006-10-06 | 2017-03-21 | Hrl Laboratories, Llc | System, method, and computer program product for generating a single software code based on a description of a distributed architecture |
CN110287378A (en) * | 2019-05-24 | 2019-09-27 | 中国科学院计算技术研究所 | A graph computing method and system based on dynamic code generation |
-
2021
- 2021-12-27 CN CN202111610217.0A patent/CN114443046A/en active Pending
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US9600767B1 (en) * | 2006-10-06 | 2017-03-21 | Hrl Laboratories, Llc | System, method, and computer program product for generating a single software code based on a description of a distributed architecture |
CN110287378A (en) * | 2019-05-24 | 2019-09-27 | 中国科学院计算技术研究所 | A graph computing method and system based on dynamic code generation |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
Liao et al. | Early experiences with the OpenMP accelerator model | |
Rodríguez et al. | CPPC: a compiler‐assisted tool for portable checkpointing of message‐passing applications | |
US11740881B2 (en) | Method for implementing compiled embedded Python | |
US20130205282A1 (en) | Transferring program execution from compiled code to interpreted code | |
US20140165035A1 (en) | Expansion and reduction of source code for code refactoring | |
Zhao et al. | Optimizing the memory hierarchy by compositing automatic transformations on computations and data | |
Castanos et al. | On the benefits and pitfalls of extending a statically typed language JIT compiler for dynamic scripting languages | |
CN111625317A (en) | Container cloud construction method and related device of business system | |
CN102915386A (en) | HLA (Human Leukocyte Antigen)-based Adams simulation model integrated platform and method | |
Cho et al. | Sequential reasoning for optimizing compilers under weak memory concurrency | |
CN110287378B (en) | A graph computing method and system based on dynamic code generation | |
CN109558121A (en) | Development approach, device, equipment and the storage medium of interface drive program | |
Gray et al. | Model-based hardware generation and programming-the MADES approach | |
CN114443046A (en) | A graph computing method and system based on dynamic code generation | |
CN109597611B (en) | Front-end data flow control component development system, method, device and storage medium | |
CN113934431A (en) | A quantum program compilation method, device and electronic device | |
McCormick et al. | Exploring the construction of a domain-aware toolchain for high-performance computing | |
CN106547537A (en) | One kind realizes assemblnig electric power application software method based on QML technologies | |
CN115022312B (en) | Method and device for realizing multi-intelligent contract engine, electronic equipment and storage medium | |
CN102799462B (en) | Based on the script engine device of Eclipse platform and the collocation method of Eclipse platform | |
Tao et al. | Automatically Generating High-performance Matrix Multiplication Kernels on the Latest Sunway Processor | |
CN115237419A (en) | Heterogeneous target code generation method, device and system | |
CN114418827A (en) | Performance optimization method and device of deep learning algorithm based on GPU | |
Liang et al. | An OpenMP programming environment on mobile devices | |
Franz | Beyond Java: An Infrastructure for High-Performance Mobile Code on the World Wide Web. |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |