Data prefetching method, electronic device, computer readable medium, and computer program product

By using hash operations to distribute the prefetched states of different threads to different banks in a single-core, multi-threaded environment, the problem of prefetched state pollution is solved, and prefetch accuracy and memory access performance are improved.

CN123178302APending Publication Date: 2026-11-27BEIJING LEAPRISE TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611607790.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-10-16
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

In a single-core, multi-threaded environment, the prefetcher's state becomes polluted due to the interleaved memory access requests from different threads. This makes it difficult to correctly identify the memory access patterns of each thread, leading to decreased prefetch accuracy and erroneous prefetching.

Method used

By responding to cache miss events to obtain the current memory access address and thread identifier, and using hash operations to distribute the prefetch state of different threads into different banks, thread isolation is achieved and prefetch state pollution is avoided.

Benefits of technology

It improves the accuracy of prefetching, enhances the memory access performance of the prefetching device, reduces erroneous prefetching, and improves the latency performance of data acquisition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123178302A_ABST
    Figure CN123178302A_ABST
Patent Text Reader

Abstract

The present disclosure provides a data prefetching method, an electronic device, a computer readable medium and a computer program product. The data prefetching method comprises: in response to a cache miss event, obtaining a current memory access address and a thread identifier from the cache miss event; wherein the cache miss event refers to that the data required by the thread is not hit in the cache, the current memory access address is the storage address of the data required by the thread, and the thread identifier is the unique identifier of the thread; determining a target address based on the current memory access address and a data block size; wherein the number of bits of the target address is the same as the number of bits of the thread identifier; performing a hash operation based on the thread identifier and the target address to obtain a hash operation result; determining a target Bank corresponding to the thread identifier based on the hash operation result; and sending a prefetch request in a prefetch queue to a memory to extract the data in the prefetch address from the memory to the cache, wherein the prefetch request carries the prefetch address.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, and more particularly to a data prefetching method, electronic device, computer-readable medium, and computer program product. Background Technology

[0002] With the increasing number of processor cores, single-core multithreading technology has been widely adopted, aiming to improve the overall utilization of hardware resources by executing multiple threads concurrently. In this context, prefetching technology has become a key performance optimization technique for mitigating memory access latency and unlocking the potential of storage tiers. Specifically, data prefetching, by identifying regular fixed-step patterns in memory access address sequences (such as array traversal patterns), can preload data into the cache before it is actually accessed, thereby significantly reducing memory access latency and improving execution efficiency.

[0003] However, in a single-core, multi-threaded environment, the prefetcher is typically shared by multiple threads. Since memory access requests from different threads are interleaved in time, this poses a significant challenge to the normal operation of the prefetcher. Specifically, when memory access streams from multiple threads arrive at the prefetcher alternately, the address patterns of different threads become mixed, easily causing the prefetcher's internal history to be overwritten or interfered with, leading to prefetch state pollution. This pollution obscures the step-count detection logic, making it difficult for the prefetcher to correctly identify the independent memory access patterns of each thread, resulting in decreased prefetch accuracy and ultimately causing a large number of erroneous prefetches. Summary of the Invention

[0004] This disclosure provides a data prefetching method, an electronic device, a computer-readable medium, and a computer program product.

[0005] In a first aspect, embodiments of this disclosure provide a data prefetching method, comprising:

[0006] In response to a cache miss event, the current memory access address and thread identifier are obtained from the cache miss event; wherein, the cache miss event refers to the failure of the data required by the thread in the cache, the current memory access address is the storage address of the data required by the thread, and the thread identifier is the unique identifier of the thread;

[0007] The target address is determined based on the current memory access address and the data block size; wherein the number of bits in the target address is the same as the number of bits in the thread identifier;

[0008] A hash operation is performed based on the thread identifier and the target address to obtain the hash result;

