CN113312278B - Device and method for statically allocating shared multi-queue cache - Google Patents
Device and method for statically allocating shared multi-queue cache Download PDFInfo
- Publication number
- CN113312278B CN113312278B CN202110861235.XA CN202110861235A CN113312278B CN 113312278 B CN113312278 B CN 113312278B CN 202110861235 A CN202110861235 A CN 202110861235A CN 113312278 B CN113312278 B CN 113312278B
- Authority
- CN
- China
- Prior art keywords
- pointer
- queue
- value
- read
- scheduled
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/08—Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
- G06F12/0802—Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
- G06F12/0844—Multiple simultaneous or quasi-simultaneous cache accessing
- G06F12/0853—Cache with multiport tag or data arrays
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Memory System Of A Hierarchy Structure (AREA)
Abstract
The invention provides a device and a method for statically allocating shared multi-queue cache, wherein the device comprises a space management module, a pointer management module, a data scheduling module, a read-write command module, a configuration register, a register and a shared cache module. The invention statically allocates the buffer space of each queue, can support repeated reading of data in the buffer space and increases the data reading operation efficiency.
Description
Technical Field
The invention relates to the technical field of network communication, in particular to a device and a method for statically allocating shared multi-queue cache.
Background
With the development of information technology, the demand of people for data transmission capability is also rapidly increasing, and meanwhile, certain demand is also provided for device flexibility. The improvement of the receiving and sending rate of the equipment brings a plurality of problems of resource waste and the like caused by the compatibility of multi-rate interfaces.
For logic circuits, wasted resources are likely to increase the corresponding cost and power consumption. The flexible software environment deployed on the software layer can meet the variable user requirements, but the circuit based on the physical layer is difficult to consider all the situations in the design process, and even in some situations, the hardware design is realized by meeting the highest requirement in order to be compatible with the flexible and variable user requirements. For example, in a multi-user communication interface, when the data processing time of the device is consistent, the higher the rate is, the more the used cache resources are increased, in this case, the total bandwidth/total storage resource accessed by all users is fixed, but in an actual application, the resource called by each user is not consistent, and at this time, if the user requirement is not reduced, the resource needs to be allocated according to the requirement of the highest resource of each user.
If the number of users is large or the resource ratio is very different, huge resource waste will be brought. This problem is currently solved using a device for dynamically allocating shared multiple queues, dynamically allocated non-fixed space accessible by multiple queues, but the device is overly complex to implement, while not requiring full dynamic allocable for some application scenarios.
Disclosure of Invention
The technical problem to be solved by the invention is as follows: aiming at the technical problems in the prior art, the invention provides a device and a method for statically allocating shared multi-queue cache, wherein the device and the method statically allocate the cache space of each queue, simultaneously can support repeated reading of data in the cache space, and increase the data reading operation efficiency.
In order to solve the technical problems, the technical scheme provided by the invention is as follows:
a static distributable shared multi-queue cache device comprises a space management module, a pointer management module, a data scheduling module, a read-write command module, a configuration register, a register and a shared cache module, wherein the space management module and the pointer management module are respectively in one-to-one correspondence with each queue, and the space management module and the pointer management module are respectively in one-to-one correspondence with each queue, wherein:
the space management module is used for calculating according to the depth and the pointer minimum of the last queue to obtain the pointer minimum of the corresponding queue, calculating according to the depth and the pointer minimum of the corresponding queue to obtain the pointer maximum of the corresponding queue, distributing the cache space of the corresponding queue from the shared cache space according to the pointer maximum and the pointer minimum of the corresponding queue, and sending the pointer maximum and the pointer minimum of the corresponding queue to the corresponding pointer management module, and the space management modules are sequentially connected in series, so that the last space management module sends the depth and the pointer minimum of the last queue to the next space management module;
the pointer management module is used for configuring a read pointer, a write pointer and a copy pointer for the corresponding queue according to the maximum pointer value and the minimum pointer value of the corresponding queue, adjusting the values of the read pointer and the copy pointer of the corresponding queue according to a read release command and sending the values to the data scheduling module, adjusting the value of the write pointer of the corresponding queue according to the write command and sending the value to the data scheduling module, and adjusting the value of the copy pointer of the corresponding queue according to a read non-release command and sending the value to the data scheduling module;
the data scheduling module is used for accessing a corresponding address of the shared cache space according to the value of the write pointer to store data, accessing a corresponding address of the shared cache space according to the value of the read pointer to read and release the data, accessing a corresponding address of the shared cache space according to the value of the copy pointer to copy the data, acquiring a non-release read command and a release read command, then selecting a queue to be scheduled according to head data of the queue, and forwarding the non-release read command and the release read command to a pointer management module corresponding to the queue to be scheduled;
the read-write command module is used for generating a non-release read command and a release read command and sending the non-release read command and the release read command to the data scheduling module, and is also used for generating a write command and sending the write command to the pointer management module;
the configuration register is used for configuring the depth of all queues;
the register is used for storing the head data of all queues;
the shared cache module is used for providing a shared cache space.
Further, the pointer management module includes:
the initialization unit is used for acquiring the maximum value and the minimum value of the pointer of the corresponding queue sent by the corresponding space management module, and initializing the values of the read pointer, the write pointer and the copy pointer to be the minimum value of the pointer;
the write pointer adjusting unit is used for receiving the write command, sending the value of the write pointer to the data scheduling module and then adding one to the value of the write pointer;
the copy pointer adjusting unit is used for receiving the non-release read command, sending the value of the copy pointer to the data scheduling module and then adding one to the value of the copy pointer;
a pointer rollback unit for resetting a value of the copy pointer to be the same as a value of the read pointer;
the read pointer adjusting unit is used for receiving the read releasing command, sending the value of the read pointer to the data scheduling module, then adding one to the value of the read pointer, and adjusting the value of the copy pointer to be the same as the value of the read pointer;
and the error reporting unit is used for carrying out error prompt when the value of the copy pointer is larger than the value of the write pointer.
Further, the pointer management module further includes a calculating unit, configured to calculate a remaining writable space in the corresponding cache space according to the depth of the corresponding queue, the value of the write pointer, and the value of the read pointer, and further configured to calculate a remaining readable space in the corresponding cache space according to the value of the write pointer and the value of the copy pointer in the corresponding queue.
The invention also provides a method for statically allocating the shared multi-queue cache, which comprises the following steps:
s1) one queue is sequentially selected as a current queue, a space management module corresponding to the current queue reads configuration information in a configuration register, the maximum value and the minimum value of a pointer of the current queue are calculated according to the depths of the current queue and the last queue, a buffer space corresponding to the current queue in a shared buffer module is distributed according to the maximum value and the minimum value of the pointer, and the maximum value and the minimum value of the pointer are sent to a pointer management module corresponding to the current queue;
s2), in a pointer management module corresponding to the current queue, an initialization unit acquires a maximum pointer value and a minimum pointer value, and initializes the values of a read pointer, a write pointer and a copy pointer to be the minimum pointer value;
s3) returning to the step S1) until all queues are selected;
s4) if there is no data read/write in all queues and the configuration information in the configuration register is updated, go to step S1), if there is a queue to which data is input, go to the data write step.
Further, the specific step of calculating the maximum value and the minimum value of the pointer of the current queue according to the depths of the current queue and the previous queue in step S1) includes:
s11) if the current queue is the first queue, the minimum value of the pointer of the current queue is 0, otherwise, the depth and the minimum value of the pointer of the previous queue are obtained from the space management module corresponding to the previous queue, and the depth and the minimum value of the pointer of the previous queue are added to obtain the minimum value of the pointer of the current queue;
s12) adding and subtracting the minimum value of the pointer of the current queue and the depth of the current queue by one to obtain the maximum value of the pointer of the current queue.
Further, the data writing step in step S4) includes:
A1) taking the queue with data written in as a queue to be written in, and sending a write command to a pointer management module corresponding to the queue to be written in by a read-write command module;
A2) in a pointer management module corresponding to a queue to be written, a write pointer adjusting unit receives a write command;
A3) the write pointer adjusting unit sends the value of the write pointer corresponding to the queue to be written to a data scheduling module, and then adds one to the value of the write pointer corresponding to the queue to be written;
A4) and the data scheduling module receives the value of the write pointer corresponding to the queue to be written, accesses the corresponding address of the shared cache space according to the value of the write pointer corresponding to the queue to be written, stores the data of the queue to be written in the corresponding address, returns to the step A3 if the value of the write pointer corresponding to the queue to be written is smaller than the maximum value of the pointer corresponding to the queue to be written, and ends and exits if the value of the write pointer corresponding to the queue to be written is equal to the maximum value of the pointer corresponding to the queue to be written.
Further, step S4) further includes: if a data reading request is received, skipping a data reading step, wherein the data reading step specifically comprises:
B1) if the default state is adopted, jumping to the step B2), otherwise, jumping to the non-release reading step;
B2) the read-write command module sends a read release command to the data scheduling module, and after the data scheduling module obtains the read release command, the data scheduling module selects queues to be scheduled according to the head data of each queue, forwards the read release command to the pointer management module corresponding to the queues to be scheduled, and skips step B3);
B3) in the pointer management module corresponding to the queue to be scheduled, the read pointer adjusting unit receives the read release command, sends the value of the read pointer corresponding to the queue to be scheduled to the data scheduling module, then adds one to the value of the read pointer corresponding to the queue to be scheduled, and simultaneously adjusts the value of the copy pointer corresponding to the queue to be scheduled to be the same as the value of the read pointer corresponding to the queue to be scheduled;
B4) and the data scheduling module receives the value of the read pointer corresponding to the queue to be scheduled, accesses the corresponding address of the shared cache space according to the value of the read pointer corresponding to the queue to be scheduled to read and release data, returns to the step B3 if the value of the read pointer corresponding to the queue to be scheduled is smaller than the value of the write pointer corresponding to the queue to be scheduled, and ends and exits if the value of the read pointer corresponding to the queue to be scheduled is equal to the value of the write pointer corresponding to the queue to be scheduled.
Further, the non-release reading step in step B1) specifically includes:
C1) the read-write command module sends a non-release read command to the data scheduling module, and after the data scheduling module acquires the non-release read command, the data scheduling module selects queues to be scheduled according to the head data of each queue, forwards the non-release read command to the pointer management module corresponding to the queues to be scheduled, and skips to step C2);
C2) in a pointer management module corresponding to a queue to be scheduled, a copy pointer adjusting unit receives a non-release read command;
C3) the replication pointer adjusting unit sends the value of the replication pointer corresponding to the queue to be scheduled to the data scheduling module and then adds one to the value of the replication pointer corresponding to the queue to be scheduled;
C4) the data scheduling module receives the value of the copy pointer corresponding to the queue to be scheduled, accesses the corresponding address copy data of the shared cache space according to the value of the copy pointer corresponding to the queue to be scheduled, if the value of the copy pointer corresponding to the queue to be scheduled is smaller than the value of the write pointer corresponding to the queue to be scheduled, returns to the step C3), if the value of the copy pointer corresponding to the queue to be scheduled is equal to the value of the write pointer corresponding to the queue to be scheduled, the step C5) is skipped, if the value of the copy pointer corresponding to the queue to be scheduled is larger than the value of the write pointer corresponding to the queue to be scheduled, an error reporting unit in the pointer management module corresponding to the queue to be scheduled carries out error prompt, and the step C5 is skipped;
C5) in the pointer management module corresponding to the queue to be scheduled, the pointer rollback unit resets the value of the copy pointer corresponding to the queue to be scheduled to be the same as the value of the read pointer corresponding to the queue to be scheduled, and returns to step B1).
Further, before step a 3), a step of calculating a remaining writable space in a cache space corresponding to the queue to be written is further included, which specifically includes: determining the precedence relationship between the read pointer corresponding to the queue to be written and the write pointer corresponding to the queue to be written, calculating the remaining writable space in the cache space corresponding to the queue to be written according to the depth of the queue to be written, the value of the write pointer and the value of the read pointer, if the remaining writable space is 0, repeating the step until the remaining writable space is larger than 0, otherwise, skipping to the step A3).
Further, step C3) includes a step of calculating a remaining readable space in the buffer space corresponding to the queue to be scheduled, which specifically includes: determining the precedence relationship between the copy pointer corresponding to the queue to be scheduled and the write pointer corresponding to the queue to be scheduled, calculating the remaining readable space in the cache space corresponding to the queue to be scheduled according to the value of the write pointer corresponding to the queue to be scheduled and the value of the copy pointer, if the remaining readable space is 0, repeating the step until the remaining readable space is larger than 0, otherwise, skipping to the step C3).
Compared with the prior art, the invention has the advantages that:
1. the method limits the size of the available buffer space of each queue through the depth configuration of all queues stored in the configuration register, the space management module corresponding to each queue calculates the buffer space of the corresponding queue in the shared buffer space according to the depth of the corresponding queue, the depth of the last queue and the minimum value of the pointer, the buffer space size of each queue is fixed and is not overlapped after the configuration is finished, the complexity of the distribution formula is extremely low, and the requirement of the application which does not need dynamic shared buffer is met;
2. since some switching devices need to perform a large number of repeated reads of data in the case of performing data broadcasting, the present invention configures 3 pointers for each queue: the data scheduling module accesses a corresponding address of the shared cache space to store data according to the value of the write pointer, accesses the corresponding address of the shared cache space to read and release the data according to the value of the read pointer, accesses the corresponding address of the shared cache space to copy the data according to the value of the copy pointer, and when repeated reading is realized, the data scheduling module adjusts the value of the copy pointer according to a non-release read command, and at the moment, the read pointer and the write pointer are kept unchanged while the value of the copy pointer is changed between the read pointer and the write pointer so as to realize access and copy of data in the middle part of the addresses corresponding to the read pointer and the write pointer in the shared cache space, so that the cache space corresponding to each queue has the functions of caching and data copying;
3. the device of the invention configures corresponding register storage head data for each queue, so that the queue head is visible, when the data of the queue is read, the head data of the queue can be refreshed into the next data, when the data is read, the queue needing to be scheduled can be selected according to the head data of all the queues, and the queue which does not obtain scheduling arbitration can not be read, thereby improving the efficiency of reading the data of the queue.
Drawings
Fig. 1 is a schematic structural diagram of an apparatus according to an embodiment of the present invention.
FIG. 2 is a diagram illustrating the operation of the read pointer, the write pointer, and the copy pointer in the embodiment of the present invention.
FIG. 3 is a general flow diagram of a method in an embodiment of the invention.
FIG. 4 is a detailed flowchart of the data writing step in the method according to the embodiment of the present invention.
FIG. 5 is a detailed flowchart of the data reading step in the method according to the embodiment of the invention.
FIG. 6 is a diagram illustrating a state change of a data reading step in the method according to an embodiment of the invention.
Detailed Description
The invention is further described below with reference to the drawings and specific preferred embodiments of the description, without thereby limiting the scope of protection of the invention.
As shown in fig. 1, the present invention provides a static assignable shared multi-queue cache device, which includes a space management module, a pointer management module, a data scheduling module, a read-write command module, a configuration register, a register, and a shared cache module, where the space management module and the pointer management module correspond to each queue one-to-one, respectively, and where:
the space management module is used for calculating to obtain a pointer minimum value of a corresponding queue according to the depth of the last queue and the pointer minimum value, calculating to obtain a pointer maximum value of the corresponding queue according to the depth of the corresponding queue and the pointer minimum value, distributing a cache space of the corresponding queue from the shared cache space according to the pointer maximum value and the pointer minimum value of the corresponding queue, and sending the pointer maximum value and the pointer minimum value of the corresponding queue to the corresponding pointer management module;
the pointer management module is used for configuring a read pointer, a write pointer and a copy pointer for the corresponding queue according to the maximum pointer value and the minimum pointer value of the corresponding queue, adjusting the values of the read pointer and the copy pointer of the corresponding queue according to a read release command and sending the values to the data scheduling module, adjusting the value of the write pointer of the corresponding queue according to the write command and sending the value to the data scheduling module, and adjusting the value of the copy pointer of the corresponding queue according to a read non-release command and sending the value to the data scheduling module;
the data scheduling module is used for accessing a corresponding address of the shared cache space according to the value of the write pointer to store data, accessing a corresponding address of the shared cache space according to the value of the read pointer to read and release the data, accessing a corresponding address of the shared cache space according to the value of the copy pointer to copy the data, acquiring a non-release read command and a release read command, then selecting a queue to be scheduled according to head data of the queue, and forwarding the non-release read command and the release read command to a pointer management module corresponding to the queue to be scheduled;
the read-write command module is used for generating a non-release read command and a release read command and sending the non-release read command and the release read command to the data scheduling module, and is also used for generating a write command and sending the write command to the pointer management module;
the configuration register is used for configuring the depth of all queues;
the register is used for storing the head data of all queues;
the shared cache module is used for providing a shared cache space.
The space management modules in this embodiment are sequentially connected in series, so that the previous space management module sends the depth and the minimum value of the pointer of the previous queue to the next space management module.
Through the structure, the device for statically allocating the shared multi-queue cache of the embodiment calculates and allocates the cache space corresponding to each queue according to the fixed configuration through the configuration register and the space management module, so that the statically allocating of the shared cache space is realized, the cache spaces of each queue are not overlapped, the algorithm complexity is simplified, and the problem of read-write errors caused by the overlapping of the cache spaces is avoided; meanwhile, pointers with three different functions, namely a read pointer, a write pointer and a copy pointer, are configured for each queue through a pointer management module, a data scheduling module accesses a corresponding address of the shared cache space to store data according to the value of the write pointer, accesses the corresponding address of the shared cache space to read and release the data according to the value of the read pointer, accesses the corresponding address of the shared cache space to copy the data according to the value of the copy pointer, so that the data writing, reading and releasing of the corresponding cache space of the queue are managed through the pointers, and the repeated reading of the data in the corresponding cache space of the queue can be realized; the device for statically allocating the shared multi-queue buffer also realizes the selection of the queue to be scheduled through the head data of the queue through the register and the data scheduling module, and improves the queue reading efficiency.
The pointer management module in this embodiment includes:
the initialization unit is used for acquiring the maximum pointer value and the minimum pointer value of the corresponding queue sent by the corresponding space management module, initializing the read pointer, the write pointer and the copy pointer of the corresponding queue as the minimum pointer value, wherein the values of the read pointer, the write pointer and the copy pointer are addresses of a buffer space corresponding to the queue, and can be sequentially accumulated from the initial values, the values of the three pointers are only in the range of the maximum pointer value and the minimum pointer value of the corresponding queue, as shown in fig. 2, when data is written in, the write pointer moves, when data is released, the read pointer moves, the value of the write pointer cannot exceed the read pointer, when data is copied, the copy pointer moves between the read pointer and the write pointer, and after the data is copied, the copy pointer jumps back to the position of the read pointer to wait for next copying;
the write pointer adjusting unit is used for receiving a write command, sending the value of the write pointer to the data scheduling module and then adding one to the value of the write pointer, so that the queue data are sequentially stored at all addresses in the corresponding cache space;
the copying pointer adjusting unit is used for receiving the non-release reading command, sending the value of the copying pointer to the data scheduling module and then adding one to the value of the copying pointer, so that the data of the buffer space corresponding to the queue are sequentially read according to the stored addresses, and meanwhile, the read data are still stored in the original position of the buffer space corresponding to the queue;
the pointer rollback unit is used for resetting the value of the copy pointer to be the same as the value of the read pointer so as to realize repeated reading of the data of the buffer space corresponding to the queue;
the read pointer adjusting unit is used for receiving a read releasing command, sending the value of the read pointer to the data scheduling module and then adding one to the value of the read pointer, so that the data of the cache space corresponding to the queue are sequentially released according to the stored address, and meanwhile, in order to avoid read-write errors, the read pointer adjusting unit adjusts the value of the copy pointer to be the same as the value of the read pointer after adjusting the value of the read pointer;
and the error reporting unit is used for carrying out error prompt when the value of the copy pointer is larger than the value of the write pointer.
In this embodiment, because the size of the buffer space corresponding to each queue is limited, the pointer management module further includes a calculation unit, configured to calculate a remaining writable space in the corresponding buffer space according to the depth of the corresponding queue, the value of the write pointer, and the value of the read pointer, and further calculate a remaining readable space in the corresponding buffer space according to the value of the write pointer and the value of the copy pointer in the corresponding queue, so that the apparatus for statically allocating the shared multi-queue buffer according to this embodiment adjusts the work schedule according to the remaining writable space and the remaining readable space, and avoids occurrence of an exception in writing and reading.
As shown in fig. 3, this embodiment further provides a method for statically allocating a shared multi-queue buffer, including the following steps:
s1) one queue is sequentially selected as a current queue, a space management module corresponding to the current queue reads configuration information in a configuration register, the maximum value and the minimum value of a pointer of the current queue are calculated according to the depths of the current queue and the last queue, a buffer space corresponding to the current queue in a shared buffer module is distributed according to the maximum value and the minimum value of the pointer, and the maximum value and the minimum value of the pointer are sent to a pointer management module corresponding to the current queue;
s2), in a pointer management module corresponding to the current queue, an initialization unit acquires a maximum pointer value and a minimum pointer value, and initializes the values of a read pointer, a write pointer and a copy pointer corresponding to the current queue to be the minimum pointer value;
s3) returning to the step S1) until all queues are selected;
s4) if there is no data read/write in all queues and the configuration information in the configuration register is updated, go to step S1), if there is a queue to which data is input, go to the data write step.
Through the steps, under the condition that no data is input into any queue, the depth of each queue can be modified at will by the configuration register, the total depth of all the queues cannot exceed the total depth of the cache in the shared cache module, once data is input into any queue, the depth of each queue cannot be modified any more, at the moment, the size of the cache space corresponding to each queue is fixed and is not overlapped, the application without dynamic shared cache can be met, and the problem that read-write errors possibly occur due to overlapping of the cache spaces is also avoided.
In step S1) of this embodiment, the maximum and minimum values of the pointer of the current queue depend on the calculation result of the previous queue, and the specific steps of calculating the maximum and minimum values of the pointer of the current queue according to the depths of the current queue and the previous queue include:
s11) if the current queue is the first queue, the minimum value of the pointer of the current queue is 0, otherwise, the depth and the minimum value of the pointer of the previous queue are obtained from the space management module corresponding to the previous queue, and the depth and the minimum value of the pointer of the previous queue are added to obtain the minimum value of the pointer of the current queue, and the functional expression is as follows:
in the above formula, the first and second carbon atoms are,is the minimum value of the pointer of the last queue,is the depth of the last queue, and n is the sequence number of the current queue;
s12) adding and subtracting the minimum value of the pointer of the current queue and the depth of the current queue by one to obtain the maximum value of the pointer of the current queue, the function expression is as follows:
in the above formula, the first and second carbon atoms are,is the minimum value of the pointer of the current queue,and n is the sequence number of the current queue.
Because the calculation is only required to be stable during initialization, in this embodiment, after the maximum value and the minimum value of the pointer of one queue are calculated in each clock cycle, the corresponding buffer space is configured for the queue, and data reading and writing are prepared to start after the buffer space configuration corresponding to all queues is completed.
As shown in fig. 4, the data writing step in step S4) of the present embodiment includes:
A1) taking the queue with data written in as a queue to be written in, and sending a write command to a pointer management module corresponding to the queue to be written in by a read-write command module;
A2) in a pointer management module corresponding to a queue to be written, a write pointer adjusting unit receives a write command;
A3) the write pointer adjusting unit sends the value of the write pointer corresponding to the queue to be written to a data scheduling module, and then adds one to the value of the write pointer corresponding to the queue to be written;
A4) and the data scheduling module receives the value of the write pointer corresponding to the queue to be written, accesses the corresponding address of the shared cache space according to the value of the write pointer corresponding to the queue to be written, stores the data of the queue to be written in the corresponding address, returns to the step A3 if the value of the write pointer corresponding to the queue to be written is smaller than the maximum value of the pointer corresponding to the queue to be written, and ends and exits if the value of the write pointer corresponding to the queue to be written is equal to the maximum value of the pointer corresponding to the queue to be written.
As shown in fig. 3, step S4) further includes: if a data reading request is received, skipping the data reading step, as shown in fig. 5, the data reading step in this embodiment specifically includes:
B1) if the default state is adopted, jumping to the step B2), otherwise, jumping to the non-release reading step;
B2) the read-write command module sends a read release command to the data scheduling module, and after the data scheduling module obtains the read release command, the data scheduling module selects queues to be scheduled according to the head data of each queue, forwards the read release command to the pointer management module corresponding to the queues to be scheduled, and skips step B3);
B3) in the pointer management module corresponding to the queue to be scheduled, the read pointer adjusting unit receives the read release command, sends the value of the read pointer corresponding to the queue to be scheduled to the data scheduling module, then adds one to the value of the read pointer corresponding to the queue to be scheduled, and simultaneously adjusts the value of the copy pointer corresponding to the queue to be scheduled to be the same as the value of the read pointer corresponding to the queue to be scheduled;
B4) and the data scheduling module receives the value of the read pointer corresponding to the queue to be scheduled, accesses the corresponding address of the shared cache space according to the value of the read pointer corresponding to the queue to be scheduled to read and release data, returns to the step B3 if the value of the read pointer corresponding to the queue to be scheduled is smaller than the value of the write pointer corresponding to the queue to be scheduled, and ends and exits if the value of the read pointer corresponding to the queue to be scheduled is equal to the value of the write pointer corresponding to the queue to be scheduled.
As shown in fig. 5, the non-releasing reading step in step B1) of this embodiment specifically includes:
C1) the read-write command module sends a non-release read command to the data scheduling module, and after the data scheduling module acquires the non-release read command, the data scheduling module selects queues to be scheduled according to the head data of each queue, forwards the non-release read command to the pointer management module corresponding to the queues to be scheduled, and skips to step C2);
C2) in a pointer management module corresponding to a queue to be scheduled, a copy pointer adjusting unit receives a non-release read command;
C3) the replication pointer adjusting unit sends the value of the replication pointer corresponding to the queue to be scheduled to the data scheduling module and then adds one to the value of the replication pointer corresponding to the queue to be scheduled;
C4) the data scheduling module receives the value of the copy pointer corresponding to the queue to be scheduled, accesses the corresponding address copy data of the shared cache space according to the value of the copy pointer corresponding to the queue to be scheduled, if the value of the copy pointer corresponding to the queue to be scheduled is smaller than the value of the write pointer corresponding to the queue to be scheduled, returns to the step C3), if the value of the copy pointer corresponding to the queue to be scheduled is equal to the value of the write pointer corresponding to the queue to be scheduled, the step C5) is skipped, if the value of the copy pointer corresponding to the queue to be scheduled is larger than the value of the write pointer corresponding to the queue to be scheduled, an error reporting unit in the pointer management module corresponding to the queue to be scheduled carries out error prompt, and the step C5 is skipped;
C5) in the pointer management module corresponding to the queue to be scheduled, the pointer rollback unit resets the value of the copy pointer corresponding to the queue to be scheduled to be the same as the value of the read pointer corresponding to the queue to be scheduled, and returns to step B1).
As shown in fig. 6, in the present embodiment, the data reading of each queue has four states in total, that is, a non-read-release state, a copy pointer rollback state, and an error prompt state, where the default state of each queue is the read-release state, when the default state is selected, the data reading of the read-release is directly performed for a data reading request, otherwise, the data reading jumps to the non-read-release state, when jumping to the non-read-release state, the external cannot initiate the non-read-release state, or the copy pointer cannot be read beyond the write pointer, otherwise, the data reading jumps to the error prompt state, then enters the copy pointer rollback state, and after the copy pointer rolls back, the data reading jumps to the read-release state.
In this embodiment, the depth of each queue may not be an integer power of 2, and since there is a simple copy of data in the buffer space corresponding to the queue and the size of the buffer space corresponding to the queue is limited, the calculation of the remaining writable space and the remaining readable space will not be consistent, and to avoid a read-write error, it is necessary to compare precedence relationships of different pointers to determine the remaining writable space, step a 3) of this embodiment further includes a step of calculating the remaining writable space in the buffer space corresponding to the queue to be written, which specifically includes: and calculating the remaining writable space in the cache space corresponding to the queue to be written according to the depth of the queue to be written, the value of the write pointer and the value of the read pointer, if the remaining writable space is 0, repeating the step until the remaining writable space is larger than 0, and otherwise, skipping to the step A3).
Because the pointer is definitely turned over in the moving process, the space quantity cannot be directly calculated from the size after the pointer is turned over, and meanwhile, the function of the queue depth of the integer power which is not 2 is to be realized, the precedence relationship of the pointer needs to be compared for different pointer states, and the algorithm for writing the space is determined according to the precedence relationship;
when the read pointer corresponding to the queue to be written is before the write pointer corresponding to the queue to be written, the function expression of the remaining writable space in the cache space corresponding to the queue to be written is as follows:
in the above formula, the first and second carbon atoms are,is the depth of the queue to be written to,is the value of the write pointer corresponding to the queue to be written,the value of a read pointer corresponding to the queue to be written is i, and the sequence number of the queue to be written is i;
when the read pointer corresponding to the queue to be written is behind the write pointer corresponding to the queue to be written, the function expression of the remaining writable space in the cache space corresponding to the queue to be written is as follows:
in the above formula, the first and second carbon atoms are,is the value of the write pointer corresponding to the queue to be written,and i is the value of the read pointer corresponding to the queue to be written, and i is the sequence number of the queue to be written.
Correspondingly, the remaining readable space is determined by comparing the precedence relationship of different pointers, and step C3) includes a step of calculating the remaining readable space in the cache space corresponding to the queue to be scheduled, which specifically includes: and calculating the remaining readable space in the cache space corresponding to the queue to be scheduled according to the value of the write pointer and the value of the copy pointer corresponding to the queue to be scheduled, if the remaining readable space is 0, repeating the step until the remaining readable space is larger than 0, and otherwise, skipping to the step C3).
Similar to the write space calculation method, the precedence relationship of the pointers needs to be compared for different pointer states, and the algorithm of the read space is determined according to the precedence relationship;
when the copy pointer corresponding to the queue to be scheduled is before the write pointer corresponding to the queue to be scheduled, the expression of the function of the readable space left in the cache space corresponding to the queue to be scheduled is as follows:
in the above formula, the first and second carbon atoms are,for the value of the write pointer corresponding to the queue to be scheduled,the value of a copy pointer corresponding to the queue to be scheduled is obtained, and m is the serial number of the queue to be scheduled;
when the copy pointer corresponding to the queue to be scheduled is behind the write pointer corresponding to the queue to be scheduled, the expression of the function of the readable space left in the cache space corresponding to the queue to be scheduled is as follows:
in the above formula, the first and second carbon atoms are,for the value of the write pointer corresponding to the queue to be scheduled,for the value of the copy pointer corresponding to the queue to be scheduled,the maximum value of the pointer corresponding to the queue to be scheduled,and m is the minimum value of the pointer corresponding to the queue to be scheduled, and the sequence number of the queue to be scheduled.
The foregoing is considered as illustrative of the preferred embodiments of the invention and is not to be construed as limiting the invention in any way. Although the present invention has been described with reference to the preferred embodiments, it is not intended to be limited thereto. Therefore, any simple modification, equivalent change and modification made to the above embodiments according to the technical spirit of the present invention should fall within the protection scope of the technical scheme of the present invention, unless the technical spirit of the present invention departs from the content of the technical scheme of the present invention.
Claims (10)
1. A device for statically allocating shared multi-queue cache is characterized by comprising a space management module, a pointer management module, a data scheduling module, a read-write command module, a configuration register, a register and a shared cache module, wherein the space management module and the pointer management module are respectively in one-to-one correspondence with each queue, and the space management module and the pointer management module are respectively in one-to-one correspondence with each queue, wherein:
the space management module is used for calculating according to the depth and the pointer minimum of the last queue to obtain the pointer minimum of the corresponding queue, calculating according to the depth and the pointer minimum of the corresponding queue to obtain the pointer maximum of the corresponding queue, distributing the cache space of the corresponding queue from the shared cache space according to the pointer maximum and the pointer minimum of the corresponding queue, and sending the pointer maximum and the pointer minimum of the corresponding queue to the corresponding pointer management module, and the space management modules are sequentially connected in series, so that the last space management module sends the depth and the pointer minimum of the last queue to the next space management module;
the pointer management module is used for configuring a read pointer, a write pointer and a copy pointer for the corresponding queue according to the maximum pointer value and the minimum pointer value of the corresponding queue, adjusting the values of the read pointer and the copy pointer of the corresponding queue according to a read release command and sending the values to the data scheduling module, adjusting the value of the write pointer of the corresponding queue according to the write command and sending the value to the data scheduling module, and adjusting the value of the copy pointer of the corresponding queue according to a read non-release command and sending the value to the data scheduling module;
the data scheduling module is used for accessing a corresponding address of the shared cache space according to the value of the write pointer to store data, accessing a corresponding address of the shared cache space according to the value of the read pointer to read and release the data, accessing a corresponding address of the shared cache space according to the value of the copy pointer to copy the data, acquiring a non-release read command and a release read command, then selecting a queue to be scheduled according to head data of the queue, and forwarding the non-release read command and the release read command to a pointer management module corresponding to the queue to be scheduled;
the read-write command module is used for generating a non-release read command and a release read command and sending the non-release read command and the release read command to the data scheduling module, and is also used for generating a write command and sending the write command to the pointer management module;
the configuration register is used for configuring the depth of all queues;
the register is used for storing the head data of all queues;
the shared cache module is used for providing a shared cache space.
2. The apparatus of claim 1, wherein the pointer management module comprises:
the initialization unit is used for acquiring the maximum value and the minimum value of the pointer of the corresponding queue sent by the corresponding space management module, and initializing the values of the read pointer, the write pointer and the copy pointer to be the minimum value of the pointer;
the write pointer adjusting unit is used for receiving the write command, sending the value of the write pointer to the data scheduling module and then adding one to the value of the write pointer;
the copy pointer adjusting unit is used for receiving the non-release read command, sending the value of the copy pointer to the data scheduling module and then adding one to the value of the copy pointer;
a pointer rollback unit for resetting a value of the copy pointer to be the same as a value of the read pointer;
the read pointer adjusting unit is used for receiving the read releasing command, sending the value of the read pointer to the data scheduling module, then adding one to the value of the read pointer, and adjusting the value of the copy pointer to be the same as the value of the read pointer;
and the error reporting unit is used for carrying out error prompt when the value of the copy pointer is larger than the value of the write pointer.
3. The apparatus according to claim 1, wherein the pointer management module further includes a computing unit, configured to compute a remaining writable space in the corresponding buffer space according to the depth of the corresponding queue, the value of the write pointer, and the value of the read pointer, and further configured to compute a remaining readable space in the corresponding buffer space according to the value of the write pointer and the value of the copy pointer.
4. A method for statically allocating a shared multi-queue cache, comprising the steps of:
s1) one queue is sequentially selected as a current queue, a space management module corresponding to the current queue reads configuration information in a configuration register, the minimum value of a pointer of the current queue is calculated according to the minimum value and the depth of the pointer of the previous queue, the maximum value of the pointer of the current queue is calculated according to the minimum value and the depth of the pointer of the current queue, if the current queue is a first queue, the minimum value of the pointer of the current queue is an initial value, a buffer space corresponding to the current queue in a shared buffer module is distributed according to the maximum value and the minimum value of the pointer, and the maximum value and the minimum value of the pointer are sent to a pointer management module corresponding to the current queue;
s2), in a pointer management module corresponding to the current queue, an initialization unit acquires a maximum pointer value and a minimum pointer value, and initializes the values of a read pointer, a write pointer and a copy pointer to be the minimum pointer value;
s3) returning to the step S1) until all queues are selected;
s4) if there is no data read/write in all queues and the configuration information in the configuration register is updated, go to step S1), if there is a queue to which data is input, go to the data write step.
5. The method as claimed in claim 4, wherein the step S1) of calculating the minimum pointer value of the current queue according to the minimum pointer value and the depth of the previous queue, and the specific step of calculating the maximum pointer value of the current queue according to the minimum pointer value and the depth of the current queue includes:
s11) obtaining the depth and the pointer minimum value of the last queue from the space management module corresponding to the last queue, and adding the depth and the pointer minimum value of the last queue to obtain the pointer minimum value of the current queue;
s12) adding and subtracting the minimum value of the pointer of the current queue and the depth of the current queue by one to obtain the maximum value of the pointer of the current queue.
6. The method of claim 4, wherein the step of writing data in step S4) comprises:
A1) taking the queue with data written in as a queue to be written in, and sending a write command to a pointer management module corresponding to the queue to be written in by a read-write command module;
A2) in a pointer management module corresponding to a queue to be written, a write pointer adjusting unit receives a write command;
A3) the write pointer adjusting unit sends the value of the write pointer corresponding to the queue to be written to a data scheduling module, and then adds one to the value of the write pointer corresponding to the queue to be written;
A4) and the data scheduling module receives the value of the write pointer corresponding to the queue to be written, accesses the corresponding address of the shared cache space according to the value of the write pointer corresponding to the queue to be written, stores the data of the queue to be written in the corresponding address, returns to the step A3 if the value of the write pointer corresponding to the queue to be written is smaller than the maximum value of the pointer corresponding to the queue to be written, and ends and exits if the value of the write pointer corresponding to the queue to be written is equal to the maximum value of the pointer corresponding to the queue to be written.
7. The method of claim 6, wherein the step S4) further comprises: if a data reading request is received, skipping a data reading step, wherein the data reading step specifically comprises:
B1) if the default state is adopted, jumping to the step B2), otherwise, jumping to the non-release reading step;
B2) the read-write command module sends a read release command to the data scheduling module, and after the data scheduling module obtains the read release command, the data scheduling module selects queues to be scheduled according to the head data of each queue, forwards the read release command to the pointer management module corresponding to the queues to be scheduled, and skips step B3);
B3) in the pointer management module corresponding to the queue to be scheduled, the read pointer adjusting unit receives the read release command, sends the value of the read pointer corresponding to the queue to be scheduled to the data scheduling module, then adds one to the value of the read pointer corresponding to the queue to be scheduled, and simultaneously adjusts the value of the copy pointer corresponding to the queue to be scheduled to be the same as the value of the read pointer corresponding to the queue to be scheduled;
B4) and the data scheduling module receives the value of the read pointer corresponding to the queue to be scheduled, accesses the corresponding address of the shared cache space according to the value of the read pointer corresponding to the queue to be scheduled to read and release data, returns to the step B3 if the value of the read pointer corresponding to the queue to be scheduled is smaller than the value of the write pointer corresponding to the queue to be scheduled, and ends and exits if the value of the read pointer corresponding to the queue to be scheduled is equal to the value of the write pointer corresponding to the queue to be scheduled.
8. The method according to claim 7, wherein the non-release reading step in step B1) specifically includes:
C1) the read-write command module sends a non-release read command to the data scheduling module, and after the data scheduling module acquires the non-release read command, the data scheduling module selects queues to be scheduled according to the head data of each queue, forwards the non-release read command to the pointer management module corresponding to the queues to be scheduled, and skips to step C2);
C2) in a pointer management module corresponding to a queue to be scheduled, a copy pointer adjusting unit receives a non-release read command;
C3) the replication pointer adjusting unit sends the value of the replication pointer corresponding to the queue to be scheduled to the data scheduling module and then adds one to the value of the replication pointer corresponding to the queue to be scheduled;
C4) the data scheduling module receives the value of the copy pointer corresponding to the queue to be scheduled, accesses the corresponding address copy data of the shared cache space according to the value of the copy pointer corresponding to the queue to be scheduled, if the value of the copy pointer corresponding to the queue to be scheduled is smaller than the value of the write pointer corresponding to the queue to be scheduled, returns to the step C3), if the value of the copy pointer corresponding to the queue to be scheduled is equal to the value of the write pointer corresponding to the queue to be scheduled, the step C5) is skipped, if the value of the copy pointer corresponding to the queue to be scheduled is larger than the value of the write pointer corresponding to the queue to be scheduled, an error reporting unit in the pointer management module corresponding to the queue to be scheduled carries out error prompt, and the step C5 is skipped;
C5) in the pointer management module corresponding to the queue to be scheduled, the pointer rollback unit resets the value of the copy pointer corresponding to the queue to be scheduled to be the same as the value of the read pointer corresponding to the queue to be scheduled, and returns to step B1).
9. The method according to claim 6, wherein before step a 3), the method further includes a step of calculating a remaining writable space in the buffer space corresponding to the queue to be written, and specifically includes: determining the precedence relationship between the read pointer corresponding to the queue to be written and the write pointer corresponding to the queue to be written, calculating the remaining writable space in the cache space corresponding to the queue to be written according to the depth of the queue to be written, the value of the write pointer and the value of the read pointer, if the remaining writable space is 0, repeating the step until the remaining writable space is larger than 0, otherwise, skipping to the step A3).
10. The method according to claim 8, wherein step C3) is preceded by a step of calculating a remaining readable space in the buffer space corresponding to the queue to be scheduled, and specifically comprises: determining the precedence relationship between the copy pointer corresponding to the queue to be scheduled and the write pointer corresponding to the queue to be scheduled, calculating the remaining readable space in the cache space corresponding to the queue to be scheduled according to the value of the write pointer corresponding to the queue to be scheduled and the value of the copy pointer, if the remaining readable space is 0, repeating the step until the remaining readable space is larger than 0, otherwise, skipping to the step C3).
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110861235.XA CN113312278B (en) | 2021-07-29 | 2021-07-29 | Device and method for statically allocating shared multi-queue cache |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110861235.XA CN113312278B (en) | 2021-07-29 | 2021-07-29 | Device and method for statically allocating shared multi-queue cache |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113312278A CN113312278A (en) | 2021-08-27 |
CN113312278B true CN113312278B (en) | 2021-11-05 |
Family
ID=77381882
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110861235.XA Active CN113312278B (en) | 2021-07-29 | 2021-07-29 | Device and method for statically allocating shared multi-queue cache |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113312278B (en) |
Families Citing this family (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114579269A (en) * | 2022-02-08 | 2022-06-03 | 阿里巴巴(中国)有限公司 | Task scheduling method and device |
CN114185513B (en) * | 2022-02-17 | 2022-05-20 | 沐曦集成电路(上海)有限公司 | Data caching device and chip |
CN116192772A (en) * | 2023-03-03 | 2023-05-30 | 成都市楠菲微电子有限公司 | CPU (Central processing Unit) receiving and dispatching packet scheduling device and method based on space cache |
CN116719479B (en) * | 2023-07-03 | 2024-02-20 | 摩尔线程智能科技(北京)有限责任公司 | Memory access circuit, memory access method, integrated circuit, and electronic device |
CN116661703B (en) * | 2023-07-03 | 2024-02-20 | 摩尔线程智能科技(北京)有限责任公司 | Memory access circuit, memory access method, integrated circuit, and electronic device |
CN118093522A (en) * | 2024-04-22 | 2024-05-28 | 深圳华锐分布式技术股份有限公司 | Message data processing method, device and equipment based on data persistence |
CN118170702A (en) * | 2024-05-13 | 2024-06-11 | 北京壁仞科技开发有限公司 | DMA controller and data handling method for broadcasting |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20160321174A1 (en) * | 2015-04-29 | 2016-11-03 | Dell Products L.P. | Dynamic media cache for a data storage drive in an information handling system |
CN112099854A (en) * | 2020-11-10 | 2020-12-18 | 北京微核芯科技有限公司 | Method and device for scheduling out-of-order queue and judging queue cancellation item |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN100343826C (en) * | 2003-04-29 | 2007-10-17 | 华为技术有限公司 | Method for implementing memory management |
DE10329680A1 (en) * | 2003-07-01 | 2005-02-10 | Universität Stuttgart | Processor architecture for exact pointer identification |
CN101094183B (en) * | 2007-07-25 | 2011-12-07 | 杭州华三通信技术有限公司 | Buffer memory management method and device |
-
2021
- 2021-07-29 CN CN202110861235.XA patent/CN113312278B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20160321174A1 (en) * | 2015-04-29 | 2016-11-03 | Dell Products L.P. | Dynamic media cache for a data storage drive in an information handling system |
CN112099854A (en) * | 2020-11-10 | 2020-12-18 | 北京微核芯科技有限公司 | Method and device for scheduling out-of-order queue and judging queue cancellation item |
Non-Patent Citations (1)
Title |
---|
基于多查询特性的搜索引擎缓存替换策略研究;房耘耘;《现代计算机(专业版)》;20150815(第23期);全文 * |
Also Published As
Publication number | Publication date |
---|---|
CN113312278A (en) | 2021-08-27 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN113312278B (en) | Device and method for statically allocating shared multi-queue cache | |
JP5384576B2 (en) | Selective use of multiple disparate solid-state storage locations | |
US8402200B2 (en) | Method and apparatus for storing and restoring state of virtual machine | |
US20200089537A1 (en) | Apparatus and method for bandwidth allocation and quality of service management in a storage device shared by multiple tenants | |
US8495302B2 (en) | Selecting a target number of pages for allocation to a partition | |
JP2012523619A (en) | Data storage device command and interrupt grouping | |
KR20140082829A (en) | System And Method To Reduce Memory Access Latencies Using Selective Replication Across Multiple Memory Ports | |
JP2007026094A (en) | Execution device and application program | |
CN102473106A (en) | Resource allocation in virtualized environments | |
KR102594657B1 (en) | Method and apparatus for implementing out-of-order resource allocation | |
CN112667354B (en) | Computer readable storage medium, virtualized register device, and method of accessing the device | |
CN108351838B (en) | Memory management functions are provided using polymerization memory management unit (MMU) | |
CN109032788B (en) | Reserved resource pool dynamic dispatching method, device, computer equipment and storage medium | |
JP2020194522A (en) | Method, apparatus, device, and medium for processing data | |
CN114827048A (en) | Dynamic configurable high-performance queue scheduling method, system, processor and protocol | |
Wang et al. | Provision of storage QoS in distributed file systems for clouds | |
US9122565B2 (en) | Memory controller and memory control method | |
CN116775266A (en) | Techniques for scalable load balancing of thread groups in a processor | |
CN115640098A (en) | Virtual machine heterogeneous memory pooling method and system | |
CN112131145B (en) | Caching method and device applied to ceph | |
US10936219B2 (en) | Controller-based inter-device notational data movement system | |
Cheriere et al. | How fast can one resize a distributed file system? | |
CN113448897B (en) | Optimization method suitable for pure user mode far-end direct memory access | |
CN109308247A (en) | A kind of log processing method, device, equipment and a kind of network equipment | |
US11281612B2 (en) | Switch-based inter-device notational data movement system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |