Structure body sorting method, sorting device and sorter

文档序号:1543602 发布日期:2020-01-17 浏览:4次 中文

阅读说明:本技术 一种结构体排序方法、排序装置及排序器 (Structure body sorting method, sorting device and sorter ) 是由 苗准 王旭 杨桦 董咏梅 于 2018-07-10 设计创作,主要内容包括:本发明实施例公开了一种结构体排序方法、排序装置及排序器,该方法包括:从M个结构体的目标定点数中确定最大的N个不重复的目标定点数作为排序参考数;按照从大到小的顺序依次将每个排序参考数与每个结构体的目标定点数比较;若比较的结果为相等,则记录相等的目标定点数所属结构体的序号;根据序号的记录顺序,将对应的结构体依次写入存储器的指定位置。在排序时仅读出结构体的目标定点数,且在排序后按照序号记录的顺序将对应的结构体写入指定位置,既减少了数据读出和写入以及数据比较所消耗的动态功耗,又避免了对数据的频繁读出和写入,显著降低了排序的动态功耗。(The embodiment of the invention discloses a structural body sorting method, a sorting device and a sorter, wherein the method comprises the following steps: determining the largest N nonrepeating target fixed point numbers as sequencing reference numbers from the target fixed point numbers of the M structural bodies; sequentially comparing each sequencing reference number with the target fixed point number of each structural body according to the sequence from big to small; if the comparison result is equal, recording the serial numbers of the structures to which the equal target fixed point numbers belong; and sequentially writing the corresponding structural bodies into the designated positions of the memory according to the recording sequence of the serial numbers. And only reading the target fixed point number of the structural body during sorting, and writing the corresponding structural body into the designated position according to the sequence of the serial number record after sorting, thereby not only reducing the dynamic power consumption consumed by data reading and writing and data comparison, but also avoiding frequent reading and writing of the data, and remarkably reducing the dynamic power consumption of sorting.)

1. A method of ordering structures, the method comprising:

determining the maximum or minimum N nonrepeating target fixed point numbers as a sequencing reference number from the target fixed point numbers of the M structural bodies; m is a positive integer greater than 1, and N is a positive integer less than M;

sequentially comparing each sequencing reference number with the target fixed point number of each structural body according to a preset sequence; if the comparison result is equal, recording the serial numbers of the structures to which the equal target fixed point numbers belong; when the sequencing reference number is the maximum N nonrepeating target fixed point numbers, the preset sequence is from large to small; when the sequencing reference number is the minimum N nonrepeating target fixed point numbers, the preset sequence is from small to large;

and sequentially writing the corresponding structural bodies into the designated positions of the memory according to the recording sequence of the serial numbers.

2. The method according to claim 1, wherein the recording of the serial number of the structure to which the equal target fixed point number belongs further comprises:

judging whether the number of the recorded serial numbers is smaller than the preset sequencing number or not;

if not, the recording sequence according to the sequence number is executed, and the corresponding structural bodies are sequentially written into the designated positions of the memory.

3. The method according to claim 2, wherein when the number of recorded sequence numbers is still smaller than the preset sorting number after comparing each sorting reference number, the method sequentially writes the corresponding structures into the designated locations of the memory according to the recording order of the sequence numbers, and before further comprising:

reducing the ranking reference number of the last comparison by a preset difference value, and updating the ranking reference number of the last comparison; when the sorting reference number is the maximum N nonrepeating target fixed point numbers, the preset difference value is one; when the sorting reference number is the minimum N nonrepeating target fixed point numbers, the preset difference value is minus one;

comparing the sequencing reference number of the last comparison with the target fixed point number of the p structural body again; p is belonged to [1, M ];

when the comparison result is equal, recording the serial numbers of the structural bodies to which the equal target fixed point numbers belong and judging whether the number of the recorded serial numbers is smaller than the preset sequencing number or not;

if not, executing the recording sequence according to the sequence number, and sequentially writing the corresponding structural bodies into the designated positions of the memory;

if yes, after updating p, returning to execute the comparison of the sequencing reference number of the last comparison and the target fixed point number of the p structural body again;

and when the number of the sequence numbers recorded after the last compared sequencing reference number is compared with the target fixed point numbers of the M structural bodies is still smaller than the preset sequencing number, returning to execute the step of subtracting one from the last compared sequencing reference number to update the last compared sequencing reference number.

4. The method according to any one of claims 1 to 3, wherein the determining, as the ranking reference number, the largest or smallest N nonrepeating target fixed point numbers from among the target fixed point numbers of the M structures specifically comprises:

initially setting a first storage area to an Nth storage area, and setting the number stored in each storage area to zero;

comparing the target fixed point number of the ith structure body with the number stored in each storage area, wherein i belongs to [1, M ];

when the sorting reference number is the maximum N nonrepeating target fixed point numbers, if the target fixed point number of the ith structural body is larger than or equal to the number stored in the K storage areas and the target fixed point number of the ith structural body is not equal to the number stored in the (N-K + 1) th storage area, replacing the number stored in the (j + 1) th storage area with the number stored in the (j) th storage area, and replacing the number stored in the (N-K + 1) th storage area with the target fixed point number of the ith structural body; k belongs to [1, N ], j belongs to [ N-K +1, N-1 ];

when the sorting reference number is the minimum N nonrepeating target fixed point numbers, if the target fixed point number of the ith structural body is less than or equal to the number stored in the K storage areas and the target fixed point number of the ith structural body is not equal to the number stored in the (N-K + 1) th storage area, replacing the number stored in the (j + 1) th storage area with the number stored in the (j) th storage area, and replacing the number stored in the (N-K + 1) th storage area with the target fixed point number of the ith structural body; k belongs to [1, N ], j belongs to [ N-K +1, N-1 ];

after i is updated, returning to the step of comparing the target fixed point number of the ith structural body with the number stored in each storage area;

and when the target fixed point number of the M structural bodies is compared with the number stored in each storage area, determining the number stored in the first storage area to the Nth storage area as the sorting reference number in sequence.

5. An apparatus for sequencing structures, the apparatus comprising: a reference determination unit, a data processing unit, and a sequential writing unit;

the reference determining unit is used for determining the maximum or minimum N nonrepeating target fixed point numbers as the sequencing reference number from the target fixed point numbers of the M structural bodies; m is a positive integer greater than 1, and N is a positive integer less than M;

the data processing unit is used for sequentially comparing each sequencing reference number with the target fixed point number of each structural body according to a preset sequence; the system is also used for recording the serial numbers of the structures to which the equal target fixed point numbers belong when the comparison results are equal;

when the sorting reference number is the maximum N nonrepeating target fixed point numbers, the preset sequence is from large to small; when the sequencing reference number is the minimum N nonrepeating target fixed point numbers, the preset sequence is from small to large;

and the sequential writing unit is used for sequentially writing the corresponding structural bodies into the designated positions of the memory according to the recording sequence of the serial numbers.

6. The apparatus of claim 5, further comprising: a quantity judgment unit;

the number judging unit is used for judging whether the number of the recorded serial numbers is less than the preset sequencing number or not after the data processing unit records the serial numbers of the structural bodies to which the equal target fixed point numbers belong; and the sequential writing unit is triggered when the judgment result is negative.

7. The apparatus of claim 6, further comprising: a data update unit;

the data updating unit is used for reducing the last compared sorting reference number by a preset difference value and triggering the data processing unit after updating the last compared sorting reference number when the judgment result of the number judging unit is still yes after the data processing unit finishes comparing each sorting reference number;