[0009] The target Bank corresponding to the thread identifier is determined based on the hash operation result; wherein, the target Bank is used to maintain the prefetch queue corresponding to the thread identifier;

[0010] The prefetch request in the prefetch queue is sent to memory to retrieve data from the prefetch address from the memory to the cache, wherein the prefetch request carries the prefetch address.

[0011] Secondly, embodiments of this disclosure provide an electronic device, including a memory and a processor; the memory stores a computer program that can be executed by the processor, and when the computer program is executed by the processor, it implements the data prefetching method as described above.

[0012] Thirdly, embodiments of this disclosure provide a computer-readable medium storing a computer program that, when executed by a processor, implements the data prefetching method as described above.

[0013] Fourthly, embodiments of this disclosure also provide a computer program product, including a computer program that, when executed by a processor, implements the data prefetching method as described above.

[0014] The data prefetching method provided in this disclosure, in response to a cache miss event, obtains the current memory access address and thread identifier from the cache miss event; determines the address block index based on the current memory access address and the data block size; performs a hash operation based on the thread identifier and the address block index to obtain the hash operation result; then, determines the target Bank corresponding to the thread identifier based on the hash operation result; and sends the prefetch request in the prefetch queue to memory to extract the data in the prefetch address from the memory to the cache. Since the target Bank of the thread is determined based on the hash operation result, different threads can be managed by different Banks, thereby isolating the threads. This avoids different threads alternately prefetching data in the target Bank, thus avoiding pollution of the prefetch state, improving the accuracy of prefetching, and further improving the overall memory access performance of the prefetching device. Attached Figure Description

[0015] Figure 1 A schematic block diagram of a prefetching apparatus for implementing a data prefetching method in an embodiment of this disclosure is shown.

[0016] Figure 2 A flowchart illustrating the execution steps of the hash block selection module in this embodiment is shown.

[0017] Figure 3 A flowchart of a data prefetching method provided in an embodiment of this disclosure is shown.

[0018] Figure 4 A flowchart of another data prefetching method provided by an embodiment of this disclosure is shown.

[0019] Figure 5This is a schematic block diagram illustrating the composition of an electronic device provided in an embodiment of this disclosure. Detailed Implementation

[0020] To enable those skilled in the art to better understand the technical solutions of this disclosure, a data prefetching method, electronic device, computer-readable medium, and computer program product provided by the embodiments of this disclosure will be described in detail below with reference to the accompanying drawings.

[0021] The present disclosure will be described more fully below with reference to the accompanying drawings; however, the embodiments shown may be embodied in different forms, and the present disclosure should not be construed as limited to the embodiments set forth below. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will enable those skilled in the art to fully understand the scope of the disclosure.

[0022] The accompanying drawings are provided to further illustrate this disclosure and form part of the specification. They are used together with the detailed embodiments to explain this disclosure and do not constitute a limitation thereof. These and other features and advantages will become more apparent to those skilled in the art from the description of detailed embodiments with reference to the accompanying drawings.

[0023] Unless otherwise specified, each embodiment and feature of this disclosure may be used individually or in combination with other embodiments and features thereof.

[0024] Those skilled in the art will understand that various changes in form and detail may be made to the embodiments of this disclosure without departing from the scope of this disclosure as set forth by the appended claims.

[0025] The terminology used in this disclosure is for the purpose of describing particular embodiments only and is not intended to limit the disclosure. The term "and / or" as used in this disclosure includes any and all combinations of one or more of the associated enumerated entries. The singular forms "a" and "the" as used in this disclosure are also intended to include the plural forms, unless the context clearly indicates otherwise. The terms "comprising," "made of," etc., as used in this disclosure specify the presence of the stated feature, integral, step, operation, element, and / or component, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components, and / or groups thereof.

[0026] Unless otherwise specified, all terms used in this disclosure (including technical and scientific terms) have the same meaning as commonly understood by one of ordinary skill in the art. It will also be understood that terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and this disclosure, and will not be interpreted as having an idealized or overly formal meaning, unless expressly so defined in this disclosure.

