A method for calculating thread bundle size based on reconfigurable thread divergence

By constructing the CUDA kernel function, the thread block size is gradually increased and the GPU thread bundle size is calculated, which solves the problem of measurement difficulties in the existing technology, and realizes the precise measurement and calculation efficiency of thread bundle size Improvement.

CN118733473BActive Publication Date: 2024-11-08北京麟卓信息科技有限公司
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411200039.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-29
Publication Date
2024-11-08
Estimated Expiration
2044-08-29

AI Technical Summary

Technical Problem

The prior art is difficult to accurately measure the size of GPU thread bundles, affecting thread allocation and synchronization efficiency, resulting in a decrease in execution efficiency.

Method used

By constructing the first CUDA kernel function and the second CUDA kernel function, using the shared memory access conflict and thread divergence characteristics, gradually increase the thread block size, calculate the upper and lower limits of thread bundle size, and realize coarse-grained and fine-grained measurements.

Benefits of technology

In the absence of hardware manuals, precise measurement of GPU thread bundle size provides accurate parameter support for optimized computing programs and improves thread allocation and synchronization efficiency.

✦ Generated by Eureka AI based on patent content.
Patent Text Reader

Abstract

The present invention discloses a thread bundle size measurement method based on reconfigurable thread divergence, which constructs a first CUDA kernel function to reconstruct linear divergence so that threads in different thread bundles generate memory access conflicts to greatly increase the execution time of the threads, and gradually increases the thread block size so that the threads therein are assigned to different thread bundles for execution, resulting in an increase in execution time, thereby realizing coarse-grained measurement of the thread bundle size; constructs a second CUDA kernel function to reconstruct linear divergence so that the last thread in the thread block performs complex calculations to increase the execution time, and increases the thread block size in a fine-grained manner so that the last thread is assigned to different thread bundles for execution, resulting in a significant reduction in the execution time of the first thread, thereby realizing fine-grained and accurate measurement of the thread bundle size, and accurately measuring the thread bundle size of the GPU in a software manner without the aid of querying a hardware manual, thereby providing accurate parameter support for the optimization of related computing programs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of computer software development, and in particular relates to a thread warp size measurement method based on reconfigurable thread divergence. Background Art

[0002] Warp is an important concept in NVIDIA GPU architecture, especially in its CUDA (Compute Unified Device Architecture) programming model. A warp is essentially a group of threads that are executed in parallel on the GPU. The GPU scheduling unit schedules threads in warps, so warps are assigned to streaming multiprocessors (SMs) for execution together. Warps also provide a mechanism for synchronous execution, that is, all threads in the same warp execute the same instructions at the same time. In addition, the warp handles branches in such a way that when all threads in the warp take the same branch path, all threads will continue to execute synchronously. However, when threads have different branch paths, the warp will execute each path. At this time, not all threads will be active on each path, but the entire warp must wait for all paths to be executed before all threads can be terminated, which may result in reduced execution efficiency.

[0003] It can be seen that obtaining the size of GPU thread bundles is of great significance for the implementation of thread allocation and synchronization, the improvement of parallel efficiency, and the optimization of memory access patterns, especially for solving the problem of thread divergence. Summary of the invention

[0004] In view of this, the present invention provides a thread warp size measurement method based on reconfigurable thread divergence, which realizes the measurement of thread warp size in GPU in software mode.

[0005] The present invention provides a thread warp size calculation method based on reconfigurable thread divergence, which specifically includes the following steps:

[0006] Construct a coarse-grained measurement process for executing the first CUDA kernel function, and realize that when the thread block size is larger than the thread bundle size, a shared memory access conflict is triggered, resulting in an increase in execution time; construct a fine-grained measurement process for executing the second CUDA kernel function, and realize that only the last thread in the thread block executes the first calculation, and other threads execute the second calculation, and record the thread execution time of all threads in the thread block. The execution time of the first calculation is greater than the execution time of the second calculation;

[0007] Execute the coarse-grained measurement process, set the values ​​of the thread block size and the thread grid size, take the product of the thread block size and the thread grid size as the total number of threads to be started, start all threads, each thread executes the first CUDA kernel function, and record the execution time of this round; if the execution time of this round is greater than the execution time of the previous round and the difference is greater than the first threshold, then take the thread block size of this round as the upper limit of the thread bundle size and half of the thread block size as the lower limit of the thread bundle size, and after the coarse-grained measurement process is completed, set the thread block size to the lower limit of the thread bundle size and execute the fine-grained measurement process; otherwise, increase the thread block size to update the value, recompile and execute the coarse-grained measurement process;

