Query answering method and computer device adapted to heterogeneous computing architecture

By obtaining the conjunctive query statement in the database system and calculating the node merging cost, the flexible use of heterogeneous processors and improved query efficiency are achieved, which solves the problem in the existing technology that heterogeneous equipment needs to be reconfigured due to changes in heterogeneous equipment, and improves the efficiency of heterogeneous computing. Resource utilization and query efficiency.

CN118113720BActive Publication Date: 2024-09-03BERGMEIS (SHENZHEN) TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410166035.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-02-06
Publication Date
2024-09-03
Estimated Expiration
2044-02-06

AI Technical Summary

Technical Problem

It is difficult for existing database systems to flexibly use heterogeneous processors in heterogeneous computing architectures, resulting in low resource utilization and insufficient hardware scalability. They cannot instantly improve query performance without reconfiguring or compiling the system when heterogeneous devices change.

Method used

By obtaining the conjunctive query statement, the initial node set is constructed, and the merge cost is calculated atomically based on the comparison between nodes, and the node with the smallest merge cost is selected for merge processing until there is only one node left, and its data view is output, thereby realizing the data view node The numerical operation process uses appropriate programming models to compile and adapt to heterogeneous processors.

Benefits of technology

It improves the flexibility and efficiency of heterogeneous processors in answering database queries, avoids reconfiguration and compilation when heterogeneous devices change, and achieves elastic expansion of heterogeneous computing resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118113720B
    Figure CN118113720B
Patent Text Reader

Abstract

The present application provides a query answering method and computer device adapted to a heterogeneous computing architecture, the method comprising: forming an initial node set according to the atoms of a conjunction query statement, and when the initial node set includes at least two initial nodes, calculating the merging cost of each two initial nodes, selecting two initial nodes with the smallest merging cost for merging each time, until the initial node set includes only one node, and then outputting the data view of the only node; the merging operations of the initial nodes in the above process are all converted into numerical calculation processes based on vector sorting and matrix construction, so that the heterogeneous programming model can be used to encode and call suitable heterogeneous processors, thereby improving the flexibility of using heterogeneous processors in database query answering.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of database technology, and in particular to a query answering method and computer device adapted to a heterogeneous computing architecture. Background Art

[0002] With the rapid development of big data, cloud computing, artificial intelligence, the Internet of Things, and the development and popularization of the 5G strategy, big data is becoming a new driving force for economic and social development, which also puts higher requirements on new infrastructure. New infrastructure must collect, store, process and analyze data at extremely high speeds. Heterogeneous architecture has efficient computing resources and storage resources and has become the mainstream mode of new infrastructure. As the core software of infrastructure, database systems carry massive amounts of data. However, database systems with heterogeneous architecture as deployment units cannot give full play to the performance advantages of heterogeneous architecture because all storage and computing resources need to be managed and scheduled by the CPU (Central Processing Unit). There are disadvantages such as low resource utilization and insufficient hardware scalability.

[0003] The current heterogeneous computing architecture is mainly composed of CPU coprocessors, CPU+many-core processors, and CPU+FPGA (Field Programmable Gate Array). Among them, in the heterogeneous computing architecture of CPU+GPU (Graphics Processing Unit), the GPU and CPU are connected and work together through the PCle (Peripheral Component Interconnect Express, a high-speed serial computer expansion bus standard) bus. The location of the CPU is called the host, and the location of the GPU is called the device. At present, some database vendors have made certain progress in heterogeneous computing. For example, Huawei Cloud Database uses GPU acceleration technology, which can provide higher query performance and faster data analysis capabilities. In addition, Huawei has also developed its own AI processor Ascend, which can be used to accelerate machine learning and data mining tasks in the database. Alibaba Cloud Max Compute is a big data processing platform based on GPU acceleration, which can provide high-performance and low-cost data processing services. Tencent Cloud CDP (Cloud Database Platform) offloads time-consuming database calculation processes to the GPU, thereby reducing CPU pressure.

[0004] However, although the above-mentioned database vendors have made certain progress in heterogeneous computing, they are limited to using fixed heterogeneous devices to perform specific data processing and are unable to elastically expand for different heterogeneous resources. When heterogeneous devices change, manual reconfiguration or even redesign and compilation of the system is still required. Existing database systems still cannot flexibly use heterogeneous processors to improve query performance. Summary of the invention

[0005] The present application is adapted to a query answering method and a computer device for a heterogeneous computing architecture to solve the technical problem that heterogeneous processors have low flexibility in using in database query answering.

[0006] In a first aspect, a query answering method adapted to a heterogeneous computing architecture is provided, which is applied to a computer device, wherein the computer device adopts a heterogeneous computing architecture, and the method comprises: obtaining a conjunction query statement to be answered, and forming an initial node set according to each atom in the conjunction query statement; judging whether the initial node set includes at least two initial nodes; if the initial node set includes only one initial node, taking the only initial node as a target node, and outputting a data view of the target node; if the initial node set includes at least two initial nodes, judging whether there are cross-node comparison atoms between at least two of the initial nodes, wherein the cross-node comparison atom refers to that two variable parameters of the comparison atom appear in the basic atoms of the two initial nodes respectively; if If the cross-node comparison atom exists between at least two of the initial nodes, a first merge cost of each two initial nodes is calculated, and two initial nodes with the smallest first merge cost are selected for merging to obtain a first intermediate node; if the cross-node comparison atom does not exist between any two initial nodes, a second merge cost of each two initial nodes is calculated, and two initial nodes with the smallest second merge cost are selected for merging to obtain a second intermediate node; the initial node set is updated based on the first intermediate node or the second intermediate node; the step of judging whether the initial node set includes at least two initial nodes is returned to execute until the initial node set includes only one node, and the only node is used as the target node, and the data view of the target node is output.

[0007] In a second aspect, a computer device is provided, which adopts a heterogeneous computing architecture and includes a memory and a processor. The memory is connected to the processor, and the processor is used to execute one or more computer programs stored in the memory. When the processor executes the one or more computer programs, the computer device implements the method described in the first aspect.

