Resource allocation method, processor and electronic device

By dynamically controlling the resource allocation of micro-instruction caches, the resource occupation of each thread is optimized based on the hit rate information of multi-threads, the problem of low hit rate of micro-instruction caches caused by multi-thread competition is solved, and more efficient CPU performance and capabilities are achieved Efficiency consumption.

CN118227285BActive Publication Date: 2025-02-25HYGON INFORMATION TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202410260546.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-03-07
Publication Date
2025-02-25
Estimated Expiration
2044-03-07

AI Technical Summary

Technical Problem

In a multi-threaded environment, multiple threads compete with each other for micro-instruction cache resources, resulting in a low hit rate of the overall micro-instruction cache, affecting the performance and power consumption efficiency of the CPU.

Method used

By obtaining the micro-instruction hitting information of multiple threads in the sampling window, the micro-instruction cache hit rate and total hit rate of each thread are calculated, and the regulation strategy is generated based on this information, and the resource allocation of the micro-instruction cache is dynamically controlled to optimize each thread. resource usage.

Benefits of technology

It improves the overall hit rate of the micro instruction cache, improves the CPU's running speed and performance power consumption ratio, and solves the problem of low resource utilization caused by multi-thread competition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118227285B_ABST
    Figure CN118227285B_ABST
Patent Text Reader

Abstract

A resource allocation method, a processor and an electronic device. The resource allocation method is applied to a processor, the processor is configured to execute multiple threads concurrently, the processor includes a microinstruction cache, and the method includes: obtaining hit information of the microinstructions of multiple threads in a sampling window hitting the microinstruction cache; determining a regulation strategy according to the hit information; and controlling the allocation of resources of the microinstruction cache according to the regulation strategy. The method can at least partially solve the problem of low microinstruction cache resource utilization caused by competition between multiple threads for microinstruction cache resources, and improve the utilization of microinstruction cache resources.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present disclosure relate to a resource allocation method, a processor, and an electronic device. Background Art

[0002] Traditional processors (CPUs) can only process one instruction sequence at a time, usually called a thread. During the thread processing, the CPU processing unit needs to continuously call in instructions and data for processing. With the development of CPU technology, the CPU's main frequency and performance continue to improve, and the speed of calling in instructions and data continues to increase. Unfortunately, the development of memory technology has not kept up with the speed of CPU development, and the memory usually cannot provide enough instructions and data for the CPU to process.

[0003] In order to improve the utilization of the CPU processing unit, thread-level parallel technology is proposed, that is, executing more than one instruction sequence in the core of the CPU. For the operating system, a physical processor is equivalent to multiple logical processors, realizing multi-threading technology. Summary of the invention

[0004] At least one embodiment of the present disclosure provides a resource allocation method, which is applied to a processor, wherein the processor is configured to execute multiple threads concurrently, and the processor includes a microinstruction cache. The method includes: obtaining hit information of microinstructions of the multiple threads within a sampling window hitting the microinstruction cache; determining a regulation strategy based on the hit information; and controlling the allocation of resources of the microinstruction cache based on the regulation strategy.

[0005] For example, in a resource allocation method provided in an embodiment of the present disclosure, a regulation strategy is generated according to the hit information, including: calculating a microinstruction cache hit rate of each of the multiple threads according to the hit information, the microinstruction cache hit rate indicating the proportion of microinstructions in each thread that hit the microinstruction cache to all microinstructions of each thread in the sampling window; calculating a total microinstruction cache hit rate of the multiple threads according to the hit information, the total microinstruction cache hit rate indicating the proportion of microinstructions in the multiple threads that hit the microinstruction cache to all microinstructions of the multiple threads in the sampling window; and generating the regulation strategy based on the microinstruction cache hit rate of each of the multiple threads and the total microinstruction cache hit rate.

[0006] For example, in the resource allocation method provided in an embodiment of the present disclosure, the regulation strategy is determined based on the microinstruction cache hit rate of each of the multiple threads and the total hit rate of the microinstruction cache, including: in response to the total hit rate of the microinstruction cache being higher than or equal to a hit rate threshold, determining that the regulation strategy includes storing the target microinstructions in the microinstructions of each of the multiple threads into the microinstruction cache; in response to the total hit rate of the microinstruction cache being lower than the hit rate threshold, determining the regulation strategy according to the microinstruction cache hit rate of each of the multiple threads and the hit rate threshold.

[0007] For example, in the resource allocation method provided in an embodiment of the present disclosure, in response to the total hit rate of the microinstruction cache being lower than the hit rate threshold, the regulation strategy is determined according to the microinstruction cache hit rate of each of the multiple threads and the hit rate threshold, including: in response to the total hit rate of the microinstruction cache being lower than the hit rate threshold, selecting a target thread whose microinstruction cache hit rate meets the condition from the microinstruction cache hit rate of each of the multiple threads; and determining that the regulation strategy includes writing the microinstructions of the target thread into the microinstruction cache, and not writing the microinstructions of the remaining threads of the multiple threads except the target thread into the microinstruction cache.

[0008] For example, in a resource allocation method provided in an embodiment of the present disclosure, in response to the total microinstruction cache hit rate being lower than the hit rate threshold, selecting a target thread whose microinstruction cache hit rate meets the condition from the microinstruction cache hit rate of each of the multiple threads includes:

[0009] In response to the total microinstruction cache hit rate being lower than the hit rate threshold, the object thread with the lowest microinstruction cache hit rate among the multiple threads is excluded to obtain the target thread.

[0010] For example, in a resource allocation method provided in an embodiment of the present disclosure, in response to the total microinstruction cache hit rate being lower than the hit rate threshold, a target thread whose microinstruction cache hit rate meets the condition is selected according to the microinstruction cache hit rate of each of the multiple threads, including: sorting the multiple threads according to the microinstruction cache hit rate of each of the multiple threads, and preferentially excluding the object thread with the lowest microinstruction cache hit rate among the multiple threads in turn, and calculating the total microinstruction cache hit rate of the remaining threads after excluding the object thread, until the total microinstruction cache hit rate of the remaining threads is higher than or equal to the hit rate threshold; and taking the remaining threads corresponding to the case where the total microinstruction cache hit rate of the remaining threads is higher than or equal to the hit rate threshold as the target threads.

[0011] For example, in the resource allocation method provided in an embodiment of the present disclosure, the hit information of the microinstructions of the multiple threads within the sampling window hitting the microinstruction cache is obtained, including: monitoring a first number of microinstructions from the decoder and a second number of microinstructions from the microinstruction cache of each of the multiple threads, the first number and the second number being used as the hit information.

[0012] For example, in a resource allocation method provided in an embodiment of the present disclosure, the sampling window includes a number of clock cycles within a preset range.

[0013] For example, in a resource allocation method provided in an embodiment of the present disclosure, the allocation of resources of the microinstruction cache is controlled according to the regulation strategy, including: within a regulation window after the end of the sampling window, the allocation of resources of the microinstruction cache is controlled according to the regulation strategy.

