Method of accelerating matrix calculation based on GPU

By designing a matrix acceleration calculation method based on GPU, processing the calculation tasks as a bidirectional queue, and dynamically adjusting the task load, the problem that the CPU and GPU collaborative processing mode in heterogeneous computing systems fail to make full use of computing power, and the CPU is realized /GPU heterogeneous computing system has the best computing efficiency.

CN114675966BActive Publication Date: 2025-02-11SUAN CHOU (SHENZHEN) INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210277009.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-21
Publication Date
2025-02-11
Estimated Expiration
2042-03-21

AI Technical Summary

Technical Problem

In heterogeneous computing systems, the coordinated processing mode of CPU and GPU fails to fully utilize the computing power of both, resulting in the inability to fully utilize the computing performance.

Method used

Design a matrix acceleration calculation method based on GPU. By processing the calculation tasks into a bidirectional queue and initially allocating the theoretical peak computing capabilities of the CPU and GPU, dynamically adjusting the task load to ensure that the load of the CPU and GPU is optimal. This achieves the optimal computing efficiency of collaborative processing.

Benefits of technology

Through this method, the load capacity of the CPU and GPU is optimal, ensuring that the calculations of both are completed simultaneously, so that the collaborative processing computing efficiency of the entire CPU/GPU heterogeneous computing system is optimal and the performance is improved by 35%.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure FHA0000008351450000011
    Figure FHA0000008351450000011
  • Figure FHA0000008351450000012
    Figure FHA0000008351450000012
  • Figure FHA0000008351450000021
    Figure FHA0000008351450000021
Patent Text Reader

Abstract

The present invention belongs to the field of computer application technology, and in particular to a method for matrix accelerated calculation based on GPU. The present invention provides a method for matrix accelerated calculation based on GPU, which uses a CPU / GPU heterogeneous computing system as a computing platform to optimize the load of the CPU and GPU, thereby ensuring that the calculations of both are completed at the same time, so that the computing efficiency of the collaborative processing of the entire CPU / GPU heterogeneous computing system is optimized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of computer applications, and in particular relates to a method for matrix accelerated calculation based on a GPU. Background Art

[0002] With the continuous advancement of science and technology, the demand for computing performance in applications is also increasing. However, due to power consumption issues, the development of computer hardware computing in the past decade has basically abandoned the traditional model of increasing computer performance by increasing processor frequency, and instead adopted the method of integrating multiple processor cores to improve the computing power of chips. Due to the versatility of CPUs, even using multi-core CPUs cannot meet the computing needs of most applications. Therefore, the research on dedicated acceleration components has received widespread attention from academia and industry.

[0003] In recent years, general-purpose computing hardware represented by graphics processing units (GPUs) has gradually become the mainstream solution for solving big data computing and real-time processing problems internationally. GPUs have high computing performance, small size, low power consumption, and universal hardware and software. They can provide high-performance computing capabilities in restricted environments and have been widely used in high-performance data processing and applications in surveying and mapping, remote sensing, and geoscience.

[0004] Heterogeneous System Architecture (HSA) is a cross-development platform that allows CPU and GPU to use the same bus for memory and task sharing. The goal of this platform is to reduce the communication delay between CPU, GPU, and other computer devices, so that developers can more conveniently control multiple devices and achieve faster task scheduling and data interaction between devices.

[0005] Through experiments, it is found that in the calculation of vector inner product: CPU and GPU do not have absolute efficiency. If the CPU is assigned by other tasks, the calculation time may exceed that of GPU. Therefore, the choice of processor for vector inner product should be determined according to the location of data; in matrix and vector multiplication: the amount of parallel calculation is large, and GPU is always faster than CPU. In matrix and matrix multiplication: as in matrix and vector multiplication, GPU is always faster than CPU; in solving vector triangular linear equations: the amount of parallel calculation is large, and GPU is always faster than CPU. In solving matrix triangular linear equations: when the number of columns k is relatively small, CPU has fast calculation speed, and when the number of columns k is large, GPU has fast calculation speed. In the framework of heterogeneous computing system, if CPU is only used as the control unit of GPU, the computing power of these processing cores cannot be brought into play, resulting in the inability to fully utilize the computing performance of the entire heterogeneous computing system. To this end, it is necessary to design a corresponding CPU / GPU collaborative processing mode so that CPU and GPU can process data together in the most efficient way. Summary of the invention