[0008] The present application can achieve the following technical effects: the computer device can obtain the conjunction query statement to be answered, form an initial node set according to each atom of the conjunction query statement, and when the initial node set includes at least two initial nodes, calculate the merging cost of each two initial nodes, and select the two initial nodes with the smallest merging cost for merging each time, until the initial node set includes only one node, and then output the data view of the only node, thereby realizing the conversion of the conjunction query answering process into the numerical operation process of the data view node. Since the conjunction query answering actually uses numerical operation, when the heterogeneous processor of the computer device changes, it is no longer necessary to reconfigure or redesign and compile the system, so as to apply the appropriate programming model code to call the appropriate heterogeneous processor, so as to improve the flexibility of the heterogeneous processor in the database query answering. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] Figure 1 A schematic diagram of a scenario of a database conjunction query provided in an embodiment of the present application;

[0010] Figure 2 A query example of a conjunction query answering process provided in an embodiment of the present application;

[0011] Figure 3 A flowchart of a query answering method adapted to a heterogeneous computing architecture provided in an embodiment of the present application;

[0012] Figure 4 A schematic diagram of the structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0013] In order to make the purpose, technical solutions and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.

[0014] It should be noted that, if there is no conflict, the various features in the embodiments of the present application can be combined with each other, all within the scope of protection of the present application. In addition, although the functional modules are divided in the device schematic diagram and the logical order is shown in the flow chart, in some cases, the steps shown or described can be performed in a different order from the module division in the device or the flow chart. Furthermore, the words "first", "second", "third", etc. used in this application do not limit the data and execution order, but only distinguish the same items or similar items with basically the same functions and effects.

[0015] In order to make it easier to understand this application, the existing heterogeneous computing architecture is first introduced. Heterogeneous computing architecture refers to a computer device that contains multiple different types of computing units at the same time, which are usually CPU, GPU, FPGA, etc. Among them, in the heterogeneous computing architecture of CPU+GPU, the GPU and CPU can work together through the PCle bus connection. The location of the CPU is called the host, and the location of the GPU is called the device. The heterogeneous computing platform based on CPU+GPU can complement each other's advantages. The CPU is responsible for processing logically complex serial programs, while the GPU focuses on processing data-intensive parallel computing programs, thereby maximizing its effectiveness.

[0016] MIT (Massachusetts Institute of Technology) has made groundbreaking achievements in using GPU to accelerate database data processing. Its open source GPU database and analysis platform MapD has excellent performance in spatiotemporal data management. In terms of using new hardware technologies to improve database system performance, software vendors Oracle and SAP have respectively launched database all-in-one solutions. Oracle's EXADATA and SAP's HANA all-in-one both use new hardware technologies such as persistent memory, flash memory, and high-speed RDMA (Remote Direct Memory Access) networks, but have not made technical innovations in integrating new hardware such as GPU and FPGA for performance improvement. Domestic database vendors have made some progress in heterogeneous computing. For example, Huawei Cloud Database uses GPU acceleration technology to provide higher query performance and faster data analysis capabilities. In addition, Huawei has also developed its own AI processor Ascend, which can be used to accelerate machine learning and data mining tasks in databases. Alibaba Cloud MaxCompute is a big data processing platform based on GPU acceleration that can provide high-performance and low-cost data processing services. Tencent Cloud CDP (Cloud Database Platform) offloads time-consuming database calculation processes to the GPU, thereby reducing CPU pressure. However, although these industrial database vendors have made some progress in heterogeneous computing, they are limited to using fixed heterogeneous devices to perform specific data processing and are unable to elastically expand for different heterogeneous resources. When heterogeneous devices change, manual reconfiguration or even redesign and recompilation of the system is required.

[0017] In response to the above technical problems, the present application focuses on the data query answering process of the database, and proposes a query answering method and computer device adapted to heterogeneous computing architecture. The basic idea of ​​the present application is to form an initial node set according to the conjunction query statement after obtaining the conjunction query statement to be answered, and determine whether the initial node set includes at least two initial nodes. If it does, the first merge cost of each two initial nodes is calculated when there are cross-node comparison atoms between the at least two initial nodes, and the two initial nodes with the smallest first merge cost are selected for merge processing to obtain a first intermediate node. When there are no cross-node comparison atoms between the at least two initial nodes, the second merge cost of each two initial nodes is calculated, and the two initial nodes with the smallest second merge cost are selected for merge processing to obtain a second intermediate node. Then, the initial node set is updated based on the first intermediate node or the second intermediate node, and the merge processing operation is continued until the initial node set includes only one node, and the data view of the only node is output. This application converts the database's conjunctive query answering process into a numerical calculation process for the data view node merging sequence, so that a suitable programming model, such as the SYCL (Single-source heterogeneous programming for OpenCL) programming model, can be used to compile the conjunctive query answering process into machine code that is suitable for multiple heterogeneous processors in the current machine, such as CPU or GPU, through the compiler of the programming model, effectively improving the flexibility of using heterogeneous processors in database query answering and improving the answering efficiency of conjunctive queries. If the heterogeneous processor of the current machine changes, there is no need to recompile or even manually reconfigure the database system, realizing a database heterogeneous computing resource elastic expansion mechanism.

[0018] It should be noted that the conjunction query involved in this application is a commonly used query method in database technology. The conjunction query is composed of basic atoms and comparison atoms through conjunction connectors. The conjunction query is the core component of SQL (Standard Query Language for Relational Databases) and SPARQL (Standard Query Language for Graph Databases), and can express the SELECT clause and WHERE clause in SQL and SPARQL.

[0019] As an optional implementation, the present application can also be based on a suitable programming model, write the overall process of obtaining the query answer set in the final node into a CPU-controlled program code, and compile the program code into an executable program that supports multiple heterogeneous processors through the compiler of the programming model. When the executable program is running, it can select a suitable heterogeneous processor according to the hardware facilities of the current computer device to perform the merging processing of the initial node, and feedback the query answer set after running.

[0020] See below Figure 1 , is a scenario diagram of a database conjunction query provided by the present application. The database conjunction query mainly includes a query answering process and a compilation execution mechanism, wherein the query answering process can be executed by a computer device, and the query answering process includes:

