Data loading device and method, chip and electronic equipment
By introducing a prefetcher and a predictor into the data loading system, the data loading process is optimized, the problem of invalid prefetch requests in the data loading unit is solved, data loading efficiency is improved, and the performance of electronic devices is enhanced.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- TENCENT TECHNOLOGY (SHENZHEN) CO LTD
- Filing Date
- 2024-10-30
- Publication Date
- 2026-05-01
AI Technical Summary
In the prior art, when the data already exists in the data cache before the data loading unit executes the prefetch request, the data loading efficiency is low, which affects the performance of electronic devices.
By introducing a prefetcher and a predictor, the prefetcher sends a prediction request to the predictor to determine whether the data exists in the data cache. The predictor decides whether to send a prefetch request to the data loading unit based on the prediction result, and loads the data only if it does not exist.
This improves data loading efficiency, thereby enhancing the performance of electronic devices.
Smart Images

Figure CN121957463A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of electronic device technology, and in particular to a data loading device, method, chip, and electronic device. Background Technology
[0002] During the operation of electronic devices, data needs to be loaded into a data buffer so that data can be read from the data buffer and processed later.
[0003] In related technologies, a data loading device includes a prefetcher and a data loading unit. The prefetcher can send a prefetch request to the data loading unit, and the data loading unit loads first data into a data buffer according to the prefetch request. The data loading unit can also handle other requests; for example, a reservation station can send a memory access request to the data loading unit, and the data loading unit can load second data into the data buffer according to the memory access request. Because the data loading unit can handle multiple requests, it is easy for the first data to already exist in the data buffer before the data loading unit executes the prefetch request, affecting data loading efficiency and reducing the performance of the electronic device. Summary of the Invention
[0004] This application provides a data loading device, method, chip, and electronic device, which can improve data loading efficiency and the performance of electronic devices. The technical solution includes the following contents.
[0005] In a first aspect, a data loading apparatus is provided, the apparatus comprising a prefetcher, a predictor, and a data loading unit;
[0006] The prefetcher is used to send a prediction request to the predictor, the prediction request being used to request a prediction of whether the first data exists in the data cache;
[0007] The predictor is configured to determine first prediction information based on the prediction request and send the first prediction information to the prefetcher, wherein the first prediction information indicates whether the first data exists in the prediction result of the data cache;
[0008] The prefetcher is further configured to send a prefetch request to the data loading unit when the first prediction information indicates that the prediction result is that the first data does not exist in the data cache, the prefetch request being used to request the loading of the first data;
[0009] The data loading unit is used to load the first data into the data cache according to the prefetch request.
[0010] Secondly, a data loading method is provided, the method comprising:
[0011] The prefetcher sends a prediction request to the predictor, the prediction request being used to request a prediction of whether first data exists in the data cache.
[0012] The predictor determines first prediction information based on the prediction request and sends the first prediction information to the prefetcher. The first prediction information indicates whether the first data exists in the prediction result of the data cache.
[0013] When the first prediction information indicates that the prediction result is that the first data does not exist in the data cache, the prefetcher sends a prefetch request to the data loading unit, and the prefetch request is used to request the loading of the first data.
[0014] The data loading unit loads the first data into the data cache according to the prefetch request.
[0015] In one possible implementation, the prefetcher includes a prefetch module and a filtering module;
[0016] Sending a prediction request to the predictor via the prefetcher includes:
[0017] The prefetching module sends the prefetching request to the filtering module.
[0018] The filtering module generates the prediction request based on the prefetch request and sends the prediction request to the predictor.
[0019] The step of sending a prefetch request to the data loading unit via the prefetcher when the first prediction information indicates that the prediction result is that the first data does not exist in the data cache includes:
[0020] The first prediction information is obtained through the filtering module. If the first prediction information indicates that the first data does not exist in the data cache, the prefetch request is sent to the data loading unit.
[0021] In one possible implementation, the predictor includes a register for storing second prediction information of a plurality of cache units in the data cache, wherein the second prediction information of any cache unit indicates whether data exists in the prediction result of any cache unit;
[0022] The step of determining the first prediction information by the predictor based on the prediction request includes:
[0023] The predictor determines the first prediction information from the second prediction information of the plurality of cache units based on the address of the first data carried in the prediction request.
[0024] In one possible implementation, the method further includes:
[0025] The predictor obtains second actual information for any cache unit, the second actual information indicating the actual result of whether data exists in any cache unit;
[0026] The predictor updates the second prediction information of any cache unit based on the second actual information of any cache unit.
[0027] In one possible implementation, sending the prefetch request to the data loading unit includes:
[0028] The prediction index is obtained through the prefetcher, and the prediction index is used to indicate the accuracy of the first prediction information;
[0029] When the prediction metric indicates that the accuracy condition is met, the prefetcher sends a prefetch request to the data loading unit.
[0030] In one possible implementation, the first data resides in a first region of the data cache;
[0031] The process of obtaining the prediction index through the prefetcher includes:
[0032] The prefetcher obtains historical prediction information and historical actual information. The historical prediction information is used to characterize whether the predictor predicted the existence of data in the first region in the past, and the historical actual information is used to characterize whether the first region actually had data in the past.
[0033] The prefetcher determines the prediction index based on the historical prediction information and the historical actual information.
[0034] In one possible implementation, determining the prediction index by the prefetcher based on the historical prediction information and the historical actual information includes:
[0035] The predictor adjusts the prediction index based on the historical prediction information indicating that the predictor predicted the existence of data in the first region in the past, and the historical actual information indicating that the data actually existed in the first region in the past. The accuracy of the adjusted prediction index is greater than that of the original prediction index.
[0036] The prefetcher adjusts the prediction index when the historical prediction information indicates that the predictor predicted that the first region did not have data in the past, and the historical actual information indicates that the first region did not actually have data in the past. The accuracy of the adjusted prediction index is greater than the accuracy of the original prediction index.
[0037] In one possible implementation, determining the prediction index by the prefetcher based on the historical prediction information and the historical actual information includes:
[0038] The predictor adjusts the prediction index when the historical prediction information indicates that the predictor predicted the existence of data in the first region in the past, and the historical actual information indicates that the first region did not actually have data in the past. The accuracy of the adjusted prediction index is reduced by a first value compared with the accuracy of the original prediction index.
[0039] The prefetcher adjusts the prediction index when the historical prediction information indicates that the predictor predicted that there was no data in the first region in the past, and the historical actual information indicates that there was actually data in the first region in the past. The accuracy of the adjusted prediction index is reduced by a second value compared with the accuracy of the original prediction index, and the first value is greater than the second value.
[0040] In one possible implementation, the prefetcher further includes a buffer module; the method further includes:
[0041] The filtering module sends a prefetch request to the buffer module when the prediction index indicates that the accuracy of the first prediction information does not meet the conditions.
[0042] The buffer module sends the prefetch request to the data loading unit after the reference time.
[0043] Thirdly, a chip is provided, the chip including the data loading device described in the first aspect above, the data loading device being used to execute the data loading method described in the second aspect above or any possible implementation thereof.
[0044] Fourthly, an electronic device is provided, the electronic device including the data loading device described in the first aspect above, the data loading device being used to perform the data loading method described in the second aspect above or any possible implementation thereof.
[0045] Fifthly, a computer-readable storage medium is also provided, wherein at least one computer program is stored therein, the at least one computer program being loaded and executed by a processor to enable an electronic device to implement the data loading method described in the second aspect or any possible implementation thereof.
[0046] In a sixth aspect, a computer program is also provided, said computer program being at least one, which is loaded and executed by a processor to enable an electronic device to implement the data loading method described in the second aspect or any possible implementation thereof.
[0047] In a seventh aspect, a computer program product is also provided, wherein at least one computer program is stored therein, the at least one computer program being loaded and executed by a processor to enable an electronic device to implement the data loading method described in the second aspect or any possible implementation thereof.
[0048] The technical solution provided in this application brings at least the following beneficial effects:
[0049] The technical solution provided in this application, when the predictor predicts that the first data does not exist in the data buffer, sends a prefetch request to the data loading unit through the prefetcher to request the loading of the first data, so that the data loading unit executes the prefetch request and loads the first data into the data buffer, which can improve data loading efficiency and thus improve the performance of electronic devices. Attached Figure Description
[0050] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0051] Figure 1 This is a schematic diagram of a data loading system based on a related technology provided in an embodiment of this application;
[0052] Figure 2 This is a schematic diagram illustrating the relationship between prefetch requests and processor performance, provided in an embodiment of this application.
[0053] Figure 3 This is a schematic diagram of a computer system provided in an embodiment of this application;
[0054] Figure 4 This is a schematic diagram of the structure of a data loading device provided in an embodiment of this application;
[0055] Figure 5This is a schematic diagram of the structure of a pre-extractor provided in an embodiment of this application;
[0056] Figure 6 This is a schematic diagram illustrating the determination of predictive information provided in an embodiment of this application;
[0057] Figure 7 This is a schematic diagram of the storage information of a filtering module provided in an embodiment of this application;
[0058] Figure 8 This is a diagram of the storage information interface of a filtering module provided in an embodiment of this application;
[0059] Figure 9 This is a flowchart of a data loading method provided in an embodiment of this application;
[0060] Figure 10 This is a structural diagram of another data loading device provided in an embodiment of this application;
[0061] Figure 11 This is a flowchart of another data loading method provided in the embodiments of this application;
[0062] Figure 12 This is a schematic diagram of the structure of another data loading device provided in the embodiments of this application;
[0063] Figure 13 This is a schematic diagram of the structure of a terminal device provided in an embodiment of this application;
[0064] Figure 14 This is a schematic diagram of the structure of a server provided in an embodiment of this application. Detailed Implementation
[0065] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0066] It should be noted that the terms "first," "second," etc., used in this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such terms can be used interchangeably where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0067] First, the abbreviations and key terms involved in the embodiments of this application are defined.
[0068] Prefetcher: A device that sends prefetch requests. These requests are used to prefetch data into a buffer memory (such as a cache). By prefetching data, data is retrieved from slower memory into a faster cache before the processor actually processes it, minimizing cache miss latency.
[0069] Least Recently Used (LRU) is a page replacement algorithm that selects the least recently used page for eviction. The LRU algorithm assigns an access field to each page to record the time elapsed since its last visit. When a page needs to be evicted, the page with the longest access history (i.e., the least recently used) is selected. In practical applications, the LRU algorithm is not only applied to pages but can be extended to any data structure.
[0070] Most Recently Used (MRU) is a page replacement algorithm that, when cache space is insufficient, selects the most recently used page for replacement. The MRU algorithm typically uses a stack to maintain the page usage order; each time a page is accessed, it is moved to the top of the stack. Thus, the top element of the stack is the most recently used page, and the bottom element is the least recently used page. When a page needs to be replaced, the page at the bottom of the stack is selected. In practical applications, the MRU algorithm can also be extended to any data structure.
[0071] Feedback Directed Prefetching (FDP): This method uses feedback information from previously sent prefetch requests to guide the sending of subsequent prefetch requests, thereby improving the prefetching performance of the prefetcher.
[0072] Level 1 Data Cache (L1D or L1Dcache): Computer devices generally use multi-level caches. L1Dcache is a level 1 cache, which is most closely integrated with the central processing unit. Access usually only requires a few clock cycles, and the data volume is about tens of kilobytes (KB).
[0073] Reservation Station (RS): A temporary register used to store instructions, allowing prepared instructions to be sent to the execution unit. Typically located at the input of functional units, it resolves data or resource dependencies between instructions entering the pipeline sequentially.
[0074] Load Data Unit (LDU): Loads target data into memory by executing load instructions for the target data.
[0075] The Dcache Hit Predictor (DHP) predicts whether a prefetch request will hit the Dcache. If the requested data is already in the Dcache, the prefetch request hits the Dcache; otherwise, it misses.
[0076] Central Processing Unit (CPU): The core of a computer device for computation and control; it is the final execution unit for information processing and program execution.
[0077] During the operation of electronic devices, data needs to be loaded into a data buffer so that data can be read from the data buffer and processed later.
[0078] The data loading system in related technologies includes a prefetcher and a data loading unit. The prefetcher can send prefetch requests to the data loading unit, which performs address translation, data checking, and other operations on the prefetch requests to load the data into the data buffer. In addition, the data loading unit can also handle other requests to load data. It should be noted that the structure of the data loading system may differ in different scenarios.
[0079] like Figure 1 As shown, Figure 1 This is a possible data loading system that, in addition to a prefetcher and a data loading unit, includes a holding station, a data buffer, and a re-execution queue. The holding station can send memory access requests to the data loading unit, which performs address translation, data checking, and other operations on the memory access requests to load the data into the data buffer. If the data loading unit receives too many requests, causing it to be unable to execute any, it can place the prefetch or memory access requests into the re-execution queue, waiting for the data loading unit to re-execute the requests.
[0080] from Figure 1As can be seen, both the prefetcher and the hold station are directly connected to the data loading unit, creating a contention between prefetch requests and memory access requests. If the prefetcher sends a prefetch request to the data loading unit in a certain cycle (time cycle or operation cycle), the data loading unit can execute the prefetch request in the next cycle. During this period, if the hold station sends a memory access request to the data loading unit, that memory access request will be blocked. Conversely, if the hold station sends a memory access request to the data loading unit in a certain cycle, the data loading unit can execute the memory access request in the next cycle, while prefetch requests during this period will be blocked.
[0081] Generally, prefetch requests and memory access requests have priorities, and the data loading unit executes requests with higher priority first. That is, if a prefetch request has a higher priority than a memory access request, the data loading unit executes the prefetch request first; if a prefetch request has a lower priority than a memory access request, the data loading unit executes the memory access request first. If the priority of memory access requests is consistently higher than that of prefetch requests, it will reduce the effectiveness of prefetching; conversely, if the priority of prefetch requests is consistently higher than that of memory access requests, it will cause reservation station congestion.
[0082] like Figure 2 As shown, generally speaking, the more prefetch requests the prefetcher issues, the higher the cache hit rate of the data cache, which can improve processor performance. However, the higher the number of prefetch requests, the more intense the resource competition with memory access requests, which increases the number of times the reserved space is blocked, thereby reducing processor performance.
[0083] Because there is a trade-off between the number of prefetch requests and processor performance, the different characteristics of various programs need to be considered when designing a processor. For example, some programs are not very sensitive to L1D cache hit rate; a high or low L1D hit rate has almost no impact on performance. However, these programs are relatively more sensitive to whether the reserved cache is blocked. For these programs, the frequency of prefetch requests needs to be reduced to improve overall performance. On the other hand, some programs are very sensitive to L1D hit rate; a low hit rate will significantly reduce performance. However, these programs are not very sensitive to whether the reserved cache is blocked. For these programs, prefetch requests can be sent as frequently as possible to improve overall performance.
[0084] In general, the data loading unit needs to execute various requests to load data. If the data is already in the data buffer before the data loading unit executes the prefetch request, the prefetch request is invalid. Executing an invalid prefetch request reduces data loading efficiency, thereby degrading the performance of the electronic device. To address this, embodiments of this application provide a data loading apparatus that enables the data loading unit to execute valid prefetch requests, improving data loading efficiency and thus enhancing the performance of the electronic device.
[0085] like Figure 3 As shown, Figure 3 This is a schematic diagram of a computer system provided in an embodiment of this application. The computer system includes a terminal device 301 and a server 302. The terminal device 301 has a client installed and running, and the server 302 is used to provide background services for the client. The target object 303 can realize instant communication, obtain media information, etc. through the interaction between the client and the server 302.
[0086] At least one of the terminal device 301 or server 302 includes a chip. The chip is responsible for executing programs, and during program execution, it can generate instructions, execute instructions, process data, etc. The type of chip is not limited here; for example, the chip can be a graphics processing unit (GPU) chip, an artificial intelligence chip, etc. In this embodiment, the chip includes a data loading device, a data buffer, and a processor. The data buffer is a memory used to store data. The data loading device can load data into the data buffer, and the processor can read data from the data buffer and process the data. The method by which the data loading device loads data is described below and will not be repeated here.
[0087] In one possible implementation, server 302 undertakes the primary computational work, while terminal device 301 undertakes secondary computational work. Alternatively, server 302 undertakes secondary computational work, while terminal device 301 undertakes the primary computational work. Or, terminal device 301 and server 302 collaborate on computation using a distributed computing architecture.
[0088] Optionally, the terminal device 301 can be any electronic device product capable of human-computer interaction with the user through one or more methods such as a keyboard, touchpad, remote control, voice interaction, or handwriting device. For example, the terminal device 301 can be a smartphone, tablet computer, laptop computer, desktop computer, smart speaker, smartwatch, PC (Personal Computer), mobile phone, PDA (Personal Digital Assistant), wearable device, PPC (Pocket PC), smart car system, smart TV, etc.
[0089] Terminal device 301 can refer to one of a plurality of terminal devices. This embodiment uses terminal device 301 as an example only. Those skilled in the art will know that the number of terminal devices 301 can be more or less. For example, there may be only one terminal device 301, or there may be dozens or hundreds of terminal devices 301, or more. This application embodiment does not limit the number or type of terminal devices 301.
[0090] Server 302 can be a single server, a server cluster consisting of multiple servers, or any of the following: a cloud computing platform or a virtualization center. This embodiment of the application does not limit this. Server 302 communicates directly or indirectly with terminal device 301 via a wired or wireless network. Server 302 has data receiving, data processing, and data sending functions. Of course, server 302 may also have other functions, which are not limited in this embodiment of the application.
[0091] Those skilled in the art should understand that the terminal device 301 and server 302 described above are merely illustrative examples. Other existing or future terminal devices or servers that are applicable to this application should also be included within the scope of protection of this application, and are hereby incorporated by reference.
[0092] like Figure 4 As shown, Figure 4 This is a schematic diagram of a data loading device provided in an embodiment of this application. The data loading device includes a prefetcher 10, a predictor 20, and a data loading unit 30. Exemplarily, the data loading device can be a circuit inside a chip, and the prefetcher 10 can be any of a sub-circuit, component, or transistor within the circuit. Similarly, the predictor 20 and the data loading unit 30 can also be any of a sub-circuit, component, or transistor.
[0093] The prefetcher 10 sends a prediction request to the predictor 20, requesting a prediction of whether first data exists in the data cache. The predictor 20 determines first prediction information based on the prediction request and sends this first prediction information to the prefetcher 10, indicating the prediction result of whether the first data exists in the data cache. The prefetcher 10 is further configured to send a prefetch request to the data loading unit 30 if the first prediction information indicates that the first data does not exist in the data cache, requesting a loading of the first data. The data loading unit 30 loads the first data into the data cache according to the prefetch request.
[0094] The data loading unit 30 is connected to a data cache, which includes, but is not limited to, any one of high-speed memory, L1 cache, L2 cache, and L3 cache. The data loading unit 30 can load data into the data cache based on prefetch requests, memory access requests, or other requests. The prefetch request is a request sent by the prefetcher 10 to the data loading unit 30 to request the loading of first data. The type and content of the first data are not limited here; for example, the first data includes, but is not limited to, page images, cascading style sheets, hypertext markup language, product information, etc. The method of generating the prefetch request is not limited here. In practical applications, the prefetcher 10 can generate a prefetch request based on instructions sent by any module such as the processor, the data loading unit, or the data cache.
[0095] The prefetcher 10 can send a prefetch request to the data loading unit 30 to load data. Other modules, such as the retention station, can also send data loading requests to the data loading unit 30. In this embodiment, an invalid request refers to a request to load data into memory when the data is already in memory. A valid request refers to a request to load data into memory when the data is not in memory. In practical applications, the following situation may occur: the data loading unit 30 has loaded the first data into the data buffer according to the memory access request to load the first data sent by the retention station, and then the prefetcher 10 sends a prefetch request to the data loading unit 30 to load the first data. In this case, since the first data already exists in the data buffer, the prefetch request is an invalid request, and the data loading unit 30 does not need to execute the prefetch request, thereby reducing the data loading pressure on the data loading unit 30.
[0096] Based on this, in this embodiment, before sending a prefetch request for loading the first data to the data loading unit 30, the prefetcher 10 first generates a prediction request and sends the prediction request to the predictor 20, so that the predictor 20 can predict whether the first data exists in the data cache based on the prediction request. When the first data exists in the data cache, the prefetcher 10 no longer sends a prefetch request to the data loading unit 30; while when the first data does not exist in the data cache, the prefetcher 10 sends a prefetch request to the data loading unit 30.
[0097] In one possible implementation, such as Figure 5 As shown, the prefetcher 10 includes a prefetch module 11 and a filtering module 12. The prefetch module 11 sends a prefetch request to the filtering module 12. The filtering module 12 generates a prediction request based on the prefetch request and sends the prediction request to the predictor 20. The filtering module 12 is also used to obtain first prediction information, and if the first prediction information indicates that the first data does not exist in the data buffer, it sends a prefetch request to the data loading unit 30.
[0098] There is at least one prefetch module 11, and each prefetch module 11 can send a prefetch request to the filtering module 12. The filtering module 12 can filter the received prefetch requests, and the filtering rules are not limited here. For example, suppose there are two prefetch modules, A and B, and prefetch module A has a higher priority than prefetch module B. When prefetch modules A and B send prefetch requests for the same page, since prefetch module A has a higher priority than prefetch module B, the filtering module will filter out the prefetch request sent by prefetch module B and retain the prefetch request sent by prefetch module A.
[0099] The prefetch request can carry the address of the first data in the data cache. The filtering module 12 can generate a prediction request based on this address, and the prediction request carries this address. Generally, the address carried by the prefetch request is a virtual address. The filtering module 12 can convert the virtual address to a physical address by querying the TLB (Translation Lookaside Buffer). The prediction request can carry at least one of a virtual address or a physical address.
[0100] The filtering module 12 sends a prediction request to the predictor 20, so that the predictor 20 determines the first prediction information based on the prediction request and feeds back the first prediction information to the filtering module 12. When the first prediction information indicates that the first data exists in the data buffer, the filtering module 12 no longer sends a prefetch request to the data loading unit 30, and the prefetch request is invalid; while when the first prediction information indicates that the first data does not exist in the data buffer, the prefetcher 10 sends a prefetch request to the data loading unit 30, and the prefetch request is valid.
[0101] The filtering module generates prediction requests and determines whether to send a prefetch request to the data loading unit based on the results of the prediction requests. This achieves the filtering of invalid prefetch requests and reduces the frequency of sending prefetch requests.
[0102] Optionally, the predictor 20 includes a register for storing second prediction information for multiple cache units in a data cache. The second prediction information for any cache unit indicates the prediction result of whether data exists in any cache unit. The predictor 20 is used to determine first prediction information from the second prediction information of the multiple cache units based on the address of the first data carried in the prediction request.
[0103] The data cache comprises multiple cache units, which are used to store data. The size and dimensions of the cache units are not limited here. For example, assuming the data cache includes multiple cache regions, and each cache region includes multiple cache lines, then a cache unit can be either a cache region or a cache line. Each cache unit corresponds to a second prediction information, used to indicate whether data exists in the cache unit. Optionally, if the second prediction information is a first identifier, then the second prediction information indicates that the data exists in the cache unit; if the second prediction information is a second identifier, then the second prediction information indicates that the data does not exist in the cache unit. The first identifier and the second identifier are different; for example, the first identifier is 1, and the second identifier is 0.
[0104] The predictor 20 includes at least one register, each register used to store second prediction information for multiple cache units. For example, if the second prediction information for one cache unit is 1 bit, and the register is 128 bits, then the register can store the second prediction information for 128 cache units. In practical applications, the register may not store the second prediction information for one or more cache units; for example, if a bit of the register is empty, then the register does not store the second prediction information for the corresponding cache unit.
[0105] Optionally, the predictor 20 is further configured to obtain second actual information of any cache unit, the second actual information indicating whether data exists in any cache unit; the predictor 20 is further configured to update the second prediction information of any cache unit based on the second actual information of any cache unit.
[0106] Loading data into the data buffer is equivalent to writing data into the buffer unit. Typically, the pipeline's load unit can read data from the buffer unit and write the read data into the processor's register set for processing. After reading data from the buffer unit, the load unit can send read information to the predictor 20. This read information may carry at least one of the following: the address of the buffer unit, second prediction information, and second actual information, etc.
[0107] Predictor 20 can determine the cache unit based on the address in the read information, and thus determine the register storing the second prediction information of that cache unit. The register is updated based on the second actual information in the read information. For example, if the second actual information indicates that the data actually exists in the cache unit, then predictor 20 writes the second prediction information indicating that the data exists in the cache unit into the register; if the second actual information indicates that the data does not actually exist in the cache unit, then predictor 20 writes the second prediction information indicating that the data does not exist in the cache unit into the register.
[0108] Alternatively, the predictor 20 can compare the second actual information in the read information with the second predicted information in the read information (or stored in the register), and update the register based on the comparison result. For example, if the second actual information and the second predicted information indicate the same thing, then the second predicted information corresponding to that indication is written into the register. That is, if both the second actual information and the second predicted information indicate that the data does not exist in the cache unit, then the second predicted information indicating that the data does not exist in the cache unit is written into the register; if both the second actual information and the second predicted information indicate that the data exists in the cache unit, then the second predicted information indicating that the data exists in the cache unit is written into the register. If the second actual information and the second predicted information indicate different things, then the second predicted information stored in the register is cleared. That is, if the second predicted information indicates that the data exists in the cache unit, but the second actual information indicates that the data does not exist in the cache unit, or if the second predicted information indicates that the data does not exist in the cache unit, but the second actual information indicates that the data exists in the cache unit, then the second predicted information stored in the register is cleared.
[0109] The second prediction information in the register is updated based on whether the data actually exists in the cache unit. This makes the second prediction information closer to the actual situation, improving the accuracy of the second prediction information. In turn, this improves the accuracy of the first prediction information, enabling the prefetcher to accurately filter invalid requests, reduce the frequency of prefetch requests, and improve data loading efficiency.
[0110] Since the register can store second prediction information for multiple cache units, when the predictor 20 receives a prediction request, it can extract the address of the first data in the data cache from the prediction request. This address points to at least one cache unit. The predictor 20 can determine the cache unit pointed to by the address of the first data, and read the second prediction information of that cache unit from the register to obtain the first prediction information. For example, if the three bits of the register are 110, representing that the data exists in cache unit A, the data exists in cache unit B, and the data does not exist in cache unit C, if the predictor 20 determines cache unit B based on the address carried in the prediction request, then the predictor 20 can determine that the first prediction information indicates that the first data exists in the data cache.
[0111] By storing the second prediction information of multiple cache units in registers, the second prediction information of the cache unit corresponding to the address can be determined from the second prediction information based on the address carried in the prediction request. This enables the rapid determination of the first prediction information and improves prediction efficiency.
[0112] like Figure 6As shown, after the pipeline's loading unit reads data from the cache unit, it sends read information to the predictor 20. Here, lookup_upd0 and lookup_upd1 are the read information sent by the pipeline's loading unit to the predictor 20. The read information carries the cache unit's address `cachelineaddr`, the second prediction information `pred_hit`, and the second actual information `real_hit`. The predictor 20 determines the cache unit based on the address `cachelineaddr`, thereby determining the register used to store the second prediction information for that cache unit. If the second prediction information `pred_hit` is equal to the second actual information `real_hit`, for example, `lookup_upd0.real_hit === lookup_upd0.pred_hit`, then the predictor 20 writes the second prediction information into the corresponding bit in the register for the cache unit; if the second prediction information `pred_hit` is not equal to the second actual information `real_hit`, then the predictor 20 clears the corresponding bit in the register for the cache unit.
[0113] Optionally, the address `cachelineaddr` is a virtual address (VA). The number of bits and format of the virtual address are not limited here; for example, a virtual address could be 8'b00100000. The data cache includes multiple cache banks, cache banks include multiple cache sets, cache sets include multiple cache regions, and cache regions include multiple cache lines. The virtual address includes at least one of the following: offset, cache bank address `bankIdx`, cache set address `setIdx`, and cache line address `TagIdx`. The offset is a 3-bit address that can address 8 cache regions within each cache set. The cache bank address `bankIdx` is a 3-bit address that can address 8 cache banks. The cache set address `setIdx` is an 8-bit address that can address 256 cache sets. The cache line address `TagIdx` is a 3-bit address that can address 8 cache lines within a cache region. It should be noted that the virtual address may also include other information, such as... Figure 6 Bits [38-17] in the virtual address VA correspond to other information.
[0114] Based on this, assuming that the cache unit is a cache line, and the register stores the second prediction information for multiple cache lines, for Figure 6As shown in the cache library, the predictor 20 can address the corresponding cache group based on the index of bits [13-6] in the address cachelineaddr (i.e., the cache group address setIdx), for example, addressing cache group set0. Based on the index of bits [2-0] in the address cachelineaddr (i.e., the offset address), it can address the corresponding cache region, for example, addressing cache region reg7. Based on the index of bits [16-14] in the address cachelineaddr (i.e., the cache line address TagIdx), it can address the corresponding cache line, thereby determining the register used to store the second prediction information of the cache line, so as to write the second prediction information into the corresponding bit of the register or clear the corresponding bit.
[0115] In this way, real-time updates to the register can be achieved, ensuring that the register stores the correct second prediction information. Prefetcher 10 can send a prediction request `Prefetch_req` to predictor 20, carrying the address of the first data. Prefetcher 20 can determine the cache unit based on the address of the first data, and thus read the second prediction information of that cache unit from the register. Prefetcher 20 sends a response message `Prefetch_resp` to prefetcher 10, which may carry the first prediction information. Optionally, if the register stores the second prediction information of the cache unit, then the second prediction information is the first prediction information, and the response message `Prefetch_resp` may carry the first prediction information. If the register does not store the second prediction information, the response message `Prefetch_resp` may not carry any information, or it may carry a prompt indicating that the second prediction information was not obtained, such as carrying the prompt message `None`.
[0116] After predictor 20 sends first prediction information to prefetcher 10, if the first prediction information indicates that the first data does not exist in the data buffer, the data loading unit needs to execute a prefetch request to load the first data into the data buffer. In this case, prefetcher 10 sends a prefetch request to data loading unit 30. If the first prediction information indicates that the first data exists in the data buffer, the data loading unit does not need to execute a prefetch request. In this case, the prefetcher filters out invalid prefetch requests.
[0117] In one possible implementation, the prefetcher 10 is further configured to acquire a prediction index, which indicates the accuracy of the first prediction information; the prefetcher 10 is further configured to send a prefetch request to the data loading unit 30 when the accuracy indicated by the prediction index meets the condition.
[0118] The predictive metric is positively or negatively correlated with the accuracy of the primary predictive information. That is, the larger the predictive metric, the higher the accuracy of the primary predictive information; the smaller the predictive metric, the lower the accuracy of the primary predictive information. Conversely, the larger the predictive metric, the lower the accuracy of the primary predictive information; the smaller the predictive metric, the higher the accuracy of the primary predictive information.
[0119] The filtering module 12 can store prediction metrics for multiple cache units. When the filtering module 12 obtains the first prediction information, it can determine the cache unit based on the address corresponding to the first prediction information, thereby determining the prediction metrics of the first prediction information. In practical applications, the filtering module 12 can also store information such as the physical address, virtual address, and prefetch address of the cache unit.
[0120] like Figure 7 As shown, Figure 7 This is the internal microstructure of the filtering module 12 for storing information. In this example, the size of the cache region is 1KB, and the size of the cache line is 64B. Since 1024B = 16 × 64B, one cache region contains 16 cache lines.
[0121] The filtering module 12 can store the address tag of the cache region. Optionally, the address tag is the address obtained by hashing the address of the cache region. For example, if the address of the cache region is 39 bits, after hashing, the address tag is 10 bits, which can reduce the storage resource consumption. The filtering module 12 can also store the virtual address Region_va and the physical address Region_pa of the region. The virtual address and the physical address can be mapped to each other. Optionally, the physical address Region_pa is the real address of the cache region, aligned to the 2KB boundary; the virtual address Region_va is the virtual address of the cache region before translation by the TLB (Translation Lookaside Buffer), also aligned to the 2KB boundary. The filtering module 12 can also store the sent address Sent_vec and the pending address bit_vec. The sent address Sent_vec is the address of the cache line that has been sent in the cache region, and the pending address bit_vec is the address of the cache line waiting to be sent in the cache region. For example, bit_vec = 0x0002 indicates that the address of the second cache line in the cache region is waiting to be sent. Optionally, both the sent address (Sent_vec) and the pending address (bit_vec) are 16-bit addresses. Furthermore, the filtering module 12 also stores a prediction index (Mispred_cnt) for the cache region, which characterizes the accuracy of the prediction information corresponding to the cache region. Optionally, the virtual address (Region_va) and the prediction index (Mispred_cnt), as indicated by the gray background, are newly added storage items in the filtering module of this embodiment.
[0122] like Figure 8 As shown, Figure 8 A display interface for information stored in a filtering module is shown. The area indicated by label 801 represents the structural hierarchy of the filtering module within the data loading device. The area indicated by label 802 shows the names and bit widths of various information within the filtering module; for example, the filtering module can store address tags with a bit width of [14:0] (i.e., 15 bits). The area indicated by label 803 shows information selected from the information in the filtering module; for example, selecting an address tag with a value of 08BF. The area indicated by label 804 shows the value of the selected information over time; for example, the address tag value remains unchanged over time. Other information includes... Figure 8 As shown, it will not be elaborated further here.
[0123] In an exemplary embodiment, the first data resides in a first region of a data cache. A prefetcher 10 is configured to acquire historical prediction information and historical actual information. The historical prediction information characterizes whether the predictor historically predicted the existence of data in the first region, and the historical actual information characterizes whether data actually existed in the first region historically. The prefetcher 10 is configured to determine a prediction index based on the historical prediction information and the historical actual information.
[0124] In this embodiment, the data cache includes multiple regions, with the first region being used to store the first data. This embodiment does not limit the size of the regions; for example, a region can be a cache region or a cache line. In practical applications, before each prefetch request to load data into a region, the prefetcher 10 sends a prediction request to the predictor 20 to obtain the prediction results fed back by the predictor 20. Based on this, the filtering module 12 can obtain historical prediction information for the first region. Furthermore, before or after each loading of data into the processor, the loading unit in the pipeline sends information to the predictor 20 regarding whether the data actually exists in the region. Based on this, the filtering module 12 can obtain historical actual information for the first region. It should be noted that the data historically stored in the first region may or may not be the first data.
[0125] Next, the filtering module 12 can compare historical forecast information with historical actual information and update the forecast indicators based on the comparison results. By comparing historical forecast information with historical actual information, the accuracy of updating forecast information according to the actual situation is improved, thus improving the accuracy of forecast indicators. This, in turn, improves the filtering results of the filtering module 12 for prefetch requests and increases data loading efficiency.
[0126] In one possible implementation, the prefetcher 10 is used to adjust the forecast index when historical forecast information indicates that the predictor predicted the existence of data in the first region in the past, and historical actual information indicates that data actually existed in the first region in the past. The accuracy of the adjusted forecast index is greater than the accuracy of the unadjusted forecast index. Alternatively, the prefetcher 10 is used to adjust the forecast index when historical forecast information indicates that the predictor predicted the absence of data in the first region in the past, and historical actual information indicates that data actually did not exist in the first region in the past. The accuracy of the adjusted forecast index is greater than the accuracy of the unadjusted forecast index.
[0127] In this embodiment, if both historical prediction information and historical actual information indicate the presence of data in the first region (i.e., consistent representation), the filtering module 12 determines that the accuracy of the prediction indicator has increased, wherein the magnitude of the increase in accuracy is denoted as the first magnitude. If both historical prediction information and historical actual information indicate the absence of data in the first region (i.e., consistent representation), the filtering module 12 determines that the accuracy of the prediction indicator has increased, wherein the magnitude of the increase in accuracy is denoted as the second magnitude. The first magnitude and the second magnitude may be the same or different.
[0128] For example, the prediction metric Mispred_cnt is negatively correlated with accuracy; the larger the prediction metric Mispred_cnt, the lower the accuracy. Based on this, if the historical prediction information and the historical actual information are consistent—that is, both indicate the presence or absence of data in the first region—the filtering module 12 decrements the prediction metric Mispred_cnt by 1, thereby increasing the accuracy of the adjusted prediction metric Mispred_cnt compared to the accuracy represented by the unadjusted prediction metric Mispred_cnt.
[0129] In one possible implementation, the prefetcher 10 is used to adjust the forecast index when historical forecast information indicates that the predictor predicted the existence of data in the first region in the past, and historical actual information indicates that the first region did not actually contain data in the past. The accuracy of the adjusted forecast index is reduced by a first value compared to the accuracy of the unadjusted forecast index. The prefetcher 10 is also used to adjust the forecast index when historical forecast information indicates that the predictor predicted the absence of data in the first region in the past, and historical actual information indicates that the first region actually contained data in the past. The accuracy of the adjusted forecast index is reduced by a second value compared to the accuracy of the unadjusted forecast index, where the first value is greater than the second value.
[0130] In this embodiment, if historical prediction information indicates the presence of data in the first region, while historical actual information indicates the absence of data in the first region, then the historical prediction information and historical actual information are inconsistent. In this case, the filtering module 12 determines that the accuracy of the prediction indicator has decreased, and the decrease is a first value. Since there is actually no data in the first region, but the historical prediction information indicates the presence of data in the first region, the prefetcher will not send a prefetch request to the data loading unit, causing the data loading unit to fail to load data into the first region, affecting the processing of subsequent pipelines and resulting in performance degradation. Therefore, the first value can be a relatively large value.
[0131] If historical prediction information indicates that there is no data in the first region, while historical actual information indicates that there is data in the first region, then the historical prediction information and historical actual information are inconsistent. In this case, the filtering module 12 determines that the accuracy of the prediction indicator has decreased, and the decrease is a second value. Since there is actually data in the first region, but historical prediction information indicates that there is no data in the first region, the prefetcher will send a prefetch request to the data loading unit, causing the data loading unit to execute an invalid prefetch request. However, the data loading unit executing an invalid request will not affect the subsequent pipeline processing, and the impact on performance is low. Therefore, the second value can be a small value.
[0132] For example, the prediction metric Mispred_cnt is negatively correlated with accuracy, and it is a 4-bit data point. If historical prediction information indicates the presence of data in the first region, while historical actual information indicates the absence of data in the first region, then the filtering module 12 sets the prediction metric Mispred_cnt to its maximum value, or sets the highest bit of the prediction metric Mispred_cnt to 1. For example, if the original prediction metric Mispred_cnt was 4'b0010, setting the highest bit to 1 changes it to 4'b1010. If historical prediction information indicates the absence of data in the first region, while historical actual information indicates the presence of data in the first region, then the filtering module 12 increments the prediction metric Mispred_cnt by 1. For example, if the original prediction metric Mispred_cnt was 4'b0010, incrementing it by 1 changes it to 4'b0011.
[0133] By increasing accuracy when historical predictions and actual historical information are consistent, and decreasing accuracy when they are inconsistent, accuracy can be adjusted according to the actual situation. This improves the filtering results of the filtering module 12 for prefetch requests and increases data loading efficiency. Since the first value is greater than the second value, accuracy can be flexibly adjusted according to performance, which is beneficial for performance improvement.
[0134] From this point on, the filtering module 12 can acquire and store the prediction index, and send a prefetch request to the data loading unit 30 when the accuracy of the prediction index meets the condition. This embodiment does not limit the accuracy condition. For example, meeting the accuracy condition means that the accuracy is not less than a set value. For instance, if no bit in the prediction index mispred_cnt is 1 (i.e., mispred_cnt = 0), the accuracy is 100%, and the accuracy condition is met. By sending a prefetch request when the accuracy condition is met, the frequency of sending prefetch requests can be reduced, improving data loading efficiency. Since no prefetch request is sent when the accuracy condition is not met, the number of invalid prefetch requests executed by the data loading unit due to incorrect prediction information can be reduced, thus reducing the pressure on the data loading unit and improving performance.
[0135] Optionally, such as Figure 5 As shown, the prefetcher 10 also includes a buffer module 13. The filtering module 12 is further configured to send a prefetch request to the buffer module 13 when the accuracy of the first prediction information, as indicated by the prediction index, does not meet the conditions. The buffer module 13 is configured to send a prefetch request to the data loading unit 30 after a reference time.
[0136] If the accuracy of the prediction metric does not meet the requirements, for example, if there is a 1 bit in the prediction metric mispred_cnt, causing the accuracy to be less than 100%, then the accuracy condition is not met. In this case, the filtering module 12 sends a prefetch request to the buffer module 13. The buffer module 13 sends a prefetch request to the data loading unit 30 after a reference time. Optionally, the reference time is a preset time, or the reference time can be flexibly changed according to the actual scenario. For example, the busy level of the data loading unit can be determined by at least one of the following: CPU utilization, load value, etc. The reference time is the time elapsed from when the buffer module 13 receives the prefetch request until the busy level of the data loading unit 30 falls below a threshold.
[0137] If the accuracy condition is not met, the prefetch request is not sent directly to the data loading unit 30. Instead, it waits for a period of time before sending the prefetch request to the data loading unit 30, so as to avoid the prefetch request that should have been sent not being sent due to the accuracy condition not being met, which would affect the subsequent pipeline processing.
[0138] In practical applications, the rules for sending prefetch requests by the filtering module 12 can be flexibly changed according to the application scenario. For example, when the busy level of the data loading unit 30 is below a threshold, a prefetch request can be sent directly to the data loading unit 30 regardless of whether the accuracy condition is met. When the busy level of the data loading unit 30 is above the threshold, if the accuracy condition is met, a prefetch request is sent directly to the data loading unit 30; if the accuracy condition is not met, a prefetch request is sent to the buffer module 13, so that the prefetch request can be sent to the data loading unit 30 through the buffer module 13. Through the buffer module 13, prefetch requests that cannot directly enter the data loading unit 30 are cached. Once the busy level of the data loading unit 30 is below the threshold, the buffer module 13 sends the prefetch request to the data loading unit 30, thereby improving data loading efficiency.
[0139] It should be noted that all information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.), and signals involved in this application have been authorized by the user or fully authorized by all parties, and the collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant regions. For example, the page images and product information involved in this application were obtained with full authorization.
[0140] In the aforementioned device, when the predictor predicts that the first data does not exist in the data buffer, the prefetcher sends a prefetch request to the data loading unit to request the loading of the first data, so that the data loading unit executes the prefetch request and loads the first data into the data buffer, thereby improving data loading efficiency and thus improving the performance of the electronic device.
[0141] like Figure 9 As shown, Figure 9 This is a flowchart of a data loading method provided in an embodiment of this application. The method is executed by a data loading device in terminal device 101 or server 102. Figure 9 As shown, the method includes the following steps.
[0142] Step 901: Send a prediction request to the predictor through the prefetcher. The prediction request is used to request the prediction of whether the first data exists in the data cache.
[0143] Step 902: The predictor determines the first prediction information according to the prediction request and sends the first prediction information to the prefetcher. The first prediction information indicates whether the first data exists in the prediction result of the data cache.
[0144] Step 903: If the first prediction information indicates that the prediction result is that the first data does not exist in the data cache, the prefetcher sends a prefetch request to the data loading unit. The prefetch request is used to request the loading of the first data.
[0145] Step 904: The data loading unit loads the first data into the data cache according to the prefetch request.
[0146] In one possible implementation, the prefetcher includes a prefetch module and a filtering module;
[0147] Sending prediction requests to the predictor via the prefetcher includes:
[0148] The prefetch module sends a prefetch request to the filtering module;
[0149] The filtering module generates a prediction request based on the prefetch request and sends the prediction request to the predictor.
[0150] If the prefetcher sends a prefetch request to the data loading unit when the first prediction information indicates that the first data does not exist in the data cache, the prefetcher includes:
[0151] The first prediction information is obtained through the filtering module. If the first prediction information indicates that the first data does not exist in the data cache, a prefetch request is sent to the data loading unit.
[0152] In one possible implementation, the predictor includes a register for storing second prediction information for multiple cache units in a data cache, wherein the second prediction information for any cache unit indicates whether data exists in the prediction result of any cache unit.
[0153] The predictor determines the first prediction information based on the prediction request, including:
[0154] The predictor determines the first prediction information from the second prediction information of multiple cache units based on the address of the first data carried in the prediction request.
[0155] In one possible implementation, the method also includes:
[0156] The predictor obtains the second actual information of any cache unit, which indicates the actual result of whether the data exists in any cache unit.
[0157] The predictor updates the second prediction information of any cache unit based on the second actual information of any cache unit.
[0158] In one possible implementation, sending a prefetch request to the data loading unit includes:
[0159] A prediction index is obtained through a prefetcher, and the prediction index is used to indicate the accuracy of the first prediction information.
[0160] The prefetcher sends a prefetch request to the data loading unit when the accuracy of the prediction indicator meets the requirements.
[0161] In one possible implementation, the first data resides in the first region of the data cache;
[0162] Predictive metrics are obtained through a prefetcher, including:
[0163] The prefetcher obtains historical prediction information and historical actual information. The historical prediction information is used to characterize whether the predictor predicted the existence of data in the first region in the past, and the historical actual information is used to characterize whether the data actually existed in the first region in the past.
[0164] The predictive indicators are determined by the prefetcher based on historical forecast information and historical actual information.
[0165] In one possible implementation, a prefetcher determines forecast indicators based on historical forecast information and historical actual information, including:
[0166] By using a prefetcher, given that historical prediction information indicates that the predictor predicted the existence of data in the first region in the past, and historical actual information indicates that the data actually existed in the first region in the past, the prediction index is adjusted. The accuracy of the adjusted prediction index is greater than the accuracy of the original prediction index.
[0167] By using a prefetcher, given that historical forecast information indicates that the forecaster predicted that there was no data in the first region in the past, and historical actual information indicates that there was actually no data in the first region in the past, the forecast index is adjusted. The accuracy of the adjusted forecast index is greater than that of the unadjusted forecast index.
[0168] In one possible implementation, a prefetcher determines forecast indicators based on historical forecast information and historical actual information, including:
[0169] By using a prefetcher, when historical prediction information indicates that the predictor predicted the existence of data in the first region in the past, and historical actual information indicates that the first region did not actually have data in the past, the prediction index is adjusted. The accuracy of the adjusted prediction index is reduced by a first value compared to the accuracy of the original prediction index.
[0170] By using a prefetcher, given that historical prediction information indicates that the predictor predicted no data in the first region in the past, and historical actual information indicates that data actually existed in the first region in the past, the prediction index is adjusted. The accuracy of the adjusted prediction index is reduced by a second value compared to the accuracy of the original prediction index, and the first value is greater than the second value.
[0171] In one possible implementation, the prefetcher further includes a buffer module; the method also includes:
[0172] The filtering module sends a prefetch request to the buffer module when the accuracy of the first prediction information does not meet the conditions indicated by the prediction index.
[0173] The buffer module sends a prefetch request to the data loading unit after the reference time.
[0174] The above method, when the predictor predicts that the first data does not exist in the data buffer, sends a prefetch request to the data loading unit to request the loading of the first data through the prefetcher, so that the data loading unit executes the prefetch request and loads the first data into the data buffer, can improve data loading efficiency and thus improve the performance of electronic devices.
[0175] It should be understood that the above method embodiments and device embodiments belong to the same concept, and their specific implementation process can be found in the device embodiments, which will not be repeated here.
[0176] It should be noted that the data loading device in this application embodiment, compared with the data loading device of related technologies, adds a predictor. For example, compared with... Figure 10 and Figure 1 As can be seen, the data loading device in this embodiment of the application has added a predictor shown on a gray background. It is understood that... Figure 10 By way of example only, in practical applications, the data loading device may not include at least one of a retention station, a re-execution queue, or a data buffer, depending on the application scenario.
[0177] The following is based on Figure 10Taking an example, the data loading apparatus of this application embodiment is illustrated. In this example, before the prefetcher sends a prefetch request to the data loading unit, the interaction between the predictor and the data cache determines whether the data requested by the prefetch request exists in the data cache. If the data exists in the data cache, it indicates that the prefetch request is invalid, and the prefetcher does not need to issue a prefetch request; if the data does not exist in the data cache, it indicates that the prefetch request is valid, and the prefetcher sends a prefetch request to the data loading unit so that the data can be loaded into the data cache by the data loading unit. If the data loading unit receives too many requests, causing the data loading unit to be unable to execute the requests immediately, the data loading unit can put the prefetch requests or memory access requests into a re-execution queue to wait for the data loading unit to re-execute the requests.
[0178] The prefetcher includes a prefetch module, a filtering module, and a buffer module. These three modules interact with the predictor, data buffer, and data loading unit to implement the data loading method of this application embodiment. Figure 11 As shown, the data loading method in this application embodiment includes the following steps.
[0179] Step 1101: The prefetch module sends a prefetch request to the filtering module.
[0180] There is at least one prefetch module, such as Figure 12 The example shown includes two prefetch modules; in practice, there may be more or fewer prefetch modules. Either prefetch module can send a prefetch request to the filtering module; the content of the prefetch request can be found in the description of the device embodiment, and will not be repeated here.
[0181] Step 1102: The filtering module generates a prediction request based on the prefetch request and sends the prediction request to the predictor.
[0182] like Figure 12 As shown, the filtering module can receive prefetch requests and generate prediction requests. Optionally, the filtering module queries the page table cache to convert the address carried in the prefetch request to obtain the address carried in the prediction request. The prediction request is used to request whether the data requested by the prefetch request is located in the data cache. The predictor can determine whether the data is located in the data cache based on the address carried in the prediction request. The content of the prediction request can be found in the description of the device embodiment, and will not be repeated here.
[0183] Step 1103: The predictor feeds back the prediction information to the filtering module.
[0184] like Figure 12As shown, the predictor responds to a prediction request by sending prediction information to the filtering module. In practical applications, the data cache includes multiple cache units. The filtering module can send a prediction request to the predictor to inquire whether the predicted data is located in a cache unit. If the prediction information returned by the predictor indicates that the data is not located in that cache unit, the filtering module can resend the prediction request to the predictor to inquire whether the predicted data is located in the next cache unit. In this example, the information returned by the predictor indicating that the data is not located in a cache unit is called sample information, and the filtering module can generate a prediction request based on the sample information.
[0185] For example, a prefetch request is used to request that data be loaded into the data cache. In this case, the filtering module generates a prediction request carrying the address of cache unit A and sends it to the predictor. If the predictor reports that the data is not located in cache unit A, the filtering module generates a prediction request carrying the address of cache unit A+2 and sends it to the predictor. If the predictor reports that the data is not located in cache unit A+2, the filtering module generates a prediction request carrying the address of cache unit A+4 and sends it to the predictor. This continues until the predictor reports that the data is located in a certain cache unit, or that the data is not located in any cache unit. The content of the prediction information can be found in the description of the device embodiment, and will not be repeated here.
[0186] Step 1104: The filtering module obtains the prediction indicators of the prediction information.
[0187] Step 1105: The filtering module determines whether the prediction index meets the conditions.
[0188] Step 1106: If the prediction index meets the conditions, the filtering module sends a prefetch request to the data loading unit.
[0189] In this embodiment, the prediction index is used to indicate the accuracy of the prediction information. If the accuracy is not lower than a threshold, the prediction index meets the condition, and the filtering module can directly send a prefetch request to the data loading unit. In practical applications, such as... Figure 12 As shown, the filtering module can also send a prefetch request to the buffer module. Upon receiving the prefetch request, the buffer module immediately sends it to the data loading unit. The implementation principles of steps 1104 to 1106 can be found in the description of the filtering module above, and will not be repeated here.
[0190] Step 1107: If the prediction index does not meet the conditions, the filtering module sends a prefetch request to the buffer module.
[0191] Step 1108: The buffer module sends a prefetch request to the data loading unit after the reference time.
[0192] If the accuracy of the predictive indicator is below the threshold, then the predictive indicator does not meet the conditions. In this case, such as Figure 12 As shown, the filtering module sends a prefetch request to the buffer module. Upon receiving the prefetch request, the buffer module starts timing. After the timing reaches a reference time, it sends a prefetch request to the data loading unit. The implementation principles of steps 1107 to 1108 can be found in the description of the filtering module above, and will not be repeated here.
[0193] Step 1109: The data loading unit loads the data requested by the prefetch request into the data cache.
[0194] like Figure 12 As shown, the data loading unit can receive prefetch requests sent by the buffer module. Then, it loads data into the data buffer based on the prefetch request. Optionally, if the data loading unit cannot immediately execute the prefetch request, for example, if it is executing other requests, it can send a prefetch request to the buffer module. Upon receiving the prefetch request, the buffer module starts timing. After the timing reaches a reference time, it resends the prefetch request to the data loading unit so that the data loading unit can execute the request.
[0195] Figure 13 This illustration shows a structural block diagram of a terminal device 1300 provided in an exemplary embodiment of this application. The terminal device 1300 includes a chip (not shown in the figure), and the chip includes: Figures 4 to 5 , Figure 10 , Figure 12 The data loading device, processor 1301, and memory 1302 described herein. The memory 1302 includes a data buffer for storing data. The data loading device can load data into the data buffer, and the processor can read data from the data buffer and process the data.
[0196] Processor 1301 may include one or more processing cores, such as a quad-core processor, an octa-core processor, etc. Processor 1301 may be implemented using at least one hardware form selected from DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). Processor 1301 may also include a main processor and a coprocessor. The main processor, also known as a CPU (Central Processing Unit), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, processor 1301 may integrate a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content required to be displayed on the screen. In some embodiments, processor 1301 may also include an AI (Artificial Intelligence) processor, which is used to handle computational operations related to machine learning.
[0197] The memory 1302 may include one or more computer-readable storage media, which may be non-transitory. The memory 1302 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In some embodiments, the non-transitory computer-readable storage media in the memory 1302 are used to store at least one computer program, which is executed by the processor 1301 to implement the data loading method provided in the method embodiments of this application.
[0198] In some embodiments, the terminal device 1300 may also optionally include: a peripheral device interface 1303 and at least one peripheral device. The processor 1301, memory 1302, and peripheral device interface 1303 can be connected via a bus or signal line. Each peripheral device can be connected to the peripheral device interface 1303 via a bus, signal line, or circuit board. Specifically, the peripheral device includes at least one of: a radio frequency circuit 1304, a display screen 1305, a camera assembly 1306, an audio circuit 1307, and a power supply 1308.
[0199] Peripheral device interface 1303 can be used to connect at least one I / O (Input / Output) related peripheral device to processor 1301 and memory 1302. In some embodiments, processor 1301, memory 1302 and peripheral device interface 1303 are integrated on the same chip or circuit board; in some other embodiments, any one or two of processor 1301, memory 1302 and peripheral device interface 1303 can be implemented on separate chips or circuit boards, which is not limited in this embodiment.
[0200] The radio frequency (RF) circuit 1304 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The RF circuit 1304 communicates with communication networks and other communication devices via electromagnetic signals. The RF circuit 1304 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals back into electrical signals. Optionally, the RF circuit 1304 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, etc. The RF circuit 1304 can communicate with other terminals through at least one wireless communication protocol. This wireless communication protocol includes, but is not limited to: the World Wide Web, metropolitan area networks, intranets, various generations of mobile communication networks (2G, 3G, 4G, and 5G), wireless local area networks, and / or WiFi (Wireless Fidelity) networks. In some embodiments, the RF circuit 1304 may also include circuitry related to NFC (Near Field Communication), which is not limited in this application.
[0201] Display screen 1305 is used to display a UI (User Interface). This UI may include graphics, text, icons, videos, and any combination thereof. When display screen 1305 is a touch display screen, it also has the ability to collect touch signals on or above its surface. These touch signals can be input as control signals to processor 1301 for processing. In this case, display screen 1305 can also be used to provide virtual buttons and / or a virtual keyboard, also known as soft buttons and / or a soft keyboard. In some embodiments, display screen 1305 may be a single screen, disposed on the front panel of terminal device 1300; in other embodiments, display screen 1305 may be at least two, disposed on different surfaces of terminal device 1300 or in a folded design; in still other embodiments, display screen 1305 may be a flexible display screen, disposed on a curved or folded surface of terminal device 1300. Furthermore, display screen 1305 may also be configured as a non-rectangular, irregular shape, i.e., a non-rectangular screen. The display screen 1305 can be made of materials such as LCD (Liquid Crystal Display) and OLED (Organic Light-Emitting Diode).
[0202] The camera assembly 1306 is used to acquire images or videos. Optionally, the camera assembly 1306 includes a front-facing camera and a rear-facing camera. Typically, the front-facing camera is located on the front panel of the terminal, and the rear-facing camera is located on the back of the terminal. In some embodiments, there are at least two rear-facing cameras, which are any one of a main camera, a depth-sensing camera, a wide-angle camera, and a telephoto camera, to achieve background blurring by fusion of the main camera and the depth-sensing camera, panoramic shooting by fusion of the main camera and the wide-angle camera, VR (Virtual Reality) shooting, or other fusion shooting functions. In some embodiments, the camera assembly 1306 may also include a flash. The flash can be a single-color temperature flash or a dual-color temperature flash. A dual-color temperature flash refers to a combination of a warm-light flash and a cool-light flash, which can be used for light compensation at different color temperatures.
[0203] The audio circuit 1307 may include a microphone and a speaker. The microphone is used to collect sound waves from the user and the environment, converting the sound waves into electrical signals that are input to the processor 1301 for processing, or input to the radio frequency circuit 1304 to achieve voice communication. For stereo sound acquisition or noise reduction purposes, multiple microphones may be used, each located at a different part of the terminal device 1300. The microphone may also be an array microphone or an omnidirectional microphone. The speaker is used to convert electrical signals from the processor 1301 or the radio frequency circuit 1304 into sound waves. The speaker may be a conventional diaphragm speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can convert electrical signals not only into audible sound waves but also into inaudible sound waves for purposes such as distance measurement. In some embodiments, the audio circuit 1307 may also include a headphone jack.
[0204] Power supply 1308 is used to supply power to the various components in terminal device 1300. Power supply 1308 can be AC power, DC power, a disposable battery, or a rechargeable battery. When power supply 1308 includes a rechargeable battery, the rechargeable battery can be a wired rechargeable battery or a wireless rechargeable battery. A wired rechargeable battery is a battery that is charged via a wired line, and a wireless rechargeable battery is a battery that is charged via a wireless coil. The rechargeable battery can also be used to support fast charging technology.
[0205] In some embodiments, the terminal device 1300 further includes one or more sensors 1309. The one or more sensors 1309 include, but are not limited to: an acceleration sensor 1311, a gyroscope sensor 1312, a pressure sensor 1313, an optical sensor 1314, and a proximity sensor 1315.
[0206] Accelerometer 1311 can detect the magnitude of acceleration along the three coordinate axes of a coordinate system established by terminal device 1300. For example, accelerometer 1311 can be used to detect the components of gravitational acceleration along the three coordinate axes. Processor 1301 can control display screen 1305 to display the user interface in either a landscape or portrait view based on the gravitational acceleration signal acquired by accelerometer 1311. Accelerometer 1311 can also be used for games or for acquiring user motion data.
[0207] The gyroscope sensor 1312 can detect the orientation and rotation angle of the terminal device 1300. The gyroscope sensor 1312 can work in conjunction with the accelerometer sensor 1311 to collect 3D motion data from the user on the terminal device 1300. Based on the data collected by the gyroscope sensor 1312, the processor 1301 can perform the following functions: motion sensing (e.g., changing the UI based on the user's tilt), image stabilization during shooting, game control, and inertial navigation.
[0208] The pressure sensor 1313 can be disposed on the side bezel of the terminal device 1300 and / or on the lower layer of the display screen 1305. When the pressure sensor 1313 is disposed on the side bezel of the terminal device 1300, it can detect the user's grip signal on the terminal device 1300, and the processor 1301 can perform left / right hand recognition or quick operation based on the grip signal collected by the pressure sensor 1313. When the pressure sensor 1313 is disposed on the lower layer of the display screen 1305, the processor 1301 can control the operable controls on the UI interface based on the user's pressure operation on the display screen 1305. The operable controls include at least one of button controls, scroll bar controls, icon controls, and menu controls.
[0209] Optical sensor 1314 is used to collect ambient light intensity. In one embodiment, processor 1301 can control the display brightness of display screen 1305 based on the ambient light intensity collected by optical sensor 1314. Specifically, when the ambient light intensity is high, the display brightness of display screen 1305 is increased; when the ambient light intensity is low, the display brightness of display screen 1305 is decreased. In another embodiment, processor 1301 can also dynamically adjust the shooting parameters of camera assembly 1306 based on the ambient light intensity collected by optical sensor 1314.
[0210] The proximity sensor 1315, also known as a distance sensor, is typically located on the front panel of the terminal device 1300. The proximity sensor 1315 is used to detect the distance between the user and the front of the terminal device 1300. In one embodiment, when the proximity sensor 1315 detects that the distance between the user and the front of the terminal device 1300 is gradually decreasing, the processor 1301 controls the display screen 1305 to switch from a screen-on state to a screen-off state; when the proximity sensor 1315 detects that the distance between the user and the front of the terminal device 1300 is gradually increasing, the processor 1301 controls the display screen 1305 to switch from a screen-off state to a screen-on state.
[0211] Those skilled in the art will understand that Figure 13 The structure shown does not constitute a limitation on the terminal device 1300, and may include more or fewer components than shown, or combine certain components, or use different component arrangements.
[0212] Figure 14 This is a schematic diagram of the server structure provided in an embodiment of this application. The server 1400 includes a chip (not shown in the figure), and the chip includes: such as Figures 4 to 5 , Figure 10 , Figure 12The server 1400 comprises any of the aforementioned data loading devices, processor 1401, and memory 1402. The memory 1402 includes a data buffer for storing data. The data loading device can load data into the data buffer, and the processor 1401 can read data from the data buffer and process the data. The memory 1402 stores at least one computer program, which is loaded and executed by the processor 1401 to implement the data loading methods provided in the above-described method embodiments. For example, the processor 1401 is a CPU. Of course, the server 1400 may also have wired or wireless network interfaces, a keyboard, and input / output interfaces for input / output. The server 1400 may also include other components for implementing device functions, which will not be elaborated here.
[0213] In an exemplary embodiment, a computer-readable storage medium is also provided, which stores at least one computer program that is loaded and executed by a processor to enable an electronic device to implement any of the above-described data loading methods.
[0214] Optionally, the aforementioned computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a compact disc read-only memory (CD-ROM), magnetic tape, floppy disk, and optical data storage device, etc.
[0215] In an exemplary embodiment, a computer program is also provided, which is at least one such computer program, loaded and executed by a processor to enable the electronic device to implement any of the above-described data loading methods.
[0216] In an exemplary embodiment, a computer program product is also provided, which stores at least one computer program that is loaded and executed by a processor to enable an electronic device to implement any of the above-described data loading methods.
[0217] It should be understood that "multiple" as used in this article refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.
[0218] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0219] The above description is merely an exemplary embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the principles of this application should be included within the protection scope of this application.
Claims
1. A data loading device, characterized in that, The device includes a prefetcher, a predictor, and a data loading unit; The prefetcher is used to send a prediction request to the predictor, the prediction request being used to request a prediction of whether the first data exists in the data cache; The predictor is configured to determine first prediction information based on the prediction request and send the first prediction information to the prefetcher, wherein the first prediction information indicates whether the first data exists in the prediction result of the data cache; The prefetcher is further configured to send a prefetch request to the data loading unit when the first prediction information indicates that the prediction result is that the first data does not exist in the data cache, the prefetch request being used to request the loading of the first data; The data loading unit is used to load the first data into the data cache according to the prefetch request.
2. The apparatus according to claim 1, characterized in that, The pre-extractor includes a pre-extract module and a filtering module; The prefetch module is used to send the prefetch request to the filtering module; The filtering module is used to generate the prediction request based on the prefetch request and send the prediction request to the predictor; The filtering module is further configured to obtain the first prediction information and, when the first prediction information indicates that the first data does not exist in the data cache, send the prefetch request to the data loading unit.
3. The apparatus according to claim 1 or 2, characterized in that, The predictor includes a register for storing second prediction information of multiple cache units in the data cache, wherein the second prediction information of any cache unit indicates whether data exists in the prediction result of any cache unit; The predictor is configured to determine the first prediction information from the second prediction information of the plurality of cache units based on the address of the first data carried in the prediction request.
4. The apparatus according to claim 3, characterized in that, The predictor is further configured to obtain second actual information of any one of the cache units, the second actual information indicating the actual result of whether data exists in any one of the cache units; The predictor is further configured to update the second prediction information of any cache unit based on the second actual information of any cache unit.
5. The apparatus according to claim 1 or 2, characterized in that, The prefetcher is also used to acquire a prediction index, which is used to indicate the accuracy of the first prediction information; The prefetcher is further configured to send a prefetch request to the data loading unit when the prediction metric indicates that the accuracy meets the conditions.
6. The apparatus according to claim 5, characterized in that, The first data exists in a first region of the data cache; the prefetcher is used to acquire historical prediction information and historical actual information, the historical prediction information is used to characterize whether the predictor predicted whether data existed in the first region in the past, and the historical actual information is used to characterize whether data actually existed in the first region in the past. The prefetcher is used to determine the prediction index based on the historical prediction information and the historical actual information.
7. The apparatus according to claim 6, characterized in that, The prefetcher is used to adjust the prediction index when the historical prediction information represents information that the predictor predicted the existence of data in the first region in the past, and the historical actual information represents information that the first region actually had data in the past. The accuracy of the adjusted prediction index is greater than the accuracy of the original prediction index. The prefetcher is used to adjust the prediction index when the historical prediction information indicates that the predictor predicted that there was no data in the first region in the past, and the historical actual information indicates that there was actually no data in the first region in the past. The accuracy of the adjusted prediction index is greater than the accuracy of the original prediction index.
8. The apparatus according to claim 6, characterized in that, The prefetcher is used to adjust the prediction index when the historical prediction information indicates that the predictor predicted the existence of data in the first region in the past, and the historical actual information indicates that the first region did not actually have data in the past. The accuracy of the adjusted prediction index is reduced by a first value compared with the accuracy of the original prediction index. The prefetcher is configured to adjust the prediction index when the historical prediction information indicates that the predictor predicted that the first region did not have data in the past, and the historical actual information indicates that the first region actually had data in the past. The accuracy of the adjusted prediction index is reduced by a second value compared with the accuracy of the prediction index before adjustment, and the first value is greater than the second value.
9. The apparatus according to claim 2, characterized in that, The prefetcher also includes a buffer module; The filtering module is also used to send a prefetch request to the buffer module when the prediction index indicates that the accuracy of the first prediction information does not meet the conditions. The buffer module is used to send the prefetch request to the data loading unit after the reference time.
10. A data loading method, characterized in that, The method includes: The prefetcher sends a prediction request to the predictor, the prediction request being used to request a prediction of whether first data exists in the data cache. The predictor determines first prediction information based on the prediction request and sends the first prediction information to the prefetcher. The first prediction information is the prediction result of whether the first data exists in the data cache. When the first prediction information indicates that the first data does not exist in the data cache, the prefetcher sends a prefetch request to the data loading unit, and the prefetch request is used to request the loading of the first data. The data loading unit loads the first data into the data cache according to the prefetch request.
11. A chip, characterized in that, The chip includes a data loading device as described in any one of claims 1 to 9.
12. An electronic device, characterized in that, The electronic device includes the chip as described in claim 11.