Hardware data prefetching method capable of simultaneously supporting various area sizes

By designing a hardware prefetch architecture that supports multiple region sizes and a region size detection and switching mechanism, the problems of reduced performance and increased storage overhead caused by fixed region sizes in the existing technology are solved, and more efficient hardware resource utilization and application performance are achieved. promote.

CN118535490APending Publication Date: 2024-08-23ZHEJIANG UNIV
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202410716640.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-04
Publication Date
2024-08-23

AI Technical Summary

Technical Problem

Existing hardware data prefetching technology can only record and prefetch a fixed-size memory area, resulting in different prefetcher optimizations when the data structure size or program access behavior is different in different applications or different stages of the application. Performance is reduced and storage overhead is increased.

Method used

Design a hardware prefetch architecture that supports multiple area sizes, and automatically detects and switches area sizes through expansion units and shrinking units to adapt to memory areas of different sizes for prefetching, sharing a prefetch buffer to optimize hardware resource utilization .

Benefits of technology

It achieves more efficient utilization of hardware resources and better prefetching effects, adaptively selects the appropriate area size according to the access characteristics of the application, and improves the performance of the application.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118535490A
    Figure CN118535490A
Patent Text Reader

Abstract

The invention discloses a hardware data prefetching method capable of simultaneously supporting multiple area sizes, which comprises the following steps: a hardware prefetching framework capable of simultaneously supporting multiple area size settings is designed in advance, each area comprises respective tables FT, AT and PHT, and an expansion unit EU for detecting whether the area size is increased or not is designed between the tables FT and AT, a contraction unit SU used for detecting whether the area size is shrunk or not is designed between the table AT and the PHT, and all the area sizes share one prefetch buffer PB so as to temporarily store the predicted access footprint vector which does not send out the prefetch request; receiving an instruction address of each memory access sent by the cache and an accessed data block address, predicting a to-be-accessed data block address by adopting a hardware prefetching architecture based on the received address, and sending the to-be-accessed data block address to the cache, so that the cache loads data from the lower-layer storage equipment in advance; therefore, simultaneous hardware data prefetching of multiple area sizes can be realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of hardware data prefetching, and in particular relates to a hardware data prefetching method capable of simultaneously supporting multiple area sizes. Background Art

[0002] The von Neumann architecture faces a serious processor-memory speed gap problem, and the latency of a memory access can be as high as hundreds of clock cycles. To alleviate this problem, a cache is used in the processor to store data accessed in the past. If the data to be accessed is in the cache, it can be obtained within a few clock cycles. However, if the data to be accessed is not in the cache, that is, the cache miss, it is necessary to wait for the data to be retrieved from the memory. Nowadays, the amount of data and code in applications continues to increase, far exceeding the capacity of the cache. The traditional method of optimizing performance by increasing the cache capacity is no longer sustainable because it will lead to problems such as increased cache access time and increased chip area.

[0003] Hardware data prefetching technology is an effective way to optimize memory access latency. It uses hardware to record historical memory access information and learn some features from it. Using these features, it is possible to predict memory addresses that will be accessed in the future. Prefetch requests are issued for these memory addresses that are predicted to be accessed, and these data are loaded from lower-level storage devices to the target cache structure in advance. If the prediction is correct, then when the data is really needed, it can be hit in the cache, thereby shortening the memory access time.

[0004] Footprint prefetchers are a type of feasible and effective hardware data prefetching technology. This type of prefetcher usually uses a vector to record the access footprint of a memory area in the past period of time. Whenever a new memory area is accessed, a vector of past records is found based on the access characteristics, and the corresponding data block in this area is prefetched based on this vector.

[0005] SMS (Spatial Memory Streaming) and Bingo are the two technical solutions closest to the present invention. They both use bit vectors to represent the access footprint of the memory area, where each bit represents the access status of a data block in the area. If it is "1", it means it has been accessed; if it is "0", it means it has not been accessed. The following will introduce these two technologies respectively.

[0006] SMS consists of three tables, namely the filter table (FT), the accumulation table (AT), and the pattern history table (PHT). These three tables are essentially set-associated caches. FT is used to filter memory areas that have only accessed one data block. AT is used to continuously record the program's access footprints to the memory area. PHT is used to store the vectors recorded by AT. The following describes the working principle of SMS. After each access to a new memory area, the information of the area is recorded in FT. After accessing the second data block of this area, the relevant information of this area is transferred from FT to AT, and AT is responsible for continuously recording the access footprint of this area. In two cases, this area is considered to be recorded: (1) the data block belonging to this area is replaced from the cache; (2) the table entry of this area is replaced in AT. Each access footprint (i.e., vector) recorded by AT is associated with the trigger event of this area and stored in PHT in the form of <trigger event, access footprint>. The trigger event consists of the information of the trigger access (the first access to the memory area). SMS uses the instruction address (PC) that triggers the access and the access address offset (Offset) to construct the trigger event (PC|Offset). The prediction process of SMS is as follows: after each access to a new memory area, the PHT is searched according to the trigger event, and then the new memory area is prefetched according to the found access footprint.

[0007] Bingo improves the design of PHT on the basis of SMS. Its PHT uses two trigger events at the same time, which are recorded as (PC|Offset+PC|Address). Specifically, its PHT uses the instruction address that triggers the access and the offset of the accessed data block address as the index (PC|Offset), and uses the instruction address that triggers the access and the accessed data block address as the tag (PC|Address). This technology uses (PC|Offset) to calculate the group number to be inserted each time an entry is inserted, and then inserts the data into this group, and uses (PC|Address) as the tag part of the entry. This technology uses (PC|Offset) to first search for PHT based on the instruction address that triggers the access and the access address (PC|Address) each time a search is performed. If the search is successful, prefetching is performed based on the access footprint found. If the search fails, PHT is searched based on the instruction address that triggers the access and the access address offset (PC|Offset). At this time, multiple access footprints may be found. These access footprints are then combined and a voting method is used to generate the final result.

[0008] Existing footprint prefetchers such as SMS and Bingo can only record and prefetch a fixed-size memory area. For different applications or different stages of the same application, the area sizes they are suitable for are different due to different data structure sizes or program access behaviors. Using only a fixed area size will reduce the optimization performance of the prefetcher; at the same time, it will also increase the storage overhead of the prefetcher. Summary of the invention

[0009] In view of the above, an object of the present invention is to provide a hardware data prefetching method that can simultaneously support multiple region sizes, and to achieve hardware data prefetching of memory regions of multiple sizes simultaneously through the set hardware prefetching architecture and region size detection switching mechanism.

[0010] To achieve the above-mentioned object of the invention, an embodiment of the present invention provides a hardware data prefetching method capable of simultaneously supporting multiple region sizes, comprising the following steps:

[0011] A hardware prefetch architecture that supports multiple region size settings is pre-designed, each region contains its own table FT, AT and PHT, wherein each table entry of FT is in the form of <region number, (instruction address, trigger access offset)>, each table entry of AT is in the form of <region number, (instruction address, trigger access offset, access footprint vector)>, each table entry of PHT is in the form of <trigger event, access footprint vector>, and an expansion unit EU for detecting whether to increase the region size is designed between the table FT and AT, and a contraction unit SU for detecting whether to reduce the region size is designed between the table AT and PHT, all region sizes share a prefetch buffer PB, PB uses the maximum supported region size, and is used to temporarily store access footprint vectors that have been predicted but have not issued a prefetch request;

[0012] Receiving the instruction address and the accessed data block address of each memory access sent by the cache in the processor, predicting the data block address to be accessed based on the received instruction address and data block address and using the hardware prefetch architecture, and sending the data block address to the cache, so that the cache can load data from the lower storage device in advance;

[0013] The address of each replaced data block sent by the high-speed cache in the processor is also received, and address processing is performed based on the received address of the replaced data block and using a hardware pre-fetch architecture.

[0014] Preferably, based on the received instruction address and data block address and using a hardware prefetch architecture, predicting the data block address to be accessed and sending it to the cache memory comprises:

[0015] Search for ATs contained in all regions in parallel, that is, calculate the region number corresponding to each region according to the address of the currently accessed data block and the region size of each AT, search for AT according to the region number, and update the access footprint vector for each successfully found AT table entry, that is, set the corresponding bit of the access footprint vector to 1 according to the offset of the data block address under the region corresponding to the successfully found AT table entry;

[0016] When all ATs fail to find, search for FTs included in all area sizes in parallel, that is, search for all FTs according to the area number under each area size, and for each successfully found FT table entry, determine whether the offsets are equal, that is, determine and compare whether the offset of the currently accessed data block address under the successfully found area and the offset stored in the successfully found FT table entry are equal. When the offsets are equal, search for PB and send the predicted accessed data block address; when it is determined that the offsets are not equal, send the information of the offset and FT table entry of this access to EU, and after executing the area size increase detection step, search for PB and send the predicted accessed data block address;

[0017] When all FTs fail to find, after executing the trigger access processing step, the PB is found and the address of the data block predicted to be accessed is sent.

[0018] Preferably, the searching of PB and sending of the predicted accessed data block address comprises: searching PB according to the area number of the maximum area size, and sending the predicted accessed data block address corresponding to the corresponding access footprint vector to the cache according to the found access footprint vector for which the prefetch request has not been issued.

[0019] Preferably, the region size increase detection step comprises:

[0020] B1, construct an AT table entry, that is, construct an AT table entry of the current area size, recorded as Entry1. The area number, instruction address, and trigger access offset in the AT table entry directly use the information in the received FT table entry. The access footprint vector in the AT table entry is initialized according to the offset of this access and the offset in the FT table entry, and is used to represent the first two accesses to this area;

[0021] B2, when judging that the current area is at the highest level, jump to B5.1, otherwise continue to execute B3;

[0022] B3, calculate the mergeable area number and search for AT, where the mergeable area number is: the area number obtained by inverting the lowest bit of the area number in Entry1. Specifically, after calculating the mergeable area number, search for AT under the current area size according to the mergeable area number;

[0023] B4, when it is determined that the AT search under the current area size is successful, jump to B5.2 to increase the current area size, otherwise execute B5.1 without changing the current area size;

[0024] B5.1, inserting the current AT without changing the region size, that is, without changing the region size of the current region, directly inserting the entry Entry1 constructed by B1 into the AT under the current region size, and then jumping to B8;

[0025] B5.2, read the content and delete the entry, that is, read the found AT entry content into EU, record it as Entry2, and delete the entry in AT;

[0026] B6, merge the two AT table entries Entry1 and Entry2 and construct an AT table entry Entry3 with a larger area size;

[0027] B7, the constructed Entry3 is inserted into an AT that is one level larger than the current area;

[0028] B8, judging whether there is a table entry replaced, that is, judging whether the insertion operation of AT causes the original AT table entry to be replaced. If there is a table entry replaced, executing B9, otherwise directly ending;

[0029] B9, performing a region size reduction detection step, that is, sending the replaced AT table entry Entry4 to the shrinking unit SU under the same region size, and performing a region size reduction detection step.

[0030] Preferably, the step of merging two AT table entries Entry1 and Entry2 and constructing an AT table entry Entry3 with a larger area size includes:

[0031] The area number in Entry3 is obtained by shifting the area number of Entry1 right by one bit; the instruction address in Entry3 uses the instruction address of Entry2, and the trigger access offset and access footprint vector in Entry3 are set in two cases according to the lowest bit of the area number of Entry2;

[0032] Case 1: If the lowest bit of the area number of Entry2 is 0, the trigger access offset of Entry3 = the trigger access offset of Entry2, and the access footprint vector of Entry3 is obtained by concatenating the access footprint vectors of the two in the order of (Entry2, Entry1);

[0033] Case 2: If the least significant bit of the region number of Entry2 is 1, the trigger access offset of Entry3 = the trigger access offset of Entry2 + the width L of the access footprint vector of Entry2, and the access footprint vector of Entry3 will be obtained by concatenating the access footprint vectors of the two in the order of (Entry1, Entry2).

[0034] Preferably, the region size reduction detection step includes:

[0035] C1, determine whether it is currently at the lowest layer of the region size. If it is at the lowest layer, jump to C9; otherwise, continue to execute C2;

[0036] C2, determine whether the first half or the second half of the access footprint vector in Entry4 is all 0. If so, and the detected part is all 0, jump to C7; otherwise, continue to execute C3;

[0037] C3, calculate the trigger event and search the PHT, that is, search whether there is an entry in the PHT of this layer that stores the same trigger event as Entry4. Specifically, it includes: If (PC|Offset+PC|Address) or (PC|Address) is used as the trigger event: calculate the data block address of the trigger access of Entry4 according to the region number and trigger access offset in Entry4, and then search the PHT under the current region size according to the instruction address and the calculated data block address in Entry4; If (PC|Offset) is used as the trigger event: search the PHT under the current region size according to the instruction address and trigger access offset in Entry4;

[0038] C4, determine whether the PHT search is successful. If the search fails, do not change the region size setting of Entry4 and jump to C9. If the search is successful, continue to execute C5;

[0039] C5, read the access footprint and calculate the half-region prediction correct value;

[0040] C6, determine the size relationship between the half-region prediction correct value and the preset threshold T. If the half-region prediction correct value >= T, do not change the region size setting of Entry4 and jump to C9. If the half-region prediction correct value < T, continue to execute C7;

[0041] C7, reduce the region size and construct a new entry Entry5;

[0042] C8, insert the new entry Entry5 into the PHT of the lower layer and delete the relevant information of this layer, and end;

[0043] C9, insert the entry Entry4 into the PHT of this layer, and end.

[0044] Preferably, the steps of reading the access footprint and calculating the correct value of half-region prediction include:

[0045] Read the access footprint vector stored in the table entry found in the PHT into the SU, denoted as Vector1; denote the access footprint vector in Entry4 as Vector2;

[0046] First, perform a bitwise exclusive OR operation on Vector1 and Vector2 to obtain Vector3;

[0047] According to the region where the trigger access offset in Entry4 is located, clip Vector3 to obtain Vector4. If the trigger access of Entry4 is in the first half region, keep the second half of Vector3; conversely, if the trigger access of Entry4 is in the second half region, keep the first half of Vector3;

[0048] Count the number of 0s in Vector4, which is the correct value of half-region prediction sought.

[0049] Preferably, the steps of reducing the region size and constructing the new table entry Entry5 include:

[0050] According to the trigger access offset in Entry4, calculate the region number, trigger access offset, and access footprint vector of Entry5 in two cases:

[0051] 1. If the trigger access offset of Entry4 < L / 2, then the region number of Entry5 = the region number of Entry4 * 2; the trigger access offset of Entry5 = the trigger access offset of Entry4; the access footprint vector of Entry5 is the first half of Vector1;

[0052] 2. If the trigger access offset of Entry4 >= L / 2, then the region number of Entry5 = the region number of Entry4 * 2 + 1; the trigger access offset of Entry5 = the trigger access offset of Entry4 – L / 2; the access footprint vector of Entry5 is the second half of Vector1.

[0053] Preferably, the steps of trigger access processing include:

[0054] D1. Search all PHTs, that is, search all PHTs in parallel according to the current access;

[0055] D2. Determine whether there is a successful PHT search. If there is a successful search, continue to execute D3; otherwise, all PHT searches fail, and jump to D5;

[0056] D3, select the search result, including: the search result is related to the trigger event adopted by the PHT. If the design (PC|Offset) or (PC|Address) is adopted, at most one PHT will be successfully searched, and the result is directly selected; if (PC|Offset+PC|Address) is adopted, there may be multiple PHTs that are successfully searched, and it is necessary to select one result from them. Each successfully searched PHT has two possible results: Result 1, the search is successful through the instruction address and the trigger access address. That is, the PC and Address search is successful; Result 2, the search is successful through the instruction address and the trigger access offset, that is, the PC and Offset search is successful. The corresponding selection method is as follows: If there is a PHT with result 1, the result of the PHT is directly selected, otherwise, if there are multiple PHTs with result 2, a PHT is selected by default, and if only one PHT has result 2, the result of the PHT is selected;

[0057] D4, updates the search result to the corresponding position in PB, including: remembering that the result selected in D3 is at the i-th layer, the region number of this access under the region size Ri is RN(i), and the region number under the region size R(n-1) is RN(n-1), first calculates the region offset RO, RO=RN(i)%(2^(n-1-i)), then searches PB according to RN(n-1) to see if there is already an entry about RN(n-1), if so, updates the access footprint vector in the entry with the Li bit in the range [RO*Li,RO*Li+Li) to the Li bit of the access footprint vector of the result selected in D3, if not, inserts a new entry <region number, access footprint vector>, where the region number in the new representation is RN(n-1), the access footprint vector is a vector of L(n-1) bits, the [RO*Li,RO*Li+Li) part is the access footprint vector of the result selected in D3, and the rest is 0;

[0058] D5, allocates a new FT entry. If all searches in D2 fail, a random FT of a region size is selected to allocate a new entry. Otherwise, a new entry is allocated in the FT of the region size selected in D3. The region number and (instruction address, trigger access offset) in the new FT entry are calculated based on the current memory access and the region size of the new entry.

[0059] Preferably, the updating of the address based on the received replaced data block address and using a hardware pre-fetch architecture comprises:

[0060] E1, delete the relevant table entries in the FT, that is, first calculate the area number under each area size, then search all FTs in parallel, and set all the successfully searched table entries to invalid;

[0061] E2, search all ATs, search all ATs in parallel according to the area number calculated in E1, and invalidate all successfully searched entries, and send them to the shrinking unit SU under the area size where they are located, and perform the area size reduction detection step.

[0062] Compared with the prior art, the present invention has the following beneficial effects:

[0063] The present invention can make fuller use of hardware resources and adaptively select a more appropriate area size according to the access characteristics of the application program. In general, the present invention can achieve better pre-fetching effect with less hardware overhead and improve the performance of the application program. BRIEF DESCRIPTION OF THE DRAWINGS

[0064] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0065] Figure 1 is a flow chart of a hardware data prefetching method capable of simultaneously supporting multiple region sizes provided by an embodiment;

[0066] Figure 2 is a schematic diagram of the structure of a hardware prefetch architecture provided in an embodiment;

[0067] Figure 3 is a flowchart of memory access processing provided by an embodiment;

[0068] Figure 4 is a flow chart of a region size increase detection step provided by an embodiment;

[0069] Figure 5 is a flow chart of a region size reduction detection step provided by an embodiment;

[0070] Figure 6 is a flowchart of the trigger access processing steps provided by the embodiment;

[0071] Figure 7 It is a flowchart of the cache replacement processing steps provided by the embodiment. DETAILED DESCRIPTION

[0072] To make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific implementation methods described herein are only used to explain the present invention and do not limit the scope of protection of the present invention.

[0073] The inventive concept of the present invention is: in order to realize hardware data prefetching that supports multiple area sizes at the same time, the present invention provides a new hardware data prefetching scheme, which includes a hardware prefetching architecture that can simultaneously support multiple area size settings, can simultaneously record and prefetch access footprints of memory areas of multiple different sizes, and also includes a mechanism that can automatically detect whether the area size used by the currently recorded area is appropriate, and can adaptively switch the current area to a more appropriate area size.

[0074] like Figure 2 As shown, the hardware prefetching architecture pre-designed by the present invention supports multiple region size settings, including supporting n region sizes, and these n region sizes are respectively denoted as R0, R1, .., R(n-1), which are all powers of 2 and satisfy the quantitative relationship: R1=2R0, R2=2R1, .., R(n-1)=2R(n-2). Under each region size, the vector length used to record the access footprint is denoted as L, (Li=Ri / data block size, 0<=i <n)。

[0075] Each region under each region size contains its own table FT, AT and PHT, where each table entry of FT is in the form of <region number, (instruction address, trigger access offset)>, that is, the region number can be used to find the (instruction address, trigger access offset) corresponding to the region number. Each table entry of AT is in the form of <region number, (instruction address, trigger access offset, access footprint vector)>, that is, the region number can be used to find the (instruction address, trigger access offset, access footprint vector) corresponding to the region number. Each table entry of PHT is in the form of <trigger event, access footprint vector>, that is, the corresponding access footprint vector can be found through the trigger event. The PHT of this scheme can use the same trigger event as Bingo (that is, PC and Offset are used as indexes, and PC and Address are used as tags), or it can also use the same trigger event as SMS (that is, PC and Offset are directly used as tags), or PC and Address are used as tags. In this scheme, all region sizes share a prefetch buffer PB. PB uses the maximum region size supported by this solution (ie, R=R(n-1)) to temporarily store access footprint vectors that have been predicted but for which no prefetch request has been issued.

[0076] In order to realize the conversion of various region sizes, this solution designs an expansion unit EU between FT and AT to detect whether the region size is increased; and designs a contraction unit SU between AT and PHT to detect whether the region size is reduced.

[0077] It should be noted that FT, AT, PHT, EU, and SU with the same area size are said to be in the same layer. The smaller the area size, the lower the layer; the larger the area size, the higher the layer. The layer with an area size of R0 is the lowest layer, and the layer with an area size of R(n-1) is the highest layer. The higher layer of R0 is R1.

[0078] like Figure 1 As shown, based on the above-mentioned pre-designed hardware prefetching architecture, the working principle of the device of the present invention corresponding to the hardware data prefetching method is as follows: in the processor, the cache will send the instruction address of each memory access and the address of the accessed data block to the device of the present invention. In addition, the cache will also send the address of the data block that is replaced each time to the device of the present invention. The device of the present invention will send the data block address predicted to be accessed in the future to the cache, so that the cache device can load data from the lower storage device in advance.

[0079] Based on the above working principle, the hardware data prefetching method implemented by the present invention includes a memory access processing step (i.e., step A), that is, for each memory access, the cache will send the instruction address and data block address (data block address = access address / data block size) of this access to the device proposed in the present solution, such as Figure 3 As shown, the device of the present invention then performs the following steps:

[0080] A0: Start.

[0081] A1: Search all ATs. The device of the present invention will search all ATs contained in all regions in parallel. For each AT, the corresponding region number (region number = data block address / L) will be calculated according to the currently accessed data block address and the region size setting of the AT, and then the AT will be searched according to the region number.

[0082] A2: Determine whether there is an AT search that succeeds. If there is an AT table entry that succeeds, execute step A3.1. If all AT searches fail, execute step A3.2.

[0083] A3.1: Update the access footprint vector. According to the offset of the accessed data block address in the successfully searched area (offset = data block address % L), set the corresponding bit in the access footprint vector to 1, and then jump to step A6.

[0084] A3.2: Find all FTs. Find all FTs in parallel according to the region number under each region size (calculated in step A1).

[0085] A4: Determine whether there is a successful FT search. If there is a successful FT table entry search, execute step A5.1. If all AT searches fail, execute step A5.2.

[0086] A5.1: Determine whether the offsets are equal. Determine and compare whether the offset of the currently accessed data block address in the search success area is equal to the offset stored in the search success FT table entry. If they are equal, jump to step A6. If they are not equal, execute step A5.1.1.

[0087] A5.1.1: Region size increase detection step: The offset of this access and the information of the successfully found FT table entry are sent to the extension unit EU, and the region size increase detection step (ie, step B) is executed. After the execution, jump to step A6.

[0088] A5.2: Trigger access processing steps. This access is a triggered access, and the trigger access processing steps (ie, step D) are executed. After the execution is completed, step A6 is continued.

[0089] A6: Find PB and send the predicted address. Find PB according to the area number under R(n-1) calculated in step A1. According to the access footprint vector found that has not issued a prefetch request, send the corresponding data block address to the cache. If the search fails, end.

[0090] A7: End.

[0091] Step B. Region size increase detection step. In step 5.1.1, the offset of this access and the information of the successfully found FT table entry are sent to the expansion unit EU, such as Figure 4 and perform the following steps:

[0092] B0: Start.

[0093] B1: Construct an AT table entry. That is, construct an AT table entry <region number, (instruction address, trigger access offset, access footprint vector)> of the current region size, recorded as Entry1. Among them, the region number, instruction address, and trigger access offset are directly based on the information in the received FT table entry. The access footprint vector is initialized based on the offset of this access and the offset in the FT table entry, and is used to represent the first two accesses to this region.

[0094] B2: Determine whether the current region is at the highest level. If it is at the highest level, that is, R = R (n-1), then jump to B5.1, otherwise continue to execute B3.

[0095] B3: Calculate the mergeable area number and search for AT. This solution defines the mergeable area number as: the area number obtained by inverting the lowest bit (in binary) of the area number of Entry1. This step first calculates the mergeable area number, and then searches for AT under the current area size based on this mergeable area number.

[0096] B4: Determine whether the search is successful. If the search fails, execute step 5.1 without changing the current area size. If the search is successful, execute step B5.2 to increase the current area size.

[0097] B5.1: Insert the current AT without changing the region size. That is, without changing the region size of the current region, directly insert the entry Entry1 constructed in step B1 into the AT under the current region size, and then jump to step B8.

[0098] B5.2: Read the content and delete the entry. That is, read the found AT entry content into EU, record it as Entry2, and delete the entry in AT.

[0099] B6, merge two entries and construct an entry with a larger area size. This step will merge Entry1 and Entry2 to construct a new AT entry Entry3 with a larger area size (<area number, (instruction address, trigger access offset, access footprint vector)>). Among them, the area number of Entry3 is obtained by shifting the area number of Entry1 right by one bit; the instruction address of Entry3 uses the instruction address of Entry2. The trigger access offset and access footprint vector of Entry3 will be set according to the lowest bit (in binary) of the area number of Entry2 in two cases. Case 1: If the lowest bit of the area number of Entry2 is 0, the trigger access offset of Entry3 = the trigger access offset of Entry2, and the access footprint vector of Entry3 will be obtained by splicing the access footprint vectors of the two in the order of (Entry2, Entry1). Case 2: If the lowest bit of the area number of Entry2 is 1, the trigger access offset of Entry3 = the trigger access offset of Entry2 + L (the width of the access footprint vector of Entry2), and the access footprint vector of Entry3 will be obtained by concatenating the access footprint vectors of the two in the order of (Entry1, Entry2).

[0100] B7: Insert a higher-level AT. Send Entry3 constructed in step B6 to an AT with a larger area size and insert it.

[0101] B8: Determine whether there is a table entry replaced. That is, determine whether the insertion operation of AT causes the original AT table entry to be replaced. If there is a table entry replaced, execute step B9, otherwise jump directly to step B10.

[0102] B9: Perform region size reduction detection step, that is, send the replaced AT entry Entry4 to the shrinking unit SU under the same region size, and enter the region size reduction detection processing step (ie, step C).

[0103] B10: End.

[0104] Step C: Region size reduction detection step. In step B9, the AT will send an AT entry Entry4 to the SU under the region size where the AT is located, as Figure 5 shown, and perform the following steps:

[0105] C0: Start.

[0106] C1: Determine whether it is currently at the lowest level of the region size. If it is at the lowest level, i.e., R = R0, then jump to step C9; otherwise, continue to execute step C2.

[0107] C2: Determine whether the access footprint vector in Entry4 has all 0s in the first half or all 0s in the second half. This step will perform detection in two cases according to the region where the trigger access offset is located. One, the trigger access offset is in the first half region, i.e., 0 <= the trigger access offset of Entry4 < (L / 2), then detect whether all bits of the second half of the access footprint vector (i.e., the part [L / 2, L)) are all 0. Two, the trigger access offset is in the second half region, i.e., (L / 2) <= the trigger access offset of Entry4 < L, then detect whether all bits of the first half of the access footprint vector (i.e., the part [0, L / 2)) are all 0. If the detected part is all 0, i.e., all 0s in the first half or all 0s in the second half, then jump to step C7; otherwise, continue to execute step C3.

[0108] C3: Calculate the trigger event and search the PHT. This step will search whether there is an entry in the current layer PHT that has the same trigger event as Entry4. The specific method is related to the design adopted by the PHT.

[0109] One, if (PC|Offset+PC|Address) or (PC|Address) is used as the trigger event: Calculate the data block address of the trigger access of Entry4 according to the region number and trigger access offset in Entry4 (data block address = region number * L + trigger access offset), and then search the PHT under the current region size according to the instruction address in Entry4 and the calculated data block address;

[0110] Two, if (PC|Offset) is used as the trigger event: Search the PHT under the current region size according to the instruction address in Entry4 and the trigger access offset.

[0111] C4: Determine whether the PHT search is successful. If the search fails, do not change the region size setting of Entry4 and jump to C9. If the search is successful, continue to execute step C5.

[0112] C5: Read the access footprint and calculate the correct half-region prediction value. In this step, the access footprint vector stored in the entry found in the PHT will be read into the SU first and denoted as Vector1. Denote the access footprint vector in Entry4 as Vector2. The present invention will calculate a correct half-region prediction value based on Vector1 and Vector2 to determine whether to reduce the region size. The correct half-region prediction value reflects the number of data blocks with accurate predictions in the half region that does not include the triggering access. The specific calculation method is as follows:

[0113] 1. First, perform a bitwise exclusive OR operation on Vector1 and Vector2 to obtain Vector3;