[0021] S101, obtaining a conjunction query statement to be answered, and performing an initialization operation to obtain an initial node set.

[0022] In this step, it is assumed that the conjunction query to be answered is It indicates that, represents the basic atom, is a list of variables (corresponding to the data view P i Field set), c j (x j ,t j )(j=1,...,m) represents the comparison atom, c i It can be one of the six comparison operators: =, >, <, ≥, ≤, ≠. i is a variable, t i is a constant or a variable, is a list of answer variables, and ∧ is a conjunction symbol. The initialization operation can be to convert each basic atom and The conjunction of the covered comparison atoms is taken as the initial node to form the initial node set, and each initial node corresponds to a data view. The comparison atom covered is the comparison atom c j (x j ,t j ) are all variables in Appeared in.

[0023] S102: Determine whether there is only one node in the initial node set.

[0024] In this step, if the judgment is yes, the following step S103 is executed, and if the judgment is no, the following step S104 is executed.

[0025] S103: If yes, output the data view corresponding to the node.

[0026] In this step, if the judgment is yes, it means that there is only one node left in the initial node set, and the node must correspond to the data view of the query answer. The data view corresponding to the node can be output and the current process ends, that is, the following steps S104 to S107 are no longer executed.

[0027] S104: If not, determine whether there are at least two initial nodes with cross-node comparison atomic constraints in the initial node set.

[0028] It should be noted that the at least two initial nodes with cross-node comparison atom constraints refer to the existence of a comparison atom between at least two initial nodes, and the two variable parameters of the comparison atom appear in the basic atoms of the two initial nodes respectively. In this step, if the judgment is yes, step S105 is executed; if the judgment is no, step S106 is executed.

[0029] S105 , if yes, then merge the two initial nodes with the smallest first merge cost to obtain a first intermediate node.

[0030] In this step, if the judgment is yes, it means that there are at least two initial nodes with comparison atomic constraints in the current initial node set. Then, the total cost of merging the two initial nodes with comparison atomic constraints can be calculated for any two initial nodes. The total cost is the first merge cost, and then the two initial nodes with the smallest first merge cost are selected for merging to obtain the first intermediate node.

