A method and system for automatically allocating computing resources for three-level parallel middleware

Through the combination of program instrumentation and message middleware, computing tasks are predicted and allocated, which solves the problem of limited computing speed in heterogeneous systems, realizes efficient collaborative computing of CPU and GPU, and improves the computing rate.

CN114356550BActive Publication Date: 2024-09-24WUHAN UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111503888.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-10
Publication Date
2024-09-24
Estimated Expiration
2041-12-10

AI Technical Summary

Technical Problem

In heterogeneous systems, existing technologies are difficult to effectively allocate computing tasks, resulting in limited computing speed and inability to fully utilize the parallel processing capabilities of CPUs and GPUs.

Method used

Use program instrumentation method to predict program running time, locate loop statements and branch statements, obtain the number of loops and branches, instrument MPI communication functions, predict CPU and GPU running time, and allocate tasks to CPU and GPU through message middleware , realize resource scheduling and load balancing, and use distributed technology and computer structure to guide the automatic allocation of computing resources.

Benefits of technology

It improves the computing speed of CPU and GPU collaborative computing in heterogeneous systems, achieves efficient resource allocation and load balancing, and increases the computing rate.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114356550B
    Figure CN114356550B
Patent Text Reader

Abstract

The present invention discloses a method and system for automatically allocating computing resources for three-level parallel middleware. With distributed technology, middleware and computer organization structure as guiding theories, the present invention proposes a model for automatically allocating computing resources for three-level parallel middleware for tasks of large-scale computing in a cluster environment. The model can analyze computing tasks performed in a cluster, firstly allocate tasks to each computing unit in the form of a queue through a message middleware, and then allocate tasks to the CPU and GPU again within the computing unit. In addition to being applicable to clusters, the present invention can also be applied to a single computer when the task scale is not large. The computing tasks on a single machine are reasonably allocated to the CPU and GPU so that the two can perform calculations at the same time, thereby improving the computing rate. The present invention can be used to further improve the computing speed in the context of large computing tasks in cluster mode.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of GPU computing, cluster computing, multithreading, resource scheduling and middleware in computer science, and relates to a method and system for automatically allocating computing resources, and in particular to a method and system for reasonably allocating computing tasks in parallel computing of heterogeneous systems, which can effectively improve the computing speed of parallel computing of programs in heterogeneous systems. Background Art

[0002] GPU computing is the use of a GPU (graphics processing unit) as a co-processor to accelerate the CPU to speed up scientific, analytical, engineering, consumer and enterprise applications. The GPU accelerates applications running on the CPU by offloading some of the computationally intensive and time-consuming parts of the code. The rest of the application still runs on the CPU. From the user's perspective, the application runs faster because it uses the massively parallel processing power of the GPU to improve performance. This is called "heterogeneous" or "hybrid" computing.

[0003] While CPUs consist of 4 to 8 CPU cores, GPUs consist of hundreds of smaller cores. They work together to process data in an application. This massively parallel architecture provides high computing performance for GPUs. There are many GPU-accelerated applications that provide an easy way to access high-performance computing (HPC).

[0004] Resource scheduling is the allocation of resources required for work. Here, it mainly refers to computing resources, such as threads, processes, data streams or hardware resources. In this invention, it refers to the allocation of tasks in a cluster and the allocation of computing tasks on a single machine to the CPU and GPU. Summary of the invention

[0005] The present invention aims to provide a method and system for automatically allocating computing resources for three-level parallel middleware, so as to improve the computing speed.

[0006] The technical solution adopted by the method of the present invention is: a method for automatically allocating computing resources for three-level parallel middleware, comprising the following steps:

[0007] Step 1: Use the program instrumentation method to predict the program's running time. The specific implementation includes the following sub-steps:

[0008] Step 1.1: Locate loop statements and branch statements, insert stubs in the loop structure and branch statements, and obtain the number of loops and branches;

[0009] Step 1.2: Locate the MPI communication function, insert the MPI communication function, and obtain the communication data volume;

[0010] Step 1.3: Take the new program after the original program is instrumented as the prediction object. After the instrumentation is completed, input and run the newly generated program to obtain the output values ​​of CPU running time, GPU running time, and program overall running time, and use them as input to calculate again. The cycle is executed several times until the expected value is reached, that is, the output value is stable and the error is less than 0.001;