[0114] 2. Clip Vector3 according to the region where the triggering access offset in Entry4 is located to obtain Vector4. If the triggering access in Entry4 is in the first half region (i.e., the offset < L / 2), then keep the second half of Vector3 (i.e., Vector4 = Vector3[L / 2, L)). Conversely, if the triggering access in Entry4 is in the second half region (i.e., the offset >= L / 2), then keep the first half of Vector3 (i.e., Vector4 = Vector3[0, L / 2));

[0115] 3. Count the number of 0s in Vector4, which is the required correct half-region prediction value.

[0116] C6: Judge the size relationship between the correct half-region prediction value and the preset threshold T. Compare the correct half-region prediction value calculated in step C5 with the preset threshold T (note that each SU under a region size has a preset T). If the correct half-region prediction value >= T, then do not change the region size setting of Entry4 and jump to step C9. If the correct half-region prediction value < T, then continue to execute step C7.

[0117] C7: Reduce the region size and construct a new entry Entry5. This step will reduce the region size of Entry4 and construct a new entry Entry5 with a smaller region size. The specific construction method is as follows. According to the triggering access offset in Entry4, it is divided into two cases to calculate the region number, triggering access offset, and access footprint vector of Entry5:

[0118] 1. If the triggering access offset in Entry4 < L / 2, then the region number of Entry5 = the region number of Entry4 * 2; the triggering access offset of Entry5 = the triggering access offset of Entry4; the access footprint vector of Entry5 is the first half of Vector1 (i.e., the access footprint vector of Entry5 = Vector1[0, L / 2));

[0119] 2. If the trigger access offset of Entry4 is greater than or equal to L / 2, then the area number of Entry5 = the area number of Entry4*2+1; the trigger access offset of Entry5 = the trigger access offset of Entry4 – L / 2; the access footprint vector of Entry5 is the second half of Vector1 (i.e., the access footprint vector of Entry5 = Vector1[L / 2,L)).

[0120] C8: Insert the new entry Entry5 into the lower PHT layer and delete the related information of this layer. This step will insert the Entry5 constructed in step C7 into the next PHT layer. At the same time, the related information in the PHT layer of this layer will be deleted (after calculating the data block address of the triggering access of Entry4 using the method of step C3, search and delete the related information in the PHT layer of this layer), and then end step C.

[0121] C9: Insert the table entry Entry4 into the PHT of this layer. Do not reduce the area size of Entry4, directly insert Entry4 into the PHT corresponding to the current area size, and then end step C.

[0122] C10: End.

[0123] Step D: Trigger access processing step. In step A5.2, this memory access is considered as a trigger access, such as Figure 6 and perform the following steps:

[0124] D0: Start.

[0125] D1: Search all PHTs. That is, search all PHTs in parallel according to the current access.

[0126] D2: Determine whether there is a successful PHT search, if there is a successful search, continue to step D3. Otherwise, all PHT searches fail, jump to step D5.

[0127] D3: Select the search result. This step is related to the trigger event adopted by the PHT. The present invention can support three designs: (PC|Offset+PC|Address), (PC|Offset) and (PC|Address). If (PC|Offset) or (PC|Address) is adopted, at most only one PHT will be successfully searched, and the result will be directly selected. If (PC|Offset+PC|Address) is adopted, there may be multiple PHTs that are successfully searched, which requires selecting a result from them. Each successfully searched PHT has two possible results: Result 1, the search is successful through the instruction address and the trigger access address (that is, the PC and Address search is successful); Result 2, the search is successful through the instruction address and the trigger access offset (that is, the PC and Offset search is successful). The selection method is as follows: If there is a PHT with result 1, the result of the PHT is directly selected. Otherwise, if there are multiple PHTs with result 2, a PHT is selected by default (for example, the PHT with the largest area size is selected by default). If only one PHT has result 2, the result of the PHT is selected.

[0128] D4: Update the search result to PB. This step will update the result selected in step D3 to the corresponding position in PB, and the update method is as follows. Let the result selected in D3 be at the i-th layer, and the region number of this access under the region size Ri is RN(i) (RN(i) = access block address / Li), and the region number under the region size R(n-1) is RN(n-1). First calculate the region offset (RO, RO = RN(i)%(2^(n-1-i))). Then search PB according to RN(n-1) to see if there is already an entry about RN(n-1). If so, update the Li bit of the access footprint vector in the table entry with the subscript in the range of [RO*Li,RO*Li+Li) to the Li bit of the access footprint vector of the selected result in D3. If not, insert a new table entry <region number, access footprint vector>. The region number is RN(n-1), the access footprint vector is a L(n-1) bit vector, the [RO*Li,RO*Li+Li) part is the access footprint vector of the result selected in D3, and the rest is 0.

[0129] D5: Allocate a new FT entry. If all searches in step D2 fail, randomly select an FT of a region size to allocate a new entry. Otherwise, allocate a new entry in the FT of the region size selected in step D3. The region number and (instruction address, trigger access offset) in the new entry are calculated based on the current memory access and the region size of the new entry.

[0130] D6: End.

[0131] Step E: A cache block replacement processing step. Whenever a data block is replaced in the cache, the address of the replaced data block is sent to the device of the present invention as input. Figure 7 As shown, the following address processing steps are performed:

[0132] E0: Start.

[0133] E1: Delete the relevant entries in the FT. This step first calculates the area number under each area size, then searches all FTs in parallel, and sets all successfully searched entries to invalid.

[0134] E2: Search all ATs. This step uses the area number calculated in step E1 to search all ATs in parallel, then invalidates all successfully searched entries and sends them to the shrinking unit SU under the area size where they are located, and enters the area size reduction detection step.

[0135] E3: End.

[0136] The above scheme can make fuller use of hardware resources and adaptively select a more appropriate area size according to the access characteristics of the application. In general, the present invention can achieve better pre-fetching effect with less hardware overhead and improve the performance of the application.