[0014] For example, in a resource allocation method provided by an embodiment of the present disclosure, within the sampling window, target microinstructions in the microinstructions of each of the multiple threads are stored in the microinstruction cache.

[0015] For example, in a resource allocation method provided in an embodiment of the present disclosure, the sampling window and the control window are used as a control cycle, and the method further includes: at the end of a control cycle, the number of cycles of the clock cycle is recounted.

[0016] For example, in a resource allocation method provided in an embodiment of the present disclosure, the time length of the control window is the same as the time length of the sampling window.

[0017] For example, in a resource allocation method provided in an embodiment of the present disclosure, the target microinstructions are obtained by decoding the core instructions of each thread, wherein each thread includes the core instructions and non-core instructions, and the importance of the core instructions is greater than that of the non-core instructions.

[0018] At least one embodiment of the present disclosure provides a processor configured to execute multiple threads concurrently, the processor comprising: a microinstruction cache; a monitor and a controller. The monitor is coupled to the microinstruction cache and configured to obtain hit information of the microinstructions of the multiple threads hitting the microinstruction cache within a sampling window, and determine a control strategy based on the hit information; and the controller is coupled to the microinstruction cache and the monitor and configured to obtain the control strategy provided by the monitor, and control the allocation of resources of the microinstruction cache based on the control strategy.

[0019] For example, the processor provided in one embodiment of the present disclosure also includes: a decoder, coupled to the monitor, and configured to decode the instructions of each thread to obtain microinstructions of each thread; the monitor is configured to obtain a first number of microinstructions from the decoder for each of the multiple threads and a second number of microinstructions from the microinstruction cache, and the first number and the second number are used as the hit information.

[0020] For example, a processor provided in an embodiment of the present disclosure further includes: a buffer, an input end of the buffer is coupled to an output end of the controller, an output end of the buffer is coupled to the microinstruction cache, the buffer includes multiple buffers, the multiple buffers correspond one-to-one to the microinstructions of the multiple threads, and are configured to store the microinstructions of the multiple threads, the buffer is configured to write the microinstructions in the buffer into the microinstruction cache, the decoder is also coupled to the input end of the controller, and the controller is configured to: control whether the microinstructions of the current thread among the multiple threads provided by the decoder are written into the buffer corresponding to the current thread according to the control strategy.

[0021] At least one embodiment of the present disclosure provides an electronic device, including the processor provided by any embodiment of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings of the embodiments will be briefly introduced below. Obviously, the drawings in the following description only relate to some embodiments of the present disclosure, but are not intended to limit the present disclosure.

[0023] Figure 1 A flowchart of the CPU in SMT mode is shown;

[0024] Figure 2 A flow chart of a resource allocation method provided by at least one embodiment of the present disclosure is shown;

[0025] Figure 3 At least one embodiment of the present disclosure provides a Figure 2 The method flow chart of step S20 in FIG.

[0026] Figure 4 A flowchart of another resource allocation method provided by at least one embodiment of the present disclosure is shown;

[0027] Figure 5 A schematic diagram of a processor provided by at least one embodiment of the present disclosure is shown;

[0028] Figure 6 A schematic diagram showing a microstructure of a processor provided by at least one embodiment of the present disclosure;

[0029] Figure 7 A schematic block diagram of an electronic device provided for some embodiments of the present disclosure; and

[0030] Figure 8 A schematic block diagram of another electronic device provided for some embodiments of the present disclosure. DETAILED DESCRIPTION

[0031] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution of the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings of the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, not all of the embodiments. Based on the described embodiments of the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present disclosure.

[0032] Unless otherwise defined, the technical terms or scientific terms used in the present disclosure should be understood by people with ordinary skills in the field to which the present disclosure belongs. The "first", "second" and similar words used in the present disclosure do not indicate any order, quantity or importance, but are only used to distinguish different components. Similarly, similar words such as "one", "one" or "the" do not indicate quantity restrictions, but indicate that there is at least one. Similar words such as "include" or "comprise" mean that the elements or objects appearing before the word cover the elements or objects listed after the word and their equivalents, without excluding other elements or objects. Similar words such as "connect" or "connected" are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.

[0033] Multithreading technology includes, for example, Simulate Multi-Threading (SMT). SMT, also known as Hyper-Threading, can make a single physical CPU core look like two or more independent processors. In this way, the processor can handle multiple tasks at the same time, greatly improving the efficiency of CPU use. SMT technology is an important technology to improve the overall performance of the CPU. It uses the multi-issue and out-of-order execution mechanisms of high-performance CPU cores to execute instructions of multiple threads simultaneously, so that a physical CPU core is presented to the software and operating system as multiple virtual CPU cores. When a modern multi-issue high-performance CPU core executes a single thread, its internal multiple execution units and hardware resources cannot be fully utilized most of the time; when the thread is paused for some reason (such as a miss in the secondary cache), the hardware execution unit can only run idle, which causes a waste of hardware resources and reduces the performance-to-power ratio. In SMT mode, when a thread is paused, other threads can still run, which improves the utilization of hardware resources, thereby improving the multi-threaded throughput, overall performance and performance-to-power ratio of the CPU core. Depending on the maximum number of active threads supported, SMT can be called SMT2 (up to two active threads), SMT4 (up to four active threads), and so on.

[0034] The CPU core includes multiple pipeline stages, such as branch prediction, instruction fetch, instruction decoding, instruction dispatch and rename, instruction execution, and instruction retirement.

[0035] Modern high-performance CPUs often have instruction caches (IC) and micro-instruction caches (OC). IC is used to cache undecoded instructions, and OC is used to cache micro-instructions. Micro-instructions are one or more micro-instructions that are decoded into instructions, which can be passed to subsequent pipelines and executed. When the instruction fetch pipeline finds that the instruction exists in the IC or OC based on the results of the branch prediction pipeline, it can directly obtain the undecoded instructions or micro-instructions (decoded instructions) from these two caches to avoid the high latency caused by accessing the lower-level storage area. In addition, obtaining micro-instructions directly from the OC can reduce the process of fetching undecoded instructions from the IC and decoding them, and can obtain higher instruction issuance bandwidth and faster running speed, thereby improving CPU core performance and effectively reducing power consumption.

[0036] OC is an important component of modern high-performance CPU cores. Using it can effectively reduce the CPU core pipeline front-end latency, reduce power consumption, and increase the value bandwidth, which is of great help to CPU core performance and power consumption. When the branch prediction unit provides new instruction segment information, if the corresponding instruction segment is found in the OC, there is no need to fetch instructions from the instruction cache (IC) and then decode them. Instead, the corresponding micro-operation segment is directly obtained from the OC and provided to the back-end pipeline.

[0037] Figure 1 A flowchart of the CPU's operation in SMT mode is shown.

[0038] like Figure 1 As shown, the operation of the CPU in the SMT mode includes steps S101 to S109.