[0008] Execute the fine-grained measurement process, set the thread grid size to 1, set the thread block size to the difference between the lower limit of the thread bundle size and the set value, use the product of the thread block size and the thread grid size as the total number of threads to be started, start all threads, and each thread executes the second CUDA kernel function; obtain the thread execution time recorded in this round, if the execution time of the last thread is greater than the execution time of other threads and the difference is greater than the second threshold, then the difference between the thread block size of this round and 1 is the actual thread bundle size, and end this process; otherwise, increase the thread block size with the set step size and then execute the fine-grained measurement process.

[0009] Furthermore, the implementation method of the first CUDA kernel function is: create a first shared memory array with a length equal to the thread block size, take the remainder of the thread position in the thread block divided by the thread block size as the target index, and perform a set number of write operations on the position of the target index in the first shared memory array.

[0010] Furthermore, the coarse-grained measurement process is implemented as follows: taking the product of the dimensions of the thread block and the thread grid and the sum of the positions of the threads in the thread block as the source index, and writing the data at the source index in the first global array to the target index in the first shared memory array; then performing a set number of accumulations on the data at the target index in the first shared memory array, and finally saving the accumulation results to the source index in the first global array.

[0011] Furthermore, the second calculation is: a combination of a series of trigonometric functions and basic arithmetic operations.

[0012] Furthermore, the second CUDA kernel function stores the result of the second calculation in a global array.

[0013] Furthermore, the fine-grained measurement process is implemented as follows: a second global array is initialized, and each thread saves the calculated result to a set position of the second global array.

[0014] Furthermore, the second CUDA kernel function only records the execution time of the first thread in the thread block.

[0015] Furthermore, the method of increasing the thread block size in the coarse-grained measurement process is: setting the thread block size to 2 to the nth power, and increasing n to increase the thread block size.

[0016] Furthermore, after executing the fine-grained measurement process, the thread execution time recorded in this round is obtained. If the execution time of this round is less than the execution time of the previous round and the difference is greater than the second threshold, the difference between the thread block size of this round and 1 is the actual thread bundle size, and this process ends; otherwise, the thread block size is increased by 1 in steps to update the value of the thread block size and execute step 4.

[0017] Furthermore, the setting step size is 1. Beneficial Effects

[0018] According to the trigger mechanism of shared memory access conflict, the present invention constructs a first CUDA kernel function to reconstruct linear divergence so that threads in different thread bundles generate memory access conflict to greatly increase the execution time of the threads, and gradually increases the thread block size so that the threads therein are assigned to different thread bundles for execution, resulting in increased execution time, thereby realizing coarse-grained measurement of the thread bundle size; according to the thread divergence characteristics, that is, the execution time of threads in the same thread bundle is the same, constructs a second CUDA kernel function to reconstruct linear divergence so that the last thread in the thread block executes complex calculations to increase the execution time, and increases the thread block size in a fine-grained manner so that the last thread is assigned to different thread bundles for execution, resulting in significantly reduced execution time of the first thread, thereby realizing fine-grained accurate measurement of the thread bundle size, accurately measuring the GPU thread bundle size in a software manner without the help of querying the hardware manual, and providing accurate parameter support for the optimization of related computing programs. DETAILED DESCRIPTION

[0019] The present invention is described in detail with reference to the following embodiments.

[0020] The present invention provides a thread bundle size measurement method based on reconfigurable thread divergence, the core idea of ​​which is: according to the triggering mechanism of shared memory access conflict, a first CUDA kernel function is constructed to reconstruct linear divergence so that threads in different thread bundles generate memory access conflict to greatly increase the execution time of the threads, and the thread block size is gradually increased so that the threads therein are assigned to different thread bundles for execution, resulting in increased execution time, thereby achieving coarse-grained measurement of the thread bundle size; according to the thread divergence characteristics, that is, the execution time of threads in the same thread bundle is the same, a second CUDA kernel function is constructed to reconstruct linear divergence so that the last thread in the thread block performs complex calculations to increase the execution time, and the thread block size is fine-grainedly increased so that the last thread is assigned to different thread bundles for execution, resulting in a significant reduction in the execution time of the first thread, thereby achieving fine-grained and accurate measurement of the thread bundle size.

[0021] The present invention provides a thread warp size calculation method based on reconfigurable thread divergence, which specifically includes the following steps:

