A method and system for directly processing compressed text based on FPGA

Through the method of accelerating compressed text processing of FPGA, hierarchical traversal and hash table preprocessing, the problem of DAG node dependency and rule size differences is solved, and efficient data processing and load balancing is achieved, which is suitable for big data processing.

CN118535320BActive Publication Date: 2024-11-19RENMIN UNIVERSITY OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410399571.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-04-03
Publication Date
2024-11-19
Estimated Expiration
2044-04-03

AI Technical Summary

Technical Problem

When FPGA accelerates compressed text direct processing, the dependency and rule size differences of DAG nodes lead to difficulty in parallelism and pipeline design, and the large amount of data leads to random access competition for off-chip memory, and the throughput of high-bandwidth memory cannot be effectively utilized.

Method used

By preprocessing the compressed text data, it is divided into root rules and other rules, and the FPGA's on-chip cache and hash table are used for interaction and processing, and the top-down or bottom-up traversal strategy is adopted to reduce the number of interactions with external memory. Improve data transmission efficiency and build adaptive DAG data structures on FPGAs.

Benefits of technology

It improves the efficiency of direct processing of compressed text, balances workload, reduces the number of interactions with external memory, improves data transmission efficiency, and is suitable for the field of big data processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118535320B_ABST
    Figure CN118535320B_ABST
Patent Text Reader

Abstract

The present invention relates to a method and system for directly processing compressed text based on FPGA, comprising the following steps: reading compressed text data and an analysis application based on the compressed text data; preprocessing the compressed text data to obtain a DAG data structure adapted to FPGA; determining a preset traversal strategy according to the type of analysis application to be executed on the compressed text data, traversing the DAG data structure on the FPGA, and summarizing and counting the traversal results to obtain data processing results. The present invention proposes a compressed text direct processing technology based on FPGA, proposes an FPGA acceleration optimization solution for the compressed text field, and improves the efficiency of the compressed text direct processing technology. The present invention can be widely used in the field of big data processing technology.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a compressed text direct processing method and system based on FPGA, belonging to the technical field of big data processing. Background Art

[0002] With the development of artificial intelligence and big data, as well as the increase in data-intensive tasks, traditional central processing units (CPUs) and graphics processing units (GPUs) have become inefficient. Therefore, people are beginning to seek new hardware acceleration solutions to meet the growing computing needs. As a flexible and programmable hardware platform, FPGA has shown great potential in accelerating various applications.

[0003] Text Analytics Directly on Compression (TADOC) has been proven to be an effective solution to text analytics problems. Unlike traditional compression methods that require data to be decompressed before processing, TADOC saves space and time by directly processing compressed data. At the same time, in order to meet real-time requirements and pursue further performance, the strategic allocation of FPGA hardware resources and the design of parallel and pipeline structures can significantly improve processing speed. In addition, given the flexibility and programmability of FPGAs, customized hardware accelerators can be developed to be dedicated to TADOC.

[0004] However, there are several problems in accelerating TADOC using FPGA: First, TADOC compresses text data into rules, which can be further represented as a directed acyclic graph (DAG). However, there are a large number of dependencies between the DAG nodes formed by the TADOC rule structure, which is extremely unfavorable for parallelism and pipeline design on FPGA. To make matters worse, the huge difference in rule size leads to unbalanced workload. Second, because the amount of data to be processed is too large to be placed on the on-chip memory of the FPGA at one time, they can only be placed on off-chip memory such as high-bandwidth memory (HBM). Although HBM can provide considerable data throughput, data in TADOC is randomly accessed, which leads to huge data contention. Therefore, direct access to HBM cannot take advantage of its high throughput. Summary of the invention

[0005] In view of the above problems, the purpose of the present invention is to provide a compressed text direct processing method and system based on FPGA, which can apply TADOC in edge devices in a big data environment to support extensive data management and analysis.

[0006] To achieve the above object, the present invention adopts the following technical solutions:

[0007] In a first aspect, the present invention provides a compressed text direct processing method based on FPGA, comprising the following steps:

[0008] Reading compressed text data and analysis application based on the compressed text data;

[0009] Preprocess the compressed text data to obtain a DAG data structure suitable for FPGA;

[0010] The preset traversal strategy is determined according to the type of analysis application to be performed on the compressed text data, the DAG data structure is traversed on the FPGA, and the traversal results are summarized and counted to obtain the data processing results.

[0011] Further, the compressed text data is preprocessed to obtain a DAG data structure suitable for FPGA, including:

[0012] According to the rule characteristics of the compressed text read in, all rules are divided into root rules and other rules except the root rules;

[0013] The on-chip cache of FPGA is used to directly interact and process the root rules stored in the off-chip memory, and the processing results are used as the initial frequencies of all words and other rules; wherein the on-chip cache is an array defined in the on-chip memory of FPGA;

[0014] Read the other rules on the off-chip memory into the on-chip memory of the FPGA one by one, use the self-maintained hash table in the memory pool to pre-process each other rule, count the frequency of words and sub-rules in each other rule, and write them back to the off-chip memory through the pipeline after processing each other rule to obtain a DAG data structure suitable for FPGA.

[0015] Furthermore, the on-chip cache of the FPGA is used to directly interact and process the root rules stored in the off-chip memory, and the processing results are used as the initial frequencies of all words and other rules, including:

[0016] In each cycle clock cycle, 256-bit wide data is read from the input array stored in the off-chip memory and divided into eight 32-bit IDs;

[0017] The eight 32-bit IDs are processed in parallel using the key-value pair list in the on-chip cache;

[0018] After summarizing the parallel processing results, the summary results are used as the initial frequencies of all words and other rules.

[0019] Further, the method of using the key-value pair list in the on-chip cache to process eight 32-bit IDs in parallel includes:

[0020] ① Determine whether there is a key-value pair in the on-chip cache header. If so, write the key-value pair in the on-chip cache header back to the off-chip memory space storing the rules / word frequencies. If not, move all the key-value pairs in the on-chip cache forward by one unit to indicate the update of each key-value pair time slice.

[0021] ② Traverse all rules or words contained in the root rule, and search the key-value pairs in the on-chip cache based on the ID of the rule or word read each time. If found, it means that the rule or word exists in the on-chip cache, and execute step ③, otherwise execute step ④;

[0022] ③ Take the corresponding key-value pair from the on-chip cache, update the value of the key-value pair, and insert the updated key-value pair to the end of the on-chip cache, while setting the original position of the key-value pair to empty;

[0023] ④ Read the frequency corresponding to the sub-rule or word from the off-chip memory that actually stores the rule / word frequency, update the value of the key-value pair, and insert the updated key-value pair into the end of the on-chip cache;

[0024] ⑤ Determine whether the root rule has been traversed. If so, write all remaining key-value pairs in the on-chip cache back to the HBM. Otherwise, return to step ①.

[0025] Furthermore, the other rules on the off-chip memory are read into the on-chip memory of the FPGA one by one, each other rule is pre-processed using a self-maintainable hash table in the memory pool, the frequency of words in each other rule and the frequency of sub-rules are counted, and each other rule is written back to the off-chip memory through the pipeline after processing, to obtain a DAG data structure suitable for the FPGA, including:

[0026] ① Traverse all other rules except the root rule, and initialize the self-maintainable hash table in the FPGA memory pool before processing each other rule;

[0027] ②Use the pipeline to read the words and sub-rules contained in other rules to be processed in turn, insert their frequencies into the hash table to update the frequencies;

[0028] ③After processing other current rules, use the pipeline to write the key-value pairs on the hash table back to the off-chip memory;

[0029] ④ Determine whether all other rules have been traversed. If not, return to step ①, otherwise exit.

[0030] Further, the preset traversal strategy is determined according to the type of analysis application to be performed on the compressed text data, the DAG data structure is traversed on the FPGA, and the traversal results are summarized and counted to obtain the data processing results, including:

[0031] When it is necessary to perform word frequency counting and sorting operations on the DAG data structure, a top-down traversal method is used to traverse the structure based on the frequencies of sub-rules and sub-words contained in each other rule;

[0032] When it is necessary to perform word embedding and inverted index operations on the DAG data structure, a bottom-up traversal is used based on the frequency of sub-rules and sub-words contained in each other rule;

[0033] According to the application requirements for the DAG data structure, the traversal results are summarized and counted to obtain the text analysis results.

[0034] Furthermore, the traversal is performed in a top-down manner, including:

[0035] ① Define two arrays, ready_rule and unready_rule, on the on-chip memory of the FPGA to store the rules that can be processed and the rules that have not been processed, respectively. During initialization, put the root rule into the ready_rule array and the other rules into the unready_rule array;

[0036] ② Determine whether the rules in the ready_rule array have been traversed. If so, update the weights and in-degrees of all rules and proceed to step ④. Otherwise, proceed to step ③.

[0037] ③ Read the ID of the rule to be processed from the ready_rule array, update the frequency of its sub-rules, reduce the in-degree of each sub-rule by 1 and return to step ②;

[0038] ④If the unready_rule array is empty, it is considered that the rules have been traversed and the process ends; otherwise, the rules are taken out one by one from the unready_rule array to determine whether the current in-degree of the rule is 0. If the current in-degree is 0, the rule is placed in the ready_rule array, otherwise it remains in the unready_rule and step ② is executed.

[0039] Furthermore, the bottom-up traversal method includes the following steps:

[0040] ① Define two arrays ready_rule and unready_rule as queues to store rules that can be processed and rules that have not been processed, respectively. During initialization, put the rules with an out-degree of 0 into ready_rule and the other rules into unready_rule;

[0041] ② Take out the rules from ready_rule one by one for processing, access all the words contained in the current processing rule and its corresponding parent rule, and update the frequency of the parent rule according to the local word frequency table contained in the current processing rule, and reduce the out-degree of the parent rule by 1;

[0042] ③After processing all the rules in ready_rule, if unready_rule is empty, it is considered that the rules have been traversed and the process ends; otherwise, traverse the rules in unready_rule and read the current out-degree of the corresponding rule. If the current out-degree of the corresponding rule is 0, put it into ready_rule; otherwise, keep it in the unready_rule array and execute step ②.

[0043] In a second aspect, the present invention provides a compressed text direct processing system based on FPGA, comprising:

[0044] A data reading module, used for reading compressed text data and analyzing applications based on the compressed text data;

[0045] A preprocessing module is used to preprocess the compressed text data to obtain a DAG data structure suitable for FPGA;