[0039] Step S101: The branch predictor performs thread arbitration and selects the thread (thread 0 or thread 1) on the pipeline of the current clock cycle to the branch prediction pipeline for branch prediction, thereby obtaining a branch prediction result. Branch prediction is used to predict the target address of the branch instruction. The branch prediction result includes, for example, branch prediction information (Branch PredictionInfo, BPI), that is, the prediction information output by the branch predictor, including the target address of the instruction, the thread tag, the starting position of the storage space, etc. A BPI may include one or more consecutive instructions. For example, the SMT mode includes two active threads, thread 0 and thread 1. For example, the branch predictor performs arbitration according to polling or other methods to select the thread on the pipeline of the current clock cycle.

[0040] Step S102: Write the BPI into the branch prediction result acquisition queue of the corresponding thread. For example, if the branch predictor selects thread 0 for branch prediction in step S101, the BPI is written into the branch prediction result acquisition queue of thread 0. If the branch predictor selects thread 1 for branch prediction in step S101, the BPI is written into the branch prediction result acquisition queue of thread 1.

[0041] Step S103: The instruction cache performs thread arbitration, selects the thread (thread 0 or thread 1) on the pipeline of the current clock cycle, and sequentially obtains the BPI from the branch prediction result acquisition queue corresponding to the thread. If the thread selected by the instruction cache for thread arbitration has not been cached in the microinstruction cache 110, then the BPI is sent to the pipeline of the instruction cache, and the pipeline of the instruction cache is responsible for obtaining undecoded instructions from the instruction cache, and the instruction cache provides the obtained undecoded instructions to the decoder. For example, if the thread on the pipeline of the current clock cycle selected by the instruction cache is thread 1, then the BPI is sequentially obtained from the branch prediction result acquisition queue of thread 1, and the BPI is sent to the pipeline of the instruction cache, thereby obtaining the undecoded instructions of thread 1 from the instruction cache, and providing the undecoded instructions of thread 1 to the decoder. Similarly, the thread on the pipeline of the current clock cycle selected by the instruction cache may also be thread 0. For example, the instruction cache selects the thread on the pipeline of the current clock cycle by arbitration in a polling manner or other manner. If the BPI obtained by the thread selected by the instruction cache through thread arbitration has been cached in the microinstruction cache 110, the step jumps to the subsequent step S108.

[0042] Step S104: The decoder decodes the undecoded instruction into a microinstruction (UOP), and sends the decoded UOP to the microinstruction queue corresponding to the thread for back-end execution. For example, the decoder decodes the undecoded instruction of thread 0 to obtain the UOP of thread 0, and then the decoder provides the UOP of thread 0 to the microinstruction queue of thread 0, so that the UOP of thread 0 enters the microinstruction queue of thread 0.

[0043] Step S105: The decoder provides UOPs to the buffer at the same time. For example, the buffer includes multiple buffers, and the multiple buffers correspond to multiple threads one by one, and each buffer is used to store the UOPs of one thread. In step S105, the decoder performs arbitration and selects the buffer corresponding to which thread in the buffer the UOP obtained by the decoder is written to. For example, if the decoder obtains the UOP of thread 0, the decoder arbitrates and writes the UOP provided by the decoder into the buffer of thread 0.

[0044] For example, while the decoder provides the UOP of a certain thread to the microinstruction queue of the thread, it also performs decoder arbitration and writes the UOP of the thread into the buffer corresponding to the thread.

[0045] Step S106: The UOP of each thread accumulates multiple instructions in the buffer to form a microinstruction item.

[0046] Step S107: The pipeline of the microinstruction cache performs thread arbitration, selects the thread of the pipeline of the current clock cycle, takes out the microinstruction cache item that has been formed by the thread from the buffer, and writes it into the microinstruction cache 110. For example, if the thread of the pipeline of the current clock cycle selected by the pipeline of the microinstruction cache 110 through thread arbitration is thread 1, the microinstruction cache item that has been formed by thread 1 is taken out from the buffer and written into the microinstruction cache 110.

[0047] Step S108: The microinstruction acquisition queue stores the BPI provided by the instruction cache. For example, if the BPI obtained by the thread selected after the instruction cache arbitration from the branch prediction result acquisition queue has been cached in the microinstruction cache 110, the BPI of the thread will no longer be sent to the instruction cache pipeline and decoder, but directly to the microinstruction acquisition queue of the corresponding thread.

[0048] For example, the BPI of thread 1 selected after instruction cache arbitration has been cached in the microinstruction cache 110, so the BPI of thread 1 is no longer provided to the instruction cache pipeline and decoder, but to the microinstruction acquisition queue of thread 1, so that the microinstruction acquisition queue of thread 1 stores the BPI of thread 1.

[0049] Step S109: The pipeline of the microinstruction cache performs thread arbitration, selects the thread of the current clock cycle pipeline, obtains BPI information from the microinstruction acquisition queue of the thread, searches for the corresponding UOP in the microinstruction cache, and sends the UOP to the corresponding microinstruction queue for use in back-end execution.

[0050] For example, the pipeline of the microinstruction cache 110 performs thread arbitration and selects the thread of the pipeline in the current clock cycle as thread 0. Then, the BPI information is obtained from the microinstruction acquisition queue of thread 0, the corresponding UOP is found, and the UOP is sent to the corresponding microinstruction queue for use in back-end execution.

[0051] In this workflow, the microinstructions in the microinstruction queue of each thread may come from the decoder or from the microinstruction cache.

[0052] As described above, when filling the microinstruction cache, multiple threads share the entire microinstruction cache space, which means that multiple threads compete with each other for microinstruction cache resources. Since different threads of the processor run different program codes, different threads have different requirements for microinstruction cache resources.

[0053] Since the capacity of the microinstruction cache is limited, under the condition of limited microinstruction cache capacity, the competition for microinstruction cache resources under this multi-threading situation may cause multiple threads to fail to achieve a relatively high microinstruction cache hit rate, resulting in low utilization of the microinstruction cache.

[0054] In view of the problem of reduced microinstruction cache utilization caused by competition for microinstruction cache resources among multiple threads in current processors, the present disclosure provides a resource allocation method, which can monitor the microinstruction cache utilization of multiple threads from the perspective of the entire CPU core, form a feedback mechanism based on the monitoring results, and dynamically control the resource occupation of the microinstruction cache by different threads, thereby improving the overall hit rate of the microinstruction cache.

[0055] The resource allocation method is applied to a processor. The processor is configured to execute multiple threads concurrently, and the processor includes a microinstruction cache. The method includes: obtaining hit information of the microinstructions of multiple threads in a sampling window hitting the microinstruction cache; determining a regulation strategy based on the hit information; and controlling the allocation of resources of the microinstruction cache based on the regulation strategy. The embodiments of the present disclosure at least partially solve the problem that multiple threads compete with each other for OC resources, resulting in a low overall OC hit rate, which can not only accelerate the running speed of the entire CPU, but also save power consumption.

[0056] Figure 2 A flowchart of a resource allocation method provided by at least one embodiment of the present disclosure is shown.

[0057] like Figure 2 As shown, the resource allocation method includes steps S201 to S203. The resource allocation method is applied to a processor, and the processor is configured to execute multiple threads concurrently, for example, the processor executes multiple threads concurrently according to the SMT mode. The processor includes a microinstruction cache. The microinstruction cache includes multiple cached microinstructions.