[0027] This disclosure is not limited to the embodiments shown in the accompanying drawings, but includes modifications to the configuration based on the manufacturing process. Therefore, the areas illustrated in the drawings are schematic, and the shapes of the areas shown illustrate specific shapes of the areas of an element, but are not intended to be limiting.

[0028] Figure 1 A schematic block diagram of a prefetching apparatus implementing a data prefetching method according to an embodiment of this disclosure is shown. Figure 1 As shown, the prefetching device includes a hash block selection module 10, a step-size training module 20, a prefetch arbiter 30, and a feedback collection module 40. The hash block selection module 10 receives cache miss events, extracts the thread identifier and the current memory access address from the cache miss event, and determines the target block (Bank) through hash calculation. The hash block selection module 10 introduces an address hashing block mechanism, mixing and distributing the memory access address and thread identifier to achieve logical isolation while maintaining physical sharing. The thread identifier can be sent to the prefetcher along with software-initiated instructions.

[0029] In some embodiments, the hash block selection module 10 includes an address high-order bit extraction circuit, an XOR gate, and a hash calculator, which are electrically connected in sequence. The address high-order bit extraction circuit is used to extract the high-order bits of the access address and remove invalid bits from the access address to obtain the target address. The XOR gate is used to perform an XOR operation between the thread identifier and the target address to obtain the hash operation result. The hash calculator is used to select the target bank from multiple prefetch banks based on the hash operation result.

[0030] Figure 2 A flowchart illustrating the execution steps of the hash block selection module in this embodiment is shown. Figure 2 As shown, the steps performed by the hash block selection module include:

[0031] Step S201: Extract the current memory access address and thread identifier from the cache miss event.

[0032] Step S202: Divide the current memory access address into blocks according to the data block size to obtain the address block index.

[0033] Step S203: Perform a hash operation based on the thread identifier and the target address to obtain the hash operation result.

[0034] Step S204: Determine the target Bank corresponding to the thread identifier based on the hash operation result.

[0035] The step training module 20 is used to maintain the prefetch state of the target Bank. An internal step directory is set up within the Bank, and each entry in the step directory includes the historical memory access address, the main step size, the confidence level, and the prefetch queue.

[0036] In some embodiments, the step size training module 20 includes a parallel access port, an SRAM memory, and a FIFO. The input of the parallel access port is electrically connected to the hash calculator, the output of the parallel access port is electrically connected to the input of the SRAM memory, and the output of the SRAM memory is electrically connected to the input of the FIFO. The parallel access port receives the target bank output by the hash calculator, the SRAM memory stores the step size directory, and the FIFO manages the prefetch request queue in a first-in-first-out manner. In some embodiments, the SRAM memory comprises a 64-bit subtractor, a comparator array, and an adder / subtractor. The 64-bit subtractor calculates the address difference, the comparator array matches the address difference with the main step size or a candidate step size, and the adder / subtractor updates the confidence levels of the main step size and candidate step sizes.

[0037] The core algorithm of the step size training module 20 in this embodiment includes: increasing the confidence of the main step size when the address difference matches the main step size; increasing the confidence of the candidate step size when the address difference matches the candidate step size; storing the new step size or the confidence of the main step size below the prefetch confidence threshold in the candidate queue if a new step size is found or if the confidence of the main step size is lower than the prefetch confidence threshold; decreasing the confidence of the main step size if the address difference does not match the main step size; decreasing the confidence of the candidate step size if the address difference does not match the candidate step size; and triggering a prefetch request when the confidence reaches the prefetch confidence threshold. In this embodiment, the step size training module 20 can improve the noise immunity of the prefetching device and the response speed of step size mode switching through different candidate mechanisms and differentiated gains.

[0038] The prefetch arbiter 30 receives step-size prefetch requests and global space prefetch requests from all banks and performs unified scheduling. Different prefetch requests have different priorities, with step-size prefetch requests having a higher priority than global space prefetch requests. This application mainly describes step-size prefetch requests; therefore, the prefetch requests mentioned below refer to step-size prefetch requests. It should be noted that since this embodiment mainly focuses on step-size prefetch requests and does not involve global space prefetch requests, the prefetch arbiter 30 may not be used.

[0039] The feedback collection module 40 monitors L2 cache hit events, cache miss events, and eviction events, matches them with issued prefetch requests, and updates the relevant states to form a closed loop. The feedback collection module 40 records data prefetch information through a prefetch table. When a prefetch request is issued, an entry is allocated for that request. Each entry records the sequence number, prefetch address, source, bank identifier, and issuance period of the prefetch request. The source records whether the prefetch request originates from a step-size prefetch request or a space prefetch request. The issuance period refers to the time from when the prefetch request is issued to when the data is returned, i.e., the time difference between the time the prefetch request is issued and the time the data is returned.

[0040] When a cache entry is hit, the prefetch table is looked up by the prefetch address or the sequence number of the prefetch request. If the source is a prefetch step request, the confidence level of the step in the corresponding bank is updated; if the source is a prefetch space request, the hit count and bandwidth statistics for the corresponding pattern are updated. If the prefetched data is evicted before being used, the confidence level of the corresponding step is reduced. Prefetched data is released after a match, and matched data that times out is automatically cleaned up. The prefetcher in this embodiment can automatically adjust the step and confidence level based on the actual hit situation of the prefetched data, enabling rapid error correction and thus improving the accuracy of prefetching.

[0041] When the prefetching device provided in this embodiment is used, the prefetching device is set between the L1 cache and the L2 cache. For example, the hash block selection module 10 is electrically connected to the L1 cache, and the prefetch arbitrator 30, the feedback collection module 40 and the L2 cache are electrically connected.

[0042] This disclosure provides a data prefetching method. Figure 3 A flowchart of a data prefetching method provided by an embodiment of this disclosure is shown. Figure 3 As shown, data prefetching methods include:

[0043] Step S301: In response to a cache miss event, obtain the current memory access address and thread identifier from the cache miss event; wherein, the cache miss event refers to the failure to find the data required by the thread in the cache, the current memory access address is the storage address of the data required by the thread, and the thread identifier is the unique identifier of the thread.

[0044] A thread sends an access request to the prefetcher, carrying the current memory address and the thread identifier. If the required data cannot be obtained from the cached data, the thread needs to read the required data from memory based on the current memory address. However, reading the required data from memory takes a long time. Therefore, the higher the accuracy of prefetching, the lower the latency for the thread to obtain data.

[0045] In this embodiment, based on the prediction results, a portion of the data in memory is pre-fetched into the cache. When a thread obtains the required data from the pre-fetched cache data, it is called a cache hit event. If the thread fails to obtain the required data from the pre-fetched cache data, it is called a cache miss event.

[0046] Step S302: Determine the target address based on the current memory access address and the data block size; wherein the number of bits in the target address is the same as the number of bits in the thread identifier.

[0047] This embodiment does not limit the data block size; for example, the data block can be 4KB, 8KB, etc. In this embodiment, the number of bits in the target address is the same as the number of bits in the thread identifier. For example, if the thread identifier is three bits, then a three-bit address is selected as the target address.

[0048] Step S303: Perform a hash operation based on the thread identifier and the target address to obtain the hash operation result.

[0049] This embodiment performs a hash operation based on the thread identifier and the target address. The hash operation result mixes the thread identifier and address information. Therefore, the prefetch state of different threads will be distributed to different banks. Even if different threads access the same physical address area, the confusion of the prefetch state can be fundamentally avoided.

[0050] Step S304: Determine the target Bank corresponding to the thread identifier based on the hash operation result; wherein, the target Bank is used to maintain the prefetch queue corresponding to the thread identifier.