[0046] The traversal module is used to determine a preset traversal strategy according to the type of analysis application to be performed on the compressed text data, traverse the DAG data structure on the FPGA, and summarize and count the traversal results to obtain the data processing results.

[0047] In a third aspect, the present invention provides a computer-readable storage medium storing one or more programs, wherein the one or more programs include instructions, which, when executed by a computing device, cause the computing device to perform any method.

[0048] The present invention adopts the above technical solution, which has the following advantages:

[0049] 1. The present invention proposes a compressed text direct processing technology based on FPGA, and proposes an FPGA acceleration optimization solution for the compressed text field, thereby improving the efficiency of the compressed text direct processing technology;

[0050] 2. The FPGA used in the present invention has the advantages of low power consumption and light weight, and is suitable for the field of edge computing while providing high energy efficiency;

[0051] 3. The data module and pipeline model designed by the present invention can reduce the number of interactions with the FPGA external memory and improve the efficiency of data transmission during the processing.

[0052] Therefore, the present invention can be widely applied to the field of big data processing technology. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Throughout the accompanying drawings, the same reference numerals are used to represent the same components. In the accompanying drawings:

[0054] Figure 1 It is a flow chart of a compressed text direct processing method based on FPGA provided by an embodiment of the present invention;

[0055] Figure 2 It is a word frequency statistics flow chart of the compressed text direct processing method based on FPGA provided by an embodiment of the present invention;

[0056] Figure 3a and Figure 3b is a schematic diagram of a process flow of root rule preprocessing provided by an embodiment of the present invention;

[0057] Figure 4a and Figure 4b is a schematic diagram of a process flow of other rule preprocessing provided by an embodiment of the present invention;

[0058] Figure 5a to Figure 5d It is a schematic diagram of a memory pool capable of self-maintaining a hash table provided in an embodiment of the present invention;

[0059] Figure 6a and Figure 6b It is a schematic diagram of a top-down traversal process provided by an embodiment of the present invention;

[0060] Figure 7 is a schematic diagram of a sample of top-down traversal update rules provided by an embodiment of the present invention;

[0061] Figure 8 It is a sample schematic diagram of bottom-up traversal update rules provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0062] In order to make the purpose, technical solution and advantages of the embodiment of the present invention clearer, the technical solution of the embodiment of the present invention will be clearly and completely described below in conjunction with the drawings of the embodiment of the present invention. Obviously, the described embodiment is a part of the embodiment of the present invention, not all of the embodiments. Based on the described embodiment of the present invention, all other embodiments obtained by ordinary technicians in this field belong to the scope of protection of the present invention.

[0063] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present application. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprise" and / or "include" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.

[0064] In view of the problems existing in FPGA acceleration of TADOC in the prior art, the present invention proposes the following solutions: First, in order to utilize the parallelism and pipeline characteristics of FPGA, a hierarchical traversal is adopted for DAG. In this way, data conflicts between parent nodes between each layer can be avoided, so that pipeline access to device memory (such as HBM) can improve throughput. In addition, different processing strategies are adopted for different rules on FPGA to balance the load. Secondly, in order to solve the problem that some rules are too large to be processed on FPGA and improve data access efficiency, the present invention designs a memory pool and on-chip cache that can self-maintain hash tables on block RAM (BRAM).

[0065] Based on the above solution ideas, some embodiments of the present invention provide a method for direct processing of compressed text based on FPGA, including the following steps: preprocessing all rules and counting the frequencies of words and sub-rules contained in each rule; using a top-down or bottom-up traversal method to traverse each rule layer by layer to build a pipeline to improve the traversal efficiency; summarizing the above information according to different application requirements to complete the implementation of the application.

[0066] In addition, the present invention uses high-level synthesis (HLS) to develop FPGA, wherein the software used is Vitis, which can automatically convert the logic structure described in a high-level language into a circuit model described in a low-abstract language.

[0067] Correspondingly, in other embodiments of the present invention, a compressed text direct processing system, device and medium based on FPGA are provided.

[0068] Example 1

[0069] like Figure 1 As shown, this embodiment provides a compressed text direct processing method based on FPGA, which includes the following steps:

[0070] 1) Reading compressed text data and analyzing applications based on the compressed text data;

[0071] 2) Preprocess the compressed text data to obtain a DAG data structure suitable for FPGA;

[0072] 3) Determine a preset traversal strategy based on the type of analysis application to be performed on the compressed text data, traverse the DAG data structure on the FPGA, and summarize and count the traversal results to obtain the data processing results.

[0073] Further, in the above step 2), if Figure 2 As shown, the following steps are included:

[0074] 2.1) According to the rule characteristics of the compressed text read in, all rules are divided into root rules and other rules except root rules;

[0075] 2.2) Using the on-chip cache of FPGA to directly interact and process the root rules stored in the off-chip memory (such as HBM), and using the processing results as the initial frequencies of all words and other rules; wherein the on-chip cache is an array defined on the on-chip memory (BRAM) of FPGA, and the on-chip cache adopts the LRU (Least Recently Used) processing strategy;

[0076] 2.3) Read the other rules on the off-chip memory into the on-chip memory of the FPGA one by one, use the self-maintained hash table in the memory pool to pre-process each other rule, count the frequency of words and sub-rules in each other rule, and write them back to the off-chip memory through the pipeline after processing each other rule to obtain a DAG data structure suitable for FPGA.