[0022] Step 1: construct a coarse-grained measurement process for executing the first CUDA kernel function, which is used to realize a processing function that triggers a shared memory access conflict and causes an increase in execution time when the thread block size gradually increases to exceed the thread warp size, so as to determine the upper limit and the lower limit of the thread warp size.

[0023] Specifically, in the first CUDA kernel function, the thread block size is gradually changed so that its value gradually increases from a value less than the thread bundle size to a value greater than the thread bundle size. When the thread block size is greater than the thread bundle size, a shared memory access conflict is triggered, which leads to a significant increase in the execution time of the first CUDA kernel function. The principle of the first CUDA kernel function is that when the thread block size is not greater than the thread bundle size, all threads in the thread block are assigned to execute in the same thread bundle, and the specially constructed shared memory access conflict in the first CUDA kernel function is not triggered. When the thread block size is greater than the thread bundle size, the threads in the thread block will be assigned to execute in different thread bundles, which triggers the constructed shared memory access conflict. Therefore, the relationship between the current thread block size and the thread bundle size can be judged, and the value range of the thread bundle size can be determined.

[0024] The first CUDA kernel function can be implemented as follows: create a first shared memory array with a length equal to the thread block size, use the remainder of the thread position in the thread block divided by the thread block size as the target index, and perform a set number of write operations on the position of the target index in the first shared memory array.

[0025] The implementation method of the coarse-grained measurement process is as follows: set the initial values ​​of the thread block size and the thread grid size, and use the product of the thread block size and the thread grid size as the total number of threads to be started; start all threads, each thread executes the first CUDA kernel function, creates a first shared memory array with a length of the thread block size, and uses the remainder of the thread position in the thread block divided by the thread block size as the target index, and performs a set number of write operations on the position of the target index in the first shared memory array.

[0026] Another implementation method of the coarse-grained measurement process is: setting the initial values ​​of the thread block size and the thread grid size, initializing the first global array, and taking the product of the thread block size and the thread grid size as the total number of threads to be started; starting all threads, each thread executes the first CUDA kernel function, creating a first shared memory array with a length of the thread block size, taking the remainder of the thread position in the thread block divided by the thread block size as the target index, taking the product of the dimensions of the thread block and the thread grid and the sum of the thread position in the thread block as the source index, and writing the data at the source index in the first global array to the target index in the first shared memory array; then performing a set number of accumulations on the data at the target index in the first shared memory array, and finally saving the accumulation result to the source index in the first global array.

[0027] Step 2: Construct a fine-grained measurement process for executing the second CUDA kernel function, which is used to realize that only the last thread in the thread block executes complex calculations so that its execution time is the longest. Based on the thread divergence characteristic that all threads in the same thread bundle have the same execution time, when the thread block size is larger than the thread bundle size so that its last thread is executed in other thread bundles, the execution time of the first thread in the thread block will be significantly less than the execution time of the last thread, so the thread bundle size can be accurately determined from the thread level.

[0028] Among them, since accessing memory may cause the execution time to change each time, the complex calculation performed by the last thread in the second CUDA kernel function only involves calculation, and does not involve operations such as memory access. For example, the complex calculation in the present invention can be a combination of a series of trigonometric functions and basic arithmetic operations to increase the calculation complexity and thus increase the calculation time. The first thread or the last thread in the thread block is determined according to the size of the thread ID.

[0029] In order to prevent the complex calculation from being optimized by the compiler and further improve the reliability of the second CUDA kernel function, the present invention saves the result of the complex calculation in a global variable in the second CUDA kernel function.

[0030] The fine-grained measurement process is implemented as follows: set the thread grid size to 1, set the thread block size to the difference between the lower limit of the thread bundle size and the set value, and use the product of the thread block size and the thread grid size as the total number of threads to be started, that is, ensure that the number of threads in the thread block is the same as the thread block size; start all threads and start recording the thread execution time, each thread executes the second CUDA kernel function, if the current thread is the last thread in the thread block, execute the first calculation, otherwise execute the second calculation, and stop recording the thread execution time when the thread execution is completed. Among them, the execution time of the first calculation is greater than the execution time of the second calculation.

[0031] Another way to implement the fine-grained measurement process is: set the thread grid size to 1, set the thread block size to the difference between the lower limit of the thread bundle size and the set value, use the product of the thread block size and the thread grid size as the total number of threads to be started, and initialize the second global variable; start all threads and start recording the thread execution time, each thread executes the second CUDA kernel function, if the current thread is the last thread in the thread block, execute the first calculation, otherwise execute the second calculation, each thread saves the calculated result to the set position of the second global variable, and stops recording the thread execution time when the thread execution is completed.

[0032] According to the characteristics of thread divergence, in order to further improve the execution efficiency of the fine-grained measurement process, the second CUDA kernel function of the present invention only records the execution time of the first thread in the thread block.

[0033] Step 3, set the values ​​of the thread block size and the thread grid size, start the coarse-grained measurement process, record the execution time of this round, if the execution time of this round is greater than the execution time of the previous round and the difference is greater than the first threshold, then use the thread block size of this round as the upper limit of the thread bundle size, and use half of the thread block size as the lower limit of the thread bundle size, and after the coarse-grained measurement process is ended, set the thread block size as the lower limit of the thread bundle size to execute step 4; otherwise, increase the thread block size to update the value and recompile the coarse-grained measurement process and then execute step 3.

[0034] In order to further improve the execution efficiency of the first CUDA kernel function, the present invention sets the value of the thread block size to a power of 2, for example, 2 to the power of 1, 2 to the power of 2, and so on.

[0035] In addition, after the coarse-grained measurement process is completed, the thread block size may be set to the difference between the lower limit of the thread warp size and 1.

[0036] Step 4: Start the fine-grained measurement process to obtain the thread execution time recorded in this round. If the execution time of the last thread is greater than the execution time of other threads and the difference is greater than the second threshold, the difference between the thread block size of this round and 1 is the actual thread bundle size, and this process ends; otherwise, increase the thread block size by 1 and update the thread block size value to execute step 4.

[0037] For the second CUDA kernel function that only records the execution time of the first thread in the thread block, the process of step 4 is: start the fine-grained measurement process, obtain the thread execution time recorded in this round, if the execution time of this round is less than the execution time of the previous round and the difference is greater than the second threshold, then the difference between the thread block size of this round and 1 is the actual thread bundle size, and this process ends; otherwise, increase the thread block size by 1, update the value of the thread block size, and execute step 4. Example

[0038] In this embodiment, a thread warp size measurement method based on reconfigurable thread divergence provided by the present invention is adopted, a first CUDA kernel function and a second CUDA kernel function are constructed based on the CUDA library, and the thread warp size of the GPU to be tested is accurately measured through a coarse-grained measurement process and a fine-grained measurement process, which specifically includes the following steps:

[0039] S1. Preliminary calculation of the range of thread warp size.

[0040] S1.1. Construct the first CUDA kernel function bankConflictKernel, so that its execution time increases significantly when the thread block size exceeds the actual size of the thread bundle. This is achieved by using the shared memory access conflict (bank conflict) phenomenon. Bank conflict will cause serialization of memory access, thereby significantly increasing the execution time of the kernel function. The sample code is as follows:

[0041] __global__ void bankConflictKernel(int *data, int n)

[0042] {

[0043] / / Define a shared memory array

[0044] __shared__ int sharedData[WARP_SIZE]; / / WARP_SIZE is warp size

[0045] int idx = blockIdx.x * blockDim.x + threadIdx.x;

[0046] / / Make sure the thread index is within the data range

[0047] if (idx < n)

[0048] {

[0049] / / Load data from global memory into shared memory

[0050] sharedData[threadIdx.x % WARP_SIZE] = data[idx];

[0051] / / Synchronize threads to ensure shared memory loading is complete

[0052] __syncthreads();

[0053] / / Operate shared memory to create bank conflicts

[0054] for (int i = 0; i < 1000; ++i)

[0055] {

[0056] sharedData[threadIdx.x % WARP_SIZE] += i;

[0057] }

[0058] / / Synchronize threads to ensure shared memory operations complete

[0059] __syncthreads();

[0060] / / Write the result back to global memory

[0061] data[idx] = sharedData[threadIdx.x % WARP_SIZE];

[0062] }

[0063] }

[0064] int main()

[0065] {

[0066] const int n = 1024;

[0067] int *data = new int[n];

[0068] int *d_data;

[0069] / / Initialize data

[0070] for (int i = 0; i < n; ++i)

[0071] {

[0072] data[i] = i;

[0073] }

[0074] cudaMalloc(&d_data, n * sizeof(int));

[0075] cudaMemcpy(d_data, data, n * sizeof(int), cudaMemcpyHostToDevice);

[0076] / / Define thread block size and thread grid size

[0077] int blockSize = WARP_SIZE;

[0078] int gridSize = (n + blockSize - 1) / blockSize;

[0079] / / Start the kernel function

[0080] bankConflictKernel<<<gridSize, blockSize> >>(d_data, n);

[0081] cudaMemcpy(data, d_data, n * sizeof(int), cudaMemcpyDeviceToHost);

[0082] / / Release memory

[0083] cudaFree(d_data);

[0084] delete[] data;

[0085] return 0;

[0086] }

