SpMV task division and scheduling strategy for CPU-GPU heterogeneous platform

By adopting the strategy of data flow decomposition and PID controller in the CPU-GPU heterogeneous system, the problem of load imbalance and low PCI-e bandwidth utilization in SpMV task processing is solved, and the load balancing of CPU and GPU is achieved. Improved computing throughput.

CN118535305APending Publication Date: 2024-08-23NANJING TECH UNIV
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202410688225.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-30
Publication Date
2024-08-23

AI Technical Summary

Technical Problem

Existing CPU-GPU heterogeneous systems have problems such as waste of CPU computing resources, high PCI-e data transmission costs, and load imbalance during SpMV task processing, resulting in reduced computing performance.

Method used

The SpMV task division and scheduling strategy for CPU-GPU heterogeneous platforms is adopted to achieve CPU and GPU load balancing and PCI- Full utilization of e bandwidth.

Benefits of technology

It effectively achieves CPU and GPU load balancing, improves PCI-e bandwidth utilization, increases computing throughput by an average of 48.85%, and significantly improves the SpMV computing performance of heterogeneous systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118535305A
    Figure CN118535305A
Patent Text Reader

Abstract

An SpMV task division and scheduling strategy for a CPU-GPU heterogeneous system comprises the steps that 1, a large-scale sparse matrix is divided into a plurality of sub-tasks with the same calculation task amount, and then the sub-tasks are stored in a task pool; 2) determining initial division proportions RCPU and RGPU of the subtasks according to the peak floating point operation performance of each processor, and dividing the first subtask into a CPU end calculation task and a GPU end calculation task according to the proportion; 3) respectively starting parallel computing programs of the CPU end and the GPU end; when the CPU and the GPU parallel computing kernel execute the computing task, data transmission of the next subtask is started; 4) obtaining the calculation time of the CPU end and the GPU end, and inputting the calculation time difference of the CPU end and the GPU end to the PID controller as a control deviation; the PID controller outputs the updated CPU end task division proportion and the updated GPU end task division proportion according to the control deviation and the time threshold value; and 5) segmenting the next subtask according to the division proportion updated in the step 4), and repeating the step 2) to the step 4).
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a data processing technology for a CPU-GPU heterogeneous platform, and in particular to a SpMV task partitioning and scheduling strategy for a CPU-GPU heterogeneous platform. Background Art

[0002] Sparse Matrix-Vector Multiplication (SpMV) is a core operation in today's scientific computing field. It plays an important role in solving linear algebra problems, data mining[1], bioinformatics[2], engineering, and graph analysis[3]. In these fields, processing large-scale sparse matrix and vector multiplication tasks is essential. In many scientific computing problems, especially when solving large linear systems and eigenvalue problems, SpMV operations are one of the most time-consuming parts of many iterative algorithms

[10] . The efficient implementation of SpMV is of great significance to improving the efficiency of large-scale scientific computing tasks.

[0003] GPUs (Graphics Processing Units) have been widely used to accelerate various computationally intensive algorithms, including SpMV. Studies have shown that using GPUs for computing can significantly improve the execution speed of algorithms. Although many research works have been devoted to optimizing parallel SpMV on CPU-GPU platforms, these studies mainly focus on how to reduce the GPU computing cost [4], and pay less attention to CPU-GPU load balancing and the data transmission cost on PCI-e.

[0004] As a technology to improve computing performance, CPU-GPU heterogeneous computing is the mainstream trend in the current high-performance computing field and has become one of the most widely used heterogeneous computing platforms

[11] . These two heterogeneous processors have independent storage spaces and different numerical computing characteristics. Therefore, in order to efficiently and collaboratively utilize these two computing resources, optimization from multiple angles is required. Existing research work still has the following problems:

[0005] (1) In traditional CPU-GPU heterogeneous systems, the CPU is only used for task partitioning and logic control, but does not participate in the calculation of actual tasks. This actually results in a waste of CPU computing resources, especially with the development of multi-core and many-core processors, the CPU computing performance is constantly improving [5];

[0006] (2) The data transmission cost on the PCI-e bus has a significant impact on the SpMV computing performance in CPU-GPU heterogeneous computing systems [6]. In the traditional computing mode, all required data must be transferred from the CPU system main memory to the GPU video memory via the PCI-e bus before the CUDA kernel can be scheduled to perform the calculation, and the results are then transmitted back after the calculation is completed. This mode causes the processor and the PCI-e bus to wait for each other, resulting in a double waste of computing resources and bandwidth resources.

[0007] (3) In modern computer systems, the real-time computing performance of computing tasks on the CPU and GPU will change constantly due to many factors such as thermal management[7], dynamic frequency modulation[8], power consumption management, and computing task scale. Using a static ratio to allocate subtasks or using an unreasonable subtask splitting algorithm is likely to lead to load imbalance, with one side idle and the other side overloaded, thus losing the advantages of heterogeneous parallel computing. Summary of the invention

[0008] To solve the above problems, the present invention proposes a SpMV task partitioning and scheduling strategy for CPU-GPU heterogeneous platform to balance the computing load of CPU and GPU and make full use of PCI-e bandwidth resources.

[0009] A SpMV task partitioning and scheduling strategy for CPU-GPU heterogeneous systems is characterized by firstly dividing the SpMV task into subtasks and then scheduling the subtasks, specifically including:

[0010] 1) In the data flow decomposition stage: the large-scale sparse matrix is ​​divided into several subtasks with the same amount of computational tasks, and then stored in the task pool;