when the sorting reference number is the maximum N nonrepeating target fixed point numbers, the preset difference value is one; when the sorting reference number is the minimum N nonrepeating target fixed point numbers, the preset difference value is minus one;

the data processing unit is further used for comparing the sequencing reference number of the last comparison with the target fixed point number of each structural body again; and the data updating unit is also used for triggering the data updating unit again when the judgment result of the quantity judging unit is still yes when the sequencing reference number of the last comparison and the target fixed point number of each structural body are compared.

8. The apparatus according to any one of claims 5 to 7, wherein the reference determination unit specifically includes: the device comprises an initialization subunit, a comparison subunit, a setting subunit, an updating subunit and an acquisition subunit;

the initialization subunit is used for initially setting first to Nth storage areas and setting the number stored in each storage area to zero;

the comparison subunit is used for comparing the target fixed point number of the ith structure body with the number stored in each storage area, and i belongs to [1, M ];

the setting subunit is configured to, when the sorting reference number is the largest N nonrepeating target fixed point numbers, if the comparison result of the comparison subunit is that the target fixed point number of the ith structural body is greater than or equal to the number stored in the K storage areas and the target fixed point number of the ith structural body is not equal to the number stored in the N-K +1 storage area, replace the number stored in the j +1 storage area with the number stored in the j storage area, and trigger the updating subunit after replacing the number stored in the N-K +1 storage area with the target fixed point number of the ith structural body; the device is further configured to, when the sorting reference number is the smallest N nonrepeating target fixed point numbers, if the comparison result of the comparison subunit is that the target fixed point number of the ith structural body is less than or equal to the number stored in the K storage areas and the target fixed point number of the ith structural body is not equal to the number stored in the N-K +1 storage area, replace the number stored in the j +1 storage area with the number stored in the j storage area, and trigger the update subunit after replacing the number stored in the N-K +1 storage area with the target fixed point number of the ith structural body;

wherein, K belongs to [1, N ], j belongs to [ N-K +1, N-1 ];

the updating subunit is used for triggering the comparing subunit after updating the i;

and the acquiring subunit is configured to determine, as the sort reference number, the numbers stored in the first to nth storage areas in sequence after the target fixed point number of the M structural bodies is compared with the number stored in each storage area.

9. A structure sorter, comprising: the device comprises a read-write module, a comparison module and a write-in module;

the read-write module is used for transferring the target fixed point number of the M structural bodies to be sorted in the local memory to a local cache; the comparison module is also used for determining the maximum or minimum N nonrepeating target fixed point numbers from the target fixed point numbers of the M structural bodies as a sequencing reference number and then informing the comparison module; m is a positive integer greater than 1, and N is a positive integer less than M;

the comparison module is used for acquiring each sequencing reference number from the read-write module after receiving the notification of the read-write module, and acquiring the target fixed point number of the M structural bodies from the local cache; the cache module is further used for sequentially comparing each sequencing reference number with the target fixed point number of each structural body according to a preset sequence, and when the comparison result is equal, writing the serial number of the structural body to which the equal target fixed point number belongs into the local cache and then informing the write-in module;

when the sorting reference number is the maximum N nonrepeating target fixed point numbers, the preset sequence is from large to small; when the sequencing reference number is the minimum N nonrepeating target fixed point numbers, the preset sequence is from small to large;

and the writing module is used for acquiring recorded serial numbers from the local cache after receiving the notification of the comparison module, acquiring the structural bodies corresponding to the serial numbers from the local storage according to the recording sequence of the serial numbers, and then sequentially writing the structural bodies into the specified positions of the local storage.

10. The structure sequencer according to claim 9, wherein the comparison module specifically includes: a first reading submodule and a comparison submodule;

the first reading submodule is used for acquiring the target fixed point numbers of the M structural bodies from the local cache after receiving the notification of the read-write module, and then sending the target fixed point numbers to the comparison submodule one by one;

the comparison submodule is used for acquiring each sequencing reference number from the read-write module after receiving the notification of the read-write module, and sequentially comparing each sequencing reference number with the target fixed point number of each structural body according to the preset sequence; and the writing module is also used for judging whether the number of the recorded serial numbers is smaller than the preset sorting number or not when the comparison results are equal, and writing the serial numbers of the structural bodies to which the equal target fixed point numbers belong into the local cache if the number of the recorded serial numbers is smaller than the preset sorting number, and informing the writing module of the serial numbers.

11. The structure sequencer according to claim 10,

the comparison submodule is further configured to, when the number of recorded sequence numbers is still smaller than the preset number after each comparison of the ranking reference numbers is completed, reduce the last comparison ranking reference number by a preset difference value to update the last comparison ranking reference number, and then compare the last comparison ranking reference number with the target fixed point number of each structure again;

when the sorting reference number is the maximum N nonrepeating target fixed point numbers, the preset difference value is one; and when the sequencing reference number is the minimum N nonrepeating target fixed point numbers, the preset difference value is negative one.

12. The structure sequencer according to any one of claims 9 to 11, wherein the read/write module specifically includes: a second read submodule and a write submodule;

the second reading submodule is used for sending a reading instruction to the local storage to enable the local storage to send the target fixed point number of the M structural bodies to the writing submodule according to the reading instruction;

the writing sub-module is used for writing the obtained target fixed point number into the local cache; and is also used for executing the following steps in the writing process:

initially setting a first storage area to an Nth storage area, and setting the number stored in each storage area to zero;

comparing the target fixed point number of the ith structure body with the number stored in each storage area, wherein i belongs to [1, M ];

when the sorting reference number is the maximum N nonrepeating target fixed point numbers, if the target fixed point number of the ith structural body is larger than or equal to the number stored in the K storage areas and the target fixed point number of the ith structural body is not equal to the number stored in the (N-K + 1) th storage area, replacing the number stored in the (j + 1) th storage area with the number stored in the (j) th storage area, and replacing the number stored in the (N-K + 1) th storage area with the target fixed point number of the ith structural body; k belongs to [1, N ], j belongs to [ N-K +1, N-1 ];

when the sorting reference number is the minimum N nonrepeating target fixed point numbers, if the target fixed point number of the ith structural body is less than or equal to the number stored in the K storage areas and the target fixed point number of the ith structural body is not equal to the number stored in the (N-K + 1) th storage area, replacing the number stored in the (j + 1) th storage area with the number stored in the (j) th storage area, and replacing the number stored in the (N-K + 1) th storage area with the target fixed point number of the ith structural body; k belongs to [1, N ], j belongs to [ N-K +1, N-1 ];

after i is updated, returning to the step of comparing the target fixed point number of the ith structural body with the number stored in each storage area;

and when the target fixed point number of the M structural bodies is compared with the number stored in each storage area, determining the number stored in the first storage area to the Nth storage area as the sorting reference number in sequence.

Technical Field

The present disclosure relates to the field of data processing technologies, and in particular, to a method, an apparatus, and a sequencer for sequencing a structure.

Background

A structure is a data set that includes multiple types of data. Generally, each type of data in the structure can be regarded as a fixed point number, and the bit width of each fixed point number is different.

At present, when a plurality of structural bodies are ordered according to the size of a certain type of data in the structural bodies, reading and writing operations are performed on a local memory of a storage structural body in each round of ordering, and the local memory is frequently accessed in the ordering process, so that large dynamic power consumption is caused.

Disclosure of Invention