[0051] In this embodiment, the prefetch states of different threads are distributed to different banks through hash operations. Each bank stores a completely independent prefetch queue, and the prefetch stream state is managed according to the step size of the prefetch queue, which can fundamentally avoid prefetch state confusion. Moreover, using the hash operation result to determine the target bank can avoid excessive load concentration.

[0052] Step S305: Send the prefetch request in the prefetch queue to memory to retrieve the data in the prefetch address from memory to the cache, wherein the prefetch request carries the prefetch address.

[0053] The data prefetching method provided in this disclosure, in response to a cache miss event, obtains the current memory access address and thread identifier from the cache miss event; determines the address block index based on the current memory access address and the data block size; performs a hash operation based on the thread identifier and the address block index to obtain the hash operation result; then, determines the target Bank corresponding to the thread identifier based on the hash operation result; and sends the prefetch request in the prefetch queue to memory to extract the data in the prefetch address from the memory to the cache. Since the target Bank of the thread is determined based on the hash operation result, different threads can be managed by different Banks, thereby isolating the threads. This avoids different threads alternately prefetching data in the target Bank, thus avoiding pollution of the prefetch state, improving the accuracy of prefetching, and further improving the overall memory access performance of the prefetching device.

[0054] In some embodiments, performing a hash operation based on the thread identifier and the target address to obtain the hash operation result includes: performing a bitwise XOR operation on the target address and the thread identifier to obtain the hash operation result.

[0055] In this embodiment, the hash operation is implemented using an XOR gate. Since the target address and the thread identifier have the same number of bits, the bitwise XOR operation yields a hash result with the same number of bits as the thread identifier. The rule for XOR operation is: the same bit equals zero, and different bit equals one. For example, if the thread identifier is 0 and the target address is 0, then the hash result is 0. If the thread identifier is 0 and the target address is 1, then the hash result is 1. If both the target address and the thread identifier have three bits, then the resulting hash result will also have three bits.

[0056] In some embodiments, determining the target address based on the current memory access address and the data block size includes: determining the address block index according to the current memory access address and the data block size; removing invalid bits from the address block index; and selecting a continuous address segment from the address block index after removing invalid bits, which has the same number of bits as the thread identifier, as the target address.

[0057] The invalid bits to be removed include, but are not limited to, the high bits of the current access address that remain constant, and the low bits of the intra-block offset. The high bits of the address block index are calculated starting from the intra-page offset. The selected target address should avoid potentially constant high bits and low bits of the intra-block offset. The middle bits of the current access address can be selected. The number of bits in the target address is the same as the number of bits in the thread identifier.

[0058] For example, when the current access address is 0x2000_0000, if the data block size is 4KB, the address block index is [31:12]; if the data block size is 8KB, the address block index is [31:13].

[0059] In some embodiments, determining the target Bank corresponding to the thread identifier based on the hash operation result includes: determining the target Bank corresponding to the thread identifier from multiple Banks based on the low-order bits of the hash operation result.

[0060] In this embodiment, a correspondence between Banks and hash values ​​can be pre-established. Based on the hash calculation result, the Bank corresponding to the hash calculation result is directly determined from multiple Banks as the target Bank.

[0061] For example, assuming there are 8 threads, 8 banks, a block size of 4KB, the address block index is address [31:12], and the target address (block_index) is [14:12], the target bank is obtained by XORing the target address and the thread [2:0].

[0062] The current access address is 0x2000_0000, the thread identifier is 0, the block_index[5:3] is 0, the XOR result of block_index[5:3] and the thread identifier is 0, and the target Bank is determined to be Bank0.

[0063] The current access address is 0x2000_1000. When the thread identifier is 0, block_index[5:3] is 1. The XOR result of block_index[5:3] and the thread is 1, and the target Bank is determined to be Bank 1.

