GPGPU (General Purpose Graphics Processing Unit) performance optimization method based on perception thread bundle type
By sensing the cache bypass and memory scheduling mechanism of the thread warp type, the shared memory access of the thread warp in GPGPU is optimized, which solves the problems of thread warp execution time differentiation and shared memory divergence, and significantly improves the cache hit rate and instruction execution efficiency. Improved GPGPU performance.
Patent Information
- Application Number
- CN202410823101.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-25
- Publication Date
- 2024-09-24
AI Technical Summary
The execution time differentiation of thread warps in GPGPU leads to stalls, especially the delay differences caused by shared memory divergence, affecting instruction execution efficiency and performance.
By sensing the cache bypass mechanism, memory scheduling mechanism and cache insertion strategy of the thread warp type, it divides the thread warp types and optimizes the way they access the shared cache, reducing cache misses and improving cache hit rate and instruction execution efficiency.
Significantly improve the cache hit rate and instruction execution efficiency of GPGPU, improve the overall performance and enhance the competitiveness of the product.
Smart Images

Figure CN118689672A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of GPGPU performance optimization, and in particular to a GPGPU performance optimization method based on perceiving thread warp types. Background Art
[0002] GPGPU uses a single instruction multiple thread execution model. The highly concurrent nature of single instruction multiple threads greatly improves data processing efficiency. The threads of a GPGPU application are divided into three levels: thread grid, thread block, and thread. Multiple thread blocks can be launched into a stream multiprocessor for execution. Each thread block is divided into multiple thread bundles for execution in the processing unit. Each thread in the thread bundle executes the same instruction synchronously. Since the thread bundle is executed in lockstep, there are many reasons for the difference in execution time between different threads, which causes the entire thread bundle to pause for too long. One of the important sources of this pause is shared memory divergence, that is, the response time of shared memory requests of different threads in the thread bundle varies greatly. The thread bundle must wait for the slowest thread to complete the request response process, otherwise it cannot execute the next instruction. Therefore, solving the delay difference between different threads when accessing shared memory is conducive to speeding up the execution efficiency of instructions, thereby improving the performance of GPGPU, which is an issue worthy of attention. Summary of the invention
[0003] In order to solve the above technical problems, the present invention provides a GPGPU performance optimization method based on perceiving thread warp types.
[0004] The technical solution of the present invention is:
[0005] A GPGPU performance optimization method based on perceiving thread warp types is proposed. According to the hit rate of each thread in the thread warp in the shared cache, the thread warps can be divided into five types, namely (1) thread warps with all thread cache hits; (2) thread warps with most thread cache hits; (3) thread warps with balanced thread cache hits and misses; (4) thread warps with most thread cache misses; and (5) thread warps with all thread cache misses.
[0006] By utilizing the stable cache hit behavior of warps during a long execution cycle, GPGPU performance improvement is achieved through a warp-type-aware cache bypass mechanism, a warp-type-aware memory scheduling mechanism, and a warp-type-aware cache insertion strategy.
[0007] In the first step, a cache bypass mechanism that is aware of the thread warp type is executed to avoid the two types of thread warps, most thread cache misses and all thread cache misses, from accessing the shared cache, thereby increasing the cache space for other types of threads and improving cache hit efficiency.
[0008] In the second step, the scheduler gives priority to the thread warps hit by most threads to access external memory, which helps reduce the number of thread warp pauses and speed up the execution efficiency of instructions.
[0009] The third step is to preferentially insert the two types of thread bundles that have most thread cache hits or all thread cache hits into the shared cache at a position that is not easily cleared, to ensure that the two types of thread bundles are kept in the shared cache for a longer time and increase the number of cache hits.
[0010] Furthermore,
[0011] The shared memory access instruction contains descriptors and address information. The descriptor consists of three parts: thread block bid, thread warp wid and thread warp type wsort, which are used to indicate the specific thread warp characteristics. In the shared cache, each thread warp has two statistical counters, a cycle counter, a value comparison encoder and a record table.
[0012] After the value comparison encoder completes the type encoding of the thread warp, it outputs an encoding completion signal and transmits it to the cycle counter corresponding to its thread block bid and thread warp wid; when the cycle counter detects the encoding completion signal, it starts counting, and after the count reaches the set time period, it clears the value of the corresponding position in the record table and restarts the statistical counter, thereby realizing the periodic thread warp type identification process;
[0013] After the encoding is completed, the encoding result needs to be written back to the perception thread bundle type module for storage.
[0014] The warp type-aware module saves three types of information, including thread block bid, warp wid and warp type wsort, from the shared cache into a lookup table. When the lookup table is empty, the warp type-aware module does not perform type recognition on the input memory request instruction. Only when the lookup table is not empty, the warp type-aware module indexes the warp type wsort in the lookup table according to the thread block bid and warp wid in the memory request instruction, merges the wsort value into the memory request instruction, and passes it to the bypass module.
[0015] The bypass module includes a multiplexer, whose input signal comes from the sensing warp type module. The module has two output signals, one output is connected to the shared cache, and the other output is connected to the external memory;
[0016] The statistics completion signal from the shared cache is used as an enable signal to control the multiplexer. When the statistics completion signal is invalid, the multiplexer directly passes the input data to the shared cache to count the cache hits and cache misses of the thread warp. When the statistics completion signal is valid, the multiplexer determines whether the shared cache can be bypassed based on the thread warp type wsort in the memory instruction.
[0017] When the warp type is a balanced warp, a warp with most cache misses, or a warp with all cache misses, the memory request instruction is passed to the warp type-aware scheduling module and pushed into a low-priority request queue.
[0018] When the warp type is a warp with a majority of thread cache hits or a warp with all thread cache hits, the bypass module directly passes the memory request instruction to the shared cache.
[0019] The scheduling module contains a multiplexer and two memory request queues, one is a low-priority queue and the other is a high-priority queue. On the one hand, the scheduling module receives memory request instructions from the bypass module and sends them to the low-priority queue. On the other hand, it receives cache miss memory request instructions from the shared cache output and puts them into the high-priority queue.
[0020] The multiplexer needs to select one from the two request queues to send to the external memory. If the high-priority request queue is not empty, the request signal is always popped out from the head of the high-priority request queue and passed to the external memory. When the high-priority request queue is empty, the memory request signal is popped out from the head of the low-priority request queue and sent to the external memory.
[0021] The external memory receives the memory request signal from the scheduling module and writes the response result into the shared cache, which adopts the LRU replacement strategy.
[0022] The beneficial effects of the present invention are
[0023] The present invention can be applied to the performance optimization design of GPGPU projects, greatly improving the cache hit rate, accelerating the instruction execution efficiency of GPGPU, and enhancing the competitiveness of products. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 It is a flowchart of the present invention;
[0025] Figure 2 It is a memory request instruction format diagram of the present invention;
[0026] Figure 3 It is a structural block diagram of a numerical comparison encoder of the present invention;
[0027] Figure 4 It is a block diagram of the scheduling module of the present invention. DETAILED DESCRIPTION
[0028] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0029] The present invention provides a GPGPU performance method for perceiving thread warp types, comprising:
[0030] (1) The cache bypass mechanism of the execution-aware warp type can avoid the access of the shared cache L2 by warps of two types: most warp cache misses and all warp cache misses, thus reducing the space occupied by invalid shared cache L2 and increasing cache space for warp types with high cache hit rates, further improving the cache hit rate.
[0031] (2) Implement a cache insertion strategy that is aware of the type of thread warp, and prioritize inserting the two types of thread warps that have cache hits for most or all of the thread warps into locations in the cache that are not easily cleared, ensuring that the two types of thread warps are kept in the cache longer and increasing the number of cache hits;
[0032] (3) A memory scheduling mechanism that is aware of the thread warp type is implemented to increase the priority of the thread warps that have not been successfully converted into the majority of the thread warp cache hit types of all thread warps as much as possible, thereby reducing their queuing waiting time in the external memory and improving memory access efficiency.
[0033] The details are as follows:
[0034] 1. The shared memory access instruction contains descriptors and address information. The descriptor consists of three parts: thread block bid, thread bundle wid and thread bundle type wsort, which are used to indicate the specific thread bundle characteristics. In the shared cache, each thread bundle corresponds to two statistical counters, a cycle counter, a numerical comparison encoder and a record table. After the system reset is completed, the thread bundle type wsort is an invalid value at this time. Whenever a thread bundle accesses memory instruction into the shared cache, the two counters first read the last statistical data from the record table as the initial value based on the thread block bid and thread bundle wid, and then accumulate the number of cache hits and cache misses generated by the thread bundle this time, and the statistical results are written into the corresponding record table again; after each thread bundle is sampled 50 times in a row, the statistical counter is paused and a statistical completion signal is output. Ideally, the count value of all threads hitting the cache is 1599;
[0035] When the numerical comparison encoder detects a valid statistical completion signal, it will use the cache hit count and cache miss count corresponding to the thread warp at this moment as operands for size comparison, and the comparison results are encoded into 5 types.
[0036] (1) When the cache hit count is 1599, the warp is called the warp with all-thread cache hits, and the encoding result is wsort = 3'b111;
[0037] (2) When the number of cache hits is greater than the number of cache misses and the number of cache hits is between [1119, 1599), the thread warp is called a thread warp with majority cache hits, and the encoding result is wsort = 3'b110;
[0038] (3) When the number of cache hits is greater than the number of cache misses and the number of cache hits is between [799, 1119], or when the number of cache hits is less than the number of cache misses and the number of cache hits is between (479, 799], the thread warp is called a balanced thread warp, and the encoding result is wsort equal to 3'100;
[0039] (4) When the number of cache hits is less than the number of cache misses and the number of cache hits is between (0,479], the thread warp is called a thread warp with most thread cache misses, and the encoding result is wsort equal to 3'b001;
[0040] (5) When the cache hit count is equal to 0, the thread warp is called the thread warp with all thread cache misses, and the encoding result is wsort equal to 3'b000;
[0041] After the numerical comparison encoder completes the encoding of the thread warp type, it outputs an encoding completion signal and passes it to the cycle counter corresponding to its thread block bid and thread warp wid; when the cycle counter detects the encoding completion signal, it starts counting. After counting for 500 clock cycles, it clears the value at the corresponding position in the record table and restarts the statistical counter, thereby realizing the periodic thread warp type identification process. After the encoding is completed, the encoding result needs to be written back to the thread warp type perception module for storage.
[0042] 2. The warp type sensing module saves three types of information, namely, the thread block bid, the warp wid and the warp type wsort from the shared cache, into a lookup table. When the lookup table is empty, the warp type sensing module does not perform type recognition on the input memory request instruction. Only when the lookup table is not empty, the warp type sensing module will index the warp type wsort in the lookup table according to the thread block bid and the warp wid in the memory request instruction, and merge the wsort value into the memory request instruction and pass it to the bypass module.
[0043] 3. The bypass module includes a multiplexer, whose input signal comes from the module that senses the thread bundle type. The module has two output signals, one of which is connected to the shared cache and the other is connected to the external memory. The statistics completion signal from the shared cache is used as an enable signal to control the multiplexer. When the statistics completion signal is invalid, the multiplexer directly passes the input data to the shared cache for statistics of thread bundle cache hits and cache misses; when the statistics completion signal is valid, the multiplexer determines whether the shared cache can be bypassed based on the thread bundle type wont in the memory instruction. When the thread bundle type wont is equal to 3'b100, 3'b001 or 3'b000, the thread bundle type at this time is a balanced thread bundle, a thread bundle with most thread cache misses, and a thread bundle with all thread cache misses, then the memory request instruction is passed to the scheduling module that senses the thread bundle type and is pushed into the low-priority request queue. When the warp type wsort is equal to 3'b110 or 3'b111, the warp type at this time is a warp with a majority of thread cache hits or a warp with all thread cache hits, then the bypass module directly transparently transmits the memory request instruction to the shared cache.
[0044] 4. The scheduling module contains a multiplexer and two memory request queues, one is a low-priority queue and the other is a high-priority queue. On the one hand, the scheduling module receives memory request instructions from the bypass module and sends them to the low-priority queue; on the other hand, it receives cache-missed memory request instructions from the shared cache output and puts them into the high-priority queue. The multiplexer needs to select one from the two request queues to send to the external memory. If the high-priority request queue is not empty, the request signal is always popped out from the head of the high-priority request queue and passed to the external memory; when the high-priority request queue is empty, the memory request signal is popped out from the head of the low-priority request queue and sent to the external memory.
[0045] 5. The external memory receives the memory request signal from the scheduling module and writes the response result into the shared cache. The shared cache adopts the LRU replacement strategy. The response memory cache block is attached with a 3-bit thread warp type wsort. The shared cache module will insert the memory cache blocks with thread warp types 3'b111 and 3'b110 into the MRU position, and then insert the memory blocks with thread warp types 3'b000, 3'b001 and 3'b100 into the LRU position, thereby ensuring that the cache hit thread warps are retained in the shared cache for a longer time.
[0046] The above description is only a preferred embodiment of the present invention, which is only used to illustrate the technical solution of the present invention, and is not used to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.
Claims
1. A GPGPU performance optimization method based on perceiving thread warp types, characterized in that: According to the hit rate of each thread in the thread warp in the shared cache, the thread warps are divided into five types, namely (1) thread warps with all thread cache hits; (2) thread warps with most thread cache hits; (3) thread warps with balanced thread cache hits and misses; (4) thread warps with most thread cache misses; (5) thread warps with all thread cache misses; By utilizing the stable cache hit behavior of warps during the execution cycle, GPGPU performance improvement is achieved through a warp-type-aware cache bypass mechanism, a warp-type-aware cache insertion strategy, and a warp-type-aware memory scheduling mechanism.
2. The method according to claim 1, characterized in that By executing a cache bypass mechanism that perceives the type of thread warp, two types of thread warps, namely, most thread cache misses and all thread cache misses, are prevented from accessing the shared cache, thereby increasing the cache space for other types of threads.
3. The method according to claim 2, characterized in that Prioritize the thread warps that are hit by most threads to access external memory to reduce the number of thread warp pauses and speed up the execution efficiency of instructions.
4. The method according to claim 3, characterized in that: Prioritize inserting two types of thread warps with most thread cache hits or all thread cache hits into the shared cache at positions that are not cleared, to ensure that the two types of thread warps are kept in the shared cache for a longer time to increase the number of cache hits.
5. The method according to claim 3, characterized in that: The shared memory access instruction contains descriptors and address information. The descriptor consists of three parts: thread block bid, thread warp wid and thread warp type wsort, which are used to indicate the specific thread warp characteristics. In the shared cache, each thread warp has two statistical counters, a cycle counter, a value comparison encoder and a record table. After the value comparison encoder completes the type encoding of the thread warp, it outputs an encoding completion signal and transmits it to the cycle counter corresponding to its thread block bid and thread warp wid; when the cycle counter detects the encoding completion signal, it starts counting, and after the count reaches the set time period, it clears the value of the corresponding position in the record table and restarts the statistical counter, thereby realizing the periodic thread warp type identification process; After the encoding is completed, the encoding result needs to be written back to the perception thread bundle type module for storage.
6. The method according to claim 5, characterized in that The warp type-aware module saves three types of information, including thread block bid, warp wid and warp type wsort, from the shared cache into a lookup table. When the lookup table is empty, the warp type-aware module does not perform type recognition on the input memory request instruction. Only when the lookup table is not empty, the warp type-aware module indexes the warp type wsort in the lookup table according to the thread block bid and warp wid in the memory request instruction, merges the wsort value into the memory request instruction, and passes it to the bypass module.
7. The method according to claim 6, characterized in that The bypass module includes a multiplexer, whose input signal comes from the sensing warp type module. The module has two output signals, one output is connected to the shared cache, and the other output is connected to the external memory; The statistics completion signal from the shared cache is used as an enable signal to control the multiplexer; when the statistics completion signal is invalid, the multiplexer directly passes the input data to the shared cache to perform statistics on cache hits and cache misses of the thread warp; When the statistics completion signal is valid, the multiplexer determines whether the shared cache can be bypassed based on the warp type wsort in the memory instruction; When the warp type is a balanced warp, a warp with most cache misses, or a warp with all cache misses, the memory request instruction is passed to the warp type-aware scheduling module and pushed into a low-priority request queue. When the warp type is a warp with a majority of thread cache hits or a warp with all thread cache hits, the bypass module directly passes the memory request instruction to the shared cache.
8. The method according to claim 7, characterized in that The scheduling module contains a multiplexer and two memory request queues, one is a low-priority queue and the other is a high-priority queue. On the one hand, the scheduling module receives memory request instructions from the bypass module and sends them to the low-priority queue. On the other hand, it receives cache-miss memory request instructions from the shared cache output and puts them into the high-priority queue. The multiplexer needs to select one from the two request queues to send to the external memory. If the high-priority request queue is not empty, the request signal is always popped out from the head of the high-priority request queue and passed to the external memory. When the high-priority request queue is empty, the memory request signal is popped out from the head of the low-priority request queue and sent to the external memory.
9. The method according to claim 8, characterized in that The external memory receives the memory request signal from the scheduling module and writes the response result into the shared cache, which adopts the LRU replacement strategy.