In view of this, embodiments of the present application provide a structure ordering method, an ordering apparatus, and an ordering device, which can solve the problem of large dynamic power consumption caused by frequent accesses to a local memory in an ordering process in the prior art.

The method for sequencing the structural bodies provided by the embodiment of the application comprises the following steps:

determining the maximum or minimum N nonrepeating target fixed point numbers as a sequencing reference number from the target fixed point numbers of the M structural bodies; m is a positive integer greater than 1, and N is a positive integer less than M;

sequentially comparing each sequencing reference number with the target fixed point number of each structural body according to a preset sequence; if the comparison result is equal, recording the serial numbers of the structures to which the equal target fixed point numbers belong; when the sequencing reference number is the maximum N nonrepeating target fixed point numbers, the preset sequence is from large to small; when the sequencing reference number is the minimum N nonrepeating target fixed point numbers, the preset sequence is from small to large;

and sequentially writing the corresponding structural bodies into the designated positions of the memory according to the recording sequence of the serial numbers.

Optionally, the recording the sequence numbers of the structure bodies to which the equal target fixed point numbers belong further includes:

judging whether the number of the recorded serial numbers is smaller than the preset sequencing number or not;

if not, the recording sequence according to the sequence number is executed, and the corresponding structural bodies are sequentially written into the designated positions of the memory.

Optionally, when the number of recorded sequence numbers is still smaller than the preset sorting number after comparing each sorting reference number, the corresponding structure body is sequentially written into the designated position of the memory according to the recording order of the sequence numbers, and the method further includes:

reducing the ranking reference number of the last comparison by a preset difference value, and updating the ranking reference number of the last comparison; when the sorting reference number is the maximum N nonrepeating target fixed point numbers, the preset difference value is one; when the sorting reference number is the minimum N nonrepeating target fixed point numbers, the preset difference value is minus one;

comparing the sequencing reference number of the last comparison with the target fixed point number of the p structural body again; p is belonged to [1, M ];

when the comparison result is equal, recording the serial numbers of the structural bodies to which the equal target fixed point numbers belong and judging whether the number of the recorded serial numbers is smaller than the preset sequencing number or not;

if not, executing the recording sequence according to the sequence number, and sequentially writing the corresponding structural bodies into the designated positions of the memory;

if yes, returning to execute the comparison of the sequencing reference number of the last comparison and the target fixed point number of the p structural body again after updating p;

and when the number of the sequence numbers recorded after the last compared sequencing reference number is compared with the target fixed point numbers of the M structural bodies is still smaller than the preset sequencing number, returning to execute the step of subtracting one from the last compared sequencing reference number to update the last compared sequencing reference number.

Optionally, the determining, as the ranking reference number, the maximum or minimum N nonrepeating target fixed point numbers from the target fixed point numbers of the M structural bodies specifically includes:

initially setting a first storage area to an Nth storage area, and setting the number stored in each storage area to zero;

comparing the target fixed point number of the ith structure body with the number stored in each storage area, wherein i belongs to [1, M ];

when the sorting reference number is the largest N nonrepeating target fixed point numbers, if the target fixed point number of the ith structural body is larger than or equal to the number stored in the K storage areas and the target fixed point number of the ith structural body is not equal to the number stored in the (N-K + 1) th storage area, replacing the number stored in the (j + 1) th storage area with the number stored in the (j) th storage area, replacing the number stored in the (N-K + 1) th storage area with the target fixed point number of the ith structural body, and replacing the number stored in the (j + 1) th storage area with the number stored in the (j) th storage area; k belongs to [1, N ], j belongs to [ N-K +1, N-1 ];

when the sorting reference number is the minimum N nonrepeating target fixed point numbers, if the target fixed point number of the ith structural body is less than or equal to the number stored in the K storage areas and the target fixed point number of the ith structural body is not equal to the number stored in the (N-K + 1) th storage area, replacing the number stored in the (j + 1) th storage area with the number stored in the (j) th storage area, replacing the number stored in the (N-K + 1) th storage area with the target fixed point number of the ith structural body, and replacing the number stored in the (j + 1) th storage area with the number stored in the (j) th storage area; k belongs to [1, N ], j belongs to [ N-K +1, N-1 ];

after i is updated, returning to the step of comparing the target fixed point number of the ith structural body with the number stored in each storage area;

and when the target fixed point number of the M structural bodies is compared with the number stored in each storage area, determining the number stored in the first storage area to the Nth storage area as the sorting reference number in sequence.

The utility model provides a structure sequencing device, the device includes: a reference determination unit, a data processing unit, and a sequential writing unit;

the reference determining unit is used for determining the maximum or minimum N nonrepeating target fixed point numbers as the sequencing reference number from the target fixed point numbers of the M structural bodies; m is a positive integer greater than 1, and N is a positive integer less than M;

the data processing unit is used for sequentially comparing each sequencing reference number with the target fixed point number of each structural body according to a preset sequence; the system is also used for recording the serial numbers of the structures to which the equal target fixed point numbers belong when the comparison results are equal;

when the sorting reference number is the maximum N nonrepeating target fixed point numbers, the preset sequence is from large to small; when the sequencing reference number is the minimum N nonrepeating target fixed point numbers, the preset sequence is from small to large;

and the sequential writing unit is used for sequentially writing the corresponding structural bodies into the designated positions of the memory according to the recording sequence of the serial numbers.

Optionally, the apparatus further comprises: a quantity judgment unit;

the number judging unit is used for judging whether the number of the recorded serial numbers is less than the preset sequencing number or not after the data processing unit records the serial numbers of the structural bodies to which the equal target fixed point numbers belong; and the sequential writing unit is triggered when the judgment result is negative.

Optionally, the apparatus further comprises: the device comprises a data updating unit and a triggering unit;

the data updating unit is used for reducing the last compared sorting reference number by a preset difference value and triggering the data processing unit after updating the last compared sorting reference number when the judgment result of the number judging unit is still yes after the data processing unit finishes comparing each sorting reference number;

when the sorting reference number is the maximum N nonrepeating target fixed point numbers, the preset difference value is one; when the sorting reference number is the minimum N nonrepeating target fixed point numbers, the preset difference value is minus one;

the data processing unit is further used for comparing the sequencing reference number of the last comparison with the target fixed point number of each structural body again; and the data updating unit is also used for triggering the data updating unit again when the judgment result of the quantity judging unit is still yes when the sequencing reference number of the last comparison and the target fixed point number of each structural body are compared.

Optionally, the reference determining unit specifically includes: the device comprises an initialization subunit, a comparison subunit, a setting subunit, an updating subunit and an acquisition subunit;

the initialization subunit is used for initially setting first to Nth storage areas and setting the number stored in each storage area to zero;

the comparison subunit is used for comparing the target fixed point number of the ith structure body with the number stored in each storage area, and i belongs to [1, M ];

the setting subunit is configured to, when the sorting reference number is the largest N nonrepeating target fixed point numbers, if the comparison result of the comparison subunit is that the target fixed point number of the ith structural body is greater than or equal to the number stored in the K storage areas and the target fixed point number of the ith structural body is not equal to the number stored in the N-K +1 storage area, replace the number stored in the j +1 storage area with the number stored in the j storage area, replace the number stored in the N-K +1 storage area with the target fixed point number of the ith structural body, and replace the number stored in the j +1 storage area with the number stored in the j storage area, and then trigger the updating subunit; the device is further configured to, when the sorting reference number is the smallest N nonrepeating target fixed point numbers, if the comparison result of the comparison subunit is that the target fixed point number of the ith structural body is less than or equal to the number stored in the K storage areas and the target fixed point number of the ith structural body is not equal to the number stored in the N-K +1 storage area, replace the number stored in the j +1 storage area with the number stored in the j storage area, replace the number stored in the N-K +1 storage area with the target fixed point number of the ith structural body, and trigger the update subunit after replacing the number stored in the j +1 storage area with the number stored in the j storage area;