[0087] In the above code, sharedData has a total of WARP_SIZE elements, corresponding to the assumed warp size. In each thread, a bank conflict is introduced by sharedData[threadIdx.x % WARP_SIZE] when accessing shared memory. When the thread block size blockSize exceeds the actual warp size, different threads will access the same bank, resulting in bank conflicts and significantly increased execution time. This achieves the phenomenon of significantly increased execution time due to shared memory bank conflicts when the thread block size exceeds the actual warp size.

[0088] S1.1. Set WARP_SIZE to 1 and set the thread block size blockSize to WARP_SIZE. Compile and execute after modification. To change the value of blockSize, perform the following steps in a loop:

[0089] S1.1.1. Set blockSize to WARP_SIZE, and execute the first CUDA kernel function with gridSize*blockSize as the maximum number of threads;

[0090] S1.1.2. Record execution time;

[0091] S1.1.3. If the execution time is more than 1.5 times the previous execution time, it indicates that the blockSize exceeds the GPU thread bundle size. End the execution, record the blockSize as the warpSizeUpperBound, and record blockSize / 2 as the warpSizeLowerBound to complete the coarse-grained measurement process; otherwise, execute S1.1.4.

[0092] S1.1.4. Set the WARP_SIZE to the current WARP_SIZE * 2, recompile, and then execute S1.1.1.

[0093] S2. Based on the characteristics of thread divergence, construct a second CUDA kernel function to complete the fine-grained measurement process and measure the exact value of the thread bundle size. The specific steps are as follows:

[0094] S2.1. Construct a second CUDA kernel function. When it is determined that the thread ID is equal to the WARP_SIZE, it means that the thread is the last thread in the thread block. Then, execute a computationally intensive operation with a long running time and save the calculation result to the output. The sample code is as follows:

[0095] __global__ void findWarpSize(int warpSize, float *output) {

[0096] int tid = threadIdx.x + blockIdx.x * blockDim.x; / / Obtain the global thread ID

[0097] int laneId = tid % warpSize; / / Calculate the position laneId of the current thread in the warp

[0098] clock_t start, end1, end2;

[0099] start = clock(); / / Record the execution time

[0100] if (laneId == warpSize) {

[0101] float value = 0.0f;

[0102] for (int i = 0; i <1000000>; i++) {

[0103] value += sinf(value) * cosf(value);

[0104] }

[0105] *output = value;

[0106] end1=clock(); / / Record execution time

[0107] } end2=clock(); / / Record execution time

[0108] }

[0109] int main() {

[0110] int *d_counter;

[0111] int counter = 0;

[0112] / / Allocate device memory

[0113] cudaMalloc(&d_counter, sizeof(int));

[0114] cudaMemcpy(d_counter, &counter, sizeof(int),cudaMemcpyHostToDevice);

[0115] int WARP_SIZE = obtained from the input parameter of the main function;

[0116] / / Execute kernel function

[0117] int blockSize = WARP_SIZE;

[0118] int gridSize = 1;

[0119] float output = 0.0f;

[0120] findWarpSize<<< gridSize, blockSize >>>(WARP_SIZE, &output);

[0121] / / Copy the result from the device back to the host

[0122] cudaMemcpy(&counter, d_counter, sizeof(int),cudaMemcpyDeviceToHost);

[0123] cudaFree(d_counter);

[0124] return 0;

[0125] }

[0126] S2.2, set WARP_SIZE to (warpSizeLowerBound-1), set the thread block size blockSize to WARP_SIZE, and set gridSize to 1. No need to recompile. Execute the second CUDA kernel function with blockSize as the maximum number of threads and record the execution time. Change the thread block size blockSize and loop through the following steps:

[0127] S2.2.1, set the thread block size blockSize to WARP_SIZE, and execute the kernel function with blockSize as the maximum number of threads;

[0128] S2.2.2. Record the thread execution time of threads in the thread block;

[0129] S2.2.3, if the thread execution time is significantly longer than that of other threads before, it means that the current WARP_SIZE is the sum of the actual thread warp size of the GPU and 1, and this process ends; otherwise, execute S2.2.4;