[0064] When the current access address is 0x2000_2000 and the thread identifier is 00, block_index[5:3] is 01, and the XOR result of block_index[5:3] and the thread is 01, the target Bank is determined to be Bank 2.

[0065] The current access address is 0x2000_0000. If multiple threads 0-7 access it at the same time, the 8 threads will be assigned to 8 different banks, thus achieving complete physical isolation between threads.

[0066] In some embodiments, the data prefetching method further includes: calculating the difference between the current memory access address and the previous thread access address to obtain the address difference; if the number of times the address difference occurs exceeds a preset threshold, updating the prefetch step size in the target Bank using the address difference, generating a prefetch request based on the current memory access address and the prefetch step size, and sending the prefetch request to the prefetch queue.

[0067] In this embodiment, the prefetching device updates the prefetch step size in the target Bank in real time based on the address difference, and generates a prefetch request based on the current memory access address and the prefetch step size. The prefetching device retrieves data from memory in advance according to the order in the prefetch queue.

[0068] In this embodiment, each Bank maintains multiple data entries, and each entry stores step size information. The step size information mainly includes historical memory access addresses, main step size, step size confidence, and a prefetch queue. Prefetch requests are injected into the prefetch queue and sent to the L2 cache.

[0069] In some embodiments, the target Bank corresponds to a main step size and a candidate step size.

[0070] The data prefetching method in this embodiment further includes: increasing the confidence of the main step size when the prefetch step size is equal to the main step size; decreasing the confidence of the main step size when the prefetch step size is not equal to the main step size; using the prefetch step size as a new candidate step size and initializing the confidence of the new candidate step size when the prefetch step size is not equal to both the main step size and the candidate step size; and storing the main step size into the candidate step size when the confidence of the main step size is less than the prefetch confidence threshold.

[0071] In some embodiments, the data prefetching method further includes: if the confidence of the candidate step size is greater than the prefetch confidence threshold, determining the prefetch address based on the current memory access address, the candidate step size and the prefetch parameters, and generating a prefetch request, wherein the prefetch request carries the prefetch address, and the prefetch parameters are preset based on prefetch historical data.

[0072] In some embodiments, the prefetch address = current memory access address + candidate step size × prefetch parameter. The prefetch address in this embodiment, combined with the prefetch parameter, can avoid a small prefetched data range, thereby increasing the probability of a cache hit.

[0073] In some embodiments, after fetching data from the prefetch address from memory to the cache, the method further includes: if the data is used, determining the target bank and prefetch step size based on the identifier of the prefetch request corresponding to the data, and increasing the confidence of the prefetch step size in the target bank; if the data is not used and is evicted, determining the target bank and prefetch step size based on the identifier of the prefetch request corresponding to the data, and decreasing the confidence of the prefetch step size in the target bank.

[0074] In some embodiments, the entry space is released when an entry recording prefetched information becomes invalid. Entry invalidation includes data being returned, system refresh, or the data having been in the cache for a preset time.

[0075] To better understand this embodiment, the following is combined with... Figure 4 Further explanation. Figure 4 A flowchart of another data prefetching method provided by an embodiment of this disclosure is shown. For example... Figure 4 As shown, the data prefetching method report includes:

[0076] Step S401: Receive a cache miss event.

[0077] Step S402: Extract the thread identifier and the current memory access address from the cache miss event.

[0078] In some embodiments, the information extracted from a cache miss event includes a thread identifier, the current memory access address, and the access type. The access type includes read / write.

[0079] Step S403: Determine the target Bank corresponding to the thread identifier based on the thread identifier and the current memory access address.

[0080] In step S403, the target address is determined based on the current memory access address and the data block size. A hash operation is performed based on the thread identifier and the target address, and the target Bank corresponding to the thread identifier is determined based on the hash operation result.

[0081] Step S404: Match and evaluate the confidence level of the step-size prefetch stream of the target Bank.

