Method and apparatus for front-end gather / scatter memory merging

By introducing a system based on speculative prediction in the CPU core, merging and optimizing the memory access operations of aggregate/dispersed instructions, the problem of difficulty in supporting this instruction type by the general instruction set architecture is solved, and significant performance improvements are achieved.

CN116635823BActive Publication Date: 2024-10-29MARVELL ASIA PTE LTD +1
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202180066579.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-07-28
Publication Date
2024-10-29
Estimated Expiration
2041-07-28

AI Technical Summary

Technical Problem

General-purpose instruction set architectures struggle to effectively support gather/scatter instructions, leading to performance bottlenecks in modern scientific and data analysis applications, especially when dealing with sparse and adaptive data.

Method used

A system based on speculative prediction is designed. Through the integration of front-end and back-end pipelines, prediction units and load-store units are used to merge memory access operations and optimize the performance of the CPU core, including prediction units, decoding units and load-stores. The unit,utilizes history tables for prediction and updating,,merges multiple access operations and assigns them to,appropriate memory access channels.

Benefits of technology

Significantly improves the performance of gather/disperse instructions, achieves higher accuracy and processing efficiency, reduces the number of micro-operations, enhances the structure of the back-end pipeline, and provides significant performance gains.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116635823B_ABST
    Figure CN116635823B_ABST
Patent Text Reader

Abstract

A system for processing gather and scatter instructions may implement a front-end subsystem, a back-end subsystem, or both. The front-end subsystem includes a prediction unit configured to determine a predicted amount of coalesced memory access operations required for the instruction. The decode unit converts the instruction into a plurality of access operations based on the predicted amount, and transmits an indication of the plurality of access operations and the predicted amount to an issue queue. The back-end subsystem includes a load-store unit that receives a plurality of access operations corresponding to the instruction, determines a subset of the plurality of access operations that can be coalesced, and forms a coalesced memory access operation from the subset. The queue stores a plurality of memory addresses for a given load‑store entry to provide execution of the coalesced memory access.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] Related Applications

[0002] This application is a continuation of U.S. Application No. 16 / 944,141 filed on July 30, 2020. The entire teachings of the above application are incorporated herein by reference.

[0003] Government support

[0004] This invention was made with Government support under Government Contract No. AC52-07NA27344 and Subcontract B 620872 from the U.S. Department of Energy. The Government has certain rights in this invention. Background Art

[0005] Gather and scatter instructions are types of vector load / store instructions that access multiple memory locations. Gather instructions perform loads and scatter instructions perform stores. Gather / scatter memory operations (also called indexed memory accesses) are commonly seen in modern scientific and data analysis applications, which often involve sparse and adaptive data extraction, such as adaptive grids, sparse matrices, tensors, and graphs. For any given application context, gather / scatter operations can involve highly random or regular indirect offsets. These applications can present patterns with or without locality, and the sequence of these operations can be highly serialized or highly parallelized.

[0006] Historically, gather / scatter instructions have been supported in the context of vector supercomputers, but until recently have not been supported in general-purpose instruction set architectures. Recently, support for these instructions has appeared in general-purpose instruction sets such as x86 and ARM. Summary of the invention

[0007] Example embodiments include a system for processing gather and scatter instructions. The system may implement a front-end subsystem and / or a back-end subsystem. The front-end subsystem may include a prediction unit configured to determine a predicted amount of memory access operations to be merged required for an instruction, the instruction being a scatter instruction or a gather instruction. The decoding unit may be configured to 1) convert the instruction into a plurality of access operations based on the predicted amount, and 2) transmit an indication of the plurality of access operations and the predicted amount to an issue queue.

[0008] The system may also include a load-store unit configured to 1) determine an actual amount of coalesced memory accesses required for the instruction, and 2) provide an indication of the actual amount to the prediction unit. The prediction unit may update a table based on the predicted amount and the actual amount. The prediction unit may update an entry of the table, the entry corresponding to the instruction and including a field indicating the predicted amount and a confidence score indicating an estimated accuracy of the predicted amount. The prediction unit may update at least one of the predicted amount and the confidence score based on the actual amount.

[0009] The load-store unit may also determine a subset of the plurality of access operations that may be merged, and form a merged memory access operation from the subset. The load-store unit may analyze portions of the plurality of access operations to determine a subset of the plurality of access operations that may be merged. The load-store unit may also 1) assign the merged memory access operation to at least one register entry, and 2) execute the merged memory access operation via the load-store unit pipeline. The load-store unit may also determine a misprediction of the prediction unit based on a comparison of the predicted amount and the actual amount.