[0137] The specific implementation methods described above provide a detailed description of the technical solutions and beneficial effects of the present invention. It should be understood that the above is only the most preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, supplements and equivalent substitutions made within the scope of the principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A hardware data prefetching method capable of simultaneously supporting multiple region sizes, characterized in that: The following steps are involved: A hardware prefetch architecture that supports multiple region size settings is pre-designed, each region contains its own table FT, AT and PHT, wherein each table entry of FT is in the form of <region number, (instruction address, trigger access offset)>, each table entry of AT is in the form of <region number, (instruction address, trigger access offset, access footprint vector)>, each table entry of PHT is in the form of <trigger event, access footprint vector>, and an expansion unit EU for detecting whether to increase the region size is designed between the table FT and AT, and a contraction unit SU for detecting whether to reduce the region size is designed between the table AT and PHT, all region sizes share a prefetch buffer PB, PB uses the maximum supported region size, and is used to temporarily store access footprint vectors that have been predicted but have not issued a prefetch request; Receiving the instruction address and the accessed data block address of each memory access sent by the cache in the processor, predicting the data block address to be accessed based on the received instruction address and data block address and using the hardware prefetch architecture, and sending the data block address to the cache, so that the cache can load data from the lower storage device in advance; The address of each replaced data block sent by the high-speed cache in the processor is also received, and address processing is performed based on the received address of the replaced data block and using a hardware pre-fetch architecture.

2. The hardware data prefetching method capable of simultaneously supporting multiple region sizes according to claim 1, characterized in that: The method predicts the data block address to be accessed based on the received instruction address and data block address and sends it to the cache using a hardware prefetch architecture, including: Search for ATs contained in all regions in parallel, that is, calculate the region number corresponding to each region according to the address of the currently accessed data block and the region size of each AT, search for AT according to the region number, and update the access footprint vector for each successfully found AT table entry, that is, set the corresponding bit of the access footprint vector to 1 according to the offset of the data block address under the region corresponding to the successfully found AT table entry; When all ATs fail to find, search for FTs included in all area sizes in parallel, that is, search for all FTs according to the area number under each area size, and for each successfully found FT table entry, determine whether the offsets are equal, that is, determine and compare whether the offset of the currently accessed data block address under the successfully found area and the offset stored in the successfully found FT table entry are equal. When the offsets are equal, search for PB and send the predicted accessed data block address; when it is determined that the offsets are not equal, send the information of the offset and FT table entry of this access to EU, and after executing the area size increase detection step, search for PB and send the predicted accessed data block address; When all FTs fail to find, after executing the trigger access processing step, the PB is found and the address of the data block predicted to be accessed is sent.

3. The hardware data prefetching method capable of simultaneously supporting multiple region sizes according to claim 2, characterized in that: The step of searching for PB and sending the address of the data block predicted to be accessed includes: The PB is searched according to the area number of the maximum area size, and according to the found access footprint vector for which a prefetch request has not been issued, the address of the data block predicted to be accessed corresponding to the corresponding access footprint vector is sent to the cache.

4. The hardware data prefetching method capable of simultaneously supporting multiple region sizes according to claim 2, characterized in that: The step of detecting the increase in area size comprises: B1, construct an AT table entry, that is, construct an AT table entry of the current area size, recorded as Entry1. The area number, instruction address, and trigger access offset in the AT table entry directly use the information in the received FT table entry. The access footprint vector in the AT table entry is initialized according to the offset of this access and the offset in the FT table entry, and is used to represent the first two accesses to this area; B2, when judging that the current area is at the highest level, jump to B5.1, otherwise continue to execute B3; B3, calculate the mergeable area number and search for AT, where the mergeable area number is: the area number obtained by inverting the lowest bit of the area number in Entry1. Specifically, after calculating the mergeable area number, search for AT under the current area size according to the mergeable area number; B4, when it is determined that the AT search under the current area size is successful, jump to B5.2 to increase the current area size, otherwise execute B5.1 without changing the current area size; B5.1, inserting the current AT without changing the region size, that is, without changing the region size of the current region, directly inserting the entry Entry1 constructed by B1 into the AT under the current region size, and then jumping to B8; B5.2, read the content and delete the entry, that is, read the found AT entry content into EU, record it as Entry2, and delete the entry in AT; B6, merge the two AT table entries Entry1 and Entry2 and construct an AT table entry Entry3 with a larger area size; B7, the constructed Entry3 is inserted into an AT that is one level larger than the current area; B8, judging whether there is a table entry replaced, that is, judging whether the insertion operation of AT causes the original AT table entry to be replaced. If there is a table entry replaced, executing B9, otherwise directly ending; B9, performing a region size reduction detection step, that is, sending the replaced AT table entry Entry4 to the shrinking unit SU under the same region size, and performing a region size reduction detection step.

5. The hardware data prefetching method capable of supporting multiple region sizes simultaneously according to claim 4, characterized in that: The step of merging two AT table entries Entry1 and Entry2 and constructing an AT table entry Entry3 with a larger area size includes: The area number in Entry3 is obtained by shifting the area number of Entry1 right by one bit; the instruction address in Entry3 uses the instruction address of Entry2, and the trigger access offset and access footprint vector in Entry3 are set in two cases according to the lowest bit of the area number of Entry2; Case 1: If the lowest bit of the area number of Entry2 is 0, the trigger access offset of Entry3 = the trigger access offset of Entry2, and the access footprint vector of Entry3 is obtained by concatenating the access footprint vectors of the two in the order of (Entry2, Entry1); Case 2: If the least significant bit of the region number of Entry2 is 1, then the trigger access offset of Entry3 = the trigger access offset of Entry2 + the width L of the access footprint vector of Entry2, and the access footprint vector of Entry3 will be obtained by concatenating the access footprint vectors of the two in the order of (Entry1, Entry2).