[0006] In view of the technical problems of the above-mentioned CPU / GPU collaborative processing mode, the present invention proposes a GPU-based matrix accelerated computing method with reasonable design, simple method and the ability to process data in an efficient manner.

[0007] In order to achieve the above object, the technical solution adopted by the present invention is that the present invention provides a method for matrix accelerated calculation based on GPU, comprising the following steps:

[0008] a. First, process the computing task into a bidirectional queue;

[0009] b. Then, check whether the CPU / GPU heterogeneous computing system is running the computing task for the first time. If so, allocate computing tasks to the CPU and GPU from the head and tail of the queue respectively according to the theoretical peak computing power of the CPU single processor core and the theoretical peak computing power of the GPU, and determine the actual computing time of the CPU and GPU;

[0010] c. Then distribute the load based on the shortest time to complete the task on the CPU or GPU;

[0011] d. If the CPU and GPU complete the task at the same time, the load ratio of the CPU allocation task of such task is calculated to determine the best allocation plan for the computing task. If the CPU or GPU completes the task ahead of time, the remaining tasks are determined as dynamically adjusted tasks, and the CPU and GPU complete the tasks together until the head and tail of the queue meet and all computing tasks are completed. Then, the best allocation plan for the task is determined based on the actual computing amount completed by the CPU and GPU.

[0012] Preferably, in step b, a processor core of the CPU is designated to interact with the GPU, and the remaining N-1 processor cores participate in the computing task.

[0013] Preferably, in step d, if the CPU and GPU complete the task at the same time, then according to the formula: Determine the best allocation scheme for the computing task, where σ is the load ratio of the CPU assigned to the task, N is the number of CPU cores, and V GPU is the actual computing power of the GPU, V CPU It is the actual computing power of a single CPU core.

[0014] Preferably, in step d, if the CPU and GPU complete the task at the same time, according to the formula: Calculate the actual computing power of the GPU, where L GPUis the amount of computing tasks allocated to the GPU from the head or tail of the team based on the theoretical peak computing power of the GPU in step b, T GPU Complete L for GPU GPU time.

[0015] Preferably, in step d, if the CPU and GPU complete the task at the same time, according to the formula: Calculate the actual computing power of a single CPU core, where L CPU is the theoretical peak value calculated by a single CPU core in step b and allocated to the CPU computing tasks from the head or tail of the team, T CPU Complete L for a single CPU core CPU time.

[0016] Compared with the prior art, the advantages and positive effects of the present invention are:

[0017] 1. The present invention provides a matrix acceleration calculation method based on GPU, which takes the CPU / GPU heterogeneous computing system as the computing platform to optimize the load of the CPU and GPU, thereby ensuring that the calculations of both are completed at the same time, so that the computing efficiency of the collaborative processing of the entire CPU / GPU heterogeneous computing system is optimized. DETAILED DESCRIPTION

[0018] In order to more clearly understand the above-mentioned purpose, features and advantages of the present invention, the present invention is further described below in conjunction with embodiments. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.

[0019] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways than those described herein. Therefore, the present invention is not limited to the specific embodiments of the following disclosure.

[0020] Embodiment 1, this embodiment provides a method for matrix accelerated calculation based on GPU

[0021] Matrix computing is a core component of many scientific computing and machine learning methods. Effectively improving the performance of matrix computing is of great significance for the development of high-performance scientific computing systems or big data processing systems.