wherein, K belongs to [1, N ], j belongs to [ N-K +1, N-1 ];

the updating subunit is used for triggering the comparing subunit after updating the i;

and the acquiring subunit is configured to determine, as the sort reference number, the numbers stored in the first to nth storage areas in sequence after the target fixed point number of the M structural bodies is compared with the number stored in each storage area.

The utility model provides a structure sequencer that this application embodiment provided includes: the device comprises a read-write module, a comparison module and a write-in module;

the read-write module is used for transferring the target fixed point number of the M structural bodies to be sorted in the local memory to a local cache; the comparison module is also used for determining the maximum or minimum N nonrepeating target fixed point numbers from the target fixed point numbers of the M structural bodies as a sequencing reference number and then informing the comparison module; m is a positive integer greater than 1, and N is a positive integer less than M;

the comparison module is used for acquiring each sequencing reference number from the read-write module after receiving the notification of the read-write module, and acquiring the target fixed point number of the M structural bodies from the local cache; the cache module is further used for sequentially comparing each sequencing reference number with the target fixed point number of each structural body according to a preset sequence, and when the comparison result is equal, writing the serial number of the structural body to which the equal target fixed point number belongs into the local cache and then informing the write-in module;

when the sorting reference number is the maximum N nonrepeating target fixed point numbers, the preset sequence is from large to small; when the sequencing reference number is the minimum N nonrepeating target fixed point numbers, the preset sequence is from small to large;

and the writing module is used for acquiring recorded serial numbers from the local cache after receiving the notification of the comparison module, acquiring the structural bodies corresponding to the serial numbers from the local storage according to the recording sequence of the serial numbers, and then sequentially writing the structural bodies into the specified positions of the local storage.

Optionally, the comparing module specifically includes: a first reading submodule and a comparison submodule;

the first reading submodule is used for acquiring the target fixed point numbers of the M structural bodies from the local cache after receiving the notification of the read-write module, and then sending the target fixed point numbers to the comparison submodule one by one;

the comparison submodule is used for acquiring each sequencing reference number from the read-write module after receiving the notification of the read-write module, and sequentially comparing each sequencing reference number with the target fixed point number of each structural body according to the preset sequence; and the writing module is also used for judging whether the number of the recorded serial numbers is smaller than the preset sorting number or not when the comparison results are equal, and writing the serial numbers of the structural bodies to which the equal target fixed point numbers belong into the local cache if the number of the recorded serial numbers is smaller than the preset sorting number, and informing the writing module of the serial numbers.

Alternatively to this, the first and second parts may,

the comparison submodule is further configured to, when the number of recorded sequence numbers is still smaller than the preset number after each comparison of the ranking reference numbers is completed, reduce the last comparison ranking reference number by a preset difference value to update the last comparison ranking reference number, and then compare the last comparison ranking reference number with the target fixed point number of each structure again;

when the sorting reference number is the maximum N nonrepeating target fixed point numbers, the preset difference value is one; and when the sequencing reference number is the minimum N nonrepeating target fixed point numbers, the preset difference value is negative one.

Optionally, the read-write module specifically includes: a second read submodule and a write submodule;

the second reading submodule is used for sending a reading instruction to the local storage to enable the local storage to send the target fixed point number of the M structural bodies to the writing submodule according to the reading instruction;

the writing sub-module is used for writing the obtained target fixed point number into the local cache; and is also used for executing the following steps in the writing process:

initially setting a first storage area to an Nth storage area, and setting the number stored in each storage area to zero;

comparing the target fixed point number of the ith structure body with the number stored in each storage area, wherein i belongs to [1, M ];

when the sorting reference number is the largest N nonrepeating target fixed point numbers, if the target fixed point number of the ith structural body is larger than or equal to the number stored in the K storage areas and the target fixed point number of the ith structural body is not equal to the number stored in the (N-K + 1) th storage area, replacing the number stored in the (j + 1) th storage area with the number stored in the (j) th storage area, replacing the number stored in the (N-K + 1) th storage area with the target fixed point number of the ith structural body, and replacing the number stored in the (j + 1) th storage area with the number stored in the (j) th storage area; k belongs to [1, N ], j belongs to [ N-K +1, N-1 ];

when the sorting reference number is the minimum N nonrepeating target fixed point numbers, if the target fixed point number of the ith structural body is less than or equal to the number stored in the K storage areas and the target fixed point number of the ith structural body is not equal to the number stored in the (N-K + 1) th storage area, replacing the number stored in the (j + 1) th storage area with the number stored in the (j) th storage area, replacing the number stored in the (N-K + 1) th storage area with the target fixed point number of the ith structural body, and replacing the number stored in the (j + 1) th storage area with the number stored in the (j) th storage area; k belongs to [1, N ], j belongs to [ N-K +1, N-1 ];

after i is updated, returning to the step of comparing the target fixed point number of the ith structural body with the number stored in each storage area;

and when the target fixed point number of the M structural bodies is compared with the number stored in each storage area, determining the number stored in the first storage area to the Nth storage area as the sorting reference number in sequence.

Compared with the prior art, the method has the advantages that:

the embodiment of the application provides a structural body sequencing method, a sequencing device and a sequencer, when a plurality of structural bodies are sequenced, a target fixed point number of each structural body is read as a sequencing basis, the largest or smallest N nonrepeating target fixed point numbers are determined as sequencing reference numbers, then in the sequencing process, each sequencing reference number is sequentially compared with the target fixed point number of each structural body from large to small or from small to large, when the comparison results are equal, the serial numbers of the structural bodies to which the equal target fixed point numbers belong are recorded, and then the structural bodies corresponding to the serial numbers are sequentially written into the appointed positions of a memory according to the sequence recorded by the serial numbers, namely, the structural bodies are sequenced according to the size of the target fixed point numbers in the structural bodies. In the sorting process, on one hand, the serial numbers of the corresponding structural bodies are recorded in sequence according to the size of the target fixed point number as the basis of sequential writing, and the corresponding structural bodies are written into the designated positions only according to the sequence recorded by the serial numbers after sorting, so that frequent reading and writing of the structural bodies are avoided, and the dynamic power consumption of reading and writing of the structural bodies is reduced; on the other hand, only the target fixed point number of the structure body is read during sorting, only the target fixed point number participates in sorting comparison, and dynamic power consumption consumed by data reading and writing and data comparison is reduced.

Drawings

In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments described in the present application, and other drawings can be obtained by those skilled in the art without creative efforts.

Fig. 1 is a schematic flow chart of a structure sorting method according to an embodiment of the present disclosure;

fig. 2 is a schematic flowchart of a method for determining sort reference numbers according to an embodiment of the present application;

FIG. 3 is a schematic flow chart illustrating a method for comparing sort reference counts and target fixed point counts according to an embodiment of the present application;

fig. 4 is a schematic flow chart of another structure sequencing method provided in the embodiment of the present application;

fig. 5 is a schematic structural diagram of a structural body sorting apparatus according to an embodiment of the present application;

fig. 6 is a schematic structural diagram of another structural body sequencing apparatus provided in this embodiment of the present application;