[0082] Calculate the difference between the current memory access address and the previous thread's access address to obtain the address difference; if the number of times the address difference occurs exceeds a preset threshold, update the prefetch step size in the target Bank using the address difference, generate a prefetch request based on the current memory access address and the prefetch step size, and send the prefetch request to the prefetch queue.

[0083] Step S405: Obtain a prefetch request from the prefetch queue.

[0084] Step S406: Arbitrate the prefetch request using the prefetch arbitrator.

[0085] Step S407: Send the prefetch request to memory.

[0086] In step S407, if the arbitration result is to issue a prefetch request, the prefetch request is sent to memory; the current memory access address is carried in the prefetch request.

[0087] Step S408: Receive the data stored at the current memory access address returned by memory, and monitor the data hit status.

[0088] Step S409: Determine the feedback type. If the data is matched, proceed to step S411; otherwise, proceed to step S412.

[0089] Step S410: Update the confidence level of the step size.

[0090] Step S411: Count cache miss events.

[0091] Step S412 returns the updated confidence level and statistics of cache miss events.

[0092] In step S412, the updated confidence level and statistics of cache miss events are returned to step S404 so that the step-size prefetch stream of the target Bank can be matched and the confidence level evaluated.

[0093] The data prefetching method provided in this embodiment can be applied to the memory subsystem of multi-core / multi-threaded processors, such as the memory controller, cache coherency hub, and prefetching logic unit of the L3 cache. Application scenarios include server CPUs running virtualized environments where multiple virtual machines share physical memory; artificial intelligence (AI) accelerators executing training tasks where multiple threads access weight parameters simultaneously; database servers processing concurrent queries where each session thread has a different access mode; and hybrid parallel applications in scientific computing.

[0094] This disclosure also provides an electronic device, Figure 5This is a schematic block diagram of the electronic device provided in the embodiments of this disclosure, such as... Figure 5 As shown, the electronic device includes: at least one processor 501; at least one memory 502; and one or more I / O interfaces 503 connected between the processor 501 and the memory 502; wherein the memory 502 stores one or more computer programs that can be executed by at least one processor 501, and the one or more computer programs are executed by at least one processor 501 to enable at least one processor 501 to perform any of the above-described data prefetching methods.

[0095] In this embodiment of the disclosure, the processor 501 is a device with data processing capabilities, including but not limited to a central processing unit (CPU); the memory is a device with data storage capabilities, including but not limited to random access memory (RAM), more specifically such as SDRAM, DDR, etc., read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory (FLASH); the I / O interface, or read-write interface, is connected between the processor and the memory, enabling information interaction between the memory and the processor, including but not limited to a data bus (Bus).

[0096] This disclosure also provides a computer-readable medium, which includes a computer program that, when executed by a processor, implements any of the aforementioned data prefetching methods.

[0097] This disclosure also provides a computer program product, which includes a computer program that, when executed by a processor, implements any of the aforementioned data prefetching methods.

[0098] It will be understood by those skilled in the art that all or some of the steps, systems, or apparatuses disclosed above, and their functional modules / units, can be implemented as software, firmware, hardware, or suitable combinations thereof. In hardware implementations, the division between functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed collaboratively by several physical components. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit (ASIC). Such software may be distributed on a computer-readable medium, which may include computer storage media (or non-transitory media) and communication media (or transient media). As is known to those skilled in the art, the term computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and can be accessed by a computer. Furthermore, it is well known to those skilled in the art that communication media typically contain computer-readable instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information delivery medium.

[0099] Example embodiments have been disclosed herein, and while specific terminology has been used, it is for illustrative purposes only and should be construed as such, and is not intended to be limiting. In some instances, it will be apparent to those skilled in the art that features, characteristics, and / or elements described in connection with particular embodiments may be used alone, or in combination with features, characteristics, and / or elements described in connection with other embodiments, unless otherwise expressly indicated. Therefore, those skilled in the art will understand that various changes in form and detail may be made without departing from the scope of this disclosure as set forth by the appended claims.