[0010] The plurality of access operations may have an amount equal to the predicted amount. The prediction unit may be further configured to determine the predicted amount by locating an entry of a table based on a program counter of the instruction, the predicted amount corresponding to a field of the entry. The prediction unit may be further configured to update the field based on an indication of a misprediction and refrain from updating the table if the predicted amount exceeds an actual amount of coalesced memory accesses required by the instruction. In response to the misprediction, the decode unit may be configured to retransmit the plurality of access operations with an indication of the actual amount of coalesced memory accesses required by the instruction.

[0011] In a further embodiment, the backend subsystem may include a load-store unit and a queue, such as a load reorder queue (LRQ) and / or a store reorder queue (SRQ). The load-store unit may be configured to: 1) receive a plurality of access operations corresponding to an instruction, the instruction being one of a scatter instruction and a gather instruction, 2) determine a subset of the plurality of access operations that may be merged, and 3) form a merged memory access operation from the subset. The queue may be configured to store a plurality of memory addresses for a given load-store entry, wherein the load-store unit may be configured to load an entry corresponding to the merged memory access operation into the queue, the entry indicating an address of each of the subsets.

[0012] The load-store unit may be further configured to determine a minimum amount of cache accesses required for the instruction based on the plurality of access operations, and may reserve a plurality of operation cycles corresponding to the minimum amount of cache accesses. The load-store unit may also perform coalesced memory access operations over a plurality of operation cycles via the memory access channel.

[0013] The subsystem may also include a decode unit configured to 1) convert the instruction into a plurality of access operations, and 2) transmit the plurality of access operations to the load-store unit. The decode unit may also transmit to the load-store unit an indication of a predicted amount of coalesced memory access operations required for the instruction, and the load-store unit may determine an actual amount of coalesced memory accesses required for the instruction and provide an indication of the actual amount to the prediction unit. The prediction unit may also update a table based on the predicted amount and the actual amount. The load-store unit may determine a misprediction based on a comparison of the predicted amount of coalesced memory access operations required for the instruction with the actual amount.

[0014] The load-store unit may also analyze portions of the plurality of access operations to determine a subset of the plurality of access operations that may be merged. The load-store unit may also be configured to assign the merged memory access operations to at least one memory access channel and to perform the merged memory access operations via the memory access channel. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] The foregoing will become apparent from the following more particular description of exemplary embodiments, as illustrated in the accompanying drawings, in which like reference numerals refer to the same parts throughout the different views. The drawings are not necessarily drawn to scale, emphasis instead being placed upon illustrating the embodiments.

[0016] Figure 1 is a block diagram of a memory access system in which example embodiments may be implemented.

[0017] Figure 2 is a block diagram of a history table in one embodiment.

[0018] Figure 3 is a flow chart illustrating the process of generating a history table and making predictions in one embodiment.

[0019] Figure 4 is a diagram illustrating prediction and access operations in one embodiment.

[0020] Figure 5 is a diagram showing prediction and access operations when an incorrect prediction is made.

[0021] Figure 6 is a diagram illustrating prediction and access operations in another embodiment.

[0022] Figure 7 is a flow chart illustrating the process of executing gather and scatter instructions in one embodiment. DETAILED DESCRIPTION

[0023] A description of example embodiments follows.

[0024] Gather / scatter instructions are vector load / store instructions that access multiple memory locations. Gather performs the instructions for loads and scatter performs the instructions for stores. Historically, gather / scatter instructions have been supported in the context of vector supercomputers, but until recently general-purpose instruction set architectures have not. Recently, support for these instructions has appeared in general-purpose instruction sets, such as x86 and ARM.

[0025] Supporting instructions that access multiple disjoint (non-contiguous) memory locations represents a new challenge for modern general-purpose core microarchitectures. Such microarchitectures typically include one or more load / store units, each of which is capable of reading from or writing to a single address per cycle. Modifying such pipelines to support access to multiple memory locations may be prohibitively expensive.

[0026] One implementation of gather / scatter instructions in a general-purpose core microarchitecture involves decoding a single gather / scatter instruction into a series of micro-operations (μops), each of which is responsible for performing a load or store of a single memory location. Such an implementation is simple in terms of hardware cost, but may provide little performance benefit over conventional (non-gather / scatter) load / store instructions. For workloads with significant use of gather or scatter instructions, this type of implementation may result in a significant bottleneck in processing the increased number of μops.

[0027] The example embodiments described herein provide microarchitectural support for optimizing the performance of gather / scatter instructions in a CPU core. These optimizations include mechanisms based on speculative prediction that allow μops to be fused in the front-end pipeline of the core, as well as enhancements to the structures in the back-end pipeline of the core, focusing on the load reorder queue, the store reorder queue, the reorder buffer, and the scheduler. In one example, multiple μops from gather / scatter instructions can be fused into a smaller number of macro μops, and each resulting fused macro μop corresponds to one or more μops in the original μop sequence. The rules for determining the set of μops that are fused together can be based on the addresses touched by those μops (e.g., whether the μop set is contiguous, or whether they reference a single cache line).