fig. 7 is a schematic structural diagram of a structure sequencer according to an embodiment of the present disclosure;

fig. 8 is a schematic structural diagram of another structure sequencer according to an embodiment of the present disclosure.

Detailed Description

In order to make the technical solutions of the present application better understood, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.

For ease of understanding, a specific scenario of the embodiment of the present application is first described below. The structural body sorting method, the sorting device and the sorter provided by the embodiment of the application are used for sorting a plurality of structural bodies according to the size of specific types of data (namely target fixed point number) in the structural bodies. The sorting result is that the plurality of structural bodies are written into the appointed position of the memory according to the size sequence of the target fixed point number. The initial storage position and the final sorting written position of the structure to be sorted are not limited in the embodiment of the present application, and may be addresses in the same storage medium or addresses in different memories. The following describes the initial storage position and the ordered writing position of the structure in the local storage in detail, and the implementation manners in other cases are similar to these, and are not described in detail any more.

The currently used sorting method requires frequent read and write operations to the local memory during the sorting process. For example, when bubble sorting is performed, assuming that the structures to be sorted are [ a (1), a (2), a (3), …, a (i-1), and a (i) ], when the sorting and sorting result gradually decreases from left to right, two adjacent structures to be sorted, such as a (1) and a (2), need to be read from the local memory first, compare the target fixed point numbers in a (1) and a (2), and when the target fixed point number in a (1) is smaller than the target fixed point number in a (2), it is necessary to perform storage location exchange, write structure a (1) into the storage location of a (2), and write structure a (2) into the storage location of a (1). Then, the target fixed point numbers in A (1) and A (3) are compared, and the process is repeated until the last group, such as A (i-1) and A (i), is compared. In the bubble sorting process, the exchange of the compared storage positions needs to perform read and write operations on the local storage, and the frequent exchange causes a large dynamic power consumption problem.

Therefore, the embodiment of the application provides a structure body sequencing method, a sequencing device and a sequencer, firstly, only reading out the target fixed point number for sequencing in the structure body from a local memory, and saving the read-out power consumption; secondly, in the sorting process, the operation of data exchange is abandoned, N nonrepeating target fixed point numbers with the maximum target positioning number in the plurality of structural bodies are firstly determined as comparison reference chambers, then each comparison reference number is compared with the target fixed point number of each structural body according to a preset sequence, when the comparison results are equal, the serial numbers of the structural bodies to which the equal target fixed point numbers belong are recorded, and finally the corresponding structural bodies are sequentially written into the appointed positions according to the recording sequence of the serial numbers to complete the sorting process, so that the frequent read-write operation is not needed, the access times of a local memory are reduced, and the dynamic power consumption is reduced.

Based on the above-mentioned ideas, in order to make the above-mentioned objects, features and advantages of the present application more comprehensible, specific embodiments of the present application are described in detail below with reference to the accompanying drawings.

Referring to fig. 1, the figure is a schematic flow chart of a structure ordering method according to an embodiment of the present application.

The method for sequencing the structural bodies provided by the embodiment of the application comprises the following steps of S101-S103:

s101: and determining the largest or smallest N nonrepeating target fixed point numbers as a sequencing reference number from the target fixed point numbers of the M structures.

In the embodiment of the present application, the number M of structures to be sorted stored in the local memory is a positive integer greater than 1, and N is a positive integer smaller than M. The target fixed point number is one kind of data in the structure body and is the basis for the sequencing of the structure body. For example, the target fixed point number may be second type data in the structure body, and when sorting is performed, the plurality of structure bodies are sorted according to the size of the second type data in the structure body. When the target fixed point numbers of the M structural bodies are sorted from large to small, the sorting reference number is the largest N nonrepeating target fixed point numbers; when the target fixed point numbers of the M structures are sorted from small to large, the sorting reference number is the smallest N nonrepeating target fixed point numbers.

In practical applications, any comparison and sorting method may be adopted to determine the largest or smallest N nonrepeating target fixed point numbers among the target fixed point numbers of the M structures as a sorting reference number, which will be specifically exemplified below.

In some possible implementations of the embodiment of the present application, as shown in fig. 2, step S101 may include the following steps S1011 to S1014.

S1011: the first to nth memory areas are initially set and the number stored in each memory area is set to zero.

In this embodiment of the application, the first to nth initially set N storage areas may be storage areas corresponding to consecutive N addresses in the local memory, or may also be storage areas corresponding to non-consecutive N addresses, which is not specifically limited herein. It should be noted that the N initially set storage areas have a certain order, and if the addresses of the N storage areas are not consecutive, the addresses of the N storage areas need to be sequentially recorded to determine the order of the storage areas. As an example, the first-Nth total N storage areas may be a set of contiguous registers in the local memory.

As an example, assuming that N is 5, the first-nth storage regions may be N storage regions arranged from left to right as shown below:

the arrangement sequence of the storage regions is not specifically limited in the embodiment of the application, and the first to nth storage regions and the number stored therein which are initially set are as follows:

0 0 0 0 0

it should be noted that, the value of N may be specifically set according to an actual sorting condition, and this is not limited in the embodiment of the present application. For example, if the target fixed point number is 8 bits wide, then N may be 16.

S1012: comparing the target fixed point number of the ith structure body with the number stored in each storage area; when the sorting reference number is the largest N nonrepeating target fixed point numbers, if the target fixed point number of the i-th structural body is greater than or equal to the number stored in the K storage areas and the target fixed point number of the i-th structural body is not equal to the number stored in the N-K +1 storage area, performing step S1013; when the sorting reference number is the minimum N nonrepeating target fixed point numbers, if the target fixed point number of the i-th structural body is less than or equal to the number stored in the K storage areas and the target fixed point number of the i-th structural body is not equal to the number stored in the N-K +1 storage area, performing step S1013; wherein i belongs to [1, M ], K belongs to [1, N ].

It can be understood that the ith structure may be any one of M structures to be sorted in the local storage, and does not represent that the M structures to be sorted in the local storage have a certain order, nor represents that the target fixed point number of the structures is read out from the local storage according to a certain order during comparison, and both the storage order and the reading order of the structures in actual application may be random.

S1013: replacing the number stored in the j +1 th storage area with the number stored in the j storage area, and replacing the number stored in the (N-K + 1) th storage area with the target fixed point number of the ith structural body; after updating i, the process returns to step S1012. Wherein j belongs to [ N-K +1, N-1 ].

For example, if the target fixed-point number of the first structure is 10, comparing 10 with the number stored in each storage area, where 10 is greater than or equal to the number stored in 5 (K is 5), N-K +1 is 1, but 10 is not equal to 0 stored in the 1 st storage area, replacing the number stored in the 2 nd storage area with the number stored in the first storage area, replacing the number stored in the 3 rd storage area with the number stored in the 2 nd storage area, and so on; and replacing the number stored in the first storage area with 10 to obtain the first-Nth storage areas and the number stored in the first-Nth storage areas as follows:

10 0 0 0 0

if the target fixed point number of the 2 nd structure is 6, comparing 6 with the number stored in each storage area, and if 6 is greater than or equal to the number stored in 4(K is 4), and N-K +1 is 2, but 6 is not equal to 0 stored in the 2 nd storage area, replacing the number stored in the 3 rd storage area with the number stored in the 2 nd storage area, replacing the number stored in the 4 th storage area with the number stored in the 3 rd storage area, and so on; and replacing the number stored in the 2 nd storage area with 6 to obtain the first-Nth storage areas and the number stored in the first-Nth storage areas as follows:

10 6 0 0 0

if the target fixed point number of the 3 rd structural body is 8, comparing 8 with the number stored in each storage area, wherein 8 is greater than or equal to the number stored in 4(K is 4), N-K +1 is 2, but 8 is not equal to 6 stored in the 2 nd storage area, replacing the number stored in the 3 rd storage area with the number stored in the 2 nd storage area, replacing the number stored in the 4 th storage area with the number stored in the 3 rd storage area, and so on; and replacing the number stored in the 2 nd storage area with 8 to obtain the first-Nth storage areas and the number stored in the first-Nth storage areas as follows:

10 8 6 0 0

if the target fixed point number of the 4 th structure remains 6, 6 is compared with the number stored in each storage region, 6 is greater than or equal to the number stored in 3(K is 3) storage regions, N-K +1 is 3, but 6 is equal to 6 stored in the 3 rd storage region, the process of this round is ended, the target fixed point number of the 5 th structure is continuously compared with the number stored in each storage region, and so on until the target fixed point numbers of the M structures are all compared with the number stored in the storage region, step S1014 is executed.

S1014: and when the target fixed point numbers of the M structural bodies are compared with the numbers stored in the storage areas, determining the numbers stored in the first-Nth storage areas as the sequencing reference numbers in sequence.

It can be understood that, after the steps S1012 to S1013 are performed on all the target fixed point numbers of M structures, the numbers stored in the first to nth storage regions are the largest N nonrepeating target fixed point numbers arranged in the order from large to small or from small to large, so that not only the largest or smallest N nonrepeating target fixed point numbers are found, but also the size order among the N target fixed point numbers is determined, and support is provided for subsequent comparison.

In the embodiment of the application, when the maximum or minimum N nonrepeating target fixed point numbers are determined as the sorting reference number, each target fixed point number is simultaneously compared with the numbers stored in the plurality of storage areas in parallel, and the processing efficiency is improved.

S102: sequentially comparing each sequencing reference number with the target fixed point number of each structural body according to a preset sequence; and if the comparison result is equal, recording the serial numbers of the structures to which the equal target fixed point numbers belong.

In the embodiment of the application, when the sequencing reference number is the maximum N nonrepeating target fixed point numbers, the preset sequence is from large to small; when the sorting reference number is the minimum N nonrepeating target fixed point numbers, the preset sequence is from small to large.

Taking the example from large to small, the number stored in the first storage area is compared with the target fixed point number of each structure, and when the number is equal to the target fixed point number of each structure, the equal target fixed point number is the maximum value of the target fixed point numbers of the M structures, and the structure with the maximum target fixed point number in the M structures is found out by recording the number of the structures to which the equal target fixed point number belongs. And then, comparing the number stored in the second storage area with the target fixed point number of each structure body, and when the number stored in the second storage area is equal to the target fixed point number of each structure body, indicating that the equal target fixed point number is the second largest value of the target fixed point numbers of the M structure bodies, recording the serial numbers of the structure bodies to which the equal target fixed point number belongs, namely finding out the structure body with the second largest target fixed point number of the M structure bodies, and so on, namely realizing that the M structure bodies are sorted according to the sequence of the target fixed point numbers from large to small. The ordering from small to large is similar and will not be described further herein.

It should be noted that, in the embodiment of the present application, the serial numbers of the corresponding structures are sequentially recorded according to the size of the target fixed point number as the basis for sequential writing, so that frequent reading and writing of the structures are avoided, and dynamic power consumption for reading and writing of the structures is reduced.

S103: and sequentially writing the structures corresponding to the sequence numbers into the designated positions of the memory according to the recording sequence of the sequence numbers.

Since the sequence numbers recorded in step S102 are recorded in the order of the sorted structures, that is, the sorting order of the structures, the sorting of the M structures by the size of the target fixed point is completed after the corresponding structures are sequentially written into the designated positions of the memory according to the recording order of the sequence numbers. In practical applications, the writing position (i.e. the designated position of the memory) after the sorting of the structure body can be specifically set according to actual needs, and is not listed here.

In the embodiment of the application, the target fixed point number of each structural body to be sorted is read as a sorting basis, the largest or smallest N nonrepeating target fixed point numbers are determined as sorting reference numbers, then in the sorting process, each sorting reference number is sequentially compared with the target fixed point number of each structural body from large to small or from small to large, when the comparison results are equal, the serial numbers of the structural bodies to which the equal target fixed point numbers belong are recorded, and then the structural bodies corresponding to the serial numbers are sequentially written into the specified positions of the memory according to the sequence recorded by the serial numbers, namely, the structural bodies are sorted according to the size of the target fixed point number in the structural body. In the sorting process, on one hand, the serial numbers of the corresponding structural bodies are recorded in sequence according to the size of the target fixed point number as the basis of sequential writing, and the corresponding structural bodies are written into the designated positions only according to the sequence recorded by the serial numbers after sorting, so that frequent reading and writing of the structural bodies are avoided, and the dynamic power consumption of reading and writing of the structural bodies is reduced; on the other hand, only the target fixed point number of the structure body is read during sorting, only the target fixed point number participates in sorting comparison, and dynamic power consumption consumed by data reading and writing and data comparison is reduced.

In practical applications, although the number of structures participating in the sorting is M, only the largest or smallest L structures may actually need to be output, L < M. For example, when M is 256, only the maximum 10(L is 10) structures need to be output. In this case, if all 256 structures are sorted and then output to the first 10 structures, there is an unnecessary comparison process, and the process is time-consuming and expensive.

For this reason, in some possible implementations of the embodiment of the present application, the initial setting x is 1, and y is 1, and the step S102 may specifically include the following steps S1021 to S1025, as shown in fig. 3.

S1021: comparing the maximum or minimum xth sequencing reference number with the target fixed point number of the yth structural body; when the comparison results are equal, step S1022 is performed.

In the embodiment of the application, the largest xth sorting reference number is the xth sorting reference number obtained by sorting N sorting reference numbers in descending order; similarly, the smallest xth sorting reference number is the xth sorting reference number obtained by sorting the N sorting reference numbers in the order from small to large.

S1022: and recording the serial numbers of the structures to which the equal target fixed point numbers belong.

S1023: judging whether the number of the recorded serial numbers is smaller than the preset sequencing number or not; if yes, executing step S1024; if not, step S103 is executed.

S1024: judging whether y is smaller than M; if yes, after y is equal to y +1, returning to execute the step S1021; if not, step S1025 is executed.

S1025: judging whether x is smaller than N; if so, the process returns to step S1021 after x is equal to x +1 and y is equal to 1.

In the embodiment of the present application, the preset sorting number, i.e. L described above, is the number of preset desired sorted structural bodies, and can be specifically set according to actual needs. The number of the recorded sequence numbers is judged after the sequence numbers are recorded each time, whether the sequence numbers with the preset sorting number are recorded or not is determined, once the number of the recorded sequence numbers is equal to the preset sorting number, the sorting process is finished, the step S103 is executed, the sorting of the structure bodies with the preset sorting number is completed, and the sorting process is saved.

The foregoing describes how the structure body sorting method provided in this embodiment determines to output L structure bodies with the largest or smallest target fixed point number in a plurality of structure bodies, but in some possible cases, after the comparison between each sorting reference number and each structure body is completed, the number of recorded sequence numbers is still smaller than the preset sorting number. In order to meet the requirement of the preset structural body sorting quantity, the embodiment of the application provides a more specific structural body sorting method.