[0011] 2) In the task division stage: determine the initial division ratio R of subtasks based on the peak floating-point computing performance of each processor CPU and R GPU , and divide the first subtask into CPU-side computing tasks and GPU-side computing tasks according to the ratio; R CP and R GPU They represent the proportion of computing tasks allocated to the CPU and the proportion of computing tasks allocated to the GPU respectively;

[0012] 3) In the overlapping computing stage: start the parallel computing programs on the CPU and GPU respectively and start to execute the computing tasks; according to the overlapping computing mechanism, while the CPU and GPU parallel computing kernels are executing the computing tasks, start the data transmission for the next subtask to realize overlapping computing;

[0013] 4) In the proportion update stage: the calculation time of the CPU and GPU is obtained, and the calculation time difference between the two is input to the PID controller as the control deviation; the PID controller outputs the updated CPU and GPU task division ratio according to the control deviation and the time threshold;

[0014] 5) Divide the next subtask according to the updated division ratio in step 4), and repeat steps 2) to 4) until all subtasks are calculated;

[0015] The steps 1) to 3) are the task division process, and step 4) is the subtask scheduling process.

[0016] The main contributions of the present invention are as follows:

[0017] (1) By analyzing the impact of data transmission cost in PCI-e on the computing throughput and bandwidth utilization of CPU-GPU heterogeneous systems, an overlapping computing strategy based on data flow decomposition is designed. Large-scale computing tasks are decomposed into subtasks for time-sharing transmission, and the computing cost is overlapped with the data transmission cost to fully utilize the PCI-e bandwidth. When decomposing sparse matrices, a subtask partitioning algorithm driven by non-zero element density is designed based on the SpMV computing characteristics.

[0018] (2) Design a feedback subtask scheduling algorithm based on PID controller. The running status of the current subtask is used as the input of the PID controller, and the task ratio is adjusted in real time by referring to the output of the PID controller to achieve load balancing.

[0019] Experimental results show that the SpMV task division and scheduling strategy proposed in this invention can not only effectively achieve load balancing, but also improve the computing PCI-e bandwidth utilization. Compared with the benchmark CPU-GPU heterogeneous system, the computing throughput is increased by an average of 48.85%. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1 It represents the workflow of SpMV task partitioning and scheduling strategy for CPU-GPU heterogeneous systems;

[0021] Figure 2 Represents the CUDA parallel computing process under the traditional programming mode (serial);

[0022] Figure 3 It represents the calculation process of overlapping calculation algorithm based on data flow decomposition;

[0023] Figure 4 Represents the schematic diagram of PID control algorithm;

[0024] Figure 5 It shows the comparison between the solution proposed by the present invention and the result of the naive adjustment algorithm;

[0025] Figure 6 Comparison of the computing throughput of a CPU-GPU heterogeneous system with GPU computing only and a benchmark CPU-GPU heterogeneous system;

[0026] Figure 7 The SpMV operation time representing the computational throughput of the benchmark CPU-GPU heterogeneous system and the proposed method;

[0027] Figure 8 It represents the comparison of SpMV performance under three experimental environments;

[0028] Fig. 9 Represents the data transmission time utilization in SpMV under three experimental environments. DETAILED DESCRIPTION 1. Summary of the Invention

[0030] Sparse Matrix-Vector Multiplication (SpMV) kernels dominate the computational cost in many applications. However, existing research on SpMV on CPU-GPU heterogeneous platforms mostly focuses on reducing the computational cost on GPUs, while ignoring the performance degradation caused by unbalanced load partitioning schemes and data transfer costs on PCI-e on heterogeneous systems.

[0031] In view of this, the present invention proposes a SpMV task partitioning and scheduling strategy for CPU-GPU heterogeneous platform to optimize the performance of heterogeneous system.

[0032] Firstly, by analyzing the impact of data transmission cost in PCI-e on the performance of heterogeneous systems, an overlapping computing strategy based on data flow decomposition is proposed.

[0033] Then, by designing a subtask partitioning algorithm driven by non-zero element density, the large-scale computing tasks are decomposed and transmitted sequentially, so that the execution cost of the computing tasks is hidden in the inherent overhead of data transmission.

[0034] Finally, by referring to the dynamic output of the proportional-integral-derivative (PID) controller, a subtask scheduling strategy is designed to dynamically adjust the computational load division ratio of each processor.

[0035] Experimental results show that the proposed method improves the computational throughput by 48.85% on average compared with the baseline method.

[0036] 2. Design

[0037] The workflow of the SpMV task partitioning and scheduling strategy for CPU-GPU heterogeneous systems proposed in this invention is as follows: Figure 1 As shown, its core part consists of the following modules:

[0038] (1) Overlapping calculation based on data flow decomposition. By decomposing large-scale SpMV calculation tasks into several subtasks and transmitting them in time, the next subtask is transmitted while the calculation is executed, so that the data transmission cost is hidden in the calculation cost, thereby improving the PCI-e bandwidth utilization. For details, see 2.1.

[0039] (2) Subtask partitioning algorithm driven by non-zero element density. Using the number of non-zero elements as the sub-matrix partitioning criterion can effectively meet the load balancing requirements. See 2.2 for details.

[0040] (3) Subtask scheduling algorithm based on PID controller. The running time difference of the current subtask is selected as the control deviation, and the subtask division ratio is dynamically adjusted according to the output of the PID controller. See 2.3 for details.

[0041] For a CPU-GPU heterogeneous system to which the task partitioning and scheduling strategy of the present invention is applied, the execution process of large-scale sparse matrix-vector multiplication can be described as follows:

[0042] In the data flow decomposition stage, the large-scale sparse matrix is ​​divided into several subtasks with the same computational workload through the partitioning algorithm, and stored in the data pool to achieve data flow decomposition. When decomposing the subtasks, the subtask partitioning algorithm driven by non-zero element density is used to achieve the same computational workload for each subtask.

[0043] In the task division stage, the initial division ratio R is determined based on the peak floating-point computing performance of each processor. CPU and R GPU , and divide the first subtask into CPU-side computing tasks and GPU-side computing tasks according to the ratio. When performing secondary division of subtasks, the subtask partitioning algorithm driven by non-zero element density is still used to match the computing tasks and computing capabilities assigned to the CPU and GPU sides.

[0044] In the overlapping computing phase, the computation begins. The parallel computing programs on the CPU and GPU are started respectively. According to the overlapping computing mechanism based on data flow decomposition, while the CPU and GPU parallel computing kernels are executing, the data transmission for the next subtask is started to achieve overlapping computing.

[0045] In the proportion update phase, the calculation time of the CPU and GPU is obtained, and the time difference is input to the PID controller as the control deviation. The PID feedback controller outputs the updated CPU and GPU task division ratio based on the control deviation and time threshold.

[0046] Finally, the next subtask is divided according to the updated division ratio, and the above process is repeated until all subtasks are calculated.

[0047] By implementing optimization strategies such as task partitioning, overlapping computing, and subtask scheduling algorithms in CPU-GPU heterogeneous systems, we aim to achieve load balancing among processors, improve PCI-e bandwidth and processor utilization, and ultimately achieve performance improvement in heterogeneous systems.

[0048] 2.1 Overlapping Computation Based on Data Stream Decomposition

[0049] 2.1.1 Analysis of the Impact of Data Transmission on Heterogeneous Systems

[0050] This section aims to evaluate the performance of the CPU-GPU heterogeneous computing system based on CUDA using the SHOC benchmark suite to analyze the performance of the CPU-GPU heterogeneous computing system under different workloads. This paper selects a single CPU and a single GPU to build an experimental platform. The specific device information is shown in Table 1.

[0051] Table 1 Experimental platform equipment specifications

[0052]

[0053] In order to analyze the impact of data transmission in CPU-GPU heterogeneous systems, we consider the execution speed V when ignoring PCI-e communication overhead and taking into account PCI-e communication loss. no_PCIe and V with_PCIe . V for each benchmark program no_PCIe 、V with_PCIe And the ratio V no_PCIe / V with_PCIe As shown in Table 2.

[0054] Table 2 SHOC benchmark results

[0055]

[0056] According to Table 2, after considering the data transmission loss between the CPU and GPU through the PCI-e bus, the running performance of each benchmark instance on the GPU device has generally declined to varying degrees. The impact on programs such as BFS, S3D-SP, and S3D-DP is relatively small, but the performance of programs such as Reduction and Scan has declined a lot. For SpMV studied in this article, its performance has also declined significantly, exceeding 50%. Therefore, in order to optimize the computing performance of SpMV in heterogeneous systems, the impact of PCI-e data transmission must be considered.

[0057] 2.1.2 Overlapping calculation mechanism design

[0058] For most computing tasks in CPU-GPU heterogeneous systems, the input data and output data are stored in the system main memory. When the GPU is required to participate in the calculation, the data is transferred from the system main memory to the video memory through the PCI-e bus for the GPU to perform calculations.

[0059] Traditional heterogeneous systems usually adopt the "serial" concept. Figure 2 As shown in the figure, all the required data is transferred from the CPU system main memory to the GPU memory via the PCI-e bus, and then the CUDA parallel calculation is started, and finally the calculation results are transferred from the GPU memory to the CPU system main memory via the PCI-e bus. This mode will lead to a double waste of CPU, GPU computing resources and PCI-e bandwidth resources.

[0060] Different from the traditional computing model, this paper adopts the data flow decomposition strategy, that is, decomposing the complete data flow transmission task into multiple subtasks with smaller data volumes, and using the overlapping computing algorithm to maximize the use of CPU, GPU computing resources and PCI-e bandwidth resources. In this way of data flow decomposition and overlapping computing, the decomposition process of computing tasks is as follows: Figure 3 As shown. Before the first data stream transmission subtask is completed from the system main memory to the GPU video memory, the computing resources on the GPU will be idle. However, with the completion of the data transmission of the first subtask, the computing kernels on the CPU and GPU begin to execute, and the next sub-data stream transmission task in the PCI-e bus also begins. The core idea is that when the calculation of the i-th subtask is completed, the calculation of the i+1-th subtask is immediately executed, and the PCI-e transmits the i+2-th subtask at the same time. Except before the completion of the first data stream transmission subtask and the numerical calculation process of the last subtask, the numerical calculation tasks and data transmission tasks on the CPU and GPU are carried out simultaneously, and the data transmission cost is concealed by this partial or complete overlap.

[0061] 2.2 Subtask segmentation algorithm driven by non-zero element density

[0062] Computational tasks are usually adapted to computing power, and for SpMV, the computational scale of a subtask can be reflected by the number of non-zeros in the subtask. This section mainly discusses two subtask segmentation algorithms: the first is a segmentation algorithm based on the number of rows; the second is a segmentation algorithm driven by the density of non-zero elements.

[0063] (1) Row-scale driven segmentation algorithm

[0064] The algorithm uses the number of rows as the computational scale evaluation index. That is, according to the computing power of K processors CC1, CC2, ..., CC K, split the sparse matrix A into K row vector blocks A1, A2, ..., A K , the number of rows in the row vector block corresponds to the computing power of the processor. The above division basis is described as

[0065]

[0066]

[0067] However, in the SpMV calculation, only non-zero elements are involved in the calculation. Algorithm 1 is an algorithm that splits based on the number of rows, without considering the number of non-zero elements. Therefore, the number of non-zero elements in the row vector blocks generated by the splitting is not equivalent to the computing power of the processor, which will lead to unbalanced load between processors.

[0068] (2) Segmentation algorithm driven by non-zero element density

[0069] The algorithm uses the number of non-zero elements as the evaluation index of the computational scale, so that the number of non-zero elements of the K row vector blocks can match the computing power of each processor to achieve the purpose of load balancing of each processor. The partitioning basis of the partitioning algorithm is expressed as

[0070]

[0071] Algorithm 2 is a segmentation algorithm driven by non-zero element density. In lines 8-12, the present invention uses a while loop to find the critical row number between two row vector blocks, and its time complexity is O(n). In the specific implementation, a binary search algorithm is used to replace the original while linear scan, and its time complexity is optimized to O(log n). In the context of large-scale sparse matrix-vector multiplication, the use of a binary search algorithm can significantly improve the efficiency of the algorithm.

[0072]

[0073] 2.3 Subtask Scheduling Algorithm Based on PID Controller

[0074] Assume that the total amount of numerical calculation tasks is Q, the amount of data to be transmitted through PCI-e is D, the bandwidth of the PCI-e bus is W, and the computing performance of the CPU is P. CPU , the computing performance of GPU is P GPU Then the running time of the numerical computing task on the CPU and GPU can be defined as

[0075]

[0076] and

[0077]

[0078] when When , it means that after considering the data transmission cost, it is more efficient to choose CPU to perform calculation alone. When the CPU and GPU participate in the collaborative calculation.

[0079] The division ratio can be determined by the computing performance of the CPU and GPU, so the ratio of task allocation on the CPU side and GPU side is calculated as

[0080]

[0081] and

[0082]

[0083] At this time, suppose that the CPU computing time of the part of a computing task assigned to the CPU side is T′ CPU , the GPU computing time allocated to the GPU side is T′ GPU At this time, the time it takes to complete the computing task in the CPU-GPU heterogeneous computing system can be roughly estimated as

[0084] T=max{T′ cPU , T′ GPU} (7)

[0085] When the ratio of task division is unreasonable, it will lead to T′ CPU and T′ GPU If the difference is too large, the CPU and GPU are still calculating while the other has completed the calculation. Then they will be in a blocked state, resulting in the overall running time becoming longer and the efficiency of heterogeneous computing is reduced. Therefore, the task allocation optimization problem can also be abstracted into the following planning problem:

[0086] Minimize|T′ CPU -T′ GPU | (8)

[0087] For the initial allocation ratio R CPU and R GPU , which is determined by the peak floating-point computing power, which is related to the number of cores, frequency, and single-cycle floating-point computing power of the CPU or GPU. The peak floating-point computing power of the CPU and GPU is calculated as

[0088] PeakP CPU =N_Core CPU ×F CPU ×IPC CPU (9)

[0089] and

[0090] PeakP GPU =N_Core CPU ×F CPU ×IPC CPU (10)

[0091] In modern computer systems, many factors such as dynamic frequency modulation, thermal management, power management, and computing task scale make the real-time computing performance of CPU and GPU processing constantly change. Therefore, unlike the existing work that uses static allocation or real-time monitoring, this section designs a subtask scheduling algorithm for large-scale SpMV computing tasks in CPU-GPU heterogeneous computing systems. The algorithm uses a feedback mechanism to continuously adjust the task division ratio according to the planning target of Formula 8 during operation, and finally achieves load balancing on the CPU and GPU sides.

[0092] PID (Proportional-Integral-Derivative) controller is a classic feedback control algorithm, which is often used to adjust the output of the control system to reach the expected value or stabilize near a target value. In the scenario of dynamic task division, we use PID controller to dynamically adjust the task division ratio according to the time difference between CPU and GPU execution tasks. PID controller adjusts the output of the system through three control items: proportional, integral, and derivative. Its control deviation is determined by the difference between the expected value r(t) and the actual output value c(t), which can be expressed as

[0093] error(t)=r(t)-c(t) (11)

[0094] In the dynamic task partitioning scenario of CPU-GPU heterogeneous systems, the ideal state is that the CPU and GPU processing time are the same, that is, T CPU -T GPU =0, so the expected value r(t) is set to 0, and the actual output value is the difference between the CPU and GPU running time of each subtask, that is, c(t) = T CPU (t)-T GPU (t). Therefore, in this scenario, the control deviation defined by Formula 11 can be calculated as

[0095] error(t)=0-[T CPU (t)-T GPU (t)] = T GPU (t)-T CPU (t) (12)

[0096] The ideal PID control law is expressed as

[0097]

[0098] In the dynamic task partitioning scenario of a CPU-GPU heterogeneous system, the PID controller needs to dynamically adjust the partition ratio of the next subtask based on the CPU and GPU running time of the previous subtask, so this is a discrete background. Discretizing formula 13 yields

[0099]

[0100] Where K p is the proportionality coefficient, T t is the integration time constant, T D is the derivative time parameter.

[0101] By adopting the subtask scheduling strategy of PID feedback control algorithm, compared with algorithms such as simulated annealing, it has the advantages of real-time performance, low computational cost, fast adjustment speed and strong robustness.

[0102]

[0103]

[0104] The subtask scheduling process based on the PID controller is summarized as Algorithm 3, and the specific execution process is as follows:

[0105] First, line 1 of Algorithm 3 divides the entire SpMV calculation task into X subtasks of roughly the same size according to the non-zero elements.

[0106] Then, lines 2-5 calculate the peak floating-point computing power PeakP of the CPU and GPU. CPU and PeakP GPU , and the initial task division ratio R of the CPU and GPU is obtained CPU and R GPU . Set the time threshold Threshold for achieving load balancing based on experience and actual needs.

[0107] Next, lines 8-9 are based on R CPU and R GPU Divide the first subtask into CPU-side and GPU-side tasks, and obtain the CPU running time T′ after execution. CPU and the running time T′ on the GPU GPU .

[0108] Then, lines 12-17 calculate T′ CPU and T′ GPUThe difference timeDiff is calculated and timeDiff is compared with Threshold. If |timeDiff|>Threshold, it means that the heterogeneous system is in an unbalanced load state according to the current division ratio and the status of the device. At this time, timeDiff is input into the PID controller as the control deviation, and the task division ratio is adjusted according to the output of the PID controller. When timeDiff>Threshold, it is necessary to reduce R CPU And simultaneously increase R GPU ; When timeDiff<-Threshold, then R needs to be increased CPU And simultaneously reduce R GPU If |timeDiff|≤Threshold, it means that the task load balance between the CPU and GPU has been achieved within the error range allowed by the time threshold. At this time, it is approximately considered that in the current state, the next subtask will maintain the load balance by maintaining the division ratio, so the current task division ratio remains unchanged.

[0109] Finally, in the CPU-GPU heterogeneous system, according to the updated and adjusted R CPU With R GPU The next subtask is divided into two parts, the CPU and GPU, and each performs its own computing task. The algorithm line 7 uses a while loop to repeat the above process until all subtasks are completed.

[0110] 3 Experimental design and performance evaluation

[0111] The heterogeneous platform constructed in this experiment consists of a CPU and a GPU. The specific software and hardware environment configuration information in the experiment is shown in Table 3.

[0112] Table 3 System test environment configuration information

[0113]

[0114]

[0115] The large-scale sparse matrices involved in this paper are all from the SuiteSparse matrix collection, which is formerly the University of Florida Sparse Matrix Collection. Since this paper mainly focuses on the performance optimization of large-scale sparse matrix multiplication, the number of non-zero elements in the selected matrices is more than one million.

[0116] Next, three sets of experiments are designed to verify the effectiveness of the proposed scheme, and the computing performance of the benchmark CPU-GPU heterogeneous system and the optimized scheme in this paper are tested.

[0117] 3.1 Subtask segmentation algorithm deviation test

[0118] Algorithm 1 divides the submatrix based on the row size, and Algorithm 2 divides the submatrix based on the non-zero element density. In order to evaluate the deviation of the two algorithms and verify whether they can meet the load balancing requirements, this section selects 10 groups of sparse matrices to divide large-scale sparse matrices into subtasks according to Algorithm 1 and Algorithm 2. First, an evaluation index is formulated to evaluate the two algorithms. The deviation can be defined as

[0119]

[0120] Among them A i is the i-th subtask, NNZ is the number of non-zero elements in the large-scale sparse matrix, K is the number of subtasks, CC i is the proportion of the computational load of the i-th subtask in the entire large-scale sparse matrix.

[0121] The deviation test results of the two segmentation algorithms are summarized in Table 4. The average segmentation deviations of Algorithm 1 and Algorithm 2 in these 10 matrix tasks are 8.4014% and 0.0167%, and the average deviations in all data sets are 12.5810% and 0.0151%. Compared with the row-scale driven segmentation algorithm, the deviation of the non-zero element density driven segmentation algorithm is only 0.0012 times that of the former. This shows that the non-zero element density driven segmentation algorithm performs better in load balancing and can more effectively meet the requirements of load balancing.

[0122] Table 4 Deviation test results of two segmentation algorithms

[0123]

[0124] 3.2 Subtask Scheduling Strategy Effectiveness Test

[0125] The theoretical peak floating-point computing performance of the CPU and GPU in the experimental environment of this paper is calculated to be 14561.28 GFlops and 1689.6 GFlops respectively. Therefore, according to Formulas 5 and 6, it can be calculated that the initial task ratio of the CPU is 0.1040 and the initial task ratio of the GPU is 0.8960. When dividing the subtasks, the non-zero element driven subtask partitioning algorithm is used.

[0126] According to experience, Threshold = 0.01 is selected. The running time of each subtask of the proposed method is shown in Table 5. Since the selection of the initial ratio is determined by the theoretical peak floating-point operation performance, it may be quite different from the performance during actual operation, resulting in a large difference in the running time of the first subtask on the CPU and GPU. During the execution of the following subtasks, the task division ratio changes rapidly. This is because the PID control algorithm is applied when designing the subtask scheduling strategy, and its proportional term and control term can quickly and effectively adjust the ratio.

[0127] Table 5 Execution status after applying the subtask scheduling algorithm

[0128]

[0129] As a control experiment, we chose a simple adjustment scheme as the control group, that is, when T CPU -T GPU >Threshold, let R CPU Minus 0.002, R GPU Add 0.002; when T CPU -T GPU <-Threshold, let R CPU Add 0.002, R GPU The experimental results of the simple adjustment scheme are summarized in Table 6, and the comparison of the two adjustment schemes is shown in Figure 5 ,It can be seen that in the same 11 iterations, although the naive adjustment scheme plays a certain role, the adjustment efficiency is 58.82%, and the processor is still in an unbalanced state; while the proposed scheme achieves load balance after 9 adjustments, showing a higher adjustment efficiency.