[0031] For example, suppose that for the initial node R(u1,…,u r ) and S(v1,…,v s ), R(u1,…,u r ) and S(v1,…,v s ) between the form c(u i ,v j ) comparison atom, then R(u1,…,u r ) and S(v1,…,v s ) based on c(u i ,v j ) is defined as (|R|+|S|)log2(|R|+|S|)+α|R||S|, where |R| and |S| represent the total number of records in R and S respectively, and α is a manually set trade-off parameter between 0 and 1, reflecting the cost ratio of the construction of the merged result set and the sorting of the merged columns; further, R(u1,…,u r ) and S(v1,…,v s ) is defined as k((|R|+|S|)log2(|R|+|S|)+α|R||S|), called the first merge cost, where k is the total cost of all the input queries of the form c k (u i ,v j Then, two initial nodes with the smallest first merge cost are selected for merging to obtain the first intermediate node.

[0032] S106: If not, merge the two initial nodes with the smallest second merging cost to obtain a second intermediate node.

[0033] In this step, if the judgment is no, it means that any two initial nodes in the current initial node set have no comparison atomic constraints. Then, for any two initial nodes, the total cost of merging the any two initial nodes can be calculated. The total cost is the second merge cost. Then, the two initial nodes with the smallest second merge cost are selected for merging to obtain the intermediate node.

[0034] For example, suppose we select the initial node R(u1,…,u r ) and S(v1,…,v s ) Calculate the second merge cost, which can be defined as |R||S|, called the second merge cost. Calculate the second merge cost of any two initial nodes in the initial node set, and then select the two initial nodes with the minimum second merge cost to merge and obtain the second intermediate node.

[0035] S107: Update the initial node set based on the first intermediate node (or the second intermediate node), and return to execute step S102.

[0036] For example, suppose the first intermediate node (or the second intermediate node) is represented by T(u1,…,u r ,v1,…,v s ) indicates that the two initial nodes of the intermediate node are merged into R(u1,…,u r ) and S(v1,…,v s ), updating the initial node set based on the first intermediate node (or the second intermediate node) may include: updating R(u1,…,u r ) and S(v1,…,v s ) and replace T(u1,…,u r ,v1,…,v s ) is added to the initial node set as a new initial node, and the column variables in the data view of the new initial node that are not query answer variables and do not appear in unused comparison atoms are deleted.

[0037] As a feasible implementation, after the initial node set is updated, the step S102 may be returned to be executed until it is determined through the step S102 that only one node is left in the initial node set, and after the step S103 is executed, the query answering process ends.

[0038] See below Figure 2, which is a query example of the above-mentioned conjunction query answering process. The first block diagram shows the input conjunction query statement, which is Q(v1,v2,v3)←P1(u1,v1,)∧P2(u2,u3,v2)∧P3(u4,v3)∧u1=u2∧u3≤u4∧v3≠c. The conjunction query statement is obtained by combining the basic atoms and the comparison atoms covered by them to obtain the initial nodes, forming an initial node set as shown in the second block diagram. The initial node set includes three initial nodes, namely P1(u1,v1,), P2(u2,u3,v2), and P3(u4,v3)∧v3≠c; the computer device determines the above three If there are at least two initial nodes with comparison atomic constraints, the first merge cost of the initial nodes is calculated. The third block diagram shows the merging process of the two nodes P1(u1,v1) and P2(u2,u3,v2) with the smallest first merge cost. After this merger, there are two remaining nodes Q1(v1,u3,v2) and P3(u4,v3); the fourth block diagram shows the merging process of the remaining two nodes Q1(v1,u3,v2) and P3(u4,v3), and finally there is one node Q(v1,v2,v3) left; the fifth block diagram gives the output result, that is, the data view corresponding to Q.

[0039] The compilation and execution mechanism of the present application is further described below. The present application can compile the above query answering process into a program code for CPU master control based on a programming model (such as SYCL). Among them, the merging process involved in steps S105 and S106 in the query answering process can be implemented using a code block specific to the programming model, in which the device selector can select the most suitable heterogeneous processor of the computer device to execute the node merging process, while the other parts can be implemented using traditional high-level language codes.

[0040] In a feasible implementation, the programming model may be a SYCL programming model, which is an open programming model for multiple heterogeneous processors (CPU / GPU / FPGA) based on OpenCL and based on C++ by the Kronos organization. For example, the present application may use Intel's Data Parallel C++ (DPC++) framework to implement the application of the SYCL programming model, and use C++ language coding to implement the CPU master control program.

[0041] In a feasible implementation, the suitable heterogeneous processor may be a CPU or GPU available in the current machine. For example, the heterogeneous processors may be selected in descending order of performance, such as first selecting a GPU from Nvidia, then a GPU from AMD, then a GPU from Intel, and finally a CPU from Intel or other CPUs.

[0042] It should be noted that in the above-mentioned query answering process, the merge processing usually takes up most of the processor's performance. If the merge processing is performed only by the CPU, it will easily fall into a data bottleneck, affecting the query efficiency and failing to give full play to the processing performance of the heterogeneous computing architecture. Through the above-mentioned compilation and execution mechanism, the computer device can choose to call a suitable heterogeneous processor such as a GPU to handle the process when executing the merge processing. The speed will be increased by ten times compared to CPU processing, and the compilation and execution mechanism also supports the elastic expansion of heterogeneous processors. When changes occur in heterogeneous devices, there is no need for manual reconfiguration or recompilation of executable programs, which greatly improves the query execution efficiency of the conjunction query answering process.

[0043] It can be seen that through the above-mentioned query answering process and compilation execution mechanism, the present application can achieve the following beneficial effects: First, the conjunction query answering process of the database is converted into a numerical calculation process of the data view node merging sequence, so as to utilize the characteristics that certain calculation processes (such as the sorting process of the vector list) are executed faster in some heterogeneous accelerators (such as GPU) than directly in the CPU, which can significantly improve the efficiency of conjunction query answering. Second, the process of merging two data view nodes can be converted into a numerical calculation process based on vector list sorting and sparse matrix multiplication, especially further simplifying the sparse matrix multiplication operation to a matrix construction that does not require multiplication operations, which fully optimizes the node merging process and can greatly improve the efficiency of node merging. Third, a suitable programming model can be used to compile the conjunction query answering process into a CPU master control and the performance bottleneck module is adapted to a variety of heterogeneous processors (CPU / GPU) machine code for execution, which can maximize the efficiency of conjunction query answering. Fourth, the program code is compiled into an executable program that supports multiple heterogeneous processors through a compiler with a suitable programming model. At runtime, the appropriate heterogeneous processor is selected according to the hardware facilities of the current machine to perform the data view node merging operation. This can support the elastic expansion of heterogeneous processors, and there is no need for manual reconfiguration or recompilation of executable programs when heterogeneous devices change.

[0044] The following is a detailed description of the query answering method adapted to the heterogeneous computing architecture of this application. Figure 3 , is a flow chart of a query answering method adapted to a heterogeneous computing architecture provided in an embodiment of the present application, such as Figure 3 The method shown can be applied to a computer device that adopts a heterogeneous computing architecture. The method includes:

[0045] S301: Obtain a conjunction query statement to be answered, and construct an initial node set according to each atom in the conjunction query statement.

[0046] In one embodiment, the conjunction query statement is composed of basic atoms and comparison atoms through conjunction connectors. When all atoms in the conjunction query statement are true at the same time, the assignment of the answer variable in the atom is the real query answer. Each of the basic atoms is composed of a predicate and a variable parameter. The predicate corresponds to the name of the database form, and the variable parameter corresponds to each field in the database form. The variable parameter is the answer variable of the conjunction query statement or is not the answer variable of the conjunction query statement. Each answer variable in the conjunction query statement appears in the basic atoms included in the conjunction query statement, and any two basic atoms in the conjunction query statement do not have the same variable parameter. Each comparison atom is composed of a comparison predicate and two parameters. The comparison predicate is one of the six comparison operators of less than, equal to, greater than, not less than, not greater than, and not equal to. The first parameter of the two parameters is a variable parameter, which must appear in the basic atoms included in the conjunction query statement. The second parameter is a variable parameter or a constant parameter. If it is the variable parameter, it must appear in the basic atoms included in the conjunction query statement, otherwise it is a string, date time or value.

[0047] In one embodiment, when the initial node set is formed according to the atoms in the conjunction query statement, each basic atom and the comparison atom covered by its variable parameters constitute an initial node, wherein the comparison atom being covered by the variable parameters of a basic atom means that the variable parameters in the comparison atom are all the variable parameters of the basic atom.

[0048] For example, Figure 2 The conjunction query statement shown is Q(v1,v2,v3)←P1(u1,v1,)∧P2(u2,u3,v2)∧P3(u4,v3)∧u1=u2∧u3≤u4∧v3≠c, which concatenates the basic atom P1(u1,v1,) and the comparison atom (none) covered by the basic atom P1(u1,v1,), and concatenates the basic atom P2(u2,u3,v2) and the comparison atom (none) covered by the basic atom P2(u2,u3,v2) The comparison atom (none) covered by the current atom P2(u2,u3,v2) is conjuncted, the basic atom P3(u4,v3) and the comparison atom v3≠c covered by the basic atom P3(u4,v3) are conjuncted, and three initial nodes P1(u1,v1,), P2(u2,u3,v2), and P3(u4,v3)∧v3≠c are obtained, and these three initial nodes form the initial node set.

[0049] In one embodiment, before obtaining the conjunction query statement to be answered and forming an initial node set according to each atom in the conjunction query statement, the method further includes: obtaining the query statement to be answered; dividing the query statement into a general statement and the conjunction query statement to be answered.

[0050] For example, when the computer device receives a general query statement, it can divide the query statement into two parts: a general statement and a conjunction query statement to be answered, such as a GROUP BY clause, an ORDER BY clause, and a field value function, etc. For the conjunction query statement to be answered, the following conjunction query steps can be performed to obtain a conjunction query answer (i.e., the data view of the target node described below), and for the general statement, processing can be performed after obtaining the conjunction query answer.

[0051] It should be noted that, compared with the merging process in the conjunction query, the other parts can be more easily converted into numerical calculations, or are more convenient for CPU management and scheduling control.

[0052] S302: Determine whether the initial node set includes at least two initial nodes.

[0053] In this step, the computer device determines whether the initial node set includes at least two initial nodes, which may correspond to the following results: one result is that the initial node set includes at least two initial nodes, then the following steps S304 to S308 can be executed. Another result is that there is only one initial node in the initial node set, then the following step S303 can be executed.

[0054] S303: If the initial node set includes only one initial node, use the only initial node as a target node, and output a data view of the target node.

[0055] It can be understood that when there is only one initial node in the initial node set, the initial node must correspond to the query result of the conjunction query statement (that is, the data view corresponding to the initial node). At this time, the computer device can use the only initial node as the target node and output the data view of the target node, thereby ending the current conjunction query answering process.

[0056] S304: If the initial node set includes at least two initial nodes, determine whether there are cross-node comparison atoms between at least two of the initial nodes.

[0057] The cross-node comparison atom refers to that two variable parameters of the comparison atom appear in the basic atoms of the two initial nodes respectively.

[0058] As a feasible implementation, the computer device can further divide the situation where the initial node set includes at least two initial nodes into: at least two initial nodes of the initial node set have the cross-node comparison atoms, and at least two initial nodes of the initial node set do not have the cross-node comparison atoms, according to whether the at least two initial nodes have the cross-node comparison atoms.

[0059] S305: If the cross-node comparison atom exists between the at least two initial nodes, a first merging cost of each two initial nodes is calculated, and two initial nodes with the smallest first merging cost are selected for merging to obtain a first intermediate node.

[0060] In one embodiment, the S305 step includes: if the at least two initial nodes have the cross-node comparison atoms, then for every two initial nodes with the cross-node comparison atoms, calculating the first merge cost of the two initial nodes; merging the two initial nodes corresponding to the minimum first merge cost; calculating an identification matrix of the two initial nodes corresponding to the minimum first merge cost based on a single cross-node comparison atom, the number of identification matrices is the same as the number of cross-node comparison atoms; performing a bitwise multiplication operation on all the identification matrices to obtain a target matrix; constructing a data view of the first intermediate node according to the row and column numbers corresponding to all 1 elements in the target matrix, and treating the data view of the first intermediate node as the basic atoms of the first intermediate node.

[0061] In one embodiment, if the cross-node comparison atoms exist between the at least two initial nodes, the first merge cost of every two initial nodes is calculated, including: defining the two initial nodes as a first initial node and a second initial node; and calculating the first merge cost of the first initial node and the second initial node based on the total number of records of each of the first initial node and the second initial node, the number of cross-node comparison atoms between the first initial node and the second initial node, and a preset trade-off parameter.

[0062] It should be noted that the preset trade-off parameter is a parameter set in advance by humans, and can be used to reflect the cost ratio of the construction of the merged result set and the sorting of the merged columns. In one embodiment, the selection range of the preset trade-off parameter is between 0 and 1.

[0063] For example, suppose the first initial node and the second initial node are R(u1,…,u r ) and S(v1,…,v s ), R(u1,…,u r ) and S(v1,…,v s ) exists in the form c(u i ,v j ) comparison atoms, we can use R(u1,…,u r ) and S(v1,…,v s ) based on c(u i ,v j) is defined as (|R|+|S|)log2(|R|+|S|)+α|R||S|, where |R| and |S| represent the total number of records in R and S respectively, and α is a preset trade-off parameter between 0 and 1. r ) and s(v1,…,v s ) is defined as k((|R|+|S|)log2(|R|+|S|)+α|R||S|), called the first merge cost, where k is the total cost of all the input queries of the form c k (u i ,v j ) is the number of comparison atoms.