[0058] Step S201: Obtain hit information of microinstructions of multiple threads within a sampling window hitting a microinstruction cache.

[0059] Step S202: Determine the control strategy according to the hit information.

[0060] Step S203: Control the allocation of microinstruction cache resources according to the regulation strategy.

[0061] For step S201, a microinstruction hit in the microinstruction cache means that the microinstruction has been cached in the microinstruction cache. Figure 1 The description can determine whether the microinstruction has been cached in the microinstruction cache based on the BPI. If the microinstruction has been cached in the microinstruction cache, the microinstruction is directly provided by the microinstruction cache item microinstruction queue without going through the decoder to provide the microinstruction to the microinstruction queue.

[0062] For example, within the adoption window, a first number of microinstructions from a decoder and a second number of microinstructions from a microinstruction cache of each of the multiple threads are monitored, and the first number and the second number are used as hit information. Figure 1 In an example, it may be possible to monitor which microinstructions in the microinstruction queues of thread 0 and thread 1 are from the decoder and which are from the microinstruction cache within the adoption window, and to count the number of microinstructions from the decoder and the number of microinstructions from the microinstruction cache in the microinstruction queue of thread 0 and the microinstruction queue of thread 1 respectively.

[0063] In some embodiments of the present disclosure, a sampling window is set to collect the hit information of the microinstructions of each thread hitting the microinstruction cache within the sampling window. The sampling window, for example, includes the number of clock cycles within a preset range. For example, the sampling window includes a preset number of clock cycles, in which the preset number is an example of a preset range. For example, every 500 clock cycles is used as a sampling window, that is, the number of clock cycles in [0,499] is used as a sampling window. In other embodiments, the sampling window may also be a preset number of instructions.

[0064] For example, 1000 clock cycles are used as a sampling window, and the hit information of microinstructions of multiple threads hitting the microinstruction cache in 1000 clock cycles is collected. For another example, 50,000 instructions are used as a sampling window, that is, the preset number of instructions is 50,000. After collecting a total of 50,000 microinstructions from multiple threads, the number of microinstructions from the decoder and the number of microinstructions in the microinstruction cache, as well as the thread to which each microinstruction belongs, are counted.

[0065] For step S202, the control strategy includes, for example, whether to store microinstructions of multiple threads in the microinstruction cache, or which threads' microinstructions are stored in the microinstruction cache. For example, according to the hit information, a target thread is selected from the multiple threads, and the control strategy is to store only the microinstructions of the target thread in the microinstruction cache.

[0066] For step S203, the resources of the microinstruction cache include the storage space of the microinstruction cache. For example, if the control strategy is to store only the microinstructions of the target thread in the microinstruction cache, the storage space of the microinstruction cache is controlled to store only the microinstructions of the target thread.

[0067] For example, if the number of core instructions of one thread among the multiple threads is large, the microinstructions of the thread may not be stored in the microinstruction cache.

[0068] Figure 3 At least one embodiment of the present disclosure provides a Figure 2 Flow chart of the method of step S20 in FIG.

[0069] like Figure 3 As shown, the method includes steps S212 to S232.

[0070] Step S212: Calculate the microinstruction cache hit rate of each of the multiple threads according to the hit information, where the microinstruction cache hit rate indicates the proportion of microinstructions that hit the microinstruction cache in each thread to all microinstructions of each thread in the sampling window.

[0071] Step S222: Calculate the total hit rate of the microinstruction cache of the multiple threads according to the hit information, where the total hit rate of the microinstruction cache indicates the proportion of the microinstructions that hit the microinstruction cache of the multiple threads in all the microinstructions of the multiple threads in the sampling window.

[0072] Step S232: Generate a control strategy based on the microinstruction cache hit rate of each of the multiple threads and the total microinstruction cache hit rate.

[0073] The method dynamically controls the occupation of microinstruction cache resources by different threads according to the microinstruction cache hit rate of each thread and the total microinstruction cache hit rate, thereby improving the overall hit rate of the microinstruction cache.

[0074] For step S212 , for example, in the SMT mode, including concurrently executed threads 0 and 1 , the microinstruction cache hit rate of thread 0 and the microinstruction cache hit rate of thread 1 are calculated according to the hit information.

[0075] The microinstruction cache hit rate is, for example, the ratio of the number of microinstructions that hit the microinstruction cache among all microinstructions of the thread (e.g., thread 0 or thread 1) obtained within the sampling window to the number of all microinstructions of the thread. For example, if P1 microinstructions of a thread are obtained within the sampling window, of which m1 microinstructions hit the microinstruction cache, then the microinstruction cache hit rate of the thread is Y1=m1 / P1.

[0076] For example, if 1000 microinstructions of thread 0 are obtained in the sampling window, 200 of which hit the microinstruction cache, then the microinstruction cache hit rate of thread 0 is 20%. For example, if 1500 microinstructions of thread 1 are obtained in the sampling window, 450 of which hit the microinstruction cache, then the microinstruction cache hit rate of thread 1 is 30%.

[0077] For step S222, the total hit rate of the microinstruction cache of multiple threads refers to the proportion of microinstructions that hit the microinstruction cache in the multiple threads as a whole. For example, in the sampling window, a total of P microinstructions of multiple threads are obtained, and m of the P microinstructions hit the microinstruction cache, then the total hit rate of the microinstruction cache Y=m / P.

[0078] For example, in the sampling window, a total of 1000 microinstructions of thread 0 and 2000 microinstructions of thread 1 are obtained, so the total number of microinstructions is 3000. Among these 3000 microinstructions, a total of 650 microinstructions (200 microinstructions of thread 0 and 450 microinstructions of thread 1) hit the microinstruction cache, and the total hit rate of the microinstruction cache is 650 / 3000≈21.67%.

[0079] For step S232, a regulation strategy is generated based on the microinstruction cache hit rate and the total microinstruction cache hit rate.

[0080] For example, a regulation strategy is generated according to the microinstruction cache hit rate Y1 of each of the multiple threads and the total microinstruction cache hit rate Y.

[0081] The control policy is used, for example, to indicate which threads' microinstructions are to be written into (also referred to as "filled") the microinstruction cache and which threads' microinstructions are not to be written into the microinstruction cache.

[0082] For example, based on the microinstruction cache hit rate Y1 of each of the multiple threads and the total microinstruction cache hit rate Y, threads with lower microinstruction cache hit rates are selected, and these threads are excluded to obtain the target thread. The control strategy in this case is, for example, to write the microinstructions of the specified target thread into the microinstruction cache.

[0083] In some embodiments of the present disclosure, step S232 includes: in response to the total hit rate of the microinstruction cache being higher than or equal to a hit rate threshold, determining a control strategy including storing the target microinstructions in the microinstructions of each of the multiple threads into the microinstruction cache; in response to the total hit rate of the microinstruction cache being lower than the hit rate threshold, determining a control strategy based on the microinstruction cache hit rate of each of the multiple threads.