[0130] Table 6 Simple adjustment scheme

[0131]

[0132] 3.3 Heterogeneous System Performance Test

[0133] In this section, 20 sparse matrices in the SuiteSparse matrix set are selected to test the SpMV computing performance in the following three environments: (1) CPU-GPU heterogeneous system with GPU computing only; (2) benchmark CPU-GPU heterogeneous system; (3) CPU-GPU heterogeneous system with application task partitioning and scheduling strategy. The above three experimental environments are composed of the software and hardware in Table 3, and the data transmission time on the PCI-e bus is considered. When dividing the large-scale SpMV task into subtasks and dividing the subtasks into CPU and GPU computing tasks, the non-zero element driven subtask partitioning algorithm is used.

[0134] Figure 6 The comparison of the computing throughput of the CPU-GPU heterogeneous system with only GPU computing and the benchmark CPU-GPU heterogeneous system is shown. The average computing throughput of the two is 2.0916GFlop / s and 2.1035GFlop / s respectively, and the speedup ratio of the benchmark CPU-GPU heterogeneous system is only 1.0075. Compared with the CPU-GPU heterogeneous system with only GPU computing, the SpMV computing performance of some matrices in the benchmark CPU-GPU heterogeneous system even decreases.

[0135] Figure 7 The computing performance of the CPU-GPU heterogeneous system before and after the application of task partitioning and scheduling strategies is compared, and the average computing throughput of the two is 2.1035GFlop / s and 3.1540GFlop / s respectively. Compared with the benchmark CPU-GPU heterogeneous system, the average speedup ratio of the proposed method on the SpMV operation on these 20 test matrices reaches 1.4885, and the speedup ratio on the crankseg_2 matrix is ​​even as high as 1.9293.

[0136] exist Figure 8 In the paper, the SpMV computing performance in three experimental environments was compared: a CPU-GPU heterogeneous system with GPU computing only, a benchmark CPU-GPU heterogeneous system, and a CPU-GPU heterogeneous system with application of task partitioning and scheduling strategies. The CPU-GPU heterogeneous system with application of task partitioning and scheduling strategies has a computing throughput improvement of 48.85% compared to the benchmark CPU-GPU heterogeneous system; and a computing throughput improvement of 49.95% compared to the CPU-GPU heterogeneous system with GPU computing only. This shows that through task partitioning and scheduling strategies, the CPU and GPU can collaborate more efficiently, thereby significantly improving the performance of SpMV computing in heterogeneous systems.

[0137] Since the data transfer time on PCI-e is a fixed overhead, the core idea of ​​overlapping computing is to try to hide the task computing cost in the data transfer cost. In this case, the less the additional computing time cost is, the less the total running time is. That is, the higher the data transfer time utilization, the better the system performance is likely to be. The data transfer time utilization is defined as

[0138]

[0139] Where T Trans is the data transmission time, T total For total time

[0140] like Fig. 9As shown. We found that the data transmission time accounted for 88.41%, 89.01%, and 96.86% of the total SpMV calculation time in these three experimental environments, respectively. In the CPU-GPU heterogeneous system with GPU computing only and the benchmark CPU-GPU heterogeneous system, the data transmission time utilization rate is relatively low. This is because the CPU and GPU wait for all data to be transferred from the main memory to the device memory before performing the calculation. For the CPU-GPU heterogeneous computing system that adopts the task division and scheduling strategy, except for the first subtask transmission when the CPU and GPU must be in a waiting state, the subsequent task calculation time can be hidden in the data transmission task process of the next subtask. Therefore, the data transmission time utilization rate in this environment is very high.

[0141] 4 Conclusion

[0142] This paper proposes a SpMV task partitioning and scheduling strategy for CPU-GPU heterogeneous platforms to achieve load balancing between processors and improve PCI-e bandwidth utilization. First, the constructed heterogeneous system is evaluated using the SHOC benchmark suite. By analyzing the impact of PCI-e data transmission cost on the heterogeneous system, an overlapping computing mechanism based on data flow decomposition is proposed; finally, a non-zero element driven subtask partitioning algorithm is designed, and a subtask scheduling strategy is designed based on the PID controller, which dynamically adjusts the computing task partition ratio according to the current state of the system to achieve load balancing. Experimental results show that the task partitioning and scheduling strategy not only effectively achieves load balancing, but also improves PCI-e bandwidth utilization. Compared with the benchmark CPU-GPU heterogeneous system, the computing throughput of the proposed method is increased by 48.85%, significantly improving the overall performance of the heterogeneous system.

[0143] References

[0144] [1] Chen Guoliang, ed. Parallel Computing: Structure, Algorithm, and Programming (Revised Edition) [M]. Higher Education Press, 2003

[0145] [2] Wu Enhua. Technology, status and challenges of graphics processors for general computing[J]. Journal of Software, 2004, 15(10), 1493-1504.

[0146] [3]LNTrefethen and D.Bau,III,Numerical Linear Algebra.Society for Industrial and Applied Mathematics,1997.

[0147] [4]Y.Xia,P.Jiang,G.Agrawal and R.Ramnath,"Scaling Sparse MatrixMultiplication on CPU-GPU Nodes,"2021 IEEE International Parallel andDistributed Processing Symposium(IPDPS),Portland,OR,USA,2021,pp.392-401,doi:10.1109 / IPDPS49936.2021.00047.

