A hardware-based data ranking method, system, device and storage medium

CN115562618BActive Publication Date: 2026-10-23SHANDONG YUNHAI GUOCHUANG CLOUD COMPUTING EQUIP IND INNOVATION CENT CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202211164672.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-23
Publication Date
2026-10-23
Estimated Expiration
2042-09-23

AI Technical Summary

Technical Problem

但除了乘加运算,还有一些运算通过电路难以实现,比如计算中位数,就是一种排序求值运算

Benefits of technology

[0033]本发明提出了一种基于硬件的数据排位方法的方法,通过对基本比较单元的复用,提出一种可以达到不浪费资源在有限资源(基本单元)下的排位分组方法,以及基于此量化了时间和资源的关系,实现了在ASIC或FPGA资源有限的前提下,为了满足PPA要求的不同情况下的电路设计实现方式,进行有效的量化调整,使实现方案在时间和资源上进行互换,已达标PPA要求。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115562618B_ABST
    Figure CN115562618B_ABST
Patent Text Reader

Abstract

The application belongs to the field of computers and particularly relates to a hardware-based data ranking method, system, device and readable storage medium. The method comprises the following steps: determining the data amount of each round of calculation according to the length of input data and the expected time for completing a calculation task, and determining the number of calculation units of each round of calculation according to the data amount of each round of calculation; determining a corresponding number of calculation units according to the number of calculation units, inputting data into the calculation units in a predetermined manner, calculating the score of each element in the input data, and taking the element score as the serial number of the element in the input data. The application proposes a ranking grouping method under limited resources (basic units), and based on the relationship between the quantization time and resources, effective quantization adjustment is realized under the premise of limited ASIC or FPGA resources, so that the implementation scheme is interchanged in time and resources to meet the PPA requirement.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of computer science, and specifically relates to a hardware-based data sorting method, system, device, and readable storage medium. Background Technology

[0002] Algorithms often require sorting data and then selecting one or more data items that meet the order requirements for output.

[0003] For example, Wiener filtering based on infrared images can effectively remove noise from images, restoring them to a clearer state. The Wiener filtering operation is typically optimized using methods such as FFT or covariance matrix calculations to reduce computational complexity or improve denoising effectiveness to varying degrees.

[0004] Wiener filtering was originally implemented through software computation. However, with the expansion of application scenarios, the development of technology, and changes in demand, there is now an increasing demand for hardware implementation of Wiener filtering with different accuracy and speed requirements.

[0005] In the hardware module of the Wiener filtering algorithm, most operations are standard multiplication and addition. These are achieved by utilizing a multiply-add module, dividing the computation into parallel operations based on the required frame rate, and then pipelined to connect the entire operation. However, besides multiply-add, some operations are difficult to implement using circuits, such as calculating the median, which is a sorting and evaluation operation.

[0006] This seemingly simple ranking operation is actually very complex in circuits because all data needs to be compared and every two data points need to be calculated. Therefore, common ranking operations are often difficult to design due to limitations in hardware resources and completion time.

[0007] Therefore, although there are different algorithms such as algorithms and binary trees, as well as corresponding hardware implementations, their performance often only achieves a single advantage in terms of speed or area, which poses a significant challenge for chips with strict PPA constraints. Summary of the Invention

[0008] To address the above problems, this invention proposes a hardware-based data ranking method, comprising:

[0009] The amount of data for each round of computation is determined based on the length of the input data and the expected time to complete the computation task, and the number of computation units for each round of computation is determined based on the amount of data for each round of computation.

[0010] The number of calculation units is determined according to the number of calculation units. The input data is input into the calculation units in a predetermined manner, and the score of each element of the input data is calculated. The score of each element is used as the index of the element in the input data.

[0011] In some embodiments of the present invention, inputting the input data into the computing unit in a predetermined manner and calculating the score of each element of the input data includes:

[0012] The input data is grouped according to the amount of data calculated in each round. Two elements in each group are input into a calculation unit in a permutation and combination manner. The calculation result of the calculation unit is used as the score of the corresponding element of the input data.

[0013] In some embodiments of the present invention, inputting the input data into the computing unit in a predetermined manner and calculating the score of each element of the input data further includes:

[0014] Construct a data matrix matching the length of the input data;

[0015] In response to the completion of calculation of all groups of the input data, new groups are re-formed based on the data matrix in a diagonal manner with a predetermined offset;