Claims

1. A data prefetching method, characterized in that, include: In response to a cache miss event, the current memory access address and thread identifier are obtained from the cache miss event; wherein, the cache miss event refers to the failure of the data required by the thread in the cache, the current memory access address is the storage address of the data required by the thread, and the thread identifier is the unique identifier of the thread; The target address is determined based on the current memory access address and the data block size; wherein the number of bits in the target address is the same as the number of bits in the thread identifier; A hash operation is performed based on the thread identifier and the target address to obtain the hash result; The target Bank corresponding to the thread identifier is determined based on the hash operation result; wherein, the target Bank is used to maintain the prefetch queue corresponding to the thread identifier; The prefetch request in the prefetch queue is sent to memory to retrieve data from the prefetch address from the memory to the cache, wherein the prefetch request carries the prefetch address.

2. The method according to claim 1, characterized in that, The step of performing a hash operation based on the thread identifier and the target address to obtain the hash result includes: The target address and the thread identifier are XORed bitwise to obtain the hash result.

3. The method according to claim 1, characterized in that, The step of determining the target address based on the current memory access address and the data block size includes: Determine the address block index based on the current memory access address and the data block size; Remove invalid bits from the address block index; Select a contiguous address segment from the address block index after removing invalid bits, which has the same number of bits as the thread identifier, and use it as the target address.

4. The method according to claim 1, characterized in that, Determining the target Bank corresponding to the thread identifier based on the hash operation result includes: Based on the low-order bits of the hash operation result, the target bank corresponding to the thread identifier is determined from multiple banks.

5. The method according to claim 1, characterized in that, Also includes: Calculate the difference between the current memory access address and the previous memory access address of the thread to obtain the address difference; If the number of times the address difference occurs exceeds a preset threshold, the prefetch step size in the target Bank is updated using the address difference, and a prefetch request is generated based on the current memory access address and the prefetch step size, and the prefetch request is sent to the prefetch queue.

6. The method according to claim 5, characterized in that, The target Bank corresponds to a main step size and a candidate step size; Also includes: If the prefetch step size is equal to the main step size, increase the confidence level of the main step size; If the prefetch step size is not equal to the main step size, reduce the confidence level of the main step size; If the prefetch step size is not equal to the main step size and the candidate step size, the prefetch step size is used as the new candidate step size, and the confidence of the new candidate step size is initialized. If the confidence level of the main step size is less than the prefetch confidence threshold, the main step size is stored in the candidate step size.

7. The method according to claim 6, characterized in that, Also includes: If the confidence level of the candidate step size is greater than the prefetch confidence threshold, the prefetch address is determined based on the current memory access address, the candidate step size, and the prefetch parameters, and a prefetch request is generated. The prefetch request carries the prefetch address, wherein the prefetch parameters are preset based on prefetch historical data.

8. The method according to claim 1, characterized in that, After retrieving the data from the prefetch address from the memory to the cache, the process further includes: When the data is used, the target bank and the prefetch step size are determined according to the identifier of the prefetch request corresponding to the data, and the confidence of the prefetch step size in the target bank is increased; In the case where the data is unused and has been evicted, the target bank and prefetch step size are determined based on the identifier of the prefetch request corresponding to the data, and the confidence level of the prefetch step size in the target bank is reduced.

9. An electronic device, characterized in that, It includes a memory and a processor; the memory stores a computer program that can be executed by the processor, and when the computer program is executed by the processor, it implements the data prefetching method according to any one of claims 1 to 8.

10. A computer-readable medium, characterized in that, The device contains a computer program that, when executed by a processor, implements the data prefetching method according to any one of claims 1 to 8.

11. A computer program product, characterized in that, It includes a computer program that, when executed by a processor, implements the data prefetching method according to any one of claims 1 to 8.