[0022] In matrix calculations, especially sparse matrix calculations, it is necessary to preprocess the matrix to meet the requirements of parallel computing. The specific operation method is as follows:

[0023] 1. Specify the distribution of non-zero elements of M in advance according to a certain rule, thus avoiding asynchronous calculations;

[0024] 2. The same submatrix of A can be used to calculate some columns in M-1;

[0025] 3. The number of elements in each column of M-1 is the same, so solving all columns of M-1 can be implemented in full parallel on the GPU. Then, CSC storage is used to process the computing tasks into a bidirectional queue. Processing it into a bidirectional queue mainly involves storing the computing tasks in the bidirectional queue before parallel task processing. When dispatching computing tasks to different types of processors, the CPU dispatches from the head of the queue and the GPU dispatches from the tail of the queue. In this way, the time computing capabilities of the CPU and GPU for the task can be determined.

[0026] Then, it is detected whether the CPU / GPU heterogeneous computing system is running the computing task for the first time. If so, the computing power of the theoretical peak value of the CPU single processor core and the theoretical peak value of the GPU are allocated to the CPU and GPU computing tasks from the head and tail of the team respectively to determine the actual computing time of the CPU and GPU.

[0027] Then, the load is distributed according to the shortest time to complete the task in the CPU or GPU. According to the calculation task and calculation time, the actual computing power of the CPU or GPU can be determined. Specifically, according to the formula: Calculate the actual computing power of the GPU, where L GPU is the amount of computing tasks allocated to the GPU from the head or tail of the team based on the theoretical peak computing power of the GPU in step b, T GPU Complete L for GPU GPU time.

[0028] According to the formula: Calculate the actual computing power of a single CPU core, where L CPU is the theoretical peak value calculated by a single CPU core in step b and allocated to the CPU computing tasks from the head or tail of the team, T CPU Complete L for a single CPU core CPU In the collaborative computing of CPU and GPU, it is necessary to specify a single CPU processor core to interact with GPU. For this reason, this single CPU processor core does not participate in the computing. Assuming that the number of processor cores of a CPU is N, the number of CPU processor cores actually participating in the collaborative computing is N-1. In this way, their computing performance can be fully utilized. If all of them participate in computing and interaction, it will affect the single-core computing capability of the CPU.

[0029] Thus, assuming the total computational task is L, the time required for the computation is Then the amount of work that the CPU can complete is T*V CPU (N-1), similarly, the amount of work that the GPU can complete is T*V GPU, according to this task volume, the corresponding tasks are allocated to the CPU and GPU to verify whether the allocation is reasonable.

[0030] If the CPU and GPU complete the task at the same time, according to the formula: Determine the best allocation scheme for the computing task, where σ is the load ratio of the CPU assigned to the task, N is the number of CPU cores, and V GPU is the actual computing power of the GPU, V CPU It is the actual computing power of a single CPU core.

[0031] If the CPU or GPU completes the task ahead of time, the remaining tasks are determined as dynamically adjusted tasks, and the CPU and GPU complete the tasks together until the head and tail of the queue meet and all the computing tasks are completed. Then, based on the actual computing amount completed by the CPU and GPU, the actual computing power of the CPU single processor core and the actual processing power of the GPU are determined again. Then, the task is calculated again to calculate the time required. Then the amount of work that the CPU can complete is T*V CPU (N-1), similarly, the amount of work that the GPU can complete is T*V GPU , according to this task volume, corresponding tasks are allocated to the CPU and GPU. If the CPU and GPU complete the tasks at the same time, the best allocation plan for this type of computing tasks is verified. If they are still not completed synchronously, the work is repeated until the best allocation plan is iterated when the CPU and GPU complete the tasks at the same time.