[0016] The new grouping is re-inputted into the calculation unit to calculate the score of the element corresponding to the input data.

[0017] In some embodiments of the present invention, the method further includes:

[0018] In response to the fact that the length of the input data is less than the size of the constructed data matrix, the remaining data is padded with predetermined values.

[0019] In some embodiments of the present invention, the method further includes:

[0020] Obtain the current number of available computing units, and determine the number of computing units for the computing task based on the current number of available computing units.

[0021] In some embodiments of the present invention, the method further includes:

[0022] In response to the fact that the currently available computing units cannot meet the expected time of the computing task for the input data, the computing task is blocked and the currently available computing units are locked.

[0023] The released computing units are preferentially allocated to the computing task, and in response to the availability of computing units to satisfy the computing task, the corresponding computing units are allocated to the computing task.

[0024] In some embodiments of the present invention, the method further includes:

[0025] Based on the length of the input data and the expected time to complete the computation task, the amount of data for each round of computation is determined according to a predetermined strategy, and the number of computation units for each round of computation is determined based on the amount of data for each round of computation.

[0026] Another aspect of the present invention proposes a hardware-based data ranking system, comprising:

[0027] A computing unit allocation module is configured to determine the amount of data for each round of computing based on the length of the input data and the expected time to complete the computing task, and to determine the number of computing units for each round of computing based on the amount of data for each round of computing.

[0028] The data ranking calculation module is configured to determine the corresponding number of calculation units according to the number of calculation units, input the input data into the calculation units in a predetermined manner, calculate the score of each element of the input data, and use the element score as the index of the element in the input data.

[0029] Another aspect of the present invention provides a computer device comprising:

[0030] At least one processor; and

[0031] A memory storing computer instructions executable on the processor, which, when executed by the processor, implement the steps of any of the methods described in the above embodiments.

[0032] Another aspect of the present invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of any one of the methods summarized in the above embodiments.

[0033] This invention proposes a hardware-based data ranking method. By reusing basic comparison units, it proposes a ranking and grouping method that can achieve resource-efficient operation with limited resources (basic units). Based on this, it quantifies the relationship between time and resources, and realizes effective quantitative adjustment of circuit design implementation methods under different conditions of limited ASIC or FPGA resources in order to meet PPA requirements. This allows the implementation schemes to be interchangeable in terms of time and resources, thus meeting PPA requirements. Attached Figure Description

[0034] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0035] Figure 1 A flowchart of a hardware-based data ranking method provided in this embodiment of the invention;

[0036] Figure 2 A schematic diagram of a hardware-based data ranking system provided in an embodiment of the present invention;

[0037] Figure 3 A schematic diagram of the structure of a computer device provided in an embodiment of the present invention;

[0038] Figure 4 This is a schematic diagram of the structure of a computer-readable storage medium provided in an embodiment of the present invention.

[0039] Figure 5 A schematic diagram illustrating the calculation process for each set of input data provided in this embodiment of the invention;

[0040] Figure 6 This is a schematic diagram of the calculation process for grouping input data according to an embodiment of the present invention;

[0041] Figure 7 This is a schematic diagram illustrating the data filling process for input data according to an embodiment of the present invention. Detailed Implementation

[0042] To make the objectives, technical solutions, and advantages of the present invention clearer, the embodiments of the present invention will be further described in detail below with reference to specific examples and the accompanying drawings.

[0043] This invention aims to address the challenge of balancing performance and chip area consumption in implementing sorting algorithms within chips. Sorting is a common algorithmic operation that compares and sorts finite or continuously changing data values ​​according to ascending or descending order, ultimately outputting values ​​that conform to the sorted sequence. Common sorting outputs include finding the maximum, minimum, or median value.

[0044] A common method for sorting in circuits is to prepare all inputs and then use polling or binary tree comparison to obtain the desired sort value. This approach requires first combining all input data and inputting it to the corresponding ports, then using a relatively large circuit area for traversal and comparison, and finally outputting the complete sorting result. Alternatively, it may require a large temporary storage device, using fewer comparison devices to store a larger number of temporary results, resulting in a longer operating time and higher storage overhead, but achieving the sorting comparison function in a smaller area.

[0045] However, in actual ASICs and FPGAs, the implementation of a function involves more than just considering whether the function can be accomplished by the corresponding hardware; it also requires considering:

[0046] 1. Can the existing chip area, or the limited resources of the FPGA such as LUTs, FFs, and DSPs, accommodate the current hardware for implementing the corresponding functions?

[0047] 2. Based on the existing chip operating frequency or FPGA clock frequency, can the required work be completed within a limited time under functional requirements? The above two points are mutually exclusive in circuit implementation; different requirements for these two points generally result in significantly different circuits. Therefore, it is very meaningful to design a reasonable, universal circuit module and a quantifiable algorithm. Based on this algorithm, different permutations and combinations of this module can implement different ranking algorithms to meet the product's area or time performance requirements.

[0048] like Figure 1 As shown, to solve the above problems, this invention proposes a hardware-based data ranking method, including:

[0049] Step S1: Determine the amount of data for each round of calculation based on the length of the input data and the expected time to complete the calculation task, and determine the number of calculation units for each round of calculation based on the amount of data for each round of calculation.

[0050] Step S2: Determine the corresponding number of calculation units according to the number of calculation units, input the input data into the calculation units in a predetermined manner, calculate the score of each element of the input data, and use the element score as the index of the element in the input data.

[0051] In embodiments of the present invention, input data refers to data to be sorted, and the length of input data refers to the number of elements in the data to be sorted. For any sorting algorithm or sorting method, the more data to be sorted, the longer the sorting time. Therefore, in step S1, the length of the data to be sorted and the expected time to complete the sorting task are first determined. In this embodiment, the expected time is measured in clock cycles, that is, the expected time refers to how many clock cycles are needed to complete the corresponding sorting task. The amount of data calculated in each round refers to the number of elements that the computing unit completes one ranking calculation, that is, the number of elements completed in one clock cycle. Hardware-based ranking algorithm implementations also have scenarios where only one ranking calculation is needed, such as when the input data consists of only two elements to be sorted. In this case, only one clock cycle is needed to calculate the corresponding ranking order, which is simply comparing the size of the two elements to obtain the ranking result. For example, if there are three elements, and the hardware-implemented computing unit (such as a comparator) is only one, comparing the size of the three elements for sorting requires three clock cycles to complete one comparison calculation, that is, three comparisons. If there are two computing units, then only two clock cycles are needed to arrange the three data.

[0052] Based on the above relationship, assuming that sorting several elements is completed within one clock cycle, the relationship between the number of computation units *a* required and the number of data elements *k* participating in one computation should satisfy:

[0053]

[0054] As in the example above, if sorting three elements is completed in one go, it requires 3*(3-1) = 6 computation units. If a hardware implementation using comparators as computation units is used, then for three elements to be sorted, 6 comparators are needed for computation. However, the length of the input data is uncontrollable due to the size of the data transmitted by the software layer in different scenarios. In some cases, the number of data elements to be sorted may reach 100 or 1000. If the computation is to be completed in one clock cycle, according to the above formula, 100*99 = 9900 or 1000*999 = 999000 need to be designed in the chip, which would consume a large amount of chip area in the physical chip implementation, making it almost impossible. Therefore, in this embodiment, the input data is split into multiple corresponding groups, such as m groups, with each group containing k elements for multiple rounds of sorting operations. Assuming the number of elements in the input data is n, the relationship between the number of groups m and the amount of data in each group k is: k = n / m.

[0055] Furthermore, when performing calculations in groups, taking m groups as an example, completing the sorting calculation for m groups only yields m ordered groups. However, the size of these m ordered groups and the size of multiple groups are uncertain, thus requiring multiple iterations. Assuming the number of iterations is b, then b should satisfy:

[0056]

[0057] Here, n-1 represents the number of times any element needs to be compared with other elements besides itself, i.e., the number of other elements. k-1 represents the number of comparisons any element makes with other elements in one clock cycle. For example, in sorting three elements, assuming a comparator is used to compare the data size between the three elements (k=2), the comparator input can only be two elements. Therefore, only two elements can be compared in one clock cycle. For any given element, it can only be compared with k-1 elements in one clock cycle. When k=2, k-1=1. Considering the total amount of data n, any element needs to be compared with n-1 other elements. When n=3, n-1=2, therefore 2 / 1=2. With one comparator, it takes two clock cycles to complete the comparison calculation, requiring 2 iterations. If k=3, i.e., three elements are involved in the calculation, then according to the formula... Six comparators are needed to obtain the result of the input data in one clock cycle, eliminating the need to divide the input data into two groups.