Referring to fig. 4, this figure is a schematic flow chart of another structure ordering method provided in the embodiment of the present application.

In some possible implementation manners of the embodiment of the present application, when the number of recorded sequence numbers is still smaller than the preset sorting number after each sorting reference number is compared with the target fixed point number of each structure, the following steps S401 to S405 are further included before step S103.

S401: and reducing the ranking reference number of the last comparison by a preset difference value, and updating the ranking reference number of the last comparison.

In the embodiment of the present application, when the largest ranking reference number is the largest N nonrepeating target fixed point numbers, that is, the structure is ranked according to the sequence of the target fixed point numbers from large to small, a difference value of 1 is preset, and the ranking process is repeated after the smallest ranking reference number is reduced by 1 (i.e., steps S402-405), so as to meet the requirement of the ranking number of the structure. Similarly, when the sorting reference number is the smallest N nonrepeating target fixed point numbers, that is, the structure is sorted according to the sequence of the target fixed point numbers from small to large, the preset difference value is-1, and the sorting process is repeated after the largest sorting reference number is added by 1.

S402: comparing the sequencing reference number of the last comparison with the target fixed point number of the p structural body again; when the results of the comparison are equal, step S403 is performed. Wherein p is ∈ [1, M ].

S403: and recording the serial numbers of the structures to which the equal target fixed point numbers belong.

S404: judging whether the number of the recorded serial numbers is smaller than the preset sequencing number or not; if not, executing step S103; if yes, go to step S405;

s405: judging whether the last compared sequencing reference number is compared with the target fixed point number of each structural body; if not, returning to execute the step S402 after updating the p; if yes, the process returns to step S401.

It is understood that steps S402-S405 are similar to steps S1021-S1025, and refer to the above description specifically, which is not described herein again. And when the updated last compared sorting reference number is compared with the target fixed point number of each structural body and the number of the recorded sequence numbers is still smaller than the preset sorting reference number, updating the last compared sorting reference number again, repeating the sorting process until the number of the recorded sequence numbers is equal to the preset sorting reference number, and executing the step S103 to finish sorting the structural bodies.

Based on the structural body sorting method provided by the embodiment, the embodiment of the application also provides a structural body sorting device.

Referring to fig. 5, the figure is a schematic structural diagram of a structural body sorting apparatus according to an embodiment of the present application.

The structure sequencing device provided in the embodiment of the present application may be configured in any processor, and specifically includes: a reference determination unit 100, a data processing unit 200, and a sequential writing unit 300;

a reference determination unit 100 for determining the maximum or minimum N nonrepeating target fixed point numbers as a sort reference number from among the target fixed point numbers of the M structural bodies; m is a positive integer greater than 1, and N is a positive integer less than M;

the data processing unit 200 is used for sequentially comparing each sequencing reference number with the target fixed point number of each structural body according to a preset sequence; the system is also used for recording the serial numbers of the structures to which the equal target fixed point numbers belong when the comparison results are equal;

when the sequencing reference number is the maximum N nonrepeating target fixed point numbers, the preset sequence is from large to small; when the sequencing reference number is the minimum N nonrepeating target fixed point numbers, the preset sequence is from small to large;

a sequential writing unit 300, configured to sequentially write the corresponding structures into the designated positions of the memory according to the recording sequence of the sequence numbers.

In some possible implementation manners, the structural body sorting apparatus provided in the embodiment of the present application may further include: a quantity judgment unit;

a quantity judging unit, configured to judge whether the number of recorded sequence numbers is smaller than a preset sorting number after the data processing unit 200 records the sequence numbers of the structures to which the equal target fixed point numbers belong; and is also used for triggering the sequential writing unit 300 when the judgment result is negative.

In some possible implementation manners, the structural body sorting apparatus provided in the embodiment of the present application may further include: a data update unit;

the data updating unit is used for reducing the last compared sorting reference number by a preset difference value and triggering the data processing unit 200 after updating the last compared sorting reference number when the data processing unit 200 compares each sorting reference number and the judgment result of the quantity judging unit is still yes;

when the sequencing reference number is the maximum N nonrepeating target fixed point numbers, the preset difference value is one; when the sequencing reference number is the minimum N nonrepeating target fixed point numbers, the preset difference value is negative one;

the data processing unit 200 is further configured to compare the ranking reference number of the last comparison with the target fixed point number of each structure again; and the data updating unit is also used for triggering the data updating unit again when the judgment result of the quantity judging unit is still yes when the sequencing reference number of the last comparison and the target fixed point number of each structural body are compared.

Optionally, as shown in fig. 6, the reference determining unit may specifically include: an initialization sub-unit 101, a comparison sub-unit 102, a setting sub-unit 103, an updating sub-unit 104 and an obtaining sub-unit 105;

an initialization subunit 101, configured to initially set first to nth storage areas, and set a number stored in each storage area to zero;

a comparison subunit 102, configured to compare the target fixed point number of the ith structure with the number stored in each storage area, where i belongs to [1, M ];

a setting subunit 103, configured to, when the sorting reference number is the largest N nonrepeating target fixed point numbers, if the comparison result of the comparing subunit 102 is that the target fixed point number of the ith structural body is greater than or equal to the number stored in the K storage areas and the target fixed point number of the ith structural body is not equal to the number stored in the N-K +1 storage area, replace the number stored in the j +1 storage area with the number stored in the j storage area, and after replacing the number stored in the N-K +1 storage area with the target fixed point number of the ith structural body, trigger the updating subunit 104; the updating subunit 104 is further configured to, when the sorting reference number is the minimum N nonrepeating target fixed-point numbers, if the comparison result of the comparing subunit 102 is that the target fixed-point number of the ith structural body is less than or equal to the number stored in the K storage areas and the target fixed-point number of the ith structural body is not equal to the number stored in the N-K +1 storage area, replace the number stored in the j +1 storage area with the number stored in the j storage area, and replace the number stored in the N-K +1 storage area with the target fixed-point number of the ith structural body, and then trigger the updating subunit;

wherein, K belongs to [1, N ], j belongs to [ N-K +1, N-1 ];

an updating subunit 104, configured to trigger the comparing subunit 102 after updating i;

and an obtaining subunit 105, configured to determine, as the sort reference number, the numbers stored in the first to nth storage areas in order after the target fixed point number of the M structural bodies is compared with the number stored in each storage area.

In the embodiment of the application, the target fixed point number of each structural body to be sorted is read as a sorting basis, the largest or smallest N nonrepeating target fixed point numbers are determined as sorting reference numbers, then in the sorting process, each sorting reference number is sequentially compared with the target fixed point number of each structural body from large to small or from small to large, when the comparison results are equal, the serial numbers of the structural bodies to which the equal target fixed point numbers belong are recorded, and then the structural bodies corresponding to the serial numbers are sequentially written into the specified positions of the memory according to the sequence recorded by the serial numbers, namely, the structural bodies are sorted according to the size of the target fixed point number in the structural body. In the sorting process, on one hand, the serial numbers of the corresponding structural bodies are recorded in sequence according to the size of the target fixed point number as the basis of sequential writing, and the corresponding structural bodies are written into the designated positions only according to the sequence recorded by the serial numbers after sorting, so that frequent reading and writing of the structural bodies are avoided, and the dynamic power consumption of reading and writing of the structural bodies is reduced; on the other hand, only the target fixed point number of the structure body is read during sorting, only the target fixed point number participates in sorting comparison, and dynamic power consumption consumed by data reading and writing and data comparison is reduced.

Based on the structural body sorting method and device provided by the embodiment, the embodiment of the application also provides a structural body sorter.

Referring to fig. 7, the figure is a schematic structural diagram of a structure body sequencer according to an embodiment of the present application.

The structural body sequencer provided in the embodiment of the present application may be implemented by using a hardware structure, and specifically includes: the device comprises a read-write module 10, a comparison module 20 and a write-in module wr _ stru;

the read-write module 10 is configured to forward target fixed point numbers of M structures to be sorted in the local memory DDR to the local cache lbuf; the comparison module 20 is further configured to determine the maximum or minimum N nonrepeating target fixed point numbers from the target fixed point numbers of the M structures as the ranking reference number and then notify the determined ranking reference number to the comparison module; m is a positive integer greater than 1, and N is a positive integer less than M;

the comparison module 20 is configured to obtain each sequencing reference number from the read-write module 10 after receiving the notification from the read-write module 10, and obtain the target fixed point numbers of the M structural bodies from the local cache lbuf; the system is also used for sequentially comparing each sequencing reference number with the target fixed point number of each structural body according to a preset sequence, and when the comparison result is equal, writing the serial number of the structural body to which the equal target fixed point number belongs into the local cache lbuf and then informing the write-in module wr _ stru;

when the sequencing reference number is the maximum N nonrepeating target fixed point numbers, the preset sequence is from large to small; when the sequencing reference number is the minimum N nonrepeating target fixed point numbers, the preset sequence is from small to large;

and the write-in module wr _ stru is configured to, after receiving the notification of the comparison module 20, acquire the recorded sequence number from the local cache lbuf, acquire the structural body corresponding to the sequence number from the local memory DDR according to the recording sequence of the sequence number, and then sequentially write the structural body into the specified position of the local memory DDR.

It can be understood that the sorting method adopted by the structure sorter provided in the embodiment of the present application is similar to the sorting method described in the foregoing embodiment, and specific reference may be made to relevant descriptions of the method embodiment, and details are not described here.

In the embodiment of the application, the target fixed point number of each structural body to be sorted is read as a sorting basis, the largest or smallest N nonrepeating target fixed point numbers are determined as sorting reference numbers, then in the sorting process, each sorting reference number is sequentially compared with the target fixed point number of each structural body from large to small or from small to large, when the comparison results are equal, the serial numbers of the structural bodies to which the equal target fixed point numbers belong are recorded, and then the structural bodies corresponding to the serial numbers are sequentially written into the specified positions of the memory according to the sequence recorded by the serial numbers, namely, the structural bodies are sorted according to the size of the target fixed point number in the structural body. In the sorting process, on one hand, the serial numbers of the corresponding structural bodies are recorded in sequence according to the size of the target fixed point number as the basis of sequential writing, and the corresponding structural bodies are written into the designated positions only according to the sequence recorded by the serial numbers after sorting, so that frequent reading and writing of the structural bodies are avoided, and the dynamic power consumption of reading and writing of the structural bodies is reduced; on the other hand, only the target fixed point number of the structure body is read during sorting, only the target fixed point number participates in sorting comparison, and dynamic power consumption consumed by data reading and writing and data comparison is reduced.

Referring to fig. 8, the figure is a schematic structural diagram of another structure sequencer provided in the embodiment of the present application. This figure provides a more specific structure sequencer than figure 7.

In this embodiment, the comparing module 20 may specifically include: a first reading submodule fet _ dat and a comparison submodule cmp;

the first reading sub-module fet _ dat is used for acquiring target fixed point numbers of the M structural bodies from the local cache lbuf after receiving the notification of the read-write module 10, and then sending the target fixed point numbers to the comparison sub-module cmp one by one;

the comparison sub-module cmp is used for acquiring each sequencing reference number from the read-write module 10 after receiving the notification of the read-write module 10, and sequentially comparing each sequencing reference number with the target fixed point number of each structural body according to a preset sequence; and the writing module is further used for judging whether the number of the recorded serial numbers is smaller than the preset sorting number or not when the comparison results are equal, writing the serial numbers of the structural bodies to which the equal target fixed point numbers belong into the local cache lbuf if the number of the recorded serial numbers is smaller than the preset sorting number, and informing the writing module wr _ stru of the serial numbers.

In some possible implementation manners, the comparison sub-module cmp is further configured to, after comparing each ranking reference number, reduce the last compared ranking reference number by a preset difference value to update the last compared ranking reference number, and then compare the last compared ranking reference number with the target fixed point number of each structure body again;

when the sequencing reference number is the maximum N nonrepeating target fixed point numbers, the preset difference value is one; when the sorting reference number is the minimum N nonrepeating target fixed point numbers, the preset difference value is negative one.

With continued reference to fig. 8, in some possible implementation manners of the embodiment of the present application, the read/write module 10 may specifically include: a second reading sub-module rd _ ddr and a writing sub-module wr _ lbuf;

the second reading sub-module rd _ DDR is used for sending a reading instruction to the local storage DDR, so that the local storage DDR sends the target fixed point number of the M structural bodies to the writing sub-module wr _ lbuf according to the reading instruction;

the write-in sub-module wr _ lbuf is used for writing the obtained target fixed point number into the local cache lbuf; and is also used for executing the following steps in the writing process:

initially setting a first storage area to an Nth storage area, and setting the number stored in each storage area to zero;

comparing the target fixed point number of the ith structure body with the number stored in each storage area, wherein i belongs to [1, M ];

when the sequencing reference number is the largest N nonrepeating target fixed point numbers, if the target fixed point number of the ith structural body is larger than or equal to the number stored in the K storage areas and the target fixed point number of the ith structural body is not equal to the number stored in the (N-K + 1) th storage area, replacing the number stored in the (j + 1) th storage area with the number stored in the (j) th storage area, and replacing the number stored in the (N-K + 1) th storage area with the target fixed point number of the ith structural body; k belongs to [1, N ], j belongs to [ N-K +1, N-1 ];

when the sequencing reference number is the minimum N nonrepetitive target fixed point numbers, if the target fixed point number of the ith structural body is less than or equal to the number stored in the K storage areas and the target fixed point number of the ith structural body is not equal to the number stored in the (N-K + 1) th storage area, replacing the number stored in the (j + 1) th storage area with the number stored in the (j) th storage area, and replacing the number stored in the (N-K + 1) th storage area with the target fixed point number of the ith structural body; k belongs to [1, N ], j belongs to [ N-K +1, N-1 ];

after updating i, returning to compare the target fixed point number of the ith structural body with the number stored in each storage area;

and after the target fixed point number of the M structural bodies is compared with the number stored in each storage area, determining the number stored in the first-Nth storage areas as a sequencing reference number in sequence.

It should be noted that, in the present specification, the embodiments are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments may be referred to each other. The sorting device and the sorter disclosed by the embodiment correspond to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description.

It is further noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.

The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

The foregoing is merely a preferred embodiment of the present application and is not intended to limit the present application in any way. Although the present application has been described with reference to the preferred embodiments, it is not intended to limit the present application. Those skilled in the art can now make numerous possible variations and modifications to the disclosed embodiments, or modify equivalent embodiments, using the methods and techniques disclosed above, without departing from the scope of the claimed embodiments. Therefore, any simple modification, equivalent change and modification made to the above embodiments according to the technical essence of the present application still fall within the protection scope of the technical solution of the present application without departing from the content of the technical solution of the present application.

24页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:控制器及其操作方法

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类