[0064] As a feasible implementation, after calculating the first merge cost, the computer device may select two initial nodes of the first merge cost for merging. The computer device may assume that the input is a node R(u1,…,u r ) and S(v1,…,v s ) and the comparison atom c(u i ,v j ), the output can be based on c(u i ,v j )Merge R(u1,…,u r ) and S(v1,…,v s ) The first pair of subsets of sequence numbers of the data view obtained after ) on R and S {(a,b)|1≤a≤|R|,1≤b≤|S|,E c (R a [u i ],S b [v j ])}, where E c (R a [u i ],S b [v j ]) represents the u of the a-th record in R i The column value is the same as v in the bth record in S j The column values ​​satisfy the comparison relation c.

[0065] For the case where there are multiple cross-node comparison atoms, assume that the input is R(u1,…,u r ) and S(v1,…,v s ), and all comparison atoms c1(u i1 ,v j1 ),…,c k (u ik ,v jk), the output is based on all comparison atoms merge R(u1,…,u r ) and S(v1,…,v s ) The data view obtained after the sequence number on R and S is a subset of in represents u of the ath record in R il The column value is the same as v in the bth record in S jl The column value satisfies the comparison relation c l .

[0066] For example, assume that k represents the number of atoms to be compared across nodes. For l = 1, ..., k, the computer device can respectively calculate the number of atoms to be compared based on c l (u il ,v jl )Merge R(u1,…,u r ) and S(v1,…,v s )’s identity matrix M l ∈{0,1} |R|×|S| ; Then calculate M = M1⊙M2⊙…⊙M k , where ⊙ is a bitwise multiplication operation; finally, the row and column number pairs of the 1 element in M ​​are returned, that is, {(a,b)|1≤a≤|R|,1≤b≤|S|, M a,b =1}.