[0084] For example, if the total hit rate Y of the microinstruction cache is ≥ the hit rate threshold Y0, the control strategy includes storing the target microinstructions in the microinstructions of each of the multiple threads into the microinstruction cache, that is, each of the multiple threads is used as a target thread, and the target microinstructions of the target thread are stored in the microinstruction cache.

[0085] In some embodiments of the present disclosure, the target micro-instructions are obtained by decoding the core instructions of each thread. Each thread includes core instructions and non-core instructions, and the importance level of the core instructions is higher than that of the non-core instructions. Only storing the micro-instructions obtained by decoding the core instructions of the target thread into the micro-instruction cache, rather than storing all the micro-instructions of the target thread into the micro-instruction cache, can save the storage space of the micro-instruction cache for other threads to use. The importance level of an instruction is characterized by, for example, the number of times the instruction is executed during the complete execution of the program. The more times an instruction is executed, the higher its importance level. For example, a program often includes a loop body, and the instructions in the loop body are often executed multiple times. Then, the importance level of the instructions in the loop body is higher than that of the instructions outside the loop body. In some embodiments of the present disclosure, the core instructions are, for example, the instructions (i.e., loop instructions) in the loop body, and the non-core instructions are the instructions outside the loop body. Or, the core instructions are, for example, the instructions that are executed more than once during the complete execution of the program, and the non-core instructions are the instructions that are executed only once during the complete execution of the program.

[0086] For example, if the overall hit rate Y of the micro-instruction cache is less than Y0, a regulation strategy is determined based on the micro-instruction cache hit rates and the hit rate threshold of each of the multiple threads.

[0087] For example, each micro-instruction cache hit rate Y1 is compared with the hit rate threshold Y0 to determine the micro-instruction cache hit rate Y1 that is greater than the hit rate threshold Y0. The threads with Y1 > Y0 are taken as the target threads, and the regulation strategy includes storing the target micro-instructions of these target threads into the micro-instruction cache.

[0088] In some embodiments of the present disclosure, in response to the overall hit rate Y of the micro-instruction cache being lower than the hit rate threshold Y0, target threads are selected from the micro-instruction cache hit rates Y1 of each of the multiple threads where the micro-instruction cache hit rate Y1 meets the conditions; and it is determined that the regulation strategy includes writing the micro-instructions of the target threads into the micro-instruction cache, and not writing the micro-instructions of the remaining threads other than the target threads among the multiple threads into the micro-instruction cache.

[0089] The target threads where the micro-instruction cache hit rate Y1 meets the conditions are, for example, the target threads where the micro-instruction cache hit rate Y1 is lower than the preset hit rate. The preset hit rate can be set by those skilled in the art. Or, the multiple micro-instruction cache hit rates Y1 are sorted from smallest to largest, and the threads after the preset position in the sorting are the target threads that meet the conditions.

[0090] In some embodiments of the present disclosure, for example, in response to the overall hit rate Y of the micro-instruction cache being lower than the hit rate threshold Y0, the object thread with the lowest micro-instruction cache hit rate Y1 among the multiple threads is excluded to obtain the target threads.

[0091] In some other embodiments of the present disclosure, for example, multiple threads are sorted according to the micro-instruction cache hit rate of each of the multiple threads, and the object thread with the lowest micro-instruction cache hit rate among the multiple threads is preferentially excluded in sequence, and the total micro-instruction cache hit rate of the remaining threads after excluding the object thread is calculated until the total micro-instruction cache hit rate of the remaining threads is higher than or equal to the hit rate threshold; and the remaining threads corresponding to the case where the total micro-instruction cache hit rate of the remaining threads is higher than or equal to the hit rate threshold are used as target threads.

[0092] For example, the processor concurrently executes 4 threads, namely thread 1, thread 2, thread 3, and thread 0; the micro-instruction cache hit rates of these 4 threads are Y11, Y12, Y13, and Y10 respectively, and the total micro-instruction cache hit rate of these 4 threads is Y. If Y < Y0, then the threads 1, 2, 3, and 0 are sorted according to the magnitudes of Y11, Y12, Y13, and Y10. For example, the sorting result in ascending order is thread 1, thread 2, thread 0, and thread 3. After excluding the preceding thread 1, the total micro-instruction cache hit rate Y' of the remaining threads (thread 2, thread 0, and thread 3) is calculated. If Y' < Y0, then thread 2 is continuously excluded, and the total micro-instruction cache hit rate Y'' of the remaining threads (thread 0 and thread 3) is calculated. If Y'' ≥ Y0, then thread 0 and thread 3 are used as target threads. If Y'' < Y0, then thread 0 is continuously excluded until the total micro-instruction cache hit rate of the remaining threads is greater than or equal to the hit rate threshold.

[0093] In the embodiments of the present disclosure, those skilled in the art can set the hit rate threshold according to actual needs, and the present disclosure does not specifically limit the hit rate threshold. For example, the hit rate threshold can be 50%.

[0094] In some embodiments of the present disclosure, Figure 2 step S203 in the method includes: within the regulation window after the end of the sampling window, controlling the allocation of resources of the micro-instruction cache according to the regulation strategy. In some embodiments of the present disclosure, the size of the regulation window may be the same as the size of the sampling window. For example, if the number of clock cycles of the sampling window is within a preset range, then the time length of the regulation window is the same as the time length of the sampling window.

[0095] In some other embodiments of the present disclosure, the size of the regulation window may not be the same as the size of the sampling window.

[0096] In some embodiments of the present disclosure, within the sampling window, the target micro-instructions in the micro-instructions of each of the multiple threads are all stored in the micro-instruction cache.

[0097] In some embodiments of the present disclosure, the sampling window and the regulation window are used as a regulation period, and the method further includes: at the end of a regulation period, the number of clock cycles is recounted.

[0098] Combine the following Figure 4 The present disclosure is described as an embodiment of resource allocation.

[0099] Figure 4 A flowchart of another resource allocation method provided by at least one embodiment of the present disclosure is shown.

[0100] like Figure 4 As shown, the resource allocation method includes steps S401 to S412.

[0101] Step S401: Count the clock cycles, and increase the count value of each clock cycle by a preset step length, where the preset step length is, for example, 1. Of course, the preset step length may also be other positive integers such as 2 or 3.

[0102] Step S402: Compare the count value at this time with the clock threshold. The clock threshold determines the sampling window. For example, if the clock threshold is 500, the sampling window is the clock cycle with a count value of [0,500]. For example, compare the count value at this time with 500. For example, if the count value ≤ the clock threshold, execute step S404; if the clock threshold < count value < 2×clock threshold, execute step S403; if the count value = clock threshold, execute step S405.

[0103] Step S403: The count value is cleared to 0 and the next sampling window is restarted. If the clock threshold < count value < 2×clock threshold, the count value is cleared to 0, that is, the time length of the control window is the same as the time length of the sampling window, both of which are 500 clock cycles, and at the end of a control cycle, the number of cycles of the clock cycle is recounted.

