A current goal for designers of high-performance computing (“HPC”) systems is to reach exascale computing, that is, exascale floating-point operations per second (“exaFLOPS”). To achieve exascale computing, designers envision an exascale computing system with many nodes, each of which has many cores. The use of many cores per node allows for increased performance through parallelization. Unfortunately, many application programs are constrained by limited memory bandwidth, even with many fewer cores in a node. As a result of the limited memory bandwidth, the memory read requests of the application programs are queued at the core, and the application programs stall while waiting for the queued read requests to be processed. One reason that the read requests are queued is that the cache into which the data is to be stored has no available outstanding request buffer (“ORB”). Whenever a memory request is to be sent to memory, an ORB is allocated to support issuing the memory request and receiving the corresponding response. If all the ORBs for a cache are allocated, the subsequent memory requests need to be queued pending deallocation of an ORB.
High-bandwidth memory (“HBM”) has the potential of allowing such application programs to execute without incurring significant delays due to stalling while waiting for queued memory read requests. HBM achieves higher bandwidth while using less power in a substantially smaller form factor than other memory techniques. The high bandwidth is achieved by stacking up to eight DRAM dies, which may include a base die with a memory controller. The memory bus of an HBM memory is very wide in comparison to other DRAM memories. An HBM stack of four DRAM dies may have two 128-bit channels per die for a total of eight channels and a total width of 1024 bits. Examples of HBM include the High-Bandwidth Memory provided by Advanced Micro Devices, Inc. and the Hybrid Memory Cube provided by Micron Technology, Inc.
Unfortunately, even with HBM, significant queuing delays can still occur because application programs that execute on HPC systems commonly execute a large number of vector or single-instruction-multiple-data (“SIMD”) instructions. These queuing delays can be very significant with certain memory access patterns such as a gather operation in which the consecutive elements of the vector or array are not consecutive in memory. Although HBM is theoretically capable of supporting such application programs without significant queuing delays, the number of ORBs associated with a cache can present a bottleneck, resulting in significant queue delays. Thus, if an application program has a memory access pattern that is optimally supported by 24 ORBs, but the cache has only 10 ORBs, significant queueing delays can occur. Current computer architectures typically have 10 ORBs for an L1 cache. Even application programs that do not perform gather operations may still incur significant queuing delays resulting from not enough ORBs because a vectorized loop may have many array references. Moreover, as cores support larger vector widths (e.g., 2048 bits) and support simultaneous multithreading (“SMT”) (e.g., 4-way) the number of ORBs will continue to be a limiting factor.
One solution would be to add more ORBs for the cache. Unfortunately, ORBs, especially for an L1 cache, are expensive in terms of area since they are close to the core and in terms of power since each cache miss initiates a fully associative look up encompassing all the ORBs for a matching address. In summary, while HBM will support significantly increased memory parallelism, current cores are unprepared to support such memory parallelism.
A high-bandwidth prefetcher (“HBP”) is provided that prefetches data of an application program as directed by execution of a prefetch instruction that is included in the application program. The prefetch instruction is an instruction of the instruction set of a processor. In some embodiments, the prefetch instruction directs the HBP to start prefetching a certain amount of data from memory, starting from a start address. After the HBP starts the prefetching, subsequent instructions of the application program are executed in parallel with the prefetching. For example, an application program may perform a gather operation that reads each 64th byte of an array with a size of 1M bytes. In such a case, the application program, prior to starting the gather operation, may execute the prefetch instruction with an operand specifying the start address of the array and the number of blocks (i.e., cache lines) to retrieve. If the start address of the array is 0.5M and the block size is 128 bytes, then the prefetch instruction may specify its operands to be a start address of 0.5M and a number of blocks of 8192. A prefetch instruction may be added to an application program by a programmer or by a compiler based on analysis of the code of the application program. The HBP allocates an ORB for prefetching and sets an address field of the ORB to the start address and a number of blocks field of the ORB to the number of blocks to retrieve. The HBP then issues initial prefetch requests to retrieve some number of blocks, referred to as the degree, from memory starting at the address into a cache (e.g., an L1 cache). Continuing with the example, if the degree is four, then the HBP may issue a first prefetch request for address 0.5M, a second prefetch request for address 0.5M+128, a third prefetch request for address 0.5M+256, and a fourth prefetch request for address 0.5M+384. When a prefetch response is received for all the outstanding prefetch requests, the HBP increases the address field of the ORB by the degree times the block size representing the address for the next prefetch and decreases the number of blocks field of the ORB by the degree representing the remaining number of blocks to prefetch. Continuing with the example, the HBP sets the address field of the ORB to 0.5M+512 and the number of blocks field of the ORB to 8188. If the number of blocks field of the ORB is greater than zero, the HBP continues issuing prefetch requests for the next degree blocks. This processing continues until the number of blocks field of the ORB is zero, in which case the prefetching is complete and the HBP deallocates the ORB. By specifying the number of blocks to prefetch, the prefetch instruction need be executed only once. As a result, the prefetch instruction can be moved outside of a loop that accesses the elements of an array. The moving of a prefetch instruction outside of a loop eliminates the overhead of executing a prefetch instruction during every iteration of the loop. This overhead can be especially significant for small loops.
The HBP allows an application program to specify what data to prefetch and when to start prefetching. In some embodiments, the prefetch instruction may have a degree operand so that the application program can specify the number of prefetch requests that can be outstanding. For example, if the application program sets the degree to four, the HBP will issue four prefetch requests at a time. If the application program sets the degree to eight, the HBP will issue eight prefetch requests at a time. In some embodiments, the prefetch instruction may select a maximum distance that is a fixed multiple of the degree or may have a maximum distance operand to allow the application program to specify the maximum distance. The distance represents the number of prefetch blocks that are in the cache but have not yet been read by the application program. For example, if the maximum distance is 16, the HBP will continue issuing prefetch requests (a degree number at a time) as long as the distance is less than 16. When the HBP issues a prefetch request, it increments a distance field of the ORB, and when the application program reads a prefetched block, the HBP decrements the distance field of the ORB. If the distance field of the ORB is equal to the maximum distance, the HBP pauses the issuance of prefetch requests until the application program reads more prefetched blocks. If the distance is a maximum distance and is a fixed multiple of the degree specified in the prefetch instructions, the programmer or the compiler need not perform any analysis of the application program to determine the maximum distance. The maximum distance that is selected by the prefetch instruction or specified by the maximum distance operand of the prefetch instruction may vary based on the code of the application, the design of the hardware, the level of the cache, and so on. For example, a maximum distance of four times the degree for an L1 cache may be suitable for many types of application programs. By allowing the prefetch instruction to specify the degree, the programmer or compiler can select a degree that is most appropriate given the number of arrays (more generally data streams) to be accessed simultaneously and given the maximum distance. Thus, if many arrays are accessed simultaneously, a smaller degree will result in a smaller maximum distance so that prefetching of the elements from the multiple arrays will not result in replacement in the cache of elements by other elements of the arrays before those elements are accessed by the application program.
In some embodiments, the HBP uses several fields associated with each block of the cache and several fields of an ORB. Table 1 provides a description of fields for each cache block, and Table 2 provides description of the fields for each ORB.
In some embodiments, the degree and the maximum distance are restricted to being a power of two. The HBP also aligns the address at which the HBP is to start prefetching to a block boundary that is a multiple of the degree, which is referred to as a degree boundary. For example, if the block size is 128 and the degree is four, the degree boundaries are addresses 0, 512, 1024, 1536, 2048, and so on. This allows for more efficient determination (e.g., using less logic and being faster) of whether an address is currently being prefetched by comparing the most significant bits of the address to the most significant bits of an address field of an ORB. Also, since the address of the prefetch instruction is a virtual address, the HBP needs to identify when the virtual address increases to a new page. In such a case, the HBP determines the corresponding physical address of the new page using, for example, a translation lookaside buffer (“TLB”). The aligning of the addresses to a degree boundary also allows for more efficient determination of whether the virtual address is increased to a new page based on whether the least significant bits are all zero.
With certain multiprocessing systems, an ORB associated with a core that is allocated for a first prefetch instruction of a first process executing on the core may be allocated to a second prefetch instruction of a second process as a result of a process switch that allows the second process to execute on the core. In such a case, when the first process resumes its execution on the core (or even on a different core), the prefetching of the first prefetch instruction will not be resumed. If the first prefetch instruction is located outside of a loop to avoid the overhead of executing a prefetch instruction during every iteration of the loop as described above and a process switch occurs during the loop, the remaining iterations of the loop will not have the benefit of the prefetching when execution of the first process resumes. To avoid losing the benefit of the prefetching, an operating system may save the state of the ORBs used for prefetching as part of the context or state of a process. When the process is to resume execution, the operating system may execute a prefetch instruction to resume prefetching for the process. Alternatively, if the operating system does not support resuming prefetching, a programmer or a compiler may modify the loop so that it includes an outer loop and an inner loop using a loop tiling or strip mining technique. For example, if the loop is to be executed 1,000,000 times, then the outer loop may specify 50 iterations and the inner loop may specify 20,000 iterations. Rather than being located outside of the outer loop, the prefetch instruction may be located inside the outer loop, but before the inner loop. In such a case, if a process switch occurs during execution of the loop, a prefetch instruction will be executed prior to the start of the next execution of the inner loop. Thus, the loop will have the benefit of prefetching for the subsequent iterations of the outer loop after the process resumes execution. Also, if a thread is created for each iteration of the outer loop, then each thread will execute its own prefetch instruction before executing the inner loop. Each thread will thus have the benefit of prefetching. The inner loop that is executed by each thread may also modified to have a further nested loop with a prefetch instruction that is executed for each iteration of the inner loop to allow the benefit of prefetching after execution of the thread resumes after a process or thread switch.
In some embodiments, the HBP may deallocate an ORB, which is allocated for a first prefetch instruction of an application program, before all the blocks that have been prefeteched have been read by the application program. The ORB may be deallocated, for example, because all the blocks have been prefetched or because the ORB has not been used recently to issue prefetch requests (e.g., the application program has exited a loop before reading all the data prefetched for the loop). If the HBP then allocates the deallocated ORB to a second prefetch instruction (e.g., for the same or different application program), then the HBP may not be able to distinguish whether a read of data in the cache is a read of data prefetched by the first prefetch instruction or the second prefetch instruction. As a result, the HBP would not know to whether to update or not update distance field in the ORB that is now allocated to the second prefetch instruction. So, the HBP may update the distance field when data of a prefetched block is read only when the physical address of the data being read and the physical address field of the ORB are on the same page. The HBP ensures that the calculated distance is greater than zero and not greater than the maximum distance because the physical address of the data being read may be greater than or may be much less than the physical address field of the ORB. Since the HBP does not update distance when the physical address field of the ORB and physical data of the data being read are not on the same page, the HBP would continue prefetching at a new page even if the actual distance exceeds the maximum distance. To avoid this continued prefetching, the HBP suppresses prefetching until the reads catch up with the prefetching. To avoid the delay in prefetching blocks at the beginning of a page when the reads eventually catch up and to avoid normal catch processing (described below), the HBP may prefetch the next degree blocks at the beginning of a new page irrespective of the distance field of the ORB. So, when the reads reach the new page, the first blocks of the new page will have been prefetched to avoid any delay and any catch up processing. The HBP will also start updating the distance field of the ORB when the reads reach the new page and no longer suppress the prefetching. Alternatively, when an ORB is to be allocated, the HBP may clear the prefetch field of each block in the cache whose orb field indicates that the block contains data prefetched for that ORB. In this way, the HBP will handle each read to such a block as if it was not prefetched and not update any ORB.
In some embodiments, the HBP employs additional logic (not shown in the Figures) to deallocate an ORB that would otherwise never be deallocated. If the prefetching is paused and the application program stops reading prefetched data, then the HBP will never execute the prefetch response logic or the read response logic for that ORB. As a result, the ORB would never be deallocated. To prevent such a failure to deallocate an ORB, the HBP increments a lookup field of an ORB whenever the ORB is accessed to determine whether the ORB has an outstanding request for a physical address. The HBP resets the lookup field whenever the HBP updates a field of the ORB indicating that the ORB is still being used. If the HBP increments the lookup field of an ORB to a maximum lookup, then the ORB is deallocated.
The following paragraphs describe various embodiments of aspects of the HBP. An implementation of the HBP may employ any combination of the embodiments.
A duplicated copy of the claims to be inserted after inventor review.
Although the subject matter has been described in language specific to structural features and/or acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims. In some embodiments, the operand of the prefetch instruction that specified an amount of data to prefetch may be designated as some other unit, such as number of bytes, rather than number of blocks. In such case, the HBP may convert the amount of data to numbers of blocks. In some embodiments, the HBP may be implemented in a processor as computer logic via discrete logic or microcode. The HBP may be employed to prefetch various levels of cache such as L1, L2, L3, and so on. The HBP may also be employed to prefetch from memory that is not high-bandwidth such as double data rate (“DDR”) synchronous dynamic random-access memory (“SDRAM”). Accordingly, the invention is not limited except as by the appended claims.
This application claims the benefit of U.S. Provisional Patent Application Nos. 62/385,857 filed Sep. 9, 2016, entitled “THE PERFECT MATCH: HBP, A HIGH-BANDWIDTH PREFETCHER FOR THE HIGH-BANDWIDTH MEMORY;” 62/385,866 filed Sep. 9, 2016, entitled “THE PERFECT MATCH: HBP, A HIGH-BANDWIDTH PREFETCHER FOR THE HIGH-BANDWIDTH MEMORY;” and 62/405,531 filed Oct. 7, 2016, entitled “HIGH-BANDWIDTH PREFETCHER FOR HIGH-BANDWIDTH MEMORY,” each of which is incorporated herein by reference in its entirety.
Number | Date | Country | |
---|---|---|---|
62405531 | Oct 2016 | US | |
62385857 | Sep 2016 | US | |
62385866 | Sep 2016 | US |