[0058] As we know from the above, for input data n, the number of groups to be divided into according to the size of k requires m clock cycles per iteration. Therefore, the total time taken to calculate the input data should be the number of iterations multiplied by the number of clock cycles consumed in each iteration. So the consumed clock cycles T = m * b.

[0059] Furthermore, as stated above, m = n / k, b = (n-1) / (k-1), therefore the total clock cycles consumed in calculating the input data should be:

[0060]

[0061] Therefore, in step S1, for any input data, its data length n is fixed and can be obtained upon acquiring the input data. The sorting time for the input data can be specified by the upper-level software or a default sorting time T can be specified for a certain data length. Therefore, for any input data, after determining the length of the input data and the sorting time, the number of elements k (i.e., the number of elements in each group) participating in each sorting calculation can be calculated using the aforementioned clock cycle formula. Then, the number of elements k is substituted into the formula: This allows you to call or activate the corresponding 'a' hardware computing units to sort the input data by size.

[0062] Furthermore, in step S2, refer to Figure 5 , Figure 5 The diagram illustrates the sorting of input data: "235146987", consisting of 9 elements divided into 3 groups (m=3), with k=3 elements in each group. As shown, in the first cycle (first clock cycle), elements 2, 3, and 5 are input to the calculation unit (the comparators in the diagram). The comparison of these three data points can be completed in one cycle using only 6 comparators. Comparator 1 and Comparator 2 compare element 2 as the first element with the corresponding elements 3 and 5. If the value of element 2 is greater than elements 3 and 5, then the score for element 2 is increased by 1 point. That is, if 2 is greater than 3, then 2's score increases by 1 point; if 2 is greater than 5, then 2's score increases by 1 point. Based on mathematical common sense, in the first cycle, the score for 2 is 0. Based on this principle, Comparator 3 and Comparator 4 compare element 3 as the second-lower element with the corresponding elements 2 and 5. If 3 is greater than 2, then element 3's score increases by 1 point; if element 3 is greater than 5, then element 3's score increases by 1 point. Based on common mathematical knowledge, the score for 3 is 1. The score for element 5 is 2.

[0063] After three cycles of calculation, three ordered groups can be obtained. Taking the first group, 235, as an example, 5 scores 2, 3 scores 1, and 2 scores 0. The higher the score, the larger the value. In the corresponding second group, 1 scores 0, 4 scores 1, and 6 scores 2. In the third group, 9 scores 2, 8 scores 1, and 7 scores 0. Therefore, through the above round of calculation, three ordered groups can be obtained.

[0064] Furthermore, when grouping the input data, after sorting each group, we obtain corresponding ordered groups. Since this is a holistic sort of the input data, to obtain the sorted data for all data, we need to compare the corresponding valid group data with all other remaining data. Therefore, we need to redistribute the elements within each group to achieve a non-redundant regrouping. According to common sorting knowledge, for any element among n elements, it needs to be compared with n-1 elements. Since the size of each group is k, each calculation requires redistributing k-1 new elements to compare with that element. Therefore, (n-1) / (k-1) iterations are needed. Taking an input data element count of n=9 and a group element count of k=3 as an example, only 8 / 2=4 iterations are needed to complete the comparison of all elements. Except for the first grouping according to the default order, we need to select 2 of the 6 elements outside the default order as elements for the next grouping and compare them with that element to calculate its score. After performing four groupings (the first grouping is already included by default), the data with an input length of 9 can be sorted, and the corresponding sorting score is used as the sorting result. The higher the score, the larger the value of the corresponding element.

[0065] In some embodiments of the present invention, inputting the input data into the computing unit in a predetermined manner and calculating the score of each element of the input data includes:

[0066] The input data is grouped according to the amount of data calculated in each round. Two elements in each group are input into a calculation unit in a permutation and combination manner. The calculation result of the calculation unit is used as the score of the corresponding element of the input data.

[0067] In this embodiment, as described above, in the calculation of each group, each element needs to be compared and operated on with elements in other groups. (See reference...) Figure 5 The calculation method is shown in the figure.

[0068] In some embodiments of the present invention, inputting the input data into the computing unit in a predetermined manner and calculating the score of each element of the input data further includes:

[0069] Construct a data matrix matching the length of the input data;

[0070] In response to the completion of calculation of all groups of the input data, new groups are re-formed based on the data matrix in a diagonal manner with a predetermined offset;