[0104] Step S404: Thread 0 and Thread 1 are both filled into the microinstruction cache. That is, when the count value does not reach the clock threshold, the microinstructions of each thread are filled into the microinstruction cache. That is, within the sampling window, the target microinstructions in the microinstructions of each of the multiple threads are stored in the microinstruction cache, and the multiple threads compete for resources. After executing step S404, step S412 is directly performed.

[0105] Step S405: when the count value is equal to the clock threshold, obtain the microinstruction cache hit rate Y10 of thread 0, the microinstruction cache hit rate Y11 of thread 1 and the total microinstruction cache hit rate Y to generate a control strategy according to the above hit rates.

[0106] It should be noted that, in this embodiment, the concurrent execution of two threads (thread 0 and thread 1) is taken as an example to illustrate the implementation method, but this has no limiting effect on the present disclosure.

[0107] In the above embodiment, as shown in the algorithm, each clock cycle is incremented by 1. When the count value is less than the clock threshold, all threads are normally filled into the microinstruction cache, and everyone competes for resources; at the same time, the hit information of each overall microinstruction cache within the sampling window of the clock threshold is monitored. When the count value is equal to the clock threshold, a decision is made based on the hit information. That is, within the control window after the end of the sampling window, the allocation of resources of the microinstruction cache is controlled according to the control strategy, and within the sampling window, the target microinstructions in the microinstructions of each of the multiple threads are stored in the microinstruction cache. In the above example,

[0108] Step S406: Determine whether the total microinstruction cache hit rate Y is less than the hit rate threshold. If the total microinstruction cache hit rate Y is less than the hit rate threshold, execute step S407; if the total microinstruction cache hit rate Y is not less than the hit rate threshold, execute step S410.

[0109] Step S407: Compare the microinstruction cache hit rate Y10 of thread 0 and the microinstruction cache hit rate Y11 of thread 1. If Y10>Y11, execute step S409; if Y10≤Y11, execute step S408.

[0110] Step S408: Fill the microinstructions of thread 1 into the microinstruction cache.

[0111] Step S409: Fill the microinstructions of thread 0 into the microinstruction cache.

[0112] Step S410: Fill the microinstructions of thread 0 and thread 1 into the microinstruction cache.

[0113] Step S411: Generate a control strategy. The control strategy, for example, includes the results obtained in steps S408 to S410.

[0114] Step S412: Control the resource allocation of the microinstruction cache according to the regulation strategy.

[0115] exist Figure 4 In the example, if the overall microinstruction cache hit rate (i.e., the total microinstruction cache hit rate Y) is higher than the hit rate threshold, the control strategy is to continue to fill the microinstructions of all threads into the microinstruction cache at the same time; if the overall microinstruction cache hit rate is lower than the hit rate threshold, a control strategy decision is generated based on the microinstruction cache hit rate of each thread. The control strategy is, for example, to stop filling the thread with the lowest microinstruction cache hit rate into the microinstruction cache.

[0116] The embodiment of the present disclosure proposes a method for allocating microinstruction cache resources in a concurrent multithreading mode, which solves the problem that multiple threads compete for microinstruction cache resources, resulting in a low overall microinstruction cache hit rate. This not only speeds up the running speed of the entire CPU, but also saves power consumption.

[0117] Another aspect of the present disclosure provides a processor configured to execute multiple threads concurrently. The processor includes: a microinstruction cache, a monitor, and a controller. The monitor is coupled to the microinstruction cache, and is configured to obtain hit information of microinstructions of multiple threads in a sampling window hitting the microinstruction cache, and to determine a control strategy based on the hit information; the controller is coupled to the microinstruction cache and the monitor, and is configured to obtain the control strategy provided by the monitor, and to control the allocation of resources of the microinstruction cache based on the control strategy. The processor can at least partially solve the problem that multiple threads compete with each other for microinstruction cache resources, resulting in a low overall microinstruction cache hit rate, which can not only accelerate the running speed of the entire CPU, but also save power consumption.

[0118] The embodiment of the present disclosure proposes a processor for allocating microinstruction cache resources in a concurrent multithreaded mode. The processor can, for example, add a monitor before the microinstruction queue and a controller before the microinstruction cache, wherein the monitor is used to generate a control strategy based on hit information, and the controller is used to control the resource allocation of the microinstruction cache based on the control strategy.

[0119] It should be noted that although the embodiments of the present disclosure illustrate the disclosed implementation method by executing two threads (thread 0 and thread 1) in parallel, this has no limiting effect on the present disclosure, and the resource allocation method provided by the present disclosure can be applied to the concurrent execution of any number of threads.

[0120] Figure 5 A schematic diagram of a processor 500 provided by at least one embodiment of the present disclosure is shown.

[0121] like Figure 5 As shown, the processor 500 includes a microinstruction cache 501 , a controller 502 , and a monitor 503 .

[0122] The monitor 503 is coupled to the microinstruction cache 501 and is configured to obtain hit information of the microinstructions of multiple threads in the sampling window hitting the microinstruction cache, and determine the control strategy according to the hit information. Figure 2 Steps S201 and S202 in .

[0123] The controller 502 is coupled to the microinstruction cache 501 and the monitor 503, and is configured to obtain the control strategy provided by the monitor 503, and control the allocation of resources of the microinstruction cache according to the control strategy. Figure 2 Step S203 in .

[0124] Please refer to the above description for the microinstruction cache 501. The controller 502 and the monitor 503 can be hardware, software, firmware, and any feasible combination thereof. For example, the controller 502 and the monitor 503 can be dedicated or general circuits, chips, or devices, etc. Regarding the specific implementation form of each of the above-mentioned units, the embodiments of the present disclosure do not limit this. The controller 502 and the monitor 503 correspond to the various steps of the aforementioned resource allocation method. For the specific functions of the controller 502 and the monitor 503, please refer to the relevant description of the resource allocation method, which will not be repeated here.

[0125] Figure 6 A schematic diagram of a microstructure of a processor provided by at least one embodiment of the present disclosure is shown.

[0126] like Figure 6 As shown, the processor includes a decoder 603 in addition to a microinstruction cache 601 , a controller 602 and a monitor 605 .

[0127] The microinstruction cache 601, the controller 602 and the monitor 605 are similar to the above Figure 5 The microinstruction cache 501, controller 502 and monitor 503 in FIG. 601 are similar to those in FIG. Figure 1 The microinstruction cache 110 in is similar.

[0128] The decoder 603 is coupled to the monitor 605 and is configured to decode the instructions of each thread to obtain the microinstructions of each thread; the monitor 605 is configured to obtain a first number of microinstructions from the decoder 603 and a second number of microinstructions from the microinstruction cache 601 for each of the multiple threads, and the first number and the second number are used as hit information.

[0129] like Figure 6 As shown, the processor may also include a buffer 604 .

[0130] The input end of the buffer 604 is coupled to the output end of the controller 602, and the output end of the buffer 604 is coupled to the microinstruction cache 601. The buffer includes multiple buffers, and the multiple buffers correspond one-to-one to the microinstructions of multiple threads. The buffer is configured to store the microinstructions of multiple threads, and the buffer is configured to write the microinstructions in the buffer into the microinstruction cache.