[0011] Step 2: Divide the computing tasks and reasonably allocate them to the CPU and GPU of the task execution unit for computing to achieve resource scheduling and load balancing.

[0012] The technical solution adopted by the system of the present invention is: a computing resource automatic allocation system for three-level parallel middleware, including the following modules:

[0013] Module 1 is used to predict the running time of the program by using the program instrumentation method. The specific implementation includes the following sub-modules:

[0014] Module 1.1 is used to locate loop statements and branch statements, insert stubs in loop structures and branch statements, and obtain the number of loops and branches;

[0015] Module 1.2 is used to locate the MPI communication function, insert the MPI communication function, and obtain the communication data volume;

[0016] Module 1.3 is used to use the new program after the original program is plugged in as the prediction object. After the plugging is completed, the newly generated program is input and run to obtain the output values ​​of CPU running time, GPU running time, and overall program running time, and the output values ​​are used as input for calculation again. The calculation is repeated several times until the expected value is reached.

[0017] Module 2 is used to divide the computing tasks and reasonably allocate the computing tasks to the CPU and GPU of the task execution unit for computing, so as to realize resource scheduling and load balancing.

[0018] The computing resource automatic allocation system of the present invention mainly comprises a task allocation module and a computing resource scheduling module. The task allocation module allocates tasks to each task computing unit in the form of a queue through the message middleware when the host communicates with the cluster. The computing resource scheduling module reasonably allocates the computing tasks on a single machine to the CPU and GPU, so that the two can perform calculations at the same time, thereby improving the computing rate.

[0019] The computing resource scheduling module of the present invention allocates tasks to the CPU and GPU on a single task execution unit respectively based on the principle that the total time is the shortest when the CPU and GPU are executed simultaneously.

[0020] The main content of the automatic computing resource allocation system of the present invention also includes the prediction of the target program running time, which can be predicted by program instrumentation or a method based on skeleton program according to the specific task form. At the same time, when the program instrumentation method is used, the fitting model should be selected according to the specific situation.

[0021] The present invention takes distributed technology, middleware and computer organization structure as guiding theories, and proposes a method for automatically allocating computing resources for three-level parallel middleware for tasks of large-scale computing in a cluster environment. The method can analyze the computing tasks performed in the cluster, firstly allocate the tasks to each computing unit in the form of a queue through the message middleware, and then allocate the tasks to the CPU and GPU again in the computing unit. In addition to being applied to clusters, the present invention can also be applied to a single computer when the task scale is not large. The computing tasks on a single machine are reasonably allocated to the CPU and GPU, so that the two can perform calculations at the same time, thereby improving the computing rate. The present invention can be used to further improve the computing speed in the context of large computing tasks in cluster mode. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 A flowchart of program running time prediction according to an embodiment of the present invention;

[0023] Figure 2 A schematic diagram of a resource scheduling model for middleware on a single node according to an embodiment of the present invention;

[0024] Figure 3 The overall flow chart of CPU\GPU computing of fine-grained parallel computing in an embodiment of the present invention;

[0025] Figure 4 This is a CPU\GPU overall architecture diagram for coarse-grained parallel computing in an embodiment of the present invention. DETAILED DESCRIPTION

[0026] In order to facilitate ordinary technicians in the field to understand and implement the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the implementation examples described herein are only used to illustrate and explain the present invention, and are not used to limit the present invention.

[0027] The present invention provides an automatic computing resource allocation method for three-level parallel middleware, which can allocate computing tasks to be run on a cluster to each task execution unit, and reasonably allocate computing resources again on a single task execution unit, so that the CPU and GPU can execute tasks together, thereby achieving the purpose of improving computing speed.

[0028] The following steps are involved:

[0029] Step 1: Use program instrumentation method to predict the program running time;

[0030] Please see Figure 1 , this embodiment first predicts the running time of the program. The present invention uses the program instrumentation method to predict the time. Since the platform used in this study is relatively stable, only the problem of predicting the running time of a parallel program on a certain computing platform under a certain input is considered, that is, "the running time of the program when the input is a is t1, predict the running time of the program under other inputs".

[0031] Since loop statements are the most time-consuming structures in parallel computing, the more times they are repeated, the longer they take, so stubbing is first done in loop structures. Since the calculation time of different branches in branch statements may vary greatly, branch statements are also one of the objects to be stubbing. For MPI communication functions, when there are relatively few loops and many communications, the communication between programs is likely to take longer than the calculation time, so stubbing is also done for MPI communication functions. The new program after stubbing the original program is used as the prediction object. After stubbing is completed, the newly generated program is run with a large amount of input to obtain the output values ​​of all features as the input of the model. Select a suitable prediction model for fitting, evaluate the impact of each feature value on time, make reasonable choices, and prevent overfitting until the final prediction model is obtained.

[0032] In this middleware, the parallel tasks on the cluster usually have the characteristics of large data volume and many loops, so the number of program loops will be used as the main input. Since the running time of some programs is related to specific parameters in the program, such as the value of a parameter or the change of its symbol, the characteristic value can be added, deleted or modified according to the specific project.

[0033] After obtaining the final prediction model, the predicted value of the current program running time can be obtained by changing the characteristic parameters. If the original program has the characteristic that the program logic remains unchanged under a small amount of data, the prediction based on the skeleton program can also be used. In this way, the running time of the original program can be estimated by running the skeleton program, but it is more targeted and less universal.

[0034] After the program running time is predicted, the next step is to automatically allocate computing resources in the middleware. Table 1 shows some parameters needed for the computing resource allocation method.

[0035] Table 1

[0036]

[0037] In a cluster environment, tasks to be processed (mainly computing tasks) are sent from the outside to the message middleware, which then distributes and monitors each task execution unit. The results of the task execution unit after completion will be stored in the backend. The middleware for automatic three-level parallel resource scheduling works in each task execution unit.

[0038] Step 2: Divide the computing tasks and reasonably allocate them to the CPU and GPU of the task execution unit for computing to achieve resource scheduling and load balancing.

[0039] To improve the computing speed in a heterogeneous system with CPU\GPU collaborative computing, this embodiment analyzes and calculates various influencing factors, uses the idea of ​​block partitioning, reasonably allocates computing tasks to the CPU and GPU, and makes the computing time of the two basically the same, in order to achieve the best computing effect.

[0040] The specific idea is to treat hardware performance, threads and other complex overheads and factors that change with environmental changes as a whole with the data to be processed, and not to process them separately. Then, using the idea of ​​sharding, the overall data is divided into blocks, and the calculation time of a data block is used as the benchmark for measuring hardware performance.

[0041] The results required are the number of tasks assigned to the CPU, the number of tasks assigned to the GPU, and the number of threads created by the CPU. At the same time, a prediction of the target program's running time is also required.

[0042] Task allocation requires the calculation of three undetermined variables, namely the number of blocks allocated to the CPU, the number of blocks allocated to the GPU, and the number of threads created on the CPU. The ultimate goal is to use this task allocation strategy to shorten the total execution time as much as possible. Define the number of blocks allocated to the CPU as b1, the number of blocks allocated to the GPU as b2, and the number of threads created on the CPU as Thread.

[0043] Please see Figure 2 In this embodiment, the total computing tasks are divided through a distributed framework, and the total number of tasks N is used as input and connected through a message middleware; the message middleware distributes the total number of tasks N to each task execution unit respectively, and monitors the operation status of each task execution unit; when the calculation of the task execution unit is completed, the result is stored.

[0044] The message middleware of this embodiment takes the number of tasks of a task execution unit as input, calculates the number of blocks allocated to the CPU, the number of blocks allocated to the GPU, and the number of threads created on the CPU, and allocates tasks according to the principle of minimizing the total calculation time when the CPU and GPU complete the tasks at the same time through a resource scheduling model, thereby realizing simultaneous calculation of the two.