[0148] [5]Q.Yuan,W.Pang and Y.Shi,"A Design of Homogeneous Multi-Core SoCwith General-Purpose Floating-Point Processors,"2023 IEEE 17th InternationalConference on Anti-counterfeiting,Security,and Identification(ASID),Xiamen,China,2023,pp.126-130,doi:10.1109 / ASID60355.2023.10425983.

[0149] [6]P.Mpakos,D.Galanopoulos,P.Anastasiadis,N.Papadopoulou,N.Kozirisand G.Goumas,"Feature-based SpMV Performance Analysis on ContemporaryDevices,"2023 IEEE International Parallel and Distributed ProcessingSymposium(IPDPS),St.Petersburg,FL,USA,2023,pp.668-679,doi:10.1109 / IPDPS54959.2023.00072.

[0150] [7]Joonho Kong,Sung Woo Chung,and Kevin Skadron.2012.Recent thermalmanagement techniques for microprocessors.ACM Comput.Surv.44,3,Article 13(June 2012),42 pages.https: / / doi.org / 10.1145 / 2187671.2187675.

[0151] [8]Cheng,Chun-Hung and Ying-Wen Bai.“Dynamic Performance Adjustmentof CPU and GPU in a Gaming Notebook at the Battery Mode.”IEICETrans.Inf.Syst.102-D(2019):1257-1270.

[0152] [9]Bell,Nathan,and Michael Garland."Implementing sparse matrix-vectormultiplication on throughput-oriented processors."Proceedings of theconference on high performance computing networking,storage andanalysis.2009.

[0153]

[10] W.Yang,K.Li,Z.Mo and K.Li,"Performance Optimization UsingPartitioned SpMV on GPUs and Multicore CPUs,"in IEEE Transactions onComputers,vol.64,no.9,pp.2623-2636,1 Sept.2015,doi:10.1109 / TC.2014.2366731.

[0154]

[11] Sparsh Mittal and Jeffrey S.Vetter.2015.A Survey of CPU-GPUHeterogeneous Computing Techniques.ACM Comput.Surv.47,4,Article 69(July2015),35 pages. https: / / doi.org / 10.1145 / 2788396 .

Claims

1. A SpMV task partitioning and scheduling strategy for CPU-GPU heterogeneous systems, characterized by First, divide the SpMV task into subtasks, and then schedule the subtasks, including: 1) In the data flow decomposition stage: the large-scale sparse matrix is ​​divided into several subtasks with the same amount of computational tasks, and then stored in the task pool; 2) In the task division stage: determine the initial division ratio R of subtasks based on the peak floating-point computing performance of each processor CPU and R GPU , and divide the first subtask into CPU-side computing tasks and GPU-side computing tasks according to the ratio; R CP and R GPU They represent the proportion of computing tasks allocated to the CPU and the proportion of computing tasks allocated to the GPU respectively; 3) In the overlapping computing stage: start the parallel computing programs on the CPU and GPU respectively and start to execute the computing tasks; according to the overlapping computing mechanism, while the CPU and GPU parallel computing kernels are executing the computing tasks, start the data transmission for the next subtask to realize overlapping computing; 4) In the proportion update stage: the calculation time of the CPU and GPU is obtained, and the calculation time difference between the two is input to the PID controller as the control deviation; the PID controller outputs the updated CPU and GPU task division ratio according to the control deviation and the time threshold; 5) Divide the next subtask according to the updated division ratio in step 4), and repeat steps 2) to 4) until all subtasks are calculated; Steps 1) to 3) are the task division process, and step 4) is the subtask scheduling process; In step 4), a subtask scheduling algorithm based on a PID controller is used, and the PID controller outputs an updated CPU and GPU task division ratio according to the control deviation and the time threshold; the subtask scheduling process is as follows: In steps 1) to 3), first, the entire large-scale SpMV calculation task is divided into several subtasks of roughly the same size according to non-zero elements; Then, calculate the peak floating-point computing capability PeakP of the CPU and GPU CPU and PeakP GPU , and the initial task division ratio R of the CPU and GPU is obtained CPU and R GPU ; Set the time threshold for achieving load balancing based on experience and actual needs; In step 4), according to R CPU and R GPU Divide the first subtask into CPU-side and GPU-side tasks, and obtain the CPU running time T′ after execution. CPU and the running time T′ on the GPU GPU ; Then, calculate T′ CPU and T′ GPU The difference timeDiff, and compare timeDiff with Threshold; If |timeDiff|>Threshold, it means that according to the current division ratio and the status of the device, the heterogeneous system is in a load imbalance state. At this time, timeDiff is input into the PID controller as the control deviation, and the task division ratio is adjusted according to the output of the PID controller: When timeDiff>Threshold, reduce R CPU And simultaneously increase R GPU ; When timeDiff<-Threshold, increase R CPU And simultaneously reduce R GPU ; If |timeDiff|≤Threshold, it means that the task load balance between the CPU and GPU has been achieved within the error range allowed by the time threshold. At this time, it is approximately considered that in the current state, the next subtask will maintain the load balance by maintaining the division ratio, so the current task division ratio remains unchanged. Finally, in the CPU-GPU heterogeneous system, according to the updated and adjusted R CPU With R GPU To divide the next subtask into two parts, the CPU and GPU, and perform their respective computing tasks; Repeat the above process until all subtasks are completed.