[0071] The new grouping is re-inputted into the calculation unit to calculate the score of the element corresponding to the input data.

[0072] In this embodiment, a data matrix is ​​constructed based on the length of the input data, such as... Figure 6 As shown, for the input data "235146987", a data matrix of size 3x3 is constructed.

[0073] Furthermore, as mentioned earlier, for an input data length of 9 and an element size k = 3 within a group (the same as the matrix size), the number of iterations is (9-1) / (3-1) = 4, thus requiring four iterations. Figure 6 As shown, in the first round of iterative calculation, the matrices are grouped according to their horizontal order, as follows: Figure 6 The matrix represented by ① yields the corresponding "235", "146", and "987", with each row forming a group. After the first round of iteration, the groups formed from the original data are offset by one position to construct matrix ②, i.e., the grouping method shown in the figure, where groups are separated by one position. Based on the arrangement order of matrix ②, the data is then grouped horizontally to obtain the corresponding three groups of data: "247", "369", and "518". These are then input into the corresponding calculation units for the next round of iteration. The data for the subsequent third and fourth rounds of iteration are as follows... Figure 6 The matrices ③ and ④ shown represent new matrices generated by crossing two and three more times respectively from the original matrix of the input data.

[0074] In other words, the predetermined offset unit depends on the number of iterations. For higher iteration numbers, theoretically it should be the response coefficient of the square matrix. For example, for input data with 16 elements, the corresponding iteration number should be 16-1 divided by 4-1 = 5. The resulting 5 matrices are then offset using the method described above, crossing one, two, up to four positions to obtain new matrices. Data is then grouped according to the matrix size, and based on the number of elements k within each group, according to... The number of corresponding computing units (comparators) is determined in this way.

[0075] In some embodiments of the present invention, the method further includes:

[0076] In response to the fact that the length of the input data is less than the size of the constructed data matrix, the remaining data is padded with predetermined values.

[0077] In this embodiment, when the number of elements is too small to meet the size requirement of a square matrix, the remaining matrix data is padded with 0s. For example, if the input data length is 8, a 3x3 matrix is ​​constructed, and the last element of the matrix is ​​padded with 0s. Similarly, if the input data is 12, the last row of elements in the constructed 4x4 matrix is ​​padded with 0s. (See reference...) Figure 7 As shown.

[0078] In some embodiments of the present invention, the method further includes:

[0079] Obtain the current number of available computing units, and determine the number of computing units for the computing task based on the current number of available computing units.

[0080] In this embodiment, when receiving the corresponding input data to be sorted, when setting the corresponding computing unit for the input data, the system first checks and calculates whether the number of available computing units (comparators) required to satisfy the sorting requirements of the input data is satisfied.

[0081] In some embodiments of the present invention, the method further includes:

[0082] In response to the fact that the currently available computing units cannot meet the expected time of the computing task for the input data, the computing task is blocked and the currently available computing units are locked.

[0083] The released computing units are preferentially allocated to the computing task, and in response to the availability of computing units to satisfy the computing task, the corresponding computing units are allocated to the computing task.

[0084] In this embodiment, if the currently available computing units cannot meet the time requirements of the input data sorting task, the computing task for that input data is suspended and feedback is sent to the corresponding application indicating that the expected sorting requirements cannot be met. Simultaneously, the available computing units are used for sorting other input data.

[0085] In some embodiments of the present invention, the method further includes:

[0086] Based on the length of the input data and the expected time to complete the computation task, the amount of data for each round of computation is determined according to a predetermined strategy, and the number of computation units for each round of computation is determined based on the amount of data for each round of computation.

[0087] In this embodiment, when the input data contains the expected time for the corresponding sorting, the strategy of the current sorting algorithm is obtained. If the sorting strategy is time-first, then a sufficient number of computing units are allocated to compute the corresponding input data. For example, if the input time is "235146987", as mentioned earlier, with k=3, the time required for this input data is T=m*b=4*3=12 cycles. If it is time-first, the amount of data involved in each computation can be adjusted as much as possible. For example, if k=9, the number of comparators required is 9*8=72. If the number of available comparators is greater than 72, then 72 comparators are directly called or activated to complete the sorting of the input data within one clock cycle. If it is computational resource-first and the expected time is met, the corresponding comparators are allocated as few as possible.

[0088] Example:

[0089] Quantify the approach to problem-solving:

[0090] First, assuming the total amount of data to be compared in the ranking is n, then based on the algorithm principle of comparison operation, we know that under the requirement of pairwise comparison of all data, the number of comparisons for each data is n-1.

[0091] Following the principle of divisibility, we divide n data points into m groups, and the number of data points k in each group is: k = n / m.

[0092] Here, 'k' determines the design of the smallest unit. The smallest unit is composed of comparators. Since we assume that the smallest unit with 'k' data needs to be completed within one clock cycle, based on this relationship, we know that the number of comparators in the smallest unit is 'a', and their operational relationship is as follows:

[0093]

[0094] Minimum unit connection relationship:

[0095] Taking an example where n is 9 and the corresponding data input relationship is 235146987, and assuming k is 3, then a = 6. The input at this point selects the first three data points as the smallest unit input according to k = 3, which is 235 in this case. The connection relationship of the smallest unit can be found by referring to... Figure 5 The first set of calculations.

[0096] like Figure 5 As shown, because it is engaged in ratio ranking, the basic hardware component is a comparator. Each comparator has two inputs and performs the comparison of two data information based on the bit width of the input information.

[0097] In this embodiment, since all the data needs to be compared with other data to obtain a score, the required comparators must satisfy the condition of formula (1), which is a = 6.

[0098] The connection relationship of the 6 comparators is as follows Figure 5 As shown, the three input signals are first input to two comparators respectively. In the case of 235 shown in the figure, signal 2 is input to comparator 12, signal 3 to comparator 34, and signal 5 to comparator 56. Then, based on the inputs, the remaining signals are compared. Taking signal 3 as an example, signal 2 is input to comparator 12, and the remaining signals are 3 and 5. Therefore, signal 3 is input to comparator 1, and signal 5 is input to comparator 2.

[0099] The same applies to other signals:

[0100] As shown above, comparator 1 compares data 2 and 3, and 2 and 5, and outputs a score to the temporary storage module "score of 2". This comparison follows the comparator's working principle: it compares the input data; if 2 is greater than 3, the score is increased by 1; similarly, if 2 is greater than 5, the score is increased by 1. The temporary storage modules "score of 2", "score of 4", and "score of 5" are reset to 0 during initial operation. The scores are added based on the comparator's results. Taking the above diagram as an example, because the comparison result between 2 and 3 is less than, and the comparison result between 2 and 5 is less than, the result for module "score of 2" is 0. The result for "score of 3" is 1, and the result for "score of 5" is 2.

[0101] Complete the first iteration with all data:

[0102] Based on the above introduction, n data points are divided into m groups according to the method of k data points per group. In step 2, the minimum unit combination is established. Each time, k data points are input into the minimum unit combination to complete a comparison. The time required for this comparison is 1 clock cycle.

[0103] There are no particular restrictions on the grouping method. For simplicity, we suggest dividing the data in order based on the number k. In the example above, the input data is 235146987. We plan to use k=3, so we divide it into three groups: 235, 146, and 987 in order.

[0104] The comparison of 2, 3, and 5 in the first group has been completed. Now, the remaining data will be compared based on the same minimum unit combination. The comparison method is to input the input data into the minimum unit combination according to the group in turn, and the scores obtained are recorded in their respective data-related positions.

[0105] like Figure 5 As can be seen, under the data structure divided according to the case of n=9 and k=3, the smallest unit combination compares 3 data at a time and completes the corresponding work within one clock cycle. Therefore, the number of cycles required to compare all the data is m, and the relationship is consistent with the description given above: m=n / k.

[0106] The remaining iterations required to complete all data:

[0107] The grouping method described above can compare all the data within the same group once. However, in order to obtain all the data, it is necessary to compare this data with all the other remaining data to obtain a correct ranking score.

[0108] Assuming that b iterations are needed to complete the comparison of all data, the relationship is as follows:

[0109] Formula 2:

[0110] There is a premise here: the ratios will not overlap each time.

[0111] As we know, in binary trees and bubble sort, the number of comparisons in each round gradually decreases, which can effectively reduce the probability of repetition. However, this also increases the number of comparison rounds, resulting in additional time consumption.

[0112] Therefore, we designed a round-grouping method to ensure that each iteration of data comparison can fully utilize all comparators, while avoiding arbitrary duplicate comparisons of data.

[0113] The grouping method is as follows: first, group sequentially; second, group across one position; third, group across two positions, and so on to complete the traversal.