[0028] In an example embodiment, a fusion approach to gather / scatter operations can utilize a combination of enhancements to the front-end pipeline and the back-end pipeline. A speculative prediction-based solution allows μops to be fused in the core's front-end pipeline, and other enhancements can widen the structures in the core's back-end pipeline, including the load reorder queue, store reorder queue, reorder buffer, and scheduler. Fusion of both the front-end and back-end can provide significant performance gains.

[0029] Fusion in the front end can utilize a history-based fusion predictor to determine the number of fused μops (also called macro μops or fused μops) that should be passed to the back end of the core. In one exemplary embodiment tested, a 512-entry table using the maximum value of the most recently observed gather / scatter instances can achieve nearly 100% accuracy and substantial coverage. Another embodiment that implements the merged μops in the back end structure also shows performance gains. In combination, the gains from back end and front end fusion can be additive in many embodiments. There are also applications that can benefit more from either the front end approach or the back end approach.

[0030] Figure 1 1 is a block diagram of a memory access system 100 in which an example embodiment may be implemented. The front end module 110 communicates with one or more processor cores 105 that issue memory access requests, such as scatter and gather instructions. The front end module 110 may obtain those requests from the core 105 and provide confirmation or requested data to the core 105 when each request is completed. The front end module 110 may include components that make up the front end pipeline, including a prediction unit 120 and a decode unit 130, which are described in further detail below. For a given gather / scatter instruction, the front end module 110 may generate a plurality of μops that are forwarded to an issue queue 150, which assigns the μops to one or more load / store units 160A-160B. The load / store units 160A-160B, in turn, may perform a load or store operation according to the assigned μops. In doing so, the load / store units 160A-160B may access one or more of the L1 data cache 180, the L2 cache 182, and other memory devices (e.g., an L3 cache or DRAM, not shown) to load data to and / or store data from these devices. The load / store units 160A-160B may then return an acknowledgement and / or the requested data to the front end module 110, which in turn provides the acknowledgement and / or the requested data to the core 105.

[0031] The issue queue 150 and the load / store unit (LSU) 160A to 160B may be components of the back-end pipeline. In order to implement out-of-order processing of access requests, the back-end pipeline may further include an out-of-order resource 170. The resource may include a reorder buffer (ROB) 172, which is configured to maintain and retract μop in order, and may maintain an ordered list of access requests. The load reorder queue (LRQ) 174 and the store reorder queue (SRQ) each maintain a queue of pending load and store requests, respectively. The back-end pipeline may further include a physical register file PRN 178 for general registers, floating point registers, and / or predicate ("predicate") registers. Each general and / or floating point register file entry may be segmented into channels, which are written by gather instructions and read by scatter instructions. The predicate register file PRN 178 may store predicate register file entries with one bit per channel. These bits may control whether the operation on a particular channel is performed by a gather instruction or a scatter instruction. Arithmetic logic units (ALUs) 162A to 162D (and optionally, an FPU or SIMD unit) may perform various operations on subject data of memory accesses and / or may perform processing on the out-of-order resources 170 or the LSU 160 .

[0032] System 100 may implement one or more features described herein to optimize processing of gather / scatter instructions issued by core 105. These features include features implemented at the front-end pipeline and features implemented in the back-end pipeline, and those features may be implemented independently or in combination with each other.

[0033] At the front-end pipeline, the front-end module 110 may implement a prediction unit 120 that enables the module 110 to coalesce multiple memory accesses before sending to the back-end pipeline. Based on the previous history maintained at the history table 122, the prediction unit 120 may predict the number of coalesced accesses that will be made by a given gather / scatter instruction, and based on this prediction, the decode unit 120 may decode the gather / scatter instruction and create as many μops as predicted, rather than creating one μop for each lane (e.g., a vector register lane or a scalable vector extension (SVE) lane). The μop created for the gather / scatter instruction that the prediction unit 120 returns a prediction for may be referred to as a coalesced μop (or coalesced memory access operation).

[0034] Without merging, each gather / scatter μop will be responsible for only one lane. In contrast, each merged gather / scatter μop (a gather / scatter μop created using predictions from the prediction unit 120) can be responsible for more than one lane. The merged μop can have wider access to ensure that even if fewer μops are created, all bytes assumed to be accessed by the gather / scatter instruction will still be accessed. Because the memory location accessed by the gather / scatter instruction is not known until the instruction executes, the memory location accessed by the merged μop cannot be determined until later in the pipeline (e.g., when the merged μop is executed at the back-end pipeline). The history table 122 maintained by the prediction unit 120 may include entries marked with bits from the program counter (PC) of the gather / scatter instruction to track the history of each gather / scatter instruction and make predictions. The PC bits may also be used to index the history table 122.

[0035] Figure 2 History table 122 is shown in more detail. History table 122 may store multiple entries corresponding to gather / scatter instructions previously processed by a back-end pipeline (e.g., LSU), and each entry of the table may include multiple fields, including one or more of a transaction identifier (TID) field 205, a tag field 210, a μop count field 215, a use count field 220, and a prediction threshold field 225. TID field 205 (e.g., 2 bits) may contain a thread identifier of the thread that owns the entry. Tag field 205 (e.g., 62 bits) may include multiple PC bits and may be used to distinguish the history information of one PC from another. μop count field 215 (e.g., 5 bits) may indicate the predicted number of accesses that a gather / scatter instruction will require when memory accesses to the same cache line are merged; thus, it indicates the number of merged μops required by the instruction. Use count field 220 (e.g., 3 bits) may be a saturating counter that measures the number of times an entry has been accessed / updated, and may be used as an indicator of the confidence of the value in μop count field 215. The prediction unit 120 may be configured to use the entry for prediction when the entry usage count is above a configured prediction threshold. When the PC does not have an entry in the history table 122 or if the usage count of the PC in the table is not above the prediction threshold, the decode unit 130 may create as many μops as the number of channels (e.g., SVE channels) of the gather / scatter instruction. The history table 122 may include multiple rows with multiple entries in each row. Having multiple entries in a row may reduce conflicts caused by multiple PCs mapping to the same table row. Although each field of the history table 122 is shown with an example bit length, in further embodiments, the fields may have different or variable lengths.

[0036] Figure 3is a flow chart illustrating a process 300 of building a history at the history table 122 and making predictions via the prediction unit 120 in one embodiment. Figure 1 and 2 , when the system 100 is initialized or reset, the history table 122 may not contain entries. The history table 122 may also be periodically cleared (partially or completely) during operation to remove obsolete or unused entries. The entries of the history table 122 may be constructed as follows (305). When a gather / scatter instruction retires, a component of the back-end pipeline (e.g., LSUs 160A to 160B) may determine the number of merged accesses / μops required for the instruction. Then, the LSUs 160A to 160B (or other elements) may send a tuple containing the thread ID, PC, and the number of merged μops required for the instruction to the prediction unit 120. Upon receiving the tuple, the prediction unit 120 may fold the non-zero PC bits (i.e., bits other than bit-0 and bit-1) once, and may perform an exclusive OR (XOR) operation on the folded bits and the remaining non-zero bits to generate an index to access the history table 122. Alternatively, other indexing processes may be implemented. The number of folded bits may be equal to the index width (e.g., log2) (predictor table length). History table 122 may be accessed, and if a matching entry is found (e.g., TID 203 and μop count 215 are in the tuple, the tag calculated from the tuple matches TID 205, and μop count and tag 210 are in the table entry), then the use count field 220 of the entry may be incremented. If TID 205 and tag 210 match, but μop count 220 does not match, then use count 220 may be decremented by 2. If no TID 205 and tag 210 match and a free entry is available (e.g., the entry use count is 0), then a new entry may be initialized with data from the tuple, and the use count 220 of the new entry may be set to 1. In the event that no TID 205 and tag 210 match and no free entry is available, the use counts of all entries in the row may be decremented by 1. Alternatively, other replacement strategies may be implemented.

[0037] When updating the history table 122 to include entries associated with the newly received gather / scatter instruction, the prediction unit 120 may predict the instruction as follows. When a gather / scatter instruction is obtained (310), the prediction unit 120 may use a calculation comparable to the calculation described above for generating entries of the history table (e.g., an XOR calculation) to look up the history table 122 with an index generated from the PC of the gather / scatter instruction (315). If a matching entry is found and the usage count 220 of the entry is higher than the prediction threshold 225, the prediction unit 120 may predict that all accesses of the gather / scatter instruction can be completed with a reduced number of μops. The prediction unit 120 may determine the predicted amount of memory access operations merged (e.g., merged μops) based on the μop count field 215 of the matching entry, and may then pass this predicted amount to the decoder 130 (320). Then, when the instruction is decoded, the decoder 130 may generate multiple access operations (μops) based on the predicted amount (325). For example, the decoder 130 may generate a number of multiple access operations equal to the predicted amount. Alternatively, to increase the likelihood of an accurate prediction, decoder 130 may generate a number of μops greater than the predicted amount. A similar result may be achieved by building a tolerance in μop count field 215 of history table 122 .

[0038] The decoder unit 130 may then transmit the access operation and the indication of the predicted amount to the issue queue 150 for execution by the back-end pipeline (e.g., LSUs 160A to 160B) (330). The issue queue 150 may assign the access operation to one or more of the LSUs 160A to 160B that perform the access operation accordingly (e.g., load / store from / to the L1D cache 180, the L2 cache 182, and / or other cache / memory units). The operation of the LSUs 160A to 160B is described in further detail below. The LSUs 160A to 160B may also provide feedback indicating the accuracy of the predicted amount, wherein the feedback may indicate the actual amount of merged access operations required for the instruction, a confirmation that the prediction is accurate, or an indication that the prediction is incorrect (e.g., the instruction requires a greater amount of merged access operations than predicted). In response to the feedback, the prediction unit 120 may update the history table 122 accordingly (330). For example, after an accurate prediction, the prediction unit 120 may increment the usage count 220 of the corresponding entry. After the inaccurate prediction, the prediction unit may update the μop count 220 of the entry to match or exceed the actual amount of access operations merged as reported by the LSUs 160A-160B. After the inaccurate prediction, the front end module 110 may also perform a pipeline flush and repeat operations 310-330, where the decoder 130 may transmit a number of access operations corresponding to the actual amount of access operations merged.

[0039] Figure 4 A process 400 including prediction and access operations in one embodiment is shown. In this example, a gather / scatter instruction may include eight access operations (μops) 405, where each μop may occupy a separate lane as shown as lanes 0 to 7. Each of the access operations 405 may be executed in Figure 4 405 is represented by the starting address in the memory to be accessed by the operation. After the prediction unit 120 predicts the three merged memory access operations required for the instruction, the decoder unit 130 can transmit an indication of the access operation and the prediction amount to the issue queue 150. As a result of the prediction amount, the instruction is assigned three merged memory access operations (merged μop) 410. Then, one or more of the LSUs 160A to 160B can determine which operations in the access operation 405 can be merged based on the target address and / or other attributes, as described in further detail below. Based on this determination, the LSUs 160A to 160B can then merge the access operation 405 into three merged memory accesses 415. The three merged memory accesses 415 are in Figure 2 410. The merged memory accesses 415 are represented by the starting address for the sequence of memory accesses that includes all the memory accesses being merged. For example, the merged memory access access-0 is represented by address 0xfca740, which corresponds to the first of three adjacent addresses to be accessed by the three access operations that make up access-0. Once merged, the LSUs 160A-160B may assign each merged memory access 415 to an available merged memory access operation 410 and then execute each merged memory access operation accordingly.

[0040] Figure 5 The process 500 including prediction and access operations when the predicted amount of memory access operations to be merged is less than the number required for a given instruction is described. In this example, in addition to the prediction unit 120 predicting two memory access operations to be merged 510, the process 500 may be performed in conjunction with Figure 4 4. Compared to process 400, however, the instruction still requires three access operations 505, as indicated by the three coalesced memory accesses 515. As a result, if two of the memory accesses 515 are allocated to corresponding access operations 510, the third memory access ("Access-2") cannot be allocated and therefore cannot be executed by LSU 160A-160B. In response, LSU 160A-160B or another component may issue an indication of an incorrect prediction and issue a pipeline flush (530). The indication (or other notification of the number of coalesced memory access operations required) may also be transmitted to prediction unit 120 to update history table 122 as described above. After the pipeline flush, as described above with reference to Figure 3 and Figure 4As described above, process 500 may be repeated using a number of access operations that matches the desired number of coalesced memory accesses.

[0041] Figure 6 600 including prediction and access operations when the predicted amount of memory access operations to be merged exceeds the number required for a given instruction. In this example, in addition to the prediction unit 120 predicting four memory access operations to be merged 610, the process 600 may be performed in conjunction with Figure 4 Compared to process 400, the instruction still requires three access operations 605, as indicated by the three coalesced memory accesses 615. Therefore, after all three memory accesses in memory access 615 are assigned to corresponding access operations 610, the fourth memory access (access-3) remains unassigned and can be considered a "no-op". However, unlike Figure 5 In contrast to process 500, a pipeline flush is unnecessary because each of the coalesced memory accesses 615 can be performed by the assigned memory access operation 610. Even so, the LSUs 160A-160B or other components can issue a notification to the prediction unit 120 to update the history table 122 (630), thereby using the corresponding table entries to improve the accuracy of future predictions.

[0042] Return to Figure 1 , various aspects of system 100, and in particular LSUs 160A-160B, may be configured with a number of features to operate with front-end module 110 and perform merged access operations. Examples of such features and configurations are described below. Turning first to decoder 130, when a gather / scatter instruction is decoded in the front end using a prediction from prediction unit 120, each merged μop generated by decoder 130 may be assigned a sequence number ranging from 0 to n-1, where n is the number of μops generated for the gather / scatter instruction.

[0043] Turning to the LSUs 160A-160B, after issuing the merged memory access to the LSUs 160A-160B, the load / store μop may undergo a register read (REG) and address generation (AGEN) phase before performing a lookup in a translation lookaside buffer (TLB) and accessing the data cache. In the REG phase, the LSUs 160A-160B may read source registers. In the case of a gather / scatter μop, the source registers may be general registers, vector registers, and predicate registers. Without merging, each gather / scatter μop only requires information corresponding to its lane. However, a merged gather / scatter μop may be configured to fully read all input registers since it may access memory for multiple lanes of a gather / scatter instruction.

[0044] In the AGEN stage of the merged μop, LSU 160A to 160B can generate addresses for all active channels and then determine the number of merged accesses and their addresses and widths. The access width can be set so as to cover all accesses mapped to the cache line. The list of merged addresses can be sorted using a given standard so that the system 100 can access the merged addresses in the same order as all other merged μops when calculating the address, and only one merged μop is responsible for the merged access. From the merged address list, the merged μop can be responsible for the address with the same index as its sequence number. The address that the merged μop will access can be known at the end of the AGEN stage so that LSU 160A to 160B can look up the TLB in the next cycle. The determination of other information (such as bytes enabled for access and data offsets for individual channels) can be delayed until it is needed to be further down the pipeline. When the merged μop has a cache hit, the data offset for the individual channel can be used to return the correct byte for each channel. In order to return the correct data when a merged μop has a cache miss, the miss status holding register (MSHR) may be augmented to hold the data offsets for the individual lanes.

[0045] When the number of merged μops created for a gather / scatter instruction is less than the number of merged accesses required by the instruction, such as in the above process 500, a misprediction has occurred because memory accesses for some active channels in the gather / scatter instruction will not be completed. In the case of a misprediction, the pipeline can be flushed and instructions can be re-fetched starting from the gather / scatter instruction that incorrectly predicted the number of merged accesses. After the flush, the prediction unit 120 can stop executing the prediction to avoid the recurrence of the flush condition. To handle the flush, various mechanisms known in the art for flushing memory ordering violations can be used. To detect mispredictions, the active channels for the gather / scatter instruction and the active channels for the memory to be accessed by the merged μop can be tracked by the LSU 160A to 160B or another component. When the merged μop arrives at the AGEN stage at the LSU 160A to 160B along with the address it accesses, the LSU 160A to 160B can also determine the channels for which the memory will be accessed, and then can update the table that tracks the mask of the channel to be processed for each gather / scatter instruction. The table may be stored in an entry of a reorder buffer 172 associated with the instruction. The reorder buffer 172 may be configured to verify that the number of read / write channels matches the number of channels expected to read / write. Alternatively, the table may reside in the ISSQ 150, the LRQ 174, and / or the SRQ 176. When the merged μop is the last μop to reach the AGEN stage, the LSU 160A to 160B may compare the mask of the processed channel with the mask of the active channel. When the two are not equal, it may be determined that a misprediction has occurred, and the pipeline may then be flushed.

[0046] When the number of merged μops created for a gather / scatter instruction is greater than the number of merged accesses required for the instruction, such as in the above process 600, accesses for all active channels may be completed, and therefore, the over-predicted number of merged accesses may not be considered an incorrect prediction. However, because more μops than needed are created, it may be beneficial to ensure that incorrect architectural changes are not made in the system 100. When the merged μop reaches the AGEN stage, the LSUs 160A to 160B may determine the number of merged accesses for the instruction, and if its sequence number is greater than or equal to the number of merged accesses, the μop may be considered a "no operation" (nop) and may be marked as completed.

[0047] Turning to the prediction unit 120, when the μop count for static gather / scatter instructions is unstable, the unit 120 may experience lower precision. To improve the performance of the prediction unit 120 in this case, the prediction unit may be configured to track the maximum number of accesses observed to be merged, rather than tracking the exact number of accesses observed to be merged. In this configuration, for a given entry of the history table 122, the use count 220 may be incremented at each update to the history table 122, and predictions may be made when the use count 220 is above a prediction threshold. A predictor configuration that tracks the maximum number of accesses merged may be referred to as a "maximum" configuration, while a predictor configuration that tracks the exact number of accesses merged may be referred to as a "basic" configuration. In the maximum configuration, when predicting for a gather / scatter instruction, the prediction unit 120 may predict an amount corresponding to the maximum number of accesses merged for the gather / scatter instruction required in the past, and this amount is typically greater than the number of accesses merged required for the instruction. The additionally allocated μops may consume pipeline resources, such as entries of the reorder buffer 172, the load reorder queue 174, and the store reorder queue 176. However, this configuration may also benefit from a reduced number of incorrect predictions and pipeline flushes required after those incorrect predictions.