[0077] Further, in the above step 2.2), if Figure 3a As shown, the following steps are included:

[0078] 2.2.1) In each cycle clock cycle, 256-bit wide data (the maximum bit width of a single HBM channel) is read from the input array stored in the off-chip memory and divided into eight 32-bit IDs (i.e., one ID occupies 4 bytes);

[0079] 2.2.2) Use the key-value pair list in the on-chip cache to process eight 32-bit IDs in parallel;

[0080] 2.2.3) After summarizing the parallel processing results, the summary results are used as the initial frequencies of all words and other rules.

[0081] In this embodiment, during the specific implementation:

[0082] The data reading module reads 256-bit wide data (the maximum bit width of a single HBM channel) from the input array stored in the HBM in each cycle clock cycle, divides it into eight 32-bit IDs (i.e., one ID occupies 4 bytes), and distributes it to the eight on-chip cache modules in the cache control module for parallel processing;

[0083] The cache control module is equipped with eight on-chip cache modules, and each on-chip cache module processes a 32-bit ID in parallel. Before each on-chip cache module receives a new ID in each cycle, the cache controller updates the timestamp of the data in the cache and writes the key-value pairs of the cache header back to the corresponding Count array. After receiving the ID passed by the data reading module, the on-chip cache module matches the key-value pairs in the Count array at the same time, and gives priority to the key-value pairs in the cache. After receiving all IDs, the cache controller writes the remaining key-value pairs back to the Count array.

[0084] The merge module includes eight Count arrays, which are used to aggregate the results of the eight Count arrays into a single array and write it back to the HBM.

[0085] Further, in the above step 2.2.2), if Figure 3b As shown, processing each 32-bit ID includes the following steps:

[0086] ① Before updating a rule / word read from the root rule, determine whether there is a key-value pair in the on-chip cache header. If so, write the key-value pair in the on-chip cache header back to the off-chip memory space storing the rule / word frequency. If not, move all the key-value pairs in the on-chip cache forward by one unit to indicate the update of each key-value pair time slice;

[0087] ② Traverse all rules or words contained in the root rule, and search the key-value pairs in the on-chip cache based on the ID of the rule or word read each time. If found, it means that the rule or word exists in the on-chip cache, and execute step ③, otherwise execute step ④;

[0088] ③ Take the corresponding key-value pair from the on-chip cache, update the value of the key-value pair (+1, which means the current frequency +1), and insert the updated key-value pair to the end of the on-chip cache, while leaving the original position of the key-value pair empty;

[0089] ④ Read the frequency corresponding to the sub-rule or word from the off-chip memory that actually stores the rule / word frequency, update the value of the key-value pair (+1), and insert the updated key-value pair into the end of the on-chip cache;

[0090] ⑤ Determine whether the root rule has been traversed. If so, write all remaining key-value pairs in the on-chip cache back to the HBM. Otherwise, return to step ①.

[0091] Further, in the above step 2.3), if Figure 4a and Figure 4b As shown in FIG. 1 , the process of preprocessing other rules includes the following steps:

[0092] 2.3.1) Traverse all other rules except the root rule, and initialize the self-maintainable hash table in the FPGA memory pool before processing each other rule;

[0093] 2.3.2) Using the pipeline, the words and sub-rules contained in the other rules to be processed are read in turn, and their frequencies are inserted into the hash table to update the frequencies. In this embodiment, two hash tables are used in total to process the words and sub-rules contained in other rules respectively;

[0094] 2.3.3) After processing other current rules, use the pipeline to write the key-value pairs in the hash table back to the off-chip memory;

[0095] 2.3.4) Determine whether all other rules have been traversed. If not, return to step 2.3.1), otherwise exit.

[0096] Further, the above step 2.3.2) includes the following steps:

[0097] ① Read the offset of each rule in the original compressed text data from the content_offsets array in sequence; where the compressed text data is organized in CSR format;

[0098] ② According to the offset of each rule, read the sub-rules and words contained in the parent rule from the contents array containing the rule information;

[0099] ③ After classifying the read sub-rules and words, output their corresponding IDs and quantities to the pipeline;

[0100] Since the rule ID is after the word ID and is arranged in order, the classification of rules and words only needs to be based on whether the ID value is greater than the total number of words;

[0101] ④ Use the two pre-established hash tables to process the IDs and quantities of sub-words and sub-rules respectively, and output the corresponding IDs and frequencies.

[0102] The two hash modules receive these IDs and num and calculate in parallel the number of words and sub-rules contained in the rule. When processing a new rule, the memory pool controller creates and initializes a hash table in the memory pool for the hash operation. The size of the hash table corresponds to the number of words / sub-rules read. The memory pool is also located on the BRAM. After processing the current rule, the hash module outputs the ID and frequency freq of the word / sub-rule to the next module via a stream.

[0103] To facilitate traversal, the output of other rule preprocessing is also in CSR format. Therefore, the key-value pair output module writes the read ID and frequency freq into the corresponding ID_freqs array in sequence, and the offset output module also records the offset of each rule's word / sub-rule according to the read size size.

[0104] In order to perform subsequent traversal of the DAG, other rule preprocessing calculation units also need to calculate the in-degree of each rule. Therefore, after the processing of the hash module 2 corresponding to the sub-rule is completed, the rule ID needs to be copied and streamed to the module that stores the rule degree rule_degrees array.