[0131] The decoder 603 is also coupled to the input end of the controller 602. The controller is configured to control whether the microinstructions of the current thread among the multiple threads provided by the decoder 603 are written into the buffer corresponding to the current thread according to the regulation strategy.

[0132] In this embodiment, the controller 602 first writes the target microinstructions of the target thread into the buffer corresponding to the target thread in the buffer 604 according to the regulation strategy. After a certain number of microinstruction cache items are accumulated in the buffer, they are taken out from the buffer according to the arbitration of the microinstruction cache 601 and stored in the microinstruction cache 601.

[0133] For example, the controller 602 obtains the microinstructions of thread 0 from the decoder 603, and determines whether the microinstructions of thread 0 are stored in the buffer corresponding to thread 0 according to the control strategy. If the microinstructions of thread 0 are stored in the buffer corresponding to thread 0, step S601 is executed, that is, the controller 602 arbitrates to store thread 0 in the buffer corresponding to thread 0.

[0134] like Figure 6 As shown, the microstructure of the processor includes the controller 602 and the monitor 605, which are outlined by the oval dotted line, and the arbitration of step S601 performed by the controller. The other structures and processes are similar to those of FIG. Figure 1 similar.

[0135] Figure 5 and Figure 6 The components and structures of the processor shown are merely exemplary and non-limiting. The processor may further include other components and structures as required.

[0136] The specific implementation forms of the above-mentioned units can be hardware, software, firmware, and any feasible combination thereof, which is not limited in the embodiments of the present disclosure.

[0137] It should be noted that the embodiments of the present disclosure are not only applicable to the SMT mode, but also to other concurrent multi-threaded execution modes. As long as the processor concurrently executes multiple threads, the resource allocation method provided by the embodiments of the present disclosure can be used.

[0138] Another aspect of the present disclosure provides an electronic device, which includes the process provided by any embodiment of the present disclosure.

[0139] Figure 7 A schematic block diagram of an electronic device provided in some embodiments of the present disclosure. Figure 7 As shown, the electronic device 700 includes a processor 710 and a memory 720. The memory 720 is used to store non-transitory computer-readable instructions (e.g., one or more computer program modules). The processor 710 is used to run non-transitory computer-readable instructions, and when the non-transitory computer-readable instructions are run by the processor 710, one or more steps in the resource allocation method described above can be executed. The memory 720 and the processor 710 can be interconnected through a bus system and / or other forms of connection mechanisms (not shown).

[0140] The processor 701 may be a processor provided by any embodiment of the present disclosure, for example, the microstructure of the processor 701 is similar to Figure 6 The microstructure of the processor in is similar.

[0141] For example, the processor 710 may be a central processing unit (CPU), a graphics processing unit (GPU), or other forms of processing units having data processing capabilities and / or program execution capabilities. For example, the central processing unit (CPU) may be an X86 or ARM architecture, etc. The processor 710 may be a general-purpose processor or a dedicated processor, and may control other components in the electronic device 700 to perform desired functions.

[0142] For example, the memory 720 may include any combination of one or more computer program products, and the computer program product may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. Volatile memory may include, for example, random access memory (RAM) and / or cache memory (cache), etc. Non-volatile memory may include, for example, read-only memory (ROM), hard disk, erasable programmable read-only memory (EPROM), portable compact disk read-only memory (CD-ROM), USB memory, flash memory, etc. One or more computer program modules may be stored on the computer-readable storage medium, and the processor 710 may run one or more computer program modules to implement various functions of the electronic device 700. Various applications and various data, as well as various data used and / or generated by the application, etc. may also be stored in the computer-readable storage medium.

[0143] It should be noted that, in the embodiment of the present disclosure, the specific functions and technical effects of the electronic device 700 can refer to the above description of the resource allocation method, which will not be repeated here.

[0144] Figure 8 This is a schematic block diagram of another electronic device provided in some embodiments of the present disclosure. The electronic device 800 is suitable for implementing the resource allocation method provided in the embodiments of the present disclosure. The electronic device 800 may be a terminal device, etc. It should be noted that: Figure 8 The electronic device 800 shown is merely an example and does not impose any limitation on the functions and scope of use of the embodiments of the present disclosure.

[0145] like Figure 8As shown, the electronic device 800 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 810, which may perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 820 or a program loaded from a storage device 880 to a random access memory (RAM) 830. The processing device 810 may be, for example, a processor provided in any embodiment of the present disclosure, such as a microstructure of the processor 810 and a processor 810 having a plurality of CPUs and CPUs. Figure 6 The microstructure of the processor in is similar.

[0146] In the RAM 830, various programs and data required for the operation of the electronic device 800 are also stored. The processing device 810, the ROM 820, and the RAM 830 are connected to each other through a bus 840. An input / output (I / O) interface 850 is also connected to the bus 840.

[0147] Typically, the following devices may be connected to the I / O interface 850: an input device 860 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 870 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 880 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 890. The communication device 890 may allow the electronic device 800 to communicate with other electronic devices wirelessly or by wire to exchange data. Although Figure 8 The electronic device 800 is shown to have various devices, but it should be understood that it is not required to implement or possess all of the devices shown, and the electronic device 800 may alternatively implement or possess more or fewer devices.

[0148] There are a few points to note:

[0149] (1) The drawings of the embodiments of the present disclosure only relate to the structures involved in the embodiments of the present disclosure, and other structures may refer to the general design.

[0150] (2) In the absence of conflict, the embodiments of the present disclosure and the features therein may be combined with each other to obtain new embodiments.

[0151] The above description is only a specific implementation of the present disclosure, but the protection scope of the present disclosure is not limited thereto. The protection scope of the present disclosure shall be based on the protection scope of the claims.

Claims

1. A resource allocation method, applied to a processor, wherein: The processor is configured to execute multiple threads concurrently, the processor includes a microinstruction cache, and the method includes: Obtaining hit information of microinstructions of the plurality of threads within a sampling window hitting the microinstruction cache; Determining a regulation strategy according to the hit information; and According to the control strategy, the allocation of resources of the microinstruction cache is controlled, The microinstruction hitting the microinstruction cache means that the microinstruction cache has already cached the microinstruction; Wherein, determining the control strategy according to the hit information includes: According to the hit information, the microinstruction cache of each of the multiple threads is calculated. The microinstruction cache hit rate indicates the number of hits in each thread. The microinstructions in the microinstruction cache are within the sampling window for each line The proportion of all microinstructions in the program; Calculating a total hit rate of the microinstruction cache of the multiple threads according to the hit information, wherein the total hit rate of the microinstruction cache indicates a proportion of the microinstructions of the multiple threads that hit the microinstruction cache in all the microinstructions of the multiple threads in the sampling window; and Generate the control strategy based on the microinstruction cache hit rate of each of the multiple threads and the total microinstruction cache hit rate; Wherein, generating the control strategy based on the microinstruction cache hit rate of each of the multiple threads and the total microinstruction cache hit rate includes: In response to the total hit rate of the microinstruction cache being higher than or equal to a hit rate threshold, determining the regulation strategy includes storing a target microinstruction in the microinstructions of each of the plurality of threads into the microinstruction cache; In response to the total microinstruction cache hit rate being lower than the hit rate threshold, determining the regulation strategy according to the microinstruction cache hit rate of each of the plurality of threads and the hit rate threshold; Wherein, in response to the total hit rate of the microinstruction cache being lower than the hit rate threshold, determining the regulation strategy according to the microinstruction cache hit rate of each of the multiple threads and the hit rate threshold, includes: Determining the control strategy includes writing the microinstructions of the target thread into the The microinstruction cache is used, and the remaining threads of the plurality of threads except the target thread are The microinstructions of the remaining threads are not written into the microinstruction cache, wherein the target thread The process includes threads whose microinstruction cache hit rates meet the conditions among the multiple threads.