[0067] In one embodiment, the calculation is based on a single cross-node comparison atom to merge the identification matrix of the two initial nodes corresponding to the first merge cost with the minimum, including: according to the single cross-node comparison atom, the two initial nodes corresponding to the first merge cost with the minimum are vectorized to obtain a first vector and a second vector; according to the first vector and the second vector, a splicing process is performed to obtain a vector list; the vector list is sorted to obtain a position list and a sorted list; according to the sorted list, a sequence number list is calculated; according to the sequence number list, the first vector is converted into a one-hot encoding vector of a preset dimension, and a target vector is obtained according to the 1-element position of the one-hot encoding vector, wherein the preset dimension is the maximum sequence number of the sequence number list; according to the second vector and the single comparison atom, an intermediate matrix is ​​obtained; according to the intermediate matrix and the target vector, an identification matrix of the two initial nodes corresponding to the first merge cost with the minimum is constructed based on the single cross-node comparison atom to merge.

[0068] For example, the two initial nodes corresponding to the minimum first merge cost are represented by R and D respectively, and the computer device can i List all values ​​u i,1 ,…,u i,|R| and S j List all values ​​vj,1 ,…,v j,|S| are converted into vectors respectively, where if u in R i Column and S in v h If all columns are numeric fields, they are converted into one-dimensional vectors consisting of field values ​​(i.e., u i,k and v j,k are all one-dimensional vectors), the one-dimensional vectors corresponding to R and S are the first vector and the second vector. Otherwise, they can be converted into d-dimensional vectors with zero-filled high-dimensional components according to the character encoding conversion rules, where d represents the total number of characters in the longest field value, and the d-dimensional vectors corresponding to R and S are the first vector and the second vector. Then, we can concatenate u in R i List all values ​​and v in D j List all the vectors with different values ​​and get a vector list. The vector list is represented by [u i,1 ,…,u i,|R| ,v j,1 ,…,v j,|S| ] represents. Further, for the above vector list [u i,1 ,…,u i,|R| ,v j,1 ,…,v j,|S| ] to get the position list of all vectors [p1,…,p |R| ,p |R|+1 ,…,p |R|+|S| ] and the sorted list [w1,...,w |R| ,w |R|+1 ,...,w |R|+|S| ], where [p1,…,p |R|+|S| ] is a permutation of the list of natural numbers [1,…,|R|+|D|], [w1,…,w |R|+|S| ] is a list of vectors [u i,1 ,…,u i,|R| ,v j,1 ,…,v j,|S| ] satisfies w1≤…≤w |R| ≤w |R|+1 ≤…≤w |R|+|S| It can be understood that for any k∈{1,…,|R|}, And for any k∈{1,…,|S|}, Furthermore, we can take the view R as i Columns are converted into |R| q |R|+|S| dimensional one-hot encoding vector (one-hot vector), and then use vector N to represent the target vector, which records the position of the 1 element in these |R| one-hot vectors, that is, Set view S in v j Convert columns into an intermediate matrix The intermediate matrix M can satisfy:

[0069] When c is =, if v j,a =w b ,but otherwise

[0070] When c is >, if v j,a <w b ,but otherwise

[0071] When c is <, if v j,a >w b ,but otherwise

[0072] When c is ≥, if v j,a ≤w b ,but otherwise

[0073] When c is ≤, if v j,a ≥w b ,but otherwise

[0074] When c is ≠, if v j,a ≠w b ,but otherwise

[0075] The computer device may be configured to Construct based on c(u i ,v j )Merge R(u1,…,u r ) and S(v1,…,v s )’s identity matrix M′∈{0,1} |R|×|S| Among them, the identity matrix M′ is equivalent to the sparse matrix M corresponding to the view R # The result M of multiplying the matrix M corresponding to the view S # M T , where M T represents the transposed matrix of M, M # It is defined as: for any a∈{1,…,|R|} and b∈{1,…,q |R|+|S|},like but otherwise Return the row and column number pairs of 1 elements in M′ as the first pair of subsets, that is, {(a,b)|1≤a≤|R|,1≤b≤|S|, M′ a,b=1}.

[0076] It should be noted that in this step, in the example of the identity matrix operation process, u in R is i Columns are converted into vectors, and then v in S j According to the commutativity of the merge operation, there is an equivalent alternative method for this step, that is, v in S j Columns are converted into vectors, and then u in view R i The columns are converted into corresponding matrices, and this application does not impose any restrictions on this.

[0077] S306: If there is no cross-node comparison atom between any two initial nodes, calculate the second merging cost of every two initial nodes, and select two initial nodes with the smallest second merging cost for merging to obtain a second intermediate node.

[0078] In one embodiment, the second merge cost of every two initial nodes is calculated, and the two initial nodes with the smallest second merge cost are selected for merging to obtain a second intermediate node, including: defining any two initial nodes as a third initial node and a fourth initial node; calculating the second merge cost of the third initial node and the fourth initial node according to the total number of records of each of the third initial node and the fourth initial node; when selecting the two initial nodes with the smallest second merge cost for merging, the Cartesian product of the corresponding data views of the two initial nodes with the smallest second merge cost is calculated as the data view of the second intermediate node, and the data view of the second intermediate node is regarded as the basic atom of the second intermediate node.

[0079] For example, suppose the third initial node is R(u1,…,u r ), the fourth initial node is S(v1,…,v s ), the cost of merging the third initial node and the fourth initial node is defined as |R||S|, where |R||S| is the second merging cost. If the two initial nodes with the smallest second merging cost are R(u1,…,u r ) and S(v1,…,v s ), we can directly calculate R(u1,…,u r ) and S(v1,…,v s ) corresponds to the Cartesian product of the data view, and obtains the second intermediate node T(u1,...,u r ,v1,...,v s ), the data view of the second intermediate node is regarded as the basic atom of the second intermediate node.

[0080] S307: Update the initial node set based on the first intermediate node or the second intermediate node.

[0081] In one embodiment, updating the initial node set based on the first intermediate node or the second intermediate node includes: deleting the two initial nodes with the smallest first merge cost (or second merge cost); adding the first intermediate node (or the second intermediate node) to the initial node set, and deleting the column variables that are not query answer variables and appear in the unused comparison atoms in the merged view of the first intermediate node (or the second intermediate node).

[0082] It should be noted that after the first intermediate node (or the second intermediate node) is added to the initial node set, the added first intermediate node (or the second intermediate node) is used as a new initial node in the initial node set.