[0130] S2.2.4. Increase WARP_SIZE by 1 and execute S2.2.1.

[0131] In summary, the above are only preferred embodiments of the present invention and are not intended to limit the protection scope of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A thread warp size calculation method based on reconfigurable thread divergence, characterized in that: The specific steps include: Construct a coarse-grained measurement process for executing the first CUDA kernel function, and realize that when the thread block size is larger than the thread bundle size, a shared memory access conflict is triggered, resulting in an increase in execution time; construct a fine-grained measurement process for executing the second CUDA kernel function, and realize that only the last thread in the thread block executes the first calculation, and other threads execute the second calculation, and record the thread execution time of all threads in the thread block. The execution time of the first calculation is greater than the execution time of the second calculation; Execute the coarse-grained measurement process, set the values ​​of the thread block size and the thread grid size, take the product of the thread block size and the thread grid size as the total number of threads to be started, start all threads, each thread executes the first CUDA kernel function, and record the execution time of this round; if the execution time of this round is greater than the execution time of the previous round and the difference is greater than the first threshold, then take the thread block size of this round as the upper limit of the thread bundle size and half of the thread block size as the lower limit of the thread bundle size, and after the coarse-grained measurement process is completed, set the thread block size to the lower limit of the thread bundle size and execute the fine-grained measurement process; otherwise, increase the thread block size to update the value, recompile and execute the coarse-grained measurement process; Execute the fine-grained measurement process, set the thread grid size to 1, set the thread block size to the difference between the lower limit of the thread bundle size and the set value, take the product of the thread block size and the thread grid size as the total number of threads to be started, start all threads, and each thread executes the second CUDA kernel function; obtain the thread execution time recorded in this round, if the execution time of the last thread is greater than the execution time of other threads and the difference is greater than the second threshold, then the difference between the thread block size of this round and 1 is the actual thread bundle size, and end this process; otherwise, increase the thread block size with the set step size and then execute the fine-grained measurement process; The first CUDA kernel function is implemented by: creating a first shared memory array with a length equal to the thread block size, taking the remainder of the position of the thread in the thread block divided by the thread block size as the target index, and performing a set number of write operations on the position of the target index in the first shared memory array; The complex calculation performed by the last thread in the second CUDA kernel function only involves calculation.

2. The thread warp size estimation method according to claim 1, characterized in that: The coarse-grained measurement process is implemented as follows: the product of the dimensions of the thread block and the thread grid and the sum of the positions of the threads in the thread block are used as the source index, and the data at the source index in the first global array is written to the target index in the first shared memory array; then the data at the target index in the first shared memory array is accumulated a set number of times, and finally the accumulated result is saved to the source index in the first global array.

3. The thread warp size estimation method according to claim 1, characterized in that: The second calculation is: a combination of a series of trigonometric functions and basic arithmetic operations.

4. The thread warp size estimation method according to claim 1, characterized in that: The second CUDA kernel function stores the result of the second calculation in a global array.

5. The thread warp size estimation method according to claim 4, characterized in that: The fine-grained measurement process is implemented as follows: a second global array is initialized, and each thread saves the calculated result to a set position of the second global array.

6. The thread warp size estimation method according to claim 1, characterized in that: The second CUDA kernel function only records the execution time of the first thread in the thread block.

7. The thread warp size estimation method according to claim 1, characterized in that: The method of increasing the thread block size in the coarse-grained measurement process is: setting the thread block size to the nth power of 2, and increasing n to increase the thread block size.

8. The thread warp size estimation method according to claim 6, characterized in that: After executing the fine-grained measurement process, obtain the thread execution time recorded in this round. If the execution time of this round is less than the execution time of the previous round and the difference is greater than the second threshold, the difference between the thread block size of this round and 1 is the actual thread bundle size, and end this process; otherwise, increase the thread block size by 1, update the thread block size value and execute step 4.

9. The thread warp size estimation method according to claim 1, characterized in that: The setting step size is 1.

Citation Information

Patent Citations

  • Self-adaptive thread based GPU parallel particle swarm optimization method

    CN106502632A

  • Register file structure used for branch processing in GPU

    CN106648545A

  • System and method for allocating and scheduling thread bundles of GPU (Graphics Processing Unit)

    CN118210612A

  • Memory bank size measuring and calculating method based on memory access conflict measurement

    CN118227449A

  • System, methods and apparatus for program optimization for multi-threaded processor architectures

    US20100218196A1