2. The method according to claim 1, wherein: In response to the total microinstruction cache hit rate being lower than the hit rate threshold, determining the regulation strategy according to the microinstruction cache hit rate of each of the plurality of threads and the hit rate threshold, further comprising: In response to the total microinstruction cache hit rate being lower than the hit rate threshold, a target thread whose microinstruction cache hit rate meets the condition is selected according to the microinstruction cache hit rate of each of the multiple threads.

3. The method according to claim 2, wherein: In response to the total microinstruction cache hit rate being lower than the hit rate threshold, selecting a target thread whose microinstruction cache hit rate meets the condition according to the microinstruction cache hit rate of each of the multiple threads, including: In response to the total microinstruction cache hit rate being lower than the hit rate threshold, the object thread with the lowest microinstruction cache hit rate among the multiple threads is excluded to obtain the target thread.

4. The method according to claim 2, wherein: In response to the total microinstruction cache hit rate being lower than the hit rate threshold, selecting a target thread whose microinstruction cache hit rate meets the condition according to the microinstruction cache hit rate of each of the multiple threads, including: sorting the multiple threads according to the microinstruction cache hit rate of each of the multiple threads, preferentially excluding the target thread with the lowest microinstruction cache hit rate among the multiple threads, and calculating the total microinstruction cache hit rate of the remaining threads after excluding the target thread, until the total microinstruction cache hit rate of the remaining threads is higher than or equal to the hit rate threshold; and The remaining threads corresponding to the case where the total microinstruction cache hit rate of the remaining threads is higher than or equal to the hit rate threshold are used as the target threads.

5. The method according to claim 1, wherein: Obtaining hit information of the microinstructions of the multiple threads within the sampling window hitting the microinstruction cache, including: monitoring a first number of microinstructions from a decoder and a second number of microinstructions from a microinstruction cache for each of the plurality of threads, The first number and the second number serve as the hit information.

6. The method according to claim 1, wherein: The sampling window includes a number of clock cycles within a preset range.

7. The method according to claim 6, wherein: According to the control strategy, controlling the allocation of resources of the microinstruction cache includes: In a control window after the sampling window ends, allocation of resources of the microinstruction cache is controlled according to the control strategy.

8. The method according to claim 7, wherein: Within the sampling window, target microinstructions in the microinstructions of each of the plurality of threads are stored in the microinstruction cache.

9. The method according to claim 7, wherein: The sampling window and the control window are used as a control cycle, and the method further includes: At the end of a regulation cycle, the number of cycles of the clock cycle is re-counted.

10. The method according to claim 7, wherein: The time length of the control window is the same as the time length of the sampling window.

11. The method according to claim 1, wherein: The target microinstructions are obtained by decoding the core instructions of each thread, wherein each thread includes the core instructions and non-core instructions, and the importance of the core instructions is greater than that of the non-core instructions.

12. A processor configured to execute multiple threads concurrently, wherein: The processor comprises: Microinstruction cache; A monitor coupled to the microinstruction cache and configured to obtain hit information of microinstructions of the multiple threads hitting the microinstruction cache within a sampling window, and determine a control strategy based on the hit information; and a controller coupled to the microinstruction cache and the monitor and configured to obtain the regulation strategy provided by the monitor and control the allocation of resources of the microinstruction cache according to the regulation strategy, The microinstruction hitting the microinstruction cache means that the microinstruction cache has already cached the microinstruction; Wherein, determining the control strategy according to the hit information includes: According to the hit information, the microinstruction cache of each of the multiple threads is calculated. The microinstruction cache hit rate indicates the number of hits in each thread. The microinstructions in the microinstruction cache are within the sampling window for each line The proportion of all microinstructions in the program; Calculating a total hit rate of the microinstruction cache of the multiple threads according to the hit information, wherein the total hit rate of the microinstruction cache indicates a proportion of the microinstructions of the multiple threads that hit the microinstruction cache in all the microinstructions of the multiple threads in the sampling window; and Generate the control strategy based on the microinstruction cache hit rate of each of the multiple threads and the total microinstruction cache hit rate; Wherein, generating the control strategy based on the microinstruction cache hit rate of each of the multiple threads and the total microinstruction cache hit rate includes: In response to the total hit rate of the microinstruction cache being higher than or equal to a hit rate threshold, determining the regulation strategy includes storing a target microinstruction in the microinstructions of each of the plurality of threads into the microinstruction cache; In response to the total microinstruction cache hit rate being lower than the hit rate threshold, determining the regulation strategy according to the microinstruction cache hit rate of each of the plurality of threads and the hit rate threshold; Wherein, in response to the total hit rate of the microinstruction cache being lower than the hit rate threshold, determining the regulation strategy according to the microinstruction cache hit rate of each of the multiple threads and the hit rate threshold, includes: Determining the control strategy includes writing the microinstructions of the target thread into the The microinstruction cache is used, and the remaining threads of the plurality of threads except the target thread are The microinstructions of the remaining threads are not written into the microinstruction cache, wherein the target thread The process includes threads whose microinstruction cache hit rates meet the conditions among the multiple threads.

13. The processor of claim 12, further comprising: A decoder, coupled to the monitor and configured to decode the instructions of each thread to obtain microinstructions of each thread; The monitor is configured to obtain a first number of microinstructions from a decoder and a second number of microinstructions from a microinstruction cache for each of the multiple threads, wherein the first number and the second number are used as the hit information.

14. The processor of claim 13, further comprising: a buffer, wherein an input end of the buffer is coupled to an output end of the controller, an output end of the buffer is coupled to the microinstruction cache, the buffer comprises a plurality of buffers, the plurality of buffers correspond to the microinstructions of the plurality of threads one by one, and are configured to store the microinstructions of the plurality of threads, and the buffer is configured to write the microinstructions in the buffers into the microinstruction cache, The decoder is also coupled to the input terminal of the controller. Wherein, the controller is configured to: according to the regulation strategy, control whether the microinstructions of the current thread among the multiple threads provided by the decoder are written into the buffer corresponding to the current thread.

15. An electronic device, comprising: A processor as claimed in any one of claims 12 to 14.

Citation Information

Patent Citations

  • Microinstruction cache resource scheduling method and device, program product and chip

    CN114138341A