[0083] For example, assuming that the first intermediate node (or the second intermediate node) is T(u1,...,u r ,v1,...,v s ), the intermediate node is composed of the initial node R(u1,…,u r ) and S(v1,…,v s ) can be merged, then R(u1,…,u r ) and S(v1,…,v s ), and T(u1,...,u r ,v1,...,v s ) is added, and at the same time, the column variables that are not query answer variables and appear in unused comparison atoms in the merged view of the intermediate node are deleted.

[0084] S308 , returning to the step of determining whether the initial node set includes at least two initial nodes, until the initial node set includes only one node, taking the only node as the target node, and outputting the data view of the target node.

[0085] In one embodiment, the above method can be implemented based on a target programming model, and the target programming model at least includes a SYCL programming model. That is, the above steps S301-S308 can be implemented based on a target programming model, and the target programming model at least includes a SYCL programming model.

[0086] It should be noted that the SYCL programming model refers to an open programming model for multiple heterogeneous processors (CPU / GPU / FPGA) based on OpenCL and C++ developed by the Kronos organization.

[0087] In one embodiment, the computer device selects a target heterogeneous processor based on the target programming model according to preset selection rules to use the target heterogeneous processor to merge the initial nodes, and the target heterogeneous processor is a heterogeneous processor that best matches the preset selection rules; the preset selection rules at least include a rule that gives priority to the performance of the heterogeneous processors currently available to the computer device in descending order.

[0088] For example, based on the SYCL programming model, the above steps S301-S308 can be written into a CPU-controlled program code, wherein the above node merging process can be implemented using a code block unique to the SYCL programming model, in which a device selector can be used to select a suitable heterogeneous processor in the computer device to execute the node merging process, while other parts can be implemented using traditional high-level language codes.

[0089] In one embodiment, the preset selection rule may be a rule of giving priority to selecting in descending order of performance of heterogeneous processors currently available to the computer device, or may be other selection rules, and the present application does not impose any limitation on this.

[0090] For example, the target heterogeneous processor may be a CPU or a GPU. Assuming a preset selection rule of giving priority to these heterogeneous processors in order of performance from large to small, for example, it may be set to first select Nvidia's GPU, then AMD's GPU, Intel's GPU, and finally Intel's CPU or other CPUs.

[0091] For another example, the computer device can use Intel's Data Parallel C++ (DPC++) framework to implement the application of the SYCL programming model, and use C++ language coding to implement the CPU master control program. Alternatively, the computer device can also use other SYCL programming model frameworks such as ComputeCPP and OpenSYCL to implement the application of the SYCL programming model, and this application does not impose any restrictions on this.

[0092] It can be seen that through the query answering method adapted to the heterogeneous computing architecture shown in the present application, the conjunction query statement to be answered can be obtained, and the initial node set is formed according to each atom of the conjunction query statement. When the initial node set includes at least two initial nodes, the merging cost of each two initial nodes is calculated, and each merging selects two initial nodes with the smallest merging cost for merging processing until the initial node set includes only one node, and then outputs the data view of the only node, thereby realizing the conversion of the conjunction query answering process into the numerical operation process of the data view node. Since the conjunction query answering actually uses numerical operations, when the heterogeneous processor of the computer device changes, the system can be no longer reconfigured or redesigned and compiled, so that the appropriate programming model code is applied to call the appropriate heterogeneous processor, which effectively improves the flexibility of heterogeneous processors in database query answering. In addition, in the process of merging two initial nodes, the merging process is converted into a numerical calculation process based on vector list sorting and sparse matrix multiplication, especially the sparse matrix multiplication operation process is further simplified to a matrix construction that does not require multiplication operations, which fully optimizes the node merging process, greatly improves the efficiency of node merging, and further improves the query efficiency of database conjunction query.

[0093] The method of the present application is introduced above, and the device of the present application is introduced below.

[0094] See also Figure 4 , Figure 4 40 is a schematic diagram of a computer device provided in an embodiment of the present application. The computer device 40 adopts a heterogeneous computing architecture and includes a processor group 401 and a memory 402. The processor group 401 is composed of two or more heterogeneous processors. The memory 402 is connected to the processor 401 via a bus.

[0095] The processor group 401 is configured to support the computer device 40 to perform the corresponding functions in the method in the above method embodiment. The processor group 401 includes a central processing unit (CPU), a graphics processing unit (GPU) or a hardware chip. The above hardware chip can be an application specific integrated circuit (ASIC), a programmable logic device (PLD) or a combination thereof. The above PLD can be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL) or any combination thereof.

[0096] The memory 402 is used to store program codes, etc. The memory 402 may include a volatile memory (VM), such as a random access memory (RAM); the memory 402 may also include a non-volatile memory (NVM), such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD), or a solid-state drive (SSD); the memory 402 may also include a combination of the above-mentioned types of memories.

[0097] The processor group 401 may call the program code to perform the following operations:

[0098] Obtaining a conjunction query statement to be answered, and forming an initial node set according to each atom in the conjunction query statement;

[0099] Determining whether the initial node set includes at least two initial nodes;

[0100] If the initial node set includes only one initial node, the only initial node is used as the target node, and the data view of the target node is output;

[0101] If the initial node set includes at least two initial nodes, determining whether there is a cross-node comparison atom between at least two of the initial nodes, wherein the cross-node comparison atom refers to two variable parameters of the comparison atom appearing in the basic atoms of the two initial nodes respectively;

[0102] If the cross-node comparison atom exists in the at least two initial nodes, a first merging cost of each two initial nodes is calculated, and two initial nodes with the smallest first merging cost are selected for merging to obtain a first intermediate node;

[0103] If the cross-node comparison atom does not exist between any two initial nodes, then the second merging cost of each two initial nodes is calculated, and two initial nodes with the smallest second merging cost are selected for merging to obtain a second intermediate node;

[0104] updating the initial node set based on the first intermediate node or the second intermediate node;

[0105] Return to executing the step of determining whether the initial node set includes at least two initial nodes, until the initial node set includes only one node, then use the only node as the target node, and output the data view of the target node.

[0106] A person skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.

[0107] The above disclosure is only the preferred embodiment of the present application, which certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.

Claims

