Event statistics method and apparatus
By setting the mode encoding field and event encoding table in the registers of the performance counter, selecting the target field and performing operations, the problem of combining counting of multiple events in the prior art is solved, and flexible event statistics are achieved.
Patent Information
- Application Number
- PCT/CN2024/104892
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-12-28
- Filing Date
- 2024-07-11
- Publication Date
- 2025-07-03
AI Technical Summary
Existing performance counters are difficult to fit in scenarios where multiple event combinations are counted, and lack flexibility and applicability.
Determine the target mode by the pattern encoding field in the register of the event counter, and select the target field based on the event encoding table and the operation type encoding table, perform corresponding operations to obtain the current event statistical results, and update the historical event statistical results.
A flexible counting of single events and multiple event combinations in a specific mode is achieved, improving the applicability and flexibility of event statistics.
Smart Images

Figure CN2024104892_03072025_PF_FP_ABST
Abstract
Description
Event statistics method and device
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This application is based on the Chinese patent application with application number 202311828931.6 and application date December 28, 2023, and claims the priority of the Chinese patent application. The entire content of the Chinese patent application is hereby introduced into this application as a reference. Technical Field
[0003] The present disclosure relates to the field of computer technology, and in particular to an event statistics method and device. Background Art
[0004] The performance counter (Performance Counter) is located within the processor. Its primary function is to provide real-time statistical feedback on the processor's internal performance parameters while the processor is running a program. The performance counter belongs to a special register group within the processor, responsible for counting performance events of specific operations within the processor while the processor is running a program. External access methods, such as extended instructions or external debugging interfaces, are used to obtain the performance parameters counted by the processor's performance counter. Performance counters provide processor performance testers and users with statistical information on the performance time they are interested in, playing a vital role in optimizing high-performance processor design and software programs. The design of the performance counter needs to be simple in structure, have minimal impact on the processor load, occupy as little valuable processor real estate as possible, provide accurate and real-time performance data, and possess good scalability.
[0005] Currently, existing performance counters are only encoded with simple one-dimensional performance counting events, which makes them difficult to apply to scenarios where multiple event combinations are counted.
[0006] Summary of the Invention
[0007] The present disclosure provides an event statistics method and device to solve the problem in the prior art that it is difficult to apply to scenarios where multiple event combinations are counted.
[0008] In a first aspect, the present disclosure provides an event statistics method, comprising:
[0009] Determining a target mode for event statistics supported by the event counter based on a mode code field in a register of the event counter;
[0010] When it is determined that the current mode of the event counter is consistent with the target mode, based on at least two event code fields to be counted in the register and a preset event code table, selecting a target field for performing an event counting operation in the current input event of the event counter;
[0011] Based on the operation type code field in the register and a preset operation type code table, performing a target operation corresponding to the operation type code field on the target field to obtain a current event statistical result corresponding to the current input event;
[0012] Based on the current event statistics, the historical event statistics of the event counter are updated.
[0013] According to an event statistics method provided by the present disclosure, the method further includes:
[0014] When it is determined that the target field corresponding to the event code field does not exist in the event code table, executing the event statistics operation on the current input event is prohibited.
[0015] According to an event statistics method provided by the present disclosure, the method further includes:
[0016] When it is determined that all bits in the operation type code field are 0, no event statistics operation is performed on all fields of the current input event by default;
[0017] When it is determined that all bits in the operation type code field are 1, an event statistics operation is performed on all fields of the current input event by default.
[0018] According to an event statistics method provided by the present disclosure, updating the historical event statistics results of the event counter based on the current event statistics results includes:
[0019] When it is determined that the bit corresponding to the count control code field in the register is the first value, the current event statistical result and the historical event statistical result are accumulated as the event statistical result after the event counter is updated.
[0020] According to an event statistics method provided by the present disclosure, the event counter is set in at least one submodule of the processor, and the number of the event counters in each submodule is set to be equal to the number of events that need to be counted simultaneously.
[0021] According to an event statistics method provided by the present disclosure, the event counters are respectively provided in the two sub-modules of the processor, and the event code fields of the event counters corresponding to the two sub-modules have overlapping fields; wherein the overlapping fields are used to count the events of interaction between the two sub-modules.
[0022] According to an event statistics method provided by the present disclosure, the target operation includes at least one of an OR operation, an AND operation, an XOR operation, an increase operation, and a decrease operation.
[0023] According to an event statistics method provided by the present disclosure, the event includes at least one of the following:
[0024] Utilization of each queue;
[0025] Single event;
[0026] A combined event, wherein the combined event is composed of multiple single events;
[0027] The utilization rate of the register group's read and write ports;
[0028] The conflict rate corresponding to the read and write ports of the register group;
[0029] The time interval between request and reply.
[0030] In a second aspect, the present disclosure further provides an event statistics device, comprising:
[0031] A determination module, configured to determine a target mode supported by the event counter for event statistics based on a mode code field in a register of the event counter;
[0032] a selection module configured to, when determining that the current mode of the event counter is consistent with the target mode, select a target field on which an event statistics operation is to be performed in the current input event of the event counter based on at least two event code fields to be counted in the register and a preset event code table;
[0033] an execution module, configured to execute a target operation corresponding to the operation type code field on the target field based on the operation type code field in the register and a preset operation type code table, to obtain a current event statistical result corresponding to the current input event;
[0034] An updating module is used to update the historical event statistics of the event counter based on the current event statistics.
[0035] In a third aspect, the present disclosure further provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, wherein when the processor executes the program, any of the event statistics methods described above is implemented.
[0036] In a fourth aspect, the present disclosure further provides a non-transitory computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements any of the above-described event statistics methods.
[0037] In a fifth aspect, the present disclosure further provides a computer program product, comprising a computer program, which implements any of the above-described event statistics methods when executed by a processor.
[0038] The present disclosure provides an event statistics method and apparatus. The method and apparatus first determine the target mode supported by the event counter for event statistics based on a mode code field in a register of an event counter. The mode code field can be set according to actual conditions to perform event statistics in a specific target mode. When the current mode of the event counter is consistent with the target mode, the event statistics process can be initiated. Specifically, based on the event code field to be counted and an event code table in the register, a target field is selected from the current input event of the event counter. Then, based on the operation type code field and the operation type code table in the register, a target operation corresponding to the operation type code field is performed on the target field to obtain a current event statistics result corresponding to the current input event. The historical event statistics result of the event counter is then updated based on the result, thereby achieving event statistics. Compared with existing methods that rely on simple one-dimensional performance counting event encoding, the present disclosure can achieve event counting in a specific target mode. Furthermore, the register of the event counter designed in the present disclosure can include at least two event code fields to be counted. This allows for both single event statistics and event statistics for combinations of multiple events, resulting in wider applicability and greater flexibility. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the technical solutions in the present disclosure or the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0040] FIG1 is a flow chart of an event statistics method provided by the present disclosure;
[0041] FIG2 is a schematic diagram of a register in the event statistics method provided by the present disclosure;
[0042] FIG3 is a schematic diagram of an hwevent register in the event statistics method provided by the present disclosure;
[0043] FIG4 is a schematic diagram of the structure of a processor used in the event statistics method provided by the present disclosure;
[0044] FIG5 is a second flow chart of the event statistics method provided by the present disclosure;
[0045] FIG6 is a schematic diagram of the structure of an event statistics device provided by the present disclosure;
[0046] FIG7 is a schematic structural diagram of an electronic device provided by the present disclosure. DETAILED DESCRIPTION
[0047] To make the objectives, technical solutions, and advantages of this disclosure more clear, the technical solutions of this disclosure will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the embodiments described are only part of the embodiments of this disclosure, not all of them. All other embodiments obtained by persons of ordinary skill in the art based on the embodiments of this disclosure without creative effort shall fall within the scope of protection of this disclosure.
[0048] The event statistics method and device disclosed in the present invention are described below with reference to the accompanying drawings.
[0049] FIG1 is one of the flowcharts of the event statistics method provided by the present disclosure. As shown in FIG1 , the event statistics method includes steps 101 to 104 .
[0050] Step 101: Based on the mode code field in the register of the event counter, determine the target mode for event statistics supported by the event counter.
[0051] Step 102: When it is determined that the current mode of the event counter is consistent with the target mode, based on at least two event code fields to be counted in the register and a preset event code table, a target field for performing an event statistics operation is selected in the current input event of the event counter.
[0052] Step 103: Based on the operation type code field in the register and a preset operation type code table, execute the target operation corresponding to the operation type code field on the target field to obtain a current event statistics result corresponding to the current input event.
[0053] Step 104: Based on the current event statistics, update the historical event statistics of the event counter.
[0054] First, the control and status register (CSR) involved in the embodiment of the present disclosure is described, as shown in Table 1 below:
[0055] Table 1 CSR description
[0056] According to the description in the above table, a user-defined event counter interface is formed.
[0057] Next, we analyze the types of events that the event counter needs to count. The event counter may include a performance counter for counting performance events.
[0058] We hope to use the performance counters in the event counter to count some basic performance parameters under the current microarchitecture, and at the same time hope to use these parameters to guide the microarchitecture information of the next generation processor. Therefore, the performance counter types are counted as follows:
[0059] 1) Statistics on the utilization of each queue, such as the interval distribution diagram of the effective queue.
[0060] 2) Count single performance events, such as flush and stall events.
[0061] 3) Count the combination of multiple events, such as the utilization of a queue when stalled.
[0062] 4) Count the utilization and conflict rate of the read and write ports of the register group.
[0063] 5) Count the time interval between request and response.
[0064] In the related art, if a combination of multiple events is to be implemented, encoding is performed by relying on simple one-dimensional performance counting events, which is relatively fixed and not flexible enough.
[0065] In the disclosed embodiment, the target mode supported by the event counter for event statistics is first determined based on the mode coding field in the register of the event counter. The mode coding field can be set according to actual conditions to perform event statistics in a specific target mode.
[0066] In some embodiments, the event counter may include a performance counter for counting performance events, and may also include other counters unrelated to performance counting, such as those that can be used to count the number of interruptions, the number of exceptions, the number of executions of a certain type of instruction, etc.
[0067] For example, FIG2 is a schematic diagram of registers in the event statistics method provided by the present disclosure. As shown in FIG2 , each event counter may include the following registers:
[0068] [a] The first register (1 bit), specifically the Countinhibit register;
[0069] [b] The second register (64 bits), specifically the hwcounter register;
[0070] [c] The third register (64 bits), specifically the hwevent register.
[0071] Each hwevent is 64 bits. In order to count events of multiple event combinations, the event field is split according to function. FIG3 is a schematic diagram of the hwevent register in the event statistics method provided by the present disclosure. As shown in FIG3, taking the counting of events of four event combinations as an example, the hwevent register includes the following fields:
[0072] [1] Event 0, including bits 0-9;
[0073] [2] Event 1, including bits 10-19;
[0074] [3] Event 2 (Event 1), including bits 20-29;
[0075] [4] Event 3 (Event 1), including bits 30-39;
[0076] The above-mentioned event 0 to 3 fields are also the event coding fields in the present disclosure.
[0077] The event code field (Event field) indicates the event code to be counted. Here, four Event fields are used as an example. A different number of Event fields may also be set according to actual conditions.
[0078] In some embodiments, when it is determined that all bits in the operation type code field are 0, the event statistics operation is not performed on all fields of the current input event by default;
[0079] When it is determined that all bits in the operation type code field are 1, an event statistics operation is performed on all fields of the current input event by default.
[0080] Specifically, two default situations can be set according to actual conditions. When all bits in the Event field are equal to 0, it indicates no event, and event statistics operations are not performed on all fields of the current input event by default; when all bits in the Event field are equal to 1, it indicates cycle, and event statistics operations are performed on all fields of the current input event by default.
[0081] [5] Operation type 0 (Op_type0), including bits 40-44;
[0082] [6] Operation type 1 (Op_type1), including bits 45-49;
[0083] [7] Operation type 2 (Op_type2), including bits 50-54;
[0084] The above-mentioned operation type 0-2 fields are also the operation type coding fields in this disclosure.
[0085] [8] Reserved (RESERVED), including bits 55-57; the specific use of the bits in this field can be based on actual conditions.
[0086] [9] Mode, also known as the mode coding field in the present disclosure, including bits 58-63.
[0087] Mode indicates that the corresponding event counter is to count in a specific mode, which can be encoded using a one-hot encoding method. Table 2 below shows the Mode field encoding corresponding to Mode and its encoding in hwevent.
[0088] Table 2 Mode field encoding corresponding to Mode and encoding in hwevent
[0089] Among them, M represents machine mode, HS represents administrator mode, U represents user mode, VS represents virtual administrator mode, VU represents virtual user mode, and D represents debug mode.
[0090] After determining the target mode, for example, through the above table, the current mode of the event counter can be obtained; when the current mode of the event counter is consistent with the target mode, the event statistics process is started again, specifically based on the event code field to be counted and the event code table in the register, and the target field is selected in the current input event of the event counter.
[0091] It should be noted that the event coding table is used to represent the correspondence between the event coding field and the target field to be counted. The correspondence can be set according to the actual situation, and then the event coding field to be counted in the register can be used to find the target field corresponding to the event coding field in the event coding table.
[0092] Then, based on the operation type coding field and the operation type coding table in the register, the target operation corresponding to the operation type coding field is performed between the target fields corresponding to different events to obtain the current event statistics corresponding to the current input event, and then the historical event statistics of the event counter are updated based on the result to realize event statistics.
[0093] In some embodiments, the target operation may include at least one of an OR operation, an AND operation, an XOR operation, an increase operation, and a decrease operation.
[0094] Specifically, the operation type coding table is, for example, the following Table 3:
[0095] Table 3 Operation type coding table
[0096] It should be noted that the correspondence between different Op_type field codes and different operation behaviors can be set according to actual conditions. The correspondence in the above operation type code table is only an example and is not limited in this disclosure.
[0097] In some embodiments, the event may include at least one of the following:
[0098] 1) Utilization of each queue;
[0099] Specifically, the utilization rate of each queue can be represented by a distribution graph of the intervals where the effective queues are located.
[0100] 2) Single event;
[0101] Specifically, single events include flush and stall events, for example.
[0102] 3) Combined events, which are composed of multiple single events;
[0103] Specifically, the combined event is, for example, the utilization of a queue during stall.
[0104] 4) Utilization of the register group's read and write ports;
[0105] 5) The conflict rate corresponding to the read and write ports of the register group;
[0106] 6) The time interval between request and response.
[0107] In the event statistics method provided by the embodiment of the present disclosure, compared with the existing encoding of simple one-dimensional performance counting events, the embodiment of the present disclosure can realize the counting of events under a specific target mode, and the register of the event counter designed by the present disclosure can include at least two event coding fields to be counted, which can realize event statistics for a single event and can also be adapted to event statistics for a combination of multiple events, with wider applicability and higher flexibility.
[0108] In some embodiments, when it is determined that the target field corresponding to the event code field does not exist in the event code table, the event statistics operation on the current input event may be prohibited.
[0109] Specifically, when selecting the target field, it is necessary to search for the target field corresponding to the operation type code field in the register in the pre-set event code table. If the target field corresponding to the operation type code field cannot be found in the event code table, it is considered that the correspondence between the operation type code field and the event code table is not defined. This operation type code field is an invalid field. At this time, it is prohibited to perform event statistics operations on the current input event, which is equivalent to ignoring the current input event and not performing event statistics operations on it.
[0110] In some embodiments, the updating of the historical event statistics of the event counter based on the current event statistics may include:
[0111] When it is determined that the bit corresponding to the count control code field in the register is the first value, the current event statistical result and the historical event statistical result are accumulated as the event statistical result after the event counter is updated.
[0112] Specifically, according to actual conditions, the counting control code field (Countinhibit field) in the register can be used to control whether to use the current event statistics corresponding to the current input event to update the historical event statistics of the event counter. Specifically, when the bit corresponding to the counting control code field is a first value, for example, when the Countinhibit field is 1, the current event statistics and the historical event statistics are accumulated and used as the event statistics after the event counter is updated;
[0113] In some embodiments, if the Countinhibit field is 0, the event statistics result of the event counter is not updated using the current event statistics result, which is equivalent to setting the current event statistics result to 0.
[0114] In some embodiments, the event counter is set in at least one submodule of the processor, and the number of the event counters in each submodule is set to be equal to the number of events that need to be counted simultaneously.
[0115] Specifically, Figure 4 is a structural diagram of the processor used in the event statistics method provided by the present disclosure. As shown in Figure 4, the processor can be divided into multiple sub-modules (blocks), for example, including a front-end (FRONT_END), a second-level cache (L2 cache), a control (CTRL) sub-module, a floating-point (FLOAT) execution unit, a fixed-point (INT) execution unit, a load storage unit (LSU) execution unit, etc.
[0116] In some embodiments, to avoid redundant wiring, a distributed hardware event monitor (HEM) can be used. That is, an independent HEM is set up in each block. The HEM can also contain mirror values of some other CSRs. The mirror registers can only be modified by instructions.
[0117] It should be noted that the HEM may include a hardware performance monitor (HPM) or monitors of other events.
[0118] Each HEM contains multiple registers for hardware event counting, which are used to count events within the submodule. The specific number of event counters needs to be set based on the number of events to be counted simultaneously in different blocks.
[0119] In some embodiments, the event counters are respectively provided in the two submodules of the processor, and the event code fields of the event counters corresponding to the two submodules have overlapping fields; wherein the overlapping fields are used to count the events of interaction between the two submodules.
[0120] Specifically, the Event field can be classified according to blocks. An overlapping portion can be set between two consecutive blocks. The overlapping portion is used to count events between the blocks.
[0121] For example, when block 1 sends a message to block 2, the event counter of block 1 can perform event statistics on the sent message, and the event counter of block 2 can also perform event statistics on the corresponding received message. In this way, an overlapping field can be set in the event code field of block 1 and block 2 to perform event statistics on the messages exchanged between block 1 and block 2 through the overlapping field.
[0122] The following example illustrates the event statistics method provided by the embodiment of the present disclosure.
[0123] FIG5 is a second flow chart of the event statistics method provided by the present disclosure. As shown in FIG5 , the input of the multiplexer is the bit corresponding to the current input event. Events 0 to 3 (Event0 to 3) are used to control the four multiplexers to select which bit to output. The output of the multiplexer is connected to one input of the AND gate (&). The mode (Mode) and the current mode (Current_mode) are firstly ANDed bit by bit, and then the output multiple bits are reduced to 1 bit through the reduction or operation as the other input of the AND gate. The output of the AND gate is connected to the operation module (N bits, N+1 bits, N+2 bits) controlled by operation types 0 to 2 (Op_type0 to 2). The two inputs of the N bit are the two outputs controlled by Event0 and Event1 respectively. Op_type0 is used to control what operation is performed on the two inputs. The specific operation can be referred to in the above Table 3. According to the corresponding relationship, after the operation is executed, the result is input to an input end of the N+1 bit, and the other input end of the N+1 bit is the output controlled by Event2. Op_type1 is used to control what operation is performed on these two inputs. After the operation is executed, the result is input to an input end of the N+2 bit, and the other input end of the N+2 bit is the output controlled by Event3. Op_type2 is used to control what operation is performed on these two inputs. After the operation is executed, the result is used as the current event statistics result and output to one of the input ends of another AND gate. The other input end of the AND gate is the inversion of the counting control code field (~inhibit), which is equivalent to controlling whether the current event statistics result and the historical event statistics result in the counter (Counter_r) are accumulated through the adder (adder) as the updated event statistics result of Counter_r.
[0124] It should be noted that the embodiment of the present disclosure is illustrated by taking one hwevent register corresponding to one Counter_r as an example. Multiple hwevent registers may also be set to correspond to the same Counter_r, which is not limited here.
[0125] It should also be noted that the last adder and Counter_r can be placed in either the individual HEMs or HPMs or in the CSR, depending on the current CSR design. In some embodiments, it is preferred to place them in separate HEMs or HPMs so that Counter_r can be read using the CSR's write data channel.
[0126] The event statistics device provided by the present disclosure is described below. The event statistics device described below and the event statistics method described above can be referenced to each other.
[0127] FIG6 is a schematic diagram of the structure of an event statistics device provided by the present disclosure. As shown in FIG6 , the event statistics device 600 includes:
[0128] A determination module 601 is configured to determine a target mode supported by the event counter for event statistics based on a mode code field in a register of the event counter;
[0129] A selection module 602 is configured to, when determining that the current mode of the event counter is consistent with the target mode, select a target field on which an event statistics operation is to be performed in the current input event of the event counter based on at least two event code fields to be counted in the register and a preset event code table;
[0130] An execution module 603 is configured to execute a target operation corresponding to the operation type code field on the target field based on the operation type code field in the register and a preset operation type code table, to obtain a current event statistical result corresponding to the current input event;
[0131] The updating module 604 is configured to update the historical event statistics of the event counter based on the current event statistics.
[0132] In the event statistics device provided by the embodiment of the present disclosure, a determination module first determines the target mode supported by the event counter for event statistics based on the mode code field in the register of the event counter. The mode code field can be set according to actual conditions to perform event statistics in a specific target mode. When the current mode of the event counter is consistent with the target mode, the event statistics process can be started. The specific selection module selects the target field from the current input event of the event counter based on the event code field to be counted and the event code table in the register. Then, the execution module performs the target operation corresponding to the operation type code field on the target field based on the operation type code field in the register and the operation type code table to obtain the current event statistics result corresponding to the current input event. Then, the update module updates the historical event statistics result of the event counter based on the result, thereby achieving event statistics. Compared with the existing method that only relies on simple one-dimensional performance counting event encoding, the embodiment of the present disclosure can achieve event counting in a specific target mode. Moreover, the register of the event counter designed by the present disclosure can include at least two event code fields to be counted, which can achieve event statistics for both a single event and a combination of multiple events, with wider applicability and higher flexibility.
[0133] In some embodiments, the event statistics device 600 includes:
[0134] The processing module is configured to prohibit executing an event statistics operation on the current input event when it is determined that the target field corresponding to the event code field does not exist in the event code table.
[0135] In some embodiments, the processing module is further configured to:
[0136] When it is determined that all bits in the operation type code field are 0, no event statistics operation is performed on all fields of the current input event by default;
[0137] When it is determined that all bits in the operation type code field are 1, an event statistics operation is performed on all fields of the current input event by default.
[0138] In some embodiments, the update module 604 is specifically configured to:
[0139] When it is determined that the bit corresponding to the count control code field in the register is the first value, the current event statistical result and the historical event statistical result are accumulated as the event statistical result after the event counter is updated.
[0140] In some embodiments, the event counter is set in at least one submodule of the processor, and the number of the event counters in each submodule is set to be equal to the number of events that need to be counted simultaneously.
[0141] In some embodiments, the event counters are respectively provided in the two submodules of the processor, and the event code fields of the event counters corresponding to the two submodules have overlapping fields; wherein the overlapping fields are used to count the events of interaction between the two submodules.
[0142] In some embodiments, the target operation includes at least one of an OR operation, an AND operation, an XOR operation, an increase operation, and a decrease operation.
[0143] In some embodiments, the event includes at least one of the following:
[0144] 1) Utilization of each queue;
[0145] 2) Single event;
[0146] 3) Combined events, which are composed of multiple single events;
[0147] 4) Utilization of the register group's read and write ports;
[0148] 5) The conflict rate corresponding to the read and write ports of the register group;
[0149] 6) The time interval between request and response.
[0150] FIG7 is a schematic diagram of the structure of an electronic device provided by the present disclosure. As shown in FIG7 , the electronic device may include: a processor 710, a communication interface 720, a memory 730, and a communication bus 740. The processor 710, the communication interface 720, and the memory 730 communicate with each other via the communication bus 740. The processor 710 may call the logic instructions in the memory 730 to execute the event statistics method, which includes:
[0151] Determining a target mode for event statistics supported by the event counter based on a mode code field in a register of the event counter;
[0152] When it is determined that the current mode of the event counter is consistent with the target mode, based on at least two event code fields to be counted in the register and a preset event code table, selecting a target field for performing an event counting operation in the current input event of the event counter;
[0153] Based on the operation type code field in the register and a preset operation type code table, performing a target operation corresponding to the operation type code field on the target field to obtain a current event statistical result corresponding to the current input event;
[0154] Based on the current event statistics, the historical event statistics of the event counter are updated.
[0155] In addition, the logic instructions in the above-mentioned memory 730 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present disclosure is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0156] On the other hand, the present disclosure further provides a computer program product, comprising a computer program. The computer program may be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can perform the event statistics method provided by each of the above methods, the method comprising:
[0157] Determining a target mode for event statistics supported by the event counter based on a mode code field in a register of the event counter;
[0158] When it is determined that the current mode of the event counter is consistent with the target mode, based on at least two event code fields to be counted in the register and a preset event code table, selecting a target field for performing an event counting operation in the current input event of the event counter;
[0159] Based on the operation type code field in the register and a preset operation type code table, performing a target operation corresponding to the operation type code field on the target field to obtain a current event statistical result corresponding to the current input event;
[0160] Based on the current event statistics, the historical event statistics of the event counter are updated.
[0161] In another aspect, the present disclosure further provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the event statistics method provided by the above methods is implemented, and the method includes:
[0162] Determining a target mode for event statistics supported by the event counter based on a mode code field in a register of the event counter;
[0163] When it is determined that the current mode of the event counter is consistent with the target mode, based on at least two event code fields to be counted in the register and a preset event code table, selecting a target field for performing an event counting operation in the current input event of the event counter;
[0164] Based on the operation type code field in the register and a preset operation type code table, performing a target operation corresponding to the operation type code field on the target field to obtain a current event statistical result corresponding to the current input event;
[0165] Based on the current event statistics, the historical event statistics of the event counter are updated.
[0166] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they may be located in one location or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.
[0167] Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented using software plus a necessary general-purpose hardware platform, or alternatively, hardware. Based on this understanding, the essence of the above technical solution, or the portion that contributes to the prior art, can be embodied in the form of a software product. This software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, or an optical disk, and includes instructions for enabling a computer device (such as a personal computer, server, or network device) to execute the methods described in each embodiment or portions thereof.
[0168] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present disclosure, rather than to limit them. Although the present disclosure has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present disclosure.
Claims
1. An event statistics method, comprising: Determining a target mode for event statistics supported by the event counter based on a mode encoding field in a register of the event counter; When determining that the current mode of the event counter is consistent with the target mode, based on at least two event encoding fields to be statistically counted in the register and a preset event encoding table, selecting a target field for performing an event statistics operation from the current input events of the event counter; Performing a target operation corresponding to the operation type encoding field on the target field based on the operation type encoding field in the register and a preset operation type encoding table, to obtain a current event statistics result corresponding to the current input event; Updating a historical event statistics result of the event counter based on the current event statistics result.
2. The event statistics method according to claim 1, further comprising: When determining that there is no target field corresponding to the event encoding field in the event encoding table, prohibiting performing an event statistics operation on the current input event.
3. The event statistics method according to claim 1 or 2, further comprising: When determining that all bit positions in the operation type encoding field are all 0, by default, not performing an event statistics operation on all fields of the current input event; When determining that all bit positions in the operation type encoding field are all 1, by default, performing an event statistics operation on all fields of the current input event.
4. The event statistics method according to claim 1, wherein, The updating the historical event statistics result of the event counter based on the current event statistics result includes: When determining that a bit position corresponding to a count control encoding field in the register is a first value, adding the current event statistics result and the historical event statistics result as an event statistics result after updating the event counter.
5. The event statistics method according to claim 1, wherein, The event counter is provided in at least one sub-module of the processor, and the number of event counters in each sub-module is set to be equal to the number of events to be statistically counted simultaneously.
6. The event statistics method according to claim 5, wherein, Event counters are respectively provided in two sub-modules of the processor, and there are overlapping fields in the event encoding fields of the event counters respectively corresponding to the two sub-modules; wherein, the overlapping fields are used for statistically counting events interacting between the two sub-modules.
7. The event statistics method according to claim 1 or 2, wherein, The target operation includes at least one of an OR operation, an AND operation, an XOR operation, an increment operation, and a decrement operation.
8. The event statistics method according to claim 1 or 2, wherein, The event includes at least one of the following: The utilization rate of each queue; A single event; A combined event, which is composed of multiple single events combined; The utilization rate corresponding to the read / write port of the register bank; The conflict rate corresponding to the read / write port of the register bank; The time interval between a request and a response.
9. An event statistics device, comprising: A determination module, configured to determine a target mode for event statistics supported by the event counter based on a mode encoding field in a register of the event counter; A selection module, configured to, when it is determined that the current mode of the event counter is consistent with the target mode, select a target field for which an event statistics operation is to be performed from the current input events of the event counter based on at least two event coding fields to be counted in the register and a preset event coding table; An execution module, configured to perform a target operation corresponding to the operation type coding field on the target field based on the operation type coding field in the register and a preset operation type coding table, to obtain a current event statistics result corresponding to the current input event; An update module, configured to update the historical event statistics result of the event counter based on the current event statistics result.
10. An electronic device, comprising: A memory, a processor, and a computer program stored on the memory and running on the processor, wherein when the processor executes the program, the event statistics method according to any one of claims 1 to 8 is implemented.
11. A non-transitory computer-readable storage medium having a computer program stored thereon, wherein, When the computer program is executed by a processor, the event statistics method according to any one of claims 1 to 8 is implemented.
12. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the event statistics method according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Configurable device with integrated timing and performance counting
CN107358978A
Performance analysis method, device and equipment and storage medium
CN109885442A
Event statistical method and device
CN117472721A
Apparatus for monitoring the performance of a microprocessor
US5657253A