[0114] Taking the above situation as an example, the existing data is 235146987, and the grouping relationship is: 235 / 146 / 987. Then the grouping method under this method is as follows: Figure 6 As shown.

[0115] As can be seen above, by using this grouping method, the corresponding ratio sorting work can be completed without any waste within b rounds.

[0116] In this case, the required time T and the number of comparators cn are respectively:

[0117] Formula 3: T = m * b; cn = a.

[0118] From the above method, we can see that in order to achieve a solution with absolutely no resource waste, the optimal solution in terms of both time and resources must satisfy the following:

[0119] Formula 4:

[0120] Methods for exchanging time and resources:

[0121] Taking the above situation as an example, when n=9 and k=3, a unique solution can be obtained. The way to exchange time and resources is as follows: under the premise that the smallest unit with k=3 has a total of 6 comparators, the speed-up is achieved by adding a multiple of the comparators. The work of each of the 6 comparators is allocated according to the method described above. Assuming there are a total of s groups of comparators, and each group of comparators is as described above, the time at this time is T / s.

[0122] The corresponding resource replacement method is to split the unit group formed by the comparators mentioned above. Assuming that the smallest unit group is 6 comparators, splitting it into r comparators, the time becomes: T*cn / r.

[0123] 2. When the mathematical relationship between n and k cannot meet the requirements of formula (4)

[0124] As described above, when time and resources can reach the optimal solution, formula (4) needs to be satisfied. However, the actual number of operands may differ, requiring adjustments to the method. Zeros are added upwards in stages until the condition is met.

[0125] As shown in the figure, when n does not satisfy formula (4), zeros are added upwards according to the actual position to achieve the relationship that n can satisfy at the next level. Assuming that the data n = 10 at this time, the corresponding data is: 2 3 5 1 4 6 9 8 7 10, then zeros are added upwards to n = 16, and the corresponding data is: 2 3 5 1 4 6 9 8 7 10 0 0 0 0 0 0.

[0126] like Figure 7 As shown, due to the padding with zeros, all zeros may appear during grouping, but no operation is actually needed. They can be directly removed during grouping, meaning there's no need to allocate a comparator for zero elements. Then, using the appropriate method, all data comparisons and rankings are finally completed. At this point, the lower digits of the ranking score will definitely be zeros padded with zeros, so the actual ranking order can be calculated starting from the number of zeros padded.

[0127] This invention proposes a general ranking algorithm hardware circuit scheme that allows for interchangeable time and resources. By reusing basic comparison units, a ranking grouping method is proposed that can achieve ranking without wasting resources under limited resources (basic units). Based on this, the relationship between time and resources is quantified, realizing effective quantitative adjustment of circuit design implementation methods under different conditions of limited ASIC or FPGA resources in order to meet PPA requirements. This allows the implementation scheme to be interchangeable in terms of time and resources, thus meeting PPA requirements.

[0128] like Figure 2 As shown, another aspect of the present invention proposes a hardware-based data ranking system, comprising:

[0129] The computing unit allocation module 1 is configured to determine the amount of data for each round of calculation based on the length of the input data and the expected time to complete the calculation task, and to determine the number of computing units for each round of calculation based on the amount of data for each round of calculation.

[0130] The data ranking calculation module 2 is configured to determine the corresponding number of calculation units according to the number of calculation units, input the input data into the calculation units in a predetermined manner, calculate the score of each element of the input data, and use the element score as the sequence number of the element in the input data.

[0131] like Figure 3 As shown, another aspect of the present invention also provides a computer device comprising:

[0132] At least one processor 21; and

[0133] The memory 22 stores computer instructions 23 that can be executed on the processor 21, which, when executed by the processor 21, implement the steps of any of the methods described in the above embodiments.

[0134] like Figure 4 As shown, another aspect of the present invention provides a computer-readable storage medium 401 storing a computer program 402, which, when executed by a processor, implements the steps of any of the methods described in the above embodiments.

[0135] The above are exemplary embodiments disclosed in this invention. However, it should be noted that various changes and modifications can be made without departing from the scope of the embodiments of this invention as defined by the claims. The functions, steps, and / or actions of the methods according to the disclosed embodiments described herein do not need to be performed in any particular order. Furthermore, although the elements disclosed in the embodiments of this invention may be described or claimed individually, they may be understood as multiple unless explicitly limited to a singular number.

[0136] It should be understood that, as used herein, the singular form “a” is intended to include the plural form as well, unless the context clearly supports an exception. It should also be understood that, as used herein, “and / or” refers to any and all possible combinations of one or more of the associated listed items.

[0137] The embodiment numbers disclosed in the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0138] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.

[0139] Those skilled in the art should understand that the discussion of any of the above embodiments is merely exemplary and is not intended to imply that the scope of the invention (including the claims) is limited to these examples. Within the framework of the invention, technical features of the above embodiments or different embodiments can be combined, and many other variations of the different aspects of the invention as described above exist, which are not provided in the details for the sake of brevity. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the invention should be included within the protection scope of the invention.

Claims

1. A hardware-based data ranking method, characterized in that, include: The amount of data for each round of computation is determined based on the length of the input data and the expected time to complete the computation task, and the number of computation units for each round of computation is determined based on the amount of data for each round of computation. The number of calculation units is determined according to the number of calculation units. The input data is input into the calculation unit in a predetermined manner and the score of each element of the input data is calculated. This includes: grouping the input data according to the amount of data calculated in each round, inputting two elements in the group as a set of input data into a calculation unit in a permutation and combination manner, and using the calculation result of the calculation unit as the score of the corresponding element of the input data. A data matrix matching the length of the input data is constructed based on the length of the input data; in response to the length of the input data being less than the size of the constructed data matrix, the remaining data is padded with predetermined values; In response to the completion of calculations for all groups of the input data, new groups are formed diagonally based on the data matrix with a predetermined offset. The new groups are then re-inputted into the calculation unit to calculate the scores of the corresponding elements of the input data. The grouping method is to first group sequentially, then group across one position, then group across two positions, and so on to complete the traversal. This ensures that each iteration of data comparison can fully utilize all comparators while preventing arbitrary data from being compared repeatedly. The score of the element is then used as the index of the element in the input data.

2. The method according to claim 1, characterized in that, Also includes: Obtain the current number of available computing units, and determine the number of computing units for the computing task based on the current number of available computing units.

3. The method according to claim 2, characterized in that, Also includes: In response to the fact that the currently available computing units cannot meet the expected time of the computing task for the input data, the computing task is blocked and the currently available computing units are locked. The released computing units are preferentially allocated to the computing task, and in response to the availability of computing units to satisfy the computing task, the corresponding computing units are allocated to the computing task.

4. The method according to claim 1, characterized in that, Also includes: Based on the length of the input data and the expected time to complete the computation task, the amount of data for each round of computation is determined according to a predetermined strategy, and the number of computation units for each round of computation is determined based on the amount of data for each round of computation.

5. A hardware-based data ranking system, characterized in that, include: A computing unit allocation module is configured to determine the amount of data for each round of computing based on the length of the input data and the expected time to complete the computing task, and to determine the number of computing units for each round of computing based on the amount of data for each round of computing. The data ranking calculation module is configured to determine the corresponding number of calculation units according to the number of calculation units, input the input data into the calculation units in a predetermined manner, calculate the score of each element of the input data, and use the element score as the index of the element in the input data; The data ranking calculation module is also used to: group the input data according to the amount of data calculated in each round, input two elements in the group as a set of input data into a calculation unit in a permutation and combination manner, and use the calculation result of the calculation unit as the score of the corresponding element of the input data; A data matrix matching the length of the input data is constructed based on the length of the input data; in response to the length of the input data being less than the size of the constructed data matrix, the remaining data is padded with predetermined values; In response to the completion of calculations for all groups of the input data, new groups are formed diagonally based on the data matrix with a predetermined offset. The new groups are then re-inputted into the calculation unit to calculate the scores of the corresponding elements of the input data. The grouping method is to group sequentially in the first step, then group across one position in the second step, then group across two positions in the third step, and so on to complete the traversal. This ensures that each iteration of data comparison can fully utilize all comparators, while avoiding arbitrary repeated comparisons of data.

6. A computer device, characterized in that, include: At least one processor; as well as A memory storing computer instructions executable on the processor, which, when executed by the processor, implement the steps of the method according to any one of claims 1-4.

7. A computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the method according to any one of claims 1-4.

Citation Information

Patent Citations

  • Verification method based on NAND FLASH memory, terminal device and storage medium

    CN110277131A

  • Sequencing method for FPGA implementation

    CN111258535A

  • Data sorting method and device and computer equipment

    CN111857991A

  • Propagation latency reduction

    CN114026543A