Processor table look-up method, processor, equipment and readable medium
By setting up multiple processes in the hardware thread to execute table lookup tasks in parallel and using the CHKRSP instruction to control thread switching, the performance loss problem caused by frequent thread switching in the network processor is solved, and the processor's table lookup efficiency and performance are improved.
Patent Information
- Application Number
- CN202410367200.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-28
- Publication Date
- 2025-10-10
AI Technical Summary
Network processors suffer performance loss due to frequent thread switching during table lookup operations, especially when a large number of table lookups are required, resulting in pipeline pauses and performance degradation.
Multiple processes are set in the hardware thread. Multiple table lookup tasks are executed in parallel. One process is used to execute the table lookup task without switching the hardware thread. The CHKRSP instruction is used to control thread switching and optimize the table lookup process.
It improves the execution efficiency of the processor pipeline, expands the processing resources of table lookup instructions, avoids the performance loss caused by frequent switching of hardware threads, and improves processor performance.
Smart Images

Figure CN120762871A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of processor technology, and in particular to a processor table lookup method, a processor, a device, and a readable medium. Background Art
[0002] A network processor is a programmable processor specialized for network message processing and is used for a variety of communications tasks. Network processors contain multiple microengines (MEs). When an ME issues instructions to access a coprocessor or external memory, it spends significant time waiting for the results to return. To efficiently utilize this idle time, hardware multithreading is often employed.
[0003] The process of implementing table lookup functionality in a network processor through hardware multithreading technology is roughly as follows: the key values required for table lookup are saved in the key-value memory (KEY_MEM) through microcode; a table lookup request is then issued to the table lookup engine through a specific table lookup command; each time a table lookup request is issued, the hardware automatically switches threads, and the switched thread waits for the table lookup result to return before continuing to execute subsequent instructions. Summary of the Invention
[0004] Embodiments of the present disclosure provide a processor table lookup method, a processor, a device, and a readable medium.
[0005] A first aspect of an embodiment of the present disclosure provides a table lookup method for a processor, which is applied to any hardware thread in the processor, where the hardware thread includes at least two processes. The method includes:
[0006] Each time the hardware thread executes a parallel table lookup, it obtains a target process corresponding to the table lookup key value; wherein the target process is an idle process among the at least two processes; calls the target process to perform a table lookup according to the table lookup key value, and updates the state of the target process to a state of waiting for a table lookup result to be returned;
[0007] When the hardware thread detects the return information of the table lookup result, it updates the state of the corresponding target process to the result returned state and saves the table lookup result.
[0008] A second aspect of an embodiment of the present disclosure provides a processor, the processor comprising at least two hardware threads, any of the hardware threads comprising at least two processes;
[0009] Any of the hardware threads is used to obtain the target process corresponding to the table lookup key value each time a parallel table lookup is executed; wherein, the target process is the process in the idle state among the at least two processes; the target process is called to perform a table lookup according to the table lookup key value, and the state of the target process is updated to the waiting result return state; when the return information of the table lookup result is monitored, the state of the target process is updated to the result returned state and the table lookup result is saved.
[0010] A third aspect of the present disclosure provides an electronic device, including:
[0011] at least one processor;
[0012] a memory having at least one program stored thereon, wherein when the at least one program is executed by the at least one processor, the at least one processor implements the method according to the first aspect;
[0013] At least one I / O interface is connected between the processor and the memory and is configured to implement information interaction between the processor and the memory.
[0014] A fourth aspect of the embodiments of the present disclosure provides a computer-readable medium having a computer program stored thereon, which implements the method described in the first aspect when the program is executed by a processor.
[0015] The embodiments of the present disclosure have the following advantages:
[0016] Multiple processes are set up in the hardware thread, and multiple table lookup tasks can be executed in parallel through the multiple processes. One process is used to execute a table lookup task, and another process is started to execute the next table lookup task without switching hardware threads. In this way, within one hardware thread, multiple table lookup instructions can be processed in the time spent on a single lookup instruction, thereby improving the processor pipeline execution efficiency, expanding the processing resources for table lookup instructions, improving processor performance, and avoiding performance losses caused by frequent switching of hardware threads. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 Schematic diagram of an application environment of a table lookup method for a processor provided in an embodiment of the present disclosure Figure 1 ;
[0018] Figure 2 Schematic diagram of an application environment of a table lookup method for a processor provided in an embodiment of the present disclosure Figure 2 ;
[0019] Figure 3 A schematic diagram of a hardware thread state machine provided in an embodiment of the present disclosure;
[0020] Figure 4A flowchart of a table lookup method for a processor provided in an embodiment of the present disclosure is shown;
[0021] Figure 5 A schematic diagram of a hardware thread parallel table lookup process provided in an embodiment of the present disclosure Figure 1 ;
[0022] Figure 6 A schematic diagram of a hardware thread parallel table lookup process provided in an embodiment of the present disclosure Figure 2 ;
[0023] Figure 7 A schematic diagram comparing the execution effects of a parallel table lookup and a non-parallel table lookup provided in an embodiment of the present disclosure;
[0024] Figure 8 A schematic structural diagram of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0025] The following describes the specific embodiments of the present disclosure in detail with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are only used to illustrate and explain the present disclosure and are not intended to limit the present disclosure.
[0026] As used in this disclosure, the term "and / or" includes any and all combinations of one or more of the associated listed items.
[0027] The terms used in the present disclosure are only used to describe specific embodiments and are not intended to limit the present disclosure.As used in the present disclosure, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
[0028] When the terms “comprising” and / or “made of…” are used in the present disclosure, it specifies the existence of the stated features, integers, steps, operations, elements and / or components, but does not preclude the existence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.
[0029] Unless otherwise defined, all terms (including technical and scientific terms) used in this disclosure have the same meanings as those commonly understood by those skilled in the art. It will also be understood that terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and this disclosure, and will not be interpreted as having an idealized or overly formal meaning unless expressly defined in this disclosure.
[0030] The inventors discovered during the process of implementing the present disclosure that:
[0031] In the hardware multithreading technology of the network processor, the thread will be switched after the operation of searching the external memory is triggered. After the search result is returned, the thread will be switched back and the subsequent instructions will continue to be executed through the thread. The table access delay is shielded by a large number of parallel thread switches.
[0032] For a single thread, instructions are executed sequentially and table lookup requests are issued serially. After issuing a table lookup request, you must wait for the table lookup result to be returned before issuing the next table lookup request.
[0033] Because each table lookup triggers a thread switch, frequent thread switching can lead to performance loss when there are numerous table lookup requests. Furthermore, if the latency of a single table lookup is too large, exceeding the range that can be masked by other threads, this can lead to a lack of available threads, causing a pipeline stall. For a short period of time, no instructions can be processed in the pipeline, resulting in performance degradation.
[0034] Based on this, the embodiment of the present disclosure provides a table lookup method for a processor, the application environment of the table lookup method for the processor is as follows: Figure 1 and Figure 2 As shown, when executing a table lookup instruction, a network processor with a hardware multi-threaded structure accesses an external memory through a table lookup engine. In the ME of the network processor, multiple hardware threads are included, represented as threads 0 to N.
[0035] The core pipeline is used to parse and execute instructions, write data to the table lookup key-value memory according to the instructions, read data from the table lookup result memory, or operate the table lookup process status register;
[0036] A lookup key value memory, used to store the spliced lookup key values;
[0037] A table lookup result memory, used to store the table lookup results returned by the table lookup engine;
[0038] A table lookup process status register is used to store a flag indicating whether the table lookup result of the process corresponding to the parallel table lookup is returned;
[0039] The thread state machine is used to record the current state of the hardware thread. The state machine is controlled by microcode execution and table lookup return status;
[0040] Thread controller, used to control hardware thread switching and authorization according to the thread state machine;
[0041] Table lookup engine for accessing external memory.
[0042] Among them, the core pipeline, thread controller and table lookup engine are shared by all hardware threads, and the remaining modules are unique to each hardware thread.
[0043] An embodiment of the present disclosure provides a table lookup method for a processor. The method can be applied to any hardware thread in the processor. The hardware thread includes at least two processes. When executing a table lookup instruction, one of the processes is called, and when executing another table lookup instruction, another process is called. Parallel table lookup is implemented through multiple processes.
[0044] In the embodiment of the present disclosure, a state machine of a hardware thread is defined, such as Figure 3 The figure shows a schematic diagram of the hardware thread state machine. The state machine of the hardware thread is initially in the idle (IDLE) state and switches to the ready (RDY) state after receiving instruction authorization.
[0045] The disclosed embodiment also defines a table lookup result check instruction, namely the CHKRSP instruction, which is a pre-defined special instruction used to check the table lookup results of the parallel table lookup and control the hardware thread switching. There is a keyword in the instruction, represented as PROCESS_ID_MASK, which is used to represent the identifier of the specified target process. These specified target processes are processes that need to pay attention to whether the table lookup results are returned.
[0046] In the RDY state, the hardware thread fetches instructions through the kernel pipeline for data processing. If a parallel table lookup instruction is executed, the hardware thread does not switch and remains in the RDY state. If a CHKRSP instruction is executed, and the table lookup result for the designated target process corresponding to the CHKRSP instruction has been returned, the hardware thread does not switch and remains in the RDY state. If a CHKRSP instruction is executed, and the table lookup result for the designated target process corresponding to the CHKRSP instruction has not been fully returned, the hardware thread switches to the WAIT state, waiting for the result of each designated target process to be returned before being triggered by the instruction to enter the RDY state.
[0047] In the WAIT state, if the table lookup result is a table lookup failure, the state is switched to the IDLE state and the message processing is completed.
[0048] It should be noted that the state machine for controlling hardware threads may have many other variations, but at least includes the above three states.
[0049] like Figure 4 FIG. 1 is a flow chart of a table lookup method for a processor provided by an embodiment of the present disclosure. The table lookup method for a processor mainly includes the following steps:
[0050] In step 401, the hardware thread obtains the target process corresponding to the table lookup key value each time it executes a parallel table lookup; wherein, the target process is the process in the idle state among the at least two processes; the target process is called to perform a table lookup according to the table lookup key value, and the state of the target process is updated to a state of waiting for the table lookup result to be returned.
[0051] In some embodiments, the method further includes: when the hardware thread is in an idle state, the hardware thread is converted from the idle state to the ready state through instruction authorization, and executes a parallel table lookup instruction to start the parallel table lookup.
[0052] In an exemplary embodiment, a thread controller grants an instruction to an idle hardware thread, causing the hardware thread to transition from the idle state to the ready state. When executing a parallel table lookup instruction, the core pipeline initiates a parallel table lookup based on the instruction and saves the concatenated table lookup key value to a table lookup key value memory.
[0053] In an exemplary embodiment, the parallel table lookup instruction may be predefined, and the parallel table lookup instruction may carry an identifier of a specified process and / or carry tag information for indicating a parallel table lookup.
[0054] When the parallel table lookup instruction carries the identifier of a designated process, the kernel pipeline can verify whether the designated process is in an idle state through the table lookup process status register of the hardware thread. If it is in an idle state, the kernel pipeline provides the table lookup key value to the hardware thread, along with the identifier of the process, so that the hardware thread performs a table lookup through the process. If it is not in an idle state, the kernel pipeline can prompt the hardware thread to re-designate the process.
[0055] When the parallel table lookup instruction carries tag information for indicating a parallel table lookup but does not carry the identifier of a specified process, the kernel pipeline checks the table lookup process status register of the hardware thread and selects a process in an idle state based on the table lookup process status register; while providing the table lookup key value to the hardware thread, the kernel pipeline carries the identifier of the process so that the hardware thread performs a table lookup through the process.
[0056] In an exemplary embodiment, a dedicated thread switching instruction is predefined, defined as SRH_SWITCH, and is controlled by a microcode writer. The instruction forces the current hardware thread to be suspended and controls other hardware threads to switch from the IDLE state to the RDY state. The microcode writer controls by adding a flag bit in the instruction to indicate whether the table lookup instruction switches the hardware thread. When the flag bit indicates not to switch the hardware thread, each time the hardware thread executes the table lookup instruction, a table lookup is performed through the corresponding process, and the hardware thread is not switched after the table lookup instruction is issued. After all the table lookup instructions are completed, the hardware thread is switched by executing a separate hardware thread switching instruction. After all the table lookup results of the hardware thread are returned, the instruction continues to be executed without switching the hardware thread.
[0057] Step 402 : When the hardware thread detects the return information of the table lookup result, the hardware thread updates the state of the corresponding target process to the result returned state and saves the table lookup result.
[0058] In some embodiments, the method also includes: the hardware thread obtains a check table result instruction, the check table result instruction carries an identifier of a specified target process, obtains the status of the target process corresponding to the identifier of the specified target process, and determines whether to switch the hardware thread based on the status of the target process corresponding to the identifier of the specified target process.
[0059] In an exemplary embodiment, obtaining the status of the target process corresponding to the identifier of the specified target process includes: obtaining the status of the target process corresponding to the identifier of the specified target process from the table lookup process status register of the hardware thread, and the table lookup process status register stores a flag indicating whether the table lookup result corresponding to the process identifier is returned.
[0060] In some embodiments, the determination of whether to switch the hardware thread based on the state of the target process corresponding to the identifier of the specified target process includes: when the state of at least one of the specified target processes is a waiting state for result return, switching the hardware thread to a waiting state to switch other hardware threads; when the state of each of the specified target processes is a result returned state, the hardware thread continues to execute the next instruction.
[0061] It should be noted that when the state of at least one specified target process is the waiting result return state, it indicates that the hardware thread has not yet returned the table lookup result, and the hardware thread is switched from the RDY state to the WAIT state so that the kernel pipeline authorizes other hardware threads in the RDY state to continue executing instructions, avoiding wasting time waiting for the result to be returned, thereby improving processor efficiency.
[0062] When the status of each designated target process is the result-returned status, it indicates that the hardware thread currently has an idle process that can be used to execute a new table lookup instruction, and there is no need to perform hardware thread switching to avoid performance degradation caused by hardware thread switching.
[0063] In some embodiments, calling the target process to perform a table lookup based on the table lookup key value includes: the hardware thread generating a table lookup request, the table lookup request including the table lookup key value and the identifier of the target process; and sending the table lookup request to a table lookup engine through the target process.
[0064] In some embodiments, the hardware thread updates the status of the target process to a result-returned status when monitoring the return information of the table lookup result, including: when the hardware thread monitors the return information of the table lookup result, the hardware thread updates the status of the target process to a result-returned status based on the identifier of the target process included in the return information of the table lookup result.
[0065] It should be noted that by carrying the identifier of the target process in the table lookup request, when the table lookup engine obtains the table lookup result, the table lookup result can be matched with the identifier of the target process, so that the hardware thread can modify the table lookup process status register according to the identifier of the target process corresponding to the table lookup result, and save the table lookup result to the correct storage location.
[0066] In some embodiments, saving the table lookup result includes: the hardware thread obtains the identifier of the target process from the return information of the table lookup result, obtains the corresponding table lookup key value according to the identifier of the target process, and saves the table lookup result according to the storage location corresponding to the table lookup key value.
[0067] In an exemplary embodiment, an offset corresponding to a lookup key value is pre-configured. When a hardware thread obtains a lookup result corresponding to a lookup key value, a storage location in a lookup result memory is determined based on the offset corresponding to the lookup key value, and the lookup result is saved to the storage location. The offset corresponding to the lookup key value is an offset of a designated storage location in the lookup result memory corresponding to the lookup key value. The offset is superimposed on the designated storage location in the lookup result memory to obtain the storage location corresponding to the lookup result of the lookup key value.
[0068] In some embodiments, after saving the table lookup result, the method further includes: the hardware thread setting the target process to an idle state.
[0069] It should be noted that the status of the process in the table lookup process status register includes an idle state and a waiting result return state, wherein the idle state is equivalent to the table lookup result returned state.
[0070] In a specific embodiment, combining Figure 5 and Figure 6 As shown in FIG, the process of parallel table lookup in a single hardware thread is illustrated, which mainly includes the following steps:
[0071] Step 1: The network processor loads the message into the core pipeline and triggers the hardware thread to execute the microcode instruction through the message to authorize the hardware thread to execute the microcode instruction;
[0072] In step 2, the hardware thread obtains the parallel table lookup instruction through the kernel pipeline, obtains the spliced table lookup key value from the table lookup key value memory, clears the table lookup process status register corresponding to the process through the identifier (PROCESS_ID number) of the process specified in the parallel table lookup instruction, and calls the process to issue a table lookup instruction to the table lookup engine based on the table lookup key value without switching the hardware thread; the table lookup process status register is used to store the indication information of whether the table lookup result is returned.
[0073] In order to avoid reusing the same process when initiating parallel table lookups multiple times, it is necessary to verify the identifier of the process that initiated the table lookup, that is, to check whether the table lookup process status register of the process is in the non-return state. If it is in the non-return state, the process is rejected and a prompt is given. If it is in the return state, the process is continued to be used for table lookup.
[0074] In step 3, the hardware thread continues to execute instructions. It can execute ordinary instructions other than table lookup instructions, or continue to execute parallel table lookup instructions, and pre-configure the storage location corresponding to each table lookup key value to save the table lookup result returned by the process corresponding to the table lookup key value to avoid overwriting each other's table lookup results.
[0075] Step 4: The hardware thread executes the CHKRSP instruction to determine whether to switch the hardware thread.
[0076] The hardware thread determines whether to switch the hardware thread through the decoding logic of the core pipeline based on the identifier of the specified process carried in the PROCESS_ID_MASK keyword in the CHKRSP instruction and the table lookup process status register of the specified process; if the table lookup process status register indicates that the table lookup result of the specified process has not been returned, it is necessary to switch the hardware thread and switch the hardware thread to the WAIT state to wait for the table lookup result to be returned; if the table lookup process status register indicates that the table lookup result of the specified process has been returned, the hardware thread remains in the RDY state to continue executing the next instruction.
[0077] Step 5: When the hardware thread detects that the table lookup result is returned, it determines the offset based on the table lookup key value corresponding to the table lookup result, writes the table lookup result to the corresponding position of the table lookup result memory based on the offset, waits for the kernel pipeline to access it, and simultaneously completes the setting operation of the table lookup process status register of the corresponding process to indicate that the table lookup result has been returned.
[0078] If the hardware thread is in the WAIT state and the table lookup results of all processes in the process specified in the CHKRSP instruction are returned, it is ready to execute the next instruction and wait for the hardware thread to be authorized by the instruction to enter the RDY state to continue execution; otherwise, it continues to wait for the table lookup result to return.
[0079] The actual execution order of step 4 and step 5 is determined by the table lookup delay.
[0080] Step 6: The core pipeline reads the table lookup result from the table lookup result memory and continues processing.
[0081] The table lookup method for a processor provided by the embodiments of the present disclosure sets multiple processes in a hardware thread. Multiple table lookup tasks can be executed in parallel through the multiple processes. One process is used to execute a table lookup task, and another process is started to execute the next table lookup task without switching hardware threads. Therefore, within a hardware thread, multiple table lookup instructions can be processed in the time taken for a single lookup instruction, thereby improving the execution efficiency of the processor pipeline, expanding the processing resources for table lookup instructions, improving processor performance, and avoiding performance losses caused by frequent switching of hardware threads.
[0082] like Figure 7 The figure below compares the execution performance of parallel and non-parallel table lookups. The non-parallel table lookup waits for the lookup result from cycle 2 and cannot process instructions before cycle N. The parallel table lookup continues executing instructions after cycle 2. If the result of table lookup 2 is returned before cycle N, the behavior of table lookup 2 can be completely masked. Table lookup latency is typically much greater than the processing latency of non-table lookup instructions. The return time of multiple parallel table lookups can be approximated as the longest table lookup latency. This shows that parallel table lookups significantly improve performance.
[0083] Furthermore, in the table lookup method of the processor provided by the embodiment of the present disclosure, the control of hardware thread switching can be achieved through the defined CHKRSP instruction, which is beneficial for microcode personnel to fully utilize network processor resources, reasonably encode, and improve network processor performance by optimizing encoding.
[0084] The steps of the various methods above are divided only for clarity of description. During implementation, they can be combined into one step or some steps can be split and decomposed into multiple steps. As long as they include the same logical relationship, they are all within the scope of protection of this disclosure. Adding insignificant modifications or introducing insignificant designs to the algorithm or process without changing the core design of the algorithm and process are all within the scope of protection of this disclosure.
[0085] A processor is provided in an embodiment of the present disclosure, wherein the processor includes at least two hardware threads, and any of the hardware threads includes at least two processes. The specific implementation of the processor can be found in the relevant description of the method embodiment, which will not be repeated here.
[0086] Any of the hardware threads is used to obtain the target process corresponding to the table lookup key value each time a parallel table lookup is executed; wherein, the target process is the process in the idle state among the at least two processes; the target process is called to perform a table lookup according to the table lookup key value, and the state of the target process is updated to the waiting result return state; when the return information of the table lookup result is monitored, the state of the target process is updated to the result returned state and the table lookup result is saved.
[0087] The functions or modules included in the apparatus provided in the embodiments of the present disclosure can be used to execute the method described in the method embodiments. The specific implementation and technical effects thereof can be referred to the description of the above method embodiments, and will not be repeated here for the sake of brevity.
[0088] It should be noted that all modules involved in this embodiment are logical modules. In actual applications, a logical unit can be a physical unit, a part of a physical unit, or a combination of multiple physical units. In addition, to highlight the innovations of this disclosure, this embodiment does not include units that are not closely related to solving the technical problems proposed by this disclosure. However, this does not mean that other units do not exist in this embodiment.
[0089] Reference Figure 8 , an embodiment of the present disclosure provides an electronic device, comprising:
[0090] at least one processor 801;
[0091] a memory 802 storing at least one program, which, when executed by the at least one processor, causes the at least one processor to implement the above method;
[0092] At least one I / O interface 803 is connected between the processor and the memory and is configured to implement information exchange between the processor and the memory.
[0093] Among them, the processor 801 is a device with data processing capabilities, including but not limited to a central processing unit (CPU); the memory 802 is a device with data storage capabilities, including but not limited to random access memory (RAM, more specifically such as SDRAM, DDR, etc.), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), and flash memory (FLASH); the I / O interface (read-write interface) 803 is connected between the processor 801 and the memory 802, and can realize information exchange between the processor 801 and the memory 802, including but not limited to a data bus (Bus), etc.
[0094] In some embodiments, the processor 801 , the memory 802 , and the I / O interface 803 are connected to each other via a bus, and further connected to other components of the computing device.
[0095] This embodiment further provides a computer-readable medium on which a computer program is stored. When the program is executed by a processor, the method provided in this embodiment is implemented. To avoid repeated description, the specific steps of the method are not repeated here.
[0096] It will be appreciated by those skilled in the art that all or some of the steps, systems, and functional modules / units in the methods applied for above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In hardware implementations, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or implemented as hardware, or implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or non-transitory medium) and a communication medium (or temporary medium). As is well known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable, and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, it is well known to those skilled in the art that communication media typically embodies computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.
[0097] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or apparatus comprising the element.
[0098] Those skilled in the art will understand that although some embodiments described herein include certain features included in other embodiments but not other features, the combination of features from different embodiments is meant to be within the scope of the present embodiment and to form different embodiments.
[0099] It is understood that the above embodiments are merely exemplary embodiments for illustrating the principles of the present disclosure, and the present disclosure is not limited thereto. Those skilled in the art may make various modifications and improvements without departing from the spirit and substance of the present disclosure, and such modifications and improvements are also considered to be within the scope of protection of the present disclosure.
Claims
1. A table lookup method for a processor, characterized in that: Applied to any hardware thread in a processor, the hardware thread including at least two processes, the method comprising: Each time the hardware thread executes a parallel table lookup, it obtains a target process corresponding to the table lookup key value; wherein the target process is an idle process among the at least two processes; calls the target process to perform a table lookup according to the table lookup key value, and updates the state of the target process to a state of waiting for a table lookup result to be returned; When the hardware thread detects the return information of the table lookup result, it updates the state of the corresponding target process to the result returned state and saves the table lookup result.
2. The method according to claim 1, characterized in that The method further comprises: When the hardware thread is in an idle state, the hardware thread is converted from the idle state to the ready state through instruction authorization, and executes a parallel table lookup instruction to start a parallel table lookup.
3. The method according to claim 1, characterized in that The method further comprises: The hardware thread obtains an instruction to check the table lookup result, which carries the identifier of the specified target process, obtains the status of the target process corresponding to the identifier of the specified target process, and determines whether to switch the hardware thread based on the status of the target process corresponding to the identifier of the specified target process.
4. The method according to claim 3, characterized in that The determining whether to switch the hardware thread according to the state of the target process corresponding to the identifier of the designated target process includes: When the state of at least one of the designated target processes is a waiting state for a result to be returned, switching the hardware thread to a waiting state to switch other hardware threads; When the status of each of the designated target processes is a result-returned status, the hardware thread continues to execute the next instruction.
5. The method according to claim 1, wherein The calling of the target process to perform a table lookup according to the table lookup key value includes: The hardware thread generates a table lookup request, wherein the table lookup request includes the table lookup key value and the identifier of the target process; and sends the table lookup request to a table lookup engine through the target process.
6. The method according to claim 5, characterized in that When the hardware thread detects the return information of the table lookup result, it updates the state of the target process to the result returned state, including: When the hardware thread monitors the return information of the table lookup result, it updates the state of the target process to the result-returned state according to the identifier of the target process included in the return information of the table lookup result.
7. The method according to claim 5, characterized in that The storing of the table lookup result includes: The hardware thread obtains the identifier of the target process from the return information of the table lookup result, obtains the corresponding table lookup key value according to the identifier of the target process, and saves the table lookup result according to the storage location corresponding to the table lookup key value.
8. The method according to claim 1, characterized in that After saving the table lookup result, the method further includes: The hardware thread places the target process in an idle state.
9. A processor, characterized in that: The processor includes at least two hardware threads, and any of the hardware threads includes at least two processes; Any of the hardware threads is used to obtain the target process corresponding to the table lookup key value each time a parallel table lookup is executed; wherein, the target process is the process in the idle state among the at least two processes; the target process is called to perform a table lookup according to the table lookup key value, and the state of the target process is updated to the waiting result return state; when the return information of the table lookup result is monitored, the state of the target process is updated to the result returned state and the table lookup result is saved.
10. An electronic device, characterized in that: include: at least one processor; a memory having at least one program stored thereon, wherein when the at least one program is executed by the at least one processor, the at least one processor implements the method according to any one of claims 1 to 8; At least one I / O interface is connected between the processor and the memory and is configured to implement information interaction between the processor and the memory.
11. A computer-readable medium having a computer program stored thereon, wherein when the program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.