CN104714782A - Matrix data element identification serialization method and system - Google Patents
Matrix data element identification serialization method and system Download PDFInfo
- Publication number
- CN104714782A CN104714782A CN201510138373.XA CN201510138373A CN104714782A CN 104714782 A CN104714782 A CN 104714782A CN 201510138373 A CN201510138373 A CN 201510138373A CN 104714782 A CN104714782 A CN 104714782A
- Authority
- CN
- China
- Prior art keywords
- identifier
- calculation
- computing node
- row
- data
- 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.)
- Granted
Links
- 239000011159 matrix material Substances 0.000 title claims abstract description 86
- 238000000034 method Methods 0.000 title claims abstract description 43
- 238000004364 calculation method Methods 0.000 claims abstract description 200
- 238000011437 continuous method Methods 0.000 claims abstract 2
- 239000013598 vector Substances 0.000 claims description 82
- 238000005192 partition Methods 0.000 abstract 1
- 238000010586 diagram Methods 0.000 description 11
- 238000013500 data storage Methods 0.000 description 4
- 238000004891 communication Methods 0.000 description 3
- 238000004590 computer program Methods 0.000 description 2
- 230000006870 function Effects 0.000 description 2
- 238000006243 chemical reaction Methods 0.000 description 1
- 230000005055 memory storage Effects 0.000 description 1
Landscapes
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
本发明公开了一种矩阵数据元素标识连续化方法和系统,涉及计算机领域。所述方法包括:针对N个计算节点,每个参与计算的计算节点读取矩阵数据中被分配给该计算节点的矩阵分块的数据元素;每个参与计算的计算节点根据预置的数据标识散步规则,将所读取的数据元素中的数据标识保留在本地或者发送到相应的计算节点,并接收剩余N-1个计算节点发送的数据标识,获得由所述计算节点进行处理的最终数据标识;每个参与计算的计算节点根据所述最终数据标识进行连续化,获得与每个数据标识相应的第一标识;每个参与计算的计算节点将第一标识与原数据标识的对应关系通知给其他计算节点。对于大规模的矩阵数据,可以通过各个计算节点并行的进行连续化,加快了连续化的速度,提高了数据处理效率。
The invention discloses a matrix data element identification continuous method and system, relating to the computer field. The method includes: for N computing nodes, each computing node participating in the calculation reads the data element of the matrix partition assigned to the computing node in the matrix data; each computing node participating in the computing identifies Propagation rules, keep the data identifiers in the read data elements locally or send them to the corresponding computing nodes, and receive the data identifiers sent by the remaining N-1 computing nodes, and obtain the final data processed by the computing nodes identification; each calculation node participating in the calculation performs serialization according to the final data identification, and obtains a first identification corresponding to each data identification; each calculation node participating in the calculation notifies the corresponding relationship between the first identification and the original data identification to other computing nodes. For large-scale matrix data, serialization can be carried out in parallel through each computing node, which speeds up the speed of serialization and improves the efficiency of data processing.
Description
技术领域 technical field
本发明涉及计算机领域,特别是涉及一种矩阵数据元素标识连续化方法和系统。 The invention relates to the field of computers, in particular to a method and system for continuous identification of matrix data elements.
背景技术 Background technique
在大规模并行计算中,很重要一类计算是矩阵或向量的计算。通常描述矩阵采用(Rowkey,colkey,value)的三元组(其中Rowkey,colkey分别为行标、列标,value为实际存储的数据内容),这样可以采用稀疏的存储方式,从而减少存储空间。用户再将矩阵按照行(Rowkey)或者列(colkey)进行划分,将数据散布到多个计算结点(也即计算服务器)上,从而达到并行计算的目的。通常为了唯一标识矩阵中每个数据元素,输入的Rowkey和colkey采用位数较多(64位,128位)的签名。而在实际的计算过程中,Rowkey和colkey仅作为一个下标,并不需要很多的位数。因此为了减少节点内存存储空间,并且方便计算时顺序访问,常常要对key和colkey进行连续的id化,即将Rowkey和colkey都转换为连续的0-N的整数列。 In large-scale parallel computing, a very important type of calculation is the calculation of matrices or vectors. Usually, the description matrix adopts triplets of (Rowkey, colkey, value) (where Rowkey, colkey are the row label and column label respectively, and value is the actual stored data content), so that the sparse storage method can be used to reduce the storage space. The user then divides the matrix by row (Rowkey) or column (colkey), and distributes the data to multiple computing nodes (that is, computing servers), so as to achieve the purpose of parallel computing. Usually, in order to uniquely identify each data element in the matrix, the input Rowkey and colkey adopt a signature with more digits (64 bits, 128 bits). In the actual calculation process, Rowkey and colkey are only used as a subscript and do not require a lot of digits. Therefore, in order to reduce the memory storage space of the node and facilitate sequential access during calculation, it is often necessary to continuously id the key and colkey, that is, convert both Rowkey and colkey into continuous 0-N integer columns.
现有技术中,存在一种对矩阵数据的的存储标识进行id化的方法是串行id化方法,即采用一个计算节点,逐个获取矩阵中的数据元素将其行标和列标进行id化,但是该种方法处理效率低,时间长。 In the prior art, there is a serial id method to id the storage identifier of matrix data, that is, a computing node is used to obtain the data elements in the matrix one by one and id their row and column labels , but the processing efficiency of this method is low and the time is long.
发明内容 Contents of the invention
鉴于上述问题,提出了本发明以便提供一种克服上述问题或者至少部分地解决上述问题的一种矩阵数据元素标识连续化装置和相应的一种矩阵数据元素标识连续化方法。 In view of the above problems, the present invention is proposed to provide a matrix data element identifier serialization device and a corresponding matrix data element identifier serialization method that overcome the above problems or at least partially solve the above problems.
依据本发明的一个方面,提供了一种矩阵数据元素标识连续化方法,包括: According to one aspect of the present invention, a method for continuous identification of matrix data elements is provided, including:
针对N个计算节点,每个参与计算的计算节点读取矩阵数据中被分配给该计算节点的矩阵分块的数据元素; For N computing nodes, each computing node participating in the calculation reads the data elements of the matrix block assigned to the computing node in the matrix data;
每个参与计算的计算节点根据预置的数据标识散步规则,将所读取的数据元素中的数据标识保留在本地或者发送到相应的计算节点,并接收剩余 N-1个计算节点发送的数据标识,获得由所述计算节点进行处理的最终数据标识; Each computing node participating in the calculation keeps the data identifier in the read data element locally or sends it to the corresponding computing node according to the preset data identifier spreading rule, and receives the data sent by the remaining N-1 computing nodes identification, obtaining the final data identification processed by the computing node;
每个参与计算的计算节点根据所述最终数据标识进行连续化,获得与每个数据标识相应的第一标识; Each computing node participating in the calculation performs serialization according to the final data identifier, and obtains a first identifier corresponding to each data identifier;
每个参与计算的计算节点将第一标识与原数据标识的对应关系通知给其他计算节点。 Each computing node participating in the calculation notifies other computing nodes of the correspondence between the first identifier and the original data identifier.
可选的,所述每个参与计算的计算节点读取矩阵数据中被分配给该计算节点的矩阵分块的数据元素包括: Optionally, the data elements of the matrix block allocated to the computing node in the matrix data read by each computing node participating in the computing include:
每个参与计算的计算节点读取矩阵数据中按行分块的数据元素,或者按列分块的数据元素。 Each computing node participating in the calculation reads the data elements in the matrix data that are divided into blocks by rows, or data elements that are divided into blocks by columns.
可选的,所述每个参与计算的计算节点根据预置的数据标识散步规则,将所读取的数据元素中的数据标识保留在本地或者发送到相应的计算节点包括: Optionally, said each computing node participating in the calculation, according to the preset data identifier spreading rule, retaining the data identifier in the read data element locally or sending it to the corresponding computing node includes:
每个参与计算的计算节点根据阈值的列标识散步规则,将所读取的数据元素中的列标识保留在本地或者发送到相应的计算节点;并接收其他N-1个计算节点发送的列标识。 Each computing node participating in the calculation keeps the column identifier in the read data element locally or sends it to the corresponding computing node according to the column identifier spreading rule of the threshold; and receives the column identifier sent by other N-1 computing nodes .
可选的,所述每个参与计算的计算节点根据所述最终数据标识进行连续化,获得与每个数据标识相应的第一标识包括: Optionally, each computing node participating in the calculation performs serialization according to the final data identifier, and obtaining the first identifier corresponding to each data identifier includes:
每个参与计算的计算节点根据本地的行标识生成行标识向量,并对行标识向量进行连续化,获得与每个行标识相应的第一行标识; Each computing node participating in the calculation generates a row identifier vector according to the local row identifier, and serializes the row identifier vector to obtain the first row identifier corresponding to each row identifier;
每个参与计算的计算节点对本地的列标识进行去重并生成列标识向量,并对列标识向量进行连续化,获得与每个列标识相应的第一列标识。 Each computing node participating in the calculation deduplicates the local column identifiers to generate column identifier vectors, and serializes the column identifier vectors to obtain the first column identifier corresponding to each column identifier.
可选的,所述每个参与计算的计算节点将第一标识与原数据标识的对应关系通知给其他计算节点包括: Optionally, each computing node participating in the computing notifying other computing nodes of the correspondence between the first identifier and the original data identifier includes:
每个参与计算的计算节点根据第一列标识与原列标识的对应关系,将第一列标识通知给其他计算节点。 Each computing node participating in the calculation notifies other computing nodes of the first column identifier according to the corresponding relationship between the first column identifier and the original column identifier.
可选的,所述每个参与计算的计算节点根据预置的数据标识散步规则,将所读取的数据元素中的数据标识保留在本地或者发送到相应的计算节点 包括: Optionally, each of the computing nodes participating in the calculation retains the data identifier in the read data element locally or sends it to the corresponding computing node according to the preset data identifier spreading rule, including:
每个参与计算的计算节点根据阈值的行标识散步规则,将所读取的数据元素中的行标识保留在本地或者发送到相应的计算节点;并接收其他计算节点发送的行标识。 Each computing node participating in the calculation keeps the row ID in the read data element locally or sends it to the corresponding computing node according to the row ID spreading rule of the threshold; and receives the row ID sent by other computing nodes.
可选的,所述每个参与计算的计算节点根据所述最终数据标识进行连续化,获得与每个数据标识相应的第一标识包括: Optionally, each computing node participating in the calculation performs serialization according to the final data identifier, and obtaining the first identifier corresponding to each data identifier includes:
每个参与计算的计算节点根据本地的列标识生成行标识向量,并对列标识向量进行连续化,获得与每个列标识相应的第一列标识; Each computing node participating in the calculation generates a row identification vector according to the local column identification, and serializes the column identification vector to obtain the first column identification corresponding to each column identification;
每个参与计算的计算节点对本地的行标识进行去重并生成行标识向量,并对行标识向量进行连续化,获得与每个行标识相应的第一行标识。 Each computing node participating in the calculation deduplicates the local row ID to generate a row ID vector, and serializes the row ID vector to obtain the first row ID corresponding to each row ID.
可选的,所述每个参与计算的计算节点将第一标识与原数据标识的对应关系通知给其他计算节点包括: Optionally, each computing node participating in the computing notifying other computing nodes of the correspondence between the first identifier and the original data identifier includes:
每个参与计算的计算节点根据第一行标识与原行标识的对应关系,将第一行标识通知给其他计算节点。 Each computing node participating in the calculation notifies other computing nodes of the first row identifier according to the corresponding relationship between the first row identifier and the original row identifier.
可选的,所述对向量进行连续化包括: Optionally, the continuous vector includes:
每个参与计算的计算节点i统计待计算的标识总数Ni,并将所述总数通知给其他计算节点; Each calculation node i participating in the calculation counts the total number of identifiers Ni to be calculated, and notifies the other calculation nodes of the total number;
每个参与计算的计算节点根据各计算节点待计算的标识总数Ni,计算本节点起始的第一标识; Each computing node participating in the calculation calculates the first logo starting from the node according to the total number Ni of the logos to be calculated by each computing node;
每个参与计算的计算节点根据本节点的起始的第一标识,对本节点的标识向量进行连续化,获得相应的第一标识。 Each computing node participating in the calculation serializes the identification vector of the node according to the initial first identification of the node, and obtains the corresponding first identification.
依据本发明的另一个方面,提供一种矩阵数据元素标识连续化系统,包括: According to another aspect of the present invention, a matrix data element identification continuous system is provided, including:
N个计算节点; N computing nodes;
所述每个参与计算的计算节点包括: Each computing node involved in computing includes:
数据读取模块,适于每个参与计算的计算节点读取矩阵数据中被分配给该计算节点的矩阵分块的数据元素; The data reading module is suitable for each computing node participating in the computing to read the data elements of the matrix block assigned to the computing node in the matrix data;
散步和接收模块,适于每个参与计算的计算节点根据预置的数据标识散 步规则,将所读取的数据元素中的数据标识保留在本地或者发送到相应的计算节点,并接收剩余N-1个计算节点发送的数据标识,获得由所述计算节点进行处理的最终数据标识; The spreading and receiving module is suitable for each computing node participating in the calculation to keep the data identifier in the read data element locally or send it to the corresponding computing node according to the preset data identifier walking rule, and receive the remaining N - a data identifier sent by a computing node, to obtain the final data identifier processed by the computing node;
连续化模块,适于每个参与计算的计算节点根据所述最终数据标识进行连续化,获得与每个数据标识相应的第一标识; A serialization module, adapted for each computing node participating in the calculation to perform serialization according to the final data identifier, and obtain a first identifier corresponding to each data identifier;
通知模块,适于每个参与计算的计算节点将第一标识与原数据标识的对应关系通知给其他计算节点。 The notification module is adapted for each computing node participating in the computing to notify other computing nodes of the corresponding relationship between the first identifier and the original data identifier.
可选的,所述数据读取模块进一步适于: Optionally, the data reading module is further adapted to:
每个参与计算的计算节点读取矩阵数据中按行分块的数据元素,或者按列分块的数据元素。 Each computing node participating in the calculation reads the data elements in the matrix data that are divided into blocks by rows, or data elements that are divided into blocks by columns.
可选的,当每个参与计算的计算节点读取矩阵数据中按行分块的数据元素时,所述散步和接收模块包括: Optionally, when each computing node participating in the calculation reads the data elements divided by rows in the matrix data, the spreading and receiving module includes:
列散步和接收模块,适于每个参与计算的计算节点根据阈值的列标识散步规则,将所读取的数据元素中的列标识保留在本地或者发送到相应的计算节点;并接收其他N-1个计算节点发送的列标识。 The column spreading and receiving module is suitable for each computing node participating in the calculation to keep the column identification in the read data element locally or send it to the corresponding computing node according to the column identification spreading rule of the threshold; and receive other N- A column ID sent by a compute node.
可选的,所述连续化模块包括: Optionally, the serialization module includes:
第一行连续化模块,适于每个参与计算的计算节点根据本地的行标识生成行标识向量,并对行标识向量进行连续化,获得与每个行标识相应的第一行标识; The first row serialization module is suitable for each computing node participating in the calculation to generate a row identifier vector according to the local row identifier, and to serialize the row identifier vector to obtain the first row identifier corresponding to each row identifier;
第一列连续化模块,适于每个参与计算的计算节点对本地的列标识进行去重并生成列标识向量,并对列标识向量进行连续化,获得与每个列标识相应的第一列标识。 The first column serialization module is suitable for each computing node participating in the calculation to deduplicate the local column ID and generate a column ID vector, and serialize the column ID vector to obtain the first column corresponding to each column ID logo.
可选的,所述通知模块包括: Optionally, the notification module includes:
第一通知模块,适于每个参与计算的计算节点根据第一列标识与原列标识的对应关系,将第一列标识通知给其他计算节点。 The first notification module is adapted for each computing node participating in the calculation to notify other computing nodes of the first column identifier according to the corresponding relationship between the first column identifier and the original column identifier.
可选的,当每个参与计算的计算节点读取矩阵数据中按列分块的数据元素时,所述散步和接收模块包括: Optionally, when each computing node participating in the calculation reads the data elements in the matrix data divided by columns, the dispersing and receiving module includes:
行散步和接收模块,适于每个参与计算的计算节点根据阈值的行标识散 步规则,将所读取的数据元素中的行标识保留在本地或者发送到相应的计算节点;并接收其他计算节点发送的行标识。 The row dispersal and receiving module is suitable for each computing node participating in the calculation to retain the row identifier in the read data element locally or send it to the corresponding computing node according to the row identifier dispersal rule of the threshold; and receive other calculation The row ID sent by the node.
可选的,所述连续化模块包括: Optionally, the serialization module includes:
第二列续化模块,适于每个参与计算的计算节点根据本地的列标识生成行标识向量,并对列标识向量进行连续化,获得与每个列标识相应的第一列标识; The second column continuation module is suitable for each calculation node participating in the calculation to generate a row identification vector according to the local column identification, and perform serialization on the column identification vector to obtain the first column identification corresponding to each column identification;
第二行续化模块,适于每个参与计算的计算节点对本地的行标识进行去重并生成行标识向量,并对行标识向量进行连续化,获得与每个行标识相应的第一行标识。 The second row continuation module is suitable for each computing node participating in the calculation to de-duplicate the local row ID and generate a row ID vector, and perform serialization on the row ID vector to obtain the first row corresponding to each row ID logo.
可选的,所述通知模块包括: Optionally, the notification module includes:
第二通知模块,适于每个参与计算的计算节点根据第一行标识与原行标识的对应关系,将第一行标识通知给其他计算节点。 The second notification module is adapted for each computing node participating in the calculation to notify other computing nodes of the first row identifier according to the corresponding relationship between the first row identifier and the original row identifier.
可选的,所述第一列续化模块、第一行续化模块、第二列续化模块、第二行续化模块包括: Optionally, the first column continuation module, the first row continuation module, the second column continuation module, and the second row continuation module include:
统计模块,适于每个参与计算的计算节点i统计待计算的标识总数Ni,并将所述总数通知给其他计算节点; A statistics module, suitable for each calculation node i participating in the calculation to count the total number of identifications Ni to be calculated, and notify the other calculation nodes of the total number;
起始标识计算模块,适于每个参与计算的计算节点根据各计算节点待计算的标识总数Ni,计算本节点起始的第一标识; The initial identification calculation module is suitable for each calculation node participating in the calculation to calculate the initial first identification of the node according to the total number of identifications Ni to be calculated by each calculation node;
向量连续化模块,适于每个参与计算的计算节点根据本节点的起始的第一标识,对本节点的标识向量进行连续化,获得相应的第一标识。与现有技术相比,本发明包括以下优点: The vector continuation module is adapted for each computing node participating in the calculation to serialize the identification vector of the node according to the initial first identification of the node to obtain the corresponding first identification. Compared with the prior art, the present invention includes the following advantages:
本发明每个参与计算的计算节点从存储矩阵数据元素的服务器中读取相应矩阵分块的数据元素,然后根据数据标识的散步规则,将数据元素中的数据标识发送至相应的计算该类数据标识的计算节点中,然后每个参与计算的计算节点将得到的各数据标识生成数据标识向量,对该数据标识向量中每个分量(也即数据标识)进行连续化,获得与每个分量对应的第一标识;然后每个参与计算的计算节点再将本地计算得到的数据标识与第一标识的对应关系通知给其他计算节点,那么其他计算节点即可获知本地需要进行计算 的数据元素的连续化后的第一标识。在这个过程中,对于大规模的矩阵数据,可以通过各个计算节点并行的进行连续化,加快了连续化的速度,提高了数据处理效率。 In the present invention, each computing node participating in the calculation reads the data elements of the corresponding matrix block from the server that stores the matrix data elements, and then sends the data identification in the data element to the corresponding calculation data of this type according to the spreading rules of the data identification. In the identified computing nodes, each computing node that participates in the calculation will generate a data identification vector for each data identification obtained, and continue each component (that is, the data identification) in the data identification vector to obtain the corresponding to each component. Then each computing node participating in the calculation notifies other computing nodes of the corresponding relationship between the locally calculated data ID and the first ID, and then other computing nodes can learn the continuity of the data elements that need to be calculated locally. The first logo after conversion. In this process, for large-scale matrix data, serialization can be carried out in parallel through each computing node, which speeds up the serialization speed and improves the data processing efficiency.
上述说明仅是本发明技术方案的概述,为了能够更清楚了解本发明的技术手段,而可依照说明书的内容予以实施,并且为了让本发明的上述和其它目的、特征和优点能够更明显易懂,以下特举本发明的具体实施方式。 The above description is only an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention, it can be implemented according to the contents of the description, and in order to make the above and other purposes, features and advantages of the present invention more obvious and understandable , the specific embodiments of the present invention are enumerated below.
附图说明 Description of drawings
通过阅读下文优选实施方式的详细描述,各种其他的优点和益处对于本领域普通技术人员将变得清楚明了。附图仅用于示出优选实施方式的目的,而并不认为是对本发明的限制。而且在整个附图中,用相同的参考符号表示相同的部件。在附图中: Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiment. The drawings are only for the purpose of illustrating a preferred embodiment and are not to be considered as limiting the invention. Also throughout the drawings, the same reference numerals are used to designate the same parts. In the attached picture:
图1示出了根据本发明一个实施例的一种矩阵数据元素标识连续化方法实施例一的流程示意图; Fig. 1 shows a schematic flow chart of Embodiment 1 of a method for continuous identification of matrix data elements according to an embodiment of the present invention;
图2示出了根据本发明一个实施例的矩阵数据存储逻辑示意图; Fig. 2 shows a schematic diagram of matrix data storage logic according to an embodiment of the present invention;
图3根据本发明一个实施例的一种矩阵数据元素标识连续化方法实施例二的流程示意图; Fig. 3 is a schematic flowchart of Embodiment 2 of a method for continuous identification of matrix data elements according to an embodiment of the present invention;
图4示出了根据本发明实施例的一种数据标识广播逻辑示意图; Fig. 4 shows a schematic diagram of a data identification broadcast logic according to an embodiment of the present invention;
图5根据本发明一个实施例的一种矩阵数据元素标识连续化方法实施例三的流程示意图; Fig. 5 is a schematic flow chart of Embodiment 3 of a method for continuous identification of matrix data elements according to an embodiment of the present invention;
图6根据本发明一个实施例的一种矩阵数据元素标识连续化系统实施例一的结构示意图; FIG. 6 is a schematic structural diagram of Embodiment 1 of a matrix data element identification serialization system according to an embodiment of the present invention;
图7示出了根据本发明一个实施例的一种矩阵数据元素标识连续化系统实施例二的结构示意图;以及 Fig. 7 shows a schematic structural diagram of Embodiment 2 of a matrix data element identification serialization system according to an embodiment of the present invention; and
图8示出了根据本发明一个实施例的一种矩阵数据元素标识连续化系统实施例三的结构示意图。 Fig. 8 shows a schematic structural diagram of Embodiment 3 of a matrix data element identification serialization system according to an embodiment of the present invention.
具体实施方式 detailed description
下面将参照附图更详细地描述本公开的示例性实施例。虽然附图中显示 了本公开的示例性实施例,然而应当理解,可以以各种形式实现本公开而不应被这里阐述的实施例所限制。相反,提供这些实施例是为了能够更透彻地理解本公开,并且能够将本公开的范围完整的传达给本领域的技术人员。 Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided for more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
参照图1,示出了本发明一种矩阵数据元素标识连续化方法实施例一的流程示意图,具体可以包括: Referring to Fig. 1, it shows a schematic flow chart of Embodiment 1 of a method for continuous identification of matrix data elements according to the present invention, which may specifically include:
步骤110,针对N个计算节点,每个参与计算的计算节点读取矩阵数据中被分配给该计算节点的矩阵分块的数据元素; Step 110, for N computing nodes, each computing node participating in the computing reads the data elements of the matrix block assigned to the computing node in the matrix data;
在本发明实施例中,矩阵数据存储在指定的数据服务器中,比如日志数据,其存储的逻辑方式可为矩阵的形式。如图2所示,value为实际的数据内容,比如日志数据,ColKeyi(i=1、2……M)为相应value的列标,RowKeyi(i=1、2……N)为相应value的行标。其中在该稀疏矩阵中,每行没列可能存在一定数量的非零元素(即实际数据),和大量的零元素(零元素没有数据,不进行存储)。 In the embodiment of the present invention, the matrix data is stored in a designated data server, such as log data, and the logical storage method may be in the form of a matrix. As shown in Figure 2, value is the actual data content, such as log data, ColKeyi (i=1, 2...M) is the column label of the corresponding value, and RowKeyi (i=1, 2...N) is the corresponding value row mark. In the sparse matrix, there may be a certain number of non-zero elements (that is, actual data) in each row and column, and a large number of zero elements (zero elements have no data and are not stored).
那么对于用于计算的N个计算节点来说(也即N个计算服务器),首先需要预先将图1的矩阵数据进行分块,比如按行分为N块(N小于等于行数,一般情况下计算节点的个数远远小于矩阵的行数和列数),然后分别将N指定给一个计算节点,由该计算节点进行处理。 Then, for N computing nodes (that is, N computing servers) used for computing, it is first necessary to divide the matrix data in Figure 1 into blocks in advance, for example, divide them into N blocks by row (N is less than or equal to the number of rows, generally The number of lower computing nodes is much smaller than the number of rows and columns of the matrix), and then N is assigned to a computing node, and the computing node performs processing.
那么在进行实际计算之前,各个计算节点需要根据预先指定的矩阵分块,读取相应矩阵分块的数据。比如当前存在10个计算节点,10000行*10000列矩阵的矩阵数据,其中第1~1000行的数据分配给计算节点1,第1001~2000行的数据分配给计算节点2,……第9001~10000行的数据分配给计算节点10,那么计算节点1至10则分别读取相应1000行的数据。 Then, before the actual calculation, each computing node needs to read the data of the corresponding matrix block according to the pre-specified matrix block. For example, there are currently 10 computing nodes, matrix data of 10,000 rows*10,000 columns, among which the data of the 1st to 1000th row is allocated to the computing node 1, the data of the 1001st to 2000th row is allocated to the computing node 2, ... the 9001st~ 10,000 rows of data are allocated to computing node 10, and then computing nodes 1 to 10 respectively read the corresponding 1,000 rows of data.
步骤120,每个参与计算的计算节点根据预置的数据标识散步规则,将所读取的数据元素中的数据标识保留在本地或者发送到相应的计算节点,并接收剩余N-1个计算节点发送的数据标识,获得由所述计算节点进行处理的最终数据标识; Step 120, each computing node participating in the calculation keeps the data identifier in the read data element locally or sends it to the corresponding computing node according to the preset data identifier spreading rule, and receives the remaining N-1 computing nodes The sent data identifier, to obtain the final data identifier processed by the computing node;
本发明实施例为了将矩阵数据的数据标识利用各计算节点进行并行的连续化(也即id化),可将各节点的矩阵数据按某个规则将具有同一属性的 数据标识集中发送到某个计算节点进行处理。也即每个参与计算的计算节点,将将当前读取的每个数据元素的数据标识,根据预置的数据标识散步规则进行计算,根据计算结果见数据标识发送给与计算结果相对应的计算节点。同时,每个参与计算的计算节点也接收其他计算节点发送到本节点数据标识。那么最终,每个参与计算的计算节点则保存了未发送出去的数据标识和其他计算节点发送到本节点数据标识。 In the embodiment of the present invention, in order to serialize (i.e. idize) the data identification of the matrix data in parallel using each computing node, the matrix data of each node can be sent to a certain data identification with the same attribute according to a certain rule. computing nodes for processing. That is to say, each computing node participating in the calculation will calculate the data identifier of each data element currently read according to the preset data identifier distribution rules, and send the data identifier to the calculation corresponding to the calculation result according to the calculation result. node. At the same time, each computing node participating in the calculation also receives the data identification sent by other computing nodes to the node. Then in the end, each computing node participating in the calculation saves the unsent data identifier and the data identifier sent to the node by other computing nodes.
如此每个参与计算的计算节点只处理一部分数据标识,并且各个计算节点处理的数据标识两两互不相同。 In this way, each computing node participating in the calculation only processes a part of data identifiers, and the data identifiers processed by each computing node are different from each other.
在本申请实施例中,各计算节点之间的通信通过MPI(Message Passing Interface,讯息传递接口;一种消息传递编程接口,同时提供了实现其一系列接口的多语言函数库)进行。 In the embodiment of this application, the communication between computing nodes is carried out through MPI (Message Passing Interface, message passing interface; a message passing programming interface, and a multilingual function library for implementing a series of interfaces is provided at the same time).
即每个参与计算的计算节点根据预置的数据标识散步规则,通过MPI将所读取的数据元素中的数据标识保留在本地或者发送到相应的计算节点,并接收剩余N-1个计算节点发送的数据标识,获得由所述计算节点进行处理的最终数据标识。 That is, each computing node participating in the calculation retains the data identifier in the read data element locally or sends it to the corresponding computing node through MPI according to the preset data identifier spreading rule, and receives the remaining N-1 computing nodes The sent data identifier is used to obtain the final data identifier processed by the computing node.
步骤130,每个参与计算的计算节点根据所述最终数据标识进行连续化,获得与每个数据标识相应的第一标识; Step 130, each computing node participating in the calculation performs serialization according to the final data identifier, and obtains a first identifier corresponding to each data identifier;
如前所述,每个参与计算的计算节点最终保存了未发送出去的数据标识和其他计算节点发送到本节点数据标识,那么每个参与计算的计算节点基于上述最终数据标识,进行连续化。 As mentioned above, each computing node participating in the calculation finally saves the unsent data identifier and the data identifier sent to the node by other computing nodes, then each computing node participating in the calculation performs serialization based on the above-mentioned final data identifier.
其中,进行连续化时,每个参与计算的计算节点根据所述最终数据标识,生成数据标识向量并进行向量连续化,获得与每个数据标识相应的第一标识。 Wherein, when performing serialization, each computing node participating in the calculation generates a data identification vector according to the final data identification and performs vector serialization to obtain a first identification corresponding to each data identification.
步骤140,每个参与计算的计算节点将第一标识与原数据标识的对应关系通知给其他计算节点。 Step 140, each computing node participating in the calculation notifies other computing nodes of the correspondence between the first identifier and the original data identifier.
由于对数据标识进行连续化是在进程中进行,而为了使其他计算节点的进程也能知道同步知道,需要每个参与计算的计算节点将当前id化得到的数据标识与第一标识的对应关系通知给其他计算节点,以使整个计算系统全局 均知道数据标识与第一标识的对应关系,以使后续计算过程可以使各进程方便将相应矩阵分块的数据以第一标识存储于内存中。 Since the serialization of data identification is carried out in the process, and in order to make the processes of other computing nodes know synchronously, it is necessary for each computing node participating in the calculation to convert the corresponding relationship between the data identification obtained by the current id and the first identification Notify other computing nodes so that the entire computing system globally knows the correspondence between the data identifier and the first identifier, so that the subsequent calculation process can make it convenient for each process to store the data of the corresponding matrix block in the memory with the first identifier.
本步骤中,每个参与计算的计算节点通过MPI将第一标识与原数据标识的对应关系通知给其他计算节点。 In this step, each computing node participating in the calculation notifies other computing nodes of the corresponding relationship between the first identifier and the original data identifier through MPI.
参照图3,示出了本发明一种矩阵数据元素标识连续化方法实施例二的流程示意图,具体可以包括: Referring to FIG. 3 , it shows a schematic flow diagram of Embodiment 2 of a method for continuous identification of matrix data elements according to the present invention, which may specifically include:
步骤210,针对N个计算节点,每个参与计算的计算节点读取矩阵数据中按行分块的数据元素。 Step 210, for the N computing nodes, each computing node participating in the calculation reads the row-blocked data elements in the matrix data.
即图2中的矩阵数据按行分成N个行块,并将N个行块分别分配给一个计算节点进行计算。 That is, the matrix data in FIG. 2 is divided into N row blocks by row, and the N row blocks are respectively allocated to a computing node for calculation.
那么每个参与计算的计算节点则读取分配给该计算节点的若干行的数据元素。即计算节点按行标读取矩阵元素,直至在其范围内的行标的矩阵元素读取完毕。 Then each computing node participating in the computing reads the data elements of several rows assigned to the computing node. That is, the computing node reads the matrix elements by row label until the matrix elements of the row labels within its range are completely read.
步骤220,每个参与计算的计算节点根据阈值的列标识散步规则,将所读取的数据元素中的列标识保留在本地或者发送到相应的计算节点;并接收其他N-1个计算节点发送的列标识。 Step 220, each computing node participating in the calculation keeps the column identifier in the read data element locally or sends it to the corresponding computing node according to the column identifier spreading rule of the threshold; and receives the other N-1 computing nodes sending The column ID for .
在本发明实施例中,首先可定义全局的列标(Colkey)的散步规则,将每个数据元素的列标散步到相应计算节点,比如规则: In the embodiment of the present invention, firstly, a global column label (Colkey) distribution rule can be defined, and the column label of each data element is distributed to the corresponding computing node, such as the rule:
R→(RANK=COLKEY%NODES) 公式(1) R→(RANK=COLKEY%NODES) Formula (1)
上述公式为对ColKey针对计算节点总数Nodes取余,每种余数对应一个计算节点R。比如总共4个计算节点A、B、C、D,余数为0,1,2,3,那么余数0可对应计算节点A,余数1可对应计算节点B,余数2可对应计算节点C,余数3可对应计算节点D。 The above formula is to take the remainder of ColKey against the total number of computing nodes Nodes, and each type of remainder corresponds to one computing node R. For example, there are a total of 4 computing nodes A, B, C, and D, and the remainder is 0, 1, 2, and 3, then the remainder 0 corresponds to computing node A, the remainder 1 corresponds to computing node B, the remainder 2 corresponds to computing node C, and the remainder 3 may correspond to compute node D.
那么计算节点将当前读取的矩阵元素,也即(Rowkey,colkey,value),将其中的colkey采用公式(1)进行计算,根据计算结果与计算节点的对应关系,将colkey发送至相应计算节点。每个参与计算的计算节点也接收其他计算节点根据公式(1)对colkey进行计算然后发送到本节点colkey。 Then the computing node calculates the currently read matrix elements, that is, (Rowkey, colkey, value), the colkey in it using the formula (1), and sends the colkey to the corresponding computing node according to the correspondence between the calculation result and the computing node . Each computing node participating in the calculation also receives the colkey calculated by other computing nodes according to the formula (1) and then sends it to the node colkey.
步骤230,每个参与计算的计算节点根据本地的行标识生成行标识向量, 并对行标识向量进行连续化,获得与每个行标识相应的第一行标识; Step 230, each computing node participating in the calculation generates a row identifier vector according to the local row identifier, and serializes the row identifier vector to obtain the first row identifier corresponding to each row identifier;
步骤240,每个参与计算的计算节点对本地的列标识进行去重并生成列标识向量,并对列标识向量进行连续化,获得与每个列标识相应的第一列标识。 Step 240 , each computing node participating in the calculation deduplicates the local column identifiers to generate a column identifier vector, and serializes the column identifier vector to obtain a first column identifier corresponding to each column identifier.
在步骤230,中,还包括:对相同的列标进行合并。即保证每个colkey只有一份。 In step 230', it also includes: merging the same column labels. That is to say, there is only one copy of each colkey.
由步骤230和240,经过计算节点之间的第一次通信过后,每个参与计算的计算节点保存了一部分列标(colkey)和本节点当前被分配进行处理行矩阵块的行标(rowkey)。那么即可针对该节点保存的rowkey生成行向量,colkey生成列向量,然后进行连续化(id化),得到行标识和第一行标识(连续化后的标识)的对应关系,和列标识和第一列标识(连续化后的标识)的对应关系,也即(RowKey->RowId)和(ColKey->ColId)。 From steps 230 and 240, after the first communication between computing nodes, each computing node participating in the calculation saves a part of the column key (colkey) and the row key (rowkey) that the node is currently assigned to process the row matrix block . Then you can generate a row vector for the rowkey saved in this node, colkey generates a column vector, and then perform serialization (idization) to obtain the corresponding relationship between the row identifier and the first row identifier (the serialized identifier), and the column identifier and The corresponding relationship of the first column identifier (the serialized identifier), that is, (RowKey->RowId) and (ColKey->ColId).
其中,针对行向量和列向量的连续化,其采用方法包括: Among them, for the continuation of row vectors and column vectors, the methods used include:
步骤S11,每个参与计算的计算节点i统计待计算的标识总数Ni,并将所述总数通知给其他计算节点; Step S11, each calculation node i participating in the calculation counts the total number of identifiers N i to be calculated, and notifies the other calculation nodes of the total number;
步骤S12,每个参与计算的计算节点根据各计算节点待计算的标识总数Ni,计算本节点起始的第一标识; Step S12, each computing node participating in the calculation calculates the first identifier starting from the node according to the total number N i of identifiers to be calculated by each computing node;
步骤S13,每个参与计算的计算节点根据本节点的起始的第一标识,对本节点的标识向量进行连续化,获得相应的第一标识。 Step S13 , each computing node participating in the calculation serializes the identification vector of the node according to the initial first identification of the node, and obtains the corresponding first identification.
下面以列向量为例进行说明: Let's take a column vector as an example to illustrate:
1、针对N个计算节点,每个参与计算的计算节点统计其列向量中分量的数目Ni; 1. For N computing nodes, count the number N i of components in its column vector for each computing node participating in the calculation;
2、每个计算节i点调用MPI_Allgather函数将本节点的分量数目Ni广播给其他N-1计算节点,并接收其他N-1个计算节点广播的分量数目,获得每个参与计算的计算节点i计算的分量数目; 2. Each computing node i calls the MPI_Allgather function to broadcast the number of components N i of this node to other N-1 computing nodes, and receive the number of components broadcast by other N-1 computing nodes, and obtain each computing node participating in the calculation the number of components computed by i;
3、每个参与计算的计算节点i,根据如下公式(2)计算本节点的起始(第一列标识)ID编号: 3. For each calculation node i participating in the calculation, calculate the starting (first column identification) ID number of this node according to the following formula (2):
其中,Ni为计算节点i的分量数目,rank为当前计算节点的编号(rank可设置为0……n,其中rank=0时,StarID=0)。 Wherein, N i is the component number of computing node i, and rank is the serial number of the current computing node (rank can be set to 0...n, where rank=0, StarID=0).
4、每个参与计算的计算节点根据本节点的起始ID号,对本节点列向量的各分量进行id化。 4. Each computing node participating in the calculation idizes each component of the column vector of the node according to the initial ID number of the node.
当然本申请对各个计算节点针对(RowKey->RowId)和(ColKey->ColId)这种二维结构形式的连续ID化还可采用其他形式,本发明实施例对其加以限制。 Of course, in this application, other forms can also be used for the continuous ID of each computing node in the two-dimensional structure form (RowKey->RowId) and (ColKey->ColId), which is limited by the embodiment of the present invention.
另外,可选的,还包括: Also, optionally, include:
步骤S21,在本计算结点内部设置多个工作线程,并将本结点处理的行分量依次分配到每个工作线程上; Step S21, setting multiple working threads inside the computing node, and assigning the row components processed by the node to each working thread in turn;
步骤S22,利用每个工作线程对各自对应的数据进行连接id化处理。 Step S22, using each worker thread to perform connection id processing on the corresponding data.
可选地,所述利用每个工作线程对各自对应的数据进行连接id化处理,包括: Optionally, the use of each worker thread to perform connection id processing on the corresponding data includes:
步骤S31对于任意一个工作线程, Step S31 For any worker thread,
判断当前处理的数据是否是自身所处理的最后一条数据; Determine whether the currently processed data is the last piece of data processed by itself;
若是,则结束并退出处理流程; If so, end and exit the processing flow;
若否,则为当前数据赋予id,并触发下一条数据的处理。 If not, assign an id to the current data and trigger the processing of the next piece of data.
可选地,所述触发下一条数据的处理,包括:利用原子递增atomic_inc,对下一条数据进行连接id化处理。 Optionally, the triggering the processing of the next piece of data includes: performing connection id processing on the next piece of data by using atomic increment atomic_inc.
在上述对分量进行id化的过程中,总体上分为行分量处理过程,和列分量处理过程,即每个参与计算的计算节点计算行分量时获取其他计算节点的行分量数据进行计算,每个参与计算的计算节点计算列分量时获取其他计算节点的列分量数据进行计算。 In the above-mentioned process of idizing components, it is generally divided into row component processing and column component processing, that is, each computing node participating in the calculation obtains the row component data of other computing nodes to calculate the row component, and each When a computing node participating in the calculation calculates the column component, it obtains the column component data of other computing nodes for calculation.
通过上述对分量的计算,那么数据并不是在一个队列中依次进行处理的,而是在多个队列中并行处理的,其处理速度相对现有技术中的 id化处理有大幅度的提升。并行处理的结点数越多,该数据被处理结束的速度就越快。采用本发明实施例能够缩短数据存储的时间,尤其是对于大规模数据的存储,能够起到节省时间提高存储速率的作用,满足大规模数据存储的时间性要求,节省系统资源。 Through the calculation of the above-mentioned components, the data is not sequentially processed in one queue, but processed in parallel in multiple queues, and its processing speed is greatly improved compared with the id-based processing in the prior art. The more nodes processed in parallel, the faster the data will be processed. Adopting the embodiment of the present invention can shorten the time of data storage, especially for large-scale data storage, can save time and increase the storage rate, meet the time requirement of large-scale data storage, and save system resources.
步骤250,每个参与计算的计算节点根据第一列标识与原列标识的对应关系,将第一列标识通知给其他计算节点。 Step 250, each computing node participating in the calculation notifies other computing nodes of the first column identifier according to the corresponding relationship between the first column identifier and the original column identifier.
在本发明实施例中,由于每个参与计算的计算节点处理的行向量为本身需要处理的矩阵数据的行表,即矩阵数据是按行划分给每个参与计算的计算节点的,因此(RowKey->RowId)和本地的RowKey是一一对应的。而(ColKey->ColId)和本地的ColKey不是一一对应,每一行数据都可能包含全部的列,因此需要将(ColKey->ColId)全局化,即每个参与计算的计算节点将本地id化得到的(ColKey->ColId)广播到其他N-1个计算节中,参照图4,其为本实施例每个参与计算的计算节点的每个(ColKey->ColId)广播到其他计算节点的一个逻辑示意图。每个参与计算的计算节点计算得到的(ColKey->ColId)广播到其他计算节点相应的colkey处。如此,对于全局计算节点来说,均可记录所有计算节点计算的(ColKey->ColId)和其节点本身的(RowKey->RowId)。 In the embodiment of the present invention, since the row vector processed by each computing node participating in the calculation is the row table of the matrix data that needs to be processed, that is, the matrix data is divided into each computing node participating in the calculation by row, so (RowKey ->RowId) and the local RowKey are in one-to-one correspondence. However, (ColKey->ColId) is not in one-to-one correspondence with the local ColKey, and each row of data may contain all columns, so (ColKey->ColId) needs to be globalized, that is, each computing node participating in the calculation will localize the id The obtained (ColKey->ColId) is broadcast to other N-1 calculation nodes, referring to Figure 4, which is the broadcast of each (ColKey->ColId) of each calculation node participating in the calculation to other calculation nodes in this embodiment A schematic diagram. The (ColKey->ColId) calculated by each computing node participating in the calculation is broadcast to the corresponding colkey of other computing nodes. In this way, for global computing nodes, (ColKey->ColId) calculated by all computing nodes and (RowKey->RowId) of the node itself can be recorded.
其中,将MPI的MPI_Allgather接口,将本地的(ColKey->ColId)广播到其他所有计算结点。 Among them, the MPI_Allgather interface of MPI broadcasts the local (ColKey->ColId) to all other computing nodes.
然后,每个参与计算的计算节点在计算其行块的数据元素时,即可根据其(RowKey->RowId)和(ColKey->ColId)对其value存储至内存,在计算时,也可很容易的知道数据界限。 Then, each computing node participating in the calculation can store its value in the memory according to its (RowKey->RowId) and (ColKey->ColId) when calculating the data elements of its row block. It is easy to know the data boundaries.
参照图5,示出了本发明一种矩阵数据元素标识连续化方法实施例二的流程示意图,具体可以包括: Referring to FIG. 5 , it shows a schematic flow diagram of Embodiment 2 of a method for continuous identification of matrix data elements according to the present invention, which may specifically include:
步骤310,针对N个计算节点,每个参与计算的计算节点读取矩阵数据中按列分块的数据元素。 Step 310, for the N computing nodes, each computing node participating in the calculation reads the data elements in the matrix data divided by column.
即将图2中矩阵数据即按列分成N个行块,并将N个列块分别分配给一个计算节点进行计算。那么每个参与计算的计算节点则读取分配给该计算 节点的若干列的数据元素。 That is, the matrix data in Figure 2 is divided into N row blocks by column, and the N column blocks are respectively assigned to a computing node for calculation. Then each computing node participating in the calculation reads the data elements of several columns assigned to the computing node.
步骤320,每个参与计算的计算节点根据阈值的行标识散步规则,将所读取的数据元素中的行标识保留在本地或者发送到相应的计算节点;并接收其他计算节点发送的行标识。 Step 320 , each computing node participating in the calculation saves the row ID in the read data element locally or sends it to the corresponding computing node according to the row ID spreading rule of the threshold; and receives the row ID sent by other computing nodes.
在本发明实施例中,首先可定义全局的列标(Colkey)的散步规则,将每个数据元素的列标散步到相应计算节点,比如规则: In the embodiment of the present invention, firstly, a global column label (Colkey) distribution rule can be defined, and the column label of each data element is distributed to the corresponding computing node, such as the rule:
R→(RANK=ROWKEY%NODES) 公式(3) R→(RANK=ROWKEY%NODES) formula (3)
那么计算节点将当前读取的矩阵元素,也即(Rowkey,colkey,value),将其中的rowkey采用公式(3)进行计算,根据计算结果与计算节点的对应关系,将rowkey发送至相应计算节点。每个参与计算的计算节点也接收其他计算节点根据公式(3)对rowkey进行计算然后发送到本节点rowkey。 Then the computing node calculates the currently read matrix elements, that is, (Rowkey, colkey, value), the rowkey in it using the formula (3), and sends the rowkey to the corresponding computing node according to the corresponding relationship between the calculation result and the computing node . Each computing node participating in the calculation also receives the rowkey calculated by other computing nodes according to the formula (3) and then sends the rowkey to this node.
步骤330,每个参与计算的计算节点根据本地的列标识生成行标识向量,并对列标识向量进行连续化,获得与每个列标识相应的第一列标识; Step 330, each computing node participating in the calculation generates a row identifier vector according to the local column identifier, and serializes the column identifier vector to obtain a first column identifier corresponding to each column identifier;
步骤340,每个参与计算的计算节点对本地的行标识进行去重并生成行标识向量,并对行标识向量进行连续化,获得与每个行标识相应的第一行标识。 Step 340 , each computing node participating in the calculation deduplicates the local row IDs to generate a row ID vector, and serializes the row ID vectors to obtain the first row ID corresponding to each row ID.
在步骤330,中,还包括:对相同的行标进行合并。即保证每个rowkey只有一份。 In step 330', it also includes: merging the same row labels. That is, it is guaranteed that each rowkey has only one copy.
第一次通信过后,步骤320,步骤330,每个参与计算的计算节点保存了一部分行标(rowkey)和本节点当前被分配进行处理行矩阵块的列标(colkey)。那么即可针对该节点保存的rowkey生成行向量,colkey生成列向量,然后进行连续化(id化),得到行标识和第一行标识(连续化后的标识)的对应关系,和列标识和第一列标识(连续化后的标识)的对应关系,也即(RowKey->RowId)和(ColKey->ColId)。 After the first communication, in steps 320 and 330, each computing node participating in the calculation saves a part of the row key (rowkey) and the column key (colkey) of the node currently assigned to process the row matrix block. Then you can generate a row vector for the rowkey saved in this node, colkey generates a column vector, and then perform serialization (idization) to obtain the corresponding relationship between the row identifier and the first row identifier (the serialized identifier), and the column identifier and The corresponding relationship of the first column identifier (the serialized identifier), that is, (RowKey->RowId) and (ColKey->ColId).
其也可以利用步骤S11至S13和公式(2)进行计算。 It can also be calculated using steps S11 to S13 and formula (2).
步骤350,每个参与计算的计算节点根据第一行标识与原行标识的对应关系,将第一行标识通知给其他计算节点。 Step 350, each computing node participating in the calculation notifies other computing nodes of the first row identifier according to the corresponding relationship between the first row identifier and the original row identifier.
本实施例(colKey->colId)和本地的colKey是一一对应的。而 (rowKey->ColId)和本地的rowKey不是一一对应,每一行数据都可能包含全部的列,因此需要将(rowKey->rowId)全局化,即每个参与计算的计算节点将本地id化得到的(rowKey->rowId)广播到其他N-1个计算节中。 In this embodiment (colKey->colId) is in one-to-one correspondence with the local colKey. However, (rowKey->ColId) and the local rowKey are not one-to-one correspondence, and each row of data may contain all columns, so (rowKey->rowId) needs to be globalized, that is, each computing node participating in the calculation will localize the id The obtained (rowKey->rowId) is broadcast to other N-1 calculation sections.
本实施例与实施例二基本原理类似,在此不再详述。 The basic principle of this embodiment is similar to that of the second embodiment, and will not be described in detail here.
参照图6,其示出了本发明一种矩阵数据元素标识连续化系统实施例一的结构示意图,包括: Referring to Fig. 6, it shows a schematic structural diagram of Embodiment 1 of a matrix data element identification serialization system according to the present invention, including:
N个计算节点; N computing nodes;
所述每个参与计算的计算节点400包括: Each computing node 400 participating in computing includes:
数据读取模块410,适于每个参与计算的计算节点读取矩阵数据中被分配给该计算节点的矩阵分块的数据元素; The data reading module 410 is adapted for each computing node participating in the computing to read the data elements of the matrix block assigned to the computing node in the matrix data;
散步和接收模块420,适于每个参与计算的计算节点根据预置的数据标识散步规则,将所读取的数据元素中的数据标识保留在本地或者发送到相应的计算节点,并接收剩余N-1个计算节点发送的数据标识,获得由所述计算节点进行处理的最终数据标识; The spreading and receiving module 420 is adapted to keep the data identification in the read data element locally or send it to the corresponding computing node according to the preset data identification spreading rules for each computing node participating in the calculation, and receive the remaining N - a data identifier sent by a computing node, to obtain the final data identifier processed by the computing node;
连续化模块430,适于每个参与计算的计算节点根据所述最终数据标识进行连续化,获得与每个数据标识相应的第一标识; The serialization module 430 is adapted to serialize each computing node participating in the calculation according to the final data identifier, and obtain a first identifier corresponding to each data identifier;
通知模块440,适于每个参与计算的计算节点将第一标识与原数据标识的对应关系通知给其他计算节点。 The notification module 440 is adapted for each computing node participating in computing to notify other computing nodes of the correspondence between the first identifier and the original data identifier.
可选的,所述数据读取模块进一步适于: Optionally, the data reading module is further adapted to:
每个参与计算的计算节点读取矩阵数据中按行分块的数据元素,或者按列分块的数据元素。 Each computing node participating in the calculation reads the data elements in the matrix data that are divided into blocks by rows, or data elements that are divided into blocks by columns.
可选的,当每个参与计算的计算节点读取矩阵数据中按行分块的数据元素时,所述散步和接收模块包括: Optionally, when each computing node participating in the calculation reads the data elements divided by rows in the matrix data, the spreading and receiving module includes:
列散步和接收模块,适于每个参与计算的计算节点根据阈值的列标识散步规则,将所读取的数据元素中的列标识保留在本地或者发送到相应的计算节点;并接收其他N-1个计算节点发送的列标识。 The column spreading and receiving module is suitable for each computing node participating in the calculation to keep the column identification in the read data element locally or send it to the corresponding computing node according to the column identification spreading rule of the threshold; and receive other N- A column ID sent by a compute node.
可选的,所述连续化模块包括: Optionally, the serialization module includes:
第一行连续化模块,适于每个参与计算的计算节点根据本地的行标识生 成行标识向量,并对行标识向量进行连续化,获得与每个行标识相应的第一行标识; The first row serialization module is suitable for each computing node participating in the calculation to generate a row identifier vector according to the local row identifier, and serialize the row identifier vector to obtain the first row identifier corresponding to each row identifier;
第一列连续化模块,适于每个参与计算的计算节点对本地的列标识进行去重并生成列标识向量,并对列标识向量进行连续化,获得与每个列标识相应的第一列标识。 The first column serialization module is suitable for each computing node participating in the calculation to deduplicate the local column ID and generate a column ID vector, and serialize the column ID vector to obtain the first column corresponding to each column ID logo.
可选的,所述通知模块包括: Optionally, the notification module includes:
第一通知模块,适于每个参与计算的计算节点根据第一列标识与原列标识的对应关系,将第一列标识通知给其他计算节点。 The first notification module is adapted for each computing node participating in the calculation to notify other computing nodes of the first column identifier according to the corresponding relationship between the first column identifier and the original column identifier.
可选的,当每个参与计算的计算节点读取矩阵数据中按列分块的数据元素时,所述散步和接收模块包括: Optionally, when each computing node participating in the calculation reads the data elements in the matrix data divided by columns, the dispersing and receiving module includes:
行散步和接收模块,适于每个参与计算的计算节点根据阈值的行标识散步规则,将所读取的数据元素中的行标识保留在本地或者发送到相应的计算节点;并接收其他计算节点发送的行标识。 The row spreading and receiving module is suitable for each computing node participating in the calculation to keep the row identifier in the read data element locally or send it to the corresponding computing node according to the row identifier spreading rule of the threshold; and receive other computing nodes The row ID sent.
可选的,所述连续化模块包括: Optionally, the serialization module includes:
第二列续化模块,适于每个参与计算的计算节点根据本地的列标识生成行标识向量,并对列标识向量进行连续化,获得与每个列标识相应的第一列标识; The second column continuation module is suitable for each calculation node participating in the calculation to generate a row identification vector according to the local column identification, and perform serialization on the column identification vector to obtain the first column identification corresponding to each column identification;
第二行续化模块,适于每个参与计算的计算节点对本地的行标识进行去重并生成行标识向量,并对行标识向量进行连续化,获得与每个行标识相应的第一行标识。 The second row continuation module is suitable for each computing node participating in the calculation to de-duplicate the local row ID and generate a row ID vector, and perform serialization on the row ID vector to obtain the first row corresponding to each row ID logo.
可选的,所述通知模块包括: Optionally, the notification module includes:
第二通知模块,适于每个参与计算的计算节点根据第一行标识与原行标识的对应关系,将第一行标识通知给其他计算节点。 The second notification module is adapted for each computing node participating in the calculation to notify other computing nodes of the first row identifier according to the corresponding relationship between the first row identifier and the original row identifier.
可选的,所述第一列续化模块、第一行续化模块、第二列续化模块、第二行续化模块包括: Optionally, the first column continuation module, the first row continuation module, the second column continuation module, and the second row continuation module include:
统计模块,适于每个参与计算的计算节点i统计待计算的标识总数Ni,并将所述总数通知给其他计算节点; A statistics module, suitable for each calculation node i participating in the calculation to count the total number of identifications Ni to be calculated, and notify the other calculation nodes of the total number;
起始标识计算模块,适于每个参与计算的计算节点根据各计算节点待计 算的标识总数Ni,计算本节点起始的第一标识; The initial identification calculation module is suitable for each calculation node participating in the calculation to calculate the initial first identification of the node according to the total number of identifications Ni to be calculated by each calculation node;
向量连续化模块,适于每个参与计算的计算节点根据本节点的起始的第一标识,对本节点的标识向量进行连续化,获得相应的第一标识。 The vector continuation module is adapted for each computing node participating in the calculation to serialize the identification vector of the node according to the initial first identification of the node to obtain the corresponding first identification.
参照图7,其示出了本发明一种矩阵数据元素标识连续化系统实施例二的结构示意图,包括: Referring to Fig. 7, it shows a schematic structural diagram of Embodiment 2 of a matrix data element identification serialization system according to the present invention, including:
N个计算节点; N computing nodes;
所述每个参与计算的计算节点500包括: Each computing node 500 participating in computing includes:
数据读取模块510,每个参与计算的计算节点读取矩阵数据中按行分块的数据元素; Data reading module 510, each computing node participating in the calculation reads the data elements in the matrix data divided by rows;
列散步和接收模块520,适于每个参与计算的计算节点根据阈值的列标识散步规则,将所读取的数据元素中的列标识保留在本地或者发送到相应的计算节点;并接收其他N-1个计算节点发送的列标识; The column spreading and receiving module 520 is adapted to keep the column identification in the read data element locally or send it to the corresponding computing node according to the column identification spreading rule of the threshold for each computing node participating in the calculation; and receive other N - 1 column identifier sent by the compute node;
第一行连续化模块530,适于每个参与计算的计算节点根据本地的行标识生成行标识向量,并对行标识向量进行连续化,获得与每个行标识相应的第一行标识; The first row serialization module 530 is adapted for each computing node participating in the calculation to generate a row identifier vector according to the local row identifier, and serialize the row identifier vector to obtain the first row identifier corresponding to each row identifier;
第一列连续化模块540,适于每个参与计算的计算节点对本地的列标识进行去重并生成列标识向量,并对列标识向量进行连续化,获得与每个列标识相应的第一列标识。 The first column serialization module 540 is adapted for each computing node participating in the calculation to deduplicate the local column ID and generate a column ID vector, and to serialize the column ID vector to obtain the first column ID corresponding to each column ID. Column ID.
第一通知模块550,适于每个参与计算的计算节点根据第一列标识与原列标识的对应关系,将第一列标识通知给其他计算节点。 The first notification module 550 is adapted for each computing node participating in the calculation to notify other computing nodes of the first column identifier according to the corresponding relationship between the first column identifier and the original column identifier.
参照图8,其示出了本发明一种矩阵数据元素标识连续化系统实施例二的结构示意图,包括: Referring to Fig. 8, it shows a schematic structural diagram of Embodiment 2 of a matrix data element identification serialization system according to the present invention, including:
N个计算节点; N computing nodes;
所述每个参与计算的计算节点600包括: Each computing node 600 participating in computing includes:
数据读取模块610,每个参与计算的计算节点读取矩阵数据中按列分块的数据元素; Data reading module 610, each computing node participating in the calculation reads the data elements in the matrix data divided into columns;
行散步和接收模块620,适于每个参与计算的计算节点根据阈值的行标识散步规则,将所读取的数据元素中的行标识保留在本地或者发送到相应的 计算节点;并接收其他计算节点发送的行标识。 Row spreading and receiving module 620, adapted to each computing node participating in the calculation according to the row identifier spreading rule of the threshold, keeping the row identifier in the read data element locally or sending it to the corresponding computing node; and receiving other calculation The row ID sent by the node.
第二列续化模块630,适于每个参与计算的计算节点根据本地的列标识生成行标识向量,并对列标识向量进行连续化,获得与每个列标识相应的第一列标识; The second column continuation module 630 is suitable for each computing node participating in the calculation to generate a row identification vector according to the local column identification, and to perform serialization on the column identification vector to obtain the first column identification corresponding to each column identification;
第二行续化模块640,适于每个参与计算的计算节点对本地的行标识进行去重并生成行标识向量,并对行标识向量进行连续化,获得与每个行标识相应的第一行标识。 The second row continuation module 640 is suitable for each computing node participating in the calculation to de-duplicate the local row ID and generate a row ID vector, and perform serialization on the row ID vector to obtain the first row ID corresponding to each row ID Row ID.
第二通知模块650,适于每个参与计算的计算节点根据第一行标识与原行标识的对应关系,将第一行标识通知给其他计算节点。 The second notification module 650 is adapted for each computing node participating in the calculation to notify other computing nodes of the first row identifier according to the corresponding relationship between the first row identifier and the original row identifier.
在此提供的算法和显示不与任何特定计算机、虚拟系统或者其它设备固有相关。各种通用系统也可以与基于在此的示教一起使用。根据上面的描述,构造这类系统所要求的结构是显而易见的。此外,本发明也不针对任何特定编程语言。应当明白,可以利用各种编程语言实现在此描述的本发明的内容,并且上面对特定语言所做的描述是为了披露本发明的最佳实施方式。 The algorithms and displays presented herein are not inherently related to any particular computer, virtual system, or other device. Various generic systems can also be used with the teachings based on this. The structure required to construct such a system is apparent from the above description. Furthermore, the present invention is not specific to any particular programming language. It should be understood that various programming languages can be used to implement the content of the present invention described herein, and the above description of specific languages is for disclosing the best mode of the present invention.
在此处所提供的说明书中,说明了大量具体细节。然而,能够理解,本发明的实施例可以在没有这些具体细节的情况下实践。在一些实例中,并未详细示出公知的方法、结构和技术,以便不模糊对本说明书的理解。 In the description provided herein, numerous specific details are set forth. However, it is understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure the understanding of this description.
类似地,应当理解,为了精简本公开并帮助理解各个发明方面中的一个或多个,在上面对本发明的示例性实施例的描述中,本发明的各个特征有时被一起分组到单个实施例、图、或者对其的描述中。然而,并不应将该公开的方法解释成反映如下意图:即所要求保护的本发明要求比在每个权利要求中所明确记载的特征更多的特征。更确切地说,如下面的权利要求书所反映的那样,发明方面在于少于前面公开的单个实施例的所有特征。因此,遵循具体实施方式的权利要求书由此明确地并入该具体实施方式,其中每个权利要求本身都作为本发明的单独实施例。 Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the invention, in order to streamline this disclosure and to facilitate an understanding of one or more of the various inventive aspects, various features of the invention are sometimes grouped together in a single embodiment, figure, or its description. This method of disclosure, however, is not to be interpreted as reflecting an intention that the claimed invention requires more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the Detailed Description are hereby expressly incorporated into this Detailed Description, with each claim standing on its own as a separate embodiment of this invention.
本领域那些技术人员可以理解,可以对实施例中的设备中的模块进行自适应性地改变并且把它们设置在与该实施例不同的一个或多个设备中。可以 把实施例中的模块或单元或组件组合成一个模块或单元或组件,以及此外可以把它们分成多个子模块或子单元或子组件。除了这样的特征和/或过程或者单元中的至少一些是相互排斥之外,可以采用任何组合对本说明书(包括伴随的权利要求、摘要和附图)中公开的所有特征以及如此公开的任何方法或者设备的所有过程或单元进行组合。除非另外明确陈述,本说明书(包括伴随的权利要求、摘要和附图)中公开的每个特征可以由提供相同、等同或相似目的的替代特征来代替。 Those skilled in the art can understand that the modules in the device in the embodiment can be adaptively changed and arranged in one or more devices different from the embodiment. Modules or units or components in the embodiments may be combined into one module or unit or component, and furthermore may be divided into a plurality of submodules or subunits or subassemblies. All features disclosed in this specification (including accompanying claims, abstract and drawings) and any method or method so disclosed may be used in any combination, except that at least some of such features and/or processes or units are mutually exclusive. All processes or units of equipment are combined. Each feature disclosed in this specification (including accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
此外,本领域的技术人员能够理解,尽管在此所述的一些实施例包括其它实施例中所包括的某些特征而不是其它特征,但是不同实施例的特征的组合意味着处于本发明的范围之内并且形成不同的实施例。例如,在下面的权利要求书中,所要求保护的实施例的任意之一都可以以任意的组合方式来使用。 Furthermore, those skilled in the art will understand that although some embodiments described herein include some features included in other embodiments but not others, combinations of features from different embodiments are meant to be within the scope of the invention. and form different embodiments. For example, in the following claims, any of the claimed embodiments may be used in any combination.
本发明的各个部件实施例可以以硬件实现,或者以在一个或者多个处理器上运行的软件模块实现,或者以它们的组合实现。本领域的技术人员应当理解,可以在实践中使用微处理器或者数字信号处理器(DSP)来实现根据本发明实施例的一种矩阵数据元素标识连续化设备中的一些或者全部部件的一些或者全部功能。本发明还可以实现为用于执行这里所描述的方法的一部分或者全部的设备或者装置程序(例如,计算机程序和计算机程序产品)。这样的实现本发明的程序可以存储在计算机可读介质上,或者可以具有一个或者多个信号的形式。这样的信号可以从因特网网站上下载得到,或者在载体信号上提供,或者以任何其他形式提供。 The various component embodiments of the present invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. Those skilled in the art should understand that a microprocessor or a digital signal processor (DSP) can be used in practice to implement a matrix data element identification serialization device according to an embodiment of the present invention. Full functionality. The present invention can also be implemented as an apparatus or an apparatus program (for example, a computer program and a computer program product) for performing a part or all of the methods described herein. Such a program for realizing the present invention may be stored on a computer-readable medium, or may be in the form of one or more signals. Such a signal may be downloaded from an Internet site, or provided on a carrier signal, or provided in any other form.
应该注意的是上述实施例对本发明进行说明而不是对本发明进行限制,并且本领域技术人员在不脱离所附权利要求的范围的情况下可设计出替换实施例。在权利要求中,不应将位于括号之间的任何参考符号构造成对权利要求的限制。单词“包含”不排除存在未列在权利要求中的元件或步骤。位于元件之前的单词“一”或“一个”不排除存在多个这样的元件。本发明可以借助于包括有若干不同元件的硬件以及借助于适当编程的计算机来实现。在列举了若干装置的单元权利要求中,这些装置中的若干个可以是通过同一 个硬件项来具体体现。单词第一、第二、以及第三等的使用不表示任何顺序。可将这些单词解释为名称。 It should be noted that the above-mentioned embodiments illustrate rather than limit the invention, and that those skilled in the art will be able to design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention can be implemented by means of hardware comprising several distinct elements, and by means of a suitably programmed computer. In a unit claim enumerating several means, several of these means may be embodied by one and the same item of hardware. The use of the words first, second, and third, etc. does not indicate any order. These words can be interpreted as names.
Claims (18)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510138373.XA CN104714782B (en) | 2012-12-05 | 2012-12-05 | A kind of matrix data elements mark continuous process and system |
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201210518577.2A CN103049246B (en) | 2012-12-05 | 2012-12-05 | Method and system for identification continuity of array data elements |
CN201510138373.XA CN104714782B (en) | 2012-12-05 | 2012-12-05 | A kind of matrix data elements mark continuous process and system |
Related Parent Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201210518577.2A Division CN103049246B (en) | 2012-12-05 | 2012-12-05 | Method and system for identification continuity of array data elements |
Publications (2)
Publication Number | Publication Date |
---|---|
CN104714782A true CN104714782A (en) | 2015-06-17 |
CN104714782B CN104714782B (en) | 2017-12-08 |
Family
ID=53414161
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510138373.XA Expired - Fee Related CN104714782B (en) | 2012-12-05 | 2012-12-05 | A kind of matrix data elements mark continuous process and system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN104714782B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109062856A (en) * | 2018-07-17 | 2018-12-21 | 北京比特大陆科技有限公司 | Calculation processing apparatus and method, electronic equipment |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6438496B1 (en) * | 1997-08-20 | 2002-08-20 | Toa Gosei Kabushiki Kaisha | Method and apparatus for revealing latent characteristics existing in symbolic sequences |
CN1874538A (en) * | 2005-07-20 | 2006-12-06 | 华为技术有限公司 | Concurrent method for treating calling events |
CN102141976A (en) * | 2011-01-10 | 2011-08-03 | 中国科学院软件研究所 | Method for storing diagonal data of sparse matrix and SpMV (Sparse Matrix Vector) realization method based on method |
CN103049246A (en) * | 2012-12-05 | 2013-04-17 | 北京奇虎科技有限公司 | Method and system for identification continuity of array data elements |
-
2012
- 2012-12-05 CN CN201510138373.XA patent/CN104714782B/en not_active Expired - Fee Related
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6438496B1 (en) * | 1997-08-20 | 2002-08-20 | Toa Gosei Kabushiki Kaisha | Method and apparatus for revealing latent characteristics existing in symbolic sequences |
CN1874538A (en) * | 2005-07-20 | 2006-12-06 | 华为技术有限公司 | Concurrent method for treating calling events |
CN102141976A (en) * | 2011-01-10 | 2011-08-03 | 中国科学院软件研究所 | Method for storing diagonal data of sparse matrix and SpMV (Sparse Matrix Vector) realization method based on method |
CN103049246A (en) * | 2012-12-05 | 2013-04-17 | 北京奇虎科技有限公司 | Method and system for identification continuity of array data elements |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109062856A (en) * | 2018-07-17 | 2018-12-21 | 北京比特大陆科技有限公司 | Calculation processing apparatus and method, electronic equipment |
WO2020015252A1 (en) * | 2018-07-17 | 2020-01-23 | 北京比特大陆科技有限公司 | Computation processing apparatus and method, and electronic device |
CN109062856B (en) * | 2018-07-17 | 2021-09-21 | 北京比特大陆科技有限公司 | Computing processing device and method, and electronic device |
Also Published As
Publication number | Publication date |
---|---|
CN104714782B (en) | 2017-12-08 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
HRP20201937T1 (en) | Methods and apparatus for a distributed database within a network | |
JP2016527636A5 (en) | ||
US10127281B2 (en) | Dynamic hash table size estimation during database aggregation processing | |
CN105512179B (en) | Hard-wired data sorting device, method and data processing chip | |
JP2020519981A (en) | Dedicated neural network training chip | |
US9400767B2 (en) | Subgraph-based distributed graph processing | |
US8375200B2 (en) | Embedded device and file change notification method of the embedded device | |
CN103207785B (en) | The processing method of data download request, Apparatus and system | |
CN104714785A (en) | Task scheduling device, task scheduling method and data parallel processing device | |
CN103336672B (en) | Method for reading data, device and computing device | |
CN106325996B (en) | A method and system for allocating GPU resources | |
US10185743B2 (en) | Method and system for optimizing reduce-side join operation in a map-reduce framework | |
CN111708495B (en) | Ring queue storage method, device, computing device, and storage medium | |
CN103049246B (en) | Method and system for identification continuity of array data elements | |
WO2016202153A1 (en) | Gpu resource allocation method and system | |
EP4102354A1 (en) | Method, circuit, and soc for performing matrix multiplication operation | |
CN103049487B (en) | For the method and system of serialization matrix data elements mark | |
CN104714782B (en) | A kind of matrix data elements mark continuous process and system | |
CN103823712A (en) | Data flow processing method and device for multi-CPU virtual machine system | |
CN103218425A (en) | Method and device for processing browser extension items | |
CN103336721B (en) | Method, device and system for allocating database operation request | |
US10728178B2 (en) | Apparatus and method for distribution of congestion information in a switch | |
CN110837414B (en) | Task processing method and device | |
CN109962861A (en) | A kind of message statistical method and device | |
CN113204382B (en) | Data processing method, device, electronic equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
CF01 | Termination of patent right due to non-payment of annual fee | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20171208 Termination date: 20211205 |