[0105] Furthermore, in the above step 2.3.2), when the frequency of the sub-rules included in other rules is updated, the traversal method (for example, ) is determined according to the application type executed on the compressed text, and the frequency of the sub-rules is determined based on the traversal method. Specifically:

[0106] When the application type is word frequency counting (WordCount) and sorting (Sort), a top-down traversal method is adopted. At this time, it is necessary to count the frequency of sub-rules contained in each other rule and the in-degree of each other rule;

[0107] When the application type is TermVector and InvertedIndex, a bottom-up traversal method is used. At this time, it is necessary to count the frequency of the parent rules contained in each other rule and the out-degree of each other rule.

[0108] like Figure 5a to Figure 5b The following is a sample hash table on a memory pool. The memory pool size in the sample is 16. The size of the current rule is 3, so the hash map is aligned to 4 (aligned to a power of 2, and bit operations can be used instead of multiplication and division operations to improve efficiency). The entry and next arrays are used to store the location of key-value pairs and check for hash conflicts. The processing flow of other rules is as follows:

[0109] like Figure 5aAs shown, they are initialized to -1. The key and value arrays are used to store the values ​​of the key-value pairs in order. In addition, the variable size is used to record the number of elements in the current hash table. The insertion of the key and value arrays also depends on the size.

[0110] like Figure 5b As shown in the figure, the memory pool state is shown when the key-value pair <6,1> is successfully inserted without hash collision. Since the value of size is 0, the key and value of this key-value pair are placed at the 0th position of the key and value arrays. At the same time, the second position of the entry array is allocated as the storage location of the pair. This is because the hash value of the key is 2, and the second position of the entry array is -1, indicating that there is no key-value pair for the time being. The value of size is now 1.

[0111] like Figure 5c The figure shows the insertion of the key-value pair <7,1> without hash collision. The key-value pair is inserted into the first position of the key and value arrays. Its hash value is 3.

[0112] like Figure 5d As shown in Figure 1, the memory pool is used to handle hash conflicts. Figure 4b In the example, the hash value of the key-value pair <2,1> is 2, and the hash value of <6,1> is also 2. The second position of the entry array is now 0, indicating that a key-value pair has been inserted. However, the next array corresponding to the storage position <6,1> has not been assigned a value, that is, the 0th next is empty. Therefore, the 0th position of the next array is used to store the position of the current key-value pair <2,1>.

[0113] Further, the above step 3) includes the following steps:

[0114] 3.1) When it is necessary to perform word frequency counting and sorting operations on the DAG data structure, a top-down traversal method is used to traverse the DAG data structure based on the frequencies of sub-rules and sub-words contained in each other rule;

[0115] 3.2) When it is necessary to perform word vector and inverted index operations on the DAG data structure, a bottom-up traversal is used based on the frequency of sub-rules and sub-words contained in each other rule;

[0116] 3.3) According to the application requirements of the DAG data structure, the traversal results are summarized and counted to obtain the text analysis results.

[0117] Further, in the above step 3.1), if Figure 6a and Figure 6b As shown, a top-down traversal is used to traverse the network, including the following steps:

[0118] 3.2.1) Define two arrays ready_rule and unready_rule on the BRAM of FPGA to store the rules that can be processed and the rules that have not been processed, respectively. During initialization, put the root rule into the ready_rule array and other rules into the unready_rule array;

[0119] 3.2.2) Determine whether the rules in the ready_rule array have been traversed (i.e., whether it is empty). If so, update the weights and in-degrees of all rules and proceed to step 3.2.4); otherwise, proceed to step 3.2.3);

[0120] 3.2.3) Read the ID of the pending rule from the ready_rule array, update the frequency of its sub-rules, reduce the in-degree of each sub-rule by 1 and return to step 3.2.2);

[0121] 3.2.4) Determine whether the rules in the unready_rule array have been traversed (i.e., whether it is empty). If so, the traversal ends, otherwise, execute step 3.2.5);

[0122] 3.2.5) Take a rule from the unready_rule array and determine whether the current in-degree of the rule is 0. If the current in-degree is 0, put the rule into the ready_rule array and execute step 3.2.2), otherwise directly execute step 3.2.2).

[0123] It should be noted that since there is no dependency between the rules to be processed in the ready_rule array each time, these rules can be pipelined and processed in parallel. Therefore, the rules in the ready_rule after each update can be regarded as a layer, and the layer-by-layer traversal method is also based on this.

[0124] Further, the above step 3.2.3) includes the following steps:

[0125] ① According to the ID of the rule to be processed, read the weight of the rule to be processed and the offset of the sub-rule it contains from the weight (weights) and offset (subrule_offsets) array maintained in the memory pool;

[0126] ② According to the weight of the rule to be processed and the offset of the sub-rule it contains, read the ID and frequency of the sub-rule from the sub-rule frequency (subrule_ID_freqs) array maintained in the memory pool;

[0127] ③ Update the frequency of the sub-rule according to the frequency of the rule to be processed, that is, update the frequency of the sub-rule to the existing frequency of the sub-rule + the frequency of the sub-rule in the rule to be processed * the frequency of the rule to be processed.

[0128] Furthermore, in the above step 3.2.2), in the specific implementation, a global array weight_update and indegree_update are maintained on the HBM for updating the sub-rule frequency and degree respectively, and the two arrays are maintained using the on-chip cache. The two arrays are updated using the on-chip cache each time, and after processing the rules contained in the current ready_rule, the results of weight_update and indegree_update are updated to the weight and indegree arrays.