[0045] The resource scheduling model of this embodiment is based on the attached Figure 4 For the incoming new data, we first check in the database whether the Worker to be called has the relevant parameters that have been configured (the number of CPU blocks, the number of GPU blocks and the number of threads created on the CPU mentioned above). If the relevant parameters do not exist, we send the task and let the Worker call the plug-in program for fitting, and get the relevant results (the information obtained by the plug-in program is enough to analyze and fit) to obtain these parameters (the same as the above relevant parameters). Then, according to these parameters, they are sent to the task queue together with the data to wait for the slave to pull the task to run. The innovation of this model is to use a mathematical model to pre-allocate the number of CPUs, GPUs and threads in advance, so as to achieve the purpose of efficient use of CPU and GPU at the same time.

[0046] Please see Figure 3 The creation of the thread of this embodiment includes the following sub-steps:

[0047] (1) Create a main process to run the sequential execution part of the program.

[0048] (2) Enter the program to parallelize some areas and divide the tasks.

[0049] (3) Allocate threads to the divided tasks according to the threads predicted by the instrumentation program.

[0050] (4) Create one more thread than the pre-allocated thread to control the CUDA kernel.

[0051] (5) Two-level programs are executed in parallel.

[0052] (6) Wait for all threads to complete their computational tasks.

[0053] (7) Once completed, run the sequential execution portion of the program.

[0054] In this embodiment, the multi-core CPU creates an appropriate number of threads, one of which is responsible for GPU scheduling, while the other threads execute the parallel tasks assigned to the CPU. At the same time, the GPU executes the tasks assigned to it. A simplified mapping example is provided below. The specific implementation process of "mapping" is as follows:

[0055] (1) Use #program parallel to mark the code blocks that can be parallelized after analysis.

[0056] (2) Create threads on the CPU according to the number of threads determined in the analysis phase, and create one more thread than the determined number of threads to control the GPU to execute the task.

[0057] (3)CPU threads execute assigned tasks in parallel.

[0058] (4.1) Under the control of the CPU thread, the CUDA kernel performs parallel computing on the tasks.

[0059] (4.2) After clarifying the tasks that need to be performed on the GPU, allocate GPU cores and assign threads to the corresponding loops.

[0060] (4.3) Determine the dimensions and size of the grid and block.

[0061] (4.4) CUDA kernels run computing tasks.

[0062] The automatic computing resource allocation system for three-level parallel middleware of this embodiment is to improve the computing rate of CPU\GPU collaborative computing in heterogeneous systems. The present invention is further explained below through specific embodiments.

[0063] The overall task N in the cluster is distributed to each task execution unit through the message middleware. Assuming there are i task execution units, there are n1+n2+...+n i = N. For each task execution unit to be executed, computing resources are allocated again. Taking the i-th task execution unit as an example, the number of task blocks it needs to execute is n i . For n i To allocate computing resources, a CPU thread is allocated to each task block, a thread is reserved to control the GPU, and the remaining task blocks are calculated by the GPU. As shown in Table 1, in task execution unit i, the number of task blocks allocated to the CPU is n. ic , the number of blocks assigned to the GPU is n ig The number of threads generated by the CPU is Thread.

[0064] The optimal computing time can be obtained when the total CPU execution time and the total GPU execution time are the same or closest, and the number of CPU threads allocated directly affects the CPU memory access time and computing time. Therefore, there is an optimal division:

[0065]

[0066] Since the computing power of GPU is much higher than that of CPU, when n ic 、n ig When a non-integer solution occurs, the extra tasks are assigned to the GPU. For the number of threads created by the CPU, experiments have found that when the number of threads exceeds the number of CPU cores, additional overhead will be generated and the calculation time will increase. Therefore, the number of threads is less than the number of CPU cores. In addition, threads are also related to the number of blocks n allocated to the CPU. ic Therefore, the value of Thread is:

[0067]

[0068] The present invention can be applied to a cluster or a single machine to improve the computing speed through resource scheduling. By combining the parallelization framework with the cluster, each task execution unit can be run separately.

[0069] It should be understood that parts not elaborated in detail in this specification belong to the prior art.

[0070] It should be understood that the above description of the preferred embodiment is relatively detailed and cannot be regarded as limiting the scope of patent protection of the present invention. Under the enlightenment of the present invention, ordinary technicians in this field can also make substitutions or modifications without departing from the scope of protection of the claims of the present invention, which all fall within the scope of protection of the present invention. The scope of protection requested for the present invention shall be based on the attached claims.

Claims