[0048] As described above, exemplary embodiments may improve memory access system 100 by reducing the number of gather / scatter μops. In addition to the foregoing features, the back-end pipeline of system 100 may also be configured to provide improved performance when processing gather / scatter instructions. For example, instead of decoding gather / scatter instructions as a sequence of μops (e.g., one per channel), a single μop may be decoded and delivered to the back-end of system 100 (e.g., LSUs 160A to 160B), and the back-end of system 100 may be configured to process gather / scatter instructions locally. In this configuration, some or all of out-of-order resources 170 may be configured with a field for each channel that supports gather / scatter instructions. Specifically, referring to Figure 1 , the LRQ 174 and SRQ 176 may be configured to have one or more fields for each entry that store multiple memory addresses for a given load-store entry, thereby enabling each entry of the LRQ 174 and SRQ 176 to track the address for each gather / scatter channel. The LSUs 160A-160B may be configured such that the corresponding load-store pipelines are extended to accept full-width gather / scatter instructions, and during address generation, the required number of cache accesses may be determined. In a later cycle, this gather / scatter instruction may cause the LSUs 160A-160B to block dispatch of other instructions to the load / store pipeline, thereby enabling the instruction to be internally reinserted into the load / store pipeline for multiple cycles (e.g., one cycle per required data TLB / cache lookup).

[0049] Figure 7 is a flow chart illustrating a process 700 that may be performed by a back-end pipeline including one or more LSUs to execute gather and scatter instructions in one embodiment. Figure 1 , LSU 160A may receive multiple access operations corresponding to a gather / scatter instruction (705) and determine a subset of the multiple access operations that may be merged (710). LSU 160A may then form a merged memory access operation from the subset (715). A queue, such as LRQ 174 (for gather operations) or SRQ 176 (for scatter operations) may be configured to store multiple memory addresses for a given load-store entry, and LSU 160A may load an entry corresponding to the merged memory access operation into the queue, wherein the entry indicates an address for each access operation of the subset (720).

[0050] LSU 160A may determine a minimum amount of cache accesses required for the instruction based on the plurality of access operations, and may reserve a plurality of operation cycles corresponding to the minimum amount of cache accesses. LSU 160A may then perform the coalesced memory access operation over the plurality of operation cycles via the memory access channel (725).

[0051] The LSU 160A may also communicate with the front end module 110, wherein the decode unit 130 converts the instruction into a plurality of access operations and transmits the plurality of access operations to the LSU 160A. The decode unit 130 may also transmit an indication of a predicted amount of coalesced memory access operations required for the instruction to the LSU 160A, and the LSU 160A may determine an actual amount of coalesced memory accesses required for the instruction and provide an indication of the actual amount to the prediction unit 120. The prediction unit 120 may also update the table 122 based on the predicted amount and the actual amount. The LSU 160A may determine a misprediction based on a comparison of the predicted amount and the actual amount of coalesced memory access operations required for the instruction.

[0052] The LSU 160A may also analyze portions of the plurality of access operations to determine a subset of the plurality of access operations that may be merged. The LSU 160A may also be configured to assign the merged memory access operations to at least one memory access channel and execute the merged memory access operations via the memory access channels (725).

[0053] In addition to the core microarchitecture described above, the example embodiments described above may be implemented in a graphics processing unit (GPU). One difference between CPU merging and merging performed in a GPU can be found in the execution model. In a GPU, if any thread in a warp experiences a delay (e.g., due to an L1 cache miss), the warp can be context-switched to another warp that can be ready for execution. In other words, latency can be hidden by context switching between a large number of threads. Therefore, in the GPU execution model, there may be no substantial difference in the way a GPU performs aggregation versus stride-1 loads (although aggregation can initiate multiple memory accesses). On the other hand, in the CPU execution model, the purpose of latency hiding is the ability of the processor to extract instruction-level parallelism (ILP), which requires processor resources such as load reorder queues (LRQs) and reorder buffers (ROBs). In this regard, GPU resources can be expanded as needed to handle aggregation operations, while stride-1 loads can be processed with fewer resources.

[0054] While exemplary embodiments have been particularly shown and described, it will be understood by those skilled in the art that various changes in form and details may be made without departing from the scope of the embodiments as encompassed by the following claims.

Claims

