Cache prefetching method and device of graph neural network, terminal and medium
By identifying the hybrid memory access mode of graph neural networks and calculating candidate prefetch addresses, the problem of low hit rate of traditional processors in processing graph neural network memory accesses is solved, achieving more efficient cache prefetching and accurate prefetching. requests, improving the cache hit rate.
Patent Information
- Application Number
- CN202410615111.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-17
- Publication Date
- 2024-09-03
AI Technical Summary
It is difficult for traditional processors to efficiently handle the complex mixed memory access patterns of graph neural networks in the memory access process, resulting in low hit rates for the on-chip second-level cache and the last level cache.
Use the preset hybrid memory access mode of large page and super cache line recognition graph neural network to calculate the candidate prefetch address, and decide whether to send a prefetch request to the second level cache or the last level cache based on its confidence level, through the filter Determine whether the address has been prefetched to avoid false positive rates.
It improves the hit rate of the on-chip second-level cache and the last-level cache of the graph neural network, reduces the false alarm rate of abnormal network traffic, and enhances the accuracy and coverage of prefetching.
Smart Images

Figure CN118585486A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of on-chip cache technology, and in particular to a cache prefetching method, device, terminal and medium for a graph neural network. Background Art
[0002] During the operation of the graph neural network, the graph aggregation phase and the graph update phase are executed alternately. The memory access pattern of the graph aggregation phase is mainly irregular, while the memory access pattern of the graph update phase is usually regular. This leads to a mixed memory access pattern in which regular and irregular patterns coexist in the memory access process of the graph neural network. However, most traditional processors only consider regular memory access patterns based on spatial locality, and are unable to efficiently cope with and process this complex mixed memory access pattern, resulting in low on-chip second-level cache and last-level cache hit rates of the graph neural network. Summary of the invention
[0003] The present invention provides a cache prefetching method, device, terminal and medium for a graph neural network, which adopts preset large pages and super cache lines to identify the hybrid memory access mode of the graph neural network, calculates candidate prefetch addresses, and judges the correctness and prefetch positions of the candidate prefetch addresses, thereby improving the on-chip secondary cache and last-level cache hit rates of the graph neural network.
[0004] Determine whether the candidate prefetch address exists in the filter, and if so, abandon the candidate prefetch address; if not, insert the candidate prefetch address into the corresponding position of the filter, and issue a prefetch request for the candidate prefetch address;
[0005] Pre-fetch the candidate pre-fetch address into the second-level cache or the last-level cache according to the confidence level of the candidate pre-fetch address, so as to reduce the false alarm rate of network traffic anomaly.
[0006] In order to achieve the above object, an embodiment of the present invention provides a cache prefetching method for a graph neural network, comprising:
[0007] When receiving a memory access request from the secondary cache, pattern recognition is performed on a hybrid memory access mode of the graph neural network according to the memory access request and preset large pages and super cache lines to determine a prefetch mode;
[0008] Selecting a corresponding prefetcher to perform prefetching according to the prefetching mode, and calculating a candidate prefetching address;
[0009] Determine whether the candidate prefetch address has not been prefetched; if so, issue a prefetch request for the candidate prefetch address; if not, abandon the candidate prefetch address;
[0010] The prefetch request is sent to the second-level cache or the last-level cache according to the confidence of the candidate prefetch address.
[0011] As an improvement of the above scheme, the mixed memory access mode of the graph neural network is pattern recognized according to the memory access request and the preset large page and super cache line to determine the prefetch mode, including:
[0012] According to the current memory access address of the memory access request, updating a preset stride history table, a stride signature table and a mode table;
[0013] According to the updated stride history table, stride signature table, and pattern table, pattern recognition is performed on the mixed memory access pattern of the graph neural network according to the preset huge pages and super cache lines;
[0014] If the mode recognition is the first mode, determining the first pre-fetch mode;
[0015] If the mode is identified as the second mode, determining the second pre-fetch mode;
[0016] If the mode recognition is that the first mode and the second mode coexist, determining a third prefetch mode;
[0017] If the mode recognition is neither the first mode nor the second mode, a fourth prefetch mode is determined.
[0018] As an improvement of the above solution, the method of performing pattern recognition on the mixed memory access pattern of the graph neural network according to the preset large pages and super cache lines includes:
[0019] The memory access flow of the graph neural network is divided according to the granularity of a preset large page, and the memory access address of the graph neural network is normalized with a preset super cache behavior unit;
[0020] Pattern recognition is performed on the mixed memory access pattern of the graph neural network according to the normalized memory access address.
[0021] As an improvement of the above solution, selecting a corresponding prefetcher to perform prefetching according to the prefetching mode and calculating a candidate prefetching address includes:
[0022] Selecting a first prefetcher to perform prefetching according to the first prefetch mode, and calculating a first candidate prefetch address;
[0023] Selecting a second prefetcher to perform prefetching according to the second prefetching mode, and calculating a second candidate prefetching address;
[0024] Selecting the first prefetcher to perform prefetching according to the third prefetching mode, and calculating a third candidate prefetching address;
[0025] According to the fourth prefetch mode, a prefetcher corresponding to the previous prefetch is selected to perform prefetching, and a fourth candidate prefetch address is calculated.
[0026] As an improvement of the above solution, the determining whether the candidate prefetch address has not been prefetched includes:
[0027] If the candidate prefetch address exists in the filter table, and the valid bit of the candidate prefetch address is 1, then the candidate prefetch address has been prefetched;
[0028] If the candidate prefetch address exists in the filter table and the valid bit of the candidate prefetch address is 0, the candidate prefetch address is not prefetched;
[0029] If the candidate pre-fetch address does not exist in the filter table, the candidate pre-fetch address is not pre-fetched.
[0030] As an improvement of the above solution, sending the prefetch request to the second-level cache or the last-level cache according to the confidence of the candidate prefetch address includes:
[0031] Determining whether the confidence of the candidate prefetch address exceeds a specified threshold, and if so, sending the prefetch request to the secondary cache;
[0032] If not, the pre-fetch request is sent to the last level cache.
[0033] As an improvement of the above solution, before receiving a memory access request of the secondary cache, the cache prefetching method of the graph neural network further includes:
[0034] If the first-level cache misses, a memory access request to the second-level cache is triggered.
[0035] In order to achieve the above object, an embodiment of the present invention provides a cache prefetching device for a graph neural network, comprising:
[0036] A prefetch mode confirmation module is used to, when receiving a memory access request from the secondary cache, perform pattern recognition on the hybrid memory access mode of the graph neural network according to the preset large page and super cache line according to the memory access request to determine the prefetch mode;
[0037] A prefetch address calculation module, used for selecting a corresponding prefetcher for prefetching according to the prefetch mode, and calculating a candidate prefetch address;
[0038] A prefetch address determination module, used for determining whether the candidate prefetch address has not been prefetched; if so, issuing a prefetch request for the candidate prefetch address; if not, abandoning the candidate prefetch address;
[0039] The pre-fetch cache confirmation module is used to send the pre-fetch request to the second-level cache or the last-level cache according to the confidence of the candidate pre-fetch address.
[0040] In order to achieve the above-mentioned purpose, an embodiment of the present invention provides a terminal device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, and the processor implements the cache prefetching method of the above-mentioned graph neural network when executing the computer program.
[0041] In addition, an embodiment of the present invention also provides a computer-readable storage medium, which includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute the cache prefetching method of the above-mentioned graph neural network.
[0042] Compared with the prior art, the cache prefetching method, device, terminal and medium of a graph neural network disclosed in the embodiment of the present invention, when receiving a memory access request of the secondary cache, according to the memory access request, the hybrid memory access mode of the graph neural network is pattern recognized according to the preset large page and super cache line, and the prefetching mode is determined; according to the prefetching mode, the corresponding prefetcher is selected for prefetching, and the candidate prefetching address is calculated; it is determined whether the candidate prefetching address has not been prefetched; if so, a prefetching request for the candidate prefetching address is issued; if not, the candidate prefetching address is abandoned; according to the confidence of the candidate prefetching address, the prefetching request is sent to the secondary cache or the last level cache. It can accurately identify the constant stride mode and the compound stride mode from the hybrid memory access mode of the graph neural network, select the corresponding prefetcher for prefetching according to the prefetching mode, calculate the candidate prefetching address, and judge the correctness and prefetching position of the candidate prefetching address, so as to improve the accuracy and coverage of prefetching, thereby improving the on-chip secondary cache and last level cache hit rate of the graph neural network. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 It is a flowchart of a cache prefetching method of a graph neural network provided by an embodiment of the present invention;
[0044] Figure 2 A pre-fetch architecture diagram provided for an embodiment of the present invention;
[0045] Figure 3 It is a schematic diagram of a coordinator pre-fetching mode determination process provided by an embodiment of the present invention;
[0046] Figure 4 is an incremental sequence curve diagram of a compound stride mode provided by an embodiment of the present invention;
[0047] Figure 5 is a schematic diagram of an address space representation method provided by an embodiment of the present invention;
[0048] Figure 6 is a schematic diagram of a filter pre-fetching determination process provided by an embodiment of the present invention;
[0049] Figure 7 is a schematic diagram of the principle of compression vector provided by an embodiment of the present invention;
[0050] Figure 8 is a schematic diagram of an indexing method of a compressed vector provided by an embodiment of the present invention;
[0051] Fig. 9 It is a structural schematic diagram of a cache prefetching device for a graph neural network provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0052] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0053] It should be noted that the terms "comprises" and "specifically" and any variations of the present invention are intended to cover non-exclusive inclusions. For example, a process, method, system, product or apparatus comprising a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units that are not explicitly listed or inherent to these processes, methods, products or apparatuses.
[0054] See also Figure 1 , Figure 1 1 is a flow chart of a cache pre-fetching method for a graph neural network provided by an embodiment of the present invention. The cache pre-fetching method for a graph neural network includes:
[0055] S1, when receiving a memory access request from the secondary cache, according to the memory access request, pattern recognition is performed on the hybrid memory access mode of the graph neural network according to the preset large page and super cache line, and a prefetch mode is determined;
[0056] S2, selecting a corresponding prefetcher to perform prefetching according to the prefetching mode, and calculating a candidate prefetching address;
[0057] S3, determining whether the candidate prefetch address has not been prefetched; if so, issuing a prefetch request for the candidate prefetch address; if not, abandoning the candidate prefetch address;
[0058] S4: Send the prefetch request to the second-level cache or the last-level cache according to the confidence of the candidate prefetch address.
[0059] It should be noted that the memory access pattern of graph neural networks is difficult to identify, which is mainly manifested in two aspects: ① Since regular and irregular memory access patterns coexist during the operation of graph neural networks, regular patterns and irregular patterns will interfere with each other when the prefetcher performs pattern recognition. For example, when the graph aggregation stage of the graph neural network accesses the attribute data of a vertex and then accesses another vertex and its attribute data, the address increment may show the following memory access pattern: (+1, +1, +1, +9, +1, +1, +1). The appearance of increment 9 makes the regularity of increment 1 discontinuous, and it is difficult for the prefetcher to identify its regularity; ② Since the vertices, edges, and attribute data of the graph are stored separately in memory, there are frequent cross-page accesses in the graph aggregation stage, and the pages crossed are discontinuous.
[0060] Exemplarily, the cache prefetching method of the graph neural network is implemented by a prefetching server, and the prefetching server includes an on-chip cache combination prefetcher, for example, named Chameleon (translated as "chameleon"), such as Figure 2 As shown, Figure 2 The prefetch architecture diagram provided for the embodiment of the present invention, Chameleon mainly includes a coordinator and a filter, the coordinator includes three prefetchers (such as a constant stride prefetcher, a compound stride prefetcher and a previous line prefetcher), and the prefetch server can interact with the CPU (Central Processing Unit), the first level cache (L1 cache), the second level cache (L2 cache), and the last level cache (LLC cache) for information. When receiving a memory access request from the L2 cache, the coordinator determines the constant stride mode or the compound stride mode according to the hybrid memory access mode of the preset large page and super cache line recognition graph neural network according to the memory access request. If it is the constant stride mode, a constant stride prefetcher is selected for prefetching; if it is the compound stride mode, a compound stride prefetcher is selected for prefetching, and the corresponding candidate prefetch address is calculated and searched for in the filter. If it can be found, it means that the address has been prefetched not long ago, and no prefetch request is issued; if it cannot be found, the address is inserted into the filter table of the filter, and a prefetch request is issued; according to the confidence of the candidate prefetch address, the prefetch request is sent to the L2 cache or LLC cache. It is worth noting that the last level cache is generally a third-level cache (L3 cache).
[0061] In order to save storage overhead, the filter does not record the complete address of the memory access request, but records the 7-bit tag bit (16th to 22nd bits of the prefetch address) and 1 valid bit of the cache line of the memory access request prefetch address. The filter is indexed by bits 6 to 15 of the memory address, so a filter entry is equivalent to recording 17 bits of address information, which is enough to distinguish different memory access requests. In addition, checking the filter is a direct mapping process. Chameleon will not waste a lot of time looking up the filter, which can effectively reduce the prefetch latency. However, using bits 6 to 15 of the cache line to index the filter may cause conflicts while providing convenience: two cache lines may have the same bits 6 to 15, but different high bits, resulting in the filter entry being occupied by another cache line. In this case, Chameleon directly replaces the old cache line with the new one and issues a prefetch request for the current cache line.
[0062] Specifically, in step S1, according to the memory access request, pattern recognition is performed on the hybrid memory access mode of the graph neural network according to the preset large page and super cache line to determine the prefetch mode, including:
[0063] According to the current memory access address of the memory access request, updating a preset stride history table, a stride signature table and a mode table;
[0064] According to the updated stride history table, stride signature table, and pattern table, pattern recognition is performed on the mixed memory access pattern of the graph neural network according to the preset huge pages and super cache lines;
[0065] If the mode recognition is the first mode, determining the first pre-fetch mode;
[0066] If the mode is identified as the second mode, determining the second pre-fetch mode;
[0067] If the mode recognition is that the first mode and the second mode coexist, determining a third prefetch mode;
[0068] If the mode recognition is neither the first mode nor the second mode, a fourth prefetch mode is determined.
[0069] For example, Figure 3As shown, the coordinator updates the stride history table, stride signature table, and pattern table simultaneously according to the current memory access request to the L2 cache. The updated stride history table is used to identify whether it is a constant stride mode, and the updated stride signature table and pattern table are used to identify whether it is a compound stride mode. If only one of the constant stride mode and the compound stride mode is identified, the corresponding prefetch mode is determined to perform prefetching; if both modes are identified at the same time, the constant stride prefetch mode is determined to perform prefetching. If neither the constant stride mode nor the compound stride mode is identified, the previous row prefetch mode is determined to perform prefetching.
[0070] It should be noted that the identification of the constant stride mode mainly relies on a preset stride history table. The entries of the preset stride history table consist of 5 fields: tag, last offset, stride (delta), counter (count) and compression vector (com_vector). The tag consists of the high bits of the address and is used to identify different large pages. Considering the storage overhead of the stride history table and the fact that the high bits of the address do not change frequently during the memory access process, the length of the tag is set to 9 bits, including the 16th to 24th bits of the address. Last_offset represents the offset of the last accessed super cache line within the large page, which is used to calculate the difference between the two offsets, that is, the stride, and requires a total of 6 bits, consisting of the 10th to 15th bits of the address. For a 6-bit offset, the difference (stride) range is (-64, +64), so the length of delta is 7 bits, including 1 sign bit. Count is a 3-bit counter used to detect the length of the constant stride stream while avoiding interference caused by different strides.
[0071] Compound stride mode means that a set of different increment sequences will be repeated multiple times during the execution of the program, such as Figure 4As shown, repeated increment sequences (36, -37, 40, -2, -8, -35, 54, -32, 30, -53) appear during the operation of GIN (Graph Isomorphism Networks). Correspondingly, there are other similar repeated increment sequences of different lengths. In the embodiment of the present invention, such repeated increment sequences are collectively referred to as compound stride patterns because they contain multiple different strides. Unlike constant stride patterns, the recognition of complex stride patterns is very difficult in hardware implementation because it has multiple different stride sequences, so it is difficult to determine when the current compound stride pattern terminates or whether other memory access patterns interfere in the middle. Without considering the hardware overhead, the purpose of identifying compound stride patterns can also be achieved by recording a sufficiently long period of historical information, but this makes it lose its practicality. Therefore, the embodiment of the present invention designs a forward-looking pattern recognition method for compound stride patterns existing in the memory access process of graph neural networks, which includes a stride signature table and a pattern table. The stride signature table is used to record the historical incremental information of memory access, and the pattern table identifies the compound stride pattern therein according to the stride signature.
[0072] The preset pattern table records the 512 signatures most recently generated during the memory access process, that is, the signature in the stride signature table, as well as the increment when each signature is updated and the number of times the current signature is accessed. In the stride signature table, each large page has its own signature, but their signatures may be the same, that is, they exhibit the same composite stride pattern. In order to save storage overhead, the embodiment of the present invention does not distinguish the ownership of signatures in the pattern table, and all large pages use the same pattern table for pattern recognition. Among them, signature contains 18 bits, delta contains 7 bits, and count contains 4 bits, which are used to determine the depth of recursion.
[0073] The update of the pattern table is very simple. It also adopts the LRU (least recently used) method. When a new signature is generated in the stride signature table, the pattern table is searched. When the pattern table space is insufficient, the entry at the end of the pattern table is ejected; if the entry does not exist in the pattern table, the entry is inserted into the head of the pattern table, delta = cur_offset-last_offset, count is set to 1; if the entry exists in the pattern table, delta = cur_offset-last_offset, count + 1.
[0074] Since the recognition of compound stride patterns is forward-looking, its accuracy will continue to decrease with the depth of recursion, and the compression vector itself will also lose some accuracy. Therefore, for compound stride patterns, the conditions for triggering prefetching must be strictly controlled. In the process of pattern recognition, the embodiment of the present invention adds a decay factor α to the counter, so that the confidence of delta gradually decreases during the recursive process, thereby controlling the depth of prefetching. The confidence of delta P n It is calculated as follows:
[0075] P n =α n ·count,α<1, (1)
[0076] Where n represents the depth of recursion, which can also be understood as the depth of prefetching.
[0077] In the process of pattern recognition, when the confidence level P of delta n When the stride threshold threshold_c is exceeded, prefetching of the super cache line with an increment of delta is triggered, and the address of the specific cache line is calculated according to the value of the compression vector. The embodiment of the present invention also sets a compression threshold threshold_t for the compression vector in the stride signature table.
[0078] The preset stride signature table tracks the 256 large pages most recently accessed by the graph neural network, and uses the offset increment to generate a signature for each large page to record the historical stride of the large page. The entries in the preset stride signature table contain a total of 4 fields: tag, last offset (last_offset), compression vector (com_vector), and stride signature (signature). Similar to the preset stride history table, the tag in the preset stride signature table also occupies 9 bits, consisting of the 16th to 24th bits of the address; last_offset occupies 6 bits, consisting of the 10th to 15th bits of the address; the compression vector occupies 32 bits, a total of 16 units, 2 bits per unit, indexed by the 6th to 9th bits of the memory address. The stride signature is used to record the increment of the offset of the last 3 memory accesses, requiring a total of 18 bits. The signature is generated through a series of shift and XOR operations, as shown in the formula:
[0079] signature′=(signature<<6)^delta, (2)
[0080] Among them, signature′ is the current stride signature, and signature is the previous stride signature.
[0081] For example, the tag cur_tag, offset cur_offset and compressed vector index pos of the current memory access address are calculated according to the current memory access address of the memory access request; then the stride history table and the stride signature table are searched, if the tag cur_tag of the current memory access address is not in the stride history table and the stride signature table, a new entry is inserted into the stride history table and the stride signature table, the tags cur_tag, last_offset and dlta of the new entry in the stride history table are set to the offset cur_ffst of the current memory access address, and the values of the counter connt and the compressed vector index pos are set to 1; the tag cur_tag, last_offset and signature signature of the new entry in the stride signature table are set to the offset cur_offset of the current memory access address, and the value of the compressed vector index pos is set to 1; if the tag cur_tag of the current memory access address is in the stride history table, according to the last_offset of the found entry The offset increment cur_delta of the memory access request is calculated by the difference between t and the offset cur_offset of the current memory access address; if the offset increment cur_delta of the memory access request is the same as the previous increment delta, the values of the counter count and the compression vector index pos are increased, otherwise it is considered that the constant stride mode is not recognized; if the offset increment cur_delta of the memory access request is different from the previous increment delta, the offset increment cur_delta of the memory access request is used to update delta, and the values of the counter count and the compression vector index pos are reset to 1; if the tag cur_tag of the current memory access address is in the stride signature table, the offset increment delta of the memory access request is calculated according to the difference between the last_offset of the found entry and the offset cur_offset of the current memory access address, and the signature is updated, and finally cur_offset is used to update last_offset, and the value of the compression vector is increased by 1.
[0082] Specifically, the updating process of the preset stride history table is as follows:
[0083] Calculating, according to the current memory access address of the memory access request, a tag, an offset, and an index of a compression vector of the current memory access address;
[0084] If the tag of the current memory access address is not in the preset stride history table, inserting a new entry into the head of the preset stride history table;
[0085] If the mark of the current memory access address is in the preset stride history table, the offset increment of the memory access request is calculated according to the difference between the last offset of the found entry and the offset of the current memory access address;
[0086] If the offset increment is the same as the offset increment of the last memory access request, then increase the value of the counter and the index of the compression vector;
[0087] If the offset increment of the memory access request is different from the offset increment of the previous memory access request, the step size is updated using the offset increment of the memory access request, and the values of the counter and the compressed vector index are reset to 1;
[0088] The adjusted entry is moved to the head of the stride history table.
[0089] The updating of the preset stride history table ensures that the entries consisting of the most recently accessed addresses are always at the head of the stride history table, and the principle of temporal locality is used to reduce the delay caused by searching the stride history table.
[0090] Specifically, the updating process of the preset stride signature table is:
[0091] Calculating, according to the current memory access address of the memory access request, a tag, an offset, and an index of a compression vector of the current memory access address;
[0092] If the tag of the current access address is not in the preset stride signature table, inserting a new entry into the head of the preset stride signature table;
[0093] If the mark of the current memory access address is in the preset stride signature table, the offset increment of the memory access request is calculated according to the difference between the last offset of the found entry and the offset of the current memory access address;
[0094] The signature of the current memory access address is updated, and the value of the compression vector is increased by 1; and the adjusted entry is moved to the head of the stride signature table.
[0095] More specifically, the method of performing pattern recognition on the mixed memory access pattern of the graph neural network according to the preset large pages and super cache lines includes:
[0096] The memory access flow of the graph neural network is divided according to the granularity of a preset large page, and the memory access address of the graph neural network is normalized with a preset super cache behavior unit;
[0097] Pattern recognition is performed on the mixed memory access pattern of the graph neural network according to the normalized memory access address.
[0098] The preset large page is obtained by combining 16 pages; and the preset super cache line is obtained by combining 16 cache lines.
[0099] It should be noted that in order to more clearly express the memory access mode of the graph neural network, the embodiment of the present invention defines the concepts of large pages and super cache lines. In the memory management system of a modern processor, the size of a page is usually 4KB, and the size of a cache line is 64B. Therefore, a page contains 64 cache lines. This article combines 16 cache lines to form a super cache line. That is, a page contains 4 super cache lines. In order to better capture the rules between cross-page accesses, 16 pages are combined to form a large page, and the memory access flow of the graph neural network is divided according to the granularity of the large page. When learning the rules of the offset, it is no longer based on the granularity of the cache line, but on the unit of a super cache line. Therefore, within a large page, the intra-page offset of a super cache line still maintains 6 bits. As Figure 5 As shown, Figure 5 The super cache line, the offset of the super cache line in the huge page, and the huge page tag are shown in the address space. When performing pattern recognition, the memory access address of the graph neural network is first normalized in units of super cache lines. The formula is as follows:
[0100] A′=A>>10, (3)
[0101] Among them, A is the original address and A′ is the normalized address.
[0102] It should be noted that in modern applications, stride access is a ubiquitous memory access mode, especially for large-scale scientific computing where arrays and matrices are frequently used. In graph neural networks, vertices and edges are organized in the form of arrays, while adjacency matrices, eigenvectors, and other neural network parameters exist in the form of matrices, which meets the basic premise of stride access. The embodiment of the present invention refers to this stride mode in the graph neural network as a constant stride mode to distinguish it. The constant stride mode shown by the normalized address can be expressed as:
[0103] A′ n =A′ n-1 +delta, delta∈(-64, 64), (4)
[0104] Among them, A′ n is the normalized nth address; A′ n-1 is the normalized n-1th address; delta is the step size.
[0105] Specifically, the step S2 includes:
[0106] Selecting a first prefetcher to perform prefetching according to the first prefetch mode, and calculating a first candidate prefetch address;
[0107] Selecting a second prefetcher to perform prefetching according to the second prefetching mode, and calculating a second candidate prefetching address;
[0108] Select the first prefetcher to perform prefetching according to the third prefetch mode, and calculate a third candidate prefetch address:
[0109] According to the fourth prefetch mode, a prefetcher corresponding to the previous prefetch is selected to perform prefetching, and a fourth candidate prefetch address is calculated.
[0110] Exemplarily, formula (5) is used to calculate the super cache line address pref_addr′ to be accessed next time according to the current memory access address addr and the identified step size delta;
[0111] Then, formula (6) is used to calculate the single cache line address pref_addr (candidate prefetch address) to be prefetched according to the compressed vector index pos. The formula is as follows:
[0112] pref_addr′=addr>>10+delta, (5)
[0113] pref_addr=pref_addr′<<4+pos, (6)
[0114] For example, the process of prefetching a composite stride using a stride signature table and a pattern table. Update the stride signature table and the pattern table; then initialize the confidence of pattern recognition to the value of the counter count in the pattern table, and initialize the depth n of the forward prefetch to 0; then enter the loop for forward prefetching: first calculate the prefetch confidence P of the current loop according to formula (1) n , if P n When it is greater than the pattern recognition step threshold threshold_c, the prefetch address is calculated according to formulas (5) and (6); then the signature is updated according to the delta value of the pattern table for the next round of pattern recognition, and the depth n of the forward prefetch is increased by 1; the prefetch confidence P of the current cycle is n If it is not greater than the pattern recognition step threshold threshold_c, the loop ends and the forward prefetching stops.
[0115] Specifically, in step S3, determining whether the candidate prefetch address has not been prefetched includes:
[0116] If the candidate prefetch address exists in the filter table, and the valid bit of the candidate prefetch address is 1, then the candidate prefetch address has been prefetched;
[0117] If the candidate prefetch address exists in the filter table and the valid bit of the candidate prefetch address is 0, the candidate prefetch address is not prefetched;
[0118] If the candidate pre-fetch address does not exist in the filter table, the candidate pre-fetch address is not pre-fetched.
[0119] For example, the filter tracks the last 1024 prefetch requests issued and maintains a 1-bit validity bit for each request. When the coordinator generates a candidate prefetch address, Chameleon always checks the filter before issuing a prefetch. Figure 6 As shown, for example, if the filter already contains this cache line address (candidate prefetch address), and its large page tag is the same and its valid bit is 1, it means that the cache line address has been prefetched not long ago, and Chameleon will abandon the prefetch; if the filter already contains this cache line address, but its tag is different, replace the filter entry of the cache line address, and set the valid bit to 1, and Chameleon will prefetch the cache line address again; if the filter does not contain this address, insert the cache line at the corresponding position of the filter, and set the valid bit to 1, and Chameleon will issue a prefetch request for the cache line address; when a prefetched cache line address is evicted from the cache, the filter clears the prefetch record by resetting its valid bit to 0. Therefore, when a cache line address is found in the filter, but its valid bit is 0, it means that although the cache line address has been prefetched before, it has been evicted from the cache, and Chameleon will prefetch the cache line address again and set its valid bit to 1 in the filter.
[0120] Specifically, the step S4 includes:
[0121] Determining whether the confidence of the candidate prefetch address exceeds a specified threshold, and if so, sending the prefetch request to the secondary cache;
[0122] If not, the pre-fetch request is sent to the last level cache.
[0123] Exemplarily, if it is a constant stride mode prefetch, determine whether the values of the counter count and the compressed vector unit exceed the specified threshold. If both exceed the specified threshold, the candidate prefetch address is prefetched to the L2 cache. If only the counter count exceeds the specified threshold, it is prefetched to the LLC cache. If it is a compound stride mode prefetch, when the counter of the compressed vector exceeds the compression threshold, the corresponding candidate prefetch address is prefetched to the L2 cache, otherwise it is prefetched to the LLC cache.
[0124] Furthermore, before receiving a memory access request from the secondary cache, the cache prefetching method of the graph neural network further includes:
[0125] If the first-level cache misses, a memory access request to the second-level cache is triggered.
[0126] Furthermore, the cache prefetching method of the graph neural network also includes:
[0127] The access status of cache lines during the memory access process of the graph neural network is stored in the form of compressed vectors.
[0128] It should be noted that pattern recognition through super cache lines can directly prefetch the next super cache line according to the law of constant stride or compound stride. However, prefetching one super cache line at a time is not allowed for cache. Because the capacity of the cache is extremely scarce, and most of the data in the prefetched super cache line will not be used, they will not only occupy cache space, but may even cause the useful data in the cache to be replaced, causing serious cache pollution. At the same time, prefetching one super cache line at a time will also seriously increase the burden on memory bandwidth, and bandwidth is an extremely important and limited resource during the operation of the computer. In addition, prefetching one super cache line at a time also requires the design of a new cache replacement strategy to ensure that the prefetched super cache line can be completely placed in the cache, because most of the existing cache replacement strategies are based on the granularity of a single cache line.
[0129] Generally speaking, there are two ways to organize compressed vectors: one is horizontal compression, that is, compressing several cache lines adjacent to each other into one unit; the other is vertical compression, that is, compressing several cache lines adjacent to each other into one unit. A compressed vector uses one unit of data to represent the footprint information of multiple cache lines. It is a storage method commonly used in computer science to reduce hardware overhead at the expense of accuracy. If a simple bit vector is used to store the access status of each cache line in a large page, a total of 1024 bits are required.
[0130] Exemplarily, the embodiment of the present invention stores the footprint information of the graph neural network memory access process in the form of compressed vectors, and combines the memory access pattern recognition method based on super cache lines to achieve prefetching at the granularity of a single cache line. Figure 7 As shown, the embodiment of the present invention adopts a longitudinal compression method, using one unit to represent the access status of cache lines at the same position of all super cache lines in a large page. For example, the embodiment of the present invention compresses all super cache lines in a large page longitudinally, and uses one compression vector unit to represent the access status of 64 cache lines at the same position. Therefore, the length of the compression vector is 16 units. Figure 8 As shown, during the recognition of the memory access mode, the compression vector is indexed by bits 6 to 9 of the memory address.
[0131] During prefetching, since a compression vector may record cache line accesses on multiple super cache lines, and prefetching is only for cache lines on a single super cache line, if all cache lines at positions where the compression vector is 1 on the super cache line are prefetched into the cache during prefetching, multiple prefetches need to be issued. In order to more reasonably utilize the memory bandwidth, the embodiment of the present invention expands a unit of the compression vector to 2 bits, and each time an access occurs on the super cache line, the compression vector unit at the corresponding position is increased by 1. So far, the compression vector has another meaning, that is, the frequency of memory accesses triggered at different positions on the super cache line. This allows the compression vector to capture the spatial locality of memory accesses while identifying different cache lines. During prefetching, you can choose to prefetch to the L2 cache or LLC cache according to the strength of locality and the size of bandwidth, thereby improving the hit rate of the L2 cache or LLC cache. Therefore, for a large page, it only takes 32 bits to use a compression vector to identify the access status of each cache line in the large page, which reduces the storage overhead by nearly 97% compared to using a conventional bit vector.
[0132] A cache prefetch method for a graph neural network disclosed in an embodiment of the present invention determines a prefetch mode by performing pattern recognition on a mixed memory access mode of the graph neural network according to preset large pages and super cache lines based on a memory access request received from a secondary cache; selects a corresponding prefetcher for prefetching according to the prefetch mode, and calculates a candidate prefetch address; determines whether the candidate prefetch address has not been prefetched; if so, issues a prefetch request for the candidate prefetch address; if not, abandons the candidate prefetch address; and sends the prefetch request to the secondary cache or the last level cache based on the confidence level of the candidate prefetch address. It can accurately identify constant stride mode and compound stride mode from the mixed memory access mode of the graph neural network, avoid mutual interference between regular mode and irregular mode, select the corresponding prefetcher for prefetching according to the prefetch mode, calculate the candidate prefetch address, and judge the correctness of the candidate prefetch address and the prefetch position, so as to improve the accuracy and coverage of prefetching, thereby improving the on-chip secondary cache and last-level cache hit rate of the graph neural network; store the footprint information in the process of memory access of the graph neural network in the form of compressed vectors, and combine the memory access pattern recognition of super cache lines to realize prefetching at the granularity of a single cache line to avoid cache pollution; adopt efficient coordination strategies for multiple prefetchers through coordinators and filters to reduce prefetch delay, thereby improving the on-chip secondary cache and last-level cache hit rate of the graph neural network; use vertical compression units to represent the access status of cache lines at the same position of all super cache lines in a large page, avoid excessive storage overhead of the combined prefetcher, and thus realize its deployment to the on-chip memory.
[0133] See also Fig. 9 , Fig. 91 is a schematic diagram of the structure of a cache pre-fetching device for a graph neural network provided by an embodiment of the present invention, wherein the cache pre-fetching device for the graph neural network comprises:
[0134] The prefetch mode confirmation module 11 is used to, when receiving a memory access request from the secondary cache, perform pattern recognition on the hybrid memory access mode of the graph neural network according to the preset large page and super cache line according to the memory access request to determine the prefetch mode;
[0135] A prefetch address calculation module 12, used for selecting a corresponding prefetcher for prefetching according to the prefetch mode, and calculating a candidate prefetch address;
[0136] The prefetch address determination module 13 is used to determine whether the candidate prefetch address has not been prefetched; if so, a prefetch request for the candidate prefetch address is issued; if not, the candidate prefetch address is abandoned;
[0137] The pre-fetch cache confirmation module 14 is used to send the pre-fetch request to the second-level cache or the last-level cache according to the confidence of the candidate pre-fetch address.
[0138] Specifically, in the pre-fetch mode confirmation module 11, according to the memory access request, the hybrid memory access mode of the graph neural network is pattern recognized according to the preset large page and super cache line to determine the pre-fetch mode, including:
[0139] According to the current memory access address of the memory access request, updating a preset stride history table, a stride signature table and a mode table;
[0140] According to the updated stride history table, stride signature table, and pattern table, pattern recognition is performed on the mixed memory access pattern of the graph neural network according to the preset huge pages and super cache lines;
[0141] If the mode recognition is the first mode, determining the first pre-fetch mode;
[0142] If the mode is identified as the second mode, determining the second pre-fetch mode;
[0143] If the mode recognition is that the first mode and the second mode coexist, determining a third prefetch mode;
[0144] If the mode recognition is neither the first mode nor the second mode, a fourth prefetch mode is determined.
[0145] More specifically, the method of performing pattern recognition on the mixed memory access pattern of the graph neural network according to the preset large pages and super cache lines includes:
[0146] The memory access flow of the graph neural network is divided according to the granularity of a preset large page, and the memory access address of the graph neural network is normalized with a preset super cache behavior unit;
[0147] Pattern recognition is performed on the mixed memory access pattern of the graph neural network according to the normalized memory access address.
[0148] Specifically, the pre-fetch address calculation module 12 is used to:
[0149] Selecting a first prefetcher to perform prefetching according to the first prefetch mode, and calculating a first candidate prefetch address;
[0150] Selecting a second prefetcher to perform prefetching according to the second prefetching mode, and calculating a second candidate prefetching address;
[0151] Selecting the first prefetcher to perform prefetching according to the third prefetching mode, and calculating a third candidate prefetching address;
[0152] According to the fourth prefetch mode, a prefetcher corresponding to the previous prefetch is selected to perform prefetching, and a fourth candidate prefetch address is calculated.
[0153] Specifically, in the prefetch address determination module 13, determining whether the candidate prefetch address has not been prefetched includes:
[0154] If the candidate prefetch address exists in the filter table, and the valid bit of the candidate prefetch address is 1, then the candidate prefetch address has been prefetched;
[0155] If the candidate prefetch address exists in the filter table and the valid bit of the candidate prefetch address is 0, the candidate prefetch address is not prefetched;
[0156] If the candidate pre-fetch address does not exist in the filter table, the candidate pre-fetch address is not pre-fetched.
[0157] Specifically, the pre-fetch cache confirmation module 14 is used to:
[0158] Determining whether the confidence of the candidate prefetch address exceeds a specified threshold, and if so, sending the prefetch request to the secondary cache;
[0159] If not, the pre-fetch request is sent to the last level cache.
[0160] Furthermore, before receiving a memory access request from the secondary cache, the cache prefetching method of the graph neural network further includes:
[0161] If the first-level cache misses, a memory access request to the second-level cache is triggered.
[0162] A cache prefetching device for a graph neural network provided by an embodiment of the present invention is capable of implementing all processes of the cache prefetching method for a graph neural network in the above-mentioned embodiment. The functions of each module in the device and the technical effects achieved are respectively the same as the functions and technical effects achieved by the cache prefetching method for a graph neural network in the above-mentioned embodiment, and will not be repeated here.
[0163] An embodiment of the present invention provides a terminal device, which includes: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps in the cache prefetching method embodiment of the above-mentioned graph neural network are implemented. Alternatively, when the processor executes the computer program, the functions of each module in the cache prefetching device embodiment of the above-mentioned graph neural network are implemented.
[0164] The terminal device may be a computing device such as a desktop computer, a notebook, a PDA, and a cloud server. The terminal device may include, but is not limited to, a processor and a memory. Those skilled in the art will appreciate that the schematic diagram is merely an example of a terminal device and does not constitute a limitation on the terminal device. The terminal device may include more or fewer components than shown in the diagram, or may combine certain components, or different components. For example, the terminal device may also include an input / output device, a network access device, a bus, etc.
[0165] The processor may be a central processing unit, or other general-purpose processors, digital signal processors, application-specific integrated circuits, field programmable gate arrays or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc. The processor is the control center of the terminal device, and uses various interfaces and lines to connect various parts of the entire terminal device.
[0166] The memory can be used to store the computer program and / or module, and the processor realizes various functions of the terminal device by running or executing the computer program and / or module stored in the memory, and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card, at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0167] It should be noted that the device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0168] An embodiment of the present invention also provides a computer-readable storage medium, which includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute the cache prefetching method of the graph neural network as described in the above embodiment.
[0169] The above is a preferred embodiment of the present invention. It should be pointed out that a person skilled in the art can make several improvements and modifications without departing from the principle of the present invention. These improvements and modifications are also considered to be within the scope of protection of the present invention.
Claims
1. A cache prefetching method for a graph neural network, characterized in that: include: When receiving a memory access request from the secondary cache, pattern recognition is performed on a hybrid memory access mode of the graph neural network according to the memory access request and the preset large page and super cache line to determine a prefetch mode; Selecting a corresponding prefetcher to perform prefetching according to the prefetching mode, and calculating a candidate prefetching address; Determine whether the candidate prefetch address has not been prefetched; if so, issue a prefetch request for the candidate prefetch address; if not, abandon the candidate prefetch address; The prefetch request is sent to the second-level cache or the last-level cache according to the confidence of the candidate prefetch address.
2. The cache prefetching method of a graph neural network as claimed in claim 1, characterized in that: The method of performing pattern recognition on a hybrid memory access mode of a graph neural network according to the memory access request and the preset large page and super cache line to determine a prefetch mode includes: According to the current memory access address of the memory access request, updating a preset stride history table, a stride signature table and a mode table; According to the updated stride history table, stride signature table, and pattern table, pattern recognition is performed on the mixed memory access pattern of the graph neural network according to the preset huge pages and super cache lines; If the mode recognition is the first mode, determining the first pre-fetch mode; If the mode is identified as the second mode, determining the second pre-fetch mode; If the mode recognition is that the first mode and the second mode coexist, determining a third prefetch mode; If the mode recognition is neither the first mode nor the second mode, a fourth prefetch mode is determined.
3. The cache prefetching method of a graph neural network as claimed in claim 2, characterized in that: The method of performing pattern recognition on the mixed memory access pattern of the graph neural network according to the preset large pages and super cache lines includes: The memory access flow of the graph neural network is divided according to the granularity of a preset large page, and the memory access address of the graph neural network is normalized with a preset super cache behavior unit; Pattern recognition is performed on the mixed memory access pattern of the graph neural network according to the normalized memory access address.
4. The cache prefetching method of a graph neural network as claimed in claim 2, characterized in that: The selecting a corresponding prefetcher to perform prefetching according to the prefetching mode and calculating a candidate prefetching address includes: Selecting a first prefetcher to perform prefetching according to the first prefetch mode, and calculating a first candidate prefetch address; Selecting a second prefetcher to perform prefetching according to the second prefetching mode, and calculating a second candidate prefetching address; Selecting the first prefetcher to perform prefetching according to the third prefetching mode, and calculating a third candidate prefetching address; According to the fourth prefetch mode, a prefetcher corresponding to the previous prefetch is selected to perform prefetching, and a fourth candidate prefetch address is calculated.
5. The cache prefetching method of a graph neural network as claimed in claim 1, characterized in that: The determining whether the candidate prefetch address has not been prefetched includes: If the candidate prefetch address exists in the filter table, and the valid bit of the candidate prefetch address is 1, then the candidate prefetch address has been prefetched; If the candidate prefetch address exists in the filter table and the valid bit of the candidate prefetch address is 0, the candidate prefetch address is not prefetched; If the candidate pre-fetch address does not exist in the filter table, the candidate pre-fetch address is not pre-fetched.
6. The cache prefetching method of a graph neural network as claimed in claim 1, characterized in that: The step of sending the prefetch request to the second-level cache or the last-level cache according to the confidence of the candidate prefetch address includes: Determining whether the confidence of the candidate prefetch address exceeds a specified threshold, and if so, sending the prefetch request to the secondary cache; If not, the pre-fetch request is sent to the last level cache.
7. The cache prefetching method of a graph neural network as claimed in claim 1, characterized in that: Before receiving a memory access request of the secondary cache, the method further includes: If the first-level cache misses, a memory access request to the second-level cache is triggered.
8. A cache prefetching device for a graph neural network, characterized in that: include: A prefetch mode confirmation module is used to, when receiving a memory access request from the secondary cache, perform pattern recognition on the hybrid memory access mode of the graph neural network according to the preset large page and super cache line according to the memory access request to determine the prefetch mode; A prefetch address calculation module, used for selecting a corresponding prefetcher for prefetching according to the prefetch mode, and calculating a candidate prefetch address; A prefetch address determination module, used for determining whether the candidate prefetch address has not been prefetched; if so, issuing a prefetch request for the candidate prefetch address; if not, abandoning the candidate prefetch address; The pre-fetch cache confirmation module is used to send the pre-fetch request to the second-level cache or the last-level cache according to the confidence of the candidate pre-fetch address.
9. A terminal device, characterized in that: It includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, and when the processor executes the computer program, it implements the cache prefetching method of the graph neural network as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute the cache prefetching method of the graph neural network as described in any one of claims 1 to 7.
Citation Information
Cited By
Cache data prefetching processing method based on neural network
CN122285548A