[0129] like Figure 7 As shown, assume that rule 1 and rule 4 are in the ready_rule array, indicating that they are waiting to be processed. The sub-rule information table obtained in the preprocessing stage stores sub-rules and their frequencies in the order of parent rules. For example, rule 1 contains sub-rules 2 and 5, while rule 4 contains sub-rules 2, 23, and 40. During traversal, the weight of the parent rule is multiplied by the frequency of its sub-rules and then updated to the weight of the corresponding sub-rule. In addition, each time a rule is processed, the in-degree of its sub-rules is reduced by 1.

[0130] For example, consider rule 2. It receives weights 5*1 and 3*3 from parent rule 1 and parent rule 4, respectively, and simultaneously reduces its in-degree by 2. When its in-degree reaches 0, it can be taken out of unready_rule and put into the ready_rule array, waiting for further processing in the next loop iteration.

[0131] Furthermore, in the above step 2.3), the traversal is performed in a bottom-up traversal manner, including the following steps:

[0132] 2.3.1) Define two arrays ready_rule and unready_rule on the BRAM of FPGA to store the rules that can be processed and the rules that have not been processed, respectively. During initialization, put the rules with out-degree 0 into ready_rule and the other rules into unready_rule;

[0133] 2.3.2) Take out the rules from ready_rule one by one for processing, access all the words contained in the current processing rule and its corresponding parent rule, and update the frequency of the parent rule according to the local word frequency table (hereinafter referred to as the word frequency table) contained in the current processing rule, and reduce the out-degree of the parent rule by 1;

[0134] Specifically, in this embodiment, the local word frequency table of the sub-rule is updated to the local word frequency table of the parent rule in an appending manner, and the size of the local word frequency table of the parent rule is sufficient to accommodate the local word frequency tables of all sub-rules;

[0135] 2.3.3) After processing all the rules in ready_rule, traverse the rules in unready_rule and read the current out-degree of the corresponding rule. If the current out-degree of the corresponding rule is 0, put it into ready_rule; if ready_rule is not empty at this time, execute 2.3.2), otherwise it is considered that the rules have been traversed and the process ends.

[0136] Furthermore, in the above step 2.3.2), the frequency of the parent rule is updated according to the word frequency table contained in the current processing rule, which means that the local word frequency table contained in the current processing rule is passed to its parent rule for updating, and the passed word frequency is the frequency of the rule * the frequency of each word in the rule.

[0137] In particular, since the parent rule receives local word frequency tables from different child rules, and different local word frequency tables may contain the same words, it is necessary to call other rule preprocessing modules to merge and update the word frequency tables of each rule. The merging method can adopt the technology known to those skilled in the art, and the present invention will not elaborate on this.

[0138] Therefore use Figure 8 Example showing actual updates in a bottom-up traversal:

[0139] From parrules_info_table, we can observe that rule 3 has parent rule 1, while rule 5 has parents 1 and 7. Furthermore, rule 3 contains words 10 and 2, and rule 5 contains word 11.

[0140] When propagating the local frequency table to the parent rule, the updated frequency is calculated by multiplying the frequency of the child rule by the number of times the parent rule points to it. For example, since rule 5 is pointed to by its parent rule 1, and the corresponding frequency is 4, and it contains word 11 with a frequency of 3, it will pass word 11 to rule 1, and the corresponding updated frequency is 3*4=12. In addition, after the layer is updated, the out-degree of rule 1 is 0, indicating that it can be put into ready_rule and processed in the next layer.

[0141] Furthermore, in the above step 3.3), according to different application requirements, the traversal results are summarized and counted, including:

[0142] 3.3.1) Word frequency statistics operation:

[0143] After executing rule preprocessing and traversing the rule DAG from top to bottom, count the frequencies of all words. The statistical method is: traverse all rules, traverse the words and frequencies contained in each rule, and update the frequency of the corresponding word. The update method is: the existing frequency of the word + the frequency of the rule * the frequency of the word in the rule.

[0144] 3.3.2) Sorting operation:

[0145] After completing the word frequency counting operation, sort the words according to their dictionary order.

[0146] 3.3.3) Word vector operation:

[0147] After executing the rule preprocessing operation and traversing the rule DAG from bottom to top, the root rule is divided according to the file separator contained in the root rule (because a large compressed file may be composed of multiple different files), and the word frequency is counted according to different files. The statistical method is: traverse the rules and words contained in the current part of the root rule (that is, the single file) after each division (that is, the local word frequency table), and update the frequency of the corresponding word. The update method is: the current frequency of the word + the frequency of the rule * the frequency of the word in the rule. Then sort the words in this part from large to small according to the word frequency.

[0148] This example shows the steps for implementing word vectors. The preprocessing process is the same as the word frequency statistics, but it should be noted that the positions of parent rules and child rules must be swapped during file reading, as the traversal direction is opposite to that from top to bottom. Therefore, this adjustment allows us to derive each rule and its corresponding parent rule information table and out-degree.

[0149] 3.3.4) Inverted index operation:

[0150] After executing the rule preprocessing operation and traversing the rule DAG from bottom to top, the root rule is divided according to the file separator contained in the root rule (because a large compressed file may be composed of multiple different files), a container of the number of words is established, and the file number containing the corresponding word is stored in the corresponding container. The method is: traverse the rules and the words contained in the current part of the root rule (that is, the single file) after each division (that is, the local word frequency table), and for each accessed word, the number corresponding to the current file is stored in the container corresponding to the word.

[0151] Example 2

[0152] The above-mentioned embodiment 1 provides a compressed text direct processing method based on FPGA, and correspondingly, this embodiment provides a compressed text direct processing system based on FPGA. The system provided by this embodiment can implement the compressed text direct processing method based on FPGA of embodiment 1, and the system can be implemented by software, hardware or a combination of software and hardware. For example, the system may include integrated or separate functional modules or functional units to execute the corresponding steps in each method of embodiment 1. Since the system of this embodiment is basically similar to the method embodiment, the process described in this embodiment is relatively simple, and the relevant parts can refer to the partial description of embodiment 1. The embodiment of the system provided in this embodiment is only schematic.

[0153] The FPGA-based compressed text direct processing system provided in this embodiment includes:

[0154] A data reading module, used for reading compressed text data and analyzing applications based on the compressed text data;

[0155] A preprocessing module is used to preprocess the compressed text data to obtain a DAG data structure suitable for FPGA;

[0156] The traversal module is used to determine a preset traversal strategy according to the type of analysis application to be performed on the compressed text data, traverse the DAG data structure on the FPGA, and summarize and count the traversal results to obtain the data processing results.

[0157] Example 3

[0158] This embodiment provides a processing device corresponding to the FPGA-based compressed text direct processing method provided in this embodiment 1. The processing device can be a processing device for a client, such as a mobile phone, a laptop computer, a tablet computer, a desktop computer, etc., to execute the method of embodiment 1.

[0159] The processing device includes a processor, a memory, a communication interface and a bus, and the processor, the memory and the communication interface are connected through the bus to complete mutual communication. The memory stores a computer program that can be run on the processor, and the processor executes the FPGA-based compressed text direct processing method provided in this embodiment 1 when running the computer program.

[0160] Preferably, the memory may be a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk memory.

[0161] Preferably, the processor may be a central processing unit (CPU), a digital signal processor (DSP) or other general-purpose processors of various types, which are not limited here.

[0162] Example 4

[0163] The FPGA-based compressed text direct processing method of this embodiment 1 can be specifically implemented as a computer program product, which may include a computer-readable storage medium carrying computer-readable program instructions for executing the FPGA-based compressed text direct processing method described in this embodiment 1.

[0164] Computer readable storage media can be tangible devices that hold and store instructions used by instruction execution devices. Computer readable storage media can be, for example, but not limited to, electronic storage devices, magnetic storage devices, optical storage devices, electromagnetic storage devices, semiconductor storage devices, or any combination thereof.

[0165] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0166] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0167] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0168] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0169] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the relevant field should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents. Any modification or equivalent replacement that does not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.

Claims

1. A method for directly processing compressed text based on FPGA, characterized in that: The following steps are involved: Reading compressed text data and analysis application based on the compressed text data; Preprocess the compressed text data to obtain a DAG data structure suitable for FPGA; Determine a preset traversal strategy according to the type of analysis application to be performed on the compressed text data, traverse the DAG data structure on the FPGA, and summarize and count the traversal results to obtain the data processing results; The preprocessing of the compressed text data to obtain a DAG data structure adapted to the FPGA includes: According to the rule characteristics of the compressed text read in, all rules are divided into root rules and other rules except the root rules; The on-chip cache of FPGA is used to directly interact and process the root rules stored in the off-chip memory, and the processing results are used as the initial frequencies of all words and other rules; wherein the on-chip cache is an array defined in the on-chip memory of FPGA; Read the other rules on the off-chip memory into the on-chip memory of the FPGA one by one, use the self-maintained hash table in the memory pool to pre-process each other rule, count the frequency of words and sub-rules in each other rule, and write them back to the off-chip memory through the pipeline after processing each other rule to obtain a DAG data structure suitable for FPGA.

2. The method for directly processing compressed text based on FPGA as claimed in claim 1, characterized in that: The on-chip cache of the FPGA is used to directly interact and process the root rules stored in the off-chip memory, and the processing results are used as the initial frequencies of all words and other rules, including: In each cycle clock cycle, 256-bit wide data is read from the input array stored in the off-chip memory and divided into eight 32-bit IDs; The eight 32-bit IDs are processed in parallel using the key-value pair list in the on-chip cache; After summarizing the parallel processing results, the summary results are used as the initial frequencies of all words and other rules.

3. A method for directly processing compressed text based on FPGA as claimed in claim 2, characterized in that: The method of using the key-value pair list in the on-chip cache to process eight 32-bit IDs in parallel includes: ① Determine whether there is a key-value pair in the on-chip cache header. If so, write the key-value pair in the on-chip cache header back to the off-chip memory space storing the rules / word frequencies. If not, move all the key-value pairs in the on-chip cache forward by one unit to indicate the update of each key-value pair time slice. ② Traverse all rules or words contained in the root rule, and search the key-value pairs in the on-chip cache based on the ID of the rule or word read each time. If found, it means that the rule or word exists in the on-chip cache, and execute step ③, otherwise execute step ④; ③ Take the corresponding key-value pair from the on-chip cache, update the value of the key-value pair, and insert the updated key-value pair to the end of the on-chip cache, while setting the original position of the key-value pair to empty; ④ Read the frequency corresponding to the sub-rule or word from the off-chip memory that actually stores the rule / word frequency, update the value of the key-value pair, and insert the updated key-value pair into the end of the on-chip cache; ⑤ Determine whether the root rule has been traversed. If so, write all remaining key-value pairs in the on-chip cache back to the HBM. Otherwise, return to step ①.