1. A method for automatically allocating computing resources for three-level parallel middleware, characterized in that: The following steps are involved: Step 1: Use the program instrumentation method to predict the program's running time. The specific implementation includes the following sub-steps: Step 1.1: Locate loop statements and branch statements, insert stubs in the loop structure and the branch statements, and obtain the number of loop statements and the number of branch statements; Step 1.2: Locate the MPI communication function, insert the MPI communication function, and obtain the MPI communication data volume; Step 1.3: Take the new program after the original program is instrumented as the prediction object. After the instrumentation is completed, input and run the newly generated program to obtain the output values ​​of CPU running time, GPU running time and the total running time of the program, and use them as input to calculate again. The cycle is executed several times until the expected value is reached, that is, the output value is stable and the error is less than the preset value; Step 2: Divide the computing tasks and reasonably allocate them to the CPU and GPU of the task execution unit for computing to achieve resource scheduling and load balancing.

2. The method for automatically allocating computing resources for three-level parallel middleware according to claim 1, characterized in that: The expected value described in step 1.3 is a fit to each output value based on the impact of the output value of each feature on time.

3. The method for automatically allocating computing resources for three-level parallel middleware according to claim 1, characterized in that: In step 2, the total computing tasks are divided through a distributed framework, and the total number of tasks N is taken as input and connected through a message middleware; the message middleware distributes the total number of tasks N to each task execution unit respectively, and monitors the operation status of each task execution unit; when the calculation of the task execution unit is completed, the result is stored.

4. The method for automatically allocating computing resources for three-level parallel middleware according to claim 3, characterized in that: The message middleware takes the number of tasks of a task execution unit as input, calculates the number of blocks allocated to the CPU, the number of blocks allocated to the GPU, and the number of threads created on the CPU, and allocates tasks according to the principle of minimizing the total calculation time when the CPU and GPU complete the tasks at the same time through a resource scheduling model, so as to realize simultaneous calculation of the two. The resource scheduling model, for the input of new data, first determines in the database whether the Worker to be called has configured relevant parameters, including the number of CPU blocks, the number of GPU blocks, and the number of threads created on the CPU; if the relevant parameters do not exist, the task is sent to let the Worker call the plug-in program for fitting, and obtain these parameters from the relevant results; then, according to these parameters, they are sent to the task queue together with the data to wait for the slave to pull the task to run.

5. The method for automatically allocating computing resources for three-level parallel middleware according to any one of claims 1 to 4, characterized in that: The CPU is responsible for processing the creation and allocation of a portion of data blocks and threads, and the GPU is responsible for processing the remaining data blocks.

6. The method for automatically allocating computing resources for three-level parallel middleware according to claim 5, characterized in that: The creation of the thread is specifically implemented by the following steps: (1) Create the main thread of the program and first complete the sequential part of the program in the main thread; (2) For parallelizable loops, the main task of the division is to determine how many loops are executed by the CPU, that is, how many CPU threads are needed to execute them, and secondly, to determine the number of tasks executed by the GPU; (3) Create threads to execute the assigned tasks. Some threads execute computing tasks, and some threads control the GPU to execute the tasks assigned to the GPU. (4) Wait for all tasks to be completed and merge the task results; (5) Continue executing the rest of the code.

7. A computing resource automatic allocation system for three-level parallel middleware, characterized in that: Includes the following modules: Module 1 is used to predict the running time of the program by using the program instrumentation method. The specific implementation includes the following sub-modules: Module 1.1 is used to locate loop statements and branch statements, insert stubs in loop structures and branch statements, and obtain the number of loops and branches; Module 1.2 is used to locate the MPI communication function, insert the MPI communication function, and obtain the communication data volume; Module 1.3 is used to use the new program after the original program is instrumented as the prediction object. After the instrumentation is completed, the newly generated program is input and run to obtain the output values ​​of CPU running time, GPU running time, and program overall running time, and the output values ​​are used as input for calculation again. The calculation is repeated several times until the expected value is reached, that is, the output value is stable and the error is less than 0.001; Module 2 is used to divide the computing tasks and reasonably allocate the computing tasks to the CPU and GPU of the task execution unit for computing, so as to realize resource scheduling and load balancing.