[0032] Then, the four groups of benchmark programs selected in the experiment were debugged on the CPU / GPU heterogeneous computing platform. The CPU used was the Intel Xeon E5-2697 v2CPU with 12 cores and 24 threads, and the graphics card used was the GeForce RTX3060Ti graphics card. The system performance was measured based on the data calculation time. Then, it was compared with the traditional scheduling algorithm (the CPU is responsible for the serial calculation part, and the GPU manages and provides the data required for GPU calculation and receives the results of GPU calculation), and it was found that its performance was improved by 35%.

[0033] The above description is only a preferred embodiment of the present invention and does not limit the present invention in other forms. Any technician familiar with the profession may use the technical content disclosed above to change or modify it into an equivalent embodiment with equivalent changes and apply it to other fields. However, any simple modification, equivalent change and modification made to the above embodiment based on the technical essence of the present invention without departing from the content of the technical solution of the present invention still falls within the protection scope of the technical solution of the present invention.

Claims

1. A method for matrix accelerated computing based on GPU, characterized in that: The following steps are involved: a. First, process the computing task into a bidirectional queue; b. Then check whether the CPU / GPU heterogeneous computing system is running the computing task for the first time. If so, Then, according to the theoretical peak computing power of the CPU single processor core and the theoretical peak computing power of the GPU, the computing tasks are allocated to the CPU and GPU from the head and tail of the team respectively to determine the actual computing time of the CPU and GPU; c. Then distribute the load based on the shortest time to complete the task on the CPU or GPU; d. If the CPU and GPU complete the task at the same time, the load ratio of the CPU-allocated tasks of such tasks is calculated to determine the best allocation plan for the computing task. If the CPU or GPU completes the task ahead of time, the remaining tasks are determined as dynamically adjusted tasks, and the CPU and GPU complete the tasks together until the head and tail of the queue meet and all computing tasks are completed. Then, the best allocation plan for the task is determined based on the actual computing amount completed by the CPU and GPU. In step b, a CPU processor core is designated to interact with the GPU, and the remaining N-1 processor cores participate in the computing task. In step d, if the CPU and GPU complete the task at the same time, according to the formula: Determine the best allocation scheme for the computing task, where σ is the load ratio of the CPU assigned to the task, N is the number of CPU cores, and V GPU is the actual computing power of the GPU, V CPU is the actual computing power of the CPU single processor core; if the CPU or GPU completes the task ahead of time, the remaining tasks are determined as dynamically adjusted tasks, and the CPU and GPU complete the tasks together until the head and tail of the queue meet and all the computing tasks are completed. Then, based on the actual computing amount completed by the CPU and GPU, the actual computing power of the CPU single processor core and the actual processing power of the GPU are determined again. Then, the task is calculated again, and the time required for calculation is Where L is the total computing task, then the amount of tasks that the CPU can complete is T*V CPU (N-1), similarly, the amount of work that the GPU can complete is T*V GPU , according to this task volume, corresponding tasks are allocated to the CPU and GPU. If the CPU and GPU complete the tasks at the same time, the optimal allocation plan for this type of computing tasks is verified. If they are still not completed synchronously, the work is repeated until the optimal allocation plan is iterated when the CPU and GPU complete the tasks at the same time.

2. The method for matrix accelerated computing based on GPU according to claim 1, characterized in that: In step d, if the CPU and GPU complete the task at the same time, according to the formula: Calculate the actual computing power of the GPU, where L GPU is the amount of computing tasks allocated to the GPU from the head or tail of the team based on the theoretical peak computing power of the GPU in step b, T GPU Complete L for GPU GPU time.

3. The method for matrix accelerated calculation based on GPU according to claim 2, characterized in that: In step d, if the CPU and GPU complete the task at the same time, according to the formula: Calculate the actual computing power of a single CPU core, where L CPU is the theoretical peak value calculated by a single CPU core in step b and allocated to the CPU computing tasks from the head or tail of the team, T CPU Complete L for a single CPU core CPU time.

Citation Information

Patent Citations

  • Allocating Compute Kernels to Processors in a Heterogeneous System

    US20130160016A1

  • KR1018794190000B1