4. The method for directly processing compressed text based on FPGA as claimed in claim 1, characterized in that: The other rules on the off-chip memory are read into the on-chip memory of the FPGA one by one, each other rule is pre-processed using a self-maintainable hash table in the memory pool, the frequency of words and the frequency of sub-rules in each other rule are counted, and each other rule is written back to the off-chip memory through the pipeline after processing, to obtain a DAG data structure suitable for the FPGA, including: ① Traverse all other rules except the root rule, and initialize the self-maintainable hash table in the FPGA memory pool before processing each other rule; ②Use the pipeline to read the words and sub-rules contained in other rules to be processed in turn, insert their frequencies into the hash table to update the frequencies; ③After processing other current rules, use the pipeline to write the key-value pairs on the hash table back to the off-chip memory; ④ Determine whether all other rules have been traversed. If not, return to step ①, otherwise exit.

5. The method for directly processing compressed text based on FPGA as claimed in claim 1, characterized in that: The method includes determining a preset traversal strategy according to the type of analysis application to be performed on the compressed text data, traversing the DAG data structure on the FPGA, and summarizing and counting the traversal results to obtain data processing results, including: When it is necessary to perform word frequency counting and sorting operations on the DAG data structure, a top-down traversal method is used to traverse the structure based on the frequencies of sub-rules and sub-words contained in each other rule; When it is necessary to perform word embedding and inverted index operations on the DAG data structure, a bottom-up traversal is used based on the frequency of sub-rules and sub-words contained in each other rule; According to the application requirements for the DAG data structure, the traversal results are summarized and counted to obtain the text analysis results.

6. The method for directly processing compressed text based on FPGA as claimed in claim 5, characterized in that: The traversal is performed in a top-down manner, including: ① Define two arrays, ready_rule and unready_rule, on the on-chip memory of the FPGA to store the rules that can be processed and the rules that have not been processed, respectively. During initialization, put the root rule into the ready_rule array and the other rules into the unready_rule array; ② Determine whether the rules in the ready_rule array have been traversed. If so, update the weights and in-degrees of all rules and proceed to step ④. Otherwise, proceed to step ③. ③ Read the ID of the rule to be processed from the ready_rule array, update the frequency of its sub-rules, reduce the in-degree of each sub-rule by 1 and return to step ②; ④If the unready_rule array is empty, it is considered that the rules have been traversed and the process ends; otherwise, the rules are taken out one by one from the unready_rule array to determine whether the current in-degree of the rule is 0. If the current in-degree is 0, the rule is placed in the ready_rule array, otherwise it remains in the unready_rule array and step ② is executed.

7. The method for directly processing compressed text based on FPGA as claimed in claim 5, characterized in that: The bottom-up traversal method is used to traverse, including the following steps: ① Define two arrays ready_rule and unready_rule as queues to store rules that can be processed and rules that have not been processed, respectively. During initialization, put the rules with an out-degree of 0 into ready_rule and the other rules into unready_rule; ② Take out the rules from ready_rule one by one for processing, access all the words contained in the current processing rule and its corresponding parent rule, and update the frequency of the parent rule according to the local word frequency table contained in the current processing rule, and reduce the out-degree of the parent rule by 1; ③After processing all the rules in ready_rule, if the unready_rule array is empty, the rules are considered to have been traversed and the process ends; otherwise, the rules in unready_rule are traversed and the current out-degree of the corresponding rule is read. If the current out-degree of the corresponding rule is 0, it is put into ready_rule; otherwise, it remains in the unready_rule array and step ② is executed.

8. A compressed text direct processing system based on FPGA, characterized in that: include: A data reading module, used for reading compressed text data and analyzing applications based on the compressed text data; A preprocessing module is used to preprocess the compressed text data to obtain a DAG data structure suitable for FPGA; A traversal module is used to determine a preset traversal strategy according to the type of analysis application to be performed on the compressed text data, traverse the DAG data structure on the FPGA, and summarize and count the traversal results to obtain data processing results; The preprocessing of the compressed text data to obtain a DAG data structure adapted to the FPGA includes: According to the rule characteristics of the compressed text read in, all rules are divided into root rules and other rules except the root rules; The on-chip cache of FPGA is used to directly interact and process the root rules stored in the off-chip memory, and the processing results are used as the initial frequencies of all words and other rules; wherein the on-chip cache is an array defined in the on-chip memory of FPGA; Read the other rules on the off-chip memory into the on-chip memory of the FPGA one by one, use the self-maintained hash table in the memory pool to pre-process each other rule, count the frequency of words and sub-rules in each other rule, and write them back to the off-chip memory through the pipeline after processing each other rule to obtain a DAG data structure suitable for FPGA.

9. A computer-readable storage medium storing one or more programs, characterized in that: The one or more programs include instructions, which, when executed by a computing device, cause the computing device to perform any one of the methods of claims 1 to 7.