6. The hardware data prefetching method capable of supporting multiple region sizes simultaneously according to claim 4, characterized in that: The region size reduction detection step includes: C1. Determine whether it is currently at the lowest layer of the region size. If it is at the lowest layer, jump to C9; otherwise, continue to execute C2; C2. Determine whether the first half or the second half of the access footprint vector in Entry4 is all 0. If so, jump to C7; otherwise, continue to execute C3; C3. Calculate the trigger event and search the PHT, that is, search whether there is an entry in the PHT of this layer that stores the same trigger event as Entry4. Specifically, it includes: If (PC|Offset+PC|Address) or (PC|Address) is used as the trigger event: Calculate the data block address of the trigger access of Entry4 according to the region number and trigger access offset in Entry4, and then search the PHT under the current region size according to the instruction address and the calculated data block address in Entry4; If (PC|Offset) is used as the trigger event: Search the PHT under the current region size according to the instruction address and trigger access offset in Entry4; C4. Determine whether the search of the PHT is successful. If the search fails, do not change the region size setting of Entry4 and jump to C9. If the search is successful, continue to execute C5; C5. Read the access footprint and calculate the half-region prediction correct value; C6. Determine the size relationship between the half-region prediction correct value and the preset threshold T. If the half-region prediction correct value >= T, do not change the region size setting of Entry4 and jump to C9. If the half-region prediction correct value < T, continue to execute C7; C7. Reduce the region size and construct a new entry Entry5; C8. Insert the new entry Entry5 into the PHT of the lower layer and delete the relevant information of this layer, and end; C9. Insert the entry Entry4 into the PHT of this layer and end.

7. The hardware data prefetching method capable of supporting multiple region sizes simultaneously according to claim 6, characterized in that: The step of reading the access footprint and calculating the half-region prediction correct value includes: Read the access footprint vector stored in the entry found in the PHT into SU and denote it as Vector1; Denote the access footprint vector in Entry4 as Vector2; First perform a bitwise exclusive OR operation on Vector1 and Vector2 to obtain Vector3; Crop Vector3 according to the region where the trigger access offset in Entry4 is located to obtain Vector4. If the trigger access of Entry4 is in the first half region, keep the second half of Vector3; conversely, if the trigger access of Entry4 is in the second half region, keep the first half of Vector3; Count the number of 0s in Vector4, which is the required half-region prediction correct value.

8. The hardware data prefetching method capable of supporting multiple region sizes simultaneously according to claim 6, characterized in that: Shrinking the region size and constructing a new table entry Entry5 includes: Based on the trigger access offset in Entry4, two cases are considered to calculate the region number, trigger access offset, and access footprint vector of Entry5:

1. If the trigger access offset of Entry4 < L / 2, then the region number of Entry5 = the region number of Entry4 * 2; the trigger access offset of Entry5 = the trigger access offset of Entry4; the access footprint vector of Entry5 is the first half of Vector1; 2. If the trigger access offset of Entry4 >= L / 2, then the region number of Entry5 = the region number of Entry4 * 2 + 1; the trigger access offset of Entry5 = the trigger access offset of Entry4 – L / 2; the access footprint vector of Entry5 is the second half of Vector1.

9. The hardware data prefetching method capable of simultaneously supporting multiple region sizes according to claim 2, characterized in that: The trigger access processing steps include: D1, Searching all PHTs, that is, searching all PHTs in parallel according to the current access; D2, Judging whether there is a successful PHT search. If there is a successful search, then continue to execute D3. Otherwise, all PHT searches fail, and jump to D5; D3, Selecting the search result, including: The selected search result is related to the trigger event adopted by the PHT. If the design (PC|Offset) or (PC|Address) is adopted, then at most only one PHT search will be successful, and the result is directly selected. If (PC|Offset + PC|Address) is adopted, then multiple PHT searches may be successful, and one result needs to be selected from them. Each successful PHT search has two possible results: Result 1, The search is successful through the instruction address and the trigger access address. That is, the PC and Address searches are successful; Result 2, The search is successful through the instruction address and the trigger access offset, that is, the PC and Offset searches are successful. The corresponding selection method is as follows: If there is a PHT with Result 1, then directly select the result of that PHT. Otherwise, if there are multiple PHTs with Result 2, then select one PHT in the default way. If there is only one PHT with Result 2, then select the result of that PHT; D4, updates the search result to the corresponding position in PB, including: remembering that the result selected in D3 is at the i-th layer, the region number of this access under the region size Ri is RN(i), and the region number under the region size R(n-1) is RN(n-1), first calculates the region offset RO, RO=RN(i)%(2^(n-1-i)), then searches PB according to RN(n-1) to see if there is already an entry about RN(n-1), if so, updates the access footprint vector in the entry with the Li bit in the range [RO*Li,RO*Li+Li) to the Li bit of the access footprint vector of the result selected in D3, if not, inserts a new entry <region number, access footprint vector>, where the region number in the new representation is RN(n-1), the access footprint vector is a vector of L(n-1) bits, the [RO*Li,RO*Li+Li) part is the access footprint vector of the result selected in D3, and the rest is 0; D5, allocates a new FT table entry. If all searches in D2 fail, a random FT of a region size is selected to allocate a new table entry. Otherwise, a new table entry is allocated in the FT under the region size selected in D3. The region number and (instruction address, trigger access offset) in the new FT table entry are calculated based on the current memory access and the region size of the new table entry.

10. The hardware data prefetching method capable of supporting multiple region sizes simultaneously according to claim 1, characterized in that: The method of updating the address based on the received replaced data block address and using a hardware pre-fetch architecture includes: E1, delete the relevant table entries in the FT, that is, first calculate the area number under each area size, then search all FTs in parallel, and set all the successfully searched table entries to invalid; E2, search all ATs, search all ATs in parallel according to the area number calculated in E1, and invalidate all successfully searched entries, and send them to the shrinking unit SU under the area size where they are located, and perform the area size reduction detection step.

Citation Information

Cited By

  • Data prefetching method, processor, electronic equipment and computer equipment

    CN120407443A

  • Data prefetching method, processor, electronic device, and computer device

    CN120407443B