1. A query answering method adapted to heterogeneous computing architectures, It is characterized in that Applied to a computer device, the computer device adopts a heterogeneous computing architecture, and the method includes: Obtain a conjunction query statement to be answered, and form an initial node set according to each atom in the conjunction query statement; the conjunction query statement is composed of basic atoms and comparison atoms through conjunction connectors, and when all atoms in the conjunction query statement are true at the same time, the assignment of answer variables in the atoms is the real query answer; each of the basic atoms is composed of a predicate and a variable parameter, the predicate corresponds to the name of a database form, and the variable parameters correspond to each field in the database form, wherein the variable parameter is the answer variable of the conjunction query statement or is not the answer variable of the conjunction query statement, and the conjunction query statement Each answer variable appears in the basic atoms included in the conjunction query statement, and any two basic atoms in the conjunction query statement do not have the same variable parameter; each comparison atom is composed of a comparison predicate and two parameters, the comparison predicate is one of the six comparison operators of less than, equal to, greater than, not less than, not greater than, and not equal to, the first of the two parameters is a variable parameter, which must appear in the basic atoms included in the conjunction query statement, and the second parameter is a variable parameter or a constant parameter, if it is the variable parameter, it must appear in the basic atoms included in the conjunction query statement, otherwise it is a string, date time or value; Determining whether the initial node set includes at least two initial nodes; If the initial node set includes only one initial node, the only initial node is used as the target node, and the data view of the target node is output; If the initial node set includes at least two initial nodes, determining whether there are cross-node comparison atoms between at least two of the initial nodes, wherein the cross-node comparison atom refers to two variable parameters of the comparison atom appearing in basic atoms of the two initial nodes respectively; If the cross-node comparison atoms exist in at least two of the initial nodes, the first merge cost of each two initial nodes is calculated, and the two initial nodes with the smallest first merge cost are selected for merging to obtain a first intermediate node, including: if the cross-node comparison atoms exist in the at least two initial nodes, the first merge cost of the two initial nodes is calculated for each two initial nodes with the cross-node comparison atoms; the two initial nodes corresponding to the smallest first merge cost are merged; the identification matrix of the two initial nodes corresponding to the smallest first merge cost is calculated based on a single cross-node comparison atom, and the number of the identification matrices is the same as the number of the cross-node comparison atoms; all the identification matrices are bitwise multiplied to obtain a target matrix; the data view of the first intermediate node is constructed according to the row and column numbers corresponding to all 1 elements in the target matrix, and the data view of the first intermediate node is regarded as the basic atom of the first intermediate node; If the cross-node comparison atom does not exist between any two initial nodes, then the second merge cost of each two initial nodes is calculated, and two initial nodes with the smallest second merge cost are selected for merging to obtain a second intermediate node; updating the initial node set based on the first intermediate node or the second intermediate node; Return to executing the step of determining whether the initial node set includes at least two initial nodes, until the initial node set includes only one node, then use the one node as the target node, and output the data view of the target node.

2. The method according to claim 1, Its characteristics are also that When the initial node set is formed according to the atoms in the conjunction query statement, each basic atom and the comparison atom covered by its variable parameters form an initial node, wherein the comparison atom being covered by the variable parameters of a basic atom means that the variable parameters in the comparison atom are all the variable parameters of the basic atom.

3. The method according to claim 1, It is characterized in that If the cross-node comparison atom exists in the at least two initial nodes, calculating a first merge cost of each two initial nodes includes: defining the two initial nodes as a first initial node and a second initial node; A first merge cost of the first initial node and the second initial node is calculated based on the total number of records of each of the first initial node and the second initial node, the number of cross-node comparison atoms between the first initial node and the second initial node, and preset trade-off parameters.

4. The method according to claim 1, Its characteristics are also that The calculation of the identification matrices of the two initial nodes corresponding to the first minimum merging cost based on a single cross-node comparison atomic merge includes: According to the single cross-node comparison atom, performing vector conversion processing on two initial nodes corresponding to the first minimum merge cost to obtain a first vector and a second vector; Perform concatenation processing on the first vector and the second vector to obtain a vector list; Sorting the vector list to obtain a position list and a sorting list; Calculate a sequence number list according to the sorted list; Converting the first vector into a one-hot encoded vector of a preset dimension according to the sequence number list, and obtaining a target vector according to the position of the 1 element of the one-hot encoded vector, wherein the preset dimension is the maximum sequence number of the sequence number list; Obtaining an intermediate matrix according to the second vector and the single cross-node comparison atom; According to the intermediate matrix and the target vector, an identification matrix corresponding to two initial nodes with the minimum first merging cost based on the single cross-node comparison atomic merging is constructed.

5. The method according to claim 1, Its characteristics are also that The calculating the second merging cost of every two initial nodes, and selecting two initial nodes with the smallest second merging cost for merging to obtain a second intermediate node, includes: Define any two initial nodes as the third initial node and the fourth initial node; Calculate a second merge cost of the third initial node and the fourth initial node according to the total number of records of the third initial node and the fourth initial node; When selecting the two initial nodes with the smallest second merge cost for merging, the Cartesian product of the corresponding data views of the two initial nodes with the smallest second merge cost is calculated as the data view of the second intermediate node, and the data view of the second intermediate node is regarded as the basic atom of the second intermediate node.

6. The method according to claim 1, Its characteristics are also that The method is implemented based on a target programming model, which at least includes a SYCL programming model.

7. The method according to claim 6, It is characterized in that The computer device selects a target heterogeneous processor according to a preset selection rule based on the target programming model to merge the initial nodes using the target heterogeneous processor, wherein the target heterogeneous processor is a heterogeneous processor that best matches the preset selection rule; The preset selection rule at least includes a rule of preferentially selecting in descending order of performance of heterogeneous processors currently available to the computer device.

8. A computer device, It is characterized in that The computer device adopts a heterogeneous computing architecture, including a memory and a processor group, the memory is connected to the processor group, the processor group includes at least two processors, the processor is used to execute one or more computer programs stored in the memory, and when the processor executes the one or more computer programs, the computer device implements the method according to any one of claims 1 to 7.