2. The SpMV task partitioning and scheduling strategy for CPU-GPU heterogeneous systems according to claim 1 is characterized in that In step 1), the large-scale sparse matrix is ​​divided into several subtasks with the same amount of computational tasks by using a subtask partitioning algorithm driven by non-zero element density; In step 2), the subtask splitting algorithm driven by non-zero element density is still used when dividing the subtasks, so as to match the computing tasks assigned to the CPU and GPU ends with the computing capabilities of the CPU and GPU; the subtask splitting algorithm driven by non-zero element density in step 1) and step 2) is the same.

3. The SpMV task partitioning and scheduling strategy for CPU-GPU heterogeneous systems according to claim 2 is characterized by: The subtask partitioning algorithm driven by the non-zero element density in step 1) and step 2) uses the number of non-zero elements as the sub-matrix partitioning criterion; Assume that the sparse matrix A is partitioned into K row vector blocks A1, A2, ..., A K ,The number of non-zero elements of each row vector block matches the computing power of each processor to achieve the purpose of load balancing of each processor; The segmentation basis of the segmentation algorithm is expressed as Among them, A k represents the kth subtask, NNZ represents the number of non-zero elements in the sparse matrix, K is the number of subtasks, CC k Indicates the proportion of the computational load of the kth subtask in the entire sparse matrix; The process of the subtask segmentation algorithm is: First, initialize K empty row vector blocks A1, A2, ..., A k , traverse each processor and allocate the non-zero element load NNZ to be processed according to the proportion of its computing power to the total computing power carry ; In the inner loop, try to add the row vector to the row vector block of the current processor until the number of non-zero elements in the attempted allocation is NNZ try Exceed or reach the processor load; Each time you add a row vector, update the number of non-zero elements you are trying to allocate and move the row pointer to the next row; After the inner loop ends, the next processor is processed; Finally, K row vector blocks A1, A2, ..., A are returned. k .

4. The SpMV task partitioning and scheduling strategy for CPU-GPU heterogeneous systems according to claim 1, characterized in that The overlapping calculation mechanism based on data stream decomposition in step 3) is: Before the data of the first subtask is transferred from the system main memory to the GPU memory, the computing resources on the GPU are idle; As the data transmission of the first subtask is completed, the computing cores on the CPU and GPU begin to execute the computing task, and the data stream transmission of the next subtask in the PCI-e bus also begins; That is, when the calculation of the i-th subtask is completed, the calculation of the i+1-th subtask is immediately executed, and the PCI-e transmits the i+2-th subtask at the same time; Except before the data transfer of the first subtask is completed and during the numerical calculation of the last subtask, the computing tasks and data transfer on the CPU and GPU are performed simultaneously, thus masking the data transfer cost through this partial or complete overlap.

5. The SpMV task partitioning and scheduling strategy for CPU-GPU heterogeneous systems according to claim 1 is characterized by: In step 4), the subtask scheduling algorithm design process based on PID controller: First, the task allocation optimization problem is abstracted into a planning problem Assume that the total amount of numerical calculation tasks is Q, the amount of data to be transmitted through PCI-e is D, the bandwidth of the PCI-e bus is W, and the computing performance of the CPU is P. CPU , the computing performance of GPU is P GPU , then the running time of Q on CPU or GPU is defined as and When T CPU >T GPU When using CPU to perform calculations alone, it is more efficient; When T CPU <T GPU When , the CPU and GPU participate in collaborative computing; The ratio of task division is determined by the computing performance of the CPU and GPU, so the ratio of task allocation on the CPU side and the GPU side is and At this time, suppose that the CPU computing time of the part of a computing task assigned to the CPU side is T′ CPU , the GPU computing time allocated to the GPU side is T′ GPU At this time, the estimated time consumption of the computing task in the CPU-GPU heterogeneous system is T=max{T′ CPU ,T′ GPU } When the ratio of task division is unreasonable, it will lead to T′ GPU and T′ GPU If the difference is too large, the CPU and GPU are still calculating while the other has completed the calculation, and will remain in a blocked state. Therefore, the task allocation optimization problem is abstracted into the following planning problem: For the initial allocation ratio R CPU and R GPU , determined by the peak floating-point computing capabilities of the CPU and GPU, which are calculated as PeakP CPU =N_Core CPU ×F CPU ×IPC GPU and PeakP GPU =N_Core GPU ×F GPU ×IPC GPU The PID controller then uses a feedback mechanism to continuously adjust the Plan your goals to adjust the task division ratio and ultimately achieve load balancing between the CPU and GPU. The PID controller dynamically adjusts the task division ratio according to the time difference between CPU and GPU execution tasks; The PID controller adjusts the system output through three control items: proportional, integral and derivative. The control deviation is determined by the difference between the expected value r(t) and the actual output value c(t), expressed as error(t) = r(t)-c(t). In the dynamic task partitioning scenario of CPU-GPU heterogeneous systems, the ideal state is that the CPU and GPU processing time are the same, that is, T CPU -T GPU =0; therefore, the expected value r(t) is set to 0, and the actual output value is the difference between the CPU and GPU running time of each subtask, that is, c(t) = T CPU (t)-T GPU (t); Then the control deviation defined in the above formula is calculated as error(t)=0-[T CPU (t)-T GPU (t)]=T GPU (t)-T CPU (t) The ideal PID control law is expressed as The parameter t represents time; The PID controller dynamically adjusts the division ratio of the next subtask according to the CPU and GPU running time of the previous subtask. The above formula is discretized to obtain Where K p is the proportionality coefficient, T t is the integration time constant, T D is the derivative time parameter.

Citation Information

Cited By

  • Heterogeneous cluster environment-oriented model assembly line division and deployment method and system

    CN120123103A

  • Intelligent control method and system for frequency modulation of CPU based on big data

    CN121349590A