1. A system for processing gather and scatter instructions, comprising: a prediction unit configured to determine a predicted amount of coalesced memory access operations required by an instruction, the instruction being one of a scatter instruction and a gather instruction; a decode unit configured to 1) convert the instruction into a plurality of access operations based on the prediction amount, and 2) transmit the plurality of access operations and an indication of the prediction amount to an issue queue; and The prediction unit is further configured to determine the prediction amount by locating an entry of a table based on a program counter of the instruction.

2. The system of claim 1 , further comprising a load store unit configured to 1) determine an actual amount of coalesced memory accesses required by the instruction, and 2) provide an indication of the actual amount to the prediction unit. 3 . The system according to claim 2 , wherein the prediction unit is further configured to update a table based on the predicted amount and the actual amount. 4 . The system of claim 3 , wherein the prediction unit is further configured to update an entry of the table, the entry corresponding to the instruction and comprising a field indicating the predicted quantity and a confidence score indicating an estimated accuracy of the predicted quantity. 5 . The system according to claim 4 , wherein the prediction unit is further configured to update at least one of the predicted quantity and the confidence score based on the actual quantity.

6. The system of claim 2, wherein the load-store unit is further configured to 1) determine a subset of the plurality of access operations that can be coalesced, and 2) form a coalesced memory access operation from the subset. 7 . The system of claim 6 , wherein the load store unit analyzes portions of the plurality of access operations to determine the subset of the plurality of access operations that can be merged.

8. The system of claim 6, wherein the load-store unit is further configured to 1) distribute the coalesced memory access operation to at least one register entry, and 2) execute the coalesced memory access operation via a load-store unit pipeline. 9 . The system of claim 2 , wherein the load-store unit is further configured to determine a misprediction of the prediction unit based on a comparison of the predicted amount and the actual amount.

10. The system of claim 1, wherein the plurality of access operations have an amount equal to the predicted amount.

11. The system of claim 1, wherein the predicted quantity corresponds to a field of the entry.

12. The system of claim 9, wherein the prediction unit is further configured to update a field of the entry based on the indication of the misprediction.

13. The system of claim 11, wherein the prediction unit is further configured to refrain from updating the table if the predicted amount exceeds an actual amount of coalesced memory accesses required by the instruction.

14. The system of claim 9, wherein the decode unit is further configured, in response to the misprediction, to retransmit the plurality of access operations with an indication of an actual amount of coalesced memory accesses required by the instruction.

15. A method of processing a gather and scatter instruction, comprising: determining a predicted amount of coalesced memory access operations required by an instruction, the instruction being one of a scatter instruction and a gather instruction; converting the instruction into a plurality of access operations based on the prediction quantity; transmitting the plurality of access operations and an indication of the predicted quantity to an issue queue; as well as The pre-measure is determined by locating an entry of a table based on a program counter of the instruction.

16. The method according to claim 15, further comprising: determining an actual amount of coalesced memory accesses required by the instruction; as well as An indication of the actual amount is provided to a prediction unit.

17. The method according to claim 16, further comprising: A table is updated based on the predicted amount and the actual amount.

18. The method according to claim 17, further comprising: An entry of the table is updated, the entry corresponding to the instruction and including a field indicating the predicted quantity and a confidence score indicating an estimated accuracy of the predicted quantity.

19. The method according to claim 18, further comprising: At least one of the predicted quantity and the confidence score is updated based on the actual quantity.

20. The method of claim 16, further comprising: determining a subset of the plurality of access operations that can be merged; as well as A coalesced memory access operation is formed from the subsets.

21. The method according to claim 20, further comprising: Portions of the plurality of access operations are analyzed to determine the subset of the plurality of access operations that can be merged.

22. The method according to claim 20, further comprising: assigning the coalesced memory access operation to at least one register entry; as well as The coalesced memory access operation is performed via a load-store pipeline.

23. The method of claim 16, further comprising: A misprediction is determined based on a comparison of the predicted quantity and the actual quantity.

24. The method of claim 15, wherein the plurality of access operations have an amount equal to the predicted amount.

25. The method of claim 15, wherein the predicted quantity corresponds to a field of the entry.

26. The method of claim 23, further comprising: A field of the entry is updated based on the indication of the misprediction.

27. The method of claim 25, further comprising: If the predicted amount exceeds an actual amount of coalesced memory accesses required for the instruction, then updating the table is refrained from.

28. The method of claim 23, further comprising: In response to the misprediction, the plurality of access operations are retransmitted with an indication of an actual amount of coalesced memory accesses required by the instruction.

Citation Information

Patent Citations

  • Method and apparatus for front end gather / scatter memory coalescing

    US11567767B2

  • System and method for performing shaped memory access operations

    CN103218208A

  • Coalescing adjacent gather / scatter operations

    CN104756068A